Add and configure ESLint and update configuration for Prettier (#703)

* Add ESLinter and update Prettier

* Update eslint config

* Update dependencies

* Rebuild action

* Update package.json

* Updates docs

* Update docs
This commit is contained in:
Ivan 2023-03-08 10:47:38 +02:00 committed by GitHub
parent 7c29869aec
commit 962678f22c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
31 changed files with 3804 additions and 1545 deletions

6
.eslintignore Normal file
View File

@ -0,0 +1,6 @@
# Ignore list
/*
# Do not ignore these folders:
!__tests__/
!src/

49
.eslintrc.js Normal file
View File

@ -0,0 +1,49 @@
module.exports = {
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'plugin:eslint-plugin-jest/recommended',
'eslint-config-prettier'
],
parser: '@typescript-eslint/parser',
plugins: ['@typescript-eslint', 'eslint-plugin-jest'],
rules: {
'@typescript-eslint/no-require-imports': 'error',
'@typescript-eslint/no-non-null-assertion': 'off',
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-empty-function': 'off',
'@typescript-eslint/ban-ts-comment': [
'error',
{
'ts-ignore': 'allow-with-description'
}
],
'no-console': 'error',
'yoda': 'error',
'prefer-const': [
'error',
{
destructuring: 'all'
}
],
'no-control-regex': 'off',
'no-constant-condition': ['error', {checkLoops: false}]
},
overrides: [
{
files: ['**/*{test,spec}.ts'],
rules: {
'@typescript-eslint/no-unused-vars': 'off',
'jest/no-standalone-expect': 'off',
'jest/no-conditional-expect': 'off',
'no-console': 'off',
}
}
],
env: {
node: true,
es6: true,
'jest/globals': true
}
};

1
.gitattributes vendored
View File

@ -1 +1,2 @@
* text=auto eol=lf
.licenses/** -diff linguist-generated=true .licenses/** -diff linguist-generated=true

View File

@ -1 +1 @@
blank_issues_enabled: false blank_issues_enabled: false

View File

@ -14,4 +14,4 @@ on:
jobs: jobs:
call-basic-validation: call-basic-validation:
name: Basic validation name: Basic validation
uses: actions/reusable-workflows/.github/workflows/basic-validation.yml@main uses: actions/reusable-workflows/.github/workflows/basic-validation.yml@main

View File

@ -14,4 +14,4 @@ on:
jobs: jobs:
call-check-dist: call-check-dist:
name: Check dist/ name: Check dist/
uses: actions/reusable-workflows/.github/workflows/check-dist.yml@main uses: actions/reusable-workflows/.github/workflows/check-dist.yml@main

View File

@ -2,13 +2,13 @@ name: CodeQL analysis
on: on:
push: push:
branches: [ main ] branches: [main]
pull_request: pull_request:
branches: [ main ] branches: [main]
schedule: schedule:
- cron: '0 3 * * 0' - cron: '0 3 * * 0'
jobs: jobs:
call-codeQL-analysis: call-codeQL-analysis:
name: CodeQL analysis name: CodeQL analysis
uses: actions/reusable-workflows/.github/workflows/codeql-analysis.yml@main uses: actions/reusable-workflows/.github/workflows/codeql-analysis.yml@main

View File

@ -21,8 +21,8 @@ jobs:
name: releaseNewActionVersion name: releaseNewActionVersion
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Update the ${{ env.TAG_NAME }} tag - name: Update the ${{ env.TAG_NAME }} tag
uses: actions/publish-action@v0.2.2 uses: actions/publish-action@v0.2.2
with: with:
source-tag: ${{ env.TAG_NAME }} source-tag: ${{ env.TAG_NAME }}
slack-webhook: ${{ secrets.SLACK_WEBHOOK }} slack-webhook: ${{ secrets.SLACK_WEBHOOK }}

View File

@ -57,7 +57,12 @@ jobs:
fail-fast: false fail-fast: false
matrix: matrix:
os: [ubuntu-latest, windows-latest, macos-latest] os: [ubuntu-latest, windows-latest, macos-latest]
node-version: ['20-v8-canary', '20.0.0-v8-canary','20.0.0-v8-canary20221103f7e2421e91'] node-version:
[
'20-v8-canary',
'20.0.0-v8-canary',
'20.0.0-v8-canary20221103f7e2421e91'
]
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- name: Setup Node - name: Setup Node
@ -77,7 +82,8 @@ jobs:
fail-fast: false fail-fast: false
matrix: matrix:
os: [ubuntu-latest, windows-latest, macos-latest] os: [ubuntu-latest, windows-latest, macos-latest]
node-version: [16.0.0-nightly20210420a0261d231c, 17-nightly, 18.0.0-nightly] node-version:
[16.0.0-nightly20210420a0261d231c, 17-nightly, 18.0.0-nightly]
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- name: Setup Node - name: Setup Node
@ -170,7 +176,7 @@ jobs:
strategy: strategy:
fail-fast: false fail-fast: false
matrix: matrix:
os: [ ubuntu-latest, windows-latest, macos-latest ] os: [ubuntu-latest, windows-latest, macos-latest]
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- name: Setup node from node version file - name: Setup node from node version file

7
.prettierignore Normal file
View File

@ -0,0 +1,7 @@
# Ignore list
/*
# Do not ignore these folders:
!__tests__/
!.github/
!src/

10
.prettierrc.js Normal file
View File

@ -0,0 +1,10 @@
module.exports = {
printWidth: 80,
tabWidth: 2,
useTabs: false,
semi: true,
singleQuote: true,
trailingComma: 'none',
bracketSpacing: false,
arrowParens: 'avoid'
};

View File

@ -1,11 +0,0 @@
{
"printWidth": 80,
"tabWidth": 2,
"useTabs": false,
"semi": true,
"singleQuote": true,
"trailingComma": "none",
"bracketSpacing": false,
"arrowParens": "avoid",
"parser": "typescript"
}

View File

@ -15,11 +15,7 @@ describe('authutil tests', () => {
let dbgSpy: jest.SpyInstance; let dbgSpy: jest.SpyInstance;
beforeAll(async () => { beforeAll(async () => {
const randPath = path.join( const randPath = path.join(Math.random().toString(36).substring(7));
Math.random()
.toString(36)
.substring(7)
);
console.log('::stop-commands::stoptoken'); // Disable executing of runner commands when running tests in actions console.log('::stop-commands::stoptoken'); // Disable executing of runner commands when running tests in actions
process.env['GITHUB_ENV'] = ''; // Stub out Environment file functionality so we can verify it writes to standard out (toolkit is backwards compatible) process.env['GITHUB_ENV'] = ''; // Stub out Environment file functionality so we can verify it writes to standard out (toolkit is backwards compatible)
const tempDir = path.join(_runnerDir, randPath, 'temp'); const tempDir = path.join(_runnerDir, randPath, 'temp');
@ -67,10 +63,10 @@ describe('authutil tests', () => {
}, 100000); }, 100000);
function readRcFile(rcFile: string) { function readRcFile(rcFile: string) {
let rc = {}; const rc = {};
let contents = fs.readFileSync(rcFile, {encoding: 'utf8'}); const contents = fs.readFileSync(rcFile, {encoding: 'utf8'});
for (const line of contents.split(os.EOL)) { for (const line of contents.split(os.EOL)) {
let parts = line.split('='); const parts = line.split('=');
if (parts.length == 2) { if (parts.length == 2) {
rc[parts[0].trim()] = parts[1].trim(); rc[parts[0].trim()] = parts[1].trim();
} }
@ -82,8 +78,8 @@ describe('authutil tests', () => {
await auth.configAuthentication('https://registry.npmjs.org/', 'false'); await auth.configAuthentication('https://registry.npmjs.org/', 'false');
expect(fs.statSync(rcFile)).toBeDefined(); expect(fs.statSync(rcFile)).toBeDefined();
let contents = fs.readFileSync(rcFile, {encoding: 'utf8'}); const contents = fs.readFileSync(rcFile, {encoding: 'utf8'});
let rc = readRcFile(rcFile); const rc = readRcFile(rcFile);
expect(rc['registry']).toBe('https://registry.npmjs.org/'); expect(rc['registry']).toBe('https://registry.npmjs.org/');
expect(rc['always-auth']).toBe('false'); expect(rc['always-auth']).toBe('false');
}); });
@ -92,7 +88,7 @@ describe('authutil tests', () => {
await auth.configAuthentication('https://registry.npmjs.org', 'false'); await auth.configAuthentication('https://registry.npmjs.org', 'false');
expect(fs.statSync(rcFile)).toBeDefined(); expect(fs.statSync(rcFile)).toBeDefined();
let rc = readRcFile(rcFile); const rc = readRcFile(rcFile);
expect(rc['registry']).toBe('https://registry.npmjs.org/'); expect(rc['registry']).toBe('https://registry.npmjs.org/');
expect(rc['always-auth']).toBe('false'); expect(rc['always-auth']).toBe('false');
}); });
@ -102,7 +98,7 @@ describe('authutil tests', () => {
await auth.configAuthentication('https://registry.npmjs.org', 'false'); await auth.configAuthentication('https://registry.npmjs.org', 'false');
expect(fs.statSync(rcFile)).toBeDefined(); expect(fs.statSync(rcFile)).toBeDefined();
let rc = readRcFile(rcFile); const rc = readRcFile(rcFile);
expect(rc['@myscope:registry']).toBe('https://registry.npmjs.org/'); expect(rc['@myscope:registry']).toBe('https://registry.npmjs.org/');
expect(rc['always-auth']).toBe('false'); expect(rc['always-auth']).toBe('false');
}); });
@ -111,7 +107,7 @@ describe('authutil tests', () => {
await auth.configAuthentication('npm.pkg.github.com', 'false'); await auth.configAuthentication('npm.pkg.github.com', 'false');
expect(fs.statSync(rcFile)).toBeDefined(); expect(fs.statSync(rcFile)).toBeDefined();
let rc = readRcFile(rcFile); const rc = readRcFile(rcFile);
expect(rc['@ownername:registry']).toBe('npm.pkg.github.com/'); expect(rc['@ownername:registry']).toBe('npm.pkg.github.com/');
expect(rc['always-auth']).toBe('false'); expect(rc['always-auth']).toBe('false');
}); });
@ -119,16 +115,16 @@ describe('authutil tests', () => {
it('Sets up npmrc for always-auth true', async () => { it('Sets up npmrc for always-auth true', async () => {
await auth.configAuthentication('https://registry.npmjs.org/', 'true'); await auth.configAuthentication('https://registry.npmjs.org/', 'true');
expect(fs.statSync(rcFile)).toBeDefined(); expect(fs.statSync(rcFile)).toBeDefined();
let rc = readRcFile(rcFile); const rc = readRcFile(rcFile);
expect(rc['registry']).toBe('https://registry.npmjs.org/'); expect(rc['registry']).toBe('https://registry.npmjs.org/');
expect(rc['always-auth']).toBe('true'); expect(rc['always-auth']).toBe('true');
}); });
it('It is already set the NODE_AUTH_TOKEN export it ', async () => { it('is already set the NODE_AUTH_TOKEN export it', async () => {
process.env.NODE_AUTH_TOKEN = 'foobar'; process.env.NODE_AUTH_TOKEN = 'foobar';
await auth.configAuthentication('npm.pkg.github.com', 'false'); await auth.configAuthentication('npm.pkg.github.com', 'false');
expect(fs.statSync(rcFile)).toBeDefined(); expect(fs.statSync(rcFile)).toBeDefined();
let rc = readRcFile(rcFile); const rc = readRcFile(rcFile);
expect(rc['@ownername:registry']).toBe('npm.pkg.github.com/'); expect(rc['@ownername:registry']).toBe('npm.pkg.github.com/');
expect(rc['always-auth']).toBe('false'); expect(rc['always-auth']).toBe('false');
expect(process.env.NODE_AUTH_TOKEN).toEqual('foobar'); expect(process.env.NODE_AUTH_TOKEN).toEqual('foobar');
@ -137,7 +133,7 @@ describe('authutil tests', () => {
it('configAuthentication should overwrite non-scoped with non-scoped', async () => { it('configAuthentication should overwrite non-scoped with non-scoped', async () => {
fs.writeFileSync(rcFile, 'registry=NNN'); fs.writeFileSync(rcFile, 'registry=NNN');
await auth.configAuthentication('https://registry.npmjs.org/', 'true'); await auth.configAuthentication('https://registry.npmjs.org/', 'true');
let contents = fs.readFileSync(rcFile, {encoding: 'utf8'}); const contents = fs.readFileSync(rcFile, {encoding: 'utf8'});
expect(contents).toBe( expect(contents).toBe(
`//registry.npmjs.org/:_authToken=\${NODE_AUTH_TOKEN}${os.EOL}registry=https://registry.npmjs.org/${os.EOL}always-auth=true` `//registry.npmjs.org/:_authToken=\${NODE_AUTH_TOKEN}${os.EOL}registry=https://registry.npmjs.org/${os.EOL}always-auth=true`
); );
@ -146,7 +142,7 @@ describe('authutil tests', () => {
it('configAuthentication should overwrite only non-scoped', async () => { it('configAuthentication should overwrite only non-scoped', async () => {
fs.writeFileSync(rcFile, `registry=NNN${os.EOL}@myscope:registry=MMM`); fs.writeFileSync(rcFile, `registry=NNN${os.EOL}@myscope:registry=MMM`);
await auth.configAuthentication('https://registry.npmjs.org/', 'true'); await auth.configAuthentication('https://registry.npmjs.org/', 'true');
let contents = fs.readFileSync(rcFile, {encoding: 'utf8'}); const contents = fs.readFileSync(rcFile, {encoding: 'utf8'});
expect(contents).toBe( expect(contents).toBe(
`@myscope:registry=MMM${os.EOL}//registry.npmjs.org/:_authToken=\${NODE_AUTH_TOKEN}${os.EOL}registry=https://registry.npmjs.org/${os.EOL}always-auth=true` `@myscope:registry=MMM${os.EOL}//registry.npmjs.org/:_authToken=\${NODE_AUTH_TOKEN}${os.EOL}registry=https://registry.npmjs.org/${os.EOL}always-auth=true`
); );
@ -155,7 +151,7 @@ describe('authutil tests', () => {
it('configAuthentication should add non-scoped to scoped', async () => { it('configAuthentication should add non-scoped to scoped', async () => {
fs.writeFileSync(rcFile, '@myscope:registry=NNN'); fs.writeFileSync(rcFile, '@myscope:registry=NNN');
await auth.configAuthentication('https://registry.npmjs.org/', 'true'); await auth.configAuthentication('https://registry.npmjs.org/', 'true');
let contents = fs.readFileSync(rcFile, {encoding: 'utf8'}); const contents = fs.readFileSync(rcFile, {encoding: 'utf8'});
expect(contents).toBe( expect(contents).toBe(
`@myscope:registry=NNN${os.EOL}//registry.npmjs.org/:_authToken=\${NODE_AUTH_TOKEN}${os.EOL}registry=https://registry.npmjs.org/${os.EOL}always-auth=true` `@myscope:registry=NNN${os.EOL}//registry.npmjs.org/:_authToken=\${NODE_AUTH_TOKEN}${os.EOL}registry=https://registry.npmjs.org/${os.EOL}always-auth=true`
); );
@ -165,7 +161,7 @@ describe('authutil tests', () => {
process.env['INPUT_SCOPE'] = 'myscope'; process.env['INPUT_SCOPE'] = 'myscope';
fs.writeFileSync(rcFile, `@myscope:registry=NNN`); fs.writeFileSync(rcFile, `@myscope:registry=NNN`);
await auth.configAuthentication('https://registry.npmjs.org/', 'true'); await auth.configAuthentication('https://registry.npmjs.org/', 'true');
let contents = fs.readFileSync(rcFile, {encoding: 'utf8'}); const contents = fs.readFileSync(rcFile, {encoding: 'utf8'});
expect(contents).toBe( expect(contents).toBe(
`//registry.npmjs.org/:_authToken=\${NODE_AUTH_TOKEN}${os.EOL}@myscope:registry=https://registry.npmjs.org/${os.EOL}always-auth=true` `//registry.npmjs.org/:_authToken=\${NODE_AUTH_TOKEN}${os.EOL}@myscope:registry=https://registry.npmjs.org/${os.EOL}always-auth=true`
); );
@ -175,7 +171,7 @@ describe('authutil tests', () => {
process.env['INPUT_SCOPE'] = 'myscope'; process.env['INPUT_SCOPE'] = 'myscope';
fs.writeFileSync(rcFile, `registry=NNN${os.EOL}@myscope:registry=MMM`); fs.writeFileSync(rcFile, `registry=NNN${os.EOL}@myscope:registry=MMM`);
await auth.configAuthentication('https://registry.npmjs.org/', 'true'); await auth.configAuthentication('https://registry.npmjs.org/', 'true');
let contents = fs.readFileSync(rcFile, {encoding: 'utf8'}); const contents = fs.readFileSync(rcFile, {encoding: 'utf8'});
expect(contents).toBe( expect(contents).toBe(
`registry=NNN${os.EOL}//registry.npmjs.org/:_authToken=\${NODE_AUTH_TOKEN}${os.EOL}@myscope:registry=https://registry.npmjs.org/${os.EOL}always-auth=true` `registry=NNN${os.EOL}//registry.npmjs.org/:_authToken=\${NODE_AUTH_TOKEN}${os.EOL}@myscope:registry=https://registry.npmjs.org/${os.EOL}always-auth=true`
); );
@ -185,7 +181,7 @@ describe('authutil tests', () => {
process.env['INPUT_SCOPE'] = 'myscope'; process.env['INPUT_SCOPE'] = 'myscope';
fs.writeFileSync(rcFile, `registry=MMM`); fs.writeFileSync(rcFile, `registry=MMM`);
await auth.configAuthentication('https://registry.npmjs.org/', 'true'); await auth.configAuthentication('https://registry.npmjs.org/', 'true');
let contents = fs.readFileSync(rcFile, {encoding: 'utf8'}); const contents = fs.readFileSync(rcFile, {encoding: 'utf8'});
expect(contents).toBe( expect(contents).toBe(
`registry=MMM${os.EOL}//registry.npmjs.org/:_authToken=\${NODE_AUTH_TOKEN}${os.EOL}@myscope:registry=https://registry.npmjs.org/${os.EOL}always-auth=true` `registry=MMM${os.EOL}//registry.npmjs.org/:_authToken=\${NODE_AUTH_TOKEN}${os.EOL}@myscope:registry=https://registry.npmjs.org/${os.EOL}always-auth=true`
); );
@ -198,7 +194,7 @@ describe('authutil tests', () => {
`@otherscope:registry=NNN${os.EOL}@myscope:registry=MMM` `@otherscope:registry=NNN${os.EOL}@myscope:registry=MMM`
); );
await auth.configAuthentication('https://registry.npmjs.org/', 'true'); await auth.configAuthentication('https://registry.npmjs.org/', 'true');
let contents = fs.readFileSync(rcFile, {encoding: 'utf8'}); const contents = fs.readFileSync(rcFile, {encoding: 'utf8'});
expect(contents).toBe( expect(contents).toBe(
`@otherscope:registry=NNN${os.EOL}//registry.npmjs.org/:_authToken=\${NODE_AUTH_TOKEN}${os.EOL}@myscope:registry=https://registry.npmjs.org/${os.EOL}always-auth=true` `@otherscope:registry=NNN${os.EOL}//registry.npmjs.org/:_authToken=\${NODE_AUTH_TOKEN}${os.EOL}@myscope:registry=https://registry.npmjs.org/${os.EOL}always-auth=true`
); );
@ -208,7 +204,7 @@ describe('authutil tests', () => {
process.env['INPUT_SCOPE'] = 'myscope'; process.env['INPUT_SCOPE'] = 'myscope';
fs.writeFileSync(rcFile, `@otherscope:registry=MMM`); fs.writeFileSync(rcFile, `@otherscope:registry=MMM`);
await auth.configAuthentication('https://registry.npmjs.org/', 'true'); await auth.configAuthentication('https://registry.npmjs.org/', 'true');
let contents = fs.readFileSync(rcFile, {encoding: 'utf8'}); const contents = fs.readFileSync(rcFile, {encoding: 'utf8'});
expect(contents).toBe( expect(contents).toBe(
`@otherscope:registry=MMM${os.EOL}//registry.npmjs.org/:_authToken=\${NODE_AUTH_TOKEN}${os.EOL}@myscope:registry=https://registry.npmjs.org/${os.EOL}always-auth=true` `@otherscope:registry=MMM${os.EOL}//registry.npmjs.org/:_authToken=\${NODE_AUTH_TOKEN}${os.EOL}@myscope:registry=https://registry.npmjs.org/${os.EOL}always-auth=true`
); );

View File

@ -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.toThrowError( await expect(restoreCache(packageManager)).rejects.toThrow(
`Caching for '${packageManager}' is not supported` `Caching for '${packageManager}' is not supported`
); );
} }

View File

@ -18,7 +18,7 @@ describe('run', () => {
const commonPath = '/some/random/path'; const commonPath = '/some/random/path';
process.env['GITHUB_WORKSPACE'] = path.join(__dirname, 'data'); process.env['GITHUB_WORKSPACE'] = path.join(__dirname, 'data');
let inputs = {} as any; const inputs = {} as any;
let getInputSpy: jest.SpyInstance; let getInputSpy: jest.SpyInstance;
let infoSpy: jest.SpyInstance; let infoSpy: jest.SpyInstance;

View File

@ -12,11 +12,11 @@ import * as main from '../src/main';
import * as auth from '../src/authutil'; import * as auth from '../src/authutil';
import {INodeVersion} from '../src/distributions/base-models'; import {INodeVersion} from '../src/distributions/base-models';
const nodeTestManifest = require('./data/versions-manifest.json'); import nodeTestManifest from './data/versions-manifest.json';
const nodeTestDist = require('./data/node-dist-index.json'); import nodeTestDist from './data/node-dist-index.json';
const nodeTestDistNightly = require('./data/node-nightly-index.json'); import nodeTestDistNightly from './data/node-nightly-index.json';
const nodeTestDistRc = require('./data/node-rc-index.json'); import nodeTestDistRc from './data/node-rc-index.json';
const nodeV8CanaryTestDist = require('./data/v8-canary-dist-index.json'); import nodeV8CanaryTestDist from './data/v8-canary-dist-index.json';
describe('setup-node', () => { describe('setup-node', () => {
let inputs = {} as any; let inputs = {} as any;
@ -95,13 +95,13 @@ describe('setup-node', () => {
getJsonSpy.mockImplementation(url => { getJsonSpy.mockImplementation(url => {
let res: any; let res: any;
if (url.includes('/rc')) { if (url.includes('/rc')) {
res = <INodeVersion>nodeTestDistRc; res = <INodeVersion[]>nodeTestDistRc;
} else if (url.includes('/nightly')) { } else if (url.includes('/nightly')) {
res = <INodeVersion>nodeTestDistNightly; res = <INodeVersion[]>nodeTestDistNightly;
} else if (url.includes('/v8-canary')) { } else if (url.includes('/v8-canary')) {
res = <INodeVersion>nodeV8CanaryTestDist; res = <INodeVersion[]>nodeV8CanaryTestDist;
} else { } else {
res = <INodeVersion>nodeTestDist; res = <INodeVersion[]>nodeTestDist;
} }
return {result: res}; return {result: res};
@ -154,7 +154,7 @@ describe('setup-node', () => {
os['arch'] = 'x64'; os['arch'] = 'x64';
inputs.stable = 'true'; inputs.stable = 'true';
let toolPath = path.normalize( const toolPath = path.normalize(
'/cache/node/20.0.0-v8-canary20221103f7e2421e91/x64' '/cache/node/20.0.0-v8-canary20221103f7e2421e91/x64'
); );
findSpy.mockImplementation(() => toolPath); findSpy.mockImplementation(() => toolPath);
@ -180,7 +180,7 @@ describe('setup-node', () => {
inSpy.mockImplementation(name => inputs[name]); inSpy.mockImplementation(name => inputs[name]);
let toolPath = path.normalize( const toolPath = path.normalize(
'/cache/node/20.0.0-v8-canary20221103f7e2421e91/x64' '/cache/node/20.0.0-v8-canary20221103f7e2421e91/x64'
); );
findSpy.mockImplementation(() => toolPath); findSpy.mockImplementation(() => toolPath);
@ -192,13 +192,13 @@ describe('setup-node', () => {
]); ]);
await main.run(); await main.run();
let expPath = path.join(toolPath, 'bin'); const expPath = path.join(toolPath, 'bin');
expect(cnSpy).toHaveBeenCalledWith(`::add-path::${expPath}${osm.EOL}`); expect(cnSpy).toHaveBeenCalledWith(`::add-path::${expPath}${osm.EOL}`);
}); });
it('handles unhandled find error and reports error', async () => { it('handles unhandled find error and reports error', async () => {
os.platform = 'linux'; os.platform = 'linux';
let errMsg = 'unhandled error message'; const errMsg = 'unhandled error message';
inputs['node-version'] = '20.0.0-v8-canary20221103f7e2421e91'; inputs['node-version'] = '20.0.0-v8-canary20221103f7e2421e91';
findSpy.mockImplementation(() => { findSpy.mockImplementation(() => {
@ -224,7 +224,7 @@ describe('setup-node', () => {
os.arch = 'x64'; os.arch = 'x64';
// a version which is not in the manifest but is in node dist // a version which is not in the manifest but is in node dist
let versionSpec = '11.15.0'; const versionSpec = '11.15.0';
inputs['node-version'] = versionSpec; inputs['node-version'] = versionSpec;
inputs['always-auth'] = false; inputs['always-auth'] = false;
@ -234,13 +234,13 @@ describe('setup-node', () => {
findSpy.mockImplementation(() => ''); findSpy.mockImplementation(() => '');
dlSpy.mockImplementation(async () => '/some/temp/path'); dlSpy.mockImplementation(async () => '/some/temp/path');
let toolPath = path.normalize('/cache/node/11.11.0/x64'); const toolPath = path.normalize('/cache/node/11.11.0/x64');
exSpy.mockImplementation(async () => '/some/other/temp/path'); exSpy.mockImplementation(async () => '/some/other/temp/path');
cacheSpy.mockImplementation(async () => toolPath); cacheSpy.mockImplementation(async () => toolPath);
await main.run(); await main.run();
let expPath = path.join(toolPath, 'bin'); const expPath = path.join(toolPath, 'bin');
expect(dlSpy).toHaveBeenCalled(); expect(dlSpy).toHaveBeenCalled();
expect(exSpy).toHaveBeenCalled(); expect(exSpy).toHaveBeenCalled();
@ -257,7 +257,7 @@ describe('setup-node', () => {
os.platform = 'linux'; os.platform = 'linux';
os.arch = 'x64'; os.arch = 'x64';
let versionSpec = '23.0.0-v8-canary20221103f7e2421e91'; const versionSpec = '23.0.0-v8-canary20221103f7e2421e91';
inputs['node-version'] = versionSpec; inputs['node-version'] = versionSpec;
findSpy.mockImplementation(() => ''); findSpy.mockImplementation(() => '');
@ -275,12 +275,12 @@ describe('setup-node', () => {
}); });
it('reports a failed download', async () => { it('reports a failed download', async () => {
let errMsg = 'unhandled download message'; const errMsg = 'unhandled download message';
os.platform = 'linux'; os.platform = 'linux';
os.arch = 'x64'; os.arch = 'x64';
// a version which is in the manifest // a version which is in the manifest
let versionSpec = '19.0.0-v8-canary'; const versionSpec = '19.0.0-v8-canary';
inputs['node-version'] = versionSpec; inputs['node-version'] = versionSpec;
inputs['always-auth'] = false; inputs['always-auth'] = false;
@ -327,14 +327,14 @@ describe('setup-node', () => {
inputs['always-auth'] = false; inputs['always-auth'] = false;
inputs['token'] = 'faketoken'; inputs['token'] = 'faketoken';
let expectedUrl = `https://nodejs.org/download/v8-canary/v${version}/node-v${version}-${platform}-${arch}.${fileExtension}`; const expectedUrl = `https://nodejs.org/download/v8-canary/v${version}/node-v${version}-${platform}-${arch}.${fileExtension}`;
// ... but not in the local cache // ... but not in the local cache
findSpy.mockImplementation(() => ''); findSpy.mockImplementation(() => '');
findAllVersionsSpy.mockImplementation(() => []); findAllVersionsSpy.mockImplementation(() => []);
dlSpy.mockImplementation(async () => '/some/temp/path'); dlSpy.mockImplementation(async () => '/some/temp/path');
let toolPath = path.normalize(`/cache/node/${version}/${arch}`); const toolPath = path.normalize(`/cache/node/${version}/${arch}`);
exSpy.mockImplementation(async () => '/some/other/temp/path'); exSpy.mockImplementation(async () => '/some/other/temp/path');
cacheSpy.mockImplementation(async () => toolPath); cacheSpy.mockImplementation(async () => toolPath);
@ -502,7 +502,7 @@ describe('setup-node', () => {
describe('setup-node v8 canary tests', () => { describe('setup-node v8 canary tests', () => {
it('v8 canary setup node flow with cached', async () => { it('v8 canary setup node flow with cached', async () => {
let versionSpec = 'v20-v8-canary'; const versionSpec = 'v20-v8-canary';
inputs['node-version'] = versionSpec; inputs['node-version'] = versionSpec;
inputs['always-auth'] = false; inputs['always-auth'] = false;

View File

@ -7,9 +7,11 @@ dependencies:
express: 4.17.1 express: 4.17.1
packages: packages:
/accepts/1.3.7: /accepts/1.3.7:
resolution: {integrity: sha512-Il80Qs2WjYlJIBNzNkK6KYqlVMTbZLXgHx2oT0pU/fjRHyEp+PEfEPY0R3WCwAGVOtauxh1hOxNgIf5bv7dQpA==} resolution:
{
integrity: sha512-Il80Qs2WjYlJIBNzNkK6KYqlVMTbZLXgHx2oT0pU/fjRHyEp+PEfEPY0R3WCwAGVOtauxh1hOxNgIf5bv7dQpA==
}
engines: {node: '>= 0.6'} engines: {node: '>= 0.6'}
dependencies: dependencies:
mime-types: 2.1.31 mime-types: 2.1.31
@ -21,7 +23,10 @@ packages:
dev: false dev: false
/body-parser/1.19.0: /body-parser/1.19.0:
resolution: {integrity: sha512-dhEPs72UPbDnAQJ9ZKMNTP6ptJaionhP5cBb541nXPlW60Jepo9RV/a4fX4XWW9CuFNK22krhrj1+rgzifNCsw==} resolution:
{
integrity: sha512-dhEPs72UPbDnAQJ9ZKMNTP6ptJaionhP5cBb541nXPlW60Jepo9RV/a4fX4XWW9CuFNK22krhrj1+rgzifNCsw==
}
engines: {node: '>= 0.8'} engines: {node: '>= 0.8'}
dependencies: dependencies:
bytes: 3.1.0 bytes: 3.1.0
@ -37,19 +42,28 @@ packages:
dev: false dev: false
/bytes/3.1.0: /bytes/3.1.0:
resolution: {integrity: sha512-zauLjrfCG+xvoyaqLoV8bLVXXNGC4JqlxFCutSDWA6fJrTo2ZuvLYTqZ7aHBLZSMOopbzwv8f+wZcVzfVTI2Dg==} resolution:
{
integrity: sha512-zauLjrfCG+xvoyaqLoV8bLVXXNGC4JqlxFCutSDWA6fJrTo2ZuvLYTqZ7aHBLZSMOopbzwv8f+wZcVzfVTI2Dg==
}
engines: {node: '>= 0.8'} engines: {node: '>= 0.8'}
dev: false dev: false
/content-disposition/0.5.3: /content-disposition/0.5.3:
resolution: {integrity: sha512-ExO0774ikEObIAEV9kDo50o+79VCUdEB6n6lzKgGwupcVeRlhrj3qGAfwq8G6uBJjkqLrhT0qEYFcWng8z1z0g==} resolution:
{
integrity: sha512-ExO0774ikEObIAEV9kDo50o+79VCUdEB6n6lzKgGwupcVeRlhrj3qGAfwq8G6uBJjkqLrhT0qEYFcWng8z1z0g==
}
engines: {node: '>= 0.6'} engines: {node: '>= 0.6'}
dependencies: dependencies:
safe-buffer: 5.1.2 safe-buffer: 5.1.2
dev: false dev: false
/content-type/1.0.4: /content-type/1.0.4:
resolution: {integrity: sha512-hIP3EEPs8tB9AT1L+NUqtwOAps4mk2Zob89MWXMHjHWg9milF/j4osnnQLXBCBFBk/tvIG/tUc9mOUJiPBhPXA==} resolution:
{
integrity: sha512-hIP3EEPs8tB9AT1L+NUqtwOAps4mk2Zob89MWXMHjHWg9milF/j4osnnQLXBCBFBk/tvIG/tUc9mOUJiPBhPXA==
}
engines: {node: '>= 0.6'} engines: {node: '>= 0.6'}
dev: false dev: false
@ -58,12 +72,18 @@ packages:
dev: false dev: false
/cookie/0.4.0: /cookie/0.4.0:
resolution: {integrity: sha512-+Hp8fLp57wnUSt0tY0tHEXh4voZRDnoIrZPqlo3DPiI4y9lwg/jqx+1Om94/W6ZaPDOUbnjOt/99w66zk+l1Xg==} resolution:
{
integrity: sha512-+Hp8fLp57wnUSt0tY0tHEXh4voZRDnoIrZPqlo3DPiI4y9lwg/jqx+1Om94/W6ZaPDOUbnjOt/99w66zk+l1Xg==
}
engines: {node: '>= 0.6'} engines: {node: '>= 0.6'}
dev: false dev: false
/debug/2.6.9: /debug/2.6.9:
resolution: {integrity: sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==} resolution:
{
integrity: sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==
}
dependencies: dependencies:
ms: 2.0.0 ms: 2.0.0
dev: false dev: false
@ -96,7 +116,10 @@ packages:
dev: false dev: false
/express/4.17.1: /express/4.17.1:
resolution: {integrity: sha512-mHJ9O79RqluphRrcw2X/GTh3k9tVv8YcoyY4Kkh4WDMUYKRZUq0h1o0w2rrrxBqM7VoeUVqgb27xlEMXTnYt4g==} resolution:
{
integrity: sha512-mHJ9O79RqluphRrcw2X/GTh3k9tVv8YcoyY4Kkh4WDMUYKRZUq0h1o0w2rrrxBqM7VoeUVqgb27xlEMXTnYt4g==
}
engines: {node: '>= 0.10.0'} engines: {node: '>= 0.10.0'}
dependencies: dependencies:
accepts: 1.3.7 accepts: 1.3.7
@ -132,7 +155,10 @@ packages:
dev: false dev: false
/finalhandler/1.1.2: /finalhandler/1.1.2:
resolution: {integrity: sha512-aAWcW57uxVNrQZqFXjITpW3sIUQmHGG3qSb9mUah9MgMC4NeWhNOlNjXEYq3HjRAvL6arUviZGGJsBg6z0zsWA==} resolution:
{
integrity: sha512-aAWcW57uxVNrQZqFXjITpW3sIUQmHGG3qSb9mUah9MgMC4NeWhNOlNjXEYq3HjRAvL6arUviZGGJsBg6z0zsWA==
}
engines: {node: '>= 0.8'} engines: {node: '>= 0.8'}
dependencies: dependencies:
debug: 2.6.9 debug: 2.6.9
@ -145,7 +171,10 @@ packages:
dev: false dev: false
/forwarded/0.2.0: /forwarded/0.2.0:
resolution: {integrity: sha512-buRG0fpBtRHSTCOASe6hD258tEubFoRLb4ZNA6NxMVHNw2gOcwHo9wyablzMzOA5z9xA9L1KNjk/Nt6MT9aYow==} resolution:
{
integrity: sha512-buRG0fpBtRHSTCOASe6hD258tEubFoRLb4ZNA6NxMVHNw2gOcwHo9wyablzMzOA5z9xA9L1KNjk/Nt6MT9aYow==
}
engines: {node: '>= 0.6'} engines: {node: '>= 0.6'}
dev: false dev: false
@ -155,7 +184,10 @@ packages:
dev: false dev: false
/http-errors/1.7.2: /http-errors/1.7.2:
resolution: {integrity: sha512-uUQBt3H/cSIVfch6i1EuPNy/YsRSOUBXTVfZ+yR7Zjez3qjBz6i9+i4zjNaoqcoFVI4lQJ5plg63TvGfRSDCRg==} resolution:
{
integrity: sha512-uUQBt3H/cSIVfch6i1EuPNy/YsRSOUBXTVfZ+yR7Zjez3qjBz6i9+i4zjNaoqcoFVI4lQJ5plg63TvGfRSDCRg==
}
engines: {node: '>= 0.6'} engines: {node: '>= 0.6'}
dependencies: dependencies:
depd: 1.1.2 depd: 1.1.2
@ -166,7 +198,10 @@ packages:
dev: false dev: false
/http-errors/1.7.3: /http-errors/1.7.3:
resolution: {integrity: sha512-ZTTX0MWrsQ2ZAhA1cejAwDLycFsd7I7nVtnkT3Ol0aqodaKW+0CTZDQ1uBv5whptCnc8e8HeRRJxRs0kmm/Qfw==} resolution:
{
integrity: sha512-ZTTX0MWrsQ2ZAhA1cejAwDLycFsd7I7nVtnkT3Ol0aqodaKW+0CTZDQ1uBv5whptCnc8e8HeRRJxRs0kmm/Qfw==
}
engines: {node: '>= 0.6'} engines: {node: '>= 0.6'}
dependencies: dependencies:
depd: 1.1.2 depd: 1.1.2
@ -177,7 +212,10 @@ packages:
dev: false dev: false
/iconv-lite/0.4.24: /iconv-lite/0.4.24:
resolution: {integrity: sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==} resolution:
{
integrity: sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==
}
engines: {node: '>=0.10.0'} engines: {node: '>=0.10.0'}
dependencies: dependencies:
safer-buffer: 2.1.2 safer-buffer: 2.1.2
@ -188,11 +226,17 @@ packages:
dev: false dev: false
/inherits/2.0.4: /inherits/2.0.4:
resolution: {integrity: sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==} resolution:
{
integrity: sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==
}
dev: false dev: false
/ipaddr.js/1.9.1: /ipaddr.js/1.9.1:
resolution: {integrity: sha512-0KI/607xoxSToH7GjN1FfSbLoU0+btTicjsQSWQlh/hZykN8KpmMf7uYwPW3R+akZ6R/w18ZlXSHBYXiYUPO3g==} resolution:
{
integrity: sha512-0KI/607xoxSToH7GjN1FfSbLoU0+btTicjsQSWQlh/hZykN8KpmMf7uYwPW3R+akZ6R/w18ZlXSHBYXiYUPO3g==
}
engines: {node: '>= 0.10'} engines: {node: '>= 0.10'}
dev: false dev: false
@ -211,19 +255,28 @@ packages:
dev: false dev: false
/mime-db/1.48.0: /mime-db/1.48.0:
resolution: {integrity: sha512-FM3QwxV+TnZYQ2aRqhlKBMHxk10lTbMt3bBkMAp54ddrNeVSfcQYOOKuGuy3Ddrm38I04If834fOUSq1yzslJQ==} resolution:
{
integrity: sha512-FM3QwxV+TnZYQ2aRqhlKBMHxk10lTbMt3bBkMAp54ddrNeVSfcQYOOKuGuy3Ddrm38I04If834fOUSq1yzslJQ==
}
engines: {node: '>= 0.6'} engines: {node: '>= 0.6'}
dev: false dev: false
/mime-types/2.1.31: /mime-types/2.1.31:
resolution: {integrity: sha512-XGZnNzm3QvgKxa8dpzyhFTHmpP3l5YNusmne07VUOXxou9CqUqYa/HBy124RqtVh/O2pECas/MOcsDgpilPOPg==} resolution:
{
integrity: sha512-XGZnNzm3QvgKxa8dpzyhFTHmpP3l5YNusmne07VUOXxou9CqUqYa/HBy124RqtVh/O2pECas/MOcsDgpilPOPg==
}
engines: {node: '>= 0.6'} engines: {node: '>= 0.6'}
dependencies: dependencies:
mime-db: 1.48.0 mime-db: 1.48.0
dev: false dev: false
/mime/1.6.0: /mime/1.6.0:
resolution: {integrity: sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg==} resolution:
{
integrity: sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg==
}
engines: {node: '>=4'} engines: {node: '>=4'}
hasBin: true hasBin: true
dev: false dev: false
@ -233,11 +286,17 @@ packages:
dev: false dev: false
/ms/2.1.1: /ms/2.1.1:
resolution: {integrity: sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg==} resolution:
{
integrity: sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg==
}
dev: false dev: false
/negotiator/0.6.2: /negotiator/0.6.2:
resolution: {integrity: sha512-hZXc7K2e+PgeI1eDBe/10Ard4ekbfrrqG8Ep+8Jmf4JID2bNg7NvCPOZN+kfF574pFQI7mum2AUqDidoKqcTOw==} resolution:
{
integrity: sha512-hZXc7K2e+PgeI1eDBe/10Ard4ekbfrrqG8Ep+8Jmf4JID2bNg7NvCPOZN+kfF574pFQI7mum2AUqDidoKqcTOw==
}
engines: {node: '>= 0.6'} engines: {node: '>= 0.6'}
dev: false dev: false
@ -249,7 +308,10 @@ packages:
dev: false dev: false
/parseurl/1.3.3: /parseurl/1.3.3:
resolution: {integrity: sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ==} resolution:
{
integrity: sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ==
}
engines: {node: '>= 0.8'} engines: {node: '>= 0.8'}
dev: false dev: false
@ -258,7 +320,10 @@ packages:
dev: false dev: false
/proxy-addr/2.0.7: /proxy-addr/2.0.7:
resolution: {integrity: sha512-llQsMLSUDUPT44jdrU/O37qlnifitDP+ZwrmmZcoSKyLKvtZxpyV0n2/bD/N4tBAAZ/gJEdZU7KMraoK1+XYAg==} resolution:
{
integrity: sha512-llQsMLSUDUPT44jdrU/O37qlnifitDP+ZwrmmZcoSKyLKvtZxpyV0n2/bD/N4tBAAZ/gJEdZU7KMraoK1+XYAg==
}
engines: {node: '>= 0.10'} engines: {node: '>= 0.10'}
dependencies: dependencies:
forwarded: 0.2.0 forwarded: 0.2.0
@ -266,17 +331,26 @@ packages:
dev: false dev: false
/qs/6.7.0: /qs/6.7.0:
resolution: {integrity: sha512-VCdBRNFTX1fyE7Nb6FYoURo/SPe62QCaAyzJvUjwRaIsc+NePBEniHlvxFmmX56+HZphIGtV0XeCirBtpDrTyQ==} resolution:
{
integrity: sha512-VCdBRNFTX1fyE7Nb6FYoURo/SPe62QCaAyzJvUjwRaIsc+NePBEniHlvxFmmX56+HZphIGtV0XeCirBtpDrTyQ==
}
engines: {node: '>=0.6'} engines: {node: '>=0.6'}
dev: false dev: false
/range-parser/1.2.1: /range-parser/1.2.1:
resolution: {integrity: sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg==} resolution:
{
integrity: sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg==
}
engines: {node: '>= 0.6'} engines: {node: '>= 0.6'}
dev: false dev: false
/raw-body/2.4.0: /raw-body/2.4.0:
resolution: {integrity: sha512-4Oz8DUIwdvoa5qMJelxipzi/iJIi40O5cGV1wNYp5hvZP8ZN0T+jiNkL0QepXs+EsQ9XJ8ipEDoiH70ySUJP3Q==} resolution:
{
integrity: sha512-4Oz8DUIwdvoa5qMJelxipzi/iJIi40O5cGV1wNYp5hvZP8ZN0T+jiNkL0QepXs+EsQ9XJ8ipEDoiH70ySUJP3Q==
}
engines: {node: '>= 0.8'} engines: {node: '>= 0.8'}
dependencies: dependencies:
bytes: 3.1.0 bytes: 3.1.0
@ -286,15 +360,24 @@ packages:
dev: false dev: false
/safe-buffer/5.1.2: /safe-buffer/5.1.2:
resolution: {integrity: sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==} resolution:
{
integrity: sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==
}
dev: false dev: false
/safer-buffer/2.1.2: /safer-buffer/2.1.2:
resolution: {integrity: sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==} resolution:
{
integrity: sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==
}
dev: false dev: false
/send/0.17.1: /send/0.17.1:
resolution: {integrity: sha512-BsVKsiGcQMFwT8UxypobUKyv7irCNRHk1T0G680vk88yf6LBByGcZJOTJCrTP2xVN6yI+XjPJcNuE3V4fT9sAg==} resolution:
{
integrity: sha512-BsVKsiGcQMFwT8UxypobUKyv7irCNRHk1T0G680vk88yf6LBByGcZJOTJCrTP2xVN6yI+XjPJcNuE3V4fT9sAg==
}
engines: {node: '>= 0.8.0'} engines: {node: '>= 0.8.0'}
dependencies: dependencies:
debug: 2.6.9 debug: 2.6.9
@ -313,7 +396,10 @@ packages:
dev: false dev: false
/serve-static/1.14.1: /serve-static/1.14.1:
resolution: {integrity: sha512-JMrvUwE54emCYWlTI+hGrGv5I8dEwmco/00EvkzIIsR7MqrHonbD9pO2MOfFnpFntl7ecpZs+3mW+XbQZu9QCg==} resolution:
{
integrity: sha512-JMrvUwE54emCYWlTI+hGrGv5I8dEwmco/00EvkzIIsR7MqrHonbD9pO2MOfFnpFntl7ecpZs+3mW+XbQZu9QCg==
}
engines: {node: '>= 0.8.0'} engines: {node: '>= 0.8.0'}
dependencies: dependencies:
encodeurl: 1.0.2 encodeurl: 1.0.2
@ -323,7 +409,10 @@ packages:
dev: false dev: false
/setprototypeof/1.1.1: /setprototypeof/1.1.1:
resolution: {integrity: sha512-JvdAWfbXeIGaZ9cILp38HntZSFSo3mWg6xGcJJsd+d4aRMOqauag1C63dJfDw7OaMYwEbHMOxEZ1lqVRYP2OAw==} resolution:
{
integrity: sha512-JvdAWfbXeIGaZ9cILp38HntZSFSo3mWg6xGcJJsd+d4aRMOqauag1C63dJfDw7OaMYwEbHMOxEZ1lqVRYP2OAw==
}
dev: false dev: false
/statuses/1.5.0: /statuses/1.5.0:
@ -332,12 +421,18 @@ packages:
dev: false dev: false
/toidentifier/1.0.0: /toidentifier/1.0.0:
resolution: {integrity: sha512-yaOH/Pk/VEhBWWTlhI+qXxDFXlejDGcQipMlyxda9nthulaxLZUNcUqFxokp0vcYnvteJln5FNQDRrxj3YcbVw==} resolution:
{
integrity: sha512-yaOH/Pk/VEhBWWTlhI+qXxDFXlejDGcQipMlyxda9nthulaxLZUNcUqFxokp0vcYnvteJln5FNQDRrxj3YcbVw==
}
engines: {node: '>=0.6'} engines: {node: '>=0.6'}
dev: false dev: false
/type-is/1.6.18: /type-is/1.6.18:
resolution: {integrity: sha512-TkRKr9sUTxEH8MdfuCSP7VizJyzRNMjj2J2do2Jr3Kym598JVdEksuzPQCnlFPW4ky9Q+iA+ma9BGm06XQBy8g==} resolution:
{
integrity: sha512-TkRKr9sUTxEH8MdfuCSP7VizJyzRNMjj2J2do2Jr3Kym598JVdEksuzPQCnlFPW4ky9Q+iA+ma9BGm06XQBy8g==
}
engines: {node: '>= 0.6'} engines: {node: '>= 0.6'}
dependencies: dependencies:
media-typer: 0.3.0 media-typer: 0.3.0

View File

@ -266,7 +266,7 @@ describe('main tests', () => {
inSpy.mockImplementation(name => inputs[name]); inSpy.mockImplementation(name => inputs[name]);
let toolPath = path.normalize('/cache/node/12.16.1/x64'); const toolPath = path.normalize('/cache/node/12.16.1/x64');
findSpy.mockImplementation(() => toolPath); findSpy.mockImplementation(() => toolPath);
// expect(logSpy).toHaveBeenCalledWith(`Found in cache @ ${toolPath}`); // expect(logSpy).toHaveBeenCalledWith(`Found in cache @ ${toolPath}`);
@ -286,7 +286,7 @@ describe('main tests', () => {
inSpy.mockImplementation(name => inputs[name]); inSpy.mockImplementation(name => inputs[name]);
let toolPath = path.normalize('/cache/node/12.16.1/x64'); const toolPath = path.normalize('/cache/node/12.16.1/x64');
findSpy.mockImplementation(() => toolPath); findSpy.mockImplementation(() => toolPath);
// expect(logSpy).toHaveBeenCalledWith(`Found in cache @ ${toolPath}`); // expect(logSpy).toHaveBeenCalledWith(`Found in cache @ ${toolPath}`);

View File

@ -12,11 +12,11 @@ import * as main from '../src/main';
import * as auth from '../src/authutil'; import * as auth from '../src/authutil';
import {INodeVersion} from '../src/distributions/base-models'; import {INodeVersion} from '../src/distributions/base-models';
const nodeTestManifest = require('./data/versions-manifest.json'); import nodeTestManifest from './data/versions-manifest.json';
const nodeTestDist = require('./data/node-dist-index.json'); import nodeTestDist from './data/node-dist-index.json';
const nodeTestDistNightly = require('./data/node-nightly-index.json'); import nodeTestDistNightly from './data/node-nightly-index.json';
const nodeTestDistRc = require('./data/node-rc-index.json'); import nodeTestDistRc from './data/node-rc-index.json';
const nodeV8CanaryTestDist = require('./data/v8-canary-dist-index.json'); import nodeV8CanaryTestDist from './data/v8-canary-dist-index.json';
describe('setup-node', () => { describe('setup-node', () => {
let inputs = {} as any; let inputs = {} as any;
@ -89,11 +89,11 @@ describe('setup-node', () => {
getJsonSpy.mockImplementation(url => { getJsonSpy.mockImplementation(url => {
let res: any; let res: any;
if (url.includes('/rc')) { if (url.includes('/rc')) {
res = <INodeVersion>nodeTestDistRc; res = <INodeVersion[]>nodeTestDistRc;
} else if (url.includes('/nightly')) { } else if (url.includes('/nightly')) {
res = <INodeVersion>nodeTestDistNightly; res = <INodeVersion[]>nodeTestDistNightly;
} else { } else {
res = <INodeVersion>nodeTestDist; res = <INodeVersion[]>nodeTestDist;
} }
return {result: res}; return {result: res};
@ -146,7 +146,7 @@ describe('setup-node', () => {
os['arch'] = 'x64'; os['arch'] = 'x64';
inputs.stable = 'true'; inputs.stable = 'true';
let toolPath = path.normalize( const toolPath = path.normalize(
'/cache/node/16.0.0-nightly20210417bc31dc0e0f/x64' '/cache/node/16.0.0-nightly20210417bc31dc0e0f/x64'
); );
findSpy.mockImplementation(() => toolPath); findSpy.mockImplementation(() => toolPath);
@ -172,7 +172,7 @@ describe('setup-node', () => {
os['arch'] = 'x64'; os['arch'] = 'x64';
inputs.stable = 'false'; inputs.stable = 'false';
let toolPath = path.normalize( const toolPath = path.normalize(
'/cache/node/16.0.0-nightly20210415c3a5e15ebe/x64' '/cache/node/16.0.0-nightly20210415c3a5e15ebe/x64'
); );
findSpy.mockImplementation(() => toolPath); findSpy.mockImplementation(() => toolPath);
@ -199,7 +199,7 @@ describe('setup-node', () => {
inSpy.mockImplementation(name => inputs[name]); inSpy.mockImplementation(name => inputs[name]);
let toolPath = path.normalize( const toolPath = path.normalize(
'/cache/node/16.0.0-nightly20210417bc31dc0e0f/x64' '/cache/node/16.0.0-nightly20210417bc31dc0e0f/x64'
); );
findSpy.mockImplementation(() => toolPath); findSpy.mockImplementation(() => toolPath);
@ -218,12 +218,12 @@ describe('setup-node', () => {
'x64' 'x64'
); );
let expPath = path.join(toolPath, 'bin'); const expPath = path.join(toolPath, 'bin');
expect(cnSpy).toHaveBeenCalledWith(`::add-path::${expPath}${osm.EOL}`); expect(cnSpy).toHaveBeenCalledWith(`::add-path::${expPath}${osm.EOL}`);
}); });
it('handles unhandled find error and reports error', async () => { it('handles unhandled find error and reports error', async () => {
let errMsg = 'unhandled error message'; const errMsg = 'unhandled error message';
inputs['node-version'] = '16.0.0-nightly20210417bc31dc0e0f'; inputs['node-version'] = '16.0.0-nightly20210417bc31dc0e0f';
findAllVersionsSpy.mockImplementation(() => [ findAllVersionsSpy.mockImplementation(() => [
@ -247,7 +247,7 @@ describe('setup-node', () => {
os.arch = 'x64'; os.arch = 'x64';
// a version which is not in the manifest but is in node dist // a version which is not in the manifest but is in node dist
let versionSpec = '13.13.1-nightly20200415947ddec091'; const versionSpec = '13.13.1-nightly20200415947ddec091';
inputs['node-version'] = versionSpec; inputs['node-version'] = versionSpec;
inputs['always-auth'] = false; inputs['always-auth'] = false;
@ -258,7 +258,7 @@ describe('setup-node', () => {
findAllVersionsSpy.mockImplementation(() => []); findAllVersionsSpy.mockImplementation(() => []);
dlSpy.mockImplementation(async () => '/some/temp/path'); dlSpy.mockImplementation(async () => '/some/temp/path');
let toolPath = path.normalize( const toolPath = path.normalize(
'/cache/node/13.13.1-nightly20200415947ddec091/x64' '/cache/node/13.13.1-nightly20200415947ddec091/x64'
); );
exSpy.mockImplementation(async () => '/some/other/temp/path'); exSpy.mockImplementation(async () => '/some/other/temp/path');
@ -266,7 +266,7 @@ describe('setup-node', () => {
await main.run(); await main.run();
let expPath = path.join(toolPath, 'bin'); const expPath = path.join(toolPath, 'bin');
expect(dlSpy).toHaveBeenCalled(); expect(dlSpy).toHaveBeenCalled();
expect(exSpy).toHaveBeenCalled(); expect(exSpy).toHaveBeenCalled();
@ -277,7 +277,7 @@ describe('setup-node', () => {
os.platform = 'linux'; os.platform = 'linux';
os.arch = 'x64'; os.arch = 'x64';
let versionSpec = '10.13.1-nightly20200415947ddec091'; const versionSpec = '10.13.1-nightly20200415947ddec091';
inputs['node-version'] = versionSpec; inputs['node-version'] = versionSpec;
findSpy.mockImplementation(() => ''); findSpy.mockImplementation(() => '');
@ -290,12 +290,12 @@ describe('setup-node', () => {
}); });
it('reports a failed download', async () => { it('reports a failed download', async () => {
let errMsg = 'unhandled download message'; const errMsg = 'unhandled download message';
os.platform = 'linux'; os.platform = 'linux';
os.arch = 'x64'; os.arch = 'x64';
// a version which is in the manifest // a version which is in the manifest
let versionSpec = '18.0.0-nightly202204180699150267'; const versionSpec = '18.0.0-nightly202204180699150267';
inputs['node-version'] = versionSpec; inputs['node-version'] = versionSpec;
inputs['always-auth'] = false; inputs['always-auth'] = false;
@ -339,14 +339,14 @@ describe('setup-node', () => {
inputs['always-auth'] = false; inputs['always-auth'] = false;
inputs['token'] = 'faketoken'; inputs['token'] = 'faketoken';
let expectedUrl = `https://nodejs.org/download/nightly/v${version}/node-v${version}-${platform}-${arch}.${fileExtension}`; const expectedUrl = `https://nodejs.org/download/nightly/v${version}/node-v${version}-${platform}-${arch}.${fileExtension}`;
// ... but not in the local cache // ... but not in the local cache
findSpy.mockImplementation(() => ''); findSpy.mockImplementation(() => '');
findAllVersionsSpy.mockImplementation(() => []); findAllVersionsSpy.mockImplementation(() => []);
dlSpy.mockImplementation(async () => '/some/temp/path'); dlSpy.mockImplementation(async () => '/some/temp/path');
let toolPath = path.normalize(`/cache/node/${version}/${arch}`); const toolPath = path.normalize(`/cache/node/${version}/${arch}`);
exSpy.mockImplementation(async () => '/some/other/temp/path'); exSpy.mockImplementation(async () => '/some/other/temp/path');
cacheSpy.mockImplementation(async () => toolPath); cacheSpy.mockImplementation(async () => toolPath);

View File

@ -13,11 +13,11 @@ import * as auth from '../src/authutil';
import OfficialBuilds from '../src/distributions/official_builds/official_builds'; import OfficialBuilds from '../src/distributions/official_builds/official_builds';
import {INodeVersion} from '../src/distributions/base-models'; import {INodeVersion} from '../src/distributions/base-models';
const nodeTestManifest = require('./data/versions-manifest.json'); import nodeTestManifest from './data/versions-manifest.json';
const nodeTestDist = require('./data/node-dist-index.json'); import nodeTestDist from './data/node-dist-index.json';
const nodeTestDistNightly = require('./data/node-nightly-index.json'); import nodeTestDistNightly from './data/node-nightly-index.json';
const nodeTestDistRc = require('./data/node-rc-index.json'); import nodeTestDistRc from './data/node-rc-index.json';
const nodeV8CanaryTestDist = require('./data/v8-canary-dist-index.json'); import nodeV8CanaryTestDist from './data/v8-canary-dist-index.json';
describe('setup-node', () => { describe('setup-node', () => {
let build: OfficialBuilds; let build: OfficialBuilds;
@ -95,11 +95,11 @@ describe('setup-node', () => {
getJsonSpy.mockImplementation(url => { getJsonSpy.mockImplementation(url => {
let res: any; let res: any;
if (url.includes('/rc')) { if (url.includes('/rc')) {
res = <INodeVersion>nodeTestDistRc; res = <INodeVersion[]>nodeTestDistRc;
} else if (url.includes('/nightly')) { } else if (url.includes('/nightly')) {
res = <INodeVersion>nodeTestDistNightly; res = <INodeVersion[]>nodeTestDistNightly;
} else { } else {
res = <INodeVersion>nodeTestDist; res = <INodeVersion[]>nodeTestDist;
} }
return {result: res}; return {result: res};
@ -156,13 +156,13 @@ describe('setup-node', () => {
async (versionSpec, platform, expectedVersion, expectedLts) => { async (versionSpec, platform, expectedVersion, expectedLts) => {
os.platform = platform; os.platform = platform;
os.arch = 'x64'; os.arch = 'x64';
let versions: tc.IToolRelease[] | null = await tc.getManifestFromRepo( const versions: tc.IToolRelease[] | null = await tc.getManifestFromRepo(
'actions', 'actions',
'node-versions', 'node-versions',
'mocktoken' 'mocktoken'
); );
expect(versions).toBeDefined(); expect(versions).toBeDefined();
let match = await tc.findFromManifest(versionSpec, true, versions); const match = await tc.findFromManifest(versionSpec, true, versions);
expect(match).toBeDefined(); expect(match).toBeDefined();
expect(match?.version).toBe(expectedVersion); expect(match?.version).toBe(expectedVersion);
expect((match as any).lts).toBe(expectedLts); expect((match as any).lts).toBe(expectedLts);
@ -177,7 +177,7 @@ describe('setup-node', () => {
inputs['node-version'] = '12'; inputs['node-version'] = '12';
inputs.stable = 'true'; inputs.stable = 'true';
let toolPath = path.normalize('/cache/node/12.16.1/x64'); const toolPath = path.normalize('/cache/node/12.16.1/x64');
findSpy.mockImplementation(() => toolPath); findSpy.mockImplementation(() => toolPath);
await main.run(); await main.run();
@ -189,7 +189,7 @@ describe('setup-node', () => {
inSpy.mockImplementation(name => inputs[name]); inSpy.mockImplementation(name => inputs[name]);
let toolPath = path.normalize('/cache/node/12.16.1/x64'); const toolPath = path.normalize('/cache/node/12.16.1/x64');
findSpy.mockImplementation(() => toolPath); findSpy.mockImplementation(() => toolPath);
await main.run(); await main.run();
@ -201,16 +201,16 @@ describe('setup-node', () => {
inSpy.mockImplementation(name => inputs[name]); inSpy.mockImplementation(name => inputs[name]);
let toolPath = path.normalize('/cache/node/12.16.1/x64'); const toolPath = path.normalize('/cache/node/12.16.1/x64');
findSpy.mockImplementation(() => toolPath); findSpy.mockImplementation(() => toolPath);
await main.run(); await main.run();
let expPath = path.join(toolPath, 'bin'); const expPath = path.join(toolPath, 'bin');
expect(cnSpy).toHaveBeenCalledWith(`::add-path::${expPath}${osm.EOL}`); expect(cnSpy).toHaveBeenCalledWith(`::add-path::${expPath}${osm.EOL}`);
}); });
it('handles unhandled find error and reports error', async () => { it('handles unhandled find error and reports error', async () => {
let errMsg = 'unhandled error message'; const errMsg = 'unhandled error message';
inputs['node-version'] = '12'; inputs['node-version'] = '12';
findSpy.mockImplementation(() => { findSpy.mockImplementation(() => {
@ -231,27 +231,27 @@ describe('setup-node', () => {
os.arch = 'x64'; os.arch = 'x64';
// a version which is in the manifest // a version which is in the manifest
let versionSpec = '12.16.2'; const versionSpec = '12.16.2';
let resolvedVersion = versionSpec; const resolvedVersion = versionSpec;
inputs['node-version'] = versionSpec; inputs['node-version'] = versionSpec;
inputs['always-auth'] = false; inputs['always-auth'] = false;
inputs['token'] = 'faketoken'; inputs['token'] = 'faketoken';
let expectedUrl = const expectedUrl =
'https://github.com/actions/node-versions/releases/download/12.16.2-20200507.95/node-12.16.2-linux-x64.tar.gz'; 'https://github.com/actions/node-versions/releases/download/12.16.2-20200507.95/node-12.16.2-linux-x64.tar.gz';
// ... but not in the local cache // ... but not in the local cache
findSpy.mockImplementation(() => ''); findSpy.mockImplementation(() => '');
dlSpy.mockImplementation(async () => '/some/temp/path'); dlSpy.mockImplementation(async () => '/some/temp/path');
let toolPath = path.normalize('/cache/node/12.16.2/x64'); const toolPath = path.normalize('/cache/node/12.16.2/x64');
exSpy.mockImplementation(async () => '/some/other/temp/path'); exSpy.mockImplementation(async () => '/some/other/temp/path');
cacheSpy.mockImplementation(async () => toolPath); cacheSpy.mockImplementation(async () => toolPath);
await main.run(); await main.run();
let expPath = path.join(toolPath, 'bin'); const expPath = path.join(toolPath, 'bin');
expect(getExecOutputSpy).toHaveBeenCalledWith( expect(getExecOutputSpy).toHaveBeenCalledWith(
'node', 'node',
@ -284,7 +284,7 @@ describe('setup-node', () => {
os.arch = 'x64'; os.arch = 'x64';
// a version which is not in the manifest but is in node dist // a version which is not in the manifest but is in node dist
let versionSpec = '11.15.0'; const versionSpec = '11.15.0';
inputs['node-version'] = versionSpec; inputs['node-version'] = versionSpec;
inputs['always-auth'] = false; inputs['always-auth'] = false;
@ -318,7 +318,7 @@ describe('setup-node', () => {
os.platform = 'linux'; os.platform = 'linux';
os.arch = 'x64'; os.arch = 'x64';
let versionSpec = '9.99.9'; const versionSpec = '9.99.9';
inputs['node-version'] = versionSpec; inputs['node-version'] = versionSpec;
findSpy.mockImplementation(() => ''); findSpy.mockImplementation(() => '');
@ -336,13 +336,13 @@ describe('setup-node', () => {
}); });
it('reports a failed download', async () => { it('reports a failed download', async () => {
let errMsg = 'unhandled download message'; const errMsg = 'unhandled download message';
os.platform = 'linux'; os.platform = 'linux';
os.arch = 'x64'; os.arch = 'x64';
// a version which is in the manifest // a version which is in the manifest
let versionSpec = '12.16.2'; const versionSpec = '12.16.2';
let resolvedVersion = versionSpec; const resolvedVersion = versionSpec;
inputs['node-version'] = versionSpec; inputs['node-version'] = versionSpec;
inputs['always-auth'] = false; inputs['always-auth'] = false;
@ -376,7 +376,7 @@ describe('setup-node', () => {
inputs['always-auth'] = false; inputs['always-auth'] = false;
inputs['token'] = 'faketoken'; inputs['token'] = 'faketoken';
let expectedUrl = const expectedUrl =
arch === 'x64' arch === 'x64'
? `https://github.com/actions/node-versions/releases/download/${version}/node-${version}-${platform}-${arch}.zip` ? `https://github.com/actions/node-versions/releases/download/${version}/node-${version}-${platform}-${arch}.zip`
: `https://nodejs.org/dist/v${version}/node-v${version}-${platform}-${arch}.${fileExtension}`; : `https://nodejs.org/dist/v${version}/node-v${version}-${platform}-${arch}.${fileExtension}`;
@ -385,7 +385,7 @@ describe('setup-node', () => {
findSpy.mockImplementation(() => ''); findSpy.mockImplementation(() => '');
dlSpy.mockImplementation(async () => '/some/temp/path'); dlSpy.mockImplementation(async () => '/some/temp/path');
let toolPath = path.normalize(`/cache/node/${version}/${arch}`); const toolPath = path.normalize(`/cache/node/${version}/${arch}`);
exSpy.mockImplementation(async () => '/some/other/temp/path'); exSpy.mockImplementation(async () => '/some/other/temp/path');
cacheSpy.mockImplementation(async () => toolPath); cacheSpy.mockImplementation(async () => toolPath);
@ -481,7 +481,7 @@ describe('setup-node', () => {
os.arch = 'x64'; os.arch = 'x64';
// a version which is not in the manifest but is in node dist // a version which is not in the manifest but is in node dist
let versionSpec = '11'; const versionSpec = '11';
inputs['node-version'] = versionSpec; inputs['node-version'] = versionSpec;
inputs['check-latest'] = 'true'; inputs['check-latest'] = 'true';
@ -492,13 +492,13 @@ describe('setup-node', () => {
findSpy.mockImplementation(() => ''); findSpy.mockImplementation(() => '');
dlSpy.mockImplementation(async () => '/some/temp/path'); dlSpy.mockImplementation(async () => '/some/temp/path');
let toolPath = path.normalize('/cache/node/11.11.0/x64'); const toolPath = path.normalize('/cache/node/11.11.0/x64');
exSpy.mockImplementation(async () => '/some/other/temp/path'); exSpy.mockImplementation(async () => '/some/other/temp/path');
cacheSpy.mockImplementation(async () => toolPath); cacheSpy.mockImplementation(async () => toolPath);
await main.run(); await main.run();
let expPath = path.join(toolPath, 'bin'); const expPath = path.join(toolPath, 'bin');
expect(dlSpy).toHaveBeenCalled(); expect(dlSpy).toHaveBeenCalled();
expect(exSpy).toHaveBeenCalled(); expect(exSpy).toHaveBeenCalled();
@ -523,7 +523,7 @@ describe('setup-node', () => {
os.arch = 'x64'; os.arch = 'x64';
// a version which is not in the manifest but is in node dist // a version which is not in the manifest but is in node dist
let versionSpec = '12'; const versionSpec = '12';
inputs['node-version'] = versionSpec; inputs['node-version'] = versionSpec;
inputs['check-latest'] = 'true'; inputs['check-latest'] = 'true';
@ -537,13 +537,13 @@ describe('setup-node', () => {
}); });
dlSpy.mockImplementation(async () => '/some/temp/path'); dlSpy.mockImplementation(async () => '/some/temp/path');
let toolPath = path.normalize('/cache/node/12.11.0/x64'); const toolPath = path.normalize('/cache/node/12.11.0/x64');
exSpy.mockImplementation(async () => '/some/other/temp/path'); exSpy.mockImplementation(async () => '/some/other/temp/path');
cacheSpy.mockImplementation(async () => toolPath); cacheSpy.mockImplementation(async () => toolPath);
await main.run(); await main.run();
let expPath = path.join(toolPath, 'bin'); const expPath = path.join(toolPath, 'bin');
expect(dlSpy).toHaveBeenCalled(); expect(dlSpy).toHaveBeenCalled();
expect(exSpy).toHaveBeenCalled(); expect(exSpy).toHaveBeenCalled();

View File

@ -1,10 +1,12 @@
import tscMatcher from '../.github/tsc.json';
describe('problem matcher tests', () => { describe('problem matcher tests', () => {
it('tsc: matches TypeScript "pretty" error message', () => { it('tsc: matches TypeScript "pretty" error message', () => {
const [ const [
{ {
pattern: [{regexp}] pattern: [{regexp}]
} }
] = require('../.github/tsc.json').problemMatcher; ] = tscMatcher.problemMatcher;
const exampleErrorMessage = const exampleErrorMessage =
"lib/index.js:23:42 - error TS2345: Argument of type 'A' is not assignable to parameter of type 'B'."; "lib/index.js:23:42 - error TS2345: Argument of type 'A' is not assignable to parameter of type 'B'.";
@ -25,7 +27,7 @@ describe('problem matcher tests', () => {
{ {
pattern: [{regexp}] pattern: [{regexp}]
} }
] = require('../.github/tsc.json').problemMatcher; ] = tscMatcher.problemMatcher;
const exampleErrorMessage = const exampleErrorMessage =
"lib/index.js(23,42): error TS2345: Argument of type 'A' is not assignable to parameter of type 'B'."; "lib/index.js(23,42): error TS2345: Argument of type 'A' is not assignable to parameter of type 'B'.";

View File

@ -12,10 +12,10 @@ import * as main from '../src/main';
import * as auth from '../src/authutil'; import * as auth from '../src/authutil';
import {INodeVersion} from '../src/distributions/base-models'; import {INodeVersion} from '../src/distributions/base-models';
const nodeTestDist = require('./data/node-dist-index.json'); import nodeTestDist from './data/node-dist-index.json';
const nodeTestDistNightly = require('./data/node-nightly-index.json'); import nodeTestDistNightly from './data/node-nightly-index.json';
const nodeTestDistRc = require('./data/node-rc-index.json'); import nodeTestDistRc from './data/node-rc-index.json';
const nodeV8CanaryTestDist = require('./data/v8-canary-dist-index.json'); import nodeV8CanaryTestDist from './data/v8-canary-dist-index.json';
describe('setup-node', () => { describe('setup-node', () => {
let inputs = {} as any; let inputs = {} as any;
@ -86,11 +86,11 @@ describe('setup-node', () => {
getJsonSpy.mockImplementation(url => { getJsonSpy.mockImplementation(url => {
let res: any; let res: any;
if (url.includes('/rc')) { if (url.includes('/rc')) {
res = <INodeVersion>nodeTestDistRc; res = <INodeVersion[]>nodeTestDistRc;
} else if (url.includes('/nightly')) { } else if (url.includes('/nightly')) {
res = <INodeVersion>nodeTestDistNightly; res = <INodeVersion[]>nodeTestDistNightly;
} else { } else {
res = <INodeVersion>nodeTestDist; res = <INodeVersion[]>nodeTestDist;
} }
return {result: res}; return {result: res};
@ -142,7 +142,7 @@ describe('setup-node', () => {
inputs['node-version'] = '12.0.0-rc.1'; inputs['node-version'] = '12.0.0-rc.1';
inputs.stable = 'true'; inputs.stable = 'true';
let toolPath = path.normalize('/cache/node/12.0.0-rc.1/x64'); const toolPath = path.normalize('/cache/node/12.0.0-rc.1/x64');
findSpy.mockImplementation(() => toolPath); findSpy.mockImplementation(() => toolPath);
await main.run(); await main.run();
@ -154,7 +154,7 @@ describe('setup-node', () => {
inSpy.mockImplementation(name => inputs[name]); inSpy.mockImplementation(name => inputs[name]);
let toolPath = path.normalize('/cache/node/12.0.0-rc.1/x64'); const toolPath = path.normalize('/cache/node/12.0.0-rc.1/x64');
findSpy.mockImplementation(() => toolPath); findSpy.mockImplementation(() => toolPath);
await main.run(); await main.run();
@ -166,16 +166,16 @@ describe('setup-node', () => {
inSpy.mockImplementation(name => inputs[name]); inSpy.mockImplementation(name => inputs[name]);
let toolPath = path.normalize('/cache/node/12.0.0-rc.1/x64'); const toolPath = path.normalize('/cache/node/12.0.0-rc.1/x64');
findSpy.mockImplementation(() => toolPath); findSpy.mockImplementation(() => toolPath);
await main.run(); await main.run();
let expPath = path.join(toolPath, 'bin'); const expPath = path.join(toolPath, 'bin');
expect(cnSpy).toHaveBeenCalledWith(`::add-path::${expPath}${osm.EOL}`); expect(cnSpy).toHaveBeenCalledWith(`::add-path::${expPath}${osm.EOL}`);
}); });
it('handles unhandled find error and reports error', async () => { it('handles unhandled find error and reports error', async () => {
let errMsg = 'unhandled error message'; const errMsg = 'unhandled error message';
inputs['node-version'] = '12.0.0-rc.1'; inputs['node-version'] = '12.0.0-rc.1';
findSpy.mockImplementation(() => { findSpy.mockImplementation(() => {
@ -191,7 +191,7 @@ describe('setup-node', () => {
os.platform = 'linux'; os.platform = 'linux';
os.arch = 'x64'; os.arch = 'x64';
let versionSpec = '13.0.0-rc.0'; const versionSpec = '13.0.0-rc.0';
inputs['node-version'] = versionSpec; inputs['node-version'] = versionSpec;
inputs['always-auth'] = false; inputs['always-auth'] = false;
@ -201,13 +201,13 @@ describe('setup-node', () => {
findSpy.mockImplementation(() => ''); findSpy.mockImplementation(() => '');
dlSpy.mockImplementation(async () => '/some/temp/path'); dlSpy.mockImplementation(async () => '/some/temp/path');
let toolPath = path.normalize('/cache/node/13.0.0-rc.0/x64'); const toolPath = path.normalize('/cache/node/13.0.0-rc.0/x64');
exSpy.mockImplementation(async () => '/some/other/temp/path'); exSpy.mockImplementation(async () => '/some/other/temp/path');
cacheSpy.mockImplementation(async () => toolPath); cacheSpy.mockImplementation(async () => toolPath);
await main.run(); await main.run();
let expPath = path.join(toolPath, 'bin'); const expPath = path.join(toolPath, 'bin');
expect(dlSpy).toHaveBeenCalled(); expect(dlSpy).toHaveBeenCalled();
expect(exSpy).toHaveBeenCalled(); expect(exSpy).toHaveBeenCalled();
@ -220,7 +220,7 @@ describe('setup-node', () => {
os.platform = 'linux'; os.platform = 'linux';
os.arch = 'x64'; os.arch = 'x64';
let versionSpec = '9.99.9-rc.1'; const versionSpec = '9.99.9-rc.1';
inputs['node-version'] = versionSpec; inputs['node-version'] = versionSpec;
findSpy.mockImplementation(() => ''); findSpy.mockImplementation(() => '');
@ -232,11 +232,11 @@ describe('setup-node', () => {
}); });
it('reports a failed download', async () => { it('reports a failed download', async () => {
let errMsg = 'unhandled download message'; const errMsg = 'unhandled download message';
os.platform = 'linux'; os.platform = 'linux';
os.arch = 'x64'; os.arch = 'x64';
let versionSpec = '14.7.0-rc.1'; const versionSpec = '14.7.0-rc.1';
inputs['node-version'] = versionSpec; inputs['node-version'] = versionSpec;
inputs['always-auth'] = false; inputs['always-auth'] = false;
@ -271,14 +271,14 @@ describe('setup-node', () => {
inputs['always-auth'] = false; inputs['always-auth'] = false;
inputs['token'] = 'faketoken'; inputs['token'] = 'faketoken';
let expectedUrl = `https://nodejs.org/download/rc/v${version}/node-v${version}-${platform}-${arch}.${fileExtension}`; const expectedUrl = `https://nodejs.org/download/rc/v${version}/node-v${version}-${platform}-${arch}.${fileExtension}`;
// ... but not in the local cache // ... but not in the local cache
findSpy.mockImplementation(() => ''); findSpy.mockImplementation(() => '');
findAllVersionsSpy.mockImplementation(() => []); findAllVersionsSpy.mockImplementation(() => []);
dlSpy.mockImplementation(async () => '/some/temp/path'); dlSpy.mockImplementation(async () => '/some/temp/path');
let toolPath = path.normalize(`/cache/node/${version}/${arch}`); const toolPath = path.normalize(`/cache/node/${version}/${arch}`);
exSpy.mockImplementation(async () => '/some/other/temp/path'); exSpy.mockImplementation(async () => '/some/other/temp/path');
cacheSpy.mockImplementation(async () => toolPath); cacheSpy.mockImplementation(async () => toolPath);

View File

@ -61018,87 +61018,87 @@ exports.fromPromise = function (fn) {
/***/ (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 cache = __importStar(__nccwpck_require__(7799)); const cache = __importStar(__nccwpck_require__(7799));
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);
// Catch and log any unhandled exceptions. These exceptions can leak out of the uploadChunk method in // Catch and log any unhandled exceptions. These exceptions can leak out of the uploadChunk method in
// @actions/toolkit when a failed upload closes the file descriptor causing any in-process reads to // @actions/toolkit when a failed upload closes the file descriptor causing any in-process reads to
// throw an uncaught exception. Instead of failing this action, just warn. // throw an uncaught exception. Instead of failing this action, just warn.
process.on('uncaughtException', e => { process.on('uncaughtException', e => {
const warningPrefix = '[warning]'; const warningPrefix = '[warning]';
core.info(`${warningPrefix}${e.message}`); core.info(`${warningPrefix}${e.message}`);
}); });
function run() { function run() {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
try { try {
const cacheLock = core.getInput('cache'); const cacheLock = core.getInput('cache');
yield cachePackages(cacheLock); yield cachePackages(cacheLock);
} }
catch (error) { catch (error) {
core.setFailed(error.message); core.setFailed(error.message);
} }
}); });
} }
exports.run = run; exports.run = run;
const cachePackages = (packageManager) => __awaiter(void 0, void 0, void 0, function* () { const cachePackages = (packageManager) => __awaiter(void 0, void 0, void 0, function* () {
const state = core.getState(constants_1.State.CacheMatchedKey); const state = core.getState(constants_1.State.CacheMatchedKey);
const primaryKey = core.getState(constants_1.State.CachePrimaryKey); const primaryKey = core.getState(constants_1.State.CachePrimaryKey);
const packageManagerInfo = yield cache_utils_1.getPackageManagerInfo(packageManager); const packageManagerInfo = yield cache_utils_1.getPackageManagerInfo(packageManager);
if (!packageManagerInfo) { if (!packageManagerInfo) {
core.debug(`Caching for '${packageManager}' is not supported`); core.debug(`Caching for '${packageManager}' is not supported`);
return; return;
} }
const cachePath = yield cache_utils_1.getCacheDirectoryPath(packageManagerInfo, packageManager); const cachePath = yield cache_utils_1.getCacheDirectoryPath(packageManagerInfo, packageManager);
if (!fs_1.default.existsSync(cachePath)) { if (!fs_1.default.existsSync(cachePath)) {
throw new Error(`Cache folder path is retrieved for ${packageManager} but doesn't exist on disk: ${cachePath}`); 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([cachePath], 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();
/***/ }), /***/ }),
@ -61107,123 +61107,123 @@ 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 })); Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.isCacheFeatureAvailable = exports.isGhes = exports.getCacheDirectoryPath = exports.getPackageManagerInfo = exports.getCommandOutput = exports.supportedPackageManagers = void 0; exports.isCacheFeatureAvailable = exports.isGhes = exports.getCacheDirectoryPath = exports.getPackageManagerInfo = exports.getCommandOutput = exports.supportedPackageManagers = void 0;
const core = __importStar(__nccwpck_require__(2186)); const core = __importStar(__nccwpck_require__(2186));
const exec = __importStar(__nccwpck_require__(1514)); const exec = __importStar(__nccwpck_require__(1514));
const cache = __importStar(__nccwpck_require__(7799)); const cache = __importStar(__nccwpck_require__(7799));
exports.supportedPackageManagers = { exports.supportedPackageManagers = {
npm: { npm: {
lockFilePatterns: ['package-lock.json', 'npm-shrinkwrap.json', 'yarn.lock'], lockFilePatterns: ['package-lock.json', 'npm-shrinkwrap.json', 'yarn.lock'],
getCacheFolderCommand: 'npm config get cache' getCacheFolderCommand: 'npm config get cache'
}, },
pnpm: { pnpm: {
lockFilePatterns: ['pnpm-lock.yaml'], lockFilePatterns: ['pnpm-lock.yaml'],
getCacheFolderCommand: 'pnpm store path --silent' getCacheFolderCommand: 'pnpm store path --silent'
}, },
yarn1: { yarn1: {
lockFilePatterns: ['yarn.lock'], lockFilePatterns: ['yarn.lock'],
getCacheFolderCommand: 'yarn cache dir' getCacheFolderCommand: 'yarn cache dir'
}, },
yarn2: { yarn2: {
lockFilePatterns: ['yarn.lock'], lockFilePatterns: ['yarn.lock'],
getCacheFolderCommand: 'yarn config get cacheFolder' getCacheFolderCommand: 'yarn config get cacheFolder'
} }
}; };
const getCommandOutput = (toolCommand) => __awaiter(void 0, void 0, void 0, function* () { const getCommandOutput = (toolCommand) => __awaiter(void 0, void 0, void 0, function* () {
let { stdout, stderr, exitCode } = yield exec.getExecOutput(toolCommand, undefined, { ignoreReturnCode: true }); let { stdout, stderr, exitCode } = yield exec.getExecOutput(toolCommand, undefined, { ignoreReturnCode: true });
if (exitCode) { if (exitCode) {
stderr = !stderr.trim() stderr = !stderr.trim()
? `The '${toolCommand}' command failed with exit code: ${exitCode}` ? `The '${toolCommand}' command failed with exit code: ${exitCode}`
: stderr; : stderr;
throw new Error(stderr); throw new Error(stderr);
} }
return stdout.trim(); return stdout.trim();
}); });
exports.getCommandOutput = getCommandOutput; exports.getCommandOutput = getCommandOutput;
const getPackageManagerVersion = (packageManager, command) => __awaiter(void 0, void 0, void 0, function* () { const getPackageManagerVersion = (packageManager, command) => __awaiter(void 0, void 0, void 0, function* () {
const stdOut = yield exports.getCommandOutput(`${packageManager} ${command}`); const stdOut = yield exports.getCommandOutput(`${packageManager} ${command}`);
if (!stdOut) { if (!stdOut) {
throw new Error(`Could not retrieve version of ${packageManager}`); throw new Error(`Could not retrieve version of ${packageManager}`);
} }
return stdOut; return stdOut;
}); });
const getPackageManagerInfo = (packageManager) => __awaiter(void 0, void 0, void 0, function* () { const getPackageManagerInfo = (packageManager) => __awaiter(void 0, void 0, void 0, function* () {
if (packageManager === 'npm') { if (packageManager === 'npm') {
return exports.supportedPackageManagers.npm; return exports.supportedPackageManagers.npm;
} }
else if (packageManager === 'pnpm') { else if (packageManager === 'pnpm') {
return exports.supportedPackageManagers.pnpm; return exports.supportedPackageManagers.pnpm;
} }
else if (packageManager === 'yarn') { else if (packageManager === 'yarn') {
const yarnVersion = yield getPackageManagerVersion('yarn', '--version'); const yarnVersion = yield getPackageManagerVersion('yarn', '--version');
core.debug(`Consumed yarn version is ${yarnVersion}`); core.debug(`Consumed yarn version is ${yarnVersion}`);
if (yarnVersion.startsWith('1.')) { if (yarnVersion.startsWith('1.')) {
return exports.supportedPackageManagers.yarn1; return exports.supportedPackageManagers.yarn1;
} }
else { else {
return exports.supportedPackageManagers.yarn2; return exports.supportedPackageManagers.yarn2;
} }
} }
else { else {
return null; return null;
} }
}); });
exports.getPackageManagerInfo = getPackageManagerInfo; exports.getPackageManagerInfo = getPackageManagerInfo;
const getCacheDirectoryPath = (packageManagerInfo, packageManager) => __awaiter(void 0, void 0, void 0, function* () { const getCacheDirectoryPath = (packageManagerInfo, packageManager) => __awaiter(void 0, void 0, void 0, function* () {
const stdOut = yield exports.getCommandOutput(packageManagerInfo.getCacheFolderCommand); const stdOut = yield exports.getCommandOutput(packageManagerInfo.getCacheFolderCommand);
if (!stdOut) { if (!stdOut) {
throw new Error(`Could not get cache folder path for ${packageManager}`); throw new Error(`Could not get cache folder path for ${packageManager}`);
} }
core.debug(`${packageManager} path is ${stdOut}`); core.debug(`${packageManager} path is ${stdOut}`);
return stdOut.trim(); return stdOut.trim();
}); });
exports.getCacheDirectoryPath = getCacheDirectoryPath; exports.getCacheDirectoryPath = getCacheDirectoryPath;
function isGhes() { function isGhes() {
const ghUrl = new URL(process.env['GITHUB_SERVER_URL'] || 'https://github.com'); const ghUrl = new URL(process.env['GITHUB_SERVER_URL'] || 'https://github.com');
return ghUrl.hostname.toUpperCase() !== 'GITHUB.COM'; return ghUrl.hostname.toUpperCase() !== 'GITHUB.COM';
} }
exports.isGhes = isGhes; exports.isGhes = isGhes;
function isCacheFeatureAvailable() { function isCacheFeatureAvailable() {
if (cache.isFeatureAvailable()) if (cache.isFeatureAvailable())
return true; return true;
if (isGhes()) { if (isGhes()) {
core.warning('Cache action is only supported on GHES version >= 3.5. If you are on version >=3.5 Please check with GHES admin if Actions cache service is enabled or not.'); core.warning('Cache action is only supported on GHES version >= 3.5. If you are on version >=3.5 Please check with GHES admin if Actions cache service is enabled or not.');
return false; return false;
} }
core.warning('The runner was not able to contact the cache service. Caching will be skipped'); core.warning('The runner was not able to contact the cache service. Caching will be skipped');
return false; return false;
} }
exports.isCacheFeatureAvailable = isCacheFeatureAvailable; exports.isCacheFeatureAvailable = isCacheFeatureAvailable;
/***/ }), /***/ }),
@ -61232,24 +61232,24 @@ 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 = exports.State || (exports.State = {}));
var Outputs; var Outputs;
(function (Outputs) { (function (Outputs) {
Outputs["CacheHit"] = "cache-hit"; Outputs["CacheHit"] = "cache-hit";
})(Outputs = exports.Outputs || (exports.Outputs = {})); })(Outputs = exports.Outputs || (exports.Outputs = {}));
/***/ }), /***/ }),

2210
dist/setup/index.js vendored

File diff suppressed because it is too large Load Diff

View File

@ -52,7 +52,7 @@ Pull requests are the easiest way to contribute changes to git repos at GitHub.
- Please check that no one else has already created a pull request with these or similar changes - Please check that no one else has already created a pull request with these or similar changes
- Use a "feature branch" for your changes. That separates the changes in the pull request from your other changes and makes it easy to edit/amend commits in the pull request - Use a "feature branch" for your changes. That separates the changes in the pull request from your other changes and makes it easy to edit/amend commits in the pull request
- **Run `pre-checkin` script to format, build and test changes** - **Run `pre-checkin` script to format, lint, build and test changes**
- Make sure your changes are well formatted and that all tests are passing - Make sure your changes are well formatted and that all tests are passing
- If your pull request is connected to an open issue, please, leave a link to this issue in the `Related issue:` section - If your pull request is connected to an open issue, please, leave a link to this issue in the `Related issue:` section
- If you later need to add new commits to the pull request, you can simply commit the changes to the local branch and then push them. The pull request gets automatically updated - If you later need to add new commits to the pull request, you can simply commit the changes to the local branch and then push them. The pull request gets automatically updated
@ -61,6 +61,7 @@ Pull requests are the easiest way to contribute changes to git repos at GitHub.
- To implement new features or fix bugs, you need to make changes to the `.ts` files, which are located in the `src` folder - To implement new features or fix bugs, you need to make changes to the `.ts` files, which are located in the `src` folder
- To comply with the code style, **you need to run the `format` script** - To comply with the code style, **you need to run the `format` script**
- To lint the code, **you need to run the `lint:fix` script**
- To transpile source code to `javascript` we use [NCC](https://github.com/vercel/ncc). **It is very important to run the `build` script after making changes**, otherwise your changes will not get into the final `javascript` build - To transpile source code to `javascript` we use [NCC](https://github.com/vercel/ncc). **It is very important to run the `build` script after making changes**, otherwise your changes will not get into the final `javascript` build
- You can also start formatting, building code, and testing with a single `pre-checkin` command - You can also start formatting, building code, and testing with a single `pre-checkin` command

2130
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -6,11 +6,12 @@
"main": "lib/setup-node.js", "main": "lib/setup-node.js",
"scripts": { "scripts": {
"build": "ncc build -o dist/setup src/setup-node.ts && ncc build -o dist/cache-save src/cache-save.ts", "build": "ncc build -o dist/setup src/setup-node.ts && ncc build -o dist/cache-save src/cache-save.ts",
"format": "prettier --write **/*.ts", "format": "prettier --no-error-on-unmatched-pattern --config ./.prettierrc.js --write **/*.{ts,yml,yaml}",
"format-check": "prettier --check **/*.ts", "format-check": "prettier --no-error-on-unmatched-pattern --config ./.prettierrc.js --check **/*.{ts,yml,yaml}",
"lint": "echo \"Fake command that does nothing. It is used in reusable workflows\"", "lint": "eslint --config ./.eslintrc.js **/*.ts",
"lint:fix": "eslint --config ./.eslintrc.js **/*.ts --fix",
"test": "jest --coverage", "test": "jest --coverage",
"pre-checkin": "npm run format && npm run build && npm test" "pre-checkin": "npm run format && npm run lint:fix && npm run build && npm test"
}, },
"repository": { "repository": {
"type": "git", "type": "git",
@ -38,10 +39,15 @@
"@types/jest": "^27.0.2", "@types/jest": "^27.0.2",
"@types/node": "^16.11.25", "@types/node": "^16.11.25",
"@types/semver": "^6.0.0", "@types/semver": "^6.0.0",
"@typescript-eslint/eslint-plugin": "^5.54.0",
"@typescript-eslint/parser": "^5.54.0",
"@vercel/ncc": "^0.33.4", "@vercel/ncc": "^0.33.4",
"eslint": "^8.35.0",
"eslint-config-prettier": "^8.6.0",
"eslint-plugin-jest": "^27.2.1",
"jest": "^27.2.5", "jest": "^27.2.5",
"jest-circus": "^27.2.5", "jest-circus": "^27.2.5",
"prettier": "^1.19.1", "prettier": "^2.8.4",
"ts-jest": "^27.0.5", "ts-jest": "^27.0.5",
"typescript": "^4.2.3" "typescript": "^4.2.3"
} }

View File

@ -33,7 +33,7 @@ function writeRegistryToFile(
} }
core.debug(`Setting auth in ${fileLocation}`); core.debug(`Setting auth in ${fileLocation}`);
let newContents: string = ''; let newContents = '';
if (fs.existsSync(fileLocation)) { if (fs.existsSync(fileLocation)) {
const curContents: string = fs.readFileSync(fileLocation, 'utf8'); const curContents: string = fs.readFileSync(fileLocation, 'utf8');
curContents.split(os.EOL).forEach((line: string) => { curContents.split(os.EOL).forEach((line: string) => {
@ -46,8 +46,8 @@ function writeRegistryToFile(
// Remove http: or https: from front of registry. // Remove http: or https: from front of registry.
const authString: string = const authString: string =
registryUrl.replace(/(^\w+:|^)/, '') + ':_authToken=${NODE_AUTH_TOKEN}'; registryUrl.replace(/(^\w+:|^)/, '') + ':_authToken=${NODE_AUTH_TOKEN}';
const registryString: string = `${scope}registry=${registryUrl}`; const registryString = `${scope}registry=${registryUrl}`;
const alwaysAuthString: string = `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);

View File

@ -54,7 +54,7 @@ export const restoreCache = async (
}; };
const findLockFile = (packageManager: PackageManagerInfo) => { const findLockFile = (packageManager: PackageManagerInfo) => {
let 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);

View File

@ -70,7 +70,7 @@ export default abstract class BaseDistribution {
core.debug(`evaluating ${versions.length} versions`); core.debug(`evaluating ${versions.length} versions`);
for (let potential of versions) { for (const potential of versions) {
const satisfied: boolean = semver.satisfies(potential, range, options); const satisfied: boolean = semver.satisfies(potential, range, options);
if (satisfied) { if (satisfied) {
version = potential; version = potential;
@ -95,18 +95,18 @@ export default abstract class BaseDistribution {
const initialUrl = this.getDistributionUrl(); const initialUrl = this.getDistributionUrl();
const dataUrl = `${initialUrl}/index.json`; const dataUrl = `${initialUrl}/index.json`;
let response = await this.httpClient.getJson<INodeVersion[]>(dataUrl); const response = await this.httpClient.getJson<INodeVersion[]>(dataUrl);
return response.result || []; return response.result || [];
} }
protected getNodejsDistInfo(version: string) { protected getNodejsDistInfo(version: string) {
let osArch: string = this.translateArchToDistUrl(this.nodeInfo.arch); const osArch: string = this.translateArchToDistUrl(this.nodeInfo.arch);
version = semver.clean(version) || ''; version = semver.clean(version) || '';
let fileName: string = const fileName: string =
this.osPlat == 'win32' 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}`;
let urlFileName: string = const urlFileName: string =
this.osPlat == 'win32' ? `${fileName}.7z` : `${fileName}.tar.gz`; 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}`;
@ -137,7 +137,7 @@ export default abstract class BaseDistribution {
throw err; throw err;
} }
let toolPath = await this.extractArchive(downloadPath, info); const toolPath = await this.extractArchive(downloadPath, info);
core.info('Done'); core.info('Done');
return toolPath; return toolPath;
@ -156,7 +156,7 @@ export default abstract class BaseDistribution {
arch: string = os.arch() arch: string = os.arch()
): Promise<string> { ): Promise<string> {
const initialUrl = this.getDistributionUrl(); const initialUrl = this.getDistributionUrl();
let osArch: string = this.translateArchToDistUrl(arch); const osArch: string = this.translateArchToDistUrl(arch);
// Create temporary folder to download in to // Create temporary folder to download in to
const tempDownloadFolder: string = const tempDownloadFolder: string =
@ -240,7 +240,7 @@ export default abstract class BaseDistribution {
} }
protected getDistFileName(): string { protected getDistFileName(): string {
let osArch: string = this.translateArchToDistUrl(this.nodeInfo.arch); const osArch: string = this.translateArchToDistUrl(this.nodeInfo.arch);
// node offers a json list of versions // node offers a json list of versions
let dataFileName: string; let dataFileName: string;

View File

@ -7,7 +7,8 @@
"sourceMap": true, "sourceMap": true,
"strict": true, /* Enable all strict type-checking options. */ "strict": true, /* Enable all strict type-checking options. */
"noImplicitAny": false, /* Raise error on expressions and declarations with an implied 'any' type. */ "noImplicitAny": false, /* Raise error on expressions and declarations with an implied 'any' type. */
"esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */ "esModuleInterop": true, /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
"resolveJsonModule": true, /* Allows importing modules with a '.json' extension, which is a common practice in node projects. */
}, },
"exclude": ["__tests__", "lib", "node_modules"] "exclude": ["__tests__", "lib", "node_modules"]
} }