|
|
|
@ -18,6 +18,7 @@ export default class OfficialBuilds extends BaseDistribution {
|
|
|
|
|
let manifest: tc.IToolRelease[] | undefined;
|
|
|
|
|
let nodeJsVersions: INodeVersion[] | undefined;
|
|
|
|
|
const osArch = this.translateArchToDistUrl(this.nodeInfo.arch);
|
|
|
|
|
|
|
|
|
|
if (this.isLtsAlias(this.nodeInfo.versionSpec)) {
|
|
|
|
|
core.info('Attempt to resolve LTS alias from manifest...');
|
|
|
|
|
|
|
|
|
@ -61,7 +62,10 @@ export default class OfficialBuilds extends BaseDistribution {
|
|
|
|
|
|
|
|
|
|
if (toolPath) {
|
|
|
|
|
core.info(`Found in cache @ ${toolPath}`);
|
|
|
|
|
} else {
|
|
|
|
|
this.addToolPath(toolPath);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
let downloadPath = '';
|
|
|
|
|
try {
|
|
|
|
|
core.info(`Attempting to download ${this.nodeInfo.versionSpec}...`);
|
|
|
|
@ -72,6 +76,7 @@ export default class OfficialBuilds extends BaseDistribution {
|
|
|
|
|
osArch,
|
|
|
|
|
manifest
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
if (versionInfo) {
|
|
|
|
|
core.info(
|
|
|
|
|
`Acquiring ${versionInfo.resolvedVersion} - ${versionInfo.arch} from ${versionInfo.downloadUrl}`
|
|
|
|
@ -107,24 +112,51 @@ export default class OfficialBuilds extends BaseDistribution {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!toolPath) {
|
|
|
|
|
toolPath = await this.downloadDirectlyFromNode();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (this.osPlat != 'win32') {
|
|
|
|
|
toolPath = path.join(toolPath, 'bin');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
core.addPath(toolPath);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected addToolPath(toolPath: string) {
|
|
|
|
|
if (this.osPlat != 'win32') {
|
|
|
|
|
toolPath = path.join(toolPath, 'bin');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
core.addPath(toolPath);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected async downloadDirectlyFromNode() {
|
|
|
|
|
const nodeJsVersions = await this.getNodeJsVersions();
|
|
|
|
|
const versions = this.filterVersions(nodeJsVersions);
|
|
|
|
|
const evaluatedVersion = this.evaluateVersions(versions);
|
|
|
|
|
|
|
|
|
|
if (!evaluatedVersion) {
|
|
|
|
|
throw new Error(
|
|
|
|
|
`Unable to find Node version '${this.nodeInfo.versionSpec}' for platform ${this.osPlat} and architecture ${this.nodeInfo.arch}.`
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const toolName = this.getNodejsDistInfo(evaluatedVersion);
|
|
|
|
|
toolPath = await this.downloadNodejs(toolName);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (this.osPlat != 'win32') {
|
|
|
|
|
toolPath = path.join(toolPath, 'bin');
|
|
|
|
|
try {
|
|
|
|
|
const toolPath = await this.downloadNodejs(toolName);
|
|
|
|
|
return toolPath;
|
|
|
|
|
} catch (error) {
|
|
|
|
|
if (error instanceof tc.HTTPError && error.httpStatusCode === 404) {
|
|
|
|
|
core.info(
|
|
|
|
|
`Node version ${this.nodeInfo.versionSpec} for platform ${this.osPlat} and architecture ${this.nodeInfo.arch} was found but failed to download. ` +
|
|
|
|
|
'This usually happens when downloadable binaries are not fully updated at https://nodejs.org/. ' +
|
|
|
|
|
'To resolve this issue you may either fall back to the older version or try again later.'
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
core.addPath(toolPath);
|
|
|
|
|
throw error;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected evaluateVersions(versions: string[]): string {
|
|
|
|
|