mirror of
https://gitea.com/actions/setup-node.git
synced 2025-04-22 16:55:37 +08:00
comment code
This commit is contained in:
parent
c849fe6824
commit
e25fd13757
46
dist/setup/index.js
vendored
46
dist/setup/index.js
vendored
@ -73233,28 +73233,33 @@ exports.distributionOf = (versionSpec) => {
|
|||||||
return Distributions.DEFAULT;
|
return Distributions.DEFAULT;
|
||||||
};
|
};
|
||||||
exports.semverVersionMatcherFactory = (range) => {
|
exports.semverVersionMatcherFactory = (range) => {
|
||||||
const matcher = (potential) => {
|
const matcher = (potential) => semver.satisfies(potential, range);
|
||||||
core.debug(`potential is ${potential}`);
|
|
||||||
return semver.satisfies(potential, range);
|
|
||||||
};
|
|
||||||
core.debug(`range is ${range}`);
|
|
||||||
matcher.factory = exports.semverVersionMatcherFactory;
|
matcher.factory = exports.semverVersionMatcherFactory;
|
||||||
return matcher;
|
return matcher;
|
||||||
};
|
};
|
||||||
exports.canaryRangeVersionMatcherFactory = (version) => {
|
// export const canaryRangeVersionMatcherFactory = (
|
||||||
const { range, includePrerelease } = createRangePreRelease(version, Distributions.CANARY);
|
// version: string
|
||||||
const matcher = (potential) => semver.satisfies(potential.replace(Distributions.CANARY, `${Distributions.CANARY}.`), range, { includePrerelease: includePrerelease });
|
// ): VersionMatcher => {
|
||||||
matcher.factory = exports.canaryRangeVersionMatcherFactory;
|
// const {range, includePrerelease} = createRangePreRelease(
|
||||||
return matcher;
|
// version,
|
||||||
};
|
// Distributions.CANARY
|
||||||
exports.nightlyRangeVersionMatcherFactory = (version) => {
|
// )!;
|
||||||
const { range, includePrerelease } = createRangePreRelease(version, Distributions.NIGHTLY);
|
// const matcher = (potential: string): boolean =>
|
||||||
const matcher = (potential) => exports.distributionOf(potential) === Distributions.NIGHTLY &&
|
// semver.satisfies(
|
||||||
semver.satisfies(potential.replace(Distributions.NIGHTLY, `${Distributions.NIGHTLY}.`), range, { includePrerelease: includePrerelease });
|
// potential.replace(Distributions.CANARY, `${Distributions.CANARY}.`),
|
||||||
|
// range!,
|
||||||
|
// {includePrerelease: includePrerelease}
|
||||||
|
// );
|
||||||
|
// matcher.factory = canaryRangeVersionMatcherFactory;
|
||||||
|
// return matcher;
|
||||||
|
// };
|
||||||
|
exports.nightlyRangeVersionMatcherFactory = (version, distribution) => {
|
||||||
|
const { range, includePrerelease } = createRangePreRelease(version, distribution);
|
||||||
|
const matcher = (potential) => exports.distributionOf(potential) === distribution &&
|
||||||
|
semver.satisfies(potential.replace(distribution, `${distribution}.`), range, { includePrerelease: includePrerelease });
|
||||||
matcher.factory = exports.nightlyRangeVersionMatcherFactory;
|
matcher.factory = exports.nightlyRangeVersionMatcherFactory;
|
||||||
return matcher;
|
return matcher;
|
||||||
};
|
};
|
||||||
// [raw, prerelease]
|
|
||||||
exports.splitVersionSpec = (versionSpec) => versionSpec.split(/-(.*)/s);
|
exports.splitVersionSpec = (versionSpec) => versionSpec.split(/-(.*)/s);
|
||||||
const createRangePreRelease = (versionSpec, preRelease = '') => {
|
const createRangePreRelease = (versionSpec, preRelease = '') => {
|
||||||
let range;
|
let range;
|
||||||
@ -73263,16 +73268,12 @@ const createRangePreRelease = (versionSpec, preRelease = '') => {
|
|||||||
const rawVersion = isValidVersion ? raw : semver.coerce(raw);
|
const rawVersion = isValidVersion ? raw : semver.coerce(raw);
|
||||||
if (rawVersion) {
|
if (rawVersion) {
|
||||||
if (`-${prerelease}` !== preRelease) {
|
if (`-${prerelease}` !== preRelease) {
|
||||||
core.debug(`came to full version ${preRelease}`);
|
|
||||||
range = `${rawVersion}${`-${prerelease}`.replace(preRelease, `${preRelease}.`)}`;
|
range = `${rawVersion}${`-${prerelease}`.replace(preRelease, `${preRelease}.`)}`;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
core.debug('came to range version');
|
|
||||||
range = `${semver.validRange(`^${rawVersion}${preRelease}`)}-0`;
|
range = `${semver.validRange(`^${rawVersion}${preRelease}`)}-0`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
core.debug(`prerelease is ${prerelease}, preRelease is ${preRelease}`);
|
|
||||||
core.debug(`Version Range for ${versionSpec} is ${range}`);
|
|
||||||
return { range, includePrerelease: !isValidVersion };
|
return { range, includePrerelease: !isValidVersion };
|
||||||
};
|
};
|
||||||
function versionMatcherFactory(versionSpec) {
|
function versionMatcherFactory(versionSpec) {
|
||||||
@ -73282,9 +73283,10 @@ function versionMatcherFactory(versionSpec) {
|
|||||||
if (validVersion) {
|
if (validVersion) {
|
||||||
switch (exports.distributionOf(versionSpec)) {
|
switch (exports.distributionOf(versionSpec)) {
|
||||||
case Distributions.CANARY:
|
case Distributions.CANARY:
|
||||||
return exports.canaryRangeVersionMatcherFactory(versionSpec);
|
|
||||||
case Distributions.NIGHTLY:
|
case Distributions.NIGHTLY:
|
||||||
return exports.nightlyRangeVersionMatcherFactory(versionSpec);
|
return exports.nightlyRangeVersionMatcherFactory(versionSpec, Distributions.CANARY);
|
||||||
|
case Distributions.NIGHTLY:
|
||||||
|
return exports.nightlyRangeVersionMatcherFactory(versionSpec, Distributions.NIGHTLY);
|
||||||
case Distributions.RC:
|
case Distributions.RC:
|
||||||
case Distributions.DEFAULT:
|
case Distributions.DEFAULT:
|
||||||
return exports.semverVersionMatcherFactory(versionSpec);
|
return exports.semverVersionMatcherFactory(versionSpec);
|
||||||
|
@ -56,43 +56,42 @@ interface VersionMatcher {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const semverVersionMatcherFactory = (range: string): VersionMatcher => {
|
export const semverVersionMatcherFactory = (range: string): VersionMatcher => {
|
||||||
const matcher = (potential: string): boolean =>{
|
const matcher = (potential: string): boolean =>
|
||||||
core.debug(`potential is ${potential}`)
|
semver.satisfies(potential, range);
|
||||||
return semver.satisfies(potential, range);
|
|
||||||
}
|
|
||||||
core.debug(`range is ${range}`);
|
|
||||||
matcher.factory = semverVersionMatcherFactory;
|
matcher.factory = semverVersionMatcherFactory;
|
||||||
return matcher;
|
return matcher;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const canaryRangeVersionMatcherFactory = (
|
// export const canaryRangeVersionMatcherFactory = (
|
||||||
version: string
|
// version: string
|
||||||
): VersionMatcher => {
|
// ): VersionMatcher => {
|
||||||
const {range, includePrerelease} = createRangePreRelease(
|
// const {range, includePrerelease} = createRangePreRelease(
|
||||||
version,
|
// version,
|
||||||
Distributions.CANARY
|
// Distributions.CANARY
|
||||||
)!;
|
// )!;
|
||||||
const matcher = (potential: string): boolean =>
|
// const matcher = (potential: string): boolean =>
|
||||||
semver.satisfies(
|
// semver.satisfies(
|
||||||
potential.replace(Distributions.CANARY, `${Distributions.CANARY}.`),
|
// potential.replace(Distributions.CANARY, `${Distributions.CANARY}.`),
|
||||||
range!,
|
// range!,
|
||||||
{includePrerelease: includePrerelease}
|
// {includePrerelease: includePrerelease}
|
||||||
);
|
// );
|
||||||
matcher.factory = canaryRangeVersionMatcherFactory;
|
// matcher.factory = canaryRangeVersionMatcherFactory;
|
||||||
return matcher;
|
// return matcher;
|
||||||
};
|
// };
|
||||||
|
|
||||||
export const nightlyRangeVersionMatcherFactory = (
|
export const nightlyRangeVersionMatcherFactory = (
|
||||||
version: string
|
version: string,
|
||||||
|
distribution: string
|
||||||
): VersionMatcher => {
|
): VersionMatcher => {
|
||||||
const {range, includePrerelease} = createRangePreRelease(
|
const {range, includePrerelease} = createRangePreRelease(
|
||||||
version,
|
version,
|
||||||
Distributions.NIGHTLY
|
distribution
|
||||||
)!;
|
)!;
|
||||||
const matcher = (potential: string): boolean =>
|
const matcher = (potential: string): boolean =>
|
||||||
distributionOf(potential) === Distributions.NIGHTLY &&
|
distributionOf(potential) === distribution &&
|
||||||
semver.satisfies(
|
semver.satisfies(
|
||||||
potential.replace(Distributions.NIGHTLY, `${Distributions.NIGHTLY}.`),
|
potential.replace(distribution, `${distribution}.`),
|
||||||
range!,
|
range!,
|
||||||
{includePrerelease: includePrerelease}
|
{includePrerelease: includePrerelease}
|
||||||
);
|
);
|
||||||
@ -100,7 +99,6 @@ export const nightlyRangeVersionMatcherFactory = (
|
|||||||
return matcher;
|
return matcher;
|
||||||
};
|
};
|
||||||
|
|
||||||
// [raw, prerelease]
|
|
||||||
export const splitVersionSpec = (versionSpec: string): string[] =>
|
export const splitVersionSpec = (versionSpec: string): string[] =>
|
||||||
versionSpec.split(/-(.*)/s);
|
versionSpec.split(/-(.*)/s);
|
||||||
|
|
||||||
@ -115,18 +113,14 @@ const createRangePreRelease = (
|
|||||||
|
|
||||||
if (rawVersion) {
|
if (rawVersion) {
|
||||||
if (`-${prerelease}` !== preRelease) {
|
if (`-${prerelease}` !== preRelease) {
|
||||||
core.debug(`came to full version ${preRelease}`);
|
|
||||||
range = `${rawVersion}${`-${prerelease}`.replace(
|
range = `${rawVersion}${`-${prerelease}`.replace(
|
||||||
preRelease,
|
preRelease,
|
||||||
`${preRelease}.`
|
`${preRelease}.`
|
||||||
)}`;
|
)}`;
|
||||||
} else {
|
} else {
|
||||||
core.debug('came to range version');
|
|
||||||
range = `${semver.validRange(`^${rawVersion}${preRelease}`)}-0`;
|
range = `${semver.validRange(`^${rawVersion}${preRelease}`)}-0`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
core.debug(`prerelease is ${prerelease}, preRelease is ${preRelease}`);
|
|
||||||
core.debug(`Version Range for ${versionSpec} is ${range}`);
|
|
||||||
|
|
||||||
return {range, includePrerelease: !isValidVersion};
|
return {range, includePrerelease: !isValidVersion};
|
||||||
};
|
};
|
||||||
@ -138,9 +132,16 @@ export function versionMatcherFactory(versionSpec: string): VersionMatcher {
|
|||||||
if (validVersion) {
|
if (validVersion) {
|
||||||
switch (distributionOf(versionSpec)) {
|
switch (distributionOf(versionSpec)) {
|
||||||
case Distributions.CANARY:
|
case Distributions.CANARY:
|
||||||
return canaryRangeVersionMatcherFactory(versionSpec);
|
|
||||||
case Distributions.NIGHTLY:
|
case Distributions.NIGHTLY:
|
||||||
return nightlyRangeVersionMatcherFactory(versionSpec);
|
return nightlyRangeVersionMatcherFactory(
|
||||||
|
versionSpec,
|
||||||
|
Distributions.CANARY
|
||||||
|
);
|
||||||
|
case Distributions.NIGHTLY:
|
||||||
|
return nightlyRangeVersionMatcherFactory(
|
||||||
|
versionSpec,
|
||||||
|
Distributions.NIGHTLY
|
||||||
|
);
|
||||||
case Distributions.RC:
|
case Distributions.RC:
|
||||||
case Distributions.DEFAULT:
|
case Distributions.DEFAULT:
|
||||||
return semverVersionMatcherFactory(versionSpec);
|
return semverVersionMatcherFactory(versionSpec);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user