Skip to content

Commit 5600572

Browse files
nexdrewbcoe
authored andcommitted
docs(README): add faq and more details on installation/usage (#26)
* docs(README): add faq and more details on installation/usage * chore(keywords): add standard keyword \o/
1 parent c6c8930 commit 5600572

File tree

2 files changed

+97
-21
lines changed

2 files changed

+97
-21
lines changed

README.md

Lines changed: 94 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -7,40 +7,36 @@
77

88
> stop using `npm version`, use `standard-version` it rocks!
99
10-
Automatic release and CHANGELOG management, using GitHub's new squash button and
11-
the workflow outlined in [conventional-changelog-standard](https://github.com/bcoe/conventional-changelog-standard/blob/master/convention.md).
10+
Automatic versioning and CHANGELOG management, using GitHub's new squash button and
11+
the [recommended workflow](https://github.com/conventional-changelog/conventional-changelog-cli#recommended-workflow) for `conventional-changelog`.
1212

1313
_how it works:_
1414

1515
1. when you land commits on your `master` branch, select the _Squash and Merge_ option.
1616
2. add a title and body that follows the [conventional-changelog-standard conventions](https://github.com/bcoe/conventional-changelog-standard/blob/master/convention.md).
1717
3. when you're ready to release to npm:
18-
1. checkout `master`.
19-
2. run `standard-version`.
20-
3. `git push --follow-tags origin master; npm publish`.
18+
1. `git checkout master; git pull origin master`
19+
2. run `standard-version`
20+
3. `git push --follow-tags origin master; npm publish`
2121

2222
`standard-version` does the following:
2323

24-
1. bumps the version in package.json (based on your commit history).
25-
2. uses [conventional-changelog](https://github.com/conventional-changelog/conventional-changelog) to update _CHANGELOG.md._
26-
3. commits _package.json_ and _CHANGELOG.md_.
27-
4. tags a new release.
28-
29-
## Initial CHANGELOG.md Generation
30-
31-
When you're generating your changelog for the first time, simply do:
32-
33-
`standard-version --first-release`
24+
1. bumps the version in _package.json_ (based on your commit history)
25+
2. uses [conventional-changelog](https://github.com/conventional-changelog/conventional-changelog) to update _CHANGELOG.md_
26+
3. commits _package.json_ and _CHANGELOG.md_
27+
4. tags a new release
3428

3529
## Installation
3630

37-
`npm i standard-version -g`
31+
### As `npm run` script
3832

39-
_Or, add it as a development dependency like so:_
33+
Install and add to `devDependencies`:
4034

41-
`npm i standard-version --save-dev`
35+
```
36+
npm i --save-dev standard-version
37+
```
4238

43-
_And add this to your _package.json:_
39+
Add an [`npm run` script](https://docs.npmjs.com/cli/run-script) to your _package.json_:
4440

4541
```json
4642
{
@@ -50,6 +46,63 @@ _And add this to your _package.json:_
5046
}
5147
```
5248

49+
Now you can use `npm run release` in place of `npm version`.
50+
51+
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.
52+
53+
### As global bin
54+
55+
Install globally (add to your `PATH`):
56+
57+
```
58+
npm i -g standard-version
59+
```
60+
61+
Now you can use `standard-version` in place of `npm version`.
62+
63+
This has the benefit of allowing you to use `standard-version` on any repo/package without adding a dev dependency to each one.
64+
65+
## Usage
66+
67+
### First Release
68+
69+
To generate your changelog for your first release, simply do:
70+
71+
```sh
72+
# npm run script
73+
npm run release -- --first-release
74+
# or global bin
75+
standard-version --first-release
76+
```
77+
78+
This will tag a release **without bumping the version in package.json**.
79+
80+
When ready, push the git tag and `npm publish` your first release. \o/
81+
82+
### Cut a Release
83+
84+
If you typically use `npm version` to cut a new release, do this instead:
85+
86+
```sh
87+
# npm run script
88+
npm run release
89+
# or global bin
90+
standard-version
91+
```
92+
93+
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/
94+
95+
After you cut a release, you can push the new git tag and `npm publish` (or `npm publish --tag next`) when you're ready.
96+
97+
### CLI Help
98+
99+
```sh
100+
# npm run script
101+
npm run release -- --help
102+
# or global bin
103+
standard-version --help
104+
```
105+
53106
## Commit Message Convention, at a Glance
54107

55108
_patches:_
@@ -92,6 +145,28 @@ Tell your users that you adhere to the `standard-version` commit guidelines:
92145
[![Standard Version](https://img.shields.io/badge/release-standard%20version-brightgreen.svg)](https://github.com/conventional-changelog/standard-version)
93146
```
94147

148+
## FAQ
149+
150+
### How is `standard-version` different from `semantic-release`?
151+
152+
[`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.
153+
154+
`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.
155+
156+
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`.
157+
158+
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.
159+
160+
### Should I always squash commits when merging PRs?
161+
162+
The instructions to squash commits when merging pull requests assumes that **one PR equals, at most, one feature or fix**.
163+
164+
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.
165+
166+
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.
167+
168+
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.
169+
95170
## License
96171

97172
ISC

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@
1919
"automatic",
2020
"workflow",
2121
"version",
22-
"angular"
22+
"angular",
23+
"standard"
2324
],
2425
"author": "Ben Coe <[email protected]>",
2526
"license": "ISC",
@@ -45,4 +46,4 @@
4546
"shelljs": "^0.6.0",
4647
"standard": "^6.0.8"
4748
}
48-
}
49+
}

0 commit comments

Comments
 (0)