Add support for node version codename

Refactored for optimization and maintainability
This commit is contained in:
Jimi (Dimitris) Charalampidis 2019-09-13 13:15:45 +03:00
parent 7a3ce83626
commit 62a25ae2c2
No known key found for this signature in database
GPG Key ID: 36C7F609B733BD60
10 changed files with 507 additions and 401 deletions

View File

@ -1,30 +1,30 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP // Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`installer tests Appends trailing slash to registry 1`] = ` exports[`auth tests Appends trailing slash to registry 1`] = `
"//registry.npmjs.org/:_authToken=\${NODE_AUTH_TOKEN} "//registry.npmjs.org/:_authToken=\${NODE_AUTH_TOKEN}
registry=https://registry.npmjs.org/ registry=https://registry.npmjs.org/
always-auth=false" always-auth=false"
`; `;
exports[`installer tests Automatically configures GPR scope 1`] = ` exports[`auth tests Automatically configures GPR scope 1`] = `
"npm.pkg.github.com/:_authToken=\${NODE_AUTH_TOKEN} "npm.pkg.github.com/:_authToken=\${NODE_AUTH_TOKEN}
@ownername:registry=npm.pkg.github.com/ @ownername:registry=npm.pkg.github.com/
always-auth=false" always-auth=false"
`; `;
exports[`installer tests Configures scoped npm registries 1`] = ` exports[`auth tests Configures scoped npm registries 1`] = `
"//registry.npmjs.org/:_authToken=\${NODE_AUTH_TOKEN} "//registry.npmjs.org/:_authToken=\${NODE_AUTH_TOKEN}
@myscope:registry=https://registry.npmjs.org/ @myscope:registry=https://registry.npmjs.org/
always-auth=false" always-auth=false"
`; `;
exports[`installer tests Sets up npmrc for always-auth true 1`] = ` exports[`auth tests Sets up npmrc for always-auth true 1`] = `
"//registry.npmjs.org/:_authToken=\${NODE_AUTH_TOKEN} "//registry.npmjs.org/:_authToken=\${NODE_AUTH_TOKEN}
registry=https://registry.npmjs.org/ registry=https://registry.npmjs.org/
always-auth=true" always-auth=true"
`; `;
exports[`installer tests Sets up npmrc for npmjs 1`] = ` exports[`auth tests Sets up npmrc for npmjs 1`] = `
"//registry.npmjs.org/:_authToken=\${NODE_AUTH_TOKEN} "//registry.npmjs.org/:_authToken=\${NODE_AUTH_TOKEN}
registry=https://registry.npmjs.org/ registry=https://registry.npmjs.org/
always-auth=false" always-auth=false"

View File

@ -1,25 +1,20 @@
import io = require('@actions/io'); import * as io from '@actions/io';
import fs = require('fs'); import * as fs from 'fs';
import path = require('path'); import * as path from'path';
const tempDir = path.join(
__dirname,
'runner',
path.join(
Math.random()
.toString(36)
.substring(7)
),
'temp'
);
const runnerDir = path.join(__dirname, 'runner');
const randomizer = () =>
Math.random()
.toString(36)
.substring(7);
const tempDir = path.join(runnerDir, randomizer(), 'temp');
const rcFile = path.join(tempDir, '.npmrc'); const rcFile = path.join(tempDir, '.npmrc');
process.env['GITHUB_REPOSITORY'] = 'OwnerName/repo'; process.env['GITHUB_REPOSITORY'] = 'OwnerName/repo';
process.env['RUNNER_TEMP'] = tempDir; process.env['RUNNER_TEMP'] = tempDir;
import * as auth from '../src/authutil'; import * as auth from '../src/authutil';
describe('installer tests', () => { describe('auth tests', () => {
beforeAll(async () => { beforeAll(async () => {
await io.rmRF(tempDir); await io.rmRF(tempDir);
await io.mkdirP(tempDir); await io.mkdirP(tempDir);
@ -32,36 +27,36 @@ describe('installer tests', () => {
process.env['INPUT_SCOPE'] = ''; process.env['INPUT_SCOPE'] = '';
}); });
it('Sets up npmrc for npmjs', async () => { it('Sets up npmrc for npmjs', () => {
await auth.configAuthentication('https://registry.npmjs.org/', 'false'); auth.configAuthentication('https://registry.npmjs.org/', 'false');
expect(fs.existsSync(rcFile)).toBe(true); expect(fs.existsSync(rcFile)).toBe(true);
expect(fs.readFileSync(rcFile, {encoding: 'utf8'})).toMatchSnapshot(); expect(fs.readFileSync(rcFile, {encoding: 'utf8'})).toMatchSnapshot();
}); });
it('Appends trailing slash to registry', async () => { it('Appends trailing slash to registry', () => {
await auth.configAuthentication('https://registry.npmjs.org', 'false'); auth.configAuthentication('https://registry.npmjs.org', 'false');
expect(fs.existsSync(rcFile)).toBe(true); expect(fs.existsSync(rcFile)).toBe(true);
expect(fs.readFileSync(rcFile, {encoding: 'utf8'})).toMatchSnapshot(); expect(fs.readFileSync(rcFile, {encoding: 'utf8'})).toMatchSnapshot();
}); });
it('Configures scoped npm registries', async () => { it('Configures scoped npm registries', () => {
process.env['INPUT_SCOPE'] = 'myScope'; process.env['INPUT_SCOPE'] = 'myScope';
await auth.configAuthentication('https://registry.npmjs.org', 'false'); auth.configAuthentication('https://registry.npmjs.org', 'false');
expect(fs.existsSync(rcFile)).toBe(true); expect(fs.existsSync(rcFile)).toBe(true);
expect(fs.readFileSync(rcFile, {encoding: 'utf8'})).toMatchSnapshot(); expect(fs.readFileSync(rcFile, {encoding: 'utf8'})).toMatchSnapshot();
}); });
it('Automatically configures GPR scope', async () => { it('Automatically configures GPR scope', () => {
await auth.configAuthentication('npm.pkg.github.com', 'false'); auth.configAuthentication('npm.pkg.github.com', 'false');
expect(fs.existsSync(rcFile)).toBe(true); expect(fs.existsSync(rcFile)).toBe(true);
expect(fs.readFileSync(rcFile, {encoding: 'utf8'})).toMatchSnapshot(); expect(fs.readFileSync(rcFile, {encoding: 'utf8'})).toMatchSnapshot();
}); });
it('Sets up npmrc for always-auth true', async () => { it('Sets up npmrc for always-auth true', () => {
await auth.configAuthentication('https://registry.npmjs.org/', 'true'); auth.configAuthentication('https://registry.npmjs.org/', 'true');
expect(fs.existsSync(rcFile)).toBe(true); expect(fs.existsSync(rcFile)).toBe(true);
expect(fs.readFileSync(rcFile, {encoding: 'utf8'})).toMatchSnapshot(); expect(fs.readFileSync(rcFile, {encoding: 'utf8'})).toMatchSnapshot();
}); });

View File

@ -1,123 +1,255 @@
import io = require('@actions/io'); import * as io from '@actions/io';
import fs = require('fs'); import * as fs from 'fs';
import os = require('os'); import * as os from 'os';
import path = require('path'); import * as path from 'path';
import * as semver from 'semver';
import * as restm from 'typed-rest-client/RestClient';
const toolDir = path.join( const IS_WINDOWS = process.platform === 'win32';
__dirname, const osArch = os.arch();
'runner', const runnerDir = path.join(__dirname, 'runner');
path.join( const randomizer = () =>
Math.random() Math.random()
.toString(36) .toString(36)
.substring(7) .substring(7);
), const toolDir = path.join(runnerDir, randomizer(), 'tools');
'tools' const tempDir = path.join(runnerDir, randomizer(), 'temp');
);
const tempDir = path.join(
__dirname,
'runner',
path.join(
Math.random()
.toString(36)
.substring(7)
),
'temp'
);
process.env['RUNNER_TOOL_CACHE'] = toolDir; process.env['RUNNER_TOOL_CACHE'] = toolDir;
process.env['RUNNER_TEMP'] = tempDir; process.env['RUNNER_TEMP'] = tempDir;
import * as installer from '../src/installer'; import * as installer from '../src/installer';
const IS_WINDOWS = process.platform === 'win32';
describe('installer tests', () => { describe('installer tests', () => {
beforeAll(async () => { beforeAll(async () => {
await io.rmRF(toolDir); await io.rmRF(toolDir);
await io.rmRF(tempDir); await io.rmRF(tempDir);
}, 100000); }, 100000);
it('Acquires version of node if no matching version is installed', async () => {
await installer.getNode('10.16.0');
const nodeDir = path.join(toolDir, 'node', '10.16.0', os.arch());
expect(fs.existsSync(`${nodeDir}.complete`)).toBe(true);
if (IS_WINDOWS) {
expect(fs.existsSync(path.join(nodeDir, 'node.exe'))).toBe(true);
} else {
expect(fs.existsSync(path.join(nodeDir, 'bin', 'node'))).toBe(true);
}
}, 100000);
if (IS_WINDOWS) { if (IS_WINDOWS) {
it('Falls back to backup location if first one doesnt contain correct version', async () => { it(`Falls back to backup location if first one doesn't contain correct version`, async () => {
await installer.getNode('5.10.1'); await installer.getNode('5.10.1');
const nodeDir = path.join(toolDir, 'node', '5.10.1', os.arch()); const nodeDir = path.join(toolDir, 'node', '5.10.1', osArch);
expect(fs.existsSync(`${nodeDir}.complete`)).toBe(true); expect(fs.existsSync(`${nodeDir}.complete`)).toBe(true);
expect(fs.existsSync(path.join(nodeDir, 'node.exe'))).toBe(true); expect(fs.existsSync(path.join(nodeDir, 'node.exe'))).toBe(true);
}, 100000); }, 100000);
it('Falls back to third location if second one doesnt contain correct version', async () => { it(`Falls back to third location if second one doesn't contain correct version`, async () => {
await installer.getNode('0.12.18'); await installer.getNode('0.12.18');
const nodeDir = path.join(toolDir, 'node', '0.12.18', os.arch()); const nodeDir = path.join(toolDir, 'node', '0.12.18', osArch);
expect(fs.existsSync(`${nodeDir}.complete`)).toBe(true); expect(fs.existsSync(`${nodeDir}.complete`)).toBe(true);
expect(fs.existsSync(path.join(nodeDir, 'node.exe'))).toBe(true); expect(fs.existsSync(path.join(nodeDir, 'node.exe'))).toBe(true);
}, 100000); }, 100000);
} }
it('Throws if no location contains correct node version', async () => {
let thrown = false;
try {
await installer.getNode('1000');
} catch {
thrown = true;
}
expect(thrown).toBe(true);
});
it('Acquires version of node with long paths', async () => {
const toolpath = await installer.getNode('8.8.1');
const nodeDir = path.join(toolDir, 'node', '8.8.1', os.arch());
expect(fs.existsSync(`${nodeDir}.complete`)).toBe(true);
if (IS_WINDOWS) {
expect(fs.existsSync(path.join(nodeDir, 'node.exe'))).toBe(true);
} else {
expect(fs.existsSync(path.join(nodeDir, 'bin', 'node'))).toBe(true);
}
}, 100000);
it('Uses version of node installed in cache', async () => { it('Uses version of node installed in cache', async () => {
const nodeDir: string = path.join(toolDir, 'node', '250.0.0', os.arch()); const nodeDir: string = path.join(toolDir, 'node', '250.0.0', osArch);
await io.mkdirP(nodeDir); await io.mkdirP(nodeDir);
fs.writeFileSync(`${nodeDir}.complete`, 'hello'); fs.writeFileSync(`${nodeDir}.complete`, 'hello');
// This will throw if it doesn't find it in the cache (because no such version exists) // This will throw if it doesn't find it in the cache (because no such version exists)
await installer.getNode('250.0.0'); await installer.getNode('250.0.0');
return;
}); });
it('Doesnt use version of node that was only partially installed in cache', async () => { it(`Doesn't use version of node that was only partially installed in cache`, async () => {
const nodeDir: string = path.join(toolDir, 'node', '251.0.0', os.arch()); const nodeDir: string = path.join(toolDir, 'node', '251.0.0', osArch);
await io.mkdirP(nodeDir); await io.mkdirP(nodeDir);
let thrown = false;
try { try {
// This will throw if it doesn't find it in the cache (because no such version exists) // This will throw if it doesn't find it in the cache (because no such version exists)
await installer.getNode('251.0.0'); await installer.getNode('251.0.0');
} catch { } catch (error) {
thrown = true; expect(error).toBeInstanceOf(Error);
} }
expect(thrown).toBe(true);
return;
}); });
it('Resolves semantic versions of node installed in cache', async () => { describe('Throws', () => {
const nodeDir: string = path.join(toolDir, 'node', '252.0.0', os.arch()); it('on unknown node version codename', async () => {
await io.mkdirP(nodeDir); try {
fs.writeFileSync(`${nodeDir}.complete`, 'hello'); await installer.getNode('potterium');
// These will throw if it doesn't find it in the cache (because no such version exists) } catch (error) {
await installer.getNode('252.0.0'); expect(error).toBeInstanceOf(Error);
await installer.getNode('252'); }
await installer.getNode('252.0'); });
it('if no location contains correct node version', async () => {
try {
await installer.getNode('1000');
} catch (error) {
expect(error).toBeInstanceOf(Error);
}
});
});
describe(`Acquires version of node if no matching version is installed of pattern`, () => {
it(`'x'`, async () => {
await installer.getNode('6');
const nodeDir = path.join(toolDir, 'node', '6.17.1', osArch);
expect(fs.existsSync(`${nodeDir}.complete`)).toBe(true);
if (IS_WINDOWS) {
expect(fs.existsSync(path.join(nodeDir, 'node.exe'))).toBe(true);
} else {
expect(fs.existsSync(path.join(nodeDir, 'bin', 'node'))).toBe(true);
}
}, 100000);
it(`'x.x'`, async () => {
await installer.getNode('6.x');
const nodeDir = path.join(toolDir, 'node', '6.17.1', osArch);
expect(fs.existsSync(`${nodeDir}.complete`)).toBe(true);
if (IS_WINDOWS) {
expect(fs.existsSync(path.join(nodeDir, 'node.exe'))).toBe(true);
} else {
expect(fs.existsSync(path.join(nodeDir, 'bin', 'node'))).toBe(true);
}
}, 100000);
it(`'x.x.x'`, async () => {
await installer.getNode('6.17.1');
const nodeDir = path.join(toolDir, 'node', '6.17.1', osArch);
expect(fs.existsSync(`${nodeDir}.complete`)).toBe(true);
if (IS_WINDOWS) {
expect(fs.existsSync(path.join(nodeDir, 'node.exe'))).toBe(true);
} else {
expect(fs.existsSync(path.join(nodeDir, 'bin', 'node'))).toBe(true);
}
}, 100000);
});
describe(`Resolves`, () => {
let getLatestNodeVersionOf: (
predicator: (...args: any[]) => boolean
) => string;
beforeAll(async () => {
const restClient = new restm.RestClient('setup-node');
const request = await restClient.get<installer.INodeVersion[]>(
'https://nodejs.org/dist/index.json'
);
const nodeVersions = request.result || [];
const osPlat = IS_WINDOWS
? 'win'
: process.platform === 'darwin'
? 'osx'
: 'linux';
getLatestNodeVersionOf = (predicator: (...args: any[]) => boolean) => {
const osPlatArchRegExp = new RegExp(
`^${osPlat}-${osArch}-?(?:7z|tar)?`
);
const version = nodeVersions
.filter((version: installer.INodeVersion) =>
version.files.some((file: string) => osPlatArchRegExp.test(file))
)
.filter(predicator)
.sort((a: installer.INodeVersion, b: installer.INodeVersion) =>
semver.gt(b.version, a.version) ? 1 : -1
)[0].version;
return semver.clean(version) || '';
};
});
it('semantic versions of node installed in cache', async () => {
const nodeDir: string = path.join(toolDir, 'node', '252.0.0', osArch);
await io.mkdirP(nodeDir);
fs.writeFileSync(`${nodeDir}.complete`, 'hello');
// These will throw if it doesn't find it in the cache (because no such version exists)
await installer.getNode('252.0.0');
await installer.getNode('252');
await installer.getNode('252.0');
});
it(`'latest' to latest node version`, async () => {
await installer.getNode('latest');
const nodeDir = path.join(
toolDir,
'node',
getLatestNodeVersionOf(
(nv: installer.INodeVersion) => typeof nv.lts !== 'string'
),
osArch
);
expect(fs.existsSync(`${nodeDir}.complete`)).toBe(true);
}, 100000);
it(`'current' to current node version`, async () => {
await installer.getNode('current');
const nodeDir = path.join(
toolDir,
'node',
getLatestNodeVersionOf(
(nv: installer.INodeVersion) => typeof nv.lts !== 'string'
),
osArch
);
expect(fs.existsSync(`${nodeDir}.complete`)).toBe(true);
}, 100000);
it(`'lts' to latest LTS node version`, async () => {
await installer.getNode('lts');
const nodeDir = path.join(
toolDir,
'node',
getLatestNodeVersionOf(
(nv: installer.INodeVersion) => typeof nv.lts === 'string'
),
osArch
);
expect(fs.existsSync(`${nodeDir}.complete`)).toBe(true);
}, 100000);
it(`'argon' to latest node version 4`, async () => {
await installer.getNode('argon');
const nodeDir = path.join(
toolDir,
'node',
getLatestNodeVersionOf((nv: installer.INodeVersion) =>
/v4.\d+.\d+/.test(nv.version)
),
osArch
);
expect(fs.existsSync(`${nodeDir}.complete`)).toBe(true);
}, 100000);
it(`'boron' to latest node version 6`, async () => {
await installer.getNode('boron');
const nodeDir = path.join(
toolDir,
'node',
getLatestNodeVersionOf((nv: installer.INodeVersion) =>
/v6.\d+.\d+/.test(nv.version)
),
osArch
);
expect(fs.existsSync(`${nodeDir}.complete`)).toBe(true);
}, 100000);
it(`'carbon' to latest node version 8`, async () => {
await installer.getNode('carbon');
const nodeDir = path.join(
toolDir,
'node',
getLatestNodeVersionOf((nv: installer.INodeVersion) =>
/v8.\d+.\d+/.test(nv.version)
),
osArch
);
expect(fs.existsSync(`${nodeDir}.complete`)).toBe(true);
}, 100000);
it(`'dubnium' to latest node version 10`, async () => {
await installer.getNode('dubnium');
const nodeDir = path.join(
toolDir,
'node',
getLatestNodeVersionOf((nv: installer.INodeVersion) =>
/v10.\d+.\d+/.test(nv.version)
),
osArch
);
expect(fs.existsSync(`${nodeDir}.complete`)).toBe(true);
}, 100000);
}); });
}); });

View File

@ -7,7 +7,6 @@ inputs:
default: 'false' default: 'false'
node-version: node-version:
description: 'Version Spec of the version to use. Examples: 10.x, 10.15.1, >=10.15.0' description: 'Version Spec of the version to use. Examples: 10.x, 10.15.1, >=10.15.0'
default: '10.x'
registry-url: registry-url:
description: 'Optional registry to set up for auth. Will set the registry in a project level .npmrc and .yarnrc file, and set up auth to read in from env.NODE_AUTH_TOKEN' description: 'Optional registry to set up for auth. Will set the registry in a project level .npmrc and .yarnrc file, and set up auth to read in from env.NODE_AUTH_TOKEN'
scope: scope:

View File

@ -7,11 +7,11 @@ var __importStar = (this && this.__importStar) || function (mod) {
return result; return result;
}; };
Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "__esModule", { value: true });
const core = __importStar(require("@actions/core"));
const github = __importStar(require("@actions/github"));
const fs = __importStar(require("fs")); const fs = __importStar(require("fs"));
const os = __importStar(require("os")); const os = __importStar(require("os"));
const path = __importStar(require("path")); const path = __importStar(require("path"));
const core = __importStar(require("@actions/core"));
const github = __importStar(require("@actions/github"));
function configAuthentication(registryUrl, alwaysAuth) { function configAuthentication(registryUrl, alwaysAuth) {
const npmrc = path.resolve(process.env['RUNNER_TEMP'] || process.cwd(), '.npmrc'); const npmrc = path.resolve(process.env['RUNNER_TEMP'] || process.cwd(), '.npmrc');
if (!registryUrl.endsWith('/')) { if (!registryUrl.endsWith('/')) {

View File

@ -15,170 +15,141 @@ var __importStar = (this && this.__importStar) || function (mod) {
return result; return result;
}; };
Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "__esModule", { value: true });
// Load tempDirectory before it gets wiped by tool-cache
let tempDirectory = process.env['RUNNER_TEMPDIRECTORY'] || '';
const core = __importStar(require("@actions/core")); const core = __importStar(require("@actions/core"));
const io = __importStar(require("@actions/io")); const io = __importStar(require("@actions/io"));
const tc = __importStar(require("@actions/tool-cache")); const tc = __importStar(require("@actions/tool-cache"));
const restm = __importStar(require("typed-rest-client/RestClient"));
const os = __importStar(require("os")); const os = __importStar(require("os"));
const path = __importStar(require("path")); const path = __importStar(require("path"));
const semver = __importStar(require("semver")); const semver = __importStar(require("semver"));
const restm = __importStar(require("typed-rest-client/RestClient"));
let osPlat = os.platform(); let osPlat = os.platform();
let osArch = os.arch(); let osArch = os.arch();
if (!tempDirectory) { const IS_WINDOWS = osPlat === 'win32';
let baseLocation;
if (process.platform === 'win32') {
// On windows use the USERPROFILE env variable
baseLocation = process.env['USERPROFILE'] || 'C:\\';
}
else {
if (process.platform === 'darwin') {
baseLocation = '/Users';
}
else {
baseLocation = '/home';
}
}
tempDirectory = path.join(baseLocation, 'actions', 'temp');
}
function getNode(versionSpec) { function getNode(versionSpec) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
// check cache versionSpec = versionSpec.trim();
let toolPath; // resolve node codenames
toolPath = tc.find('node', versionSpec); let version = yield resolve(versionSpec);
// If not found in cache, download if (!version) {
if (!toolPath) { throw new Error(`Unable to find Node version '${versionSpec}' for platform ${osPlat} and architecture ${osArch}.`);
let version; }
const c = semver.clean(versionSpec) || ''; // check cache
// If explicit version let toolPath = tc.find('node', version, osArch);
if (semver.valid(c) != null) { // Not found in cache -> download
// version to download if (!toolPath) {
version = versionSpec; // download, extract, cache
} toolPath = yield acquireNode(version);
else {
// query nodejs.org for a matching version
version = yield queryLatestMatch(versionSpec);
if (!version) {
throw new Error(`Unable to find Node version '${versionSpec}' for platform ${osPlat} and architecture ${osArch}.`);
}
// check cache
toolPath = tc.find('node', version);
}
if (!toolPath) {
// download, extract, cache
toolPath = yield acquireNode(version);
}
} }
//
// a tool installer initimately knows details about the layout of that tool // a tool installer initimately knows details about the layout of that tool
// for example, node binary is in the bin folder after the extract on Mac/Linux. // for example, node binary is in the bin folder after the extract on Mac/Linux.
// layouts could change by version, by platform etc... but that's the tool installers job // layouts could change by version, by platform etc... but that's the tool installers job
// if (!IS_WINDOWS) {
if (osPlat != 'win32') {
toolPath = path.join(toolPath, 'bin'); toolPath = path.join(toolPath, 'bin');
} }
//
// prepend the tools path. instructs the agent to prepend for future tasks // prepend the tools path. instructs the agent to prepend for future tasks
core.addPath(toolPath); core.addPath(toolPath);
}); });
} }
exports.getNode = getNode; exports.getNode = getNode;
function queryLatestMatch(versionSpec) { function resolve(versionSpec) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
let version = semver.clean(versionSpec) || '';
return semver.valid(version) || tc.find('node', versionSpec, osArch)
? version || versionSpec
: queryNodeVersions(versionSpec);
});
}
function queryNodeVersions(versionSpec) {
return __awaiter(this, void 0, void 0, function* () {
core.debug(`querying Node.js for ${versionSpec}`);
// node offers a json list of versions // node offers a json list of versions
let dataUrl = 'https://nodejs.org/dist/index.json';
let rest = new restm.RestClient('setup-node');
let nodeVersions = (yield rest.get(dataUrl)).result || [];
let dataFileName; let dataFileName;
switch (osPlat) { switch (osPlat) {
case 'linux': case 'linux':
dataFileName = 'linux-' + osArch; dataFileName = `linux-${osArch}`;
break; break;
case 'darwin': case 'darwin':
dataFileName = 'osx-' + osArch + '-tar'; dataFileName = `osx-${osArch}-tar`;
break; break;
case 'win32': case 'win32':
dataFileName = 'win-' + osArch + '-exe'; dataFileName = `win-${osArch}-7z`;
break; break;
default: default:
throw new Error(`Unexpected OS '${osPlat}'`); throw new Error(`Unexpected OS '${osPlat}'`);
} }
let versions = []; // ensure this version supports your os and platform
let dataUrl = 'https://nodejs.org/dist/index.json'; nodeVersions = nodeVersions.filter((nodeVersion) => nodeVersion.files.indexOf(dataFileName) > -1);
let rest = new restm.RestClient('setup-node'); // sort node versions by descending version
let nodeVersions = (yield rest.get(dataUrl)).result || []; nodeVersions = nodeVersions.sort((a, b) => semver.gt(b.version, a.version) ? 1 : -1);
nodeVersions.forEach((nodeVersion) => { const isLatestSpec = /^latest|current$/i.test(versionSpec);
// ensure this version supports your os and platform const isLTSSpec = /^lts$/i.test(versionSpec);
if (nodeVersion.files.indexOf(dataFileName) >= 0) { const isLTSCodenameSpec = !isLatestSpec && !isLTSSpec && /^[a-zA-Z]+$/.test(versionSpec);
versions.push(nodeVersion.version); const findNodeVersion = (predicator) => {
} nodeVersions = nodeVersions.filter(predicator);
}); return nodeVersions.length
? semver.clean(nodeVersions[0].version) || ''
: '';
};
// resolve latest or current node version
if (isLatestSpec) {
return findNodeVersion((nodeVersion) => typeof nodeVersion.lts !== 'string');
}
// resolve lts node version
if (isLTSSpec) {
return findNodeVersion((nodeVersion) => typeof nodeVersion.lts === 'string');
}
// resolve node version codename
if (isLTSCodenameSpec) {
return findNodeVersion((nodeVersion) => typeof nodeVersion.lts === 'string' &&
nodeVersion.lts.toLowerCase() === versionSpec.toLowerCase());
}
// get the latest version that matches the version spec // get the latest version that matches the version spec
let version = evaluateVersions(versions, versionSpec); return evaluateVersions(nodeVersions, versionSpec);
return version;
}); });
} }
// TODO - should we just export this from @actions/tool-cache? Lifted directly from there // TODO - should we just export this from @actions/tool-cache? Lifted directly from there
function evaluateVersions(versions, versionSpec) { function evaluateVersions(nodeVersions, versionSpec) {
let version = ''; core.debug(`evaluating ${nodeVersions.length} versions`);
core.debug(`evaluating ${versions.length} versions`); const versions = nodeVersions.map((nodeVersion) => nodeVersion.version);
versions = versions.sort((a, b) => { const version = versions.find((potential) => semver.satisfies(potential, versionSpec)) || '';
if (semver.gt(a, b)) {
return 1;
}
return -1;
});
for (let i = versions.length - 1; i >= 0; i--) {
const potential = versions[i];
const satisfied = semver.satisfies(potential, versionSpec);
if (satisfied) {
version = potential;
break;
}
}
if (version) { if (version) {
core.debug(`matched: ${version}`); core.debug(`matched: ${version}`);
} }
else { else {
core.debug('match not found'); core.debug('match not found');
} }
return version; return semver.clean(version) || '';
} }
function acquireNode(version) { function acquireNode(version) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
//
// Download - a tool installer intimately knows how to get the tool (and construct urls) // Download - a tool installer intimately knows how to get the tool (and construct urls)
// const fileName = `node-v${version}-${IS_WINDOWS ? 'win' : osPlat}-${osArch}`;
version = semver.clean(version) || ''; const urlFileName = `${fileName}.${IS_WINDOWS ? '7z' : 'tar.gz'}`;
let fileName = osPlat == 'win32' const downloadUrl = `https://nodejs.org/dist/v${version}/${urlFileName}`;
? 'node-v' + version + '-win-' + os.arch()
: 'node-v' + version + '-' + osPlat + '-' + os.arch();
let urlFileName = osPlat == 'win32' ? fileName + '.7z' : fileName + '.tar.gz';
let downloadUrl = 'https://nodejs.org/dist/v' + version + '/' + urlFileName;
let downloadPath; let downloadPath;
try { try {
downloadPath = yield tc.downloadTool(downloadUrl); downloadPath = yield tc.downloadTool(downloadUrl);
} }
catch (err) { catch (err) {
if (err instanceof tc.HTTPError && err.httpStatusCode == 404) { if (err instanceof tc.HTTPError && err.httpStatusCode === 404) {
return yield acquireNodeFromFallbackLocation(version); if (IS_WINDOWS) {
return acquireNodeFromFallbackLocation(version);
}
} }
throw err; throw err;
} }
//
// Extract // Extract
// const _7zPath = path.join(__dirname, '..', 'externals', '7zr.exe');
let extPath; const extPath = IS_WINDOWS
if (osPlat == 'win32') { ? yield tc.extract7z(downloadPath, undefined, _7zPath)
let _7zPath = path.join(__dirname, '..', 'externals', '7zr.exe'); : yield tc.extractTar(downloadPath);
extPath = yield tc.extract7z(downloadPath, undefined, _7zPath); // Install into the local tool cache
} // node extracts with a root folder that matches the fileName downloaded
else { const toolRoot = path.join(extPath, fileName);
extPath = yield tc.extractTar(downloadPath); return tc.cacheDir(toolRoot, 'node', version, osArch);
}
//
// Install into the local tool cache - node extracts with a root folder that matches the fileName downloaded
//
let toolRoot = path.join(extPath, fileName);
return yield tc.cacheDir(toolRoot, 'node', version);
}); });
} }
// For non LTS versions of Node, the files we need (for Windows) are sometimes located // For non LTS versions of Node, the files we need (for Windows) are sometimes located
@ -196,32 +167,39 @@ function acquireNode(version) {
function acquireNodeFromFallbackLocation(version) { function acquireNodeFromFallbackLocation(version) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
// Create temporary folder to download in to // Create temporary folder to download in to
let tempDownloadFolder = 'temp_' + Math.floor(Math.random() * 2000000000); const tempDownloadFolder = `temp_${Math.floor(Math.random() * 2000000000)}`;
let tempDir = path.join(tempDirectory, tempDownloadFolder); const tempDir = path.join(getTempDirectory(), tempDownloadFolder);
yield io.mkdirP(tempDir); const baseUrl = `https://nodejs.org/dist/v${version}/`;
let exeUrl; const tryDownload = (url) => __awaiter(this, void 0, void 0, function* () {
let libUrl; const exeFileName = 'node.exe';
const libFileName = 'node.lib';
const exePath = yield tc.downloadTool(`${url}${exeFileName}`);
yield io.cp(exePath, path.join(tempDir, exeFileName));
const libPath = yield tc.downloadTool(`${url}${libFileName}`);
yield io.cp(libPath, path.join(tempDir, libFileName));
});
try { try {
exeUrl = `https://nodejs.org/dist/v${version}/win-${os.arch()}/node.exe`; yield io.mkdirP(tempDir);
libUrl = `https://nodejs.org/dist/v${version}/win-${os.arch()}/node.lib`; yield tryDownload(`${baseUrl}win-${osArch}/`);
const exePath = yield tc.downloadTool(exeUrl);
yield io.cp(exePath, path.join(tempDir, 'node.exe'));
const libPath = yield tc.downloadTool(libUrl);
yield io.cp(libPath, path.join(tempDir, 'node.lib'));
} }
catch (err) { catch (err) {
if (err instanceof tc.HTTPError && err.httpStatusCode == 404) { if (err instanceof tc.HTTPError && err.httpStatusCode === 404) {
exeUrl = `https://nodejs.org/dist/v${version}/node.exe`; yield tryDownload(baseUrl);
libUrl = `https://nodejs.org/dist/v${version}/node.lib`;
const exePath = yield tc.downloadTool(exeUrl);
yield io.cp(exePath, path.join(tempDir, 'node.exe'));
const libPath = yield tc.downloadTool(libUrl);
yield io.cp(libPath, path.join(tempDir, 'node.lib'));
} }
else { else {
throw err; throw err;
} }
} }
return yield tc.cacheDir(tempDir, 'node', version); return tc.cacheDir(tempDir, 'node', version, osArch);
}); });
} }
function getTempDirectory() {
const baseLocation =
// On windows use the USERPROFILE env variable
process.platform === 'win32'
? process.env['USERPROFILE'] || 'C:\\'
: process.platform === 'darwin'
? '/Users'
: '/home';
return (process.env['RUNNER_TEMP'] || path.join(baseLocation, 'actions', 'temp'));
}

View File

@ -16,20 +16,16 @@ var __importStar = (this && this.__importStar) || function (mod) {
}; };
Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "__esModule", { value: true });
const core = __importStar(require("@actions/core")); const core = __importStar(require("@actions/core"));
const installer = __importStar(require("./installer"));
const auth = __importStar(require("./authutil"));
const path = __importStar(require("path")); const path = __importStar(require("path"));
const auth = __importStar(require("./authutil"));
const installer = __importStar(require("./installer"));
function run() { function run() {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
try { try {
// // Version is optional. If supplied, install / use from the tool cache
// Version is optional. If supplied, install / use from the tool cache
// If not supplied then task is still used to setup proxy, auth, etc... // If not supplied then task is still used to setup proxy, auth, etc...
// const version = core.getInput('version') || core.getInput('node-version');
let version = core.getInput('version'); // allow user to not specify a node version
if (!version) {
version = core.getInput('node-version');
}
if (version) { if (version) {
// TODO: installer doesn't support proxy // TODO: installer doesn't support proxy
yield installer.getNode(version); yield installer.getNode(version);

View File

@ -1,8 +1,8 @@
import * as core from '@actions/core';
import * as github from '@actions/github';
import * as fs from 'fs'; import * as fs from 'fs';
import * as os from 'os'; import * as os from 'os';
import * as path from 'path'; import * as path from 'path';
import * as core from '@actions/core';
import * as github from '@actions/github';
export function configAuthentication(registryUrl: string, alwaysAuth: string) { export function configAuthentication(registryUrl: string, alwaysAuth: string) {
const npmrc: string = path.resolve( const npmrc: string = path.resolve(

View File

@ -1,138 +1,149 @@
// Load tempDirectory before it gets wiped by tool-cache
let tempDirectory = process.env['RUNNER_TEMPDIRECTORY'] || '';
import * as core from '@actions/core'; import * as core from '@actions/core';
import * as io from '@actions/io'; import * as io from '@actions/io';
import * as tc from '@actions/tool-cache'; import * as tc from '@actions/tool-cache';
import * as restm from 'typed-rest-client/RestClient';
import * as os from 'os'; import * as os from 'os';
import * as path from 'path'; import * as path from 'path';
import * as semver from 'semver'; import * as semver from 'semver';
import * as restm from 'typed-rest-client/RestClient';
let osPlat: string = os.platform(); let osPlat: string = os.platform();
let osArch: string = os.arch(); let osArch: string = os.arch();
const IS_WINDOWS: boolean = osPlat === 'win32';
if (!tempDirectory) { /*
let baseLocation; * Node versions interface
if (process.platform === 'win32') { * see https://nodejs.org/dist/index.json
// On windows use the USERPROFILE env variable */
baseLocation = process.env['USERPROFILE'] || 'C:\\'; export interface INodeVersion {
} else {
if (process.platform === 'darwin') {
baseLocation = '/Users';
} else {
baseLocation = '/home';
}
}
tempDirectory = path.join(baseLocation, 'actions', 'temp');
}
//
// Node versions interface
// see https://nodejs.org/dist/index.json
//
interface INodeVersion {
version: string; version: string;
files: string[]; files: string[];
lts: string | false;
} }
export async function getNode(versionSpec: string) { export async function getNode(versionSpec: string): Promise<void> {
// check cache versionSpec = versionSpec.trim();
let toolPath: string;
toolPath = tc.find('node', versionSpec);
// If not found in cache, download // resolve node codenames
if (!toolPath) { let version = await resolve(versionSpec);
let version: string;
const c = semver.clean(versionSpec) || '';
// If explicit version
if (semver.valid(c) != null) {
// version to download
version = versionSpec;
} else {
// query nodejs.org for a matching version
version = await queryLatestMatch(versionSpec);
if (!version) {
throw new Error(
`Unable to find Node version '${versionSpec}' for platform ${osPlat} and architecture ${osArch}.`
);
}
// check cache if (!version) {
toolPath = tc.find('node', version); throw new Error(
} `Unable to find Node version '${versionSpec}' for platform ${osPlat} and architecture ${osArch}.`
);
if (!toolPath) { }
// download, extract, cache
toolPath = await acquireNode(version); // check cache
} let toolPath = tc.find('node', version, osArch);
// Not found in cache -> download
if (!toolPath) {
// download, extract, cache
toolPath = await acquireNode(version);
} }
//
// a tool installer initimately knows details about the layout of that tool // a tool installer initimately knows details about the layout of that tool
// for example, node binary is in the bin folder after the extract on Mac/Linux. // for example, node binary is in the bin folder after the extract on Mac/Linux.
// layouts could change by version, by platform etc... but that's the tool installers job // layouts could change by version, by platform etc... but that's the tool installers job
// if (!IS_WINDOWS) {
if (osPlat != 'win32') {
toolPath = path.join(toolPath, 'bin'); toolPath = path.join(toolPath, 'bin');
} }
//
// prepend the tools path. instructs the agent to prepend for future tasks // prepend the tools path. instructs the agent to prepend for future tasks
core.addPath(toolPath); core.addPath(toolPath);
} }
async function queryLatestMatch(versionSpec: string): Promise<string> { async function resolve(versionSpec: string): Promise<string> {
let version = semver.clean(versionSpec) || '';
return semver.valid(version) || tc.find('node', versionSpec, osArch)
? version || versionSpec
: queryNodeVersions(versionSpec);
}
async function queryNodeVersions(versionSpec: string): Promise<string> {
core.debug(`querying Node.js for ${versionSpec}`);
// node offers a json list of versions // node offers a json list of versions
let dataUrl = 'https://nodejs.org/dist/index.json';
let rest = new restm.RestClient('setup-node');
let nodeVersions: INodeVersion[] =
(await rest.get<INodeVersion[]>(dataUrl)).result || [];
let dataFileName: string; let dataFileName: string;
switch (osPlat) { switch (osPlat) {
case 'linux': case 'linux':
dataFileName = 'linux-' + osArch; dataFileName = `linux-${osArch}`;
break; break;
case 'darwin': case 'darwin':
dataFileName = 'osx-' + osArch + '-tar'; dataFileName = `osx-${osArch}-tar`;
break; break;
case 'win32': case 'win32':
dataFileName = 'win-' + osArch + '-exe'; dataFileName = `win-${osArch}-7z`;
break; break;
default: default:
throw new Error(`Unexpected OS '${osPlat}'`); throw new Error(`Unexpected OS '${osPlat}'`);
} }
let versions: string[] = []; // ensure this version supports your os and platform
let dataUrl = 'https://nodejs.org/dist/index.json'; nodeVersions = nodeVersions.filter(
let rest: restm.RestClient = new restm.RestClient('setup-node'); (nodeVersion: INodeVersion) => nodeVersion.files.indexOf(dataFileName) > -1
let nodeVersions: INodeVersion[] = );
(await rest.get<INodeVersion[]>(dataUrl)).result || [];
nodeVersions.forEach((nodeVersion: INodeVersion) => { // sort node versions by descending version
// ensure this version supports your os and platform nodeVersions = nodeVersions.sort((a: INodeVersion, b: INodeVersion) =>
if (nodeVersion.files.indexOf(dataFileName) >= 0) { semver.gt(b.version, a.version) ? 1 : -1
versions.push(nodeVersion.version); );
}
}); const isLatestSpec = /^latest|current$/i.test(versionSpec);
const isLTSSpec = /^lts$/i.test(versionSpec);
const isLTSCodenameSpec =
!isLatestSpec && !isLTSSpec && /^[a-zA-Z]+$/.test(versionSpec);
const findNodeVersion = (
predicator: (nodeVersion: INodeVersion) => boolean
): string => {
nodeVersions = nodeVersions.filter(predicator);
return nodeVersions.length
? semver.clean(nodeVersions[0].version) || ''
: '';
};
// resolve latest or current node version
if (isLatestSpec) {
return findNodeVersion(
(nodeVersion: INodeVersion) => typeof nodeVersion.lts !== 'string'
);
}
// resolve lts node version
if (isLTSSpec) {
return findNodeVersion(
(nodeVersion: INodeVersion) => typeof nodeVersion.lts === 'string'
);
}
// resolve node version codename
if (isLTSCodenameSpec) {
return findNodeVersion(
(nodeVersion: INodeVersion) =>
typeof nodeVersion.lts === 'string' &&
nodeVersion.lts.toLowerCase() === versionSpec.toLowerCase()
);
}
// get the latest version that matches the version spec // get the latest version that matches the version spec
let version: string = evaluateVersions(versions, versionSpec); return evaluateVersions(nodeVersions, versionSpec);
return version;
} }
// TODO - should we just export this from @actions/tool-cache? Lifted directly from there // TODO - should we just export this from @actions/tool-cache? Lifted directly from there
function evaluateVersions(versions: string[], versionSpec: string): string { function evaluateVersions(
let version = ''; nodeVersions: INodeVersion[],
core.debug(`evaluating ${versions.length} versions`); versionSpec: string
versions = versions.sort((a, b) => { ): string {
if (semver.gt(a, b)) { core.debug(`evaluating ${nodeVersions.length} versions`);
return 1; const versions = nodeVersions.map(
} (nodeVersion: INodeVersion) => nodeVersion.version
return -1; );
}); const version =
for (let i = versions.length - 1; i >= 0; i--) { versions.find((potential: string) =>
const potential: string = versions[i]; semver.satisfies(potential, versionSpec)
const satisfied: boolean = semver.satisfies(potential, versionSpec); ) || '';
if (satisfied) {
version = potential;
break;
}
}
if (version) { if (version) {
core.debug(`matched: ${version}`); core.debug(`matched: ${version}`);
@ -140,51 +151,39 @@ function evaluateVersions(versions: string[], versionSpec: string): string {
core.debug('match not found'); core.debug('match not found');
} }
return version; return semver.clean(version) || '';
} }
async function acquireNode(version: string): Promise<string> { async function acquireNode(version: string): Promise<string> {
//
// Download - a tool installer intimately knows how to get the tool (and construct urls) // Download - a tool installer intimately knows how to get the tool (and construct urls)
// const fileName: string = `node-v${version}-${
version = semver.clean(version) || ''; IS_WINDOWS ? 'win' : osPlat
let fileName: string = }-${osArch}`;
osPlat == 'win32' const urlFileName: string = `${fileName}.${IS_WINDOWS ? '7z' : 'tar.gz'}`;
? 'node-v' + version + '-win-' + os.arch() const downloadUrl = `https://nodejs.org/dist/v${version}/${urlFileName}`;
: 'node-v' + version + '-' + osPlat + '-' + os.arch();
let urlFileName: string =
osPlat == 'win32' ? fileName + '.7z' : fileName + '.tar.gz';
let downloadUrl = 'https://nodejs.org/dist/v' + version + '/' + urlFileName;
let downloadPath: string; let downloadPath: string;
try { try {
downloadPath = await tc.downloadTool(downloadUrl); downloadPath = await tc.downloadTool(downloadUrl);
} catch (err) { } catch (err) {
if (err instanceof tc.HTTPError && err.httpStatusCode == 404) { if (err instanceof tc.HTTPError && err.httpStatusCode === 404) {
return await acquireNodeFromFallbackLocation(version); if (IS_WINDOWS) {
return acquireNodeFromFallbackLocation(version);
}
} }
throw err; throw err;
} }
//
// Extract // Extract
// const _7zPath = path.join(__dirname, '..', 'externals', '7zr.exe');
let extPath: string; const extPath: string = IS_WINDOWS
if (osPlat == 'win32') { ? await tc.extract7z(downloadPath, undefined, _7zPath)
let _7zPath = path.join(__dirname, '..', 'externals', '7zr.exe'); : await tc.extractTar(downloadPath);
extPath = await tc.extract7z(downloadPath, undefined, _7zPath);
} else {
extPath = await tc.extractTar(downloadPath);
}
// // Install into the local tool cache
// Install into the local tool cache - node extracts with a root folder that matches the fileName downloaded // node extracts with a root folder that matches the fileName downloaded
// const toolRoot = path.join(extPath, fileName);
let toolRoot = path.join(extPath, fileName); return tc.cacheDir(toolRoot, 'node', version, osArch);
return await tc.cacheDir(toolRoot, 'node', version);
} }
// For non LTS versions of Node, the files we need (for Windows) are sometimes located // For non LTS versions of Node, the files we need (for Windows) are sometimes located
@ -203,32 +202,42 @@ async function acquireNodeFromFallbackLocation(
version: string version: string
): Promise<string> { ): Promise<string> {
// Create temporary folder to download in to // Create temporary folder to download in to
let tempDownloadFolder: string = const tempDownloadFolder: string = `temp_${Math.floor(
'temp_' + Math.floor(Math.random() * 2000000000); Math.random() * 2000000000
let tempDir: string = path.join(tempDirectory, tempDownloadFolder); )}`;
await io.mkdirP(tempDir); const tempDir: string = path.join(getTempDirectory(), tempDownloadFolder);
let exeUrl: string; const baseUrl = `https://nodejs.org/dist/v${version}/`;
let libUrl: string; const tryDownload = async (url: string) => {
const exeFileName = 'node.exe';
const libFileName = 'node.lib';
const exePath = await tc.downloadTool(`${url}${exeFileName}`);
await io.cp(exePath, path.join(tempDir, exeFileName));
const libPath = await tc.downloadTool(`${url}${libFileName}`);
await io.cp(libPath, path.join(tempDir, libFileName));
};
try { try {
exeUrl = `https://nodejs.org/dist/v${version}/win-${os.arch()}/node.exe`; await io.mkdirP(tempDir);
libUrl = `https://nodejs.org/dist/v${version}/win-${os.arch()}/node.lib`; await tryDownload(`${baseUrl}win-${osArch}/`);
const exePath = await tc.downloadTool(exeUrl);
await io.cp(exePath, path.join(tempDir, 'node.exe'));
const libPath = await tc.downloadTool(libUrl);
await io.cp(libPath, path.join(tempDir, 'node.lib'));
} catch (err) { } catch (err) {
if (err instanceof tc.HTTPError && err.httpStatusCode == 404) { if (err instanceof tc.HTTPError && err.httpStatusCode === 404) {
exeUrl = `https://nodejs.org/dist/v${version}/node.exe`; await tryDownload(baseUrl);
libUrl = `https://nodejs.org/dist/v${version}/node.lib`;
const exePath = await tc.downloadTool(exeUrl);
await io.cp(exePath, path.join(tempDir, 'node.exe'));
const libPath = await tc.downloadTool(libUrl);
await io.cp(libPath, path.join(tempDir, 'node.lib'));
} else { } else {
throw err; throw err;
} }
} }
return await tc.cacheDir(tempDir, 'node', version); return tc.cacheDir(tempDir, 'node', version, osArch);
}
function getTempDirectory(): string {
const baseLocation: string =
// On windows use the USERPROFILE env variable
process.platform === 'win32'
? process.env['USERPROFILE'] || 'C:\\'
: process.platform === 'darwin'
? '/Users'
: '/home';
return (
process.env['RUNNER_TEMP'] || path.join(baseLocation, 'actions', 'temp')
);
} }

View File

@ -1,18 +1,15 @@
import * as core from '@actions/core'; import * as core from '@actions/core';
import * as installer from './installer';
import * as auth from './authutil';
import * as path from 'path'; import * as path from 'path';
import * as auth from './authutil';
import * as installer from './installer';
async function run() { async function run() {
try { try {
// // Version is optional. If supplied, install / use from the tool cache
// Version is optional. If supplied, install / use from the tool cache
// If not supplied then task is still used to setup proxy, auth, etc... // If not supplied then task is still used to setup proxy, auth, etc...
// const version = core.getInput('version') || core.getInput('node-version');
let version = core.getInput('version');
if (!version) { // allow user to not specify a node version
version = core.getInput('node-version');
}
if (version) { if (version) {
// TODO: installer doesn't support proxy // TODO: installer doesn't support proxy
await installer.getNode(version); await installer.getNode(version);