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

bash-semver

v1.2.0

Published

Simple semantic version increment tool, a fork of fmahnke/shell-semver

Downloads

2

Readme

shellcheck

semver.bash is a loose implementation of semantic versioning that suits a particular need and may not strictly adhere to the specification described at https://semver.org/spec/v2.0.0.html.

This code lives at https://github.com/unforswearing/bash-semver

Installation

Clone this repository and run semver.bash directly:

$ git clone https://github.com/unforswearing/bash_semver.git
Cloning into 'bash_semver'...
remote: Enumerating objects: 86, done.
remote: Counting objects: 100% (86/86), done.
remote: Compressing objects: 100% (60/60), done.
remote: Total 86 (delta 40), reused 65 (delta 22), pack-reused 0
Unpacking objects: 100% (86/86), done.

$ cd bash_semver
$ bash bash_semver --help
usage: semver.bash [ -M | -m | -p | -s | -d ] version
use option --help for full help text.

Usage

# General options for semver.bash
semver.bash [option [ -M | -m | -p | -s | -d <metadata> ]] version

View help by running semver.bash --help

Options

  • Both short and long options can be used with semver.bash.
  • Two arguments are required for all options execpt -d | --metadata.
    • If you are adding metadata to your version with option -d you must include the metadata string immediately after the option flag.
# Metadata must immediately follow the -d or --metadata flag
semver.bash -d <metadata> version
  • You can not use more than one flag at a time.
    • This means you will not be able to use semver.bash to make multiple updates with a single execution.
# Bad Code
# This command has multiple flags and will not work
semver.bash -M -m 1.2.9

# Good Code
# Instead, use the following code to update the Major and Minor version
semver.bash -M 1.2.9 | semver.bash -m "$(cat -)"

Major

option flags: -M, --major

Increment major version.

# semver.bash --major 1.0.0
semver.bash -M 1.0.0

Output: 2.0.0

Minor

option flags: -m, --minor

Increment minor version.

# semver.bash --minor 2.0.0
semver.bash -m 2.0.0

Output: 2.1.0

Patch

option flags: -p, --patch

Increment "patch" version.

# semver.bash --patch 2.1.0
semver.bash -p 2.1.0

Output: 2.1.1

Subpatch

option flags: -s, --subpatch

Increment "subpatch" version.

# semver.bash --subpatch 2.1.1
semver.bash -s 2.1.1

Output: 2.1.1-a

Adding or updating a subpatch

Option -s is append only. when passing a version to without a so-called "subpatch", option -s will append "a" as the subpatch to the version as "version-a". If the version already has a subpatch that is in the format -[aA-zZ], the subpatch will be incrmented, eg: version 1.5.2-r will increment to 1.5.2-s. Incrementation of single letters works through letter z.

Subpatches and metadata

If the version contains metadata (set with option -d), the subpatch will be appended to the version after the metadata. For example, version 1.5.2-r-dev-1.5.3 will be updated to 1.5.2-r-dev-1.5.3-a.

Metadata

option flags: -d, --metadata

Add metadata to the version.

# semver.bash --metadata "dev-2.1.2" "2.1.1-a"
semver.bash -d "dev-2.1.2" "2.1.1-a"

Output: 2.1.1-dev-2.1.2

Note: Metadata will replace the subpatch in your version. For example:

semver.bash --metadata "beta-1.5.3" 1.5.2-r

Output: 1.5.2-beta-1.5.3