diff --git a/npmextra.json b/npmextra.json index 59a55be..a3b9b0c 100644 --- a/npmextra.json +++ b/npmextra.json @@ -9,12 +9,20 @@ "githost": "code.foss.global", "gitscope": "push.rocks", "gitrepo": "smartversion", - "description": "handle semver with ease", + "description": "A library to handle semantic versioning with ease.", "npmPackagename": "@push.rocks/smartversion", - "license": "MIT" + "license": "MIT", + "keywords": [ + "semantic versioning", + "semver", + "version management", + "npm package", + "version comparison", + "typescript" + ] } }, - "tsdocs": { + "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" } } \ No newline at end of file diff --git a/package.json b/package.json index 6424e8a..805c732 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "@push.rocks/smartversion", "version": "3.0.5", "private": false, - "description": "handle semver with ease", + "description": "A library to handle semantic versioning with ease.", "main": "dist_ts/index.js", "typings": "dist_ts/index.d.ts", "type": "module", @@ -46,5 +46,13 @@ "bugs": { "url": "https://gitlab.com/push.rocks/smartversion/issues" }, - "homepage": "https://gitlab.com/push.rocks/smartversion#readme" -} + "homepage": "https://gitlab.com/push.rocks/smartversion#readme", + "keywords": [ + "semantic versioning", + "semver", + "version management", + "npm package", + "version comparison", + "typescript" + ] +} \ No newline at end of file diff --git a/readme.hints.md b/readme.hints.md new file mode 100644 index 0000000..0519ecb --- /dev/null +++ b/readme.hints.md @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/readme.md b/readme.md index 81d2468..83743a8 100644 --- a/readme.md +++ b/readme.md @@ -1,40 +1,132 @@ # @push.rocks/smartversion handle semver with ease -## Availabililty and Links -* [npmjs.org (npm package)](https://www.npmjs.com/package/@push.rocks/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 +To incorporate `@push.rocks/smartversion` into your project, run the following command using npm: -Status Category | Status Badge --- | -- -GitLab Pipelines | [![pipeline status](https://gitlab.com/pushrocks/smartversion/badges/master/pipeline.svg)](https://lossless.cloud) -GitLab Pipline Test Coverage | [![coverage report](https://gitlab.com/pushrocks/smartversion/badges/master/coverage.svg)](https://lossless.cloud) -npm | [![npm downloads per month](https://badgen.net/npm/dy/@push.rocks/smartversion)](https://lossless.cloud) -Snyk | [![Known Vulnerabilities](https://badgen.net/snyk/pushrocks/smartversion)](https://lossless.cloud) -TypeScript Support | [![TypeScript](https://badgen.net/badge/TypeScript/>=%203.x/blue?icon=typescript)](https://lossless.cloud) -node Support | [![node](https://img.shields.io/badge/node->=%2010.x.x-blue.svg)](https://nodejs.org/dist/latest-v10.x/docs/api/) -Code Style | [![Code Style](https://badgen.net/badge/style/prettier/purple)](https://lossless.cloud) -PackagePhobia (total standalone install weight) | [![PackagePhobia](https://badgen.net/packagephobia/install/@push.rocks/smartversion)](https://lossless.cloud) -PackagePhobia (package size on registry) | [![PackagePhobia](https://badgen.net/packagephobia/publish/@push.rocks/smartversion)](https://lossless.cloud) -BundlePhobia (total size when bundled) | [![BundlePhobia](https://badgen.net/bundlephobia/minzip/@push.rocks/smartversion)](https://lossless.cloud) -Platform support | [![Supports Windows 10](https://badgen.net/badge/supports%20Windows%2010/yes/green?icon=windows)](https://lossless.cloud) [![Supports Mac OS X](https://badgen.net/badge/supports%20Mac%20OS%20X/yes/green?icon=apple)](https://lossless.cloud) +```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. +### Importing the module -## Contribution +Begin by importing `SmartVersion` from the package: -We are always happy for code contributions. If you are not the code contributing type that is ok. Still, maintaining Open Source repositories takes considerable time and thought. If you like the quality of what we do and our modules are useful to you we would appreciate a little monthly contribution: You can [contribute one time](https://lossless.link/contribute-onetime) or [contribute monthly](https://lossless.link/contribute). :) +```typescript +import { SmartVersion } from '@push.rocks/smartversion'; +``` -For further information read the linked docs at the top of this readme. +### Creating a SmartVersion instance -> MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh) -| By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy) +You can instantiate `SmartVersion` with a semver string: -[![repo-footer](https://lossless.gitlab.io/publicrelations/repofooter.svg)](https://maintainedby.lossless.com) +```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.