🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Sign inDemoInstall
Socket

broccoli-version

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

broccoli-version - npm Package Compare versions

Comparing version

to
0.2.1

.travis.yml

39

CHANGELOG.md

@@ -1,18 +0,35 @@

#### 0.1.1 (2016-7-31)
<a name="0.2.1"></a>
## [0.2.1](https://github.com/stfsy/broccoli-version/compare/v0.2.0...v0.2.1) (2016-07-31)
##### Chores
* **package.json:** add release workflow (1ae268c1)
* **README.md:**
* update installation command (eac0f56b)
* add installation documentation, update example (6ec37425)
##### Bug Fixes
<a name="0.2.0"></a>
# [0.2.0](https://github.com/stfsy/broccoli-version/compare/v0.1.1...v0.2.0) (2016-07-31)
* **copier.js:** only first element of input node arrays is used (70dab5bd)
* **version.js:** do not increment if increment param is given and undefined (f64284b1)
##### Refactors
### Bug Fixes
* **copier.spec.js:** remove console.logs, clean up (7af11316)
* **copier.spec.js:** uppercase require fails on travis ([cd89f8e](https://github.com/stfsy/broccoli-version/commit/cd89f8e))
* **incrementer.js:** uppercase require fails on travis ([ccd3031](https://github.com/stfsy/broccoli-version/commit/ccd3031))
* **incrementer.spec.js:** uppercase require fails on travis ([75ca5da](https://github.com/stfsy/broccoli-version/commit/75ca5da))
* **version.spec.js:** uppercase require fails on travis ([990b7f0](https://github.com/stfsy/broccoli-version/commit/990b7f0))
### Features
* **index.js:** add option for build meta data support ([6b1d9a0](https://github.com/stfsy/broccoli-version/commit/6b1d9a0))
* **version.js:** add build meta data support ([683ac70](https://github.com/stfsy/broccoli-version/commit/683ac70))
<a name="0.1.1"></a>
## [0.1.1](https://github.com/stfsy/broccoli-version/compare/f64284b...v0.1.1) (2016-07-31)
### Bug Fixes
* **copier.js:** only first element of input node arrays is used ([70dab5b](https://github.com/stfsy/broccoli-version/commit/70dab5b))
* **version.js:** do not increment if increment param is given and undefined ([f64284b](https://github.com/stfsy/broccoli-version/commit/f64284b))
'use strict'
const fileSystem = require('fs-promise')
const Version = require('./Version')
const Version = require('./version')

@@ -6,0 +6,0 @@ module.exports = class Incrementer {

@@ -11,3 +11,3 @@ 'use strict'

constructor(inputNodes, options) {
super(Arrays.isArray(inputNodes) ? inputNodes : [inputNodes], options)
super(Array.isArray(inputNodes) ? inputNodes : [inputNodes], options)

@@ -24,4 +24,17 @@ const holders = []

version.patch(options.patch).minor(options.minor).major(options.major)
version.patch(options.patch)
.minor(options.minor)
.major(options.major)
.meta((version) => {
if (options.meta) {
return options.meta.call(null, {
patch: options.patch,
minor: options.minor,
major: options.major,
meta: version.meta
})
}
})
}).catch((error) => {

@@ -28,0 +41,0 @@

@@ -5,9 +5,14 @@ 'use strict'

constructor(version) {
constructor(semanticVersion) {
const split = version.split('.')
const split = semanticVersion.split('+')
this.majorVersion = parseInt(split[0])
this.minorVersion = parseInt(split[1] || 0)
this.patchVersion = parseInt(split[2] || 0)
const version = split[0].split('.')
const meta = split[1]
this.majorVersion = parseInt(version[0])
this.minorVersion = parseInt(version[1] || 0)
this.patchVersion = parseInt(version[2] || 0)
this.previousBuildMetaData = meta || null
}

@@ -17,3 +22,3 @@

if (arguments.length === 0 || increment) {
if (increment) {

@@ -28,3 +33,3 @@ this.patchVersion += 1

if (arguments.length === 0 || increment) {
if (increment) {

@@ -40,3 +45,3 @@ this.minorVersion += 1

if (arguments.length === 0 || increment) {
if (increment) {

@@ -51,6 +56,32 @@ this.majorVersion += 1

meta(fn) {
if (typeof fn === 'function') {
this.buildMetaData = fn.call(null, {
major: this.majorVersion,
minor: this.minorVersion,
patch: this.patchVersion,
meta: this.previousBuildMetaData
})
} else {
this.buildMetaData = null
}
return this
}
toString() {
return [this.majorVersion, this.minorVersion, this.patchVersion].join('.')
let semVersion = [this.majorVersion, this.minorVersion, this.patchVersion].join('.')
if (this.buildMetaData) {
semVersion += '+' + this.buildMetaData
}
return semVersion
}
}
{
"name": "broccoli-version",
"version": "0.1.1",
"version": "0.2.1",
"description": "Broccoli plugin for incrementing version numbers in .json files",

@@ -9,8 +9,13 @@ "main": "lib/index.js",

"preversion": "npm test",
"postversion": "git add CHANGELOG.md && git push && git push --tags",
"release-major": "changelog -M && npm version major -m \"chore(release): v%s\"",
"release-minor": "changelog -m && npm version minor -m \"chore(release): v%s\"",
"release-patch": "changelog -p && npm version patch -m \"chore(release): v%s\""
"version": "npm run changelog && git add -A CHANGELOG.md",
"postversion": "git push && git push --tags",
"release-major": "npm version major -m \"chore(release): v%s\"",
"release-minor": "npm version minor -m \"chore(release): v%s\"",
"release-patch": "npm version patch -m \"chore(release): v%s\"",
"changelog": "conventional-changelog -p angular -i CHANGELOG.md -s -r 0"
},
"repository": "https://github.com/stfsy/broccoli-version.git",
"repository": {
"type": "git",
"url": "git+https://github.com/stfsy/broccoli-version.git"
},
"keywords": [

@@ -31,5 +36,6 @@ "broccoli-plugin"

"chai": "^3.5.0",
"generate-changelog": "^1.0.2",
"chai-spies": "^0.7.1",
"conventional-changelog": "^1.1.0",
"mocha": "^2.5.3"
}
}
# Broccoli Version Plugin
[![Build Status](https://travis-ci.org/stfsy/broccoli-version.svg)](https://travis-ci.org/stfsy/broccoli-version)
[![Dependency Status](https://img.shields.io/david/stfsy/broccoli-version.svg)](https://github.com/stfsy/broccoli-version/blob/master/package.json)
[![DevDependency Status](https://img.shields.io/david/dev/stfsy/broccoli-version.svg)](https://github.com/stfsy/broccoli-version/blob/master/package.json)
[![Npm downloads](https://img.shields.io/npm/dm/broccoli-version.svg)](https://www.npmjs.com/package/broccoli-version)
[![Npm Version](https://img.shields.io/npm/v/broccoli-version.svg)](https://www.npmjs.com/package/broccoli-version)
[![Git tag](https://img.shields.io/github/tag/stfsy/broccoli-version.svg)](https://github.com/stfsy/broccoli-version/releases)
[![Github issues](https://img.shields.io/github/issues/stfsy/broccoli-version.svg)](https://github.com/stfsy/broccoli-version/issues)
[![License](https://img.shields.io/npm/l/broccoli-version.svg)](https://github.com/stfsy/broccoli-version/blob/master/LICENSE)
Broccoli plugin for incrementing version numbers in bower.json and package.json files
## Example
## Example

@@ -14,2 +23,9 @@ ```js

patch: true,
meta: (options) => {
if(!options.major && !options.minor && !options.patch) {
return options.meta += 1
} else {
return 0
}
}
targets: {

@@ -24,2 +40,29 @@ npm: true,

## Example incrementing daily builds
```js
const BroccoliVersion = require('broccoli-version')
const versioned = new BroccoliVersion('app', {
meta: (options) => {
let builds = 0
const now = new Date()
const string = [now.getFullYear(), now.getMonth() + 1, now.getDay()].join('')
if (options.meta && options.meta.indexOf(string) > -1) {
builds = parseInt(options.meta.split('-')[1])
}
return [string, ++builds].join('-')
},
targets: {
npm: true,
bower: false
}
})
module.exports = versioned
```
## Installation

@@ -40,8 +83,10 @@ ```js

* `targets`: An object specifying what configuration files should be updated.
* `meta`: An optional function returning additional build metadata. The function is called with the three boolean flags mentioned above plus the current value of the build meta data or null. Build meta data is appended to the version with a leading '+'.
The returned outputNodes are a copy of the supplied inputNodes.
* `targets`: An object specifying what configuration files should be updated. Needs at least npm set to true.
The returned output node contains umodified copies of all files and subfolders of the input nodes.
## License
This project is distributed under the MIT license.
'use strict'
const Copier = require('../../lib/Copier')
const Copier = require('../../lib/copier')

@@ -5,0 +5,0 @@ const expect = require('chai').expect

'use strict'
const Incrementer = require('../../lib/Incrementer')
const Incrementer = require('../../lib/incrementer')

@@ -12,3 +12,3 @@ const expect = require('chai').expect

let incrementer = null
let incrementer = null

@@ -18,7 +18,8 @@ beforeEach(() => {

incrementer = new Incrementer([resolve('test/test.package.json')])
})
})
afterEach(() => {
fileSystem.writeJson(resolve('test/test.package.json'), {version: '1.2.3'})
fileSystem.writeJsonSync(resolve('test/test.package.json'), { version: '1.2.3' })
fileSystem.writeJsonSync(resolve('test/test.package.withBuildMeta.json'), { version: '1.4.15+beta14-ABC' })
})

@@ -35,3 +36,3 @@

it('should persist an increment version number', (done) => {
it('should persist an incremented version number', (done) => {

@@ -43,9 +44,26 @@ incrementer.readVersion().then((version) => {

}).then(incrementer.persistAll.bind(incrementer))
.then(incrementer.readVersion.bind(incrementer))
.then((version) => {
.then(incrementer.readVersion.bind(incrementer))
.then((version) => {
expect(version.toString()).to.equal('2.0.0')
expect(version.toString()).to.equal('2.0.0')
}).then(done, done)
}).then(done, done)
})
it('should persist an incremented version number without build number if no build function was given', (done) => {
incrementer = new Incrementer([resolve('test/test.package.withBuildMeta.json')])
incrementer.readVersion().then((version) => {
version.major(true).meta()
}).then(incrementer.persistAll.bind(incrementer))
.then(incrementer.readVersion.bind(incrementer))
.then((version) => {
expect(version.toString()).to.equal('2.0.0')
}).then(done, done)
})
})
'use strict'
const Version = require('../../lib/Version')
const Version = require('../../lib/version')
const expect = require('chai').expect

@@ -9,2 +9,3 @@

let semver = null
let versionWithBuildMeta = null
let version = null

@@ -16,2 +17,3 @@

version = new Version(semver)
versionWithBuildMeta = new Version(semver + '+415-beta')
})

@@ -24,2 +26,7 @@

it('should parse a valid semver string with build metadata', () => {
expect(versionWithBuildMeta.toString()).to.equal(semver)
})
it('should not increment the patch level', () => {

@@ -30,5 +37,35 @@

it('should increment the patch level and not append build data', () => {
expect(versionWithBuildMeta.patch(true).toString()).to.equal('0.0.2')
})
it('should call back with correct major, minor patch und meta data values', () => {
versionWithBuildMeta.meta((version) => {
expect(version.major).to.equal(0)
expect(version.minor).to.equal(0)
expect(version.patch).to.equal(1)
expect(version.meta).to.equal('415-beta')
})
})
it('should only not update any part of the version string', () => {
expect(versionWithBuildMeta.meta().toString()).to.equal('0.0.1')
})
it('should only update build meta data', () => {
expect(versionWithBuildMeta.meta(() => {
return 'beta413'
}).toString()).to.equal('0.0.1' + '+beta413')
})
it('should increment the patch level', () => {
expect(version.patch().toString()).to.equal('0.0.2')
expect(version.patch(true).toString()).to.equal('0.0.2')
})

@@ -58,7 +95,2 @@

expect(version.minor().toString()).to.equal('0.1.0')
})
it('should increment the minor level', () => {
expect(version.minor(true).toString()).to.equal('0.1.0')

@@ -84,7 +116,2 @@ })

expect(version.major().toString()).to.equal('1.0.0')
})
it('should increment the major level', () => {
expect(version.major(true).toString()).to.equal('1.0.0')

@@ -91,0 +118,0 @@ })