standard-version
Advanced tools
Comparing version 2.2.1 to 2.3.0
@@ -5,2 +5,18 @@ # Change Log | ||
<a name="2.3.0"></a> | ||
# [2.3.0](https://github.com/conventional-changelog/standard-version/compare/v2.2.1...v2.3.0) (2016-06-02) | ||
### Bug Fixes | ||
* append line feed to end of package.json ([#42](https://github.com/conventional-changelog/standard-version/issues/42))([178e001](https://github.com/conventional-changelog/standard-version/commit/178e001)) | ||
### Features | ||
* **index.js:** add checkpoint for publish script after tag successfully ([#47](https://github.com/conventional-changelog/standard-version/issues/47))([e414ed7](https://github.com/conventional-changelog/standard-version/commit/e414ed7)) | ||
* add a --no-verify option to prevent git hooks from being verified ([#44](https://github.com/conventional-changelog/standard-version/issues/44))([026d844](https://github.com/conventional-changelog/standard-version/commit/026d844)) | ||
<a name="2.2.1"></a> | ||
@@ -7,0 +23,0 @@ ## [2.2.1](https://github.com/conventional-changelog/standard-version/compare/v2.2.0...v2.2.1) (2016-05-02) |
16
index.js
@@ -34,2 +34,9 @@ #!/usr/bin/env node | ||
}) | ||
.option('no-verify', { | ||
alias: 'n', | ||
describe: 'Bypass pre-commit or commit-msg git hooks during the commit phase', | ||
type: 'boolean', | ||
default: false, | ||
global: true | ||
}) | ||
.help() | ||
@@ -65,3 +72,3 @@ .alias('help', 'h') | ||
pkg.version = newVersion | ||
fs.writeFileSync(pkgPath, JSON.stringify(pkg, null, 2), 'utf-8') | ||
fs.writeFileSync(pkgPath, JSON.stringify(pkg, null, 2) + '\n', 'utf-8') | ||
} else { | ||
@@ -113,2 +120,3 @@ console.log(chalk.red(figures.cross) + ' skip version bump on first release') | ||
var args = [argv.infile] | ||
var verify = argv.verify === false || argv.n ? '--no-verify ' : '' | ||
if (!argv.firstRelease) { | ||
@@ -119,3 +127,3 @@ msg += ' and %s' | ||
checkpoint(msg, args) | ||
exec('git add package.json ' + argv.infile + ';git commit ' + (argv.sign ? '-S ' : '') + 'package.json ' + argv.infile + ' -m "' + formatCommitMessage(argv.message, newVersion) + '"', function (err, stdout, stderr) { | ||
exec('git add package.json ' + argv.infile + ';git commit ' + verify + (argv.sign ? '-S ' : '') + 'package.json ' + argv.infile + ' -m "' + formatCommitMessage(argv.message, newVersion) + '"', function (err, stdout, stderr) { | ||
var errMessage = null | ||
@@ -151,2 +159,6 @@ if (err) errMessage = err.message | ||
process.exit(1) | ||
} else { | ||
checkpoint('Run `%s` to publish.', [ | ||
'git push --follow-tags origin master; npm publish' | ||
]) | ||
} | ||
@@ -153,0 +165,0 @@ }) |
{ | ||
"name": "standard-version", | ||
"version": "2.2.1", | ||
"version": "2.3.0", | ||
"description": "replacement for `npm version` with automatic CHANGELOG generation", | ||
@@ -9,3 +9,3 @@ "bin": "index.js", | ||
"coverage": "nyc report --reporter=text-lcov | coveralls", | ||
"test": "nyc mocha --timeout=10000 test.js" | ||
"test": "nyc mocha --timeout=20000 test.js" | ||
}, | ||
@@ -45,7 +45,8 @@ "repository": { | ||
"coveralls": "^2.11.9", | ||
"mocha": "^2.4.5", | ||
"mocha": "^2.5.1", | ||
"mock-git": "^1.0.2", | ||
"nyc": "^6.4.2", | ||
"shelljs": "^0.7.0", | ||
"standard": "^6.0.8" | ||
"standard": "^7.0.1" | ||
} | ||
} | ||
} |
@@ -97,2 +97,13 @@ # Standard Version | ||
### Prevent Git Hooks | ||
If you use git hooks, like pre-commit, to test your code before committing, you can prevent hooks from being verified during the commit step by passing the `--no-verify` option: | ||
```sh | ||
# npm run script | ||
npm run release -- --no-verify | ||
# or global bin | ||
standard-version --no-verify | ||
``` | ||
### CLI Help | ||
@@ -99,0 +110,0 @@ |
109
test.js
@@ -8,2 +8,3 @@ /* global describe it beforeEach afterEach */ | ||
var path = require('path') | ||
var mockGit = require('mock-git') | ||
var cliPath = path.resolve(__dirname, './index.js') | ||
@@ -17,2 +18,13 @@ | ||
function writePackageJson (version) { | ||
fs.writeFileSync('package.json', JSON.stringify({ | ||
version: version | ||
}), 'utf-8') | ||
} | ||
function writeGitPreCommitHook () { | ||
fs.writeFileSync('.git/hooks/pre-commit', '#!/bin/sh\necho "precommit ran"\nexit 1', 'utf-8') | ||
fs.chmodSync('.git/hooks/pre-commit', '755') | ||
} | ||
describe('cli', function () { | ||
@@ -35,5 +47,3 @@ beforeEach(function () { | ||
it('populates changelog with commits since last tag by default', function () { | ||
fs.writeFileSync('package.json', JSON.stringify({ | ||
version: '1.0.0' | ||
}), 'utf-8') | ||
writePackageJson('1.0.0') | ||
@@ -52,5 +62,3 @@ commit('feat: first commit') | ||
it('includes all commits if --first-release is true', function () { | ||
fs.writeFileSync('package.json', JSON.stringify({ | ||
version: '1.0.1' | ||
}), 'utf-8') | ||
writePackageJson('1.0.1') | ||
@@ -70,5 +78,3 @@ commit('feat: first commit') | ||
it('appends the new release above the last release, removing the old header', function () { | ||
fs.writeFileSync('package.json', JSON.stringify({ | ||
version: '1.0.0' | ||
}), 'utf-8') | ||
writePackageJson('1.0.0') | ||
fs.writeFileSync('CHANGELOG.md', 'legacy header format<a name="1.0.0">\n', 'utf-8') | ||
@@ -87,20 +93,52 @@ | ||
it('respects the --sign option', function () { | ||
fs.writeFileSync('package.json', JSON.stringify({ | ||
version: '1.0.0' | ||
}), 'utf-8') | ||
describe('with mocked git', function () { | ||
it('--sign signs the commit and tag', function () { | ||
// mock git with file that writes args to gitcapture.log | ||
mockGit('require("fs").appendFileSync("gitcapture.log", JSON.stringify(process.argv.splice(2)) + "\\n")') | ||
.then(function (unmock) { | ||
writePackageJson('1.0.0') | ||
commit('feat: first commit') | ||
shell.exec(cliPath + ' --sign').code.should.equal(0) | ||
// this should fail without a GPG key | ||
var result = shell.exec(cliPath + ' --sign') | ||
result.code.should.equal(1) | ||
result.stdout.should.match(/gpg\: signing failed\: secret key not available/) | ||
result.stdout.should.match(/error\: gpg failed to sign the data/) | ||
var captured = shell.cat('gitcapture.log').stdout.split('\n').map(function (line) { | ||
return line ? JSON.parse(line) : line | ||
}) | ||
captured[captured.length - 3].should.deep.equal(['commit', '-S', 'package.json', 'CHANGELOG.md', '-m', 'chore(release): 1.0.1']) | ||
captured[captured.length - 2].should.deep.equal(['tag', '-s', 'v1.0.1', '-m', 'chore(release): 1.0.1']) | ||
unmock() | ||
}) | ||
}) | ||
it('exits with error code if git commit fails', function () { | ||
// mock git by throwing on attempt to commit | ||
mockGit('console.error("commit yourself"); process.exit(128);', 'commit') | ||
.then(function (unmock) { | ||
writePackageJson('1.0.0') | ||
var result = shell.exec(cliPath) | ||
result.code.should.equal(1) | ||
result.stdout.should.match(/commit yourself/) | ||
unmock() | ||
}) | ||
}) | ||
it('exits with error code if git tag fails', function () { | ||
// mock git by throwing on attempt to commit | ||
return mockGit('console.error("tag, you\'re it"); process.exit(128);', 'tag') | ||
.then(function (unmock) { | ||
writePackageJson('1.0.0') | ||
var result = shell.exec(cliPath) | ||
result.code.should.equal(1) | ||
result.stdout.should.match(/tag, you're it/) | ||
unmock() | ||
}) | ||
}) | ||
}) | ||
it('handles commit messages longer than 80 characters', function () { | ||
fs.writeFileSync('package.json', JSON.stringify({ | ||
version: '1.0.0' | ||
}), 'utf-8') | ||
writePackageJson('1.0.0') | ||
@@ -118,5 +156,3 @@ commit('feat: first commit') | ||
it('formats the commit and tag messages appropriately', function () { | ||
fs.writeFileSync('package.json', JSON.stringify({ | ||
version: '1.0.0' | ||
}), 'utf-8') | ||
writePackageJson('1.0.0') | ||
@@ -130,6 +166,25 @@ commit('feat: first commit') | ||
// check last commit message | ||
shell.exec('git log --oneline -n1').stdout.should.match(/chore\(release\)\: 1\.1\.0/) | ||
shell.exec('git log --oneline -n1').stdout.should.match(/chore\(release\): 1\.1\.0/) | ||
// check annotated tag message | ||
shell.exec('git tag -l -n1 v1.1.0').stdout.should.match(/chore\(release\)\: 1\.1\.0/) | ||
shell.exec('git tag -l -n1 v1.1.0').stdout.should.match(/chore\(release\): 1\.1\.0/) | ||
}) | ||
it('appends line feed at end of package.json', function () { | ||
writePackageJson('1.0.0') | ||
shell.exec(cliPath).code.should.equal(0) | ||
var pkgJson = fs.readFileSync('package.json', 'utf-8') | ||
pkgJson.should.equal(['{', ' "version": "1.0.1"', '}', ''].join('\n')) | ||
}) | ||
it('does not run git hooks if the --no-verify flag is passed', function () { | ||
writePackageJson('1.0.0') | ||
writeGitPreCommitHook() | ||
commit('feat: first commit') | ||
shell.exec(cliPath + ' --no-verify').code.should.equal(0) | ||
commit('feat: second commit') | ||
shell.exec(cliPath + ' -n').code.should.equal(0) | ||
}) | ||
}) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
25163
308
184
7