Skip to content

Commit

Permalink
src: add undici and acorn to process.versions
Browse files Browse the repository at this point in the history
Fixes: #45260
Refs: #45599
Refs: #45260
PR-URL: #45621
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Antoine du Hamel <[email protected]>
Reviewed-By: Joyee Cheung <[email protected]>
Reviewed-By: Darshan Sen <[email protected]>
  • Loading branch information
debadree25 authored and targos committed Jan 1, 2023
1 parent ff14282 commit a482d8f
Show file tree
Hide file tree
Showing 7 changed files with 72 additions and 1 deletion.
6 changes: 6 additions & 0 deletions src/acorn_version.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// This is an auto generated file, please do not edit.
// Refer to tools/update-acorn.sh
#ifndef SRC_ACORN_VERSION_H_
#define SRC_ACORN_VERSION_H_
#define ACORN_VERSION "8.8.1"
#endif // SRC_ACORN_VERSION_H_
6 changes: 6 additions & 0 deletions src/node_metadata.cc
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
#include "node_metadata.h"
#include "acorn_version.h"
#include "ares.h"
#include "brotli/encode.h"
#include "llhttp.h"
#include "nghttp2/nghttp2ver.h"
#include "node.h"
#include "undici_version.h"
#include "util.h"
#include "uv.h"
#include "uvwasi.h"
Expand Down Expand Up @@ -90,6 +92,10 @@ Metadata::Versions::Versions() {
std::to_string((BrotliEncoderVersion() & 0xFFF000) >> 12) +
"." +
std::to_string(BrotliEncoderVersion() & 0xFFF);
#ifndef NODE_SHARED_BUILTIN_UNDICI_UNDICI_PATH
undici = UNDICI_VERSION;
#endif
acorn = ACORN_VERSION;

uvwasi = UVWASI_VERSION_STRING;

Expand Down
10 changes: 9 additions & 1 deletion src/node_metadata.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@ namespace node {
#define NODE_HAS_RELEASE_URLS
#endif

#ifndef NODE_SHARED_BUILTIN_UNDICI_UNDICI_PATH
#define NODE_VERSIONS_KEY_UNDICI(V) V(undici)
#else
#define NODE_VERSIONS_KEY_UNDICI(V)
#endif

#define NODE_VERSIONS_KEYS_BASE(V) \
V(node) \
V(v8) \
Expand All @@ -38,7 +44,9 @@ namespace node {
V(nghttp2) \
V(napi) \
V(llhttp) \
V(uvwasi)
V(uvwasi) \
V(acorn) \
NODE_VERSIONS_KEY_UNDICI(V)

#if HAVE_OPENSSL
#define NODE_VERSIONS_KEY_CRYPTO(V) V(openssl)
Expand Down
6 changes: 6 additions & 0 deletions src/undici_version.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// This is an auto generated file, please do not edit.
// Refer to tools/update-undici.sh
#ifndef SRC_UNDICI_VERSION_H_
#define SRC_UNDICI_VERSION_H_
#define UNDICI_VERSION "5.14.0"
#endif // SRC_UNDICI_VERSION_H_
24 changes: 24 additions & 0 deletions test/parallel/test-process-versions.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
const common = require('../common');
const assert = require('assert');

// Import of pure js (non-shared) deps for comparison
const acorn = require('../../deps/acorn/acorn/package.json');

const expected_keys = [
'ares',
'brotli',
Expand All @@ -14,8 +17,15 @@ const expected_keys = [
'napi',
'llhttp',
'uvwasi',
'acorn',
];

const hasUndici = process.config.variables.node_builtin_shareable_builtins.includes('deps/undici/undici.js');

if (hasUndici) {
expected_keys.push('undici');
}

if (common.hasCrypto) {
expected_keys.push('openssl');
}
Expand All @@ -39,13 +49,18 @@ assert.deepStrictEqual(actual_keys, expected_keys);

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

assert.match(process.versions.acorn, commonTemplate);
assert.match(process.versions.ares, commonTemplate);
assert.match(process.versions.brotli, commonTemplate);
assert.match(process.versions.llhttp, commonTemplate);
assert.match(process.versions.node, commonTemplate);
assert.match(process.versions.uv, commonTemplate);
assert.match(process.versions.zlib, commonTemplate);

if (hasUndici) {
assert.match(process.versions.undici, commonTemplate);
}

assert.match(
process.versions.v8,
/^\d+\.\d+\.\d+(?:\.\d+)?-node\.\d+(?: \(candidate\))?$/
Expand All @@ -70,3 +85,12 @@ for (let i = 0; i < expected_keys.length; i++) {

assert.strictEqual(process.config.variables.napi_build_version,
process.versions.napi);

if (hasUndici) {
const undici = require('../../deps/undici/src/package.json');
const expectedUndiciVersion = undici.version;
assert.strictEqual(process.versions.undici, expectedUndiciVersion);
}

const expectedAcornVersion = acorn.version;
assert.strictEqual(process.versions.acorn, expectedAcornVersion);
11 changes: 11 additions & 0 deletions tools/update-acorn.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,17 @@ rm -rf deps/acorn/acorn
"$NODE" "$NPM" init --yes

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

mv acorn-tmp/node_modules/acorn deps/acorn
Expand Down
10 changes: 10 additions & 0 deletions tools/update-undici.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,16 @@ rm -f deps/undici/undici.js
"$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_ACORN_VERSION_H_" >> "$FILE_PATH"
echo "#define SRC_ACORN_VERSION_H_" >> "$FILE_PATH"
echo "#define UNDICI_VERSION \"$UNDICI_VERSION\"" >> "$FILE_PATH"
echo "#endif // SRC_ACORN_VERSION_H_" >> "$FILE_PATH"
)

mv undici-tmp/node_modules/undici deps/undici/src
Expand Down

0 comments on commit a482d8f

Please sign in to comment.