add possible improvement for canary

This commit is contained in:
Dmitry Shibanov 2022-12-13 14:19:28 +01:00
parent 7fc684f251
commit 0d35e2c938
3 changed files with 33 additions and 26 deletions

24
dist/setup/index.js vendored
View file

@ -73848,11 +73848,17 @@ const core = __importStar(__nccwpck_require__(2186));
const semver_1 = __importDefault(__nccwpck_require__(5911));
const base_distribution_1 = __importDefault(__nccwpck_require__(8653));
class CanaryBuild extends base_distribution_1.default {
constructor(nodeInfo) {
super(nodeInfo);
}
getDistributionUrl() {
return 'https://nodejs.org/download/v8-canary';
}
evaluateVersions(nodeVersions) {
let version = '';
const versions = this.filterVersions(nodeVersions);
core.debug(`evaluating ${versions.length} versions`);
const { includePrerelease, range } = this.createRangePreRelease(this.nodeInfo.versionSpec, '-v8-canary');
const { includePrerelease, range } = this.createRangePreRelease(this.nodeInfo.versionSpec, 'v8-canary');
for (let i = 0; i < versions.length; i++) {
const potential = versions[i];
const satisfied = semver_1.default.satisfies(potential.replace('v8-canary', 'v8-canary.'), range, {
@ -73871,12 +73877,6 @@ class CanaryBuild extends base_distribution_1.default {
}
return version;
}
constructor(nodeInfo) {
super(nodeInfo);
}
getDistributionUrl() {
return 'https://nodejs.org/download/v8-canary';
}
getNodejsVersions() {
return __awaiter(this, void 0, void 0, function* () {
const initialUrl = this.getDistributionUrl();
@ -73890,11 +73890,11 @@ class CanaryBuild extends base_distribution_1.default {
const [raw, prerelease] = this.splitVersionSpec(versionSpec);
const isValidVersion = semver_1.default.valid(raw);
const rawVersion = (isValidVersion ? raw : semver_1.default.coerce(raw));
if (`-${prerelease}` !== distribution) {
range = `${rawVersion}${`-${prerelease}`.replace(distribution, `${distribution}.`)}`;
if (prerelease !== distribution) {
range = `${rawVersion}-${prerelease.replace(distribution, `${distribution}.`)}`;
}
else {
range = `${semver_1.default.validRange(`^${rawVersion}${distribution}`)}-0`;
range = `${semver_1.default.validRange(`^${rawVersion}-${distribution}`)}-0`;
}
return { range, includePrerelease: !isValidVersion };
}
@ -74471,7 +74471,6 @@ function run() {
if (version) {
const token = core.getInput('token');
const auth = !token ? undefined : `token ${token}`;
const stable = (core.getInput('stable') || 'true').toUpperCase() === 'TRUE';
const checkLatest = (core.getInput('check-latest') || 'false').toUpperCase() === 'TRUE';
const nodejsInfo = {
versionSpec: version,
@ -74483,6 +74482,9 @@ function run() {
if (nodeDistribution) {
yield (nodeDistribution === null || nodeDistribution === void 0 ? void 0 : nodeDistribution.getNodeJsInfo());
}
else {
throw new Error(`Could not resolve version: ${version} for build`);
}
// await installer.getNode(version, stable, checkLatest, auth, arch);
}
yield printEnvDetailsAndSetOutput();

View file

@ -6,6 +6,14 @@ import BaseDistribution from '../base-distribution';
import {INodejs, INodeVersion} from '../base-models';
export default class CanaryBuild extends BaseDistribution {
constructor(nodeInfo: INodejs) {
super(nodeInfo);
}
protected getDistributionUrl(): string {
return 'https://nodejs.org/download/v8-canary';
}
protected evaluateVersions(nodeVersions: INodeVersion[]): string {
let version = '';
const versions = this.filterVersions(nodeVersions);
@ -14,7 +22,7 @@ export default class CanaryBuild extends BaseDistribution {
const {includePrerelease, range} = this.createRangePreRelease(
this.nodeInfo.versionSpec,
'-v8-canary'
'v8-canary'
);
for (let i = 0; i < versions.length; i++) {
@ -40,12 +48,6 @@ export default class CanaryBuild extends BaseDistribution {
return version;
}
constructor(nodeInfo: INodejs) {
super(nodeInfo);
}
protected getDistributionUrl(): string {
return 'https://nodejs.org/download/v8-canary';
}
async getNodejsVersions(): Promise<INodeVersion[]> {
const initialUrl = this.getDistributionUrl();
@ -55,25 +57,28 @@ export default class CanaryBuild extends BaseDistribution {
return response.result || [];
}
createRangePreRelease(versionSpec: string, distribution: string = '') {
let range: string | undefined;
protected createRangePreRelease(
versionSpec: string,
distribution: string = ''
) {
let range: string;
const [raw, prerelease] = this.splitVersionSpec(versionSpec);
const isValidVersion = semver.valid(raw);
const rawVersion = (isValidVersion ? raw : semver.coerce(raw))!;
if (`-${prerelease}` !== distribution) {
range = `${rawVersion}${`-${prerelease}`.replace(
if (prerelease !== distribution) {
range = `${rawVersion}-${prerelease.replace(
distribution,
`${distribution}.`
)}`;
} else {
range = `${semver.validRange(`^${rawVersion}${distribution}`)}-0`;
range = `${semver.validRange(`^${rawVersion}-${distribution}`)}-0`;
}
return {range, includePrerelease: !isValidVersion};
}
splitVersionSpec(versionSpec: string) {
protected splitVersionSpec(versionSpec: string) {
return versionSpec.split(/-(.*)/s);
}
}

View file

@ -35,8 +35,6 @@ export async function run() {
if (version) {
const token = core.getInput('token');
const auth = !token ? undefined : `token ${token}`;
const stable =
(core.getInput('stable') || 'true').toUpperCase() === 'TRUE';
const checkLatest =
(core.getInput('check-latest') || 'false').toUpperCase() === 'TRUE';
const nodejsInfo = {
@ -48,6 +46,8 @@ export async function run() {
const nodeDistribution = getNodejsDistribution(nodejsInfo);
if (nodeDistribution) {
await nodeDistribution?.getNodeJsInfo();
} else {
throw new Error(`Could not resolve version: ${version} for build`);
}
// await installer.getNode(version, stable, checkLatest, auth, arch);