11cb0ef41Sopenharmony_ci'use strict';
21cb0ef41Sopenharmony_ciconst common = require('../common');
31cb0ef41Sopenharmony_ciconst assert = require('assert');
41cb0ef41Sopenharmony_ci
51cb0ef41Sopenharmony_ci// Import of pure js (non-shared) deps for comparison
61cb0ef41Sopenharmony_ciconst acorn = require('../../deps/acorn/acorn/package.json');
71cb0ef41Sopenharmony_ciconst cjs_module_lexer = require('../../deps/cjs-module-lexer/package.json');
81cb0ef41Sopenharmony_ci
91cb0ef41Sopenharmony_ciconst expected_keys = [
101cb0ef41Sopenharmony_ci  'ares',
111cb0ef41Sopenharmony_ci  'brotli',
121cb0ef41Sopenharmony_ci  'modules',
131cb0ef41Sopenharmony_ci  'uv',
141cb0ef41Sopenharmony_ci  'v8',
151cb0ef41Sopenharmony_ci  'zlib',
161cb0ef41Sopenharmony_ci  'nghttp2',
171cb0ef41Sopenharmony_ci  'napi',
181cb0ef41Sopenharmony_ci  'llhttp',
191cb0ef41Sopenharmony_ci  'uvwasi',
201cb0ef41Sopenharmony_ci  'acorn',
211cb0ef41Sopenharmony_ci  'simdutf',
221cb0ef41Sopenharmony_ci  'ada',
231cb0ef41Sopenharmony_ci  'cjs_module_lexer',
241cb0ef41Sopenharmony_ci  'base64',
251cb0ef41Sopenharmony_ci];
261cb0ef41Sopenharmony_ci
271cb0ef41Sopenharmony_ciconst hasUndici = process.config.variables.node_builtin_shareable_builtins.includes('deps/undici/undici.js');
281cb0ef41Sopenharmony_ci
291cb0ef41Sopenharmony_ciif (hasUndici) {
301cb0ef41Sopenharmony_ci  expected_keys.push('undici');
311cb0ef41Sopenharmony_ci}
321cb0ef41Sopenharmony_ci
331cb0ef41Sopenharmony_ciif (common.hasCrypto) {
341cb0ef41Sopenharmony_ci  expected_keys.push('openssl');
351cb0ef41Sopenharmony_ci}
361cb0ef41Sopenharmony_ci
371cb0ef41Sopenharmony_ciif (common.hasQuic) {
381cb0ef41Sopenharmony_ci  expected_keys.push('ngtcp2');
391cb0ef41Sopenharmony_ci  expected_keys.push('nghttp3');
401cb0ef41Sopenharmony_ci}
411cb0ef41Sopenharmony_ci
421cb0ef41Sopenharmony_ciif (common.hasIntl) {
431cb0ef41Sopenharmony_ci  expected_keys.push('icu');
441cb0ef41Sopenharmony_ci  expected_keys.push('cldr');
451cb0ef41Sopenharmony_ci  expected_keys.push('tz');
461cb0ef41Sopenharmony_ci  expected_keys.push('unicode');
471cb0ef41Sopenharmony_ci}
481cb0ef41Sopenharmony_ci
491cb0ef41Sopenharmony_ciexpected_keys.sort();
501cb0ef41Sopenharmony_ciexpected_keys.unshift('node');
511cb0ef41Sopenharmony_ci
521cb0ef41Sopenharmony_ciconst actual_keys = Object.keys(process.versions);
531cb0ef41Sopenharmony_ci
541cb0ef41Sopenharmony_ciassert.deepStrictEqual(actual_keys, expected_keys);
551cb0ef41Sopenharmony_ci
561cb0ef41Sopenharmony_ciconst commonTemplate = /^\d+\.\d+\.\d+(?:-.*)?$/;
571cb0ef41Sopenharmony_ci
581cb0ef41Sopenharmony_ciassert.match(process.versions.acorn, commonTemplate);
591cb0ef41Sopenharmony_ciassert.match(process.versions.ares, commonTemplate);
601cb0ef41Sopenharmony_ciassert.match(process.versions.brotli, commonTemplate);
611cb0ef41Sopenharmony_ciassert.match(process.versions.llhttp, commonTemplate);
621cb0ef41Sopenharmony_ciassert.match(process.versions.node, commonTemplate);
631cb0ef41Sopenharmony_ciassert.match(process.versions.uv, commonTemplate);
641cb0ef41Sopenharmony_ciassert.match(process.versions.zlib, /^\d+(?:\.\d+){1,3}(?:-.*)?$/);
651cb0ef41Sopenharmony_ci
661cb0ef41Sopenharmony_ciif (hasUndici) {
671cb0ef41Sopenharmony_ci  assert.match(process.versions.undici, commonTemplate);
681cb0ef41Sopenharmony_ci}
691cb0ef41Sopenharmony_ci
701cb0ef41Sopenharmony_ciassert.match(
711cb0ef41Sopenharmony_ci  process.versions.v8,
721cb0ef41Sopenharmony_ci  /^\d+\.\d+\.\d+(?:\.\d+)?-node\.\d+(?: \(candidate\))?$/
731cb0ef41Sopenharmony_ci);
741cb0ef41Sopenharmony_ciassert.match(process.versions.modules, /^\d+$/);
751cb0ef41Sopenharmony_ciassert.match(process.versions.cjs_module_lexer, commonTemplate);
761cb0ef41Sopenharmony_ci
771cb0ef41Sopenharmony_ciif (common.hasCrypto) {
781cb0ef41Sopenharmony_ci  if (process.config.variables.node_shared_openssl) {
791cb0ef41Sopenharmony_ci    assert.ok(process.versions.openssl);
801cb0ef41Sopenharmony_ci  } else {
811cb0ef41Sopenharmony_ci    const versionRegex = common.hasOpenSSL3 ?
821cb0ef41Sopenharmony_ci      // The following also matches a development version of OpenSSL 3.x which
831cb0ef41Sopenharmony_ci      // can be in the format '3.0.0-alpha4-dev'. This can be handy when
841cb0ef41Sopenharmony_ci      // building and linking against the main development branch of OpenSSL.
851cb0ef41Sopenharmony_ci      /^\d+\.\d+\.\d+(?:[-+][a-z0-9]+)*$/ :
861cb0ef41Sopenharmony_ci      /^\d+\.\d+\.\d+[a-z]?(\+quic)?(-fips)?$/;
871cb0ef41Sopenharmony_ci    assert.match(process.versions.openssl, versionRegex);
881cb0ef41Sopenharmony_ci  }
891cb0ef41Sopenharmony_ci}
901cb0ef41Sopenharmony_ci
911cb0ef41Sopenharmony_cifor (let i = 0; i < expected_keys.length; i++) {
921cb0ef41Sopenharmony_ci  const key = expected_keys[i];
931cb0ef41Sopenharmony_ci  const descriptor = Object.getOwnPropertyDescriptor(process.versions, key);
941cb0ef41Sopenharmony_ci  assert.strictEqual(descriptor.writable, false);
951cb0ef41Sopenharmony_ci}
961cb0ef41Sopenharmony_ci
971cb0ef41Sopenharmony_ciassert.strictEqual(process.config.variables.napi_build_version,
981cb0ef41Sopenharmony_ci                   process.versions.napi);
991cb0ef41Sopenharmony_ci
1001cb0ef41Sopenharmony_ciif (hasUndici) {
1011cb0ef41Sopenharmony_ci  const undici = require('../../deps/undici/src/package.json');
1021cb0ef41Sopenharmony_ci  const expectedUndiciVersion = undici.version;
1031cb0ef41Sopenharmony_ci  assert.strictEqual(process.versions.undici, expectedUndiciVersion);
1041cb0ef41Sopenharmony_ci}
1051cb0ef41Sopenharmony_ci
1061cb0ef41Sopenharmony_ciconst expectedAcornVersion = acorn.version;
1071cb0ef41Sopenharmony_ciassert.strictEqual(process.versions.acorn, expectedAcornVersion);
1081cb0ef41Sopenharmony_ciconst expectedCjsModuleLexerVersion = cjs_module_lexer.version;
1091cb0ef41Sopenharmony_ciassert.strictEqual(process.versions.cjs_module_lexer, expectedCjsModuleLexerVersion);
110