Skip to content

Commit 3fb789c

Browse files
tools: maintaining undici
1 parent 7b57b55 commit 3fb789c

File tree

5 files changed

+55
-19
lines changed

5 files changed

+55
-19
lines changed

.github/workflows/tools.yml

+4-6
Original file line numberDiff line numberDiff line change
@@ -69,12 +69,10 @@ jobs:
6969
subsystem: deps
7070
label: dependencies
7171
run: |
72-
NEW_VERSION=$(npm view undici dist-tags.latest)
73-
CURRENT_VERSION=$(node -p "require('./deps/undici/src/package.json').version")
74-
if [ "$NEW_VERSION" != "$CURRENT_VERSION" ]; then
75-
echo "NEW_VERSION=$NEW_VERSION" >> $GITHUB_ENV
76-
./tools/update-undici.sh
77-
fi
72+
./tools/dep_updaters/update-undici.sh > temp-output
73+
cat temp-output
74+
tail -n1 temp-output | grep "NEW_VERSION=" >> "$GITHUB_ENV" || true
75+
rm temp-output
7876
- id: postject
7977
subsystem: deps,test
8078
label: test

doc/contributing/maintaining-brotli.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Maintaining brotli
22

3-
The [brotli](https://github.com/google/brotli) dependency is used for
3+
The [brotli](https://github.com/google/brotli) dependency is used for
44
the homonym generic-purpose lossless compression algorithm.
55

66
## Updating brotli

doc/contributing/maintaining-http.md

+3
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ more control is required. The current plan is for the following APIs:
6262
Fetch-based API. As this gets worked out we will discuss which
6363
APIs to expose in the Node.js API surface.
6464

65+
For info see [maintaining undici][].
66+
6567
### Server APIs
6668

6769
For the server APIs we do not yet have a clear path, other than wanting
@@ -116,3 +118,4 @@ The low-level implementation of
116118
is based on [nghttp2](https://nghttp2.org/). See [maintaining nghttp2][].
117119

118120
[maintaining nghttp2]: ./maintaining-nghttp2.md
121+
[maintaining undici]: ./maintaining-undici.md
+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Maintaining undici
2+
3+
The [undici](https://github.com/nodejs/undici) dependency is
4+
an HTTP/1.1 client, written from scratch for Node.js.
5+
6+
## Updating undici
7+
8+
The `tools/dep_updaters/update-undici.sh` script automates the update of the
9+
undici source files.
10+
11+
Check that Node.js still builds and tests.
12+
13+
## Committing postject
14+
15+
1. Add undici:
16+
```console
17+
$ git add deps/undici
18+
```
19+
2. Commit the changes: `git commit`.
20+
3. Add a message like:
21+
22+
```text
23+
deps,test: update undici to <version>
24+
25+
Updated as described in doc/contributing/maintaining-undici.md.
26+
```

tools/update-undici.sh tools/dep_updaters/update-undici.sh

+21-12
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,24 @@
22

33
# Shell script to update undici in the source tree to the latest release.
44

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-
85
set -ex
96

10-
cd "$( dirname "$0" )/.." || exit
7+
ROOT=$(cd "$(dirname "$0")/../.." && pwd)
8+
[ -z "$NODE" ] && NODE="$ROOT/out/Release/node"
9+
[ -x "$NODE" ] || NODE=$(command -v node)
10+
NPM="$ROOT/deps/npm/bin/npm-cli.js"
11+
12+
NEW_VERSION=$("$NODE" "$NPM" view undici dist-tags.latest)
13+
CURRENT_VERSION=$("$NODE" -p "require('./deps/undici/src/package.json').version")
14+
15+
echo "Comparing $NEW_VERSION with $CURRENT_VERSION"
16+
17+
if [ "$NEW_VERSION" = "$CURRENT_VERSION" ]; then
18+
echo "Skipped because Undici is on the latest version."
19+
exit 0
20+
fi
21+
22+
cd "$( dirname "$0" )/../.." || exit
1123
rm -rf deps/undici/src
1224
rm -f deps/undici/undici.js
1325

@@ -16,25 +28,18 @@ rm -f deps/undici/undici.js
1628
mkdir undici-tmp
1729
cd undici-tmp || exit
1830

19-
ROOT="$PWD/.."
20-
[ -z "$NODE" ] && NODE="$ROOT/out/Release/node"
21-
[ -x "$NODE" ] || NODE=$(command -v node)
22-
NPM="$ROOT/deps/npm/bin/npm-cli.js"
23-
2431
"$NODE" "$NPM" init --yes
2532

2633
"$NODE" "$NPM" install --global-style --no-bin-links --ignore-scripts undici
2734
cd node_modules/undici
2835
"$NODE" "$NPM" run build:node
29-
# get the new version of undici
30-
UNDICI_VERSION=$("$NODE" -p "require('./package.json').version")
3136
# update this version information in src/undici_version.h
3237
FILE_PATH="$ROOT/src/undici_version.h"
3338
echo "// This is an auto generated file, please do not edit." > "$FILE_PATH"
3439
echo "// Refer to tools/update-undici.sh" >> "$FILE_PATH"
3540
echo "#ifndef SRC_UNDICI_VERSION_H_" >> "$FILE_PATH"
3641
echo "#define SRC_UNDICI_VERSION_H_" >> "$FILE_PATH"
37-
echo "#define UNDICI_VERSION \"$UNDICI_VERSION\"" >> "$FILE_PATH"
42+
echo "#define UNDICI_VERSION \"$NEW_VERSION\"" >> "$FILE_PATH"
3843
echo "#endif // SRC_UNDICI_VERSION_H_" >> "$FILE_PATH"
3944
)
4045

@@ -43,3 +48,7 @@ mv deps/undici/src/undici-fetch.js deps/undici/undici.js
4348
cp deps/undici/src/LICENSE deps/undici/LICENSE
4449

4550
rm -rf undici-tmp/
51+
52+
# The last line of the script should always print the new version,
53+
# as we need to add it to $GITHUB_ENV variable.
54+
echo "NEW_VERSION=$NEW_VERSION"

0 commit comments

Comments
 (0)