npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

chronver

v2020.6.18

Published

The chronologic versioner

Downloads

5

Readme

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

import chronver from "chronver";

new chronver({ increment: "change", version: "2030.04.03" }).version;
// ^ Returns 2030.04.03.1

new chronver({ increment: "year", version: "2030.04.03" }).version;
// ^ Returns 2031.04.03

new chronver({ increment: "month", version: "2030.04.03" }).version;
// ^ Returns 2030.05.03

new chronver({ increment: "day", version: "2030.04.03" }).version;
// ^ Returns 2030.04.04

new chronver({ coerce: "2030.4.3" }).version;
// ^ Returns 2030.04.03

new chronver().version;
// ^ Returns the current date in ChronVer format
// Here is how a full response looks
ChronVer {
  change: 0,
  day: 3,
  month: 4,
  raw: "2030.04.03",
  version: "2030.04.03",
  year: 2030
}

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. 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 :/"
    }
  }
}

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 supplied version...version by one.
    • day: increments supplied version year by one.
    • month: increments supplied version year by one.
    • year: increments supplied version year by one.
  • If supplied value is blank (""):
  • If version parameter is not supplied along with an increment 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 specification
Copyright © netop://ウエハ (Paul Anthony Webb)

Usage: chronver [options] <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.



Examples:
$ chronver --initialize
$ chronver --increment month 2030.03.03
$ chronver --increment package

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://ウエハ