mirror of
https://code.forgejo.org/actions/setup-node.git
synced 2025-05-19 21:04:45 +00:00
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:
parent
7c29869aec
commit
962678f22c
31 changed files with 3804 additions and 1545 deletions
|
@ -12,11 +12,11 @@ import * as main from '../src/main';
|
|||
import * as auth from '../src/authutil';
|
||||
import {INodeVersion} from '../src/distributions/base-models';
|
||||
|
||||
const nodeTestManifest = require('./data/versions-manifest.json');
|
||||
const nodeTestDist = require('./data/node-dist-index.json');
|
||||
const nodeTestDistNightly = require('./data/node-nightly-index.json');
|
||||
const nodeTestDistRc = require('./data/node-rc-index.json');
|
||||
const nodeV8CanaryTestDist = require('./data/v8-canary-dist-index.json');
|
||||
import nodeTestManifest from './data/versions-manifest.json';
|
||||
import nodeTestDist from './data/node-dist-index.json';
|
||||
import nodeTestDistNightly from './data/node-nightly-index.json';
|
||||
import nodeTestDistRc from './data/node-rc-index.json';
|
||||
import nodeV8CanaryTestDist from './data/v8-canary-dist-index.json';
|
||||
|
||||
describe('setup-node', () => {
|
||||
let inputs = {} as any;
|
||||
|
@ -95,13 +95,13 @@ describe('setup-node', () => {
|
|||
getJsonSpy.mockImplementation(url => {
|
||||
let res: any;
|
||||
if (url.includes('/rc')) {
|
||||
res = <INodeVersion>nodeTestDistRc;
|
||||
res = <INodeVersion[]>nodeTestDistRc;
|
||||
} else if (url.includes('/nightly')) {
|
||||
res = <INodeVersion>nodeTestDistNightly;
|
||||
res = <INodeVersion[]>nodeTestDistNightly;
|
||||
} else if (url.includes('/v8-canary')) {
|
||||
res = <INodeVersion>nodeV8CanaryTestDist;
|
||||
res = <INodeVersion[]>nodeV8CanaryTestDist;
|
||||
} else {
|
||||
res = <INodeVersion>nodeTestDist;
|
||||
res = <INodeVersion[]>nodeTestDist;
|
||||
}
|
||||
|
||||
return {result: res};
|
||||
|
@ -154,7 +154,7 @@ describe('setup-node', () => {
|
|||
os['arch'] = 'x64';
|
||||
inputs.stable = 'true';
|
||||
|
||||
let toolPath = path.normalize(
|
||||
const toolPath = path.normalize(
|
||||
'/cache/node/20.0.0-v8-canary20221103f7e2421e91/x64'
|
||||
);
|
||||
findSpy.mockImplementation(() => toolPath);
|
||||
|
@ -180,7 +180,7 @@ describe('setup-node', () => {
|
|||
|
||||
inSpy.mockImplementation(name => inputs[name]);
|
||||
|
||||
let toolPath = path.normalize(
|
||||
const toolPath = path.normalize(
|
||||
'/cache/node/20.0.0-v8-canary20221103f7e2421e91/x64'
|
||||
);
|
||||
findSpy.mockImplementation(() => toolPath);
|
||||
|
@ -192,13 +192,13 @@ describe('setup-node', () => {
|
|||
]);
|
||||
await main.run();
|
||||
|
||||
let expPath = path.join(toolPath, 'bin');
|
||||
const expPath = path.join(toolPath, 'bin');
|
||||
expect(cnSpy).toHaveBeenCalledWith(`::add-path::${expPath}${osm.EOL}`);
|
||||
});
|
||||
|
||||
it('handles unhandled find error and reports error', async () => {
|
||||
os.platform = 'linux';
|
||||
let errMsg = 'unhandled error message';
|
||||
const errMsg = 'unhandled error message';
|
||||
inputs['node-version'] = '20.0.0-v8-canary20221103f7e2421e91';
|
||||
|
||||
findSpy.mockImplementation(() => {
|
||||
|
@ -224,7 +224,7 @@ describe('setup-node', () => {
|
|||
os.arch = 'x64';
|
||||
|
||||
// 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['always-auth'] = false;
|
||||
|
@ -234,13 +234,13 @@ describe('setup-node', () => {
|
|||
findSpy.mockImplementation(() => '');
|
||||
|
||||
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');
|
||||
cacheSpy.mockImplementation(async () => toolPath);
|
||||
|
||||
await main.run();
|
||||
|
||||
let expPath = path.join(toolPath, 'bin');
|
||||
const expPath = path.join(toolPath, 'bin');
|
||||
|
||||
expect(dlSpy).toHaveBeenCalled();
|
||||
expect(exSpy).toHaveBeenCalled();
|
||||
|
@ -257,7 +257,7 @@ describe('setup-node', () => {
|
|||
os.platform = 'linux';
|
||||
os.arch = 'x64';
|
||||
|
||||
let versionSpec = '23.0.0-v8-canary20221103f7e2421e91';
|
||||
const versionSpec = '23.0.0-v8-canary20221103f7e2421e91';
|
||||
inputs['node-version'] = versionSpec;
|
||||
|
||||
findSpy.mockImplementation(() => '');
|
||||
|
@ -275,12 +275,12 @@ describe('setup-node', () => {
|
|||
});
|
||||
|
||||
it('reports a failed download', async () => {
|
||||
let errMsg = 'unhandled download message';
|
||||
const errMsg = 'unhandled download message';
|
||||
os.platform = 'linux';
|
||||
os.arch = 'x64';
|
||||
|
||||
// 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['always-auth'] = false;
|
||||
|
@ -327,14 +327,14 @@ describe('setup-node', () => {
|
|||
inputs['always-auth'] = false;
|
||||
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
|
||||
findSpy.mockImplementation(() => '');
|
||||
findAllVersionsSpy.mockImplementation(() => []);
|
||||
|
||||
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');
|
||||
cacheSpy.mockImplementation(async () => toolPath);
|
||||
|
||||
|
@ -502,7 +502,7 @@ describe('setup-node', () => {
|
|||
|
||||
describe('setup-node v8 canary tests', () => {
|
||||
it('v8 canary setup node flow with cached', async () => {
|
||||
let versionSpec = 'v20-v8-canary';
|
||||
const versionSpec = 'v20-v8-canary';
|
||||
|
||||
inputs['node-version'] = versionSpec;
|
||||
inputs['always-auth'] = false;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue