summaryrefslogtreecommitdiff
path: root/tools/dep_updaters
diff options
context:
space:
mode:
authorTony Gorez <gorez.tony@gmail.com>2023-03-02 13:10:59 +0100
committerGitHub <noreply@github.com>2023-03-02 12:10:59 +0000
commitac6ceff6100ca45b22e6ab9a36bf0798ed398277 (patch)
treea7307ecfe3e539829247ed10bba6692e4f66e7e9 /tools/dep_updaters
parent024e648d905dcc120741530042810352508d2583 (diff)
downloadnode-new-ac6ceff6100ca45b22e6ab9a36bf0798ed398277.tar.gz
tools: refactor dep_updaters
PR-URL: https://github.com/nodejs/node/pull/46488 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Darshan Sen <raisinten@gmail.com>
Diffstat (limited to 'tools/dep_updaters')
-rwxr-xr-xtools/dep_updaters/update-eslint.sh23
-rwxr-xr-xtools/dep_updaters/update-libuv.sh35
-rwxr-xr-xtools/dep_updaters/update-postject.sh22
-rwxr-xr-xtools/dep_updaters/update-simdutf.sh29
4 files changed, 84 insertions, 25 deletions
diff --git a/tools/dep_updaters/update-eslint.sh b/tools/dep_updaters/update-eslint.sh
index 7d536ef502..b3025bb8ff 100755
--- a/tools/dep_updaters/update-eslint.sh
+++ b/tools/dep_updaters/update-eslint.sh
@@ -7,6 +7,20 @@
set -ex
+ROOT=$(cd "$(dirname "$0")/../.." && pwd)
+
+[ -z "$NODE" ] && NODE="$ROOT/out/Release/node"
+[ -x "$NODE" ] || NODE=$(command -v node)
+NPM="$ROOT/deps/npm/bin/npm-cli.js"
+
+NEW_VERSION=$("$NODE" "$NPM" view eslint dist-tags.latest)
+CURRENT_VERSION=$("$NODE" -p "require('./tools/node_modules/eslint/package.json').version")
+
+if [ "$NEW_VERSION" = "$CURRENT_VERSION" ]; then
+ echo "Skipped because ESlint is on the latest version."
+ exit 0
+fi
+
cd "$( dirname "$0" )" || exit
rm -rf ../node_modules/eslint
(
@@ -14,11 +28,6 @@ rm -rf ../node_modules/eslint
mkdir eslint-tmp
cd eslint-tmp || exit
- ROOT="$PWD/../../.."
- [ -z "$NODE" ] && NODE="$ROOT/out/Release/node"
- [ -x "$NODE" ] || NODE=$(command -v node)
- NPM="$ROOT/deps/npm/bin/npm-cli.js"
-
"$NODE" "$NPM" init --yes
"$NODE" "$NPM" install \
@@ -63,3 +72,7 @@ rm -rf ../node_modules/eslint
mv eslint-tmp/node_modules/eslint ../node_modules/eslint
rm -rf eslint-tmp/
+
+# 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"
diff --git a/tools/dep_updaters/update-libuv.sh b/tools/dep_updaters/update-libuv.sh
index ae7fe9a76c..a7ab4de930 100755
--- a/tools/dep_updaters/update-libuv.sh
+++ b/tools/dep_updaters/update-libuv.sh
@@ -4,12 +4,29 @@ set -e
BASE_DIR=$(cd "$(dirname "$0")/../.." && pwd)
DEPS_DIR="$BASE_DIR/deps"
-LIBUV_VERSION=$1
+[ -z "$NODE" ] && NODE="$BASE_DIR/out/Release/node"
+[ -x "$NODE" ] || NODE=$(command -v node)
-if [ "$#" -le 0 ]; then
- echo "Error: please provide an libuv version to update to"
- echo " e.g. $0 1.44.2"
- exit 1
+NEW_VERSION="$("$NODE" --input-type=module <<'EOF'
+const res = await fetch('https://api.github.com/repos/libuv/libuv/releases/latest');
+if (!res.ok) throw new Error(`FetchError: ${res.status} ${res.statusText}`, { cause: res });
+const { tag_name } = await res.json();
+console.log(tag_name.replace('v', ''));
+EOF
+)"
+
+VERSION_H="$DEPS_DIR/uv/include/uv/version.h"
+CURRENT_MAJOR_VERSION=$(grep "#define UV_VERSION_MAJOR" "$VERSION_H" | sed -n "s/^.*MAJOR \(.*\)/\1/p")
+CURRENT_MINOR_VERSION=$(grep "#define UV_VERSION_MINOR" "$VERSION_H" | sed -n "s/^.*MINOR \(.*\)/\1/p")
+CURRENT_PATCH_VERSION=$(grep "#define UV_VERSION_PATCH" "$VERSION_H" | sed -n "s/^.*PATCH \(.*\)/\1/p")
+CURRENT_IS_RELEASE=$(grep "#define UV_VERSION_IS_RELEASE" "$VERSION_H" | sed -n "s/^.*RELEASE \(.*\)/\1/p")
+CURRENT_SUFFIX_VERSION=$(grep "#define UV_VERSION_SUFFIX" "$VERSION_H" | sed -n "s/^.*SUFFIX \"\(.*\)\"/\1/p")
+SUFFIX_STRING=$([ "$CURRENT_IS_RELEASE" = 1 ] || [ -z "$CURRENT_SUFFIX_VERSION" ] && echo "" || echo "-$CURRENT_SUFFIX_VERSION")
+CURRENT_VERSION="$CURRENT_MAJOR_VERSION.$CURRENT_MINOR_VERSION.$CURRENT_PATCH_VERSION$SUFFIX_STRING"
+
+if [ "$NEW_VERSION" = "$CURRENT_VERSION" ]; then
+ echo "Skipped because libuv is on the latest version."
+ exit 0
fi
echo "Making temporary workspace..."
@@ -27,7 +44,7 @@ trap cleanup INT TERM EXIT
cd "$WORKSPACE"
echo "Fetching libuv source archive..."
-curl -sL "https://api.github.com/repos/libuv/libuv/tarball/v$LIBUV_VERSION" | tar xzf -
+curl -sL "https://api.github.com/repos/libuv/libuv/tarball/v$NEW_VERSION" | tar xzf -
mv libuv-libuv-* uv
echo "Replacing existing libuv (except GYP build files)"
@@ -40,5 +57,9 @@ echo ""
echo "Please git add uv, commit the new version:"
echo ""
echo "$ git add -A deps/uv"
-echo "$ git commit -m \"deps: update libuv to $LIBUV_VERSION\""
+echo "$ git commit -m \"deps: update libuv 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"
diff --git a/tools/dep_updaters/update-postject.sh b/tools/dep_updaters/update-postject.sh
index 66b207f966..f7a63ce181 100755
--- a/tools/dep_updaters/update-postject.sh
+++ b/tools/dep_updaters/update-postject.sh
@@ -7,16 +7,24 @@
set -ex
+ROOT=$(cd "$(dirname "$0")/../.." && pwd)
+[ -z "$NODE" ] && NODE="$ROOT/out/Release/node"
+[ -x "$NODE" ] || NODE=$(command -v node)
+NPM="$ROOT/deps/npm/bin/npm-cli.js"
+
+NEW_VERSION=$("$NODE" "$NPM" view postject dist-tags.latest)
+CURRENT_VERSION=$("$NODE" -p "require('./test/fixtures/postject-copy/node_modules/postject/package.json').version")
+
+if [ "$NEW_VERSION" = "$CURRENT_VERSION" ]; then
+ echo "Skipped because Postject is on the latest version."
+ exit 0
+fi
+
cd "$( dirname "$0" )/../.." || exit
rm -rf test/fixtures/postject-copy
mkdir test/fixtures/postject-copy
cd test/fixtures/postject-copy || exit
-ROOT="$PWD/../../.."
-[ -z "$NODE" ] && NODE="$ROOT/out/Release/node"
-[ -x "$NODE" ] || NODE=$(command -v node)
-NPM="$ROOT/deps/npm/bin/npm-cli.js"
-
"$NODE" "$NPM" init --yes
"$NODE" "$NPM" install --no-bin-links --ignore-scripts postject
@@ -27,3 +35,7 @@ rm -rf deps/postject
mkdir deps/postject
cp test/fixtures/postject-copy/node_modules/postject/LICENSE deps/postject
cp test/fixtures/postject-copy/node_modules/postject/dist/postject-api.h deps/postject
+
+# 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"
diff --git a/tools/dep_updaters/update-simdutf.sh b/tools/dep_updaters/update-simdutf.sh
index d502558b47..d9e97cb21e 100755
--- a/tools/dep_updaters/update-simdutf.sh
+++ b/tools/dep_updaters/update-simdutf.sh
@@ -4,12 +4,21 @@ set -e
BASE_DIR=$(cd "$(dirname "$0")/../.." && pwd)
DEPS_DIR="$BASE_DIR/deps"
-SIMDUTF_VERSION=$1
+[ -z "$NODE" ] && NODE="$BASE_DIR/out/Release/node"
+[ -x "$NODE" ] || NODE=$(command -v node)
-if [ "$#" -le 0 ]; then
- echo "Error: please provide an simdutf version to update to"
- echo " e.g. $0 2.0.3"
- exit 1
+NEW_VERSION="$("$NODE" --input-type=module <<'EOF'
+const res = await fetch('https://api.github.com/repos/simdutf/simdutf/releases/latest');
+if (!res.ok) throw new Error(`FetchError: ${res.status} ${res.statusText}`, { cause: res });
+const { tag_name } = await res.json();
+console.log(tag_name.replace('v', ''));
+EOF
+)"
+CURRENT_VERSION=$(grep "#define SIMDUTF_VERSION" "$DEPS_DIR/simdutf/simdutf.h" | sed -n "s/^.*VERSION \"\(.*\)\"/\1/p")
+
+if [ "$NEW_VERSION" = "$CURRENT_VERSION" ]; then
+ echo "Skipped because simdutf is on the latest version."
+ exit 0
fi
echo "Making temporary workspace..."
@@ -24,8 +33,8 @@ cleanup () {
trap cleanup INT TERM EXIT
-SIMDUTF_REF="v$SIMDUTF_VERSION"
-SIMDUTF_ZIP="simdutf-$SIMDUTF_VERSION.zip"
+SIMDUTF_REF="v$NEW_VERSION"
+SIMDUTF_ZIP="simdutf-$NEW_VERSION.zip"
SIMDUTF_LICENSE="LICENSE-MIT"
cd "$WORKSPACE"
@@ -48,5 +57,9 @@ echo ""
echo "Please git add simdutf, commit the new version:"
echo ""
echo "$ git add -A deps/simdutf"
-echo "$ git commit -m \"deps: update simdutf to $SIMDUTF_VERSION\""
+echo "$ git commit -m \"deps: update simdutf 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"