@boostercloud/cli
Version:
CLI of the Booster Framework, the next level of abstraction for cloud-native applications
30 lines (29 loc) • 1.12 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
class Semver {
constructor(semverString) {
this.versionParts = semverString.split('.').map((v) => parseInt(v, 10));
if (this.versionParts.length !== 3) {
throw new Error(`Versions must follow semantic convention X.Y.Z | current version: ${semverString}.`);
}
}
equalsInBreakingSection(version) {
return this.versionParts[0] === version.versionParts[0];
}
equalsInFeatureSection(version) {
return this.versionParts[1] === version.versionParts[1];
}
equalsInFixSection(version) {
return this.versionParts[2] === version.versionParts[2];
}
equals(version) {
return (this.equalsInBreakingSection(version) && this.equalsInFeatureSection(version) && this.equalsInFixSection(version));
}
greaterInBreakingSectionThan(version) {
return this.versionParts[0] > version.versionParts[0];
}
greaterInFeatureSectionThan(version) {
return this.versionParts[1] > version.versionParts[1];
}
}
exports.default = Semver;