@@ -39252,7 +39252,137 @@ exports.NOOP_METER_PROVIDER = new NoopMeterProvider();
39252
39252
39253
39253
39254
39254
/***/ }),
39255
- /* 452 */,
39255
+ /* 452 */
39256
+ /***/ (function(__unusedmodule, exports, __webpack_require__) {
39257
+
39258
+ "use strict";
39259
+
39260
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
39261
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
39262
+ return new (P || (P = Promise))(function (resolve, reject) {
39263
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
39264
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
39265
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
39266
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
39267
+ });
39268
+ };
39269
+ var __asyncValues = (this && this.__asyncValues) || function (o) {
39270
+ if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
39271
+ var m = o[Symbol.asyncIterator], i;
39272
+ return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
39273
+ function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
39274
+ function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
39275
+ };
39276
+ var __importStar = (this && this.__importStar) || function (mod) {
39277
+ if (mod && mod.__esModule) return mod;
39278
+ var result = {};
39279
+ if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
39280
+ result["default"] = mod;
39281
+ return result;
39282
+ };
39283
+ Object.defineProperty(exports, "__esModule", { value: true });
39284
+ const exec = __importStar(__webpack_require__(986));
39285
+ const constants_1 = __webpack_require__(196);
39286
+ const glob = __importStar(__webpack_require__(281));
39287
+ const crypto = __importStar(__webpack_require__(417));
39288
+ const fs = __importStar(__webpack_require__(747));
39289
+ const stream = __importStar(__webpack_require__(794));
39290
+ const util = __importStar(__webpack_require__(669));
39291
+ const path = __importStar(__webpack_require__(622));
39292
+ const toolCacheCommands = {
39293
+ npm: 'npm config get cache',
39294
+ yarn1: 'yarn cache dir',
39295
+ yarn2: 'yarn config get cacheFolder'
39296
+ };
39297
+ const execHandler = (toolCommand, errMessage) => __awaiter(void 0, void 0, void 0, function* () {
39298
+ let stdOut;
39299
+ let stdErr;
39300
+ yield exec.exec(toolCommand, undefined, {
39301
+ listeners: {
39302
+ stderr: (err) => (stdErr = err.toString()),
39303
+ stdout: (out) => (stdOut = out.toString())
39304
+ }
39305
+ });
39306
+ if (stdErr) {
39307
+ throw new Error(stdErr);
39308
+ }
39309
+ if (!stdOut) {
39310
+ throw new Error(errMessage);
39311
+ }
39312
+ return stdOut;
39313
+ });
39314
+ const getToolVersion = (toolName, command, regex) => __awaiter(void 0, void 0, void 0, function* () {
39315
+ const stdOut = yield execHandler(`${toolName} ${command}`, `Could not get version for ${toolName}`);
39316
+ if (stdOut.startsWith('1.')) {
39317
+ return '1';
39318
+ }
39319
+ return '2';
39320
+ });
39321
+ const getCmdCommand = (toolName) => __awaiter(void 0, void 0, void 0, function* () {
39322
+ let cmdCommand = toolName;
39323
+ if (toolName === 'yarn') {
39324
+ const toolVersion = yield getToolVersion(toolName, '--version');
39325
+ cmdCommand = `${toolName}${toolVersion}`;
39326
+ }
39327
+ return cmdCommand;
39328
+ });
39329
+ exports.isPackageManagerCacheSupported = toolName => {
39330
+ const arr = Array.of(...Object.values(constants_1.LockType));
39331
+ return arr.includes(toolName);
39332
+ };
39333
+ exports.getCacheDirectoryPath = (toolName) => __awaiter(void 0, void 0, void 0, function* () {
39334
+ const fullToolName = yield getCmdCommand(toolName);
39335
+ const toolCommand = toolCacheCommands[fullToolName];
39336
+ const stdOut = yield execHandler(toolCommand, `Could not get version for ${toolName}`);
39337
+ return stdOut;
39338
+ });
39339
+ // https://github.com/actions/runner/blob/master/src/Misc/expressionFunc/hashFiles/src/hashFiles.ts
39340
+ // replace it, when the issue will be resolved: https://github.com/actions/toolkit/issues/472
39341
+ function hashFile(matchPatterns) {
39342
+ var e_1, _a;
39343
+ return __awaiter(this, void 0, void 0, function* () {
39344
+ let hasMatch = false;
39345
+ let followSymbolicLinks = false;
39346
+ if (process.env.followSymbolicLinks === 'true') {
39347
+ followSymbolicLinks = true;
39348
+ }
39349
+ const githubWorkspace = process.env.GITHUB_WORKSPACE;
39350
+ const result = crypto.createHash('sha256');
39351
+ const globber = yield glob.create(matchPatterns, { followSymbolicLinks });
39352
+ try {
39353
+ for (var _b = __asyncValues(globber.globGenerator()), _c; _c = yield _b.next(), !_c.done;) {
39354
+ const file = _c.value;
39355
+ console.log(file);
39356
+ if (!file.startsWith(`${githubWorkspace}${path.sep}`)) {
39357
+ continue;
39358
+ }
39359
+ if (fs.statSync(file).isDirectory()) {
39360
+ continue;
39361
+ }
39362
+ const hash = crypto.createHash('sha256');
39363
+ const pipeline = util.promisify(stream.pipeline);
39364
+ yield pipeline(fs.createReadStream(file), hash);
39365
+ result.write(hash.digest());
39366
+ if (!hasMatch) {
39367
+ hasMatch = true;
39368
+ }
39369
+ }
39370
+ }
39371
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
39372
+ finally {
39373
+ try {
39374
+ if (_c && !_c.done && (_a = _b.return)) yield _a.call(_b);
39375
+ }
39376
+ finally { if (e_1) throw e_1.error; }
39377
+ }
39378
+ result.end();
39379
+ return result.digest('hex');
39380
+ });
39381
+ }
39382
+ exports.hashFile = hashFile;
39383
+
39384
+
39385
+ /***/ }),
39256
39386
/* 453 */,
39257
39387
/* 454 */
39258
39388
/***/ (function(module, exports, __webpack_require__) {
@@ -47699,101 +47829,7 @@ exports.ProxyTracerProvider = ProxyTracerProvider;
47699
47829
/* 719 */,
47700
47830
/* 720 */,
47701
47831
/* 721 */,
47702
- /* 722 */
47703
- /***/ (function(__unusedmodule, exports, __webpack_require__) {
47704
-
47705
- "use strict";
47706
-
47707
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
47708
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
47709
- return new (P || (P = Promise))(function (resolve, reject) {
47710
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
47711
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
47712
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
47713
- step((generator = generator.apply(thisArg, _arguments || [])).next());
47714
- });
47715
- };
47716
- var __importStar = (this && this.__importStar) || function (mod) {
47717
- if (mod && mod.__esModule) return mod;
47718
- var result = {};
47719
- if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
47720
- result["default"] = mod;
47721
- return result;
47722
- };
47723
- Object.defineProperty(exports, "__esModule", { value: true });
47724
- const exec = __importStar(__webpack_require__(986));
47725
- const core = __importStar(__webpack_require__(470));
47726
- const constants_1 = __webpack_require__(196);
47727
- const semver_1 = __webpack_require__(280);
47728
- const toolCacheCommands = {
47729
- npm: 'npm config get cache',
47730
- yarn1: 'yarn cache dir',
47731
- yarn2: 'yarn config get cacheFolder'
47732
- };
47733
- const getToolVersion = (toolName, command, regex) => __awaiter(void 0, void 0, void 0, function* () {
47734
- let stdErr;
47735
- let stdOut;
47736
- let toolVersion;
47737
- yield exec.exec(`${toolName} ${command}`, undefined, {
47738
- listeners: {
47739
- stdout: (err) => (stdOut = err.toString()),
47740
- stderr: (out) => (stdErr = out.toString())
47741
- }
47742
- });
47743
- core.info(`stdout is ${stdOut}`);
47744
- core.info(`stdErr is ${stdErr}`);
47745
- if (stdErr) {
47746
- throw new Error(stdErr);
47747
- }
47748
- if (!stdOut) {
47749
- throw new Error(`Could not get version for ${toolName}`);
47750
- }
47751
- if (regex) {
47752
- core.info('add regex support');
47753
- toolVersion = stdOut;
47754
- }
47755
- else {
47756
- toolVersion = semver_1.major(stdOut).toString();
47757
- }
47758
- return toolVersion;
47759
- });
47760
- const getCmdCommand = (toolName, version) => {
47761
- let cmdCommand = toolName;
47762
- if (toolName === 'yarn') {
47763
- cmdCommand = `${toolName}${version}`;
47764
- }
47765
- return cmdCommand;
47766
- };
47767
- exports.isToolSupported = toolName => {
47768
- const arr = Array.of(...Object.values(constants_1.LockType));
47769
- return arr.includes(toolName);
47770
- };
47771
- exports.getDefaultCacheDirectory = (toolName) => __awaiter(void 0, void 0, void 0, function* () {
47772
- let stdOut;
47773
- let stdErr;
47774
- if (!exports.isToolSupported(toolName)) {
47775
- throw new Error(`${toolName} is not supported`);
47776
- }
47777
- const toolVersion = yield getToolVersion(toolName, '--version');
47778
- const fullToolName = getCmdCommand(toolName, toolVersion);
47779
- const toolCommand = toolCacheCommands[fullToolName];
47780
- yield exec.exec(toolCommand, undefined, {
47781
- listeners: {
47782
- stderr: (err) => (stdErr = err.toString()),
47783
- stdout: (out) => (stdOut = out.toString())
47784
- }
47785
- });
47786
- if (stdErr) {
47787
- throw new Error(stdErr);
47788
- }
47789
- if (!stdOut) {
47790
- throw new Error(`Could not get version for ${toolName}`);
47791
- }
47792
- return stdOut;
47793
- });
47794
-
47795
-
47796
- /***/ }),
47832
+ /* 722 */,
47797
47833
/* 723 */,
47798
47834
/* 724 */
47799
47835
/***/ (function(module) {
@@ -50296,24 +50332,22 @@ Object.defineProperty(exports, "__esModule", { value: true });
50296
50332
const core = __importStar(__webpack_require__(470));
50297
50333
const cache = __importStar(__webpack_require__(692));
50298
50334
const constants_1 = __webpack_require__(196);
50299
- const cache_1 = __webpack_require__(722 );
50335
+ const cache_utils_1 = __webpack_require__(452 );
50300
50336
function run() {
50301
50337
return __awaiter(this, void 0, void 0, function* () {
50302
50338
const cacheLock = core.getInput(constants_1.Inputs.Cache);
50303
- if (cacheLock && cache_1.isToolSupported(cacheLock)) {
50304
- try {
50305
- yield cachePackages(cacheLock);
50306
- }
50307
- catch (error) {
50308
- core.setFailed('Failed to remove private key');
50309
- }
50339
+ try {
50340
+ yield cachePackages(cacheLock);
50341
+ }
50342
+ catch (error) {
50343
+ core.setFailed('Failed to remove private key');
50310
50344
}
50311
50345
});
50312
50346
}
50313
50347
const cachePackages = (toolName) => __awaiter(void 0, void 0, void 0, function* () {
50314
50348
const state = getCacheState();
50315
50349
const primaryKey = core.getState(constants_1.State.CachePrimaryKey);
50316
- const cachePath = yield cache_1.getDefaultCacheDirectory (toolName);
50350
+ const cachePath = yield cache_utils_1.getCacheDirectoryPath (toolName);
50317
50351
if (isExactKeyMatch(primaryKey, state)) {
50318
50352
core.info(`Cache hit occurred on the primary key ${primaryKey}, not saving cache.`);
50319
50353
return;
0 commit comments