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

@modea/modea-increment-version

v0.6.2

Published

Increments version and build numbers in specified files

Downloads

347

Readme

Modea Increment Version Library

A npm package that increments build and version numbers.

What it does

Increments version and build numbers in specified files.

Optionally it can also follow git flow on a bitbucket repo.

For example: you have just finished a new feature and pushed that onto your dev branch. If you run this script, it can create a new branch, increment build and version numbers and then PR that branch onto master and dev and merge those PR's if no conflicts arise.

Install

npm install @modea/modea-increment-version

Usage

Once installed create a file at the base of your repo with the file name .incrementrc

In that file enter a valid json list of files you want changed and where, and optionally git information if you want the script to push to git

You can then run

increment [major | minor | patch | build]

Where major increments the first version number, minor the second, and patch the third

so

increment -t patch

on version 1.9.3 build 27 would increment to 1.9.4 and 28

increment -t build

on version 1.9.3 build 27 would increment to 1.9.3 and 28

File Object:

{
 "colloquialName": "the colloquial name for this file",
 "path": "path from repo root of the file you want changed",
 "changes": [
   {
     "type": "wether this is a [build] number or [version] code",
     "startIdentifier": "the text right before the build or version code that uniquely identifies it",
     "endIdentifier": "the text right after"
   }
 ]
}

Git Object

{
  "branchName": "the name of the branch you want to push the changes to. You can include version and build numbers in this by writting {{fileColloquialName.[version | build]}}",
  "pr": {
    "createUrl": "url to curl to for creating a PR",
    "mergeUrl": "url to curl to for merging a PR",
    "branches": A list of branches you want to PR onto [
      {
        "name": "branch name",
        "mergeStrategy": "which merge strategy to use for merging the PR"
      },
    ]
  },
  "user": {
    "name": "git username to use in curl request",
    "password": "git password to use in curl request"
  }}

Ticket Prefix

Optionally if you want the increment script to add ticket id's since last increment triggered sync merge from master onto development you can include the ticket prefix attribute to the json object This prefix is the part before the dash in your jira ticket id's

ticketPrefix: 'BH23'

Example

Sample .incrementrc file for changing version and build number in build.gradle for android and version and build number in info.plist for ios

{
  "files": [
    {
      "colloquialName": "android",
      "path": "android/app/build.gradle",
      "changes": [
        {
          "type": "version",
          "startIdentifier": "versionName '",
          "endIdentifier": "'\n"
        },
        {
          "type": "build",
          "startIdentifier": "versionCode ",
          "endIdentifier": "\n"
        }
      ]
    },
    {
      "colloquialName": "ios",
      "path": "ios/App/App.xcodeproj/project.pbxproj",
      "changes": [
        {
          "type": "version",
          "startIdentifier": "RELEASE_MARKETING_VERSION = ",
          "endIdentifier": ";"
        },
        {
          "type": "build",
          "startIdentifier": "RELEASE_PROJECT_VERSION = ",
          "endIdentifier": ";"
        },
        {
          "type": "version",
          "startIdentifier": "DEBUG_MARKETING_VERSION = ",
          "endIdentifier": ";"
        },
        {
          "type": "build",
          "startIdentifier": "DEBUG_PROJECT_VERSION = ",
          "endIdentifier": ";"
        }
      ]
    },
    {
      "colloquialName": "package.json",
      "path": "package.json",
      "changes": [
        {
          "type": "version",
          "startIdentifier": "\"version\": \"",
          "endIdentifier": "\","
        }
      ]
    }
  ],
  "git": {
    "branchName": "release/v{{ios.version}}",
    "pr": {
      "branches": [
        {
          "name": "development",
          "mergeStrategy": "squash"
        },
        {
          "name": "master",
          "mergeStrategy": "squash"
        }
      ]
    },
    "packageLocation": "/usr/local/lib/node_modules/"
  },
  "ticketPrefix": "BH23"
}


What the build.gradle file looks like:

...
        minSdkVersion 21
        targetSdkVersion 29
        versionCode 1568
        versionName '10.4.3'
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
...

What the info.plist file looks like:

...
	<string>APPL</string>
	<key>CFBundleShortVersionString</key>
	<string>1.9.3</string>
	<key>CFBundleURLTypes</key>
...
	</array>
	<key>CFBundleVersion</key>
	<string>27</string>
	<key>FIREBASE_ANALYTICS_COLLECTION_ENABLED</key>
...

bitbucket-pipelines.yml

  custom:
    increment-patch-version:
      - step:
          image: node:10
          script:
            - increment patch
    increment-minor-version:
      - step:
          image: node:10
          script:
            - increment minor
    increment-major-version:
      - step:
          image: node:10
          script:
            - increment major

Future Work

  • Command line options for
    • path to config file
    • changing only specified files out of the ones in the config file
    • turning git on or off
  • git changes
    • Use with github ci as well as bitbucket pipeline
    • custom commit messages
    • tagging support
    • just pushing straight back to specified branch (no PR's)