mirror of
https://github.com/actions/setup-node.git
synced 2025-04-22 09:21:00 +00:00
optimize code
This commit is contained in:
parent
15798eaae7
commit
785620d55b
6 changed files with 16 additions and 92 deletions
67
dist/setup/index.js
vendored
67
dist/setup/index.js
vendored
|
@ -73244,6 +73244,14 @@ class BaseDistribution {
|
||||||
findVersionInHoostedToolCacheDirectory() {
|
findVersionInHoostedToolCacheDirectory() {
|
||||||
return tc.find('node', this.nodeInfo.versionSpec, this.nodeInfo.arch);
|
return tc.find('node', this.nodeInfo.versionSpec, this.nodeInfo.arch);
|
||||||
}
|
}
|
||||||
|
getNodejsVersions() {
|
||||||
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
|
const initialUrl = this.getDistributionUrl();
|
||||||
|
const dataUrl = `${initialUrl}/index.json`;
|
||||||
|
let response = yield this.httpClient.getJson(dataUrl);
|
||||||
|
return response.result || [];
|
||||||
|
});
|
||||||
|
}
|
||||||
getNodejsDistInfo(version, osPlat) {
|
getNodejsDistInfo(version, osPlat) {
|
||||||
let osArch = this.translateArchToDistUrl(this.nodeInfo.arch);
|
let osArch = this.translateArchToDistUrl(this.nodeInfo.arch);
|
||||||
version = semver_1.default.clean(version) || '';
|
version = semver_1.default.clean(version) || '';
|
||||||
|
@ -73454,15 +73462,6 @@ exports.getNodejsDistribution = getNodejsDistribution;
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
||||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
||||||
return new (P || (P = Promise))(function (resolve, reject) {
|
|
||||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
||||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
||||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
||||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
||||||
});
|
|
||||||
};
|
|
||||||
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 = {};
|
||||||
|
@ -73524,14 +73523,6 @@ class NightlyNodejs extends base_distribution_1.default {
|
||||||
getDistributionUrl() {
|
getDistributionUrl() {
|
||||||
return 'https://nodejs.org/download/nightly';
|
return 'https://nodejs.org/download/nightly';
|
||||||
}
|
}
|
||||||
getNodejsVersions() {
|
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
const initialUrl = this.getDistributionUrl();
|
|
||||||
const dataUrl = `${initialUrl}/index.json`;
|
|
||||||
let response = yield this.httpClient.getJson(dataUrl);
|
|
||||||
return response.result || [];
|
|
||||||
});
|
|
||||||
}
|
|
||||||
createRangePreRelease(versionSpec, distribution = '') {
|
createRangePreRelease(versionSpec, distribution = '') {
|
||||||
let range;
|
let range;
|
||||||
const [raw, prerelease] = this.splitVersionSpec(versionSpec);
|
const [raw, prerelease] = this.splitVersionSpec(versionSpec);
|
||||||
|
@ -73667,14 +73658,6 @@ class OfficialBuilds extends base_distribution_1.default {
|
||||||
getDistributionUrl() {
|
getDistributionUrl() {
|
||||||
return `https://nodejs.org/dist`;
|
return `https://nodejs.org/dist`;
|
||||||
}
|
}
|
||||||
getNodejsVersions() {
|
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
const initialUrl = this.getDistributionUrl();
|
|
||||||
const dataUrl = `${initialUrl}/index.json`;
|
|
||||||
let response = yield this.httpClient.getJson(dataUrl);
|
|
||||||
return response.result || [];
|
|
||||||
});
|
|
||||||
}
|
|
||||||
getManifest() {
|
getManifest() {
|
||||||
core.debug('Getting manifest from actions/node-versions@main');
|
core.debug('Getting manifest from actions/node-versions@main');
|
||||||
return tc.getManifestFromRepo('actions', 'node-versions', this.nodeInfo.auth, 'main');
|
return tc.getManifestFromRepo('actions', 'node-versions', this.nodeInfo.auth, 'main');
|
||||||
|
@ -73739,15 +73722,6 @@ exports["default"] = OfficialBuilds;
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
||||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
||||||
return new (P || (P = Promise))(function (resolve, reject) {
|
|
||||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
||||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
||||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
||||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
||||||
});
|
|
||||||
};
|
|
||||||
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 = {};
|
||||||
|
@ -73766,14 +73740,6 @@ class RcBuild extends base_distribution_1.default {
|
||||||
constructor(nodeInfo) {
|
constructor(nodeInfo) {
|
||||||
super(nodeInfo);
|
super(nodeInfo);
|
||||||
}
|
}
|
||||||
getNodejsVersions() {
|
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
const initialUrl = this.getDistributionUrl();
|
|
||||||
const dataUrl = `${initialUrl}/index.json`;
|
|
||||||
let response = yield this.httpClient.getJson(dataUrl);
|
|
||||||
return response.result || [];
|
|
||||||
});
|
|
||||||
}
|
|
||||||
evaluateVersions(versions) {
|
evaluateVersions(versions) {
|
||||||
let version = '';
|
let version = '';
|
||||||
core.debug(`evaluating ${versions.length} versions`);
|
core.debug(`evaluating ${versions.length} versions`);
|
||||||
|
@ -73807,15 +73773,6 @@ exports["default"] = RcBuild;
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
||||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
||||||
return new (P || (P = Promise))(function (resolve, reject) {
|
|
||||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
||||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
||||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
||||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
||||||
});
|
|
||||||
};
|
|
||||||
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 = {};
|
||||||
|
@ -73877,14 +73834,6 @@ class CanaryBuild extends base_distribution_1.default {
|
||||||
}
|
}
|
||||||
return version;
|
return version;
|
||||||
}
|
}
|
||||||
getNodejsVersions() {
|
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
const initialUrl = this.getDistributionUrl();
|
|
||||||
const dataUrl = `${initialUrl}/index.json`;
|
|
||||||
let response = yield this.httpClient.getJson(dataUrl);
|
|
||||||
return response.result || [];
|
|
||||||
});
|
|
||||||
}
|
|
||||||
createRangePreRelease(versionSpec, distribution = '') {
|
createRangePreRelease(versionSpec, distribution = '') {
|
||||||
let range;
|
let range;
|
||||||
const [raw, prerelease] = this.splitVersionSpec(versionSpec);
|
const [raw, prerelease] = this.splitVersionSpec(versionSpec);
|
||||||
|
|
|
@ -24,7 +24,6 @@ export default abstract class BaseDistribution {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected abstract getDistributionUrl(): string;
|
protected abstract getDistributionUrl(): string;
|
||||||
protected abstract getNodejsVersions(): Promise<INodeVersion[]>;
|
|
||||||
protected abstract evaluateVersions(nodeVersions: string[]): string;
|
protected abstract evaluateVersions(nodeVersions: string[]): string;
|
||||||
|
|
||||||
public async getNodeJsInfo() {
|
public async getNodeJsInfo() {
|
||||||
|
@ -48,6 +47,14 @@ export default abstract class BaseDistribution {
|
||||||
return tc.find('node', this.nodeInfo.versionSpec, this.nodeInfo.arch);
|
return tc.find('node', this.nodeInfo.versionSpec, this.nodeInfo.arch);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected async getNodejsVersions(): Promise<INodeVersion[]> {
|
||||||
|
const initialUrl = this.getDistributionUrl();
|
||||||
|
const dataUrl = `${initialUrl}/index.json`;
|
||||||
|
|
||||||
|
let response = await this.httpClient.getJson<INodeVersion[]>(dataUrl);
|
||||||
|
return response.result || [];
|
||||||
|
}
|
||||||
|
|
||||||
protected getNodejsDistInfo(version: string, osPlat: string) {
|
protected getNodejsDistInfo(version: string, osPlat: string) {
|
||||||
let osArch: string = this.translateArchToDistUrl(this.nodeInfo.arch);
|
let osArch: string = this.translateArchToDistUrl(this.nodeInfo.arch);
|
||||||
version = semver.clean(version) || '';
|
version = semver.clean(version) || '';
|
||||||
|
|
|
@ -69,14 +69,6 @@ export default class NightlyNodejs extends BaseDistribution {
|
||||||
return 'https://nodejs.org/download/nightly';
|
return 'https://nodejs.org/download/nightly';
|
||||||
}
|
}
|
||||||
|
|
||||||
async getNodejsVersions(): Promise<INodeVersion[]> {
|
|
||||||
const initialUrl = this.getDistributionUrl();
|
|
||||||
const dataUrl = `${initialUrl}/index.json`;
|
|
||||||
|
|
||||||
let response = await this.httpClient.getJson<INodeVersion[]>(dataUrl);
|
|
||||||
return response.result || [];
|
|
||||||
}
|
|
||||||
|
|
||||||
protected createRangePreRelease(
|
protected createRangePreRelease(
|
||||||
versionSpec: string,
|
versionSpec: string,
|
||||||
distribution: string = ''
|
distribution: string = ''
|
||||||
|
|
|
@ -131,14 +131,6 @@ export default class OfficialBuilds extends BaseDistribution {
|
||||||
return `https://nodejs.org/dist`;
|
return `https://nodejs.org/dist`;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected async getNodejsVersions(): Promise<INodeVersion[]> {
|
|
||||||
const initialUrl = this.getDistributionUrl();
|
|
||||||
const dataUrl = `${initialUrl}/index.json`;
|
|
||||||
|
|
||||||
let response = await this.httpClient.getJson<INodeVersion[]>(dataUrl);
|
|
||||||
return response.result || [];
|
|
||||||
}
|
|
||||||
|
|
||||||
private getManifest(): Promise<tc.IToolRelease[]> {
|
private getManifest(): Promise<tc.IToolRelease[]> {
|
||||||
core.debug('Getting manifest from actions/node-versions@main');
|
core.debug('Getting manifest from actions/node-versions@main');
|
||||||
return tc.getManifestFromRepo(
|
return tc.getManifestFromRepo(
|
||||||
|
|
|
@ -10,14 +10,6 @@ export default class RcBuild extends BaseDistribution {
|
||||||
super(nodeInfo);
|
super(nodeInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected async getNodejsVersions(): Promise<INodeVersion[]> {
|
|
||||||
const initialUrl = this.getDistributionUrl();
|
|
||||||
const dataUrl = `${initialUrl}/index.json`;
|
|
||||||
|
|
||||||
let response = await this.httpClient.getJson<INodeVersion[]>(dataUrl);
|
|
||||||
return response.result || [];
|
|
||||||
}
|
|
||||||
|
|
||||||
protected evaluateVersions(versions: string[]): string {
|
protected evaluateVersions(versions: string[]): string {
|
||||||
let version = '';
|
let version = '';
|
||||||
|
|
||||||
|
|
|
@ -70,14 +70,6 @@ export default class CanaryBuild extends BaseDistribution {
|
||||||
return version;
|
return version;
|
||||||
}
|
}
|
||||||
|
|
||||||
async getNodejsVersions(): Promise<INodeVersion[]> {
|
|
||||||
const initialUrl = this.getDistributionUrl();
|
|
||||||
const dataUrl = `${initialUrl}/index.json`;
|
|
||||||
|
|
||||||
let response = await this.httpClient.getJson<INodeVersion[]>(dataUrl);
|
|
||||||
return response.result || [];
|
|
||||||
}
|
|
||||||
|
|
||||||
protected createRangePreRelease(
|
protected createRangePreRelease(
|
||||||
versionSpec: string,
|
versionSpec: string,
|
||||||
distribution: string = ''
|
distribution: string = ''
|
||||||
|
|
Loading…
Add table
Reference in a new issue