BREAKING CHANGE(core): update

This commit is contained in:
2022-04-26 14:44:53 +02:00
parent fdef084c6b
commit fc41cb1403
5 changed files with 14592 additions and 8857 deletions

View File

@ -1,29 +1,19 @@
import * as plugins from './smartversion.plugins';
import * as plugins from './smartversion.plugins.js';
export class SmartVersion {
public static fromFuzzyString(fuzzyString): SmartVersion {
public static fromFuzzyString(fuzzyString: string): SmartVersion {
return new SmartVersion(plugins.semver.minVersion(fuzzyString).version, fuzzyString);
}
public originalVersionString: string;
public semver: plugins.semver.SemVer;
public versionString: string;
public update = {
patch: () => {
this.semver.patch = this.semver.patch + 1;
},
minor: () => {
this.semver.minor = this.semver.minor + 1;
},
major: () => {
this.semver.major = this.semver.major + 1;
},
public get versionString(): string {
return this.semver.version;
};
constructor(semVerStringArg: string, originalStringArg?: string) {
this.originalVersionString = originalStringArg;
this.semver = new plugins.semver.SemVer(semVerStringArg);
this.versionString = this.semver.version;
}
public get major() {
@ -45,7 +35,7 @@ export class SmartVersion {
/**
* compares the version of this against a string
*/
public greaterThanString(versionStringArg) {
public greaterThanString(versionStringArg: string) {
return plugins.semver.gt(this.versionString, versionStringArg);
}
@ -56,7 +46,7 @@ export class SmartVersion {
/**
* compares the version of this against a string
*/
public lessThanString(versionStringArg) {
public lessThanString(versionStringArg: string) {
return plugins.semver.lt(this.versionString, versionStringArg);
}
@ -79,4 +69,19 @@ export class SmartVersion {
}
return bestMatchingVersion;
}
public getNewPatchVersion() {
const newInstance = new SmartVersion(`${this.semver.major}.${this.semver.minor}.${this.semver.patch + 1}`);
return newInstance;
}
public getNewMinorVersion() {
const newInstance = new SmartVersion(`${this.semver.major}.${this.semver.minor + 1}.${this.semver.patch}`);
return newInstance;
}
public getNewMajorVersion() {
const newInstance = new SmartVersion(`${this.semver.major + 1}.${this.semver.minor}.${this.semver.patch}`);
return newInstance;
}
}

View File

@ -1,3 +1,3 @@
import * as semver from 'semver';
import semver from 'semver';
export { semver };