mirror of
https://github.com/actions/setup-node.git
synced 2025-04-22 03:28:42 +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() {
|
||||
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) {
|
||||
let osArch = this.translateArchToDistUrl(this.nodeInfo.arch);
|
||||
version = semver_1.default.clean(version) || '';
|
||||
|
@ -73454,15 +73462,6 @@ exports.getNodejsDistribution = getNodejsDistribution;
|
|||
|
||||
"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) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
|
@ -73524,14 +73523,6 @@ class NightlyNodejs extends base_distribution_1.default {
|
|||
getDistributionUrl() {
|
||||
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 = '') {
|
||||
let range;
|
||||
const [raw, prerelease] = this.splitVersionSpec(versionSpec);
|
||||
|
@ -73667,14 +73658,6 @@ class OfficialBuilds extends base_distribution_1.default {
|
|||
getDistributionUrl() {
|
||||
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() {
|
||||
core.debug('Getting manifest from actions/node-versions@main');
|
||||
return tc.getManifestFromRepo('actions', 'node-versions', this.nodeInfo.auth, 'main');
|
||||
|
@ -73739,15 +73722,6 @@ exports["default"] = OfficialBuilds;
|
|||
|
||||
"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) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
|
@ -73766,14 +73740,6 @@ class RcBuild extends base_distribution_1.default {
|
|||
constructor(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) {
|
||||
let version = '';
|
||||
core.debug(`evaluating ${versions.length} versions`);
|
||||
|
@ -73807,15 +73773,6 @@ exports["default"] = RcBuild;
|
|||
|
||||
"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) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
|
@ -73877,14 +73834,6 @@ class CanaryBuild extends base_distribution_1.default {
|
|||
}
|
||||
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 = '') {
|
||||
let range;
|
||||
const [raw, prerelease] = this.splitVersionSpec(versionSpec);
|
||||
|
|
|
@ -24,7 +24,6 @@ export default abstract class BaseDistribution {
|
|||
}
|
||||
|
||||
protected abstract getDistributionUrl(): string;
|
||||
protected abstract getNodejsVersions(): Promise<INodeVersion[]>;
|
||||
protected abstract evaluateVersions(nodeVersions: string[]): string;
|
||||
|
||||
public async getNodeJsInfo() {
|
||||
|
@ -48,6 +47,14 @@ export default abstract class BaseDistribution {
|
|||
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) {
|
||||
let osArch: string = this.translateArchToDistUrl(this.nodeInfo.arch);
|
||||
version = semver.clean(version) || '';
|
||||
|
|
|
@ -69,14 +69,6 @@ export default class NightlyNodejs extends BaseDistribution {
|
|||
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(
|
||||
versionSpec: string,
|
||||
distribution: string = ''
|
||||
|
|
|
@ -131,14 +131,6 @@ export default class OfficialBuilds extends BaseDistribution {
|
|||
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[]> {
|
||||
core.debug('Getting manifest from actions/node-versions@main');
|
||||
return tc.getManifestFromRepo(
|
||||
|
|
|
@ -10,14 +10,6 @@ export default class RcBuild extends BaseDistribution {
|
|||
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 {
|
||||
let version = '';
|
||||
|
||||
|
|
|
@ -70,14 +70,6 @@ export default class CanaryBuild extends BaseDistribution {
|
|||
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(
|
||||
versionSpec: string,
|
||||
distribution: string = ''
|
||||
|
|
Loading…
Add table
Reference in a new issue