version_ts

A simple tool for managing semantic versions of modules stored in version.ts (a TypeScript file that can be consumed via import).

Installation

deno install --allow-read=version.ts --allow-write=version.ts --allow-run=git https://deno.land/x/version_ts/main.ts

Usage

$ version_ts --help
Usage: version_ts [options] [major|minor|patch]

Options:
  -i, --increment <major|minor|patch>  Increments the specified version component
  -s, --set <version>                  Overwrites the existing version with the specified version
  -g, --get                            Prints the current version
  -t, --tag                            Adds a Git tag for the current version
  --version                            Prints the version of version_ts itself (not the current module!)
  -h, -?, --help                       Display usage information

Example

$ version_ts --set 0.1.0
Updated version from (none) to 0.1.0

This produces the follow version.ts file:

export const version = "0.1.0";

This can be consumed at compile/run time:

import version from "./version.ts"; // "0.1.0"

Now, if you want to tag your Git repository with the current version:

$ git add version.ts
$ git commit -m "Update version"
$ version_ts --tag      
Running command: git tag 0.1.0

Result:

$ git tag
0.1.0

More examples

$ version_ts patch
Updated version from 0.1.0 to 0.1.1

$ version_ts minor
Updated version from 0.1.1 to 0.2.0

$ version_ts major
Updated version from 0.2.0 to 1.0.0