Skip to content

Commit dc072db

Browse files
committed
feat: download from cnpm mirror
1 parent c6d5248 commit dc072db

2 files changed

Lines changed: 11 additions & 45 deletions

File tree

dist/setup/index.js

Lines changed: 8 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -50261,10 +50261,10 @@ var Distributions;
5026150261
})(Distributions || (Distributions = {}));
5026250262
function getNodejsDistribution(installerOptions) {
5026350263
const versionSpec = installerOptions.versionSpec;
50264-
if (versionSpec.includes(Distributions.NIGHTLY ||
50264+
if (versionSpec.includes(Distributions.NIGHTLY) ||
5026550265
versionSpec.includes(Distributions.CANARY) ||
50266-
versionSpec.includes(Distributions.RC))) {
50267-
throw Error('Only Offical Build supported for now');
50266+
versionSpec.includes(Distributions.RC)) {
50267+
throw Error('Only Official Build supported for now');
5026850268
}
5026950269
else {
5027050270
return new official_builds_1.default(installerOptions);
@@ -50331,16 +50331,10 @@ class OfficialBuilds extends base_distribution_1.default {
5033150331
let nodeJsVersions;
5033250332
const osArch = this.translateArchToDistUrl(this.nodeInfo.arch);
5033350333
if (this.isLtsAlias(this.nodeInfo.versionSpec)) {
50334-
core.info('Attempt to resolve LTS alias from manifest...');
50335-
// No try-catch since it's not possible to resolve LTS alias without manifest
50336-
manifest = await this.getManifest();
50337-
this.nodeInfo.versionSpec = this.resolveLtsAliasFromManifest(this.nodeInfo.versionSpec, this.nodeInfo.stable, manifest);
50334+
throw Error('lts/* version spec is not supported anymore.');
5033850335
}
5033950336
if (this.isLatestSyntax(this.nodeInfo.versionSpec)) {
50340-
nodeJsVersions = await this.getNodeJsVersions();
50341-
const versions = this.filterVersions(nodeJsVersions);
50342-
this.nodeInfo.versionSpec = this.evaluateVersions(versions);
50343-
core.info('getting latest node version...');
50337+
throw Error("'current/latest' version spec is not supported anymore.");
5034450338
}
5034550339
if (this.nodeInfo.checkLatest) {
5034650340
core.info('Attempt to resolve the latest version from manifest...');
@@ -50359,16 +50353,12 @@ class OfficialBuilds extends base_distribution_1.default {
5035950353
this.addToolPath(toolPath);
5036050354
return;
5036150355
}
50362-
let downloadPath = '';
5036350356
try {
5036450357
core.info(`Attempting to download ${this.nodeInfo.versionSpec}...`);
5036550358
const versionInfo = await this.getInfoFromManifest(this.nodeInfo.versionSpec, this.nodeInfo.stable, osArch, manifest);
5036650359
if (versionInfo) {
50367-
core.info(`Acquiring ${versionInfo.resolvedVersion} - ${versionInfo.arch} from ${versionInfo.downloadUrl}`);
50368-
downloadPath = await tc.downloadTool(versionInfo.downloadUrl, undefined, this.nodeInfo.mirror ? this.nodeInfo.mirrorToken : this.nodeInfo.auth);
50369-
if (downloadPath) {
50370-
toolPath = await this.extractArchive(downloadPath, versionInfo, false);
50371-
}
50360+
this.nodeInfo.versionSpec = versionInfo.resolvedVersion;
50361+
core.info(`Resolved ${versionInfo.resolvedVersion} from manifest. Preparing to download from ${this.getFallbackDisplayUrl()}.`);
5037250362
}
5037350363
else {
5037450364
core.info(`Not found in manifest. Falling back to download directly from ${this.getFallbackDisplayUrl()}`);
@@ -50431,15 +50421,10 @@ class OfficialBuilds extends base_distribution_1.default {
5043150421
return version;
5043250422
}
5043350423
getDistributionUrl(mirror) {
50434-
if (mirror) {
50435-
return `${mirror.replace(/\/$/, '')}/dist`;
50436-
}
5043750424
return constants_1.DEFAULT_NODE_MIRROR;
5043850425
}
5043950426
getFallbackDisplayUrl() {
50440-
return this.nodeInfo.mirror
50441-
? this.nodeInfo.mirror.replace(/\/$/, '')
50442-
: constants_1.DEFAULT_NODE_MIRROR;
50427+
return constants_1.DEFAULT_NODE_MIRROR;
5044350428
}
5044450429
getManifest() {
5044550430
core.debug('Getting manifest from actions/node-versions@main');

src/distributions/official_builds/official_builds.ts

Lines changed: 3 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ export default class OfficialBuilds extends BaseDistribution {
5454
return;
5555
}
5656

57-
let downloadPath = '';
5857
try {
5958
core.info(`Attempting to download ${this.nodeInfo.versionSpec}...`);
6059

@@ -66,22 +65,10 @@ export default class OfficialBuilds extends BaseDistribution {
6665
);
6766

6867
if (versionInfo) {
68+
this.nodeInfo.versionSpec = versionInfo.resolvedVersion;
6969
core.info(
70-
`Acquiring ${versionInfo.resolvedVersion} - ${versionInfo.arch} from ${versionInfo.downloadUrl}`
70+
`Resolved ${versionInfo.resolvedVersion} from manifest. Preparing to download from ${this.getFallbackDisplayUrl()}.`
7171
);
72-
downloadPath = await tc.downloadTool(
73-
versionInfo.downloadUrl,
74-
undefined,
75-
this.nodeInfo.mirror ? this.nodeInfo.mirrorToken : this.nodeInfo.auth
76-
);
77-
78-
if (downloadPath) {
79-
toolPath = await this.extractArchive(
80-
downloadPath,
81-
versionInfo,
82-
false
83-
);
84-
}
8572
} else {
8673
core.info(
8774
`Not found in manifest. Falling back to download directly from ${this.getFallbackDisplayUrl()}`
@@ -167,17 +154,11 @@ export default class OfficialBuilds extends BaseDistribution {
167154
}
168155

169156
protected getDistributionUrl(mirror: string): string {
170-
if (mirror) {
171-
return `${mirror.replace(/\/$/, '')}/dist`;
172-
}
173-
174157
return DEFAULT_NODE_MIRROR;
175158
}
176159

177160
private getFallbackDisplayUrl(): string {
178-
return this.nodeInfo.mirror
179-
? this.nodeInfo.mirror.replace(/\/$/, '')
180-
: DEFAULT_NODE_MIRROR;
161+
return DEFAULT_NODE_MIRROR;
181162
}
182163

183164
private getManifest(): Promise<tc.IToolRelease[]> {

0 commit comments

Comments
 (0)