UNPKG

6.37 kBMarkdownView Raw
1# shifted-semver-increment
2
3> Support _major version zero_ incrementing alongside existing `semver` package behavior.
4
5`shifted-semver-increment` supports a different incrementing behavior then the [semver](https://www.npmjs.com/package/semver) package when the `major` version, the first number in `major.minor.patch`, of a [semantic version](http://semver.org/) string, is zero.
6
7When using the standard `semver` package, a _major version zero_ is treated the same as a any other value for the major version. For example, incrementing a `minor` for `0.0.0` will increment the middle number by one, just as it would if the initial version had been `1.0.0`.
8
9With `shifted-semver-increment`, incrementing the `major` version will increment what is traditionally the `minor` number in the semantic version string, while incrementing the `minor` or `patch` version will increment the `patch` number in the semantic version string.
10
11When the major version is greater than zero, `shifted-semver-increment` will defer to the [`inc`](https://www.npmjs.com/package/semver#functions) function provided by the [semver](https://www.npmjs.com/package/semver) package.
12
13## Table of Contents
14<!-- START doctoc generated TOC please keep comment here to allow auto update -->
15<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
16
17
18- [Installation](#installation)
19- [Usage](#usage)
20- [Debugging](#debugging)
21- [Node Support Policy](#node-support-policy)
22- [Contributing](#contributing)
23
24<!-- END doctoc generated TOC please keep comment here to allow auto update -->
25
26## Installation
27
28To install the `shifted-semver-increment` tool for use in your project please run the following command:
29
30```bash
31yarn add [--dev] shifted-semver-increment
32```
33
34## Usage
35
36```javascript
37const shiftedSemver = require(`shifted-semver-increment`);
38
39// When using a version with the major version set to zero.
40shiftedSemver(`0.0.0`, `patch`); // `0.0.1`
41shiftedSemver(`0.0.0`, `minor`); // `0.0.1`
42shiftedSemver(`0.0.0`, `major`); // `0.1.0`
43
44// When using a version with the major version greater than zero.
45shiftedSemver(`1.0.0`, `patch`); // `1.0.1`
46shiftedSemver(`1.0.0`, `minor`); // `1.1.0`
47shiftedSemver(`1.0.0`, `major`); // `2.0.0`
48```
49
50By shifting the use of each number developers can continue to use semantic concepts such as releasing breaking changes in a `major` release, but remain in a pre-`1.0.0` release stage (The pre-release stage means the project does not have a stable, publicly consumable, API according to [Semantic Versioning 2.0.0](http://semver.org/)).
51
52`shifted-semver-increment` also supports [_Prerelease Identifiers_](https://www.npmjs.com/package/semver#prerelease-identifiers) for _major version zero_ releases.
53
54```javascript
55const shiftedSemver = require(`shifted-semver-increment`);
56
57// When using version with the major version set to zero.
58shiftedSemver(`0.0.0`, `prerelease`, `beta`); // `0.0.1-beta.0`
59shiftedSemver(`0.0.0`, `prepatch`, `beta`); // `0.0.1-beta.0`
60shiftedSemver(`0.0.0`, `preminor`, `beta`); // `0.0.1-beta.0`
61shiftedSemver(`0.0.0`, `premajor`, `beta`); // `0.1.0-beta.0`
62shiftedSemver(`0.1.0-beta.0`, `prerelease`, `beta`); // `0.1.0-beta.1`
63shiftedSemver(`0.1.0-beta.0`, `prepatch`, `beta`); // `0.1.1-beta.0`
64shiftedSemver(`0.1.0-beta.0`, `preminor`, `beta`); // `0.1.1-beta.0`
65shiftedSemver(`0.1.0-beta.0`, `premajor`, `beta`); // `0.2.0-beta.0`
66
67// When using a version with the major version greater than zero.
68shiftedSemver(`1.0.0`, `prerelease`, `beta`); // `1.0.1-beta.0`
69shiftedSemver(`1.0.0`, `prepatch`, `beta`); // `1.0.1-beta.0`
70shiftedSemver(`1.0.0`, `preminor`, `beta`); // `1.1.0-beta.`
71shiftedSemver(`1.0.0`, `premajor`, `beta`); // `2.0.0-beta.0`
72```
73
74## Debugging
75
76To assist users of `shifted-semver-increment` with debugging the behavior of this module we use the [debug](https://www.npmjs.com/package/debug) utility package to print information to the console. To enable debug message printing, the environment variable `DEBUG`, which is the variable used by the `debug` package, must be set to a value configured by the package containing the debug messages to be printed.
77
78To print debug messages on a unix system set the environment variable `DEBUG` with the name of this package prior to executing a tool that invokes this module:
79
80```bash
81DEBUG=shifted-semver-increment [CONSUMING TOOL]
82```
83
84On the Windows command line you may do:
85
86```bash
87set DEBUG=shifted-semver-increment
88[CONSUMING TOOL]
89```
90
91## Node Support Policy
92
93We only support [Long-Term Support](https://github.com/nodejs/LTS) versions of Node.
94
95We specifically limit our support to LTS versions of Node, not because this package won't work on other versions, but because we have a limited amount of time, and supporting LTS offers the greatest return on that investment.
96
97It's possible this package will work correctly on newer versions of Node. It may even be possible to use this package on older versions of Node, though that's more unlikely as we'll make every effort to take advantage of features available in the oldest LTS version we support.
98
99As each Node LTS version reaches its end-of-life we will remove that version from the `node` `engines` property of our package's `package.json` file. Removing a Node version is considered a breaking change and will entail the publishing of a new major version of this package. We will not accept any requests to support an end-of-life version of Node. Any merge requests or issues supporting an end-of-life version of Node will be closed.
100
101We will accept code that allows this package to run on newer, non-LTS, versions of Node. Furthermore, we will attempt to ensure our own changes work on the latest version of Node. To help in that commitment, our continuous integration setup runs against all LTS versions of Node in addition the most recent Node release; called _current_.
102
103JavaScript package managers should allow you to install this package with any version of Node, with, at most, a warning if your version of Node does not fall within the range specified by our `node` `engines` property. If you encounter issues installing this package, please report the issue to your package manager.
104
105## Contributing
106
107Please read our [contributing guide](https://gitlab.com/hyper-expanse/open-source/shifted-semver-increment/blob/master/CONTRIBUTING.md) to see how you may contribute to this project.