remove changing prerelease

This commit is contained in:
Dmitry Shibanov 2022-12-27 20:58:46 +01:00
parent 7f2fa59092
commit 363785e8f4
4 changed files with 29 additions and 128 deletions

64
dist/setup/index.js vendored
View File

@ -73254,9 +73254,10 @@ class BaseDistribution {
}
evaluateVersions(versions) {
let version = '';
const { range, options } = this.validRange(this.nodeInfo.versionSpec);
core.debug(`evaluating ${versions.length} versions`);
for (let potential of versions) {
const satisfied = semver_1.default.satisfies(potential, this.nodeInfo.versionSpec);
const satisfied = semver_1.default.satisfies(potential, range, options);
if (satisfied) {
version = potential;
break;
@ -73315,6 +73316,13 @@ class BaseDistribution {
return toolPath;
});
}
validRange(versionSpec) {
var _a;
let options;
const c = semver_1.default.clean(versionSpec) || '';
const valid = (_a = semver_1.default.valid(c)) !== null && _a !== void 0 ? _a : versionSpec;
return { range: valid, options };
}
acquireNodeFromFallbackLocation(version, arch = os_1.default.arch()) {
return __awaiter(this, void 0, void 0, function* () {
const initialUrl = this.getDistributionUrl();
@ -73487,7 +73495,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
const core = __importStar(__nccwpck_require__(2186));
const tc = __importStar(__nccwpck_require__(7784));
const semver_1 = __importDefault(__nccwpck_require__(5911));
const base_distribution_1 = __importDefault(__nccwpck_require__(7));
@ -73514,32 +73521,10 @@ class NightlyNodejs extends base_distribution_1.default {
}
return toolPath;
}
evaluateVersions(versions) {
let version = '';
core.debug(`evaluating ${versions.length} versions`);
const { includePrerelease, range } = this.createRangePreRelease(this.nodeInfo.versionSpec);
for (let i = 0; i < versions.length; i++) {
const potential = versions[i];
const satisfied = semver_1.default.satisfies(potential.replace(this.distribution, `${this.distribution}.`), range, {
includePrerelease: includePrerelease
});
if (satisfied) {
version = potential;
break;
}
}
if (version) {
core.debug(`matched: ${version}`);
}
else {
core.debug('match not found');
}
return version;
}
getDistributionUrl() {
return 'https://nodejs.org/download/nightly';
}
createRangePreRelease(versionSpec) {
validRange(versionSpec) {
let range;
const [raw, prerelease] = this.splitVersionSpec(versionSpec);
const isValidVersion = semver_1.default.valid(raw);
@ -73550,7 +73535,7 @@ class NightlyNodejs extends base_distribution_1.default {
else {
range = `${semver_1.default.validRange(`^${rawVersion}-${this.distribution}`)}-0`;
}
return { range, includePrerelease: !isValidVersion };
return { range, options: { includePrerelease: !isValidVersion } };
}
splitVersionSpec(versionSpec) {
return versionSpec.split(/-(.*)/s);
@ -73794,7 +73779,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
const core = __importStar(__nccwpck_require__(2186));
const tc = __importStar(__nccwpck_require__(7784));
const semver_1 = __importDefault(__nccwpck_require__(5911));
const base_distribution_1 = __importDefault(__nccwpck_require__(7));
@ -73824,29 +73808,7 @@ class CanaryBuild extends base_distribution_1.default {
getDistributionUrl() {
return 'https://nodejs.org/download/v8-canary';
}
evaluateVersions(versions) {
let version = '';
core.debug(`evaluating ${versions.length} versions`);
const { includePrerelease, range } = this.createRangePreRelease(this.nodeInfo.versionSpec);
for (let i = 0; i < versions.length; i++) {
const potential = versions[i];
const satisfied = semver_1.default.satisfies(potential.replace(this.distribution, `${this.distribution}.`), range, {
includePrerelease: includePrerelease
});
if (satisfied) {
version = potential;
break;
}
}
if (version) {
core.debug(`matched: ${version}`);
}
else {
core.debug('match not found');
}
return version;
}
createRangePreRelease(versionSpec) {
validRange(versionSpec) {
let range;
const [raw, prerelease] = this.splitVersionSpec(versionSpec);
const isValidVersion = semver_1.default.valid(raw);
@ -73857,7 +73819,7 @@ class CanaryBuild extends base_distribution_1.default {
else {
range = `${semver_1.default.validRange(`^${rawVersion}-${this.distribution}`)}-0`;
}
return { range, includePrerelease: !isValidVersion };
return { range, options: { includePrerelease: !isValidVersion } };
}
splitVersionSpec(versionSpec) {
return versionSpec.split(/-(.*)/s);

View File

@ -60,16 +60,15 @@ export default abstract class BaseDistribution {
core.addPath(toolPath);
}
protected evaluateVersions(versions: string[]) {
protected evaluateVersions(versions: string[]): string {
let version = '';
const {range, options} = this.validRange(this.nodeInfo.versionSpec);
core.debug(`evaluating ${versions.length} versions`);
for (let potential of versions) {
const satisfied: boolean = semver.satisfies(
potential,
this.nodeInfo.versionSpec
);
const satisfied: boolean = semver.satisfies(potential, range, options);
if (satisfied) {
version = potential;
break;
@ -141,6 +140,14 @@ export default abstract class BaseDistribution {
return toolPath;
}
protected validRange(versionSpec: string) {
let options: semver.Options | undefined;
const c = semver.clean(versionSpec) || '';
const valid = semver.valid(c) ?? versionSpec;
return {range: valid, options};
}
protected async acquireNodeFromFallbackLocation(
version: string,
arch: string = os.arch()

View File

@ -1,4 +1,3 @@
import * as core from '@actions/core';
import * as tc from '@actions/tool-cache';
import semver from 'semver';
@ -33,44 +32,11 @@ export default class NightlyNodejs extends BaseDistribution {
return toolPath;
}
protected evaluateVersions(versions: string[]): string {
let version = '';
core.debug(`evaluating ${versions.length} versions`);
const {includePrerelease, range} = this.createRangePreRelease(
this.nodeInfo.versionSpec
);
for (let i = 0; i < versions.length; i++) {
const potential: string = versions[i];
const satisfied: boolean = semver.satisfies(
potential.replace(this.distribution, `${this.distribution}.`),
range,
{
includePrerelease: includePrerelease
}
);
if (satisfied) {
version = potential;
break;
}
}
if (version) {
core.debug(`matched: ${version}`);
} else {
core.debug('match not found');
}
return version;
}
protected getDistributionUrl(): string {
return 'https://nodejs.org/download/nightly';
}
protected createRangePreRelease(versionSpec: string) {
protected validRange(versionSpec: string) {
let range: string;
const [raw, prerelease] = this.splitVersionSpec(versionSpec);
const isValidVersion = semver.valid(raw);
@ -85,7 +51,7 @@ export default class NightlyNodejs extends BaseDistribution {
range = `${semver.validRange(`^${rawVersion}-${this.distribution}`)}-0`;
}
return {range, includePrerelease: !isValidVersion};
return {range, options: {includePrerelease: !isValidVersion}};
}
protected splitVersionSpec(versionSpec: string) {

View File

@ -1,4 +1,3 @@
import * as core from '@actions/core';
import * as tc from '@actions/tool-cache';
import semver from 'semver';
@ -37,40 +36,7 @@ export default class CanaryBuild extends BaseDistribution {
return 'https://nodejs.org/download/v8-canary';
}
protected evaluateVersions(versions: string[]): string {
let version = '';
core.debug(`evaluating ${versions.length} versions`);
const {includePrerelease, range} = this.createRangePreRelease(
this.nodeInfo.versionSpec
);
for (let i = 0; i < versions.length; i++) {
const potential: string = versions[i];
const satisfied: boolean = semver.satisfies(
potential.replace(this.distribution, `${this.distribution}.`),
range,
{
includePrerelease: includePrerelease
}
);
if (satisfied) {
version = potential;
break;
}
}
if (version) {
core.debug(`matched: ${version}`);
} else {
core.debug('match not found');
}
return version;
}
protected createRangePreRelease(versionSpec: string) {
protected validRange(versionSpec: string) {
let range: string;
const [raw, prerelease] = this.splitVersionSpec(versionSpec);
const isValidVersion = semver.valid(raw);
@ -85,7 +51,7 @@ export default class CanaryBuild extends BaseDistribution {
range = `${semver.validRange(`^${rawVersion}-${this.distribution}`)}-0`;
}
return {range, includePrerelease: !isValidVersion};
return {range, options: {includePrerelease: !isValidVersion}};
}
protected splitVersionSpec(versionSpec: string) {