Detect cached folders from multiple directories (#735)
* Add project-dir * Fix find lock file * Remove package-dir input * format & resolve conflicts * Add unit tests * build dist * Apply change request fixes * handle non-dir cache-dependency-path * bump cache version * run checks * Handle globs in cacheDependencyPath * refactor, introduce `cacheDependencyPathToProjectsDirectories` it is necessary for the next PR related yarn optimization * Changes requests * Apply fixes * review fixes * add e2e * Add unique * review updates * review updates second stage * Review fixes 3 * imporve e2e tests
This commit is contained in:
parent
698d50532e
commit
8170e22e8f
27
.github/workflows/e2e-cache.yml
vendored
27
.github/workflows/e2e-cache.yml
vendored
@ -134,3 +134,30 @@ jobs:
|
|||||||
- name: Verify node and yarn
|
- name: Verify node and yarn
|
||||||
run: __tests__/verify-node.sh "${{ matrix.node-version }}"
|
run: __tests__/verify-node.sh "${{ matrix.node-version }}"
|
||||||
shell: bash
|
shell: bash
|
||||||
|
|
||||||
|
yarn-subprojects:
|
||||||
|
name: Test yarn subprojects
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
node-version: [12, 14, 16]
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: prepare sub-projects
|
||||||
|
run: __tests__/prepare-subprojects.sh
|
||||||
|
|
||||||
|
# expect
|
||||||
|
# - no errors
|
||||||
|
# - log
|
||||||
|
# ##[debug]Cache Paths:
|
||||||
|
# ##[debug]["sub2/.yarn/cache","sub3/.yarn/cache","../../../.cache/yarn/v6"]
|
||||||
|
- name: Setup Node
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
node-version: ${{ matrix.node-version }}
|
||||||
|
cache: 'yarn'
|
||||||
|
cache-dependency-path: |
|
||||||
|
**/*.lock
|
||||||
|
yarn.lock
|
||||||
|
|||||||
@ -1,9 +1,10 @@
|
|||||||
import os from 'os';
|
import os from 'os';
|
||||||
import * as fs from 'fs';
|
import fs from 'fs';
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
import * as core from '@actions/core';
|
import * as core from '@actions/core';
|
||||||
import * as io from '@actions/io';
|
import * as io from '@actions/io';
|
||||||
import * as auth from '../src/authutil';
|
import * as auth from '../src/authutil';
|
||||||
|
import * as cacheUtils from '../src/cache-utils';
|
||||||
|
|
||||||
let rcFile: string;
|
let rcFile: string;
|
||||||
|
|
||||||
|
|||||||
@ -32,13 +32,13 @@ describe('cache-restore', () => {
|
|||||||
|
|
||||||
function findCacheFolder(command: string) {
|
function findCacheFolder(command: string) {
|
||||||
switch (command) {
|
switch (command) {
|
||||||
case utils.supportedPackageManagers.npm.getCacheFolderCommand:
|
case 'npm config get cache':
|
||||||
return npmCachePath;
|
return npmCachePath;
|
||||||
case utils.supportedPackageManagers.pnpm.getCacheFolderCommand:
|
case 'pnpm store path --silent':
|
||||||
return pnpmCachePath;
|
return pnpmCachePath;
|
||||||
case utils.supportedPackageManagers.yarn1.getCacheFolderCommand:
|
case 'yarn cache dir':
|
||||||
return yarn1CachePath;
|
return yarn1CachePath;
|
||||||
case utils.supportedPackageManagers.yarn2.getCacheFolderCommand:
|
case 'yarn config get cacheFolder':
|
||||||
return yarn2CachePath;
|
return yarn2CachePath;
|
||||||
default:
|
default:
|
||||||
return 'packge/not/found';
|
return 'packge/not/found';
|
||||||
@ -108,7 +108,7 @@ describe('cache-restore', () => {
|
|||||||
it.each([['npm7'], ['npm6'], ['pnpm6'], ['yarn1'], ['yarn2'], ['random']])(
|
it.each([['npm7'], ['npm6'], ['pnpm6'], ['yarn1'], ['yarn2'], ['random']])(
|
||||||
'Throw an error because %s is not supported',
|
'Throw an error because %s is not supported',
|
||||||
async packageManager => {
|
async packageManager => {
|
||||||
await expect(restoreCache(packageManager)).rejects.toThrow(
|
await expect(restoreCache(packageManager, '')).rejects.toThrow(
|
||||||
`Caching for '${packageManager}' is not supported`
|
`Caching for '${packageManager}' is not supported`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -132,7 +132,7 @@ describe('cache-restore', () => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
await restoreCache(packageManager);
|
await restoreCache(packageManager, '');
|
||||||
expect(hashFilesSpy).toHaveBeenCalled();
|
expect(hashFilesSpy).toHaveBeenCalled();
|
||||||
expect(infoSpy).toHaveBeenCalledWith(
|
expect(infoSpy).toHaveBeenCalledWith(
|
||||||
`Cache restored from key: node-cache-${platform}-${packageManager}-${fileHash}`
|
`Cache restored from key: node-cache-${platform}-${packageManager}-${fileHash}`
|
||||||
@ -163,7 +163,7 @@ describe('cache-restore', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
restoreCacheSpy.mockImplementationOnce(() => undefined);
|
restoreCacheSpy.mockImplementationOnce(() => undefined);
|
||||||
await restoreCache(packageManager);
|
await restoreCache(packageManager, '');
|
||||||
expect(hashFilesSpy).toHaveBeenCalled();
|
expect(hashFilesSpy).toHaveBeenCalled();
|
||||||
expect(infoSpy).toHaveBeenCalledWith(
|
expect(infoSpy).toHaveBeenCalledWith(
|
||||||
`${packageManager} cache is not found`
|
`${packageManager} cache is not found`
|
||||||
|
|||||||
@ -107,18 +107,20 @@ describe('run', () => {
|
|||||||
describe('Validate unchanged cache is not saved', () => {
|
describe('Validate unchanged cache is not saved', () => {
|
||||||
it('should not save cache for yarn1', async () => {
|
it('should not save cache for yarn1', async () => {
|
||||||
inputs['cache'] = 'yarn';
|
inputs['cache'] = 'yarn';
|
||||||
getStateSpy.mockImplementation(() => yarnFileHash);
|
getStateSpy.mockImplementation(key =>
|
||||||
getCommandOutputSpy
|
key === State.CachePrimaryKey || key === State.CacheMatchedKey
|
||||||
.mockImplementationOnce(() => '1.2.3')
|
? yarnFileHash
|
||||||
.mockImplementationOnce(() => `${commonPath}/yarn1`);
|
: key === State.CachePaths
|
||||||
|
? '["/foo/bar"]'
|
||||||
|
: 'not expected'
|
||||||
|
);
|
||||||
|
|
||||||
await run();
|
await run();
|
||||||
|
|
||||||
expect(getInputSpy).toHaveBeenCalled();
|
expect(getInputSpy).toHaveBeenCalled();
|
||||||
expect(getStateSpy).toHaveBeenCalledTimes(2);
|
expect(getStateSpy).toHaveBeenCalledTimes(3);
|
||||||
expect(getCommandOutputSpy).toHaveBeenCalledTimes(2);
|
expect(getCommandOutputSpy).toHaveBeenCalledTimes(0);
|
||||||
expect(debugSpy).toHaveBeenCalledWith(`yarn path is ${commonPath}/yarn1`);
|
expect(debugSpy).toHaveBeenCalledTimes(0);
|
||||||
expect(debugSpy).toHaveBeenCalledWith('Consumed yarn version is 1.2.3');
|
|
||||||
expect(infoSpy).toHaveBeenCalledWith(
|
expect(infoSpy).toHaveBeenCalledWith(
|
||||||
`Cache hit occurred on the primary key ${yarnFileHash}, not saving cache.`
|
`Cache hit occurred on the primary key ${yarnFileHash}, not saving cache.`
|
||||||
);
|
);
|
||||||
@ -127,18 +129,20 @@ 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(() => yarnFileHash);
|
getStateSpy.mockImplementation(key =>
|
||||||
getCommandOutputSpy
|
key === State.CachePrimaryKey || key === State.CacheMatchedKey
|
||||||
.mockImplementationOnce(() => '2.2.3')
|
? yarnFileHash
|
||||||
.mockImplementationOnce(() => `${commonPath}/yarn2`);
|
: key === State.CachePaths
|
||||||
|
? '["/foo/bar"]'
|
||||||
|
: 'not expected'
|
||||||
|
);
|
||||||
|
|
||||||
await run();
|
await run();
|
||||||
|
|
||||||
expect(getInputSpy).toHaveBeenCalled();
|
expect(getInputSpy).toHaveBeenCalled();
|
||||||
expect(getStateSpy).toHaveBeenCalledTimes(2);
|
expect(getStateSpy).toHaveBeenCalledTimes(3);
|
||||||
expect(getCommandOutputSpy).toHaveBeenCalledTimes(2);
|
expect(getCommandOutputSpy).toHaveBeenCalledTimes(0);
|
||||||
expect(debugSpy).toHaveBeenCalledWith(`yarn path is ${commonPath}/yarn2`);
|
expect(debugSpy).toHaveBeenCalledTimes(0);
|
||||||
expect(debugSpy).toHaveBeenCalledWith('Consumed yarn version is 2.2.3');
|
|
||||||
expect(infoSpy).toHaveBeenCalledWith(
|
expect(infoSpy).toHaveBeenCalledWith(
|
||||||
`Cache hit occurred on the primary key ${yarnFileHash}, not saving cache.`
|
`Cache hit occurred on the primary key ${yarnFileHash}, not saving cache.`
|
||||||
);
|
);
|
||||||
@ -147,35 +151,40 @@ 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(() => npmFileHash);
|
getStateSpy.mockImplementation(key =>
|
||||||
|
key === State.CachePrimaryKey || key === State.CacheMatchedKey
|
||||||
|
? yarnFileHash
|
||||||
|
: key === State.CachePaths
|
||||||
|
? '["/foo/bar"]'
|
||||||
|
: 'not expected'
|
||||||
|
);
|
||||||
getCommandOutputSpy.mockImplementationOnce(() => `${commonPath}/npm`);
|
getCommandOutputSpy.mockImplementationOnce(() => `${commonPath}/npm`);
|
||||||
|
|
||||||
await run();
|
await run();
|
||||||
|
|
||||||
expect(getInputSpy).toHaveBeenCalled();
|
expect(getInputSpy).toHaveBeenCalled();
|
||||||
expect(getStateSpy).toHaveBeenCalledTimes(2);
|
expect(getStateSpy).toHaveBeenCalledTimes(3);
|
||||||
expect(getCommandOutputSpy).toHaveBeenCalledTimes(1);
|
expect(getCommandOutputSpy).toHaveBeenCalledTimes(0);
|
||||||
expect(debugSpy).toHaveBeenCalledWith(`npm path is ${commonPath}/npm`);
|
expect(debugSpy).toHaveBeenCalledTimes(0);
|
||||||
expect(infoSpy).toHaveBeenCalledWith(
|
|
||||||
`Cache hit occurred on the primary key ${npmFileHash}, not saving cache.`
|
|
||||||
);
|
|
||||||
expect(setFailedSpy).not.toHaveBeenCalled();
|
expect(setFailedSpy).not.toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should not save cache for pnpm', async () => {
|
it('should not save cache for pnpm', async () => {
|
||||||
inputs['cache'] = 'pnpm';
|
inputs['cache'] = 'pnpm';
|
||||||
getStateSpy.mockImplementation(() => pnpmFileHash);
|
getStateSpy.mockImplementation(key =>
|
||||||
getCommandOutputSpy.mockImplementationOnce(() => `${commonPath}/pnpm`);
|
key === State.CachePrimaryKey || key === State.CacheMatchedKey
|
||||||
|
? yarnFileHash
|
||||||
|
: key === State.CachePaths
|
||||||
|
? '["/foo/bar"]'
|
||||||
|
: 'not expected'
|
||||||
|
);
|
||||||
|
|
||||||
await run();
|
await run();
|
||||||
|
|
||||||
expect(getInputSpy).toHaveBeenCalled();
|
expect(getInputSpy).toHaveBeenCalled();
|
||||||
expect(getStateSpy).toHaveBeenCalledTimes(2);
|
expect(getStateSpy).toHaveBeenCalledTimes(3);
|
||||||
expect(getCommandOutputSpy).toHaveBeenCalledTimes(1);
|
expect(getCommandOutputSpy).toHaveBeenCalledTimes(0);
|
||||||
expect(debugSpy).toHaveBeenCalledWith(`pnpm path is ${commonPath}/pnpm`);
|
expect(debugSpy).toHaveBeenCalledTimes(0);
|
||||||
expect(infoSpy).toHaveBeenCalledWith(
|
|
||||||
`Cache hit occurred on the primary key ${pnpmFileHash}, not saving cache.`
|
|
||||||
);
|
|
||||||
expect(setFailedSpy).not.toHaveBeenCalled();
|
expect(setFailedSpy).not.toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -183,24 +192,22 @@ describe('run', () => {
|
|||||||
describe('action saves the cache', () => {
|
describe('action saves the cache', () => {
|
||||||
it('saves cache from yarn 1', async () => {
|
it('saves cache from yarn 1', async () => {
|
||||||
inputs['cache'] = 'yarn';
|
inputs['cache'] = 'yarn';
|
||||||
getStateSpy.mockImplementation((name: string) => {
|
getStateSpy.mockImplementation((key: string) =>
|
||||||
if (name === State.CacheMatchedKey) {
|
key === State.CacheMatchedKey
|
||||||
return yarnFileHash;
|
? yarnFileHash
|
||||||
} else {
|
: key === State.CachePrimaryKey
|
||||||
return npmFileHash;
|
? npmFileHash
|
||||||
}
|
: key === State.CachePaths
|
||||||
});
|
? '["/foo/bar"]'
|
||||||
getCommandOutputSpy
|
: 'not expected'
|
||||||
.mockImplementationOnce(() => '1.2.3')
|
);
|
||||||
.mockImplementationOnce(() => `${commonPath}/yarn1`);
|
|
||||||
|
|
||||||
await run();
|
await run();
|
||||||
|
|
||||||
expect(getInputSpy).toHaveBeenCalled();
|
expect(getInputSpy).toHaveBeenCalled();
|
||||||
expect(getStateSpy).toHaveBeenCalledTimes(2);
|
expect(getStateSpy).toHaveBeenCalledTimes(3);
|
||||||
expect(getCommandOutputSpy).toHaveBeenCalledTimes(2);
|
expect(getCommandOutputSpy).toHaveBeenCalledTimes(0);
|
||||||
expect(debugSpy).toHaveBeenCalledWith(`yarn path is ${commonPath}/yarn1`);
|
expect(debugSpy).toHaveBeenCalledTimes(0);
|
||||||
expect(debugSpy).toHaveBeenCalledWith('Consumed yarn version is 1.2.3');
|
|
||||||
expect(infoSpy).not.toHaveBeenCalledWith(
|
expect(infoSpy).not.toHaveBeenCalledWith(
|
||||||
`Cache hit occurred on the primary key ${yarnFileHash}, not saving cache.`
|
`Cache hit occurred on the primary key ${yarnFileHash}, not saving cache.`
|
||||||
);
|
);
|
||||||
@ -213,24 +220,22 @@ describe('run', () => {
|
|||||||
|
|
||||||
it('saves cache from yarn 2', async () => {
|
it('saves cache from yarn 2', async () => {
|
||||||
inputs['cache'] = 'yarn';
|
inputs['cache'] = 'yarn';
|
||||||
getStateSpy.mockImplementation((name: string) => {
|
getStateSpy.mockImplementation((key: string) =>
|
||||||
if (name === State.CacheMatchedKey) {
|
key === State.CacheMatchedKey
|
||||||
return yarnFileHash;
|
? yarnFileHash
|
||||||
} else {
|
: key === State.CachePrimaryKey
|
||||||
return npmFileHash;
|
? npmFileHash
|
||||||
}
|
: key === State.CachePaths
|
||||||
});
|
? '["/foo/bar"]'
|
||||||
getCommandOutputSpy
|
: 'not expected'
|
||||||
.mockImplementationOnce(() => '2.2.3')
|
);
|
||||||
.mockImplementationOnce(() => `${commonPath}/yarn2`);
|
|
||||||
|
|
||||||
await run();
|
await run();
|
||||||
|
|
||||||
expect(getInputSpy).toHaveBeenCalled();
|
expect(getInputSpy).toHaveBeenCalled();
|
||||||
expect(getStateSpy).toHaveBeenCalledTimes(2);
|
expect(getStateSpy).toHaveBeenCalledTimes(3);
|
||||||
expect(getCommandOutputSpy).toHaveBeenCalledTimes(2);
|
expect(getCommandOutputSpy).toHaveBeenCalledTimes(0);
|
||||||
expect(debugSpy).toHaveBeenCalledWith(`yarn path is ${commonPath}/yarn2`);
|
expect(debugSpy).toHaveBeenCalledTimes(0);
|
||||||
expect(debugSpy).toHaveBeenCalledWith('Consumed yarn version is 2.2.3');
|
|
||||||
expect(infoSpy).not.toHaveBeenCalledWith(
|
expect(infoSpy).not.toHaveBeenCalledWith(
|
||||||
`Cache hit occurred on the primary key ${yarnFileHash}, not saving cache.`
|
`Cache hit occurred on the primary key ${yarnFileHash}, not saving cache.`
|
||||||
);
|
);
|
||||||
@ -243,21 +248,22 @@ describe('run', () => {
|
|||||||
|
|
||||||
it('saves cache from npm', async () => {
|
it('saves cache from npm', async () => {
|
||||||
inputs['cache'] = 'npm';
|
inputs['cache'] = 'npm';
|
||||||
getStateSpy.mockImplementation((name: string) => {
|
getStateSpy.mockImplementation((key: string) =>
|
||||||
if (name === State.CacheMatchedKey) {
|
key === State.CacheMatchedKey
|
||||||
return npmFileHash;
|
? npmFileHash
|
||||||
} else {
|
: key === State.CachePrimaryKey
|
||||||
return yarnFileHash;
|
? yarnFileHash
|
||||||
}
|
: key === State.CachePaths
|
||||||
});
|
? '["/foo/bar"]'
|
||||||
getCommandOutputSpy.mockImplementationOnce(() => `${commonPath}/npm`);
|
: 'not expected'
|
||||||
|
);
|
||||||
|
|
||||||
await run();
|
await run();
|
||||||
|
|
||||||
expect(getInputSpy).toHaveBeenCalled();
|
expect(getInputSpy).toHaveBeenCalled();
|
||||||
expect(getStateSpy).toHaveBeenCalledTimes(2);
|
expect(getStateSpy).toHaveBeenCalledTimes(3);
|
||||||
expect(getCommandOutputSpy).toHaveBeenCalledTimes(1);
|
expect(getCommandOutputSpy).toHaveBeenCalledTimes(0);
|
||||||
expect(debugSpy).toHaveBeenCalledWith(`npm path is ${commonPath}/npm`);
|
expect(debugSpy).toHaveBeenCalledTimes(0);
|
||||||
expect(infoSpy).not.toHaveBeenCalledWith(
|
expect(infoSpy).not.toHaveBeenCalledWith(
|
||||||
`Cache hit occurred on the primary key ${npmFileHash}, not saving cache.`
|
`Cache hit occurred on the primary key ${npmFileHash}, not saving cache.`
|
||||||
);
|
);
|
||||||
@ -270,21 +276,22 @@ describe('run', () => {
|
|||||||
|
|
||||||
it('saves cache from pnpm', async () => {
|
it('saves cache from pnpm', async () => {
|
||||||
inputs['cache'] = 'pnpm';
|
inputs['cache'] = 'pnpm';
|
||||||
getStateSpy.mockImplementation((name: string) => {
|
getStateSpy.mockImplementation((key: string) =>
|
||||||
if (name === State.CacheMatchedKey) {
|
key === State.CacheMatchedKey
|
||||||
return pnpmFileHash;
|
? pnpmFileHash
|
||||||
} else {
|
: key === State.CachePrimaryKey
|
||||||
return npmFileHash;
|
? npmFileHash
|
||||||
}
|
: key === State.CachePaths
|
||||||
});
|
? '["/foo/bar"]'
|
||||||
getCommandOutputSpy.mockImplementationOnce(() => `${commonPath}/pnpm`);
|
: 'not expected'
|
||||||
|
);
|
||||||
|
|
||||||
await run();
|
await run();
|
||||||
|
|
||||||
expect(getInputSpy).toHaveBeenCalled();
|
expect(getInputSpy).toHaveBeenCalled();
|
||||||
expect(getStateSpy).toHaveBeenCalledTimes(2);
|
expect(getStateSpy).toHaveBeenCalledTimes(3);
|
||||||
expect(getCommandOutputSpy).toHaveBeenCalledTimes(1);
|
expect(getCommandOutputSpy).toHaveBeenCalledTimes(0);
|
||||||
expect(debugSpy).toHaveBeenCalledWith(`pnpm path is ${commonPath}/pnpm`);
|
expect(debugSpy).toHaveBeenCalledTimes(0);
|
||||||
expect(infoSpy).not.toHaveBeenCalledWith(
|
expect(infoSpy).not.toHaveBeenCalledWith(
|
||||||
`Cache hit occurred on the primary key ${pnpmFileHash}, not saving cache.`
|
`Cache hit occurred on the primary key ${pnpmFileHash}, not saving cache.`
|
||||||
);
|
);
|
||||||
@ -297,14 +304,15 @@ 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((name: string) => {
|
getStateSpy.mockImplementation((key: string) =>
|
||||||
if (name === State.CacheMatchedKey) {
|
key === State.CacheMatchedKey
|
||||||
return npmFileHash;
|
? npmFileHash
|
||||||
} else {
|
: key === State.CachePrimaryKey
|
||||||
return yarnFileHash;
|
? yarnFileHash
|
||||||
}
|
: key === State.CachePaths
|
||||||
});
|
? '["/foo/bar"]'
|
||||||
getCommandOutputSpy.mockImplementationOnce(() => `${commonPath}/npm`);
|
: 'not expected'
|
||||||
|
);
|
||||||
saveCacheSpy.mockImplementation(() => {
|
saveCacheSpy.mockImplementation(() => {
|
||||||
return -1;
|
return -1;
|
||||||
});
|
});
|
||||||
@ -312,9 +320,9 @@ describe('run', () => {
|
|||||||
await run();
|
await run();
|
||||||
|
|
||||||
expect(getInputSpy).toHaveBeenCalled();
|
expect(getInputSpy).toHaveBeenCalled();
|
||||||
expect(getStateSpy).toHaveBeenCalledTimes(2);
|
expect(getStateSpy).toHaveBeenCalledTimes(3);
|
||||||
expect(getCommandOutputSpy).toHaveBeenCalledTimes(1);
|
expect(getCommandOutputSpy).toHaveBeenCalledTimes(0);
|
||||||
expect(debugSpy).toHaveBeenCalledWith(`npm path is ${commonPath}/npm`);
|
expect(debugSpy).toHaveBeenCalledTimes(0);
|
||||||
expect(infoSpy).not.toHaveBeenCalledWith(
|
expect(infoSpy).not.toHaveBeenCalledWith(
|
||||||
`Cache hit occurred on the primary key ${npmFileHash}, not saving cache.`
|
`Cache hit occurred on the primary key ${npmFileHash}, not saving cache.`
|
||||||
);
|
);
|
||||||
@ -327,14 +335,15 @@ 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((name: string) => {
|
getStateSpy.mockImplementation((key: string) =>
|
||||||
if (name === State.CacheMatchedKey) {
|
key === State.CacheMatchedKey
|
||||||
return npmFileHash;
|
? npmFileHash
|
||||||
} else {
|
: key === State.CachePrimaryKey
|
||||||
return yarnFileHash;
|
? yarnFileHash
|
||||||
}
|
: key === State.CachePaths
|
||||||
});
|
? '["/foo/bar"]'
|
||||||
getCommandOutputSpy.mockImplementationOnce(() => `${commonPath}/npm`);
|
: 'not expected'
|
||||||
|
);
|
||||||
saveCacheSpy.mockImplementation(() => {
|
saveCacheSpy.mockImplementation(() => {
|
||||||
throw new cache.ValidationError('Validation failed');
|
throw new cache.ValidationError('Validation failed');
|
||||||
});
|
});
|
||||||
@ -342,9 +351,9 @@ describe('run', () => {
|
|||||||
await run();
|
await run();
|
||||||
|
|
||||||
expect(getInputSpy).toHaveBeenCalled();
|
expect(getInputSpy).toHaveBeenCalled();
|
||||||
expect(getStateSpy).toHaveBeenCalledTimes(2);
|
expect(getStateSpy).toHaveBeenCalledTimes(3);
|
||||||
expect(getCommandOutputSpy).toHaveBeenCalledTimes(1);
|
expect(getCommandOutputSpy).toHaveBeenCalledTimes(0);
|
||||||
expect(debugSpy).toHaveBeenCalledWith(`npm path is ${commonPath}/npm`);
|
expect(debugSpy).toHaveBeenCalledTimes(0);
|
||||||
expect(infoSpy).not.toHaveBeenCalledWith(
|
expect(infoSpy).not.toHaveBeenCalledWith(
|
||||||
`Cache hit occurred on the primary key ${npmFileHash}, not saving cache.`
|
`Cache hit occurred on the primary key ${npmFileHash}, not saving cache.`
|
||||||
);
|
);
|
||||||
|
|||||||
@ -2,7 +2,17 @@ import * as core from '@actions/core';
|
|||||||
import * as cache from '@actions/cache';
|
import * as cache from '@actions/cache';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import * as utils from '../src/cache-utils';
|
import * as utils from '../src/cache-utils';
|
||||||
import {PackageManagerInfo, isCacheFeatureAvailable} from '../src/cache-utils';
|
import {
|
||||||
|
PackageManagerInfo,
|
||||||
|
isCacheFeatureAvailable,
|
||||||
|
supportedPackageManagers,
|
||||||
|
getCommandOutput
|
||||||
|
} from '../src/cache-utils';
|
||||||
|
import fs from 'fs';
|
||||||
|
import * as cacheUtils from '../src/cache-utils';
|
||||||
|
import * as glob from '@actions/glob';
|
||||||
|
import {Globber} from '@actions/glob';
|
||||||
|
import {MockGlobber} from './mock/glob-mock';
|
||||||
|
|
||||||
describe('cache-utils', () => {
|
describe('cache-utils', () => {
|
||||||
const versionYarn1 = '1.2.3';
|
const versionYarn1 = '1.2.3';
|
||||||
@ -30,7 +40,7 @@ describe('cache-utils', () => {
|
|||||||
it.each<[string, PackageManagerInfo | null]>([
|
it.each<[string, PackageManagerInfo | null]>([
|
||||||
['npm', utils.supportedPackageManagers.npm],
|
['npm', utils.supportedPackageManagers.npm],
|
||||||
['pnpm', utils.supportedPackageManagers.pnpm],
|
['pnpm', utils.supportedPackageManagers.pnpm],
|
||||||
['yarn', utils.supportedPackageManagers.yarn1],
|
['yarn', utils.supportedPackageManagers.yarn],
|
||||||
['yarn1', null],
|
['yarn1', null],
|
||||||
['yarn2', null],
|
['yarn2', null],
|
||||||
['npm7', null]
|
['npm7', null]
|
||||||
@ -72,4 +82,261 @@ describe('cache-utils', () => {
|
|||||||
jest.resetAllMocks();
|
jest.resetAllMocks();
|
||||||
jest.clearAllMocks();
|
jest.clearAllMocks();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('getCacheDirectoriesPaths', () => {
|
||||||
|
let existsSpy: jest.SpyInstance;
|
||||||
|
let lstatSpy: jest.SpyInstance;
|
||||||
|
let globCreateSpy: jest.SpyInstance;
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
existsSpy = jest.spyOn(fs, 'existsSync');
|
||||||
|
existsSpy.mockImplementation(() => true);
|
||||||
|
|
||||||
|
lstatSpy = jest.spyOn(fs, 'lstatSync');
|
||||||
|
lstatSpy.mockImplementation(arg => ({
|
||||||
|
isDirectory: () => true
|
||||||
|
}));
|
||||||
|
|
||||||
|
globCreateSpy = jest.spyOn(glob, 'create');
|
||||||
|
|
||||||
|
globCreateSpy.mockImplementation(
|
||||||
|
(pattern: string): Promise<Globber> =>
|
||||||
|
MockGlobber.create(['/foo', '/bar'])
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
afterEach(() => {
|
||||||
|
existsSpy.mockRestore();
|
||||||
|
lstatSpy.mockRestore();
|
||||||
|
globCreateSpy.mockRestore();
|
||||||
|
});
|
||||||
|
|
||||||
|
it.each([
|
||||||
|
[supportedPackageManagers.npm, ''],
|
||||||
|
[supportedPackageManagers.npm, '/dir/file.lock'],
|
||||||
|
[supportedPackageManagers.npm, '/**/file.lock'],
|
||||||
|
[supportedPackageManagers.pnpm, ''],
|
||||||
|
[supportedPackageManagers.pnpm, '/dir/file.lock'],
|
||||||
|
[supportedPackageManagers.pnpm, '/**/file.lock']
|
||||||
|
])(
|
||||||
|
'getCacheDirectoriesPaths should return one dir for non yarn',
|
||||||
|
async (packageManagerInfo, cacheDependency) => {
|
||||||
|
getCommandOutputSpy.mockImplementation(() => 'foo');
|
||||||
|
|
||||||
|
const dirs = await cacheUtils.getCacheDirectories(
|
||||||
|
packageManagerInfo,
|
||||||
|
cacheDependency
|
||||||
|
);
|
||||||
|
expect(dirs).toEqual(['foo']);
|
||||||
|
// to do not call for a version
|
||||||
|
// call once for get cache folder
|
||||||
|
expect(getCommandOutputSpy).toHaveBeenCalledTimes(1);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
it('getCacheDirectoriesPaths should return one dir for yarn without cacheDependency', async () => {
|
||||||
|
getCommandOutputSpy.mockImplementation(() => 'foo');
|
||||||
|
|
||||||
|
const dirs = await cacheUtils.getCacheDirectories(
|
||||||
|
supportedPackageManagers.yarn,
|
||||||
|
''
|
||||||
|
);
|
||||||
|
expect(dirs).toEqual(['foo']);
|
||||||
|
});
|
||||||
|
|
||||||
|
it.each([
|
||||||
|
[supportedPackageManagers.npm, ''],
|
||||||
|
[supportedPackageManagers.npm, '/dir/file.lock'],
|
||||||
|
[supportedPackageManagers.npm, '/**/file.lock'],
|
||||||
|
[supportedPackageManagers.pnpm, ''],
|
||||||
|
[supportedPackageManagers.pnpm, '/dir/file.lock'],
|
||||||
|
[supportedPackageManagers.pnpm, '/**/file.lock'],
|
||||||
|
[supportedPackageManagers.yarn, ''],
|
||||||
|
[supportedPackageManagers.yarn, '/dir/file.lock'],
|
||||||
|
[supportedPackageManagers.yarn, '/**/file.lock']
|
||||||
|
])(
|
||||||
|
'getCacheDirectoriesPaths should throw for getCommandOutput returning empty',
|
||||||
|
async (packageManagerInfo, cacheDependency) => {
|
||||||
|
getCommandOutputSpy.mockImplementation((command: string) =>
|
||||||
|
// return empty string to indicate getCacheFolderPath failed
|
||||||
|
// --version still works
|
||||||
|
command.includes('version') ? '1.' : ''
|
||||||
|
);
|
||||||
|
|
||||||
|
await expect(
|
||||||
|
cacheUtils.getCacheDirectories(packageManagerInfo, cacheDependency)
|
||||||
|
).rejects.toThrow(); //'Could not get cache folder path for /dir');
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
it.each([
|
||||||
|
[supportedPackageManagers.yarn, '/dir/file.lock'],
|
||||||
|
[supportedPackageManagers.yarn, '/**/file.lock']
|
||||||
|
])(
|
||||||
|
'getCacheDirectoriesPaths should nothrow in case of having not directories',
|
||||||
|
async (packageManagerInfo, cacheDependency) => {
|
||||||
|
lstatSpy.mockImplementation(arg => ({
|
||||||
|
isDirectory: () => false
|
||||||
|
}));
|
||||||
|
|
||||||
|
await cacheUtils.getCacheDirectories(
|
||||||
|
packageManagerInfo,
|
||||||
|
cacheDependency
|
||||||
|
);
|
||||||
|
expect(warningSpy).toHaveBeenCalledTimes(1);
|
||||||
|
expect(warningSpy).toHaveBeenCalledWith(
|
||||||
|
`No existing directories found containing cache-dependency-path="${cacheDependency}"`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
it.each(['1.1.1', '2.2.2'])(
|
||||||
|
'getCacheDirectoriesPaths yarn v%s should return one dir without cacheDependency',
|
||||||
|
async version => {
|
||||||
|
getCommandOutputSpy.mockImplementationOnce(() => version);
|
||||||
|
getCommandOutputSpy.mockImplementationOnce(() => `foo${version}`);
|
||||||
|
|
||||||
|
const dirs = await cacheUtils.getCacheDirectories(
|
||||||
|
supportedPackageManagers.yarn,
|
||||||
|
''
|
||||||
|
);
|
||||||
|
expect(dirs).toEqual([`foo${version}`]);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
it.each(['1.1.1', '2.2.2'])(
|
||||||
|
'getCacheDirectoriesPaths yarn v%s should return 2 dirs with globbed cacheDependency',
|
||||||
|
async version => {
|
||||||
|
let dirNo = 1;
|
||||||
|
getCommandOutputSpy.mockImplementation((command: string) =>
|
||||||
|
command.includes('version') ? version : `file_${version}_${dirNo++}`
|
||||||
|
);
|
||||||
|
globCreateSpy.mockImplementation(
|
||||||
|
(pattern: string): Promise<Globber> =>
|
||||||
|
MockGlobber.create(['/tmp/dir1/file', '/tmp/dir2/file'])
|
||||||
|
);
|
||||||
|
|
||||||
|
const dirs = await cacheUtils.getCacheDirectories(
|
||||||
|
supportedPackageManagers.yarn,
|
||||||
|
'/tmp/**/file'
|
||||||
|
);
|
||||||
|
expect(dirs).toEqual([`file_${version}_1`, `file_${version}_2`]);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
it.each(['1.1.1', '2.2.2'])(
|
||||||
|
'getCacheDirectoriesPaths yarn v%s should return 2 dirs with globbed cacheDependency expanding to duplicates',
|
||||||
|
async version => {
|
||||||
|
let dirNo = 1;
|
||||||
|
getCommandOutputSpy.mockImplementation((command: string) =>
|
||||||
|
command.includes('version') ? version : `file_${version}_${dirNo++}`
|
||||||
|
);
|
||||||
|
globCreateSpy.mockImplementation(
|
||||||
|
(pattern: string): Promise<Globber> =>
|
||||||
|
MockGlobber.create([
|
||||||
|
'/tmp/dir1/file',
|
||||||
|
'/tmp/dir2/file',
|
||||||
|
'/tmp/dir1/file'
|
||||||
|
])
|
||||||
|
);
|
||||||
|
|
||||||
|
const dirs = await cacheUtils.getCacheDirectories(
|
||||||
|
supportedPackageManagers.yarn,
|
||||||
|
'/tmp/**/file'
|
||||||
|
);
|
||||||
|
expect(dirs).toEqual([`file_${version}_1`, `file_${version}_2`]);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
it.each(['1.1.1', '2.2.2'])(
|
||||||
|
'getCacheDirectoriesPaths yarn v%s should return 2 uniq dirs despite duplicate cache directories',
|
||||||
|
async version => {
|
||||||
|
let dirNo = 1;
|
||||||
|
getCommandOutputSpy.mockImplementation((command: string) =>
|
||||||
|
command.includes('version')
|
||||||
|
? version
|
||||||
|
: `file_${version}_${dirNo++ % 2}`
|
||||||
|
);
|
||||||
|
globCreateSpy.mockImplementation(
|
||||||
|
(pattern: string): Promise<Globber> =>
|
||||||
|
MockGlobber.create([
|
||||||
|
'/tmp/dir1/file',
|
||||||
|
'/tmp/dir2/file',
|
||||||
|
'/tmp/dir3/file'
|
||||||
|
])
|
||||||
|
);
|
||||||
|
|
||||||
|
const dirs = await cacheUtils.getCacheDirectories(
|
||||||
|
supportedPackageManagers.yarn,
|
||||||
|
'/tmp/**/file'
|
||||||
|
);
|
||||||
|
expect(dirs).toEqual([`file_${version}_1`, `file_${version}_0`]);
|
||||||
|
expect(getCommandOutputSpy).toHaveBeenCalledTimes(6);
|
||||||
|
expect(getCommandOutputSpy).toHaveBeenCalledWith(
|
||||||
|
'yarn --version',
|
||||||
|
'/tmp/dir1'
|
||||||
|
);
|
||||||
|
expect(getCommandOutputSpy).toHaveBeenCalledWith(
|
||||||
|
'yarn --version',
|
||||||
|
'/tmp/dir2'
|
||||||
|
);
|
||||||
|
expect(getCommandOutputSpy).toHaveBeenCalledWith(
|
||||||
|
'yarn --version',
|
||||||
|
'/tmp/dir3'
|
||||||
|
);
|
||||||
|
expect(getCommandOutputSpy).toHaveBeenCalledWith(
|
||||||
|
version.startsWith('1.')
|
||||||
|
? 'yarn cache dir'
|
||||||
|
: 'yarn config get cacheFolder',
|
||||||
|
'/tmp/dir1'
|
||||||
|
);
|
||||||
|
expect(getCommandOutputSpy).toHaveBeenCalledWith(
|
||||||
|
version.startsWith('1.')
|
||||||
|
? 'yarn cache dir'
|
||||||
|
: 'yarn config get cacheFolder',
|
||||||
|
'/tmp/dir2'
|
||||||
|
);
|
||||||
|
expect(getCommandOutputSpy).toHaveBeenCalledWith(
|
||||||
|
version.startsWith('1.')
|
||||||
|
? 'yarn cache dir'
|
||||||
|
: 'yarn config get cacheFolder',
|
||||||
|
'/tmp/dir3'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
it.each(['1.1.1', '2.2.2'])(
|
||||||
|
'getCacheDirectoriesPaths yarn v%s should return 4 dirs with multiple globs',
|
||||||
|
async version => {
|
||||||
|
// simulate wrong indents
|
||||||
|
const cacheDependencyPath = `/tmp/dir1/file
|
||||||
|
/tmp/dir2/file
|
||||||
|
/tmp/**/file
|
||||||
|
`;
|
||||||
|
globCreateSpy.mockImplementation(
|
||||||
|
(pattern: string): Promise<Globber> =>
|
||||||
|
MockGlobber.create([
|
||||||
|
'/tmp/dir1/file',
|
||||||
|
'/tmp/dir2/file',
|
||||||
|
'/tmp/dir3/file',
|
||||||
|
'/tmp/dir4/file'
|
||||||
|
])
|
||||||
|
);
|
||||||
|
let dirNo = 1;
|
||||||
|
getCommandOutputSpy.mockImplementation((command: string) =>
|
||||||
|
command.includes('version') ? version : `file_${version}_${dirNo++}`
|
||||||
|
);
|
||||||
|
const dirs = await cacheUtils.getCacheDirectories(
|
||||||
|
supportedPackageManagers.yarn,
|
||||||
|
cacheDependencyPath
|
||||||
|
);
|
||||||
|
expect(dirs).toEqual([
|
||||||
|
`file_${version}_1`,
|
||||||
|
`file_${version}_2`,
|
||||||
|
`file_${version}_3`,
|
||||||
|
`file_${version}_4`
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
18
__tests__/mock/glob-mock.test.ts
Normal file
18
__tests__/mock/glob-mock.test.ts
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
import {MockGlobber} from './glob-mock';
|
||||||
|
|
||||||
|
describe('mocked globber tests', () => {
|
||||||
|
it('globber should return generator', async () => {
|
||||||
|
const globber = new MockGlobber(['aaa', 'bbb', 'ccc']);
|
||||||
|
const generator = globber.globGenerator();
|
||||||
|
const result: string[] = [];
|
||||||
|
for await (const itemPath of generator) {
|
||||||
|
result.push(itemPath);
|
||||||
|
}
|
||||||
|
expect(result).toEqual(['aaa', 'bbb', 'ccc']);
|
||||||
|
});
|
||||||
|
it('globber should return glob', async () => {
|
||||||
|
const globber = new MockGlobber(['aaa', 'bbb', 'ccc']);
|
||||||
|
const result: string[] = await globber.glob();
|
||||||
|
expect(result).toEqual(['aaa', 'bbb', 'ccc']);
|
||||||
|
});
|
||||||
|
});
|
||||||
29
__tests__/mock/glob-mock.ts
Normal file
29
__tests__/mock/glob-mock.ts
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
import {Globber} from '@actions/glob';
|
||||||
|
|
||||||
|
export class MockGlobber implements Globber {
|
||||||
|
private readonly expected: string[];
|
||||||
|
constructor(expected: string[]) {
|
||||||
|
this.expected = expected;
|
||||||
|
}
|
||||||
|
getSearchPaths(): string[] {
|
||||||
|
return this.expected.slice();
|
||||||
|
}
|
||||||
|
|
||||||
|
async glob(): Promise<string[]> {
|
||||||
|
const result: string[] = [];
|
||||||
|
for await (const itemPath of this.globGenerator()) {
|
||||||
|
result.push(itemPath);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
async *globGenerator(): AsyncGenerator<string, void> {
|
||||||
|
for (const e of this.expected) {
|
||||||
|
yield e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static async create(expected: string[]): Promise<MockGlobber> {
|
||||||
|
return new MockGlobber(expected);
|
||||||
|
}
|
||||||
|
}
|
||||||
48
__tests__/prepare-subprojects.sh
Executable file
48
__tests__/prepare-subprojects.sh
Executable file
@ -0,0 +1,48 @@
|
|||||||
|
#!/bin/sh -e
|
||||||
|
export YARN_ENABLE_IMMUTABLE_INSTALLS=false
|
||||||
|
rm package.json
|
||||||
|
rm package-lock.json
|
||||||
|
echo "create yarn2 project in the sub2"
|
||||||
|
mkdir sub2
|
||||||
|
cd sub2
|
||||||
|
cat <<EOT >package.json
|
||||||
|
{
|
||||||
|
"name": "subproject",
|
||||||
|
"dependencies": {
|
||||||
|
"random": "^3.0.6",
|
||||||
|
"uuid": "^9.0.0"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
EOT
|
||||||
|
yarn set version 2.4.3
|
||||||
|
yarn install
|
||||||
|
|
||||||
|
echo "create yarn3 project in the sub3"
|
||||||
|
cd ..
|
||||||
|
mkdir sub3
|
||||||
|
cd sub3
|
||||||
|
cat <<EOT >package.json
|
||||||
|
{
|
||||||
|
"name": "subproject",
|
||||||
|
"dependencies": {
|
||||||
|
"random": "^3.0.6",
|
||||||
|
"uuid": "^9.0.0"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
EOT
|
||||||
|
yarn set version 3.5.1
|
||||||
|
yarn install
|
||||||
|
|
||||||
|
echo "create yarn1 project in the root"
|
||||||
|
cd ..
|
||||||
|
cat <<EOT >package.json
|
||||||
|
{
|
||||||
|
"name": "subproject",
|
||||||
|
"dependencies": {
|
||||||
|
"random": "^3.0.6",
|
||||||
|
"uuid": "^9.0.0"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
EOT
|
||||||
|
yarn set version 1.22.19
|
||||||
|
yarn install
|
||||||
@ -25,7 +25,7 @@ inputs:
|
|||||||
description: 'Used to specify a package manager for caching in the default directory. Supported values: npm, yarn, pnpm.'
|
description: 'Used to specify a package manager for caching in the default directory. Supported values: npm, yarn, pnpm.'
|
||||||
cache-dependency-path:
|
cache-dependency-path:
|
||||||
description: 'Used to specify the path to a dependency file: package-lock.json, yarn.lock, etc. Supports wildcards or a list of file names for caching multiple dependencies.'
|
description: 'Used to specify the path to a dependency file: package-lock.json, yarn.lock, etc. Supports wildcards or a list of file names for caching multiple dependencies.'
|
||||||
# TODO: add input to control forcing to pull from cloud or dist.
|
# TODO: add input to control forcing to pull from cloud or dist.
|
||||||
# escape valve for someone having issues or needing the absolute latest which isn't cached yet
|
# escape valve for someone having issues or needing the absolute latest which isn't cached yet
|
||||||
outputs:
|
outputs:
|
||||||
cache-hit:
|
cache-hit:
|
||||||
|
|||||||
1792
dist/cache-save/index.js
vendored
1792
dist/cache-save/index.js
vendored
@ -6480,6 +6480,1193 @@ class ExecState extends events.EventEmitter {
|
|||||||
|
|
||||||
/***/ }),
|
/***/ }),
|
||||||
|
|
||||||
|
/***/ 8090:
|
||||||
|
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
||||||
|
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||||
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||||
|
return new (P || (P = Promise))(function (resolve, reject) {
|
||||||
|
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 step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||||||
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||||
|
});
|
||||||
|
};
|
||||||
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||||
|
exports.hashFiles = exports.create = void 0;
|
||||||
|
const internal_globber_1 = __nccwpck_require__(8298);
|
||||||
|
const internal_hash_files_1 = __nccwpck_require__(2448);
|
||||||
|
/**
|
||||||
|
* Constructs a globber
|
||||||
|
*
|
||||||
|
* @param patterns Patterns separated by newlines
|
||||||
|
* @param options Glob options
|
||||||
|
*/
|
||||||
|
function create(patterns, options) {
|
||||||
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
|
return yield internal_globber_1.DefaultGlobber.create(patterns, options);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
exports.create = create;
|
||||||
|
/**
|
||||||
|
* Computes the sha256 hash of a glob
|
||||||
|
*
|
||||||
|
* @param patterns Patterns separated by newlines
|
||||||
|
* @param options Glob options
|
||||||
|
*/
|
||||||
|
function hashFiles(patterns, options) {
|
||||||
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
|
let followSymbolicLinks = true;
|
||||||
|
if (options && typeof options.followSymbolicLinks === 'boolean') {
|
||||||
|
followSymbolicLinks = options.followSymbolicLinks;
|
||||||
|
}
|
||||||
|
const globber = yield create(patterns, { followSymbolicLinks });
|
||||||
|
return internal_hash_files_1.hashFiles(globber);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
exports.hashFiles = hashFiles;
|
||||||
|
//# sourceMappingURL=glob.js.map
|
||||||
|
|
||||||
|
/***/ }),
|
||||||
|
|
||||||
|
/***/ 1026:
|
||||||
|
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
||||||
|
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||||
|
if (k2 === undefined) k2 = k;
|
||||||
|
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
||||||
|
}) : (function(o, m, k, k2) {
|
||||||
|
if (k2 === undefined) k2 = k;
|
||||||
|
o[k2] = m[k];
|
||||||
|
}));
|
||||||
|
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||||
|
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||||
|
}) : function(o, v) {
|
||||||
|
o["default"] = v;
|
||||||
|
});
|
||||||
|
var __importStar = (this && this.__importStar) || function (mod) {
|
||||||
|
if (mod && mod.__esModule) return mod;
|
||||||
|
var result = {};
|
||||||
|
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||||
|
__setModuleDefault(result, mod);
|
||||||
|
return result;
|
||||||
|
};
|
||||||
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||||
|
exports.getOptions = void 0;
|
||||||
|
const core = __importStar(__nccwpck_require__(2186));
|
||||||
|
/**
|
||||||
|
* Returns a copy with defaults filled in.
|
||||||
|
*/
|
||||||
|
function getOptions(copy) {
|
||||||
|
const result = {
|
||||||
|
followSymbolicLinks: true,
|
||||||
|
implicitDescendants: true,
|
||||||
|
matchDirectories: true,
|
||||||
|
omitBrokenSymbolicLinks: true
|
||||||
|
};
|
||||||
|
if (copy) {
|
||||||
|
if (typeof copy.followSymbolicLinks === 'boolean') {
|
||||||
|
result.followSymbolicLinks = copy.followSymbolicLinks;
|
||||||
|
core.debug(`followSymbolicLinks '${result.followSymbolicLinks}'`);
|
||||||
|
}
|
||||||
|
if (typeof copy.implicitDescendants === 'boolean') {
|
||||||
|
result.implicitDescendants = copy.implicitDescendants;
|
||||||
|
core.debug(`implicitDescendants '${result.implicitDescendants}'`);
|
||||||
|
}
|
||||||
|
if (typeof copy.matchDirectories === 'boolean') {
|
||||||
|
result.matchDirectories = copy.matchDirectories;
|
||||||
|
core.debug(`matchDirectories '${result.matchDirectories}'`);
|
||||||
|
}
|
||||||
|
if (typeof copy.omitBrokenSymbolicLinks === 'boolean') {
|
||||||
|
result.omitBrokenSymbolicLinks = copy.omitBrokenSymbolicLinks;
|
||||||
|
core.debug(`omitBrokenSymbolicLinks '${result.omitBrokenSymbolicLinks}'`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
exports.getOptions = getOptions;
|
||||||
|
//# sourceMappingURL=internal-glob-options-helper.js.map
|
||||||
|
|
||||||
|
/***/ }),
|
||||||
|
|
||||||
|
/***/ 8298:
|
||||||
|
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
||||||
|
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||||
|
if (k2 === undefined) k2 = k;
|
||||||
|
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
||||||
|
}) : (function(o, m, k, k2) {
|
||||||
|
if (k2 === undefined) k2 = k;
|
||||||
|
o[k2] = m[k];
|
||||||
|
}));
|
||||||
|
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||||
|
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||||
|
}) : function(o, v) {
|
||||||
|
o["default"] = v;
|
||||||
|
});
|
||||||
|
var __importStar = (this && this.__importStar) || function (mod) {
|
||||||
|
if (mod && mod.__esModule) return mod;
|
||||||
|
var result = {};
|
||||||
|
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||||
|
__setModuleDefault(result, mod);
|
||||||
|
return result;
|
||||||
|
};
|
||||||
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||||
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||||
|
return new (P || (P = Promise))(function (resolve, reject) {
|
||||||
|
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 step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||||||
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||||
|
});
|
||||||
|
};
|
||||||
|
var __asyncValues = (this && this.__asyncValues) || function (o) {
|
||||||
|
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
||||||
|
var m = o[Symbol.asyncIterator], i;
|
||||||
|
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);
|
||||||
|
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); }); }; }
|
||||||
|
function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
|
||||||
|
};
|
||||||
|
var __await = (this && this.__await) || function (v) { return this instanceof __await ? (this.v = v, this) : new __await(v); }
|
||||||
|
var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) {
|
||||||
|
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
||||||
|
var g = generator.apply(thisArg, _arguments || []), i, q = [];
|
||||||
|
return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
|
||||||
|
function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
|
||||||
|
function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
|
||||||
|
function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
|
||||||
|
function fulfill(value) { resume("next", value); }
|
||||||
|
function reject(value) { resume("throw", value); }
|
||||||
|
function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
|
||||||
|
};
|
||||||
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||||
|
exports.DefaultGlobber = void 0;
|
||||||
|
const core = __importStar(__nccwpck_require__(2186));
|
||||||
|
const fs = __importStar(__nccwpck_require__(7147));
|
||||||
|
const globOptionsHelper = __importStar(__nccwpck_require__(1026));
|
||||||
|
const path = __importStar(__nccwpck_require__(1017));
|
||||||
|
const patternHelper = __importStar(__nccwpck_require__(9005));
|
||||||
|
const internal_match_kind_1 = __nccwpck_require__(1063);
|
||||||
|
const internal_pattern_1 = __nccwpck_require__(4536);
|
||||||
|
const internal_search_state_1 = __nccwpck_require__(9117);
|
||||||
|
const IS_WINDOWS = process.platform === 'win32';
|
||||||
|
class DefaultGlobber {
|
||||||
|
constructor(options) {
|
||||||
|
this.patterns = [];
|
||||||
|
this.searchPaths = [];
|
||||||
|
this.options = globOptionsHelper.getOptions(options);
|
||||||
|
}
|
||||||
|
getSearchPaths() {
|
||||||
|
// Return a copy
|
||||||
|
return this.searchPaths.slice();
|
||||||
|
}
|
||||||
|
glob() {
|
||||||
|
var e_1, _a;
|
||||||
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
|
const result = [];
|
||||||
|
try {
|
||||||
|
for (var _b = __asyncValues(this.globGenerator()), _c; _c = yield _b.next(), !_c.done;) {
|
||||||
|
const itemPath = _c.value;
|
||||||
|
result.push(itemPath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
||||||
|
finally {
|
||||||
|
try {
|
||||||
|
if (_c && !_c.done && (_a = _b.return)) yield _a.call(_b);
|
||||||
|
}
|
||||||
|
finally { if (e_1) throw e_1.error; }
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
globGenerator() {
|
||||||
|
return __asyncGenerator(this, arguments, function* globGenerator_1() {
|
||||||
|
// Fill in defaults options
|
||||||
|
const options = globOptionsHelper.getOptions(this.options);
|
||||||
|
// Implicit descendants?
|
||||||
|
const patterns = [];
|
||||||
|
for (const pattern of this.patterns) {
|
||||||
|
patterns.push(pattern);
|
||||||
|
if (options.implicitDescendants &&
|
||||||
|
(pattern.trailingSeparator ||
|
||||||
|
pattern.segments[pattern.segments.length - 1] !== '**')) {
|
||||||
|
patterns.push(new internal_pattern_1.Pattern(pattern.negate, true, pattern.segments.concat('**')));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Push the search paths
|
||||||
|
const stack = [];
|
||||||
|
for (const searchPath of patternHelper.getSearchPaths(patterns)) {
|
||||||
|
core.debug(`Search path '${searchPath}'`);
|
||||||
|
// Exists?
|
||||||
|
try {
|
||||||
|
// Intentionally using lstat. Detection for broken symlink
|
||||||
|
// will be performed later (if following symlinks).
|
||||||
|
yield __await(fs.promises.lstat(searchPath));
|
||||||
|
}
|
||||||
|
catch (err) {
|
||||||
|
if (err.code === 'ENOENT') {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
throw err;
|
||||||
|
}
|
||||||
|
stack.unshift(new internal_search_state_1.SearchState(searchPath, 1));
|
||||||
|
}
|
||||||
|
// Search
|
||||||
|
const traversalChain = []; // used to detect cycles
|
||||||
|
while (stack.length) {
|
||||||
|
// Pop
|
||||||
|
const item = stack.pop();
|
||||||
|
// Match?
|
||||||
|
const match = patternHelper.match(patterns, item.path);
|
||||||
|
const partialMatch = !!match || patternHelper.partialMatch(patterns, item.path);
|
||||||
|
if (!match && !partialMatch) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
// Stat
|
||||||
|
const stats = yield __await(DefaultGlobber.stat(item, options, traversalChain)
|
||||||
|
// Broken symlink, or symlink cycle detected, or no longer exists
|
||||||
|
);
|
||||||
|
// Broken symlink, or symlink cycle detected, or no longer exists
|
||||||
|
if (!stats) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
// Directory
|
||||||
|
if (stats.isDirectory()) {
|
||||||
|
// Matched
|
||||||
|
if (match & internal_match_kind_1.MatchKind.Directory && options.matchDirectories) {
|
||||||
|
yield yield __await(item.path);
|
||||||
|
}
|
||||||
|
// Descend?
|
||||||
|
else if (!partialMatch) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
// Push the child items in reverse
|
||||||
|
const childLevel = item.level + 1;
|
||||||
|
const childItems = (yield __await(fs.promises.readdir(item.path))).map(x => new internal_search_state_1.SearchState(path.join(item.path, x), childLevel));
|
||||||
|
stack.push(...childItems.reverse());
|
||||||
|
}
|
||||||
|
// File
|
||||||
|
else if (match & internal_match_kind_1.MatchKind.File) {
|
||||||
|
yield yield __await(item.path);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Constructs a DefaultGlobber
|
||||||
|
*/
|
||||||
|
static create(patterns, options) {
|
||||||
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
|
const result = new DefaultGlobber(options);
|
||||||
|
if (IS_WINDOWS) {
|
||||||
|
patterns = patterns.replace(/\r\n/g, '\n');
|
||||||
|
patterns = patterns.replace(/\r/g, '\n');
|
||||||
|
}
|
||||||
|
const lines = patterns.split('\n').map(x => x.trim());
|
||||||
|
for (const line of lines) {
|
||||||
|
// Empty or comment
|
||||||
|
if (!line || line.startsWith('#')) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
// Pattern
|
||||||
|
else {
|
||||||
|
result.patterns.push(new internal_pattern_1.Pattern(line));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
result.searchPaths.push(...patternHelper.getSearchPaths(result.patterns));
|
||||||
|
return result;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
static stat(item, options, traversalChain) {
|
||||||
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
|
// Note:
|
||||||
|
// `stat` returns info about the target of a symlink (or symlink chain)
|
||||||
|
// `lstat` returns info about a symlink itself
|
||||||
|
let stats;
|
||||||
|
if (options.followSymbolicLinks) {
|
||||||
|
try {
|
||||||
|
// Use `stat` (following symlinks)
|
||||||
|
stats = yield fs.promises.stat(item.path);
|
||||||
|
}
|
||||||
|
catch (err) {
|
||||||
|
if (err.code === 'ENOENT') {
|
||||||
|
if (options.omitBrokenSymbolicLinks) {
|
||||||
|
core.debug(`Broken symlink '${item.path}'`);
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
throw new Error(`No information found for the path '${item.path}'. This may indicate a broken symbolic link.`);
|
||||||
|
}
|
||||||
|
throw err;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// Use `lstat` (not following symlinks)
|
||||||
|
stats = yield fs.promises.lstat(item.path);
|
||||||
|
}
|
||||||
|
// Note, isDirectory() returns false for the lstat of a symlink
|
||||||
|
if (stats.isDirectory() && options.followSymbolicLinks) {
|
||||||
|
// Get the realpath
|
||||||
|
const realPath = yield fs.promises.realpath(item.path);
|
||||||
|
// Fixup the traversal chain to match the item level
|
||||||
|
while (traversalChain.length >= item.level) {
|
||||||
|
traversalChain.pop();
|
||||||
|
}
|
||||||
|
// Test for a cycle
|
||||||
|
if (traversalChain.some((x) => x === realPath)) {
|
||||||
|
core.debug(`Symlink cycle detected for path '${item.path}' and realpath '${realPath}'`);
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
// Update the traversal chain
|
||||||
|
traversalChain.push(realPath);
|
||||||
|
}
|
||||||
|
return stats;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
exports.DefaultGlobber = DefaultGlobber;
|
||||||
|
//# sourceMappingURL=internal-globber.js.map
|
||||||
|
|
||||||
|
/***/ }),
|
||||||
|
|
||||||
|
/***/ 2448:
|
||||||
|
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
||||||
|
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||||
|
if (k2 === undefined) k2 = k;
|
||||||
|
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
||||||
|
}) : (function(o, m, k, k2) {
|
||||||
|
if (k2 === undefined) k2 = k;
|
||||||
|
o[k2] = m[k];
|
||||||
|
}));
|
||||||
|
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||||
|
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||||
|
}) : function(o, v) {
|
||||||
|
o["default"] = v;
|
||||||
|
});
|
||||||
|
var __importStar = (this && this.__importStar) || function (mod) {
|
||||||
|
if (mod && mod.__esModule) return mod;
|
||||||
|
var result = {};
|
||||||
|
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||||
|
__setModuleDefault(result, mod);
|
||||||
|
return result;
|
||||||
|
};
|
||||||
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||||
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||||
|
return new (P || (P = Promise))(function (resolve, reject) {
|
||||||
|
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 step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||||||
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||||
|
});
|
||||||
|
};
|
||||||
|
var __asyncValues = (this && this.__asyncValues) || function (o) {
|
||||||
|
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
||||||
|
var m = o[Symbol.asyncIterator], i;
|
||||||
|
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);
|
||||||
|
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); }); }; }
|
||||||
|
function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
|
||||||
|
};
|
||||||
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||||
|
exports.hashFiles = void 0;
|
||||||
|
const crypto = __importStar(__nccwpck_require__(6113));
|
||||||
|
const core = __importStar(__nccwpck_require__(2186));
|
||||||
|
const fs = __importStar(__nccwpck_require__(7147));
|
||||||
|
const stream = __importStar(__nccwpck_require__(2781));
|
||||||
|
const util = __importStar(__nccwpck_require__(3837));
|
||||||
|
const path = __importStar(__nccwpck_require__(1017));
|
||||||
|
function hashFiles(globber) {
|
||||||
|
var e_1, _a;
|
||||||
|
var _b;
|
||||||
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
|
let hasMatch = false;
|
||||||
|
const githubWorkspace = (_b = process.env['GITHUB_WORKSPACE']) !== null && _b !== void 0 ? _b : process.cwd();
|
||||||
|
const result = crypto.createHash('sha256');
|
||||||
|
let count = 0;
|
||||||
|
try {
|
||||||
|
for (var _c = __asyncValues(globber.globGenerator()), _d; _d = yield _c.next(), !_d.done;) {
|
||||||
|
const file = _d.value;
|
||||||
|
core.debug(file);
|
||||||
|
if (!file.startsWith(`${githubWorkspace}${path.sep}`)) {
|
||||||
|
core.debug(`Ignore '${file}' since it is not under GITHUB_WORKSPACE.`);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (fs.statSync(file).isDirectory()) {
|
||||||
|
core.debug(`Skip directory '${file}'.`);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
const hash = crypto.createHash('sha256');
|
||||||
|
const pipeline = util.promisify(stream.pipeline);
|
||||||
|
yield pipeline(fs.createReadStream(file), hash);
|
||||||
|
result.write(hash.digest());
|
||||||
|
count++;
|
||||||
|
if (!hasMatch) {
|
||||||
|
hasMatch = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
||||||
|
finally {
|
||||||
|
try {
|
||||||
|
if (_d && !_d.done && (_a = _c.return)) yield _a.call(_c);
|
||||||
|
}
|
||||||
|
finally { if (e_1) throw e_1.error; }
|
||||||
|
}
|
||||||
|
result.end();
|
||||||
|
if (hasMatch) {
|
||||||
|
core.debug(`Found ${count} files to hash.`);
|
||||||
|
return result.digest('hex');
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
core.debug(`No matches found for glob`);
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
exports.hashFiles = hashFiles;
|
||||||
|
//# sourceMappingURL=internal-hash-files.js.map
|
||||||
|
|
||||||
|
/***/ }),
|
||||||
|
|
||||||
|
/***/ 1063:
|
||||||
|
/***/ ((__unused_webpack_module, exports) => {
|
||||||
|
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||||
|
exports.MatchKind = void 0;
|
||||||
|
/**
|
||||||
|
* Indicates whether a pattern matches a path
|
||||||
|
*/
|
||||||
|
var MatchKind;
|
||||||
|
(function (MatchKind) {
|
||||||
|
/** Not matched */
|
||||||
|
MatchKind[MatchKind["None"] = 0] = "None";
|
||||||
|
/** Matched if the path is a directory */
|
||||||
|
MatchKind[MatchKind["Directory"] = 1] = "Directory";
|
||||||
|
/** Matched if the path is a regular file */
|
||||||
|
MatchKind[MatchKind["File"] = 2] = "File";
|
||||||
|
/** Matched */
|
||||||
|
MatchKind[MatchKind["All"] = 3] = "All";
|
||||||
|
})(MatchKind = exports.MatchKind || (exports.MatchKind = {}));
|
||||||
|
//# sourceMappingURL=internal-match-kind.js.map
|
||||||
|
|
||||||
|
/***/ }),
|
||||||
|
|
||||||
|
/***/ 1849:
|
||||||
|
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
||||||
|
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||||
|
if (k2 === undefined) k2 = k;
|
||||||
|
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
||||||
|
}) : (function(o, m, k, k2) {
|
||||||
|
if (k2 === undefined) k2 = k;
|
||||||
|
o[k2] = m[k];
|
||||||
|
}));
|
||||||
|
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||||
|
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||||
|
}) : function(o, v) {
|
||||||
|
o["default"] = v;
|
||||||
|
});
|
||||||
|
var __importStar = (this && this.__importStar) || function (mod) {
|
||||||
|
if (mod && mod.__esModule) return mod;
|
||||||
|
var result = {};
|
||||||
|
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||||
|
__setModuleDefault(result, mod);
|
||||||
|
return result;
|
||||||
|
};
|
||||||
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||||
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||||
|
};
|
||||||
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||||
|
exports.safeTrimTrailingSeparator = exports.normalizeSeparators = exports.hasRoot = exports.hasAbsoluteRoot = exports.ensureAbsoluteRoot = exports.dirname = void 0;
|
||||||
|
const path = __importStar(__nccwpck_require__(1017));
|
||||||
|
const assert_1 = __importDefault(__nccwpck_require__(9491));
|
||||||
|
const IS_WINDOWS = process.platform === 'win32';
|
||||||
|
/**
|
||||||
|
* Similar to path.dirname except normalizes the path separators and slightly better handling for Windows UNC paths.
|
||||||
|
*
|
||||||
|
* For example, on Linux/macOS:
|
||||||
|
* - `/ => /`
|
||||||
|
* - `/hello => /`
|
||||||
|
*
|
||||||
|
* For example, on Windows:
|
||||||
|
* - `C:\ => C:\`
|
||||||
|
* - `C:\hello => C:\`
|
||||||
|
* - `C: => C:`
|
||||||
|
* - `C:hello => C:`
|
||||||
|
* - `\ => \`
|
||||||
|
* - `\hello => \`
|
||||||
|
* - `\\hello => \\hello`
|
||||||
|
* - `\\hello\world => \\hello\world`
|
||||||
|
*/
|
||||||
|
function dirname(p) {
|
||||||
|
// Normalize slashes and trim unnecessary trailing slash
|
||||||
|
p = safeTrimTrailingSeparator(p);
|
||||||
|
// Windows UNC root, e.g. \\hello or \\hello\world
|
||||||
|
if (IS_WINDOWS && /^\\\\[^\\]+(\\[^\\]+)?$/.test(p)) {
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
// Get dirname
|
||||||
|
let result = path.dirname(p);
|
||||||
|
// Trim trailing slash for Windows UNC root, e.g. \\hello\world\
|
||||||
|
if (IS_WINDOWS && /^\\\\[^\\]+\\[^\\]+\\$/.test(result)) {
|
||||||
|
result = safeTrimTrailingSeparator(result);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
exports.dirname = dirname;
|
||||||
|
/**
|
||||||
|
* Roots the path if not already rooted. On Windows, relative roots like `\`
|
||||||
|
* or `C:` are expanded based on the current working directory.
|
||||||
|
*/
|
||||||
|
function ensureAbsoluteRoot(root, itemPath) {
|
||||||
|
assert_1.default(root, `ensureAbsoluteRoot parameter 'root' must not be empty`);
|
||||||
|
assert_1.default(itemPath, `ensureAbsoluteRoot parameter 'itemPath' must not be empty`);
|
||||||
|
// Already rooted
|
||||||
|
if (hasAbsoluteRoot(itemPath)) {
|
||||||
|
return itemPath;
|
||||||
|
}
|
||||||
|
// Windows
|
||||||
|
if (IS_WINDOWS) {
|
||||||
|
// Check for itemPath like C: or C:foo
|
||||||
|
if (itemPath.match(/^[A-Z]:[^\\/]|^[A-Z]:$/i)) {
|
||||||
|
let cwd = process.cwd();
|
||||||
|
assert_1.default(cwd.match(/^[A-Z]:\\/i), `Expected current directory to start with an absolute drive root. Actual '${cwd}'`);
|
||||||
|
// Drive letter matches cwd? Expand to cwd
|
||||||
|
if (itemPath[0].toUpperCase() === cwd[0].toUpperCase()) {
|
||||||
|
// Drive only, e.g. C:
|
||||||
|
if (itemPath.length === 2) {
|
||||||
|
// Preserve specified drive letter case (upper or lower)
|
||||||
|
return `${itemPath[0]}:\\${cwd.substr(3)}`;
|
||||||
|
}
|
||||||
|
// Drive + path, e.g. C:foo
|
||||||
|
else {
|
||||||
|
if (!cwd.endsWith('\\')) {
|
||||||
|
cwd += '\\';
|
||||||
|
}
|
||||||
|
// Preserve specified drive letter case (upper or lower)
|
||||||
|
return `${itemPath[0]}:\\${cwd.substr(3)}${itemPath.substr(2)}`;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Different drive
|
||||||
|
else {
|
||||||
|
return `${itemPath[0]}:\\${itemPath.substr(2)}`;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Check for itemPath like \ or \foo
|
||||||
|
else if (normalizeSeparators(itemPath).match(/^\\$|^\\[^\\]/)) {
|
||||||
|
const cwd = process.cwd();
|
||||||
|
assert_1.default(cwd.match(/^[A-Z]:\\/i), `Expected current directory to start with an absolute drive root. Actual '${cwd}'`);
|
||||||
|
return `${cwd[0]}:\\${itemPath.substr(1)}`;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
assert_1.default(hasAbsoluteRoot(root), `ensureAbsoluteRoot parameter 'root' must have an absolute root`);
|
||||||
|
// Otherwise ensure root ends with a separator
|
||||||
|
if (root.endsWith('/') || (IS_WINDOWS && root.endsWith('\\'))) {
|
||||||
|
// Intentionally empty
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// Append separator
|
||||||
|
root += path.sep;
|
||||||
|
}
|
||||||
|
return root + itemPath;
|
||||||
|
}
|
||||||
|
exports.ensureAbsoluteRoot = ensureAbsoluteRoot;
|
||||||
|
/**
|
||||||
|
* On Linux/macOS, true if path starts with `/`. On Windows, true for paths like:
|
||||||
|
* `\\hello\share` and `C:\hello` (and using alternate separator).
|
||||||
|
*/
|
||||||
|
function hasAbsoluteRoot(itemPath) {
|
||||||
|
assert_1.default(itemPath, `hasAbsoluteRoot parameter 'itemPath' must not be empty`);
|
||||||
|
// Normalize separators
|
||||||
|
itemPath = normalizeSeparators(itemPath);
|
||||||
|
// Windows
|
||||||
|
if (IS_WINDOWS) {
|
||||||
|
// E.g. \\hello\share or C:\hello
|
||||||
|
return itemPath.startsWith('\\\\') || /^[A-Z]:\\/i.test(itemPath);
|
||||||
|
}
|
||||||
|
// E.g. /hello
|
||||||
|
return itemPath.startsWith('/');
|
||||||
|
}
|
||||||
|
exports.hasAbsoluteRoot = hasAbsoluteRoot;
|
||||||
|
/**
|
||||||
|
* On Linux/macOS, true if path starts with `/`. On Windows, true for paths like:
|
||||||
|
* `\`, `\hello`, `\\hello\share`, `C:`, and `C:\hello` (and using alternate separator).
|
||||||
|
*/
|
||||||
|
function hasRoot(itemPath) {
|
||||||
|
assert_1.default(itemPath, `isRooted parameter 'itemPath' must not be empty`);
|
||||||
|
// Normalize separators
|
||||||
|
itemPath = normalizeSeparators(itemPath);
|
||||||
|
// Windows
|
||||||
|
if (IS_WINDOWS) {
|
||||||
|
// E.g. \ or \hello or \\hello
|
||||||
|
// E.g. C: or C:\hello
|
||||||
|
return itemPath.startsWith('\\') || /^[A-Z]:/i.test(itemPath);
|
||||||
|
}
|
||||||
|
// E.g. /hello
|
||||||
|
return itemPath.startsWith('/');
|
||||||
|
}
|
||||||
|
exports.hasRoot = hasRoot;
|
||||||
|
/**
|
||||||
|
* Removes redundant slashes and converts `/` to `\` on Windows
|
||||||
|
*/
|
||||||
|
function normalizeSeparators(p) {
|
||||||
|
p = p || '';
|
||||||
|
// Windows
|
||||||
|
if (IS_WINDOWS) {
|
||||||
|
// Convert slashes on Windows
|
||||||
|
p = p.replace(/\//g, '\\');
|
||||||
|
// Remove redundant slashes
|
||||||
|
const isUnc = /^\\\\+[^\\]/.test(p); // e.g. \\hello
|
||||||
|
return (isUnc ? '\\' : '') + p.replace(/\\\\+/g, '\\'); // preserve leading \\ for UNC
|
||||||
|
}
|
||||||
|
// Remove redundant slashes
|
||||||
|
return p.replace(/\/\/+/g, '/');
|
||||||
|
}
|
||||||
|
exports.normalizeSeparators = normalizeSeparators;
|
||||||
|
/**
|
||||||
|
* Normalizes the path separators and trims the trailing separator (when safe).
|
||||||
|
* For example, `/foo/ => /foo` but `/ => /`
|
||||||
|
*/
|
||||||
|
function safeTrimTrailingSeparator(p) {
|
||||||
|
// Short-circuit if empty
|
||||||
|
if (!p) {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
// Normalize separators
|
||||||
|
p = normalizeSeparators(p);
|
||||||
|
// No trailing slash
|
||||||
|
if (!p.endsWith(path.sep)) {
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
// Check '/' on Linux/macOS and '\' on Windows
|
||||||
|
if (p === path.sep) {
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
// On Windows check if drive root. E.g. C:\
|
||||||
|
if (IS_WINDOWS && /^[A-Z]:\\$/i.test(p)) {
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
// Otherwise trim trailing slash
|
||||||
|
return p.substr(0, p.length - 1);
|
||||||
|
}
|
||||||
|
exports.safeTrimTrailingSeparator = safeTrimTrailingSeparator;
|
||||||
|
//# sourceMappingURL=internal-path-helper.js.map
|
||||||
|
|
||||||
|
/***/ }),
|
||||||
|
|
||||||
|
/***/ 6836:
|
||||||
|
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
||||||
|
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||||
|
if (k2 === undefined) k2 = k;
|
||||||
|
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
||||||
|
}) : (function(o, m, k, k2) {
|
||||||
|
if (k2 === undefined) k2 = k;
|
||||||
|
o[k2] = m[k];
|
||||||
|
}));
|
||||||
|
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||||
|
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||||
|
}) : function(o, v) {
|
||||||
|
o["default"] = v;
|
||||||
|
});
|
||||||
|
var __importStar = (this && this.__importStar) || function (mod) {
|
||||||
|
if (mod && mod.__esModule) return mod;
|
||||||
|
var result = {};
|
||||||
|
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||||
|
__setModuleDefault(result, mod);
|
||||||
|
return result;
|
||||||
|
};
|
||||||
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||||
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||||
|
};
|
||||||
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||||
|
exports.Path = void 0;
|
||||||
|
const path = __importStar(__nccwpck_require__(1017));
|
||||||
|
const pathHelper = __importStar(__nccwpck_require__(1849));
|
||||||
|
const assert_1 = __importDefault(__nccwpck_require__(9491));
|
||||||
|
const IS_WINDOWS = process.platform === 'win32';
|
||||||
|
/**
|
||||||
|
* Helper class for parsing paths into segments
|
||||||
|
*/
|
||||||
|
class Path {
|
||||||
|
/**
|
||||||
|
* Constructs a Path
|
||||||
|
* @param itemPath Path or array of segments
|
||||||
|
*/
|
||||||
|
constructor(itemPath) {
|
||||||
|
this.segments = [];
|
||||||
|
// String
|
||||||
|
if (typeof itemPath === 'string') {
|
||||||
|
assert_1.default(itemPath, `Parameter 'itemPath' must not be empty`);
|
||||||
|
// Normalize slashes and trim unnecessary trailing slash
|
||||||
|
itemPath = pathHelper.safeTrimTrailingSeparator(itemPath);
|
||||||
|
// Not rooted
|
||||||
|
if (!pathHelper.hasRoot(itemPath)) {
|
||||||
|
this.segments = itemPath.split(path.sep);
|
||||||
|
}
|
||||||
|
// Rooted
|
||||||
|
else {
|
||||||
|
// Add all segments, while not at the root
|
||||||
|
let remaining = itemPath;
|
||||||
|
let dir = pathHelper.dirname(remaining);
|
||||||
|
while (dir !== remaining) {
|
||||||
|
// Add the segment
|
||||||
|
const basename = path.basename(remaining);
|
||||||
|
this.segments.unshift(basename);
|
||||||
|
// Truncate the last segment
|
||||||
|
remaining = dir;
|
||||||
|
dir = pathHelper.dirname(remaining);
|
||||||
|
}
|
||||||
|
// Remainder is the root
|
||||||
|
this.segments.unshift(remaining);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Array
|
||||||
|
else {
|
||||||
|
// Must not be empty
|
||||||
|
assert_1.default(itemPath.length > 0, `Parameter 'itemPath' must not be an empty array`);
|
||||||
|
// Each segment
|
||||||
|
for (let i = 0; i < itemPath.length; i++) {
|
||||||
|
let segment = itemPath[i];
|
||||||
|
// Must not be empty
|
||||||
|
assert_1.default(segment, `Parameter 'itemPath' must not contain any empty segments`);
|
||||||
|
// Normalize slashes
|
||||||
|
segment = pathHelper.normalizeSeparators(itemPath[i]);
|
||||||
|
// Root segment
|
||||||
|
if (i === 0 && pathHelper.hasRoot(segment)) {
|
||||||
|
segment = pathHelper.safeTrimTrailingSeparator(segment);
|
||||||
|
assert_1.default(segment === pathHelper.dirname(segment), `Parameter 'itemPath' root segment contains information for multiple segments`);
|
||||||
|
this.segments.push(segment);
|
||||||
|
}
|
||||||
|
// All other segments
|
||||||
|
else {
|
||||||
|
// Must not contain slash
|
||||||
|
assert_1.default(!segment.includes(path.sep), `Parameter 'itemPath' contains unexpected path separators`);
|
||||||
|
this.segments.push(segment);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Converts the path to it's string representation
|
||||||
|
*/
|
||||||
|
toString() {
|
||||||
|
// First segment
|
||||||
|
let result = this.segments[0];
|
||||||
|
// All others
|
||||||
|
let skipSlash = result.endsWith(path.sep) || (IS_WINDOWS && /^[A-Z]:$/i.test(result));
|
||||||
|
for (let i = 1; i < this.segments.length; i++) {
|
||||||
|
if (skipSlash) {
|
||||||
|
skipSlash = false;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
result += path.sep;
|
||||||
|
}
|
||||||
|
result += this.segments[i];
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
exports.Path = Path;
|
||||||
|
//# sourceMappingURL=internal-path.js.map
|
||||||
|
|
||||||
|
/***/ }),
|
||||||
|
|
||||||
|
/***/ 9005:
|
||||||
|
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
||||||
|
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||||
|
if (k2 === undefined) k2 = k;
|
||||||
|
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
||||||
|
}) : (function(o, m, k, k2) {
|
||||||
|
if (k2 === undefined) k2 = k;
|
||||||
|
o[k2] = m[k];
|
||||||
|
}));
|
||||||
|
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||||
|
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||||
|
}) : function(o, v) {
|
||||||
|
o["default"] = v;
|
||||||
|
});
|
||||||
|
var __importStar = (this && this.__importStar) || function (mod) {
|
||||||
|
if (mod && mod.__esModule) return mod;
|
||||||
|
var result = {};
|
||||||
|
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||||
|
__setModuleDefault(result, mod);
|
||||||
|
return result;
|
||||||
|
};
|
||||||
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||||
|
exports.partialMatch = exports.match = exports.getSearchPaths = void 0;
|
||||||
|
const pathHelper = __importStar(__nccwpck_require__(1849));
|
||||||
|
const internal_match_kind_1 = __nccwpck_require__(1063);
|
||||||
|
const IS_WINDOWS = process.platform === 'win32';
|
||||||
|
/**
|
||||||
|
* Given an array of patterns, returns an array of paths to search.
|
||||||
|
* Duplicates and paths under other included paths are filtered out.
|
||||||
|
*/
|
||||||
|
function getSearchPaths(patterns) {
|
||||||
|
// Ignore negate patterns
|
||||||
|
patterns = patterns.filter(x => !x.negate);
|
||||||
|
// Create a map of all search paths
|
||||||
|
const searchPathMap = {};
|
||||||
|
for (const pattern of patterns) {
|
||||||
|
const key = IS_WINDOWS
|
||||||
|
? pattern.searchPath.toUpperCase()
|
||||||
|
: pattern.searchPath;
|
||||||
|
searchPathMap[key] = 'candidate';
|
||||||
|
}
|
||||||
|
const result = [];
|
||||||
|
for (const pattern of patterns) {
|
||||||
|
// Check if already included
|
||||||
|
const key = IS_WINDOWS
|
||||||
|
? pattern.searchPath.toUpperCase()
|
||||||
|
: pattern.searchPath;
|
||||||
|
if (searchPathMap[key] === 'included') {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
// Check for an ancestor search path
|
||||||
|
let foundAncestor = false;
|
||||||
|
let tempKey = key;
|
||||||
|
let parent = pathHelper.dirname(tempKey);
|
||||||
|
while (parent !== tempKey) {
|
||||||
|
if (searchPathMap[parent]) {
|
||||||
|
foundAncestor = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
tempKey = parent;
|
||||||
|
parent = pathHelper.dirname(tempKey);
|
||||||
|
}
|
||||||
|
// Include the search pattern in the result
|
||||||
|
if (!foundAncestor) {
|
||||||
|
result.push(pattern.searchPath);
|
||||||
|
searchPathMap[key] = 'included';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
exports.getSearchPaths = getSearchPaths;
|
||||||
|
/**
|
||||||
|
* Matches the patterns against the path
|
||||||
|
*/
|
||||||
|
function match(patterns, itemPath) {
|
||||||
|
let result = internal_match_kind_1.MatchKind.None;
|
||||||
|
for (const pattern of patterns) {
|
||||||
|
if (pattern.negate) {
|
||||||
|
result &= ~pattern.match(itemPath);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
result |= pattern.match(itemPath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
exports.match = match;
|
||||||
|
/**
|
||||||
|
* Checks whether to descend further into the directory
|
||||||
|
*/
|
||||||
|
function partialMatch(patterns, itemPath) {
|
||||||
|
return patterns.some(x => !x.negate && x.partialMatch(itemPath));
|
||||||
|
}
|
||||||
|
exports.partialMatch = partialMatch;
|
||||||
|
//# sourceMappingURL=internal-pattern-helper.js.map
|
||||||
|
|
||||||
|
/***/ }),
|
||||||
|
|
||||||
|
/***/ 4536:
|
||||||
|
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
||||||
|
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||||
|
if (k2 === undefined) k2 = k;
|
||||||
|
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
||||||
|
}) : (function(o, m, k, k2) {
|
||||||
|
if (k2 === undefined) k2 = k;
|
||||||
|
o[k2] = m[k];
|
||||||
|
}));
|
||||||
|
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||||
|
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||||
|
}) : function(o, v) {
|
||||||
|
o["default"] = v;
|
||||||
|
});
|
||||||
|
var __importStar = (this && this.__importStar) || function (mod) {
|
||||||
|
if (mod && mod.__esModule) return mod;
|
||||||
|
var result = {};
|
||||||
|
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||||
|
__setModuleDefault(result, mod);
|
||||||
|
return result;
|
||||||
|
};
|
||||||
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||||
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||||
|
};
|
||||||
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||||
|
exports.Pattern = void 0;
|
||||||
|
const os = __importStar(__nccwpck_require__(2037));
|
||||||
|
const path = __importStar(__nccwpck_require__(1017));
|
||||||
|
const pathHelper = __importStar(__nccwpck_require__(1849));
|
||||||
|
const assert_1 = __importDefault(__nccwpck_require__(9491));
|
||||||
|
const minimatch_1 = __nccwpck_require__(3973);
|
||||||
|
const internal_match_kind_1 = __nccwpck_require__(1063);
|
||||||
|
const internal_path_1 = __nccwpck_require__(6836);
|
||||||
|
const IS_WINDOWS = process.platform === 'win32';
|
||||||
|
class Pattern {
|
||||||
|
constructor(patternOrNegate, isImplicitPattern = false, segments, homedir) {
|
||||||
|
/**
|
||||||
|
* Indicates whether matches should be excluded from the result set
|
||||||
|
*/
|
||||||
|
this.negate = false;
|
||||||
|
// Pattern overload
|
||||||
|
let pattern;
|
||||||
|
if (typeof patternOrNegate === 'string') {
|
||||||
|
pattern = patternOrNegate.trim();
|
||||||
|
}
|
||||||
|
// Segments overload
|
||||||
|
else {
|
||||||
|
// Convert to pattern
|
||||||
|
segments = segments || [];
|
||||||
|
assert_1.default(segments.length, `Parameter 'segments' must not empty`);
|
||||||
|
const root = Pattern.getLiteral(segments[0]);
|
||||||
|
assert_1.default(root && pathHelper.hasAbsoluteRoot(root), `Parameter 'segments' first element must be a root path`);
|
||||||
|
pattern = new internal_path_1.Path(segments).toString().trim();
|
||||||
|
if (patternOrNegate) {
|
||||||
|
pattern = `!${pattern}`;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Negate
|
||||||
|
while (pattern.startsWith('!')) {
|
||||||
|
this.negate = !this.negate;
|
||||||
|
pattern = pattern.substr(1).trim();
|
||||||
|
}
|
||||||
|
// Normalize slashes and ensures absolute root
|
||||||
|
pattern = Pattern.fixupPattern(pattern, homedir);
|
||||||
|
// Segments
|
||||||
|
this.segments = new internal_path_1.Path(pattern).segments;
|
||||||
|
// Trailing slash indicates the pattern should only match directories, not regular files
|
||||||
|
this.trailingSeparator = pathHelper
|
||||||
|
.normalizeSeparators(pattern)
|
||||||
|
.endsWith(path.sep);
|
||||||
|
pattern = pathHelper.safeTrimTrailingSeparator(pattern);
|
||||||
|
// Search path (literal path prior to the first glob segment)
|
||||||
|
let foundGlob = false;
|
||||||
|
const searchSegments = this.segments
|
||||||
|
.map(x => Pattern.getLiteral(x))
|
||||||
|
.filter(x => !foundGlob && !(foundGlob = x === ''));
|
||||||
|
this.searchPath = new internal_path_1.Path(searchSegments).toString();
|
||||||
|
// Root RegExp (required when determining partial match)
|
||||||
|
this.rootRegExp = new RegExp(Pattern.regExpEscape(searchSegments[0]), IS_WINDOWS ? 'i' : '');
|
||||||
|
this.isImplicitPattern = isImplicitPattern;
|
||||||
|
// Create minimatch
|
||||||
|
const minimatchOptions = {
|
||||||
|
dot: true,
|
||||||
|
nobrace: true,
|
||||||
|
nocase: IS_WINDOWS,
|
||||||
|
nocomment: true,
|
||||||
|
noext: true,
|
||||||
|
nonegate: true
|
||||||
|
};
|
||||||
|
pattern = IS_WINDOWS ? pattern.replace(/\\/g, '/') : pattern;
|
||||||
|
this.minimatch = new minimatch_1.Minimatch(pattern, minimatchOptions);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Matches the pattern against the specified path
|
||||||
|
*/
|
||||||
|
match(itemPath) {
|
||||||
|
// Last segment is globstar?
|
||||||
|
if (this.segments[this.segments.length - 1] === '**') {
|
||||||
|
// Normalize slashes
|
||||||
|
itemPath = pathHelper.normalizeSeparators(itemPath);
|
||||||
|
// Append a trailing slash. Otherwise Minimatch will not match the directory immediately
|
||||||
|
// preceding the globstar. For example, given the pattern `/foo/**`, Minimatch returns
|
||||||
|
// false for `/foo` but returns true for `/foo/`. Append a trailing slash to handle that quirk.
|
||||||
|
if (!itemPath.endsWith(path.sep) && this.isImplicitPattern === false) {
|
||||||
|
// Note, this is safe because the constructor ensures the pattern has an absolute root.
|
||||||
|
// For example, formats like C: and C:foo on Windows are resolved to an absolute root.
|
||||||
|
itemPath = `${itemPath}${path.sep}`;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// Normalize slashes and trim unnecessary trailing slash
|
||||||
|
itemPath = pathHelper.safeTrimTrailingSeparator(itemPath);
|
||||||
|
}
|
||||||
|
// Match
|
||||||
|
if (this.minimatch.match(itemPath)) {
|
||||||
|
return this.trailingSeparator ? internal_match_kind_1.MatchKind.Directory : internal_match_kind_1.MatchKind.All;
|
||||||
|
}
|
||||||
|
return internal_match_kind_1.MatchKind.None;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Indicates whether the pattern may match descendants of the specified path
|
||||||
|
*/
|
||||||
|
partialMatch(itemPath) {
|
||||||
|
// Normalize slashes and trim unnecessary trailing slash
|
||||||
|
itemPath = pathHelper.safeTrimTrailingSeparator(itemPath);
|
||||||
|
// matchOne does not handle root path correctly
|
||||||
|
if (pathHelper.dirname(itemPath) === itemPath) {
|
||||||
|
return this.rootRegExp.test(itemPath);
|
||||||
|
}
|
||||||
|
return this.minimatch.matchOne(itemPath.split(IS_WINDOWS ? /\\+/ : /\/+/), this.minimatch.set[0], true);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Escapes glob patterns within a path
|
||||||
|
*/
|
||||||
|
static globEscape(s) {
|
||||||
|
return (IS_WINDOWS ? s : s.replace(/\\/g, '\\\\')) // escape '\' on Linux/macOS
|
||||||
|
.replace(/(\[)(?=[^/]+\])/g, '[[]') // escape '[' when ']' follows within the path segment
|
||||||
|
.replace(/\?/g, '[?]') // escape '?'
|
||||||
|
.replace(/\*/g, '[*]'); // escape '*'
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Normalizes slashes and ensures absolute root
|
||||||
|
*/
|
||||||
|
static fixupPattern(pattern, homedir) {
|
||||||
|
// Empty
|
||||||
|
assert_1.default(pattern, 'pattern cannot be empty');
|
||||||
|
// Must not contain `.` segment, unless first segment
|
||||||
|
// Must not contain `..` segment
|
||||||
|
const literalSegments = new internal_path_1.Path(pattern).segments.map(x => Pattern.getLiteral(x));
|
||||||
|
assert_1.default(literalSegments.every((x, i) => (x !== '.' || i === 0) && x !== '..'), `Invalid pattern '${pattern}'. Relative pathing '.' and '..' is not allowed.`);
|
||||||
|
// Must not contain globs in root, e.g. Windows UNC path \\foo\b*r
|
||||||
|
assert_1.default(!pathHelper.hasRoot(pattern) || literalSegments[0], `Invalid pattern '${pattern}'. Root segment must not contain globs.`);
|
||||||
|
// Normalize slashes
|
||||||
|
pattern = pathHelper.normalizeSeparators(pattern);
|
||||||
|
// Replace leading `.` segment
|
||||||
|
if (pattern === '.' || pattern.startsWith(`.${path.sep}`)) {
|
||||||
|
pattern = Pattern.globEscape(process.cwd()) + pattern.substr(1);
|
||||||
|
}
|
||||||
|
// Replace leading `~` segment
|
||||||
|
else if (pattern === '~' || pattern.startsWith(`~${path.sep}`)) {
|
||||||
|
homedir = homedir || os.homedir();
|
||||||
|
assert_1.default(homedir, 'Unable to determine HOME directory');
|
||||||
|
assert_1.default(pathHelper.hasAbsoluteRoot(homedir), `Expected HOME directory to be a rooted path. Actual '${homedir}'`);
|
||||||
|
pattern = Pattern.globEscape(homedir) + pattern.substr(1);
|
||||||
|
}
|
||||||
|
// Replace relative drive root, e.g. pattern is C: or C:foo
|
||||||
|
else if (IS_WINDOWS &&
|
||||||
|
(pattern.match(/^[A-Z]:$/i) || pattern.match(/^[A-Z]:[^\\]/i))) {
|
||||||
|
let root = pathHelper.ensureAbsoluteRoot('C:\\dummy-root', pattern.substr(0, 2));
|
||||||
|
if (pattern.length > 2 && !root.endsWith('\\')) {
|
||||||
|
root += '\\';
|
||||||
|
}
|
||||||
|
pattern = Pattern.globEscape(root) + pattern.substr(2);
|
||||||
|
}
|
||||||
|
// Replace relative root, e.g. pattern is \ or \foo
|
||||||
|
else if (IS_WINDOWS && (pattern === '\\' || pattern.match(/^\\[^\\]/))) {
|
||||||
|
let root = pathHelper.ensureAbsoluteRoot('C:\\dummy-root', '\\');
|
||||||
|
if (!root.endsWith('\\')) {
|
||||||
|
root += '\\';
|
||||||
|
}
|
||||||
|
pattern = Pattern.globEscape(root) + pattern.substr(1);
|
||||||
|
}
|
||||||
|
// Otherwise ensure absolute root
|
||||||
|
else {
|
||||||
|
pattern = pathHelper.ensureAbsoluteRoot(Pattern.globEscape(process.cwd()), pattern);
|
||||||
|
}
|
||||||
|
return pathHelper.normalizeSeparators(pattern);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Attempts to unescape a pattern segment to create a literal path segment.
|
||||||
|
* Otherwise returns empty string.
|
||||||
|
*/
|
||||||
|
static getLiteral(segment) {
|
||||||
|
let literal = '';
|
||||||
|
for (let i = 0; i < segment.length; i++) {
|
||||||
|
const c = segment[i];
|
||||||
|
// Escape
|
||||||
|
if (c === '\\' && !IS_WINDOWS && i + 1 < segment.length) {
|
||||||
|
literal += segment[++i];
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
// Wildcard
|
||||||
|
else if (c === '*' || c === '?') {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
// Character set
|
||||||
|
else if (c === '[' && i + 1 < segment.length) {
|
||||||
|
let set = '';
|
||||||
|
let closed = -1;
|
||||||
|
for (let i2 = i + 1; i2 < segment.length; i2++) {
|
||||||
|
const c2 = segment[i2];
|
||||||
|
// Escape
|
||||||
|
if (c2 === '\\' && !IS_WINDOWS && i2 + 1 < segment.length) {
|
||||||
|
set += segment[++i2];
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
// Closed
|
||||||
|
else if (c2 === ']') {
|
||||||
|
closed = i2;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
// Otherwise
|
||||||
|
else {
|
||||||
|
set += c2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Closed?
|
||||||
|
if (closed >= 0) {
|
||||||
|
// Cannot convert
|
||||||
|
if (set.length > 1) {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
// Convert to literal
|
||||||
|
if (set) {
|
||||||
|
literal += set;
|
||||||
|
i = closed;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Otherwise fall thru
|
||||||
|
}
|
||||||
|
// Append
|
||||||
|
literal += c;
|
||||||
|
}
|
||||||
|
return literal;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Escapes regexp special characters
|
||||||
|
* https://javascript.info/regexp-escaping
|
||||||
|
*/
|
||||||
|
static regExpEscape(s) {
|
||||||
|
return s.replace(/[[\\^$.|?*+()]/g, '\\$&');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
exports.Pattern = Pattern;
|
||||||
|
//# sourceMappingURL=internal-pattern.js.map
|
||||||
|
|
||||||
|
/***/ }),
|
||||||
|
|
||||||
|
/***/ 9117:
|
||||||
|
/***/ ((__unused_webpack_module, exports) => {
|
||||||
|
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||||
|
exports.SearchState = void 0;
|
||||||
|
class SearchState {
|
||||||
|
constructor(path, level) {
|
||||||
|
this.path = path;
|
||||||
|
this.level = level;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
exports.SearchState = SearchState;
|
||||||
|
//# sourceMappingURL=internal-search-state.js.map
|
||||||
|
|
||||||
|
/***/ }),
|
||||||
|
|
||||||
/***/ 1962:
|
/***/ 1962:
|
||||||
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
||||||
|
|
||||||
@ -59126,87 +60313,86 @@ exports.debug = debug; // for test
|
|||||||
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||||
if (k2 === undefined) k2 = k;
|
if (k2 === undefined) k2 = k;
|
||||||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
||||||
}) : (function(o, m, k, k2) {
|
}) : (function(o, m, k, k2) {
|
||||||
if (k2 === undefined) k2 = k;
|
if (k2 === undefined) k2 = k;
|
||||||
o[k2] = m[k];
|
o[k2] = m[k];
|
||||||
}));
|
}));
|
||||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||||
}) : function(o, v) {
|
}) : function(o, v) {
|
||||||
o["default"] = v;
|
o["default"] = v;
|
||||||
});
|
});
|
||||||
var __importStar = (this && this.__importStar) || function (mod) {
|
var __importStar = (this && this.__importStar) || function (mod) {
|
||||||
if (mod && mod.__esModule) return mod;
|
if (mod && mod.__esModule) return mod;
|
||||||
var result = {};
|
var result = {};
|
||||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||||
__setModuleDefault(result, mod);
|
__setModuleDefault(result, mod);
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||||
return new (P || (P = Promise))(function (resolve, reject) {
|
return new (P || (P = Promise))(function (resolve, reject) {
|
||||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
exports.run = void 0;
|
||||||
};
|
const core = __importStar(__nccwpck_require__(2186));
|
||||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
const cache = __importStar(__nccwpck_require__(7799));
|
||||||
exports.run = void 0;
|
const constants_1 = __nccwpck_require__(9042);
|
||||||
const core = __importStar(__nccwpck_require__(2186));
|
const cache_utils_1 = __nccwpck_require__(1678);
|
||||||
const cache = __importStar(__nccwpck_require__(7799));
|
// Catch and log any unhandled exceptions. These exceptions can leak out of the uploadChunk method in
|
||||||
const fs_1 = __importDefault(__nccwpck_require__(7147));
|
// @actions/toolkit when a failed upload closes the file descriptor causing any in-process reads to
|
||||||
const constants_1 = __nccwpck_require__(9042);
|
// throw an uncaught exception. Instead of failing this action, just warn.
|
||||||
const cache_utils_1 = __nccwpck_require__(1678);
|
process.on('uncaughtException', e => {
|
||||||
// Catch and log any unhandled exceptions. These exceptions can leak out of the uploadChunk method in
|
const warningPrefix = '[warning]';
|
||||||
// @actions/toolkit when a failed upload closes the file descriptor causing any in-process reads to
|
core.info(`${warningPrefix}${e.message}`);
|
||||||
// throw an uncaught exception. Instead of failing this action, just warn.
|
});
|
||||||
process.on('uncaughtException', e => {
|
function run() {
|
||||||
const warningPrefix = '[warning]';
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
core.info(`${warningPrefix}${e.message}`);
|
try {
|
||||||
});
|
const cacheLock = core.getInput('cache');
|
||||||
function run() {
|
yield cachePackages(cacheLock);
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
}
|
||||||
try {
|
catch (error) {
|
||||||
const cacheLock = core.getInput('cache');
|
core.setFailed(error.message);
|
||||||
yield cachePackages(cacheLock);
|
}
|
||||||
}
|
});
|
||||||
catch (error) {
|
}
|
||||||
core.setFailed(error.message);
|
exports.run = run;
|
||||||
}
|
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);
|
||||||
exports.run = run;
|
const cachePaths = JSON.parse(core.getState(constants_1.State.CachePaths) || '[]');
|
||||||
const cachePackages = (packageManager) => __awaiter(void 0, void 0, void 0, function* () {
|
const packageManagerInfo = yield cache_utils_1.getPackageManagerInfo(packageManager);
|
||||||
const state = core.getState(constants_1.State.CacheMatchedKey);
|
if (!packageManagerInfo) {
|
||||||
const primaryKey = core.getState(constants_1.State.CachePrimaryKey);
|
core.debug(`Caching for '${packageManager}' is not supported`);
|
||||||
const packageManagerInfo = yield cache_utils_1.getPackageManagerInfo(packageManager);
|
return;
|
||||||
if (!packageManagerInfo) {
|
}
|
||||||
core.debug(`Caching for '${packageManager}' is not supported`);
|
if (cachePaths.length === 0) {
|
||||||
return;
|
// TODO: core.getInput has a bug - it can return undefined despite its definition (tests only?)
|
||||||
}
|
// export declare function getInput(name: string, options?: InputOptions): string;
|
||||||
const cachePath = yield cache_utils_1.getCacheDirectoryPath(packageManagerInfo, packageManager);
|
const cacheDependencyPath = core.getInput('cache-dependency-path') || '';
|
||||||
if (!fs_1.default.existsSync(cachePath)) {
|
throw new Error(`Cache folder paths are not retrieved for ${packageManager} with cache-dependency-path = ${cacheDependencyPath}`);
|
||||||
throw new Error(`Cache folder path is retrieved for ${packageManager} but doesn't exist on disk: ${cachePath}`);
|
}
|
||||||
}
|
if (primaryKey === state) {
|
||||||
if (primaryKey === state) {
|
core.info(`Cache hit occurred on the primary key ${primaryKey}, not saving cache.`);
|
||||||
core.info(`Cache hit occurred on the primary key ${primaryKey}, not saving cache.`);
|
return;
|
||||||
return;
|
}
|
||||||
}
|
const cacheId = yield cache.saveCache(cachePaths, primaryKey);
|
||||||
const cacheId = yield cache.saveCache([cachePath], primaryKey);
|
if (cacheId == -1) {
|
||||||
if (cacheId == -1) {
|
return;
|
||||||
return;
|
}
|
||||||
}
|
core.info(`Cache saved with the key: ${primaryKey}`);
|
||||||
core.info(`Cache saved with the key: ${primaryKey}`);
|
});
|
||||||
});
|
run();
|
||||||
run();
|
|
||||||
|
|
||||||
|
|
||||||
/***/ }),
|
/***/ }),
|
||||||
@ -59215,123 +60401,186 @@ run();
|
|||||||
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||||
if (k2 === undefined) k2 = k;
|
if (k2 === undefined) k2 = k;
|
||||||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
||||||
}) : (function(o, m, k, k2) {
|
}) : (function(o, m, k, k2) {
|
||||||
if (k2 === undefined) k2 = k;
|
if (k2 === undefined) k2 = k;
|
||||||
o[k2] = m[k];
|
o[k2] = m[k];
|
||||||
}));
|
}));
|
||||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||||
}) : function(o, v) {
|
}) : function(o, v) {
|
||||||
o["default"] = v;
|
o["default"] = v;
|
||||||
});
|
});
|
||||||
var __importStar = (this && this.__importStar) || function (mod) {
|
var __importStar = (this && this.__importStar) || function (mod) {
|
||||||
if (mod && mod.__esModule) return mod;
|
if (mod && mod.__esModule) return mod;
|
||||||
var result = {};
|
var result = {};
|
||||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||||
__setModuleDefault(result, mod);
|
__setModuleDefault(result, mod);
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||||
return new (P || (P = Promise))(function (resolve, reject) {
|
return new (P || (P = Promise))(function (resolve, reject) {
|
||||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||||
exports.isCacheFeatureAvailable = exports.isGhes = exports.getCacheDirectoryPath = exports.getPackageManagerInfo = exports.getCommandOutput = exports.supportedPackageManagers = void 0;
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||||
const core = __importStar(__nccwpck_require__(2186));
|
};
|
||||||
const exec = __importStar(__nccwpck_require__(1514));
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||||
const cache = __importStar(__nccwpck_require__(7799));
|
exports.isCacheFeatureAvailable = exports.isGhes = exports.getCacheDirectories = exports.getPackageManagerInfo = exports.getCommandOutputNotEmpty = exports.getCommandOutput = exports.supportedPackageManagers = void 0;
|
||||||
exports.supportedPackageManagers = {
|
const core = __importStar(__nccwpck_require__(2186));
|
||||||
npm: {
|
const exec = __importStar(__nccwpck_require__(1514));
|
||||||
lockFilePatterns: ['package-lock.json', 'npm-shrinkwrap.json', 'yarn.lock'],
|
const cache = __importStar(__nccwpck_require__(7799));
|
||||||
getCacheFolderCommand: 'npm config get cache'
|
const glob = __importStar(__nccwpck_require__(8090));
|
||||||
},
|
const path_1 = __importDefault(__nccwpck_require__(1017));
|
||||||
pnpm: {
|
const fs_1 = __importDefault(__nccwpck_require__(7147));
|
||||||
lockFilePatterns: ['pnpm-lock.yaml'],
|
const util_1 = __nccwpck_require__(2629);
|
||||||
getCacheFolderCommand: 'pnpm store path --silent'
|
exports.supportedPackageManagers = {
|
||||||
},
|
npm: {
|
||||||
yarn1: {
|
name: 'npm',
|
||||||
lockFilePatterns: ['yarn.lock'],
|
lockFilePatterns: ['package-lock.json', 'npm-shrinkwrap.json', 'yarn.lock'],
|
||||||
getCacheFolderCommand: 'yarn cache dir'
|
getCacheFolderPath: () => exports.getCommandOutputNotEmpty('npm config get cache', 'Could not get npm cache folder path')
|
||||||
},
|
},
|
||||||
yarn2: {
|
pnpm: {
|
||||||
lockFilePatterns: ['yarn.lock'],
|
name: 'pnpm',
|
||||||
getCacheFolderCommand: 'yarn config get cacheFolder'
|
lockFilePatterns: ['pnpm-lock.yaml'],
|
||||||
}
|
getCacheFolderPath: () => exports.getCommandOutputNotEmpty('pnpm store path --silent', 'Could not get pnpm cache folder path')
|
||||||
};
|
},
|
||||||
const getCommandOutput = (toolCommand) => __awaiter(void 0, void 0, void 0, function* () {
|
yarn: {
|
||||||
let { stdout, stderr, exitCode } = yield exec.getExecOutput(toolCommand, undefined, { ignoreReturnCode: true });
|
name: 'yarn',
|
||||||
if (exitCode) {
|
lockFilePatterns: ['yarn.lock'],
|
||||||
stderr = !stderr.trim()
|
getCacheFolderPath: (projectDir) => __awaiter(void 0, void 0, void 0, function* () {
|
||||||
? `The '${toolCommand}' command failed with exit code: ${exitCode}`
|
const yarnVersion = yield exports.getCommandOutputNotEmpty(`yarn --version`, 'Could not retrieve version of yarn', projectDir);
|
||||||
: stderr;
|
core.debug(`Consumed yarn version is ${yarnVersion} (working dir: "${projectDir || ''}")`);
|
||||||
throw new Error(stderr);
|
const stdOut = yarnVersion.startsWith('1.')
|
||||||
}
|
? yield exports.getCommandOutput('yarn cache dir', projectDir)
|
||||||
return stdout.trim();
|
: yield exports.getCommandOutput('yarn config get cacheFolder', projectDir);
|
||||||
});
|
if (!stdOut) {
|
||||||
exports.getCommandOutput = getCommandOutput;
|
throw new Error(`Could not get yarn cache folder path for ${projectDir}`);
|
||||||
const getPackageManagerVersion = (packageManager, command) => __awaiter(void 0, void 0, void 0, function* () {
|
}
|
||||||
const stdOut = yield exports.getCommandOutput(`${packageManager} ${command}`);
|
return stdOut;
|
||||||
if (!stdOut) {
|
})
|
||||||
throw new Error(`Could not retrieve version of ${packageManager}`);
|
}
|
||||||
}
|
};
|
||||||
return stdOut;
|
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 })));
|
||||||
const getPackageManagerInfo = (packageManager) => __awaiter(void 0, void 0, void 0, function* () {
|
if (exitCode) {
|
||||||
if (packageManager === 'npm') {
|
stderr = !stderr.trim()
|
||||||
return exports.supportedPackageManagers.npm;
|
? `The '${toolCommand}' command failed with exit code: ${exitCode}`
|
||||||
}
|
: stderr;
|
||||||
else if (packageManager === 'pnpm') {
|
throw new Error(stderr);
|
||||||
return exports.supportedPackageManagers.pnpm;
|
}
|
||||||
}
|
return stdout.trim();
|
||||||
else if (packageManager === 'yarn') {
|
});
|
||||||
const yarnVersion = yield getPackageManagerVersion('yarn', '--version');
|
exports.getCommandOutput = getCommandOutput;
|
||||||
core.debug(`Consumed yarn version is ${yarnVersion}`);
|
const getCommandOutputNotEmpty = (toolCommand, error, cwd) => __awaiter(void 0, void 0, void 0, function* () {
|
||||||
if (yarnVersion.startsWith('1.')) {
|
const stdOut = exports.getCommandOutput(toolCommand, cwd);
|
||||||
return exports.supportedPackageManagers.yarn1;
|
if (!stdOut) {
|
||||||
}
|
throw new Error(error);
|
||||||
else {
|
}
|
||||||
return exports.supportedPackageManagers.yarn2;
|
return stdOut;
|
||||||
}
|
});
|
||||||
}
|
exports.getCommandOutputNotEmpty = getCommandOutputNotEmpty;
|
||||||
else {
|
const getPackageManagerInfo = (packageManager) => __awaiter(void 0, void 0, void 0, function* () {
|
||||||
return null;
|
if (packageManager === 'npm') {
|
||||||
}
|
return exports.supportedPackageManagers.npm;
|
||||||
});
|
}
|
||||||
exports.getPackageManagerInfo = getPackageManagerInfo;
|
else if (packageManager === 'pnpm') {
|
||||||
const getCacheDirectoryPath = (packageManagerInfo, packageManager) => __awaiter(void 0, void 0, void 0, function* () {
|
return exports.supportedPackageManagers.pnpm;
|
||||||
const stdOut = yield exports.getCommandOutput(packageManagerInfo.getCacheFolderCommand);
|
}
|
||||||
if (!stdOut) {
|
else if (packageManager === 'yarn') {
|
||||||
throw new Error(`Could not get cache folder path for ${packageManager}`);
|
return exports.supportedPackageManagers.yarn;
|
||||||
}
|
}
|
||||||
core.debug(`${packageManager} path is ${stdOut}`);
|
else {
|
||||||
return stdOut.trim();
|
return null;
|
||||||
});
|
}
|
||||||
exports.getCacheDirectoryPath = getCacheDirectoryPath;
|
});
|
||||||
function isGhes() {
|
exports.getPackageManagerInfo = getPackageManagerInfo;
|
||||||
const ghUrl = new URL(process.env['GITHUB_SERVER_URL'] || 'https://github.com');
|
/**
|
||||||
return ghUrl.hostname.toUpperCase() !== 'GITHUB.COM';
|
* Expands (converts) the string input `cache-dependency-path` to list of directories that
|
||||||
}
|
* may be project roots
|
||||||
exports.isGhes = isGhes;
|
* @param cacheDependencyPath - either a single string or multiline string with possible glob patterns
|
||||||
function isCacheFeatureAvailable() {
|
* expected to be the result of `core.getInput('cache-dependency-path')`
|
||||||
if (cache.isFeatureAvailable())
|
* @return list of directories and possible
|
||||||
return true;
|
*/
|
||||||
if (isGhes()) {
|
const getProjectDirectoriesFromCacheDependencyPath = (cacheDependencyPath) => __awaiter(void 0, void 0, void 0, function* () {
|
||||||
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.');
|
const globber = yield glob.create(cacheDependencyPath);
|
||||||
return false;
|
const cacheDependenciesPaths = yield globber.glob();
|
||||||
}
|
const existingDirectories = cacheDependenciesPaths
|
||||||
core.warning('The runner was not able to contact the cache service. Caching will be skipped');
|
.map(path_1.default.dirname)
|
||||||
return false;
|
.filter(util_1.unique())
|
||||||
}
|
.filter(directory => fs_1.default.lstatSync(directory).isDirectory());
|
||||||
exports.isCacheFeatureAvailable = isCacheFeatureAvailable;
|
if (!existingDirectories.length)
|
||||||
|
core.warning(`No existing directories found containing cache-dependency-path="${cacheDependencyPath}"`);
|
||||||
|
return existingDirectories;
|
||||||
|
});
|
||||||
|
/**
|
||||||
|
* Finds the cache directories configured for the repo if cache-dependency-path is not empty
|
||||||
|
* @param packageManagerInfo - an object having getCacheFolderPath method specific to given PM
|
||||||
|
* @param cacheDependencyPath - either a single string or multiline string with possible glob patterns
|
||||||
|
* expected to be the result of `core.getInput('cache-dependency-path')`
|
||||||
|
* @return list of files on which the cache depends
|
||||||
|
*/
|
||||||
|
const getCacheDirectoriesFromCacheDependencyPath = (packageManagerInfo, cacheDependencyPath) => __awaiter(void 0, void 0, void 0, function* () {
|
||||||
|
const projectDirectories = yield getProjectDirectoriesFromCacheDependencyPath(cacheDependencyPath);
|
||||||
|
const cacheFoldersPaths = yield Promise.all(projectDirectories.map((projectDirectory) => __awaiter(void 0, void 0, void 0, function* () {
|
||||||
|
const cacheFolderPath = packageManagerInfo.getCacheFolderPath(projectDirectory);
|
||||||
|
core.debug(`${packageManagerInfo.name}'s cache folder "${cacheFolderPath}" configured for the directory "${projectDirectory}"`);
|
||||||
|
return cacheFolderPath;
|
||||||
|
})));
|
||||||
|
// uniq in order to do not cache the same directories twice
|
||||||
|
return cacheFoldersPaths.filter(util_1.unique());
|
||||||
|
});
|
||||||
|
/**
|
||||||
|
* Finds the cache directories configured for the repo ignoring cache-dependency-path
|
||||||
|
* @param packageManagerInfo - an object having getCacheFolderPath method specific to given PM
|
||||||
|
* @return list of files on which the cache depends
|
||||||
|
*/
|
||||||
|
const getCacheDirectoriesForRootProject = (packageManagerInfo) => __awaiter(void 0, void 0, void 0, function* () {
|
||||||
|
const cacheFolderPath = yield packageManagerInfo.getCacheFolderPath();
|
||||||
|
core.debug(`${packageManagerInfo.name}'s cache folder "${cacheFolderPath}" configured for the root directory`);
|
||||||
|
return [cacheFolderPath];
|
||||||
|
});
|
||||||
|
/**
|
||||||
|
* A function to find the cache directories configured for the repo
|
||||||
|
* currently it handles only the case of PM=yarn && cacheDependencyPath is not empty
|
||||||
|
* @param packageManagerInfo - an object having getCacheFolderPath method specific to given PM
|
||||||
|
* @param cacheDependencyPath - either a single string or multiline string with possible glob patterns
|
||||||
|
* expected to be the result of `core.getInput('cache-dependency-path')`
|
||||||
|
* @return list of files on which the cache depends
|
||||||
|
*/
|
||||||
|
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
|
||||||
|
if (packageManagerInfo.name === 'yarn' && cacheDependencyPath) {
|
||||||
|
return getCacheDirectoriesFromCacheDependencyPath(packageManagerInfo, cacheDependencyPath);
|
||||||
|
}
|
||||||
|
return getCacheDirectoriesForRootProject(packageManagerInfo);
|
||||||
|
});
|
||||||
|
exports.getCacheDirectories = getCacheDirectories;
|
||||||
|
function isGhes() {
|
||||||
|
const ghUrl = new URL(process.env['GITHUB_SERVER_URL'] || 'https://github.com');
|
||||||
|
return ghUrl.hostname.toUpperCase() !== 'GITHUB.COM';
|
||||||
|
}
|
||||||
|
exports.isGhes = isGhes;
|
||||||
|
function 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;
|
||||||
|
|
||||||
|
|
||||||
/***/ }),
|
/***/ }),
|
||||||
@ -59340,24 +60589,135 @@ exports.isCacheFeatureAvailable = isCacheFeatureAvailable;
|
|||||||
/***/ ((__unused_webpack_module, exports) => {
|
/***/ ((__unused_webpack_module, exports) => {
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||||
exports.Outputs = exports.State = exports.LockType = void 0;
|
exports.Outputs = exports.State = exports.LockType = void 0;
|
||||||
var LockType;
|
var LockType;
|
||||||
(function (LockType) {
|
(function (LockType) {
|
||||||
LockType["Npm"] = "npm";
|
LockType["Npm"] = "npm";
|
||||||
LockType["Pnpm"] = "pnpm";
|
LockType["Pnpm"] = "pnpm";
|
||||||
LockType["Yarn"] = "yarn";
|
LockType["Yarn"] = "yarn";
|
||||||
})(LockType = exports.LockType || (exports.LockType = {}));
|
})(LockType = exports.LockType || (exports.LockType = {}));
|
||||||
var State;
|
var State;
|
||||||
(function (State) {
|
(function (State) {
|
||||||
State["CachePrimaryKey"] = "CACHE_KEY";
|
State["CachePrimaryKey"] = "CACHE_KEY";
|
||||||
State["CacheMatchedKey"] = "CACHE_RESULT";
|
State["CacheMatchedKey"] = "CACHE_RESULT";
|
||||||
})(State = exports.State || (exports.State = {}));
|
State["CachePaths"] = "CACHE_PATHS";
|
||||||
var Outputs;
|
})(State = exports.State || (exports.State = {}));
|
||||||
(function (Outputs) {
|
var Outputs;
|
||||||
Outputs["CacheHit"] = "cache-hit";
|
(function (Outputs) {
|
||||||
})(Outputs = exports.Outputs || (exports.Outputs = {}));
|
Outputs["CacheHit"] = "cache-hit";
|
||||||
|
})(Outputs = exports.Outputs || (exports.Outputs = {}));
|
||||||
|
|
||||||
|
|
||||||
|
/***/ }),
|
||||||
|
|
||||||
|
/***/ 2629:
|
||||||
|
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
||||||
|
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||||
|
if (k2 === undefined) k2 = k;
|
||||||
|
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
||||||
|
}) : (function(o, m, k, k2) {
|
||||||
|
if (k2 === undefined) k2 = k;
|
||||||
|
o[k2] = m[k];
|
||||||
|
}));
|
||||||
|
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||||
|
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||||
|
}) : function(o, v) {
|
||||||
|
o["default"] = v;
|
||||||
|
});
|
||||||
|
var __importStar = (this && this.__importStar) || function (mod) {
|
||||||
|
if (mod && mod.__esModule) return mod;
|
||||||
|
var result = {};
|
||||||
|
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||||
|
__setModuleDefault(result, mod);
|
||||||
|
return result;
|
||||||
|
};
|
||||||
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||||
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||||
|
return new (P || (P = Promise))(function (resolve, reject) {
|
||||||
|
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 step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||||||
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||||
|
});
|
||||||
|
};
|
||||||
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||||
|
exports.unique = exports.printEnvDetailsAndSetOutput = exports.parseNodeVersionFile = void 0;
|
||||||
|
const core = __importStar(__nccwpck_require__(2186));
|
||||||
|
const exec = __importStar(__nccwpck_require__(1514));
|
||||||
|
function parseNodeVersionFile(contents) {
|
||||||
|
var _a, _b, _c;
|
||||||
|
let nodeVersion;
|
||||||
|
// Try parsing the file as an NPM `package.json` file.
|
||||||
|
try {
|
||||||
|
nodeVersion = (_a = JSON.parse(contents).volta) === null || _a === void 0 ? void 0 : _a.node;
|
||||||
|
if (!nodeVersion)
|
||||||
|
nodeVersion = (_b = JSON.parse(contents).engines) === null || _b === void 0 ? void 0 : _b.node;
|
||||||
|
}
|
||||||
|
catch (_d) {
|
||||||
|
core.info('Node version file is not JSON file');
|
||||||
|
}
|
||||||
|
if (!nodeVersion) {
|
||||||
|
const found = contents.match(/^(?:nodejs\s+)?v?(?<version>[^\s]+)$/m);
|
||||||
|
nodeVersion = (_c = found === null || found === void 0 ? void 0 : found.groups) === null || _c === void 0 ? void 0 : _c.version;
|
||||||
|
}
|
||||||
|
// In the case of an unknown format,
|
||||||
|
// return as is and evaluate the version separately.
|
||||||
|
if (!nodeVersion)
|
||||||
|
nodeVersion = contents.trim();
|
||||||
|
return nodeVersion;
|
||||||
|
}
|
||||||
|
exports.parseNodeVersionFile = parseNodeVersionFile;
|
||||||
|
function printEnvDetailsAndSetOutput() {
|
||||||
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
|
core.startGroup('Environment details');
|
||||||
|
const promises = ['node', 'npm', 'yarn'].map((tool) => __awaiter(this, void 0, void 0, function* () {
|
||||||
|
const output = yield getToolVersion(tool, ['--version']);
|
||||||
|
return { tool, output };
|
||||||
|
}));
|
||||||
|
const tools = yield Promise.all(promises);
|
||||||
|
tools.forEach(({ tool, output }) => {
|
||||||
|
if (tool === 'node') {
|
||||||
|
core.setOutput(`${tool}-version`, output);
|
||||||
|
}
|
||||||
|
core.info(`${tool}: ${output}`);
|
||||||
|
});
|
||||||
|
core.endGroup();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
exports.printEnvDetailsAndSetOutput = printEnvDetailsAndSetOutput;
|
||||||
|
function getToolVersion(tool, options) {
|
||||||
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
|
try {
|
||||||
|
const { stdout, stderr, exitCode } = yield exec.getExecOutput(tool, options, {
|
||||||
|
ignoreReturnCode: true,
|
||||||
|
silent: true
|
||||||
|
});
|
||||||
|
if (exitCode > 0) {
|
||||||
|
core.info(`[warning]${stderr}`);
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
return stdout.trim();
|
||||||
|
}
|
||||||
|
catch (err) {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
const unique = () => {
|
||||||
|
const encountered = new Set();
|
||||||
|
return (value) => {
|
||||||
|
if (encountered.has(value))
|
||||||
|
return false;
|
||||||
|
encountered.add(value);
|
||||||
|
return true;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
exports.unique = unique;
|
||||||
|
|
||||||
|
|
||||||
/***/ }),
|
/***/ }),
|
||||||
|
|||||||
2289
dist/setup/index.js
vendored
2289
dist/setup/index.js
vendored
@ -71022,73 +71022,73 @@ function wrappy (fn, cb) {
|
|||||||
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||||
if (k2 === undefined) k2 = k;
|
if (k2 === undefined) k2 = k;
|
||||||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
||||||
}) : (function(o, m, k, k2) {
|
}) : (function(o, m, k, k2) {
|
||||||
if (k2 === undefined) k2 = k;
|
if (k2 === undefined) k2 = k;
|
||||||
o[k2] = m[k];
|
o[k2] = m[k];
|
||||||
}));
|
}));
|
||||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||||
}) : function(o, v) {
|
}) : function(o, v) {
|
||||||
o["default"] = v;
|
o["default"] = v;
|
||||||
});
|
});
|
||||||
var __importStar = (this && this.__importStar) || function (mod) {
|
var __importStar = (this && this.__importStar) || function (mod) {
|
||||||
if (mod && mod.__esModule) return mod;
|
if (mod && mod.__esModule) return mod;
|
||||||
var result = {};
|
var result = {};
|
||||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||||
__setModuleDefault(result, mod);
|
__setModuleDefault(result, mod);
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||||
exports.configAuthentication = void 0;
|
exports.configAuthentication = void 0;
|
||||||
const fs = __importStar(__nccwpck_require__(7147));
|
const fs = __importStar(__nccwpck_require__(7147));
|
||||||
const os = __importStar(__nccwpck_require__(2037));
|
const os = __importStar(__nccwpck_require__(2037));
|
||||||
const path = __importStar(__nccwpck_require__(1017));
|
const path = __importStar(__nccwpck_require__(1017));
|
||||||
const core = __importStar(__nccwpck_require__(2186));
|
const core = __importStar(__nccwpck_require__(2186));
|
||||||
const github = __importStar(__nccwpck_require__(5438));
|
const github = __importStar(__nccwpck_require__(5438));
|
||||||
function configAuthentication(registryUrl, alwaysAuth) {
|
function configAuthentication(registryUrl, alwaysAuth) {
|
||||||
const npmrc = path.resolve(process.env['RUNNER_TEMP'] || process.cwd(), '.npmrc');
|
const npmrc = path.resolve(process.env['RUNNER_TEMP'] || process.cwd(), '.npmrc');
|
||||||
if (!registryUrl.endsWith('/')) {
|
if (!registryUrl.endsWith('/')) {
|
||||||
registryUrl += '/';
|
registryUrl += '/';
|
||||||
}
|
}
|
||||||
writeRegistryToFile(registryUrl, npmrc, alwaysAuth);
|
writeRegistryToFile(registryUrl, npmrc, alwaysAuth);
|
||||||
}
|
}
|
||||||
exports.configAuthentication = configAuthentication;
|
exports.configAuthentication = configAuthentication;
|
||||||
function writeRegistryToFile(registryUrl, fileLocation, alwaysAuth) {
|
function writeRegistryToFile(registryUrl, fileLocation, alwaysAuth) {
|
||||||
let scope = core.getInput('scope');
|
let scope = core.getInput('scope');
|
||||||
if (!scope && registryUrl.indexOf('npm.pkg.github.com') > -1) {
|
if (!scope && registryUrl.indexOf('npm.pkg.github.com') > -1) {
|
||||||
scope = github.context.repo.owner;
|
scope = github.context.repo.owner;
|
||||||
}
|
}
|
||||||
if (scope && scope[0] != '@') {
|
if (scope && scope[0] != '@') {
|
||||||
scope = '@' + scope;
|
scope = '@' + scope;
|
||||||
}
|
}
|
||||||
if (scope) {
|
if (scope) {
|
||||||
scope = scope.toLowerCase() + ':';
|
scope = scope.toLowerCase() + ':';
|
||||||
}
|
}
|
||||||
core.debug(`Setting auth in ${fileLocation}`);
|
core.debug(`Setting auth in ${fileLocation}`);
|
||||||
let newContents = '';
|
let newContents = '';
|
||||||
if (fs.existsSync(fileLocation)) {
|
if (fs.existsSync(fileLocation)) {
|
||||||
const curContents = fs.readFileSync(fileLocation, 'utf8');
|
const curContents = fs.readFileSync(fileLocation, 'utf8');
|
||||||
curContents.split(os.EOL).forEach((line) => {
|
curContents.split(os.EOL).forEach((line) => {
|
||||||
// Add current contents unless they are setting the registry
|
// Add current contents unless they are setting the registry
|
||||||
if (!line.toLowerCase().startsWith(`${scope}registry`)) {
|
if (!line.toLowerCase().startsWith(`${scope}registry`)) {
|
||||||
newContents += line + os.EOL;
|
newContents += line + os.EOL;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
// Remove http: or https: from front of registry.
|
// Remove http: or https: from front of registry.
|
||||||
const authString = registryUrl.replace(/(^\w+:|^)/, '') + ':_authToken=${NODE_AUTH_TOKEN}';
|
const authString = registryUrl.replace(/(^\w+:|^)/, '') + ':_authToken=${NODE_AUTH_TOKEN}';
|
||||||
const registryString = `${scope}registry=${registryUrl}`;
|
const registryString = `${scope}registry=${registryUrl}`;
|
||||||
const alwaysAuthString = `always-auth=${alwaysAuth}`;
|
const alwaysAuthString = `always-auth=${alwaysAuth}`;
|
||||||
newContents += `${authString}${os.EOL}${registryString}${os.EOL}${alwaysAuthString}`;
|
newContents += `${authString}${os.EOL}${registryString}${os.EOL}${alwaysAuthString}`;
|
||||||
fs.writeFileSync(fileLocation, newContents);
|
fs.writeFileSync(fileLocation, newContents);
|
||||||
core.exportVariable('NPM_CONFIG_USERCONFIG', fileLocation);
|
core.exportVariable('NPM_CONFIG_USERCONFIG', fileLocation);
|
||||||
// Export empty node_auth_token if didn't exist so npm doesn't complain about not being able to find it
|
// Export empty node_auth_token if didn't exist so npm doesn't complain about not being able to find it
|
||||||
core.exportVariable('NODE_AUTH_TOKEN', process.env.NODE_AUTH_TOKEN || 'XXXXX-XXXXX-XXXXX-XXXXX');
|
core.exportVariable('NODE_AUTH_TOKEN', process.env.NODE_AUTH_TOKEN || 'XXXXX-XXXXX-XXXXX-XXXXX');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/***/ }),
|
/***/ }),
|
||||||
@ -71097,84 +71097,85 @@ function writeRegistryToFile(registryUrl, fileLocation, alwaysAuth) {
|
|||||||
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||||
if (k2 === undefined) k2 = k;
|
if (k2 === undefined) k2 = k;
|
||||||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
||||||
}) : (function(o, m, k, k2) {
|
}) : (function(o, m, k, k2) {
|
||||||
if (k2 === undefined) k2 = k;
|
if (k2 === undefined) k2 = k;
|
||||||
o[k2] = m[k];
|
o[k2] = m[k];
|
||||||
}));
|
}));
|
||||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||||
}) : function(o, v) {
|
}) : function(o, v) {
|
||||||
o["default"] = v;
|
o["default"] = v;
|
||||||
});
|
});
|
||||||
var __importStar = (this && this.__importStar) || function (mod) {
|
var __importStar = (this && this.__importStar) || function (mod) {
|
||||||
if (mod && mod.__esModule) return mod;
|
if (mod && mod.__esModule) return mod;
|
||||||
var result = {};
|
var result = {};
|
||||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||||
__setModuleDefault(result, mod);
|
__setModuleDefault(result, mod);
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||||
return new (P || (P = Promise))(function (resolve, reject) {
|
return new (P || (P = Promise))(function (resolve, reject) {
|
||||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||||
exports.restoreCache = void 0;
|
exports.restoreCache = void 0;
|
||||||
const cache = __importStar(__nccwpck_require__(7799));
|
const cache = __importStar(__nccwpck_require__(7799));
|
||||||
const core = __importStar(__nccwpck_require__(2186));
|
const core = __importStar(__nccwpck_require__(2186));
|
||||||
const glob = __importStar(__nccwpck_require__(8090));
|
const glob = __importStar(__nccwpck_require__(8090));
|
||||||
const path_1 = __importDefault(__nccwpck_require__(1017));
|
const path_1 = __importDefault(__nccwpck_require__(1017));
|
||||||
const fs_1 = __importDefault(__nccwpck_require__(7147));
|
const fs_1 = __importDefault(__nccwpck_require__(7147));
|
||||||
const constants_1 = __nccwpck_require__(9042);
|
const constants_1 = __nccwpck_require__(9042);
|
||||||
const cache_utils_1 = __nccwpck_require__(1678);
|
const cache_utils_1 = __nccwpck_require__(1678);
|
||||||
const restoreCache = (packageManager, cacheDependencyPath) => __awaiter(void 0, void 0, void 0, function* () {
|
const restoreCache = (packageManager, cacheDependencyPath) => __awaiter(void 0, void 0, void 0, function* () {
|
||||||
const packageManagerInfo = yield cache_utils_1.getPackageManagerInfo(packageManager);
|
const packageManagerInfo = yield cache_utils_1.getPackageManagerInfo(packageManager);
|
||||||
if (!packageManagerInfo) {
|
if (!packageManagerInfo) {
|
||||||
throw new Error(`Caching for '${packageManager}' is not supported`);
|
throw new Error(`Caching for '${packageManager}' is not supported`);
|
||||||
}
|
}
|
||||||
const platform = process.env.RUNNER_OS;
|
const platform = process.env.RUNNER_OS;
|
||||||
const cachePath = yield cache_utils_1.getCacheDirectoryPath(packageManagerInfo, packageManager);
|
const cachePaths = yield cache_utils_1.getCacheDirectories(packageManagerInfo, cacheDependencyPath);
|
||||||
const lockFilePath = cacheDependencyPath
|
core.saveState(constants_1.State.CachePaths, cachePaths);
|
||||||
? cacheDependencyPath
|
const lockFilePath = cacheDependencyPath
|
||||||
: findLockFile(packageManagerInfo);
|
? cacheDependencyPath
|
||||||
const fileHash = yield glob.hashFiles(lockFilePath);
|
: findLockFile(packageManagerInfo);
|
||||||
if (!fileHash) {
|
const fileHash = yield glob.hashFiles(lockFilePath);
|
||||||
throw new Error('Some specified paths were not resolved, unable to cache dependencies.');
|
if (!fileHash) {
|
||||||
}
|
throw new Error('Some specified paths were not resolved, unable to cache dependencies.');
|
||||||
const primaryKey = `node-cache-${platform}-${packageManager}-${fileHash}`;
|
}
|
||||||
core.debug(`primary key is ${primaryKey}`);
|
const primaryKey = `node-cache-${platform}-${packageManager}-${fileHash}`;
|
||||||
core.saveState(constants_1.State.CachePrimaryKey, primaryKey);
|
core.debug(`primary key is ${primaryKey}`);
|
||||||
const cacheKey = yield cache.restoreCache([cachePath], primaryKey);
|
core.saveState(constants_1.State.CachePrimaryKey, primaryKey);
|
||||||
core.setOutput('cache-hit', Boolean(cacheKey));
|
const cacheKey = yield cache.restoreCache(cachePaths, primaryKey);
|
||||||
if (!cacheKey) {
|
core.setOutput('cache-hit', Boolean(cacheKey));
|
||||||
core.info(`${packageManager} cache is not found`);
|
if (!cacheKey) {
|
||||||
return;
|
core.info(`${packageManager} cache is not found`);
|
||||||
}
|
return;
|
||||||
core.saveState(constants_1.State.CacheMatchedKey, cacheKey);
|
}
|
||||||
core.info(`Cache restored from key: ${cacheKey}`);
|
core.saveState(constants_1.State.CacheMatchedKey, cacheKey);
|
||||||
});
|
core.info(`Cache restored from key: ${cacheKey}`);
|
||||||
exports.restoreCache = restoreCache;
|
});
|
||||||
const findLockFile = (packageManager) => {
|
exports.restoreCache = restoreCache;
|
||||||
const lockFiles = packageManager.lockFilePatterns;
|
const findLockFile = (packageManager) => {
|
||||||
const workspace = process.env.GITHUB_WORKSPACE;
|
const lockFiles = packageManager.lockFilePatterns;
|
||||||
const rootContent = fs_1.default.readdirSync(workspace);
|
const workspace = process.env.GITHUB_WORKSPACE;
|
||||||
const lockFile = lockFiles.find(item => rootContent.includes(item));
|
const rootContent = fs_1.default.readdirSync(workspace);
|
||||||
if (!lockFile) {
|
const lockFile = lockFiles.find(item => rootContent.includes(item));
|
||||||
throw new Error(`Dependencies lock file is not found in ${workspace}. Supported file patterns: ${lockFiles.toString()}`);
|
if (!lockFile) {
|
||||||
}
|
throw new Error(`Dependencies lock file is not found in ${workspace}. Supported file patterns: ${lockFiles.toString()}`);
|
||||||
return path_1.default.join(workspace, lockFile);
|
}
|
||||||
};
|
return path_1.default.join(workspace, lockFile);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
/***/ }),
|
/***/ }),
|
||||||
@ -71183,123 +71184,186 @@ const findLockFile = (packageManager) => {
|
|||||||
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||||
if (k2 === undefined) k2 = k;
|
if (k2 === undefined) k2 = k;
|
||||||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
||||||
}) : (function(o, m, k, k2) {
|
}) : (function(o, m, k, k2) {
|
||||||
if (k2 === undefined) k2 = k;
|
if (k2 === undefined) k2 = k;
|
||||||
o[k2] = m[k];
|
o[k2] = m[k];
|
||||||
}));
|
}));
|
||||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||||
}) : function(o, v) {
|
}) : function(o, v) {
|
||||||
o["default"] = v;
|
o["default"] = v;
|
||||||
});
|
});
|
||||||
var __importStar = (this && this.__importStar) || function (mod) {
|
var __importStar = (this && this.__importStar) || function (mod) {
|
||||||
if (mod && mod.__esModule) return mod;
|
if (mod && mod.__esModule) return mod;
|
||||||
var result = {};
|
var result = {};
|
||||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||||
__setModuleDefault(result, mod);
|
__setModuleDefault(result, mod);
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||||
return new (P || (P = Promise))(function (resolve, reject) {
|
return new (P || (P = Promise))(function (resolve, reject) {
|
||||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||||
exports.isCacheFeatureAvailable = exports.isGhes = exports.getCacheDirectoryPath = exports.getPackageManagerInfo = exports.getCommandOutput = exports.supportedPackageManagers = void 0;
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||||
const core = __importStar(__nccwpck_require__(2186));
|
};
|
||||||
const exec = __importStar(__nccwpck_require__(1514));
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||||
const cache = __importStar(__nccwpck_require__(7799));
|
exports.isCacheFeatureAvailable = exports.isGhes = exports.getCacheDirectories = exports.getPackageManagerInfo = exports.getCommandOutputNotEmpty = exports.getCommandOutput = exports.supportedPackageManagers = void 0;
|
||||||
exports.supportedPackageManagers = {
|
const core = __importStar(__nccwpck_require__(2186));
|
||||||
npm: {
|
const exec = __importStar(__nccwpck_require__(1514));
|
||||||
lockFilePatterns: ['package-lock.json', 'npm-shrinkwrap.json', 'yarn.lock'],
|
const cache = __importStar(__nccwpck_require__(7799));
|
||||||
getCacheFolderCommand: 'npm config get cache'
|
const glob = __importStar(__nccwpck_require__(8090));
|
||||||
},
|
const path_1 = __importDefault(__nccwpck_require__(1017));
|
||||||
pnpm: {
|
const fs_1 = __importDefault(__nccwpck_require__(7147));
|
||||||
lockFilePatterns: ['pnpm-lock.yaml'],
|
const util_1 = __nccwpck_require__(2629);
|
||||||
getCacheFolderCommand: 'pnpm store path --silent'
|
exports.supportedPackageManagers = {
|
||||||
},
|
npm: {
|
||||||
yarn1: {
|
name: 'npm',
|
||||||
lockFilePatterns: ['yarn.lock'],
|
lockFilePatterns: ['package-lock.json', 'npm-shrinkwrap.json', 'yarn.lock'],
|
||||||
getCacheFolderCommand: 'yarn cache dir'
|
getCacheFolderPath: () => exports.getCommandOutputNotEmpty('npm config get cache', 'Could not get npm cache folder path')
|
||||||
},
|
},
|
||||||
yarn2: {
|
pnpm: {
|
||||||
lockFilePatterns: ['yarn.lock'],
|
name: 'pnpm',
|
||||||
getCacheFolderCommand: 'yarn config get cacheFolder'
|
lockFilePatterns: ['pnpm-lock.yaml'],
|
||||||
}
|
getCacheFolderPath: () => exports.getCommandOutputNotEmpty('pnpm store path --silent', 'Could not get pnpm cache folder path')
|
||||||
};
|
},
|
||||||
const getCommandOutput = (toolCommand) => __awaiter(void 0, void 0, void 0, function* () {
|
yarn: {
|
||||||
let { stdout, stderr, exitCode } = yield exec.getExecOutput(toolCommand, undefined, { ignoreReturnCode: true });
|
name: 'yarn',
|
||||||
if (exitCode) {
|
lockFilePatterns: ['yarn.lock'],
|
||||||
stderr = !stderr.trim()
|
getCacheFolderPath: (projectDir) => __awaiter(void 0, void 0, void 0, function* () {
|
||||||
? `The '${toolCommand}' command failed with exit code: ${exitCode}`
|
const yarnVersion = yield exports.getCommandOutputNotEmpty(`yarn --version`, 'Could not retrieve version of yarn', projectDir);
|
||||||
: stderr;
|
core.debug(`Consumed yarn version is ${yarnVersion} (working dir: "${projectDir || ''}")`);
|
||||||
throw new Error(stderr);
|
const stdOut = yarnVersion.startsWith('1.')
|
||||||
}
|
? yield exports.getCommandOutput('yarn cache dir', projectDir)
|
||||||
return stdout.trim();
|
: yield exports.getCommandOutput('yarn config get cacheFolder', projectDir);
|
||||||
});
|
if (!stdOut) {
|
||||||
exports.getCommandOutput = getCommandOutput;
|
throw new Error(`Could not get yarn cache folder path for ${projectDir}`);
|
||||||
const getPackageManagerVersion = (packageManager, command) => __awaiter(void 0, void 0, void 0, function* () {
|
}
|
||||||
const stdOut = yield exports.getCommandOutput(`${packageManager} ${command}`);
|
return stdOut;
|
||||||
if (!stdOut) {
|
})
|
||||||
throw new Error(`Could not retrieve version of ${packageManager}`);
|
}
|
||||||
}
|
};
|
||||||
return stdOut;
|
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 })));
|
||||||
const getPackageManagerInfo = (packageManager) => __awaiter(void 0, void 0, void 0, function* () {
|
if (exitCode) {
|
||||||
if (packageManager === 'npm') {
|
stderr = !stderr.trim()
|
||||||
return exports.supportedPackageManagers.npm;
|
? `The '${toolCommand}' command failed with exit code: ${exitCode}`
|
||||||
}
|
: stderr;
|
||||||
else if (packageManager === 'pnpm') {
|
throw new Error(stderr);
|
||||||
return exports.supportedPackageManagers.pnpm;
|
}
|
||||||
}
|
return stdout.trim();
|
||||||
else if (packageManager === 'yarn') {
|
});
|
||||||
const yarnVersion = yield getPackageManagerVersion('yarn', '--version');
|
exports.getCommandOutput = getCommandOutput;
|
||||||
core.debug(`Consumed yarn version is ${yarnVersion}`);
|
const getCommandOutputNotEmpty = (toolCommand, error, cwd) => __awaiter(void 0, void 0, void 0, function* () {
|
||||||
if (yarnVersion.startsWith('1.')) {
|
const stdOut = exports.getCommandOutput(toolCommand, cwd);
|
||||||
return exports.supportedPackageManagers.yarn1;
|
if (!stdOut) {
|
||||||
}
|
throw new Error(error);
|
||||||
else {
|
}
|
||||||
return exports.supportedPackageManagers.yarn2;
|
return stdOut;
|
||||||
}
|
});
|
||||||
}
|
exports.getCommandOutputNotEmpty = getCommandOutputNotEmpty;
|
||||||
else {
|
const getPackageManagerInfo = (packageManager) => __awaiter(void 0, void 0, void 0, function* () {
|
||||||
return null;
|
if (packageManager === 'npm') {
|
||||||
}
|
return exports.supportedPackageManagers.npm;
|
||||||
});
|
}
|
||||||
exports.getPackageManagerInfo = getPackageManagerInfo;
|
else if (packageManager === 'pnpm') {
|
||||||
const getCacheDirectoryPath = (packageManagerInfo, packageManager) => __awaiter(void 0, void 0, void 0, function* () {
|
return exports.supportedPackageManagers.pnpm;
|
||||||
const stdOut = yield exports.getCommandOutput(packageManagerInfo.getCacheFolderCommand);
|
}
|
||||||
if (!stdOut) {
|
else if (packageManager === 'yarn') {
|
||||||
throw new Error(`Could not get cache folder path for ${packageManager}`);
|
return exports.supportedPackageManagers.yarn;
|
||||||
}
|
}
|
||||||
core.debug(`${packageManager} path is ${stdOut}`);
|
else {
|
||||||
return stdOut.trim();
|
return null;
|
||||||
});
|
}
|
||||||
exports.getCacheDirectoryPath = getCacheDirectoryPath;
|
});
|
||||||
function isGhes() {
|
exports.getPackageManagerInfo = getPackageManagerInfo;
|
||||||
const ghUrl = new URL(process.env['GITHUB_SERVER_URL'] || 'https://github.com');
|
/**
|
||||||
return ghUrl.hostname.toUpperCase() !== 'GITHUB.COM';
|
* Expands (converts) the string input `cache-dependency-path` to list of directories that
|
||||||
}
|
* may be project roots
|
||||||
exports.isGhes = isGhes;
|
* @param cacheDependencyPath - either a single string or multiline string with possible glob patterns
|
||||||
function isCacheFeatureAvailable() {
|
* expected to be the result of `core.getInput('cache-dependency-path')`
|
||||||
if (cache.isFeatureAvailable())
|
* @return list of directories and possible
|
||||||
return true;
|
*/
|
||||||
if (isGhes()) {
|
const getProjectDirectoriesFromCacheDependencyPath = (cacheDependencyPath) => __awaiter(void 0, void 0, void 0, function* () {
|
||||||
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.');
|
const globber = yield glob.create(cacheDependencyPath);
|
||||||
return false;
|
const cacheDependenciesPaths = yield globber.glob();
|
||||||
}
|
const existingDirectories = cacheDependenciesPaths
|
||||||
core.warning('The runner was not able to contact the cache service. Caching will be skipped');
|
.map(path_1.default.dirname)
|
||||||
return false;
|
.filter(util_1.unique())
|
||||||
}
|
.filter(directory => fs_1.default.lstatSync(directory).isDirectory());
|
||||||
exports.isCacheFeatureAvailable = isCacheFeatureAvailable;
|
if (!existingDirectories.length)
|
||||||
|
core.warning(`No existing directories found containing cache-dependency-path="${cacheDependencyPath}"`);
|
||||||
|
return existingDirectories;
|
||||||
|
});
|
||||||
|
/**
|
||||||
|
* Finds the cache directories configured for the repo if cache-dependency-path is not empty
|
||||||
|
* @param packageManagerInfo - an object having getCacheFolderPath method specific to given PM
|
||||||
|
* @param cacheDependencyPath - either a single string or multiline string with possible glob patterns
|
||||||
|
* expected to be the result of `core.getInput('cache-dependency-path')`
|
||||||
|
* @return list of files on which the cache depends
|
||||||
|
*/
|
||||||
|
const getCacheDirectoriesFromCacheDependencyPath = (packageManagerInfo, cacheDependencyPath) => __awaiter(void 0, void 0, void 0, function* () {
|
||||||
|
const projectDirectories = yield getProjectDirectoriesFromCacheDependencyPath(cacheDependencyPath);
|
||||||
|
const cacheFoldersPaths = yield Promise.all(projectDirectories.map((projectDirectory) => __awaiter(void 0, void 0, void 0, function* () {
|
||||||
|
const cacheFolderPath = packageManagerInfo.getCacheFolderPath(projectDirectory);
|
||||||
|
core.debug(`${packageManagerInfo.name}'s cache folder "${cacheFolderPath}" configured for the directory "${projectDirectory}"`);
|
||||||
|
return cacheFolderPath;
|
||||||
|
})));
|
||||||
|
// uniq in order to do not cache the same directories twice
|
||||||
|
return cacheFoldersPaths.filter(util_1.unique());
|
||||||
|
});
|
||||||
|
/**
|
||||||
|
* Finds the cache directories configured for the repo ignoring cache-dependency-path
|
||||||
|
* @param packageManagerInfo - an object having getCacheFolderPath method specific to given PM
|
||||||
|
* @return list of files on which the cache depends
|
||||||
|
*/
|
||||||
|
const getCacheDirectoriesForRootProject = (packageManagerInfo) => __awaiter(void 0, void 0, void 0, function* () {
|
||||||
|
const cacheFolderPath = yield packageManagerInfo.getCacheFolderPath();
|
||||||
|
core.debug(`${packageManagerInfo.name}'s cache folder "${cacheFolderPath}" configured for the root directory`);
|
||||||
|
return [cacheFolderPath];
|
||||||
|
});
|
||||||
|
/**
|
||||||
|
* A function to find the cache directories configured for the repo
|
||||||
|
* currently it handles only the case of PM=yarn && cacheDependencyPath is not empty
|
||||||
|
* @param packageManagerInfo - an object having getCacheFolderPath method specific to given PM
|
||||||
|
* @param cacheDependencyPath - either a single string or multiline string with possible glob patterns
|
||||||
|
* expected to be the result of `core.getInput('cache-dependency-path')`
|
||||||
|
* @return list of files on which the cache depends
|
||||||
|
*/
|
||||||
|
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
|
||||||
|
if (packageManagerInfo.name === 'yarn' && cacheDependencyPath) {
|
||||||
|
return getCacheDirectoriesFromCacheDependencyPath(packageManagerInfo, cacheDependencyPath);
|
||||||
|
}
|
||||||
|
return getCacheDirectoriesForRootProject(packageManagerInfo);
|
||||||
|
});
|
||||||
|
exports.getCacheDirectories = getCacheDirectories;
|
||||||
|
function isGhes() {
|
||||||
|
const ghUrl = new URL(process.env['GITHUB_SERVER_URL'] || 'https://github.com');
|
||||||
|
return ghUrl.hostname.toUpperCase() !== 'GITHUB.COM';
|
||||||
|
}
|
||||||
|
exports.isGhes = isGhes;
|
||||||
|
function 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;
|
||||||
|
|
||||||
|
|
||||||
/***/ }),
|
/***/ }),
|
||||||
@ -71308,24 +71372,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["CachePrimaryKey"] = "CACHE_KEY";
|
State["CachePrimaryKey"] = "CACHE_KEY";
|
||||||
State["CacheMatchedKey"] = "CACHE_RESULT";
|
State["CacheMatchedKey"] = "CACHE_RESULT";
|
||||||
})(State = exports.State || (exports.State = {}));
|
State["CachePaths"] = "CACHE_PATHS";
|
||||||
var Outputs;
|
})(State = exports.State || (exports.State = {}));
|
||||||
(function (Outputs) {
|
var Outputs;
|
||||||
Outputs["CacheHit"] = "cache-hit";
|
(function (Outputs) {
|
||||||
})(Outputs = exports.Outputs || (exports.Outputs = {}));
|
Outputs["CacheHit"] = "cache-hit";
|
||||||
|
})(Outputs = exports.Outputs || (exports.Outputs = {}));
|
||||||
|
|
||||||
|
|
||||||
/***/ }),
|
/***/ }),
|
||||||
@ -71334,73 +71399,73 @@ var Outputs;
|
|||||||
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||||
if (k2 === undefined) k2 = k;
|
if (k2 === undefined) k2 = k;
|
||||||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
||||||
}) : (function(o, m, k, k2) {
|
}) : (function(o, m, k, k2) {
|
||||||
if (k2 === undefined) k2 = k;
|
if (k2 === undefined) k2 = k;
|
||||||
o[k2] = m[k];
|
o[k2] = m[k];
|
||||||
}));
|
}));
|
||||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||||
}) : function(o, v) {
|
}) : function(o, v) {
|
||||||
o["default"] = v;
|
o["default"] = v;
|
||||||
});
|
});
|
||||||
var __importStar = (this && this.__importStar) || function (mod) {
|
var __importStar = (this && this.__importStar) || function (mod) {
|
||||||
if (mod && mod.__esModule) return mod;
|
if (mod && mod.__esModule) return mod;
|
||||||
var result = {};
|
var result = {};
|
||||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||||
__setModuleDefault(result, mod);
|
__setModuleDefault(result, mod);
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||||
const tc = __importStar(__nccwpck_require__(7784));
|
const tc = __importStar(__nccwpck_require__(7784));
|
||||||
const semver_1 = __importDefault(__nccwpck_require__(5911));
|
const semver_1 = __importDefault(__nccwpck_require__(5911));
|
||||||
const base_distribution_1 = __importDefault(__nccwpck_require__(7));
|
const base_distribution_1 = __importDefault(__nccwpck_require__(7));
|
||||||
class BasePrereleaseNodejs extends base_distribution_1.default {
|
class BasePrereleaseNodejs extends base_distribution_1.default {
|
||||||
constructor(nodeInfo) {
|
constructor(nodeInfo) {
|
||||||
super(nodeInfo);
|
super(nodeInfo);
|
||||||
}
|
}
|
||||||
findVersionInHostedToolCacheDirectory() {
|
findVersionInHostedToolCacheDirectory() {
|
||||||
let toolPath = '';
|
let toolPath = '';
|
||||||
const localVersionPaths = tc
|
const localVersionPaths = tc
|
||||||
.findAllVersions('node', this.nodeInfo.arch)
|
.findAllVersions('node', this.nodeInfo.arch)
|
||||||
.filter(i => {
|
.filter(i => {
|
||||||
const prerelease = semver_1.default.prerelease(i);
|
const prerelease = semver_1.default.prerelease(i);
|
||||||
if (!prerelease) {
|
if (!prerelease) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return prerelease[0].includes(this.distribution);
|
return prerelease[0].includes(this.distribution);
|
||||||
});
|
});
|
||||||
localVersionPaths.sort(semver_1.default.rcompare);
|
localVersionPaths.sort(semver_1.default.rcompare);
|
||||||
const localVersion = this.evaluateVersions(localVersionPaths);
|
const localVersion = this.evaluateVersions(localVersionPaths);
|
||||||
if (localVersion) {
|
if (localVersion) {
|
||||||
toolPath = tc.find('node', localVersion, this.nodeInfo.arch);
|
toolPath = tc.find('node', localVersion, this.nodeInfo.arch);
|
||||||
}
|
}
|
||||||
return toolPath;
|
return toolPath;
|
||||||
}
|
}
|
||||||
validRange(versionSpec) {
|
validRange(versionSpec) {
|
||||||
let range;
|
let range;
|
||||||
const [raw, prerelease] = this.splitVersionSpec(versionSpec);
|
const [raw, prerelease] = this.splitVersionSpec(versionSpec);
|
||||||
const isValidVersion = semver_1.default.valid(raw);
|
const isValidVersion = semver_1.default.valid(raw);
|
||||||
const rawVersion = (isValidVersion ? raw : semver_1.default.coerce(raw));
|
const rawVersion = (isValidVersion ? raw : semver_1.default.coerce(raw));
|
||||||
if (prerelease !== this.distribution) {
|
if (prerelease !== this.distribution) {
|
||||||
range = versionSpec;
|
range = versionSpec;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
range = `${semver_1.default.validRange(`^${rawVersion}-${this.distribution}`)}-0`;
|
range = `${semver_1.default.validRange(`^${rawVersion}-${this.distribution}`)}-0`;
|
||||||
}
|
}
|
||||||
return { range, options: { includePrerelease: !isValidVersion } };
|
return { range, options: { includePrerelease: !isValidVersion } };
|
||||||
}
|
}
|
||||||
splitVersionSpec(versionSpec) {
|
splitVersionSpec(versionSpec) {
|
||||||
return versionSpec.split(/-(.*)/s);
|
return versionSpec.split(/-(.*)/s);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
exports["default"] = BasePrereleaseNodejs;
|
exports["default"] = BasePrereleaseNodejs;
|
||||||
|
|
||||||
|
|
||||||
/***/ }),
|
/***/ }),
|
||||||
@ -71409,275 +71474,275 @@ exports["default"] = BasePrereleaseNodejs;
|
|||||||
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||||
if (k2 === undefined) k2 = k;
|
if (k2 === undefined) k2 = k;
|
||||||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
||||||
}) : (function(o, m, k, k2) {
|
}) : (function(o, m, k, k2) {
|
||||||
if (k2 === undefined) k2 = k;
|
if (k2 === undefined) k2 = k;
|
||||||
o[k2] = m[k];
|
o[k2] = m[k];
|
||||||
}));
|
}));
|
||||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||||
}) : function(o, v) {
|
}) : function(o, v) {
|
||||||
o["default"] = v;
|
o["default"] = v;
|
||||||
});
|
});
|
||||||
var __importStar = (this && this.__importStar) || function (mod) {
|
var __importStar = (this && this.__importStar) || function (mod) {
|
||||||
if (mod && mod.__esModule) return mod;
|
if (mod && mod.__esModule) return mod;
|
||||||
var result = {};
|
var result = {};
|
||||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||||
__setModuleDefault(result, mod);
|
__setModuleDefault(result, mod);
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||||
return new (P || (P = Promise))(function (resolve, reject) {
|
return new (P || (P = Promise))(function (resolve, reject) {
|
||||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||||
const tc = __importStar(__nccwpck_require__(7784));
|
const tc = __importStar(__nccwpck_require__(7784));
|
||||||
const hc = __importStar(__nccwpck_require__(9925));
|
const hc = __importStar(__nccwpck_require__(9925));
|
||||||
const core = __importStar(__nccwpck_require__(2186));
|
const core = __importStar(__nccwpck_require__(2186));
|
||||||
const io = __importStar(__nccwpck_require__(7436));
|
const io = __importStar(__nccwpck_require__(7436));
|
||||||
const semver_1 = __importDefault(__nccwpck_require__(5911));
|
const semver_1 = __importDefault(__nccwpck_require__(5911));
|
||||||
const assert = __importStar(__nccwpck_require__(9491));
|
const assert = __importStar(__nccwpck_require__(9491));
|
||||||
const path = __importStar(__nccwpck_require__(1017));
|
const path = __importStar(__nccwpck_require__(1017));
|
||||||
const os_1 = __importDefault(__nccwpck_require__(2037));
|
const os_1 = __importDefault(__nccwpck_require__(2037));
|
||||||
const fs_1 = __importDefault(__nccwpck_require__(7147));
|
const fs_1 = __importDefault(__nccwpck_require__(7147));
|
||||||
class BaseDistribution {
|
class BaseDistribution {
|
||||||
constructor(nodeInfo) {
|
constructor(nodeInfo) {
|
||||||
this.nodeInfo = nodeInfo;
|
this.nodeInfo = nodeInfo;
|
||||||
this.osPlat = os_1.default.platform();
|
this.osPlat = os_1.default.platform();
|
||||||
this.httpClient = new hc.HttpClient('setup-node', [], {
|
this.httpClient = new hc.HttpClient('setup-node', [], {
|
||||||
allowRetries: true,
|
allowRetries: true,
|
||||||
maxRetries: 3
|
maxRetries: 3
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
setupNodeJs() {
|
setupNodeJs() {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
let nodeJsVersions;
|
let nodeJsVersions;
|
||||||
if (this.nodeInfo.checkLatest) {
|
if (this.nodeInfo.checkLatest) {
|
||||||
const evaluatedVersion = yield this.findVersionInDist(nodeJsVersions);
|
const evaluatedVersion = yield this.findVersionInDist(nodeJsVersions);
|
||||||
this.nodeInfo.versionSpec = evaluatedVersion;
|
this.nodeInfo.versionSpec = evaluatedVersion;
|
||||||
}
|
}
|
||||||
let toolPath = this.findVersionInHostedToolCacheDirectory();
|
let toolPath = this.findVersionInHostedToolCacheDirectory();
|
||||||
if (toolPath) {
|
if (toolPath) {
|
||||||
core.info(`Found in cache @ ${toolPath}`);
|
core.info(`Found in cache @ ${toolPath}`);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
const evaluatedVersion = yield this.findVersionInDist(nodeJsVersions);
|
const evaluatedVersion = yield this.findVersionInDist(nodeJsVersions);
|
||||||
const toolName = this.getNodejsDistInfo(evaluatedVersion);
|
const toolName = this.getNodejsDistInfo(evaluatedVersion);
|
||||||
toolPath = yield this.downloadNodejs(toolName);
|
toolPath = yield this.downloadNodejs(toolName);
|
||||||
}
|
}
|
||||||
if (this.osPlat != 'win32') {
|
if (this.osPlat != 'win32') {
|
||||||
toolPath = path.join(toolPath, 'bin');
|
toolPath = path.join(toolPath, 'bin');
|
||||||
}
|
}
|
||||||
core.addPath(toolPath);
|
core.addPath(toolPath);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
findVersionInDist(nodeJsVersions) {
|
findVersionInDist(nodeJsVersions) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
if (!nodeJsVersions) {
|
if (!nodeJsVersions) {
|
||||||
nodeJsVersions = yield this.getNodeJsVersions();
|
nodeJsVersions = yield this.getNodeJsVersions();
|
||||||
}
|
}
|
||||||
const versions = this.filterVersions(nodeJsVersions);
|
const versions = this.filterVersions(nodeJsVersions);
|
||||||
const evaluatedVersion = this.evaluateVersions(versions);
|
const evaluatedVersion = this.evaluateVersions(versions);
|
||||||
if (!evaluatedVersion) {
|
if (!evaluatedVersion) {
|
||||||
throw new Error(`Unable to find Node version '${this.nodeInfo.versionSpec}' for platform ${this.osPlat} and architecture ${this.nodeInfo.arch}.`);
|
throw new Error(`Unable to find Node version '${this.nodeInfo.versionSpec}' for platform ${this.osPlat} and architecture ${this.nodeInfo.arch}.`);
|
||||||
}
|
}
|
||||||
return evaluatedVersion;
|
return evaluatedVersion;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
evaluateVersions(versions) {
|
evaluateVersions(versions) {
|
||||||
let version = '';
|
let version = '';
|
||||||
const { range, options } = this.validRange(this.nodeInfo.versionSpec);
|
const { range, options } = this.validRange(this.nodeInfo.versionSpec);
|
||||||
core.debug(`evaluating ${versions.length} versions`);
|
core.debug(`evaluating ${versions.length} versions`);
|
||||||
for (const potential of versions) {
|
for (const potential of versions) {
|
||||||
const satisfied = semver_1.default.satisfies(potential, range, options);
|
const satisfied = semver_1.default.satisfies(potential, range, options);
|
||||||
if (satisfied) {
|
if (satisfied) {
|
||||||
version = potential;
|
version = potential;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (version) {
|
if (version) {
|
||||||
core.debug(`matched: ${version}`);
|
core.debug(`matched: ${version}`);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
core.debug('match not found');
|
core.debug('match not found');
|
||||||
}
|
}
|
||||||
return version;
|
return version;
|
||||||
}
|
}
|
||||||
findVersionInHostedToolCacheDirectory() {
|
findVersionInHostedToolCacheDirectory() {
|
||||||
return tc.find('node', this.nodeInfo.versionSpec, this.nodeInfo.arch);
|
return tc.find('node', this.nodeInfo.versionSpec, this.nodeInfo.arch);
|
||||||
}
|
}
|
||||||
getNodeJsVersions() {
|
getNodeJsVersions() {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
const initialUrl = this.getDistributionUrl();
|
const initialUrl = this.getDistributionUrl();
|
||||||
const dataUrl = `${initialUrl}/index.json`;
|
const dataUrl = `${initialUrl}/index.json`;
|
||||||
const response = yield this.httpClient.getJson(dataUrl);
|
const response = yield this.httpClient.getJson(dataUrl);
|
||||||
return response.result || [];
|
return response.result || [];
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
getNodejsDistInfo(version) {
|
getNodejsDistInfo(version) {
|
||||||
const osArch = this.translateArchToDistUrl(this.nodeInfo.arch);
|
const osArch = this.translateArchToDistUrl(this.nodeInfo.arch);
|
||||||
version = semver_1.default.clean(version) || '';
|
version = semver_1.default.clean(version) || '';
|
||||||
const fileName = this.osPlat == 'win32'
|
const fileName = this.osPlat == 'win32'
|
||||||
? `node-v${version}-win-${osArch}`
|
? `node-v${version}-win-${osArch}`
|
||||||
: `node-v${version}-${this.osPlat}-${osArch}`;
|
: `node-v${version}-${this.osPlat}-${osArch}`;
|
||||||
const urlFileName = this.osPlat == 'win32' ? `${fileName}.7z` : `${fileName}.tar.gz`;
|
const urlFileName = this.osPlat == 'win32' ? `${fileName}.7z` : `${fileName}.tar.gz`;
|
||||||
const initialUrl = this.getDistributionUrl();
|
const initialUrl = this.getDistributionUrl();
|
||||||
const url = `${initialUrl}/v${version}/${urlFileName}`;
|
const url = `${initialUrl}/v${version}/${urlFileName}`;
|
||||||
return {
|
return {
|
||||||
downloadUrl: url,
|
downloadUrl: url,
|
||||||
resolvedVersion: version,
|
resolvedVersion: version,
|
||||||
arch: osArch,
|
arch: osArch,
|
||||||
fileName: fileName
|
fileName: fileName
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
downloadNodejs(info) {
|
downloadNodejs(info) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
let downloadPath = '';
|
let downloadPath = '';
|
||||||
core.info(`Acquiring ${info.resolvedVersion} - ${info.arch} from ${info.downloadUrl}`);
|
core.info(`Acquiring ${info.resolvedVersion} - ${info.arch} from ${info.downloadUrl}`);
|
||||||
try {
|
try {
|
||||||
downloadPath = yield tc.downloadTool(info.downloadUrl);
|
downloadPath = yield tc.downloadTool(info.downloadUrl);
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
if (err instanceof tc.HTTPError &&
|
if (err instanceof tc.HTTPError &&
|
||||||
err.httpStatusCode == 404 &&
|
err.httpStatusCode == 404 &&
|
||||||
this.osPlat == 'win32') {
|
this.osPlat == 'win32') {
|
||||||
return yield this.acquireWindowsNodeFromFallbackLocation(info.resolvedVersion, info.arch);
|
return yield this.acquireWindowsNodeFromFallbackLocation(info.resolvedVersion, info.arch);
|
||||||
}
|
}
|
||||||
throw err;
|
throw err;
|
||||||
}
|
}
|
||||||
const toolPath = yield this.extractArchive(downloadPath, info);
|
const toolPath = yield this.extractArchive(downloadPath, info);
|
||||||
core.info('Done');
|
core.info('Done');
|
||||||
return toolPath;
|
return toolPath;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
validRange(versionSpec) {
|
validRange(versionSpec) {
|
||||||
var _a;
|
var _a;
|
||||||
let options;
|
let options;
|
||||||
const c = semver_1.default.clean(versionSpec) || '';
|
const c = semver_1.default.clean(versionSpec) || '';
|
||||||
const valid = (_a = semver_1.default.valid(c)) !== null && _a !== void 0 ? _a : versionSpec;
|
const valid = (_a = semver_1.default.valid(c)) !== null && _a !== void 0 ? _a : versionSpec;
|
||||||
return { range: valid, options };
|
return { range: valid, options };
|
||||||
}
|
}
|
||||||
acquireWindowsNodeFromFallbackLocation(version, arch = os_1.default.arch()) {
|
acquireWindowsNodeFromFallbackLocation(version, arch = os_1.default.arch()) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
const initialUrl = this.getDistributionUrl();
|
const initialUrl = this.getDistributionUrl();
|
||||||
const osArch = this.translateArchToDistUrl(arch);
|
const osArch = this.translateArchToDistUrl(arch);
|
||||||
// Create temporary folder to download in to
|
// Create temporary folder to download in to
|
||||||
const tempDownloadFolder = 'temp_' + Math.floor(Math.random() * 2000000000);
|
const tempDownloadFolder = 'temp_' + Math.floor(Math.random() * 2000000000);
|
||||||
const tempDirectory = process.env['RUNNER_TEMP'] || '';
|
const tempDirectory = process.env['RUNNER_TEMP'] || '';
|
||||||
assert.ok(tempDirectory, 'Expected RUNNER_TEMP to be defined');
|
assert.ok(tempDirectory, 'Expected RUNNER_TEMP to be defined');
|
||||||
const tempDir = path.join(tempDirectory, tempDownloadFolder);
|
const tempDir = path.join(tempDirectory, tempDownloadFolder);
|
||||||
yield io.mkdirP(tempDir);
|
yield io.mkdirP(tempDir);
|
||||||
let exeUrl;
|
let exeUrl;
|
||||||
let libUrl;
|
let libUrl;
|
||||||
try {
|
try {
|
||||||
exeUrl = `${initialUrl}/v${version}/win-${osArch}/node.exe`;
|
exeUrl = `${initialUrl}/v${version}/win-${osArch}/node.exe`;
|
||||||
libUrl = `${initialUrl}/v${version}/win-${osArch}/node.lib`;
|
libUrl = `${initialUrl}/v${version}/win-${osArch}/node.lib`;
|
||||||
core.info(`Downloading only node binary from ${exeUrl}`);
|
core.info(`Downloading only node binary from ${exeUrl}`);
|
||||||
const exePath = yield tc.downloadTool(exeUrl);
|
const exePath = yield tc.downloadTool(exeUrl);
|
||||||
yield io.cp(exePath, path.join(tempDir, 'node.exe'));
|
yield io.cp(exePath, path.join(tempDir, 'node.exe'));
|
||||||
const libPath = yield tc.downloadTool(libUrl);
|
const libPath = yield tc.downloadTool(libUrl);
|
||||||
yield io.cp(libPath, path.join(tempDir, 'node.lib'));
|
yield io.cp(libPath, path.join(tempDir, 'node.lib'));
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
if (err instanceof tc.HTTPError && err.httpStatusCode == 404) {
|
if (err instanceof tc.HTTPError && err.httpStatusCode == 404) {
|
||||||
exeUrl = `${initialUrl}/v${version}/node.exe`;
|
exeUrl = `${initialUrl}/v${version}/node.exe`;
|
||||||
libUrl = `${initialUrl}/v${version}/node.lib`;
|
libUrl = `${initialUrl}/v${version}/node.lib`;
|
||||||
const exePath = yield tc.downloadTool(exeUrl);
|
const exePath = yield tc.downloadTool(exeUrl);
|
||||||
yield io.cp(exePath, path.join(tempDir, 'node.exe'));
|
yield io.cp(exePath, path.join(tempDir, 'node.exe'));
|
||||||
const libPath = yield tc.downloadTool(libUrl);
|
const libPath = yield tc.downloadTool(libUrl);
|
||||||
yield io.cp(libPath, path.join(tempDir, 'node.lib'));
|
yield io.cp(libPath, path.join(tempDir, 'node.lib'));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
throw err;
|
throw err;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const toolPath = yield tc.cacheDir(tempDir, 'node', version, arch);
|
const toolPath = yield tc.cacheDir(tempDir, 'node', version, arch);
|
||||||
return toolPath;
|
return toolPath;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
extractArchive(downloadPath, info) {
|
extractArchive(downloadPath, info) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
//
|
//
|
||||||
// Extract
|
// Extract
|
||||||
//
|
//
|
||||||
core.info('Extracting ...');
|
core.info('Extracting ...');
|
||||||
let extPath;
|
let extPath;
|
||||||
info = info || {}; // satisfy compiler, never null when reaches here
|
info = info || {}; // satisfy compiler, never null when reaches here
|
||||||
if (this.osPlat == 'win32') {
|
if (this.osPlat == 'win32') {
|
||||||
const _7zPath = path.join(__dirname, '../..', 'externals', '7zr.exe');
|
const _7zPath = path.join(__dirname, '../..', 'externals', '7zr.exe');
|
||||||
extPath = yield tc.extract7z(downloadPath, undefined, _7zPath);
|
extPath = yield tc.extract7z(downloadPath, undefined, _7zPath);
|
||||||
// 7z extracts to folder matching file name
|
// 7z extracts to folder matching file name
|
||||||
const nestedPath = path.join(extPath, path.basename(info.fileName, '.7z'));
|
const nestedPath = path.join(extPath, path.basename(info.fileName, '.7z'));
|
||||||
if (fs_1.default.existsSync(nestedPath)) {
|
if (fs_1.default.existsSync(nestedPath)) {
|
||||||
extPath = nestedPath;
|
extPath = nestedPath;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
extPath = yield tc.extractTar(downloadPath, undefined, [
|
extPath = yield tc.extractTar(downloadPath, undefined, [
|
||||||
'xz',
|
'xz',
|
||||||
'--strip',
|
'--strip',
|
||||||
'1'
|
'1'
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
// Install into the local tool cache - node extracts with a root folder that matches the fileName downloaded
|
// Install into the local tool cache - node extracts with a root folder that matches the fileName downloaded
|
||||||
//
|
//
|
||||||
core.info('Adding to the cache ...');
|
core.info('Adding to the cache ...');
|
||||||
const toolPath = yield tc.cacheDir(extPath, 'node', info.resolvedVersion, info.arch);
|
const toolPath = yield tc.cacheDir(extPath, 'node', info.resolvedVersion, info.arch);
|
||||||
return toolPath;
|
return toolPath;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
getDistFileName() {
|
getDistFileName() {
|
||||||
const osArch = this.translateArchToDistUrl(this.nodeInfo.arch);
|
const osArch = this.translateArchToDistUrl(this.nodeInfo.arch);
|
||||||
// node offers a json list of versions
|
// node offers a json list of versions
|
||||||
let dataFileName;
|
let dataFileName;
|
||||||
switch (this.osPlat) {
|
switch (this.osPlat) {
|
||||||
case 'linux':
|
case 'linux':
|
||||||
dataFileName = `linux-${osArch}`;
|
dataFileName = `linux-${osArch}`;
|
||||||
break;
|
break;
|
||||||
case 'darwin':
|
case 'darwin':
|
||||||
dataFileName = `osx-${osArch}-tar`;
|
dataFileName = `osx-${osArch}-tar`;
|
||||||
break;
|
break;
|
||||||
case 'win32':
|
case 'win32':
|
||||||
dataFileName = `win-${osArch}-exe`;
|
dataFileName = `win-${osArch}-exe`;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw new Error(`Unexpected OS '${this.osPlat}'`);
|
throw new Error(`Unexpected OS '${this.osPlat}'`);
|
||||||
}
|
}
|
||||||
return dataFileName;
|
return dataFileName;
|
||||||
}
|
}
|
||||||
filterVersions(nodeJsVersions) {
|
filterVersions(nodeJsVersions) {
|
||||||
const versions = [];
|
const versions = [];
|
||||||
const dataFileName = this.getDistFileName();
|
const dataFileName = this.getDistFileName();
|
||||||
nodeJsVersions.forEach((nodeVersion) => {
|
nodeJsVersions.forEach((nodeVersion) => {
|
||||||
// ensure this version supports your os and platform
|
// ensure this version supports your os and platform
|
||||||
if (nodeVersion.files.indexOf(dataFileName) >= 0) {
|
if (nodeVersion.files.indexOf(dataFileName) >= 0) {
|
||||||
versions.push(nodeVersion.version);
|
versions.push(nodeVersion.version);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return versions.sort(semver_1.default.rcompare);
|
return versions.sort(semver_1.default.rcompare);
|
||||||
}
|
}
|
||||||
translateArchToDistUrl(arch) {
|
translateArchToDistUrl(arch) {
|
||||||
switch (arch) {
|
switch (arch) {
|
||||||
case 'arm':
|
case 'arm':
|
||||||
return 'armv7l';
|
return 'armv7l';
|
||||||
default:
|
default:
|
||||||
return arch;
|
return arch;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
exports["default"] = BaseDistribution;
|
exports["default"] = BaseDistribution;
|
||||||
|
|
||||||
|
|
||||||
/***/ }),
|
/***/ }),
|
||||||
@ -71686,41 +71751,41 @@ exports["default"] = BaseDistribution;
|
|||||||
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||||
exports.getNodejsDistribution = void 0;
|
exports.getNodejsDistribution = void 0;
|
||||||
const nightly_builds_1 = __importDefault(__nccwpck_require__(7127));
|
const nightly_builds_1 = __importDefault(__nccwpck_require__(7127));
|
||||||
const official_builds_1 = __importDefault(__nccwpck_require__(7854));
|
const official_builds_1 = __importDefault(__nccwpck_require__(7854));
|
||||||
const rc_builds_1 = __importDefault(__nccwpck_require__(8837));
|
const rc_builds_1 = __importDefault(__nccwpck_require__(8837));
|
||||||
const canary_builds_1 = __importDefault(__nccwpck_require__(969));
|
const canary_builds_1 = __importDefault(__nccwpck_require__(969));
|
||||||
var Distributions;
|
var Distributions;
|
||||||
(function (Distributions) {
|
(function (Distributions) {
|
||||||
Distributions["DEFAULT"] = "";
|
Distributions["DEFAULT"] = "";
|
||||||
Distributions["CANARY"] = "v8-canary";
|
Distributions["CANARY"] = "v8-canary";
|
||||||
Distributions["NIGHTLY"] = "nightly";
|
Distributions["NIGHTLY"] = "nightly";
|
||||||
Distributions["RC"] = "rc";
|
Distributions["RC"] = "rc";
|
||||||
})(Distributions || (Distributions = {}));
|
})(Distributions || (Distributions = {}));
|
||||||
function getNodejsDistribution(installerOptions) {
|
function getNodejsDistribution(installerOptions) {
|
||||||
const versionSpec = installerOptions.versionSpec;
|
const versionSpec = installerOptions.versionSpec;
|
||||||
let distribution;
|
let distribution;
|
||||||
if (versionSpec.includes(Distributions.NIGHTLY)) {
|
if (versionSpec.includes(Distributions.NIGHTLY)) {
|
||||||
distribution = new nightly_builds_1.default(installerOptions);
|
distribution = new nightly_builds_1.default(installerOptions);
|
||||||
}
|
}
|
||||||
else if (versionSpec.includes(Distributions.CANARY)) {
|
else if (versionSpec.includes(Distributions.CANARY)) {
|
||||||
distribution = new canary_builds_1.default(installerOptions);
|
distribution = new canary_builds_1.default(installerOptions);
|
||||||
}
|
}
|
||||||
else if (versionSpec.includes(Distributions.RC)) {
|
else if (versionSpec.includes(Distributions.RC)) {
|
||||||
distribution = new rc_builds_1.default(installerOptions);
|
distribution = new rc_builds_1.default(installerOptions);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
distribution = new official_builds_1.default(installerOptions);
|
distribution = new official_builds_1.default(installerOptions);
|
||||||
}
|
}
|
||||||
return distribution;
|
return distribution;
|
||||||
}
|
}
|
||||||
exports.getNodejsDistribution = getNodejsDistribution;
|
exports.getNodejsDistribution = getNodejsDistribution;
|
||||||
|
|
||||||
|
|
||||||
/***/ }),
|
/***/ }),
|
||||||
@ -71729,22 +71794,22 @@ exports.getNodejsDistribution = getNodejsDistribution;
|
|||||||
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||||
const base_distribution_prerelease_1 = __importDefault(__nccwpck_require__(957));
|
const base_distribution_prerelease_1 = __importDefault(__nccwpck_require__(957));
|
||||||
class NightlyNodejs extends base_distribution_prerelease_1.default {
|
class NightlyNodejs extends base_distribution_prerelease_1.default {
|
||||||
constructor(nodeInfo) {
|
constructor(nodeInfo) {
|
||||||
super(nodeInfo);
|
super(nodeInfo);
|
||||||
this.distribution = 'nightly';
|
this.distribution = 'nightly';
|
||||||
}
|
}
|
||||||
getDistributionUrl() {
|
getDistributionUrl() {
|
||||||
return 'https://nodejs.org/download/nightly';
|
return 'https://nodejs.org/download/nightly';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
exports["default"] = NightlyNodejs;
|
exports["default"] = NightlyNodejs;
|
||||||
|
|
||||||
|
|
||||||
/***/ }),
|
/***/ }),
|
||||||
@ -71753,203 +71818,203 @@ exports["default"] = NightlyNodejs;
|
|||||||
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||||
if (k2 === undefined) k2 = k;
|
if (k2 === undefined) k2 = k;
|
||||||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
||||||
}) : (function(o, m, k, k2) {
|
}) : (function(o, m, k, k2) {
|
||||||
if (k2 === undefined) k2 = k;
|
if (k2 === undefined) k2 = k;
|
||||||
o[k2] = m[k];
|
o[k2] = m[k];
|
||||||
}));
|
}));
|
||||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||||
}) : function(o, v) {
|
}) : function(o, v) {
|
||||||
o["default"] = v;
|
o["default"] = v;
|
||||||
});
|
});
|
||||||
var __importStar = (this && this.__importStar) || function (mod) {
|
var __importStar = (this && this.__importStar) || function (mod) {
|
||||||
if (mod && mod.__esModule) return mod;
|
if (mod && mod.__esModule) return mod;
|
||||||
var result = {};
|
var result = {};
|
||||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||||
__setModuleDefault(result, mod);
|
__setModuleDefault(result, mod);
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||||
return new (P || (P = Promise))(function (resolve, reject) {
|
return new (P || (P = Promise))(function (resolve, reject) {
|
||||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||||
const core = __importStar(__nccwpck_require__(2186));
|
const core = __importStar(__nccwpck_require__(2186));
|
||||||
const tc = __importStar(__nccwpck_require__(7784));
|
const tc = __importStar(__nccwpck_require__(7784));
|
||||||
const path_1 = __importDefault(__nccwpck_require__(1017));
|
const path_1 = __importDefault(__nccwpck_require__(1017));
|
||||||
const base_distribution_1 = __importDefault(__nccwpck_require__(7));
|
const base_distribution_1 = __importDefault(__nccwpck_require__(7));
|
||||||
class OfficialBuilds extends base_distribution_1.default {
|
class OfficialBuilds extends base_distribution_1.default {
|
||||||
constructor(nodeInfo) {
|
constructor(nodeInfo) {
|
||||||
super(nodeInfo);
|
super(nodeInfo);
|
||||||
}
|
}
|
||||||
setupNodeJs() {
|
setupNodeJs() {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
let manifest;
|
let manifest;
|
||||||
let nodeJsVersions;
|
let nodeJsVersions;
|
||||||
const osArch = this.translateArchToDistUrl(this.nodeInfo.arch);
|
const osArch = this.translateArchToDistUrl(this.nodeInfo.arch);
|
||||||
if (this.isLtsAlias(this.nodeInfo.versionSpec)) {
|
if (this.isLtsAlias(this.nodeInfo.versionSpec)) {
|
||||||
core.info('Attempt to resolve LTS alias from manifest...');
|
core.info('Attempt to resolve LTS alias from manifest...');
|
||||||
// No try-catch since it's not possible to resolve LTS alias without manifest
|
// No try-catch since it's not possible to resolve LTS alias without manifest
|
||||||
manifest = yield this.getManifest();
|
manifest = yield this.getManifest();
|
||||||
this.nodeInfo.versionSpec = this.resolveLtsAliasFromManifest(this.nodeInfo.versionSpec, this.nodeInfo.stable, manifest);
|
this.nodeInfo.versionSpec = this.resolveLtsAliasFromManifest(this.nodeInfo.versionSpec, this.nodeInfo.stable, manifest);
|
||||||
}
|
}
|
||||||
if (this.isLatestSyntax(this.nodeInfo.versionSpec)) {
|
if (this.isLatestSyntax(this.nodeInfo.versionSpec)) {
|
||||||
nodeJsVersions = yield this.getNodeJsVersions();
|
nodeJsVersions = yield this.getNodeJsVersions();
|
||||||
const versions = this.filterVersions(nodeJsVersions);
|
const versions = this.filterVersions(nodeJsVersions);
|
||||||
this.nodeInfo.versionSpec = this.evaluateVersions(versions);
|
this.nodeInfo.versionSpec = this.evaluateVersions(versions);
|
||||||
core.info('getting latest node version...');
|
core.info('getting latest node version...');
|
||||||
}
|
}
|
||||||
if (this.nodeInfo.checkLatest) {
|
if (this.nodeInfo.checkLatest) {
|
||||||
core.info('Attempt to resolve the latest version from manifest...');
|
core.info('Attempt to resolve the latest version from manifest...');
|
||||||
const resolvedVersion = yield this.resolveVersionFromManifest(this.nodeInfo.versionSpec, this.nodeInfo.stable, osArch, manifest);
|
const resolvedVersion = yield this.resolveVersionFromManifest(this.nodeInfo.versionSpec, this.nodeInfo.stable, osArch, manifest);
|
||||||
if (resolvedVersion) {
|
if (resolvedVersion) {
|
||||||
this.nodeInfo.versionSpec = resolvedVersion;
|
this.nodeInfo.versionSpec = resolvedVersion;
|
||||||
core.info(`Resolved as '${resolvedVersion}'`);
|
core.info(`Resolved as '${resolvedVersion}'`);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
core.info(`Failed to resolve version ${this.nodeInfo.versionSpec} from manifest`);
|
core.info(`Failed to resolve version ${this.nodeInfo.versionSpec} from manifest`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let toolPath = this.findVersionInHostedToolCacheDirectory();
|
let toolPath = this.findVersionInHostedToolCacheDirectory();
|
||||||
if (toolPath) {
|
if (toolPath) {
|
||||||
core.info(`Found in cache @ ${toolPath}`);
|
core.info(`Found in cache @ ${toolPath}`);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
let downloadPath = '';
|
let downloadPath = '';
|
||||||
try {
|
try {
|
||||||
core.info(`Attempting to download ${this.nodeInfo.versionSpec}...`);
|
core.info(`Attempting to download ${this.nodeInfo.versionSpec}...`);
|
||||||
const versionInfo = yield this.getInfoFromManifest(this.nodeInfo.versionSpec, this.nodeInfo.stable, osArch, manifest);
|
const versionInfo = yield this.getInfoFromManifest(this.nodeInfo.versionSpec, this.nodeInfo.stable, osArch, manifest);
|
||||||
if (versionInfo) {
|
if (versionInfo) {
|
||||||
core.info(`Acquiring ${versionInfo.resolvedVersion} - ${versionInfo.arch} from ${versionInfo.downloadUrl}`);
|
core.info(`Acquiring ${versionInfo.resolvedVersion} - ${versionInfo.arch} from ${versionInfo.downloadUrl}`);
|
||||||
downloadPath = yield tc.downloadTool(versionInfo.downloadUrl, undefined, this.nodeInfo.auth);
|
downloadPath = yield tc.downloadTool(versionInfo.downloadUrl, undefined, this.nodeInfo.auth);
|
||||||
if (downloadPath) {
|
if (downloadPath) {
|
||||||
toolPath = yield this.extractArchive(downloadPath, versionInfo);
|
toolPath = yield this.extractArchive(downloadPath, versionInfo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
core.info('Not found in manifest. Falling back to download directly from Node');
|
core.info('Not found in manifest. Falling back to download directly from Node');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
// Rate limit?
|
// Rate limit?
|
||||||
if (err instanceof tc.HTTPError &&
|
if (err instanceof tc.HTTPError &&
|
||||||
(err.httpStatusCode === 403 || err.httpStatusCode === 429)) {
|
(err.httpStatusCode === 403 || err.httpStatusCode === 429)) {
|
||||||
core.info(`Received HTTP status code ${err.httpStatusCode}. This usually indicates the rate limit has been exceeded`);
|
core.info(`Received HTTP status code ${err.httpStatusCode}. This usually indicates the rate limit has been exceeded`);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
core.info(err.message);
|
core.info(err.message);
|
||||||
}
|
}
|
||||||
core.debug(err.stack);
|
core.debug(err.stack);
|
||||||
core.info('Falling back to download directly from Node');
|
core.info('Falling back to download directly from Node');
|
||||||
}
|
}
|
||||||
if (!toolPath) {
|
if (!toolPath) {
|
||||||
const nodeJsVersions = yield this.getNodeJsVersions();
|
const nodeJsVersions = yield this.getNodeJsVersions();
|
||||||
const versions = this.filterVersions(nodeJsVersions);
|
const versions = this.filterVersions(nodeJsVersions);
|
||||||
const evaluatedVersion = this.evaluateVersions(versions);
|
const evaluatedVersion = this.evaluateVersions(versions);
|
||||||
if (!evaluatedVersion) {
|
if (!evaluatedVersion) {
|
||||||
throw new Error(`Unable to find Node version '${this.nodeInfo.versionSpec}' for platform ${this.osPlat} and architecture ${this.nodeInfo.arch}.`);
|
throw new Error(`Unable to find Node version '${this.nodeInfo.versionSpec}' for platform ${this.osPlat} and architecture ${this.nodeInfo.arch}.`);
|
||||||
}
|
}
|
||||||
const toolName = this.getNodejsDistInfo(evaluatedVersion);
|
const toolName = this.getNodejsDistInfo(evaluatedVersion);
|
||||||
toolPath = yield this.downloadNodejs(toolName);
|
toolPath = yield this.downloadNodejs(toolName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (this.osPlat != 'win32') {
|
if (this.osPlat != 'win32') {
|
||||||
toolPath = path_1.default.join(toolPath, 'bin');
|
toolPath = path_1.default.join(toolPath, 'bin');
|
||||||
}
|
}
|
||||||
core.addPath(toolPath);
|
core.addPath(toolPath);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
evaluateVersions(versions) {
|
evaluateVersions(versions) {
|
||||||
let version = '';
|
let version = '';
|
||||||
if (this.isLatestSyntax(this.nodeInfo.versionSpec)) {
|
if (this.isLatestSyntax(this.nodeInfo.versionSpec)) {
|
||||||
core.info(`getting latest node version...`);
|
core.info(`getting latest node version...`);
|
||||||
return versions[0];
|
return versions[0];
|
||||||
}
|
}
|
||||||
version = super.evaluateVersions(versions);
|
version = super.evaluateVersions(versions);
|
||||||
return version;
|
return version;
|
||||||
}
|
}
|
||||||
getDistributionUrl() {
|
getDistributionUrl() {
|
||||||
return `https://nodejs.org/dist`;
|
return `https://nodejs.org/dist`;
|
||||||
}
|
}
|
||||||
getManifest() {
|
getManifest() {
|
||||||
core.debug('Getting manifest from actions/node-versions@main');
|
core.debug('Getting manifest from actions/node-versions@main');
|
||||||
return tc.getManifestFromRepo('actions', 'node-versions', this.nodeInfo.auth, 'main');
|
return tc.getManifestFromRepo('actions', 'node-versions', this.nodeInfo.auth, 'main');
|
||||||
}
|
}
|
||||||
resolveLtsAliasFromManifest(versionSpec, stable, manifest) {
|
resolveLtsAliasFromManifest(versionSpec, stable, manifest) {
|
||||||
var _a;
|
var _a;
|
||||||
const alias = (_a = versionSpec.split('lts/')[1]) === null || _a === void 0 ? void 0 : _a.toLowerCase();
|
const alias = (_a = versionSpec.split('lts/')[1]) === null || _a === void 0 ? void 0 : _a.toLowerCase();
|
||||||
if (!alias) {
|
if (!alias) {
|
||||||
throw new Error(`Unable to parse LTS alias for Node version '${versionSpec}'`);
|
throw new Error(`Unable to parse LTS alias for Node version '${versionSpec}'`);
|
||||||
}
|
}
|
||||||
core.debug(`LTS alias '${alias}' for Node version '${versionSpec}'`);
|
core.debug(`LTS alias '${alias}' for Node version '${versionSpec}'`);
|
||||||
// Supported formats are `lts/<alias>`, `lts/*`, and `lts/-n`. Where asterisk means highest possible LTS and -n means the nth-highest.
|
// Supported formats are `lts/<alias>`, `lts/*`, and `lts/-n`. Where asterisk means highest possible LTS and -n means the nth-highest.
|
||||||
const n = Number(alias);
|
const n = Number(alias);
|
||||||
const aliases = Object.fromEntries(manifest
|
const aliases = Object.fromEntries(manifest
|
||||||
.filter(x => x.lts && x.stable === stable)
|
.filter(x => x.lts && x.stable === stable)
|
||||||
.map(x => [x.lts.toLowerCase(), x])
|
.map(x => [x.lts.toLowerCase(), x])
|
||||||
.reverse());
|
.reverse());
|
||||||
const numbered = Object.values(aliases);
|
const numbered = Object.values(aliases);
|
||||||
const release = alias === '*'
|
const release = alias === '*'
|
||||||
? numbered[numbered.length - 1]
|
? numbered[numbered.length - 1]
|
||||||
: n < 0
|
: n < 0
|
||||||
? numbered[numbered.length - 1 + n]
|
? numbered[numbered.length - 1 + n]
|
||||||
: aliases[alias];
|
: aliases[alias];
|
||||||
if (!release) {
|
if (!release) {
|
||||||
throw new Error(`Unable to find LTS release '${alias}' for Node version '${versionSpec}'.`);
|
throw new Error(`Unable to find LTS release '${alias}' for Node version '${versionSpec}'.`);
|
||||||
}
|
}
|
||||||
core.debug(`Found LTS release '${release.version}' for Node version '${versionSpec}'`);
|
core.debug(`Found LTS release '${release.version}' for Node version '${versionSpec}'`);
|
||||||
return release.version.split('.')[0];
|
return release.version.split('.')[0];
|
||||||
}
|
}
|
||||||
resolveVersionFromManifest(versionSpec, stable, osArch, manifest) {
|
resolveVersionFromManifest(versionSpec, stable, osArch, manifest) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
try {
|
try {
|
||||||
const info = yield this.getInfoFromManifest(versionSpec, stable, osArch, manifest);
|
const info = yield this.getInfoFromManifest(versionSpec, stable, osArch, manifest);
|
||||||
return info === null || info === void 0 ? void 0 : info.resolvedVersion;
|
return info === null || info === void 0 ? void 0 : info.resolvedVersion;
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
core.info('Unable to resolve version from manifest...');
|
core.info('Unable to resolve version from manifest...');
|
||||||
core.debug(err.message);
|
core.debug(err.message);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
getInfoFromManifest(versionSpec, stable, osArch, manifest) {
|
getInfoFromManifest(versionSpec, stable, osArch, manifest) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
let info = null;
|
let info = null;
|
||||||
if (!manifest) {
|
if (!manifest) {
|
||||||
core.debug('No manifest cached');
|
core.debug('No manifest cached');
|
||||||
manifest = yield this.getManifest();
|
manifest = yield this.getManifest();
|
||||||
}
|
}
|
||||||
const rel = yield tc.findFromManifest(versionSpec, stable, manifest, osArch);
|
const rel = yield tc.findFromManifest(versionSpec, stable, manifest, osArch);
|
||||||
if (rel && rel.files.length > 0) {
|
if (rel && rel.files.length > 0) {
|
||||||
info = {};
|
info = {};
|
||||||
info.resolvedVersion = rel.version;
|
info.resolvedVersion = rel.version;
|
||||||
info.arch = rel.files[0].arch;
|
info.arch = rel.files[0].arch;
|
||||||
info.downloadUrl = rel.files[0].download_url;
|
info.downloadUrl = rel.files[0].download_url;
|
||||||
info.fileName = rel.files[0].filename;
|
info.fileName = rel.files[0].filename;
|
||||||
}
|
}
|
||||||
return info;
|
return info;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
isLtsAlias(versionSpec) {
|
isLtsAlias(versionSpec) {
|
||||||
return versionSpec.startsWith('lts/');
|
return versionSpec.startsWith('lts/');
|
||||||
}
|
}
|
||||||
isLatestSyntax(versionSpec) {
|
isLatestSyntax(versionSpec) {
|
||||||
return ['current', 'latest', 'node'].includes(versionSpec);
|
return ['current', 'latest', 'node'].includes(versionSpec);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
exports["default"] = OfficialBuilds;
|
exports["default"] = OfficialBuilds;
|
||||||
|
|
||||||
|
|
||||||
/***/ }),
|
/***/ }),
|
||||||
@ -71958,21 +72023,21 @@ exports["default"] = OfficialBuilds;
|
|||||||
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||||
const base_distribution_1 = __importDefault(__nccwpck_require__(7));
|
const base_distribution_1 = __importDefault(__nccwpck_require__(7));
|
||||||
class RcBuild extends base_distribution_1.default {
|
class RcBuild extends base_distribution_1.default {
|
||||||
constructor(nodeInfo) {
|
constructor(nodeInfo) {
|
||||||
super(nodeInfo);
|
super(nodeInfo);
|
||||||
}
|
}
|
||||||
getDistributionUrl() {
|
getDistributionUrl() {
|
||||||
return 'https://nodejs.org/download/rc';
|
return 'https://nodejs.org/download/rc';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
exports["default"] = RcBuild;
|
exports["default"] = RcBuild;
|
||||||
|
|
||||||
|
|
||||||
/***/ }),
|
/***/ }),
|
||||||
@ -71981,22 +72046,22 @@ exports["default"] = RcBuild;
|
|||||||
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||||
const base_distribution_prerelease_1 = __importDefault(__nccwpck_require__(957));
|
const base_distribution_prerelease_1 = __importDefault(__nccwpck_require__(957));
|
||||||
class CanaryBuild extends base_distribution_prerelease_1.default {
|
class CanaryBuild extends base_distribution_prerelease_1.default {
|
||||||
constructor(nodeInfo) {
|
constructor(nodeInfo) {
|
||||||
super(nodeInfo);
|
super(nodeInfo);
|
||||||
this.distribution = 'v8-canary';
|
this.distribution = 'v8-canary';
|
||||||
}
|
}
|
||||||
getDistributionUrl() {
|
getDistributionUrl() {
|
||||||
return 'https://nodejs.org/download/v8-canary';
|
return 'https://nodejs.org/download/v8-canary';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
exports["default"] = CanaryBuild;
|
exports["default"] = CanaryBuild;
|
||||||
|
|
||||||
|
|
||||||
/***/ }),
|
/***/ }),
|
||||||
@ -72005,122 +72070,122 @@ exports["default"] = CanaryBuild;
|
|||||||
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||||
if (k2 === undefined) k2 = k;
|
if (k2 === undefined) k2 = k;
|
||||||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
||||||
}) : (function(o, m, k, k2) {
|
}) : (function(o, m, k, k2) {
|
||||||
if (k2 === undefined) k2 = k;
|
if (k2 === undefined) k2 = k;
|
||||||
o[k2] = m[k];
|
o[k2] = m[k];
|
||||||
}));
|
}));
|
||||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||||
}) : function(o, v) {
|
}) : function(o, v) {
|
||||||
o["default"] = v;
|
o["default"] = v;
|
||||||
});
|
});
|
||||||
var __importStar = (this && this.__importStar) || function (mod) {
|
var __importStar = (this && this.__importStar) || function (mod) {
|
||||||
if (mod && mod.__esModule) return mod;
|
if (mod && mod.__esModule) return mod;
|
||||||
var result = {};
|
var result = {};
|
||||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||||
__setModuleDefault(result, mod);
|
__setModuleDefault(result, mod);
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||||
return new (P || (P = Promise))(function (resolve, reject) {
|
return new (P || (P = Promise))(function (resolve, reject) {
|
||||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||||
exports.run = void 0;
|
exports.run = void 0;
|
||||||
const core = __importStar(__nccwpck_require__(2186));
|
const core = __importStar(__nccwpck_require__(2186));
|
||||||
const fs_1 = __importDefault(__nccwpck_require__(7147));
|
const fs_1 = __importDefault(__nccwpck_require__(7147));
|
||||||
const os_1 = __importDefault(__nccwpck_require__(2037));
|
const os_1 = __importDefault(__nccwpck_require__(2037));
|
||||||
const auth = __importStar(__nccwpck_require__(7573));
|
const auth = __importStar(__nccwpck_require__(7573));
|
||||||
const path = __importStar(__nccwpck_require__(1017));
|
const path = __importStar(__nccwpck_require__(1017));
|
||||||
const cache_restore_1 = __nccwpck_require__(9517);
|
const cache_restore_1 = __nccwpck_require__(9517);
|
||||||
const cache_utils_1 = __nccwpck_require__(1678);
|
const cache_utils_1 = __nccwpck_require__(1678);
|
||||||
const installer_factory_1 = __nccwpck_require__(5617);
|
const installer_factory_1 = __nccwpck_require__(5617);
|
||||||
const util_1 = __nccwpck_require__(2629);
|
const util_1 = __nccwpck_require__(2629);
|
||||||
function run() {
|
function run() {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
try {
|
try {
|
||||||
//
|
//
|
||||||
// Version is optional. If supplied, install / use from the tool cache
|
// Version is optional. If supplied, install / use from the tool cache
|
||||||
// If not supplied then task is still used to setup proxy, auth, etc...
|
// If not supplied then task is still used to setup proxy, auth, etc...
|
||||||
//
|
//
|
||||||
const version = resolveVersionInput();
|
const version = resolveVersionInput();
|
||||||
let arch = core.getInput('architecture');
|
let arch = core.getInput('architecture');
|
||||||
const cache = core.getInput('cache');
|
const cache = core.getInput('cache');
|
||||||
// if architecture supplied but node-version is not
|
// if architecture supplied but node-version is not
|
||||||
// if we don't throw a warning, the already installed x64 node will be used which is not probably what user meant.
|
// if we don't throw a warning, the already installed x64 node will be used which is not probably what user meant.
|
||||||
if (arch && !version) {
|
if (arch && !version) {
|
||||||
core.warning('`architecture` is provided but `node-version` is missing. In this configuration, the version/architecture of Node will not be changed. To fix this, provide `architecture` in combination with `node-version`');
|
core.warning('`architecture` is provided but `node-version` is missing. In this configuration, the version/architecture of Node will not be changed. To fix this, provide `architecture` in combination with `node-version`');
|
||||||
}
|
}
|
||||||
if (!arch) {
|
if (!arch) {
|
||||||
arch = os_1.default.arch();
|
arch = os_1.default.arch();
|
||||||
}
|
}
|
||||||
if (version) {
|
if (version) {
|
||||||
const token = core.getInput('token');
|
const token = core.getInput('token');
|
||||||
const auth = !token ? undefined : `token ${token}`;
|
const auth = !token ? undefined : `token ${token}`;
|
||||||
const stable = (core.getInput('stable') || 'true').toUpperCase() === 'TRUE';
|
const stable = (core.getInput('stable') || 'true').toUpperCase() === 'TRUE';
|
||||||
const checkLatest = (core.getInput('check-latest') || 'false').toUpperCase() === 'TRUE';
|
const checkLatest = (core.getInput('check-latest') || 'false').toUpperCase() === 'TRUE';
|
||||||
const nodejsInfo = {
|
const nodejsInfo = {
|
||||||
versionSpec: version,
|
versionSpec: version,
|
||||||
checkLatest,
|
checkLatest,
|
||||||
auth,
|
auth,
|
||||||
stable,
|
stable,
|
||||||
arch
|
arch
|
||||||
};
|
};
|
||||||
const nodeDistribution = installer_factory_1.getNodejsDistribution(nodejsInfo);
|
const nodeDistribution = installer_factory_1.getNodejsDistribution(nodejsInfo);
|
||||||
yield nodeDistribution.setupNodeJs();
|
yield nodeDistribution.setupNodeJs();
|
||||||
}
|
}
|
||||||
yield util_1.printEnvDetailsAndSetOutput();
|
yield util_1.printEnvDetailsAndSetOutput();
|
||||||
const registryUrl = core.getInput('registry-url');
|
const registryUrl = core.getInput('registry-url');
|
||||||
const alwaysAuth = core.getInput('always-auth');
|
const alwaysAuth = core.getInput('always-auth');
|
||||||
if (registryUrl) {
|
if (registryUrl) {
|
||||||
auth.configAuthentication(registryUrl, alwaysAuth);
|
auth.configAuthentication(registryUrl, alwaysAuth);
|
||||||
}
|
}
|
||||||
if (cache && cache_utils_1.isCacheFeatureAvailable()) {
|
if (cache && cache_utils_1.isCacheFeatureAvailable()) {
|
||||||
const cacheDependencyPath = core.getInput('cache-dependency-path');
|
const cacheDependencyPath = core.getInput('cache-dependency-path');
|
||||||
yield cache_restore_1.restoreCache(cache, cacheDependencyPath);
|
yield cache_restore_1.restoreCache(cache, cacheDependencyPath);
|
||||||
}
|
}
|
||||||
const matchersPath = path.join(__dirname, '../..', '.github');
|
const matchersPath = path.join(__dirname, '../..', '.github');
|
||||||
core.info(`##[add-matcher]${path.join(matchersPath, 'tsc.json')}`);
|
core.info(`##[add-matcher]${path.join(matchersPath, 'tsc.json')}`);
|
||||||
core.info(`##[add-matcher]${path.join(matchersPath, 'eslint-stylish.json')}`);
|
core.info(`##[add-matcher]${path.join(matchersPath, 'eslint-stylish.json')}`);
|
||||||
core.info(`##[add-matcher]${path.join(matchersPath, 'eslint-compact.json')}`);
|
core.info(`##[add-matcher]${path.join(matchersPath, 'eslint-compact.json')}`);
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
core.setFailed(err.message);
|
core.setFailed(err.message);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
exports.run = run;
|
exports.run = run;
|
||||||
function resolveVersionInput() {
|
function resolveVersionInput() {
|
||||||
let version = core.getInput('node-version');
|
let version = core.getInput('node-version');
|
||||||
const versionFileInput = core.getInput('node-version-file');
|
const versionFileInput = core.getInput('node-version-file');
|
||||||
if (version && versionFileInput) {
|
if (version && versionFileInput) {
|
||||||
core.warning('Both node-version and node-version-file inputs are specified, only node-version will be used');
|
core.warning('Both node-version and node-version-file inputs are specified, only node-version will be used');
|
||||||
}
|
}
|
||||||
if (version) {
|
if (version) {
|
||||||
return version;
|
return version;
|
||||||
}
|
}
|
||||||
if (versionFileInput) {
|
if (versionFileInput) {
|
||||||
const versionFilePath = path.join(process.env.GITHUB_WORKSPACE, versionFileInput);
|
const versionFilePath = path.join(process.env.GITHUB_WORKSPACE, versionFileInput);
|
||||||
if (!fs_1.default.existsSync(versionFilePath)) {
|
if (!fs_1.default.existsSync(versionFilePath)) {
|
||||||
throw new Error(`The specified node version file at: ${versionFilePath} does not exist`);
|
throw new Error(`The specified node version file at: ${versionFilePath} does not exist`);
|
||||||
}
|
}
|
||||||
version = util_1.parseNodeVersionFile(fs_1.default.readFileSync(versionFilePath, 'utf8'));
|
version = util_1.parseNodeVersionFile(fs_1.default.readFileSync(versionFilePath, 'utf8'));
|
||||||
core.info(`Resolved ${versionFileInput} as ${version}`);
|
core.info(`Resolved ${versionFileInput} as ${version}`);
|
||||||
}
|
}
|
||||||
return version;
|
return version;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/***/ }),
|
/***/ }),
|
||||||
@ -72129,98 +72194,108 @@ function resolveVersionInput() {
|
|||||||
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||||
if (k2 === undefined) k2 = k;
|
if (k2 === undefined) k2 = k;
|
||||||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
||||||
}) : (function(o, m, k, k2) {
|
}) : (function(o, m, k, k2) {
|
||||||
if (k2 === undefined) k2 = k;
|
if (k2 === undefined) k2 = k;
|
||||||
o[k2] = m[k];
|
o[k2] = m[k];
|
||||||
}));
|
}));
|
||||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||||
}) : function(o, v) {
|
}) : function(o, v) {
|
||||||
o["default"] = v;
|
o["default"] = v;
|
||||||
});
|
});
|
||||||
var __importStar = (this && this.__importStar) || function (mod) {
|
var __importStar = (this && this.__importStar) || function (mod) {
|
||||||
if (mod && mod.__esModule) return mod;
|
if (mod && mod.__esModule) return mod;
|
||||||
var result = {};
|
var result = {};
|
||||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||||
__setModuleDefault(result, mod);
|
__setModuleDefault(result, mod);
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||||
return new (P || (P = Promise))(function (resolve, reject) {
|
return new (P || (P = Promise))(function (resolve, reject) {
|
||||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||||
exports.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(/^(?:nodejs\s+)?v?(?<version>[^\s]+)$/m);
|
const found = contents.match(/^(?:nodejs\s+)?v?(?<version>[^\s]+)$/m);
|
||||||
nodeVersion = (_c = found === null || found === void 0 ? void 0 : found.groups) === null || _c === void 0 ? void 0 : _c.version;
|
nodeVersion = (_c = found === null || found === void 0 ? void 0 : found.groups) === null || _c === void 0 ? void 0 : _c.version;
|
||||||
}
|
}
|
||||||
// In the case of an unknown format,
|
// In the case of an unknown format,
|
||||||
// return as is and evaluate the version separately.
|
// return as is and evaluate the version separately.
|
||||||
if (!nodeVersion)
|
if (!nodeVersion)
|
||||||
nodeVersion = contents.trim();
|
nodeVersion = contents.trim();
|
||||||
return nodeVersion;
|
return nodeVersion;
|
||||||
}
|
}
|
||||||
exports.parseNodeVersionFile = parseNodeVersionFile;
|
exports.parseNodeVersionFile = parseNodeVersionFile;
|
||||||
function printEnvDetailsAndSetOutput() {
|
function printEnvDetailsAndSetOutput() {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
core.startGroup('Environment details');
|
core.startGroup('Environment details');
|
||||||
const promises = ['node', 'npm', 'yarn'].map((tool) => __awaiter(this, void 0, void 0, function* () {
|
const promises = ['node', 'npm', 'yarn'].map((tool) => __awaiter(this, void 0, void 0, function* () {
|
||||||
const output = yield getToolVersion(tool, ['--version']);
|
const output = yield getToolVersion(tool, ['--version']);
|
||||||
return { tool, output };
|
return { tool, output };
|
||||||
}));
|
}));
|
||||||
const tools = yield Promise.all(promises);
|
const tools = yield Promise.all(promises);
|
||||||
tools.forEach(({ tool, output }) => {
|
tools.forEach(({ tool, output }) => {
|
||||||
if (tool === 'node') {
|
if (tool === 'node') {
|
||||||
core.setOutput(`${tool}-version`, output);
|
core.setOutput(`${tool}-version`, output);
|
||||||
}
|
}
|
||||||
core.info(`${tool}: ${output}`);
|
core.info(`${tool}: ${output}`);
|
||||||
});
|
});
|
||||||
core.endGroup();
|
core.endGroup();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
exports.printEnvDetailsAndSetOutput = printEnvDetailsAndSetOutput;
|
exports.printEnvDetailsAndSetOutput = printEnvDetailsAndSetOutput;
|
||||||
function getToolVersion(tool, options) {
|
function getToolVersion(tool, options) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
try {
|
try {
|
||||||
const { stdout, stderr, exitCode } = yield exec.getExecOutput(tool, options, {
|
const { stdout, stderr, exitCode } = yield exec.getExecOutput(tool, options, {
|
||||||
ignoreReturnCode: true,
|
ignoreReturnCode: true,
|
||||||
silent: true
|
silent: true
|
||||||
});
|
});
|
||||||
if (exitCode > 0) {
|
if (exitCode > 0) {
|
||||||
core.info(`[warning]${stderr}`);
|
core.info(`[warning]${stderr}`);
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
return stdout.trim();
|
return stdout.trim();
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
const unique = () => {
|
||||||
|
const encountered = new Set();
|
||||||
|
return (value) => {
|
||||||
|
if (encountered.has(value))
|
||||||
|
return false;
|
||||||
|
encountered.add(value);
|
||||||
|
return true;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
exports.unique = unique;
|
||||||
|
|
||||||
|
|
||||||
/***/ }),
|
/***/ }),
|
||||||
@ -72468,10 +72543,10 @@ var __webpack_exports__ = {};
|
|||||||
(() => {
|
(() => {
|
||||||
"use strict";
|
"use strict";
|
||||||
var exports = __webpack_exports__;
|
var exports = __webpack_exports__;
|
||||||
|
|
||||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||||
const main_1 = __nccwpck_require__(399);
|
const main_1 = __nccwpck_require__(399);
|
||||||
main_1.run();
|
main_1.run();
|
||||||
|
|
||||||
})();
|
})();
|
||||||
|
|
||||||
|
|||||||
@ -6,14 +6,14 @@ import fs from 'fs';
|
|||||||
|
|
||||||
import {State} from './constants';
|
import {State} from './constants';
|
||||||
import {
|
import {
|
||||||
getCacheDirectoryPath,
|
getCacheDirectories,
|
||||||
getPackageManagerInfo,
|
getPackageManagerInfo,
|
||||||
PackageManagerInfo
|
PackageManagerInfo
|
||||||
} from './cache-utils';
|
} from './cache-utils';
|
||||||
|
|
||||||
export const restoreCache = async (
|
export const restoreCache = async (
|
||||||
packageManager: string,
|
packageManager: string,
|
||||||
cacheDependencyPath?: string
|
cacheDependencyPath: string
|
||||||
) => {
|
) => {
|
||||||
const packageManagerInfo = await getPackageManagerInfo(packageManager);
|
const packageManagerInfo = await getPackageManagerInfo(packageManager);
|
||||||
if (!packageManagerInfo) {
|
if (!packageManagerInfo) {
|
||||||
@ -21,10 +21,11 @@ export const restoreCache = async (
|
|||||||
}
|
}
|
||||||
const platform = process.env.RUNNER_OS;
|
const platform = process.env.RUNNER_OS;
|
||||||
|
|
||||||
const cachePath = await getCacheDirectoryPath(
|
const cachePaths = await getCacheDirectories(
|
||||||
packageManagerInfo,
|
packageManagerInfo,
|
||||||
packageManager
|
cacheDependencyPath
|
||||||
);
|
);
|
||||||
|
core.saveState(State.CachePaths, cachePaths);
|
||||||
const lockFilePath = cacheDependencyPath
|
const lockFilePath = cacheDependencyPath
|
||||||
? cacheDependencyPath
|
? cacheDependencyPath
|
||||||
: findLockFile(packageManagerInfo);
|
: findLockFile(packageManagerInfo);
|
||||||
@ -41,7 +42,7 @@ export const restoreCache = async (
|
|||||||
|
|
||||||
core.saveState(State.CachePrimaryKey, primaryKey);
|
core.saveState(State.CachePrimaryKey, primaryKey);
|
||||||
|
|
||||||
const cacheKey = await cache.restoreCache([cachePath], primaryKey);
|
const cacheKey = await cache.restoreCache(cachePaths, primaryKey);
|
||||||
core.setOutput('cache-hit', Boolean(cacheKey));
|
core.setOutput('cache-hit', Boolean(cacheKey));
|
||||||
|
|
||||||
if (!cacheKey) {
|
if (!cacheKey) {
|
||||||
@ -56,6 +57,7 @@ export const restoreCache = async (
|
|||||||
const findLockFile = (packageManager: PackageManagerInfo) => {
|
const findLockFile = (packageManager: PackageManagerInfo) => {
|
||||||
const lockFiles = packageManager.lockFilePatterns;
|
const lockFiles = packageManager.lockFilePatterns;
|
||||||
const workspace = process.env.GITHUB_WORKSPACE!;
|
const workspace = process.env.GITHUB_WORKSPACE!;
|
||||||
|
|
||||||
const rootContent = fs.readdirSync(workspace);
|
const rootContent = fs.readdirSync(workspace);
|
||||||
|
|
||||||
const lockFile = lockFiles.find(item => rootContent.includes(item));
|
const lockFile = lockFiles.find(item => rootContent.includes(item));
|
||||||
|
|||||||
@ -1,8 +1,7 @@
|
|||||||
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 {getCacheDirectoryPath, getPackageManagerInfo} from './cache-utils';
|
import {getPackageManagerInfo} from './cache-utils';
|
||||||
|
|
||||||
// Catch and log any unhandled exceptions. These exceptions can leak out of the uploadChunk method in
|
// Catch and log any unhandled exceptions. These exceptions can leak out of the uploadChunk method in
|
||||||
// @actions/toolkit when a failed upload closes the file descriptor causing any in-process reads to
|
// @actions/toolkit when a failed upload closes the file descriptor causing any in-process reads to
|
||||||
@ -24,6 +23,7 @@ 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(core.getState(State.CachePaths) || '[]');
|
||||||
|
|
||||||
const packageManagerInfo = await getPackageManagerInfo(packageManager);
|
const packageManagerInfo = await getPackageManagerInfo(packageManager);
|
||||||
if (!packageManagerInfo) {
|
if (!packageManagerInfo) {
|
||||||
@ -31,14 +31,12 @@ const cachePackages = async (packageManager: string) => {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const cachePath = await getCacheDirectoryPath(
|
if (cachePaths.length === 0) {
|
||||||
packageManagerInfo,
|
// TODO: core.getInput has a bug - it can return undefined despite its definition (tests only?)
|
||||||
packageManager
|
// export declare function getInput(name: string, options?: InputOptions): string;
|
||||||
);
|
const cacheDependencyPath = core.getInput('cache-dependency-path') || '';
|
||||||
|
|
||||||
if (!fs.existsSync(cachePath)) {
|
|
||||||
throw new Error(
|
throw new Error(
|
||||||
`Cache folder path is retrieved for ${packageManager} but doesn't exist on disk: ${cachePath}`
|
`Cache folder paths are not retrieved for ${packageManager} with cache-dependency-path = ${cacheDependencyPath}`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -49,7 +47,7 @@ const cachePackages = async (packageManager: string) => {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const cacheId = await cache.saveCache([cachePath], primaryKey);
|
const cacheId = await cache.saveCache(cachePaths, primaryKey);
|
||||||
if (cacheId == -1) {
|
if (cacheId == -1) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,40 +1,79 @@
|
|||||||
import * as core from '@actions/core';
|
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';
|
||||||
type SupportedPackageManagers = {
|
import path from 'path';
|
||||||
[prop: string]: PackageManagerInfo;
|
import fs from 'fs';
|
||||||
};
|
import {unique} from './util';
|
||||||
|
|
||||||
export interface PackageManagerInfo {
|
export interface PackageManagerInfo {
|
||||||
|
name: string;
|
||||||
lockFilePatterns: Array<string>;
|
lockFilePatterns: Array<string>;
|
||||||
getCacheFolderCommand: string;
|
getCacheFolderPath: (projectDir?: string) => Promise<string>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
interface SupportedPackageManagers {
|
||||||
|
npm: PackageManagerInfo;
|
||||||
|
pnpm: PackageManagerInfo;
|
||||||
|
yarn: PackageManagerInfo;
|
||||||
|
}
|
||||||
export const supportedPackageManagers: SupportedPackageManagers = {
|
export const supportedPackageManagers: SupportedPackageManagers = {
|
||||||
npm: {
|
npm: {
|
||||||
|
name: 'npm',
|
||||||
lockFilePatterns: ['package-lock.json', 'npm-shrinkwrap.json', 'yarn.lock'],
|
lockFilePatterns: ['package-lock.json', 'npm-shrinkwrap.json', 'yarn.lock'],
|
||||||
getCacheFolderCommand: 'npm config get cache'
|
getCacheFolderPath: () =>
|
||||||
|
getCommandOutputNotEmpty(
|
||||||
|
'npm config get cache',
|
||||||
|
'Could not get npm cache folder path'
|
||||||
|
)
|
||||||
},
|
},
|
||||||
pnpm: {
|
pnpm: {
|
||||||
|
name: 'pnpm',
|
||||||
lockFilePatterns: ['pnpm-lock.yaml'],
|
lockFilePatterns: ['pnpm-lock.yaml'],
|
||||||
getCacheFolderCommand: 'pnpm store path --silent'
|
getCacheFolderPath: () =>
|
||||||
|
getCommandOutputNotEmpty(
|
||||||
|
'pnpm store path --silent',
|
||||||
|
'Could not get pnpm cache folder path'
|
||||||
|
)
|
||||||
},
|
},
|
||||||
yarn1: {
|
yarn: {
|
||||||
|
name: 'yarn',
|
||||||
lockFilePatterns: ['yarn.lock'],
|
lockFilePatterns: ['yarn.lock'],
|
||||||
getCacheFolderCommand: 'yarn cache dir'
|
getCacheFolderPath: async projectDir => {
|
||||||
},
|
const yarnVersion = await getCommandOutputNotEmpty(
|
||||||
yarn2: {
|
`yarn --version`,
|
||||||
lockFilePatterns: ['yarn.lock'],
|
'Could not retrieve version of yarn',
|
||||||
getCacheFolderCommand: 'yarn config get cacheFolder'
|
projectDir
|
||||||
|
);
|
||||||
|
|
||||||
|
core.debug(
|
||||||
|
`Consumed yarn version is ${yarnVersion} (working dir: "${
|
||||||
|
projectDir || ''
|
||||||
|
}")`
|
||||||
|
);
|
||||||
|
|
||||||
|
const stdOut = yarnVersion.startsWith('1.')
|
||||||
|
? await getCommandOutput('yarn cache dir', projectDir)
|
||||||
|
: await getCommandOutput('yarn config get cacheFolder', projectDir);
|
||||||
|
|
||||||
|
if (!stdOut) {
|
||||||
|
throw new Error(
|
||||||
|
`Could not get yarn cache folder path for ${projectDir}`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return stdOut;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getCommandOutput = async (toolCommand: string) => {
|
export const getCommandOutput = async (
|
||||||
|
toolCommand: string,
|
||||||
|
cwd?: string
|
||||||
|
): Promise<string> => {
|
||||||
let {stdout, stderr, exitCode} = await exec.getExecOutput(
|
let {stdout, stderr, exitCode} = await exec.getExecOutput(
|
||||||
toolCommand,
|
toolCommand,
|
||||||
undefined,
|
undefined,
|
||||||
{ignoreReturnCode: true}
|
{ignoreReturnCode: true, ...(cwd && {cwd})}
|
||||||
);
|
);
|
||||||
|
|
||||||
if (exitCode) {
|
if (exitCode) {
|
||||||
@ -47,16 +86,15 @@ export const getCommandOutput = async (toolCommand: string) => {
|
|||||||
return stdout.trim();
|
return stdout.trim();
|
||||||
};
|
};
|
||||||
|
|
||||||
const getPackageManagerVersion = async (
|
export const getCommandOutputNotEmpty = async (
|
||||||
packageManager: string,
|
toolCommand: string,
|
||||||
command: string
|
error: string,
|
||||||
) => {
|
cwd?: string
|
||||||
const stdOut = await getCommandOutput(`${packageManager} ${command}`);
|
): Promise<string> => {
|
||||||
|
const stdOut = getCommandOutput(toolCommand, cwd);
|
||||||
if (!stdOut) {
|
if (!stdOut) {
|
||||||
throw new Error(`Could not retrieve version of ${packageManager}`);
|
throw new Error(error);
|
||||||
}
|
}
|
||||||
|
|
||||||
return stdOut;
|
return stdOut;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -66,35 +104,102 @@ export const getPackageManagerInfo = async (packageManager: string) => {
|
|||||||
} else if (packageManager === 'pnpm') {
|
} else if (packageManager === 'pnpm') {
|
||||||
return supportedPackageManagers.pnpm;
|
return supportedPackageManagers.pnpm;
|
||||||
} else if (packageManager === 'yarn') {
|
} else if (packageManager === 'yarn') {
|
||||||
const yarnVersion = await getPackageManagerVersion('yarn', '--version');
|
return supportedPackageManagers.yarn;
|
||||||
|
|
||||||
core.debug(`Consumed yarn version is ${yarnVersion}`);
|
|
||||||
|
|
||||||
if (yarnVersion.startsWith('1.')) {
|
|
||||||
return supportedPackageManagers.yarn1;
|
|
||||||
} else {
|
|
||||||
return supportedPackageManagers.yarn2;
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getCacheDirectoryPath = async (
|
/**
|
||||||
|
* 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
|
||||||
|
* expected to be the result of `core.getInput('cache-dependency-path')`
|
||||||
|
* @return list of directories and possible
|
||||||
|
*/
|
||||||
|
const getProjectDirectoriesFromCacheDependencyPath = async (
|
||||||
|
cacheDependencyPath: string
|
||||||
|
): Promise<string[]> => {
|
||||||
|
const globber = await glob.create(cacheDependencyPath);
|
||||||
|
const cacheDependenciesPaths = await globber.glob();
|
||||||
|
|
||||||
|
const existingDirectories: string[] = cacheDependenciesPaths
|
||||||
|
.map(path.dirname)
|
||||||
|
.filter(unique())
|
||||||
|
.filter(directory => fs.lstatSync(directory).isDirectory());
|
||||||
|
|
||||||
|
if (!existingDirectories.length)
|
||||||
|
core.warning(
|
||||||
|
`No existing directories found containing cache-dependency-path="${cacheDependencyPath}"`
|
||||||
|
);
|
||||||
|
|
||||||
|
return existingDirectories;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Finds the cache directories configured for the repo if cache-dependency-path is not empty
|
||||||
|
* @param packageManagerInfo - an object having getCacheFolderPath method specific to given PM
|
||||||
|
* @param cacheDependencyPath - either a single string or multiline string with possible glob patterns
|
||||||
|
* expected to be the result of `core.getInput('cache-dependency-path')`
|
||||||
|
* @return list of files on which the cache depends
|
||||||
|
*/
|
||||||
|
const getCacheDirectoriesFromCacheDependencyPath = async (
|
||||||
packageManagerInfo: PackageManagerInfo,
|
packageManagerInfo: PackageManagerInfo,
|
||||||
packageManager: string
|
cacheDependencyPath: string
|
||||||
) => {
|
): Promise<string[]> => {
|
||||||
const stdOut = await getCommandOutput(
|
const projectDirectories = await getProjectDirectoriesFromCacheDependencyPath(
|
||||||
packageManagerInfo.getCacheFolderCommand
|
cacheDependencyPath
|
||||||
);
|
);
|
||||||
|
const cacheFoldersPaths = await Promise.all(
|
||||||
|
projectDirectories.map(async projectDirectory => {
|
||||||
|
const cacheFolderPath =
|
||||||
|
packageManagerInfo.getCacheFolderPath(projectDirectory);
|
||||||
|
core.debug(
|
||||||
|
`${packageManagerInfo.name}'s cache folder "${cacheFolderPath}" configured for the directory "${projectDirectory}"`
|
||||||
|
);
|
||||||
|
return cacheFolderPath;
|
||||||
|
})
|
||||||
|
);
|
||||||
|
// uniq in order to do not cache the same directories twice
|
||||||
|
return cacheFoldersPaths.filter(unique());
|
||||||
|
};
|
||||||
|
|
||||||
if (!stdOut) {
|
/**
|
||||||
throw new Error(`Could not get cache folder path for ${packageManager}`);
|
* Finds the cache directories configured for the repo ignoring cache-dependency-path
|
||||||
|
* @param packageManagerInfo - an object having getCacheFolderPath method specific to given PM
|
||||||
|
* @return list of files on which the cache depends
|
||||||
|
*/
|
||||||
|
const getCacheDirectoriesForRootProject = async (
|
||||||
|
packageManagerInfo: PackageManagerInfo
|
||||||
|
): Promise<string[]> => {
|
||||||
|
const cacheFolderPath = await packageManagerInfo.getCacheFolderPath();
|
||||||
|
core.debug(
|
||||||
|
`${packageManagerInfo.name}'s cache folder "${cacheFolderPath}" configured for the root directory`
|
||||||
|
);
|
||||||
|
return [cacheFolderPath];
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A function to find the cache directories configured for the repo
|
||||||
|
* currently it handles only the case of PM=yarn && cacheDependencyPath is not empty
|
||||||
|
* @param packageManagerInfo - an object having getCacheFolderPath method specific to given PM
|
||||||
|
* @param cacheDependencyPath - either a single string or multiline string with possible glob patterns
|
||||||
|
* expected to be the result of `core.getInput('cache-dependency-path')`
|
||||||
|
* @return list of files on which the cache depends
|
||||||
|
*/
|
||||||
|
export const getCacheDirectories = async (
|
||||||
|
packageManagerInfo: PackageManagerInfo,
|
||||||
|
cacheDependencyPath: string
|
||||||
|
): Promise<string[]> => {
|
||||||
|
// 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
|
||||||
|
if (packageManagerInfo.name === 'yarn' && cacheDependencyPath) {
|
||||||
|
return getCacheDirectoriesFromCacheDependencyPath(
|
||||||
|
packageManagerInfo,
|
||||||
|
cacheDependencyPath
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
return getCacheDirectoriesForRootProject(packageManagerInfo);
|
||||||
core.debug(`${packageManager} path is ${stdOut}`);
|
|
||||||
|
|
||||||
return stdOut.trim();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export function isGhes(): boolean {
|
export function isGhes(): boolean {
|
||||||
|
|||||||
@ -6,7 +6,8 @@ export enum LockType {
|
|||||||
|
|
||||||
export enum State {
|
export enum State {
|
||||||
CachePrimaryKey = 'CACHE_KEY',
|
CachePrimaryKey = 'CACHE_KEY',
|
||||||
CacheMatchedKey = 'CACHE_RESULT'
|
CacheMatchedKey = 'CACHE_RESULT',
|
||||||
|
CachePaths = 'CACHE_PATHS'
|
||||||
}
|
}
|
||||||
|
|
||||||
export enum Outputs {
|
export enum Outputs {
|
||||||
|
|||||||
@ -61,3 +61,12 @@ async function getToolVersion(tool: string, options: string[]) {
|
|||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const unique = () => {
|
||||||
|
const encountered = new Set();
|
||||||
|
return (value: unknown): boolean => {
|
||||||
|
if (encountered.has(value)) return false;
|
||||||
|
encountered.add(value);
|
||||||
|
return true;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user