Skip to content

Commit 96451f5

Browse files
facutuescadanielleadams
authored andcommitted
tools: add automation for updating acorn dependency
Add a Github Action that checks for new versions of the `acorn` and `acorn-walk` dependencies, and creates PRs to update them if newer versions than the ones present in the repo are found. Refs: nodejs/security-wg#828 PR-URL: #45357 Reviewed-By: Darshan Sen <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Jiawen Geng <[email protected]>
1 parent a8fd147 commit 96451f5

File tree

3 files changed

+80
-0
lines changed

3 files changed

+80
-0
lines changed

.github/workflows/tools.yml

+20
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,26 @@ jobs:
8989
echo "NEW_VERSION=$NEW_VERSION" >> $GITHUB_ENV
9090
./tools/update-base64.sh "$NEW_VERSION"
9191
fi
92+
- id: acorn
93+
subsystem: deps
94+
label: dependencies
95+
run: |
96+
NEW_VERSION=$(npm view acorn dist-tags.latest)
97+
CURRENT_VERSION=$(node -p "require('./deps/acorn/acorn/package.json').version")
98+
if [ "$NEW_VERSION" != "$CURRENT_VERSION" ]; then
99+
echo "NEW_VERSION=$NEW_VERSION" >> $GITHUB_ENV
100+
./tools/update-acorn.sh
101+
fi
102+
- id: acorn-walk
103+
subsystem: deps
104+
label: dependencies
105+
run: |
106+
NEW_VERSION=$(npm view acorn-walk dist-tags.latest)
107+
CURRENT_VERSION=$(node -p "require('./deps/acorn/acorn-walk/package.json').version")
108+
if [ "$NEW_VERSION" != "$CURRENT_VERSION" ]; then
109+
echo "NEW_VERSION=$NEW_VERSION" >> $GITHUB_ENV
110+
./tools/update-acorn-walk.sh
111+
fi
92112
steps:
93113
- uses: actions/checkout@v3
94114
with:

tools/update-acorn-walk.sh

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!/bin/sh
2+
3+
# Shell script to update acorn-walk in the source tree to the latest release.
4+
5+
# This script must be in the tools directory when it runs because it uses the
6+
# script source file path to determine directories to work in.
7+
8+
set -ex
9+
10+
cd "$( dirname "$0" )/.." || exit
11+
rm -rf deps/acorn/acorn-walk
12+
13+
(
14+
rm -rf acorn-walk-tmp
15+
mkdir acorn-walk-tmp
16+
cd acorn-walk-tmp || exit
17+
18+
ROOT="$PWD/.."
19+
[ -z "$NODE" ] && NODE="$ROOT/out/Release/node"
20+
[ -x "$NODE" ] || NODE=$(command -v node)
21+
NPM="$ROOT/deps/npm/bin/npm-cli.js"
22+
23+
"$NODE" "$NPM" init --yes
24+
25+
"$NODE" "$NPM" install --global-style --no-bin-links --ignore-scripts acorn-walk
26+
)
27+
28+
mv acorn-walk-tmp/node_modules/acorn-walk deps/acorn
29+
30+
rm -rf acorn-walk-tmp/

tools/update-acorn.sh

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!/bin/sh
2+
3+
# Shell script to update acorn in the source tree to the latest release.
4+
5+
# This script must be in the tools directory when it runs because it uses the
6+
# script source file path to determine directories to work in.
7+
8+
set -ex
9+
10+
cd "$( dirname "$0" )/.." || exit
11+
rm -rf deps/acorn/acorn
12+
13+
(
14+
rm -rf acorn-tmp
15+
mkdir acorn-tmp
16+
cd acorn-tmp || exit
17+
18+
ROOT="$PWD/.."
19+
[ -z "$NODE" ] && NODE="$ROOT/out/Release/node"
20+
[ -x "$NODE" ] || NODE=$(command -v node)
21+
NPM="$ROOT/deps/npm/bin/npm-cli.js"
22+
23+
"$NODE" "$NPM" init --yes
24+
25+
"$NODE" "$NPM" install --global-style --no-bin-links --ignore-scripts acorn
26+
)
27+
28+
mv acorn-tmp/node_modules/acorn deps/acorn
29+
30+
rm -rf acorn-tmp/

0 commit comments

Comments
 (0)