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 |
|
7 | When 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 |
|
9 | With `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 |
|
11 | When 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 |
|
15 |
|
16 |
|
17 |
|
18 | - [Installation](#installation)
|
19 | - [Usage](#usage)
|
20 | - [Debugging](#debugging)
|
21 | - [Node Support Policy](#node-support-policy)
|
22 | - [Contributing](#contributing)
|
23 |
|
24 |
|
25 |
|
26 | ## Installation
|
27 |
|
28 | To install the `shifted-semver-increment` tool for use in your project please run the following command:
|
29 |
|
30 | ```bash
|
31 | yarn add [--dev] shifted-semver-increment
|
32 | ```
|
33 |
|
34 | ## Usage
|
35 |
|
36 | ```javascript
|
37 | const shiftedSemver = require(`shifted-semver-increment`);
|
38 |
|
39 | // When using a version with the major version set to zero.
|
40 | shiftedSemver(`0.0.0`, `patch`); // `0.0.1`
|
41 | shiftedSemver(`0.0.0`, `minor`); // `0.0.1`
|
42 | shiftedSemver(`0.0.0`, `major`); // `0.1.0`
|
43 |
|
44 | // When using a version with the major version greater than zero.
|
45 | shiftedSemver(`1.0.0`, `patch`); // `1.0.1`
|
46 | shiftedSemver(`1.0.0`, `minor`); // `1.1.0`
|
47 | shiftedSemver(`1.0.0`, `major`); // `2.0.0`
|
48 | ```
|
49 |
|
50 | By 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
|
55 | const shiftedSemver = require(`shifted-semver-increment`);
|
56 |
|
57 | // When using version with the major version set to zero.
|
58 | shiftedSemver(`0.0.0`, `prerelease`, `beta`); // `0.0.1-beta.0`
|
59 | shiftedSemver(`0.0.0`, `prepatch`, `beta`); // `0.0.1-beta.0`
|
60 | shiftedSemver(`0.0.0`, `preminor`, `beta`); // `0.0.1-beta.0`
|
61 | shiftedSemver(`0.0.0`, `premajor`, `beta`); // `0.1.0-beta.0`
|
62 | shiftedSemver(`0.1.0-beta.0`, `prerelease`, `beta`); // `0.1.0-beta.1`
|
63 | shiftedSemver(`0.1.0-beta.0`, `prepatch`, `beta`); // `0.1.1-beta.0`
|
64 | shiftedSemver(`0.1.0-beta.0`, `preminor`, `beta`); // `0.1.1-beta.0`
|
65 | shiftedSemver(`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.
|
68 | shiftedSemver(`1.0.0`, `prerelease`, `beta`); // `1.0.1-beta.0`
|
69 | shiftedSemver(`1.0.0`, `prepatch`, `beta`); // `1.0.1-beta.0`
|
70 | shiftedSemver(`1.0.0`, `preminor`, `beta`); // `1.1.0-beta.`
|
71 | shiftedSemver(`1.0.0`, `premajor`, `beta`); // `2.0.0-beta.0`
|
72 | ```
|
73 |
|
74 | ## Debugging
|
75 |
|
76 | To 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 |
|
78 | To 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
|
81 | DEBUG=shifted-semver-increment [CONSUMING TOOL]
|
82 | ```
|
83 |
|
84 | On the Windows command line you may do:
|
85 |
|
86 | ```bash
|
87 | set DEBUG=shifted-semver-increment
|
88 | [CONSUMING TOOL]
|
89 | ```
|
90 |
|
91 | ## Node Support Policy
|
92 |
|
93 | We only support [Long-Term Support](https://github.com/nodejs/LTS) versions of Node.
|
94 |
|
95 | We 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 |
|
97 | It'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 |
|
99 | As 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 |
|
101 | We 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 |
|
103 | JavaScript 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 |
|
107 | Please 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.
|