Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 1271b0e

Browse filesBrowse files
marco-ippolitoMoLow
authored andcommitted
tools: automate cjs-module-lexer dependency update
PR-URL: #47446 Refs: nodejs/security-wg#828 Reviewed-By: Debadree Chatterjee <debadree333@gmail.com> Reviewed-By: Paolo Insogna <paolo@cowtech.it> Reviewed-By: Guy Bedford <guybedford@gmail.com> Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
1 parent 3ceb2c4 commit 1271b0e
Copy full SHA for 1271b0e

File tree

Expand file treeCollapse file tree

2 files changed

+71
-0
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

2 files changed

+71
-0
lines changed
Open diff view settings
Collapse file

‎.github/workflows/tools.yml‎

Copy file name to clipboardExpand all lines: .github/workflows/tools.yml
+8Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,14 @@ jobs:
174174
label: crypto, notable-change
175175
run: |
176176
node ./tools/dep_updaters/update-root-certs.mjs -v -f "$GITHUB_ENV"
177+
- id: cjs-module-lexer
178+
subsystem: deps
179+
label: dependencies
180+
run: |
181+
./tools/dep_updaters/update-cjs-module-lexer.sh > temp-output
182+
cat temp-output
183+
tail -n1 temp-output | grep "NEW_VERSION=" >> "$GITHUB_ENV" || true
184+
rm temp-output
177185
steps:
178186
- uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
179187
with:
Collapse file
+63Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
#!/bin/sh
2+
set -e
3+
# Shell script to update cjs-module-lexer in the source tree to a specific version
4+
5+
BASE_DIR=$(cd "$(dirname "$0")/../.." && pwd)
6+
7+
DEPS_DIR="$BASE_DIR/deps"
8+
[ -z "$NODE" ] && NODE="$BASE_DIR/out/Release/node"
9+
[ -x "$NODE" ] || NODE=$(command -v node)
10+
11+
NPM="$DEPS_DIR/npm/bin/npm-cli.js"
12+
13+
NEW_VERSION="$("$NODE" --input-type=module <<'EOF'
14+
const res = await fetch('https://api.github.com/repos/nodejs/cjs-module-lexer/tags');
15+
if (!res.ok) throw new Error(`FetchError: ${res.status} ${res.statusText}`, { cause: res });
16+
const tags = await res.json();
17+
const { name } = tags.at(0)
18+
console.log(name);
19+
EOF
20+
)"
21+
22+
CURRENT_VERSION=$("$NODE" -p "require('./deps/cjs-module-lexer/package.json').version")
23+
24+
echo "Comparing $NEW_VERSION with $CURRENT_VERSION"
25+
26+
if [ "$NEW_VERSION" = "$CURRENT_VERSION" ]; then
27+
echo "Skipped because ada is on the latest version."
28+
exit 0
29+
fi
30+
31+
echo "Making temporary workspace"
32+
33+
WORKSPACE=$(mktemp -d 2> /dev/null || mktemp -d -t 'tmp')
34+
35+
cleanup () {
36+
EXIT_CODE=$?
37+
[ -d "$WORKSPACE" ] && rm -rf "$WORKSPACE"
38+
exit $EXIT_CODE
39+
}
40+
41+
trap cleanup INT TERM EXIT
42+
43+
cd "$WORKSPACE"
44+
45+
"$NODE" "$NPM" init --yes
46+
47+
"$NODE" "$NPM" install --global-style --no-bin-links --ignore-scripts cjs-module-lexer
48+
49+
rm -rf "$DEPS_DIR/cjs-module-lexer"
50+
51+
mv node_modules/cjs-module-lexer "$DEPS_DIR/cjs-module-lexer"
52+
53+
echo "All done!"
54+
echo ""
55+
echo "Please git add cjs-module-lexer, commit the new version:"
56+
echo ""
57+
echo "$ git add -A deps/cjs-module-lexer"
58+
echo "$ git commit -m \"deps: update cjs-module-lexer to $NEW_VERSION\""
59+
echo ""
60+
61+
# The last line of the script should always print the new version,
62+
# as we need to add it to $GITHUB_ENV variable.
63+
echo "NEW_VERSION=$NEW_VERSION"

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.