mirror of
https://github.com/actions/setup-node
synced 2026-10-19 10:11:05 +08:00
e2e-cache / Test npm (Node 22, ubuntu-latest) (push) Failing after 32s
e2e-cache / Test npm (Node 24, ubuntu-latest) (push) Failing after 17m5s
e2e-cache / Test npm (Node 26, ubuntu-latest) (push) Successful in 10m9s
e2e-cache / Test pnpm (Node 22, ubuntu-latest) (push) Failing after 5m40s
e2e-cache / Test pnpm (Node 24, ubuntu-latest) (push) Failing after 5m34s
e2e-cache / Test pnpm (Node 26, ubuntu-latest) (push) Failing after 6m1s
e2e-cache / Test yarn 1 (Node 22, ubuntu-latest) (push) Failing after 11s
e2e-cache / Test yarn 1 (Node 24, ubuntu-latest) (push) Failing after 7s
e2e-cache / Test yarn 1 (Node 26, ubuntu-latest) (push) Failing after 7s
e2e-cache / Test yarn 3 (Node 22, ubuntu-latest) (push) Failing after 6s
e2e-cache / Test yarn 3 (Node 24, ubuntu-latest) (push) Failing after 7s
e2e-cache / Test yarn 3 (Node 26, ubuntu-latest) (push) Failing after 7s
e2e-cache / Test yarn subprojects (22) (push) Failing after 7s
e2e-cache / Test yarn subprojects (24) (push) Failing after 8s
e2e-cache / Test yarn subprojects (26) (push) Failing after 7s
e2e-cache / Test yarn subprojects all locally managed (22) (push) Failing after 7s
e2e-cache / Test yarn subprojects all locally managed (24) (push) Failing after 7s
e2e-cache / Test yarn subprojects all locally managed (26) (push) Failing after 7s
e2e-cache / Test yarn subprojects some locally managed (22) (push) Failing after 6s
e2e-cache / Test yarn subprojects some locally managed (24) (push) Failing after 7s
e2e-cache / Test yarn subprojects some locally managed (26) (push) Failing after 7s
e2e-cache / Test yarn subprojects managed by git (22) (push) Failing after 7s
e2e-cache / Test yarn subprojects managed by git (24) (push) Failing after 8s
e2e-cache / Test yarn subprojects managed by git (26) (push) Failing after 7s
e2e-cache / Test auto cache with top-level packageManager (22, ubuntu-latest) (push) Successful in 9m32s
e2e-cache / Test auto cache with top-level packageManager (24, ubuntu-latest) (push) Successful in 9m38s
e2e-cache / Test auto cache with top-level packageManager (26, ubuntu-latest) (push) Successful in 9m37s
e2e-cache / Test auto cache with devEngines.packageManager (22, ubuntu-latest) (push) Successful in 9m41s
e2e-cache / Test auto cache with devEngines.packageManager (24, ubuntu-latest) (push) Successful in 9m38s
e2e-cache / Test auto cache with devEngines.packageManager (26, ubuntu-latest) (push) Successful in 9m39s
proxy / test-proxy (push) Failing after 1s
proxy / test-bypass-proxy (push) Failing after 40s
versions / local-cache (22, ubuntu-latest) (push) Successful in 21s
versions / local-cache (24, ubuntu-latest) (push) Successful in 17s
versions / local-cache (26, ubuntu-latest) (push) Successful in 16s
versions / lts-syntax (lts/*, ubuntu-latest) (push) Failing after 20s
versions / lts-syntax (lts/-1, ubuntu-latest) (push) Failing after 19s
versions / v8-canary-syntax (26-v8-canary, ubuntu-latest) (push) Successful in 20s
versions / v8-canary-syntax (26.0.0-v8-canary, ubuntu-latest) (push) Successful in 16s
versions / v8-canary-syntax (26.0.0-v8-canary20251016054584e5cf, ubuntu-latest) (push) Successful in 35s
versions / nightly-syntax (24.0.0-nightly, ubuntu-latest) (push) Successful in 38s
versions / nightly-syntax (25-nightly, ubuntu-latest) (push) Failing after 30s
versions / nightly-syntax (26-nightly, ubuntu-latest) (push) Failing after 30s
versions / rc-syntax (22.14.0-rc.1, ubuntu-latest) (push) Failing after 30s
versions / rc-syntax (24.0.0-rc.4, ubuntu-latest) (push) Failing after 31s
versions / rc-syntax (26.0.0-rc.1, ubuntu-latest) (push) Failing after 1m35s
versions / manifest (22.0.0, ubuntu-latest) (push) Failing after 31s
versions / manifest (24.9.0, ubuntu-latest) (push) Failing after 31s
versions / manifest (26.5.0, ubuntu-latest) (push) Failing after 31s
versions / check-latest (22, ubuntu-latest) (push) Successful in 42s
versions / check-latest (24, ubuntu-latest) (push) Successful in 26s
versions / check-latest (26, ubuntu-latest) (push) Successful in 26s
versions / version-file (.nvmrc, ubuntu-latest) (push) Successful in 16s
versions / version-file (.tool-versions, ubuntu-latest) (push) Successful in 16s
versions / version-file (.tool-versions-node, ubuntu-latest) (push) Successful in 17s
versions / version-file (mise.toml, ubuntu-latest) (push) Successful in 16s
versions / version-file (package.json, ubuntu-latest) (push) Successful in 17s
versions / version-file-dev-engines (ubuntu-latest) (push) Successful in 16s
versions / version-file-volta (ubuntu-latest) (push) Successful in 16s
versions / version-file-volta-extends (ubuntu-latest) (push) Successful in 16s
versions / node-dist (21, ubuntu-latest) (push) Successful in 16s
versions / node-dist (23, ubuntu-latest) (push) Successful in 17s
versions / old-versions (ubuntu-latest) (push) Successful in 7s
versions / node-latest-aliases (current, ubuntu-latest) (push) Successful in 18s
versions / node-latest-aliases (latest, ubuntu-latest) (push) Successful in 19s
versions / node-latest-aliases (node, ubuntu-latest) (push) Successful in 19s
e2e-cache / Test npm (Node 22, macos-15-intel) (push) Canceled after 0s
e2e-cache / Test npm (Node 22, macos-latest) (push) Canceled after 0s
e2e-cache / Test npm (Node 22, windows-latest) (push) Canceled after 0s
e2e-cache / Test npm (Node 24, macos-15-intel) (push) Canceled after 0s
e2e-cache / Test npm (Node 24, macos-latest) (push) Canceled after 0s
e2e-cache / Test npm (Node 24, windows-latest) (push) Canceled after 0s
e2e-cache / Test npm (Node 26, macos-15-intel) (push) Canceled after 0s
e2e-cache / Test npm (Node 26, macos-latest) (push) Canceled after 0s
e2e-cache / Test npm (Node 26, windows-latest) (push) Canceled after 0s
e2e-cache / Test pnpm (Node 22, macos-15-intel) (push) Canceled after 0s
e2e-cache / Test pnpm (Node 22, macos-latest) (push) Canceled after 0s
e2e-cache / Test pnpm (Node 22, windows-latest) (push) Canceled after 0s
e2e-cache / Test pnpm (Node 24, macos-15-intel) (push) Canceled after 0s
e2e-cache / Test pnpm (Node 24, macos-latest) (push) Canceled after 0s
e2e-cache / Test pnpm (Node 24, windows-latest) (push) Canceled after 0s
e2e-cache / Test pnpm (Node 26, macos-15-intel) (push) Canceled after 0s
e2e-cache / Test pnpm (Node 26, macos-latest) (push) Canceled after 0s
e2e-cache / Test pnpm (Node 26, windows-latest) (push) Canceled after 0s
e2e-cache / Test yarn 1 (Node 22, macos-15-intel) (push) Canceled after 0s
e2e-cache / Test yarn 1 (Node 22, macos-latest) (push) Canceled after 0s
e2e-cache / Test yarn 1 (Node 22, windows-latest) (push) Canceled after 0s
e2e-cache / Test yarn 1 (Node 24, macos-15-intel) (push) Canceled after 0s
e2e-cache / Test yarn 1 (Node 24, macos-latest) (push) Canceled after 0s
e2e-cache / Test yarn 1 (Node 24, windows-latest) (push) Canceled after 0s
e2e-cache / Test yarn 1 (Node 26, macos-15-intel) (push) Canceled after 0s
e2e-cache / Test yarn 1 (Node 26, macos-latest) (push) Canceled after 0s
e2e-cache / Test yarn 1 (Node 26, windows-latest) (push) Canceled after 0s
e2e-cache / Test yarn 3 (Node 22, macos-15-intel) (push) Canceled after 0s
e2e-cache / Test yarn 3 (Node 22, macos-latest) (push) Canceled after 0s
e2e-cache / Test yarn 3 (Node 22, windows-latest) (push) Canceled after 0s
e2e-cache / Test yarn 3 (Node 24, macos-15-intel) (push) Canceled after 0s
e2e-cache / Test yarn 3 (Node 24, macos-latest) (push) Canceled after 0s
e2e-cache / Test yarn 3 (Node 24, windows-latest) (push) Canceled after 0s
e2e-cache / Test yarn 3 (Node 26, macos-15-intel) (push) Canceled after 0s
e2e-cache / Test yarn 3 (Node 26, macos-latest) (push) Canceled after 0s
e2e-cache / Test yarn 3 (Node 26, windows-latest) (push) Canceled after 0s
e2e-cache / Test auto cache with top-level packageManager (22, macos-15-intel) (push) Canceled after 0s
e2e-cache / Test auto cache with top-level packageManager (22, macos-latest) (push) Canceled after 0s
e2e-cache / Test auto cache with top-level packageManager (22, windows-latest) (push) Canceled after 0s
e2e-cache / Test auto cache with top-level packageManager (24, macos-15-intel) (push) Canceled after 0s
e2e-cache / Test auto cache with top-level packageManager (24, macos-latest) (push) Canceled after 0s
e2e-cache / Test auto cache with top-level packageManager (24, windows-latest) (push) Canceled after 0s
e2e-cache / Test auto cache with top-level packageManager (26, macos-15-intel) (push) Canceled after 0s
e2e-cache / Test auto cache with top-level packageManager (26, macos-latest) (push) Canceled after 0s
e2e-cache / Test auto cache with top-level packageManager (26, windows-latest) (push) Canceled after 0s
e2e-cache / Test auto cache with devEngines.packageManager (22, macos-15-intel) (push) Canceled after 0s
e2e-cache / Test auto cache with devEngines.packageManager (22, macos-latest) (push) Canceled after 0s
e2e-cache / Test auto cache with devEngines.packageManager (22, windows-latest) (push) Canceled after 0s
e2e-cache / Test auto cache with devEngines.packageManager (24, macos-15-intel) (push) Canceled after 0s
e2e-cache / Test auto cache with devEngines.packageManager (24, macos-latest) (push) Canceled after 0s
e2e-cache / Test auto cache with devEngines.packageManager (24, windows-latest) (push) Canceled after 0s
e2e-cache / Test auto cache with devEngines.packageManager (26, macos-15-intel) (push) Canceled after 0s
e2e-cache / Test auto cache with devEngines.packageManager (26, macos-latest) (push) Canceled after 0s
e2e-cache / Test auto cache with devEngines.packageManager (26, windows-latest) (push) Canceled after 0s
versions / local-cache (22, macos-15-intel) (push) Canceled after 0s
versions / local-cache (22, macos-latest) (push) Canceled after 0s
versions / local-cache (22, windows-latest) (push) Canceled after 0s
versions / local-cache (24, macos-15-intel) (push) Canceled after 0s
versions / local-cache (24, macos-latest) (push) Canceled after 0s
versions / local-cache (24, windows-latest) (push) Canceled after 0s
versions / local-cache (26, macos-15-intel) (push) Canceled after 0s
versions / local-cache (26, macos-latest) (push) Canceled after 0s
versions / local-cache (26, windows-latest) (push) Canceled after 0s
versions / lts-syntax (lts/*, macos-15-intel) (push) Canceled after 0s
versions / lts-syntax (lts/*, windows-latest) (push) Canceled after 0s
versions / lts-syntax (lts/-1, macos-15-intel) (push) Canceled after 0s
versions / lts-syntax (lts/-1, windows-latest) (push) Canceled after 0s
versions / v8-canary-syntax (26-v8-canary, macos-15-intel) (push) Canceled after 0s
versions / v8-canary-syntax (26-v8-canary, macos-latest) (push) Canceled after 0s
versions / v8-canary-syntax (26-v8-canary, windows-latest) (push) Canceled after 0s
versions / v8-canary-syntax (26.0.0-v8-canary, macos-15-intel) (push) Canceled after 0s
versions / v8-canary-syntax (26.0.0-v8-canary, macos-latest) (push) Canceled after 0s
versions / v8-canary-syntax (26.0.0-v8-canary, windows-latest) (push) Canceled after 0s
versions / v8-canary-syntax (26.0.0-v8-canary20251016054584e5cf, macos-15-intel) (push) Canceled after 0s
versions / v8-canary-syntax (26.0.0-v8-canary20251016054584e5cf, macos-latest) (push) Canceled after 0s
versions / v8-canary-syntax (26.0.0-v8-canary20251016054584e5cf, windows-latest) (push) Canceled after 0s
versions / nightly-syntax (24.0.0-nightly, macos-15-intel) (push) Canceled after 0s
versions / nightly-syntax (24.0.0-nightly, macos-latest) (push) Canceled after 0s
versions / nightly-syntax (24.0.0-nightly, windows-latest) (push) Canceled after 0s
versions / nightly-syntax (25-nightly, macos-15-intel) (push) Canceled after 0s
versions / nightly-syntax (25-nightly, macos-latest) (push) Canceled after 0s
versions / nightly-syntax (25-nightly, windows-latest) (push) Canceled after 0s
versions / nightly-syntax (26-nightly, macos-15-intel) (push) Canceled after 0s
versions / nightly-syntax (26-nightly, macos-latest) (push) Canceled after 0s
versions / nightly-syntax (26-nightly, windows-latest) (push) Canceled after 0s
versions / rc-syntax (22.14.0-rc.1, macos-15-intel) (push) Canceled after 0s
versions / rc-syntax (22.14.0-rc.1, macos-latest) (push) Canceled after 0s
versions / rc-syntax (22.14.0-rc.1, windows-latest) (push) Canceled after 0s
versions / rc-syntax (24.0.0-rc.4, macos-15-intel) (push) Canceled after 0s
versions / rc-syntax (24.0.0-rc.4, macos-latest) (push) Canceled after 0s
versions / rc-syntax (24.0.0-rc.4, windows-latest) (push) Canceled after 0s
versions / rc-syntax (26.0.0-rc.1, macos-15-intel) (push) Canceled after 0s
versions / rc-syntax (26.0.0-rc.1, macos-latest) (push) Canceled after 0s
versions / rc-syntax (26.0.0-rc.1, windows-latest) (push) Canceled after 0s
versions / manifest (22.0.0, macos-15-intel) (push) Canceled after 0s
versions / manifest (22.0.0, macos-latest) (push) Canceled after 0s
versions / manifest (22.0.0, windows-latest) (push) Canceled after 0s
versions / manifest (24.9.0, macos-15-intel) (push) Canceled after 0s
versions / manifest (24.9.0, macos-latest) (push) Canceled after 0s
versions / manifest (24.9.0, windows-latest) (push) Canceled after 0s
versions / manifest (26.5.0, macos-15-intel) (push) Canceled after 0s
versions / manifest (26.5.0, macos-latest) (push) Canceled after 0s
versions / manifest (26.5.0, windows-latest) (push) Canceled after 0s
versions / check-latest (22, macos-15-intel) (push) Canceled after 0s
versions / check-latest (22, macos-latest) (push) Canceled after 0s
versions / check-latest (22, windows-latest) (push) Canceled after 0s
versions / check-latest (24, macos-15-intel) (push) Canceled after 0s
versions / check-latest (24, macos-latest) (push) Canceled after 0s
versions / check-latest (24, windows-latest) (push) Canceled after 0s
versions / check-latest (26, macos-15-intel) (push) Canceled after 0s
versions / check-latest (26, macos-latest) (push) Canceled after 0s
versions / check-latest (26, windows-latest) (push) Canceled after 0s
versions / version-file (.nvmrc, macos-15-intel) (push) Canceled after 0s
versions / version-file (.nvmrc, macos-latest) (push) Canceled after 0s
versions / version-file (.nvmrc, windows-latest) (push) Canceled after 0s
versions / version-file (.tool-versions, macos-15-intel) (push) Canceled after 0s
versions / version-file (.tool-versions, macos-latest) (push) Canceled after 0s
versions / version-file (.tool-versions, windows-latest) (push) Canceled after 0s
versions / version-file (.tool-versions-node, macos-15-intel) (push) Canceled after 0s
versions / version-file (.tool-versions-node, macos-latest) (push) Canceled after 0s
versions / version-file (.tool-versions-node, windows-latest) (push) Canceled after 0s
versions / version-file (mise.toml, macos-15-intel) (push) Canceled after 0s
versions / version-file (mise.toml, macos-latest) (push) Canceled after 0s
versions / version-file (mise.toml, windows-latest) (push) Canceled after 0s
versions / version-file (package.json, macos-15-intel) (push) Canceled after 0s
versions / version-file (package.json, macos-latest) (push) Canceled after 0s
versions / version-file (package.json, windows-latest) (push) Canceled after 0s
versions / version-file-dev-engines (macos-latest) (push) Canceled after 0s
versions / version-file-dev-engines (windows-latest) (push) Canceled after 0s
versions / version-file-volta (macos-15-intel) (push) Canceled after 0s
versions / version-file-volta (macos-latest) (push) Canceled after 0s
versions / version-file-volta (windows-latest) (push) Canceled after 0s
versions / version-file-volta-extends (macos-15-intel) (push) Canceled after 0s
versions / version-file-volta-extends (macos-latest) (push) Canceled after 0s
versions / version-file-volta-extends (windows-latest) (push) Canceled after 0s
versions / node-dist (21, macos-15-intel) (push) Canceled after 0s
versions / node-dist (21, macos-latest) (push) Canceled after 0s
versions / node-dist (21, windows-latest) (push) Canceled after 0s
versions / node-dist (23, macos-15-intel) (push) Canceled after 0s
versions / node-dist (23, macos-latest) (push) Canceled after 0s
versions / node-dist (23, windows-latest) (push) Canceled after 0s
versions / old-versions (macos-15-intel) (push) Canceled after 0s
versions / old-versions (windows-latest) (push) Canceled after 0s
versions / arch (push) Canceled after 0s
versions / node-latest-aliases (current, macos-15-intel) (push) Canceled after 0s
versions / node-latest-aliases (current, macos-latest) (push) Canceled after 0s
versions / node-latest-aliases (current, windows-latest) (push) Canceled after 0s
versions / node-latest-aliases (latest, macos-15-intel) (push) Canceled after 0s
versions / node-latest-aliases (latest, macos-latest) (push) Canceled after 0s
versions / node-latest-aliases (latest, windows-latest) (push) Canceled after 0s
versions / node-latest-aliases (node, macos-15-intel) (push) Canceled after 0s
versions / node-latest-aliases (node, macos-latest) (push) Canceled after 0s
versions / node-latest-aliases (node, windows-latest) (push) Canceled after 0s
* path.resolve for composite actions * log and documentation update --------- Co-authored-by: mahabaleshwars <147705296+mahabaleshwars@users.noreply.github.com>
176 lines
5.5 KiB
TypeScript
176 lines
5.5 KiB
TypeScript
import * as core from '@actions/core';
|
|
|
|
import os from 'os';
|
|
import fs from 'fs';
|
|
import {fileURLToPath} from 'url';
|
|
|
|
import * as auth from './authutil.js';
|
|
import * as path from 'path';
|
|
import {restoreCache} from './cache-restore.js';
|
|
import {isCacheFeatureAvailable} from './cache-utils.js';
|
|
import {getNodejsDistribution} from './distributions/installer-factory.js';
|
|
import {getNodeVersionFromFile, printEnvDetailsAndSetOutput} from './util.js';
|
|
import {State} from './constants.js';
|
|
|
|
export async function run() {
|
|
try {
|
|
//
|
|
// Version is optional. If supplied, install / use from the tool cache
|
|
// If not supplied then task is still used to setup proxy, auth, etc...
|
|
//
|
|
const version = resolveVersionInput();
|
|
|
|
let arch = core.getInput('architecture');
|
|
const cache = core.getInput('cache');
|
|
const packagemanagercache =
|
|
(core.getInput('package-manager-cache') || 'true').toUpperCase() ===
|
|
'TRUE';
|
|
|
|
// if architecture supplied but node-version is not
|
|
// if we don't throw a warning, the already installed x64 node will be used which is not probably what user meant.
|
|
if (arch && !version) {
|
|
core.warning(
|
|
'`architecture` is provided but `node-version` is missing. In this configuration, the version/architecture of Node will not be changed. To fix this, provide `architecture` in combination with `node-version`'
|
|
);
|
|
}
|
|
|
|
if (!arch) {
|
|
arch = os.arch();
|
|
}
|
|
|
|
if (version) {
|
|
const token = core.getInput('token');
|
|
const auth = !token ? undefined : `token ${token}`;
|
|
const mirror = core.getInput('mirror');
|
|
const mirrorToken = core.getInput('mirror-token');
|
|
const stable =
|
|
(core.getInput('stable') || 'true').toUpperCase() === 'TRUE';
|
|
const checkLatest =
|
|
(core.getInput('check-latest') || 'false').toUpperCase() === 'TRUE';
|
|
const nodejsInfo = {
|
|
versionSpec: version,
|
|
checkLatest,
|
|
auth,
|
|
stable,
|
|
arch,
|
|
mirror,
|
|
mirrorToken
|
|
};
|
|
const nodeDistribution = getNodejsDistribution(nodejsInfo);
|
|
await nodeDistribution.setupNodeJs();
|
|
}
|
|
|
|
await printEnvDetailsAndSetOutput();
|
|
|
|
const registryUrl: string = core.getInput('registry-url');
|
|
if (registryUrl) {
|
|
auth.configAuthentication(registryUrl);
|
|
}
|
|
|
|
const cacheDependencyPath = core.getInput('cache-dependency-path');
|
|
|
|
if (isCacheFeatureAvailable()) {
|
|
// if the cache input is provided, use it for caching.
|
|
if (cache) {
|
|
core.saveState(State.CachePackageManager, cache);
|
|
await restoreCache(cache, cacheDependencyPath);
|
|
// package manager npm is detected from package.json, enable auto-caching for npm.
|
|
} else if (packagemanagercache) {
|
|
const resolvedPackageManager = getNameFromPackageManagerField();
|
|
if (resolvedPackageManager) {
|
|
core.info(
|
|
"Detected npm as the package manager from package.json's packageManager field. " +
|
|
'Auto caching has been enabled for npm. If you want to disable it, set package-manager-cache input to false'
|
|
);
|
|
core.saveState(State.CachePackageManager, resolvedPackageManager);
|
|
await restoreCache(resolvedPackageManager, cacheDependencyPath);
|
|
}
|
|
}
|
|
}
|
|
|
|
const matchersPath = path.join(
|
|
path.dirname(fileURLToPath(import.meta.url)),
|
|
'../..',
|
|
'.github'
|
|
);
|
|
core.info(`##[add-matcher]${path.join(matchersPath, 'tsc.json')}`);
|
|
core.info(
|
|
`##[add-matcher]${path.join(matchersPath, 'eslint-stylish.json')}`
|
|
);
|
|
core.info(
|
|
`##[add-matcher]${path.join(matchersPath, 'eslint-compact.json')}`
|
|
);
|
|
} catch (err) {
|
|
core.setFailed((err as Error).message);
|
|
}
|
|
}
|
|
|
|
function resolveVersionInput(): string {
|
|
let version = core.getInput('node-version');
|
|
const versionFileInput = core.getInput('node-version-file');
|
|
|
|
if (version && versionFileInput) {
|
|
core.warning(
|
|
'Both node-version and node-version-file inputs are specified, only node-version will be used'
|
|
);
|
|
}
|
|
|
|
if (version) {
|
|
return version;
|
|
}
|
|
|
|
if (versionFileInput) {
|
|
// `path.resolve` (unlike `path.join`) keeps an already-absolute input as-is,
|
|
// so a composite action can pass `${{ github.action_path }}/.nvmrc`.
|
|
const versionFilePath = path.resolve(
|
|
process.env.GITHUB_WORKSPACE!,
|
|
versionFileInput
|
|
);
|
|
|
|
const parsedVersion = getNodeVersionFromFile(versionFilePath);
|
|
|
|
if (parsedVersion) {
|
|
version = parsedVersion;
|
|
} else {
|
|
core.warning(
|
|
`Could not determine node version from ${versionFilePath}. Falling back`
|
|
);
|
|
}
|
|
|
|
core.info(`Resolved ${versionFileInput} as ${version}`);
|
|
}
|
|
|
|
return version;
|
|
}
|
|
|
|
export function getNameFromPackageManagerField(): string | undefined {
|
|
const npmRegex = /^(\^)?npm(@.*)?$/; // matches "npm", "npm@...", "^npm@..."
|
|
try {
|
|
const packageJson = JSON.parse(
|
|
fs.readFileSync(
|
|
path.join(process.env.GITHUB_WORKSPACE!, 'package.json'),
|
|
'utf-8'
|
|
)
|
|
);
|
|
|
|
// Check devEngines.packageManager first (object or array)
|
|
const devPM = packageJson?.devEngines?.packageManager;
|
|
const devPMArray = devPM ? (Array.isArray(devPM) ? devPM : [devPM]) : [];
|
|
for (const obj of devPMArray) {
|
|
if (typeof obj?.name === 'string' && npmRegex.test(obj.name)) {
|
|
return 'npm';
|
|
}
|
|
}
|
|
|
|
// Check top-level packageManager
|
|
const topLevelPM = packageJson?.packageManager;
|
|
if (typeof topLevelPM === 'string' && npmRegex.test(topLevelPM)) {
|
|
return 'npm';
|
|
}
|
|
|
|
return undefined;
|
|
} catch {
|
|
return undefined;
|
|
}
|
|
}
|