Show More
Commit Commit message Age Author Refs
r13:a9f928759f2c
Updated deps and README
0
r12:624a00571835
Updated README
0
r11:d42e9d8d5fb7
Incrementing version within a module should work now
0
r10:0de9e6bf26a1
Switched modules for accessing app root
0
r9:8213be868b9b
Added CLI option for updating package.json
0
r8:e0828ee76cba
Updated README
0
r7:a62d412191d5
Exposed functions to API
0
r6:7a54fdcf056d
Updated main file
0
r5:8d025479e5d8
Minor updates
0
r4:3b6024e9e9d8
Fixed issue with 3-digit year by silently failing
0
< 1 2 >

chronver

The chronological versioner

Install

$ npm i chronver

Usage

Node.js:

import chronver from "chronver";

chronver("2019.04.03").increment().version; // or
chronver("2019.04.03").increment("change").version;
// => 2019.04.03.1

chronver("2019.04.03").increment("year").version;
// => 2020.04.03

chronver("2019.04.03").increment("month").version;
// => 2019.05.03

chronver("2019.04.03").increment("day").version;
// => 2019.04.03

chronver("").coerce("2019.4.3").version;
// => 2019.04.03

chronver("").initialize().version;
// => The current date in ChronVer format

package.json:

{
  "scripts": {
    "increment": "chronver --increment package"
  }
}

This allows you to run npm run increment and have your package.json version incremented to ChronVer's spec automatically. However if you want to have this happen automatically when committing to a repo, employ husky like so:

{
  "husky": {
    "hooks": {
      "pre-commit": "npm run increment && git add -A :/"
    }
  }
}

Command-line interface:

$ chronver --help

ChronVer 2019.10.27.1

A JavaScript implementation of the https://chronver.org specification
Copyright © netop://ウエハ (Paul Anthony Webb)

Usage: chronver [options] <version> [<version> [...]]
Prints valid ChronVer versions

Options:
-c --coerce
        Coerce a string into ChronVer if possible, silently fail otherwise.

-? -h --help
        Show this help message.

-i --inc --increment [<level>]
        Increment a version by the specified level. Level can be one of: year,
        month, day, or change. Default level is "change".

        Only one version may be specified.

        The version returned will always default to the present. However,
        supplied versions with a future date will remain in the future.

        ex. Passing "1970.04.03 -i month" to ChronVer will return the present
        date but passing "3027.04.03 -i month" will return "3027.05.03".

--init --initialize
        Creates a ChronVer string, defaulting to the present.

ChronVer exits upon failure.

Versions

A "version" is described by the specification found at https://chronver.org.

Note

You may have to set your version to "0000.00.00" prior to initializing ChronVer. This will be fixed an done automatically in a future update.

License

MIT © netop://ウエハ