Move semver into the utils directory rather than as a set of utils specifically for release tooling. While the utils are only currently used in the release tooling, they are not providing a release specific utility and can be used by any subtool of ng-dev. PR Close #42917
28 lines
990 B
TypeScript
28 lines
990 B
TypeScript
/**
|
|
* @license
|
|
* Copyright Google LLC All Rights Reserved.
|
|
*
|
|
* Use of this source code is governed by an MIT-style license that can be
|
|
* found in the LICENSE file at https://angular.io/license
|
|
*/
|
|
|
|
import * as semver from 'semver';
|
|
|
|
/**
|
|
* Increments a specified SemVer version. Compared to the original increment in SemVer,
|
|
* the version is cloned to not modify the original version instance.
|
|
*/
|
|
export function semverInc(
|
|
version: semver.SemVer, release: semver.ReleaseType, identifier?: string) {
|
|
const clone = new semver.SemVer(version.version);
|
|
return clone.inc(release, identifier);
|
|
}
|
|
|
|
/** Creates the equivalent experimental version for a provided SemVer. */
|
|
export function createExperimentalSemver(version: semver.SemVer): semver.SemVer {
|
|
const experimentalVersion = new semver.SemVer(version.format());
|
|
experimentalVersion.major = 0;
|
|
experimentalVersion.minor = version.major * 100 + version.minor;
|
|
return new semver.SemVer(experimentalVersion.format());
|
|
}
|