Skip to content

Commit e696a48

Browse files
marco-ippolitoMoLow
authored andcommitted
tools: move update-undici.sh to dep_updaters and create maintain md
PR-URL: nodejs#47380 Refs: nodejs/security-wg#828 Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Paolo Insogna <paolo@cowtech.it> Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
1 parent b019637 commit e696a48

File tree

6 files changed

+56
-20
lines changed

6 files changed

+56
-20
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
+3-4
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
@@ -10,17 +10,16 @@ brotli source files.
1010

1111
Check that Node.js still builds and tests.
1212

13-
## Committing postject
13+
## Committing brotli
1414

1515
1. Add brotli:
1616
```console
1717
$ git add deps/brotli
1818
```
1919
2. Commit the changes: `git commit`.
2020
3. Add a message like:
21-
2221
```text
23-
deps,test: update brotli to <version>
22+
deps: update brotli to <version>
2423
2524
Updated as described in doc/contributing/maintaining-brotli.md.
2625
```

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

doc/contributing/maintaining-postject.md

-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ Check that Node.js still builds and tests.
1919
```
2020
2. Commit the changes: `git commit`.
2121
3. Add a message like:
22-
2322
```text
2423
deps,test: update postject to <version>
2524
+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
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 undici
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+
```text
22+
deps: update undici to <version>
23+
24+
Updated as described in doc/contributing/maintaining-undici.md.
25+
```

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

+21-9
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,22 @@
77

88
set -ex
99

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

@@ -16,25 +31,18 @@ rm -f deps/undici/undici.js
1631
mkdir undici-tmp
1732
cd undici-tmp || exit
1833

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-
2434
"$NODE" "$NPM" init --yes
2535

2636
"$NODE" "$NPM" install --global-style --no-bin-links --ignore-scripts undici
2737
cd node_modules/undici
2838
"$NODE" "$NPM" run build:node
29-
# get the new version of undici
30-
UNDICI_VERSION=$("$NODE" -p "require('./package.json').version")
3139
# update this version information in src/undici_version.h
3240
FILE_PATH="$ROOT/src/undici_version.h"
3341
echo "// This is an auto generated file, please do not edit." > "$FILE_PATH"
3442
echo "// Refer to tools/update-undici.sh" >> "$FILE_PATH"
3543
echo "#ifndef SRC_UNDICI_VERSION_H_" >> "$FILE_PATH"
3644
echo "#define SRC_UNDICI_VERSION_H_" >> "$FILE_PATH"
37-
echo "#define UNDICI_VERSION \"$UNDICI_VERSION\"" >> "$FILE_PATH"
45+
echo "#define UNDICI_VERSION \"$NEW_VERSION\"" >> "$FILE_PATH"
3846
echo "#endif // SRC_UNDICI_VERSION_H_" >> "$FILE_PATH"
3947
)
4048

@@ -43,3 +51,7 @@ mv deps/undici/src/undici-fetch.js deps/undici/undici.js
4351
cp deps/undici/src/LICENSE deps/undici/LICENSE
4452

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

0 commit comments

Comments
 (0)