@varlet/release 0.3.3 → 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/LICENSE +21 -21
- package/README.md +161 -161
- package/README.zh-CN.md +161 -161
- package/bin/index.js +47 -47
- package/dist/index.cjs +40 -33
- package/dist/index.d.cts +4 -1
- package/dist/index.d.ts +4 -1
- package/dist/index.js +40 -33
- package/package.json +14 -14
package/LICENSE
CHANGED
|
@@ -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,161 +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/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)
|
|
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,161 +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
|
-
| -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)
|
|
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,47 +1,47 @@
|
|
|
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()
|
|
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
|
@@ -48,6 +48,7 @@ var import_prompts = require("@inquirer/prompts");
|
|
|
48
48
|
var import_fs_extra2 = __toESM(require("fs-extra"), 1);
|
|
49
49
|
var import_glob = require("glob");
|
|
50
50
|
var import_nanospinner2 = require("nanospinner");
|
|
51
|
+
var import_rslog = require("rslog");
|
|
51
52
|
var import_semver = __toESM(require("semver"), 1);
|
|
52
53
|
var import_tinyexec = require("tinyexec");
|
|
53
54
|
|
|
@@ -60,37 +61,42 @@ var { createWriteStream } = import_fs_extra.default;
|
|
|
60
61
|
function changelog({
|
|
61
62
|
releaseCount = 0,
|
|
62
63
|
file = "CHANGELOG.md",
|
|
63
|
-
preset = "angular"
|
|
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
|
+
}
|
|
64
81
|
} = {}) {
|
|
65
82
|
const s = (0, import_nanospinner.createSpinner)("Generating changelog").start();
|
|
66
83
|
return new Promise((resolve2) => {
|
|
67
|
-
(0, import_conventional_changelog.default)(
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
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", () => {
|
|
71
94
|
s.success({ text: "Changelog generated success!" });
|
|
72
95
|
resolve2();
|
|
73
96
|
});
|
|
74
97
|
});
|
|
75
98
|
}
|
|
76
99
|
|
|
77
|
-
// src/logger.ts
|
|
78
|
-
var import_picocolors = __toESM(require("picocolors"), 1);
|
|
79
|
-
var logger_default = {
|
|
80
|
-
info(text) {
|
|
81
|
-
console.log(text);
|
|
82
|
-
},
|
|
83
|
-
success(text) {
|
|
84
|
-
console.log(import_picocolors.default.green(text));
|
|
85
|
-
},
|
|
86
|
-
warning(text) {
|
|
87
|
-
console.log(import_picocolors.default.yellow(text));
|
|
88
|
-
},
|
|
89
|
-
error(text) {
|
|
90
|
-
console.log(import_picocolors.default.red(text));
|
|
91
|
-
}
|
|
92
|
-
};
|
|
93
|
-
|
|
94
100
|
// src/release.ts
|
|
95
101
|
var cwd = process.cwd();
|
|
96
102
|
var { writeFileSync, readJSONSync } = import_fs_extra2.default;
|
|
@@ -124,7 +130,7 @@ async function publish({ preRelease, checkRemoteVersion, npmTag }) {
|
|
|
124
130
|
const s = (0, import_nanospinner2.createSpinner)("Publishing all packages").start();
|
|
125
131
|
const args = ["-r", "publish", "--no-git-checks", "--access", "public"];
|
|
126
132
|
if (checkRemoteVersion && await isSameVersion()) {
|
|
127
|
-
|
|
133
|
+
import_rslog.logger.error("publishing automatically skipped.");
|
|
128
134
|
return;
|
|
129
135
|
}
|
|
130
136
|
if (preRelease) {
|
|
@@ -137,7 +143,7 @@ async function publish({ preRelease, checkRemoteVersion, npmTag }) {
|
|
|
137
143
|
throw new Error("\n" + ret.stderr);
|
|
138
144
|
} else {
|
|
139
145
|
s.success({ text: "Publish all packages successfully" });
|
|
140
|
-
ret.stdout &&
|
|
146
|
+
ret.stdout && import_rslog.logger.info(ret.stdout);
|
|
141
147
|
}
|
|
142
148
|
}
|
|
143
149
|
async function pushGit(version, remote = "origin", skipGitTag = false) {
|
|
@@ -160,7 +166,7 @@ async function pushGit(version, remote = "origin", skipGitTag = false) {
|
|
|
160
166
|
throwOnError: true
|
|
161
167
|
});
|
|
162
168
|
s.success({ text: "Push remote repository successfully" });
|
|
163
|
-
ret.stdout &&
|
|
169
|
+
ret.stdout && import_rslog.logger.info(ret.stdout);
|
|
164
170
|
}
|
|
165
171
|
function getPackageJsons() {
|
|
166
172
|
const packageJsons = ["package.json", ...import_glob.glob.sync("packages/*/package.json")];
|
|
@@ -230,11 +236,11 @@ async function release(options) {
|
|
|
230
236
|
try {
|
|
231
237
|
const currentVersion = readJSONSync((0, import_path2.resolve)(cwd, "package.json")).version;
|
|
232
238
|
if (!currentVersion) {
|
|
233
|
-
|
|
239
|
+
import_rslog.logger.error("Your package is missing the version field");
|
|
234
240
|
return;
|
|
235
241
|
}
|
|
236
242
|
if (!await isWorktreeEmpty()) {
|
|
237
|
-
|
|
243
|
+
import_rslog.logger.error("Git worktree is not empty, please commit changed");
|
|
238
244
|
return;
|
|
239
245
|
}
|
|
240
246
|
if (!await confirmRefs(options.remote)) {
|
|
@@ -245,7 +251,7 @@ async function release(options) {
|
|
|
245
251
|
}
|
|
246
252
|
const { isPreRelease, expectVersion } = await getReleaseVersion(currentVersion);
|
|
247
253
|
if (options.checkRemoteVersion && await isSameVersion(expectVersion)) {
|
|
248
|
-
|
|
254
|
+
import_rslog.logger.error("Please check remote version.");
|
|
249
255
|
return;
|
|
250
256
|
}
|
|
251
257
|
updateVersion(expectVersion);
|
|
@@ -261,7 +267,7 @@ async function release(options) {
|
|
|
261
267
|
}
|
|
262
268
|
await pushGit(expectVersion, options.remote, options.skipGitTag);
|
|
263
269
|
}
|
|
264
|
-
|
|
270
|
+
import_rslog.logger.success(`Release version ${expectVersion} successfully!`);
|
|
265
271
|
if (isPreRelease) {
|
|
266
272
|
try {
|
|
267
273
|
await (0, import_tinyexec.x)("git", ["restore", "**/package.json"], {
|
|
@@ -277,13 +283,14 @@ async function release(options) {
|
|
|
277
283
|
}
|
|
278
284
|
}
|
|
279
285
|
} catch (error) {
|
|
280
|
-
|
|
286
|
+
import_rslog.logger.error(error.toString());
|
|
281
287
|
process.exit(1);
|
|
282
288
|
}
|
|
283
289
|
}
|
|
284
290
|
|
|
285
291
|
// src/commitLint.ts
|
|
286
292
|
var import_fs_extra3 = __toESM(require("fs-extra"), 1);
|
|
293
|
+
var import_rslog2 = require("rslog");
|
|
287
294
|
var import_semver2 = __toESM(require("semver"), 1);
|
|
288
295
|
var { readFileSync } = import_fs_extra3.default;
|
|
289
296
|
var COMMIT_MESSAGE_RE = /^(revert|fix|feat|docs|perf|test|types|style|build|chore|release|refactor|merge|wip)(\(.+\))?!?: (.|\n)+/;
|
|
@@ -333,14 +340,14 @@ function commitLint(options) {
|
|
|
333
340
|
warningMessage = WARNING_MESSAGE
|
|
334
341
|
} = options;
|
|
335
342
|
if (!commitMessagePath) {
|
|
336
|
-
|
|
343
|
+
import_rslog2.logger.error("commitMessagePath is required");
|
|
337
344
|
process.exit(1);
|
|
338
345
|
}
|
|
339
346
|
const commitMessage = getCommitMessage(commitMessagePath);
|
|
340
347
|
const isValidCommitMessage = new RegExp(commitMessageRe).test(commitMessage);
|
|
341
348
|
if (!isVersionCommitMessage(commitMessage) && !isValidCommitMessage) {
|
|
342
|
-
|
|
343
|
-
|
|
349
|
+
import_rslog2.logger.error(errorMessage);
|
|
350
|
+
import_rslog2.logger.warn(warningMessage);
|
|
344
351
|
process.exit(1);
|
|
345
352
|
}
|
|
346
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;
|
|
@@ -21,8 +23,9 @@ interface ChangelogCommandOptions {
|
|
|
21
23
|
file?: string;
|
|
22
24
|
releaseCount?: number;
|
|
23
25
|
preset?: 'angular' | 'atom' | 'codemirror' | 'conventionalcommits' | 'ember' | 'eslint' | 'express' | 'jquery' | 'jshint';
|
|
26
|
+
writerOpts?: Parameters<typeof conventionalChangelog>['4'];
|
|
24
27
|
}
|
|
25
|
-
declare function changelog({ releaseCount, file, preset, }?: ChangelogCommandOptions): Promise<void>;
|
|
28
|
+
declare function changelog({ releaseCount, file, preset, writerOpts, }?: ChangelogCommandOptions): Promise<void>;
|
|
26
29
|
|
|
27
30
|
declare const COMMIT_MESSAGE_RE: RegExp;
|
|
28
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;
|
|
@@ -21,8 +23,9 @@ interface ChangelogCommandOptions {
|
|
|
21
23
|
file?: string;
|
|
22
24
|
releaseCount?: number;
|
|
23
25
|
preset?: 'angular' | 'atom' | 'codemirror' | 'conventionalcommits' | 'ember' | 'eslint' | 'express' | 'jquery' | 'jshint';
|
|
26
|
+
writerOpts?: Parameters<typeof conventionalChangelog>['4'];
|
|
24
27
|
}
|
|
25
|
-
declare function changelog({ releaseCount, file, preset, }?: ChangelogCommandOptions): Promise<void>;
|
|
28
|
+
declare function changelog({ releaseCount, file, preset, writerOpts, }?: ChangelogCommandOptions): Promise<void>;
|
|
26
29
|
|
|
27
30
|
declare const COMMIT_MESSAGE_RE: RegExp;
|
|
28
31
|
declare function isVersionCommitMessage(message: string): string | false | null;
|
package/dist/index.js
CHANGED
|
@@ -4,6 +4,7 @@ import { confirm, select } from "@inquirer/prompts";
|
|
|
4
4
|
import fse2 from "fs-extra";
|
|
5
5
|
import { glob } from "glob";
|
|
6
6
|
import { createSpinner as createSpinner2 } from "nanospinner";
|
|
7
|
+
import { logger } from "rslog";
|
|
7
8
|
import semver from "semver";
|
|
8
9
|
import { x as exec } from "tinyexec";
|
|
9
10
|
|
|
@@ -16,37 +17,42 @@ var { createWriteStream } = fse;
|
|
|
16
17
|
function changelog({
|
|
17
18
|
releaseCount = 0,
|
|
18
19
|
file = "CHANGELOG.md",
|
|
19
|
-
preset = "angular"
|
|
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
|
+
}
|
|
20
37
|
} = {}) {
|
|
21
38
|
const s = createSpinner("Generating changelog").start();
|
|
22
39
|
return new Promise((resolve2) => {
|
|
23
|
-
conventionalChangelog(
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
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", () => {
|
|
27
50
|
s.success({ text: "Changelog generated success!" });
|
|
28
51
|
resolve2();
|
|
29
52
|
});
|
|
30
53
|
});
|
|
31
54
|
}
|
|
32
55
|
|
|
33
|
-
// src/logger.ts
|
|
34
|
-
import pico from "picocolors";
|
|
35
|
-
var logger_default = {
|
|
36
|
-
info(text) {
|
|
37
|
-
console.log(text);
|
|
38
|
-
},
|
|
39
|
-
success(text) {
|
|
40
|
-
console.log(pico.green(text));
|
|
41
|
-
},
|
|
42
|
-
warning(text) {
|
|
43
|
-
console.log(pico.yellow(text));
|
|
44
|
-
},
|
|
45
|
-
error(text) {
|
|
46
|
-
console.log(pico.red(text));
|
|
47
|
-
}
|
|
48
|
-
};
|
|
49
|
-
|
|
50
56
|
// src/release.ts
|
|
51
57
|
var cwd = process.cwd();
|
|
52
58
|
var { writeFileSync, readJSONSync } = fse2;
|
|
@@ -80,7 +86,7 @@ async function publish({ preRelease, checkRemoteVersion, npmTag }) {
|
|
|
80
86
|
const s = createSpinner2("Publishing all packages").start();
|
|
81
87
|
const args = ["-r", "publish", "--no-git-checks", "--access", "public"];
|
|
82
88
|
if (checkRemoteVersion && await isSameVersion()) {
|
|
83
|
-
|
|
89
|
+
logger.error("publishing automatically skipped.");
|
|
84
90
|
return;
|
|
85
91
|
}
|
|
86
92
|
if (preRelease) {
|
|
@@ -93,7 +99,7 @@ async function publish({ preRelease, checkRemoteVersion, npmTag }) {
|
|
|
93
99
|
throw new Error("\n" + ret.stderr);
|
|
94
100
|
} else {
|
|
95
101
|
s.success({ text: "Publish all packages successfully" });
|
|
96
|
-
ret.stdout &&
|
|
102
|
+
ret.stdout && logger.info(ret.stdout);
|
|
97
103
|
}
|
|
98
104
|
}
|
|
99
105
|
async function pushGit(version, remote = "origin", skipGitTag = false) {
|
|
@@ -116,7 +122,7 @@ async function pushGit(version, remote = "origin", skipGitTag = false) {
|
|
|
116
122
|
throwOnError: true
|
|
117
123
|
});
|
|
118
124
|
s.success({ text: "Push remote repository successfully" });
|
|
119
|
-
ret.stdout &&
|
|
125
|
+
ret.stdout && logger.info(ret.stdout);
|
|
120
126
|
}
|
|
121
127
|
function getPackageJsons() {
|
|
122
128
|
const packageJsons = ["package.json", ...glob.sync("packages/*/package.json")];
|
|
@@ -186,11 +192,11 @@ async function release(options) {
|
|
|
186
192
|
try {
|
|
187
193
|
const currentVersion = readJSONSync(resolve(cwd, "package.json")).version;
|
|
188
194
|
if (!currentVersion) {
|
|
189
|
-
|
|
195
|
+
logger.error("Your package is missing the version field");
|
|
190
196
|
return;
|
|
191
197
|
}
|
|
192
198
|
if (!await isWorktreeEmpty()) {
|
|
193
|
-
|
|
199
|
+
logger.error("Git worktree is not empty, please commit changed");
|
|
194
200
|
return;
|
|
195
201
|
}
|
|
196
202
|
if (!await confirmRefs(options.remote)) {
|
|
@@ -201,7 +207,7 @@ async function release(options) {
|
|
|
201
207
|
}
|
|
202
208
|
const { isPreRelease, expectVersion } = await getReleaseVersion(currentVersion);
|
|
203
209
|
if (options.checkRemoteVersion && await isSameVersion(expectVersion)) {
|
|
204
|
-
|
|
210
|
+
logger.error("Please check remote version.");
|
|
205
211
|
return;
|
|
206
212
|
}
|
|
207
213
|
updateVersion(expectVersion);
|
|
@@ -217,7 +223,7 @@ async function release(options) {
|
|
|
217
223
|
}
|
|
218
224
|
await pushGit(expectVersion, options.remote, options.skipGitTag);
|
|
219
225
|
}
|
|
220
|
-
|
|
226
|
+
logger.success(`Release version ${expectVersion} successfully!`);
|
|
221
227
|
if (isPreRelease) {
|
|
222
228
|
try {
|
|
223
229
|
await exec("git", ["restore", "**/package.json"], {
|
|
@@ -233,13 +239,14 @@ async function release(options) {
|
|
|
233
239
|
}
|
|
234
240
|
}
|
|
235
241
|
} catch (error) {
|
|
236
|
-
|
|
242
|
+
logger.error(error.toString());
|
|
237
243
|
process.exit(1);
|
|
238
244
|
}
|
|
239
245
|
}
|
|
240
246
|
|
|
241
247
|
// src/commitLint.ts
|
|
242
248
|
import fse3 from "fs-extra";
|
|
249
|
+
import { logger as logger2 } from "rslog";
|
|
243
250
|
import semver2 from "semver";
|
|
244
251
|
var { readFileSync } = fse3;
|
|
245
252
|
var COMMIT_MESSAGE_RE = /^(revert|fix|feat|docs|perf|test|types|style|build|chore|release|refactor|merge|wip)(\(.+\))?!?: (.|\n)+/;
|
|
@@ -289,14 +296,14 @@ function commitLint(options) {
|
|
|
289
296
|
warningMessage = WARNING_MESSAGE
|
|
290
297
|
} = options;
|
|
291
298
|
if (!commitMessagePath) {
|
|
292
|
-
|
|
299
|
+
logger2.error("commitMessagePath is required");
|
|
293
300
|
process.exit(1);
|
|
294
301
|
}
|
|
295
302
|
const commitMessage = getCommitMessage(commitMessagePath);
|
|
296
303
|
const isValidCommitMessage = new RegExp(commitMessageRe).test(commitMessage);
|
|
297
304
|
if (!isVersionCommitMessage(commitMessage) && !isValidCommitMessage) {
|
|
298
|
-
|
|
299
|
-
|
|
305
|
+
logger2.error(errorMessage);
|
|
306
|
+
logger2.warn(warningMessage);
|
|
300
307
|
process.exit(1);
|
|
301
308
|
}
|
|
302
309
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@varlet/release",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "publish all packages, generate changelogs and check commit messages",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"varlet",
|
|
@@ -32,15 +32,6 @@
|
|
|
32
32
|
"files": [
|
|
33
33
|
"dist"
|
|
34
34
|
],
|
|
35
|
-
"scripts": {
|
|
36
|
-
"build": "tsup",
|
|
37
|
-
"clean": "rimraf node_modules dist",
|
|
38
|
-
"commit-lint": "node bin/index.js commit-lint",
|
|
39
|
-
"dev": "tsup --watch",
|
|
40
|
-
"format": "prettier --write .",
|
|
41
|
-
"lint": "eslint --fix .",
|
|
42
|
-
"release": "pnpm build && node bin/index.js release -c"
|
|
43
|
-
},
|
|
44
35
|
"simple-git-hooks": {
|
|
45
36
|
"pre-commit": "pnpm exec lint-staged --allow-empty --concurrent false",
|
|
46
37
|
"commit-msg": "pnpm run commit-lint -p $1"
|
|
@@ -59,13 +50,13 @@
|
|
|
59
50
|
"fs-extra": "^11.1.1",
|
|
60
51
|
"glob": "^10.3.10",
|
|
61
52
|
"nanospinner": "^1.1.0",
|
|
62
|
-
"
|
|
53
|
+
"rslog": "^1.2.3",
|
|
63
54
|
"semver": "^7.5.4",
|
|
64
55
|
"tinyexec": "^0.3.0"
|
|
65
56
|
},
|
|
66
57
|
"devDependencies": {
|
|
67
|
-
"@configurajs/eslint": "^0.1.
|
|
68
|
-
"@configurajs/prettier": "^0.1.
|
|
58
|
+
"@configurajs/eslint": "^0.1.2",
|
|
59
|
+
"@configurajs/prettier": "^0.1.4",
|
|
69
60
|
"@types/conventional-changelog": "^3.1.5",
|
|
70
61
|
"@types/fs-extra": "^11.0.4",
|
|
71
62
|
"@types/node": "^20.9.0",
|
|
@@ -79,9 +70,18 @@
|
|
|
79
70
|
"tsup": "^8.3.0",
|
|
80
71
|
"typescript": "^5.2.2"
|
|
81
72
|
},
|
|
82
|
-
"packageManager": "pnpm@9.0.1",
|
|
83
73
|
"engines": {
|
|
84
74
|
"node": ">=16.0.0",
|
|
85
75
|
"pnpm": ">=9.0"
|
|
76
|
+
},
|
|
77
|
+
"scripts": {
|
|
78
|
+
"build": "tsup",
|
|
79
|
+
"clean": "rimraf node_modules dist",
|
|
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"
|
|
86
86
|
}
|
|
87
87
|
}
|