diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 54bcad374..0b9da27b2 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,55 +1,54 @@ name: Build Project on: - push: - branches: - - master + push: + branches: + - master jobs: - build: - runs-on: ubuntu-latest - steps: - - name: Pull Repo - uses: actions/checkout@v2 - with: - fetch-depth: 0 - ref: ${{ github.event.pull_request.head.ref }} - node-version: '16' - - name: Run Script - shell: bash - run: | - set -x - - npm ci # install packages - - NODE_OUTPUT=`node scripts/aggregate-json.mjs 2>&1` - - if [[ ! $NODE_OUTPUT ]];then - exit 0 - fi - - NODE_OUTPUT="
${NODE_OUTPUT//$'\n'/
}
" - PR_NUMBER=$(echo $GITHUB_REF | awk 'BEGIN { FS = "/" } ; { print $3 }') - - if [[ ! $PR_NUMBER ]]; then - exit 0 - fi - - jq -n --arg body "$(echo $NODE_OUTPUT)" '{ body: $body }' |\ - curl -sL -X POST -d @- \ - -H "Content-Type: application/json" \ - -H "Accept: application/vnd.github.v3+json" \ - -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ - "https://github.com/gitapi/repos/${{ github.repository }}/commits/$GITHUB_SHA/comments" - - - name: Build Project - run: | - CI=false npm run build - - - - name: Publish - uses: JamesIves/github-pages-deploy-action@3.7.1 - with: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - BRANCH: gh-pages # The branch the action should deploy to. - FOLDER: build - CLEAN: true + build: + runs-on: ubuntu-latest + steps: + - name: Pull Repo + uses: actions/checkout@v2 + with: + fetch-depth: 0 + ref: ${{ github.event.pull_request.head.ref }} + node-version: '20' + - name: Run Script + shell: bash + run: | + set -x + + npm ci # install packages + + NODE_OUTPUT=`node scripts/aggregate-json.mjs 2>&1` + + if [[ ! $NODE_OUTPUT ]];then + exit 0 + fi + + NODE_OUTPUT="
${NODE_OUTPUT//$'\n'/
}
" + PR_NUMBER=$(echo $GITHUB_REF | awk 'BEGIN { FS = "/" } ; { print $3 }') + + if [[ ! $PR_NUMBER ]]; then + exit 0 + fi + + jq -n --arg body "$(echo $NODE_OUTPUT)" '{ body: $body }' |\ + curl -sL -X POST -d @- \ + -H "Content-Type: application/json" \ + -H "Accept: application/vnd.github.v3+json" \ + -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ + "https://github.com/gitapi/repos/${{ github.repository }}/commits/$GITHUB_SHA/comments" + + - name: Build Project + run: | + CI=false npm run build + + - name: Publish + uses: JamesIves/github-pages-deploy-action@3.7.1 + with: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + BRANCH: gh-pages # The branch the action should deploy to. + FOLDER: build + CLEAN: true diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index f3a80fb33..89ca44c8c 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,35 +1,35 @@ name: Test on: - pull_request: - branches: - - master + pull_request: + branches: + - master jobs: - test: - runs-on: ubuntu-latest - strategy: - matrix: - node-version: [16, 18] - steps: - - name: Check out source code - uses: actions/checkout@v2 - - - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v1 - with: - node-version: ${{ matrix.node-version }} - - - name: Use cache - uses: actions/cache@v2 - with: - path: | - node_modules - */*/node_modules - key: ${{ runner.os }}-${{ hashFiles('**/package-lock.json') }} - - - name: Install dependencies - run: npm ci - - - name: Run tests - run: npm test + test: + runs-on: ubuntu-latest + strategy: + matrix: + node-version: [18, 20] + steps: + - name: Check out source code + uses: actions/checkout@v2 + + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v1 + with: + node-version: ${{ matrix.node-version }} + + - name: Use cache + uses: actions/cache@v2 + with: + path: | + node_modules + */*/node_modules + key: ${{ runner.os }}-${{ hashFiles('**/package-lock.json') }} + + - name: Install dependencies + run: npm ci + + - name: Run tests + run: npm test diff --git a/.nvmrc b/.nvmrc index 860cc5000..c12134be3 100644 --- a/.nvmrc +++ b/.nvmrc @@ -1 +1 @@ -v18.17.1 +v20.15.0 diff --git a/package-lock.json b/package-lock.json index f060dda89..661dab3e2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -17,7 +17,6 @@ "react-scripts": "^5.0.1", "react-search-input": "^0.11.3", "tachyons": "^4.12.0", - "uuid": "^9.0.1", "webfontloader": "^1.6.28" }, "devDependencies": { @@ -25,7 +24,7 @@ "@fullhuman/postcss-purgecss": "^6.0.0", "@types/jest": "^29.5.12", "@types/leaflet": "^1.9.12", - "@types/node": "^20.13.0", + "@types/node": "^20.14.7", "@types/react": "^18.3.3", "@types/react-dom": "^18.3.0", "@types/react-lazyload": "^3.2.3", @@ -33,11 +32,11 @@ "gh-pages": "^6.1.1", "husky": "^9.0.11", "jsonlint": "^1.6.3", - "lint-staged": "^15.2.5", + "lint-staged": "^15.2.7", "node-fetch": "^3.3.2", "npm-run-all": "^4.1.5", - "prettier": "^3.3.0", - "sass": "^1.77.4", + "prettier": "^3.3.2", + "sass": "^1.77.6", "typescript": "^4.9.5" } }, @@ -3884,9 +3883,9 @@ "integrity": "sha512-YATxVxgRqNH6nHEIsvg6k2Boc1JHI9ZbH5iWFFv/MTkchz3b1ieGDa5T0a9RznNdI0KhVbdbWSN+KWWrQZRxTw==" }, "node_modules/@types/node": { - "version": "20.13.0", - "resolved": "https://registry.npmjs.org/@types/node/-/node-20.13.0.tgz", - "integrity": "sha512-FM6AOb3khNkNIXPnHFDYaHerSv8uN22C91z098AnGccVu+Pcdhi+pNUFDi0iLmPIsVE0JBD0KVS7mzUYt4nRzQ==", + "version": "20.14.7", + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.14.7.tgz", + "integrity": "sha512-uTr2m2IbJJucF3KUxgnGOZvYbN0QgkGyWxG6973HCpMYFy2KfcgYuIwkJQMQkt1VbBMlvWRbpshFTLxnxCZjKQ==", "dependencies": { "undici-types": "~5.26.4" } @@ -11724,9 +11723,9 @@ "integrity": "sha512-7ylylesZQ/PV29jhEDl3Ufjo6ZX7gCqJr5F7PKrqc93v7fzSymt1BpwEU8nAUXs8qzzvqhbjhK5QZg6Mt/HkBg==" }, "node_modules/lint-staged": { - "version": "15.2.5", - "resolved": "https://registry.npmjs.org/lint-staged/-/lint-staged-15.2.5.tgz", - "integrity": "sha512-j+DfX7W9YUvdzEZl3Rk47FhDF6xwDBV5wwsCPw6BwWZVPYJemusQmvb9bRsW23Sqsaa+vRloAWogbK4BUuU2zA==", + "version": "15.2.7", + "resolved": "https://registry.npmjs.org/lint-staged/-/lint-staged-15.2.7.tgz", + "integrity": "sha512-+FdVbbCZ+yoh7E/RosSdqKJyUM2OEjTciH0TFNkawKgvFp1zbGlEC39RADg+xKBG1R4mhoH2j85myBQZ5wR+lw==", "dev": true, "dependencies": { "chalk": "~5.3.0", @@ -14517,9 +14516,9 @@ } }, "node_modules/prettier": { - "version": "3.3.0", - "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.3.0.tgz", - "integrity": "sha512-J9odKxERhCQ10OC2yb93583f6UnYutOeiV5i0zEDS7UGTdUt0u+y8erxl3lBKvwo/JHyyoEdXjwp4dke9oyZ/g==", + "version": "3.3.2", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.3.2.tgz", + "integrity": "sha512-rAVeHYMcv8ATV5d508CFdn+8/pHPpXeIid1DdrPwXnaAdH7cqjVbpJaT5eq4yRAFU/lsbwYwSF/n5iNrdJHPQA==", "dev": true, "bin": { "prettier": "bin/prettier.cjs" @@ -15710,9 +15709,9 @@ "integrity": "sha512-ZRwKbh/eQ6w9vmTjkuG0Ioi3HBwPFce0O+v//ve+aOq1oeCy7jMV2qzzAlpsNuqpqCBjjriM1lbtZbF/Q8jVyA==" }, "node_modules/sass": { - "version": "1.77.4", - "resolved": "https://registry.npmjs.org/sass/-/sass-1.77.4.tgz", - "integrity": "sha512-vcF3Ckow6g939GMA4PeU7b2K/9FALXk2KF9J87txdHzXbUF9XRQRwSxcAs/fGaTnJeBFd7UoV22j3lzMLdM0Pw==", + "version": "1.77.6", + "resolved": "https://registry.npmjs.org/sass/-/sass-1.77.6.tgz", + "integrity": "sha512-ByXE1oLD79GVq9Ht1PeHWCPMPB8XHpBuz1r85oByKHjZY6qV6rWnQovQzXJXuQ/XyE1Oj3iPk3lo28uzaRA2/Q==", "devOptional": true, "dependencies": { "chokidar": ">=3.0.0 <4.0.0", @@ -17631,18 +17630,6 @@ "node": ">= 0.4.0" } }, - "node_modules/uuid": { - "version": "9.0.1", - "resolved": "https://registry.npmjs.org/uuid/-/uuid-9.0.1.tgz", - "integrity": "sha512-b+1eJOlsR9K8HJpow9Ok3fiWOWSIcIzXodvv0rQjVoOVNpWMpxf1wZNpt4y9h10odCNrqnYp1OBzRktckBe3sA==", - "funding": [ - "https://github.com/sponsors/broofa", - "https://github.com/sponsors/ctavan" - ], - "bin": { - "uuid": "dist/bin/uuid" - } - }, "node_modules/v8-compile-cache": { "version": "2.3.0", "resolved": "https://registry.npmjs.org/v8-compile-cache/-/v8-compile-cache-2.3.0.tgz", @@ -21591,9 +21578,9 @@ "integrity": "sha512-YATxVxgRqNH6nHEIsvg6k2Boc1JHI9ZbH5iWFFv/MTkchz3b1ieGDa5T0a9RznNdI0KhVbdbWSN+KWWrQZRxTw==" }, "@types/node": { - "version": "20.13.0", - "resolved": "https://registry.npmjs.org/@types/node/-/node-20.13.0.tgz", - "integrity": "sha512-FM6AOb3khNkNIXPnHFDYaHerSv8uN22C91z098AnGccVu+Pcdhi+pNUFDi0iLmPIsVE0JBD0KVS7mzUYt4nRzQ==", + "version": "20.14.7", + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.14.7.tgz", + "integrity": "sha512-uTr2m2IbJJucF3KUxgnGOZvYbN0QgkGyWxG6973HCpMYFy2KfcgYuIwkJQMQkt1VbBMlvWRbpshFTLxnxCZjKQ==", "requires": { "undici-types": "~5.26.4" } @@ -27215,9 +27202,9 @@ "integrity": "sha512-7ylylesZQ/PV29jhEDl3Ufjo6ZX7gCqJr5F7PKrqc93v7fzSymt1BpwEU8nAUXs8qzzvqhbjhK5QZg6Mt/HkBg==" }, "lint-staged": { - "version": "15.2.5", - "resolved": "https://registry.npmjs.org/lint-staged/-/lint-staged-15.2.5.tgz", - "integrity": "sha512-j+DfX7W9YUvdzEZl3Rk47FhDF6xwDBV5wwsCPw6BwWZVPYJemusQmvb9bRsW23Sqsaa+vRloAWogbK4BUuU2zA==", + "version": "15.2.7", + "resolved": "https://registry.npmjs.org/lint-staged/-/lint-staged-15.2.7.tgz", + "integrity": "sha512-+FdVbbCZ+yoh7E/RosSdqKJyUM2OEjTciH0TFNkawKgvFp1zbGlEC39RADg+xKBG1R4mhoH2j85myBQZ5wR+lw==", "dev": true, "requires": { "chalk": "~5.3.0", @@ -29075,9 +29062,9 @@ "integrity": "sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g==" }, "prettier": { - "version": "3.3.0", - "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.3.0.tgz", - "integrity": "sha512-J9odKxERhCQ10OC2yb93583f6UnYutOeiV5i0zEDS7UGTdUt0u+y8erxl3lBKvwo/JHyyoEdXjwp4dke9oyZ/g==", + "version": "3.3.2", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.3.2.tgz", + "integrity": "sha512-rAVeHYMcv8ATV5d508CFdn+8/pHPpXeIid1DdrPwXnaAdH7cqjVbpJaT5eq4yRAFU/lsbwYwSF/n5iNrdJHPQA==", "dev": true }, "pretty-bytes": { @@ -29922,9 +29909,9 @@ "integrity": "sha512-ZRwKbh/eQ6w9vmTjkuG0Ioi3HBwPFce0O+v//ve+aOq1oeCy7jMV2qzzAlpsNuqpqCBjjriM1lbtZbF/Q8jVyA==" }, "sass": { - "version": "1.77.4", - "resolved": "https://registry.npmjs.org/sass/-/sass-1.77.4.tgz", - "integrity": "sha512-vcF3Ckow6g939GMA4PeU7b2K/9FALXk2KF9J87txdHzXbUF9XRQRwSxcAs/fGaTnJeBFd7UoV22j3lzMLdM0Pw==", + "version": "1.77.6", + "resolved": "https://registry.npmjs.org/sass/-/sass-1.77.6.tgz", + "integrity": "sha512-ByXE1oLD79GVq9Ht1PeHWCPMPB8XHpBuz1r85oByKHjZY6qV6rWnQovQzXJXuQ/XyE1Oj3iPk3lo28uzaRA2/Q==", "devOptional": true, "requires": { "chokidar": ">=3.0.0 <4.0.0", @@ -31327,11 +31314,6 @@ "resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.1.tgz", "integrity": "sha1-n5VxD1CiZ5R7LMwSR0HBAoQn5xM=" }, - "uuid": { - "version": "9.0.1", - "resolved": "https://registry.npmjs.org/uuid/-/uuid-9.0.1.tgz", - "integrity": "sha512-b+1eJOlsR9K8HJpow9Ok3fiWOWSIcIzXodvv0rQjVoOVNpWMpxf1wZNpt4y9h10odCNrqnYp1OBzRktckBe3sA==" - }, "v8-compile-cache": { "version": "2.3.0", "resolved": "https://registry.npmjs.org/v8-compile-cache/-/v8-compile-cache-2.3.0.tgz", diff --git a/package.json b/package.json index b8e279756..d1d619300 100644 --- a/package.json +++ b/package.json @@ -14,7 +14,6 @@ "react-scripts": "^5.0.1", "react-search-input": "^0.11.3", "tachyons": "^4.12.0", - "uuid": "^9.0.1", "webfontloader": "^1.6.28" }, "husky": { @@ -44,7 +43,7 @@ "@fullhuman/postcss-purgecss": "^6.0.0", "@types/jest": "^29.5.12", "@types/leaflet": "^1.9.12", - "@types/node": "^20.13.0", + "@types/node": "^20.14.7", "@types/react": "^18.3.3", "@types/react-dom": "^18.3.0", "@types/react-lazyload": "^3.2.3", @@ -52,11 +51,11 @@ "gh-pages": "^6.1.1", "husky": "^9.0.11", "jsonlint": "^1.6.3", - "lint-staged": "^15.2.5", + "lint-staged": "^15.2.7", "node-fetch": "^3.3.2", "npm-run-all": "^4.1.5", - "prettier": "^3.3.0", - "sass": "^1.77.4", + "prettier": "^3.3.2", + "sass": "^1.77.6", "typescript": "^4.9.5" }, "browserslist": [ @@ -66,6 +65,6 @@ "not op_mini all" ], "volta": { - "node": "18.17.1" + "node": "20.15.0" } } diff --git a/scripts/aggregate-json.mjs b/scripts/aggregate-json.mjs index 83720ac75..78f3188a6 100644 --- a/scripts/aggregate-json.mjs +++ b/scripts/aggregate-json.mjs @@ -1,34 +1,34 @@ -import fs from "fs" -import path from "path" -import { v4 as uuidv4 } from "uuid" +import fs from 'fs' +import path from 'path' +import crypto from 'crypto' -const JSON_SOURCE_DIR = "Submissions" -const FINAL_JSON_FILE = "src/assets/persons.json" +const JSON_SOURCE_DIR = 'Submissions' +const FINAL_JSON_FILE = 'src/assets/persons.json' let dirContent = null const finalJSON = [] try { - dirContent = fs.readdirSync(path.resolve(JSON_SOURCE_DIR)) + dirContent = fs.readdirSync(path.resolve(JSON_SOURCE_DIR)) } catch (e) { - console.log(`error while reading "${JSON_SOURCE_DIR}": ` + e.message) + console.log(`error while reading "${JSON_SOURCE_DIR}": ` + e.message) } try { - for (let i = 0; i < dirContent.length; i++) { - const jsonContent__raw = fs.readFileSync( - path.resolve(JSON_SOURCE_DIR, dirContent[i]), - { encoding: "utf-8" } - ) + for (let i = 0; i < dirContent.length; i++) { + const jsonContent__raw = fs.readFileSync( + path.resolve(JSON_SOURCE_DIR, dirContent[i]), + { encoding: 'utf-8' } + ) - const jsonContent__parsed = JSON.parse(jsonContent__raw) - jsonContent__parsed.id = uuidv4() - finalJSON.push(jsonContent__parsed) - } + const jsonContent__parsed = JSON.parse(jsonContent__raw) + jsonContent__parsed.id = crypto.randomUUID() + finalJSON.push(jsonContent__parsed) + } } catch (e) { - console.log(`error: ` + e.message) + console.log(`error: ` + e.message) } fs.writeFileSync( - path.resolve(FINAL_JSON_FILE), - JSON.stringify(finalJSON, null, 2) + path.resolve(FINAL_JSON_FILE), + JSON.stringify(finalJSON, null, 2) )