Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

appversion

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

appversion - npm Package Compare versions

Comparing version 1.1.0 to 1.2.0

appversion.js

7

appversion.default.json

@@ -17,6 +17,5 @@ {

"commit": null,
"json": [
"package.json",
"bower.json"
]
"appversion": "1.2.0",
"json": [],
"ignore": []
}
{
"version": {
"major": 1,
"minor": 1,
"minor": 2,
"patch": 0

@@ -12,11 +12,10 @@ },

"build": {
"date": "2015.11.13",
"number": 5,
"total": 16
"date": null,
"number": 0,
"total": 0
},
"commit": null,
"json": [
"package.json",
"bower.json"
]
"json": [],
"ignore": [],
"appversion": "1.2.0"
}
{
"name": "appversion",
"version": "1.1.0",
"description": "A module for keep track the version, build and commit of your javascript application.",
"main": "index.js",
"version": "1.2.0",
"description": "An extension of npm version, useful for keep track of the version, build and commit of your javascript application.",
"main": "appversion.js",
"bin": {
"apv": "cli.js"
"apv": "apv.js"
},
"scripts": {
"build:cli": "apv update build && babel es6/cli.es6.js --watch --out-file cli.js",
"build:index": "apv update build && babel es6/index.es6.js --watch --out-file index.js",
"pretest": "standard test && standard appversion.js && standard apv.js",
"test": "node test || true"

@@ -33,7 +32,11 @@ },

"devDependencies": {
"standard": "^6.0.7",
"tape": "^4.2.0"
},
"dependencies": {
"app-root-path": "^1.0.0",
"commander": "^2.9.0",
"type-check": "^0.3.2",
"walk": "^2.3.9"
}
}

@@ -1,10 +0,10 @@

# appversion
# AppVersion
[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat)](http://standardjs.com/)
**appversion** is a **cli tool** for keep track the *version*, *build* and *commit* of your javascript application.
Project built following [semver](http://semver.org/) guidelines.
**AppVersion** is intended as an extension of *npm version* and is a **cli tool** for keep track the *version*, *build*, *status* and *commit* of your javascript application.
The project is built following [semver](http://semver.org/) guidelines.
Usually a project has different configuration/package-manager files, such as *package.json* and/or *bower.json*, and can be really tedious update the project number in every file.
Here comes to help appversion, an easy to use command line tool who updates all the files for you.
In addition appversion keeps track of the build date and number.
Here comes to help AppVersion, an easy to use command line tool who updates all the files for you.
In addition AppVersion keeps track of the build date and number.

@@ -29,23 +29,29 @@ The tool creates a json file named ```appversion.json``` in the root of your project with the following structure:

"commit": null,
"json": [
"package.json",
"bower.json"
]
"appversion": "x.y.z",
"json": [],
"ignore": []
}
```
As you can see, the version is divided in ```major```, ```minor``` and ```patch```, the build is divided in ```date```, ```number``` and ```total```, in addition, there's the ```status``` field, who can assume ```stable|rc|beta|alpha``` value.
The last field, ```json```, is the list of the *json files* who appversion must update when you change the version number, is not available via the import.
As you can see, the version is divided in ```major```, ```minor``` and ```patch```, the build is divided in ```date```, ```number``` and ```total```, in addition, there's the status, who is divided in ```stage``` field, who can assume ```stable|rc|beta|alpha``` (the first letter can be Uppercase) value and ```number```.
The ```appversion``` field is used by AppVersion for check if the json is at the latest version.
The last two fields are, ```json```, is the list of the *json files* who appversion must update when you change the version number, and ```ignore```, that is the list of the *folders* that AppVersion must ignore.
The code is written in javascript es6 and compiled in es5 via [babel.io](https://babeljs.io/).
**Needs Node.js >= 4.0.0**
## Install
Install the tool globally:
```npm install appversion -g```
```
npm install appversion -g
```
If you want to access the ```appversion.json``` inside your application, install the module also locally:
```npm install appversion```
```
npm install appversion --save
```
## Usage
### CLI:
```$ apv <cmd> <args>```
```
$ apv <cmd> <args>
```

@@ -62,54 +68,35 @@ Commands list:

| |
| version | "x.y.z" | Sets a specific version number. |
| set-version | x.y.z | Sets a specific version number. |
| |
| status | "stable" | Set the status to stable. |
| | "rc" | Set the status to rc. |
| | "beta" | Set the status to beta. |
| | "alpha" | Set the status to alpha. |
| set-status | stable | Set the status to stable. |
| | rc | Set the status to rc. |
| | beta | Set the status to beta. |
| | alpha | Set the status to alpha. |
| |
| init | | Generates the appversion.json file.|
| |
| help | | Prints the commnds list. |
| help | | Prints the commands list. |
Usage example:
```$ apv update minor```
Some usage examples:
```
$ apv update minor
$ apv set-version 1.3.2
$ apv set-status rc.2
```
By default appversion tries to update all the json file you put in appversion.json
by searching recursively for these files starting from the current working directory.
If you want that appversion ignores some folder (it automatically excludes `node_modules` and `bower_component`) just add the ignore argument in this way:
`ignore="somefolder"`
If you want to ignore more than one folder just use `|`.
`ignore="folder1|folder2"`
By default, AppVersion updates the *"version"* field in the `package.json` and `bower.json` files; if you want to update the *"version"* field in more json files, just add the file name inside *appversion.json* in the json array field.
| **cmd** | **args** | **args**
|:-------:|:---------:|:------------------------------------:|
| update | major | ignore="somefolder" |
| | minor | |
| | patch | |
| |
| version | "x.y.z" | ignore="somefolder" |
AppVersion searchs recursively inside all the subfolders of your project for json files, by default it ignores `node_modules`, `bower_components` and `.git` folders; if you want to ignore more folders just add the folder name inside *appversion.json* in the ignore array field.
If you want that AppVersion *ignores all the subfolders* in your project, just put `"*"` inside the ignore array.
Full example:
`apv version "1.1.0" ignore="folder1|folder2"`
If you want to set the stage number (which is setted by default to 0) you can easily do:
| **cmd** | **args** | **description**
|:-------:|:-----------:|:-------------------------------------:|
| status | "stable.1" | Set the status to stable1. |
| | "rc.2" | Set the status to rc2. |
| | "beta.4" | Set the status to beta4. |
| | "alpha.0" | Set the status to alpha0. |
If you don't set any number appversion sets the stage number to zero.
### In app:
| Function | |
|---------------------|-------|
| getAppVersion() | async |
| getAppVersionSync() | sync |
| compose() | async |
| composeSync() | sync |
| Function | |
|--------------------------------------------------------|-------|
| <a href="#getAppVersion">getAppVersion()</a> | async |
| <a href="#getAppVersionSync">getAppVersionSync()</a> | sync |
| <a href="#composePattern">composePattern()</a> | async |
| <a href="#composePatternSync">composePatternSync()</a> | sync |
<a name="getAppVersion"></a>
#### getAppVersion(callback)

@@ -119,2 +106,3 @@ Returns the content of appversion.json as a object.

<a name="getAppVersionSync"></a>
#### getAppVersionSync()

@@ -124,2 +112,3 @@ Returns the content of appversion.json as a object.

<a name="composePattern"></a>
#### composePattern(pattern, callback)

@@ -131,3 +120,3 @@ Return a string with the version following the pattern you passed as a input.

|:-----------:|:----------------:|
| **M** | version.major |
| **M** | version.major |
| **m** | version.minor |

@@ -147,2 +136,3 @@ | **p** | version.patch |

<a name="composePatternSync"></a>
#### composePatternSync(pattern)

@@ -180,3 +170,3 @@ Return a string with the version following the pattern you passed as a input.

getAppVersion(function (err, data) {
getAppVersion((err, data) => {
if (err) console.log(err)

@@ -188,3 +178,3 @@ console.log(data)

composePattern('M.m.p-Ss n-d', function(ptt) {
composePattern('M.m.p-Ss n-d', (ptt) => {
console.log(ptt)

@@ -195,10 +185,15 @@ })

## Automating
If you are using *npm scripts* you can easily integrate appversion in your workflow, below you can find an example of a package.json:
If you are using *npm scripts* you can easily integrate AppVersion in your workflow, below you can find an example of a package.json:
```json
...
"scripts": {
"build": "apv update build && <build command>"
"build": "<build command> && apv update build"
},
...
```
## TODO
- [x] Update status number
- [ ] Integration with GitHub
- [ ] SHA generator
- [ ] Badge generator with the application version for the README.md.

@@ -208,8 +203,6 @@ ## Build

$ npm install
$ npm run build:cli
$ npm run build:index
$ chmod u+x cli.js
$ npm run test
$ chmod u+x apv.js
$ npm test
$ ./cli.js <args>
$ ./apv.js <cmd> <args>
```

@@ -220,3 +213,3 @@

The code follow the Standard code style.
The code follows the Standard code style.
[![js-standard-style](https://cdn.rawgit.com/feross/standard/master/badge.svg)](https://github.com/feross/standard)

@@ -223,0 +216,0 @@

@@ -1,6 +0,4 @@

'use strict'
/*
* Project: appversion
* Version: 1.1.0
* Version: 1.2.0
* Author: delvedor

@@ -12,4 +10,7 @@ * Twitter: @delvedor

'use strict'
const test = require('tape')
const execSync = require('child_process').execSync
const exec = require('child_process').exec
const fs = require('fs')

@@ -19,3 +20,3 @@ const JSON_FILE = 'appversion.json'

test('Testing update', (t) => {
t.plan(12)
t.plan(13)
const original = JSON.parse(fs.readFileSync(JSON_FILE))

@@ -25,11 +26,11 @@ let mod

console.log('|- Testing build')
execSync('./cli.js update build')
execSync('./apv.js update build')
mod = JSON.parse(fs.readFileSync(JSON_FILE))
let date = new Date()
let date = (new Date()).toString()
t.equal(mod.build.number, original.build.number + 1, 'Build number was correctly updated.')
t.equal(mod.build.total, original.build.total + 1, 'Build total was correctly updated.')
t.equal(mod.build.date, `${date.getFullYear()}.${date.getMonth() + 1 }.${date.getDate()}`, 'Date was correctly updated.')
t.equal(mod.build.date, date, 'Date was correctly updated.')
console.log('|- Testing patch')
execSync('./cli.js update patch')
execSync('./apv.js update patch')
mod = JSON.parse(fs.readFileSync(JSON_FILE))

@@ -40,3 +41,3 @@ t.equal(mod.version.patch, original.version.patch + 1, 'Patch was correctly updated.')

console.log('|- Testing minor')
execSync('./cli.js update minor')
execSync('./apv.js update minor')
mod = JSON.parse(fs.readFileSync(JSON_FILE))

@@ -48,3 +49,3 @@ t.equal(mod.version.minor, original.version.minor + 1, 'Minor was correctly updated.')

console.log('|- Testing major')
execSync('./cli.js update major')
execSync('./apv.js update major')
mod = JSON.parse(fs.readFileSync(JSON_FILE))

@@ -57,4 +58,12 @@ t.equal(mod.version.major, original.version.major + 1, 'Major was correctly updated.')

console.log('|- Testing commit')
console.log('|-- Test not yet implemented')
execSync('./apv.js update commit')
mod = JSON.parse(fs.readFileSync(JSON_FILE))
exec('git log --oneline', function (error, stdout) {
if (error) {
t.equal(mod.commit, null, 'Commit was correctly updated to null.')
} else {
t.equal(mod.commit, stdout.substring(0, 7), `Commit was correctly updated to ${stdout.substring(0, 7)}.`)
}
})
// Restore JSON_FILE to the original values.
fs.writeFileSync(JSON_FILE, JSON.stringify(original, null, 2) + '\n')

@@ -68,4 +77,4 @@ })

console.log('|- Testing version "1.2.3"')
execSync('./cli.js version "1.2.3"')
console.log('|- Testing version 1.2.3')
execSync('./apv.js set-version 1.2.3')
mod = JSON.parse(fs.readFileSync(JSON_FILE))

@@ -79,3 +88,3 @@ t.deepEqual(mod.version, {

execSync(`./cli.js version "${original.version.major}.${original.version.minor}.${original.version.patch}"`)
execSync(`./apv.js set-version ${original.version.major}.${original.version.minor}.${original.version.patch}`)
fs.writeFileSync(JSON_FILE, JSON.stringify(original, null, 2) + '\n')

@@ -89,27 +98,27 @@ })

console.log('|- Testing status "stable"')
execSync('./cli.js status "stable"')
console.log('|- Testing status stable')
execSync('./apv.js set-status stable')
mod = JSON.parse(fs.readFileSync(JSON_FILE))
t.equal(mod.status.stage, 'stable', 'Status.stage "stable" was correctly updated.')
t.equal(mod.status.number, 0, 'Status.number "stable" was correctly updated.')
t.equal(mod.status.stage, 'stable', 'Status.stage stable was correctly updated.')
t.equal(mod.status.number, 0, 'Status.number stable was correctly updated.')
console.log('|- |- Testing status "rc.1"')
execSync('./cli.js status "rc.1"')
console.log('|- Testing status RC.1')
execSync('./apv.js set-status RC.1')
mod = JSON.parse(fs.readFileSync(JSON_FILE))
t.equal(mod.status.stage, 'rc', 'Status.stage "rc" was correctly updated.')
t.equal(mod.status.number, 1, 'Status.number "rc" was correctly updated.')
t.equal(mod.status.stage, 'RC', 'Status.stage rc was correctly updated.')
t.equal(mod.status.number, 1, 'Status.number rc was correctly updated.')
console.log('|- Testing status "beta.2"')
execSync('./cli.js status "beta.2"')
console.log('|- Testing status beta.2')
execSync('./apv.js set-status beta.2')
mod = JSON.parse(fs.readFileSync(JSON_FILE))
t.equal(mod.status.stage, 'beta', 'Status.stage "beta" was correctly updated.')
t.equal(mod.status.number, 2, 'Status.number "beta" was correctly updated.')
t.equal(mod.status.stage, 'beta', 'Status.stage beta was correctly updated.')
t.equal(mod.status.number, 2, 'Status.number beta was correctly updated.')
console.log('|- Testing status "alpha.0"')
execSync('./cli.js status "alpha.0"')
console.log('|- Testing status Alpha.0')
execSync('./apv.js set-status Alpha.0')
mod = JSON.parse(fs.readFileSync(JSON_FILE))
t.equal(mod.status.stage, 'alpha', 'Status.stage "alpha" was correctly updated.')
t.equal(mod.status.number, 0, 'Status.number "alpha" was correctly updated.')
t.equal(mod.status.stage, 'Alpha', 'Status.stage alpha was correctly updated.')
t.equal(mod.status.number, 0, 'Status.number alpha was correctly updated.')
// Restore JSON_FILE to the original values.
fs.writeFileSync(JSON_FILE, JSON.stringify(original, null, 2) + '\n')
})

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc