Skip to content
/ vers Public

Update version of JS package and create changelog

License

Notifications You must be signed in to change notification settings

ink8bit/vers

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

vers

Rust

vers updates version in JavaScript projects.

In general, vers does the following:

  • updates package.json
  • updates package-lock.json (if exists)
  • creates CHANGELOG.md file
  • creates commit using formatting: Version bump: v0.1.0
  • creates an annotated git tag
  • and pushes changes

vers works only with git.

vers doesn't work in main branch by design, works only in feature branches.

How to use

You can use it as a binary or as a library.

Binary app

You should choose a version type: major, minor, or patch. And include changes:

vers minor --info "some changes"

Usage

USAGE:
    vers [FLAGS] [OPTIONS] <version_type>

ARGS:
    <version_type>    [possible values: major, minor, patch]

FLAGS:
    -h, --help         Prints help information
    -n, --no-commit    Prevents committing your changes
    -V, --version      Prints version information

OPTIONS:
    -i, --info <string>    Sets info value

Library

The crate is only available via git repo for now. You can include it using rev, tag or branch key. Read more in Cargo docs.

You should add vers crate to your Cargo.toml file:

[dependencies]
vers = { git = "https://github.com/ink8bit/vers", branch = "master" }

Public API

update

Updates CHANGELOG.md, package.json, package-lock.json (if exists), commits changes, creates tag and pushes changes to the remote. Returns created version value.

match vers::update("minor", "changes", false) {
    Ok(v) => println!("Updated version: {}", v),
    Err(e) => eprintln!("{}", e),
}

save_changes

Creates commit and tag. Returns created tag value.

match vers::save_changes("v1.2.3", "releaser", "some info") {
    Ok(v) => println!("Created tag: {}", v),
    Err(e) => eprintln!("{}", e),
}

push_changes

Pushes changes to the remote. Returns current git branch value.

match vers::push_changes() {
    Ok(v) => println!("Current git branch: {}", v),
    Err(e) => eprintln!("{}", e),
}

releaser

Returns your git user name and user email, or your GitHub handle if you set env var VERS_GITHUB_NAME.

let releaser = match vers::releaser() {
    Ok(value) => value,
    Err(e) => panic!("{}", e),
};

current_branch_name

Returns current git branch value.

let branch = match vers::current_branch_name() {
    Ok(value) => value,
    Err(e) => panic!("{}", e),
};

Changelog format

Every changelog entry has these contents:

## v0.1.0

### Date string in RFC 2822 format

**Released by:** username <user email>

**Changes:** your changes

List of commits in feature branch

Using github username

You can use your GitHub username in:

  • Released by: field in your CHANGELOG.md file
  • Tagged by: field in your tag
  • Released by: field in your commit message

You need to set env variable VERS_GITHUB_NAME. For example:

export VERS_GITHUB_NAME=username

If vers could not get value from env var VERS_GITHUB_NAME, your git user name and email will be used instead.