Skip to content

Commit 1a4ff54

Browse files
committedJun 29, 2022
feat: add volta as node-version-file
1 parent 7d610f0 commit 1a4ff54

File tree

4 files changed

+938
-923
lines changed

4 files changed

+938
-923
lines changed
 

‎dist/cache-save/index.js

+188-188
Original file line numberDiff line numberDiff line change
@@ -59827,74 +59827,74 @@ exports.fromPromise = function (fn) {
5982759827
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
5982859828

5982959829
"use strict";
59830-
59831-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
59832-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
59833-
return new (P || (P = Promise))(function (resolve, reject) {
59834-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
59835-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
59836-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
59837-
step((generator = generator.apply(thisArg, _arguments || [])).next());
59838-
});
59839-
};
59840-
var __importStar = (this && this.__importStar) || function (mod) {
59841-
if (mod && mod.__esModule) return mod;
59842-
var result = {};
59843-
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
59844-
result["default"] = mod;
59845-
return result;
59846-
};
59847-
var __importDefault = (this && this.__importDefault) || function (mod) {
59848-
return (mod && mod.__esModule) ? mod : { "default": mod };
59849-
};
59850-
Object.defineProperty(exports, "__esModule", ({ value: true }));
59851-
const core = __importStar(__nccwpck_require__(2186));
59852-
const cache = __importStar(__nccwpck_require__(7799));
59853-
const fs_1 = __importDefault(__nccwpck_require__(7147));
59854-
const constants_1 = __nccwpck_require__(9042);
59855-
const cache_utils_1 = __nccwpck_require__(1678);
59856-
// Catch and log any unhandled exceptions. These exceptions can leak out of the uploadChunk method in
59857-
// @actions/toolkit when a failed upload closes the file descriptor causing any in-process reads to
59858-
// throw an uncaught exception. Instead of failing this action, just warn.
59859-
process.on('uncaughtException', e => {
59860-
const warningPrefix = '[warning]';
59861-
core.info(`${warningPrefix}${e.message}`);
59862-
});
59863-
function run() {
59864-
return __awaiter(this, void 0, void 0, function* () {
59865-
try {
59866-
const cacheLock = core.getInput('cache');
59867-
yield cachePackages(cacheLock);
59868-
}
59869-
catch (error) {
59870-
core.setFailed(error.message);
59871-
}
59872-
});
59873-
}
59874-
exports.run = run;
59875-
const cachePackages = (packageManager) => __awaiter(void 0, void 0, void 0, function* () {
59876-
const state = core.getState(constants_1.State.CacheMatchedKey);
59877-
const primaryKey = core.getState(constants_1.State.CachePrimaryKey);
59878-
const packageManagerInfo = yield cache_utils_1.getPackageManagerInfo(packageManager);
59879-
if (!packageManagerInfo) {
59880-
core.debug(`Caching for '${packageManager}' is not supported`);
59881-
return;
59882-
}
59883-
const cachePath = yield cache_utils_1.getCacheDirectoryPath(packageManagerInfo, packageManager);
59884-
if (!fs_1.default.existsSync(cachePath)) {
59885-
throw new Error(`Cache folder path is retrieved for ${packageManager} but doesn't exist on disk: ${cachePath}`);
59886-
}
59887-
if (primaryKey === state) {
59888-
core.info(`Cache hit occurred on the primary key ${primaryKey}, not saving cache.`);
59889-
return;
59890-
}
59891-
const cacheId = yield cache.saveCache([cachePath], primaryKey);
59892-
if (cacheId == -1) {
59893-
return;
59894-
}
59895-
core.info(`Cache saved with the key: ${primaryKey}`);
59896-
});
59897-
run();
59830+
59831+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
59832+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
59833+
return new (P || (P = Promise))(function (resolve, reject) {
59834+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
59835+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
59836+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
59837+
step((generator = generator.apply(thisArg, _arguments || [])).next());
59838+
});
59839+
};
59840+
var __importStar = (this && this.__importStar) || function (mod) {
59841+
if (mod && mod.__esModule) return mod;
59842+
var result = {};
59843+
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
59844+
result["default"] = mod;
59845+
return result;
59846+
};
59847+
var __importDefault = (this && this.__importDefault) || function (mod) {
59848+
return (mod && mod.__esModule) ? mod : { "default": mod };
59849+
};
59850+
Object.defineProperty(exports, "__esModule", ({ value: true }));
59851+
const core = __importStar(__nccwpck_require__(2186));
59852+
const cache = __importStar(__nccwpck_require__(7799));
59853+
const fs_1 = __importDefault(__nccwpck_require__(7147));
59854+
const constants_1 = __nccwpck_require__(9042);
59855+
const cache_utils_1 = __nccwpck_require__(1678);
59856+
// Catch and log any unhandled exceptions. These exceptions can leak out of the uploadChunk method in
59857+
// @actions/toolkit when a failed upload closes the file descriptor causing any in-process reads to
59858+
// throw an uncaught exception. Instead of failing this action, just warn.
59859+
process.on('uncaughtException', e => {
59860+
const warningPrefix = '[warning]';
59861+
core.info(`${warningPrefix}${e.message}`);
59862+
});
59863+
function run() {
59864+
return __awaiter(this, void 0, void 0, function* () {
59865+
try {
59866+
const cacheLock = core.getInput('cache');
59867+
yield cachePackages(cacheLock);
59868+
}
59869+
catch (error) {
59870+
core.setFailed(error.message);
59871+
}
59872+
});
59873+
}
59874+
exports.run = run;
59875+
const cachePackages = (packageManager) => __awaiter(void 0, void 0, void 0, function* () {
59876+
const state = core.getState(constants_1.State.CacheMatchedKey);
59877+
const primaryKey = core.getState(constants_1.State.CachePrimaryKey);
59878+
const packageManagerInfo = yield cache_utils_1.getPackageManagerInfo(packageManager);
59879+
if (!packageManagerInfo) {
59880+
core.debug(`Caching for '${packageManager}' is not supported`);
59881+
return;
59882+
}
59883+
const cachePath = yield cache_utils_1.getCacheDirectoryPath(packageManagerInfo, packageManager);
59884+
if (!fs_1.default.existsSync(cachePath)) {
59885+
throw new Error(`Cache folder path is retrieved for ${packageManager} but doesn't exist on disk: ${cachePath}`);
59886+
}
59887+
if (primaryKey === state) {
59888+
core.info(`Cache hit occurred on the primary key ${primaryKey}, not saving cache.`);
59889+
return;
59890+
}
59891+
const cacheId = yield cache.saveCache([cachePath], primaryKey);
59892+
if (cacheId == -1) {
59893+
return;
59894+
}
59895+
core.info(`Cache saved with the key: ${primaryKey}`);
59896+
});
59897+
run();
5989859898

5989959899

5990059900
/***/ }),
@@ -59903,109 +59903,109 @@ run();
5990359903
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
5990459904

5990559905
"use strict";
59906-
59907-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
59908-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
59909-
return new (P || (P = Promise))(function (resolve, reject) {
59910-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
59911-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
59912-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
59913-
step((generator = generator.apply(thisArg, _arguments || [])).next());
59914-
});
59915-
};
59916-
var __importStar = (this && this.__importStar) || function (mod) {
59917-
if (mod && mod.__esModule) return mod;
59918-
var result = {};
59919-
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
59920-
result["default"] = mod;
59921-
return result;
59922-
};
59923-
Object.defineProperty(exports, "__esModule", ({ value: true }));
59924-
const core = __importStar(__nccwpck_require__(2186));
59925-
const exec = __importStar(__nccwpck_require__(1514));
59926-
const cache = __importStar(__nccwpck_require__(7799));
59927-
exports.supportedPackageManagers = {
59928-
npm: {
59929-
lockFilePatterns: ['package-lock.json', 'yarn.lock'],
59930-
getCacheFolderCommand: 'npm config get cache'
59931-
},
59932-
pnpm: {
59933-
lockFilePatterns: ['pnpm-lock.yaml'],
59934-
getCacheFolderCommand: 'pnpm store path'
59935-
},
59936-
yarn1: {
59937-
lockFilePatterns: ['yarn.lock'],
59938-
getCacheFolderCommand: 'yarn cache dir'
59939-
},
59940-
yarn2: {
59941-
lockFilePatterns: ['yarn.lock'],
59942-
getCacheFolderCommand: 'yarn config get cacheFolder'
59943-
}
59944-
};
59945-
exports.getCommandOutput = (toolCommand) => __awaiter(void 0, void 0, void 0, function* () {
59946-
let { stdout, stderr, exitCode } = yield exec.getExecOutput(toolCommand, undefined, { ignoreReturnCode: true });
59947-
if (exitCode) {
59948-
stderr = !stderr.trim()
59949-
? `The '${toolCommand}' command failed with exit code: ${exitCode}`
59950-
: stderr;
59951-
throw new Error(stderr);
59952-
}
59953-
return stdout.trim();
59954-
});
59955-
const getPackageManagerVersion = (packageManager, command) => __awaiter(void 0, void 0, void 0, function* () {
59956-
const stdOut = yield exports.getCommandOutput(`${packageManager} ${command}`);
59957-
if (!stdOut) {
59958-
throw new Error(`Could not retrieve version of ${packageManager}`);
59959-
}
59960-
return stdOut;
59961-
});
59962-
exports.getPackageManagerInfo = (packageManager) => __awaiter(void 0, void 0, void 0, function* () {
59963-
if (packageManager === 'npm') {
59964-
return exports.supportedPackageManagers.npm;
59965-
}
59966-
else if (packageManager === 'pnpm') {
59967-
return exports.supportedPackageManagers.pnpm;
59968-
}
59969-
else if (packageManager === 'yarn') {
59970-
const yarnVersion = yield getPackageManagerVersion('yarn', '--version');
59971-
core.debug(`Consumed yarn version is ${yarnVersion}`);
59972-
if (yarnVersion.startsWith('1.')) {
59973-
return exports.supportedPackageManagers.yarn1;
59974-
}
59975-
else {
59976-
return exports.supportedPackageManagers.yarn2;
59977-
}
59978-
}
59979-
else {
59980-
return null;
59981-
}
59982-
});
59983-
exports.getCacheDirectoryPath = (packageManagerInfo, packageManager) => __awaiter(void 0, void 0, void 0, function* () {
59984-
const stdOut = yield exports.getCommandOutput(packageManagerInfo.getCacheFolderCommand);
59985-
if (!stdOut) {
59986-
throw new Error(`Could not get cache folder path for ${packageManager}`);
59987-
}
59988-
core.debug(`${packageManager} path is ${stdOut}`);
59989-
return stdOut;
59990-
});
59991-
function isGhes() {
59992-
const ghUrl = new URL(process.env['GITHUB_SERVER_URL'] || 'https://github.com');
59993-
return ghUrl.hostname.toUpperCase() !== 'GITHUB.COM';
59994-
}
59995-
exports.isGhes = isGhes;
59996-
function isCacheFeatureAvailable() {
59997-
if (!cache.isFeatureAvailable()) {
59998-
if (isGhes()) {
59999-
throw new Error('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.');
60000-
}
60001-
else {
60002-
core.warning('The runner was not able to contact the cache service. Caching will be skipped');
60003-
}
60004-
return false;
60005-
}
60006-
return true;
60007-
}
60008-
exports.isCacheFeatureAvailable = isCacheFeatureAvailable;
59906+
59907+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
59908+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
59909+
return new (P || (P = Promise))(function (resolve, reject) {
59910+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
59911+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
59912+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
59913+
step((generator = generator.apply(thisArg, _arguments || [])).next());
59914+
});
59915+
};
59916+
var __importStar = (this && this.__importStar) || function (mod) {
59917+
if (mod && mod.__esModule) return mod;
59918+
var result = {};
59919+
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
59920+
result["default"] = mod;
59921+
return result;
59922+
};
59923+
Object.defineProperty(exports, "__esModule", ({ value: true }));
59924+
const core = __importStar(__nccwpck_require__(2186));
59925+
const exec = __importStar(__nccwpck_require__(1514));
59926+
const cache = __importStar(__nccwpck_require__(7799));
59927+
exports.supportedPackageManagers = {
59928+
npm: {
59929+
lockFilePatterns: ['package-lock.json', 'yarn.lock'],
59930+
getCacheFolderCommand: 'npm config get cache'
59931+
},
59932+
pnpm: {
59933+
lockFilePatterns: ['pnpm-lock.yaml'],
59934+
getCacheFolderCommand: 'pnpm store path'
59935+
},
59936+
yarn1: {
59937+
lockFilePatterns: ['yarn.lock'],
59938+
getCacheFolderCommand: 'yarn cache dir'
59939+
},
59940+
yarn2: {
59941+
lockFilePatterns: ['yarn.lock'],
59942+
getCacheFolderCommand: 'yarn config get cacheFolder'
59943+
}
59944+
};
59945+
exports.getCommandOutput = (toolCommand) => __awaiter(void 0, void 0, void 0, function* () {
59946+
let { stdout, stderr, exitCode } = yield exec.getExecOutput(toolCommand, undefined, { ignoreReturnCode: true });
59947+
if (exitCode) {
59948+
stderr = !stderr.trim()
59949+
? `The '${toolCommand}' command failed with exit code: ${exitCode}`
59950+
: stderr;
59951+
throw new Error(stderr);
59952+
}
59953+
return stdout.trim();
59954+
});
59955+
const getPackageManagerVersion = (packageManager, command) => __awaiter(void 0, void 0, void 0, function* () {
59956+
const stdOut = yield exports.getCommandOutput(`${packageManager} ${command}`);
59957+
if (!stdOut) {
59958+
throw new Error(`Could not retrieve version of ${packageManager}`);
59959+
}
59960+
return stdOut;
59961+
});
59962+
exports.getPackageManagerInfo = (packageManager) => __awaiter(void 0, void 0, void 0, function* () {
59963+
if (packageManager === 'npm') {
59964+
return exports.supportedPackageManagers.npm;
59965+
}
59966+
else if (packageManager === 'pnpm') {
59967+
return exports.supportedPackageManagers.pnpm;
59968+
}
59969+
else if (packageManager === 'yarn') {
59970+
const yarnVersion = yield getPackageManagerVersion('yarn', '--version');
59971+
core.debug(`Consumed yarn version is ${yarnVersion}`);
59972+
if (yarnVersion.startsWith('1.')) {
59973+
return exports.supportedPackageManagers.yarn1;
59974+
}
59975+
else {
59976+
return exports.supportedPackageManagers.yarn2;
59977+
}
59978+
}
59979+
else {
59980+
return null;
59981+
}
59982+
});
59983+
exports.getCacheDirectoryPath = (packageManagerInfo, packageManager) => __awaiter(void 0, void 0, void 0, function* () {
59984+
const stdOut = yield exports.getCommandOutput(packageManagerInfo.getCacheFolderCommand);
59985+
if (!stdOut) {
59986+
throw new Error(`Could not get cache folder path for ${packageManager}`);
59987+
}
59988+
core.debug(`${packageManager} path is ${stdOut}`);
59989+
return stdOut;
59990+
});
59991+
function isGhes() {
59992+
const ghUrl = new URL(process.env['GITHUB_SERVER_URL'] || 'https://github.com');
59993+
return ghUrl.hostname.toUpperCase() !== 'GITHUB.COM';
59994+
}
59995+
exports.isGhes = isGhes;
59996+
function isCacheFeatureAvailable() {
59997+
if (!cache.isFeatureAvailable()) {
59998+
if (isGhes()) {
59999+
throw new Error('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.');
60000+
}
60001+
else {
60002+
core.warning('The runner was not able to contact the cache service. Caching will be skipped');
60003+
}
60004+
return false;
60005+
}
60006+
return true;
60007+
}
60008+
exports.isCacheFeatureAvailable = isCacheFeatureAvailable;
6000960009

6001060010

6001160011
/***/ }),
@@ -60014,23 +60014,23 @@ exports.isCacheFeatureAvailable = isCacheFeatureAvailable;
6001460014
/***/ ((__unused_webpack_module, exports) => {
6001560015

6001660016
"use strict";
60017-
60018-
Object.defineProperty(exports, "__esModule", ({ value: true }));
60019-
var LockType;
60020-
(function (LockType) {
60021-
LockType["Npm"] = "npm";
60022-
LockType["Pnpm"] = "pnpm";
60023-
LockType["Yarn"] = "yarn";
60024-
})(LockType = exports.LockType || (exports.LockType = {}));
60025-
var State;
60026-
(function (State) {
60027-
State["CachePrimaryKey"] = "CACHE_KEY";
60028-
State["CacheMatchedKey"] = "CACHE_RESULT";
60029-
})(State = exports.State || (exports.State = {}));
60030-
var Outputs;
60031-
(function (Outputs) {
60032-
Outputs["CacheHit"] = "cache-hit";
60033-
})(Outputs = exports.Outputs || (exports.Outputs = {}));
60017+
60018+
Object.defineProperty(exports, "__esModule", ({ value: true }));
60019+
var LockType;
60020+
(function (LockType) {
60021+
LockType["Npm"] = "npm";
60022+
LockType["Pnpm"] = "pnpm";
60023+
LockType["Yarn"] = "yarn";
60024+
})(LockType = exports.LockType || (exports.LockType = {}));
60025+
var State;
60026+
(function (State) {
60027+
State["CachePrimaryKey"] = "CACHE_KEY";
60028+
State["CacheMatchedKey"] = "CACHE_RESULT";
60029+
})(State = exports.State || (exports.State = {}));
60030+
var Outputs;
60031+
(function (Outputs) {
60032+
Outputs["CacheHit"] = "cache-hit";
60033+
})(Outputs = exports.Outputs || (exports.Outputs = {}));
6003460034

6003560035

6003660036
/***/ }),

0 commit comments

Comments
 (0)