Compare commits

..
Author SHA1 Message Date
Nikolai Laevskii 809128768a Fix typo 2023-09-13 09:47:12 +02:00
Nikolai Laevskii 2962d3dc11 Update license 2023-08-31 07:28:09 +02:00
Nikolai Laevskii 7d88b53df7 Update temporary directory creation 2023-08-31 07:22:40 +02:00
14 changed files with 1969 additions and 3208 deletions
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
+30 -53
View File
@@ -92,9 +92,6 @@ describe('run', () => {
it('Package manager is not valid, skip caching', async () => { it('Package manager is not valid, skip caching', async () => {
inputs['cache'] = 'yarn3'; inputs['cache'] = 'yarn3';
getStateSpy.mockImplementation(key =>
key === State.CachePackageManager ? inputs['cache'] : ''
);
await run(); await run();
@@ -111,9 +108,7 @@ describe('run', () => {
it('should not save cache for yarn1', async () => { it('should not save cache for yarn1', async () => {
inputs['cache'] = 'yarn'; inputs['cache'] = 'yarn';
getStateSpy.mockImplementation(key => getStateSpy.mockImplementation(key =>
key === State.CachePackageManager key === State.CachePrimaryKey || key === State.CacheMatchedKey
? inputs['cache']
: key === State.CachePrimaryKey || key === State.CacheMatchedKey
? yarnFileHash ? yarnFileHash
: key === State.CachePaths : key === State.CachePaths
? '["/foo/bar"]' ? '["/foo/bar"]'
@@ -122,8 +117,8 @@ describe('run', () => {
await run(); await run();
expect(getInputSpy).not.toHaveBeenCalled(); expect(getInputSpy).toHaveBeenCalled();
expect(getStateSpy).toHaveBeenCalledTimes(4); expect(getStateSpy).toHaveBeenCalledTimes(3);
expect(getCommandOutputSpy).toHaveBeenCalledTimes(0); expect(getCommandOutputSpy).toHaveBeenCalledTimes(0);
expect(debugSpy).toHaveBeenCalledTimes(0); expect(debugSpy).toHaveBeenCalledTimes(0);
expect(infoSpy).toHaveBeenCalledWith( expect(infoSpy).toHaveBeenCalledWith(
@@ -135,9 +130,7 @@ describe('run', () => {
it('should not save cache for yarn2', async () => { it('should not save cache for yarn2', async () => {
inputs['cache'] = 'yarn'; inputs['cache'] = 'yarn';
getStateSpy.mockImplementation(key => getStateSpy.mockImplementation(key =>
key === State.CachePackageManager key === State.CachePrimaryKey || key === State.CacheMatchedKey
? inputs['cache']
: key === State.CachePrimaryKey || key === State.CacheMatchedKey
? yarnFileHash ? yarnFileHash
: key === State.CachePaths : key === State.CachePaths
? '["/foo/bar"]' ? '["/foo/bar"]'
@@ -146,8 +139,8 @@ describe('run', () => {
await run(); await run();
expect(getInputSpy).not.toHaveBeenCalled(); expect(getInputSpy).toHaveBeenCalled();
expect(getStateSpy).toHaveBeenCalledTimes(4); expect(getStateSpy).toHaveBeenCalledTimes(3);
expect(getCommandOutputSpy).toHaveBeenCalledTimes(0); expect(getCommandOutputSpy).toHaveBeenCalledTimes(0);
expect(debugSpy).toHaveBeenCalledTimes(0); expect(debugSpy).toHaveBeenCalledTimes(0);
expect(infoSpy).toHaveBeenCalledWith( expect(infoSpy).toHaveBeenCalledWith(
@@ -159,9 +152,7 @@ describe('run', () => {
it('should not save cache for npm', async () => { it('should not save cache for npm', async () => {
inputs['cache'] = 'npm'; inputs['cache'] = 'npm';
getStateSpy.mockImplementation(key => getStateSpy.mockImplementation(key =>
key === State.CachePackageManager key === State.CachePrimaryKey || key === State.CacheMatchedKey
? inputs['cache']
: key === State.CachePrimaryKey || key === State.CacheMatchedKey
? yarnFileHash ? yarnFileHash
: key === State.CachePaths : key === State.CachePaths
? '["/foo/bar"]' ? '["/foo/bar"]'
@@ -171,8 +162,8 @@ describe('run', () => {
await run(); await run();
expect(getInputSpy).not.toHaveBeenCalled(); expect(getInputSpy).toHaveBeenCalled();
expect(getStateSpy).toHaveBeenCalledTimes(4); expect(getStateSpy).toHaveBeenCalledTimes(3);
expect(getCommandOutputSpy).toHaveBeenCalledTimes(0); expect(getCommandOutputSpy).toHaveBeenCalledTimes(0);
expect(debugSpy).toHaveBeenCalledTimes(0); expect(debugSpy).toHaveBeenCalledTimes(0);
expect(setFailedSpy).not.toHaveBeenCalled(); expect(setFailedSpy).not.toHaveBeenCalled();
@@ -181,9 +172,7 @@ describe('run', () => {
it('should not save cache for pnpm', async () => { it('should not save cache for pnpm', async () => {
inputs['cache'] = 'pnpm'; inputs['cache'] = 'pnpm';
getStateSpy.mockImplementation(key => getStateSpy.mockImplementation(key =>
key === State.CachePackageManager key === State.CachePrimaryKey || key === State.CacheMatchedKey
? inputs['cache']
: key === State.CachePrimaryKey || key === State.CacheMatchedKey
? yarnFileHash ? yarnFileHash
: key === State.CachePaths : key === State.CachePaths
? '["/foo/bar"]' ? '["/foo/bar"]'
@@ -192,8 +181,8 @@ describe('run', () => {
await run(); await run();
expect(getInputSpy).not.toHaveBeenCalled(); expect(getInputSpy).toHaveBeenCalled();
expect(getStateSpy).toHaveBeenCalledTimes(4); expect(getStateSpy).toHaveBeenCalledTimes(3);
expect(getCommandOutputSpy).toHaveBeenCalledTimes(0); expect(getCommandOutputSpy).toHaveBeenCalledTimes(0);
expect(debugSpy).toHaveBeenCalledTimes(0); expect(debugSpy).toHaveBeenCalledTimes(0);
expect(setFailedSpy).not.toHaveBeenCalled(); expect(setFailedSpy).not.toHaveBeenCalled();
@@ -204,9 +193,7 @@ describe('run', () => {
it('saves cache from yarn 1', async () => { it('saves cache from yarn 1', async () => {
inputs['cache'] = 'yarn'; inputs['cache'] = 'yarn';
getStateSpy.mockImplementation((key: string) => getStateSpy.mockImplementation((key: string) =>
key === State.CachePackageManager key === State.CacheMatchedKey
? inputs['cache']
: key === State.CacheMatchedKey
? yarnFileHash ? yarnFileHash
: key === State.CachePrimaryKey : key === State.CachePrimaryKey
? npmFileHash ? npmFileHash
@@ -217,8 +204,8 @@ describe('run', () => {
await run(); await run();
expect(getInputSpy).not.toHaveBeenCalled(); expect(getInputSpy).toHaveBeenCalled();
expect(getStateSpy).toHaveBeenCalledTimes(4); expect(getStateSpy).toHaveBeenCalledTimes(3);
expect(getCommandOutputSpy).toHaveBeenCalledTimes(0); expect(getCommandOutputSpy).toHaveBeenCalledTimes(0);
expect(debugSpy).toHaveBeenCalledTimes(0); expect(debugSpy).toHaveBeenCalledTimes(0);
expect(infoSpy).not.toHaveBeenCalledWith( expect(infoSpy).not.toHaveBeenCalledWith(
@@ -234,9 +221,7 @@ describe('run', () => {
it('saves cache from yarn 2', async () => { it('saves cache from yarn 2', async () => {
inputs['cache'] = 'yarn'; inputs['cache'] = 'yarn';
getStateSpy.mockImplementation((key: string) => getStateSpy.mockImplementation((key: string) =>
key === State.CachePackageManager key === State.CacheMatchedKey
? inputs['cache']
: key === State.CacheMatchedKey
? yarnFileHash ? yarnFileHash
: key === State.CachePrimaryKey : key === State.CachePrimaryKey
? npmFileHash ? npmFileHash
@@ -247,8 +232,8 @@ describe('run', () => {
await run(); await run();
expect(getInputSpy).not.toHaveBeenCalled(); expect(getInputSpy).toHaveBeenCalled();
expect(getStateSpy).toHaveBeenCalledTimes(4); expect(getStateSpy).toHaveBeenCalledTimes(3);
expect(getCommandOutputSpy).toHaveBeenCalledTimes(0); expect(getCommandOutputSpy).toHaveBeenCalledTimes(0);
expect(debugSpy).toHaveBeenCalledTimes(0); expect(debugSpy).toHaveBeenCalledTimes(0);
expect(infoSpy).not.toHaveBeenCalledWith( expect(infoSpy).not.toHaveBeenCalledWith(
@@ -264,9 +249,7 @@ describe('run', () => {
it('saves cache from npm', async () => { it('saves cache from npm', async () => {
inputs['cache'] = 'npm'; inputs['cache'] = 'npm';
getStateSpy.mockImplementation((key: string) => getStateSpy.mockImplementation((key: string) =>
key === State.CachePackageManager key === State.CacheMatchedKey
? inputs['cache']
: key === State.CacheMatchedKey
? npmFileHash ? npmFileHash
: key === State.CachePrimaryKey : key === State.CachePrimaryKey
? yarnFileHash ? yarnFileHash
@@ -277,8 +260,8 @@ describe('run', () => {
await run(); await run();
expect(getInputSpy).not.toHaveBeenCalled(); expect(getInputSpy).toHaveBeenCalled();
expect(getStateSpy).toHaveBeenCalledTimes(4); expect(getStateSpy).toHaveBeenCalledTimes(3);
expect(getCommandOutputSpy).toHaveBeenCalledTimes(0); expect(getCommandOutputSpy).toHaveBeenCalledTimes(0);
expect(debugSpy).toHaveBeenCalledTimes(0); expect(debugSpy).toHaveBeenCalledTimes(0);
expect(infoSpy).not.toHaveBeenCalledWith( expect(infoSpy).not.toHaveBeenCalledWith(
@@ -294,9 +277,7 @@ describe('run', () => {
it('saves cache from pnpm', async () => { it('saves cache from pnpm', async () => {
inputs['cache'] = 'pnpm'; inputs['cache'] = 'pnpm';
getStateSpy.mockImplementation((key: string) => getStateSpy.mockImplementation((key: string) =>
key === State.CachePackageManager key === State.CacheMatchedKey
? inputs['cache']
: key === State.CacheMatchedKey
? pnpmFileHash ? pnpmFileHash
: key === State.CachePrimaryKey : key === State.CachePrimaryKey
? npmFileHash ? npmFileHash
@@ -307,8 +288,8 @@ describe('run', () => {
await run(); await run();
expect(getInputSpy).not.toHaveBeenCalled(); expect(getInputSpy).toHaveBeenCalled();
expect(getStateSpy).toHaveBeenCalledTimes(4); expect(getStateSpy).toHaveBeenCalledTimes(3);
expect(getCommandOutputSpy).toHaveBeenCalledTimes(0); expect(getCommandOutputSpy).toHaveBeenCalledTimes(0);
expect(debugSpy).toHaveBeenCalledTimes(0); expect(debugSpy).toHaveBeenCalledTimes(0);
expect(infoSpy).not.toHaveBeenCalledWith( expect(infoSpy).not.toHaveBeenCalledWith(
@@ -324,9 +305,7 @@ describe('run', () => {
it('save with -1 cacheId , should not fail workflow', async () => { it('save with -1 cacheId , should not fail workflow', async () => {
inputs['cache'] = 'npm'; inputs['cache'] = 'npm';
getStateSpy.mockImplementation((key: string) => getStateSpy.mockImplementation((key: string) =>
key === State.CachePackageManager key === State.CacheMatchedKey
? inputs['cache']
: key === State.CacheMatchedKey
? npmFileHash ? npmFileHash
: key === State.CachePrimaryKey : key === State.CachePrimaryKey
? yarnFileHash ? yarnFileHash
@@ -340,8 +319,8 @@ describe('run', () => {
await run(); await run();
expect(getInputSpy).not.toHaveBeenCalled(); expect(getInputSpy).toHaveBeenCalled();
expect(getStateSpy).toHaveBeenCalledTimes(4); expect(getStateSpy).toHaveBeenCalledTimes(3);
expect(getCommandOutputSpy).toHaveBeenCalledTimes(0); expect(getCommandOutputSpy).toHaveBeenCalledTimes(0);
expect(debugSpy).toHaveBeenCalledTimes(0); expect(debugSpy).toHaveBeenCalledTimes(0);
expect(infoSpy).not.toHaveBeenCalledWith( expect(infoSpy).not.toHaveBeenCalledWith(
@@ -357,9 +336,7 @@ describe('run', () => {
it('saves with error from toolkit, should fail workflow', async () => { it('saves with error from toolkit, should fail workflow', async () => {
inputs['cache'] = 'npm'; inputs['cache'] = 'npm';
getStateSpy.mockImplementation((key: string) => getStateSpy.mockImplementation((key: string) =>
key === State.CachePackageManager key === State.CacheMatchedKey
? inputs['cache']
: key === State.CacheMatchedKey
? npmFileHash ? npmFileHash
: key === State.CachePrimaryKey : key === State.CachePrimaryKey
? yarnFileHash ? yarnFileHash
@@ -373,8 +350,8 @@ describe('run', () => {
await run(); await run();
expect(getInputSpy).not.toHaveBeenCalled(); expect(getInputSpy).toHaveBeenCalled();
expect(getStateSpy).toHaveBeenCalledTimes(4); expect(getStateSpy).toHaveBeenCalledTimes(3);
expect(getCommandOutputSpy).toHaveBeenCalledTimes(0); expect(getCommandOutputSpy).toHaveBeenCalledTimes(0);
expect(debugSpy).toHaveBeenCalledTimes(0); expect(debugSpy).toHaveBeenCalledTimes(0);
expect(infoSpy).not.toHaveBeenCalledWith( expect(infoSpy).not.toHaveBeenCalledWith(
+3 -2
View File
@@ -6,7 +6,8 @@ import {
PackageManagerInfo, PackageManagerInfo,
isCacheFeatureAvailable, isCacheFeatureAvailable,
supportedPackageManagers, supportedPackageManagers,
getProjectDirectoriesFromCacheDependencyPath getCommandOutput,
resetProjectDirectoriesMemoized
} from '../src/cache-utils'; } from '../src/cache-utils';
import fs from 'fs'; import fs from 'fs';
import * as cacheUtils from '../src/cache-utils'; import * as cacheUtils from '../src/cache-utils';
@@ -122,7 +123,7 @@ describe('cache-utils', () => {
MockGlobber.create(['/foo', '/bar']) MockGlobber.create(['/foo', '/bar'])
); );
getProjectDirectoriesFromCacheDependencyPath.cache.clear?.(); resetProjectDirectoriesMemoized();
}); });
afterEach(() => { afterEach(() => {
+454 -1124
View File
@@ -46782,689 +46782,6 @@ DelayedStream.prototype._checkIfMaxDataSizeExceeded = function() {
}; };
/***/ }),
/***/ 4538:
/***/ ((module) => {
/**
* lodash (Custom Build) <https://lodash.com/>
* Build: `lodash modularize exports="npm" -o ./`
* Copyright jQuery Foundation and other contributors <https://jquery.org/>
* Released under MIT license <https://lodash.com/license>
* Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
* Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
*/
/** Used as the `TypeError` message for "Functions" methods. */
var FUNC_ERROR_TEXT = 'Expected a function';
/** Used to stand-in for `undefined` hash values. */
var HASH_UNDEFINED = '__lodash_hash_undefined__';
/** `Object#toString` result references. */
var funcTag = '[object Function]',
genTag = '[object GeneratorFunction]';
/**
* Used to match `RegExp`
* [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).
*/
var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
/** Used to detect host constructors (Safari). */
var reIsHostCtor = /^\[object .+?Constructor\]$/;
/** Detect free variable `global` from Node.js. */
var freeGlobal = typeof global == 'object' && global && global.Object === Object && global;
/** Detect free variable `self`. */
var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
/** Used as a reference to the global object. */
var root = freeGlobal || freeSelf || Function('return this')();
/**
* Gets the value at `key` of `object`.
*
* @private
* @param {Object} [object] The object to query.
* @param {string} key The key of the property to get.
* @returns {*} Returns the property value.
*/
function getValue(object, key) {
return object == null ? undefined : object[key];
}
/**
* Checks if `value` is a host object in IE < 9.
*
* @private
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is a host object, else `false`.
*/
function isHostObject(value) {
// Many host objects are `Object` objects that can coerce to strings
// despite having improperly defined `toString` methods.
var result = false;
if (value != null && typeof value.toString != 'function') {
try {
result = !!(value + '');
} catch (e) {}
}
return result;
}
/** Used for built-in method references. */
var arrayProto = Array.prototype,
funcProto = Function.prototype,
objectProto = Object.prototype;
/** Used to detect overreaching core-js shims. */
var coreJsData = root['__core-js_shared__'];
/** Used to detect methods masquerading as native. */
var maskSrcKey = (function() {
var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || '');
return uid ? ('Symbol(src)_1.' + uid) : '';
}());
/** Used to resolve the decompiled source of functions. */
var funcToString = funcProto.toString;
/** Used to check objects for own properties. */
var hasOwnProperty = objectProto.hasOwnProperty;
/**
* Used to resolve the
* [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
* of values.
*/
var objectToString = objectProto.toString;
/** Used to detect if a method is native. */
var reIsNative = RegExp('^' +
funcToString.call(hasOwnProperty).replace(reRegExpChar, '\\$&')
.replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'
);
/** Built-in value references. */
var splice = arrayProto.splice;
/* Built-in method references that are verified to be native. */
var Map = getNative(root, 'Map'),
nativeCreate = getNative(Object, 'create');
/**
* Creates a hash object.
*
* @private
* @constructor
* @param {Array} [entries] The key-value pairs to cache.
*/
function Hash(entries) {
var index = -1,
length = entries ? entries.length : 0;
this.clear();
while (++index < length) {
var entry = entries[index];
this.set(entry[0], entry[1]);
}
}
/**
* Removes all key-value entries from the hash.
*
* @private
* @name clear
* @memberOf Hash
*/
function hashClear() {
this.__data__ = nativeCreate ? nativeCreate(null) : {};
}
/**
* Removes `key` and its value from the hash.
*
* @private
* @name delete
* @memberOf Hash
* @param {Object} hash The hash to modify.
* @param {string} key The key of the value to remove.
* @returns {boolean} Returns `true` if the entry was removed, else `false`.
*/
function hashDelete(key) {
return this.has(key) && delete this.__data__[key];
}
/**
* Gets the hash value for `key`.
*
* @private
* @name get
* @memberOf Hash
* @param {string} key The key of the value to get.
* @returns {*} Returns the entry value.
*/
function hashGet(key) {
var data = this.__data__;
if (nativeCreate) {
var result = data[key];
return result === HASH_UNDEFINED ? undefined : result;
}
return hasOwnProperty.call(data, key) ? data[key] : undefined;
}
/**
* Checks if a hash value for `key` exists.
*
* @private
* @name has
* @memberOf Hash
* @param {string} key The key of the entry to check.
* @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
*/
function hashHas(key) {
var data = this.__data__;
return nativeCreate ? data[key] !== undefined : hasOwnProperty.call(data, key);
}
/**
* Sets the hash `key` to `value`.
*
* @private
* @name set
* @memberOf Hash
* @param {string} key The key of the value to set.
* @param {*} value The value to set.
* @returns {Object} Returns the hash instance.
*/
function hashSet(key, value) {
var data = this.__data__;
data[key] = (nativeCreate && value === undefined) ? HASH_UNDEFINED : value;
return this;
}
// Add methods to `Hash`.
Hash.prototype.clear = hashClear;
Hash.prototype['delete'] = hashDelete;
Hash.prototype.get = hashGet;
Hash.prototype.has = hashHas;
Hash.prototype.set = hashSet;
/**
* Creates an list cache object.
*
* @private
* @constructor
* @param {Array} [entries] The key-value pairs to cache.
*/
function ListCache(entries) {
var index = -1,
length = entries ? entries.length : 0;
this.clear();
while (++index < length) {
var entry = entries[index];
this.set(entry[0], entry[1]);
}
}
/**
* Removes all key-value entries from the list cache.
*
* @private
* @name clear
* @memberOf ListCache
*/
function listCacheClear() {
this.__data__ = [];
}
/**
* Removes `key` and its value from the list cache.
*
* @private
* @name delete
* @memberOf ListCache
* @param {string} key The key of the value to remove.
* @returns {boolean} Returns `true` if the entry was removed, else `false`.
*/
function listCacheDelete(key) {
var data = this.__data__,
index = assocIndexOf(data, key);
if (index < 0) {
return false;
}
var lastIndex = data.length - 1;
if (index == lastIndex) {
data.pop();
} else {
splice.call(data, index, 1);
}
return true;
}
/**
* Gets the list cache value for `key`.
*
* @private
* @name get
* @memberOf ListCache
* @param {string} key The key of the value to get.
* @returns {*} Returns the entry value.
*/
function listCacheGet(key) {
var data = this.__data__,
index = assocIndexOf(data, key);
return index < 0 ? undefined : data[index][1];
}
/**
* Checks if a list cache value for `key` exists.
*
* @private
* @name has
* @memberOf ListCache
* @param {string} key The key of the entry to check.
* @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
*/
function listCacheHas(key) {
return assocIndexOf(this.__data__, key) > -1;
}
/**
* Sets the list cache `key` to `value`.
*
* @private
* @name set
* @memberOf ListCache
* @param {string} key The key of the value to set.
* @param {*} value The value to set.
* @returns {Object} Returns the list cache instance.
*/
function listCacheSet(key, value) {
var data = this.__data__,
index = assocIndexOf(data, key);
if (index < 0) {
data.push([key, value]);
} else {
data[index][1] = value;
}
return this;
}
// Add methods to `ListCache`.
ListCache.prototype.clear = listCacheClear;
ListCache.prototype['delete'] = listCacheDelete;
ListCache.prototype.get = listCacheGet;
ListCache.prototype.has = listCacheHas;
ListCache.prototype.set = listCacheSet;
/**
* Creates a map cache object to store key-value pairs.
*
* @private
* @constructor
* @param {Array} [entries] The key-value pairs to cache.
*/
function MapCache(entries) {
var index = -1,
length = entries ? entries.length : 0;
this.clear();
while (++index < length) {
var entry = entries[index];
this.set(entry[0], entry[1]);
}
}
/**
* Removes all key-value entries from the map.
*
* @private
* @name clear
* @memberOf MapCache
*/
function mapCacheClear() {
this.__data__ = {
'hash': new Hash,
'map': new (Map || ListCache),
'string': new Hash
};
}
/**
* Removes `key` and its value from the map.
*
* @private
* @name delete
* @memberOf MapCache
* @param {string} key The key of the value to remove.
* @returns {boolean} Returns `true` if the entry was removed, else `false`.
*/
function mapCacheDelete(key) {
return getMapData(this, key)['delete'](key);
}
/**
* Gets the map value for `key`.
*
* @private
* @name get
* @memberOf MapCache
* @param {string} key The key of the value to get.
* @returns {*} Returns the entry value.
*/
function mapCacheGet(key) {
return getMapData(this, key).get(key);
}
/**
* Checks if a map value for `key` exists.
*
* @private
* @name has
* @memberOf MapCache
* @param {string} key The key of the entry to check.
* @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
*/
function mapCacheHas(key) {
return getMapData(this, key).has(key);
}
/**
* Sets the map `key` to `value`.
*
* @private
* @name set
* @memberOf MapCache
* @param {string} key The key of the value to set.
* @param {*} value The value to set.
* @returns {Object} Returns the map cache instance.
*/
function mapCacheSet(key, value) {
getMapData(this, key).set(key, value);
return this;
}
// Add methods to `MapCache`.
MapCache.prototype.clear = mapCacheClear;
MapCache.prototype['delete'] = mapCacheDelete;
MapCache.prototype.get = mapCacheGet;
MapCache.prototype.has = mapCacheHas;
MapCache.prototype.set = mapCacheSet;
/**
* Gets the index at which the `key` is found in `array` of key-value pairs.
*
* @private
* @param {Array} array The array to inspect.
* @param {*} key The key to search for.
* @returns {number} Returns the index of the matched value, else `-1`.
*/
function assocIndexOf(array, key) {
var length = array.length;
while (length--) {
if (eq(array[length][0], key)) {
return length;
}
}
return -1;
}
/**
* The base implementation of `_.isNative` without bad shim checks.
*
* @private
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is a native function,
* else `false`.
*/
function baseIsNative(value) {
if (!isObject(value) || isMasked(value)) {
return false;
}
var pattern = (isFunction(value) || isHostObject(value)) ? reIsNative : reIsHostCtor;
return pattern.test(toSource(value));
}
/**
* Gets the data for `map`.
*
* @private
* @param {Object} map The map to query.
* @param {string} key The reference key.
* @returns {*} Returns the map data.
*/
function getMapData(map, key) {
var data = map.__data__;
return isKeyable(key)
? data[typeof key == 'string' ? 'string' : 'hash']
: data.map;
}
/**
* Gets the native function at `key` of `object`.
*
* @private
* @param {Object} object The object to query.
* @param {string} key The key of the method to get.
* @returns {*} Returns the function if it's native, else `undefined`.
*/
function getNative(object, key) {
var value = getValue(object, key);
return baseIsNative(value) ? value : undefined;
}
/**
* Checks if `value` is suitable for use as unique object key.
*
* @private
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is suitable, else `false`.
*/
function isKeyable(value) {
var type = typeof value;
return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean')
? (value !== '__proto__')
: (value === null);
}
/**
* Checks if `func` has its source masked.
*
* @private
* @param {Function} func The function to check.
* @returns {boolean} Returns `true` if `func` is masked, else `false`.
*/
function isMasked(func) {
return !!maskSrcKey && (maskSrcKey in func);
}
/**
* Converts `func` to its source code.
*
* @private
* @param {Function} func The function to process.
* @returns {string} Returns the source code.
*/
function toSource(func) {
if (func != null) {
try {
return funcToString.call(func);
} catch (e) {}
try {
return (func + '');
} catch (e) {}
}
return '';
}
/**
* Creates a function that memoizes the result of `func`. If `resolver` is
* provided, it determines the cache key for storing the result based on the
* arguments provided to the memoized function. By default, the first argument
* provided to the memoized function is used as the map cache key. The `func`
* is invoked with the `this` binding of the memoized function.
*
* **Note:** The cache is exposed as the `cache` property on the memoized
* function. Its creation may be customized by replacing the `_.memoize.Cache`
* constructor with one whose instances implement the
* [`Map`](http://ecma-international.org/ecma-262/7.0/#sec-properties-of-the-map-prototype-object)
* method interface of `delete`, `get`, `has`, and `set`.
*
* @static
* @memberOf _
* @since 0.1.0
* @category Function
* @param {Function} func The function to have its output memoized.
* @param {Function} [resolver] The function to resolve the cache key.
* @returns {Function} Returns the new memoized function.
* @example
*
* var object = { 'a': 1, 'b': 2 };
* var other = { 'c': 3, 'd': 4 };
*
* var values = _.memoize(_.values);
* values(object);
* // => [1, 2]
*
* values(other);
* // => [3, 4]
*
* object.a = 2;
* values(object);
* // => [1, 2]
*
* // Modify the result cache.
* values.cache.set(object, ['a', 'b']);
* values(object);
* // => ['a', 'b']
*
* // Replace `_.memoize.Cache`.
* _.memoize.Cache = WeakMap;
*/
function memoize(func, resolver) {
if (typeof func != 'function' || (resolver && typeof resolver != 'function')) {
throw new TypeError(FUNC_ERROR_TEXT);
}
var memoized = function() {
var args = arguments,
key = resolver ? resolver.apply(this, args) : args[0],
cache = memoized.cache;
if (cache.has(key)) {
return cache.get(key);
}
var result = func.apply(this, args);
memoized.cache = cache.set(key, result);
return result;
};
memoized.cache = new (memoize.Cache || MapCache);
return memoized;
}
// Assign cache to `_.memoize`.
memoize.Cache = MapCache;
/**
* Performs a
* [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
* comparison between two values to determine if they are equivalent.
*
* @static
* @memberOf _
* @since 4.0.0
* @category Lang
* @param {*} value The value to compare.
* @param {*} other The other value to compare.
* @returns {boolean} Returns `true` if the values are equivalent, else `false`.
* @example
*
* var object = { 'a': 1 };
* var other = { 'a': 1 };
*
* _.eq(object, object);
* // => true
*
* _.eq(object, other);
* // => false
*
* _.eq('a', 'a');
* // => true
*
* _.eq('a', Object('a'));
* // => false
*
* _.eq(NaN, NaN);
* // => true
*/
function eq(value, other) {
return value === other || (value !== value && other !== other);
}
/**
* Checks if `value` is classified as a `Function` object.
*
* @static
* @memberOf _
* @since 0.1.0
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is a function, else `false`.
* @example
*
* _.isFunction(_);
* // => true
*
* _.isFunction(/abc/);
* // => false
*/
function isFunction(value) {
// The use of `Object#toString` avoids issues with the `typeof` operator
// in Safari 8-9 which returns 'object' for typed array and other constructors.
var tag = isObject(value) ? objectToString.call(value) : '';
return tag == funcTag || tag == genTag;
}
/**
* Checks if `value` is the
* [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
* of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
*
* @static
* @memberOf _
* @since 0.1.0
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is an object, else `false`.
* @example
*
* _.isObject({});
* // => true
*
* _.isObject([1, 2, 3]);
* // => true
*
* _.isObject(_.noop);
* // => true
*
* _.isObject(null);
* // => false
*/
function isObject(value) {
var type = typeof value;
return !!value && (type == 'object' || type == 'function');
}
module.exports = memoize;
/***/ }), /***/ }),
/***/ 7426: /***/ 7426:
@@ -61015,86 +60332,91 @@ 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 })); var __importDefault = (this && this.__importDefault) || function (mod) {
exports.run = void 0; return (mod && mod.__esModule) ? mod : { "default": mod };
const core = __importStar(__nccwpck_require__(2186)); };
const cache = __importStar(__nccwpck_require__(7799)); Object.defineProperty(exports, "__esModule", ({ value: true }));
const constants_1 = __nccwpck_require__(9042); exports.run = void 0;
const cache_utils_1 = __nccwpck_require__(1678); const core = __importStar(__nccwpck_require__(2186));
// Catch and log any unhandled exceptions. These exceptions can leak out of the uploadChunk method in const cache = __importStar(__nccwpck_require__(7799));
// @actions/toolkit when a failed upload closes the file descriptor causing any in-process reads to const fs_1 = __importDefault(__nccwpck_require__(7147));
// throw an uncaught exception. Instead of failing this action, just warn. const constants_1 = __nccwpck_require__(9042);
process.on('uncaughtException', e => { const cache_utils_1 = __nccwpck_require__(1678);
const warningPrefix = '[warning]'; // Catch and log any unhandled exceptions. These exceptions can leak out of the uploadChunk method in
core.info(`${warningPrefix}${e.message}`); // @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.
function run() { process.on('uncaughtException', e => {
return __awaiter(this, void 0, void 0, function* () { const warningPrefix = '[warning]';
try { core.info(`${warningPrefix}${e.message}`);
const cacheLock = core.getState(constants_1.State.CachePackageManager); });
yield cachePackages(cacheLock); function run() {
} return __awaiter(this, void 0, void 0, function* () {
catch (error) { try {
core.setFailed(error.message); const cacheLock = core.getInput('cache');
} yield cachePackages(cacheLock);
}); }
} catch (error) {
exports.run = run; core.setFailed(error.message);
const cachePackages = (packageManager) => __awaiter(void 0, void 0, void 0, function* () { }
const state = core.getState(constants_1.State.CacheMatchedKey); });
const primaryKey = core.getState(constants_1.State.CachePrimaryKey); }
const cachePaths = JSON.parse(core.getState(constants_1.State.CachePaths) || '[]'); exports.run = run;
const packageManagerInfo = yield cache_utils_1.getPackageManagerInfo(packageManager); const cachePackages = (packageManager) => __awaiter(void 0, void 0, void 0, function* () {
if (!packageManagerInfo) { const state = core.getState(constants_1.State.CacheMatchedKey);
core.debug(`Caching for '${packageManager}' is not supported`); const primaryKey = core.getState(constants_1.State.CachePrimaryKey);
return; let cachePaths = JSON.parse(core.getState(constants_1.State.CachePaths) || '[]');
} cachePaths = cachePaths.filter(fs_1.default.existsSync);
if (!cachePaths.length) { const packageManagerInfo = yield cache_utils_1.getPackageManagerInfo(packageManager);
// TODO: core.getInput has a bug - it can return undefined despite its definition (tests only?) if (!packageManagerInfo) {
// export declare function getInput(name: string, options?: InputOptions): string; core.debug(`Caching for '${packageManager}' is not supported`);
const cacheDependencyPath = core.getInput('cache-dependency-path') || ''; return;
throw new Error(`Cache folder paths are not retrieved for ${packageManager} with cache-dependency-path = ${cacheDependencyPath}`); }
} if (!cachePaths.length) {
if (primaryKey === state) { // TODO: core.getInput has a bug - it can return undefined despite its definition (tests only?)
core.info(`Cache hit occurred on the primary key ${primaryKey}, not saving cache.`); // export declare function getInput(name: string, options?: InputOptions): string;
return; const cacheDependencyPath = core.getInput('cache-dependency-path') || '';
} throw new Error(`Cache folder paths are not retrieved for ${packageManager} with cache-dependency-path = ${cacheDependencyPath}`);
const cacheId = yield cache.saveCache(cachePaths, primaryKey); }
if (cacheId == -1) { if (primaryKey === state) {
return; core.info(`Cache hit occurred on the primary key ${primaryKey}, not saving cache.`);
} return;
core.info(`Cache saved with the key: ${primaryKey}`); }
}); const cacheId = yield cache.saveCache(cachePaths, primaryKey);
run(); if (cacheId == -1) {
return;
}
core.info(`Cache saved with the key: ${primaryKey}`);
});
run();
/***/ }), /***/ }),
@@ -61103,245 +60425,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.getProjectDirectoriesFromCacheDependencyPath = 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 lodash_memoize_1 = __importDefault(__nccwpck_require__(4538)); 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`
* Expands (converts) the string input `cache-dependency-path` to list of directories that * - first through `getCacheDirectories`
* may be project roots * - second from `repoHasYarn3ManagedCache`
* *
* getProjectDirectoriesFromCacheDependencyPath is called twice during `restoreCache` * it contains expensive IO operation and thus should be memoized
* - first through `getCacheDirectories` */
* - second from `repoHasYarn3ManagedCache` let projectDirectoriesMemoized = null;
* /**
* it contains expensive IO operation and thus should be memoized * unit test must reset memoized variables
* */
* @param cacheDependencyPath - either a single string or multiline string with possible glob patterns const resetProjectDirectoriesMemoized = () => (projectDirectoriesMemoized = null);
* expected to be the result of `core.getInput('cache-dependency-path')` exports.resetProjectDirectoriesMemoized = resetProjectDirectoriesMemoized;
* @return list of directories /**
*/ * Expands (converts) the string input `cache-dependency-path` to list of directories that
exports.getProjectDirectoriesFromCacheDependencyPath = lodash_memoize_1.default((cacheDependencyPath) => __awaiter(void 0, void 0, void 0, function* () { * may be project roots
const globber = yield glob.create(cacheDependencyPath); * @param cacheDependencyPath - either a single string or multiline string with possible glob patterns
const cacheDependenciesPaths = yield globber.glob(); * expected to be the result of `core.getInput('cache-dependency-path')`
const existingDirectories = cacheDependenciesPaths * @return list of directories and possible
.map(path_1.default.dirname) */
.filter(util_1.unique()) const getProjectDirectoriesFromCacheDependencyPath = (cacheDependencyPath) => __awaiter(void 0, void 0, void 0, function* () {
.map(dirName => fs_1.default.realpathSync(dirName)) if (projectDirectoriesMemoized !== null) {
.filter(directory => fs_1.default.lstatSync(directory).isDirectory()); return projectDirectoriesMemoized;
if (!existingDirectories.length) }
core.warning(`No existing directories found containing cache-dependency-path="${cacheDependencyPath}"`); const globber = yield glob.create(cacheDependencyPath);
return existingDirectories; const cacheDependenciesPaths = yield globber.glob();
})); const existingDirectories = cacheDependenciesPaths
/** .map(path_1.default.dirname)
* Finds the cache directories configured for the repo if cache-dependency-path is not empty .filter(util_1.unique())
* @param packageManagerInfo - an object having getCacheFolderPath method specific to given PM .map(dirName => fs_1.default.realpathSync(dirName))
* @param cacheDependencyPath - either a single string or multiline string with possible glob patterns .filter(directory => fs_1.default.lstatSync(directory).isDirectory());
* expected to be the result of `core.getInput('cache-dependency-path')` if (!existingDirectories.length)
* @return list of files on which the cache depends core.warning(`No existing directories found containing cache-dependency-path="${cacheDependencyPath}"`);
*/ projectDirectoriesMemoized = existingDirectories;
const getCacheDirectoriesFromCacheDependencyPath = (packageManagerInfo, cacheDependencyPath) => __awaiter(void 0, void 0, void 0, function* () { return existingDirectories;
const projectDirectories = yield exports.getProjectDirectoriesFromCacheDependencyPath(cacheDependencyPath); });
const cacheFoldersPaths = yield Promise.all(projectDirectories.map((projectDirectory) => __awaiter(void 0, void 0, void 0, function* () { /**
const cacheFolderPath = yield packageManagerInfo.getCacheFolderPath(projectDirectory); * Finds the cache directories configured for the repo if cache-dependency-path is not empty
core.debug(`${packageManagerInfo.name}'s cache folder "${cacheFolderPath}" configured for the directory "${projectDirectory}"`); * @param packageManagerInfo - an object having getCacheFolderPath method specific to given PM
return cacheFolderPath; * @param cacheDependencyPath - either a single string or multiline string with possible glob patterns
}))); * expected to be the result of `core.getInput('cache-dependency-path')`
// uniq in order to do not cache the same directories twice * @return list of files on which the cache depends
return cacheFoldersPaths.filter(util_1.unique()); */
}); const getCacheDirectoriesFromCacheDependencyPath = (packageManagerInfo, cacheDependencyPath) => __awaiter(void 0, void 0, void 0, function* () {
/** const projectDirectories = yield getProjectDirectoriesFromCacheDependencyPath(cacheDependencyPath);
* Finds the cache directories configured for the repo ignoring cache-dependency-path const cacheFoldersPaths = yield Promise.all(projectDirectories.map((projectDirectory) => __awaiter(void 0, void 0, void 0, function* () {
* @param packageManagerInfo - an object having getCacheFolderPath method specific to given PM const cacheFolderPath = yield packageManagerInfo.getCacheFolderPath(projectDirectory);
* @return list of files on which the cache depends core.debug(`${packageManagerInfo.name}'s cache folder "${cacheFolderPath}" configured for the directory "${projectDirectory}"`);
*/ return cacheFolderPath;
const getCacheDirectoriesForRootProject = (packageManagerInfo) => __awaiter(void 0, void 0, void 0, function* () { })));
const cacheFolderPath = yield packageManagerInfo.getCacheFolderPath(); // uniq in order to do not cache the same directories twice
core.debug(`${packageManagerInfo.name}'s cache folder "${cacheFolderPath}" configured for the root directory`); return cacheFoldersPaths.filter(util_1.unique());
return [cacheFolderPath]; });
}); /**
/** * Finds the cache directories configured for the repo ignoring cache-dependency-path
* A function to find the cache directories configured for the repo * @param packageManagerInfo - an object having getCacheFolderPath method specific to given PM
* currently it handles only the case of PM=yarn && cacheDependencyPath is not empty * @return list of files on which the cache depends
* @param packageManagerInfo - an object having getCacheFolderPath method specific to given PM */
* @param cacheDependencyPath - either a single string or multiline string with possible glob patterns const getCacheDirectoriesForRootProject = (packageManagerInfo) => __awaiter(void 0, void 0, void 0, function* () {
* expected to be the result of `core.getInput('cache-dependency-path')` const cacheFolderPath = yield packageManagerInfo.getCacheFolderPath();
* @return list of files on which the cache depends core.debug(`${packageManagerInfo.name}'s cache folder "${cacheFolderPath}" configured for the root directory`);
*/ return [cacheFolderPath];
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 /**
// folder satisfied by cacheDependencyPath https://github.com/actions/setup-node/issues/488 * A function to find the cache directories configured for the repo
if (packageManagerInfo.name === 'yarn' && cacheDependencyPath) { * currently it handles only the case of PM=yarn && cacheDependencyPath is not empty
return getCacheDirectoriesFromCacheDependencyPath(packageManagerInfo, cacheDependencyPath); * @param packageManagerInfo - an object having getCacheFolderPath method specific to given PM
} * @param cacheDependencyPath - either a single string or multiline string with possible glob patterns
return getCacheDirectoriesForRootProject(packageManagerInfo); * expected to be the result of `core.getInput('cache-dependency-path')`
}); * @return list of files on which the cache depends
exports.getCacheDirectories = getCacheDirectories; */
/** const getCacheDirectories = (packageManagerInfo, cacheDependencyPath) => __awaiter(void 0, void 0, void 0, function* () {
* A function to check if the directory is a yarn project configured to manage // For yarn, if cacheDependencyPath is set, ask information about cache folders in each project
* obsolete dependencies in the local cache // folder satisfied by cacheDependencyPath https://github.com/actions/setup-node/issues/488
* @param directory - a path to the folder if (packageManagerInfo.name === 'yarn' && cacheDependencyPath) {
* @return - true if the directory's project is yarn managed return getCacheDirectoriesFromCacheDependencyPath(packageManagerInfo, cacheDependencyPath);
* - 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 return getCacheDirectoriesForRootProject(packageManagerInfo);
* - if local cache is not explicitly enabled (not yarn3), return false });
* - return true otherwise exports.getCacheDirectories = getCacheDirectories;
*/ /**
const projectHasYarnBerryManagedDependencies = (directory) => __awaiter(void 0, void 0, void 0, function* () { * A function to check if the directory is a yarn project configured to manage
const workDir = directory || process.env.GITHUB_WORKSPACE || '.'; * obsolete dependencies in the local cache
core.debug(`check if "${workDir}" has locally managed yarn3 dependencies`); * @param directory - a path to the folder
// if .yarn/cache directory exists the cache is managed by version control system * @return - true if the directory's project is yarn managed
const yarnCacheFile = path_1.default.join(workDir, '.yarn', 'cache'); * - if there's .yarn/cache folder do not mess with the dependencies kept in the repo, return false
if (fs_1.default.existsSync(yarnCacheFile) && * - global cache is not managed by yarn @see https://yarnpkg.com/features/offline-cache, return false
fs_1.default.lstatSync(yarnCacheFile).isDirectory()) { * - if local cache is not explicitly enabled (not yarn3), return false
core.debug(`"${workDir}" has .yarn/cache - dependencies are kept in the repository`); * - return true otherwise
return Promise.resolve(false); */
} const projectHasYarnBerryManagedDependencies = (directory) => __awaiter(void 0, void 0, void 0, function* () {
// NOTE: yarn1 returns 'undefined' with return code = 0 const workDir = directory || process.env.GITHUB_WORKSPACE || '.';
const enableGlobalCache = yield exports.getCommandOutput('yarn config get enableGlobalCache', workDir); core.debug(`check if "${workDir}" has locally managed yarn3 dependencies`);
// only local cache is not managed by yarn // if .yarn/cache directory exists the cache is managed by version control system
const managed = enableGlobalCache.includes('false'); const yarnCacheFile = path_1.default.join(workDir, '.yarn', 'cache');
if (managed) { if (fs_1.default.existsSync(yarnCacheFile) &&
core.debug(`"${workDir}" dependencies are managed by yarn 3 locally`); fs_1.default.lstatSync(yarnCacheFile).isDirectory()) {
return true; core.debug(`"${workDir}" has .yarn/cache - dependencies are kept in the repository`);
} return Promise.resolve(false);
else { }
core.debug(`"${workDir}" dependencies are not managed by yarn 3 locally`); // NOTE: yarn1 returns 'undefined' with return code = 0
return false; const enableGlobalCache = yield exports.getCommandOutput('yarn config get enableGlobalCache', workDir);
} // only local cache is not managed by yarn
}); const managed = enableGlobalCache.includes('false');
/** if (managed) {
* A function to report the repo contains Yarn managed projects core.debug(`"${workDir}" dependencies are managed by yarn 3 locally`);
* @param packageManagerInfo - used to make sure current package manager is yarn return true;
* @param cacheDependencyPath - either a single string or multiline string with possible glob patterns }
* expected to be the result of `core.getInput('cache-dependency-path')` else {
* @return - true if all project directories configured to be Yarn managed core.debug(`"${workDir}" dependencies are not managed by yarn 3 locally`);
*/ return false;
const repoHasYarnBerryManagedDependencies = (packageManagerInfo, cacheDependencyPath) => __awaiter(void 0, void 0, void 0, function* () { }
if (packageManagerInfo.name !== 'yarn') });
return false; /**
const yarnDirs = cacheDependencyPath * A function to report the repo contains Yarn managed projects
? yield exports.getProjectDirectoriesFromCacheDependencyPath(cacheDependencyPath) * @param packageManagerInfo - used to make sure current package manager is yarn
: ['']; * @param cacheDependencyPath - either a single string or multiline string with possible glob patterns
const isManagedList = yield Promise.all(yarnDirs.map(projectHasYarnBerryManagedDependencies)); * expected to be the result of `core.getInput('cache-dependency-path')`
return isManagedList.every(Boolean); * @return - true if all project directories configured to be Yarn managed
}); */
exports.repoHasYarnBerryManagedDependencies = repoHasYarnBerryManagedDependencies; const repoHasYarnBerryManagedDependencies = (packageManagerInfo, cacheDependencyPath) => __awaiter(void 0, void 0, void 0, function* () {
function isGhes() { if (packageManagerInfo.name !== 'yarn')
const ghUrl = new URL(process.env['GITHUB_SERVER_URL'] || 'https://github.com'); return false;
return ghUrl.hostname.toUpperCase() !== 'GITHUB.COM'; const yarnDirs = cacheDependencyPath
} ? yield getProjectDirectoriesFromCacheDependencyPath(cacheDependencyPath)
exports.isGhes = isGhes; : [''];
function isCacheFeatureAvailable() { const isManagedList = yield Promise.all(yarnDirs.map(projectHasYarnBerryManagedDependencies));
if (cache.isFeatureAvailable()) return isManagedList.every(Boolean);
return true; });
if (isGhes()) { exports.repoHasYarnBerryManagedDependencies = repoHasYarnBerryManagedDependencies;
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.'); function isGhes() {
return false; const ghUrl = new URL(process.env['GITHUB_SERVER_URL'] || 'https://github.com');
} return ghUrl.hostname.toUpperCase() !== 'GITHUB.COM';
core.warning('The runner was not able to contact the cache service. Caching will be skipped'); }
return false; exports.isGhes = isGhes;
} function isCacheFeatureAvailable() {
exports.isCacheFeatureAvailable = isCacheFeatureAvailable; if (cache.isFeatureAvailable())
return true;
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.');
return false;
}
core.warning('The runner was not able to contact the cache service. Caching will be skipped');
return false;
}
exports.isCacheFeatureAvailable = isCacheFeatureAvailable;
/***/ }), /***/ }),
@@ -61350,26 +60681,25 @@ 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["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 = {}));
/***/ }), /***/ }),
@@ -61378,108 +60708,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;
/***/ }), /***/ }),
+1391 -1936
View File
File diff suppressed because it is too large Load Diff
+44 -57
View File
@@ -17,14 +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",
"lodash.memoize": "^4.1.2", "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/lodash.memoize": "^4.1.7",
"@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",
@@ -160,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",
@@ -1650,21 +1659,6 @@
"integrity": "sha512-wOuvG1SN4Us4rez+tylwwwCV1psiNVOkJeM3AUWUNWg/jDQY2+HE/444y5gc+jBmRqASOm2Oeh5c1axHobwRKQ==", "integrity": "sha512-wOuvG1SN4Us4rez+tylwwwCV1psiNVOkJeM3AUWUNWg/jDQY2+HE/444y5gc+jBmRqASOm2Oeh5c1axHobwRKQ==",
"dev": true "dev": true
}, },
"node_modules/@types/lodash": {
"version": "4.14.197",
"resolved": "https://registry.npmjs.org/@types/lodash/-/lodash-4.14.197.tgz",
"integrity": "sha512-BMVOiWs0uNxHVlHBgzTIqJYmj+PgCo4euloGF+5m4okL3rEYzM2EEv78mw8zWSMM57dM7kVIgJ2QDvwHSoCI5g==",
"dev": true
},
"node_modules/@types/lodash.memoize": {
"version": "4.1.7",
"resolved": "https://registry.npmjs.org/@types/lodash.memoize/-/lodash.memoize-4.1.7.tgz",
"integrity": "sha512-lGN7WeO4vO6sICVpf041Q7BX/9k1Y24Zo3FY0aUezr1QlKznpjzsDk3T3wvH8ofYzoK0QupN9TWcFAFZlyPwQQ==",
"dev": true,
"dependencies": {
"@types/lodash": "*"
}
},
"node_modules/@types/node": { "node_modules/@types/node": {
"version": "16.11.25", "version": "16.11.25",
"resolved": "https://registry.npmjs.org/@types/node/-/node-16.11.25.tgz", "resolved": "https://registry.npmjs.org/@types/node/-/node-16.11.25.tgz",
@@ -1705,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",
@@ -4989,11 +4989,6 @@
"resolved": "https://registry.npmjs.org/lodash.get/-/lodash.get-4.4.2.tgz", "resolved": "https://registry.npmjs.org/lodash.get/-/lodash.get-4.4.2.tgz",
"integrity": "sha1-LRd/ZS+jHpObRDjVNBSZ36OCXpk=" "integrity": "sha1-LRd/ZS+jHpObRDjVNBSZ36OCXpk="
}, },
"node_modules/lodash.memoize": {
"version": "4.1.2",
"resolved": "https://registry.npmjs.org/lodash.memoize/-/lodash.memoize-4.1.2.tgz",
"integrity": "sha512-t7j+NzmgnQzTAYXcsHYLgimltOV1MXHtlOWf6GjL9Kj8GK5FInw5JotxvbOs+IvV1/Dzo04/fCGfLVs7aXb4Ag=="
},
"node_modules/lodash.merge": { "node_modules/lodash.merge": {
"version": "4.6.2", "version": "4.6.2",
"resolved": "https://registry.npmjs.org/lodash.merge/-/lodash.merge-4.6.2.tgz", "resolved": "https://registry.npmjs.org/lodash.merge/-/lodash.merge-4.6.2.tgz",
@@ -6191,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": {
@@ -6313,9 +6307,9 @@
} }
}, },
"node_modules/word-wrap": { "node_modules/word-wrap": {
"version": "1.2.4", "version": "1.2.3",
"resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.4.tgz", "resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.3.tgz",
"integrity": "sha512-2V81OA4ugVo5pRo46hAoD2ivUJx8jXmWXfUkY4KFNw0hEptvN0QfH3K4nHiwzGeKl5rFKedV48QVoqYavy4YpA==", "integrity": "sha512-Hz/mrNwitNRh/HUAtM/VT/5VH+ygD6DV7mYKZAtHOrbs8U7lvPS6xf7EJKMF0uW1KJCl0H701g3ZGus+muE5vQ==",
"dev": true, "dev": true,
"engines": { "engines": {
"node": ">=0.10.0" "node": ">=0.10.0"
@@ -6579,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": {
@@ -7802,21 +7803,6 @@
"integrity": "sha512-wOuvG1SN4Us4rez+tylwwwCV1psiNVOkJeM3AUWUNWg/jDQY2+HE/444y5gc+jBmRqASOm2Oeh5c1axHobwRKQ==", "integrity": "sha512-wOuvG1SN4Us4rez+tylwwwCV1psiNVOkJeM3AUWUNWg/jDQY2+HE/444y5gc+jBmRqASOm2Oeh5c1axHobwRKQ==",
"dev": true "dev": true
}, },
"@types/lodash": {
"version": "4.14.197",
"resolved": "https://registry.npmjs.org/@types/lodash/-/lodash-4.14.197.tgz",
"integrity": "sha512-BMVOiWs0uNxHVlHBgzTIqJYmj+PgCo4euloGF+5m4okL3rEYzM2EEv78mw8zWSMM57dM7kVIgJ2QDvwHSoCI5g==",
"dev": true
},
"@types/lodash.memoize": {
"version": "4.1.7",
"resolved": "https://registry.npmjs.org/@types/lodash.memoize/-/lodash.memoize-4.1.7.tgz",
"integrity": "sha512-lGN7WeO4vO6sICVpf041Q7BX/9k1Y24Zo3FY0aUezr1QlKznpjzsDk3T3wvH8ofYzoK0QupN9TWcFAFZlyPwQQ==",
"dev": true,
"requires": {
"@types/lodash": "*"
}
},
"@types/node": { "@types/node": {
"version": "16.11.25", "version": "16.11.25",
"resolved": "https://registry.npmjs.org/@types/node/-/node-16.11.25.tgz", "resolved": "https://registry.npmjs.org/@types/node/-/node-16.11.25.tgz",
@@ -7857,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",
@@ -10281,11 +10273,6 @@
"resolved": "https://registry.npmjs.org/lodash.get/-/lodash.get-4.4.2.tgz", "resolved": "https://registry.npmjs.org/lodash.get/-/lodash.get-4.4.2.tgz",
"integrity": "sha1-LRd/ZS+jHpObRDjVNBSZ36OCXpk=" "integrity": "sha1-LRd/ZS+jHpObRDjVNBSZ36OCXpk="
}, },
"lodash.memoize": {
"version": "4.1.2",
"resolved": "https://registry.npmjs.org/lodash.memoize/-/lodash.memoize-4.1.2.tgz",
"integrity": "sha512-t7j+NzmgnQzTAYXcsHYLgimltOV1MXHtlOWf6GjL9Kj8GK5FInw5JotxvbOs+IvV1/Dzo04/fCGfLVs7aXb4Ag=="
},
"lodash.merge": { "lodash.merge": {
"version": "4.6.2", "version": "4.6.2",
"resolved": "https://registry.npmjs.org/lodash.merge/-/lodash.merge-4.6.2.tgz", "resolved": "https://registry.npmjs.org/lodash.merge/-/lodash.merge-4.6.2.tgz",
@@ -11156,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",
@@ -11255,9 +11242,9 @@
} }
}, },
"word-wrap": { "word-wrap": {
"version": "1.2.4", "version": "1.2.3",
"resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.4.tgz", "resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.3.tgz",
"integrity": "sha512-2V81OA4ugVo5pRo46hAoD2ivUJx8jXmWXfUkY4KFNw0hEptvN0QfH3K4nHiwzGeKl5rFKedV48QVoqYavy4YpA==", "integrity": "sha512-Hz/mrNwitNRh/HUAtM/VT/5VH+ygD6DV7mYKZAtHOrbs8U7lvPS6xf7EJKMF0uW1KJCl0H701g3ZGus+muE5vQ==",
"dev": true "dev": true
}, },
"wrap-ansi": { "wrap-ansi": {
+3 -3
View File
@@ -33,14 +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",
"lodash.memoize": "^4.1.2", "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/lodash.memoize": "^4.1.7",
"@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",
+5 -2
View File
@@ -1,6 +1,8 @@
import * as core from '@actions/core'; import * as core from '@actions/core';
import * as cache from '@actions/cache'; import * as cache from '@actions/cache';
import fs from 'fs';
import {State} from './constants'; import {State} from './constants';
import {getPackageManagerInfo} from './cache-utils'; import {getPackageManagerInfo} from './cache-utils';
@@ -14,7 +16,7 @@ process.on('uncaughtException', e => {
export async function run() { export async function run() {
try { try {
const cacheLock = core.getState(State.CachePackageManager); const cacheLock = core.getInput('cache');
await cachePackages(cacheLock); await cachePackages(cacheLock);
} catch (error) { } catch (error) {
core.setFailed(error.message); core.setFailed(error.message);
@@ -24,9 +26,10 @@ export async function run() {
const cachePackages = async (packageManager: string) => { const cachePackages = async (packageManager: string) => {
const state = core.getState(State.CacheMatchedKey); const state = core.getState(State.CacheMatchedKey);
const primaryKey = core.getState(State.CachePrimaryKey); const primaryKey = core.getState(State.CachePrimaryKey);
const cachePaths = JSON.parse( let cachePaths = JSON.parse(
core.getState(State.CachePaths) || '[]' core.getState(State.CachePaths) || '[]'
) as string[]; ) as string[];
cachePaths = cachePaths.filter(fs.existsSync);
const packageManagerInfo = await getPackageManagerInfo(packageManager); const packageManagerInfo = await getPackageManagerInfo(packageManager);
if (!packageManagerInfo) { if (!packageManagerInfo) {
+36 -25
View File
@@ -2,7 +2,6 @@ import * as core from '@actions/core';
import * as exec from '@actions/exec'; import * as exec from '@actions/exec';
import * as cache from '@actions/cache'; import * as cache from '@actions/cache';
import * as glob from '@actions/glob'; import * as glob from '@actions/glob';
import memoize from 'lodash.memoize';
import path from 'path'; import path from 'path';
import fs from 'fs'; import fs from 'fs';
import {unique} from './util'; import {unique} from './util';
@@ -112,38 +111,50 @@ export const getPackageManagerInfo = async (packageManager: string) => {
}; };
/** /**
* Expands (converts) the string input `cache-dependency-path` to list of directories that
* may be project roots
*
* 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: string[] | null = null;
/**
* unit test must reset memoized variables
*/
export const resetProjectDirectoriesMemoized = () =>
(projectDirectoriesMemoized = null);
/**
* Expands (converts) the string input `cache-dependency-path` to list of directories that
* 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 * @return list of directories and possible
*/ */
export const getProjectDirectoriesFromCacheDependencyPath = memoize( const getProjectDirectoriesFromCacheDependencyPath = async (
async (cacheDependencyPath: string): Promise<string[]> => { cacheDependencyPath: string
const globber = await glob.create(cacheDependencyPath); ): Promise<string[]> => {
const cacheDependenciesPaths = await globber.glob(); if (projectDirectoriesMemoized !== null) {
return projectDirectoriesMemoized;
const existingDirectories: string[] = cacheDependenciesPaths
.map(path.dirname)
.filter(unique())
.map(dirName => fs.realpathSync(dirName))
.filter(directory => fs.lstatSync(directory).isDirectory());
if (!existingDirectories.length)
core.warning(
`No existing directories found containing cache-dependency-path="${cacheDependencyPath}"`
);
return existingDirectories;
} }
);
const globber = await glob.create(cacheDependencyPath);
const cacheDependenciesPaths = await globber.glob();
const existingDirectories: string[] = cacheDependenciesPaths
.map(path.dirname)
.filter(unique())
.map(dirName => fs.realpathSync(dirName))
.filter(directory => fs.lstatSync(directory).isDirectory());
if (!existingDirectories.length)
core.warning(
`No existing directories found containing cache-dependency-path="${cacheDependencyPath}"`
);
projectDirectoriesMemoized = 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
-1
View File
@@ -5,7 +5,6 @@ export enum LockType {
} }
export enum State { export enum State {
CachePackageManager = 'SETUP_NODE_CACHE_PACKAGE_MANAGER',
CachePrimaryKey = 'CACHE_KEY', CachePrimaryKey = 'CACHE_KEY',
CacheMatchedKey = 'CACHE_RESULT', CacheMatchedKey = 'CACHE_RESULT',
CachePaths = 'CACHE_PATHS' CachePaths = 'CACHE_PATHS'
+3 -3
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);
-2
View File
@@ -9,7 +9,6 @@ import {restoreCache} from './cache-restore';
import {isCacheFeatureAvailable} from './cache-utils'; import {isCacheFeatureAvailable} from './cache-utils';
import {getNodejsDistribution} from './distributions/installer-factory'; import {getNodejsDistribution} from './distributions/installer-factory';
import {parseNodeVersionFile, printEnvDetailsAndSetOutput} from './util'; import {parseNodeVersionFile, printEnvDetailsAndSetOutput} from './util';
import {State} from './constants';
export async function run() { export async function run() {
try { try {
@@ -61,7 +60,6 @@ export async function run() {
} }
if (cache && isCacheFeatureAvailable()) { if (cache && isCacheFeatureAvailable()) {
core.saveState(State.CachePackageManager, cache);
const cacheDependencyPath = core.getInput('cache-dependency-path'); const cacheDependencyPath = core.getInput('cache-dependency-path');
await restoreCache(cache, cacheDependencyPath); await restoreCache(cache, cacheDependencyPath);
} }