Add missing dependency

This commit is contained in:
Nikolai Laevskii 2023-05-23 16:33:19 +02:00
parent d0d39bda2f
commit 7d16907b89
4 changed files with 1325 additions and 1323 deletions

View File

@ -59126,87 +59126,87 @@ exports.debug = debug; // for test
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
"use strict"; "use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k; if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) { }) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k; if (k2 === undefined) k2 = k;
o[k2] = m[k]; o[k2] = m[k];
})); }));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v }); Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) { }) : function(o, v) {
o["default"] = v; o["default"] = v;
}); });
var __importStar = (this && this.__importStar) || function (mod) { var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod; if (mod && mod.__esModule) return mod;
var result = {}; var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod); __setModuleDefault(result, mod);
return result; return result;
}; };
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) { return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next()); step((generator = generator.apply(thisArg, _arguments || [])).next());
}); });
}; };
var __importDefault = (this && this.__importDefault) || function (mod) { var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod }; return (mod && mod.__esModule) ? mod : { "default": mod };
}; };
Object.defineProperty(exports, "__esModule", ({ value: true })); Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.run = void 0; exports.run = void 0;
const core = __importStar(__nccwpck_require__(2186)); const core = __importStar(__nccwpck_require__(2186));
const cache = __importStar(__nccwpck_require__(7799)); const cache = __importStar(__nccwpck_require__(7799));
const fs_1 = __importDefault(__nccwpck_require__(7147)); const fs_1 = __importDefault(__nccwpck_require__(7147));
const constants_1 = __nccwpck_require__(9042); const constants_1 = __nccwpck_require__(9042);
const cache_utils_1 = __nccwpck_require__(1678); const cache_utils_1 = __nccwpck_require__(1678);
// Catch and log any unhandled exceptions. These exceptions can leak out of the uploadChunk method in // Catch and log any unhandled exceptions. These exceptions can leak out of the uploadChunk method in
// @actions/toolkit when a failed upload closes the file descriptor causing any in-process reads to // @actions/toolkit when a failed upload closes the file descriptor causing any in-process reads to
// throw an uncaught exception. Instead of failing this action, just warn. // throw an uncaught exception. Instead of failing this action, just warn.
process.on('uncaughtException', e => { process.on('uncaughtException', e => {
const warningPrefix = '[warning]'; const warningPrefix = '[warning]';
core.info(`${warningPrefix}${e.message}`); core.info(`${warningPrefix}${e.message}`);
}); });
function run() { function run() {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
try { try {
const cacheLock = core.getInput('cache'); const cacheLock = core.getInput('cache');
yield cachePackages(cacheLock); yield cachePackages(cacheLock);
} }
catch (error) { catch (error) {
core.setFailed(error.message); core.setFailed(error.message);
} }
}); });
} }
exports.run = run; exports.run = run;
const cachePackages = (packageManager) => __awaiter(void 0, void 0, void 0, function* () { const cachePackages = (packageManager) => __awaiter(void 0, void 0, void 0, function* () {
const state = core.getState(constants_1.State.CacheMatchedKey); const state = core.getState(constants_1.State.CacheMatchedKey);
const primaryKey = core.getState(constants_1.State.CachePrimaryKey); const primaryKey = core.getState(constants_1.State.CachePrimaryKey);
const packageManagerInfo = yield cache_utils_1.getPackageManagerInfo(packageManager); const packageManagerInfo = yield cache_utils_1.getPackageManagerInfo(packageManager);
if (!packageManagerInfo) { if (!packageManagerInfo) {
core.debug(`Caching for '${packageManager}' is not supported`); core.debug(`Caching for '${packageManager}' is not supported`);
return; return;
} }
const cachePath = yield cache_utils_1.getCacheDirectoryPath(packageManagerInfo, packageManager); const cachePath = yield cache_utils_1.getCacheDirectoryPath(packageManagerInfo, packageManager);
if (!fs_1.default.existsSync(cachePath)) { if (!fs_1.default.existsSync(cachePath)) {
throw new Error(`Cache folder path is retrieved for ${packageManager} but doesn't exist on disk: ${cachePath}`); throw new Error(`Cache folder path is retrieved for ${packageManager} but doesn't exist on disk: ${cachePath}`);
} }
if (primaryKey === state) { if (primaryKey === state) {
core.info(`Cache hit occurred on the primary key ${primaryKey}, not saving cache.`); core.info(`Cache hit occurred on the primary key ${primaryKey}, not saving cache.`);
return; return;
} }
const cacheId = yield cache.saveCache([cachePath], primaryKey); const cacheId = yield cache.saveCache([cachePath], primaryKey);
if (cacheId == -1) { if (cacheId == -1) {
return; return;
} }
core.info(`Cache saved with the key: ${primaryKey}`); core.info(`Cache saved with the key: ${primaryKey}`);
}); });
run(); run();
/***/ }), /***/ }),
@ -59215,123 +59215,123 @@ run();
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
"use strict"; "use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k; if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) { }) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k; if (k2 === undefined) k2 = k;
o[k2] = m[k]; o[k2] = m[k];
})); }));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v }); Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) { }) : function(o, v) {
o["default"] = v; o["default"] = v;
}); });
var __importStar = (this && this.__importStar) || function (mod) { var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod; if (mod && mod.__esModule) return mod;
var result = {}; var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod); __setModuleDefault(result, mod);
return result; return result;
}; };
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) { return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next()); step((generator = generator.apply(thisArg, _arguments || [])).next());
}); });
}; };
Object.defineProperty(exports, "__esModule", ({ value: true })); Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.isCacheFeatureAvailable = exports.isGhes = exports.getCacheDirectoryPath = exports.getPackageManagerInfo = exports.getCommandOutput = exports.supportedPackageManagers = void 0; exports.isCacheFeatureAvailable = exports.isGhes = exports.getCacheDirectoryPath = exports.getPackageManagerInfo = exports.getCommandOutput = exports.supportedPackageManagers = void 0;
const core = __importStar(__nccwpck_require__(2186)); const core = __importStar(__nccwpck_require__(2186));
const exec = __importStar(__nccwpck_require__(1514)); const exec = __importStar(__nccwpck_require__(1514));
const cache = __importStar(__nccwpck_require__(7799)); const cache = __importStar(__nccwpck_require__(7799));
exports.supportedPackageManagers = { exports.supportedPackageManagers = {
npm: { npm: {
lockFilePatterns: ['package-lock.json', 'npm-shrinkwrap.json', 'yarn.lock'], lockFilePatterns: ['package-lock.json', 'npm-shrinkwrap.json', 'yarn.lock'],
getCacheFolderCommand: 'npm config get cache' getCacheFolderCommand: 'npm config get cache'
}, },
pnpm: { pnpm: {
lockFilePatterns: ['pnpm-lock.yaml'], lockFilePatterns: ['pnpm-lock.yaml'],
getCacheFolderCommand: 'pnpm store path --silent' getCacheFolderCommand: 'pnpm store path --silent'
}, },
yarn1: { yarn1: {
lockFilePatterns: ['yarn.lock'], lockFilePatterns: ['yarn.lock'],
getCacheFolderCommand: 'yarn cache dir' getCacheFolderCommand: 'yarn cache dir'
}, },
yarn2: { yarn2: {
lockFilePatterns: ['yarn.lock'], lockFilePatterns: ['yarn.lock'],
getCacheFolderCommand: 'yarn config get cacheFolder' getCacheFolderCommand: 'yarn config get cacheFolder'
} }
}; };
const getCommandOutput = (toolCommand) => __awaiter(void 0, void 0, void 0, function* () { const getCommandOutput = (toolCommand) => __awaiter(void 0, void 0, void 0, function* () {
let { stdout, stderr, exitCode } = yield exec.getExecOutput(toolCommand, undefined, { ignoreReturnCode: true }); let { stdout, stderr, exitCode } = yield exec.getExecOutput(toolCommand, undefined, { ignoreReturnCode: true });
if (exitCode) { if (exitCode) {
stderr = !stderr.trim() stderr = !stderr.trim()
? `The '${toolCommand}' command failed with exit code: ${exitCode}` ? `The '${toolCommand}' command failed with exit code: ${exitCode}`
: stderr; : stderr;
throw new Error(stderr); throw new Error(stderr);
} }
return stdout.trim(); return stdout.trim();
}); });
exports.getCommandOutput = getCommandOutput; exports.getCommandOutput = getCommandOutput;
const getPackageManagerVersion = (packageManager, command) => __awaiter(void 0, void 0, void 0, function* () { const getPackageManagerVersion = (packageManager, command) => __awaiter(void 0, void 0, void 0, function* () {
const stdOut = yield exports.getCommandOutput(`${packageManager} ${command}`); const stdOut = yield exports.getCommandOutput(`${packageManager} ${command}`);
if (!stdOut) { if (!stdOut) {
throw new Error(`Could not retrieve version of ${packageManager}`); throw new Error(`Could not retrieve version of ${packageManager}`);
} }
return stdOut; return stdOut;
}); });
const getPackageManagerInfo = (packageManager) => __awaiter(void 0, void 0, void 0, function* () { const getPackageManagerInfo = (packageManager) => __awaiter(void 0, void 0, void 0, function* () {
if (packageManager === 'npm') { if (packageManager === 'npm') {
return exports.supportedPackageManagers.npm; return exports.supportedPackageManagers.npm;
} }
else if (packageManager === 'pnpm') { else if (packageManager === 'pnpm') {
return exports.supportedPackageManagers.pnpm; return exports.supportedPackageManagers.pnpm;
} }
else if (packageManager === 'yarn') { else if (packageManager === 'yarn') {
const yarnVersion = yield getPackageManagerVersion('yarn', '--version'); const yarnVersion = yield getPackageManagerVersion('yarn', '--version');
core.debug(`Consumed yarn version is ${yarnVersion}`); core.debug(`Consumed yarn version is ${yarnVersion}`);
if (yarnVersion.startsWith('1.')) { if (yarnVersion.startsWith('1.')) {
return exports.supportedPackageManagers.yarn1; return exports.supportedPackageManagers.yarn1;
} }
else { else {
return exports.supportedPackageManagers.yarn2; return exports.supportedPackageManagers.yarn2;
} }
} }
else { else {
return null; return null;
} }
}); });
exports.getPackageManagerInfo = getPackageManagerInfo; exports.getPackageManagerInfo = getPackageManagerInfo;
const getCacheDirectoryPath = (packageManagerInfo, packageManager) => __awaiter(void 0, void 0, void 0, function* () { const getCacheDirectoryPath = (packageManagerInfo, packageManager) => __awaiter(void 0, void 0, void 0, function* () {
const stdOut = yield exports.getCommandOutput(packageManagerInfo.getCacheFolderCommand); const stdOut = yield exports.getCommandOutput(packageManagerInfo.getCacheFolderCommand);
if (!stdOut) { if (!stdOut) {
throw new Error(`Could not get cache folder path for ${packageManager}`); throw new Error(`Could not get cache folder path for ${packageManager}`);
} }
core.debug(`${packageManager} path is ${stdOut}`); core.debug(`${packageManager} path is ${stdOut}`);
return stdOut.trim(); return stdOut.trim();
}); });
exports.getCacheDirectoryPath = getCacheDirectoryPath; exports.getCacheDirectoryPath = getCacheDirectoryPath;
function isGhes() { function isGhes() {
const ghUrl = new URL(process.env['GITHUB_SERVER_URL'] || 'https://github.com'); const ghUrl = new URL(process.env['GITHUB_SERVER_URL'] || 'https://github.com');
return ghUrl.hostname.toUpperCase() !== 'GITHUB.COM'; return ghUrl.hostname.toUpperCase() !== 'GITHUB.COM';
} }
exports.isGhes = isGhes; exports.isGhes = isGhes;
function isCacheFeatureAvailable() { function isCacheFeatureAvailable() {
if (cache.isFeatureAvailable()) if (cache.isFeatureAvailable())
return true; return true;
if (isGhes()) { if (isGhes()) {
core.warning('Cache action is only supported on GHES version >= 3.5. If you are on version >=3.5 Please check with GHES admin if Actions cache service is enabled or not.'); core.warning('Cache action is only supported on GHES version >= 3.5. If you are on version >=3.5 Please check with GHES admin if Actions cache service is enabled or not.');
return false; return false;
} }
core.warning('The runner was not able to contact the cache service. Caching will be skipped'); core.warning('The runner was not able to contact the cache service. Caching will be skipped');
return false; return false;
} }
exports.isCacheFeatureAvailable = isCacheFeatureAvailable; exports.isCacheFeatureAvailable = isCacheFeatureAvailable;
/***/ }), /***/ }),
@ -59340,24 +59340,24 @@ exports.isCacheFeatureAvailable = isCacheFeatureAvailable;
/***/ ((__unused_webpack_module, exports) => { /***/ ((__unused_webpack_module, exports) => {
"use strict"; "use strict";
Object.defineProperty(exports, "__esModule", ({ value: true })); Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.Outputs = exports.State = exports.LockType = void 0; exports.Outputs = exports.State = exports.LockType = void 0;
var LockType; var LockType;
(function (LockType) { (function (LockType) {
LockType["Npm"] = "npm"; LockType["Npm"] = "npm";
LockType["Pnpm"] = "pnpm"; LockType["Pnpm"] = "pnpm";
LockType["Yarn"] = "yarn"; LockType["Yarn"] = "yarn";
})(LockType = exports.LockType || (exports.LockType = {})); })(LockType = exports.LockType || (exports.LockType = {}));
var State; var State;
(function (State) { (function (State) {
State["CachePrimaryKey"] = "CACHE_KEY"; State["CachePrimaryKey"] = "CACHE_KEY";
State["CacheMatchedKey"] = "CACHE_RESULT"; State["CacheMatchedKey"] = "CACHE_RESULT";
})(State = exports.State || (exports.State = {})); })(State = exports.State || (exports.State = {}));
var Outputs; var Outputs;
(function (Outputs) { (function (Outputs) {
Outputs["CacheHit"] = "cache-hit"; Outputs["CacheHit"] = "cache-hit";
})(Outputs = exports.Outputs || (exports.Outputs = {})); })(Outputs = exports.Outputs || (exports.Outputs = {}));
/***/ }), /***/ }),

2214
dist/setup/index.js vendored
View File

@ -71022,73 +71022,73 @@ function wrappy (fn, cb) {
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
"use strict"; "use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k; if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) { }) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k; if (k2 === undefined) k2 = k;
o[k2] = m[k]; o[k2] = m[k];
})); }));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v }); Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) { }) : function(o, v) {
o["default"] = v; o["default"] = v;
}); });
var __importStar = (this && this.__importStar) || function (mod) { var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod; if (mod && mod.__esModule) return mod;
var result = {}; var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod); __setModuleDefault(result, mod);
return result; return result;
}; };
Object.defineProperty(exports, "__esModule", ({ value: true })); Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.configAuthentication = void 0; exports.configAuthentication = void 0;
const fs = __importStar(__nccwpck_require__(7147)); const fs = __importStar(__nccwpck_require__(7147));
const os = __importStar(__nccwpck_require__(2037)); const os = __importStar(__nccwpck_require__(2037));
const path = __importStar(__nccwpck_require__(1017)); const path = __importStar(__nccwpck_require__(1017));
const core = __importStar(__nccwpck_require__(2186)); const core = __importStar(__nccwpck_require__(2186));
const github = __importStar(__nccwpck_require__(5438)); const github = __importStar(__nccwpck_require__(5438));
function configAuthentication(registryUrl, alwaysAuth) { function configAuthentication(registryUrl, alwaysAuth) {
const npmrc = path.resolve(process.env['RUNNER_TEMP'] || process.cwd(), '.npmrc'); const npmrc = path.resolve(process.env['RUNNER_TEMP'] || process.cwd(), '.npmrc');
if (!registryUrl.endsWith('/')) { if (!registryUrl.endsWith('/')) {
registryUrl += '/'; registryUrl += '/';
} }
writeRegistryToFile(registryUrl, npmrc, alwaysAuth); writeRegistryToFile(registryUrl, npmrc, alwaysAuth);
} }
exports.configAuthentication = configAuthentication; exports.configAuthentication = configAuthentication;
function writeRegistryToFile(registryUrl, fileLocation, alwaysAuth) { function writeRegistryToFile(registryUrl, fileLocation, alwaysAuth) {
let scope = core.getInput('scope'); let scope = core.getInput('scope');
if (!scope && registryUrl.indexOf('npm.pkg.github.com') > -1) { if (!scope && registryUrl.indexOf('npm.pkg.github.com') > -1) {
scope = github.context.repo.owner; scope = github.context.repo.owner;
} }
if (scope && scope[0] != '@') { if (scope && scope[0] != '@') {
scope = '@' + scope; scope = '@' + scope;
} }
if (scope) { if (scope) {
scope = scope.toLowerCase() + ':'; scope = scope.toLowerCase() + ':';
} }
core.debug(`Setting auth in ${fileLocation}`); core.debug(`Setting auth in ${fileLocation}`);
let newContents = ''; let newContents = '';
if (fs.existsSync(fileLocation)) { if (fs.existsSync(fileLocation)) {
const curContents = fs.readFileSync(fileLocation, 'utf8'); const curContents = fs.readFileSync(fileLocation, 'utf8');
curContents.split(os.EOL).forEach((line) => { curContents.split(os.EOL).forEach((line) => {
// Add current contents unless they are setting the registry // Add current contents unless they are setting the registry
if (!line.toLowerCase().startsWith(`${scope}registry`)) { if (!line.toLowerCase().startsWith(`${scope}registry`)) {
newContents += line + os.EOL; newContents += line + os.EOL;
} }
}); });
} }
// Remove http: or https: from front of registry. // Remove http: or https: from front of registry.
const authString = registryUrl.replace(/(^\w+:|^)/, '') + ':_authToken=${NODE_AUTH_TOKEN}'; const authString = registryUrl.replace(/(^\w+:|^)/, '') + ':_authToken=${NODE_AUTH_TOKEN}';
const registryString = `${scope}registry=${registryUrl}`; const registryString = `${scope}registry=${registryUrl}`;
const alwaysAuthString = `always-auth=${alwaysAuth}`; const alwaysAuthString = `always-auth=${alwaysAuth}`;
newContents += `${authString}${os.EOL}${registryString}${os.EOL}${alwaysAuthString}`; newContents += `${authString}${os.EOL}${registryString}${os.EOL}${alwaysAuthString}`;
fs.writeFileSync(fileLocation, newContents); fs.writeFileSync(fileLocation, newContents);
core.exportVariable('NPM_CONFIG_USERCONFIG', fileLocation); core.exportVariable('NPM_CONFIG_USERCONFIG', fileLocation);
// Export empty node_auth_token if didn't exist so npm doesn't complain about not being able to find it // Export empty node_auth_token if didn't exist so npm doesn't complain about not being able to find it
core.exportVariable('NODE_AUTH_TOKEN', process.env.NODE_AUTH_TOKEN || 'XXXXX-XXXXX-XXXXX-XXXXX'); core.exportVariable('NODE_AUTH_TOKEN', process.env.NODE_AUTH_TOKEN || 'XXXXX-XXXXX-XXXXX-XXXXX');
} }
/***/ }), /***/ }),
@ -71097,84 +71097,84 @@ function writeRegistryToFile(registryUrl, fileLocation, alwaysAuth) {
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
"use strict"; "use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k; if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) { }) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k; if (k2 === undefined) k2 = k;
o[k2] = m[k]; o[k2] = m[k];
})); }));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v }); Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) { }) : function(o, v) {
o["default"] = v; o["default"] = v;
}); });
var __importStar = (this && this.__importStar) || function (mod) { var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod; if (mod && mod.__esModule) return mod;
var result = {}; var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod); __setModuleDefault(result, mod);
return result; return result;
}; };
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) { return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next()); step((generator = generator.apply(thisArg, _arguments || [])).next());
}); });
}; };
var __importDefault = (this && this.__importDefault) || function (mod) { var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod }; return (mod && mod.__esModule) ? mod : { "default": mod };
}; };
Object.defineProperty(exports, "__esModule", ({ value: true })); Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.restoreCache = void 0; exports.restoreCache = void 0;
const cache = __importStar(__nccwpck_require__(7799)); const cache = __importStar(__nccwpck_require__(7799));
const core = __importStar(__nccwpck_require__(2186)); const core = __importStar(__nccwpck_require__(2186));
const glob = __importStar(__nccwpck_require__(8090)); const glob = __importStar(__nccwpck_require__(8090));
const path_1 = __importDefault(__nccwpck_require__(1017)); const path_1 = __importDefault(__nccwpck_require__(1017));
const fs_1 = __importDefault(__nccwpck_require__(7147)); const fs_1 = __importDefault(__nccwpck_require__(7147));
const constants_1 = __nccwpck_require__(9042); const constants_1 = __nccwpck_require__(9042);
const cache_utils_1 = __nccwpck_require__(1678); const cache_utils_1 = __nccwpck_require__(1678);
const restoreCache = (packageManager, cacheDependencyPath) => __awaiter(void 0, void 0, void 0, function* () { const restoreCache = (packageManager, cacheDependencyPath) => __awaiter(void 0, void 0, void 0, function* () {
const packageManagerInfo = yield cache_utils_1.getPackageManagerInfo(packageManager); const packageManagerInfo = yield cache_utils_1.getPackageManagerInfo(packageManager);
if (!packageManagerInfo) { if (!packageManagerInfo) {
throw new Error(`Caching for '${packageManager}' is not supported`); throw new Error(`Caching for '${packageManager}' is not supported`);
} }
const platform = process.env.RUNNER_OS; const platform = process.env.RUNNER_OS;
const cachePath = yield cache_utils_1.getCacheDirectoryPath(packageManagerInfo, packageManager); const cachePath = yield cache_utils_1.getCacheDirectoryPath(packageManagerInfo, packageManager);
const lockFilePath = cacheDependencyPath const lockFilePath = cacheDependencyPath
? cacheDependencyPath ? cacheDependencyPath
: findLockFile(packageManagerInfo); : findLockFile(packageManagerInfo);
const fileHash = yield glob.hashFiles(lockFilePath); const fileHash = yield glob.hashFiles(lockFilePath);
if (!fileHash) { if (!fileHash) {
throw new Error('Some specified paths were not resolved, unable to cache dependencies.'); throw new Error('Some specified paths were not resolved, unable to cache dependencies.');
} }
const primaryKey = `node-cache-${platform}-${packageManager}-${fileHash}`; const primaryKey = `node-cache-${platform}-${packageManager}-${fileHash}`;
core.debug(`primary key is ${primaryKey}`); core.debug(`primary key is ${primaryKey}`);
core.saveState(constants_1.State.CachePrimaryKey, primaryKey); core.saveState(constants_1.State.CachePrimaryKey, primaryKey);
const cacheKey = yield cache.restoreCache([cachePath], primaryKey); const cacheKey = yield cache.restoreCache([cachePath], primaryKey);
core.setOutput('cache-hit', Boolean(cacheKey)); core.setOutput('cache-hit', Boolean(cacheKey));
if (!cacheKey) { if (!cacheKey) {
core.info(`${packageManager} cache is not found`); core.info(`${packageManager} cache is not found`);
return; return;
} }
core.saveState(constants_1.State.CacheMatchedKey, cacheKey); core.saveState(constants_1.State.CacheMatchedKey, cacheKey);
core.info(`Cache restored from key: ${cacheKey}`); core.info(`Cache restored from key: ${cacheKey}`);
}); });
exports.restoreCache = restoreCache; exports.restoreCache = restoreCache;
const findLockFile = (packageManager) => { const findLockFile = (packageManager) => {
const lockFiles = packageManager.lockFilePatterns; const lockFiles = packageManager.lockFilePatterns;
const workspace = process.env.GITHUB_WORKSPACE; const workspace = process.env.GITHUB_WORKSPACE;
const rootContent = fs_1.default.readdirSync(workspace); const rootContent = fs_1.default.readdirSync(workspace);
const lockFile = lockFiles.find(item => rootContent.includes(item)); const lockFile = lockFiles.find(item => rootContent.includes(item));
if (!lockFile) { if (!lockFile) {
throw new Error(`Dependencies lock file is not found in ${workspace}. Supported file patterns: ${lockFiles.toString()}`); throw new Error(`Dependencies lock file is not found in ${workspace}. Supported file patterns: ${lockFiles.toString()}`);
} }
return path_1.default.join(workspace, lockFile); return path_1.default.join(workspace, lockFile);
}; };
/***/ }), /***/ }),
@ -71183,123 +71183,123 @@ const findLockFile = (packageManager) => {
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
"use strict"; "use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k; if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) { }) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k; if (k2 === undefined) k2 = k;
o[k2] = m[k]; o[k2] = m[k];
})); }));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v }); Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) { }) : function(o, v) {
o["default"] = v; o["default"] = v;
}); });
var __importStar = (this && this.__importStar) || function (mod) { var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod; if (mod && mod.__esModule) return mod;
var result = {}; var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod); __setModuleDefault(result, mod);
return result; return result;
}; };
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) { return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next()); step((generator = generator.apply(thisArg, _arguments || [])).next());
}); });
}; };
Object.defineProperty(exports, "__esModule", ({ value: true })); Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.isCacheFeatureAvailable = exports.isGhes = exports.getCacheDirectoryPath = exports.getPackageManagerInfo = exports.getCommandOutput = exports.supportedPackageManagers = void 0; exports.isCacheFeatureAvailable = exports.isGhes = exports.getCacheDirectoryPath = exports.getPackageManagerInfo = exports.getCommandOutput = exports.supportedPackageManagers = void 0;
const core = __importStar(__nccwpck_require__(2186)); const core = __importStar(__nccwpck_require__(2186));
const exec = __importStar(__nccwpck_require__(1514)); const exec = __importStar(__nccwpck_require__(1514));
const cache = __importStar(__nccwpck_require__(7799)); const cache = __importStar(__nccwpck_require__(7799));
exports.supportedPackageManagers = { exports.supportedPackageManagers = {
npm: { npm: {
lockFilePatterns: ['package-lock.json', 'npm-shrinkwrap.json', 'yarn.lock'], lockFilePatterns: ['package-lock.json', 'npm-shrinkwrap.json', 'yarn.lock'],
getCacheFolderCommand: 'npm config get cache' getCacheFolderCommand: 'npm config get cache'
}, },
pnpm: { pnpm: {
lockFilePatterns: ['pnpm-lock.yaml'], lockFilePatterns: ['pnpm-lock.yaml'],
getCacheFolderCommand: 'pnpm store path --silent' getCacheFolderCommand: 'pnpm store path --silent'
}, },
yarn1: { yarn1: {
lockFilePatterns: ['yarn.lock'], lockFilePatterns: ['yarn.lock'],
getCacheFolderCommand: 'yarn cache dir' getCacheFolderCommand: 'yarn cache dir'
}, },
yarn2: { yarn2: {
lockFilePatterns: ['yarn.lock'], lockFilePatterns: ['yarn.lock'],
getCacheFolderCommand: 'yarn config get cacheFolder' getCacheFolderCommand: 'yarn config get cacheFolder'
} }
}; };
const getCommandOutput = (toolCommand) => __awaiter(void 0, void 0, void 0, function* () { const getCommandOutput = (toolCommand) => __awaiter(void 0, void 0, void 0, function* () {
let { stdout, stderr, exitCode } = yield exec.getExecOutput(toolCommand, undefined, { ignoreReturnCode: true }); let { stdout, stderr, exitCode } = yield exec.getExecOutput(toolCommand, undefined, { ignoreReturnCode: true });
if (exitCode) { if (exitCode) {
stderr = !stderr.trim() stderr = !stderr.trim()
? `The '${toolCommand}' command failed with exit code: ${exitCode}` ? `The '${toolCommand}' command failed with exit code: ${exitCode}`
: stderr; : stderr;
throw new Error(stderr); throw new Error(stderr);
} }
return stdout.trim(); return stdout.trim();
}); });
exports.getCommandOutput = getCommandOutput; exports.getCommandOutput = getCommandOutput;
const getPackageManagerVersion = (packageManager, command) => __awaiter(void 0, void 0, void 0, function* () { const getPackageManagerVersion = (packageManager, command) => __awaiter(void 0, void 0, void 0, function* () {
const stdOut = yield exports.getCommandOutput(`${packageManager} ${command}`); const stdOut = yield exports.getCommandOutput(`${packageManager} ${command}`);
if (!stdOut) { if (!stdOut) {
throw new Error(`Could not retrieve version of ${packageManager}`); throw new Error(`Could not retrieve version of ${packageManager}`);
} }
return stdOut; return stdOut;
}); });
const getPackageManagerInfo = (packageManager) => __awaiter(void 0, void 0, void 0, function* () { const getPackageManagerInfo = (packageManager) => __awaiter(void 0, void 0, void 0, function* () {
if (packageManager === 'npm') { if (packageManager === 'npm') {
return exports.supportedPackageManagers.npm; return exports.supportedPackageManagers.npm;
} }
else if (packageManager === 'pnpm') { else if (packageManager === 'pnpm') {
return exports.supportedPackageManagers.pnpm; return exports.supportedPackageManagers.pnpm;
} }
else if (packageManager === 'yarn') { else if (packageManager === 'yarn') {
const yarnVersion = yield getPackageManagerVersion('yarn', '--version'); const yarnVersion = yield getPackageManagerVersion('yarn', '--version');
core.debug(`Consumed yarn version is ${yarnVersion}`); core.debug(`Consumed yarn version is ${yarnVersion}`);
if (yarnVersion.startsWith('1.')) { if (yarnVersion.startsWith('1.')) {
return exports.supportedPackageManagers.yarn1; return exports.supportedPackageManagers.yarn1;
} }
else { else {
return exports.supportedPackageManagers.yarn2; return exports.supportedPackageManagers.yarn2;
} }
} }
else { else {
return null; return null;
} }
}); });
exports.getPackageManagerInfo = getPackageManagerInfo; exports.getPackageManagerInfo = getPackageManagerInfo;
const getCacheDirectoryPath = (packageManagerInfo, packageManager) => __awaiter(void 0, void 0, void 0, function* () { const getCacheDirectoryPath = (packageManagerInfo, packageManager) => __awaiter(void 0, void 0, void 0, function* () {
const stdOut = yield exports.getCommandOutput(packageManagerInfo.getCacheFolderCommand); const stdOut = yield exports.getCommandOutput(packageManagerInfo.getCacheFolderCommand);
if (!stdOut) { if (!stdOut) {
throw new Error(`Could not get cache folder path for ${packageManager}`); throw new Error(`Could not get cache folder path for ${packageManager}`);
} }
core.debug(`${packageManager} path is ${stdOut}`); core.debug(`${packageManager} path is ${stdOut}`);
return stdOut.trim(); return stdOut.trim();
}); });
exports.getCacheDirectoryPath = getCacheDirectoryPath; exports.getCacheDirectoryPath = getCacheDirectoryPath;
function isGhes() { function isGhes() {
const ghUrl = new URL(process.env['GITHUB_SERVER_URL'] || 'https://github.com'); const ghUrl = new URL(process.env['GITHUB_SERVER_URL'] || 'https://github.com');
return ghUrl.hostname.toUpperCase() !== 'GITHUB.COM'; return ghUrl.hostname.toUpperCase() !== 'GITHUB.COM';
} }
exports.isGhes = isGhes; exports.isGhes = isGhes;
function isCacheFeatureAvailable() { function isCacheFeatureAvailable() {
if (cache.isFeatureAvailable()) if (cache.isFeatureAvailable())
return true; return true;
if (isGhes()) { if (isGhes()) {
core.warning('Cache action is only supported on GHES version >= 3.5. If you are on version >=3.5 Please check with GHES admin if Actions cache service is enabled or not.'); core.warning('Cache action is only supported on GHES version >= 3.5. If you are on version >=3.5 Please check with GHES admin if Actions cache service is enabled or not.');
return false; return false;
} }
core.warning('The runner was not able to contact the cache service. Caching will be skipped'); core.warning('The runner was not able to contact the cache service. Caching will be skipped');
return false; return false;
} }
exports.isCacheFeatureAvailable = isCacheFeatureAvailable; exports.isCacheFeatureAvailable = isCacheFeatureAvailable;
/***/ }), /***/ }),
@ -71308,24 +71308,24 @@ exports.isCacheFeatureAvailable = isCacheFeatureAvailable;
/***/ ((__unused_webpack_module, exports) => { /***/ ((__unused_webpack_module, exports) => {
"use strict"; "use strict";
Object.defineProperty(exports, "__esModule", ({ value: true })); Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.Outputs = exports.State = exports.LockType = void 0; exports.Outputs = exports.State = exports.LockType = void 0;
var LockType; var LockType;
(function (LockType) { (function (LockType) {
LockType["Npm"] = "npm"; LockType["Npm"] = "npm";
LockType["Pnpm"] = "pnpm"; LockType["Pnpm"] = "pnpm";
LockType["Yarn"] = "yarn"; LockType["Yarn"] = "yarn";
})(LockType = exports.LockType || (exports.LockType = {})); })(LockType = exports.LockType || (exports.LockType = {}));
var State; var State;
(function (State) { (function (State) {
State["CachePrimaryKey"] = "CACHE_KEY"; State["CachePrimaryKey"] = "CACHE_KEY";
State["CacheMatchedKey"] = "CACHE_RESULT"; State["CacheMatchedKey"] = "CACHE_RESULT";
})(State = exports.State || (exports.State = {})); })(State = exports.State || (exports.State = {}));
var Outputs; var Outputs;
(function (Outputs) { (function (Outputs) {
Outputs["CacheHit"] = "cache-hit"; Outputs["CacheHit"] = "cache-hit";
})(Outputs = exports.Outputs || (exports.Outputs = {})); })(Outputs = exports.Outputs || (exports.Outputs = {}));
/***/ }), /***/ }),
@ -71334,73 +71334,73 @@ var Outputs;
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
"use strict"; "use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k; if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) { }) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k; if (k2 === undefined) k2 = k;
o[k2] = m[k]; o[k2] = m[k];
})); }));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v }); Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) { }) : function(o, v) {
o["default"] = v; o["default"] = v;
}); });
var __importStar = (this && this.__importStar) || function (mod) { var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod; if (mod && mod.__esModule) return mod;
var result = {}; var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod); __setModuleDefault(result, mod);
return result; return result;
}; };
var __importDefault = (this && this.__importDefault) || function (mod) { var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod }; return (mod && mod.__esModule) ? mod : { "default": mod };
}; };
Object.defineProperty(exports, "__esModule", ({ value: true })); Object.defineProperty(exports, "__esModule", ({ value: true }));
const tc = __importStar(__nccwpck_require__(7784)); const tc = __importStar(__nccwpck_require__(7784));
const semver_1 = __importDefault(__nccwpck_require__(5911)); const semver_1 = __importDefault(__nccwpck_require__(5911));
const base_distribution_1 = __importDefault(__nccwpck_require__(7)); const base_distribution_1 = __importDefault(__nccwpck_require__(7));
class BasePrereleaseNodejs extends base_distribution_1.default { class BasePrereleaseNodejs extends base_distribution_1.default {
constructor(nodeInfo) { constructor(nodeInfo) {
super(nodeInfo); super(nodeInfo);
} }
findVersionInHostedToolCacheDirectory() { findVersionInHostedToolCacheDirectory() {
let toolPath = ''; let toolPath = '';
const localVersionPaths = tc const localVersionPaths = tc
.findAllVersions('node', this.nodeInfo.arch) .findAllVersions('node', this.nodeInfo.arch)
.filter(i => { .filter(i => {
const prerelease = semver_1.default.prerelease(i); const prerelease = semver_1.default.prerelease(i);
if (!prerelease) { if (!prerelease) {
return false; return false;
} }
return prerelease[0].includes(this.distribution); return prerelease[0].includes(this.distribution);
}); });
localVersionPaths.sort(semver_1.default.rcompare); localVersionPaths.sort(semver_1.default.rcompare);
const localVersion = this.evaluateVersions(localVersionPaths); const localVersion = this.evaluateVersions(localVersionPaths);
if (localVersion) { if (localVersion) {
toolPath = tc.find('node', localVersion, this.nodeInfo.arch); toolPath = tc.find('node', localVersion, this.nodeInfo.arch);
} }
return toolPath; return toolPath;
} }
validRange(versionSpec) { validRange(versionSpec) {
let range; let range;
const [raw, prerelease] = this.splitVersionSpec(versionSpec); const [raw, prerelease] = this.splitVersionSpec(versionSpec);
const isValidVersion = semver_1.default.valid(raw); const isValidVersion = semver_1.default.valid(raw);
const rawVersion = (isValidVersion ? raw : semver_1.default.coerce(raw)); const rawVersion = (isValidVersion ? raw : semver_1.default.coerce(raw));
if (prerelease !== this.distribution) { if (prerelease !== this.distribution) {
range = versionSpec; range = versionSpec;
} }
else { else {
range = `${semver_1.default.validRange(`^${rawVersion}-${this.distribution}`)}-0`; range = `${semver_1.default.validRange(`^${rawVersion}-${this.distribution}`)}-0`;
} }
return { range, options: { includePrerelease: !isValidVersion } }; return { range, options: { includePrerelease: !isValidVersion } };
} }
splitVersionSpec(versionSpec) { splitVersionSpec(versionSpec) {
return versionSpec.split(/-(.*)/s); return versionSpec.split(/-(.*)/s);
} }
} }
exports["default"] = BasePrereleaseNodejs; exports["default"] = BasePrereleaseNodejs;
/***/ }), /***/ }),
@ -71409,275 +71409,275 @@ exports["default"] = BasePrereleaseNodejs;
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
"use strict"; "use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k; if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) { }) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k; if (k2 === undefined) k2 = k;
o[k2] = m[k]; o[k2] = m[k];
})); }));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v }); Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) { }) : function(o, v) {
o["default"] = v; o["default"] = v;
}); });
var __importStar = (this && this.__importStar) || function (mod) { var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod; if (mod && mod.__esModule) return mod;
var result = {}; var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod); __setModuleDefault(result, mod);
return result; return result;
}; };
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) { return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next()); step((generator = generator.apply(thisArg, _arguments || [])).next());
}); });
}; };
var __importDefault = (this && this.__importDefault) || function (mod) { var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod }; return (mod && mod.__esModule) ? mod : { "default": mod };
}; };
Object.defineProperty(exports, "__esModule", ({ value: true })); Object.defineProperty(exports, "__esModule", ({ value: true }));
const tc = __importStar(__nccwpck_require__(7784)); const tc = __importStar(__nccwpck_require__(7784));
const hc = __importStar(__nccwpck_require__(9925)); const hc = __importStar(__nccwpck_require__(9925));
const core = __importStar(__nccwpck_require__(2186)); const core = __importStar(__nccwpck_require__(2186));
const io = __importStar(__nccwpck_require__(7436)); const io = __importStar(__nccwpck_require__(7436));
const semver_1 = __importDefault(__nccwpck_require__(5911)); const semver_1 = __importDefault(__nccwpck_require__(5911));
const assert = __importStar(__nccwpck_require__(9491)); const assert = __importStar(__nccwpck_require__(9491));
const path = __importStar(__nccwpck_require__(1017)); const path = __importStar(__nccwpck_require__(1017));
const os_1 = __importDefault(__nccwpck_require__(2037)); const os_1 = __importDefault(__nccwpck_require__(2037));
const fs_1 = __importDefault(__nccwpck_require__(7147)); const fs_1 = __importDefault(__nccwpck_require__(7147));
class BaseDistribution { class BaseDistribution {
constructor(nodeInfo) { constructor(nodeInfo) {
this.nodeInfo = nodeInfo; this.nodeInfo = nodeInfo;
this.osPlat = os_1.default.platform(); this.osPlat = os_1.default.platform();
this.httpClient = new hc.HttpClient('setup-node', [], { this.httpClient = new hc.HttpClient('setup-node', [], {
allowRetries: true, allowRetries: true,
maxRetries: 3 maxRetries: 3
}); });
} }
setupNodeJs() { setupNodeJs() {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
let nodeJsVersions; let nodeJsVersions;
if (this.nodeInfo.checkLatest) { if (this.nodeInfo.checkLatest) {
const evaluatedVersion = yield this.findVersionInDist(nodeJsVersions); const evaluatedVersion = yield this.findVersionInDist(nodeJsVersions);
this.nodeInfo.versionSpec = evaluatedVersion; this.nodeInfo.versionSpec = evaluatedVersion;
} }
let toolPath = this.findVersionInHostedToolCacheDirectory(); let toolPath = this.findVersionInHostedToolCacheDirectory();
if (toolPath) { if (toolPath) {
core.info(`Found in cache @ ${toolPath}`); core.info(`Found in cache @ ${toolPath}`);
} }
else { else {
const evaluatedVersion = yield this.findVersionInDist(nodeJsVersions); const evaluatedVersion = yield this.findVersionInDist(nodeJsVersions);
const toolName = this.getNodejsDistInfo(evaluatedVersion); const toolName = this.getNodejsDistInfo(evaluatedVersion);
toolPath = yield this.downloadNodejs(toolName); toolPath = yield this.downloadNodejs(toolName);
} }
if (this.osPlat != 'win32') { if (this.osPlat != 'win32') {
toolPath = path.join(toolPath, 'bin'); toolPath = path.join(toolPath, 'bin');
} }
core.addPath(toolPath); core.addPath(toolPath);
}); });
} }
findVersionInDist(nodeJsVersions) { findVersionInDist(nodeJsVersions) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
if (!nodeJsVersions) { if (!nodeJsVersions) {
nodeJsVersions = yield this.getNodeJsVersions(); nodeJsVersions = yield this.getNodeJsVersions();
} }
const versions = this.filterVersions(nodeJsVersions); const versions = this.filterVersions(nodeJsVersions);
const evaluatedVersion = this.evaluateVersions(versions); const evaluatedVersion = this.evaluateVersions(versions);
if (!evaluatedVersion) { if (!evaluatedVersion) {
throw new Error(`Unable to find Node version '${this.nodeInfo.versionSpec}' for platform ${this.osPlat} and architecture ${this.nodeInfo.arch}.`); throw new Error(`Unable to find Node version '${this.nodeInfo.versionSpec}' for platform ${this.osPlat} and architecture ${this.nodeInfo.arch}.`);
} }
return evaluatedVersion; return evaluatedVersion;
}); });
} }
evaluateVersions(versions) { evaluateVersions(versions) {
let version = ''; let version = '';
const { range, options } = this.validRange(this.nodeInfo.versionSpec); const { range, options } = this.validRange(this.nodeInfo.versionSpec);
core.debug(`evaluating ${versions.length} versions`); core.debug(`evaluating ${versions.length} versions`);
for (const potential of versions) { for (const potential of versions) {
const satisfied = semver_1.default.satisfies(potential, range, options); const satisfied = semver_1.default.satisfies(potential, range, options);
if (satisfied) { if (satisfied) {
version = potential; version = potential;
break; break;
} }
} }
if (version) { if (version) {
core.debug(`matched: ${version}`); core.debug(`matched: ${version}`);
} }
else { else {
core.debug('match not found'); core.debug('match not found');
} }
return version; return version;
} }
findVersionInHostedToolCacheDirectory() { findVersionInHostedToolCacheDirectory() {
return tc.find('node', this.nodeInfo.versionSpec, this.nodeInfo.arch); return tc.find('node', this.nodeInfo.versionSpec, this.nodeInfo.arch);
} }
getNodeJsVersions() { getNodeJsVersions() {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
const initialUrl = this.getDistributionUrl(); const initialUrl = this.getDistributionUrl();
const dataUrl = `${initialUrl}/index.json`; const dataUrl = `${initialUrl}/index.json`;
const response = yield this.httpClient.getJson(dataUrl); const response = yield this.httpClient.getJson(dataUrl);
return response.result || []; return response.result || [];
}); });
} }
getNodejsDistInfo(version) { getNodejsDistInfo(version) {
const osArch = this.translateArchToDistUrl(this.nodeInfo.arch); const osArch = this.translateArchToDistUrl(this.nodeInfo.arch);
version = semver_1.default.clean(version) || ''; version = semver_1.default.clean(version) || '';
const fileName = this.osPlat == 'win32' const fileName = this.osPlat == 'win32'
? `node-v${version}-win-${osArch}` ? `node-v${version}-win-${osArch}`
: `node-v${version}-${this.osPlat}-${osArch}`; : `node-v${version}-${this.osPlat}-${osArch}`;
const urlFileName = this.osPlat == 'win32' ? `${fileName}.7z` : `${fileName}.tar.gz`; const urlFileName = this.osPlat == 'win32' ? `${fileName}.7z` : `${fileName}.tar.gz`;
const initialUrl = this.getDistributionUrl(); const initialUrl = this.getDistributionUrl();
const url = `${initialUrl}/v${version}/${urlFileName}`; const url = `${initialUrl}/v${version}/${urlFileName}`;
return { return {
downloadUrl: url, downloadUrl: url,
resolvedVersion: version, resolvedVersion: version,
arch: osArch, arch: osArch,
fileName: fileName fileName: fileName
}; };
} }
downloadNodejs(info) { downloadNodejs(info) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
let downloadPath = ''; let downloadPath = '';
core.info(`Acquiring ${info.resolvedVersion} - ${info.arch} from ${info.downloadUrl}`); core.info(`Acquiring ${info.resolvedVersion} - ${info.arch} from ${info.downloadUrl}`);
try { try {
downloadPath = yield tc.downloadTool(info.downloadUrl); downloadPath = yield tc.downloadTool(info.downloadUrl);
} }
catch (err) { catch (err) {
if (err instanceof tc.HTTPError && if (err instanceof tc.HTTPError &&
err.httpStatusCode == 404 && err.httpStatusCode == 404 &&
this.osPlat == 'win32') { this.osPlat == 'win32') {
return yield this.acquireWindowsNodeFromFallbackLocation(info.resolvedVersion, info.arch); return yield this.acquireWindowsNodeFromFallbackLocation(info.resolvedVersion, info.arch);
} }
throw err; throw err;
} }
const toolPath = yield this.extractArchive(downloadPath, info); const toolPath = yield this.extractArchive(downloadPath, info);
core.info('Done'); core.info('Done');
return toolPath; return toolPath;
}); });
} }
validRange(versionSpec) { validRange(versionSpec) {
var _a; var _a;
let options; let options;
const c = semver_1.default.clean(versionSpec) || ''; const c = semver_1.default.clean(versionSpec) || '';
const valid = (_a = semver_1.default.valid(c)) !== null && _a !== void 0 ? _a : versionSpec; const valid = (_a = semver_1.default.valid(c)) !== null && _a !== void 0 ? _a : versionSpec;
return { range: valid, options }; return { range: valid, options };
} }
acquireWindowsNodeFromFallbackLocation(version, arch = os_1.default.arch()) { acquireWindowsNodeFromFallbackLocation(version, arch = os_1.default.arch()) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
const initialUrl = this.getDistributionUrl(); const initialUrl = this.getDistributionUrl();
const osArch = this.translateArchToDistUrl(arch); const osArch = this.translateArchToDistUrl(arch);
// Create temporary folder to download in to // Create temporary folder to download in to
const tempDownloadFolder = 'temp_' + Math.floor(Math.random() * 2000000000); const tempDownloadFolder = 'temp_' + Math.floor(Math.random() * 2000000000);
const tempDirectory = process.env['RUNNER_TEMP'] || ''; const tempDirectory = process.env['RUNNER_TEMP'] || '';
assert.ok(tempDirectory, 'Expected RUNNER_TEMP to be defined'); assert.ok(tempDirectory, 'Expected RUNNER_TEMP to be defined');
const tempDir = path.join(tempDirectory, tempDownloadFolder); const tempDir = path.join(tempDirectory, tempDownloadFolder);
yield io.mkdirP(tempDir); yield io.mkdirP(tempDir);
let exeUrl; let exeUrl;
let libUrl; let libUrl;
try { try {
exeUrl = `${initialUrl}/v${version}/win-${osArch}/node.exe`; exeUrl = `${initialUrl}/v${version}/win-${osArch}/node.exe`;
libUrl = `${initialUrl}/v${version}/win-${osArch}/node.lib`; libUrl = `${initialUrl}/v${version}/win-${osArch}/node.lib`;
core.info(`Downloading only node binary from ${exeUrl}`); core.info(`Downloading only node binary from ${exeUrl}`);
const exePath = yield tc.downloadTool(exeUrl); const exePath = yield tc.downloadTool(exeUrl);
yield io.cp(exePath, path.join(tempDir, 'node.exe')); yield io.cp(exePath, path.join(tempDir, 'node.exe'));
const libPath = yield tc.downloadTool(libUrl); const libPath = yield tc.downloadTool(libUrl);
yield io.cp(libPath, path.join(tempDir, 'node.lib')); yield io.cp(libPath, path.join(tempDir, 'node.lib'));
} }
catch (err) { catch (err) {
if (err instanceof tc.HTTPError && err.httpStatusCode == 404) { if (err instanceof tc.HTTPError && err.httpStatusCode == 404) {
exeUrl = `${initialUrl}/v${version}/node.exe`; exeUrl = `${initialUrl}/v${version}/node.exe`;
libUrl = `${initialUrl}/v${version}/node.lib`; libUrl = `${initialUrl}/v${version}/node.lib`;
const exePath = yield tc.downloadTool(exeUrl); const exePath = yield tc.downloadTool(exeUrl);
yield io.cp(exePath, path.join(tempDir, 'node.exe')); yield io.cp(exePath, path.join(tempDir, 'node.exe'));
const libPath = yield tc.downloadTool(libUrl); const libPath = yield tc.downloadTool(libUrl);
yield io.cp(libPath, path.join(tempDir, 'node.lib')); yield io.cp(libPath, path.join(tempDir, 'node.lib'));
} }
else { else {
throw err; throw err;
} }
} }
const toolPath = yield tc.cacheDir(tempDir, 'node', version, arch); const toolPath = yield tc.cacheDir(tempDir, 'node', version, arch);
return toolPath; return toolPath;
}); });
} }
extractArchive(downloadPath, info) { extractArchive(downloadPath, info) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
// //
// Extract // Extract
// //
core.info('Extracting ...'); core.info('Extracting ...');
let extPath; let extPath;
info = info || {}; // satisfy compiler, never null when reaches here info = info || {}; // satisfy compiler, never null when reaches here
if (this.osPlat == 'win32') { if (this.osPlat == 'win32') {
const _7zPath = path.join(__dirname, '../..', 'externals', '7zr.exe'); const _7zPath = path.join(__dirname, '../..', 'externals', '7zr.exe');
extPath = yield tc.extract7z(downloadPath, undefined, _7zPath); extPath = yield tc.extract7z(downloadPath, undefined, _7zPath);
// 7z extracts to folder matching file name // 7z extracts to folder matching file name
const nestedPath = path.join(extPath, path.basename(info.fileName, '.7z')); const nestedPath = path.join(extPath, path.basename(info.fileName, '.7z'));
if (fs_1.default.existsSync(nestedPath)) { if (fs_1.default.existsSync(nestedPath)) {
extPath = nestedPath; extPath = nestedPath;
} }
} }
else { else {
extPath = yield tc.extractTar(downloadPath, undefined, [ extPath = yield tc.extractTar(downloadPath, undefined, [
'xz', 'xz',
'--strip', '--strip',
'1' '1'
]); ]);
} }
// //
// Install into the local tool cache - node extracts with a root folder that matches the fileName downloaded // Install into the local tool cache - node extracts with a root folder that matches the fileName downloaded
// //
core.info('Adding to the cache ...'); core.info('Adding to the cache ...');
const toolPath = yield tc.cacheDir(extPath, 'node', info.resolvedVersion, info.arch); const toolPath = yield tc.cacheDir(extPath, 'node', info.resolvedVersion, info.arch);
return toolPath; return toolPath;
}); });
} }
getDistFileName() { getDistFileName() {
const osArch = this.translateArchToDistUrl(this.nodeInfo.arch); const osArch = this.translateArchToDistUrl(this.nodeInfo.arch);
// node offers a json list of versions // node offers a json list of versions
let dataFileName; let dataFileName;
switch (this.osPlat) { switch (this.osPlat) {
case 'linux': case 'linux':
dataFileName = `linux-${osArch}`; dataFileName = `linux-${osArch}`;
break; break;
case 'darwin': case 'darwin':
dataFileName = `osx-${osArch}-tar`; dataFileName = `osx-${osArch}-tar`;
break; break;
case 'win32': case 'win32':
dataFileName = `win-${osArch}-exe`; dataFileName = `win-${osArch}-exe`;
break; break;
default: default:
throw new Error(`Unexpected OS '${this.osPlat}'`); throw new Error(`Unexpected OS '${this.osPlat}'`);
} }
return dataFileName; return dataFileName;
} }
filterVersions(nodeJsVersions) { filterVersions(nodeJsVersions) {
const versions = []; const versions = [];
const dataFileName = this.getDistFileName(); const dataFileName = this.getDistFileName();
nodeJsVersions.forEach((nodeVersion) => { nodeJsVersions.forEach((nodeVersion) => {
// ensure this version supports your os and platform // ensure this version supports your os and platform
if (nodeVersion.files.indexOf(dataFileName) >= 0) { if (nodeVersion.files.indexOf(dataFileName) >= 0) {
versions.push(nodeVersion.version); versions.push(nodeVersion.version);
} }
}); });
return versions.sort(semver_1.default.rcompare); return versions.sort(semver_1.default.rcompare);
} }
translateArchToDistUrl(arch) { translateArchToDistUrl(arch) {
switch (arch) { switch (arch) {
case 'arm': case 'arm':
return 'armv7l'; return 'armv7l';
default: default:
return arch; return arch;
} }
} }
} }
exports["default"] = BaseDistribution; exports["default"] = BaseDistribution;
/***/ }), /***/ }),
@ -71686,41 +71686,41 @@ exports["default"] = BaseDistribution;
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
"use strict"; "use strict";
var __importDefault = (this && this.__importDefault) || function (mod) { var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod }; return (mod && mod.__esModule) ? mod : { "default": mod };
}; };
Object.defineProperty(exports, "__esModule", ({ value: true })); Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.getNodejsDistribution = void 0; exports.getNodejsDistribution = void 0;
const nightly_builds_1 = __importDefault(__nccwpck_require__(7127)); const nightly_builds_1 = __importDefault(__nccwpck_require__(7127));
const official_builds_1 = __importDefault(__nccwpck_require__(7854)); const official_builds_1 = __importDefault(__nccwpck_require__(7854));
const rc_builds_1 = __importDefault(__nccwpck_require__(8837)); const rc_builds_1 = __importDefault(__nccwpck_require__(8837));
const canary_builds_1 = __importDefault(__nccwpck_require__(969)); const canary_builds_1 = __importDefault(__nccwpck_require__(969));
var Distributions; var Distributions;
(function (Distributions) { (function (Distributions) {
Distributions["DEFAULT"] = ""; Distributions["DEFAULT"] = "";
Distributions["CANARY"] = "v8-canary"; Distributions["CANARY"] = "v8-canary";
Distributions["NIGHTLY"] = "nightly"; Distributions["NIGHTLY"] = "nightly";
Distributions["RC"] = "rc"; Distributions["RC"] = "rc";
})(Distributions || (Distributions = {})); })(Distributions || (Distributions = {}));
function getNodejsDistribution(installerOptions) { function getNodejsDistribution(installerOptions) {
const versionSpec = installerOptions.versionSpec; const versionSpec = installerOptions.versionSpec;
let distribution; let distribution;
if (versionSpec.includes(Distributions.NIGHTLY)) { if (versionSpec.includes(Distributions.NIGHTLY)) {
distribution = new nightly_builds_1.default(installerOptions); distribution = new nightly_builds_1.default(installerOptions);
} }
else if (versionSpec.includes(Distributions.CANARY)) { else if (versionSpec.includes(Distributions.CANARY)) {
distribution = new canary_builds_1.default(installerOptions); distribution = new canary_builds_1.default(installerOptions);
} }
else if (versionSpec.includes(Distributions.RC)) { else if (versionSpec.includes(Distributions.RC)) {
distribution = new rc_builds_1.default(installerOptions); distribution = new rc_builds_1.default(installerOptions);
} }
else { else {
distribution = new official_builds_1.default(installerOptions); distribution = new official_builds_1.default(installerOptions);
} }
return distribution; return distribution;
} }
exports.getNodejsDistribution = getNodejsDistribution; exports.getNodejsDistribution = getNodejsDistribution;
/***/ }), /***/ }),
@ -71729,22 +71729,22 @@ exports.getNodejsDistribution = getNodejsDistribution;
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
"use strict"; "use strict";
var __importDefault = (this && this.__importDefault) || function (mod) { var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod }; return (mod && mod.__esModule) ? mod : { "default": mod };
}; };
Object.defineProperty(exports, "__esModule", ({ value: true })); Object.defineProperty(exports, "__esModule", ({ value: true }));
const base_distribution_prerelease_1 = __importDefault(__nccwpck_require__(957)); const base_distribution_prerelease_1 = __importDefault(__nccwpck_require__(957));
class NightlyNodejs extends base_distribution_prerelease_1.default { class NightlyNodejs extends base_distribution_prerelease_1.default {
constructor(nodeInfo) { constructor(nodeInfo) {
super(nodeInfo); super(nodeInfo);
this.distribution = 'nightly'; this.distribution = 'nightly';
} }
getDistributionUrl() { getDistributionUrl() {
return 'https://nodejs.org/download/nightly'; return 'https://nodejs.org/download/nightly';
} }
} }
exports["default"] = NightlyNodejs; exports["default"] = NightlyNodejs;
/***/ }), /***/ }),
@ -71753,203 +71753,203 @@ exports["default"] = NightlyNodejs;
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
"use strict"; "use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k; if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) { }) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k; if (k2 === undefined) k2 = k;
o[k2] = m[k]; o[k2] = m[k];
})); }));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v }); Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) { }) : function(o, v) {
o["default"] = v; o["default"] = v;
}); });
var __importStar = (this && this.__importStar) || function (mod) { var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod; if (mod && mod.__esModule) return mod;
var result = {}; var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod); __setModuleDefault(result, mod);
return result; return result;
}; };
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) { return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next()); step((generator = generator.apply(thisArg, _arguments || [])).next());
}); });
}; };
var __importDefault = (this && this.__importDefault) || function (mod) { var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod }; return (mod && mod.__esModule) ? mod : { "default": mod };
}; };
Object.defineProperty(exports, "__esModule", ({ value: true })); Object.defineProperty(exports, "__esModule", ({ value: true }));
const core = __importStar(__nccwpck_require__(2186)); const core = __importStar(__nccwpck_require__(2186));
const tc = __importStar(__nccwpck_require__(7784)); const tc = __importStar(__nccwpck_require__(7784));
const path_1 = __importDefault(__nccwpck_require__(1017)); const path_1 = __importDefault(__nccwpck_require__(1017));
const base_distribution_1 = __importDefault(__nccwpck_require__(7)); const base_distribution_1 = __importDefault(__nccwpck_require__(7));
class OfficialBuilds extends base_distribution_1.default { class OfficialBuilds extends base_distribution_1.default {
constructor(nodeInfo) { constructor(nodeInfo) {
super(nodeInfo); super(nodeInfo);
} }
setupNodeJs() { setupNodeJs() {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
let manifest; let manifest;
let nodeJsVersions; let nodeJsVersions;
const osArch = this.translateArchToDistUrl(this.nodeInfo.arch); const osArch = this.translateArchToDistUrl(this.nodeInfo.arch);
if (this.isLtsAlias(this.nodeInfo.versionSpec)) { if (this.isLtsAlias(this.nodeInfo.versionSpec)) {
core.info('Attempt to resolve LTS alias from manifest...'); core.info('Attempt to resolve LTS alias from manifest...');
// No try-catch since it's not possible to resolve LTS alias without manifest // No try-catch since it's not possible to resolve LTS alias without manifest
manifest = yield this.getManifest(); manifest = yield this.getManifest();
this.nodeInfo.versionSpec = this.resolveLtsAliasFromManifest(this.nodeInfo.versionSpec, this.nodeInfo.stable, manifest); this.nodeInfo.versionSpec = this.resolveLtsAliasFromManifest(this.nodeInfo.versionSpec, this.nodeInfo.stable, manifest);
} }
if (this.isLatestSyntax(this.nodeInfo.versionSpec)) { if (this.isLatestSyntax(this.nodeInfo.versionSpec)) {
nodeJsVersions = yield this.getNodeJsVersions(); nodeJsVersions = yield this.getNodeJsVersions();
const versions = this.filterVersions(nodeJsVersions); const versions = this.filterVersions(nodeJsVersions);
this.nodeInfo.versionSpec = this.evaluateVersions(versions); this.nodeInfo.versionSpec = this.evaluateVersions(versions);
core.info('getting latest node version...'); core.info('getting latest node version...');
} }
if (this.nodeInfo.checkLatest) { if (this.nodeInfo.checkLatest) {
core.info('Attempt to resolve the latest version from manifest...'); core.info('Attempt to resolve the latest version from manifest...');
const resolvedVersion = yield this.resolveVersionFromManifest(this.nodeInfo.versionSpec, this.nodeInfo.stable, osArch, manifest); const resolvedVersion = yield this.resolveVersionFromManifest(this.nodeInfo.versionSpec, this.nodeInfo.stable, osArch, manifest);
if (resolvedVersion) { if (resolvedVersion) {
this.nodeInfo.versionSpec = resolvedVersion; this.nodeInfo.versionSpec = resolvedVersion;
core.info(`Resolved as '${resolvedVersion}'`); core.info(`Resolved as '${resolvedVersion}'`);
} }
else { else {
core.info(`Failed to resolve version ${this.nodeInfo.versionSpec} from manifest`); core.info(`Failed to resolve version ${this.nodeInfo.versionSpec} from manifest`);
} }
} }
let toolPath = this.findVersionInHostedToolCacheDirectory(); let toolPath = this.findVersionInHostedToolCacheDirectory();
if (toolPath) { if (toolPath) {
core.info(`Found in cache @ ${toolPath}`); core.info(`Found in cache @ ${toolPath}`);
} }
else { else {
let downloadPath = ''; let downloadPath = '';
try { try {
core.info(`Attempting to download ${this.nodeInfo.versionSpec}...`); core.info(`Attempting to download ${this.nodeInfo.versionSpec}...`);
const versionInfo = yield this.getInfoFromManifest(this.nodeInfo.versionSpec, this.nodeInfo.stable, osArch, manifest); const versionInfo = yield this.getInfoFromManifest(this.nodeInfo.versionSpec, this.nodeInfo.stable, osArch, manifest);
if (versionInfo) { if (versionInfo) {
core.info(`Acquiring ${versionInfo.resolvedVersion} - ${versionInfo.arch} from ${versionInfo.downloadUrl}`); core.info(`Acquiring ${versionInfo.resolvedVersion} - ${versionInfo.arch} from ${versionInfo.downloadUrl}`);
downloadPath = yield tc.downloadTool(versionInfo.downloadUrl, undefined, this.nodeInfo.auth); downloadPath = yield tc.downloadTool(versionInfo.downloadUrl, undefined, this.nodeInfo.auth);
if (downloadPath) { if (downloadPath) {
toolPath = yield this.extractArchive(downloadPath, versionInfo); toolPath = yield this.extractArchive(downloadPath, versionInfo);
} }
} }
else { else {
core.info('Not found in manifest. Falling back to download directly from Node'); core.info('Not found in manifest. Falling back to download directly from Node');
} }
} }
catch (err) { catch (err) {
// Rate limit? // Rate limit?
if (err instanceof tc.HTTPError && if (err instanceof tc.HTTPError &&
(err.httpStatusCode === 403 || err.httpStatusCode === 429)) { (err.httpStatusCode === 403 || err.httpStatusCode === 429)) {
core.info(`Received HTTP status code ${err.httpStatusCode}. This usually indicates the rate limit has been exceeded`); core.info(`Received HTTP status code ${err.httpStatusCode}. This usually indicates the rate limit has been exceeded`);
} }
else { else {
core.info(err.message); core.info(err.message);
} }
core.debug(err.stack); core.debug(err.stack);
core.info('Falling back to download directly from Node'); core.info('Falling back to download directly from Node');
} }
if (!toolPath) { if (!toolPath) {
const nodeJsVersions = yield this.getNodeJsVersions(); const nodeJsVersions = yield this.getNodeJsVersions();
const versions = this.filterVersions(nodeJsVersions); const versions = this.filterVersions(nodeJsVersions);
const evaluatedVersion = this.evaluateVersions(versions); const evaluatedVersion = this.evaluateVersions(versions);
if (!evaluatedVersion) { if (!evaluatedVersion) {
throw new Error(`Unable to find Node version '${this.nodeInfo.versionSpec}' for platform ${this.osPlat} and architecture ${this.nodeInfo.arch}.`); throw new Error(`Unable to find Node version '${this.nodeInfo.versionSpec}' for platform ${this.osPlat} and architecture ${this.nodeInfo.arch}.`);
} }
const toolName = this.getNodejsDistInfo(evaluatedVersion); const toolName = this.getNodejsDistInfo(evaluatedVersion);
toolPath = yield this.downloadNodejs(toolName); toolPath = yield this.downloadNodejs(toolName);
} }
} }
if (this.osPlat != 'win32') { if (this.osPlat != 'win32') {
toolPath = path_1.default.join(toolPath, 'bin'); toolPath = path_1.default.join(toolPath, 'bin');
} }
core.addPath(toolPath); core.addPath(toolPath);
}); });
} }
evaluateVersions(versions) { evaluateVersions(versions) {
let version = ''; let version = '';
if (this.isLatestSyntax(this.nodeInfo.versionSpec)) { if (this.isLatestSyntax(this.nodeInfo.versionSpec)) {
core.info(`getting latest node version...`); core.info(`getting latest node version...`);
return versions[0]; return versions[0];
} }
version = super.evaluateVersions(versions); version = super.evaluateVersions(versions);
return version; return version;
} }
getDistributionUrl() { getDistributionUrl() {
return `https://nodejs.org/dist`; return `https://nodejs.org/dist`;
} }
getManifest() { getManifest() {
core.debug('Getting manifest from actions/node-versions@main'); core.debug('Getting manifest from actions/node-versions@main');
return tc.getManifestFromRepo('actions', 'node-versions', this.nodeInfo.auth, 'main'); return tc.getManifestFromRepo('actions', 'node-versions', this.nodeInfo.auth, 'main');
} }
resolveLtsAliasFromManifest(versionSpec, stable, manifest) { resolveLtsAliasFromManifest(versionSpec, stable, manifest) {
var _a; var _a;
const alias = (_a = versionSpec.split('lts/')[1]) === null || _a === void 0 ? void 0 : _a.toLowerCase(); const alias = (_a = versionSpec.split('lts/')[1]) === null || _a === void 0 ? void 0 : _a.toLowerCase();
if (!alias) { if (!alias) {
throw new Error(`Unable to parse LTS alias for Node version '${versionSpec}'`); throw new Error(`Unable to parse LTS alias for Node version '${versionSpec}'`);
} }
core.debug(`LTS alias '${alias}' for Node version '${versionSpec}'`); core.debug(`LTS alias '${alias}' for Node version '${versionSpec}'`);
// Supported formats are `lts/<alias>`, `lts/*`, and `lts/-n`. Where asterisk means highest possible LTS and -n means the nth-highest. // Supported formats are `lts/<alias>`, `lts/*`, and `lts/-n`. Where asterisk means highest possible LTS and -n means the nth-highest.
const n = Number(alias); const n = Number(alias);
const aliases = Object.fromEntries(manifest const aliases = Object.fromEntries(manifest
.filter(x => x.lts && x.stable === stable) .filter(x => x.lts && x.stable === stable)
.map(x => [x.lts.toLowerCase(), x]) .map(x => [x.lts.toLowerCase(), x])
.reverse()); .reverse());
const numbered = Object.values(aliases); const numbered = Object.values(aliases);
const release = alias === '*' const release = alias === '*'
? numbered[numbered.length - 1] ? numbered[numbered.length - 1]
: n < 0 : n < 0
? numbered[numbered.length - 1 + n] ? numbered[numbered.length - 1 + n]
: aliases[alias]; : aliases[alias];
if (!release) { if (!release) {
throw new Error(`Unable to find LTS release '${alias}' for Node version '${versionSpec}'.`); throw new Error(`Unable to find LTS release '${alias}' for Node version '${versionSpec}'.`);
} }
core.debug(`Found LTS release '${release.version}' for Node version '${versionSpec}'`); core.debug(`Found LTS release '${release.version}' for Node version '${versionSpec}'`);
return release.version.split('.')[0]; return release.version.split('.')[0];
} }
resolveVersionFromManifest(versionSpec, stable, osArch, manifest) { resolveVersionFromManifest(versionSpec, stable, osArch, manifest) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
try { try {
const info = yield this.getInfoFromManifest(versionSpec, stable, osArch, manifest); const info = yield this.getInfoFromManifest(versionSpec, stable, osArch, manifest);
return info === null || info === void 0 ? void 0 : info.resolvedVersion; return info === null || info === void 0 ? void 0 : info.resolvedVersion;
} }
catch (err) { catch (err) {
core.info('Unable to resolve version from manifest...'); core.info('Unable to resolve version from manifest...');
core.debug(err.message); core.debug(err.message);
} }
}); });
} }
getInfoFromManifest(versionSpec, stable, osArch, manifest) { getInfoFromManifest(versionSpec, stable, osArch, manifest) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
let info = null; let info = null;
if (!manifest) { if (!manifest) {
core.debug('No manifest cached'); core.debug('No manifest cached');
manifest = yield this.getManifest(); manifest = yield this.getManifest();
} }
const rel = yield tc.findFromManifest(versionSpec, stable, manifest, osArch); const rel = yield tc.findFromManifest(versionSpec, stable, manifest, osArch);
if (rel && rel.files.length > 0) { if (rel && rel.files.length > 0) {
info = {}; info = {};
info.resolvedVersion = rel.version; info.resolvedVersion = rel.version;
info.arch = rel.files[0].arch; info.arch = rel.files[0].arch;
info.downloadUrl = rel.files[0].download_url; info.downloadUrl = rel.files[0].download_url;
info.fileName = rel.files[0].filename; info.fileName = rel.files[0].filename;
} }
return info; return info;
}); });
} }
isLtsAlias(versionSpec) { isLtsAlias(versionSpec) {
return versionSpec.startsWith('lts/'); return versionSpec.startsWith('lts/');
} }
isLatestSyntax(versionSpec) { isLatestSyntax(versionSpec) {
return ['current', 'latest', 'node'].includes(versionSpec); return ['current', 'latest', 'node'].includes(versionSpec);
} }
} }
exports["default"] = OfficialBuilds; exports["default"] = OfficialBuilds;
/***/ }), /***/ }),
@ -71958,21 +71958,21 @@ exports["default"] = OfficialBuilds;
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
"use strict"; "use strict";
var __importDefault = (this && this.__importDefault) || function (mod) { var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod }; return (mod && mod.__esModule) ? mod : { "default": mod };
}; };
Object.defineProperty(exports, "__esModule", ({ value: true })); Object.defineProperty(exports, "__esModule", ({ value: true }));
const base_distribution_1 = __importDefault(__nccwpck_require__(7)); const base_distribution_1 = __importDefault(__nccwpck_require__(7));
class RcBuild extends base_distribution_1.default { class RcBuild extends base_distribution_1.default {
constructor(nodeInfo) { constructor(nodeInfo) {
super(nodeInfo); super(nodeInfo);
} }
getDistributionUrl() { getDistributionUrl() {
return 'https://nodejs.org/download/rc'; return 'https://nodejs.org/download/rc';
} }
} }
exports["default"] = RcBuild; exports["default"] = RcBuild;
/***/ }), /***/ }),
@ -71981,22 +71981,22 @@ exports["default"] = RcBuild;
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
"use strict"; "use strict";
var __importDefault = (this && this.__importDefault) || function (mod) { var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod }; return (mod && mod.__esModule) ? mod : { "default": mod };
}; };
Object.defineProperty(exports, "__esModule", ({ value: true })); Object.defineProperty(exports, "__esModule", ({ value: true }));
const base_distribution_prerelease_1 = __importDefault(__nccwpck_require__(957)); const base_distribution_prerelease_1 = __importDefault(__nccwpck_require__(957));
class CanaryBuild extends base_distribution_prerelease_1.default { class CanaryBuild extends base_distribution_prerelease_1.default {
constructor(nodeInfo) { constructor(nodeInfo) {
super(nodeInfo); super(nodeInfo);
this.distribution = 'v8-canary'; this.distribution = 'v8-canary';
} }
getDistributionUrl() { getDistributionUrl() {
return 'https://nodejs.org/download/v8-canary'; return 'https://nodejs.org/download/v8-canary';
} }
} }
exports["default"] = CanaryBuild; exports["default"] = CanaryBuild;
/***/ }), /***/ }),
@ -72005,122 +72005,122 @@ exports["default"] = CanaryBuild;
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
"use strict"; "use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k; if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) { }) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k; if (k2 === undefined) k2 = k;
o[k2] = m[k]; o[k2] = m[k];
})); }));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v }); Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) { }) : function(o, v) {
o["default"] = v; o["default"] = v;
}); });
var __importStar = (this && this.__importStar) || function (mod) { var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod; if (mod && mod.__esModule) return mod;
var result = {}; var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod); __setModuleDefault(result, mod);
return result; return result;
}; };
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) { return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next()); step((generator = generator.apply(thisArg, _arguments || [])).next());
}); });
}; };
var __importDefault = (this && this.__importDefault) || function (mod) { var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod }; return (mod && mod.__esModule) ? mod : { "default": mod };
}; };
Object.defineProperty(exports, "__esModule", ({ value: true })); Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.run = void 0; exports.run = void 0;
const core = __importStar(__nccwpck_require__(2186)); const core = __importStar(__nccwpck_require__(2186));
const fs_1 = __importDefault(__nccwpck_require__(7147)); const fs_1 = __importDefault(__nccwpck_require__(7147));
const os_1 = __importDefault(__nccwpck_require__(2037)); const os_1 = __importDefault(__nccwpck_require__(2037));
const auth = __importStar(__nccwpck_require__(7573)); const auth = __importStar(__nccwpck_require__(7573));
const path = __importStar(__nccwpck_require__(1017)); const path = __importStar(__nccwpck_require__(1017));
const cache_restore_1 = __nccwpck_require__(9517); const cache_restore_1 = __nccwpck_require__(9517);
const cache_utils_1 = __nccwpck_require__(1678); const cache_utils_1 = __nccwpck_require__(1678);
const installer_factory_1 = __nccwpck_require__(5617); const installer_factory_1 = __nccwpck_require__(5617);
const util_1 = __nccwpck_require__(2629); const util_1 = __nccwpck_require__(2629);
function run() { function run() {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
try { try {
// //
// Version is optional. If supplied, install / use from the tool cache // Version is optional. If supplied, install / use from the tool cache
// If not supplied then task is still used to setup proxy, auth, etc... // If not supplied then task is still used to setup proxy, auth, etc...
// //
const version = resolveVersionInput(); const version = resolveVersionInput();
let arch = core.getInput('architecture'); let arch = core.getInput('architecture');
const cache = core.getInput('cache'); const cache = core.getInput('cache');
// if architecture supplied but node-version is not // 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 we don't throw a warning, the already installed x64 node will be used which is not probably what user meant.
if (arch && !version) { 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`'); 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) { if (!arch) {
arch = os_1.default.arch(); arch = os_1.default.arch();
} }
if (version) { if (version) {
const token = core.getInput('token'); const token = core.getInput('token');
const auth = !token ? undefined : `token ${token}`; const auth = !token ? undefined : `token ${token}`;
const stable = (core.getInput('stable') || 'true').toUpperCase() === 'TRUE'; const stable = (core.getInput('stable') || 'true').toUpperCase() === 'TRUE';
const checkLatest = (core.getInput('check-latest') || 'false').toUpperCase() === 'TRUE'; const checkLatest = (core.getInput('check-latest') || 'false').toUpperCase() === 'TRUE';
const nodejsInfo = { const nodejsInfo = {
versionSpec: version, versionSpec: version,
checkLatest, checkLatest,
auth, auth,
stable, stable,
arch arch
}; };
const nodeDistribution = installer_factory_1.getNodejsDistribution(nodejsInfo); const nodeDistribution = installer_factory_1.getNodejsDistribution(nodejsInfo);
yield nodeDistribution.setupNodeJs(); yield nodeDistribution.setupNodeJs();
} }
yield util_1.printEnvDetailsAndSetOutput(); yield util_1.printEnvDetailsAndSetOutput();
const registryUrl = core.getInput('registry-url'); const registryUrl = core.getInput('registry-url');
const alwaysAuth = core.getInput('always-auth'); const alwaysAuth = core.getInput('always-auth');
if (registryUrl) { if (registryUrl) {
auth.configAuthentication(registryUrl, alwaysAuth); auth.configAuthentication(registryUrl, alwaysAuth);
} }
if (cache && cache_utils_1.isCacheFeatureAvailable()) { if (cache && cache_utils_1.isCacheFeatureAvailable()) {
const cacheDependencyPath = core.getInput('cache-dependency-path'); const cacheDependencyPath = core.getInput('cache-dependency-path');
yield cache_restore_1.restoreCache(cache, cacheDependencyPath); yield cache_restore_1.restoreCache(cache, cacheDependencyPath);
} }
const matchersPath = path.join(__dirname, '../..', '.github'); const matchersPath = path.join(__dirname, '../..', '.github');
core.info(`##[add-matcher]${path.join(matchersPath, 'tsc.json')}`); 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-stylish.json')}`);
core.info(`##[add-matcher]${path.join(matchersPath, 'eslint-compact.json')}`); core.info(`##[add-matcher]${path.join(matchersPath, 'eslint-compact.json')}`);
} }
catch (err) { catch (err) {
core.setFailed(err.message); core.setFailed(err.message);
} }
}); });
} }
exports.run = run; exports.run = run;
function resolveVersionInput() { function resolveVersionInput() {
let version = core.getInput('node-version'); let version = core.getInput('node-version');
const versionFileInput = core.getInput('node-version-file'); const versionFileInput = core.getInput('node-version-file');
if (version && versionFileInput) { if (version && versionFileInput) {
core.warning('Both node-version and node-version-file inputs are specified, only node-version will be used'); core.warning('Both node-version and node-version-file inputs are specified, only node-version will be used');
} }
if (version) { if (version) {
return version; return version;
} }
if (versionFileInput) { if (versionFileInput) {
const versionFilePath = path.join(process.env.GITHUB_WORKSPACE, versionFileInput); const versionFilePath = path.join(process.env.GITHUB_WORKSPACE, versionFileInput);
if (!fs_1.default.existsSync(versionFilePath)) { if (!fs_1.default.existsSync(versionFilePath)) {
throw new Error(`The specified node version file at: ${versionFilePath} does not exist`); throw new Error(`The specified node version file at: ${versionFilePath} does not exist`);
} }
version = util_1.parseNodeVersionFile(fs_1.default.readFileSync(versionFilePath, 'utf8')); version = util_1.parseNodeVersionFile(fs_1.default.readFileSync(versionFilePath, 'utf8'));
core.info(`Resolved ${versionFileInput} as ${version}`); core.info(`Resolved ${versionFileInput} as ${version}`);
} }
return version; return version;
} }
/***/ }), /***/ }),
@ -72129,98 +72129,98 @@ function resolveVersionInput() {
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
"use strict"; "use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k; if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) { }) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k; if (k2 === undefined) k2 = k;
o[k2] = m[k]; o[k2] = m[k];
})); }));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v }); Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) { }) : function(o, v) {
o["default"] = v; o["default"] = v;
}); });
var __importStar = (this && this.__importStar) || function (mod) { var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod; if (mod && mod.__esModule) return mod;
var result = {}; var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod); __setModuleDefault(result, mod);
return result; return result;
}; };
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) { return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next()); step((generator = generator.apply(thisArg, _arguments || [])).next());
}); });
}; };
Object.defineProperty(exports, "__esModule", ({ value: true })); Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.printEnvDetailsAndSetOutput = exports.parseNodeVersionFile = void 0; exports.printEnvDetailsAndSetOutput = exports.parseNodeVersionFile = void 0;
const core = __importStar(__nccwpck_require__(2186)); const core = __importStar(__nccwpck_require__(2186));
const exec = __importStar(__nccwpck_require__(1514)); const exec = __importStar(__nccwpck_require__(1514));
function parseNodeVersionFile(contents) { function parseNodeVersionFile(contents) {
var _a, _b, _c; var _a, _b, _c;
let nodeVersion; let nodeVersion;
// Try parsing the file as an NPM `package.json` file. // Try parsing the file as an NPM `package.json` file.
try { try {
nodeVersion = (_a = JSON.parse(contents).volta) === null || _a === void 0 ? void 0 : _a.node; nodeVersion = (_a = JSON.parse(contents).volta) === null || _a === void 0 ? void 0 : _a.node;
if (!nodeVersion) if (!nodeVersion)
nodeVersion = (_b = JSON.parse(contents).engines) === null || _b === void 0 ? void 0 : _b.node; nodeVersion = (_b = JSON.parse(contents).engines) === null || _b === void 0 ? void 0 : _b.node;
} }
catch (_d) { catch (_d) {
core.info('Node version file is not JSON file'); core.info('Node version file is not JSON file');
} }
if (!nodeVersion) { if (!nodeVersion) {
const found = contents.match(/^(?:nodejs\s+)?v?(?<version>[^\s]+)$/m); const found = contents.match(/^(?:nodejs\s+)?v?(?<version>[^\s]+)$/m);
nodeVersion = (_c = found === null || found === void 0 ? void 0 : found.groups) === null || _c === void 0 ? void 0 : _c.version; nodeVersion = (_c = found === null || found === void 0 ? void 0 : found.groups) === null || _c === void 0 ? void 0 : _c.version;
} }
// In the case of an unknown format, // In the case of an unknown format,
// return as is and evaluate the version separately. // return as is and evaluate the version separately.
if (!nodeVersion) if (!nodeVersion)
nodeVersion = contents.trim(); nodeVersion = contents.trim();
return nodeVersion; return nodeVersion;
} }
exports.parseNodeVersionFile = parseNodeVersionFile; exports.parseNodeVersionFile = parseNodeVersionFile;
function printEnvDetailsAndSetOutput() { function printEnvDetailsAndSetOutput() {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
core.startGroup('Environment details'); core.startGroup('Environment details');
const promises = ['node', 'npm', 'yarn'].map((tool) => __awaiter(this, void 0, void 0, function* () { const promises = ['node', 'npm', 'yarn'].map((tool) => __awaiter(this, void 0, void 0, function* () {
const output = yield getToolVersion(tool, ['--version']); const output = yield getToolVersion(tool, ['--version']);
return { tool, output }; return { tool, output };
})); }));
const tools = yield Promise.all(promises); const tools = yield Promise.all(promises);
tools.forEach(({ tool, output }) => { tools.forEach(({ tool, output }) => {
if (tool === 'node') { if (tool === 'node') {
core.setOutput(`${tool}-version`, output); core.setOutput(`${tool}-version`, output);
} }
core.info(`${tool}: ${output}`); core.info(`${tool}: ${output}`);
}); });
core.endGroup(); core.endGroup();
}); });
} }
exports.printEnvDetailsAndSetOutput = printEnvDetailsAndSetOutput; exports.printEnvDetailsAndSetOutput = printEnvDetailsAndSetOutput;
function getToolVersion(tool, options) { function getToolVersion(tool, options) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
try { try {
const { stdout, stderr, exitCode } = yield exec.getExecOutput(tool, options, { const { stdout, stderr, exitCode } = yield exec.getExecOutput(tool, options, {
ignoreReturnCode: true, ignoreReturnCode: true,
silent: true silent: true
}); });
if (exitCode > 0) { if (exitCode > 0) {
core.info(`[warning]${stderr}`); core.info(`[warning]${stderr}`);
return ''; return '';
} }
return stdout.trim(); return stdout.trim();
} }
catch (err) { catch (err) {
return ''; return '';
} }
}); });
} }
/***/ }), /***/ }),
@ -72468,10 +72468,10 @@ var __webpack_exports__ = {};
(() => { (() => {
"use strict"; "use strict";
var exports = __webpack_exports__; var exports = __webpack_exports__;
Object.defineProperty(exports, "__esModule", ({ value: true })); Object.defineProperty(exports, "__esModule", ({ value: true }));
const main_1 = __nccwpck_require__(399); const main_1 = __nccwpck_require__(399);
main_1.run(); main_1.run();
})(); })();

1
package-lock.json generated
View File

@ -32,6 +32,7 @@
"eslint-plugin-node": "^11.1.0", "eslint-plugin-node": "^11.1.0",
"jest": "^27.2.5", "jest": "^27.2.5",
"jest-circus": "^27.2.5", "jest-circus": "^27.2.5",
"jest-each": "^27.2.5",
"prettier": "^2.8.4", "prettier": "^2.8.4",
"ts-jest": "^27.0.5", "ts-jest": "^27.0.5",
"typescript": "^4.2.3" "typescript": "^4.2.3"

View File

@ -48,6 +48,7 @@
"eslint-plugin-node": "^11.1.0", "eslint-plugin-node": "^11.1.0",
"jest": "^27.2.5", "jest": "^27.2.5",
"jest-circus": "^27.2.5", "jest-circus": "^27.2.5",
"jest-each": "^27.2.5",
"prettier": "^2.8.4", "prettier": "^2.8.4",
"ts-jest": "^27.0.5", "ts-jest": "^27.0.5",
"typescript": "^4.2.3" "typescript": "^4.2.3"