Coder Social home page Coder Social logo

ionic-version's Introduction

ionic-version Build Status

Seamlessly shadows the behaviour of npm version.

npm-scripts hook (automatic method)

Setup

npm install ionic-version --save-dev
# or
yarn add ionic-version --dev

Hook into the "version" or "postversion" npm script in your app's package.json:

{
	"name": "myApp",
	"version": "0.0.1",
	"author": "Ionic Framework",
	"homepage": "http://ionicframework.com/",
	"private": true,
	"scripts": {
		"clean": "ionic-app-scripts clean",
		"build": "ionic-app-scripts build",
		"lint": "ionic-app-scripts lint",
		"ionic:build": "ionic-app-scripts build",
		"ionic:serve": "ionic-app-scripts serve",
+		"postversion": "ionic-version"
	},
	// ...
}

Usage

Before you publish a new build of your app, run npm version <newversion>.

ionic-version will then update your config.xml and therefore your platforms/ code during build. Depending on the script and options you choose, it can also automatically amend the version bump commit and update the Git tag created by npm version. This method should be useful in most cases. If you need more control, take a look at the CLI and options below.

CLI

Setup

npm install -g ionic-version
# or
yarn global add ionic-version

Example usage

cd myApp/
npm version patch
ionic-version

Options

-V, --version      output the version number
-a, --amend        Amend the previous commit. Also updates the latest Git tag to point to the amended commit. This is done automatically when ionic-version is run from the "version" or "postversion" npm script. Use "--never-amend" if you never want to amend.
--skip-tag         For use with "--amend", if you don't want to update Git tags.
-A, --never-amend  Never amend the previous commit.
-q, --quiet        Be quiet, only report errors.
-h, --help         output usage information

You can apply these options to the "version" or "postversion" script too. If for example you want to commit the changes made by ionic-version yourself, add the "--never-amend" option:

{
	// ...
	"scripts": {
		"postversion": "ionic-version --never-amend"
	},
	// ...
}

API

import version from "ionic-version";

async function doSomething() {
	const versionResult = await version({
		amend: true
		// ...
	});
}

// or

version({
	amend: true
	// ...
})
	.then(commitHash => {
		console.log(commitHash);
	})
	.catch(err => {
		console.error(err);
	});

Functions

version(program, projectPath)Promise.<(string|Error)>

Versions your app

Typedefs

Promise

Custom type definition for Promises

version(program, projectPath) ⇒ Promise.<(string|Error)>

Versions your app

Kind: global function
Returns: Promise.<(string|Error)> - A promise which resolves with the last commit hash

Param Type Description
program Object commander/CLI-style options, camelCased
projectPath string Path to your Ionic project

Promise

Custom type definition for Promises

Kind: global typedef
Properties

Name Type Description
result * See the implementing function for the resolve type and description
result Error Rejection error object

See also

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.