chronver
The chronological versioner.
Install
$ npm i chronver
Requirements
@chronver/regex
is an evergreen module. 🌲 This module requires an Active LTS Node version (v12.0.0+).
Usage
Node.js
; increment: "change" version: "2030.04.03" version;// ^ Returns 2030.04.03.1 increment: "year" version: "2030.04.03" version;// ^ Returns 2031.04.03 increment: "month" version: "2030.04.03" version;// ^ Returns 2030.05.03 increment: "day" version: "2030.04.03" version;// ^ Returns 2030.04.04 coerce: "2030.4.3" version;// ^ Returns 2030.04.03 version;// ^ Returns the current date in ChronVer format
// Here is how a full response looksChronVer change: 0 day: 3 month: 4 raw: "2030.04.03" version: "2030.04.03" year: 2030
package.json:
This allows you to run npm run increment
and have your package.json
version incremented to ChronVer's spec. However if you want to have this happen automatically when committing to a repo, employ husky like so:
API
new chronver({ coerce?, increment?, parse?, version? })
ChronVer must be instantiated with the new
keyword.
coerce
Type: string
(optional)
- Given a string that represents a date,
coerce
will attempt to format it into a ChronVer object. - If supplied value is blank (""), a ChronVer object representing today's date will be returned.
increment
Type: string
(optional)
- Intended for use with the
version
parameter. - Available options:
change
: increments suppliedversion
...version by one.day
: increments suppliedversion
year by one.month
: increments suppliedversion
year by one.year
: increments suppliedversion
year by one.
- If supplied value is blank (""):
- If
version
parameter is not supplied along with anincrement
option: - If supplied value is in the past:
- A ChronVer object representing today's date will be returned.
parse
Type: string
| CVType
(optional)
- Given a string that represents a date (or a ChronVer object),
parse
will test the validity of it and return a formatted ChronVer object. - If supplied value is blank (""), a ChronVer object representing today's date will be returned.
version
- When used alone, behaves like
parse
.
CLI
__ / / ____/ / _______ _____ __________/ __/ _ \/ __/ _ \/ _ | |/ / -_/ __/\__/_//_/_/ \___/_//_|___/\__/_/ A JavaScript implementation of the https://chronver.org specificationCopyright © netop://ウエハ Usage: chronver [options] <version>Prints valid ChronVer versions Options:-c --coerce Coerce a string into ChronVer
Tests
You will need to first download this repo, cd
into it, and npm i
before proceeding further.
# Run all tests, sequentially $ npm test # Test dependencies for latest versions $ npm run test:dependencies # Lint "bin" and "lib" directories $ npm run test:typescript # Run this module through its paces # PLEASE run this so I can feel my time writing and troubleshooting these tests were worth it $ npm run test:assert
License
MIT © netop://ウエハ