Skip to content

Commit a749ced

Browse files
debadree25juanarbol
authored andcommitted
src: add undici and acorn to process.versions
Fixes: #45260 Refs: #45599 Refs: #45260 PR-URL: #45621 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Darshan Sen <raisinten@gmail.com>
1 parent 1e32520 commit a749ced

7 files changed

+72
-1
lines changed

src/acorn_version.h

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// This is an auto generated file, please do not edit.
2+
// Refer to tools/update-acorn.sh
3+
#ifndef SRC_ACORN_VERSION_H_
4+
#define SRC_ACORN_VERSION_H_
5+
#define ACORN_VERSION "8.8.1"
6+
#endif // SRC_ACORN_VERSION_H_

src/node_metadata.cc

+6
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
#include "node_metadata.h"
2+
#include "acorn_version.h"
23
#include "ares.h"
34
#include "brotli/encode.h"
45
#include "llhttp.h"
56
#include "nghttp2/nghttp2ver.h"
67
#include "node.h"
8+
#include "undici_version.h"
79
#include "util.h"
810
#include "uv.h"
911
#include "uvwasi.h"
@@ -90,6 +92,10 @@ Metadata::Versions::Versions() {
9092
std::to_string((BrotliEncoderVersion() & 0xFFF000) >> 12) +
9193
"." +
9294
std::to_string(BrotliEncoderVersion() & 0xFFF);
95+
#ifndef NODE_SHARED_BUILTIN_UNDICI_UNDICI_PATH
96+
undici = UNDICI_VERSION;
97+
#endif
98+
acorn = ACORN_VERSION;
9399

94100
uvwasi = UVWASI_VERSION_STRING;
95101

src/node_metadata.h

+9-1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,12 @@ namespace node {
2727
#define NODE_HAS_RELEASE_URLS
2828
#endif
2929

30+
#ifndef NODE_SHARED_BUILTIN_UNDICI_UNDICI_PATH
31+
#define NODE_VERSIONS_KEY_UNDICI(V) V(undici)
32+
#else
33+
#define NODE_VERSIONS_KEY_UNDICI(V)
34+
#endif
35+
3036
#define NODE_VERSIONS_KEYS_BASE(V) \
3137
V(node) \
3238
V(v8) \
@@ -38,7 +44,9 @@ namespace node {
3844
V(nghttp2) \
3945
V(napi) \
4046
V(llhttp) \
41-
V(uvwasi)
47+
V(uvwasi) \
48+
V(acorn) \
49+
NODE_VERSIONS_KEY_UNDICI(V)
4250

4351
#if HAVE_OPENSSL
4452
#define NODE_VERSIONS_KEY_CRYPTO(V) V(openssl)

src/undici_version.h

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// This is an auto generated file, please do not edit.
2+
// Refer to tools/update-undici.sh
3+
#ifndef SRC_UNDICI_VERSION_H_
4+
#define SRC_UNDICI_VERSION_H_
5+
#define UNDICI_VERSION "5.14.0"
6+
#endif // SRC_UNDICI_VERSION_H_

test/parallel/test-process-versions.js

+24
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
const common = require('../common');
33
const assert = require('assert');
44

5+
// Import of pure js (non-shared) deps for comparison
6+
const acorn = require('../../deps/acorn/acorn/package.json');
7+
58
const expected_keys = [
69
'ares',
710
'brotli',
@@ -14,8 +17,15 @@ const expected_keys = [
1417
'napi',
1518
'llhttp',
1619
'uvwasi',
20+
'acorn',
1721
];
1822

23+
const hasUndici = process.config.variables.node_builtin_shareable_builtins.includes('deps/undici/undici.js');
24+
25+
if (hasUndici) {
26+
expected_keys.push('undici');
27+
}
28+
1929
if (common.hasCrypto) {
2030
expected_keys.push('openssl');
2131
}
@@ -39,13 +49,18 @@ assert.deepStrictEqual(actual_keys, expected_keys);
3949

4050
const commonTemplate = /^\d+\.\d+\.\d+(?:-.*)?$/;
4151

52+
assert.match(process.versions.acorn, commonTemplate);
4253
assert.match(process.versions.ares, commonTemplate);
4354
assert.match(process.versions.brotli, commonTemplate);
4455
assert.match(process.versions.llhttp, commonTemplate);
4556
assert.match(process.versions.node, commonTemplate);
4657
assert.match(process.versions.uv, commonTemplate);
4758
assert.match(process.versions.zlib, commonTemplate);
4859

60+
if (hasUndici) {
61+
assert.match(process.versions.undici, commonTemplate);
62+
}
63+
4964
assert.match(
5065
process.versions.v8,
5166
/^\d+\.\d+\.\d+(?:\.\d+)?-node\.\d+(?: \(candidate\))?$/
@@ -70,3 +85,12 @@ for (let i = 0; i < expected_keys.length; i++) {
7085

7186
assert.strictEqual(process.config.variables.napi_build_version,
7287
process.versions.napi);
88+
89+
if (hasUndici) {
90+
const undici = require('../../deps/undici/src/package.json');
91+
const expectedUndiciVersion = undici.version;
92+
assert.strictEqual(process.versions.undici, expectedUndiciVersion);
93+
}
94+
95+
const expectedAcornVersion = acorn.version;
96+
assert.strictEqual(process.versions.acorn, expectedAcornVersion);

tools/update-acorn.sh

+11
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,17 @@ rm -rf deps/acorn/acorn
2323
"$NODE" "$NPM" init --yes
2424

2525
"$NODE" "$NPM" install --global-style --no-bin-links --ignore-scripts acorn
26+
cd node_modules/acorn
27+
# get acorn version
28+
ACORN_VERSION=$("$NODE" -p "require('./package.json').version")
29+
# update this version information in src/acorn_version.h
30+
FILE_PATH="$ROOT/src/acorn_version.h"
31+
echo "// This is an auto generated file, please do not edit." > "$FILE_PATH"
32+
echo "// Refer to tools/update-acorn.sh" >> "$FILE_PATH"
33+
echo "#ifndef SRC_ACORN_VERSION_H_" >> "$FILE_PATH"
34+
echo "#define SRC_ACORN_VERSION_H_" >> "$FILE_PATH"
35+
echo "#define ACORN_VERSION \"$ACORN_VERSION\"" >> "$FILE_PATH"
36+
echo "#endif // SRC_ACORN_VERSION_H_" >> "$FILE_PATH"
2637
)
2738

2839
mv acorn-tmp/node_modules/acorn deps/acorn

tools/update-undici.sh

+10
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,16 @@ rm -f deps/undici/undici.js
2626
"$NODE" "$NPM" install --global-style --no-bin-links --ignore-scripts undici
2727
cd node_modules/undici
2828
"$NODE" "$NPM" run build:node
29+
# get the new version of undici
30+
UNDICI_VERSION=$("$NODE" -p "require('./package.json').version")
31+
# update this version information in src/undici_version.h
32+
FILE_PATH="$ROOT/src/undici_version.h"
33+
echo "// This is an auto generated file, please do not edit." > "$FILE_PATH"
34+
echo "// Refer to tools/update-undici.sh" >> "$FILE_PATH"
35+
echo "#ifndef SRC_ACORN_VERSION_H_" >> "$FILE_PATH"
36+
echo "#define SRC_ACORN_VERSION_H_" >> "$FILE_PATH"
37+
echo "#define UNDICI_VERSION \"$UNDICI_VERSION\"" >> "$FILE_PATH"
38+
echo "#endif // SRC_ACORN_VERSION_H_" >> "$FILE_PATH"
2939
)
3040

3141
mv undici-tmp/node_modules/undici deps/undici/src

0 commit comments

Comments
 (0)