Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

V dmshib/add rc support #2

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 18 additions & 2 deletions dist/setup/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -73352,6 +73352,7 @@ function getInfoFromManifest(versionSpec, stable, auth, osArch = translateArchTo
});
}
function getInfoFromDist(versionSpec, arch = os.arch(), nodeVersions) {
var _a;
return __awaiter(this, void 0, void 0, function* () {
let osPlat = os.platform();
let osArch = translateArchToDistUrl(arch);
Expand All @@ -73367,7 +73368,8 @@ function getInfoFromDist(versionSpec, arch = os.arch(), nodeVersions) {
? `node-v${version}-win-${osArch}`
: `node-v${version}-${osPlat}-${osArch}`;
let urlFileName = osPlat == 'win32' ? `${fileName}.7z` : `${fileName}.tar.gz`;
let url = `https://nodejs.org/dist/v${version}/${urlFileName}`;
const isPrerelease = ((_a = semver.prerelease(versionSpec)) !== null && _a !== void 0 ? _a : [])[0] === 'rc';
let url = isPrerelease ? `https://nodejs.org/download/rc/v${version}/${urlFileName}` : `https://nodejs.org/dist/v${version}/${urlFileName}`;
return {
downloadUrl: url,
resolvedVersion: version,
Expand Down Expand Up @@ -73415,6 +73417,7 @@ function evaluateVersions(versions, versionSpec) {
return version;
}
function queryDistForMatch(versionSpec, arch = os.arch(), nodeVersions) {
var _a;
return __awaiter(this, void 0, void 0, function* () {
let osPlat = os.platform();
let osArch = translateArchToDistUrl(arch);
Expand All @@ -73435,7 +73438,8 @@ function queryDistForMatch(versionSpec, arch = os.arch(), nodeVersions) {
}
if (!nodeVersions) {
core.debug('No dist manifest cached');
nodeVersions = yield getVersionsFromDist();
let preRelease = (_a = semver.prerelease(versionSpec)) !== null && _a !== void 0 ? _a : [];
nodeVersions = yield (preRelease[0] === 'rc' ? getRcVersionsFromDist() : getVersionsFromDist());
}
let versions = [];
if (isLatestSyntax(versionSpec)) {
Expand Down Expand Up @@ -73465,6 +73469,18 @@ function getVersionsFromDist() {
});
}
exports.getVersionsFromDist = getVersionsFromDist;
function getRcVersionsFromDist() {
return __awaiter(this, void 0, void 0, function* () {
let dataUrl = 'https://nodejs.org/download/rc/index.json';
let httpClient = new hc.HttpClient('setup-node', [], {
allowRetries: true,
maxRetries: 3
});
let response = yield httpClient.getJson(dataUrl);
return response.result || [];
});
}
exports.getRcVersionsFromDist = getRcVersionsFromDist;
// For non LTS versions of Node, the files we need (for Windows) are sometimes located
// in a different folder than they normally are for other versions.
// Normally the format is similar to: https://nodejs.org/dist/v5.10.1/node-v5.10.1-win-x64.7z
Expand Down
16 changes: 14 additions & 2 deletions src/installer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,8 @@ async function getInfoFromDist(
: `node-v${version}-${osPlat}-${osArch}`;
let urlFileName: string =
osPlat == 'win32' ? `${fileName}.7z` : `${fileName}.tar.gz`;
let url = `https://nodejs.org/dist/v${version}/${urlFileName}`;
const isPrerelease = (semver.prerelease(versionSpec) ?? [])[0] === 'rc';
let url = isPrerelease ? `https://nodejs.org/download/rc/v${version}/${urlFileName}` : `https://nodejs.org/dist/v${version}/${urlFileName}`;

return <INodeVersionInfo>{
downloadUrl: url,
Expand Down Expand Up @@ -392,7 +393,8 @@ async function queryDistForMatch(

if (!nodeVersions) {
core.debug('No dist manifest cached');
nodeVersions = await getVersionsFromDist();
let preRelease = semver.prerelease(versionSpec) ?? [];
nodeVersions = await (preRelease[0] === 'rc' ? getRcVersionsFromDist() : getVersionsFromDist());
}

let versions: string[] = [];
Expand Down Expand Up @@ -424,6 +426,16 @@ export async function getVersionsFromDist(): Promise<INodeVersion[]> {
return response.result || [];
}

export async function getRcVersionsFromDist(): Promise<INodeVersion[]> {
let dataUrl = 'https://nodejs.org/download/rc/index.json';
let httpClient = new hc.HttpClient('setup-node', [], {
allowRetries: true,
maxRetries: 3
});
let response = await httpClient.getJson<INodeVersion[]>(dataUrl);
return response.result || [];
}

// For non LTS versions of Node, the files we need (for Windows) are sometimes located
// in a different folder than they normally are for other versions.
// Normally the format is similar to: https://nodejs.org/dist/v5.10.1/node-v5.10.1-win-x64.7z
Expand Down