Skip to content

Commit

Permalink
tools: refactor all dependencies updater
Browse files Browse the repository at this point in the history
Most of the duplicated code in all the dependencies updaters has been moved in the `utils.sh` file
  • Loading branch information
fasenderos committed May 23, 2023
1 parent 16d6f6b commit ce7111a
Show file tree
Hide file tree
Showing 25 changed files with 219 additions and 389 deletions.
2 changes: 1 addition & 1 deletion doc/contributing/maintaining/maintaining-dependencies.md
Original file line number Diff line number Diff line change
Expand Up @@ -348,5 +348,5 @@ performance improvements not currently available in standard zlib.
[undici 5.22.1]: #undici-5221
[update-openssl-action]: ../../../.github/workflows/update-openssl.yml
[uvwasi 0.0.16]: #uvwasi-0016
[v8 11.3.244.8]: #v8-1132448
[V8 11.3.244.8]: #V8-1132448
[zlib 1.2.13]: #zlib-1213
24 changes: 7 additions & 17 deletions tools/dep_updaters/update-acorn-walk.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,14 @@ ROOT=$(cd "$(dirname "$0")/../.." && pwd)
[ -x "$NODE" ] || NODE=$(command -v node)
NPM="$ROOT/deps/npm/bin/npm-cli.js"

# shellcheck disable=SC1091
. "$ROOT/tools/dep_updaters/utils.sh"

NEW_VERSION=$("$NODE" "$NPM" view acorn-walk dist-tags.latest)
CURRENT_VERSION=$("$NODE" -p "require('./deps/acorn/acorn-walk/package.json').version")

echo "Comparing $NEW_VERSION with $CURRENT_VERSION"

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

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

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

rm -rf acorn-walk-tmp/

echo "All done!"
echo ""
echo "Please git add acorn-walk, commit the new version:"
echo ""
echo "$ git add -A deps/acorn-walk"
echo "$ git commit -m \"deps: update acorn-walk to $NEW_VERSION\""
echo ""

# The last line of the script should always print the new version,
# as we need to add it to $GITHUB_ENV variable.
echo "NEW_VERSION=$NEW_VERSION"
# Echo to commit the new version
finalize_version_update "acorn-walk" "$NEW_VERSION"
27 changes: 7 additions & 20 deletions tools/dep_updaters/update-acorn.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,14 @@ ROOT=$(cd "$(dirname "$0")/../.." && pwd)
[ -x "$NODE" ] || NODE=$(command -v node)
NPM="$ROOT/deps/npm/bin/npm-cli.js"

# shellcheck disable=SC1091
. "$ROOT/tools/dep_updaters/utils.sh"

NEW_VERSION=$("$NODE" "$NPM" view acorn dist-tags.latest)
CURRENT_VERSION=$("$NODE" -p "require('./deps/acorn/acorn/package.json').version")

echo "Comparing $NEW_VERSION with $CURRENT_VERSION"

if [ "$NEW_VERSION" = "$CURRENT_VERSION" ]; then
echo "Skipped because Acorn is on the latest version."
exit 0
fi
# This function exit with 0 if new version and current version are the same
compare_dependency_version "acorn" "$NEW_VERSION" "$CURRENT_VERSION"

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

Expand Down Expand Up @@ -50,19 +49,7 @@ mv acorn-tmp/node_modules/acorn deps/acorn
rm -rf acorn-tmp/

# Update the version number
# shellcheck disable=SC1091
. "$ROOT/tools/dep_updaters/utils.sh"
update_dependency_version "acorn" "$NEW_VERSION"

echo "All done!"
echo ""
echo "Please git add acorn, commit the new version:"
echo ""
echo "$ git add -A deps/acorn"
echo "$ git add doc/contributing/maintaining/maintaining-dependencies.md"
echo "$ git commit -m \"deps: update acorn to $NEW_VERSION\""
echo ""

# The last line of the script should always print the new version,
# as we need to add it to $GITHUB_ENV variable.
echo "NEW_VERSION=$NEW_VERSION"
# Echo to commit the new version
finalize_version_update "acorn" "$NEW_VERSION"
27 changes: 7 additions & 20 deletions tools/dep_updaters/update-ada.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ DEPS_DIR="$BASE_DIR/deps"
[ -z "$NODE" ] && NODE="$BASE_DIR/out/Release/node"
[ -x "$NODE" ] || NODE=$(command -v node)

# shellcheck disable=SC1091
. "$BASE_DIR/tools/dep_updaters/utils.sh"

NEW_VERSION="$("$NODE" --input-type=module <<'EOF'
const res = await fetch('https://api.github.com/repos/ada-url/ada/releases/latest');
if (!res.ok) throw new Error(`FetchError: ${res.status} ${res.statusText}`, { cause: res });
Expand All @@ -17,12 +20,8 @@ EOF

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

echo "Comparing $NEW_VERSION with $CURRENT_VERSION"

if [ "$NEW_VERSION" = "$CURRENT_VERSION" ]; then
echo "Skipped because ada is on the latest version."
exit 0
fi
# This function exit with 0 if new version and current version are the same
compare_dependency_version "ada" "$NEW_VERSION" "$CURRENT_VERSION"

echo "Making temporary workspace..."

Expand Down Expand Up @@ -55,19 +54,7 @@ rm -rf "$DEPS_DIR/ada"
mv "$WORKSPACE" "$DEPS_DIR/ada"

# Update the version number
# shellcheck disable=SC1091
. "$BASE_DIR/tools/dep_updaters/utils.sh"
update_dependency_version "ada" "$NEW_VERSION"

echo "All done!"
echo ""
echo "Please git add ada, commit the new version:"
echo ""
echo "$ git add -A deps/ada"
echo "$ git add doc/contributing/maintaining/maintaining-dependencies.md"
echo "$ git commit -m \"deps: update ada to $NEW_VERSION\""
echo ""

# The last line of the script should always print the new version,
# as we need to add it to $GITHUB_ENV variable.
echo "NEW_VERSION=$NEW_VERSION"
# Echo to commit the new version
finalize_version_update "ada" "$NEW_VERSION"
33 changes: 10 additions & 23 deletions tools/dep_updaters/update-base64.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ DEPS_DIR="$BASE_DIR/deps"
[ -z "$NODE" ] && NODE="$BASE_DIR/out/Release/node"
[ -x "$NODE" ] || NODE=$(command -v node)

# shellcheck disable=SC1091
. "$BASE_DIR/tools/dep_updaters/utils.sh"

NEW_VERSION="$("$NODE" --input-type=module <<'EOF'
const res = await fetch('https://api.github.com/repos/aklomp/base64/releases/latest');
if (!res.ok) throw new Error(`FetchError: ${res.status} ${res.statusText}`, { cause: res });
Expand All @@ -18,12 +21,8 @@ EOF

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

echo "Comparing $NEW_VERSION with $CURRENT_VERSION"

if [ "$NEW_VERSION" = "$CURRENT_VERSION" ]; then
echo "Skipped because base64 is on the latest version."
exit 0
fi
# This function exit with 0 if new version and current version are the same
compare_dependency_version "base64" "$NEW_VERSION" "$CURRENT_VERSION"

echo "Making temporary workspace"

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

# Update the version number
# shellcheck disable=SC1091
. "$BASE_DIR/tools/dep_updaters/utils.sh"
update_dependency_version "base64" "$NEW_VERSION"

echo "All done!"
echo ""
echo "Please git add base64/base64, commit the new version:"
echo ""
echo "$ git add -A deps/base64/base64"
echo "$ git add doc/contributing/maintaining/maintaining-dependencies.md"
echo "$ git commit -m \"deps: update base64 to $NEW_VERSION\""
echo ""

# update the base64_version.h
cat > "$BASE_DIR/src/base64_version.h" << EOL
// This is an auto generated file, please do not edit.
Expand All @@ -75,6 +60,8 @@ cat > "$BASE_DIR/src/base64_version.h" << EOL
#endif // SRC_BASE64_VERSION_H_
EOL

# The last line of the script should always print the new version,
# as we need to add it to $GITHUB_ENV variable.
echo "NEW_VERSION=$NEW_VERSION"
# Update the version number
update_dependency_version "base64" "$NEW_VERSION"

# Echo to commit the new version
finalize_version_update "base64" "$NEW_VERSION"
25 changes: 7 additions & 18 deletions tools/dep_updaters/update-brotli.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ DEPS_DIR="$BASE_DIR/deps"
[ -z "$NODE" ] && NODE="$BASE_DIR/out/Release/node"
[ -x "$NODE" ] || NODE=$(command -v node)

# shellcheck disable=SC1091
. "$BASE_DIR/tools/dep_updaters/utils.sh"

NEW_VERSION="$("$NODE" --input-type=module <<'EOF'
const res = await fetch('https://api.github.com/repos/google/brotli/releases/latest');
if (!res.ok) throw new Error(`FetchError: ${res.status} ${res.statusText}`, { cause: res });
Expand All @@ -25,10 +28,8 @@ CURRENT_VERSION="${major}.${minor}.${patch}"

echo "Comparing $NEW_VERSION with $CURRENT_VERSION"

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

echo "Making temporary workspace"

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

# Update the version number
# shellcheck disable=SC1091
. "$BASE_DIR/tools/dep_updaters/utils.sh"
update_dependency_version "brotli" "$NEW_VERSION"

echo "All done!"
echo ""
echo "Please git add brotli, commit the new version:"
echo ""
echo "$ git add -A deps/brotli"
echo "$ git add doc/contributing/maintaining/maintaining-dependencies.md"
echo "$ git commit -m \"deps: update brotli to $NEW_VERSION\""
echo ""

# The last line of the script should always print the new version,
# as we need to add it to $GITHUB_ENV variable.
echo "NEW_VERSION=$NEW_VERSION"
# Echo to commit the new version
finalize_version_update "brotli" "$NEW_VERSION"
27 changes: 7 additions & 20 deletions tools/dep_updaters/update-c-ares.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ DEPS_DIR="$BASE_DIR/deps"
[ -z "$NODE" ] && NODE="$BASE_DIR/out/Release/node"
[ -x "$NODE" ] || NODE=$(command -v node)

# shellcheck disable=SC1091
. "$BASE_DIR/tools/dep_updaters/utils.sh"

NEW_VERSION="$("$NODE" --input-type=module <<'EOF'
const res = await fetch('https://api.github.com/repos/c-ares/c-ares/releases/latest');
if (!res.ok) throw new Error(`FetchError: ${res.status} ${res.statusText}`, { cause: res });
Expand All @@ -18,12 +21,8 @@ EOF

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

echo "Comparing $NEW_VERSION with $CURRENT_VERSION"

if [ "$NEW_VERSION" = "$CURRENT_VERSION" ]; then
echo "Skipped because c-ares is on the latest version."
exit 0
fi
# This function exit with 0 if new version and current version are the same
compare_dependency_version "c-ares" "$NEW_VERSION" "$CURRENT_VERSION"

echo "Making temporary workspace"

Expand Down Expand Up @@ -59,19 +58,7 @@ rm -rf "$DEPS_DIR/cares"
mv "$WORKSPACE/cares" "$DEPS_DIR/"

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

echo "All done!"
echo ""
echo "Please git add c-ares, commit the new version:"
echo ""
echo "$ git add -A deps/cares"
echo "$ git add doc/contributing/maintaining/maintaining-dependencies.md"
echo "$ git commit -m \"deps: update c-ares to $NEW_VERSION\""
echo ""

# The last line of the script should always print the new version,
# as we need to add it to $GITHUB_ENV variable.
echo "NEW_VERSION=$NEW_VERSION"
# Echo to commit the new version
finalize_version_update "c-ares" "$NEW_VERSION"
33 changes: 10 additions & 23 deletions tools/dep_updaters/update-cjs-module-lexer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ DEPS_DIR="$BASE_DIR/deps"

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

# shellcheck disable=SC1091
. "$BASE_DIR/tools/dep_updaters/utils.sh"

NEW_VERSION="$("$NODE" --input-type=module <<'EOF'
const res = await fetch('https://api.github.com/repos/nodejs/cjs-module-lexer/tags');
if (!res.ok) throw new Error(`FetchError: ${res.status} ${res.statusText}`, { cause: res });
Expand All @@ -21,12 +24,8 @@ EOF

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

echo "Comparing $NEW_VERSION with $CURRENT_VERSION"

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

echo "Making temporary workspace"

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

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

# Update the version number
# shellcheck disable=SC1091
. "$BASE_DIR/tools/dep_updaters/utils.sh"
update_dependency_version "cjs-module-lexer" "$NEW_VERSION"

echo "All done!"
echo ""
echo "Please git add cjs-module-lexer, commit the new version:"
echo ""
echo "$ git add -A deps/cjs-module-lexer"
echo "$ git add doc/contributing/maintaining/maintaining-dependencies.md"
echo "$ git commit -m \"deps: update cjs-module-lexer to $NEW_VERSION\""
echo ""

# update cjs_module_lexer_version.h
cat > "$BASE_DIR/src/cjs_module_lexer_version.h" << EOL
// This is an auto generated file, please do not edit.
Expand All @@ -74,6 +59,8 @@ cat > "$BASE_DIR/src/cjs_module_lexer_version.h" << EOL
#endif // SRC_CJS_MODULE_LEXER_VERSION_H_
EOL

# The last line of the script should always print the new version,
# as we need to add it to $GITHUB_ENV variable.
echo "NEW_VERSION=$NEW_VERSION"
# Update the version number
update_dependency_version "cjs-module-lexer" "$NEW_VERSION"

# Echo to commit the new version
finalize_version_update "cjs-module-lexer" "$NEW_VERSION"
11 changes: 5 additions & 6 deletions tools/dep_updaters/update-eslint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,14 @@ ROOT=$(cd "$(dirname "$0")/../.." && pwd)
[ -x "$NODE" ] || NODE=$(command -v node)
NPM="$ROOT/deps/npm/bin/npm-cli.js"

# shellcheck disable=SC1091
. "$ROOT/tools/dep_updaters/utils.sh"

NEW_VERSION=$("$NODE" "$NPM" view eslint dist-tags.latest)
CURRENT_VERSION=$("$NODE" -p "require('./tools/node_modules/eslint/package.json').version")

echo "Comparing $NEW_VERSION with $CURRENT_VERSION"

if [ "$NEW_VERSION" = "$CURRENT_VERSION" ]; then
echo "Skipped because ESlint is on the latest version."
exit 0
fi
# This function exit with 0 if new version and current version are the same
compare_dependency_version "eslint" "$NEW_VERSION" "$CURRENT_VERSION"

cd "$( dirname "$0" )" || exit
rm -rf ../node_modules/eslint
Expand Down
19 changes: 5 additions & 14 deletions tools/dep_updaters/update-googletest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ DEPS_DIR="$BASE_DIR/deps"
NEW_UPSTREAM_SHA1=$(git ls-remote "https://github.com/google/googletest.git" HEAD | awk '{print $1}')
NEW_VERSION=$(echo "$NEW_UPSTREAM_SHA1" | head -c 7)

# shellcheck disable=SC1091
. "$BASE_DIR/tools/dep_updaters/utils.sh"

echo "Comparing $NEW_VERSION with current revision"

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

# Update the version number
# shellcheck disable=SC1091
. "$BASE_DIR/tools/dep_updaters/utils.sh"
update_dependency_version "googletest" "$NEW_VERSION"

echo "All done!"
echo ""
echo "Please git stage googletest, commit the new version:"
echo ""
echo "$ git stage -A deps/googletest"
echo "$ git add doc/contributing/maintaining/maintaining-dependencies.md"
echo "$ git commit -m \"deps: update googletest to $NEW_VERSION\""
echo ""

# The last line of the script should always print the new version,
# as we need to add it to $GITHUB_ENV variable.
echo "NEW_VERSION=$NEW_VERSION"
# Echo to commit the new version
finalize_version_update "googletest" "$NEW_VERSION"
Loading

0 comments on commit ce7111a

Please sign in to comment.