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 dfb3322a8..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": { @@ -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", @@ -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 c7cb5e00d..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": { @@ -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) )