@varlet/release 0.3.2 → 0.4.0
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/{LICENCE → LICENSE} +21 -21
- package/README.md +161 -150
- package/README.zh-CN.md +161 -150
- package/bin/index.js +47 -46
- package/dist/index.cjs +50 -44
- package/dist/index.d.cts +5 -1
- package/dist/index.d.ts +5 -1
- package/dist/index.js +50 -44
- package/package.json +32 -28
package/{LICENCE → LICENSE}
RENAMED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
The MIT License (MIT)
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2022 varlet
|
|
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.
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2022 varlet
|
|
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
CHANGED
|
@@ -1,150 +1,161 @@
|
|
|
1
|
-
<h1 align="center">Varlet Release</h1>
|
|
2
|
-
|
|
3
|
-
<p align="center">
|
|
4
|
-
<span>English</span> |
|
|
5
|
-
<a href="https://github.com/varletjs/release/blob/main/README.zh-CN.md">中文</a>
|
|
6
|
-
</p>
|
|
7
|
-
<p align="center">
|
|
8
|
-
<a href="https://www.npmjs.com/package/@varlet/release" target="_blank" rel="noopener noreferrer"><img src="https://badgen.net/npm/v/@varlet/release" alt="NPM Version" /></a>
|
|
9
|
-
<a href="https://github.com/varletjs/release/blob/main/
|
|
10
|
-
</p>
|
|
11
|
-
|
|
12
|
-
## Intro
|
|
13
|
-
|
|
14
|
-
`Varlet Release` is a tool used for publishing all packages, generating change logs, and checking `commit messages`, relying on `pnpm`.
|
|
15
|
-
|
|
16
|
-
## Installation
|
|
17
|
-
|
|
18
|
-
```shell
|
|
19
|
-
pnpm add @varlet/release -D
|
|
20
|
-
```
|
|
21
|
-
|
|
22
|
-
## Usage
|
|
23
|
-
|
|
24
|
-
### Using Command
|
|
25
|
-
|
|
26
|
-
```shell
|
|
27
|
-
# Release all packages and generate changelogs
|
|
28
|
-
npx vr release
|
|
29
|
-
|
|
30
|
-
# Specify remote name
|
|
31
|
-
npx vr release -r https://github.com/varletjs/varlet-release
|
|
32
|
-
# or
|
|
33
|
-
npx vr release --remote https://github.com/varletjs/varlet-release
|
|
34
|
-
|
|
35
|
-
# Just generate changelogs
|
|
36
|
-
npx vr changelog
|
|
37
|
-
|
|
38
|
-
# Specify changelog filename
|
|
39
|
-
npx vr changelog -f changelog.md
|
|
40
|
-
# or
|
|
41
|
-
npx vr changelog --file changelog.md
|
|
42
|
-
|
|
43
|
-
# Lint commit message
|
|
44
|
-
npx vr lint-commit -p .git/COMMIT_EDITMSG
|
|
45
|
-
|
|
46
|
-
# Publish to npm, which can be called in the ci environment
|
|
47
|
-
npx vr publish
|
|
48
|
-
```
|
|
49
|
-
|
|
50
|
-
### Configuration
|
|
51
|
-
|
|
52
|
-
#### release
|
|
53
|
-
|
|
54
|
-
| Params | Instructions |
|
|
55
|
-
| ------------------------- | ------------------------------------------------------------------------------------------------------------------------- |
|
|
56
|
-
| -r --remote \<remote\> | Specify remote name |
|
|
57
|
-
| -s --skip-npm-publish | Skip npm publish |
|
|
58
|
-
| -c --check-remote-version | Check if the remote version of the npm package is the same as the one you want to publish locally, if so, stop execution. |
|
|
59
|
-
| -sc --skip-changelog | Skip generate changelog |
|
|
60
|
-
| -sgt --skip-git-tag | Skip git tag |
|
|
61
|
-
| -nt --npm-tag \<npmTag\> | npm tag |
|
|
62
|
-
|
|
63
|
-
#### changelog
|
|
64
|
-
|
|
65
|
-
| Params | Instructions |
|
|
66
|
-
| ----------------------------------- | -------------------------- |
|
|
67
|
-
| -f --file \<filename\> | Specify changelog filename |
|
|
68
|
-
| -rc --releaseCount \<releaseCount\> | Release count |
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
|
74
|
-
|
|
|
75
|
-
| -
|
|
76
|
-
| -
|
|
77
|
-
| -
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
|
83
|
-
|
|
|
84
|
-
| -
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
await
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
function
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
}
|
|
145
|
-
function
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
1
|
+
<h1 align="center">Varlet Release</h1>
|
|
2
|
+
|
|
3
|
+
<p align="center">
|
|
4
|
+
<span>English</span> |
|
|
5
|
+
<a href="https://github.com/varletjs/release/blob/main/README.zh-CN.md">中文</a>
|
|
6
|
+
</p>
|
|
7
|
+
<p align="center">
|
|
8
|
+
<a href="https://www.npmjs.com/package/@varlet/release" target="_blank" rel="noopener noreferrer"><img src="https://badgen.net/npm/v/@varlet/release" alt="NPM Version" /></a>
|
|
9
|
+
<a href="https://github.com/varletjs/release/blob/main/LICENSE" target="_blank" rel="noopener noreferrer"><img src="https://badgen.net/github/license/varletjs/release" alt="License" /></a>
|
|
10
|
+
</p>
|
|
11
|
+
|
|
12
|
+
## Intro
|
|
13
|
+
|
|
14
|
+
`Varlet Release` is a tool used for publishing all packages, generating change logs, and checking `commit messages`, relying on `pnpm`.
|
|
15
|
+
|
|
16
|
+
## Installation
|
|
17
|
+
|
|
18
|
+
```shell
|
|
19
|
+
pnpm add @varlet/release -D
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Usage
|
|
23
|
+
|
|
24
|
+
### Using Command
|
|
25
|
+
|
|
26
|
+
```shell
|
|
27
|
+
# Release all packages and generate changelogs
|
|
28
|
+
npx vr release
|
|
29
|
+
|
|
30
|
+
# Specify remote name
|
|
31
|
+
npx vr release -r https://github.com/varletjs/varlet-release
|
|
32
|
+
# or
|
|
33
|
+
npx vr release --remote https://github.com/varletjs/varlet-release
|
|
34
|
+
|
|
35
|
+
# Just generate changelogs
|
|
36
|
+
npx vr changelog
|
|
37
|
+
|
|
38
|
+
# Specify changelog filename
|
|
39
|
+
npx vr changelog -f changelog.md
|
|
40
|
+
# or
|
|
41
|
+
npx vr changelog --file changelog.md
|
|
42
|
+
|
|
43
|
+
# Lint commit message
|
|
44
|
+
npx vr lint-commit -p .git/COMMIT_EDITMSG
|
|
45
|
+
|
|
46
|
+
# Publish to npm, which can be called in the ci environment
|
|
47
|
+
npx vr publish
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
### Configuration
|
|
51
|
+
|
|
52
|
+
#### release
|
|
53
|
+
|
|
54
|
+
| Params | Instructions |
|
|
55
|
+
| ------------------------- | ------------------------------------------------------------------------------------------------------------------------- |
|
|
56
|
+
| -r --remote \<remote\> | Specify remote name |
|
|
57
|
+
| -s --skip-npm-publish | Skip npm publish |
|
|
58
|
+
| -c --check-remote-version | Check if the remote version of the npm package is the same as the one you want to publish locally, if so, stop execution. |
|
|
59
|
+
| -sc --skip-changelog | Skip generate changelog |
|
|
60
|
+
| -sgt --skip-git-tag | Skip git tag |
|
|
61
|
+
| -nt --npm-tag \<npmTag\> | npm tag |
|
|
62
|
+
|
|
63
|
+
#### changelog
|
|
64
|
+
|
|
65
|
+
| Params | Instructions |
|
|
66
|
+
| ----------------------------------- | -------------------------- |
|
|
67
|
+
| -f --file \<filename\> | Specify changelog filename |
|
|
68
|
+
| -rc --releaseCount \<releaseCount\> | Release count |
|
|
69
|
+
| -p --preset \<preset\> | Specify changelog preset |
|
|
70
|
+
|
|
71
|
+
#### lint-commit
|
|
72
|
+
|
|
73
|
+
| Params | Instructions |
|
|
74
|
+
| ------------------------------- | ---------------------------------------------------------------------------------------------------------------------- |
|
|
75
|
+
| -p --commitMessagePath \<path\> | The path of the temporary file to which the git message is submitted. The git hook commit-msg will pass this parameter |
|
|
76
|
+
| -r --commitMessageRe \<reg\> | Validate the regular of whether the commit message passes |
|
|
77
|
+
| -e --errorMessage \<message\> | Validation failed to display error messages |
|
|
78
|
+
| -w --warningMessage \<message\> | Validation failed to display warning messages |
|
|
79
|
+
|
|
80
|
+
#### publish
|
|
81
|
+
|
|
82
|
+
| Params | Instructions |
|
|
83
|
+
| ------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
84
|
+
| -c --check-remote-version | Detects whether the remote version of the npm package is the same as the package version to be published locally, and if it is, skip the release |
|
|
85
|
+
| -nt --npm-tag \<npmTag\> | npm tag |
|
|
86
|
+
|
|
87
|
+
### Custom Handle
|
|
88
|
+
|
|
89
|
+
#### Example
|
|
90
|
+
|
|
91
|
+
```js
|
|
92
|
+
import { changelog, release } from '@varlet/release'
|
|
93
|
+
|
|
94
|
+
// Do what you want to do...
|
|
95
|
+
release()
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
You can pass in a task that will be called before the publish after the package version is changed.
|
|
99
|
+
|
|
100
|
+
```js
|
|
101
|
+
import { changelog, release } from '@varlet/release'
|
|
102
|
+
|
|
103
|
+
async function task() {
|
|
104
|
+
await doSomething1()
|
|
105
|
+
await doSomething2()
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
release({ task })
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
#### Types
|
|
112
|
+
|
|
113
|
+
```ts
|
|
114
|
+
interface PublishCommandOptions {
|
|
115
|
+
preRelease?: boolean
|
|
116
|
+
checkRemoteVersion?: boolean
|
|
117
|
+
npmTag?: string
|
|
118
|
+
}
|
|
119
|
+
function publish({ preRelease, checkRemoteVersion, npmTag }: PublishCommandOptions): Promise<void>
|
|
120
|
+
function updateVersion(version: string): void
|
|
121
|
+
interface ReleaseCommandOptions {
|
|
122
|
+
remote?: string
|
|
123
|
+
skipNpmPublish?: boolean
|
|
124
|
+
skipChangelog?: boolean
|
|
125
|
+
skipGitTag?: boolean
|
|
126
|
+
npmTag?: string
|
|
127
|
+
task?(newVersion: string, oldVersion: string): Promise<void>
|
|
128
|
+
}
|
|
129
|
+
function release(options: ReleaseCommandOptions): Promise<void>
|
|
130
|
+
|
|
131
|
+
interface ChangelogCommandOptions {
|
|
132
|
+
file?: string
|
|
133
|
+
releaseCount?: number
|
|
134
|
+
preset?:
|
|
135
|
+
| 'angular'
|
|
136
|
+
| 'atom'
|
|
137
|
+
| 'codemirror'
|
|
138
|
+
| 'conventionalcommits'
|
|
139
|
+
| 'ember'
|
|
140
|
+
| 'eslint'
|
|
141
|
+
| 'express'
|
|
142
|
+
| 'jquery'
|
|
143
|
+
| 'jshint'
|
|
144
|
+
}
|
|
145
|
+
function changelog({ releaseCount, file, preset }?: ChangelogCommandOptions): Promise<void>
|
|
146
|
+
|
|
147
|
+
const COMMIT_MESSAGE_RE: RegExp
|
|
148
|
+
function isVersionCommitMessage(message: string): string | false | null
|
|
149
|
+
function getCommitMessage(commitMessagePath: string): string
|
|
150
|
+
interface CommitLintCommandOptions {
|
|
151
|
+
commitMessagePath: string
|
|
152
|
+
commitMessageRe?: string | RegExp
|
|
153
|
+
errorMessage?: string
|
|
154
|
+
warningMessage?: string
|
|
155
|
+
}
|
|
156
|
+
function commitLint(options: CommitLintCommandOptions): void
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
## License
|
|
160
|
+
|
|
161
|
+
[MIT](https://github.com/varletjs/release/blob/main/LICENSE)
|
package/README.zh-CN.md
CHANGED
|
@@ -1,150 +1,161 @@
|
|
|
1
|
-
<h1 align="center">Varlet Release</h1>
|
|
2
|
-
|
|
3
|
-
<p align="center">
|
|
4
|
-
<span>中文</span> |
|
|
5
|
-
<a href="https://github.com/varletjs/release/blob/main/README.md">English</a>
|
|
6
|
-
</p>
|
|
7
|
-
<p align="center">
|
|
8
|
-
<a href="https://www.npmjs.com/package/@varlet/release" target="_blank" rel="noopener noreferrer"><img src="https://badgen.net/npm/v/@varlet/release" alt="NPM Version" /></a>
|
|
9
|
-
<a href="https://github.com/valetjs/release/blob/master/LICENSE" target="_blank" rel="noopener noreferrer"><img src="https://badgen.net/github/license/varletjs/release" alt="License" /></a>
|
|
10
|
-
</p>
|
|
11
|
-
|
|
12
|
-
## 介绍
|
|
13
|
-
|
|
14
|
-
`Varlet Release` 是一个用于发布所有包、生成变更日志和检测 `commit message` 的工具,依赖于 `pnpm`。
|
|
15
|
-
|
|
16
|
-
## 安装
|
|
17
|
-
|
|
18
|
-
```shell
|
|
19
|
-
pnpm add @varlet/release -D
|
|
20
|
-
```
|
|
21
|
-
|
|
22
|
-
## 使用
|
|
23
|
-
|
|
24
|
-
### 使用命令
|
|
25
|
-
|
|
26
|
-
```shell
|
|
27
|
-
# 发布所有包并生成变更日志
|
|
28
|
-
npx vr release
|
|
29
|
-
|
|
30
|
-
# 指定远程仓库名称
|
|
31
|
-
npx vr release -r https://github.com/varletjs/varlet-release
|
|
32
|
-
# or
|
|
33
|
-
npx vr release --remote https://github.com/varletjs/varlet-release
|
|
34
|
-
|
|
35
|
-
# 仅生成变更日志
|
|
36
|
-
npx vr changelog
|
|
37
|
-
|
|
38
|
-
# 指定变更日志文件名
|
|
39
|
-
npx vr changelog -f changelog.md
|
|
40
|
-
# or
|
|
41
|
-
npx vr changelog --file changelog.md
|
|
42
|
-
|
|
43
|
-
# 检测 commit message
|
|
44
|
-
npx vr lint-commit -p .git/COMMIT_EDITMSG
|
|
45
|
-
|
|
46
|
-
# 发布到 npm,可以在 ci 中执行
|
|
47
|
-
npx vr publish
|
|
48
|
-
```
|
|
49
|
-
|
|
50
|
-
### 配置
|
|
51
|
-
|
|
52
|
-
#### release
|
|
53
|
-
|
|
54
|
-
| 参数 | 说明 |
|
|
55
|
-
| ------------------------- | ----------------------------------------------------------------------- |
|
|
56
|
-
| -r --remote \<remote\> | 指定远程仓库名称 |
|
|
57
|
-
| -s --skip-npm-publish | 跳过 npm 发布 |
|
|
58
|
-
| -c --check-remote-version | 检测 npm 包的远程版本是否与要在本地发布的包版本相同,如果是,则停止执行 |
|
|
59
|
-
| -sc --skip-changelog | 跳过生成变更日志 |
|
|
60
|
-
| -sgt --skip-git-tag | 跳过 git tag |
|
|
61
|
-
| -nt --npm-tag \<npmTag\> | npm tag |
|
|
62
|
-
|
|
63
|
-
#### changelog
|
|
64
|
-
|
|
65
|
-
| 参数 | 说明 |
|
|
66
|
-
| ----------------------------------- | ------------------ |
|
|
67
|
-
| -f --file \<filename\> | 指定变更日志文件名 |
|
|
68
|
-
| -rc --releaseCount \<releaseCount\> | 发布数量 |
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
|
74
|
-
|
|
|
75
|
-
| -
|
|
76
|
-
| -
|
|
77
|
-
| -
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
|
83
|
-
|
|
|
84
|
-
| -
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
await
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
function
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
}
|
|
145
|
-
function
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
1
|
+
<h1 align="center">Varlet Release</h1>
|
|
2
|
+
|
|
3
|
+
<p align="center">
|
|
4
|
+
<span>中文</span> |
|
|
5
|
+
<a href="https://github.com/varletjs/release/blob/main/README.md">English</a>
|
|
6
|
+
</p>
|
|
7
|
+
<p align="center">
|
|
8
|
+
<a href="https://www.npmjs.com/package/@varlet/release" target="_blank" rel="noopener noreferrer"><img src="https://badgen.net/npm/v/@varlet/release" alt="NPM Version" /></a>
|
|
9
|
+
<a href="https://github.com/valetjs/release/blob/master/LICENSE" target="_blank" rel="noopener noreferrer"><img src="https://badgen.net/github/license/varletjs/release" alt="License" /></a>
|
|
10
|
+
</p>
|
|
11
|
+
|
|
12
|
+
## 介绍
|
|
13
|
+
|
|
14
|
+
`Varlet Release` 是一个用于发布所有包、生成变更日志和检测 `commit message` 的工具,依赖于 `pnpm`。
|
|
15
|
+
|
|
16
|
+
## 安装
|
|
17
|
+
|
|
18
|
+
```shell
|
|
19
|
+
pnpm add @varlet/release -D
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## 使用
|
|
23
|
+
|
|
24
|
+
### 使用命令
|
|
25
|
+
|
|
26
|
+
```shell
|
|
27
|
+
# 发布所有包并生成变更日志
|
|
28
|
+
npx vr release
|
|
29
|
+
|
|
30
|
+
# 指定远程仓库名称
|
|
31
|
+
npx vr release -r https://github.com/varletjs/varlet-release
|
|
32
|
+
# or
|
|
33
|
+
npx vr release --remote https://github.com/varletjs/varlet-release
|
|
34
|
+
|
|
35
|
+
# 仅生成变更日志
|
|
36
|
+
npx vr changelog
|
|
37
|
+
|
|
38
|
+
# 指定变更日志文件名
|
|
39
|
+
npx vr changelog -f changelog.md
|
|
40
|
+
# or
|
|
41
|
+
npx vr changelog --file changelog.md
|
|
42
|
+
|
|
43
|
+
# 检测 commit message
|
|
44
|
+
npx vr lint-commit -p .git/COMMIT_EDITMSG
|
|
45
|
+
|
|
46
|
+
# 发布到 npm,可以在 ci 中执行
|
|
47
|
+
npx vr publish
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
### 配置
|
|
51
|
+
|
|
52
|
+
#### release
|
|
53
|
+
|
|
54
|
+
| 参数 | 说明 |
|
|
55
|
+
| ------------------------- | ----------------------------------------------------------------------- |
|
|
56
|
+
| -r --remote \<remote\> | 指定远程仓库名称 |
|
|
57
|
+
| -s --skip-npm-publish | 跳过 npm 发布 |
|
|
58
|
+
| -c --check-remote-version | 检测 npm 包的远程版本是否与要在本地发布的包版本相同,如果是,则停止执行 |
|
|
59
|
+
| -sc --skip-changelog | 跳过生成变更日志 |
|
|
60
|
+
| -sgt --skip-git-tag | 跳过 git tag |
|
|
61
|
+
| -nt --npm-tag \<npmTag\> | npm tag |
|
|
62
|
+
|
|
63
|
+
#### changelog
|
|
64
|
+
|
|
65
|
+
| 参数 | 说明 |
|
|
66
|
+
| ----------------------------------- | ------------------ |
|
|
67
|
+
| -f --file \<filename\> | 指定变更日志文件名 |
|
|
68
|
+
| -rc --releaseCount \<releaseCount\> | 发布数量 |
|
|
69
|
+
| -p --preset \<preset\> | 指定变更预设 |
|
|
70
|
+
|
|
71
|
+
#### lint-commit
|
|
72
|
+
|
|
73
|
+
| 参数 | 说明 |
|
|
74
|
+
| ------------------------------- | --------------------------------------------------------------------------- |
|
|
75
|
+
| -p --commitMessagePath \<path\> | 提交 `git message` 的临时文件路径。`git` 钩子 `commit-msg` 会传递这个参数。 |
|
|
76
|
+
| -r --commitMessageRe \<reg\> | 验证 `commit message` 是否通过的正则 |
|
|
77
|
+
| -e --errorMessage \<message\> | 验证失败展示的错误信息 |
|
|
78
|
+
| -w --warningMessage \<message\> | 验证失败展示的提示信息 |
|
|
79
|
+
|
|
80
|
+
#### publish
|
|
81
|
+
|
|
82
|
+
| 参数 | 说明 |
|
|
83
|
+
| ------------------------- | --------------------------------------------------------------------- |
|
|
84
|
+
| -c --check-remote-version | 检测npm包的远程版本是否与要在本地发布的包版本相同,如果是,则跳过发布 |
|
|
85
|
+
| -nt --npm-tag \<npmTag\> | npm tag |
|
|
86
|
+
|
|
87
|
+
### 自定义处理
|
|
88
|
+
|
|
89
|
+
#### 示例
|
|
90
|
+
|
|
91
|
+
```js
|
|
92
|
+
import { changelog, release } from '@varlet/release'
|
|
93
|
+
|
|
94
|
+
// Do what you want to do...
|
|
95
|
+
release()
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
你可以传入一个 `task`,在包版本更改后,在发布之前会调用 `task`。
|
|
99
|
+
|
|
100
|
+
```js
|
|
101
|
+
import { changelog, release } from '@varlet/release'
|
|
102
|
+
|
|
103
|
+
async function task() {
|
|
104
|
+
await doSomething1()
|
|
105
|
+
await doSomething2()
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
release({ task })
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
#### 类型
|
|
112
|
+
|
|
113
|
+
```ts
|
|
114
|
+
interface PublishCommandOptions {
|
|
115
|
+
preRelease?: boolean
|
|
116
|
+
checkRemoteVersion?: boolean
|
|
117
|
+
npmTag?: string
|
|
118
|
+
}
|
|
119
|
+
function publish({ preRelease, checkRemoteVersion, npmTag }: PublishCommandOptions): Promise<void>
|
|
120
|
+
function updateVersion(version: string): void
|
|
121
|
+
interface ReleaseCommandOptions {
|
|
122
|
+
remote?: string
|
|
123
|
+
skipNpmPublish?: boolean
|
|
124
|
+
skipChangelog?: boolean
|
|
125
|
+
skipGitTag?: boolean
|
|
126
|
+
npmTag?: string
|
|
127
|
+
task?(newVersion: string, oldVersion: string): Promise<void>
|
|
128
|
+
}
|
|
129
|
+
function release(options: ReleaseCommandOptions): Promise<void>
|
|
130
|
+
|
|
131
|
+
interface ChangelogCommandOptions {
|
|
132
|
+
file?: string
|
|
133
|
+
releaseCount?: number
|
|
134
|
+
preset?:
|
|
135
|
+
| 'angular'
|
|
136
|
+
| 'atom'
|
|
137
|
+
| 'codemirror'
|
|
138
|
+
| 'conventionalcommits'
|
|
139
|
+
| 'ember'
|
|
140
|
+
| 'eslint'
|
|
141
|
+
| 'express'
|
|
142
|
+
| 'jquery'
|
|
143
|
+
| 'jshint'
|
|
144
|
+
}
|
|
145
|
+
function changelog({ releaseCount, file, preset }?: ChangelogCommandOptions): Promise<void>
|
|
146
|
+
|
|
147
|
+
const COMMIT_MESSAGE_RE: RegExp
|
|
148
|
+
function isVersionCommitMessage(message: string): string | false | null
|
|
149
|
+
function getCommitMessage(commitMessagePath: string): string
|
|
150
|
+
interface CommitLintCommandOptions {
|
|
151
|
+
commitMessagePath: string
|
|
152
|
+
commitMessageRe?: string | RegExp
|
|
153
|
+
errorMessage?: string
|
|
154
|
+
warningMessage?: string
|
|
155
|
+
}
|
|
156
|
+
function commitLint(options: CommitLintCommandOptions): void
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
## 许可证
|
|
160
|
+
|
|
161
|
+
[MIT](https://github.com/varletjs/release/blob/main/LICENSE)
|
package/bin/index.js
CHANGED
|
@@ -1,46 +1,47 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
const program = new Command()
|
|
7
|
-
|
|
8
|
-
const packageJson = fse.readJSONSync(new URL('../package.json', import.meta.url))
|
|
9
|
-
|
|
10
|
-
program.version(packageJson.version)
|
|
11
|
-
|
|
12
|
-
program
|
|
13
|
-
.command('release')
|
|
14
|
-
.option('-r --remote <remote>', 'Remote name')
|
|
15
|
-
.option('-s --skip-npm-publish', 'Skip npm publish')
|
|
16
|
-
.option('-sc --skip-changelog', 'Skip generate changelog')
|
|
17
|
-
.option('-sgt --skip-git-tag', 'Skip git tag')
|
|
18
|
-
.option('-nt --npm-tag <npmTag>', 'Npm tag')
|
|
19
|
-
.option('-c --check-remote-version', 'Check remote version')
|
|
20
|
-
.description('Release all packages and generate changelogs')
|
|
21
|
-
.action(
|
|
22
|
-
|
|
23
|
-
program
|
|
24
|
-
.command('publish')
|
|
25
|
-
.option('-c --check-remote-version', 'Check remote version')
|
|
26
|
-
.option('-nt --npm-tag <npmTag>', 'Npm tag')
|
|
27
|
-
.description('Publish to npm')
|
|
28
|
-
.action(
|
|
29
|
-
|
|
30
|
-
program
|
|
31
|
-
.command('changelog')
|
|
32
|
-
.option('-rc --releaseCount <releaseCount>', 'Release count')
|
|
33
|
-
.option('-f --file <file>', 'Changelog filename')
|
|
34
|
-
.
|
|
35
|
-
.
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
.
|
|
40
|
-
.option('-
|
|
41
|
-
.option('-
|
|
42
|
-
.option('-
|
|
43
|
-
.
|
|
44
|
-
.
|
|
45
|
-
|
|
46
|
-
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { Command } from 'commander'
|
|
3
|
+
import fse from 'fs-extra'
|
|
4
|
+
import { changelog, commitLint, publish, release } from '../dist/index.js'
|
|
5
|
+
|
|
6
|
+
const program = new Command()
|
|
7
|
+
|
|
8
|
+
const packageJson = fse.readJSONSync(new URL('../package.json', import.meta.url))
|
|
9
|
+
|
|
10
|
+
program.version(packageJson.version)
|
|
11
|
+
|
|
12
|
+
program
|
|
13
|
+
.command('release')
|
|
14
|
+
.option('-r --remote <remote>', 'Remote name')
|
|
15
|
+
.option('-s --skip-npm-publish', 'Skip npm publish')
|
|
16
|
+
.option('-sc --skip-changelog', 'Skip generate changelog')
|
|
17
|
+
.option('-sgt --skip-git-tag', 'Skip git tag')
|
|
18
|
+
.option('-nt --npm-tag <npmTag>', 'Npm tag')
|
|
19
|
+
.option('-c --check-remote-version', 'Check remote version')
|
|
20
|
+
.description('Release all packages and generate changelogs')
|
|
21
|
+
.action((options) => release(options))
|
|
22
|
+
|
|
23
|
+
program
|
|
24
|
+
.command('publish')
|
|
25
|
+
.option('-c --check-remote-version', 'Check remote version')
|
|
26
|
+
.option('-nt --npm-tag <npmTag>', 'Npm tag')
|
|
27
|
+
.description('Publish to npm')
|
|
28
|
+
.action((options) => publish(options))
|
|
29
|
+
|
|
30
|
+
program
|
|
31
|
+
.command('changelog')
|
|
32
|
+
.option('-rc --releaseCount <releaseCount>', 'Release count')
|
|
33
|
+
.option('-f --file <file>', 'Changelog filename')
|
|
34
|
+
.option('-p --preset <preset>', 'Changelog preset')
|
|
35
|
+
.description('Generate changelog')
|
|
36
|
+
.action((options) => changelog(options))
|
|
37
|
+
|
|
38
|
+
program
|
|
39
|
+
.command('commit-lint')
|
|
40
|
+
.option('-p --commitMessagePath <path>', 'Git commit message path')
|
|
41
|
+
.option('-r --commitMessageRe <reg>', 'Validate the regular of whether the commit message passes')
|
|
42
|
+
.option('-e --errorMessage <message>', 'Validation failed to display error messages')
|
|
43
|
+
.option('-w --warningMessage <message>', 'Validation failed to display warning messages')
|
|
44
|
+
.description('Lint commit message')
|
|
45
|
+
.action((option) => commitLint(option))
|
|
46
|
+
|
|
47
|
+
program.parse()
|
package/dist/index.cjs
CHANGED
|
@@ -43,49 +43,54 @@ __export(src_exports, {
|
|
|
43
43
|
module.exports = __toCommonJS(src_exports);
|
|
44
44
|
|
|
45
45
|
// src/release.ts
|
|
46
|
+
var import_path2 = require("path");
|
|
47
|
+
var import_prompts = require("@inquirer/prompts");
|
|
46
48
|
var import_fs_extra2 = __toESM(require("fs-extra"), 1);
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
var
|
|
50
|
-
var logger_default = {
|
|
51
|
-
info(text) {
|
|
52
|
-
console.log(text);
|
|
53
|
-
},
|
|
54
|
-
success(text) {
|
|
55
|
-
console.log(import_picocolors.default.green(text));
|
|
56
|
-
},
|
|
57
|
-
warning(text) {
|
|
58
|
-
console.log(import_picocolors.default.yellow(text));
|
|
59
|
-
},
|
|
60
|
-
error(text) {
|
|
61
|
-
console.log(import_picocolors.default.red(text));
|
|
62
|
-
},
|
|
63
|
-
title(text) {
|
|
64
|
-
console.log(import_picocolors.default.cyan(text));
|
|
65
|
-
}
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
// src/release.ts
|
|
49
|
+
var import_glob = require("glob");
|
|
50
|
+
var import_nanospinner2 = require("nanospinner");
|
|
51
|
+
var import_rslog = require("rslog");
|
|
69
52
|
var import_semver = __toESM(require("semver"), 1);
|
|
70
|
-
var import_prompts = require("@inquirer/prompts");
|
|
71
53
|
var import_tinyexec = require("tinyexec");
|
|
72
|
-
var import_nanospinner2 = require("nanospinner");
|
|
73
|
-
var import_glob = require("glob");
|
|
74
|
-
var import_path2 = require("path");
|
|
75
54
|
|
|
76
55
|
// src/changelog.ts
|
|
56
|
+
var import_path = require("path");
|
|
77
57
|
var import_conventional_changelog = __toESM(require("conventional-changelog"), 1);
|
|
78
58
|
var import_fs_extra = __toESM(require("fs-extra"), 1);
|
|
79
59
|
var import_nanospinner = require("nanospinner");
|
|
80
|
-
var import_path = require("path");
|
|
81
60
|
var { createWriteStream } = import_fs_extra.default;
|
|
82
|
-
function changelog({
|
|
61
|
+
function changelog({
|
|
62
|
+
releaseCount = 0,
|
|
63
|
+
file = "CHANGELOG.md",
|
|
64
|
+
preset = "angular",
|
|
65
|
+
writerOpts = {
|
|
66
|
+
transform: (commit) => {
|
|
67
|
+
if (commit.type === `feat`) {
|
|
68
|
+
commit.type = `Features`;
|
|
69
|
+
} else if (commit.type === `fix`) {
|
|
70
|
+
commit.type = `Bug Fixes`;
|
|
71
|
+
} else if (commit.type === `perf`) {
|
|
72
|
+
commit.type = `Performance Improvements`;
|
|
73
|
+
} else if (commit.type === `refactor`) {
|
|
74
|
+
commit.type = `Refactor`;
|
|
75
|
+
} else {
|
|
76
|
+
return false;
|
|
77
|
+
}
|
|
78
|
+
return commit;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
} = {}) {
|
|
83
82
|
const s = (0, import_nanospinner.createSpinner)("Generating changelog").start();
|
|
84
83
|
return new Promise((resolve2) => {
|
|
85
|
-
(0, import_conventional_changelog.default)(
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
84
|
+
(0, import_conventional_changelog.default)(
|
|
85
|
+
{
|
|
86
|
+
preset,
|
|
87
|
+
releaseCount
|
|
88
|
+
},
|
|
89
|
+
void 0,
|
|
90
|
+
void 0,
|
|
91
|
+
void 0,
|
|
92
|
+
writerOpts
|
|
93
|
+
).pipe(createWriteStream((0, import_path.resolve)(process.cwd(), file))).on("close", () => {
|
|
89
94
|
s.success({ text: "Changelog generated success!" });
|
|
90
95
|
resolve2();
|
|
91
96
|
});
|
|
@@ -125,7 +130,7 @@ async function publish({ preRelease, checkRemoteVersion, npmTag }) {
|
|
|
125
130
|
const s = (0, import_nanospinner2.createSpinner)("Publishing all packages").start();
|
|
126
131
|
const args = ["-r", "publish", "--no-git-checks", "--access", "public"];
|
|
127
132
|
if (checkRemoteVersion && await isSameVersion()) {
|
|
128
|
-
|
|
133
|
+
import_rslog.logger.error("publishing automatically skipped.");
|
|
129
134
|
return;
|
|
130
135
|
}
|
|
131
136
|
if (preRelease) {
|
|
@@ -138,7 +143,7 @@ async function publish({ preRelease, checkRemoteVersion, npmTag }) {
|
|
|
138
143
|
throw new Error("\n" + ret.stderr);
|
|
139
144
|
} else {
|
|
140
145
|
s.success({ text: "Publish all packages successfully" });
|
|
141
|
-
ret.stdout &&
|
|
146
|
+
ret.stdout && import_rslog.logger.info(ret.stdout);
|
|
142
147
|
}
|
|
143
148
|
}
|
|
144
149
|
async function pushGit(version, remote = "origin", skipGitTag = false) {
|
|
@@ -161,7 +166,7 @@ async function pushGit(version, remote = "origin", skipGitTag = false) {
|
|
|
161
166
|
throwOnError: true
|
|
162
167
|
});
|
|
163
168
|
s.success({ text: "Push remote repository successfully" });
|
|
164
|
-
ret.stdout &&
|
|
169
|
+
ret.stdout && import_rslog.logger.info(ret.stdout);
|
|
165
170
|
}
|
|
166
171
|
function getPackageJsons() {
|
|
167
172
|
const packageJsons = ["package.json", ...import_glob.glob.sync("packages/*/package.json")];
|
|
@@ -231,11 +236,11 @@ async function release(options) {
|
|
|
231
236
|
try {
|
|
232
237
|
const currentVersion = readJSONSync((0, import_path2.resolve)(cwd, "package.json")).version;
|
|
233
238
|
if (!currentVersion) {
|
|
234
|
-
|
|
239
|
+
import_rslog.logger.error("Your package is missing the version field");
|
|
235
240
|
return;
|
|
236
241
|
}
|
|
237
242
|
if (!await isWorktreeEmpty()) {
|
|
238
|
-
|
|
243
|
+
import_rslog.logger.error("Git worktree is not empty, please commit changed");
|
|
239
244
|
return;
|
|
240
245
|
}
|
|
241
246
|
if (!await confirmRefs(options.remote)) {
|
|
@@ -246,7 +251,7 @@ async function release(options) {
|
|
|
246
251
|
}
|
|
247
252
|
const { isPreRelease, expectVersion } = await getReleaseVersion(currentVersion);
|
|
248
253
|
if (options.checkRemoteVersion && await isSameVersion(expectVersion)) {
|
|
249
|
-
|
|
254
|
+
import_rslog.logger.error("Please check remote version.");
|
|
250
255
|
return;
|
|
251
256
|
}
|
|
252
257
|
updateVersion(expectVersion);
|
|
@@ -262,7 +267,7 @@ async function release(options) {
|
|
|
262
267
|
}
|
|
263
268
|
await pushGit(expectVersion, options.remote, options.skipGitTag);
|
|
264
269
|
}
|
|
265
|
-
|
|
270
|
+
import_rslog.logger.success(`Release version ${expectVersion} successfully!`);
|
|
266
271
|
if (isPreRelease) {
|
|
267
272
|
try {
|
|
268
273
|
await (0, import_tinyexec.x)("git", ["restore", "**/package.json"], {
|
|
@@ -278,14 +283,15 @@ async function release(options) {
|
|
|
278
283
|
}
|
|
279
284
|
}
|
|
280
285
|
} catch (error) {
|
|
281
|
-
|
|
286
|
+
import_rslog.logger.error(error.toString());
|
|
282
287
|
process.exit(1);
|
|
283
288
|
}
|
|
284
289
|
}
|
|
285
290
|
|
|
286
291
|
// src/commitLint.ts
|
|
287
|
-
var import_semver2 = __toESM(require("semver"), 1);
|
|
288
292
|
var import_fs_extra3 = __toESM(require("fs-extra"), 1);
|
|
293
|
+
var import_rslog2 = require("rslog");
|
|
294
|
+
var import_semver2 = __toESM(require("semver"), 1);
|
|
289
295
|
var { readFileSync } = import_fs_extra3.default;
|
|
290
296
|
var COMMIT_MESSAGE_RE = /^(revert|fix|feat|docs|perf|test|types|style|build|chore|release|refactor|merge|wip)(\(.+\))?!?: (.|\n)+/;
|
|
291
297
|
var ERROR_MESSAGE = "Commit message invalid.";
|
|
@@ -334,14 +340,14 @@ function commitLint(options) {
|
|
|
334
340
|
warningMessage = WARNING_MESSAGE
|
|
335
341
|
} = options;
|
|
336
342
|
if (!commitMessagePath) {
|
|
337
|
-
|
|
343
|
+
import_rslog2.logger.error("commitMessagePath is required");
|
|
338
344
|
process.exit(1);
|
|
339
345
|
}
|
|
340
346
|
const commitMessage = getCommitMessage(commitMessagePath);
|
|
341
347
|
const isValidCommitMessage = new RegExp(commitMessageRe).test(commitMessage);
|
|
342
348
|
if (!isVersionCommitMessage(commitMessage) && !isValidCommitMessage) {
|
|
343
|
-
|
|
344
|
-
|
|
349
|
+
import_rslog2.logger.error(errorMessage);
|
|
350
|
+
import_rslog2.logger.warn(warningMessage);
|
|
345
351
|
process.exit(1);
|
|
346
352
|
}
|
|
347
353
|
}
|
package/dist/index.d.cts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import conventionalChangelog from 'conventional-changelog';
|
|
2
|
+
|
|
1
3
|
declare function isSameVersion(version?: string): Promise<boolean | undefined>;
|
|
2
4
|
interface PublishCommandOptions {
|
|
3
5
|
preRelease?: boolean;
|
|
@@ -20,8 +22,10 @@ declare function release(options: ReleaseCommandOptions): Promise<void>;
|
|
|
20
22
|
interface ChangelogCommandOptions {
|
|
21
23
|
file?: string;
|
|
22
24
|
releaseCount?: number;
|
|
25
|
+
preset?: 'angular' | 'atom' | 'codemirror' | 'conventionalcommits' | 'ember' | 'eslint' | 'express' | 'jquery' | 'jshint';
|
|
26
|
+
writerOpts?: Parameters<typeof conventionalChangelog>['4'];
|
|
23
27
|
}
|
|
24
|
-
declare function changelog({ releaseCount, file }?: ChangelogCommandOptions): Promise<void>;
|
|
28
|
+
declare function changelog({ releaseCount, file, preset, writerOpts, }?: ChangelogCommandOptions): Promise<void>;
|
|
25
29
|
|
|
26
30
|
declare const COMMIT_MESSAGE_RE: RegExp;
|
|
27
31
|
declare function isVersionCommitMessage(message: string): string | false | null;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import conventionalChangelog from 'conventional-changelog';
|
|
2
|
+
|
|
1
3
|
declare function isSameVersion(version?: string): Promise<boolean | undefined>;
|
|
2
4
|
interface PublishCommandOptions {
|
|
3
5
|
preRelease?: boolean;
|
|
@@ -20,8 +22,10 @@ declare function release(options: ReleaseCommandOptions): Promise<void>;
|
|
|
20
22
|
interface ChangelogCommandOptions {
|
|
21
23
|
file?: string;
|
|
22
24
|
releaseCount?: number;
|
|
25
|
+
preset?: 'angular' | 'atom' | 'codemirror' | 'conventionalcommits' | 'ember' | 'eslint' | 'express' | 'jquery' | 'jshint';
|
|
26
|
+
writerOpts?: Parameters<typeof conventionalChangelog>['4'];
|
|
23
27
|
}
|
|
24
|
-
declare function changelog({ releaseCount, file }?: ChangelogCommandOptions): Promise<void>;
|
|
28
|
+
declare function changelog({ releaseCount, file, preset, writerOpts, }?: ChangelogCommandOptions): Promise<void>;
|
|
25
29
|
|
|
26
30
|
declare const COMMIT_MESSAGE_RE: RegExp;
|
|
27
31
|
declare function isVersionCommitMessage(message: string): string | false | null;
|
package/dist/index.js
CHANGED
|
@@ -1,47 +1,52 @@
|
|
|
1
1
|
// src/release.ts
|
|
2
|
+
import { resolve } from "path";
|
|
3
|
+
import { confirm, select } from "@inquirer/prompts";
|
|
2
4
|
import fse2 from "fs-extra";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
import
|
|
6
|
-
var logger_default = {
|
|
7
|
-
info(text) {
|
|
8
|
-
console.log(text);
|
|
9
|
-
},
|
|
10
|
-
success(text) {
|
|
11
|
-
console.log(pico.green(text));
|
|
12
|
-
},
|
|
13
|
-
warning(text) {
|
|
14
|
-
console.log(pico.yellow(text));
|
|
15
|
-
},
|
|
16
|
-
error(text) {
|
|
17
|
-
console.log(pico.red(text));
|
|
18
|
-
},
|
|
19
|
-
title(text) {
|
|
20
|
-
console.log(pico.cyan(text));
|
|
21
|
-
}
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
// src/release.ts
|
|
5
|
+
import { glob } from "glob";
|
|
6
|
+
import { createSpinner as createSpinner2 } from "nanospinner";
|
|
7
|
+
import { logger } from "rslog";
|
|
25
8
|
import semver from "semver";
|
|
26
|
-
import { confirm, select } from "@inquirer/prompts";
|
|
27
9
|
import { x as exec } from "tinyexec";
|
|
28
|
-
import { createSpinner as createSpinner2 } from "nanospinner";
|
|
29
|
-
import { glob } from "glob";
|
|
30
|
-
import { resolve } from "path";
|
|
31
10
|
|
|
32
11
|
// src/changelog.ts
|
|
12
|
+
import { resolve as resolvePath } from "path";
|
|
33
13
|
import conventionalChangelog from "conventional-changelog";
|
|
34
14
|
import fse from "fs-extra";
|
|
35
15
|
import { createSpinner } from "nanospinner";
|
|
36
|
-
import { resolve as resolvePath } from "path";
|
|
37
16
|
var { createWriteStream } = fse;
|
|
38
|
-
function changelog({
|
|
17
|
+
function changelog({
|
|
18
|
+
releaseCount = 0,
|
|
19
|
+
file = "CHANGELOG.md",
|
|
20
|
+
preset = "angular",
|
|
21
|
+
writerOpts = {
|
|
22
|
+
transform: (commit) => {
|
|
23
|
+
if (commit.type === `feat`) {
|
|
24
|
+
commit.type = `Features`;
|
|
25
|
+
} else if (commit.type === `fix`) {
|
|
26
|
+
commit.type = `Bug Fixes`;
|
|
27
|
+
} else if (commit.type === `perf`) {
|
|
28
|
+
commit.type = `Performance Improvements`;
|
|
29
|
+
} else if (commit.type === `refactor`) {
|
|
30
|
+
commit.type = `Refactor`;
|
|
31
|
+
} else {
|
|
32
|
+
return false;
|
|
33
|
+
}
|
|
34
|
+
return commit;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
} = {}) {
|
|
39
38
|
const s = createSpinner("Generating changelog").start();
|
|
40
39
|
return new Promise((resolve2) => {
|
|
41
|
-
conventionalChangelog(
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
40
|
+
conventionalChangelog(
|
|
41
|
+
{
|
|
42
|
+
preset,
|
|
43
|
+
releaseCount
|
|
44
|
+
},
|
|
45
|
+
void 0,
|
|
46
|
+
void 0,
|
|
47
|
+
void 0,
|
|
48
|
+
writerOpts
|
|
49
|
+
).pipe(createWriteStream(resolvePath(process.cwd(), file))).on("close", () => {
|
|
45
50
|
s.success({ text: "Changelog generated success!" });
|
|
46
51
|
resolve2();
|
|
47
52
|
});
|
|
@@ -81,7 +86,7 @@ async function publish({ preRelease, checkRemoteVersion, npmTag }) {
|
|
|
81
86
|
const s = createSpinner2("Publishing all packages").start();
|
|
82
87
|
const args = ["-r", "publish", "--no-git-checks", "--access", "public"];
|
|
83
88
|
if (checkRemoteVersion && await isSameVersion()) {
|
|
84
|
-
|
|
89
|
+
logger.error("publishing automatically skipped.");
|
|
85
90
|
return;
|
|
86
91
|
}
|
|
87
92
|
if (preRelease) {
|
|
@@ -94,7 +99,7 @@ async function publish({ preRelease, checkRemoteVersion, npmTag }) {
|
|
|
94
99
|
throw new Error("\n" + ret.stderr);
|
|
95
100
|
} else {
|
|
96
101
|
s.success({ text: "Publish all packages successfully" });
|
|
97
|
-
ret.stdout &&
|
|
102
|
+
ret.stdout && logger.info(ret.stdout);
|
|
98
103
|
}
|
|
99
104
|
}
|
|
100
105
|
async function pushGit(version, remote = "origin", skipGitTag = false) {
|
|
@@ -117,7 +122,7 @@ async function pushGit(version, remote = "origin", skipGitTag = false) {
|
|
|
117
122
|
throwOnError: true
|
|
118
123
|
});
|
|
119
124
|
s.success({ text: "Push remote repository successfully" });
|
|
120
|
-
ret.stdout &&
|
|
125
|
+
ret.stdout && logger.info(ret.stdout);
|
|
121
126
|
}
|
|
122
127
|
function getPackageJsons() {
|
|
123
128
|
const packageJsons = ["package.json", ...glob.sync("packages/*/package.json")];
|
|
@@ -187,11 +192,11 @@ async function release(options) {
|
|
|
187
192
|
try {
|
|
188
193
|
const currentVersion = readJSONSync(resolve(cwd, "package.json")).version;
|
|
189
194
|
if (!currentVersion) {
|
|
190
|
-
|
|
195
|
+
logger.error("Your package is missing the version field");
|
|
191
196
|
return;
|
|
192
197
|
}
|
|
193
198
|
if (!await isWorktreeEmpty()) {
|
|
194
|
-
|
|
199
|
+
logger.error("Git worktree is not empty, please commit changed");
|
|
195
200
|
return;
|
|
196
201
|
}
|
|
197
202
|
if (!await confirmRefs(options.remote)) {
|
|
@@ -202,7 +207,7 @@ async function release(options) {
|
|
|
202
207
|
}
|
|
203
208
|
const { isPreRelease, expectVersion } = await getReleaseVersion(currentVersion);
|
|
204
209
|
if (options.checkRemoteVersion && await isSameVersion(expectVersion)) {
|
|
205
|
-
|
|
210
|
+
logger.error("Please check remote version.");
|
|
206
211
|
return;
|
|
207
212
|
}
|
|
208
213
|
updateVersion(expectVersion);
|
|
@@ -218,7 +223,7 @@ async function release(options) {
|
|
|
218
223
|
}
|
|
219
224
|
await pushGit(expectVersion, options.remote, options.skipGitTag);
|
|
220
225
|
}
|
|
221
|
-
|
|
226
|
+
logger.success(`Release version ${expectVersion} successfully!`);
|
|
222
227
|
if (isPreRelease) {
|
|
223
228
|
try {
|
|
224
229
|
await exec("git", ["restore", "**/package.json"], {
|
|
@@ -234,14 +239,15 @@ async function release(options) {
|
|
|
234
239
|
}
|
|
235
240
|
}
|
|
236
241
|
} catch (error) {
|
|
237
|
-
|
|
242
|
+
logger.error(error.toString());
|
|
238
243
|
process.exit(1);
|
|
239
244
|
}
|
|
240
245
|
}
|
|
241
246
|
|
|
242
247
|
// src/commitLint.ts
|
|
243
|
-
import semver2 from "semver";
|
|
244
248
|
import fse3 from "fs-extra";
|
|
249
|
+
import { logger as logger2 } from "rslog";
|
|
250
|
+
import semver2 from "semver";
|
|
245
251
|
var { readFileSync } = fse3;
|
|
246
252
|
var COMMIT_MESSAGE_RE = /^(revert|fix|feat|docs|perf|test|types|style|build|chore|release|refactor|merge|wip)(\(.+\))?!?: (.|\n)+/;
|
|
247
253
|
var ERROR_MESSAGE = "Commit message invalid.";
|
|
@@ -290,14 +296,14 @@ function commitLint(options) {
|
|
|
290
296
|
warningMessage = WARNING_MESSAGE
|
|
291
297
|
} = options;
|
|
292
298
|
if (!commitMessagePath) {
|
|
293
|
-
|
|
299
|
+
logger2.error("commitMessagePath is required");
|
|
294
300
|
process.exit(1);
|
|
295
301
|
}
|
|
296
302
|
const commitMessage = getCommitMessage(commitMessagePath);
|
|
297
303
|
const isValidCommitMessage = new RegExp(commitMessageRe).test(commitMessage);
|
|
298
304
|
if (!isVersionCommitMessage(commitMessage) && !isValidCommitMessage) {
|
|
299
|
-
|
|
300
|
-
|
|
305
|
+
logger2.error(errorMessage);
|
|
306
|
+
logger2.warn(warningMessage);
|
|
301
307
|
process.exit(1);
|
|
302
308
|
}
|
|
303
309
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@varlet/release",
|
|
3
|
-
"
|
|
4
|
-
"version": "0.3.2",
|
|
3
|
+
"version": "0.4.0",
|
|
5
4
|
"description": "publish all packages, generate changelogs and check commit messages",
|
|
6
5
|
"keywords": [
|
|
7
6
|
"varlet",
|
|
@@ -9,16 +8,14 @@
|
|
|
9
8
|
"changelog",
|
|
10
9
|
"commit-lint"
|
|
11
10
|
],
|
|
12
|
-
"
|
|
13
|
-
"license": "MIT",
|
|
11
|
+
"bugs": "https://github.com/varletjs/release/issues",
|
|
14
12
|
"repository": {
|
|
15
13
|
"type": "git",
|
|
16
14
|
"url": "git+https://github.com/varletjs/release"
|
|
17
15
|
},
|
|
18
|
-
"
|
|
19
|
-
"
|
|
20
|
-
"
|
|
21
|
-
"types": "./dist/index.d.ts",
|
|
16
|
+
"license": "MIT",
|
|
17
|
+
"author": "clencat <2091927351@qq.com>",
|
|
18
|
+
"type": "module",
|
|
22
19
|
"exports": {
|
|
23
20
|
".": {
|
|
24
21
|
"types": "./dist/index.d.ts",
|
|
@@ -26,6 +23,9 @@
|
|
|
26
23
|
"require": "./dist/index.cjs"
|
|
27
24
|
}
|
|
28
25
|
},
|
|
26
|
+
"main": "./dist/index.cjs",
|
|
27
|
+
"module": "./dist/index.js",
|
|
28
|
+
"types": "./dist/index.d.ts",
|
|
29
29
|
"bin": {
|
|
30
30
|
"vr": "bin/index.js"
|
|
31
31
|
},
|
|
@@ -40,19 +40,29 @@
|
|
|
40
40
|
"*.{ts,js}": [
|
|
41
41
|
"prettier --write",
|
|
42
42
|
"eslint --fix"
|
|
43
|
-
]
|
|
43
|
+
],
|
|
44
|
+
"*.md": "prettier --write"
|
|
44
45
|
},
|
|
45
|
-
"
|
|
46
|
-
"
|
|
47
|
-
"
|
|
46
|
+
"dependencies": {
|
|
47
|
+
"@inquirer/prompts": "^6.0.1",
|
|
48
|
+
"commander": "^11.1.0",
|
|
49
|
+
"conventional-changelog": "^5.1.0",
|
|
50
|
+
"fs-extra": "^11.1.1",
|
|
51
|
+
"glob": "^10.3.10",
|
|
52
|
+
"nanospinner": "^1.1.0",
|
|
53
|
+
"rslog": "^1.2.3",
|
|
54
|
+
"semver": "^7.5.4",
|
|
55
|
+
"tinyexec": "^0.3.0"
|
|
48
56
|
},
|
|
49
57
|
"devDependencies": {
|
|
58
|
+
"@configurajs/eslint": "^0.1.2",
|
|
59
|
+
"@configurajs/prettier": "^0.1.4",
|
|
50
60
|
"@types/conventional-changelog": "^3.1.5",
|
|
51
61
|
"@types/fs-extra": "^11.0.4",
|
|
52
62
|
"@types/node": "^20.9.0",
|
|
53
63
|
"@types/semver": "^7.5.5",
|
|
54
64
|
"@varlet/eslint-config": "^2.18.4",
|
|
55
|
-
"eslint": "^
|
|
65
|
+
"eslint": "^9.17.0",
|
|
56
66
|
"lint-staged": "^15.2.0",
|
|
57
67
|
"prettier": "^3.1.0",
|
|
58
68
|
"rimraf": "^6.0.1",
|
|
@@ -60,24 +70,18 @@
|
|
|
60
70
|
"tsup": "^8.3.0",
|
|
61
71
|
"typescript": "^5.2.2"
|
|
62
72
|
},
|
|
63
|
-
"
|
|
64
|
-
"
|
|
65
|
-
"
|
|
66
|
-
"conventional-changelog": "^5.1.0",
|
|
67
|
-
"fs-extra": "^11.1.1",
|
|
68
|
-
"glob": "^10.3.10",
|
|
69
|
-
"nanospinner": "^1.1.0",
|
|
70
|
-
"picocolors": "^1.0.0",
|
|
71
|
-
"semver": "^7.5.4",
|
|
72
|
-
"tinyexec": "^0.3.0"
|
|
73
|
+
"engines": {
|
|
74
|
+
"node": ">=16.0.0",
|
|
75
|
+
"pnpm": ">=9.0"
|
|
73
76
|
},
|
|
74
77
|
"scripts": {
|
|
75
|
-
"dev": "tsup --watch",
|
|
76
78
|
"build": "tsup",
|
|
77
|
-
"release": "pnpm build && node bin/index.js release -c",
|
|
78
|
-
"lint": "eslint . --ext .ts,.js",
|
|
79
|
-
"format": "prettier --write .",
|
|
80
79
|
"clean": "rimraf node_modules dist",
|
|
81
|
-
"commit-lint": "node bin/index.js commit-lint"
|
|
80
|
+
"commit-lint": "node bin/index.js commit-lint",
|
|
81
|
+
"dev": "tsup --watch",
|
|
82
|
+
"format": "prettier --write .",
|
|
83
|
+
"lint": "eslint --fix .",
|
|
84
|
+
"release": "pnpm build && node bin/index.js release -c",
|
|
85
|
+
"type-check": "tsc --noEmit"
|
|
82
86
|
}
|
|
83
87
|
}
|