2020-09-09 09:01:18 -04:00
|
|
|
/**
|
|
|
|
* @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);
|
|
|
|
}
|
2021-07-21 19:36:52 -04:00
|
|
|
|
|
|
|
/** Creates the equivalent experimental version for a provided SemVer. */
|
2021-07-22 15:15:50 -04:00
|
|
|
export function createExperimentalSemver(version: string|semver.SemVer): semver.SemVer {
|
|
|
|
version = new semver.SemVer(version);
|
2021-07-21 19:36:52 -04:00
|
|
|
const experimentalVersion = new semver.SemVer(version.format());
|
|
|
|
experimentalVersion.major = 0;
|
|
|
|
experimentalVersion.minor = version.major * 100 + version.minor;
|
|
|
|
return new semver.SemVer(experimentalVersion.format());
|
|
|
|
}
|