mirror of
https://github.com/renovatebot/renovate.git
synced 2026-11-01 10:09:50 +00:00
59852479bf
* test(versioning): cover four uncovered guards - `cargo`: a converted range whose operators are already attached to their versions, so `npm2cargo` leaves the elements alone - `hashicorp`: a widen on a complex range ending in `>=`, which the underlying semver implementation refuses and returns null for - `poetry`: a version list holding an unparseable entry, for both `getSatisfyingVersion` and `minSatisfyingVersion`, plus the same widen refusal, which falls back to the current value - `swift`: an open-ended range whose bound is not a valid semver Co-authored-by: Claude Opus 5 <michael.kriese+claude-code@mend.io> * refactor(versioning): drop two guards that cannot be false - `hermit`: `major` is the only mandatory group in the version regex, so the `if (major)` around the first release segment always holds; the sibling parser already pushes it unconditionally - `rpm`: after `c1 === c2` is ruled out, one of `c1 > c2` and `c1 < c2` must hold, so the second comparison becomes a ternary Co-authored-by: Claude Opus 5 <michael.kriese+claude-code@mend.io> * test(versioning/gradle): cover three uncovered guards - `getMajor` on a version whose leading token is not a number - `getSatisfyingVersion` with a later match that is not greater than the one already held - `minSatisfyingVersion` with a later match that is not smaller than the one already held Two branches in `compare.ts` are still open and are looked at next. Co-authored-by: Claude Opus 5 <michael.kriese+claude-code@mend.io> * test(versioning/ivy): cover a later match that is not the greatest `getSatisfyingVersion` kept every matching version it walked past, so the guard that holds on to the one already found was never taken. Co-authored-by: Claude Opus 5 <michael.kriese+claude-code@mend.io> * refactor(versioning): drop three guards that cannot be false - `gradle`: `tokenCmp` compares two tokens whose only types are `Number` and `String`, so once both-numbers and both-strings are handled exactly one side is a number; the chain becomes a ternary and the unreachable `return 0` goes - `ivy`: `tokenize` always yields at least one token for a non-empty version, so the length check around the last one always holds - `ivy`: `rangeToStr` only returns null for a null range, which the `length === 1` check above it already rules out Co-authored-by: Claude Opus 5 <michael.kriese+claude-code@mend.io> * test(versioning/nuget): cover a later match that is not the greatest Both loops in `getSatisfyingVersion` walked version lists that only ever climbed, so the guard that holds on to the candidate already found was never taken -- once for a bracket range, once for a bare version acting as a minimum. Also pin down that a floating range needs a major component: `-*` alone does not parse. Co-authored-by: Claude Opus 5 <michael.kriese+claude-code@mend.io> * refactor(versioning): drop three more guards that cannot be false - `maven`: the interval picked for auto-extension is only picked when the new value is at or past its upper bound, and that upper bound is the lower one incremented, so the new value never sorts below the lower bound - `maven`: an interval never has both bounds open, because the parser only nulls one side when the other is a version - `nuget`: a floating range always carries a major component, so neither the parser's NaN check nor the serializer's undefined check can fail Co-authored-by: Claude Opus 5 <michael.kriese+claude-code@mend.io> * refactor(versioning/pep440): drop three unreachable range paths `updateRangeValue` handles `!=`, a `.*` prefix, `~=`, `==` and `<=` itself, `handleUpperBound` handles `<`, and `parseCurrentRange` rejects `===`. Only `>` and `>=` can reach `handleLowerBound`, so its operator check always holds and it never returns null. Making it total removes the null check at the call site as well. This does drop the `logger.error` that followed, which was guarded by a comment saying it could not happen unless pep440 itself changed. `isLessThanRange` classifies the same fixed operator set, so the last check there is the only one left and its fallback was dead. `divideCompatibleReleaseRange` only ever sees a `~=` version, and pep440 requires at least two release components after that operator, so there is always a component to drop. A new test pins down that `~=7` is not a valid range. Co-authored-by: Claude Opus 5 <michael.kriese+claude-code@mend.io> * test(versioning): cover three more uncovered guards - `elm`: a widen where the new version sits below the lower bound, so the upper bound is kept rather than extended - `hex`: a widen on a complex range ending in `>=`, which the underlying semver implementation refuses and returns null for - `rust-release-channel`: a concrete current version paired with a channel name as the new version, which falls through to the new version unchanged Co-authored-by: Claude Opus 5 <michael.kriese+claude-code@mend.io> * refactor(versioning): drop two more guards that cannot be false - `composer`: `getNewValue` falls back to the new version whenever nothing else matched, so it never returns null and the recursive call in the or-range path always has a value to work with - `docker`: a version's prerelease is always a string, so once an empty one on either side is handled, the remaining pair is both non-empty and unequal Co-authored-by: Claude Opus 5 <michael.kriese+claude-code@mend.io> * test(config,datasource): cover two more uncovered guards - `config/validation`: `hostRules[].allowInternal` nested inside a `packageRules[]` entry, which reports a plain configuration error rather than a security one, because nested host rules are never applied - `datasource/docker`: a non-list manifest whose response carries no `docker-content-digest` header, so the digest falls back to the hash of the manifest body Co-authored-by: Claude Opus 5 <michael.kriese+claude-code@mend.io> * refactor(config,datasource): unwind three branches v8 could not count - `config/decrypt` and `datasource/docker/common` each picked a response with an `await` inside a ternary. v8 gives the branch that follows such a ternary a negative hit count, which the reporters read as uncovered even though both paths run. Spelling the choice as an if/else makes the count come out right; behaviour is unchanged. - `datasource/index` and `datasource/npm/npmrc` each ended an exhaustive chain with an `else if` whose implicit else v8 counts but nothing can reach: `registryStrategy` is one of three literals, and `npmrc` starts as an object and is only ever reassigned to one. Co-authored-by: Claude Opus 5 <michael.kriese+claude-code@mend.io> * test(workers/global): cover seven uncovered guards The config parsers rewrite legacy boolean spellings of `dryRun`, `requireConfig` and `platformCommit`, but nothing passed a value that was already current, so the fall-through of each chain went untaken. Cover it from both the CLI and the environment. Also cover a datasource env var that names no auth field, one whose value is undefined, a default config file that cannot be read, and the error `isLimitReached` throws when asked for a concurrent limit without a branch config. That last one had an ignore hint saying it should not happen; the error message documents the contract, so it is now tested and the hint is gone. Co-authored-by: Claude Opus 5 <michael.kriese+claude-code@mend.io> * refactor(workers/global): drop a guard that cannot be false `getConfig` in the additional-config-file parser returns early unless `RENOVATE_ADDITIONAL_CONFIG_FILE` is set, so by the time a parse error is being classified the variable is always present. Co-authored-by: Claude Opus 5 <michael.kriese+claude-code@mend.io> * refactor(workers/repository): drop a dead changelog file lookup The gitea, gitlab and forgejo changelog sources each declared `files` as an empty array and then guarded the only assignment to it with `if (!files.length)`, which is always true one line after the declaration. Collapse it to the filter itself. Co-authored-by: Claude Opus 5 <michael.kriese+claude-code@mend.io> * ci: ratchet the branch coverage threshold A full run on this branch reports 100% statements (49471/49471), 100% functions (7381/7381), 100% lines (48961/48961) and 99.73% branches (25690/25759), up from 99.53% before this branch's work. The threshold moves to 99.71, keeping the same rounding-down margin as before. Statements, functions and lines are already pinned at 100 and stay there. Co-authored-by: Claude Opus 5 <michael.kriese+claude-code@mend.io> * refactor(config,datasource): say why the ternary was unwound Both sites now carry a comment explaining that the if/else is deliberate: v8 gives the branch following an `await` inside a ternary a negative hit count, which the coverage reporters read as uncovered. `apiCheckResponse` also gets an explicit `HttpResponse<unknown>` type, which is what the two branches have in common and what `isECRMaxResultsResponse` already expects. Also fix a type error in the new config file spec: the `pathExists` spy needs the same `as never` cast the surrounding tests use. Co-authored-by: Claude Opus 5 <michael.kriese+claude-code@mend.io> * refactor(versioning/pep440): use a template literal in handleLowerBound The exclude-style return is the one line this branch rewrote in that function, so it now builds its string with a template literal instead of the `+` operator. Co-authored-by: Claude Opus 5 <michael.kriese+claude-code@mend.io> * test(workers/global): drop the cast from the limits throw test Calling the overload with a non-null assertion on the config argument says the same thing without retyping the whole function. Co-authored-by: Claude Opus 5 <michael.kriese+claude-code@mend.io> --------- Co-authored-by: Claude Opus 5 <michael.kriese+claude-code@mend.io>
415 lines
13 KiB
TypeScript
415 lines
13 KiB
TypeScript
import { isNumber } from '@sindresorhus/is';
|
|
import semver from 'semver';
|
|
import { parseRange } from 'semver-utils';
|
|
import { logger } from '../../../logger/index.ts';
|
|
import type { RangeStrategy } from '../../../types/versioning.ts';
|
|
import { regEx } from '../../../util/regex.ts';
|
|
import { api as npm } from '../npm/index.ts';
|
|
import type { NewValueConfig, VersioningApi } from '../types.ts';
|
|
|
|
export const id = 'composer';
|
|
export const displayName = 'Composer';
|
|
export const urls = [
|
|
'[Composer versions](https://getcomposer.org/doc/articles/versions.md)',
|
|
'[composer/semver package](https://packagist.org/packages/composer/semver)',
|
|
'[Tilde and caret constraints](https://madewithlove.be/tilde-and-caret-constraints/)',
|
|
'[Composer semver checker](https://semver.mwl.be)',
|
|
];
|
|
export const supportsRanges = true;
|
|
export const supportedRangeStrategies: RangeStrategy[] = [
|
|
'bump',
|
|
'widen',
|
|
'replace',
|
|
'update-lockfile',
|
|
];
|
|
|
|
function getVersionParts(input: string): [string, string] {
|
|
const versionParts = input.split('-');
|
|
if (versionParts.length === 1) {
|
|
return [input, ''];
|
|
}
|
|
|
|
return [versionParts[0], `-${versionParts[1]}`];
|
|
}
|
|
|
|
function padZeroes(input: string): string {
|
|
const [output, stability] = getVersionParts(input);
|
|
|
|
const sections = output.split('.');
|
|
while (sections.length < 3) {
|
|
sections.push('0');
|
|
}
|
|
return `${sections.join('.')}${stability}`;
|
|
}
|
|
|
|
function convertStabilityModifier(input: string): string {
|
|
// Handle stability modifiers.
|
|
const versionParts = input.split('@');
|
|
if (versionParts.length === 1) {
|
|
return input;
|
|
}
|
|
|
|
// 1.0@beta2 to 1.0-beta.2
|
|
const stability = versionParts[1].replace(
|
|
regEx(/(?:^|\s)(?<label>beta|alpha|rc)(?<num>[1-9][0-9]*)(?: |$)/gi),
|
|
'$<label>.$<num>',
|
|
);
|
|
|
|
// If there is a stability part, npm semver expects the version
|
|
// to be full
|
|
return `${padZeroes(versionParts[0])}-${stability}`;
|
|
}
|
|
|
|
function normalizeVersion(input: string): string {
|
|
let output = input;
|
|
// Strip leading + prefix (not a valid composer constraint operator)
|
|
output = output.replace(regEx(/^\+/), '');
|
|
output = output.replace(regEx(/(?<prefix>^|>|>=|\^|~)v/i), '$<prefix>');
|
|
return convertStabilityModifier(output);
|
|
}
|
|
|
|
/**
|
|
* @param versions Version list in any format, it recognizes the specific patch format x.x.x-pXX
|
|
* @param range Range in composer format
|
|
* @param minMode If true, it will calculate minSatisfyingVersion, if false, it calculates the maxSatisfyingVersion
|
|
* @returns min or max satisfyingVersion from the input
|
|
*/
|
|
function calculateSatisfyingVersionIntenal(
|
|
versions: string[],
|
|
range: string,
|
|
minMode: boolean,
|
|
): string | null {
|
|
// Because composer -p versions are considered stable, we have to remove the suffix for the npm.XXX functions.
|
|
const versionsMapped = versions.map((x) => {
|
|
return {
|
|
origianl: x,
|
|
cleaned: removeComposerSpecificPatchPart(x),
|
|
npmVariant: composer2npm(removeComposerSpecificPatchPart(x)[0]),
|
|
};
|
|
});
|
|
|
|
const npmVersions = versionsMapped.map((x) => x.npmVariant);
|
|
const npmVersion = minMode
|
|
? npm.minSatisfyingVersion(npmVersions, composer2npm(range))
|
|
: npm.getSatisfyingVersion(npmVersions, composer2npm(range));
|
|
|
|
if (!npmVersion) {
|
|
return null;
|
|
}
|
|
|
|
// After we find the npm versions, we select from them back in the mapping the possible patches.
|
|
const candidates = versionsMapped
|
|
.filter((x) => x.npmVariant === npmVersion)
|
|
.sort((a, b) => (minMode ? 1 : -1) * sortVersions(a.origianl, b.origianl));
|
|
|
|
return candidates[0].origianl;
|
|
}
|
|
|
|
/**
|
|
* @param intput Version in any format, it recognizes the specific patch format x.x.x-pXX
|
|
* @returns If input contains the specific patch, it returns the input with removed the patch and true, otherwise it retunrs the same string and false.
|
|
*/
|
|
function removeComposerSpecificPatchPart(input: string): [string, boolean] {
|
|
// the regex is based on the original from composer implementation https://github.com/composer/semver/blob/fa1ec24f0ab1efe642671ec15c51a3ab879f59bf/src/VersionParser.php#L137
|
|
const pattern = regEx(
|
|
/^v?\d+(?:\.\d+(?:\.\d+(?:\.\d+)?)?)?(?<suffix>-p[1-9]\d*)$/gi,
|
|
);
|
|
const match = pattern.exec(input);
|
|
|
|
return match
|
|
? [input.replace(match.groups!.suffix, ''), true]
|
|
: [input, false];
|
|
}
|
|
|
|
function composer2npm(input: string): string {
|
|
return input
|
|
.split(regEx(/\s*\|\|?\s*/g))
|
|
.map((part): string => {
|
|
const cleanInput = normalizeVersion(part);
|
|
if (npm.isVersion(cleanInput)) {
|
|
return cleanInput;
|
|
}
|
|
if (npm.isVersion(padZeroes(cleanInput))) {
|
|
return padZeroes(cleanInput);
|
|
}
|
|
const [versionId, stability] = getVersionParts(cleanInput);
|
|
let output = versionId;
|
|
|
|
// ~4 to ^4 and ~4.1 to ^4.1
|
|
output = output.replace(
|
|
regEx(/(?:^|\s)~(?<minVersion>[1-9][0-9]*(?:\.[0-9]*)?)(?: |$)/g),
|
|
'^$<minVersion>',
|
|
);
|
|
// ~0.4 to >=0.4 <1
|
|
output = output.replace(
|
|
regEx(/(?:^|\s)~(?<minVersion>0\.[1-9][0-9]*)(?: |$)/g),
|
|
'>=$<minVersion> <1',
|
|
);
|
|
|
|
// add extra digits to <8-DEV and <8.0-DEV
|
|
output = output
|
|
.replace(regEx(/^(?<version><\d+(?:\.\d+)?)$/g), '$<version>.0')
|
|
.replace(regEx(/^(?<version><\d+(?:\.\d+)?)$/g), '$<version>.0');
|
|
|
|
return output + stability;
|
|
})
|
|
.map((part) =>
|
|
part.replace(
|
|
regEx(/(?<letter>[a-z])(?<digit>[0-9])/gi),
|
|
'$<letter>.$<digit>',
|
|
),
|
|
)
|
|
.join(' || ');
|
|
}
|
|
|
|
function equals(a: string, b: string): boolean {
|
|
return npm.equals(composer2npm(a), composer2npm(b));
|
|
}
|
|
|
|
function getMajor(version: string): number | null {
|
|
const semverVersion = semver.coerce(composer2npm(version));
|
|
return semverVersion ? npm.getMajor(semverVersion) : null;
|
|
}
|
|
|
|
function getMinor(version: string): number | null {
|
|
const semverVersion = semver.coerce(composer2npm(version));
|
|
return semverVersion ? npm.getMinor(semverVersion) : null;
|
|
}
|
|
|
|
function getPatch(version: string): number | null {
|
|
const semverVersion = semver.coerce(composer2npm(version));
|
|
|
|
// This returns only the numbers without the optional `-pXX` patch version supported by composer. Fixing that would require a bigger
|
|
// refactoring, because the API supports only numbers.
|
|
return semverVersion ? npm.getPatch(semverVersion) : null;
|
|
}
|
|
|
|
function isGreaterThan(a: string, b: string): boolean {
|
|
return sortVersions(a, b) === 1;
|
|
}
|
|
|
|
function isLessThanRange(version: string, range: string): boolean {
|
|
return !!npm.isLessThanRange?.(composer2npm(version), composer2npm(range));
|
|
}
|
|
|
|
function isSingleVersion(input: string): boolean {
|
|
return !!input && npm.isSingleVersion(composer2npm(input));
|
|
}
|
|
|
|
function isStable(version: string): boolean {
|
|
if (version) {
|
|
// Composer considers patches `-pXX` as stable: https://github.com/composer/semver/blob/fa1ec24f0ab1efe642671ec15c51a3ab879f59bf/src/VersionParser.php#L568 but npm not.
|
|
// In order to be able to use the standard npm.isStable function, we remove the potential patch version for the check.
|
|
const [withoutPatch] = removeComposerSpecificPatchPart(version);
|
|
return npm.isStable(composer2npm(withoutPatch));
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
export function isValid(input: string): boolean {
|
|
return !!input && npm.isValid(composer2npm(input));
|
|
}
|
|
|
|
export function isVersion(input: string): boolean {
|
|
return !!input && npm.isVersion(composer2npm(input));
|
|
}
|
|
|
|
function matches(version: string, range: string): boolean {
|
|
return npm.matches(composer2npm(version), composer2npm(range));
|
|
}
|
|
|
|
function getSatisfyingVersion(
|
|
versions: string[],
|
|
range: string,
|
|
): string | null {
|
|
return calculateSatisfyingVersionIntenal(versions, range, false);
|
|
}
|
|
|
|
function minSatisfyingVersion(
|
|
versions: string[],
|
|
range: string,
|
|
): string | null {
|
|
return calculateSatisfyingVersionIntenal(versions, range, true);
|
|
}
|
|
|
|
function subset(subRange: string, superRange: string): boolean | undefined {
|
|
try {
|
|
return npm.subset!(composer2npm(subRange), composer2npm(superRange));
|
|
} catch (err) {
|
|
logger.trace({ err }, 'composer.subset error');
|
|
return false;
|
|
}
|
|
}
|
|
|
|
function intersects(subRange: string, superRange: string): boolean {
|
|
try {
|
|
return npm.intersects!(composer2npm(subRange), composer2npm(superRange));
|
|
} catch (err) {
|
|
logger.trace({ err }, 'composer.intersects error');
|
|
return false;
|
|
}
|
|
}
|
|
|
|
function getNewValue({
|
|
currentValue,
|
|
rangeStrategy,
|
|
currentVersion,
|
|
newVersion,
|
|
}: NewValueConfig): string | null {
|
|
if (rangeStrategy === 'update-lockfile') {
|
|
if (matches(newVersion, currentValue)) {
|
|
return currentValue;
|
|
}
|
|
return getNewValue({
|
|
currentValue,
|
|
rangeStrategy: 'replace',
|
|
currentVersion,
|
|
newVersion,
|
|
});
|
|
}
|
|
const currentMajor = currentVersion ? getMajor(currentVersion) : null;
|
|
const toMajor = getMajor(newVersion);
|
|
const toMinor = getMinor(newVersion);
|
|
let newValue: string | null = null;
|
|
if (isVersion(currentValue)) {
|
|
newValue = newVersion;
|
|
} else if (regEx(/^[~^](?:0\.[1-9][0-9]*)$/).test(currentValue)) {
|
|
const operator = currentValue.substring(0, 1);
|
|
// handle ~0.4 case first
|
|
if (toMajor === 0) {
|
|
// TODO: types (#22198)
|
|
newValue = `${operator}0.${toMinor!}`;
|
|
} else {
|
|
// TODO: types (#22198)
|
|
newValue = `${operator}${toMajor!}.0`;
|
|
}
|
|
} else if (regEx(/^[~^](?:[0-9]*)$/).test(currentValue)) {
|
|
// handle ~4 case
|
|
const operator = currentValue.substring(0, 1);
|
|
// TODO: types (#22198)
|
|
newValue = `${operator}${toMajor!}`;
|
|
} else if (
|
|
toMajor &&
|
|
regEx(/^[~^](?:[0-9]*(?:\.[0-9]*)?)$/).test(currentValue)
|
|
) {
|
|
const operator = currentValue.substring(0, 1);
|
|
if (rangeStrategy === 'bump') {
|
|
newValue = `${operator}${newVersion}`;
|
|
} else if ((isNumber(currentMajor) && toMajor > currentMajor) || !toMinor) {
|
|
// handle ~4.1 case
|
|
newValue = `${operator}${toMajor}.0`;
|
|
} else {
|
|
newValue = `${operator}${toMajor}.${toMinor}`;
|
|
}
|
|
} else if (
|
|
currentVersion &&
|
|
npm.isVersion(padZeroes(normalizeVersion(newVersion))) &&
|
|
npm.isValid(normalizeVersion(currentValue)) &&
|
|
composer2npm(currentValue) === normalizeVersion(currentValue)
|
|
) {
|
|
newValue = npm.getNewValue({
|
|
currentValue: normalizeVersion(currentValue),
|
|
rangeStrategy,
|
|
currentVersion: padZeroes(normalizeVersion(currentVersion)),
|
|
newVersion: padZeroes(normalizeVersion(newVersion)),
|
|
});
|
|
}
|
|
|
|
if (rangeStrategy === 'widen' && matches(newVersion, currentValue)) {
|
|
newValue = currentValue;
|
|
} else {
|
|
const hasOr = currentValue.includes(' || ');
|
|
if (hasOr || rangeStrategy === 'widen') {
|
|
const splitValues = currentValue.split('||');
|
|
const lastValue = splitValues.at(-1)!;
|
|
const replacementValue = getNewValue({
|
|
currentValue: lastValue.trim(),
|
|
rangeStrategy: 'replace',
|
|
currentVersion,
|
|
newVersion,
|
|
});
|
|
if (rangeStrategy === 'replace') {
|
|
newValue = replacementValue;
|
|
} else {
|
|
// the recursive call above always produces a value: `getNewValue`
|
|
// falls back to the new version when nothing else matched
|
|
const parsedRange = parseRange(replacementValue!);
|
|
const element = parsedRange.at(-1)!;
|
|
if (element.operator?.startsWith('<')) {
|
|
const splitCurrent = currentValue.split(element.operator);
|
|
splitCurrent.pop();
|
|
newValue = `${splitCurrent.join(element.operator)}${replacementValue}`;
|
|
} else {
|
|
newValue = `${currentValue} || ${replacementValue}`;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
if (!newValue) {
|
|
logger.warn(
|
|
{ currentValue, rangeStrategy, currentVersion, newVersion },
|
|
'Unsupported composer value',
|
|
);
|
|
newValue = newVersion;
|
|
}
|
|
if (currentValue.split('.')[0].includes('v')) {
|
|
newValue = newValue.replace(regEx(/(?<digit>[0-9])/), 'v$<digit>');
|
|
}
|
|
|
|
// Preserve original min-stability specifier
|
|
if (currentValue.includes('@')) {
|
|
newValue += `@${currentValue.split('@')[1]}`;
|
|
}
|
|
|
|
return newValue;
|
|
}
|
|
|
|
function sortVersions(a: string, b: string): number {
|
|
const [aWithoutPatch, aContainsPatch] = removeComposerSpecificPatchPart(a);
|
|
const [bWithoutPatch, bContainsPatch] = removeComposerSpecificPatchPart(b);
|
|
|
|
if (aContainsPatch === bContainsPatch) {
|
|
// If both [a and b] contain patch version or both [a and b] do not contain patch version, then npm comparison deliveres correct results
|
|
return npm.sortVersions(composer2npm(a), composer2npm(b));
|
|
}
|
|
if (npm.equals(composer2npm(aWithoutPatch), composer2npm(bWithoutPatch))) {
|
|
// If only one [a or b] contains patch version and the parts without patch versions are equal, then the version with patch is greater (this is the case where npm comparison fails)
|
|
return aContainsPatch ? 1 : -1;
|
|
}
|
|
// All other cases can be compared correctly by npm
|
|
return npm.sortVersions(composer2npm(a), composer2npm(b));
|
|
}
|
|
|
|
function isCompatible(version: string): boolean {
|
|
return isVersion(version);
|
|
}
|
|
|
|
function isBreaking(current: string, version: string): boolean {
|
|
return npm.isBreaking!(composer2npm(current), composer2npm(version));
|
|
}
|
|
|
|
export const api: VersioningApi = {
|
|
equals,
|
|
getMajor,
|
|
getMinor,
|
|
getPatch,
|
|
isBreaking,
|
|
isCompatible,
|
|
isGreaterThan,
|
|
isLessThanRange,
|
|
isSingleVersion,
|
|
isStable,
|
|
isValid,
|
|
isVersion,
|
|
matches,
|
|
getSatisfyingVersion,
|
|
minSatisfyingVersion,
|
|
getNewValue,
|
|
sortVersions,
|
|
subset,
|
|
intersects,
|
|
};
|
|
export default api;
|