Compare commits

...

23 Commits

Author SHA1 Message Date
d152a5d684 update description 2024-05-29 14:17:06 +02:00
5f87891de0 update tsconfig 2024-04-14 18:32:47 +02:00
7a0de33b46 update tsconfig 2024-04-01 21:42:11 +02:00
267c8222ac update npmextra.json: githost 2024-04-01 20:00:03 +02:00
9f2d874260 update npmextra.json: githost 2024-03-30 21:49:03 +01:00
1fc47ffc85 3.0.5 2024-03-07 13:22:25 +01:00
de29ed1e5c fix(core): update 2024-03-07 13:22:24 +01:00
1431e439a0 3.0.4 2024-03-07 13:02:33 +01:00
907d655d11 fix(core): update 2024-03-07 13:02:33 +01:00
e9452c6b3c 3.0.3 2024-03-07 12:10:37 +01:00
004881ec9d fix(core): update 2024-03-07 12:10:36 +01:00
b295f3d7e3 3.0.2 2022-04-28 12:20:09 +02:00
c8438069d3 fix(core): update 2022-04-28 12:20:09 +02:00
af212b068d 3.0.1 2022-04-26 16:03:30 +02:00
ed87cdb101 fix(core): update 2022-04-26 16:03:30 +02:00
cb589f5863 3.0.0 2022-04-26 14:44:53 +02:00
fc41cb1403 BREAKING CHANGE(core): update 2022-04-26 14:44:53 +02:00
fdef084c6b 2.0.7 2021-04-26 07:16:27 +00:00
87dd7b6635 fix(core): update 2021-04-26 07:16:26 +00:00
2899972e5b 2.0.6 2021-04-26 03:44:42 +00:00
2a9d678a68 fix(core): update 2021-04-26 03:44:42 +00:00
4f984eda13 2.0.5 2021-04-25 08:52:39 +00:00
9d78a120a0 fix(core): update 2021-04-25 08:52:39 +00:00
19 changed files with 6214 additions and 1972 deletions

View File

@ -0,0 +1,66 @@
name: Default (not tags)
on:
push:
tags-ignore:
- '**'
env:
IMAGE: registry.gitlab.com/hosttoday/ht-docker-node:npmci
NPMCI_COMPUTED_REPOURL: https://${{gitea.repository_owner}}:${{secrets.GITEA_TOKEN}}@gitea.lossless.digital/${{gitea.repository}}.git
NPMCI_TOKEN_NPM: ${{secrets.NPMCI_TOKEN_NPM}}
NPMCI_TOKEN_NPM2: ${{secrets.NPMCI_TOKEN_NPM2}}
NPMCI_GIT_GITHUBTOKEN: ${{secrets.NPMCI_GIT_GITHUBTOKEN}}
NPMCI_URL_CLOUDLY: ${{secrets.NPMCI_URL_CLOUDLY}}
jobs:
security:
runs-on: ubuntu-latest
continue-on-error: true
container:
image: ${{ env.IMAGE }}
steps:
- uses: actions/checkout@v3
- name: Install pnpm and npmci
run: |
pnpm install -g pnpm
pnpm install -g @shipzone/npmci
- name: Run npm prepare
run: npmci npm prepare
- name: Audit production dependencies
run: |
npmci command npm config set registry https://registry.npmjs.org
npmci command pnpm audit --audit-level=high --prod
continue-on-error: true
- name: Audit development dependencies
run: |
npmci command npm config set registry https://registry.npmjs.org
npmci command pnpm audit --audit-level=high --dev
continue-on-error: true
test:
if: ${{ always() }}
needs: security
runs-on: ubuntu-latest
container:
image: ${{ env.IMAGE }}
steps:
- uses: actions/checkout@v3
- name: Test stable
run: |
npmci node install stable
npmci npm install
npmci npm test
- name: Test build
run: |
npmci node install stable
npmci npm install
npmci npm build

View File

@ -0,0 +1,124 @@
name: Default (tags)
on:
push:
tags:
- '*'
env:
IMAGE: registry.gitlab.com/hosttoday/ht-docker-node:npmci
NPMCI_COMPUTED_REPOURL: https://${{gitea.repository_owner}}:${{secrets.GITEA_TOKEN}}@gitea.lossless.digital/${{gitea.repository}}.git
NPMCI_TOKEN_NPM: ${{secrets.NPMCI_TOKEN_NPM}}
NPMCI_TOKEN_NPM2: ${{secrets.NPMCI_TOKEN_NPM2}}
NPMCI_GIT_GITHUBTOKEN: ${{secrets.NPMCI_GIT_GITHUBTOKEN}}
NPMCI_URL_CLOUDLY: ${{secrets.NPMCI_URL_CLOUDLY}}
jobs:
security:
runs-on: ubuntu-latest
continue-on-error: true
container:
image: ${{ env.IMAGE }}
steps:
- uses: actions/checkout@v3
- name: Prepare
run: |
pnpm install -g pnpm
pnpm install -g @shipzone/npmci
npmci npm prepare
- name: Audit production dependencies
run: |
npmci command npm config set registry https://registry.npmjs.org
npmci command pnpm audit --audit-level=high --prod
continue-on-error: true
- name: Audit development dependencies
run: |
npmci command npm config set registry https://registry.npmjs.org
npmci command pnpm audit --audit-level=high --dev
continue-on-error: true
test:
if: ${{ always() }}
needs: security
runs-on: ubuntu-latest
container:
image: ${{ env.IMAGE }}
steps:
- uses: actions/checkout@v3
- name: Prepare
run: |
pnpm install -g pnpm
pnpm install -g @shipzone/npmci
npmci npm prepare
- name: Test stable
run: |
npmci node install stable
npmci npm install
npmci npm test
- name: Test build
run: |
npmci node install stable
npmci npm install
npmci npm build
release:
needs: test
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
container:
image: ${{ env.IMAGE }}
steps:
- uses: actions/checkout@v3
- name: Prepare
run: |
pnpm install -g pnpm
pnpm install -g @shipzone/npmci
npmci npm prepare
- name: Release
run: |
npmci node install stable
npmci npm publish
metadata:
needs: test
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
container:
image: ${{ env.IMAGE }}
continue-on-error: true
steps:
- uses: actions/checkout@v3
- name: Prepare
run: |
pnpm install -g pnpm
pnpm install -g @shipzone/npmci
npmci npm prepare
- name: Code quality
run: |
npmci command npm install -g typescript
npmci npm install
- name: Trigger
run: npmci trigger
- name: Build docs and upload artifacts
run: |
npmci node install stable
npmci npm install
pnpm install -g @git.zone/tsdoc
npmci command tsdoc
continue-on-error: true

4
.gitignore vendored
View File

@ -15,8 +15,6 @@ node_modules/
# builds
dist/
dist_web/
dist_serve/
dist_ts_web/
dist_*/
# custom

View File

@ -1,119 +0,0 @@
# gitzone ci_default
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
cache:
paths:
- .npmci_cache/
key: "$CI_BUILD_STAGE"
stages:
- security
- test
- release
- metadata
# ====================
# security stage
# ====================
mirror:
stage: security
script:
- npmci git mirror
tags:
- docker
- notpriv
snyk:
stage: security
script:
- npmci npm prepare
- npmci command npm install -g snyk
- npmci command npm install --ignore-scripts
- npmci command snyk test
tags:
- docker
- notpriv
# ====================
# test stage
# ====================
testStable:
stage: test
script:
- npmci npm prepare
- npmci node install stable
- npmci npm install
- npmci npm test
coverage: /\d+.?\d+?\%\s*coverage/
tags:
- docker
- priv
testBuild:
stage: test
script:
- npmci npm prepare
- npmci node install stable
- npmci npm install
- npmci command npm run build
coverage: /\d+.?\d+?\%\s*coverage/
tags:
- docker
- notpriv
release:
stage: release
script:
- npmci node install stable
- npmci npm publish
only:
- tags
tags:
- docker
- notpriv
# ====================
# metadata stage
# ====================
codequality:
stage: metadata
allow_failure: true
script:
- npmci command npm install -g tslint typescript
- npmci npm install
- npmci command "tslint -c tslint.json ./ts/**/*.ts"
tags:
- docker
- priv
trigger:
stage: metadata
script:
- npmci trigger
only:
- tags
tags:
- docker
- notpriv
pages:
image: hosttoday/ht-docker-dbase:npmci
services:
- docker:stable-dind
stage: metadata
script:
- npmci command npm install -g @gitzone/tsdoc
- npmci npm prepare
- npmci npm install
- npmci command tsdoc
tags:
- docker
- notpriv
only:
- tags
artifacts:
expire_in: 1 week
paths:
- public
allow_failure: true

11
.vscode/launch.json vendored Normal file
View File

@ -0,0 +1,11 @@
{
"version": "0.2.0",
"configurations": [
{
"command": "npm test",
"name": "Run npm test",
"request": "launch",
"type": "node-terminal"
}
]
}

26
.vscode/settings.json vendored Normal file
View File

@ -0,0 +1,26 @@
{
"json.schemas": [
{
"fileMatch": ["/npmextra.json"],
"schema": {
"type": "object",
"properties": {
"npmci": {
"type": "object",
"description": "settings for npmci"
},
"gitzone": {
"type": "object",
"description": "settings for gitzone",
"properties": {
"projectType": {
"type": "string",
"enum": ["website", "element", "service", "npm", "wcc"]
}
}
}
}
}
}
]
}

View File

@ -4,13 +4,25 @@
"npmAccessLevel": "public"
},
"gitzone": {
"projectType": "npm",
"module": {
"githost": "gitlab.com",
"gitscope": "pushrocks",
"githost": "code.foss.global",
"gitscope": "push.rocks",
"gitrepo": "smartversion",
"shortDescription": "handle semver with easy",
"npmPackagename": "@pushrocks/smartversion",
"license": "MIT"
}
"description": "A library to handle semantic versioning with ease.",
"npmPackagename": "@push.rocks/smartversion",
"license": "MIT",
"keywords": [
"semantic versioning",
"semver",
"version management",
"npm package",
"version comparison",
"typescript"
]
}
},
"tsdoc": {
"legal": "\n## License and Legal Information\n\nThis repository contains open-source code that is licensed under the MIT License. A copy of the MIT License can be found in the [license](license) file within this repository. \n\n**Please note:** The MIT License does not grant permission to use the trade names, trademarks, service marks, or product names of the project, except as required for reasonable and customary use in describing the origin of the work and reproducing the content of the NOTICE file.\n\n### Trademarks\n\nThis project is owned and maintained by Task Venture Capital GmbH. The names and logos associated with Task Venture Capital GmbH and any related products or services are trademarks of Task Venture Capital GmbH and are not included within the scope of the MIT license granted herein. Use of these trademarks must comply with Task Venture Capital GmbH's Trademark Guidelines, and any usage must be approved in writing by Task Venture Capital GmbH.\n\n### Company Information\n\nTask Venture Capital GmbH \nRegistered at District court Bremen HRB 35230 HB, Germany\n\nFor any legal inquiries or if you require further information, please contact us via email at hello@task.vc.\n\nBy using this repository, you acknowledge that you have read this section, agree to comply with its terms, and understand that the licensing of the code does not imply endorsement by Task Venture Capital GmbH of any derivative works.\n"
}
}

1744
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -1,38 +1,58 @@
{
"name": "@pushrocks/smartversion",
"version": "2.0.4",
"name": "@push.rocks/smartversion",
"version": "3.0.5",
"private": false,
"description": "handle semver with easy",
"main": "dist/index.js",
"typings": "dist/index.d.ts",
"description": "A library to handle semantic versioning with ease.",
"main": "dist_ts/index.js",
"typings": "dist_ts/index.d.ts",
"type": "module",
"author": "Lossless GmbH",
"license": "MIT",
"scripts": {
"test": "(tstest test/)",
"build": "(tsbuild)"
"test": "(tstest test/ --web)",
"build": "(tsbuild --web)",
"buildDocs": "tsdoc"
},
"devDependencies": {
"@gitzone/tsbuild": "^2.1.17",
"@gitzone/tsrun": "^1.2.8",
"@gitzone/tstest": "^1.0.24",
"@pushrocks/tapbundle": "^3.0.13",
"@types/node": "^12.7.5",
"tslint": "^5.20.0",
"tslint-config-prettier": "^1.18.0"
"@git.zone/tsbuild": "^2.1.61",
"@git.zone/tsrun": "^1.2.32",
"@git.zone/tstest": "^1.0.88",
"@push.rocks/tapbundle": "^5.0.8",
"@types/node": "^20.11.25"
},
"dependencies": {
"@types/semver": "^6.0.2",
"semver": "^6.3.0"
"@types/semver": "^7.3.9",
"semver": "^7.3.5"
},
"files": [
"ts/*",
"ts_web/*",
"dist/*",
"dist_web/*",
"dist_ts_web/*",
"assets/*",
"ts/**/*",
"ts_web/**/*",
"dist/**/*",
"dist_*/**/*",
"dist_ts/**/*",
"dist_ts_web/**/*",
"assets/**/*",
"cli.js",
"npmextra.json",
"readme.md"
],
"browserslist": [
"last 1 chrome versions"
],
"repository": {
"type": "git",
"url": "https://code.foss.global/push.rocks/smartversion.git"
},
"bugs": {
"url": "https://gitlab.com/push.rocks/smartversion/issues"
},
"homepage": "https://code.foss.global/push.rocks/smartversion",
"keywords": [
"semantic versioning",
"semver",
"version management",
"npm package",
"version comparison",
"typescript"
]
}

5681
pnpm-lock.yaml generated Normal file

File diff suppressed because it is too large Load Diff

1
readme.hints.md Normal file
View File

@ -0,0 +1 @@

144
readme.md
View File

@ -1,28 +1,132 @@
# @pushrocks/smartversion
handle semver with easy
# @push.rocks/smartversion
handle semver with ease
## Availabililty and Links
* [npmjs.org (npm package)](https://www.npmjs.com/package/@pushrocks/smartversion)
* [gitlab.com (source)](https://gitlab.com/pushrocks/smartversion)
* [github.com (source mirror)](https://github.com/pushrocks/smartversion)
* [docs (typedoc)](https://pushrocks.gitlab.io/smartversion/)
## Install
## Status for master
[![build status](https://gitlab.com/pushrocks/smartversion/badges/master/build.svg)](https://gitlab.com/pushrocks/smartversion/commits/master)
[![coverage report](https://gitlab.com/pushrocks/smartversion/badges/master/coverage.svg)](https://gitlab.com/pushrocks/smartversion/commits/master)
[![npm downloads per month](https://img.shields.io/npm/dm/@pushrocks/smartversion.svg)](https://www.npmjs.com/package/@pushrocks/smartversion)
[![Known Vulnerabilities](https://snyk.io/test/npm/@pushrocks/smartversion/badge.svg)](https://snyk.io/test/npm/@pushrocks/smartversion)
[![TypeScript](https://img.shields.io/badge/TypeScript->=%203.x-blue.svg)](https://nodejs.org/dist/latest-v10.x/docs/api/)
[![node](https://img.shields.io/badge/node->=%2010.x.x-blue.svg)](https://nodejs.org/dist/latest-v10.x/docs/api/)
[![JavaScript Style Guide](https://img.shields.io/badge/code%20style-prettier-ff69b4.svg)](https://prettier.io/)
To incorporate `@push.rocks/smartversion` into your project, run the following command using npm:
```bash
npm install @push.rocks/smartversion --save
```
Or if you prefer using Yarn:
```bash
yarn add @push.rocks/smartversion
```
This will add it to your project's dependencies.
## Usage
Use TypeScript for best in class instellisense.
`@push.rocks/smartversion` offers a comprehensive suite of functionalities to easily manipulate and compare semantic versions (semver). The following documentation assumes that you are familiar with TypeScript and semantic versioning concepts.
For further information read the linked docs at the top of this readme.
### Importing the module
> MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh)
| By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy)
Begin by importing `SmartVersion` from the package:
[![repo-footer](https://lossless.gitlab.io/publicrelations/repofooter.svg)](https://maintainedby.lossless.com)
```typescript
import { SmartVersion } from '@push.rocks/smartversion';
```
### Creating a SmartVersion instance
You can instantiate `SmartVersion` with a semver string:
```typescript
const version = new SmartVersion('1.0.0');
console.log(version.versionString); // Outputs: '1.0.0'
```
Alternatively, if you have a fuzzy version string (e.g., `"^1.0.0"`, `"~1.2"`), you can use the static method `fromFuzzyString`:
```typescript
const fuzzyVersion = SmartVersion.fromFuzzyString('^1.0.0');
console.log(fuzzyVersion.versionString); // Outputs the minimum version satisfying the fuzzy string
```
### Accessing Parts of the Version
The major, minor, and patch components are accessible as properties:
```typescript
console.log(version.major); // Outputs: 1
console.log(version.minor); // Outputs: 0
console.log(version.patch); // Outputs: 0
```
### Comparing Versions
You can compare the instance to another `SmartVersion` instance or a semver string to determine if it's greater or lesser:
```typescript
const version1 = new SmartVersion('1.2.3');
const version2 = new SmartVersion('2.0.0');
console.log(version1.greaterThan(version2)); // Outputs: false
console.log(version1.lessThan(version2)); // Outputs: true
console.log(version1.greaterThanString('1.2.2')); // Outputs: true
console.log(version1.lessThanString('2.1.0')); // Outputs: true
```
### Getting a Best Match
For an array of available versions, to find the best match for the given version or range:
```typescript
const availableVersions = ['1.0.0', '1.2.0', '1.2.3', '2.0.0'];
console.log(version.getBestMatch(availableVersions)); // Outputs the best matching version
```
### Getting New Versions
You can also easily increment the version to get a new `SmartVersion` instance of the next major, minor, or patch version:
```typescript
const newPatchVersion = version.getNewPatchVersion();
console.log(newPatchVersion.versionString); // Outputs: '1.0.1'
const newMinorVersion = version.getNewMinorVersion();
console.log(newMinorVersion.versionString); // Outputs: '1.1.0'
const newMajorVersion = version.getNewMajorVersion();
console.log(newMajorVersion.versionString); // Outputs: '2.0.0'
```
### Dynamic Version Updates
For dynamic updates or operations based on conditions:
```typescript
const updateType = 'minor'; // Example condition
const updatedVersion = version.getNewVersion(updateType);
console.log(updatedVersion.versionString); // Outputs: '1.1.0'
```
The `SmartVersion` class and its methods offer a robust solution for managing versions in your projects, enabling you to parse, compare, and manipulate semantic versions programmatically with ease.
This tool is ideal for automated version management in continuous integration / continuous deployment (CI/CD) workflows, package publishing, or anywhere precise version control is needed.
For any updates, contributions, or issues, please visit the [GitHub repository](https://github.com/pushrocks/smartversion) or the [npm package page](https://www.npmjs.com/package/@push.rocks/smartversion).
> Note: This documentation aims to provide comprehensive examples and usage scenarios for `@push.rocks/smartversion`. However, the actual use cases might vary depending on the project context or development environment. It is always recommended to test and validate the functionality within your project setup.
## License and Legal Information
This repository contains open-source code that is licensed under the MIT License. A copy of the MIT License can be found in the [license](license) file within this repository.
**Please note:** The MIT License does not grant permission to use the trade names, trademarks, service marks, or product names of the project, except as required for reasonable and customary use in describing the origin of the work and reproducing the content of the NOTICE file.
### Trademarks
This project is owned and maintained by Task Venture Capital GmbH. The names and logos associated with Task Venture Capital GmbH and any related products or services are trademarks of Task Venture Capital GmbH and are not included within the scope of the MIT license granted herein. Use of these trademarks must comply with Task Venture Capital GmbH's Trademark Guidelines, and any usage must be approved in writing by Task Venture Capital GmbH.
### Company Information
Task Venture Capital GmbH
Registered at District court Bremen HRB 35230 HB, Germany
For any legal inquiries or if you require further information, please contact us via email at hello@task.vc.
By using this repository, you acknowledge that you have read this section, agree to comply with its terms, and understand that the licensing of the code does not imply endorsement by Task Venture Capital GmbH of any derivative works.

36
test/test.both.ts Normal file
View File

@ -0,0 +1,36 @@
import { expect, tap } from '@push.rocks/tapbundle';
import * as smartversion from '../ts/index.js';
tap.test('should create a valid SmartVersion', async () => {
const localSmartVersion = new smartversion.SmartVersion('3.2.1');
expect(localSmartVersion).toBeInstanceOf(smartversion.SmartVersion);
// tslint:disable-next-line:no-unused-expression
expect(localSmartVersion.greaterThanString('4.0.0')).toBeFalse();
// tslint:disable-next-line:no-unused-expression
expect(localSmartVersion.greaterThanString('3.0.0')).toBeTrue();
// tslint:disable-next-line:no-unused-expression
expect(localSmartVersion.lessThanString('v4.0.0')).toBeTrue();
// tslint:disable-next-line:no-unused-expression
expect(localSmartVersion.lessThanString('v3.0.0')).toBeFalse();
});
tap.test('should create a valid SmartVersion', async () => {
const localSmartVersion = smartversion.SmartVersion.fromFuzzyString('4');
expect(localSmartVersion).toBeInstanceOf(smartversion.SmartVersion);
console.log(localSmartVersion.versionString);
});
tap.test('should create a valid SmartVersion', async () => {
const localSmartVersion = smartversion.SmartVersion.fromFuzzyString('4.x');
const bestMatch = localSmartVersion.getBestMatch(['4.0.1', '4.7.5', '4.3.0']);
console.log(bestMatch);
expect(bestMatch).toEqual('4.7.5');
});
tap.test('should create a patch version', async () => {
const versInstance = smartversion.SmartVersion.fromFuzzyString('1.2.3');
const newVersion = versInstance.getNewPatchVersion();
console.log(newVersion.versionString);
})
export const runTestPromise = tap.start();

View File

@ -1,21 +0,0 @@
import { expect, tap } from '@pushrocks/tapbundle';
import * as smartversion from '../ts/index';
let localSmartVersion: smartversion.SmartVersion;
tap.test('should create a valid SmartVersion', async () => {
localSmartVersion = new smartversion.SmartVersion('3.2.1');
expect(localSmartVersion).to.be.instanceof(smartversion.SmartVersion);
});
tap.test('should correctly classify greater and less than', async () => {
// tslint:disable-next-line:no-unused-expression
expect(localSmartVersion.greaterThanString('4.0.0')).to.be.false;
// tslint:disable-next-line:no-unused-expression
expect(localSmartVersion.greaterThanString('3.0.0')).to.be.true;
// tslint:disable-next-line:no-unused-expression
expect(localSmartVersion.lessThanString('v4.0.0')).to.be.true;
// tslint:disable-next-line:no-unused-expression
expect(localSmartVersion.lessThanString('v3.0.0')).to.be.false;
});
tap.start();

8
ts/00_commitinfo_data.ts Normal file
View File

@ -0,0 +1,8 @@
/**
* autocreated commitinfo by @pushrocks/commitinfo
*/
export const commitinfo = {
name: '@push.rocks/smartversion',
version: '3.0.5',
description: 'handle semver with ease'
}

View File

@ -1,25 +1,19 @@
import * as plugins from './smartversion.plugins';
import { SemVer } from 'semver';
import * as plugins from './smartversion.plugins.js';
export class SmartVersion {
public 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 static fromFuzzyString(fuzzyString: string): SmartVersion {
return new SmartVersion(plugins.semver.minVersion(fuzzyString).version, fuzzyString);
}
public originalVersionString: string;
public semver: plugins.semver.SemVer;
public get versionString(): string {
return this.semver.version;
};
constructor(semVerStringArg: string) {
constructor(semVerStringArg: string, originalStringArg?: string) {
this.originalVersionString = originalStringArg;
this.semver = new plugins.semver.SemVer(semVerStringArg);
this.versionString = this.semver.version;
}
public get major() {
@ -41,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);
}
@ -52,7 +46,55 @@ 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);
}
/**
* tries to get the best match from a range of available versions
*/
public getBestMatch(availableVersions: string[]): string {
let bestMatchingVersion: string;
for (const versionArg of availableVersions) {
if (!plugins.semver.satisfies(versionArg, this.originalVersionString)) {
continue;
}
if(!bestMatchingVersion) {
bestMatchingVersion = versionArg;
} else {
if (plugins.semver.lt(bestMatchingVersion, versionArg)) {
bestMatchingVersion = versionArg;
}
}
}
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}.${0}`);
return newInstance;
}
public getNewMajorVersion() {
const newInstance = new SmartVersion(`${this.semver.major + 1}.${0}.${0}`);
return newInstance;
}
public getNewVersion(typeArg: 'patch' | 'minor' | 'major') {
switch (typeArg) {
case 'patch':
return this.getNewPatchVersion();
case 'minor':
return this.getNewMinorVersion();
case 'major':
return this.getNewMajorVersion();
default:
throw new Error('unknown new version type.');
}
}
}

View File

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

14
tsconfig.json Normal file
View File

@ -0,0 +1,14 @@
{
"compilerOptions": {
"experimentalDecorators": true,
"useDefineForClassFields": false,
"target": "ES2022",
"module": "NodeNext",
"moduleResolution": "NodeNext",
"esModuleInterop": true,
"verbatimModuleSyntax": true
},
"exclude": [
"dist_*/**/*.d.ts"
]
}

View File

@ -1,17 +0,0 @@
{
"extends": ["tslint:latest", "tslint-config-prettier"],
"rules": {
"semicolon": [true, "always"],
"no-console": false,
"ordered-imports": false,
"object-literal-sort-keys": false,
"member-ordering": {
"options":{
"order": [
"static-method"
]
}
}
},
"defaultSeverity": "warning"
}