chore(package): re-init package with commitizen and standard-release

This commit is contained in:
Pavel Pertsev
2018-05-16 12:54:46 +03:00
parent cb4e7a5643
commit eaf2328575
10640 changed files with 609660 additions and 117 deletions

9
node_modules/standard-version/.editorconfig generated vendored Normal file
View File

@@ -0,0 +1,9 @@
# EditorConfig is awesome: http://EditorConfig.org
root = true
[*]
trim_trailing_whitespace=true
indent_style = space
indent_size = 2
insert_final_newline = true

9
node_modules/standard-version/.travis.yml generated vendored Normal file
View File

@@ -0,0 +1,9 @@
language: node_js
node_js:
- "4"
- "5"
- "stable"
before_script:
- git config --global user.name 'Travis-CI'
- git config --global user.email 'dummy@example.org'
after_success: npm run coverage

227
node_modules/standard-version/CHANGELOG.md generated vendored Normal file
View File

@@ -0,0 +1,227 @@
# Change Log
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
<a name="4.3.0"></a>
# [4.3.0](https://github.com/conventional-changelog/standard-version/compare/v4.2.0...v4.3.0) (2018-01-03)
### Bug Fixes
* recommend `--tag` prerelease for npm publish of prereleases ([#196](https://github.com/conventional-changelog/standard-version/issues/196)) ([709dae1](https://github.com/conventional-changelog/standard-version/commit/709dae1)), closes [#183](https://github.com/conventional-changelog/standard-version/issues/183)
* use the `skip` default value for skip cli arg ([#211](https://github.com/conventional-changelog/standard-version/issues/211)) ([3fdd7fa](https://github.com/conventional-changelog/standard-version/commit/3fdd7fa))
### Features
* **format-commit-message:** support multiple %s in the message ([45fcad5](https://github.com/conventional-changelog/standard-version/commit/45fcad5))
* do not update/commit files in .gitignore ([#230](https://github.com/conventional-changelog/standard-version/issues/230)) ([4fd3bc2](https://github.com/conventional-changelog/standard-version/commit/4fd3bc2))
* publish only if commit+push succeed ([#229](https://github.com/conventional-changelog/standard-version/issues/229)) ([c5e1ee2](https://github.com/conventional-changelog/standard-version/commit/c5e1ee2))
<a name="4.2.0"></a>
# [4.2.0](https://github.com/conventional-changelog/standard-version/compare/v4.1.0...v4.2.0) (2017-06-12)
### Features
* add support for `package-lock.json` ([#190](https://github.com/conventional-changelog/standard-version/issues/190)) ([bc0fc53](https://github.com/conventional-changelog/standard-version/commit/bc0fc53))
<a name="4.1.0"></a>
# [4.1.0](https://github.com/conventional-changelog/standard-version/compare/v4.0.0...v4.1.0) (2017-06-06)
### Features
* **cli:** print error and don't run with node <4, closes [#124](https://github.com/conventional-changelog/standard-version/issues/124) ([d0d71a5](https://github.com/conventional-changelog/standard-version/commit/d0d71a5))
* add dry-run mode ([#187](https://github.com/conventional-changelog/standard-version/issues/187)) ([d073353](https://github.com/conventional-changelog/standard-version/commit/d073353))
* add prebump, postbump, precommit, lifecycle scripts ([#186](https://github.com/conventional-changelog/standard-version/issues/186)) ([dfd1d12](https://github.com/conventional-changelog/standard-version/commit/dfd1d12))
* add support for `npm-shrinkwrap.json` ([#185](https://github.com/conventional-changelog/standard-version/issues/185)) ([86af7fc](https://github.com/conventional-changelog/standard-version/commit/86af7fc))
* add support for skipping lifecycle steps, polish lifecycle work ([#188](https://github.com/conventional-changelog/standard-version/issues/188)) ([d31dcdb](https://github.com/conventional-changelog/standard-version/commit/d31dcdb))
* allow a version # to be provided for release-as, rather than just major, minor, patch. ([13eb9cd](https://github.com/conventional-changelog/standard-version/commit/13eb9cd))
<a name="4.0.0"></a>
# [4.0.0](https://github.com/conventional-changelog/standard-version/compare/v4.0.0-1...v4.0.0) (2016-12-02)
### Bug Fixes
* include merge commits in the changelog ([#139](https://github.com/conventional-changelog/standard-version/issues/139)) ([b6e1562](https://github.com/conventional-changelog/standard-version/commit/b6e1562))
* should print message before we bump version ([2894bbc](https://github.com/conventional-changelog/standard-version/commit/2894bbc))
* support a wording change made to git status in git v2.9.1 ([#140](https://github.com/conventional-changelog/standard-version/issues/140)) ([80004ec](https://github.com/conventional-changelog/standard-version/commit/80004ec))
### Features
* add support for bumping version # in bower.json ([#148](https://github.com/conventional-changelog/standard-version/issues/148)) ([b788c5f](https://github.com/conventional-changelog/standard-version/commit/b788c5f))
* make tag prefix configurable ([#143](https://github.com/conventional-changelog/standard-version/issues/143)) ([70b20c8](https://github.com/conventional-changelog/standard-version/commit/70b20c8))
* support releasing a custom version, including pre-releases ([#129](https://github.com/conventional-changelog/standard-version/issues/129)) ([068008d](https://github.com/conventional-changelog/standard-version/commit/068008d))
### BREAKING CHANGES
* merge commits are now included in the CHANGELOG.
<a name="3.0.0"></a>
# [3.0.0](https://github.com/conventional-changelog/standard-version/compare/v2.3.0...v3.0.0) (2016-10-06)
### Bug Fixes
* check the private field in package.json([#102](https://github.com/conventional-changelog/standard-version/issues/102)) ([#103](https://github.com/conventional-changelog/standard-version/issues/103)) ([2ce4160](https://github.com/conventional-changelog/standard-version/commit/2ce4160))
* **err:** don't fail on stderr output, but print the output to stderr ([#110](https://github.com/conventional-changelog/standard-version/issues/110)) ([f7a4915](https://github.com/conventional-changelog/standard-version/commit/f7a4915)), closes [#91](https://github.com/conventional-changelog/standard-version/issues/91)
### Chores
* package.json engines field >=4.0, drop Node 0.10 and 0.12 ([28ff65a](https://github.com/conventional-changelog/standard-version/commit/28ff65a))
### Features
* **options:** add --silent flag and option for squelching output ([2a3fa61](https://github.com/conventional-changelog/standard-version/commit/2a3fa61))
* added support for commitAll option in CLI ([#121](https://github.com/conventional-changelog/standard-version/issues/121)) ([a903f4d](https://github.com/conventional-changelog/standard-version/commit/a903f4d))
* separate cli and defaults from base functionality ([34a6a4e](https://github.com/conventional-changelog/standard-version/commit/34a6a4e))
### BREAKING CHANGES
* drop support for Node < 4.0 to enable usage of
new tools and packages.
<a name="2.4.0"></a>
# [2.4.0](https://github.com/conventional-changelog/standard-version/compare/v2.3.1...v2.4.0) (2016-07-13)
### Bug Fixes
* **index.js:** use blue figures.info for last checkpoint ([#64](https://github.com/conventional-changelog/standard-version/issues/64)) ([e600b42](https://github.com/conventional-changelog/standard-version/commit/e600b42))
### Features
* **changelogStream:** use more default opts ([#67](https://github.com/conventional-changelog/standard-version/issues/67)) ([3e0aa84](https://github.com/conventional-changelog/standard-version/commit/3e0aa84))
<a name="2.3.1"></a>
## [2.3.1](https://github.com/conventional-changelog/standard-version/compare/v2.3.0...v2.3.1) (2016-06-15)
### Bug Fixes
* **commit:** fix windows by separating add and commit exec ([#55](https://github.com/conventional-changelog/standard-version/issues/55)) ([f361c46](https://github.com/conventional-changelog/standard-version/commit/f361c46)), closes [#55](https://github.com/conventional-changelog/standard-version/issues/55) [#49](https://github.com/conventional-changelog/standard-version/issues/49)
<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>
## [2.2.1](https://github.com/conventional-changelog/standard-version/compare/v2.2.0...v2.2.1) (2016-05-02)
### Bug Fixes
* upgrade to version of nyc that works with new shelljs([c7ac6e2](https://github.com/conventional-changelog/standard-version/commit/c7ac6e2))
<a name="2.2.0"></a>
# [2.2.0](https://github.com/conventional-changelog/standard-version/compare/v2.1.2...v2.2.0) (2016-05-01)
### Bug Fixes
* format the annotated tag message ([#28](https://github.com/conventional-changelog/standard-version/issues/28))([8f02736](https://github.com/conventional-changelog/standard-version/commit/8f02736))
* upgraded dependencies, switched back to angular format (fixes [#27](https://github.com/conventional-changelog/standard-version/issues/27)), pinned shelljs to version that works with nyc ([#30](https://github.com/conventional-changelog/standard-version/issues/30))([3f51e94](https://github.com/conventional-changelog/standard-version/commit/3f51e94))
### Features
* add --sign flag to sign git commit and tag ([#29](https://github.com/conventional-changelog/standard-version/issues/29))([de758bc](https://github.com/conventional-changelog/standard-version/commit/de758bc))
<a name="2.1.2"></a>
## [2.1.2](https://github.com/conventional-changelog/standard-version/compare/v2.1.1...v2.1.2) (2016-04-11)
### Bug Fixes
* we had too many \n characters ([#17](https://github.com/conventional-changelog/standard-version/issues/17)) ([67a01cd](https://github.com/conventional-changelog/standard-version/commit/67a01cd))
<a name="2.1.1"></a>
## [2.1.1](https://github.com/conventional-changelog/standard-version/compare/v2.1.0...v2.1.1) (2016-04-10)
### Bug Fixes
* **docs:** had a bad URL in package.json, which was breaking all of our links ([caa6359](https://github.com/conventional-changelog/standard-version/commit/caa6359))
<a name="2.1.0"></a>
# [2.1.0](https://github.com/conventional-changelog/standard-version/compare/v2.0.0...v2.1.0) (2016-04-10)
### Features
* adds support for GitHub links (see [#13](https://github.com/conventional-changelog/standard-version/issues/13)), great idea [@bcoe](https://github.com/bcoe)! ([7bf6597](https://github.com/conventional-changelog/standard-version/commit/7bf6597))
<a name="2.0.0"></a>
# [2.0.0](https://github.com/conventional-changelog/standard-version/compare/v1.1.0...v2.0.0) (2016-04-09)
* feat(conventional-changelog-standard): Move to conventional-changelog-standard style. This style lifts the character limit on commit messages, and puts us in a position to make more opinionated decisions in the future. ([c7ccadb](https://github.com/conventional-changelog/standard-version/commit/c7ccadb))
### BREAKING CHANGES
* we no longer accept the preset configuration option.
<a name="1.1.0"></a>
# [1.1.0](https://github.com/conventional-changelog/standard-version/compare/v1.0.0...v1.1.0) (2016-04-08)
### Features
* **cli:** use conventional default commit message with version ([9fadc5f](https://github.com/conventional-changelog/standard-version/commit/9fadc5f))
* **rebrand:** rebrand recommended-workflow to standard-version (#9) ([1f673c0](https://github.com/conventional-changelog/standard-version/commit/1f673c0))
* **tests:** adds test suite, fixed several Node 0.10 issues along the way ([03bd86c](https://github.com/conventional-changelog/standard-version/commit/03bd86c))
<a name="1.0.0"></a>
# 1.0.0 (2016-04-04)
### Features
* **initial-release:** adds flag for generating CHANGELOG.md on the first release. ([b812b44](https://github.com/bcoe/conventional-recommended-workflow/commit/b812b44))

14
node_modules/standard-version/LICENSE.txt generated vendored Normal file
View File

@@ -0,0 +1,14 @@
Copyright (c) 2016, Contributors
Permission to use, copy, modify, and/or distribute this software
for any purpose with or without fee is hereby granted, provided
that the above copyright notice and this permission notice
appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE
LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES
OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

313
node_modules/standard-version/README.md generated vendored Normal file
View File

@@ -0,0 +1,313 @@
# Standard Version
[![Build Status](https://travis-ci.org/conventional-changelog/standard-version.svg?branch=master)](https://travis-ci.org/conventional-changelog/standard-version)
[![NPM version](https://img.shields.io/npm/v/standard-version.svg)](https://www.npmjs.com/package/standard-version)
[![Coverage Status](https://coveralls.io/repos/conventional-changelog/standard-version/badge.svg?branch=)](https://coveralls.io/r/conventional-changelog/standard-version?branch=master)
[![Conventional Commits](https://img.shields.io/badge/Conventional%20Commits-1.0.0-yellow.svg)](https://conventionalcommits.org)
[![community slack](http://devtoolscommunity.herokuapp.com/badge.svg)](http://devtoolscommunity.herokuapp.com)
_Having problems? want to contribute? join our [community slack](http://devtoolscommunity.herokuapp.com)_.
> stop using `npm version`, use `standard-version` it rocks!
Automatic versioning and CHANGELOG generation, using GitHub's squash button and
[conventional commit messages](https://conventionalcommits.org).
_how it works:_
1. when you land commits on your `master` branch, select the _Squash and Merge_ option.
2. add a title and body that follows the [Conventional Commits Specification](https://conventionalcommits.org).
3. when you're ready to release to npm:
1. `git checkout master; git pull origin master`
2. run `standard-version`
3. `git push --follow-tags origin master && npm publish`
`standard-version` does the following:
1. bumps the version in _package.json/bower.json_ (based on your commit history)
2. uses [conventional-changelog](https://github.com/conventional-changelog/conventional-changelog) to update _CHANGELOG.md_
3. commits _package.json (et al.)_ and _CHANGELOG.md_
4. tags a new release
## Installation
### As `npm run` script
Install and add to `devDependencies`:
```
npm i --save-dev standard-version
```
Add an [`npm run` script](https://docs.npmjs.com/cli/run-script) to your _package.json_:
```json
{
"scripts": {
"release": "standard-version"
}
}
```
Now you can use `npm run release` in place of `npm version`.
This has the benefit of making your repo/package more portable, so that other developers can cut releases without having to globally install `standard-version` on their machine.
### As global bin
Install globally (add to your `PATH`):
```
npm i -g standard-version
```
Now you can use `standard-version` in place of `npm version`.
This has the benefit of allowing you to use `standard-version` on any repo/package without adding a dev dependency to each one.
## CLI Usage
### First Release
To generate your changelog for your first release, simply do:
```sh
# npm run script
npm run release -- --first-release
# or global bin
standard-version --first-release
```
This will tag a release **without bumping the version in package.json (_et al._)**.
When ready, push the git tag and `npm publish` your first release. \o/
### Cut a Release
If you typically use `npm version` to cut a new release, do this instead:
```sh
# npm run script
npm run release
# or global bin
standard-version
```
As long as your git commit messages are conventional and accurate, you no longer need to specify the semver type - and you get CHANGELOG generation for free! \o/
After you cut a release, you can push the new git tag and `npm publish` (or `npm publish --tag next`) when you're ready.
### Release as a pre-release
Use the flag `--prerelease` to generate pre-releases:
Suppose the last version of your code is `1.0.0`, and your code to be committed has patched changes. Run:
```bash
# npm run script
npm run release -- --prerelease
```
you will get version `1.0.1-0`.
If you want to name the pre-release, you specify the name via `--prerelease <name>`.
For example, suppose your pre-release should contain the `alpha` prefix:
```bash
# npm run script
npm run release -- --prerelease alpha
```
this will tag the version `1.0.1-alpha.0`
### Release as a target type imperatively like `npm version`
To forgo the automated version bump use `--release-as` with the argument `major`, `minor` or `patch`:
Suppose the last version of your code is `1.0.0`, you've only landed `fix:` commits, but
you would like your next release to be a `minor`. Simply do:
```bash
# npm run script
npm run release -- --release-as minor
# Or
npm run release -- --release-as 1.1.0
```
you will get version `1.1.0` rather than the auto generated version `1.0.1`.
> **NOTE:** you can combine `--release-as` and `--prerelease` to generate a release. This is useful when publishing experimental feature(s).
### 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
```
### Signing commits and tags
If you have your GPG key set up, add the `--sign` or `-s` flag to your `standard-version` command.
### Lifecycle scripts
`standard-version` supports lifecycle scripts. These allow you to execute your
own supplementary commands during the release. The following
hooks are available and execute in the order documented:
* `prebump`/`postbump`: executed before and after the version is bumped. If the `prebump`
script returns a version #, it will be used rather than
the version calculated by `standard-version`.
* `prechangelog`/`postchangelog`: executes before and after the CHANGELOG is generated.
* `precommit`/`postcommit`: called before and after the commit step.
* `pretag`/`posttag`: called before and after the tagging step.
Simply add the following to your package.json to configure lifecycle scripts:
```json
{
"standard-version": {
"scripts": {
"prebump": "echo 9.9.9"
}
}
}
```
### Skipping lifecycle steps
You can skip any of the lifecycle steps (`bump`, `changelog`, `commit`, `tag`),
by adding the following to your package.json:
```json
{
"standard-version": {
"skip": {
"changelog": true
}
}
}
```
### Committing generated artifacts in the release commit
If you want to commit generated artifacts in the release commit (e.g. [#96](https://github.com/conventional-changelog/standard-version/issues/96)), you can use the `--commit-all` or `-a` flag. You will need to stage the artifacts you want to commit, so your `release` command could look like this:
```json
"prerelease": "webpack -p --bail",
"release": "git add <file(s) to commit> && standard-version -a"
```
### Dry run mode
running `standard-version` with the flag `--dry-run` allows you to see what
commands would be run, without committing to git or updating files.
```sh
# npm run script
npm run release -- --dry-run
# or global bin
standard-version --dry-run
```
### CLI Help
```sh
# npm run script
npm run release -- --help
# or global bin
standard-version --help
```
## Code usage
Use the `silent` option to stop `standard-version` from printing anything
to the console.
```js
var standardVersion = require('standard-version')
// Options are the same as command line, except camelCase
standardVersion({
noVerify: true,
infile: 'docs/CHANGELOG.md',
silent: true
}, function (err) {
if (err) {
console.error(`standard-version failed with message: ${err.message}`)
}
// standard-version is done
})
```
## Commit Message Convention, at a Glance
_patches:_
```sh
git commit -a -m "fix(parsing): fixed a bug in our parser"
```
_features:_
```sh
git commit -a -m "feat(parser): we now have a parser \o/"
```
_breaking changes:_
```sh
git commit -a -m "feat(new-parser): introduces a new parsing library
BREAKING CHANGE: new library does not support foo-construct"
```
_other changes:_
You decide, e.g., docs, chore, etc.
```sh
git commit -a -m "docs: fixed up the docs a bit"
```
_but wait, there's more!_
Github usernames (`@bcoe`) and issue references (#133) will be swapped out for the
appropriate URLs in your CHANGELOG.
## Badges!
Tell your users that you adhere to the Conventional Commits specification:
```markdown
[![Conventional Commits](https://img.shields.io/badge/Conventional%20Commits-1.0.0-yellow.svg)](https://conventionalcommits.org)
```
## FAQ
### How is `standard-version` different from `semantic-release`?
[`semantic-release`](https://github.com/semantic-release/semantic-release) is a fully automated library/system for versioning, changelog generation, git tagging, and publishing to the npm registry.
`standard-version` is different because it handles the versioning, changelog generation, and git tagging for you **without** automatic pushing (to GitHub) or publishing (to an npm registry). Use of `standard-version` only affects your local git repo - it doesn't affect remote resources at all. After you run `standard-version`, you still have to ability to review things and correct mistakes if you want to.
They are both based on the same foundation of structured commit messages (using [Angular format](https://github.com/bcoe/conventional-changelog-standard/blob/master/convention.md)), but `standard-version` is a good choice for folks who are not yet comfortable letting publishes go out automatically. In this way, you can view `standard-version` as an incremental step to adopting `semantic-release`.
We think they are both fantastic tools, and we encourage folks to use `semantic-release` instead of `standard-version` if it makes sense for them.
### Should I always squash commits when merging PRs?
The instructions to squash commits when merging pull requests assumes that **one PR equals, at most, one feature or fix**.
If you have multiple features or fixes landing in a single PR and each commit uses a structured message, then you can do a standard merge when accepting the PR. This will preserve the commit history from your branch after the merge.
Although this will allow each commit to be included as separate entries in your CHANGELOG, the entries will **not** be able to reference the PR that pulled the changes in because the preserved commit messages do not include the PR number.
For this reason, we recommend keeping the scope of each PR to one general feature or fix. In practice, this allows you to use unstructured commit messages when committing each little change and then squash them into a single commit with a structured message (referencing the PR number) once they have been reviewed and accepted.
## License
ISC

19
node_modules/standard-version/appveyor.yml generated vendored Normal file
View File

@@ -0,0 +1,19 @@
environment:
matrix:
- nodejs_version: '6'
install:
- ps: Install-Product node $env:nodejs_version
- git config --global user.name 'Appveyor'
- git config --global user.email 'dummy@example.org'
- set CI=true
- npm -g install npm@latest
- set PATH=%APPDATA%\npm;%PATH%
- npm install
matrix:
fast_finish: true
build: off
version: '{build}'
test_script:
- node --version
- npm --version
- npm test

13
node_modules/standard-version/bin/cli.js generated vendored Executable file
View File

@@ -0,0 +1,13 @@
#!/usr/bin/env node
var standardVersion = require('../index')
var cmdParser = require('../command')
/* istanbul ignore if */
if (process.version.match(/v(\d+)\./)[1] < 4) {
console.error('standard-version: Node v4 or greater is required. `standard-version` did not run.')
} else {
standardVersion(cmdParser.argv)
.catch(() => {
process.exit(1)
})
}

91
node_modules/standard-version/command.js generated vendored Executable file
View File

@@ -0,0 +1,91 @@
var defaults = require('./defaults')
module.exports = require('yargs')
.usage('Usage: $0 [options]')
.option('release-as', {
alias: 'r',
describe: 'Specify the release type manually (like npm version <major|minor|patch>)',
requiresArg: true,
string: true
})
.option('prerelease', {
alias: 'p',
describe: 'make a pre-release with optional option value to specify a tag id',
string: true
})
.option('infile', {
alias: 'i',
describe: 'Read the CHANGELOG from this file',
default: defaults.infile
})
.option('message', {
alias: 'm',
describe: 'Commit message, replaces %s with new version',
type: 'string',
default: defaults.message
})
.option('first-release', {
alias: 'f',
describe: 'Is this the first release?',
type: 'boolean',
default: defaults.firstRelease
})
.option('sign', {
alias: 's',
describe: 'Should the git commit and tag be signed?',
type: 'boolean',
default: defaults.sign
})
.option('no-verify', {
alias: 'n',
describe: 'Bypass pre-commit or commit-msg git hooks during the commit phase',
type: 'boolean',
default: defaults.noVerify
})
.option('commit-all', {
alias: 'a',
describe: 'Commit all staged changes, not just files affected by standard-version',
type: 'boolean',
default: defaults.commitAll
})
.option('silent', {
describe: 'Don\'t print logs and errors',
type: 'boolean',
default: defaults.silent
})
.option('tag-prefix', {
alias: 't',
describe: 'Set a custom prefix for the git tag to be created',
type: 'string',
default: defaults.tagPrefix
})
.option('scripts', {
describe: 'Provide scripts to execute for lifecycle events (prebump, precommit, etc.,)',
default: defaults.scripts
})
.option('skip', {
describe: 'Map of steps in the release process that should be skipped',
default: defaults.skip
})
.option('dry-run', {
type: 'boolean',
default: defaults.dryRun,
describe: 'See the commands that running standard-version would run'
})
.check((argv) => {
if (typeof argv.scripts !== 'object' || Array.isArray(argv.scripts)) {
throw Error('scripts must be an object')
} else if (typeof argv.skip !== 'object' || Array.isArray(argv.skip)) {
throw Error('skip must be an object')
} else {
return true
}
})
.version()
.alias('version', 'v')
.help()
.alias('help', 'h')
.example('$0', 'Update changelog and tag release')
.example('$0 -m "%s: see changelog for details"', 'Update changelog and tag release with custom commit message')
.pkgConf('standard-version')
.wrap(97)

13
node_modules/standard-version/defaults.json generated vendored Normal file
View File

@@ -0,0 +1,13 @@
{
"infile": "CHANGELOG.md",
"message": "chore(release): %s",
"firstRelease": false,
"sign": false,
"noVerify": false,
"commitAll": false,
"silent": false,
"tagPrefix": "v",
"scripts": {},
"skip": {},
"dryRun": false
}

36
node_modules/standard-version/index.js generated vendored Executable file
View File

@@ -0,0 +1,36 @@
const path = require('path')
const printError = require('./lib/print-error')
const bump = require('./lib/lifecycles/bump')
const changelog = require('./lib/lifecycles/changelog')
const commit = require('./lib/lifecycles/commit')
const tag = require('./lib/lifecycles/tag')
module.exports = function standardVersion (argv) {
var pkgPath = path.resolve(process.cwd(), './package.json')
var pkg = require(pkgPath)
var newVersion = pkg.version
var defaults = require('./defaults')
var args = Object.assign({}, defaults, argv)
return Promise.resolve()
.then(() => {
return bump(args, pkg)
})
.then((_newVersion) => {
// if bump runs, it calculaes the new version that we
// should release at.
if (_newVersion) newVersion = _newVersion
return changelog(args, newVersion)
})
.then(() => {
return commit(args, newVersion)
})
.then(() => {
return tag(newVersion, pkg.private, args)
})
.catch((err) => {
printError(args, err.message)
throw err
})
}

12
node_modules/standard-version/lib/checkpoint.js generated vendored Normal file
View File

@@ -0,0 +1,12 @@
const chalk = require('chalk')
const figures = require('figures')
const util = require('util')
module.exports = function (argv, msg, args, figure) {
const defaultFigure = args.dryRun ? chalk.yellow(figures.tick) : chalk.green(figures.tick)
if (!argv.silent) {
console.info((figure || defaultFigure) + ' ' + util.format.apply(util, [msg].concat(args.map(function (arg) {
return chalk.bold(arg)
}))))
}
}

View File

@@ -0,0 +1,10 @@
const util = require('util')
module.exports = function (rawMsg, newVersion) {
const message = String(rawMsg)
const matchCount = (message.match(/%s/g) || []).length
const args = Array(1 + matchCount)
args[0] = message
args.fill(newVersion, 1, args.length)
return util.format.apply(util, args)
}

165
node_modules/standard-version/lib/lifecycles/bump.js generated vendored Normal file
View File

@@ -0,0 +1,165 @@
'use strict'
const chalk = require('chalk')
const checkpoint = require('../checkpoint')
const conventionalRecommendedBump = require('conventional-recommended-bump')
const figures = require('figures')
const fs = require('fs')
const DotGitignore = require('dotgitignore')
const path = require('path')
const runLifecycleScript = require('../run-lifecycle-script')
const semver = require('semver')
const writeFile = require('../write-file')
var configsToUpdate = {}
function Bump (args, pkg) {
// reset the cache of updated config files each
// time we perform the version bump step.
configsToUpdate = {}
if (args.skip.bump) return Promise.resolve()
var newVersion = pkg.version
return runLifecycleScript(args, 'prebump')
.then((stdout) => {
if (stdout && stdout.trim().length) args.releaseAs = stdout.trim()
return bumpVersion(args.releaseAs)
})
.then((release) => {
if (!args.firstRelease) {
var releaseType = getReleaseType(args.prerelease, release.releaseType, pkg.version)
newVersion = semver.valid(releaseType) || semver.inc(pkg.version, releaseType, args.prerelease)
updateConfigs(args, newVersion)
} else {
checkpoint(args, 'skip version bump on first release', [], chalk.red(figures.cross))
}
})
.then(() => {
return runLifecycleScript(args, 'postbump')
})
.then(() => {
return newVersion
})
}
Bump.getUpdatedConfigs = function () {
return configsToUpdate
}
function getReleaseType (prerelease, expectedReleaseType, currentVersion) {
if (isString(prerelease)) {
if (isInPrerelease(currentVersion)) {
if (shouldContinuePrerelease(currentVersion, expectedReleaseType) ||
getTypePriority(getCurrentActiveType(currentVersion)) > getTypePriority(expectedReleaseType)
) {
return 'prerelease'
}
}
return 'pre' + expectedReleaseType
} else {
return expectedReleaseType
}
}
function isString (val) {
return typeof val === 'string'
}
/**
* if a version is currently in pre-release state,
* and if it current in-pre-release type is same as expect type,
* it should continue the pre-release with the same type
*
* @param version
* @param expectType
* @return {boolean}
*/
function shouldContinuePrerelease (version, expectType) {
return getCurrentActiveType(version) === expectType
}
function isInPrerelease (version) {
return Array.isArray(semver.prerelease(version))
}
var TypeList = ['major', 'minor', 'patch'].reverse()
/**
* extract the in-pre-release type in target version
*
* @param version
* @return {string}
*/
function getCurrentActiveType (version) {
var typelist = TypeList
for (var i = 0; i < typelist.length; i++) {
if (semver[typelist[i]](version)) {
return typelist[i]
}
}
}
/**
* calculate the priority of release type,
* major - 2, minor - 1, patch - 0
*
* @param type
* @return {number}
*/
function getTypePriority (type) {
return TypeList.indexOf(type)
}
function bumpVersion (releaseAs, callback) {
return new Promise((resolve, reject) => {
if (releaseAs) {
return resolve({
releaseType: releaseAs
})
} else {
conventionalRecommendedBump({
preset: 'angular'
}, function (err, release) {
if (err) return reject(err)
else return resolve(release)
})
}
})
}
/**
* attempt to update the version # in a collection of common config
* files, e.g., package.json, bower.json.
*
* @param args config object
* @param newVersion version # to update to.
* @return {string}
*/
function updateConfigs (args, newVersion) {
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
Object.keys(configsToUpdate).forEach(function (configPath) {
try {
if (dotgit.ignore(configPath)) return
var stat = fs.lstatSync(configPath)
if (stat.isFile()) {
var config = require(configPath)
var filename = path.basename(configPath)
checkpoint(args, 'bumping version in ' + filename + ' from %s to %s', [config.version, newVersion])
config.version = newVersion
writeFile(args, configPath, JSON.stringify(config, null, 2) + '\n')
// flag any config files that we modify the version # for
// as having been updated.
configsToUpdate[configPath] = true
}
} catch (err) {
if (err.code !== 'ENOENT') console.warn(err.message)
}
})
}
module.exports = Bump

View File

@@ -0,0 +1,62 @@
const accessSync = require('fs-access').sync
const chalk = require('chalk')
const checkpoint = require('../checkpoint')
const conventionalChangelog = require('conventional-changelog')
const fs = require('fs')
const runLifecycleScript = require('../run-lifecycle-script')
const writeFile = require('../write-file')
module.exports = function (args, newVersion) {
if (args.skip.changelog) return Promise.resolve()
return runLifecycleScript(args, 'prechangelog')
.then(() => {
return outputChangelog(args, newVersion)
})
.then(() => {
return runLifecycleScript(args, 'postchangelog')
})
}
function outputChangelog (args, newVersion) {
return new Promise((resolve, reject) => {
createIfMissing(args)
var header = '# Change Log\n\nAll notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.\n'
var oldContent = args.dryRun ? '' : fs.readFileSync(args.infile, 'utf-8')
// find the position of the last release and remove header:
if (oldContent.indexOf('<a name=') !== -1) {
oldContent = oldContent.substring(oldContent.indexOf('<a name='))
}
var content = ''
var context
if (args.dryRun) context = {version: newVersion}
var changelogStream = conventionalChangelog({
preset: 'angular'
}, context, {merges: null})
.on('error', function (err) {
return reject(err)
})
changelogStream.on('data', function (buffer) {
content += buffer.toString()
})
changelogStream.on('end', function () {
checkpoint(args, 'outputting changes to %s', [args.infile])
if (args.dryRun) console.info(`\n---\n${chalk.gray(content.trim())}\n---\n`)
else writeFile(args, args.infile, header + '\n' + (content + oldContent).replace(/\n+$/, '\n'))
return resolve()
})
})
}
function createIfMissing (args) {
try {
accessSync(args.infile, fs.F_OK)
} catch (err) {
if (err.code === 'ENOENT') {
checkpoint(args, 'created %s', [args.infile])
args.outputUnreleased = true
writeFile(args, args.infile, '\n')
}
}
}

39
node_modules/standard-version/lib/lifecycles/commit.js generated vendored Normal file
View File

@@ -0,0 +1,39 @@
const bump = require('../lifecycles/bump')
const checkpoint = require('../checkpoint')
const formatCommitMessage = require('../format-commit-message')
const path = require('path')
const runExec = require('../run-exec')
const runLifecycleScript = require('../run-lifecycle-script')
module.exports = function (args, newVersion) {
if (args.skip.commit) return Promise.resolve()
return runLifecycleScript(args, 'precommit')
.then((message) => {
if (message && message.length) args.message = message
return execCommit(args, newVersion)
})
.then(() => {
return runLifecycleScript(args, 'postcommit')
})
}
function execCommit (args, newVersion) {
var msg = 'committing %s'
var paths = [args.infile]
var verify = args.verify === false || args.n ? '--no-verify ' : ''
var toAdd = ''
// commit any of the config files that we've updated
// the version # for.
Object.keys(bump.getUpdatedConfigs()).forEach(function (p) {
if (bump.getUpdatedConfigs()[p]) {
msg += ' and %s'
paths.unshift(path.basename(p))
toAdd += ' ' + path.relative(process.cwd(), p)
}
})
checkpoint(args, msg, paths)
return runExec(args, 'git add' + toAdd + ' ' + args.infile)
.then(() => {
return runExec(args, 'git commit ' + verify + (args.sign ? '-S ' : '') + (args.commitAll ? '' : (args.infile + toAdd)) + ' -m "' + formatCommitMessage(args.message, newVersion) + '"')
})
}

35
node_modules/standard-version/lib/lifecycles/tag.js generated vendored Normal file
View File

@@ -0,0 +1,35 @@
const chalk = require('chalk')
const checkpoint = require('../checkpoint')
const figures = require('figures')
const formatCommitMessage = require('../format-commit-message')
const runExec = require('../run-exec')
const runLifecycleScript = require('../run-lifecycle-script')
module.exports = function (newVersion, pkgPrivate, args) {
if (args.skip.tag) return Promise.resolve()
return runLifecycleScript(args, 'pretag')
.then(() => {
return execTag(newVersion, pkgPrivate, args)
})
.then(() => {
return runLifecycleScript(args, 'posttag')
})
}
function execTag (newVersion, pkgPrivate, args) {
var tagOption
if (args.sign) {
tagOption = '-s '
} else {
tagOption = '-a '
}
checkpoint(args, 'tagging release %s', [newVersion])
return runExec(args, 'git tag ' + tagOption + args.tagPrefix + newVersion + ' -m "' + formatCommitMessage(args.message, newVersion) + '"')
.then(() => {
var message = 'git push --follow-tags origin master'
if (pkgPrivate !== true) message += ' && npm publish'
if (args.prerelease !== undefined) message += ' --tag prerelease'
checkpoint(args, 'Run `%s` to publish', [message], chalk.blue(figures.info))
})
}

12
node_modules/standard-version/lib/print-error.js generated vendored Normal file
View File

@@ -0,0 +1,12 @@
const chalk = require('chalk')
module.exports = function (args, msg, opts) {
if (!args.silent) {
opts = Object.assign({
level: 'error',
color: 'red'
}, opts)
console[opts.level](chalk[opts.color](msg))
}
}

20
node_modules/standard-version/lib/run-exec.js generated vendored Normal file
View File

@@ -0,0 +1,20 @@
const exec = require('child_process').exec
const printError = require('./print-error')
module.exports = function (args, cmd) {
if (args.dryRun) return Promise.resolve()
return new Promise((resolve, reject) => {
// Exec given cmd and handle possible errors
exec(cmd, function (err, stdout, stderr) {
// If exec returns content in stderr, but no error, print it as a warning
// If exec returns an error, print it and exit with return code 1
if (err) {
printError(args, stderr || err.message)
return reject(err)
} else if (stderr) {
printError(args, stderr, {level: 'warn', color: 'yellow'})
}
return resolve(stdout)
})
})
}

View File

@@ -0,0 +1,12 @@
const chalk = require('chalk')
const checkpoint = require('./checkpoint')
const figures = require('figures')
const runExec = require('./run-exec')
module.exports = function (args, hookName, newVersion, hooks, cb) {
if (!hooks[hookName]) return Promise.resolve()
var command = hooks[hookName] + ' --new-version="' + newVersion + '"'
checkpoint(args, 'Running lifecycle hook "%s"', [hookName])
checkpoint(args, '- hook command: "%s"', [command], chalk.blue(figures.info))
return runExec(args, command)
}

View File

@@ -0,0 +1,13 @@
const chalk = require('chalk')
const checkpoint = require('./checkpoint')
const figures = require('figures')
const runExec = require('./run-exec')
module.exports = function (args, hookName) {
const scripts = args.scripts
if (!scripts || !scripts[hookName]) return Promise.resolve()
var command = scripts[hookName]
checkpoint(args, 'Running lifecycle script "%s"', [hookName])
checkpoint(args, '- execute command: "%s"', [command], chalk.blue(figures.info))
return runExec(args, command)
}

6
node_modules/standard-version/lib/write-file.js generated vendored Normal file
View File

@@ -0,0 +1,6 @@
const fs = require('fs')
module.exports = function (args, filePath, content) {
if (args.dryRun) return
fs.writeFileSync(filePath, content, 'utf8')
}

View File

@@ -0,0 +1 @@
../../../conventional-recommended-bump/cli.js

1
node_modules/standard-version/node_modules/.bin/semver generated vendored Symbolic link
View File

@@ -0,0 +1 @@
../../../semver/bin/semver

60
node_modules/standard-version/package.json generated vendored Normal file
View File

@@ -0,0 +1,60 @@
{
"name": "standard-version",
"version": "4.3.0",
"description": "replacement for `npm version` with automatic CHANGELOG generation",
"bin": "bin/cli.js",
"scripts": {
"pretest": "standard",
"coverage": "nyc report --reporter=text-lcov | coveralls",
"test": "nyc mocha --timeout=20000 test.js",
"release": "bin/cli.js"
},
"nyc": {
"exclude": [
"tmp/**"
]
},
"repository": {
"type": "git",
"url": "git+https://github.com/conventional-changelog/standard-version.git"
},
"engines": {
"node": ">=4.0"
},
"keywords": [
"conventional-changelog",
"recommended",
"changelog",
"automatic",
"workflow",
"version",
"angular",
"standard"
],
"author": "Ben Coe <ben@npmjs.com>",
"license": "ISC",
"bugs": {
"url": "https://github.com/conventional-changelog/standard-version/issues"
},
"homepage": "https://github.com/conventional-changelog/standard-version#readme",
"dependencies": {
"chalk": "^1.1.3",
"conventional-changelog": "^1.1.0",
"conventional-recommended-bump": "^1.0.0",
"dotgitignore": "^1.0.3",
"figures": "^1.5.0",
"fs-access": "^1.0.0",
"semver": "^5.1.0",
"yargs": "^8.0.1"
},
"devDependencies": {
"chai": "^3.5.0",
"coveralls": "^2.11.9",
"mocha": "^3.1.0",
"mock-git": "^1.0.2",
"mockery": "^2.0.0",
"nyc": "^11.0.2",
"shelljs": "^0.7.3",
"standard": "^10.0.0"
}
}

812
node_modules/standard-version/test.js generated vendored Normal file
View File

@@ -0,0 +1,812 @@
/* global describe it beforeEach afterEach */
'use strict'
var shell = require('shelljs')
var fs = require('fs')
var path = require('path')
var stream = require('stream')
var mockGit = require('mock-git')
var mockery = require('mockery')
var semver = require('semver')
var formatCommitMessage = require('./lib/format-commit-message')
var cli = require('./command')
var standardVersion = require('./index')
require('chai').should()
var cliPath = path.resolve(__dirname, './bin/cli.js')
function branch (branch) {
shell.exec('git branch ' + branch)
}
function checkout (branch) {
shell.exec('git checkout ' + branch)
}
function commit (msg) {
shell.exec('git commit --allow-empty -m"' + msg + '"')
}
function merge (msg, branch) {
shell.exec('git merge --no-ff -m"' + msg + '" ' + branch)
}
function execCli (argString) {
return shell.exec('node ' + cliPath + (argString != null ? ' ' + argString : ''))
}
function execCliAsync (argString) {
return standardVersion(cli.parse('standard-version ' + argString + ' --silent'))
}
function writePackageJson (version, option) {
option = option || {}
var pkg = Object.assign(option, {version: version})
fs.writeFileSync('package.json', JSON.stringify(pkg), 'utf-8')
delete require.cache[require.resolve(path.join(process.cwd(), 'package.json'))]
}
function writeBowerJson (version, option) {
option = option || {}
var bower = Object.assign(option, {version: version})
fs.writeFileSync('bower.json', JSON.stringify(bower), 'utf-8')
}
function writeNpmShrinkwrapJson (version, option) {
option = option || {}
var shrinkwrap = Object.assign(option, { version: version })
fs.writeFileSync('npm-shrinkwrap.json', JSON.stringify(shrinkwrap), 'utf-8')
}
function writePackageLockJson (version, option) {
option = option || {}
var pkgLock = Object.assign(option, { version: version })
fs.writeFileSync('package-lock.json', JSON.stringify(pkgLock), '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')
}
function writePostBumpHook (causeError) {
writeHook('postbump', causeError)
}
function writeHook (hookName, causeError, script) {
shell.mkdir('-p', 'scripts')
var content = script || 'console.error("' + hookName + ' ran")'
content += causeError ? '\nthrow new Error("' + hookName + '-failure")' : ''
fs.writeFileSync('scripts/' + hookName + '.js', content, 'utf-8')
fs.chmodSync('scripts/' + hookName + '.js', '755')
}
function initInTempFolder () {
shell.rm('-rf', 'tmp')
shell.config.silent = true
shell.mkdir('tmp')
shell.cd('tmp')
shell.exec('git init')
commit('root-commit')
writePackageJson('1.0.0')
}
function finishTemp () {
shell.cd('../')
shell.rm('-rf', 'tmp')
}
function getPackageVersion () {
return JSON.parse(fs.readFileSync('package.json', 'utf-8')).version
}
describe('format-commit-message', function () {
it('works for no %s', function () {
formatCommitMessage('chore(release): 1.0.0', '1.0.0').should.equal('chore(release): 1.0.0')
})
it('works for one %s', function () {
formatCommitMessage('chore(release): %s', '1.0.0').should.equal('chore(release): 1.0.0')
})
it('works for two %s', function () {
formatCommitMessage('chore(release): %s \n\n* CHANGELOG: https://github.com/conventional-changelog/standard-version/blob/v%s/CHANGELOG.md', '1.0.0').should.equal('chore(release): 1.0.0 \n\n* CHANGELOG: https://github.com/conventional-changelog/standard-version/blob/v1.0.0/CHANGELOG.md')
})
})
describe('cli', function () {
beforeEach(initInTempFolder)
afterEach(finishTemp)
describe('CHANGELOG.md does not exist', function () {
it('populates changelog with commits since last tag by default', function () {
commit('feat: first commit')
shell.exec('git tag -a v1.0.0 -m "my awesome first release"')
commit('fix: patch release')
execCli().code.should.equal(0)
var content = fs.readFileSync('CHANGELOG.md', 'utf-8')
content.should.match(/patch release/)
content.should.not.match(/first commit/)
})
it('includes all commits if --first-release is true', function () {
writePackageJson('1.0.1')
commit('feat: first commit')
commit('fix: patch release')
execCli('--first-release').code.should.equal(0)
var content = fs.readFileSync('CHANGELOG.md', 'utf-8')
content.should.match(/patch release/)
content.should.match(/first commit/)
shell.exec('git tag').stdout.should.match(/1\.0\.1/)
})
})
describe('CHANGELOG.md exists', function () {
it('appends the new release above the last release, removing the old header', function () {
fs.writeFileSync('CHANGELOG.md', 'legacy header format<a name="1.0.0">\n', 'utf-8')
commit('feat: first commit')
shell.exec('git tag -a v1.0.0 -m "my awesome first release"')
commit('fix: patch release')
execCli().code.should.equal(0)
var content = fs.readFileSync('CHANGELOG.md', 'utf-8')
content.should.match(/1\.0\.1/)
content.should.not.match(/legacy header format/)
})
it('commits all staged files', function () {
fs.writeFileSync('CHANGELOG.md', 'legacy header format<a name="1.0.0">\n', 'utf-8')
commit('feat: first commit')
shell.exec('git tag -a v1.0.0 -m "my awesome first release"')
commit('fix: patch release')
fs.writeFileSync('STUFF.md', 'stuff\n', 'utf-8')
shell.exec('git add STUFF.md')
execCli('--commit-all').code.should.equal(0)
var content = fs.readFileSync('CHANGELOG.md', 'utf-8')
var status = shell.exec('git status --porcelain') // see http://unix.stackexchange.com/questions/155046/determine-if-git-working-directory-is-clean-from-a-script
status.should.equal('')
status.should.not.match(/STUFF.md/)
content.should.match(/1\.0\.1/)
content.should.not.match(/legacy header format/)
})
})
describe('with mocked git', function () {
it('--sign signs the commit and tag', function () {
// mock git with file that writes args to gitcapture.log
return mockGit('require("fs").appendFileSync("gitcapture.log", JSON.stringify(process.argv.splice(2)) + "\\n")')
.then(function (unmock) {
execCli('--sign').code.should.equal(0)
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', 'CHANGELOG.md', 'package.json', '-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
return mockGit('console.error("commit yourself"); process.exit(128);', 'commit')
.then(function (unmock) {
var result = execCli()
result.code.should.equal(1)
result.stderr.should.match(/commit yourself/)
unmock()
})
})
it('exits with error code if git add fails', function () {
// mock git by throwing on attempt to add
return mockGit('console.error("addition is hard"); process.exit(128);', 'add')
.then(function (unmock) {
var result = execCli()
result.code.should.equal(1)
result.stderr.should.match(/addition is hard/)
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) {
var result = execCli()
result.code.should.equal(1)
result.stderr.should.match(/tag, you're it/)
unmock()
})
})
it('doesn\'t fail fast on stderr output from git', function () {
// mock git by throwing on attempt to commit
return mockGit('console.error("haha, kidding, this is just a warning"); process.exit(0);', 'add')
.then(function (unmock) {
writePackageJson('1.0.0')
var result = execCli()
result.code.should.equal(0)
result.stderr.should.match(/haha, kidding, this is just a warning/)
unmock()
})
})
})
describe('lifecycle scripts', () => {
describe('prebump hook', function () {
it('should allow prebump hook to return an alternate version #', function () {
writePackageJson('1.0.0', {
'standard-version': {
'scripts': {
'prebump': 'node scripts/prebump'
}
}
})
writeHook('prebump', false, 'console.log("9.9.9")')
fs.writeFileSync('CHANGELOG.md', 'legacy header format<a name="1.0.0">\n', 'utf-8')
commit('feat: first commit')
var result = execCli('--patch')
result.stdout.should.match(/9\.9\.9/)
result.code.should.equal(0)
})
})
describe('postbump hook', function () {
it('should run the postbump hook when provided', function () {
writePackageJson('1.0.0', {
'standard-version': {
'scripts': {
'postbump': 'node scripts/postbump'
}
}
})
writePostBumpHook()
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(/postbump ran/)
})
it('should run the postbump and exit with error when postbump fails', function () {
writePackageJson('1.0.0', {
'standard-version': {
'scripts': {
'postbump': 'node scripts/postbump'
}
}
})
writePostBumpHook(true)
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(/postbump-failure/)
})
})
describe('precommit hook', function () {
it('should run the precommit hook when provided', function () {
writePackageJson('1.0.0', {
'standard-version': {
'scripts': {
'precommit': 'node scripts/precommit'
}
}
})
writeHook('precommit')
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(/precommit ran/)
})
it('should run the precommit hook and exit with error when precommit fails', function () {
writePackageJson('1.0.0', {
'standard-version': {
'scripts': {
'precommit': 'node scripts/precommit'
}
}
})
writeHook('precommit', true)
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(/precommit-failure/)
})
it('should allow an alternate commit message to be provided by precommit script', function () {
writePackageJson('1.0.0', {
'standard-version': {
'scripts': {
'precommit': 'node scripts/precommit'
}
}
})
writeHook('precommit', false, 'console.log("releasing %s delivers #222")')
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)
shell.exec('git log --oneline -n1').should.match(/delivers #222/)
})
})
})
describe('pre-release', function () {
it('works fine without specifying a tag id when prereleasing', function () {
writePackageJson('1.0.0')
fs.writeFileSync('CHANGELOG.md', 'legacy header format<a name="1.0.0">\n', 'utf-8')
commit('feat: first commit')
return execCliAsync('--prerelease')
.then(function () {
// it's a feature commit, so it's minor type
getPackageVersion().should.equal('1.1.0-0')
})
})
it('advises use of --tag prerelease for publishing to npm', function () {
writePackageJson('1.0.0')
fs.writeFileSync('CHANGELOG.md', 'legacy header format<a name="1.0.0">\n', 'utf-8')
commit('feat: first commit')
execCli('--prerelease').stdout.should.include('--tag prerelease')
})
})
describe('manual-release', function () {
it('throws error when not specifying a release type', function () {
writePackageJson('1.0.0')
fs.writeFileSync('CHANGELOG.md', 'legacy header format<a name="1.0.0">\n', 'utf-8')
commit('fix: first commit')
execCli('--release-as').code.should.above(0)
})
describe('release-types', function () {
var regularTypes = ['major', 'minor', 'patch']
regularTypes.forEach(function (type) {
it('creates a ' + type + ' release', function () {
var originVer = '1.0.0'
writePackageJson(originVer)
fs.writeFileSync('CHANGELOG.md', 'legacy header format<a name="1.0.0">\n', 'utf-8')
commit('fix: first commit')
return execCliAsync('--release-as ' + type)
.then(function () {
var version = {
major: semver.major(originVer),
minor: semver.minor(originVer),
patch: semver.patch(originVer)
}
version[type] += 1
getPackageVersion().should.equal(version.major + '.' + version.minor + '.' + version.patch)
})
})
})
// this is for pre-releases
regularTypes.forEach(function (type) {
it('creates a pre' + type + ' release', function () {
var originVer = '1.0.0'
writePackageJson(originVer)
fs.writeFileSync('CHANGELOG.md', 'legacy header format<a name="1.0.0">\n', 'utf-8')
commit('fix: first commit')
return execCliAsync('--release-as ' + type + ' --prerelease ' + type)
.then(function () {
var version = {
major: semver.major(originVer),
minor: semver.minor(originVer),
patch: semver.patch(originVer)
}
version[type] += 1
getPackageVersion().should.equal(version.major + '.' + version.minor + '.' + version.patch + '-' + type + '.0')
})
})
})
})
describe('release-as-exact', function () {
it('releases as v100.0.0', function () {
var originVer = '1.0.0'
writePackageJson(originVer)
fs.writeFileSync('CHANGELOG.md', 'legacy header format<a name="1.0.0">\n', 'utf-8')
commit('fix: first commit')
return execCliAsync('--release-as v100.0.0')
.then(function () {
getPackageVersion().should.equal('100.0.0')
})
})
it('releases as 200.0.0-amazing', function () {
var originVer = '1.0.0'
writePackageJson(originVer)
fs.writeFileSync('CHANGELOG.md', 'legacy header format<a name="1.0.0">\n', 'utf-8')
commit('fix: first commit')
return execCliAsync('--release-as 200.0.0-amazing')
.then(function () {
getPackageVersion().should.equal('200.0.0-amazing')
})
})
})
it('creates a prerelease with a new minor version after two prerelease patches', function () {
writePackageJson('1.0.0')
fs.writeFileSync('CHANGELOG.md', 'legacy header format<a name="1.0.0">\n', 'utf-8')
commit('fix: first patch')
return execCliAsync('--release-as patch --prerelease dev')
.then(function () {
getPackageVersion().should.equal('1.0.1-dev.0')
})
// second
.then(function () {
commit('fix: second patch')
return execCliAsync('--prerelease dev')
})
.then(function () {
getPackageVersion().should.equal('1.0.1-dev.1')
})
// third
.then(function () {
commit('feat: first new feat')
return execCliAsync('--release-as minor --prerelease dev')
})
.then(function () {
getPackageVersion().should.equal('1.1.0-dev.0')
})
.then(function () {
commit('fix: third patch')
return execCliAsync('--release-as minor --prerelease dev')
})
.then(function () {
getPackageVersion().should.equal('1.1.0-dev.1')
})
.then(function () {
commit('fix: forth patch')
return execCliAsync('--prerelease dev')
})
.then(function () {
getPackageVersion().should.equal('1.1.0-dev.2')
})
})
})
it('handles commit messages longer than 80 characters', function () {
commit('feat: first commit')
shell.exec('git tag -a v1.0.0 -m "my awesome first release"')
commit('fix: this is my fairly long commit message which is testing whether or not we allow for long commit messages')
execCli().code.should.equal(0)
var content = fs.readFileSync('CHANGELOG.md', 'utf-8')
content.should.match(/this is my fairly long commit message which is testing whether or not we allow for long commit messages/)
})
it('formats the commit and tag messages appropriately', function () {
commit('feat: first commit')
shell.exec('git tag -a v1.0.0 -m "my awesome first release"')
commit('feat: new feature!')
execCli().code.should.equal(0)
// check last commit message
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/)
})
it('appends line feed at end of package.json', function () {
execCli().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 () {
writeGitPreCommitHook()
commit('feat: first commit')
execCli('--no-verify').code.should.equal(0)
commit('feat: second commit')
execCli('-n').code.should.equal(0)
})
it('does not print output when the --silent flag is passed', function () {
var result = execCli('--silent')
result.code.should.equal(0)
result.stdout.should.equal('')
result.stderr.should.equal('')
})
it('does not display `npm publish` if the package is private', function () {
writePackageJson('1.0.0', {private: true})
var result = execCli()
result.code.should.equal(0)
result.stdout.should.not.match(/npm publish/)
})
it('includes merge commits', function () {
var branchName = 'new-feature'
commit('feat: first commit')
shell.exec('git tag -a v1.0.0 -m "my awesome first release"')
branch(branchName)
checkout(branchName)
commit('Implementing new feature')
checkout('master')
merge('feat: new feature from branch', branchName)
execCli().code.should.equal(0)
var content = fs.readFileSync('CHANGELOG.md', 'utf-8')
content.should.match(/new feature from branch/)
var pkgJson = fs.readFileSync('package.json', 'utf-8')
pkgJson.should.equal(['{', ' "version": "1.1.0"', '}', ''].join('\n'))
})
it('exits with error code if "scripts" is not an object', () => {
writePackageJson('1.0.0', {
'standard-version': {
scripts: 'echo hello'
}
})
commit('feat: first commit')
var result = execCli()
result.code.should.equal(1)
result.stderr.should.match(/scripts must be an object/)
})
it('exits with error code if "skip" is not an object', () => {
writePackageJson('1.0.0', {
'standard-version': {
skip: true
}
})
commit('feat: first commit')
var result = execCli()
result.code.should.equal(1)
result.stderr.should.match(/skip must be an object/)
})
})
describe('standard-version', function () {
beforeEach(initInTempFolder)
afterEach(finishTemp)
describe('with mocked conventionalRecommendedBump', function () {
beforeEach(function () {
mockery.enable({warnOnUnregistered: false, useCleanCache: true})
mockery.registerMock('conventional-recommended-bump', function (_, cb) {
cb(new Error('bump err'))
})
})
afterEach(function () {
mockery.deregisterMock('conventional-recommended-bump')
mockery.disable()
})
it('should exit on bump error', function (done) {
commit('feat: first commit')
shell.exec('git tag -a v1.0.0 -m "my awesome first release"')
commit('feat: new feature!')
require('./index')({silent: true})
.catch((err) => {
err.message.should.match(/bump err/)
done()
})
})
})
describe('with mocked conventionalChangelog', function () {
beforeEach(function () {
mockery.enable({warnOnUnregistered: false, useCleanCache: true})
mockery.registerMock('conventional-changelog', function () {
var readable = new stream.Readable({objectMode: true})
readable._read = function () {
}
setImmediate(readable.emit.bind(readable), 'error', new Error('changelog err'))
return readable
})
})
afterEach(function () {
mockery.deregisterMock('conventional-changelog')
mockery.disable()
})
it('should exit on changelog error', function (done) {
commit('feat: first commit')
shell.exec('git tag -a v1.0.0 -m "my awesome first release"')
commit('feat: new feature!')
require('./index')({silent: true})
.catch((err) => {
err.message.should.match(/changelog err/)
return done()
})
})
})
it('formats the commit and tag messages appropriately', function (done) {
commit('feat: first commit')
shell.exec('git tag -a v1.0.0 -m "my awesome first release"')
commit('feat: new feature!')
require('./index')({silent: true})
.then(() => {
// check last commit message
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/)
done()
})
})
describe('bower.json support', function () {
beforeEach(function () {
writeBowerJson('1.0.0')
})
it('bumps version # in bower.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('bower.json', 'utf-8')).version.should.equal('1.1.0')
getPackageVersion().should.equal('1.1.0')
})
})
})
describe('npm-shrinkwrap.json support', function () {
beforeEach(function () {
writeNpmShrinkwrapJson('1.0.0')
})
it('bumps version # in npm-shrinkwrap.json', function (done) {
commit('feat: first commit')
shell.exec('git tag -a v1.0.0 -m "my awesome first release"')
commit('feat: new feature!')
require('./index')({silent: true})
.then(() => {
JSON.parse(fs.readFileSync('npm-shrinkwrap.json', 'utf-8')).version.should.equal('1.1.0')
getPackageVersion().should.equal('1.1.0')
return done()
})
})
})
describe('package-lock.json support', function () {
beforeEach(function () {
writePackageLockJson('1.0.0')
fs.writeFileSync('.gitignore', '', 'utf-8')
})
it('bumps version # in package-lock.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('package-lock.json', 'utf-8')).version.should.equal('1.1.0')
getPackageVersion().should.equal('1.1.0')
})
})
})
describe('dry-run', function () {
it('skips all non-idempotent steps', function (done) {
commit('feat: first commit')
shell.exec('git tag -a v1.0.0 -m "my awesome first release"')
commit('feat: new feature!')
execCli('--dry-run').stdout.should.match(/### Features/)
shell.exec('git log --oneline -n1').stdout.should.match(/feat: new feature!/)
shell.exec('git tag').stdout.should.match(/1\.0\.0/)
getPackageVersion().should.equal('1.0.0')
return done()
})
})
describe('skip', () => {
it('allows bump and changelog generation to be skipped', function () {
let changelogContent = 'legacy header format<a name="1.0.0">\n'
writePackageJson('1.0.0')
fs.writeFileSync('CHANGELOG.md', changelogContent, 'utf-8')
commit('feat: first commit')
return execCliAsync('--skip.bump true --skip.changelog true')
.then(function () {
getPackageVersion().should.equal('1.0.0')
var content = fs.readFileSync('CHANGELOG.md', 'utf-8')
content.should.equal(changelogContent)
})
})
it('allows the commit phase to be skipped', function () {
let changelogContent = 'legacy header format<a name="1.0.0">\n'
writePackageJson('1.0.0')
fs.writeFileSync('CHANGELOG.md', changelogContent, 'utf-8')
commit('feat: new feature from branch')
return execCliAsync('--skip.commit true')
.then(function () {
getPackageVersion().should.equal('1.1.0')
var content = fs.readFileSync('CHANGELOG.md', 'utf-8')
content.should.match(/new feature from branch/)
// check last commit message
shell.exec('git log --oneline -n1').stdout.should.match(/feat: new feature from branch/)
})
})
})
describe('.gitignore', () => {
beforeEach(function () {
writeBowerJson('1.0.0')
})
it('does not update files present in .gitignore', () => {
fs.writeFileSync('.gitignore', 'bower.json', 'utf-8')
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('bower.json', 'utf-8')).version.should.equal('1.0.0')
getPackageVersion().should.equal('1.1.0')
})
})
})
})