https://github.com/stovmascript/ionic-version
:1234: Version your Ionic app in a `npm version` fashion.
https://github.com/stovmascript/ionic-version
ionic npm-version semantic-versioning semver
Last synced: 4 months ago
JSON representation
:1234: Version your Ionic app in a `npm version` fashion.
- Host: GitHub
- URL: https://github.com/stovmascript/ionic-version
- Owner: stovmascript
- License: mit
- Created: 2017-09-26T20:32:08.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2024-09-11T23:19:49.000Z (9 months ago)
- Last Synced: 2024-09-28T19:42:09.362Z (8 months ago)
- Topics: ionic, npm-version, semantic-versioning, semver
- Language: JavaScript
- Homepage:
- Size: 621 KB
- Stars: 3
- Watchers: 3
- Forks: 3
- Open Issues: 26
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ionic-version [](https://travis-ci.org/stovmascript/ionic-version)
Seamlessly shadows the behaviour of [`npm version`](https://docs.npmjs.com/cli/version).
## npm-scripts hook (automatic method)
### Setup
```bash
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:
```diff
{
"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 `.
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
```bash
npm install -g ionic-version
# or
yarn global add ionic-version
```### Example usage
```bash
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 informationYou 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:
```javascript
{
// ...
"scripts": {
"postversion": "ionic-version --never-amend"
},
// ...
}
```## API
```javascript
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
* [npm-version](https://docs.npmjs.com/cli/version)
* [Semantic Versioning (semver)](http://semver.org/)
* [react-native-version](https://github.com/stovmascript/react-native-version)