Merge pull request #859 from actions/update-temp-directory-creation

Update temp directory creation
This commit is contained in:
Nikolai Laevskii 2023-10-09 07:12:35 +02:00 committed by GitHub
commit 2a017f350d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 1888 additions and 1725 deletions

Binary file not shown.

BIN
.licenses/npm/uuid-9.0.0.dep.yml generated Normal file

Binary file not shown.

View File

@ -60332,86 +60332,86 @@ 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());
}); });
}; };
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 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.getState(constants_1.State.CachePackageManager); const cacheLock = core.getState(constants_1.State.CachePackageManager);
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 cachePaths = JSON.parse(core.getState(constants_1.State.CachePaths) || '[]'); const cachePaths = JSON.parse(core.getState(constants_1.State.CachePaths) || '[]');
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;
} }
if (!cachePaths.length) { if (!cachePaths.length) {
// TODO: core.getInput has a bug - it can return undefined despite its definition (tests only?) // TODO: core.getInput has a bug - it can return undefined despite its definition (tests only?)
// export declare function getInput(name: string, options?: InputOptions): string; // export declare function getInput(name: string, options?: InputOptions): string;
const cacheDependencyPath = core.getInput('cache-dependency-path') || ''; const cacheDependencyPath = core.getInput('cache-dependency-path') || '';
throw new Error(`Cache folder paths are not retrieved for ${packageManager} with cache-dependency-path = ${cacheDependencyPath}`); throw new Error(`Cache folder paths are not retrieved for ${packageManager} with cache-dependency-path = ${cacheDependencyPath}`);
} }
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(cachePaths, primaryKey); const cacheId = yield cache.saveCache(cachePaths, 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();
/***/ }), /***/ }),
@ -60420,254 +60420,254 @@ 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());
}); });
}; };
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.isCacheFeatureAvailable = exports.isGhes = exports.repoHasYarnBerryManagedDependencies = exports.getCacheDirectories = exports.resetProjectDirectoriesMemoized = exports.getPackageManagerInfo = exports.getCommandOutputNotEmpty = exports.getCommandOutput = exports.supportedPackageManagers = void 0; exports.isCacheFeatureAvailable = exports.isGhes = exports.repoHasYarnBerryManagedDependencies = exports.getCacheDirectories = exports.resetProjectDirectoriesMemoized = exports.getPackageManagerInfo = exports.getCommandOutputNotEmpty = 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));
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 util_1 = __nccwpck_require__(2629); const util_1 = __nccwpck_require__(2629);
exports.supportedPackageManagers = { exports.supportedPackageManagers = {
npm: { npm: {
name: 'npm', name: 'npm',
lockFilePatterns: ['package-lock.json', 'npm-shrinkwrap.json', 'yarn.lock'], lockFilePatterns: ['package-lock.json', 'npm-shrinkwrap.json', 'yarn.lock'],
getCacheFolderPath: () => exports.getCommandOutputNotEmpty('npm config get cache', 'Could not get npm cache folder path') getCacheFolderPath: () => exports.getCommandOutputNotEmpty('npm config get cache', 'Could not get npm cache folder path')
}, },
pnpm: { pnpm: {
name: 'pnpm', name: 'pnpm',
lockFilePatterns: ['pnpm-lock.yaml'], lockFilePatterns: ['pnpm-lock.yaml'],
getCacheFolderPath: () => exports.getCommandOutputNotEmpty('pnpm store path --silent', 'Could not get pnpm cache folder path') getCacheFolderPath: () => exports.getCommandOutputNotEmpty('pnpm store path --silent', 'Could not get pnpm cache folder path')
}, },
yarn: { yarn: {
name: 'yarn', name: 'yarn',
lockFilePatterns: ['yarn.lock'], lockFilePatterns: ['yarn.lock'],
getCacheFolderPath: (projectDir) => __awaiter(void 0, void 0, void 0, function* () { getCacheFolderPath: (projectDir) => __awaiter(void 0, void 0, void 0, function* () {
const yarnVersion = yield exports.getCommandOutputNotEmpty(`yarn --version`, 'Could not retrieve version of yarn', projectDir); const yarnVersion = yield exports.getCommandOutputNotEmpty(`yarn --version`, 'Could not retrieve version of yarn', projectDir);
core.debug(`Consumed yarn version is ${yarnVersion} (working dir: "${projectDir || ''}")`); core.debug(`Consumed yarn version is ${yarnVersion} (working dir: "${projectDir || ''}")`);
const stdOut = yarnVersion.startsWith('1.') const stdOut = yarnVersion.startsWith('1.')
? yield exports.getCommandOutput('yarn cache dir', projectDir) ? yield exports.getCommandOutput('yarn cache dir', projectDir)
: yield exports.getCommandOutput('yarn config get cacheFolder', projectDir); : yield exports.getCommandOutput('yarn config get cacheFolder', projectDir);
if (!stdOut) { if (!stdOut) {
throw new Error(`Could not get yarn cache folder path for ${projectDir}`); throw new Error(`Could not get yarn cache folder path for ${projectDir}`);
} }
return stdOut; return stdOut;
}) })
} }
}; };
const getCommandOutput = (toolCommand, cwd) => __awaiter(void 0, void 0, void 0, function* () { const getCommandOutput = (toolCommand, cwd) => __awaiter(void 0, void 0, void 0, function* () {
let { stdout, stderr, exitCode } = yield exec.getExecOutput(toolCommand, undefined, Object.assign({ ignoreReturnCode: true }, (cwd && { cwd }))); let { stdout, stderr, exitCode } = yield exec.getExecOutput(toolCommand, undefined, Object.assign({ ignoreReturnCode: true }, (cwd && { cwd })));
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 getCommandOutputNotEmpty = (toolCommand, error, cwd) => __awaiter(void 0, void 0, void 0, function* () { const getCommandOutputNotEmpty = (toolCommand, error, cwd) => __awaiter(void 0, void 0, void 0, function* () {
const stdOut = exports.getCommandOutput(toolCommand, cwd); const stdOut = exports.getCommandOutput(toolCommand, cwd);
if (!stdOut) { if (!stdOut) {
throw new Error(error); throw new Error(error);
} }
return stdOut; return stdOut;
}); });
exports.getCommandOutputNotEmpty = getCommandOutputNotEmpty; exports.getCommandOutputNotEmpty = getCommandOutputNotEmpty;
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') {
return exports.supportedPackageManagers.yarn; return exports.supportedPackageManagers.yarn;
} }
else { else {
return null; return null;
} }
}); });
exports.getPackageManagerInfo = getPackageManagerInfo; exports.getPackageManagerInfo = getPackageManagerInfo;
/** /**
* getProjectDirectoriesFromCacheDependencyPath is called twice during `restoreCache` * getProjectDirectoriesFromCacheDependencyPath is called twice during `restoreCache`
* - first through `getCacheDirectories` * - first through `getCacheDirectories`
* - second from `repoHasYarn3ManagedCache` * - second from `repoHasYarn3ManagedCache`
* *
* it contains expensive IO operation and thus should be memoized * it contains expensive IO operation and thus should be memoized
*/ */
let projectDirectoriesMemoized = null; let projectDirectoriesMemoized = null;
/** /**
* unit test must reset memoized variables * unit test must reset memoized variables
*/ */
const resetProjectDirectoriesMemoized = () => (projectDirectoriesMemoized = null); const resetProjectDirectoriesMemoized = () => (projectDirectoriesMemoized = null);
exports.resetProjectDirectoriesMemoized = resetProjectDirectoriesMemoized; exports.resetProjectDirectoriesMemoized = resetProjectDirectoriesMemoized;
/** /**
* Expands (converts) the string input `cache-dependency-path` to list of directories that * Expands (converts) the string input `cache-dependency-path` to list of directories that
* may be project roots * may be project roots
* @param cacheDependencyPath - either a single string or multiline string with possible glob patterns * @param cacheDependencyPath - either a single string or multiline string with possible glob patterns
* expected to be the result of `core.getInput('cache-dependency-path')` * expected to be the result of `core.getInput('cache-dependency-path')`
* @return list of directories and possible * @return list of directories and possible
*/ */
const getProjectDirectoriesFromCacheDependencyPath = (cacheDependencyPath) => __awaiter(void 0, void 0, void 0, function* () { const getProjectDirectoriesFromCacheDependencyPath = (cacheDependencyPath) => __awaiter(void 0, void 0, void 0, function* () {
if (projectDirectoriesMemoized !== null) { if (projectDirectoriesMemoized !== null) {
return projectDirectoriesMemoized; return projectDirectoriesMemoized;
} }
const globber = yield glob.create(cacheDependencyPath); const globber = yield glob.create(cacheDependencyPath);
const cacheDependenciesPaths = yield globber.glob(); const cacheDependenciesPaths = yield globber.glob();
const existingDirectories = cacheDependenciesPaths const existingDirectories = cacheDependenciesPaths
.map(path_1.default.dirname) .map(path_1.default.dirname)
.filter(util_1.unique()) .filter(util_1.unique())
.map(dirName => fs_1.default.realpathSync(dirName)) .map(dirName => fs_1.default.realpathSync(dirName))
.filter(directory => fs_1.default.lstatSync(directory).isDirectory()); .filter(directory => fs_1.default.lstatSync(directory).isDirectory());
if (!existingDirectories.length) if (!existingDirectories.length)
core.warning(`No existing directories found containing cache-dependency-path="${cacheDependencyPath}"`); core.warning(`No existing directories found containing cache-dependency-path="${cacheDependencyPath}"`);
projectDirectoriesMemoized = existingDirectories; projectDirectoriesMemoized = existingDirectories;
return existingDirectories; return existingDirectories;
}); });
/** /**
* Finds the cache directories configured for the repo if cache-dependency-path is not empty * Finds the cache directories configured for the repo if cache-dependency-path is not empty
* @param packageManagerInfo - an object having getCacheFolderPath method specific to given PM * @param packageManagerInfo - an object having getCacheFolderPath method specific to given PM
* @param cacheDependencyPath - either a single string or multiline string with possible glob patterns * @param cacheDependencyPath - either a single string or multiline string with possible glob patterns
* expected to be the result of `core.getInput('cache-dependency-path')` * expected to be the result of `core.getInput('cache-dependency-path')`
* @return list of files on which the cache depends * @return list of files on which the cache depends
*/ */
const getCacheDirectoriesFromCacheDependencyPath = (packageManagerInfo, cacheDependencyPath) => __awaiter(void 0, void 0, void 0, function* () { const getCacheDirectoriesFromCacheDependencyPath = (packageManagerInfo, cacheDependencyPath) => __awaiter(void 0, void 0, void 0, function* () {
const projectDirectories = yield getProjectDirectoriesFromCacheDependencyPath(cacheDependencyPath); const projectDirectories = yield getProjectDirectoriesFromCacheDependencyPath(cacheDependencyPath);
const cacheFoldersPaths = yield Promise.all(projectDirectories.map((projectDirectory) => __awaiter(void 0, void 0, void 0, function* () { const cacheFoldersPaths = yield Promise.all(projectDirectories.map((projectDirectory) => __awaiter(void 0, void 0, void 0, function* () {
const cacheFolderPath = yield packageManagerInfo.getCacheFolderPath(projectDirectory); const cacheFolderPath = yield packageManagerInfo.getCacheFolderPath(projectDirectory);
core.debug(`${packageManagerInfo.name}'s cache folder "${cacheFolderPath}" configured for the directory "${projectDirectory}"`); core.debug(`${packageManagerInfo.name}'s cache folder "${cacheFolderPath}" configured for the directory "${projectDirectory}"`);
return cacheFolderPath; return cacheFolderPath;
}))); })));
// uniq in order to do not cache the same directories twice // uniq in order to do not cache the same directories twice
return cacheFoldersPaths.filter(util_1.unique()); return cacheFoldersPaths.filter(util_1.unique());
}); });
/** /**
* Finds the cache directories configured for the repo ignoring cache-dependency-path * Finds the cache directories configured for the repo ignoring cache-dependency-path
* @param packageManagerInfo - an object having getCacheFolderPath method specific to given PM * @param packageManagerInfo - an object having getCacheFolderPath method specific to given PM
* @return list of files on which the cache depends * @return list of files on which the cache depends
*/ */
const getCacheDirectoriesForRootProject = (packageManagerInfo) => __awaiter(void 0, void 0, void 0, function* () { const getCacheDirectoriesForRootProject = (packageManagerInfo) => __awaiter(void 0, void 0, void 0, function* () {
const cacheFolderPath = yield packageManagerInfo.getCacheFolderPath(); const cacheFolderPath = yield packageManagerInfo.getCacheFolderPath();
core.debug(`${packageManagerInfo.name}'s cache folder "${cacheFolderPath}" configured for the root directory`); core.debug(`${packageManagerInfo.name}'s cache folder "${cacheFolderPath}" configured for the root directory`);
return [cacheFolderPath]; return [cacheFolderPath];
}); });
/** /**
* A function to find the cache directories configured for the repo * A function to find the cache directories configured for the repo
* currently it handles only the case of PM=yarn && cacheDependencyPath is not empty * currently it handles only the case of PM=yarn && cacheDependencyPath is not empty
* @param packageManagerInfo - an object having getCacheFolderPath method specific to given PM * @param packageManagerInfo - an object having getCacheFolderPath method specific to given PM
* @param cacheDependencyPath - either a single string or multiline string with possible glob patterns * @param cacheDependencyPath - either a single string or multiline string with possible glob patterns
* expected to be the result of `core.getInput('cache-dependency-path')` * expected to be the result of `core.getInput('cache-dependency-path')`
* @return list of files on which the cache depends * @return list of files on which the cache depends
*/ */
const getCacheDirectories = (packageManagerInfo, cacheDependencyPath) => __awaiter(void 0, void 0, void 0, function* () { const getCacheDirectories = (packageManagerInfo, cacheDependencyPath) => __awaiter(void 0, void 0, void 0, function* () {
// For yarn, if cacheDependencyPath is set, ask information about cache folders in each project // For yarn, if cacheDependencyPath is set, ask information about cache folders in each project
// folder satisfied by cacheDependencyPath https://github.com/actions/setup-node/issues/488 // folder satisfied by cacheDependencyPath https://github.com/actions/setup-node/issues/488
if (packageManagerInfo.name === 'yarn' && cacheDependencyPath) { if (packageManagerInfo.name === 'yarn' && cacheDependencyPath) {
return getCacheDirectoriesFromCacheDependencyPath(packageManagerInfo, cacheDependencyPath); return getCacheDirectoriesFromCacheDependencyPath(packageManagerInfo, cacheDependencyPath);
} }
return getCacheDirectoriesForRootProject(packageManagerInfo); return getCacheDirectoriesForRootProject(packageManagerInfo);
}); });
exports.getCacheDirectories = getCacheDirectories; exports.getCacheDirectories = getCacheDirectories;
/** /**
* A function to check if the directory is a yarn project configured to manage * A function to check if the directory is a yarn project configured to manage
* obsolete dependencies in the local cache * obsolete dependencies in the local cache
* @param directory - a path to the folder * @param directory - a path to the folder
* @return - true if the directory's project is yarn managed * @return - true if the directory's project is yarn managed
* - if there's .yarn/cache folder do not mess with the dependencies kept in the repo, return false * - if there's .yarn/cache folder do not mess with the dependencies kept in the repo, return false
* - global cache is not managed by yarn @see https://yarnpkg.com/features/offline-cache, return false * - global cache is not managed by yarn @see https://yarnpkg.com/features/offline-cache, return false
* - if local cache is not explicitly enabled (not yarn3), return false * - if local cache is not explicitly enabled (not yarn3), return false
* - return true otherwise * - return true otherwise
*/ */
const projectHasYarnBerryManagedDependencies = (directory) => __awaiter(void 0, void 0, void 0, function* () { const projectHasYarnBerryManagedDependencies = (directory) => __awaiter(void 0, void 0, void 0, function* () {
const workDir = directory || process.env.GITHUB_WORKSPACE || '.'; const workDir = directory || process.env.GITHUB_WORKSPACE || '.';
core.debug(`check if "${workDir}" has locally managed yarn3 dependencies`); core.debug(`check if "${workDir}" has locally managed yarn3 dependencies`);
// if .yarn/cache directory exists the cache is managed by version control system // if .yarn/cache directory exists the cache is managed by version control system
const yarnCacheFile = path_1.default.join(workDir, '.yarn', 'cache'); const yarnCacheFile = path_1.default.join(workDir, '.yarn', 'cache');
if (fs_1.default.existsSync(yarnCacheFile) && if (fs_1.default.existsSync(yarnCacheFile) &&
fs_1.default.lstatSync(yarnCacheFile).isDirectory()) { fs_1.default.lstatSync(yarnCacheFile).isDirectory()) {
core.debug(`"${workDir}" has .yarn/cache - dependencies are kept in the repository`); core.debug(`"${workDir}" has .yarn/cache - dependencies are kept in the repository`);
return Promise.resolve(false); return Promise.resolve(false);
} }
// NOTE: yarn1 returns 'undefined' with return code = 0 // NOTE: yarn1 returns 'undefined' with return code = 0
const enableGlobalCache = yield exports.getCommandOutput('yarn config get enableGlobalCache', workDir); const enableGlobalCache = yield exports.getCommandOutput('yarn config get enableGlobalCache', workDir);
// only local cache is not managed by yarn // only local cache is not managed by yarn
const managed = enableGlobalCache.includes('false'); const managed = enableGlobalCache.includes('false');
if (managed) { if (managed) {
core.debug(`"${workDir}" dependencies are managed by yarn 3 locally`); core.debug(`"${workDir}" dependencies are managed by yarn 3 locally`);
return true; return true;
} }
else { else {
core.debug(`"${workDir}" dependencies are not managed by yarn 3 locally`); core.debug(`"${workDir}" dependencies are not managed by yarn 3 locally`);
return false; return false;
} }
}); });
/** /**
* A function to report the repo contains Yarn managed projects * A function to report the repo contains Yarn managed projects
* @param packageManagerInfo - used to make sure current package manager is yarn * @param packageManagerInfo - used to make sure current package manager is yarn
* @param cacheDependencyPath - either a single string or multiline string with possible glob patterns * @param cacheDependencyPath - either a single string or multiline string with possible glob patterns
* expected to be the result of `core.getInput('cache-dependency-path')` * expected to be the result of `core.getInput('cache-dependency-path')`
* @return - true if all project directories configured to be Yarn managed * @return - true if all project directories configured to be Yarn managed
*/ */
const repoHasYarnBerryManagedDependencies = (packageManagerInfo, cacheDependencyPath) => __awaiter(void 0, void 0, void 0, function* () { const repoHasYarnBerryManagedDependencies = (packageManagerInfo, cacheDependencyPath) => __awaiter(void 0, void 0, void 0, function* () {
if (packageManagerInfo.name !== 'yarn') if (packageManagerInfo.name !== 'yarn')
return false; return false;
const yarnDirs = cacheDependencyPath const yarnDirs = cacheDependencyPath
? yield getProjectDirectoriesFromCacheDependencyPath(cacheDependencyPath) ? yield getProjectDirectoriesFromCacheDependencyPath(cacheDependencyPath)
: ['']; : [''];
const isManagedList = yield Promise.all(yarnDirs.map(projectHasYarnBerryManagedDependencies)); const isManagedList = yield Promise.all(yarnDirs.map(projectHasYarnBerryManagedDependencies));
return isManagedList.every(Boolean); return isManagedList.every(Boolean);
}); });
exports.repoHasYarnBerryManagedDependencies = repoHasYarnBerryManagedDependencies; exports.repoHasYarnBerryManagedDependencies = repoHasYarnBerryManagedDependencies;
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;
/***/ }), /***/ }),
@ -60676,26 +60676,26 @@ 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["CachePackageManager"] = "SETUP_NODE_CACHE_PACKAGE_MANAGER"; State["CachePackageManager"] = "SETUP_NODE_CACHE_PACKAGE_MANAGER";
State["CachePrimaryKey"] = "CACHE_KEY"; State["CachePrimaryKey"] = "CACHE_KEY";
State["CacheMatchedKey"] = "CACHE_RESULT"; State["CacheMatchedKey"] = "CACHE_RESULT";
State["CachePaths"] = "CACHE_PATHS"; State["CachePaths"] = "CACHE_PATHS";
})(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 = {}));
/***/ }), /***/ }),
@ -60704,108 +60704,108 @@ 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 __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.unique = exports.printEnvDetailsAndSetOutput = exports.parseNodeVersionFile = void 0; exports.unique = 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(/^(?:node(js)?\s+)?v?(?<version>[^\s]+)$/m); const found = contents.match(/^(?:node(js)?\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 '';
} }
}); });
} }
const unique = () => { const unique = () => {
const encountered = new Set(); const encountered = new Set();
return (value) => { return (value) => {
if (encountered.has(value)) if (encountered.has(value))
return false; return false;
encountered.add(value); encountered.add(value);
return true; return true;
}; };
}; };
exports.unique = unique; exports.unique = unique;
/***/ }), /***/ }),

2656
dist/setup/index.js vendored
View File

@ -65754,6 +65754,21 @@ function getUserAgentNode () {
} }
/***/ }),
/***/ 2155:
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
var v1 = __nccwpck_require__(8749);
var v4 = __nccwpck_require__(824);
var uuid = v4;
uuid.v1 = v1;
uuid.v4 = v4;
module.exports = uuid;
/***/ }), /***/ }),
/***/ 2707: /***/ 2707:
@ -65800,6 +65815,122 @@ module.exports = function nodeRNG() {
}; };
/***/ }),
/***/ 8749:
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
var rng = __nccwpck_require__(5859);
var bytesToUuid = __nccwpck_require__(2707);
// **`v1()` - Generate time-based UUID**
//
// Inspired by https://github.com/LiosK/UUID.js
// and http://docs.python.org/library/uuid.html
var _nodeId;
var _clockseq;
// Previous uuid creation time
var _lastMSecs = 0;
var _lastNSecs = 0;
// See https://github.com/broofa/node-uuid for API details
function v1(options, buf, offset) {
var i = buf && offset || 0;
var b = buf || [];
options = options || {};
var node = options.node || _nodeId;
var clockseq = options.clockseq !== undefined ? options.clockseq : _clockseq;
// node and clockseq need to be initialized to random values if they're not
// specified. We do this lazily to minimize issues related to insufficient
// system entropy. See #189
if (node == null || clockseq == null) {
var seedBytes = rng();
if (node == null) {
// Per 4.5, create and 48-bit node id, (47 random bits + multicast bit = 1)
node = _nodeId = [
seedBytes[0] | 0x01,
seedBytes[1], seedBytes[2], seedBytes[3], seedBytes[4], seedBytes[5]
];
}
if (clockseq == null) {
// Per 4.2.2, randomize (14 bit) clockseq
clockseq = _clockseq = (seedBytes[6] << 8 | seedBytes[7]) & 0x3fff;
}
}
// UUID timestamps are 100 nano-second units since the Gregorian epoch,
// (1582-10-15 00:00). JSNumbers aren't precise enough for this, so
// time is handled internally as 'msecs' (integer milliseconds) and 'nsecs'
// (100-nanoseconds offset from msecs) since unix epoch, 1970-01-01 00:00.
var msecs = options.msecs !== undefined ? options.msecs : new Date().getTime();
// Per 4.2.1.2, use count of uuid's generated during the current clock
// cycle to simulate higher resolution clock
var nsecs = options.nsecs !== undefined ? options.nsecs : _lastNSecs + 1;
// Time since last uuid creation (in msecs)
var dt = (msecs - _lastMSecs) + (nsecs - _lastNSecs)/10000;
// Per 4.2.1.2, Bump clockseq on clock regression
if (dt < 0 && options.clockseq === undefined) {
clockseq = clockseq + 1 & 0x3fff;
}
// Reset nsecs if clock regresses (new clockseq) or we've moved onto a new
// time interval
if ((dt < 0 || msecs > _lastMSecs) && options.nsecs === undefined) {
nsecs = 0;
}
// Per 4.2.1.2 Throw error if too many uuids are requested
if (nsecs >= 10000) {
throw new Error('uuid.v1(): Can\'t create more than 10M uuids/sec');
}
_lastMSecs = msecs;
_lastNSecs = nsecs;
_clockseq = clockseq;
// Per 4.1.4 - Convert from unix epoch to Gregorian epoch
msecs += 12219292800000;
// `time_low`
var tl = ((msecs & 0xfffffff) * 10000 + nsecs) % 0x100000000;
b[i++] = tl >>> 24 & 0xff;
b[i++] = tl >>> 16 & 0xff;
b[i++] = tl >>> 8 & 0xff;
b[i++] = tl & 0xff;
// `time_mid`
var tmh = (msecs / 0x100000000 * 10000) & 0xfffffff;
b[i++] = tmh >>> 8 & 0xff;
b[i++] = tmh & 0xff;
// `time_high_and_version`
b[i++] = tmh >>> 24 & 0xf | 0x10; // include version
b[i++] = tmh >>> 16 & 0xff;
// `clock_seq_hi_and_reserved` (Per 4.2.2 - include variant)
b[i++] = clockseq >>> 8 | 0x80;
// `clock_seq_low`
b[i++] = clockseq & 0xff;
// `node`
for (var n = 0; n < 6; ++n) {
b[i + n] = node[n];
}
return buf ? buf : bytesToUuid(b);
}
module.exports = v1;
/***/ }), /***/ }),
/***/ 824: /***/ 824:
@ -71083,73 +71214,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');
} }
/***/ }), /***/ }),
@ -71158,94 +71289,94 @@ 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 cachePaths = yield cache_utils_1.getCacheDirectories(packageManagerInfo, cacheDependencyPath); const cachePaths = yield cache_utils_1.getCacheDirectories(packageManagerInfo, cacheDependencyPath);
core.saveState(constants_1.State.CachePaths, cachePaths); core.saveState(constants_1.State.CachePaths, cachePaths);
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 keyPrefix = `node-cache-${platform}-${packageManager}`; const keyPrefix = `node-cache-${platform}-${packageManager}`;
const primaryKey = `${keyPrefix}-${fileHash}`; const primaryKey = `${keyPrefix}-${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 isManagedByYarnBerry = yield cache_utils_1.repoHasYarnBerryManagedDependencies(packageManagerInfo, cacheDependencyPath); const isManagedByYarnBerry = yield cache_utils_1.repoHasYarnBerryManagedDependencies(packageManagerInfo, cacheDependencyPath);
let cacheKey; let cacheKey;
if (isManagedByYarnBerry) { if (isManagedByYarnBerry) {
core.info('All dependencies are managed locally by yarn3, the previous cache can be used'); core.info('All dependencies are managed locally by yarn3, the previous cache can be used');
cacheKey = yield cache.restoreCache(cachePaths, primaryKey, [keyPrefix]); cacheKey = yield cache.restoreCache(cachePaths, primaryKey, [keyPrefix]);
} }
else { else {
cacheKey = yield cache.restoreCache(cachePaths, primaryKey); cacheKey = yield cache.restoreCache(cachePaths, 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);
}; };
/***/ }), /***/ }),
@ -71254,254 +71385,254 @@ 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());
}); });
}; };
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.isCacheFeatureAvailable = exports.isGhes = exports.repoHasYarnBerryManagedDependencies = exports.getCacheDirectories = exports.resetProjectDirectoriesMemoized = exports.getPackageManagerInfo = exports.getCommandOutputNotEmpty = exports.getCommandOutput = exports.supportedPackageManagers = void 0; exports.isCacheFeatureAvailable = exports.isGhes = exports.repoHasYarnBerryManagedDependencies = exports.getCacheDirectories = exports.resetProjectDirectoriesMemoized = exports.getPackageManagerInfo = exports.getCommandOutputNotEmpty = 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));
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 util_1 = __nccwpck_require__(2629); const util_1 = __nccwpck_require__(2629);
exports.supportedPackageManagers = { exports.supportedPackageManagers = {
npm: { npm: {
name: 'npm', name: 'npm',
lockFilePatterns: ['package-lock.json', 'npm-shrinkwrap.json', 'yarn.lock'], lockFilePatterns: ['package-lock.json', 'npm-shrinkwrap.json', 'yarn.lock'],
getCacheFolderPath: () => exports.getCommandOutputNotEmpty('npm config get cache', 'Could not get npm cache folder path') getCacheFolderPath: () => exports.getCommandOutputNotEmpty('npm config get cache', 'Could not get npm cache folder path')
}, },
pnpm: { pnpm: {
name: 'pnpm', name: 'pnpm',
lockFilePatterns: ['pnpm-lock.yaml'], lockFilePatterns: ['pnpm-lock.yaml'],
getCacheFolderPath: () => exports.getCommandOutputNotEmpty('pnpm store path --silent', 'Could not get pnpm cache folder path') getCacheFolderPath: () => exports.getCommandOutputNotEmpty('pnpm store path --silent', 'Could not get pnpm cache folder path')
}, },
yarn: { yarn: {
name: 'yarn', name: 'yarn',
lockFilePatterns: ['yarn.lock'], lockFilePatterns: ['yarn.lock'],
getCacheFolderPath: (projectDir) => __awaiter(void 0, void 0, void 0, function* () { getCacheFolderPath: (projectDir) => __awaiter(void 0, void 0, void 0, function* () {
const yarnVersion = yield exports.getCommandOutputNotEmpty(`yarn --version`, 'Could not retrieve version of yarn', projectDir); const yarnVersion = yield exports.getCommandOutputNotEmpty(`yarn --version`, 'Could not retrieve version of yarn', projectDir);
core.debug(`Consumed yarn version is ${yarnVersion} (working dir: "${projectDir || ''}")`); core.debug(`Consumed yarn version is ${yarnVersion} (working dir: "${projectDir || ''}")`);
const stdOut = yarnVersion.startsWith('1.') const stdOut = yarnVersion.startsWith('1.')
? yield exports.getCommandOutput('yarn cache dir', projectDir) ? yield exports.getCommandOutput('yarn cache dir', projectDir)
: yield exports.getCommandOutput('yarn config get cacheFolder', projectDir); : yield exports.getCommandOutput('yarn config get cacheFolder', projectDir);
if (!stdOut) { if (!stdOut) {
throw new Error(`Could not get yarn cache folder path for ${projectDir}`); throw new Error(`Could not get yarn cache folder path for ${projectDir}`);
} }
return stdOut; return stdOut;
}) })
} }
}; };
const getCommandOutput = (toolCommand, cwd) => __awaiter(void 0, void 0, void 0, function* () { const getCommandOutput = (toolCommand, cwd) => __awaiter(void 0, void 0, void 0, function* () {
let { stdout, stderr, exitCode } = yield exec.getExecOutput(toolCommand, undefined, Object.assign({ ignoreReturnCode: true }, (cwd && { cwd }))); let { stdout, stderr, exitCode } = yield exec.getExecOutput(toolCommand, undefined, Object.assign({ ignoreReturnCode: true }, (cwd && { cwd })));
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 getCommandOutputNotEmpty = (toolCommand, error, cwd) => __awaiter(void 0, void 0, void 0, function* () { const getCommandOutputNotEmpty = (toolCommand, error, cwd) => __awaiter(void 0, void 0, void 0, function* () {
const stdOut = exports.getCommandOutput(toolCommand, cwd); const stdOut = exports.getCommandOutput(toolCommand, cwd);
if (!stdOut) { if (!stdOut) {
throw new Error(error); throw new Error(error);
} }
return stdOut; return stdOut;
}); });
exports.getCommandOutputNotEmpty = getCommandOutputNotEmpty; exports.getCommandOutputNotEmpty = getCommandOutputNotEmpty;
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') {
return exports.supportedPackageManagers.yarn; return exports.supportedPackageManagers.yarn;
} }
else { else {
return null; return null;
} }
}); });
exports.getPackageManagerInfo = getPackageManagerInfo; exports.getPackageManagerInfo = getPackageManagerInfo;
/** /**
* getProjectDirectoriesFromCacheDependencyPath is called twice during `restoreCache` * getProjectDirectoriesFromCacheDependencyPath is called twice during `restoreCache`
* - first through `getCacheDirectories` * - first through `getCacheDirectories`
* - second from `repoHasYarn3ManagedCache` * - second from `repoHasYarn3ManagedCache`
* *
* it contains expensive IO operation and thus should be memoized * it contains expensive IO operation and thus should be memoized
*/ */
let projectDirectoriesMemoized = null; let projectDirectoriesMemoized = null;
/** /**
* unit test must reset memoized variables * unit test must reset memoized variables
*/ */
const resetProjectDirectoriesMemoized = () => (projectDirectoriesMemoized = null); const resetProjectDirectoriesMemoized = () => (projectDirectoriesMemoized = null);
exports.resetProjectDirectoriesMemoized = resetProjectDirectoriesMemoized; exports.resetProjectDirectoriesMemoized = resetProjectDirectoriesMemoized;
/** /**
* Expands (converts) the string input `cache-dependency-path` to list of directories that * Expands (converts) the string input `cache-dependency-path` to list of directories that
* may be project roots * may be project roots
* @param cacheDependencyPath - either a single string or multiline string with possible glob patterns * @param cacheDependencyPath - either a single string or multiline string with possible glob patterns
* expected to be the result of `core.getInput('cache-dependency-path')` * expected to be the result of `core.getInput('cache-dependency-path')`
* @return list of directories and possible * @return list of directories and possible
*/ */
const getProjectDirectoriesFromCacheDependencyPath = (cacheDependencyPath) => __awaiter(void 0, void 0, void 0, function* () { const getProjectDirectoriesFromCacheDependencyPath = (cacheDependencyPath) => __awaiter(void 0, void 0, void 0, function* () {
if (projectDirectoriesMemoized !== null) { if (projectDirectoriesMemoized !== null) {
return projectDirectoriesMemoized; return projectDirectoriesMemoized;
} }
const globber = yield glob.create(cacheDependencyPath); const globber = yield glob.create(cacheDependencyPath);
const cacheDependenciesPaths = yield globber.glob(); const cacheDependenciesPaths = yield globber.glob();
const existingDirectories = cacheDependenciesPaths const existingDirectories = cacheDependenciesPaths
.map(path_1.default.dirname) .map(path_1.default.dirname)
.filter(util_1.unique()) .filter(util_1.unique())
.map(dirName => fs_1.default.realpathSync(dirName)) .map(dirName => fs_1.default.realpathSync(dirName))
.filter(directory => fs_1.default.lstatSync(directory).isDirectory()); .filter(directory => fs_1.default.lstatSync(directory).isDirectory());
if (!existingDirectories.length) if (!existingDirectories.length)
core.warning(`No existing directories found containing cache-dependency-path="${cacheDependencyPath}"`); core.warning(`No existing directories found containing cache-dependency-path="${cacheDependencyPath}"`);
projectDirectoriesMemoized = existingDirectories; projectDirectoriesMemoized = existingDirectories;
return existingDirectories; return existingDirectories;
}); });
/** /**
* Finds the cache directories configured for the repo if cache-dependency-path is not empty * Finds the cache directories configured for the repo if cache-dependency-path is not empty
* @param packageManagerInfo - an object having getCacheFolderPath method specific to given PM * @param packageManagerInfo - an object having getCacheFolderPath method specific to given PM
* @param cacheDependencyPath - either a single string or multiline string with possible glob patterns * @param cacheDependencyPath - either a single string or multiline string with possible glob patterns
* expected to be the result of `core.getInput('cache-dependency-path')` * expected to be the result of `core.getInput('cache-dependency-path')`
* @return list of files on which the cache depends * @return list of files on which the cache depends
*/ */
const getCacheDirectoriesFromCacheDependencyPath = (packageManagerInfo, cacheDependencyPath) => __awaiter(void 0, void 0, void 0, function* () { const getCacheDirectoriesFromCacheDependencyPath = (packageManagerInfo, cacheDependencyPath) => __awaiter(void 0, void 0, void 0, function* () {
const projectDirectories = yield getProjectDirectoriesFromCacheDependencyPath(cacheDependencyPath); const projectDirectories = yield getProjectDirectoriesFromCacheDependencyPath(cacheDependencyPath);
const cacheFoldersPaths = yield Promise.all(projectDirectories.map((projectDirectory) => __awaiter(void 0, void 0, void 0, function* () { const cacheFoldersPaths = yield Promise.all(projectDirectories.map((projectDirectory) => __awaiter(void 0, void 0, void 0, function* () {
const cacheFolderPath = yield packageManagerInfo.getCacheFolderPath(projectDirectory); const cacheFolderPath = yield packageManagerInfo.getCacheFolderPath(projectDirectory);
core.debug(`${packageManagerInfo.name}'s cache folder "${cacheFolderPath}" configured for the directory "${projectDirectory}"`); core.debug(`${packageManagerInfo.name}'s cache folder "${cacheFolderPath}" configured for the directory "${projectDirectory}"`);
return cacheFolderPath; return cacheFolderPath;
}))); })));
// uniq in order to do not cache the same directories twice // uniq in order to do not cache the same directories twice
return cacheFoldersPaths.filter(util_1.unique()); return cacheFoldersPaths.filter(util_1.unique());
}); });
/** /**
* Finds the cache directories configured for the repo ignoring cache-dependency-path * Finds the cache directories configured for the repo ignoring cache-dependency-path
* @param packageManagerInfo - an object having getCacheFolderPath method specific to given PM * @param packageManagerInfo - an object having getCacheFolderPath method specific to given PM
* @return list of files on which the cache depends * @return list of files on which the cache depends
*/ */
const getCacheDirectoriesForRootProject = (packageManagerInfo) => __awaiter(void 0, void 0, void 0, function* () { const getCacheDirectoriesForRootProject = (packageManagerInfo) => __awaiter(void 0, void 0, void 0, function* () {
const cacheFolderPath = yield packageManagerInfo.getCacheFolderPath(); const cacheFolderPath = yield packageManagerInfo.getCacheFolderPath();
core.debug(`${packageManagerInfo.name}'s cache folder "${cacheFolderPath}" configured for the root directory`); core.debug(`${packageManagerInfo.name}'s cache folder "${cacheFolderPath}" configured for the root directory`);
return [cacheFolderPath]; return [cacheFolderPath];
}); });
/** /**
* A function to find the cache directories configured for the repo * A function to find the cache directories configured for the repo
* currently it handles only the case of PM=yarn && cacheDependencyPath is not empty * currently it handles only the case of PM=yarn && cacheDependencyPath is not empty
* @param packageManagerInfo - an object having getCacheFolderPath method specific to given PM * @param packageManagerInfo - an object having getCacheFolderPath method specific to given PM
* @param cacheDependencyPath - either a single string or multiline string with possible glob patterns * @param cacheDependencyPath - either a single string or multiline string with possible glob patterns
* expected to be the result of `core.getInput('cache-dependency-path')` * expected to be the result of `core.getInput('cache-dependency-path')`
* @return list of files on which the cache depends * @return list of files on which the cache depends
*/ */
const getCacheDirectories = (packageManagerInfo, cacheDependencyPath) => __awaiter(void 0, void 0, void 0, function* () { const getCacheDirectories = (packageManagerInfo, cacheDependencyPath) => __awaiter(void 0, void 0, void 0, function* () {
// For yarn, if cacheDependencyPath is set, ask information about cache folders in each project // For yarn, if cacheDependencyPath is set, ask information about cache folders in each project
// folder satisfied by cacheDependencyPath https://github.com/actions/setup-node/issues/488 // folder satisfied by cacheDependencyPath https://github.com/actions/setup-node/issues/488
if (packageManagerInfo.name === 'yarn' && cacheDependencyPath) { if (packageManagerInfo.name === 'yarn' && cacheDependencyPath) {
return getCacheDirectoriesFromCacheDependencyPath(packageManagerInfo, cacheDependencyPath); return getCacheDirectoriesFromCacheDependencyPath(packageManagerInfo, cacheDependencyPath);
} }
return getCacheDirectoriesForRootProject(packageManagerInfo); return getCacheDirectoriesForRootProject(packageManagerInfo);
}); });
exports.getCacheDirectories = getCacheDirectories; exports.getCacheDirectories = getCacheDirectories;
/** /**
* A function to check if the directory is a yarn project configured to manage * A function to check if the directory is a yarn project configured to manage
* obsolete dependencies in the local cache * obsolete dependencies in the local cache
* @param directory - a path to the folder * @param directory - a path to the folder
* @return - true if the directory's project is yarn managed * @return - true if the directory's project is yarn managed
* - if there's .yarn/cache folder do not mess with the dependencies kept in the repo, return false * - if there's .yarn/cache folder do not mess with the dependencies kept in the repo, return false
* - global cache is not managed by yarn @see https://yarnpkg.com/features/offline-cache, return false * - global cache is not managed by yarn @see https://yarnpkg.com/features/offline-cache, return false
* - if local cache is not explicitly enabled (not yarn3), return false * - if local cache is not explicitly enabled (not yarn3), return false
* - return true otherwise * - return true otherwise
*/ */
const projectHasYarnBerryManagedDependencies = (directory) => __awaiter(void 0, void 0, void 0, function* () { const projectHasYarnBerryManagedDependencies = (directory) => __awaiter(void 0, void 0, void 0, function* () {
const workDir = directory || process.env.GITHUB_WORKSPACE || '.'; const workDir = directory || process.env.GITHUB_WORKSPACE || '.';
core.debug(`check if "${workDir}" has locally managed yarn3 dependencies`); core.debug(`check if "${workDir}" has locally managed yarn3 dependencies`);
// if .yarn/cache directory exists the cache is managed by version control system // if .yarn/cache directory exists the cache is managed by version control system
const yarnCacheFile = path_1.default.join(workDir, '.yarn', 'cache'); const yarnCacheFile = path_1.default.join(workDir, '.yarn', 'cache');
if (fs_1.default.existsSync(yarnCacheFile) && if (fs_1.default.existsSync(yarnCacheFile) &&
fs_1.default.lstatSync(yarnCacheFile).isDirectory()) { fs_1.default.lstatSync(yarnCacheFile).isDirectory()) {
core.debug(`"${workDir}" has .yarn/cache - dependencies are kept in the repository`); core.debug(`"${workDir}" has .yarn/cache - dependencies are kept in the repository`);
return Promise.resolve(false); return Promise.resolve(false);
} }
// NOTE: yarn1 returns 'undefined' with return code = 0 // NOTE: yarn1 returns 'undefined' with return code = 0
const enableGlobalCache = yield exports.getCommandOutput('yarn config get enableGlobalCache', workDir); const enableGlobalCache = yield exports.getCommandOutput('yarn config get enableGlobalCache', workDir);
// only local cache is not managed by yarn // only local cache is not managed by yarn
const managed = enableGlobalCache.includes('false'); const managed = enableGlobalCache.includes('false');
if (managed) { if (managed) {
core.debug(`"${workDir}" dependencies are managed by yarn 3 locally`); core.debug(`"${workDir}" dependencies are managed by yarn 3 locally`);
return true; return true;
} }
else { else {
core.debug(`"${workDir}" dependencies are not managed by yarn 3 locally`); core.debug(`"${workDir}" dependencies are not managed by yarn 3 locally`);
return false; return false;
} }
}); });
/** /**
* A function to report the repo contains Yarn managed projects * A function to report the repo contains Yarn managed projects
* @param packageManagerInfo - used to make sure current package manager is yarn * @param packageManagerInfo - used to make sure current package manager is yarn
* @param cacheDependencyPath - either a single string or multiline string with possible glob patterns * @param cacheDependencyPath - either a single string or multiline string with possible glob patterns
* expected to be the result of `core.getInput('cache-dependency-path')` * expected to be the result of `core.getInput('cache-dependency-path')`
* @return - true if all project directories configured to be Yarn managed * @return - true if all project directories configured to be Yarn managed
*/ */
const repoHasYarnBerryManagedDependencies = (packageManagerInfo, cacheDependencyPath) => __awaiter(void 0, void 0, void 0, function* () { const repoHasYarnBerryManagedDependencies = (packageManagerInfo, cacheDependencyPath) => __awaiter(void 0, void 0, void 0, function* () {
if (packageManagerInfo.name !== 'yarn') if (packageManagerInfo.name !== 'yarn')
return false; return false;
const yarnDirs = cacheDependencyPath const yarnDirs = cacheDependencyPath
? yield getProjectDirectoriesFromCacheDependencyPath(cacheDependencyPath) ? yield getProjectDirectoriesFromCacheDependencyPath(cacheDependencyPath)
: ['']; : [''];
const isManagedList = yield Promise.all(yarnDirs.map(projectHasYarnBerryManagedDependencies)); const isManagedList = yield Promise.all(yarnDirs.map(projectHasYarnBerryManagedDependencies));
return isManagedList.every(Boolean); return isManagedList.every(Boolean);
}); });
exports.repoHasYarnBerryManagedDependencies = repoHasYarnBerryManagedDependencies; exports.repoHasYarnBerryManagedDependencies = repoHasYarnBerryManagedDependencies;
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;
/***/ }), /***/ }),
@ -71510,26 +71641,26 @@ 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["CachePackageManager"] = "SETUP_NODE_CACHE_PACKAGE_MANAGER"; State["CachePackageManager"] = "SETUP_NODE_CACHE_PACKAGE_MANAGER";
State["CachePrimaryKey"] = "CACHE_KEY"; State["CachePrimaryKey"] = "CACHE_KEY";
State["CacheMatchedKey"] = "CACHE_RESULT"; State["CacheMatchedKey"] = "CACHE_RESULT";
State["CachePaths"] = "CACHE_PATHS"; State["CachePaths"] = "CACHE_PATHS";
})(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 = {}));
/***/ }), /***/ }),
@ -71538,73 +71669,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;
/***/ }), /***/ }),
@ -71613,275 +71744,276 @@ 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 uuid_1 = __nccwpck_require__(2155);
const hc = __importStar(__nccwpck_require__(9925)); const tc = __importStar(__nccwpck_require__(7784));
const core = __importStar(__nccwpck_require__(2186)); const hc = __importStar(__nccwpck_require__(9925));
const io = __importStar(__nccwpck_require__(7436)); const core = __importStar(__nccwpck_require__(2186));
const semver_1 = __importDefault(__nccwpck_require__(5911)); const io = __importStar(__nccwpck_require__(7436));
const assert = __importStar(__nccwpck_require__(9491)); const semver_1 = __importDefault(__nccwpck_require__(5911));
const path = __importStar(__nccwpck_require__(1017)); const assert = __importStar(__nccwpck_require__(9491));
const os_1 = __importDefault(__nccwpck_require__(2037)); const path = __importStar(__nccwpck_require__(1017));
const fs_1 = __importDefault(__nccwpck_require__(7147)); const os_1 = __importDefault(__nccwpck_require__(2037));
class BaseDistribution { const fs_1 = __importDefault(__nccwpck_require__(7147));
constructor(nodeInfo) { class BaseDistribution {
this.nodeInfo = nodeInfo; constructor(nodeInfo) {
this.osPlat = os_1.default.platform(); this.nodeInfo = nodeInfo;
this.httpClient = new hc.HttpClient('setup-node', [], { this.osPlat = os_1.default.platform();
allowRetries: true, this.httpClient = new hc.HttpClient('setup-node', [], {
maxRetries: 3 allowRetries: true,
}); maxRetries: 3
} });
setupNodeJs() { }
return __awaiter(this, void 0, void 0, function* () { setupNodeJs() {
let nodeJsVersions; return __awaiter(this, void 0, void 0, function* () {
if (this.nodeInfo.checkLatest) { let nodeJsVersions;
const evaluatedVersion = yield this.findVersionInDist(nodeJsVersions); if (this.nodeInfo.checkLatest) {
this.nodeInfo.versionSpec = evaluatedVersion; const evaluatedVersion = yield this.findVersionInDist(nodeJsVersions);
} this.nodeInfo.versionSpec = evaluatedVersion;
let toolPath = this.findVersionInHostedToolCacheDirectory(); }
if (toolPath) { let toolPath = this.findVersionInHostedToolCacheDirectory();
core.info(`Found in cache @ ${toolPath}`); if (toolPath) {
} core.info(`Found in cache @ ${toolPath}`);
else { }
const evaluatedVersion = yield this.findVersionInDist(nodeJsVersions); else {
const toolName = this.getNodejsDistInfo(evaluatedVersion); const evaluatedVersion = yield this.findVersionInDist(nodeJsVersions);
toolPath = yield this.downloadNodejs(toolName); const toolName = this.getNodejsDistInfo(evaluatedVersion);
} toolPath = yield this.downloadNodejs(toolName);
if (this.osPlat != 'win32') { }
toolPath = path.join(toolPath, 'bin'); if (this.osPlat != 'win32') {
} toolPath = path.join(toolPath, 'bin');
core.addPath(toolPath); }
}); core.addPath(toolPath);
} });
findVersionInDist(nodeJsVersions) { }
return __awaiter(this, void 0, void 0, function* () { findVersionInDist(nodeJsVersions) {
if (!nodeJsVersions) { return __awaiter(this, void 0, void 0, function* () {
nodeJsVersions = yield this.getNodeJsVersions(); if (!nodeJsVersions) {
} nodeJsVersions = yield this.getNodeJsVersions();
const versions = this.filterVersions(nodeJsVersions); }
const evaluatedVersion = this.evaluateVersions(versions); const versions = this.filterVersions(nodeJsVersions);
if (!evaluatedVersion) { const evaluatedVersion = this.evaluateVersions(versions);
throw new Error(`Unable to find Node version '${this.nodeInfo.versionSpec}' for platform ${this.osPlat} and architecture ${this.nodeInfo.arch}.`); if (!evaluatedVersion) {
} 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) { }
let version = ''; evaluateVersions(versions) {
const { range, options } = this.validRange(this.nodeInfo.versionSpec); let version = '';
core.debug(`evaluating ${versions.length} versions`); const { range, options } = this.validRange(this.nodeInfo.versionSpec);
for (const potential of versions) { core.debug(`evaluating ${versions.length} versions`);
const satisfied = semver_1.default.satisfies(potential, range, options); for (const potential of versions) {
if (satisfied) { const satisfied = semver_1.default.satisfies(potential, range, options);
version = potential; if (satisfied) {
break; version = potential;
} break;
} }
if (version) { }
core.debug(`matched: ${version}`); if (version) {
} core.debug(`matched: ${version}`);
else { }
core.debug('match not found'); else {
} core.debug('match not found');
return version; }
} return version;
findVersionInHostedToolCacheDirectory() { }
return tc.find('node', this.nodeInfo.versionSpec, this.translateArchToDistUrl(this.nodeInfo.arch)); findVersionInHostedToolCacheDirectory() {
} return tc.find('node', this.nodeInfo.versionSpec, this.translateArchToDistUrl(this.nodeInfo.arch));
getNodeJsVersions() { }
return __awaiter(this, void 0, void 0, function* () { getNodeJsVersions() {
const initialUrl = this.getDistributionUrl(); return __awaiter(this, void 0, void 0, function* () {
const dataUrl = `${initialUrl}/index.json`; const initialUrl = this.getDistributionUrl();
const response = yield this.httpClient.getJson(dataUrl); const dataUrl = `${initialUrl}/index.json`;
return response.result || []; const response = yield this.httpClient.getJson(dataUrl);
}); return response.result || [];
} });
getNodejsDistInfo(version) { }
const osArch = this.translateArchToDistUrl(this.nodeInfo.arch); getNodejsDistInfo(version) {
version = semver_1.default.clean(version) || ''; const osArch = this.translateArchToDistUrl(this.nodeInfo.arch);
const fileName = this.osPlat == 'win32' version = semver_1.default.clean(version) || '';
? `node-v${version}-win-${osArch}` const fileName = this.osPlat == 'win32'
: `node-v${version}-${this.osPlat}-${osArch}`; ? `node-v${version}-win-${osArch}`
const urlFileName = this.osPlat == 'win32' ? `${fileName}.7z` : `${fileName}.tar.gz`; : `node-v${version}-${this.osPlat}-${osArch}`;
const initialUrl = this.getDistributionUrl(); const urlFileName = this.osPlat == 'win32' ? `${fileName}.7z` : `${fileName}.tar.gz`;
const url = `${initialUrl}/v${version}/${urlFileName}`; const initialUrl = this.getDistributionUrl();
return { const url = `${initialUrl}/v${version}/${urlFileName}`;
downloadUrl: url, return {
resolvedVersion: version, downloadUrl: url,
arch: osArch, resolvedVersion: version,
fileName: fileName arch: osArch,
}; fileName: fileName
} };
downloadNodejs(info) { }
return __awaiter(this, void 0, void 0, function* () { downloadNodejs(info) {
let downloadPath = ''; return __awaiter(this, void 0, void 0, function* () {
core.info(`Acquiring ${info.resolvedVersion} - ${info.arch} from ${info.downloadUrl}`); let downloadPath = '';
try { core.info(`Acquiring ${info.resolvedVersion} - ${info.arch} from ${info.downloadUrl}`);
downloadPath = yield tc.downloadTool(info.downloadUrl); try {
} downloadPath = yield tc.downloadTool(info.downloadUrl);
catch (err) { }
if (err instanceof tc.HTTPError && catch (err) {
err.httpStatusCode == 404 && if (err instanceof tc.HTTPError &&
this.osPlat == 'win32') { err.httpStatusCode == 404 &&
return yield this.acquireWindowsNodeFromFallbackLocation(info.resolvedVersion, info.arch); this.osPlat == 'win32') {
} return yield this.acquireWindowsNodeFromFallbackLocation(info.resolvedVersion, info.arch);
throw err; }
} throw err;
const toolPath = yield this.extractArchive(downloadPath, info); }
core.info('Done'); const toolPath = yield this.extractArchive(downloadPath, info);
return toolPath; core.info('Done');
}); return toolPath;
} });
validRange(versionSpec) { }
var _a; validRange(versionSpec) {
let options; var _a;
const c = semver_1.default.clean(versionSpec) || ''; let options;
const valid = (_a = semver_1.default.valid(c)) !== null && _a !== void 0 ? _a : versionSpec; const c = semver_1.default.clean(versionSpec) || '';
return { range: valid, options }; const valid = (_a = semver_1.default.valid(c)) !== null && _a !== void 0 ? _a : versionSpec;
} return { range: valid, options };
acquireWindowsNodeFromFallbackLocation(version, arch = os_1.default.arch()) { }
return __awaiter(this, void 0, void 0, function* () { acquireWindowsNodeFromFallbackLocation(version, arch = os_1.default.arch()) {
const initialUrl = this.getDistributionUrl(); return __awaiter(this, void 0, void 0, function* () {
const osArch = this.translateArchToDistUrl(arch); const initialUrl = this.getDistributionUrl();
// Create temporary folder to download in to const osArch = this.translateArchToDistUrl(arch);
const tempDownloadFolder = 'temp_' + Math.floor(Math.random() * 2000000000); // Create temporary folder to download to
const tempDirectory = process.env['RUNNER_TEMP'] || ''; const tempDownloadFolder = `temp_${uuid_1.v4()}`;
assert.ok(tempDirectory, 'Expected RUNNER_TEMP to be defined'); const tempDirectory = process.env['RUNNER_TEMP'] || '';
const tempDir = path.join(tempDirectory, tempDownloadFolder); assert.ok(tempDirectory, 'Expected RUNNER_TEMP to be defined');
yield io.mkdirP(tempDir); const tempDir = path.join(tempDirectory, tempDownloadFolder);
let exeUrl; yield io.mkdirP(tempDir);
let libUrl; let exeUrl;
try { let libUrl;
exeUrl = `${initialUrl}/v${version}/win-${osArch}/node.exe`; try {
libUrl = `${initialUrl}/v${version}/win-${osArch}/node.lib`; exeUrl = `${initialUrl}/v${version}/win-${osArch}/node.exe`;
core.info(`Downloading only node binary from ${exeUrl}`); libUrl = `${initialUrl}/v${version}/win-${osArch}/node.lib`;
const exePath = yield tc.downloadTool(exeUrl); core.info(`Downloading only node binary from ${exeUrl}`);
yield io.cp(exePath, path.join(tempDir, 'node.exe')); const exePath = yield tc.downloadTool(exeUrl);
const libPath = yield tc.downloadTool(libUrl); yield io.cp(exePath, path.join(tempDir, 'node.exe'));
yield io.cp(libPath, path.join(tempDir, 'node.lib')); const libPath = yield tc.downloadTool(libUrl);
} yield io.cp(libPath, path.join(tempDir, 'node.lib'));
catch (err) { }
if (err instanceof tc.HTTPError && err.httpStatusCode == 404) { catch (err) {
exeUrl = `${initialUrl}/v${version}/node.exe`; if (err instanceof tc.HTTPError && err.httpStatusCode == 404) {
libUrl = `${initialUrl}/v${version}/node.lib`; exeUrl = `${initialUrl}/v${version}/node.exe`;
const exePath = yield tc.downloadTool(exeUrl); libUrl = `${initialUrl}/v${version}/node.lib`;
yield io.cp(exePath, path.join(tempDir, 'node.exe')); const exePath = yield tc.downloadTool(exeUrl);
const libPath = yield tc.downloadTool(libUrl); yield io.cp(exePath, path.join(tempDir, 'node.exe'));
yield io.cp(libPath, path.join(tempDir, 'node.lib')); const libPath = yield tc.downloadTool(libUrl);
} yield io.cp(libPath, path.join(tempDir, 'node.lib'));
else { }
throw err; else {
} throw err;
} }
const toolPath = yield tc.cacheDir(tempDir, 'node', version, arch); }
return toolPath; const toolPath = yield tc.cacheDir(tempDir, 'node', version, arch);
}); return toolPath;
} });
extractArchive(downloadPath, info) { }
return __awaiter(this, void 0, void 0, function* () { extractArchive(downloadPath, info) {
// return __awaiter(this, void 0, void 0, function* () {
// Extract //
// // Extract
core.info('Extracting ...'); //
let extPath; core.info('Extracting ...');
info = info || {}; // satisfy compiler, never null when reaches here let extPath;
if (this.osPlat == 'win32') { info = info || {}; // satisfy compiler, never null when reaches here
const _7zPath = path.join(__dirname, '../..', 'externals', '7zr.exe'); if (this.osPlat == 'win32') {
extPath = yield tc.extract7z(downloadPath, undefined, _7zPath); const _7zPath = path.join(__dirname, '../..', 'externals', '7zr.exe');
// 7z extracts to folder matching file name extPath = yield tc.extract7z(downloadPath, undefined, _7zPath);
const nestedPath = path.join(extPath, path.basename(info.fileName, '.7z')); // 7z extracts to folder matching file name
if (fs_1.default.existsSync(nestedPath)) { const nestedPath = path.join(extPath, path.basename(info.fileName, '.7z'));
extPath = nestedPath; if (fs_1.default.existsSync(nestedPath)) {
} extPath = nestedPath;
} }
else { }
extPath = yield tc.extractTar(downloadPath, undefined, [ else {
'xz', extPath = yield tc.extractTar(downloadPath, undefined, [
'--strip', 'xz',
'1' '--strip',
]); '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 ...'); //
const toolPath = yield tc.cacheDir(extPath, 'node', info.resolvedVersion, info.arch); core.info('Adding to the cache ...');
return toolPath; const toolPath = yield tc.cacheDir(extPath, 'node', info.resolvedVersion, info.arch);
}); return toolPath;
} });
getDistFileName() { }
const osArch = this.translateArchToDistUrl(this.nodeInfo.arch); getDistFileName() {
// node offers a json list of versions const osArch = this.translateArchToDistUrl(this.nodeInfo.arch);
let dataFileName; // node offers a json list of versions
switch (this.osPlat) { let dataFileName;
case 'linux': switch (this.osPlat) {
dataFileName = `linux-${osArch}`; case 'linux':
break; dataFileName = `linux-${osArch}`;
case 'darwin': break;
dataFileName = `osx-${osArch}-tar`; case 'darwin':
break; dataFileName = `osx-${osArch}-tar`;
case 'win32': break;
dataFileName = `win-${osArch}-exe`; case 'win32':
break; dataFileName = `win-${osArch}-exe`;
default: break;
throw new Error(`Unexpected OS '${this.osPlat}'`); default:
} throw new Error(`Unexpected OS '${this.osPlat}'`);
return dataFileName; }
} return dataFileName;
filterVersions(nodeJsVersions) { }
const versions = []; filterVersions(nodeJsVersions) {
const dataFileName = this.getDistFileName(); const versions = [];
nodeJsVersions.forEach((nodeVersion) => { const dataFileName = this.getDistFileName();
// ensure this version supports your os and platform nodeJsVersions.forEach((nodeVersion) => {
if (nodeVersion.files.indexOf(dataFileName) >= 0) { // ensure this version supports your os and platform
versions.push(nodeVersion.version); if (nodeVersion.files.indexOf(dataFileName) >= 0) {
} versions.push(nodeVersion.version);
}); }
return versions.sort(semver_1.default.rcompare); });
} return versions.sort(semver_1.default.rcompare);
translateArchToDistUrl(arch) { }
switch (arch) { translateArchToDistUrl(arch) {
case 'arm': switch (arch) {
return 'armv7l'; case 'arm':
default: return 'armv7l';
return arch; default:
} return arch;
} }
} }
exports["default"] = BaseDistribution; }
exports["default"] = BaseDistribution;
/***/ }), /***/ }),
@ -71890,41 +72022,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;
/***/ }), /***/ }),
@ -71933,22 +72065,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;
/***/ }), /***/ }),
@ -71957,203 +72089,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;
/***/ }), /***/ }),
@ -72162,21 +72294,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;
/***/ }), /***/ }),
@ -72185,22 +72317,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;
/***/ }), /***/ }),
@ -72209,124 +72341,124 @@ 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);
const constants_1 = __nccwpck_require__(9042); const constants_1 = __nccwpck_require__(9042);
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()) {
core.saveState(constants_1.State.CachePackageManager, cache); core.saveState(constants_1.State.CachePackageManager, cache);
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;
} }
/***/ }), /***/ }),
@ -72335,108 +72467,108 @@ 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.unique = exports.printEnvDetailsAndSetOutput = exports.parseNodeVersionFile = void 0; exports.unique = 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(/^(?:node(js)?\s+)?v?(?<version>[^\s]+)$/m); const found = contents.match(/^(?:node(js)?\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 '';
} }
}); });
} }
const unique = () => { const unique = () => {
const encountered = new Set(); const encountered = new Set();
return (value) => { return (value) => {
if (encountered.has(value)) if (encountered.has(value))
return false; return false;
encountered.add(value); encountered.add(value);
return true; return true;
}; };
}; };
exports.unique = unique; exports.unique = unique;
/***/ }), /***/ }),
@ -72684,10 +72816,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();
})(); })();

47
package-lock.json generated
View File

@ -17,12 +17,14 @@
"@actions/http-client": "^1.0.11", "@actions/http-client": "^1.0.11",
"@actions/io": "^1.0.2", "@actions/io": "^1.0.2",
"@actions/tool-cache": "^1.5.4", "@actions/tool-cache": "^1.5.4",
"semver": "^6.3.1" "semver": "^6.3.1",
"uuid": "^9.0.0"
}, },
"devDependencies": { "devDependencies": {
"@types/jest": "^27.0.2", "@types/jest": "^27.0.2",
"@types/node": "^16.11.25", "@types/node": "^16.11.25",
"@types/semver": "^6.0.0", "@types/semver": "^6.0.0",
"@types/uuid": "^9.0.3",
"@typescript-eslint/eslint-plugin": "^5.54.0", "@typescript-eslint/eslint-plugin": "^5.54.0",
"@typescript-eslint/parser": "^5.54.0", "@typescript-eslint/parser": "^5.54.0",
"@vercel/ncc": "^0.33.4", "@vercel/ncc": "^0.33.4",
@ -158,6 +160,15 @@
"uuid": "^3.3.2" "uuid": "^3.3.2"
} }
}, },
"node_modules/@actions/tool-cache/node_modules/uuid": {
"version": "3.4.0",
"resolved": "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz",
"integrity": "sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==",
"deprecated": "Please upgrade to version 7 or higher. Older versions may use Math.random() in certain circumstances, which is known to be problematic. See https://v8.dev/blog/math-random for details.",
"bin": {
"uuid": "bin/uuid"
}
},
"node_modules/@azure/abort-controller": { "node_modules/@azure/abort-controller": {
"version": "1.1.0", "version": "1.1.0",
"resolved": "https://registry.npmjs.org/@azure/abort-controller/-/abort-controller-1.1.0.tgz", "resolved": "https://registry.npmjs.org/@azure/abort-controller/-/abort-controller-1.1.0.tgz",
@ -1688,6 +1699,12 @@
"@types/node": "*" "@types/node": "*"
} }
}, },
"node_modules/@types/uuid": {
"version": "9.0.3",
"resolved": "https://registry.npmjs.org/@types/uuid/-/uuid-9.0.3.tgz",
"integrity": "sha512-taHQQH/3ZyI3zP8M/puluDEIEvtQHVYcC6y3N8ijFtAd28+Ey/G4sg1u2gB01S8MwybLOKAp9/yCMu/uR5l3Ug==",
"dev": true
},
"node_modules/@types/yargs": { "node_modules/@types/yargs": {
"version": "16.0.4", "version": "16.0.4",
"resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-16.0.4.tgz", "resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-16.0.4.tgz",
@ -6169,12 +6186,11 @@
} }
}, },
"node_modules/uuid": { "node_modules/uuid": {
"version": "3.3.2", "version": "9.0.0",
"resolved": "https://registry.npmjs.org/uuid/-/uuid-3.3.2.tgz", "resolved": "https://registry.npmjs.org/uuid/-/uuid-9.0.0.tgz",
"integrity": "sha512-yXJmeNaw3DnnKAOKJE51sL/ZaYfWJRl1pK9dr19YFCu0ObS231AB1/LbqTKRAQ5kw8A90rA6fr4riOUpTZvQZA==", "integrity": "sha512-MXcSTerfPa4uqyzStbRoTgt5XIe3x5+42+q1sDuy3R5MDk66URdLMOZe5aPX/SQd+kuYAh0FdP/pO28IkQyTeg==",
"deprecated": "Please upgrade to version 7 or higher. Older versions may use Math.random() in certain circumstances, which is known to be problematic. See https://v8.dev/blog/math-random for details.",
"bin": { "bin": {
"uuid": "bin/uuid" "uuid": "dist/bin/uuid"
} }
}, },
"node_modules/v8-to-istanbul": { "node_modules/v8-to-istanbul": {
@ -6557,6 +6573,13 @@
"@actions/io": "^1.0.1", "@actions/io": "^1.0.1",
"semver": "^6.1.0", "semver": "^6.1.0",
"uuid": "^3.3.2" "uuid": "^3.3.2"
},
"dependencies": {
"uuid": {
"version": "3.4.0",
"resolved": "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz",
"integrity": "sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A=="
}
} }
}, },
"@azure/abort-controller": { "@azure/abort-controller": {
@ -7820,6 +7843,12 @@
"@types/node": "*" "@types/node": "*"
} }
}, },
"@types/uuid": {
"version": "9.0.3",
"resolved": "https://registry.npmjs.org/@types/uuid/-/uuid-9.0.3.tgz",
"integrity": "sha512-taHQQH/3ZyI3zP8M/puluDEIEvtQHVYcC6y3N8ijFtAd28+Ey/G4sg1u2gB01S8MwybLOKAp9/yCMu/uR5l3Ug==",
"dev": true
},
"@types/yargs": { "@types/yargs": {
"version": "16.0.4", "version": "16.0.4",
"resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-16.0.4.tgz", "resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-16.0.4.tgz",
@ -11114,9 +11143,9 @@
} }
}, },
"uuid": { "uuid": {
"version": "3.3.2", "version": "9.0.0",
"resolved": "https://registry.npmjs.org/uuid/-/uuid-3.3.2.tgz", "resolved": "https://registry.npmjs.org/uuid/-/uuid-9.0.0.tgz",
"integrity": "sha512-yXJmeNaw3DnnKAOKJE51sL/ZaYfWJRl1pK9dr19YFCu0ObS231AB1/LbqTKRAQ5kw8A90rA6fr4riOUpTZvQZA==" "integrity": "sha512-MXcSTerfPa4uqyzStbRoTgt5XIe3x5+42+q1sDuy3R5MDk66URdLMOZe5aPX/SQd+kuYAh0FdP/pO28IkQyTeg=="
}, },
"v8-to-istanbul": { "v8-to-istanbul": {
"version": "8.1.0", "version": "8.1.0",

View File

@ -33,12 +33,14 @@
"@actions/http-client": "^1.0.11", "@actions/http-client": "^1.0.11",
"@actions/io": "^1.0.2", "@actions/io": "^1.0.2",
"@actions/tool-cache": "^1.5.4", "@actions/tool-cache": "^1.5.4",
"semver": "^6.3.1" "semver": "^6.3.1",
"uuid": "^9.0.0"
}, },
"devDependencies": { "devDependencies": {
"@types/jest": "^27.0.2", "@types/jest": "^27.0.2",
"@types/node": "^16.11.25", "@types/node": "^16.11.25",
"@types/semver": "^6.0.0", "@types/semver": "^6.0.0",
"@types/uuid": "^9.0.3",
"@typescript-eslint/eslint-plugin": "^5.54.0", "@typescript-eslint/eslint-plugin": "^5.54.0",
"@typescript-eslint/parser": "^5.54.0", "@typescript-eslint/parser": "^5.54.0",
"@vercel/ncc": "^0.33.4", "@vercel/ncc": "^0.33.4",

View File

@ -1,3 +1,4 @@
import {v4 as uuidv4} from 'uuid';
import * as tc from '@actions/tool-cache'; import * as tc from '@actions/tool-cache';
import * as hc from '@actions/http-client'; import * as hc from '@actions/http-client';
import * as core from '@actions/core'; import * as core from '@actions/core';
@ -166,9 +167,8 @@ export default abstract class BaseDistribution {
const initialUrl = this.getDistributionUrl(); const initialUrl = this.getDistributionUrl();
const osArch: string = this.translateArchToDistUrl(arch); const osArch: string = this.translateArchToDistUrl(arch);
// Create temporary folder to download in to // Create temporary folder to download to
const tempDownloadFolder: string = const tempDownloadFolder = `temp_${uuidv4()}`;
'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: string = path.join(tempDirectory, tempDownloadFolder); const tempDir: string = path.join(tempDirectory, tempDownloadFolder);