Skip to content

Commit ce7111a

Browse files
committed
tools: refactor all dependencies updater
Most of the duplicated code in all the dependencies updaters has been moved in the `utils.sh` file
1 parent 16d6f6b commit ce7111a

25 files changed

+219
-389
lines changed

doc/contributing/maintaining/maintaining-dependencies.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -348,5 +348,5 @@ performance improvements not currently available in standard zlib.
348348
[undici 5.22.1]: #undici-5221
349349
[update-openssl-action]: ../../../.github/workflows/update-openssl.yml
350350
[uvwasi 0.0.16]: #uvwasi-0016
351-
[v8 11.3.244.8]: #v8-1132448
351+
[V8 11.3.244.8]: #V8-1132448
352352
[zlib 1.2.13]: #zlib-1213

tools/dep_updaters/update-acorn-walk.sh

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,14 @@ ROOT=$(cd "$(dirname "$0")/../.." && pwd)
1212
[ -x "$NODE" ] || NODE=$(command -v node)
1313
NPM="$ROOT/deps/npm/bin/npm-cli.js"
1414

15+
# shellcheck disable=SC1091
16+
. "$ROOT/tools/dep_updaters/utils.sh"
17+
1518
NEW_VERSION=$("$NODE" "$NPM" view acorn-walk dist-tags.latest)
1619
CURRENT_VERSION=$("$NODE" -p "require('./deps/acorn/acorn-walk/package.json').version")
1720

18-
echo "Comparing $NEW_VERSION with $CURRENT_VERSION"
19-
20-
if [ "$NEW_VERSION" = "$CURRENT_VERSION" ]; then
21-
echo "Skipped because Acorn-walk is on the latest version."
22-
exit 0
23-
fi
21+
# This function exit with 0 if new version and current version are the same
22+
compare_dependency_version "acorn-walk" "$NEW_VERSION" "$CURRENT_VERSION"
2423

2524
cd "$( dirname "$0" )/../.." || exit
2625

@@ -40,14 +39,5 @@ mv acorn-walk-tmp/node_modules/acorn-walk deps/acorn
4039

4140
rm -rf acorn-walk-tmp/
4241

43-
echo "All done!"
44-
echo ""
45-
echo "Please git add acorn-walk, commit the new version:"
46-
echo ""
47-
echo "$ git add -A deps/acorn-walk"
48-
echo "$ git commit -m \"deps: update acorn-walk to $NEW_VERSION\""
49-
echo ""
50-
51-
# The last line of the script should always print the new version,
52-
# as we need to add it to $GITHUB_ENV variable.
53-
echo "NEW_VERSION=$NEW_VERSION"
42+
# Echo to commit the new version
43+
finalize_version_update "acorn-walk" "$NEW_VERSION"

tools/dep_updaters/update-acorn.sh

Lines changed: 7 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,14 @@ ROOT=$(cd "$(dirname "$0")/../.." && pwd)
1212
[ -x "$NODE" ] || NODE=$(command -v node)
1313
NPM="$ROOT/deps/npm/bin/npm-cli.js"
1414

15+
# shellcheck disable=SC1091
16+
. "$ROOT/tools/dep_updaters/utils.sh"
17+
1518
NEW_VERSION=$("$NODE" "$NPM" view acorn dist-tags.latest)
1619
CURRENT_VERSION=$("$NODE" -p "require('./deps/acorn/acorn/package.json').version")
1720

18-
echo "Comparing $NEW_VERSION with $CURRENT_VERSION"
19-
20-
if [ "$NEW_VERSION" = "$CURRENT_VERSION" ]; then
21-
echo "Skipped because Acorn is on the latest version."
22-
exit 0
23-
fi
21+
# This function exit with 0 if new version and current version are the same
22+
compare_dependency_version "acorn" "$NEW_VERSION" "$CURRENT_VERSION"
2423

2524
cd "$( dirname "$0" )/../.." || exit
2625

@@ -50,19 +49,7 @@ mv acorn-tmp/node_modules/acorn deps/acorn
5049
rm -rf acorn-tmp/
5150

5251
# Update the version number
53-
# shellcheck disable=SC1091
54-
. "$ROOT/tools/dep_updaters/utils.sh"
5552
update_dependency_version "acorn" "$NEW_VERSION"
5653

57-
echo "All done!"
58-
echo ""
59-
echo "Please git add acorn, commit the new version:"
60-
echo ""
61-
echo "$ git add -A deps/acorn"
62-
echo "$ git add doc/contributing/maintaining/maintaining-dependencies.md"
63-
echo "$ git commit -m \"deps: update acorn to $NEW_VERSION\""
64-
echo ""
65-
66-
# The last line of the script should always print the new version,
67-
# as we need to add it to $GITHUB_ENV variable.
68-
echo "NEW_VERSION=$NEW_VERSION"
54+
# Echo to commit the new version
55+
finalize_version_update "acorn" "$NEW_VERSION"

tools/dep_updaters/update-ada.sh

Lines changed: 7 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ DEPS_DIR="$BASE_DIR/deps"
77
[ -z "$NODE" ] && NODE="$BASE_DIR/out/Release/node"
88
[ -x "$NODE" ] || NODE=$(command -v node)
99

10+
# shellcheck disable=SC1091
11+
. "$BASE_DIR/tools/dep_updaters/utils.sh"
12+
1013
NEW_VERSION="$("$NODE" --input-type=module <<'EOF'
1114
const res = await fetch('https://api.github.com/repos/ada-url/ada/releases/latest');
1215
if (!res.ok) throw new Error(`FetchError: ${res.status} ${res.statusText}`, { cause: res });
@@ -17,12 +20,8 @@ EOF
1720

1821
CURRENT_VERSION=$(grep "#define ADA_VERSION" "$DEPS_DIR/ada/ada.h" | sed -n "s/^.*VERSION \"\(.*\)\"/\1/p")
1922

20-
echo "Comparing $NEW_VERSION with $CURRENT_VERSION"
21-
22-
if [ "$NEW_VERSION" = "$CURRENT_VERSION" ]; then
23-
echo "Skipped because ada is on the latest version."
24-
exit 0
25-
fi
23+
# This function exit with 0 if new version and current version are the same
24+
compare_dependency_version "ada" "$NEW_VERSION" "$CURRENT_VERSION"
2625

2726
echo "Making temporary workspace..."
2827

@@ -55,19 +54,7 @@ rm -rf "$DEPS_DIR/ada"
5554
mv "$WORKSPACE" "$DEPS_DIR/ada"
5655

5756
# Update the version number
58-
# shellcheck disable=SC1091
59-
. "$BASE_DIR/tools/dep_updaters/utils.sh"
6057
update_dependency_version "ada" "$NEW_VERSION"
6158

62-
echo "All done!"
63-
echo ""
64-
echo "Please git add ada, commit the new version:"
65-
echo ""
66-
echo "$ git add -A deps/ada"
67-
echo "$ git add doc/contributing/maintaining/maintaining-dependencies.md"
68-
echo "$ git commit -m \"deps: update ada to $NEW_VERSION\""
69-
echo ""
70-
71-
# The last line of the script should always print the new version,
72-
# as we need to add it to $GITHUB_ENV variable.
73-
echo "NEW_VERSION=$NEW_VERSION"
59+
# Echo to commit the new version
60+
finalize_version_update "ada" "$NEW_VERSION"

tools/dep_updaters/update-base64.sh

Lines changed: 10 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ DEPS_DIR="$BASE_DIR/deps"
88
[ -z "$NODE" ] && NODE="$BASE_DIR/out/Release/node"
99
[ -x "$NODE" ] || NODE=$(command -v node)
1010

11+
# shellcheck disable=SC1091
12+
. "$BASE_DIR/tools/dep_updaters/utils.sh"
13+
1114
NEW_VERSION="$("$NODE" --input-type=module <<'EOF'
1215
const res = await fetch('https://api.github.com/repos/aklomp/base64/releases/latest');
1316
if (!res.ok) throw new Error(`FetchError: ${res.status} ${res.statusText}`, { cause: res });
@@ -18,12 +21,8 @@ EOF
1821

1922
CURRENT_VERSION=$(grep "base64 LANGUAGES C VERSION" ./deps/base64/base64/CMakeLists.txt | sed -n "s/^.*VERSION \(.*\))/\1/p")
2023

21-
echo "Comparing $NEW_VERSION with $CURRENT_VERSION"
22-
23-
if [ "$NEW_VERSION" = "$CURRENT_VERSION" ]; then
24-
echo "Skipped because base64 is on the latest version."
25-
exit 0
26-
fi
24+
# This function exit with 0 if new version and current version are the same
25+
compare_dependency_version "base64" "$NEW_VERSION" "$CURRENT_VERSION"
2726

2827
echo "Making temporary workspace"
2928

@@ -51,20 +50,6 @@ mv "$WORKSPACE/base64" "$DEPS_DIR/base64/"
5150
# to work, we create it and leave it empty.
5251
echo "// Intentionally empty" >> "$DEPS_DIR/base64/base64/lib/config.h"
5352

54-
# Update the version number
55-
# shellcheck disable=SC1091
56-
. "$BASE_DIR/tools/dep_updaters/utils.sh"
57-
update_dependency_version "base64" "$NEW_VERSION"
58-
59-
echo "All done!"
60-
echo ""
61-
echo "Please git add base64/base64, commit the new version:"
62-
echo ""
63-
echo "$ git add -A deps/base64/base64"
64-
echo "$ git add doc/contributing/maintaining/maintaining-dependencies.md"
65-
echo "$ git commit -m \"deps: update base64 to $NEW_VERSION\""
66-
echo ""
67-
6853
# update the base64_version.h
6954
cat > "$BASE_DIR/src/base64_version.h" << EOL
7055
// This is an auto generated file, please do not edit.
@@ -75,6 +60,8 @@ cat > "$BASE_DIR/src/base64_version.h" << EOL
7560
#endif // SRC_BASE64_VERSION_H_
7661
EOL
7762

78-
# The last line of the script should always print the new version,
79-
# as we need to add it to $GITHUB_ENV variable.
80-
echo "NEW_VERSION=$NEW_VERSION"
63+
# Update the version number
64+
update_dependency_version "base64" "$NEW_VERSION"
65+
66+
# Echo to commit the new version
67+
finalize_version_update "base64" "$NEW_VERSION"

tools/dep_updaters/update-brotli.sh

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ DEPS_DIR="$BASE_DIR/deps"
88
[ -z "$NODE" ] && NODE="$BASE_DIR/out/Release/node"
99
[ -x "$NODE" ] || NODE=$(command -v node)
1010

11+
# shellcheck disable=SC1091
12+
. "$BASE_DIR/tools/dep_updaters/utils.sh"
13+
1114
NEW_VERSION="$("$NODE" --input-type=module <<'EOF'
1215
const res = await fetch('https://api.github.com/repos/google/brotli/releases/latest');
1316
if (!res.ok) throw new Error(`FetchError: ${res.status} ${res.statusText}`, { cause: res });
@@ -25,10 +28,8 @@ CURRENT_VERSION="${major}.${minor}.${patch}"
2528

2629
echo "Comparing $NEW_VERSION with $CURRENT_VERSION"
2730

28-
if [ "$NEW_VERSION" = "$CURRENT_VERSION" ]; then
29-
echo "Skipped because brotli is on the latest version."
30-
exit 0
31-
fi
31+
# This function exit with 0 if new version and current version are the same
32+
compare_dependency_version "brotli" "$NEW_VERSION" "$CURRENT_VERSION"
3233

3334
echo "Making temporary workspace"
3435

@@ -63,19 +64,7 @@ echo "Update c and LICENSE"
6364
mv "$WORKSPACE/brotli/c" "$WORKSPACE/brotli/LICENSE" "$WORKSPACE/brotli/brotli.gyp" "$DEPS_DIR/brotli"
6465

6566
# Update the version number
66-
# shellcheck disable=SC1091
67-
. "$BASE_DIR/tools/dep_updaters/utils.sh"
6867
update_dependency_version "brotli" "$NEW_VERSION"
6968

70-
echo "All done!"
71-
echo ""
72-
echo "Please git add brotli, commit the new version:"
73-
echo ""
74-
echo "$ git add -A deps/brotli"
75-
echo "$ git add doc/contributing/maintaining/maintaining-dependencies.md"
76-
echo "$ git commit -m \"deps: update brotli to $NEW_VERSION\""
77-
echo ""
78-
79-
# The last line of the script should always print the new version,
80-
# as we need to add it to $GITHUB_ENV variable.
81-
echo "NEW_VERSION=$NEW_VERSION"
69+
# Echo to commit the new version
70+
finalize_version_update "brotli" "$NEW_VERSION"

tools/dep_updaters/update-c-ares.sh

Lines changed: 7 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ DEPS_DIR="$BASE_DIR/deps"
88
[ -z "$NODE" ] && NODE="$BASE_DIR/out/Release/node"
99
[ -x "$NODE" ] || NODE=$(command -v node)
1010

11+
# shellcheck disable=SC1091
12+
. "$BASE_DIR/tools/dep_updaters/utils.sh"
13+
1114
NEW_VERSION="$("$NODE" --input-type=module <<'EOF'
1215
const res = await fetch('https://api.github.com/repos/c-ares/c-ares/releases/latest');
1316
if (!res.ok) throw new Error(`FetchError: ${res.status} ${res.statusText}`, { cause: res });
@@ -18,12 +21,8 @@ EOF
1821

1922
CURRENT_VERSION=$(grep "#define ARES_VERSION_STR" ./deps/cares/include/ares_version.h | sed -n "s/^.*VERSION_STR \"\(.*\)\"/\1/p")
2023

21-
echo "Comparing $NEW_VERSION with $CURRENT_VERSION"
22-
23-
if [ "$NEW_VERSION" = "$CURRENT_VERSION" ]; then
24-
echo "Skipped because c-ares is on the latest version."
25-
exit 0
26-
fi
24+
# This function exit with 0 if new version and current version are the same
25+
compare_dependency_version "c-ares" "$NEW_VERSION" "$CURRENT_VERSION"
2726

2827
echo "Making temporary workspace"
2928

@@ -59,19 +58,7 @@ rm -rf "$DEPS_DIR/cares"
5958
mv "$WORKSPACE/cares" "$DEPS_DIR/"
6059

6160
# Update the version number
62-
# shellcheck disable=SC1091
63-
. "$BASE_DIR/tools/dep_updaters/utils.sh"
6461
update_dependency_version "c-ares" "$NEW_VERSION"
6562

66-
echo "All done!"
67-
echo ""
68-
echo "Please git add c-ares, commit the new version:"
69-
echo ""
70-
echo "$ git add -A deps/cares"
71-
echo "$ git add doc/contributing/maintaining/maintaining-dependencies.md"
72-
echo "$ git commit -m \"deps: update c-ares to $NEW_VERSION\""
73-
echo ""
74-
75-
# The last line of the script should always print the new version,
76-
# as we need to add it to $GITHUB_ENV variable.
77-
echo "NEW_VERSION=$NEW_VERSION"
63+
# Echo to commit the new version
64+
finalize_version_update "c-ares" "$NEW_VERSION"

tools/dep_updaters/update-cjs-module-lexer.sh

Lines changed: 10 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ DEPS_DIR="$BASE_DIR/deps"
1010

1111
NPM="$DEPS_DIR/npm/bin/npm-cli.js"
1212

13+
# shellcheck disable=SC1091
14+
. "$BASE_DIR/tools/dep_updaters/utils.sh"
15+
1316
NEW_VERSION="$("$NODE" --input-type=module <<'EOF'
1417
const res = await fetch('https://api.github.com/repos/nodejs/cjs-module-lexer/tags');
1518
if (!res.ok) throw new Error(`FetchError: ${res.status} ${res.statusText}`, { cause: res });
@@ -21,12 +24,8 @@ EOF
2124

2225
CURRENT_VERSION=$("$NODE" -p "require('./deps/cjs-module-lexer/package.json').version")
2326

24-
echo "Comparing $NEW_VERSION with $CURRENT_VERSION"
25-
26-
if [ "$NEW_VERSION" = "$CURRENT_VERSION" ]; then
27-
echo "Skipped because cjs-module-lexer is on the latest version."
28-
exit 0
29-
fi
27+
# This function exit with 0 if new version and current version are the same
28+
compare_dependency_version "cjs-module-lexer" "$NEW_VERSION" "$CURRENT_VERSION"
3029

3130
echo "Making temporary workspace"
3231

@@ -50,20 +49,6 @@ rm -rf "$DEPS_DIR/cjs-module-lexer"
5049

5150
mv node_modules/cjs-module-lexer "$DEPS_DIR/cjs-module-lexer"
5251

53-
# Update the version number
54-
# shellcheck disable=SC1091
55-
. "$BASE_DIR/tools/dep_updaters/utils.sh"
56-
update_dependency_version "cjs-module-lexer" "$NEW_VERSION"
57-
58-
echo "All done!"
59-
echo ""
60-
echo "Please git add cjs-module-lexer, commit the new version:"
61-
echo ""
62-
echo "$ git add -A deps/cjs-module-lexer"
63-
echo "$ git add doc/contributing/maintaining/maintaining-dependencies.md"
64-
echo "$ git commit -m \"deps: update cjs-module-lexer to $NEW_VERSION\""
65-
echo ""
66-
6752
# update cjs_module_lexer_version.h
6853
cat > "$BASE_DIR/src/cjs_module_lexer_version.h" << EOL
6954
// This is an auto generated file, please do not edit.
@@ -74,6 +59,8 @@ cat > "$BASE_DIR/src/cjs_module_lexer_version.h" << EOL
7459
#endif // SRC_CJS_MODULE_LEXER_VERSION_H_
7560
EOL
7661

77-
# The last line of the script should always print the new version,
78-
# as we need to add it to $GITHUB_ENV variable.
79-
echo "NEW_VERSION=$NEW_VERSION"
62+
# Update the version number
63+
update_dependency_version "cjs-module-lexer" "$NEW_VERSION"
64+
65+
# Echo to commit the new version
66+
finalize_version_update "cjs-module-lexer" "$NEW_VERSION"

tools/dep_updaters/update-eslint.sh

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,14 @@ ROOT=$(cd "$(dirname "$0")/../.." && pwd)
1313
[ -x "$NODE" ] || NODE=$(command -v node)
1414
NPM="$ROOT/deps/npm/bin/npm-cli.js"
1515

16+
# shellcheck disable=SC1091
17+
. "$ROOT/tools/dep_updaters/utils.sh"
18+
1619
NEW_VERSION=$("$NODE" "$NPM" view eslint dist-tags.latest)
1720
CURRENT_VERSION=$("$NODE" -p "require('./tools/node_modules/eslint/package.json').version")
1821

19-
echo "Comparing $NEW_VERSION with $CURRENT_VERSION"
20-
21-
if [ "$NEW_VERSION" = "$CURRENT_VERSION" ]; then
22-
echo "Skipped because ESlint is on the latest version."
23-
exit 0
24-
fi
22+
# This function exit with 0 if new version and current version are the same
23+
compare_dependency_version "eslint" "$NEW_VERSION" "$CURRENT_VERSION"
2524

2625
cd "$( dirname "$0" )" || exit
2726
rm -rf ../node_modules/eslint

tools/dep_updaters/update-googletest.sh

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ DEPS_DIR="$BASE_DIR/deps"
1010
NEW_UPSTREAM_SHA1=$(git ls-remote "https://github.com/google/googletest.git" HEAD | awk '{print $1}')
1111
NEW_VERSION=$(echo "$NEW_UPSTREAM_SHA1" | head -c 7)
1212

13+
# shellcheck disable=SC1091
14+
. "$BASE_DIR/tools/dep_updaters/utils.sh"
15+
1316
echo "Comparing $NEW_VERSION with current revision"
1417

1518
git remote add googletest-upstream https://github.com/google/googletest.git
@@ -81,19 +84,7 @@ NEW_GYP=$(
8184
echo "$NEW_GYP" >"$DEPS_DIR/googletest/googletest.gyp"
8285

8386
# Update the version number
84-
# shellcheck disable=SC1091
85-
. "$BASE_DIR/tools/dep_updaters/utils.sh"
8687
update_dependency_version "googletest" "$NEW_VERSION"
8788

88-
echo "All done!"
89-
echo ""
90-
echo "Please git stage googletest, commit the new version:"
91-
echo ""
92-
echo "$ git stage -A deps/googletest"
93-
echo "$ git add doc/contributing/maintaining/maintaining-dependencies.md"
94-
echo "$ git commit -m \"deps: update googletest to $NEW_VERSION\""
95-
echo ""
96-
97-
# The last line of the script should always print the new version,
98-
# as we need to add it to $GITHUB_ENV variable.
99-
echo "NEW_VERSION=$NEW_VERSION"
89+
# Echo to commit the new version
90+
finalize_version_update "googletest" "$NEW_VERSION"

0 commit comments

Comments
 (0)