standard-version
Advanced tools
Comparing version 4.3.0 to 4.4.0
@@ -5,2 +5,19 @@ # Change Log | ||
<a name="4.4.0"></a> | ||
# [4.4.0](https://github.com/conventional-changelog/standard-version/compare/v4.3.0...v4.4.0) (2018-05-21) | ||
### Bug Fixes | ||
* show full tag name in checkpoint ([#241](https://github.com/conventional-changelog/standard-version/issues/241)) ([b4ed4f9](https://github.com/conventional-changelog/standard-version/commit/b4ed4f9)) | ||
* use tagPrefix in CHANGELOG lifecycle step ([#243](https://github.com/conventional-changelog/standard-version/issues/243)) ([a56c7ac](https://github.com/conventional-changelog/standard-version/commit/a56c7ac)) | ||
### Features | ||
* add prerelease lifecycle script hook (closes [#217](https://github.com/conventional-changelog/standard-version/issues/217)) ([#234](https://github.com/conventional-changelog/standard-version/issues/234)) ([ba4e7f6](https://github.com/conventional-changelog/standard-version/commit/ba4e7f6)) | ||
* manifest.json support ([#236](https://github.com/conventional-changelog/standard-version/issues/236)) ([371d992](https://github.com/conventional-changelog/standard-version/commit/371d992)) | ||
<a name="4.3.0"></a> | ||
@@ -7,0 +24,0 @@ # [4.3.0](https://github.com/conventional-changelog/standard-version/compare/v4.2.0...v4.3.0) (2018-01-03) |
13
index.js
@@ -10,4 +10,13 @@ const path = require('path') | ||
module.exports = function standardVersion (argv) { | ||
var pkgPath = path.resolve(process.cwd(), './package.json') | ||
var pkg = require(pkgPath) | ||
var pkg | ||
bump.pkgFiles.forEach((filename) => { | ||
if (pkg) return | ||
var pkgPath = path.resolve(process.cwd(), filename) | ||
try { | ||
pkg = require(pkgPath) | ||
} catch (err) {} | ||
}) | ||
if (!pkg) { | ||
return Promise.reject(new Error('no package file found')) | ||
} | ||
var newVersion = pkg.version | ||
@@ -14,0 +23,0 @@ var defaults = require('./defaults') |
@@ -23,3 +23,4 @@ 'use strict' | ||
var newVersion = pkg.version | ||
return runLifecycleScript(args, 'prebump') | ||
return runLifecycleScript(args, 'prerelease') | ||
.then(runLifecycleScript.bind(this, args, 'prebump')) | ||
.then((stdout) => { | ||
@@ -50,2 +51,13 @@ if (stdout && stdout.trim().length) args.releaseAs = stdout.trim() | ||
Bump.pkgFiles = [ | ||
'package.json', | ||
'bower.json', | ||
'manifest.json' | ||
] | ||
Bump.lockFiles = [ | ||
'package-lock.json', | ||
'npm-shrinkwrap.json' | ||
] | ||
function getReleaseType (prerelease, expectedReleaseType, currentVersion) { | ||
@@ -143,6 +155,5 @@ if (isString(prerelease)) { | ||
const dotgit = DotGitignore() | ||
configsToUpdate[path.resolve(process.cwd(), './package.json')] = false | ||
configsToUpdate[path.resolve(process.cwd(), './package-lock.json')] = false | ||
configsToUpdate[path.resolve(process.cwd(), './npm-shrinkwrap.json')] = false | ||
configsToUpdate[path.resolve(process.cwd(), './bower.json')] = false | ||
Bump.pkgFiles.concat(Bump.lockFiles).forEach((filename) => { | ||
configsToUpdate[path.resolve(process.cwd(), filename)] = false | ||
}) | ||
Object.keys(configsToUpdate).forEach(function (configPath) { | ||
@@ -149,0 +160,0 @@ try { |
@@ -33,3 +33,4 @@ const accessSync = require('fs-access').sync | ||
var changelogStream = conventionalChangelog({ | ||
preset: 'angular' | ||
preset: 'angular', | ||
tagPrefix: args.tagPrefix | ||
}, context, {merges: null}) | ||
@@ -36,0 +37,0 @@ .on('error', function (err) { |
@@ -26,3 +26,3 @@ const chalk = require('chalk') | ||
} | ||
checkpoint(args, 'tagging release %s', [newVersion]) | ||
checkpoint(args, 'tagging release %s%s', [args.tagPrefix, newVersion]) | ||
return runExec(args, 'git tag ' + tagOption + args.tagPrefix + newVersion + ' -m "' + formatCommitMessage(args.message, newVersion) + '"') | ||
@@ -29,0 +29,0 @@ .then(() => { |
@@ -0,1 +1,3 @@ | ||
ISC License | ||
Copyright (c) 2016, Contributors | ||
@@ -2,0 +4,0 @@ |
{ | ||
"name": "standard-version", | ||
"version": "4.3.0", | ||
"version": "4.4.0", | ||
"description": "replacement for `npm version` with automatic CHANGELOG generation", | ||
@@ -52,4 +52,4 @@ "bin": "bin/cli.js", | ||
"chai": "^3.5.0", | ||
"coveralls": "^2.11.9", | ||
"mocha": "^3.1.0", | ||
"coveralls": "^3.0.1", | ||
"mocha": "^5.2.0", | ||
"mock-git": "^1.0.2", | ||
@@ -59,4 +59,4 @@ "mockery": "^2.0.0", | ||
"shelljs": "^0.7.3", | ||
"standard": "^10.0.0" | ||
"standard": "^11.0.1" | ||
} | ||
} |
@@ -162,2 +162,5 @@ # Standard Version | ||
* `prerelease`: executed before anything happens. If the `prerelease` script returns a | ||
non-zero exit code, versioning will be aborted, but it has no other effect on the | ||
process. | ||
* `prebump`/`postbump`: executed before and after the version is bumped. If the `prebump` | ||
@@ -182,2 +185,15 @@ script returns a version #, it will be used rather than | ||
As an example to change from using GitHub to track your items to using your projects Jira use a | ||
`postchangelog` script to replace the url fragment containing 'https://github.com/`myproject`/issues/' | ||
with a link to your Jira - assuming you have already installed [replace](https://www.npmjs.com/package/replace) | ||
```json | ||
{ | ||
"standard-version": { | ||
"scripts": { | ||
"postchangelog": "replace 'https://github.com/myproject/issues/' 'https://myjira/browse/' CHANGELOG.md" | ||
} | ||
} | ||
} | ||
``` | ||
### Skipping lifecycle steps | ||
@@ -184,0 +200,0 @@ |
69
test.js
@@ -57,2 +57,8 @@ /* global describe it beforeEach afterEach */ | ||
function writeManifestJson (version, option) { | ||
option = option || {} | ||
var manifest = Object.assign(option, {version: version}) | ||
fs.writeFileSync('manifest.json', JSON.stringify(manifest), 'utf-8') | ||
} | ||
function writeNpmShrinkwrapJson (version, option) { | ||
@@ -256,2 +262,38 @@ option = option || {} | ||
describe('lifecycle scripts', () => { | ||
describe('prerelease hook', function () { | ||
it('should run the prerelease hook when provided', function () { | ||
writePackageJson('1.0.0', { | ||
'standard-version': { | ||
'scripts': { | ||
'prerelease': 'node scripts/prerelease' | ||
} | ||
} | ||
}) | ||
writeHook('prerelease') | ||
fs.writeFileSync('CHANGELOG.md', 'legacy header format<a name="1.0.0">\n', 'utf-8') | ||
commit('feat: first commit') | ||
var result = execCli('--patch') | ||
result.code.should.equal(0) | ||
result.stderr.should.match(/prerelease ran/) | ||
}) | ||
it('should abort if the hook returns a non-zero exit code', function () { | ||
writePackageJson('1.0.0', { | ||
'standard-version': { | ||
'scripts': { | ||
'prerelease': 'node scripts/prerelease && exit 1' | ||
} | ||
} | ||
}) | ||
writeHook('prerelease') | ||
fs.writeFileSync('CHANGELOG.md', 'legacy header format<a name="1.0.0">\n', 'utf-8') | ||
commit('feat: first commit') | ||
var result = execCli('--patch') | ||
result.code.should.equal(1) | ||
result.stderr.should.match(/prerelease ran/) | ||
}) | ||
}) | ||
describe('prebump hook', function () { | ||
@@ -698,2 +740,12 @@ it('should allow prebump hook to return an alternate version #', function () { | ||
describe('without a package file to bump', function () { | ||
it('should exit with error', function () { | ||
shell.rm('package.json') | ||
return require('./index')({silent: true}) | ||
.catch((err) => { | ||
err.message.should.equal('no package file found') | ||
}) | ||
}) | ||
}) | ||
describe('bower.json support', function () { | ||
@@ -716,2 +768,19 @@ beforeEach(function () { | ||
describe('manifest.json support', function () { | ||
beforeEach(function () { | ||
writeManifestJson('1.0.0') | ||
}) | ||
it('bumps version # in manifest.json', function () { | ||
commit('feat: first commit') | ||
shell.exec('git tag -a v1.0.0 -m "my awesome first release"') | ||
commit('feat: new feature!') | ||
return require('./index')({silent: true}) | ||
.then(() => { | ||
JSON.parse(fs.readFileSync('manifest.json', 'utf-8')).version.should.equal('1.1.0') | ||
getPackageVersion().should.equal('1.1.0') | ||
}) | ||
}) | ||
}) | ||
describe('npm-shrinkwrap.json support', function () { | ||
@@ -718,0 +787,0 @@ beforeEach(function () { |
73413
1255
330