@picgo/bump-version 1.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.cz-config.js +75 -0
- package/.eslintrc +6 -0
- package/.github/workflows/main.yml +21 -0
- package/.github/workflows/manually.yml +18 -0
- package/.travis.deprecate.yml +24 -0
- package/CHANGELOG.md +76 -0
- package/License +21 -0
- package/README.md +286 -0
- package/bin/bump-version +114 -0
- package/commitlint-picgo/index.js +25 -0
- package/commitlint-picgo/types.js +17 -0
- package/conventional-changelog-picgo/LICENSE.md +15 -0
- package/conventional-changelog-picgo/conventional-changelog.js +10 -0
- package/conventional-changelog-picgo/conventional-recommended-bump.js +32 -0
- package/conventional-changelog-picgo/index.js +11 -0
- package/conventional-changelog-picgo/parser-opts.js +11 -0
- package/conventional-changelog-picgo/templates/commit.hbs +61 -0
- package/conventional-changelog-picgo/templates/footer.hbs +11 -0
- package/conventional-changelog-picgo/templates/header.hbs +13 -0
- package/conventional-changelog-picgo/templates/template.hbs +16 -0
- package/conventional-changelog-picgo/writer-opts.js +126 -0
- package/package.json +65 -0
- package/src/bumpVersion.js +26 -0
- package/src/changelog.js +41 -0
- package/src/commit.js +21 -0
- package/src/exec.js +19 -0
- package/src/logger.js +15 -0
- package/src/mainLifeCycle.js +25 -0
- package/src/ora.js +4 -0
- package/src/tag.js +19 -0
- package/src/utils.js +53 -0
package/.cz-config.js
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
// types,
|
|
3
|
+
types: [
|
|
4
|
+
{
|
|
5
|
+
value: ":sparkles: Feature",
|
|
6
|
+
name: "Feature: when adding new features"
|
|
7
|
+
},
|
|
8
|
+
{
|
|
9
|
+
value: ":bug: Fix",
|
|
10
|
+
name: "Fix: when fixing bugs"
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
value: ":construction: WIP",
|
|
14
|
+
name: "WIP: when working in progress"
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
value: ":hammer: Refactor",
|
|
18
|
+
name: "Refactor: when changing the code without adding features or fixing bugs"
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
value: ":package: Chore",
|
|
22
|
+
name: "Chore: when changing the build process or auxiliary tools and libraries such as documentation generation"
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
value: ":art: Style",
|
|
26
|
+
name: "Style: when improving the format/structure of the code"
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
value: ":arrow_up: Upgrade",
|
|
30
|
+
name: "Upgrade: when upgrading dependencies"
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
value: ":zap: Perf",
|
|
34
|
+
name: "Perf: when improving performance"
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
value: ":pencil: Docs",
|
|
38
|
+
name: "Docs: when wrting docs"
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
value: ":white_check_mark: Test",
|
|
42
|
+
name: "Test: when adding or updating tests"
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
value: ":back: Revert",
|
|
46
|
+
name: "Revert: when reverting some commits"
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
value: ":tada: Release",
|
|
50
|
+
name: "Release: when releasing a new version"
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
value: ":pushpin: Init",
|
|
54
|
+
name: "Init: when initializing a project"
|
|
55
|
+
}
|
|
56
|
+
],
|
|
57
|
+
|
|
58
|
+
// override the messages, defaults are as follows
|
|
59
|
+
messages: {
|
|
60
|
+
type: "Select the type of change that you're committing:",
|
|
61
|
+
scope: "\nDenote the SCOPE of this change (optional):",
|
|
62
|
+
// used if allowCustomScopes is true
|
|
63
|
+
customScope: "Denote the SCOPE of this change:",
|
|
64
|
+
subject: "[subject] Write a SHORT, IMPERATIVE tense description of the change:\n",
|
|
65
|
+
body:
|
|
66
|
+
'[body] Provide a LONGER description of the change (optional). Use "|" to break new line:\n',
|
|
67
|
+
breaking: "List any BREAKING CHANGES (optional):\n",
|
|
68
|
+
footer:
|
|
69
|
+
"[footer] List any ISSUES CLOSED by this change (optional). E.g.: #31, #34:\n",
|
|
70
|
+
confirmCommit: "Are you sure you want to proceed with the commit above?"
|
|
71
|
+
},
|
|
72
|
+
|
|
73
|
+
allowCustomScopes: false,
|
|
74
|
+
allowBreakingChanges: [":sparkles: Feature", ":bug: Fix"]
|
|
75
|
+
};
|
package/.eslintrc
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
name: publish
|
|
2
|
+
on:
|
|
3
|
+
push:
|
|
4
|
+
branches:
|
|
5
|
+
- master
|
|
6
|
+
jobs:
|
|
7
|
+
build:
|
|
8
|
+
runs-on: ubuntu-latest
|
|
9
|
+
steps:
|
|
10
|
+
- name: Clone repo
|
|
11
|
+
uses: actions/checkout@v1
|
|
12
|
+
- name: Setup node
|
|
13
|
+
uses: actions/setup-node@v1
|
|
14
|
+
with:
|
|
15
|
+
node-version: '12.x'
|
|
16
|
+
registry-url: 'https://registry.npmjs.org'
|
|
17
|
+
- name: Install modules
|
|
18
|
+
run: yarn
|
|
19
|
+
- run: npm publish --access public
|
|
20
|
+
env:
|
|
21
|
+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
name: manually-trigger
|
|
2
|
+
on: workflow_dispatch
|
|
3
|
+
jobs:
|
|
4
|
+
build:
|
|
5
|
+
runs-on: ubuntu-latest
|
|
6
|
+
steps:
|
|
7
|
+
- name: Clone repo
|
|
8
|
+
uses: actions/checkout@v1
|
|
9
|
+
- name: Setup node
|
|
10
|
+
uses: actions/setup-node@v1
|
|
11
|
+
with:
|
|
12
|
+
node-version: '12.x'
|
|
13
|
+
registry-url: 'https://registry.npmjs.org'
|
|
14
|
+
- name: Install modules
|
|
15
|
+
run: yarn
|
|
16
|
+
- run: npm publish --access public
|
|
17
|
+
env:
|
|
18
|
+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
language: node_js
|
|
2
|
+
node_js: stable
|
|
3
|
+
|
|
4
|
+
# Travis-CI Caching
|
|
5
|
+
cache:
|
|
6
|
+
directories:
|
|
7
|
+
- node_modules
|
|
8
|
+
|
|
9
|
+
stages:
|
|
10
|
+
- name: deploy
|
|
11
|
+
|
|
12
|
+
jobs:
|
|
13
|
+
include:
|
|
14
|
+
- stage: deploy
|
|
15
|
+
deploy:
|
|
16
|
+
provider: npm
|
|
17
|
+
email: "marksz@teamsz.xyz"
|
|
18
|
+
api_key: "${NPM_TOKEN}"
|
|
19
|
+
skip_cleanup: true
|
|
20
|
+
on:
|
|
21
|
+
branch: master
|
|
22
|
+
branches:
|
|
23
|
+
only:
|
|
24
|
+
- master
|
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
## :tada: 1.1.2 (2021-09-16)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### :package: Chore
|
|
5
|
+
|
|
6
|
+
* change travis-ci -> github actions ([d3c896f](https://github.com/PicGo/bump-version/commit/d3c896f))
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
## :tada: 1.1.1 (2021-04-10)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
# :tada: 1.1.0 (2020-04-30)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
### :sparkles: Features
|
|
18
|
+
|
|
19
|
+
* change some dev deps to deps ([12bd7b0](https://github.com/PicGo/bump-version/commit/12bd7b0))
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
## :tada: 1.0.3 (2019-05-11)
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
### :sparkles: Features
|
|
27
|
+
|
|
28
|
+
* **header:** add header-max-length from 72 to 100 ([7a5ec79](https://github.com/PicGo/bump-version/commit/7a5ec79))
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
### :bug: Bug Fixes
|
|
32
|
+
|
|
33
|
+
* **lint:** subject case can't be sentence-case ([860a327](https://github.com/PicGo/bump-version/commit/860a327))
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
### :pencil: Documentation
|
|
37
|
+
|
|
38
|
+
* refine readme ([#1](https://github.com/PicGo/bump-version/issues/1)) ([1984de2](https://github.com/PicGo/bump-version/commit/1984de2))
|
|
39
|
+
* remove a comma ([f484287](https://github.com/PicGo/bump-version/commit/f484287))
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
## :tada: 1.0.2 (2019-04-10)
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
### :bug: Bug Fixes
|
|
47
|
+
|
|
48
|
+
* preid command from 'pa' to 'a' && eslint error ([cf989fa](https://github.com/PicGo/bump-version/commit/cf989fa))
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
### :pencil: Documentation
|
|
52
|
+
|
|
53
|
+
* fix word error && change version badge ([0cbeb79](https://github.com/PicGo/bump-version/commit/0cbeb79))
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
## :tada: 1.0.1 (2019-04-09)
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
### :bug: Bug Fixes
|
|
61
|
+
|
|
62
|
+
* npm test command missed ([0c5301f](https://github.com/PicGo/bump-version/commit/0c5301f))
|
|
63
|
+
* symbolic links bug ([1a95111](https://github.com/PicGo/bump-version/commit/1a95111))
|
|
64
|
+
* travis yarn test bug ([77e97d4](https://github.com/PicGo/bump-version/commit/77e97d4))
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
# :tada: 1.0.0 (2019-04-09)
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
### :pushpin: Init
|
|
72
|
+
|
|
73
|
+
* picgo bump-version init commit ([b04432f](https://github.com/PicGo/bump-version/commit/b04432f))
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
|
package/License
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2019 PicGo
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,286 @@
|
|
|
1
|
+
# PicGo BumpVersion
|
|
2
|
+
|
|
3
|
+
A full `git commit` -> `changelog` -> `release` workflow & convention.
|
|
4
|
+
|
|
5
|
+
It's now only available for Node.js projects. Thanks [standard-version](https://github.com/conventional-changelog/standard-version) for the inspiration.
|
|
6
|
+
|
|
7
|
+
<p align="center">
|
|
8
|
+
<img src="https://raw.githubusercontent.com/Molunerfinn/test/master/picgo/New%20LOGO-150.png" alt="">
|
|
9
|
+
</p>
|
|
10
|
+
<p align="center">
|
|
11
|
+
<a href="https://github.com/feross/standard">
|
|
12
|
+
<img src="https://img.shields.io/badge/code%20style-standard-green.svg?style=flat-square" alt="">
|
|
13
|
+
</a>
|
|
14
|
+
<a href="https://github.com/PicGo/bump-version/releases/latest">
|
|
15
|
+
<img src="https://img.shields.io/npm/v/@picgo/bump-version.svg?style=flat-square" alt="">
|
|
16
|
+
</a>
|
|
17
|
+
<a href="https://github.com/PicGo/bump-version">
|
|
18
|
+
<img src="https://img.shields.io/badge/picgo-convention-blue.svg?style=flat-square" alt="">
|
|
19
|
+
</a>
|
|
20
|
+
</p>
|
|
21
|
+
|
|
22
|
+
## Installation
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
npm install -D @picgo/bump-version
|
|
26
|
+
|
|
27
|
+
#or
|
|
28
|
+
|
|
29
|
+
yarn add -D @picgo/bump-version
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
Also, add the following data at the top level in your `package.json` to properly config `bump-version` (replace old `config` if you have already configured `commitizen` or `cz-customizable` before):
|
|
33
|
+
|
|
34
|
+
```json
|
|
35
|
+
"husky": {
|
|
36
|
+
"hooks": {
|
|
37
|
+
"commit-msg": "commitlint -E HUSKY_GIT_PARAMS"
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
"config": {
|
|
41
|
+
"commitizen": {
|
|
42
|
+
"path": "./node_modules/cz-customizable"
|
|
43
|
+
},
|
|
44
|
+
"cz-customizable": {
|
|
45
|
+
"config": "./node_modules/@picgo/bump-version/.cz-config.js"
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
"commitlint": {
|
|
49
|
+
"extends": ["./node_modules/@picgo/bump-version/commitlint-picgo"]
|
|
50
|
+
}
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
And then add the following (inside the braces) to the `scripts` field of your package.json:
|
|
54
|
+
|
|
55
|
+
```json
|
|
56
|
+
"scripts": {
|
|
57
|
+
"cz": "git-cz",
|
|
58
|
+
"release": "bump-version"
|
|
59
|
+
}
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
Then you can use `npm run cz` for committing standard message and use `npm run release` to bump version & auto generate changelog in your project!
|
|
63
|
+
|
|
64
|
+
If you are using [yarn](https://yarnpkg.com/), then it will be more simple just like:
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
# to commit
|
|
68
|
+
yarn cz
|
|
69
|
+
|
|
70
|
+
# to bump version
|
|
71
|
+
yarn release
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
So the workflow is the following:
|
|
75
|
+
|
|
76
|
+
1. `git add` something changed
|
|
77
|
+
2. `npm run cz` to commit
|
|
78
|
+
3. `npm run release` to release or deploy
|
|
79
|
+
|
|
80
|
+
## Usage
|
|
81
|
+
|
|
82
|
+
> If you installed bump-version in a project, then you can just write down the `bump-version` command in your `package.json`'s `scripts` field. Then just `npm run you-command`.
|
|
83
|
+
|
|
84
|
+
### Commit
|
|
85
|
+
|
|
86
|
+
```bash
|
|
87
|
+
npm run cz
|
|
88
|
+
|
|
89
|
+
# or
|
|
90
|
+
|
|
91
|
+
yarn cz
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
This leads to an interactive submit message interface:
|
|
95
|
+
|
|
96
|
+
```
|
|
97
|
+
? Select the type of change that you're committing: (Use arrow keys)
|
|
98
|
+
❯ Feature: when adding new features
|
|
99
|
+
Fix: when fixing bugs
|
|
100
|
+
WIP: when working in progress
|
|
101
|
+
Refactor: when changing the code without adding features or fixing bugs
|
|
102
|
+
Chore: when changing the build process or auxiliary tools and libraries such as documentation generation
|
|
103
|
+
Style: when improving the format/structure of the code
|
|
104
|
+
Upgrade: when upgrading dependencies
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
You can use this interface to quickly generate commit information that is compliant with the PicGo convention.
|
|
108
|
+
|
|
109
|
+
### Bump version
|
|
110
|
+
|
|
111
|
+
```bash
|
|
112
|
+
npm run release
|
|
113
|
+
|
|
114
|
+
# or
|
|
115
|
+
|
|
116
|
+
yarn run cz
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
```txt
|
|
120
|
+
Usage
|
|
121
|
+
bump-version
|
|
122
|
+
|
|
123
|
+
Example
|
|
124
|
+
bump-version -t major
|
|
125
|
+
|
|
126
|
+
Options
|
|
127
|
+
-a, --preid-alpha Prerelease id: alpha. Exp. 1.0.0.alpha-0
|
|
128
|
+
|
|
129
|
+
-b, --preid-beta Prerelease id: beta. Exp. 1.0.0.beta-0
|
|
130
|
+
|
|
131
|
+
-d, --dry Run bump version without change anything & output the log in console
|
|
132
|
+
|
|
133
|
+
-f, --file Read and write the CHANGELOG file, relative to package.json's path
|
|
134
|
+
Default: CHANGELOG.md
|
|
135
|
+
|
|
136
|
+
-p, --path A filepath of where your package.json is located
|
|
137
|
+
Default: ./
|
|
138
|
+
|
|
139
|
+
-h, --help Display help message
|
|
140
|
+
|
|
141
|
+
-t, --type Release type. [major, minor, patch, premajor, preminor, prepatch, prerelease]
|
|
142
|
+
Default: patch
|
|
143
|
+
|
|
144
|
+
--push Auto push commits to origin master
|
|
145
|
+
Default: false
|
|
146
|
+
|
|
147
|
+
--no-tag Tag won't be created
|
|
148
|
+
Default: tag will be created
|
|
149
|
+
|
|
150
|
+
--no-changelog Changelog won't be created
|
|
151
|
+
Default: changelog will be created
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
Don't know which version should be the next? Never mind:
|
|
155
|
+
|
|
156
|
+
If you reject the default next version, then you can choose which version you want or customize one.
|
|
157
|
+
|
|
158
|
+

|
|
159
|
+
|
|
160
|
+
if you just want to see what the changelog will be created and nothing will be changed:
|
|
161
|
+
|
|
162
|
+
```bash
|
|
163
|
+
npm run release --dry
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
## Badges
|
|
167
|
+
|
|
168
|
+
Let more people know that you are using PicGo bump-version for elegant workflow!
|
|
169
|
+
|
|
170
|
+
```md
|
|
171
|
+
[](https://github.com/PicGo/bump-version)
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
## PicGo Convention
|
|
175
|
+
|
|
176
|
+
PicGo's commit message guidelines.
|
|
177
|
+
|
|
178
|
+
### Git Commit Message
|
|
179
|
+
|
|
180
|
+
- Use the present tense ("add feature" not "added feature")
|
|
181
|
+
- Use the imperative mood ("move cursor to..." not "moves cursor to...")
|
|
182
|
+
- Do not repeat the word in type ("Fix: xxx bugs when..." not "Fix: fix xxx bugs when...")
|
|
183
|
+
- Limit the first line to 72 characters or less
|
|
184
|
+
- Start the commit message with an applicable `emoji` & `type`:
|
|
185
|
+
|
|
186
|
+
- :sparkles: Feature `:sparkles: Feature` when adding new features
|
|
187
|
+
- :bug: Fix `:bug: Fix` when fixing bugs
|
|
188
|
+
- :construction: WIP `:construction: WIP` when working in progress
|
|
189
|
+
- :hammer: Refactor `:hammer: Refactor` when changing the code without adding features or fixing bugs
|
|
190
|
+
- :package: Chore `:package: Chore` when changing the build process or auxiliary tools and libraries such as documentation generation
|
|
191
|
+
- :art: Style `:art: Style` when improving the format/structure of the code
|
|
192
|
+
- :arrow_up: Upgrade `:arrow_up: Upgrade` when upgrading dependencies
|
|
193
|
+
- :zap: Perf `:zap: Perf` when improving performance
|
|
194
|
+
- :pencil: Docs `:pencil: Docs` when wrting docs
|
|
195
|
+
- :white_check_mark: Test `:white_check_mark: Test` when adding or updating tests
|
|
196
|
+
- :back: Revert `:back: Revert` when reverting some commits
|
|
197
|
+
- :pushpin: Init `:pushpin: Init` when initializing a project
|
|
198
|
+
- :tada: Release `:tada: Release` when releasing (**will be automatically committed by `bump-version`**)
|
|
199
|
+
|
|
200
|
+
#### Commit Message Format
|
|
201
|
+
|
|
202
|
+
A commit message consists of a **header**, **body**(optional) and **footer**(optional). The header has a **emoji**, **type**, **scope**(optional) and **subject**:
|
|
203
|
+
|
|
204
|
+
```txt
|
|
205
|
+
<emoji> <type>([scope]): <subject>
|
|
206
|
+
<BLANK LINE>
|
|
207
|
+
[body]
|
|
208
|
+
<BLANK LINE>
|
|
209
|
+
[footer]
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
#### Examples
|
|
213
|
+
|
|
214
|
+
##### 1. Normal
|
|
215
|
+
|
|
216
|
+
:sparkles: Feature(core): add error notification
|
|
217
|
+
|
|
218
|
+
:bug: Fix(core): xxx error should be thrown
|
|
219
|
+
|
|
220
|
+
```txt
|
|
221
|
+
:sparkles: Feature(core): add error notification
|
|
222
|
+
|
|
223
|
+
:bug: Fix(core): xxx error should be thrown
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
and they will be rendered into the following changelog:
|
|
227
|
+
|
|
228
|
+
```markdown
|
|
229
|
+
# x.x.0 (20xx-xx-xx)
|
|
230
|
+
|
|
231
|
+
## :sparkles: Features
|
|
232
|
+
|
|
233
|
+
- add error notification
|
|
234
|
+
|
|
235
|
+
## :bug: Bug Fixes
|
|
236
|
+
|
|
237
|
+
- xxx error should be thrown
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
##### 2. BREAKING CHANGE
|
|
241
|
+
|
|
242
|
+
**Note: BREAKING CHANGE can only be in the type of `Feature` or `Fix`.**
|
|
243
|
+
|
|
244
|
+
:sparkles: Feature(core): add error notification
|
|
245
|
+
|
|
246
|
+
BREAKING CHANGE: change api for error notification
|
|
247
|
+
|
|
248
|
+
```md
|
|
249
|
+
:sparkles: Feature(core): add error notification
|
|
250
|
+
|
|
251
|
+
BREAKING CHANGE: change api for error notification
|
|
252
|
+
```
|
|
253
|
+
|
|
254
|
+
and they will be rendered into the following changelog:
|
|
255
|
+
|
|
256
|
+
```markdown
|
|
257
|
+
# x.x.0 (20xx-xx-xx)
|
|
258
|
+
|
|
259
|
+
## :sparkles: Features
|
|
260
|
+
|
|
261
|
+
- add error notification
|
|
262
|
+
|
|
263
|
+
## BREAKING CHANGES
|
|
264
|
+
|
|
265
|
+
- change api for error notification
|
|
266
|
+
```
|
|
267
|
+
|
|
268
|
+
### Git Branch Management
|
|
269
|
+
|
|
270
|
+
**Important**: Always use `rebase` or `squash` or `cherry-pick` instead of `merge`
|
|
271
|
+
|
|
272
|
+
Available branches:
|
|
273
|
+
|
|
274
|
+
- `master` for the release
|
|
275
|
+
- `dev` for the development
|
|
276
|
+
- `docs` or `gh-pages` for the documentation **[optional]**
|
|
277
|
+
- `pr` for the pull request **[optional]**
|
|
278
|
+
- `hot-fix` for fixing the bug in master **[optional]**
|
|
279
|
+
- `feat-*` for developing a new feature
|
|
280
|
+
- `fix-*` for fixing a bug in dev branch
|
|
281
|
+
|
|
282
|
+
## License
|
|
283
|
+
|
|
284
|
+
[MIT](http://opensource.org/licenses/MIT)
|
|
285
|
+
|
|
286
|
+
Copyright (c) 2019 Molunerfinn
|
package/bin/bump-version
ADDED
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
const minimist = require('minimist')
|
|
3
|
+
const semver = require('semver')
|
|
4
|
+
const path = require('path')
|
|
5
|
+
const inquirer = require('inquirer')
|
|
6
|
+
const _ = require('lodash')
|
|
7
|
+
const logger = require('../src/logger')
|
|
8
|
+
const mainLifeCycle = require('../src/mainLifeCycle')
|
|
9
|
+
const utils = require('../src/utils')
|
|
10
|
+
|
|
11
|
+
let pkg
|
|
12
|
+
try {
|
|
13
|
+
pkg = require(path.join(process.cwd(), 'package.json'))
|
|
14
|
+
} catch (e) {
|
|
15
|
+
logger('package.json not found!', 'error')
|
|
16
|
+
process.exit(0)
|
|
17
|
+
}
|
|
18
|
+
let argv = minimist(process.argv.slice(2), {
|
|
19
|
+
alias: {
|
|
20
|
+
'preid-alpha': 'a', // alpha
|
|
21
|
+
'preid-beta': 'b', // beta
|
|
22
|
+
'dry': 'd', // dry run mode
|
|
23
|
+
'file': 'f', // changelog file,
|
|
24
|
+
'path': 'p', // package.json's path
|
|
25
|
+
'help': 'h', // help message
|
|
26
|
+
'type': 't' // bump type
|
|
27
|
+
}
|
|
28
|
+
})
|
|
29
|
+
|
|
30
|
+
if (argv.h) {
|
|
31
|
+
console.log(utils.helperMsg)
|
|
32
|
+
process.exit(0)
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
let releaseType = typeof argv.t === 'string' ? argv.t : 'patch'
|
|
36
|
+
let currentVersion = pkg.version
|
|
37
|
+
if (currentVersion === undefined) {
|
|
38
|
+
logger('Version field is not found in package.json!', 'error')
|
|
39
|
+
process.exit(0)
|
|
40
|
+
}
|
|
41
|
+
let preid = argv.a ? 'alpha' : argv.b ? 'beta' : ''
|
|
42
|
+
let nextVersion = semver.inc(currentVersion, releaseType, preid)
|
|
43
|
+
let releaseTypes = ['major', 'minor', 'patch', 'premajor', 'preminor', 'prepatch', 'prerelease']
|
|
44
|
+
|
|
45
|
+
function generateReleaseTypes (types) {
|
|
46
|
+
return types.map(item => {
|
|
47
|
+
let version = semver.inc(currentVersion, item, (preid || 'alpha'))
|
|
48
|
+
return {
|
|
49
|
+
name: `${item} - ${version}`,
|
|
50
|
+
value: version
|
|
51
|
+
}
|
|
52
|
+
})
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
let defaultObj = {
|
|
56
|
+
path: process.cwd(),
|
|
57
|
+
file: 'CHANGELOG.md'
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
argv = _.assign({}, defaultObj, argv)
|
|
61
|
+
|
|
62
|
+
let promptList = [
|
|
63
|
+
{
|
|
64
|
+
type: 'confirm',
|
|
65
|
+
name: 'confirmVersion',
|
|
66
|
+
message: `The next version is ${nextVersion}, is it right?`
|
|
67
|
+
}
|
|
68
|
+
]
|
|
69
|
+
console.log(
|
|
70
|
+
`
|
|
71
|
+
BumpVersion -- By PicGo Group
|
|
72
|
+
`
|
|
73
|
+
);
|
|
74
|
+
(async () => {
|
|
75
|
+
let answer = await inquirer.prompt(promptList)
|
|
76
|
+
if (answer.confirmVersion) {
|
|
77
|
+
await mainLifeCycle(argv, currentVersion, nextVersion)
|
|
78
|
+
} else {
|
|
79
|
+
promptList = [
|
|
80
|
+
{
|
|
81
|
+
type: 'list',
|
|
82
|
+
name: 'version',
|
|
83
|
+
message: `The current version is ${currentVersion}\n Which version would you like to bump it?`,
|
|
84
|
+
choices: [
|
|
85
|
+
...generateReleaseTypes(releaseTypes),
|
|
86
|
+
new inquirer.Separator(),
|
|
87
|
+
'custom version',
|
|
88
|
+
'never mind~'
|
|
89
|
+
],
|
|
90
|
+
pageSize: 10
|
|
91
|
+
}
|
|
92
|
+
]
|
|
93
|
+
let answer = await inquirer.prompt(promptList)
|
|
94
|
+
if (answer.version === 'never mind~') {
|
|
95
|
+
return console.log('Bye~')
|
|
96
|
+
} else if (answer.version === 'custom version') {
|
|
97
|
+
promptList = [
|
|
98
|
+
{
|
|
99
|
+
type: 'input',
|
|
100
|
+
name: 'version',
|
|
101
|
+
message: 'Write down your custom version:'
|
|
102
|
+
}
|
|
103
|
+
]
|
|
104
|
+
let result = await inquirer.prompt(promptList)
|
|
105
|
+
if (semver.valid(result.version) && semver.gte(result.version, currentVersion)) {
|
|
106
|
+
await mainLifeCycle(argv, currentVersion, result.version)
|
|
107
|
+
} else {
|
|
108
|
+
return logger('Invalid version!', 'error')
|
|
109
|
+
}
|
|
110
|
+
} else {
|
|
111
|
+
await mainLifeCycle(argv, currentVersion, answer.version)
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
})()
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
const typeEnum = require('./types')
|
|
2
|
+
|
|
3
|
+
module.exports = {
|
|
4
|
+
parserPreset: '../conventional-changelog-picgo/parser-opts',
|
|
5
|
+
rules: {
|
|
6
|
+
'body-leading-blank': [1, 'always'],
|
|
7
|
+
'footer-leading-blank': [1, 'always'],
|
|
8
|
+
'header-max-length': [2, 'always', 100],
|
|
9
|
+
'scope-case': [
|
|
10
|
+
2,
|
|
11
|
+
'always',
|
|
12
|
+
['lower-case', 'kebab-case']
|
|
13
|
+
],
|
|
14
|
+
'subject-case': [
|
|
15
|
+
2,
|
|
16
|
+
'never',
|
|
17
|
+
['sentence-case']
|
|
18
|
+
],
|
|
19
|
+
'subject-empty': [2, 'never'],
|
|
20
|
+
'subject-full-stop': [2, 'never', '.'],
|
|
21
|
+
'type-case': [0, 'always', 'lower-case'],
|
|
22
|
+
'type-empty': [2, 'never'],
|
|
23
|
+
'type-enum': [2, 'always', typeEnum]
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
const types = [
|
|
2
|
+
':sparkles: Feature',
|
|
3
|
+
':bug: Fix',
|
|
4
|
+
':construction: WIP',
|
|
5
|
+
':hammer: Refactor',
|
|
6
|
+
':package: Chore',
|
|
7
|
+
':art: Style',
|
|
8
|
+
':arrow_up: Upgrade',
|
|
9
|
+
':zap: Perf',
|
|
10
|
+
':pencil: Docs',
|
|
11
|
+
':white_check_mark: Test',
|
|
12
|
+
':back: Revert',
|
|
13
|
+
':tada: Release',
|
|
14
|
+
':pushpin: Init'
|
|
15
|
+
]
|
|
16
|
+
|
|
17
|
+
module.exports = types
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
### ISC License
|
|
2
|
+
|
|
3
|
+
Copyright © [conventional-changelog team](https://github.com/conventional-changelog)
|
|
4
|
+
|
|
5
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
6
|
+
purpose with or without fee is hereby granted, provided that the above
|
|
7
|
+
copyright notice and this permission notice appear in all copies.
|
|
8
|
+
|
|
9
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
10
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
|
11
|
+
FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
12
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
13
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
14
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
15
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const Q = require(`q`)
|
|
4
|
+
const parserOpts = require(`./parser-opts`)
|
|
5
|
+
const writerOpts = require(`./writer-opts`)
|
|
6
|
+
|
|
7
|
+
module.exports = Q.all([parserOpts, writerOpts])
|
|
8
|
+
.spread((parserOpts, writerOpts) => {
|
|
9
|
+
return { parserOpts, writerOpts }
|
|
10
|
+
})
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const parserOpts = require(`./parser-opts`)
|
|
4
|
+
|
|
5
|
+
module.exports = {
|
|
6
|
+
parserOpts,
|
|
7
|
+
|
|
8
|
+
whatBump: (commits) => {
|
|
9
|
+
let level = 2
|
|
10
|
+
let breakings = 0
|
|
11
|
+
let features = 0
|
|
12
|
+
|
|
13
|
+
commits.forEach(commit => {
|
|
14
|
+
if (commit.notes.length > 0) {
|
|
15
|
+
breakings += commit.notes.length
|
|
16
|
+
level = 0
|
|
17
|
+
} else if (commit.type === `feat`) {
|
|
18
|
+
features += 1
|
|
19
|
+
if (level === 2) {
|
|
20
|
+
level = 1
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
})
|
|
24
|
+
|
|
25
|
+
return {
|
|
26
|
+
level: level,
|
|
27
|
+
reason: breakings === 1
|
|
28
|
+
? `There is ${breakings} BREAKING CHANGE and ${features} features`
|
|
29
|
+
: `There are ${breakings} BREAKING CHANGES and ${features} features`
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
const Q = require(`q`)
|
|
3
|
+
const conventionalChangelog = require(`./conventional-changelog`)
|
|
4
|
+
const parserOpts = require(`./parser-opts`)
|
|
5
|
+
const recommendedBumpOpts = require(`./conventional-recommended-bump`)
|
|
6
|
+
const writerOpts = require(`./writer-opts`)
|
|
7
|
+
|
|
8
|
+
module.exports = Q.all([conventionalChangelog, parserOpts, recommendedBumpOpts, writerOpts])
|
|
9
|
+
.spread((conventionalChangelog, parserOpts, recommendedBumpOpts, writerOpts) => {
|
|
10
|
+
return { conventionalChangelog, parserOpts, recommendedBumpOpts, writerOpts }
|
|
11
|
+
})
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
*{{#if scope}} **{{scope}}:**
|
|
2
|
+
{{~/if}} {{#if subject}}
|
|
3
|
+
{{~subject}}
|
|
4
|
+
{{~else}}
|
|
5
|
+
{{~header}}
|
|
6
|
+
{{~/if}}
|
|
7
|
+
|
|
8
|
+
{{~!-- commit link --}} {{#if @root.linkReferences~}}
|
|
9
|
+
([{{hash}}](
|
|
10
|
+
{{~#if @root.repository}}
|
|
11
|
+
{{~#if @root.host}}
|
|
12
|
+
{{~@root.host}}/
|
|
13
|
+
{{~/if}}
|
|
14
|
+
{{~#if @root.owner}}
|
|
15
|
+
{{~@root.owner}}/
|
|
16
|
+
{{~/if}}
|
|
17
|
+
{{~@root.repository}}
|
|
18
|
+
{{~else}}
|
|
19
|
+
{{~@root.repoUrl}}
|
|
20
|
+
{{~/if}}/
|
|
21
|
+
{{~@root.commit}}/{{hash}}))
|
|
22
|
+
{{~else}}
|
|
23
|
+
{{~hash}}
|
|
24
|
+
{{~/if}}
|
|
25
|
+
|
|
26
|
+
{{~!-- commit references --}}
|
|
27
|
+
{{~#if references~}}
|
|
28
|
+
, closes
|
|
29
|
+
{{~#each references}} {{#if @root.linkReferences~}}
|
|
30
|
+
[
|
|
31
|
+
{{~#if this.owner}}
|
|
32
|
+
{{~this.owner}}/
|
|
33
|
+
{{~/if}}
|
|
34
|
+
{{~this.repository}}#{{this.issue}}](
|
|
35
|
+
{{~#if @root.repository}}
|
|
36
|
+
{{~#if @root.host}}
|
|
37
|
+
{{~@root.host}}/
|
|
38
|
+
{{~/if}}
|
|
39
|
+
{{~#if this.repository}}
|
|
40
|
+
{{~#if this.owner}}
|
|
41
|
+
{{~this.owner}}/
|
|
42
|
+
{{~/if}}
|
|
43
|
+
{{~this.repository}}
|
|
44
|
+
{{~else}}
|
|
45
|
+
{{~#if @root.owner}}
|
|
46
|
+
{{~@root.owner}}/
|
|
47
|
+
{{~/if}}
|
|
48
|
+
{{~@root.repository}}
|
|
49
|
+
{{~/if}}
|
|
50
|
+
{{~else}}
|
|
51
|
+
{{~@root.repoUrl}}
|
|
52
|
+
{{~/if}}/
|
|
53
|
+
{{~@root.issue}}/{{this.issue}})
|
|
54
|
+
{{~else}}
|
|
55
|
+
{{~#if this.owner}}
|
|
56
|
+
{{~this.owner}}/
|
|
57
|
+
{{~/if}}
|
|
58
|
+
{{~this.repository}}#{{this.issue}}
|
|
59
|
+
{{~/if}}{{/each}}
|
|
60
|
+
{{~/if}}
|
|
61
|
+
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const compareFunc = require(`compare-func`)
|
|
4
|
+
const Q = require(`q`)
|
|
5
|
+
const readFile = Q.denodeify(require(`fs`).readFile)
|
|
6
|
+
const resolve = require(`path`).resolve
|
|
7
|
+
const headerPattern = /^(:.*: (.*))$/
|
|
8
|
+
|
|
9
|
+
const compareTitleFunc = (a, b) => {
|
|
10
|
+
let sortMap = {
|
|
11
|
+
'Features': 10,
|
|
12
|
+
'Bug Fixes': 9,
|
|
13
|
+
'BREAKING CHANGES': 8
|
|
14
|
+
}
|
|
15
|
+
let typeA = a.title.match(headerPattern)[2]
|
|
16
|
+
let typeB = b.title.match(headerPattern)[2]
|
|
17
|
+
|
|
18
|
+
return (sortMap[typeB] || 0) - (sortMap[typeA] || 0)
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
module.exports = Q.all([
|
|
22
|
+
readFile(resolve(__dirname, `./templates/template.hbs`), `utf-8`),
|
|
23
|
+
readFile(resolve(__dirname, `./templates/header.hbs`), `utf-8`),
|
|
24
|
+
readFile(resolve(__dirname, `./templates/commit.hbs`), `utf-8`),
|
|
25
|
+
readFile(resolve(__dirname, `./templates/footer.hbs`), `utf-8`)
|
|
26
|
+
])
|
|
27
|
+
.spread((template, header, commit, footer) => {
|
|
28
|
+
const writerOpts = getWriterOpts()
|
|
29
|
+
|
|
30
|
+
writerOpts.mainTemplate = template
|
|
31
|
+
writerOpts.headerPartial = header
|
|
32
|
+
writerOpts.commitPartial = commit
|
|
33
|
+
writerOpts.footerPartial = footer
|
|
34
|
+
|
|
35
|
+
return writerOpts
|
|
36
|
+
})
|
|
37
|
+
|
|
38
|
+
function getWriterOpts () {
|
|
39
|
+
return {
|
|
40
|
+
transform: (commit, context) => {
|
|
41
|
+
let discard = true
|
|
42
|
+
const issues = []
|
|
43
|
+
|
|
44
|
+
commit.notes.forEach(note => {
|
|
45
|
+
note.title = `BREAKING CHANGES`
|
|
46
|
+
discard = false
|
|
47
|
+
})
|
|
48
|
+
|
|
49
|
+
if (commit.type === `:sparkles: Feature`) {
|
|
50
|
+
commit.type = `:sparkles: Features`
|
|
51
|
+
} else if (commit.type === `:bug: Fix`) {
|
|
52
|
+
commit.type = `:bug: Bug Fixes`
|
|
53
|
+
} else if (commit.type === `:zap: Perf`) {
|
|
54
|
+
commit.type = `:zap: Performance Improvements`
|
|
55
|
+
} else if (commit.type === `:back: Revert`) {
|
|
56
|
+
commit.type = `:back: Revert`
|
|
57
|
+
} else if (commit.type === `:pencil: Docs`) {
|
|
58
|
+
commit.type = `:pencil: Documentation`
|
|
59
|
+
} else if (commit.type === `:package: Chore`) {
|
|
60
|
+
commit.type = `:package: Chore`
|
|
61
|
+
} else if (commit.type === `:pushpin: Init`) {
|
|
62
|
+
commit.type = `:pushpin: Init`
|
|
63
|
+
} else if (discard) {
|
|
64
|
+
return
|
|
65
|
+
} else if (commit.type === `:arrow_up: Upgrade`) {
|
|
66
|
+
commit.type = `:arrow_up: Dependencies Upgrade`
|
|
67
|
+
} else if (commit.type === `:art: Style`) {
|
|
68
|
+
commit.type = `:art: Styles`
|
|
69
|
+
} else if (commit.type === `:hammer: Refactor`) {
|
|
70
|
+
commit.type = `:hammer: Code Refactoring`
|
|
71
|
+
} else if (commit.type === `:white_check_mark: Test`) {
|
|
72
|
+
commit.type = `:white_check_mark: Tests`
|
|
73
|
+
} else if (commit.type === `:construction: WIP` || commit.type === ':tada: Release') {
|
|
74
|
+
return
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
if (commit.scope === `*`) {
|
|
78
|
+
commit.scope = ``
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
if (typeof commit.hash === `string`) {
|
|
82
|
+
commit.hash = commit.hash.substring(0, 7)
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
if (typeof commit.subject === `string`) {
|
|
86
|
+
let url = context.repository
|
|
87
|
+
? `${context.host}/${context.owner}/${context.repository}`
|
|
88
|
+
: context.repoUrl
|
|
89
|
+
if (url) {
|
|
90
|
+
url = `${url}/issues/`
|
|
91
|
+
// Issue URLs.
|
|
92
|
+
commit.subject = commit.subject.replace(/#([0-9]+)/g, (_, issue) => {
|
|
93
|
+
issues.push(issue)
|
|
94
|
+
return `[#${issue}](${url}${issue})`
|
|
95
|
+
})
|
|
96
|
+
}
|
|
97
|
+
if (context.host) {
|
|
98
|
+
// User URLs.
|
|
99
|
+
commit.subject = commit.subject.replace(/\B@([a-z0-9](?:-?[a-z0-9/]){0,38})/g, (_, username) => {
|
|
100
|
+
if (username.includes('/')) {
|
|
101
|
+
return `@${username}`
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
return `[@${username}](${context.host}/${username})`
|
|
105
|
+
})
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
// remove references that already appear in the subject
|
|
110
|
+
commit.references = commit.references.filter(reference => {
|
|
111
|
+
if (issues.indexOf(reference.issue) === -1) {
|
|
112
|
+
return true
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
return false
|
|
116
|
+
})
|
|
117
|
+
|
|
118
|
+
return commit
|
|
119
|
+
},
|
|
120
|
+
groupBy: `type`,
|
|
121
|
+
commitGroupsSort: compareTitleFunc,
|
|
122
|
+
commitsSort: [`scope`, `subject`],
|
|
123
|
+
noteGroupsSort: `title`,
|
|
124
|
+
notesSort: compareFunc
|
|
125
|
+
}
|
|
126
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@picgo/bump-version",
|
|
3
|
+
"version": "1.1.2",
|
|
4
|
+
"description": "",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"bin": {
|
|
7
|
+
"bump-version": "./bin/bump-version"
|
|
8
|
+
},
|
|
9
|
+
"publishConfig": {
|
|
10
|
+
"access": "public"
|
|
11
|
+
},
|
|
12
|
+
"scripts": {
|
|
13
|
+
"test": "echo \"Error: no test specified\"",
|
|
14
|
+
"cz": "git-cz",
|
|
15
|
+
"release": "node ./bin/bump-version",
|
|
16
|
+
"lint": "eslint --ext .js -f ./node_modules/eslint-friendly-formatter .",
|
|
17
|
+
"lint:fix": "eslint --ext .js -f ./node_modules/eslint-friendly-formatter --fix ."
|
|
18
|
+
},
|
|
19
|
+
"husky": {
|
|
20
|
+
"hooks": {
|
|
21
|
+
"pre-commit": "npm run lint",
|
|
22
|
+
"commit-msg": "commitlint -E HUSKY_GIT_PARAMS"
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
"repository": {
|
|
26
|
+
"type": "git",
|
|
27
|
+
"url": "git+https://github.com/PicGo/bump-version.git"
|
|
28
|
+
},
|
|
29
|
+
"author": "Molunerfinn",
|
|
30
|
+
"license": "MIT",
|
|
31
|
+
"bugs": {
|
|
32
|
+
"url": "https://github.com/PicGo/bump-version/issues"
|
|
33
|
+
},
|
|
34
|
+
"homepage": "https://github.com/PicGo/bump-version#readme",
|
|
35
|
+
"devDependencies": {
|
|
36
|
+
"eslint": "^5.16.0",
|
|
37
|
+
"eslint-config-standard": "^12.0.0",
|
|
38
|
+
"eslint-friendly-formatter": "^4.0.1",
|
|
39
|
+
"eslint-plugin-import": "^2.16.0",
|
|
40
|
+
"eslint-plugin-node": "^8.0.1",
|
|
41
|
+
"eslint-plugin-promise": "^4.1.1",
|
|
42
|
+
"eslint-plugin-standard": "^4.0.0"
|
|
43
|
+
},
|
|
44
|
+
"config": {
|
|
45
|
+
"commitizen": {
|
|
46
|
+
"path": "node_modules/cz-customizable"
|
|
47
|
+
},
|
|
48
|
+
"cz-customizable": {
|
|
49
|
+
"config": ".cz-config.js"
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
"commitlint": {
|
|
53
|
+
"extends": [
|
|
54
|
+
"./commitlint-picgo"
|
|
55
|
+
]
|
|
56
|
+
},
|
|
57
|
+
"dependencies": {
|
|
58
|
+
"@commitlint/cli": "^7.5.2",
|
|
59
|
+
"commitizen": "^4.2.3",
|
|
60
|
+
"conventional-changelog": "^3.0.6",
|
|
61
|
+
"cz-customizable": "^5.8.0",
|
|
62
|
+
"ora": "^3.4.0",
|
|
63
|
+
"husky": "^1.3.1"
|
|
64
|
+
}
|
|
65
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
const fs = require('fs')
|
|
2
|
+
const checkFileAndGetPath = require('./utils').checkFileAndGetPath
|
|
3
|
+
let versionFiles = ['package.json', 'package-lock.json']
|
|
4
|
+
module.exports = (argv, version) => {
|
|
5
|
+
if (argv.dry === false) {
|
|
6
|
+
return Promise.resolve()
|
|
7
|
+
}
|
|
8
|
+
versionFiles = checkFileAndGetPath(argv, versionFiles)
|
|
9
|
+
|
|
10
|
+
for (let file of versionFiles) {
|
|
11
|
+
let content = fs.readFileSync(file, 'utf8')
|
|
12
|
+
try {
|
|
13
|
+
content = JSON.parse(content)
|
|
14
|
+
content.version = version
|
|
15
|
+
content = JSON.stringify(content, null, 2) + '\n'
|
|
16
|
+
if (argv.dry) {
|
|
17
|
+
console.log('bump version to:', version)
|
|
18
|
+
} else {
|
|
19
|
+
fs.writeFileSync(file, content, 'utf8')
|
|
20
|
+
}
|
|
21
|
+
} catch (e) {
|
|
22
|
+
return Promise.reject(e)
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
return Promise.resolve()
|
|
26
|
+
}
|
package/src/changelog.js
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
const cc = require('conventional-changelog')
|
|
2
|
+
const config = require('../conventional-changelog-picgo')
|
|
3
|
+
const fs = require('fs')
|
|
4
|
+
|
|
5
|
+
module.exports = (argv, newVersion) => {
|
|
6
|
+
if (argv.changelog === false) {
|
|
7
|
+
return Promise.resolve()
|
|
8
|
+
}
|
|
9
|
+
return new Promise((resolve, reject) => {
|
|
10
|
+
let content = ''
|
|
11
|
+
let oldContent = ''
|
|
12
|
+
try {
|
|
13
|
+
oldContent = fs.readFileSync(argv.file, 'utf8')
|
|
14
|
+
} catch (e) {
|
|
15
|
+
oldContent = ''
|
|
16
|
+
}
|
|
17
|
+
let context = ''
|
|
18
|
+
if (argv.dry) {
|
|
19
|
+
context = {
|
|
20
|
+
version: newVersion
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
let changeLogStream = cc({
|
|
24
|
+
config
|
|
25
|
+
}, context, { merges: null, path: argv.path }).on('error', (err) => {
|
|
26
|
+
return reject(err)
|
|
27
|
+
})
|
|
28
|
+
changeLogStream.on('data', (buffer) => {
|
|
29
|
+
content += buffer.toString()
|
|
30
|
+
})
|
|
31
|
+
changeLogStream.on('end', () => {
|
|
32
|
+
if (argv.dry) {
|
|
33
|
+
console.log('Changelog is:')
|
|
34
|
+
console.log(content + oldContent)
|
|
35
|
+
} else {
|
|
36
|
+
fs.writeFileSync(argv.file, content + oldContent)
|
|
37
|
+
}
|
|
38
|
+
return resolve()
|
|
39
|
+
})
|
|
40
|
+
})
|
|
41
|
+
}
|
package/src/commit.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
const utils = require('./utils')
|
|
2
|
+
const exec = require('./exec')
|
|
3
|
+
let changedFiles = [
|
|
4
|
+
'package.json',
|
|
5
|
+
'package-lock.json'
|
|
6
|
+
]
|
|
7
|
+
module.exports = (argv, newVersion) => {
|
|
8
|
+
if (argv.changelog !== false) {
|
|
9
|
+
changedFiles.push(argv.file)
|
|
10
|
+
}
|
|
11
|
+
const releaseMsg = `:tada: Release: v${newVersion}`
|
|
12
|
+
if (argv.skipCommit) return Promise.resolve()
|
|
13
|
+
changedFiles = utils.checkFileAndGetPath(argv, changedFiles).join(' ')
|
|
14
|
+
if (changedFiles === '' || argv.dry) {
|
|
15
|
+
return Promise.resolve()
|
|
16
|
+
}
|
|
17
|
+
return exec(argv, `git add ${changedFiles}`)
|
|
18
|
+
.then(() => {
|
|
19
|
+
return exec(argv, `git commit ${changedFiles} -m "${releaseMsg}"`)
|
|
20
|
+
})
|
|
21
|
+
}
|
package/src/exec.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
const exec = require('child_process').exec
|
|
2
|
+
const logger = require('./logger')
|
|
3
|
+
|
|
4
|
+
module.exports = (argv, cmd) => {
|
|
5
|
+
return new Promise((resolve, reject) => {
|
|
6
|
+
// Exec given cmd and handle possible errors
|
|
7
|
+
exec(cmd, { cwd: argv.path }, function (err, stdout, stderr) {
|
|
8
|
+
// If exec returns content in stderr, but no error, print it as a warning
|
|
9
|
+
// If exec returns an error, print it and exit with return code 1
|
|
10
|
+
if (err) {
|
|
11
|
+
logger(stderr || err.message, 'error')
|
|
12
|
+
return reject(err)
|
|
13
|
+
} else if (stderr) {
|
|
14
|
+
logger(stderr, 'warn')
|
|
15
|
+
}
|
|
16
|
+
return resolve(stdout)
|
|
17
|
+
})
|
|
18
|
+
})
|
|
19
|
+
}
|
package/src/logger.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
const ora = require('./ora')
|
|
2
|
+
const chalk = require('chalk')
|
|
3
|
+
const level = {
|
|
4
|
+
success: 'green',
|
|
5
|
+
info: 'blue',
|
|
6
|
+
warn: 'yellow',
|
|
7
|
+
error: 'red'
|
|
8
|
+
}
|
|
9
|
+
module.exports = (msg, type) => {
|
|
10
|
+
let log = chalk[level[type]](`[Bump ${type.toUpperCase()}]: `)
|
|
11
|
+
log += msg
|
|
12
|
+
ora.clear()
|
|
13
|
+
ora.frame()
|
|
14
|
+
console.log(log)
|
|
15
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
const bumpVersion = require('./bumpVersion')
|
|
2
|
+
const commit = require('./commit')
|
|
3
|
+
const changeLog = require('./changelog')
|
|
4
|
+
const tag = require('./tag')
|
|
5
|
+
const spinner = require('./ora')
|
|
6
|
+
module.exports = (argv, currentVersion, newVersion) => {
|
|
7
|
+
spinner.start()
|
|
8
|
+
return new Promise((resolve, reject) => {
|
|
9
|
+
spinner.text = 'Bumping version...'
|
|
10
|
+
return resolve(bumpVersion(argv, newVersion))
|
|
11
|
+
}).then(() => {
|
|
12
|
+
spinner.text = 'Generating changelog...'
|
|
13
|
+
return changeLog(argv, newVersion)
|
|
14
|
+
}).then(() => {
|
|
15
|
+
spinner.text = 'Commiting changes...'
|
|
16
|
+
return commit(argv, newVersion)
|
|
17
|
+
}).then(() => {
|
|
18
|
+
spinner.text = 'Creating tag...'
|
|
19
|
+
return tag(argv, newVersion)
|
|
20
|
+
}).then(() => {
|
|
21
|
+
spinner.succeed('Done!')
|
|
22
|
+
}).catch(e => {
|
|
23
|
+
spinner.fail('Failed!')
|
|
24
|
+
})
|
|
25
|
+
}
|
package/src/ora.js
ADDED
package/src/tag.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
const exec = require('./exec')
|
|
2
|
+
module.exports = (argv, newVersion) => {
|
|
3
|
+
if (argv.dry) {
|
|
4
|
+
return Promise.resolve()
|
|
5
|
+
}
|
|
6
|
+
let flow
|
|
7
|
+
if (argv.tag === false) {
|
|
8
|
+
flow = Promise.resolve()
|
|
9
|
+
} else {
|
|
10
|
+
flow = exec(argv, `git tag -a v${newVersion} -m v${newVersion}`)
|
|
11
|
+
}
|
|
12
|
+
return flow
|
|
13
|
+
.then(async () => {
|
|
14
|
+
if (argv.push) {
|
|
15
|
+
await exec(`git push --follow-tags origin master`)
|
|
16
|
+
}
|
|
17
|
+
return Promise.resolve()
|
|
18
|
+
})
|
|
19
|
+
}
|
package/src/utils.js
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
const path = require('path')
|
|
2
|
+
const fs = require('fs')
|
|
3
|
+
const checkFileAndGetPath = (argv, files) => {
|
|
4
|
+
return files.map(item => {
|
|
5
|
+
if (path.isAbsolute(item)) {
|
|
6
|
+
return item
|
|
7
|
+
}
|
|
8
|
+
return path.join(argv.path, item)
|
|
9
|
+
}).filter(item => {
|
|
10
|
+
return fs.existsSync(item)
|
|
11
|
+
})
|
|
12
|
+
}
|
|
13
|
+
const helperMsg = `
|
|
14
|
+
BumpVersion -- By PicGo Group
|
|
15
|
+
|
|
16
|
+
Usage
|
|
17
|
+
bump-version
|
|
18
|
+
|
|
19
|
+
Example
|
|
20
|
+
bump-version -t major
|
|
21
|
+
|
|
22
|
+
Options
|
|
23
|
+
-a, --preid-alpha Prerelease id: alpha. Exp. 1.0.0.alpha-0
|
|
24
|
+
|
|
25
|
+
-b, --preid-beta Prerelease id: beta. Exp. 1.0.0.beta-0
|
|
26
|
+
|
|
27
|
+
-d, --dry Run bump version without change anything & output the log in console
|
|
28
|
+
|
|
29
|
+
-f, --file Read and write the CHANGELOG file, relative to package.json's path
|
|
30
|
+
Default: CHANGELOG.md
|
|
31
|
+
|
|
32
|
+
-p, --path A filepath of where your package.json is located
|
|
33
|
+
Default: ./
|
|
34
|
+
|
|
35
|
+
-h, --help Display help message
|
|
36
|
+
|
|
37
|
+
-t, --type Release type. [major, minor, patch, premajor, preminor, prepatch, prerelease]
|
|
38
|
+
Default: patch
|
|
39
|
+
|
|
40
|
+
--push Auto push commits to origin master
|
|
41
|
+
Default: false
|
|
42
|
+
|
|
43
|
+
--no-tag Tag won't be created
|
|
44
|
+
Default: tag will be created
|
|
45
|
+
|
|
46
|
+
--no-changelog Changelog won't be created
|
|
47
|
+
Default: changelog will be created
|
|
48
|
+
`
|
|
49
|
+
|
|
50
|
+
module.exports = {
|
|
51
|
+
checkFileAndGetPath,
|
|
52
|
+
helperMsg
|
|
53
|
+
}
|