diff --git a/.github/workflows/tools.yml b/.github/workflows/tools.yml index b8706753f3965d..c04b190d25a167 100644 --- a/.github/workflows/tools.yml +++ b/.github/workflows/tools.yml @@ -69,12 +69,10 @@ jobs: subsystem: deps label: dependencies run: | - NEW_VERSION=$(npm view undici dist-tags.latest) - CURRENT_VERSION=$(node -p "require('./deps/undici/src/package.json').version") - if [ "$NEW_VERSION" != "$CURRENT_VERSION" ]; then - echo "NEW_VERSION=$NEW_VERSION" >> $GITHUB_ENV - ./tools/update-undici.sh - fi + ./tools/dep_updaters/update-undici.sh > temp-output + cat temp-output + tail -n1 temp-output | grep "NEW_VERSION=" >> "$GITHUB_ENV" || true + rm temp-output - id: postject subsystem: deps,test label: test diff --git a/doc/contributing/maintaining-brotli.md b/doc/contributing/maintaining-brotli.md index e8b0ddbe97e3c0..d2d725d161d041 100644 --- a/doc/contributing/maintaining-brotli.md +++ b/doc/contributing/maintaining-brotli.md @@ -1,6 +1,6 @@ # Maintaining brotli -The [brotli](https://github.com/google/brotli) dependency is used for +The [brotli](https://github.com/google/brotli) dependency is used for the homonym generic-purpose lossless compression algorithm. ## Updating brotli @@ -10,7 +10,7 @@ brotli source files. Check that Node.js still builds and tests. -## Committing postject +## Committing brotli 1. Add brotli: ```console @@ -18,9 +18,8 @@ Check that Node.js still builds and tests. ``` 2. Commit the changes: `git commit`. 3. Add a message like: - ```text - deps,test: update brotli to + deps: update brotli to Updated as described in doc/contributing/maintaining-brotli.md. ``` diff --git a/doc/contributing/maintaining-http.md b/doc/contributing/maintaining-http.md index 88d6fdb6ee55e5..3735c82e7b5393 100644 --- a/doc/contributing/maintaining-http.md +++ b/doc/contributing/maintaining-http.md @@ -62,6 +62,8 @@ more control is required. The current plan is for the following APIs: Fetch-based API. As this gets worked out we will discuss which APIs to expose in the Node.js API surface. +For info see [maintaining undici][]. + ### Server APIs For the server APIs we do not yet have a clear path, other than wanting @@ -116,3 +118,4 @@ The low-level implementation of is based on [nghttp2](https://nghttp2.org/). See [maintaining nghttp2][]. [maintaining nghttp2]: ./maintaining-nghttp2.md +[maintaining undici]: ./maintaining-undici.md diff --git a/doc/contributing/maintaining-postject.md b/doc/contributing/maintaining-postject.md index 22f454fa2a545b..9f1bef0d776a4b 100644 --- a/doc/contributing/maintaining-postject.md +++ b/doc/contributing/maintaining-postject.md @@ -19,7 +19,6 @@ Check that Node.js still builds and tests. ``` 2. Commit the changes: `git commit`. 3. Add a message like: - ```text deps,test: update postject to diff --git a/doc/contributing/maintaining-undici.md b/doc/contributing/maintaining-undici.md new file mode 100644 index 00000000000000..0ebae05f4d03ae --- /dev/null +++ b/doc/contributing/maintaining-undici.md @@ -0,0 +1,25 @@ +# Maintaining undici + +The [undici](https://github.com/nodejs/undici) dependency is +an HTTP/1.1 client, written from scratch for Node.js. + +## Updating undici + +The `tools/dep_updaters/update-undici.sh` script automates the update of the +undici source files. + +Check that Node.js still builds and tests. + +## Committing undici + +1. Add undici: + ```console + $ git add deps/undici + ``` +2. Commit the changes: `git commit`. +3. Add a message like: + ```text + deps: update undici to + + Updated as described in doc/contributing/maintaining-undici.md. + ``` diff --git a/tools/update-undici.sh b/tools/dep_updaters/update-undici.sh similarity index 60% rename from tools/update-undici.sh rename to tools/dep_updaters/update-undici.sh index ead449bcd1185f..68b16b90873a23 100755 --- a/tools/update-undici.sh +++ b/tools/dep_updaters/update-undici.sh @@ -7,7 +7,22 @@ set -ex -cd "$( dirname "$0" )/.." || exit +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 undici dist-tags.latest) +CURRENT_VERSION=$("$NODE" -p "require('./deps/undici/src/package.json').version") + +echo "Comparing $NEW_VERSION with $CURRENT_VERSION" + +if [ "$NEW_VERSION" = "$CURRENT_VERSION" ]; then + echo "Skipped because Undici is on the latest version." + exit 0 +fi + +cd "$( dirname "$0" )/../.." || exit rm -rf deps/undici/src rm -f deps/undici/undici.js @@ -16,25 +31,18 @@ rm -f deps/undici/undici.js mkdir undici-tmp cd undici-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 --global-style --no-bin-links --ignore-scripts undici cd node_modules/undici "$NODE" "$NPM" run build:node - # get the new version of undici - UNDICI_VERSION=$("$NODE" -p "require('./package.json').version") # update this version information in src/undici_version.h FILE_PATH="$ROOT/src/undici_version.h" echo "// This is an auto generated file, please do not edit." > "$FILE_PATH" echo "// Refer to tools/update-undici.sh" >> "$FILE_PATH" echo "#ifndef SRC_UNDICI_VERSION_H_" >> "$FILE_PATH" echo "#define SRC_UNDICI_VERSION_H_" >> "$FILE_PATH" - echo "#define UNDICI_VERSION \"$UNDICI_VERSION\"" >> "$FILE_PATH" + echo "#define UNDICI_VERSION \"$NEW_VERSION\"" >> "$FILE_PATH" echo "#endif // SRC_UNDICI_VERSION_H_" >> "$FILE_PATH" ) @@ -43,3 +51,7 @@ mv deps/undici/src/undici-fetch.js deps/undici/undici.js cp deps/undici/src/LICENSE deps/undici/LICENSE rm -rf undici-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"