-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
build: remove uuid and use Node.js built-in crypto.randomUUID, update…
… to Node 20
- Loading branch information
1 parent
cedae20
commit 75289fe
Showing
6 changed files
with
101 additions
and
121 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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="<pre>${NODE_OUTPUT//$'\n'/<br />}</pre>" | ||
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="<pre>${NODE_OUTPUT//$'\n'/<br />}</pre>" | ||
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
v18.17.1 | ||
v20.15.0 |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) | ||
) |