@varlet/release 0.2.10 → 0.3.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/README.md +150 -150
- package/README.zh-CN.md +150 -150
- package/bin/index.js +47 -41
- package/dist/index.cjs +53 -53
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +53 -53
- package/package.json +5 -6
package/README.md
CHANGED
|
@@ -1,150 +1,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/LICENCE" 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
|
-
|
|
70
|
-
#### lint-commit
|
|
71
|
-
|
|
72
|
-
| Params | Instructions |
|
|
73
|
-
| ------------------------------- | ---------------------------------------------------------------------------------------------------------------------- |
|
|
74
|
-
| -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 |
|
|
75
|
-
| -r --commitMessageRe \<reg\> | Validate the regular of whether the commit message passes |
|
|
76
|
-
| -e --errorMessage \<message\> | Validation failed to display error messages |
|
|
77
|
-
| -w --warningMessage \<message\> | Validation failed to display warning messages |
|
|
78
|
-
|
|
79
|
-
#### publish
|
|
80
|
-
|
|
81
|
-
| Params | Instructions |
|
|
82
|
-
| ------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
83
|
-
| -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 |
|
|
84
|
-
| -nt --npm-tag \<npmTag\> | npm tag |
|
|
85
|
-
|
|
86
|
-
### Custom Handle
|
|
87
|
-
|
|
88
|
-
#### Example
|
|
89
|
-
|
|
90
|
-
```js
|
|
91
|
-
import { release, changelog } from '@varlet/release'
|
|
92
|
-
|
|
93
|
-
// Do what you want to do...
|
|
94
|
-
release()
|
|
95
|
-
```
|
|
96
|
-
|
|
97
|
-
You can pass in a task that will be called before the publish after the package version is changed.
|
|
98
|
-
|
|
99
|
-
```js
|
|
100
|
-
import { release, changelog } from '@varlet/release'
|
|
101
|
-
|
|
102
|
-
async function task() {
|
|
103
|
-
await doSomething1()
|
|
104
|
-
await doSomething2()
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
release({ task })
|
|
108
|
-
```
|
|
109
|
-
|
|
110
|
-
#### Types
|
|
111
|
-
|
|
112
|
-
```ts
|
|
113
|
-
interface PublishCommandOptions {
|
|
114
|
-
preRelease?: boolean
|
|
115
|
-
checkRemoteVersion?: boolean
|
|
116
|
-
npmTag?: string
|
|
117
|
-
}
|
|
118
|
-
function publish({ preRelease, checkRemoteVersion, npmTag }: PublishCommandOptions): Promise<void>
|
|
119
|
-
function updateVersion(version: string): void
|
|
120
|
-
interface ReleaseCommandOptions {
|
|
121
|
-
remote?: string
|
|
122
|
-
skipNpmPublish?: boolean
|
|
123
|
-
skipChangelog?: boolean
|
|
124
|
-
skipGitTag?: boolean
|
|
125
|
-
npmTag?: string
|
|
126
|
-
task?(): Promise<void>
|
|
127
|
-
}
|
|
128
|
-
function release(options: ReleaseCommandOptions): Promise<void>
|
|
129
|
-
|
|
130
|
-
interface ChangelogCommandOptions {
|
|
131
|
-
file?: string
|
|
132
|
-
releaseCount?: number
|
|
133
|
-
}
|
|
134
|
-
function changelog({ releaseCount, file }?: ChangelogCommandOptions): Promise<void>
|
|
135
|
-
|
|
136
|
-
const COMMIT_MESSAGE_RE: RegExp
|
|
137
|
-
function isVersionCommitMessage(message: string): string | false | null
|
|
138
|
-
function getCommitMessage(commitMessagePath: string): string
|
|
139
|
-
interface CommitLintCommandOptions {
|
|
140
|
-
commitMessagePath: string
|
|
141
|
-
commitMessageRe?: string | RegExp
|
|
142
|
-
errorMessage?: string
|
|
143
|
-
warningMessage?: string
|
|
144
|
-
}
|
|
145
|
-
function commitLint(options: CommitLintCommandOptions): void
|
|
146
|
-
```
|
|
147
|
-
|
|
148
|
-
## License
|
|
149
|
-
|
|
150
|
-
[MIT](https://github.com/varletjs/release/blob/main/LICENCE)
|
|
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/LICENCE" 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
|
+
|
|
70
|
+
#### lint-commit
|
|
71
|
+
|
|
72
|
+
| Params | Instructions |
|
|
73
|
+
| ------------------------------- | ---------------------------------------------------------------------------------------------------------------------- |
|
|
74
|
+
| -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 |
|
|
75
|
+
| -r --commitMessageRe \<reg\> | Validate the regular of whether the commit message passes |
|
|
76
|
+
| -e --errorMessage \<message\> | Validation failed to display error messages |
|
|
77
|
+
| -w --warningMessage \<message\> | Validation failed to display warning messages |
|
|
78
|
+
|
|
79
|
+
#### publish
|
|
80
|
+
|
|
81
|
+
| Params | Instructions |
|
|
82
|
+
| ------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
83
|
+
| -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 |
|
|
84
|
+
| -nt --npm-tag \<npmTag\> | npm tag |
|
|
85
|
+
|
|
86
|
+
### Custom Handle
|
|
87
|
+
|
|
88
|
+
#### Example
|
|
89
|
+
|
|
90
|
+
```js
|
|
91
|
+
import { release, changelog } from '@varlet/release'
|
|
92
|
+
|
|
93
|
+
// Do what you want to do...
|
|
94
|
+
release()
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
You can pass in a task that will be called before the publish after the package version is changed.
|
|
98
|
+
|
|
99
|
+
```js
|
|
100
|
+
import { release, changelog } from '@varlet/release'
|
|
101
|
+
|
|
102
|
+
async function task() {
|
|
103
|
+
await doSomething1()
|
|
104
|
+
await doSomething2()
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
release({ task })
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
#### Types
|
|
111
|
+
|
|
112
|
+
```ts
|
|
113
|
+
interface PublishCommandOptions {
|
|
114
|
+
preRelease?: boolean
|
|
115
|
+
checkRemoteVersion?: boolean
|
|
116
|
+
npmTag?: string
|
|
117
|
+
}
|
|
118
|
+
function publish({ preRelease, checkRemoteVersion, npmTag }: PublishCommandOptions): Promise<void>
|
|
119
|
+
function updateVersion(version: string): void
|
|
120
|
+
interface ReleaseCommandOptions {
|
|
121
|
+
remote?: string
|
|
122
|
+
skipNpmPublish?: boolean
|
|
123
|
+
skipChangelog?: boolean
|
|
124
|
+
skipGitTag?: boolean
|
|
125
|
+
npmTag?: string
|
|
126
|
+
task?(newVersion: string, oldVersion: string): Promise<void>
|
|
127
|
+
}
|
|
128
|
+
function release(options: ReleaseCommandOptions): Promise<void>
|
|
129
|
+
|
|
130
|
+
interface ChangelogCommandOptions {
|
|
131
|
+
file?: string
|
|
132
|
+
releaseCount?: number
|
|
133
|
+
}
|
|
134
|
+
function changelog({ releaseCount, file }?: ChangelogCommandOptions): Promise<void>
|
|
135
|
+
|
|
136
|
+
const COMMIT_MESSAGE_RE: RegExp
|
|
137
|
+
function isVersionCommitMessage(message: string): string | false | null
|
|
138
|
+
function getCommitMessage(commitMessagePath: string): string
|
|
139
|
+
interface CommitLintCommandOptions {
|
|
140
|
+
commitMessagePath: string
|
|
141
|
+
commitMessageRe?: string | RegExp
|
|
142
|
+
errorMessage?: string
|
|
143
|
+
warningMessage?: string
|
|
144
|
+
}
|
|
145
|
+
function commitLint(options: CommitLintCommandOptions): void
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
## License
|
|
149
|
+
|
|
150
|
+
[MIT](https://github.com/varletjs/release/blob/main/LICENCE)
|
package/README.zh-CN.md
CHANGED
|
@@ -1,150 +1,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
|
-
|
|
70
|
-
#### lint-commit
|
|
71
|
-
|
|
72
|
-
| 参数 | 说明 |
|
|
73
|
-
| ------------------------------- | --------------------------------------------------------------------------- |
|
|
74
|
-
| -p --commitMessagePath \<path\> | 提交 `git message` 的临时文件路径。`git` 钩子 `commit-msg` 会传递这个参数。 |
|
|
75
|
-
| -r --commitMessageRe \<reg\> | 验证 `commit message` 是否通过的正则 |
|
|
76
|
-
| -e --errorMessage \<message\> | 验证失败展示的错误信息 |
|
|
77
|
-
| -w --warningMessage \<message\> | 验证失败展示的提示信息 |
|
|
78
|
-
|
|
79
|
-
#### publish
|
|
80
|
-
|
|
81
|
-
| 参数 | 说明 |
|
|
82
|
-
| ------------------------- | --------------------------------------------------------------------- |
|
|
83
|
-
| -c --check-remote-version | 检测npm包的远程版本是否与要在本地发布的包版本相同,如果是,则跳过发布 |
|
|
84
|
-
| -nt --npm-tag \<npmTag\> | npm tag |
|
|
85
|
-
|
|
86
|
-
### 自定义处理
|
|
87
|
-
|
|
88
|
-
#### 示例
|
|
89
|
-
|
|
90
|
-
```js
|
|
91
|
-
import { release, changelog } from '@varlet/release'
|
|
92
|
-
|
|
93
|
-
// Do what you want to do...
|
|
94
|
-
release()
|
|
95
|
-
```
|
|
96
|
-
|
|
97
|
-
你可以传入一个 `task`,在包版本更改后,在发布之前会调用 `task`。
|
|
98
|
-
|
|
99
|
-
```js
|
|
100
|
-
import { release, changelog } from '@varlet/release'
|
|
101
|
-
|
|
102
|
-
async function task() {
|
|
103
|
-
await doSomething1()
|
|
104
|
-
await doSomething2()
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
release({ task })
|
|
108
|
-
```
|
|
109
|
-
|
|
110
|
-
#### 类型
|
|
111
|
-
|
|
112
|
-
```ts
|
|
113
|
-
interface PublishCommandOptions {
|
|
114
|
-
preRelease?: boolean
|
|
115
|
-
checkRemoteVersion?: boolean
|
|
116
|
-
npmTag?: string
|
|
117
|
-
}
|
|
118
|
-
function publish({ preRelease, checkRemoteVersion, npmTag }: PublishCommandOptions): Promise<void>
|
|
119
|
-
function updateVersion(version: string): void
|
|
120
|
-
interface ReleaseCommandOptions {
|
|
121
|
-
remote?: string
|
|
122
|
-
skipNpmPublish?: boolean
|
|
123
|
-
skipChangelog?: boolean
|
|
124
|
-
skipGitTag?: boolean
|
|
125
|
-
npmTag?: string
|
|
126
|
-
task?(): Promise<void>
|
|
127
|
-
}
|
|
128
|
-
function release(options: ReleaseCommandOptions): Promise<void>
|
|
129
|
-
|
|
130
|
-
interface ChangelogCommandOptions {
|
|
131
|
-
file?: string
|
|
132
|
-
releaseCount?: number
|
|
133
|
-
}
|
|
134
|
-
function changelog({ releaseCount, file }?: ChangelogCommandOptions): Promise<void>
|
|
135
|
-
|
|
136
|
-
const COMMIT_MESSAGE_RE: RegExp
|
|
137
|
-
function isVersionCommitMessage(message: string): string | false | null
|
|
138
|
-
function getCommitMessage(commitMessagePath: string): string
|
|
139
|
-
interface CommitLintCommandOptions {
|
|
140
|
-
commitMessagePath: string
|
|
141
|
-
commitMessageRe?: string | RegExp
|
|
142
|
-
errorMessage?: string
|
|
143
|
-
warningMessage?: string
|
|
144
|
-
}
|
|
145
|
-
function commitLint(options: CommitLintCommandOptions): void
|
|
146
|
-
```
|
|
147
|
-
|
|
148
|
-
## License
|
|
149
|
-
|
|
150
|
-
[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
|
+
|
|
70
|
+
#### lint-commit
|
|
71
|
+
|
|
72
|
+
| 参数 | 说明 |
|
|
73
|
+
| ------------------------------- | --------------------------------------------------------------------------- |
|
|
74
|
+
| -p --commitMessagePath \<path\> | 提交 `git message` 的临时文件路径。`git` 钩子 `commit-msg` 会传递这个参数。 |
|
|
75
|
+
| -r --commitMessageRe \<reg\> | 验证 `commit message` 是否通过的正则 |
|
|
76
|
+
| -e --errorMessage \<message\> | 验证失败展示的错误信息 |
|
|
77
|
+
| -w --warningMessage \<message\> | 验证失败展示的提示信息 |
|
|
78
|
+
|
|
79
|
+
#### publish
|
|
80
|
+
|
|
81
|
+
| 参数 | 说明 |
|
|
82
|
+
| ------------------------- | --------------------------------------------------------------------- |
|
|
83
|
+
| -c --check-remote-version | 检测npm包的远程版本是否与要在本地发布的包版本相同,如果是,则跳过发布 |
|
|
84
|
+
| -nt --npm-tag \<npmTag\> | npm tag |
|
|
85
|
+
|
|
86
|
+
### 自定义处理
|
|
87
|
+
|
|
88
|
+
#### 示例
|
|
89
|
+
|
|
90
|
+
```js
|
|
91
|
+
import { release, changelog } from '@varlet/release'
|
|
92
|
+
|
|
93
|
+
// Do what you want to do...
|
|
94
|
+
release()
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
你可以传入一个 `task`,在包版本更改后,在发布之前会调用 `task`。
|
|
98
|
+
|
|
99
|
+
```js
|
|
100
|
+
import { release, changelog } from '@varlet/release'
|
|
101
|
+
|
|
102
|
+
async function task() {
|
|
103
|
+
await doSomething1()
|
|
104
|
+
await doSomething2()
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
release({ task })
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
#### 类型
|
|
111
|
+
|
|
112
|
+
```ts
|
|
113
|
+
interface PublishCommandOptions {
|
|
114
|
+
preRelease?: boolean
|
|
115
|
+
checkRemoteVersion?: boolean
|
|
116
|
+
npmTag?: string
|
|
117
|
+
}
|
|
118
|
+
function publish({ preRelease, checkRemoteVersion, npmTag }: PublishCommandOptions): Promise<void>
|
|
119
|
+
function updateVersion(version: string): void
|
|
120
|
+
interface ReleaseCommandOptions {
|
|
121
|
+
remote?: string
|
|
122
|
+
skipNpmPublish?: boolean
|
|
123
|
+
skipChangelog?: boolean
|
|
124
|
+
skipGitTag?: boolean
|
|
125
|
+
npmTag?: string
|
|
126
|
+
task?(newVersion: string, oldVersion: string): Promise<void>
|
|
127
|
+
}
|
|
128
|
+
function release(options: ReleaseCommandOptions): Promise<void>
|
|
129
|
+
|
|
130
|
+
interface ChangelogCommandOptions {
|
|
131
|
+
file?: string
|
|
132
|
+
releaseCount?: number
|
|
133
|
+
}
|
|
134
|
+
function changelog({ releaseCount, file }?: ChangelogCommandOptions): Promise<void>
|
|
135
|
+
|
|
136
|
+
const COMMIT_MESSAGE_RE: RegExp
|
|
137
|
+
function isVersionCommitMessage(message: string): string | false | null
|
|
138
|
+
function getCommitMessage(commitMessagePath: string): string
|
|
139
|
+
interface CommitLintCommandOptions {
|
|
140
|
+
commitMessagePath: string
|
|
141
|
+
commitMessageRe?: string | RegExp
|
|
142
|
+
errorMessage?: string
|
|
143
|
+
warningMessage?: string
|
|
144
|
+
}
|
|
145
|
+
function commitLint(options: CommitLintCommandOptions): void
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
## License
|
|
149
|
+
|
|
150
|
+
[MIT](https://github.com/varletjs/release/blob/main/LICENSE)
|
package/bin/index.js
CHANGED
|
@@ -1,41 +1,47 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import { release, publish, changelog, commitLint } from '../dist/index.js'
|
|
3
|
-
import { Command } from 'commander'
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
program
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
.
|
|
15
|
-
.
|
|
16
|
-
.
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
.
|
|
20
|
-
.option('-c --check-remote-version', 'Check remote version')
|
|
21
|
-
.
|
|
22
|
-
.
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
.
|
|
27
|
-
.option('-
|
|
28
|
-
.
|
|
29
|
-
.
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
.
|
|
34
|
-
.option('-
|
|
35
|
-
.
|
|
36
|
-
.
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
.
|
|
40
|
-
|
|
41
|
-
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { release, publish, changelog, commitLint } from '../dist/index.js'
|
|
3
|
+
import { Command } from 'commander'
|
|
4
|
+
import { fileURLToPath } from 'url'
|
|
5
|
+
import fse from 'fs-extra'
|
|
6
|
+
|
|
7
|
+
const program = new Command()
|
|
8
|
+
|
|
9
|
+
const packageJson = fse.readJSONSync(fileURLToPath(new URL('../package.json', import.meta.url)))
|
|
10
|
+
|
|
11
|
+
program.version(packageJson.version)
|
|
12
|
+
|
|
13
|
+
program
|
|
14
|
+
.command('release')
|
|
15
|
+
.option('-r --remote <remote>', 'Remote name')
|
|
16
|
+
.option('-s --skip-npm-publish', 'Skip npm publish')
|
|
17
|
+
.option('-sc --skip-changelog', 'Skip generate changelog')
|
|
18
|
+
.option('-sgt --skip-git-tag', 'Skip git tag')
|
|
19
|
+
.option('-nt --npm-tag <npmTag>', 'Npm tag')
|
|
20
|
+
.option('-c --check-remote-version', 'Check remote version')
|
|
21
|
+
.description('Release all packages and generate changelogs')
|
|
22
|
+
.action(async (options) => release(options))
|
|
23
|
+
|
|
24
|
+
program
|
|
25
|
+
.command('publish')
|
|
26
|
+
.option('-c --check-remote-version', 'Check remote version')
|
|
27
|
+
.option('-nt --npm-tag <npmTag>', 'Npm tag')
|
|
28
|
+
.description('Publish to npm')
|
|
29
|
+
.action(async (options) => publish(options))
|
|
30
|
+
|
|
31
|
+
program
|
|
32
|
+
.command('changelog')
|
|
33
|
+
.option('-rc --releaseCount <releaseCount>', 'Release count')
|
|
34
|
+
.option('-f --file <file>', 'Changelog filename')
|
|
35
|
+
.description('Generate changelog')
|
|
36
|
+
.action(async (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(async (option) => commitLint(option))
|
|
46
|
+
|
|
47
|
+
program.parse()
|
package/dist/index.cjs
CHANGED
|
@@ -67,8 +67,8 @@ var logger_default = {
|
|
|
67
67
|
|
|
68
68
|
// src/release.ts
|
|
69
69
|
var import_semver = __toESM(require("semver"), 1);
|
|
70
|
-
var
|
|
71
|
-
var
|
|
70
|
+
var import_prompts = require("@inquirer/prompts");
|
|
71
|
+
var import_tinyexec = require("tinyexec");
|
|
72
72
|
var import_nanospinner2 = require("nanospinner");
|
|
73
73
|
var import_glob = require("glob");
|
|
74
74
|
var import_path2 = require("path");
|
|
@@ -95,11 +95,10 @@ function changelog({ releaseCount = 0, file = "CHANGELOG.md" } = {}) {
|
|
|
95
95
|
// src/release.ts
|
|
96
96
|
var cwd = process.cwd();
|
|
97
97
|
var { writeFileSync, readJSONSync } = import_fs_extra2.default;
|
|
98
|
-
var { prompt } = import_inquirer.default;
|
|
99
98
|
var releaseTypes = ["premajor", "preminor", "prepatch", "major", "minor", "patch"];
|
|
100
99
|
var BACK_HINT = "Back to previous step";
|
|
101
100
|
async function isWorktreeEmpty() {
|
|
102
|
-
const ret = await (0,
|
|
101
|
+
const ret = await (0, import_tinyexec.x)("git", ["status", "--porcelain"]);
|
|
103
102
|
return !ret.stdout;
|
|
104
103
|
}
|
|
105
104
|
async function isSameVersion(version) {
|
|
@@ -109,7 +108,9 @@ async function isSameVersion(version) {
|
|
|
109
108
|
if (packageJson) {
|
|
110
109
|
const { config } = packageJson;
|
|
111
110
|
try {
|
|
112
|
-
await (0,
|
|
111
|
+
await (0, import_tinyexec.x)("npm", ["view", `${config.name}@${version ?? config.version}`, "version"], {
|
|
112
|
+
throwOnError: true
|
|
113
|
+
});
|
|
113
114
|
s.warn({
|
|
114
115
|
text: `The npm package has a same remote version ${config.version}.`
|
|
115
116
|
});
|
|
@@ -132,7 +133,7 @@ async function publish({ preRelease, checkRemoteVersion, npmTag }) {
|
|
|
132
133
|
} else if (npmTag) {
|
|
133
134
|
args.push("--tag", npmTag);
|
|
134
135
|
}
|
|
135
|
-
const ret = await (0,
|
|
136
|
+
const ret = await (0, import_tinyexec.x)("pnpm", args);
|
|
136
137
|
if (ret.stderr && ret.stderr.includes("npm ERR!")) {
|
|
137
138
|
throw new Error("\n" + ret.stderr);
|
|
138
139
|
} else {
|
|
@@ -142,13 +143,23 @@ async function publish({ preRelease, checkRemoteVersion, npmTag }) {
|
|
|
142
143
|
}
|
|
143
144
|
async function pushGit(version, remote = "origin", skipGitTag = false) {
|
|
144
145
|
const s = (0, import_nanospinner2.createSpinner)("Pushing to remote git repository").start();
|
|
145
|
-
await (0,
|
|
146
|
-
|
|
146
|
+
await (0, import_tinyexec.x)("git", ["add", "."], {
|
|
147
|
+
throwOnError: true
|
|
148
|
+
});
|
|
149
|
+
await (0, import_tinyexec.x)("git", ["commit", "-m", `v${version}`], {
|
|
150
|
+
throwOnError: true
|
|
151
|
+
});
|
|
147
152
|
if (!skipGitTag) {
|
|
148
|
-
await (0,
|
|
149
|
-
|
|
153
|
+
await (0, import_tinyexec.x)("git", ["tag", `v${version}`], {
|
|
154
|
+
throwOnError: true
|
|
155
|
+
});
|
|
156
|
+
await (0, import_tinyexec.x)("git", ["push", remote, `v${version}`], {
|
|
157
|
+
throwOnError: true
|
|
158
|
+
});
|
|
150
159
|
}
|
|
151
|
-
const ret = await (0,
|
|
160
|
+
const ret = await (0, import_tinyexec.x)("git", ["push"], {
|
|
161
|
+
throwOnError: true
|
|
162
|
+
});
|
|
152
163
|
s.success({ text: "Push remote repository successfully" });
|
|
153
164
|
ret.stdout && logger_default.info(ret.stdout);
|
|
154
165
|
}
|
|
@@ -170,53 +181,38 @@ function updateVersion(version) {
|
|
|
170
181
|
});
|
|
171
182
|
}
|
|
172
183
|
async function confirmRegistry() {
|
|
173
|
-
const registry = (await (0,
|
|
174
|
-
const
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
type: "confirm",
|
|
179
|
-
message: `Current registry is: ${registry}`
|
|
180
|
-
}
|
|
181
|
-
]);
|
|
182
|
-
return ret[name];
|
|
184
|
+
const registry = (await (0, import_tinyexec.x)("npm", ["config", "get", "registry"])).stdout;
|
|
185
|
+
const ret = await (0, import_prompts.confirm)({
|
|
186
|
+
message: `Current registry is: ${registry}`
|
|
187
|
+
});
|
|
188
|
+
return ret;
|
|
183
189
|
}
|
|
184
190
|
async function confirmVersion(currentVersion, expectVersion) {
|
|
185
|
-
const
|
|
186
|
-
|
|
187
|
-
{
|
|
188
|
-
name,
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
return ret[name];
|
|
191
|
+
const ret = await (0, import_prompts.select)({
|
|
192
|
+
message: "Version confirm",
|
|
193
|
+
choices: [`All packages version ${currentVersion} -> ${expectVersion}`, BACK_HINT].map((value) => ({
|
|
194
|
+
name: value,
|
|
195
|
+
value
|
|
196
|
+
}))
|
|
197
|
+
});
|
|
198
|
+
return ret;
|
|
194
199
|
}
|
|
195
200
|
async function confirmRefs(remote = "origin") {
|
|
196
|
-
const { stdout } = await (0,
|
|
201
|
+
const { stdout } = await (0, import_tinyexec.x)("git", ["remote", "-v"]);
|
|
197
202
|
const reg = new RegExp(`${remote} (.*) \\(push`);
|
|
198
203
|
const repo = stdout.match(reg)?.[1];
|
|
199
|
-
const { stdout: branch } = await (0,
|
|
200
|
-
const
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
type: "confirm",
|
|
205
|
-
message: `Current refs ${repo}:refs/for/${branch}`
|
|
206
|
-
}
|
|
207
|
-
]);
|
|
208
|
-
return ret[name];
|
|
204
|
+
const { stdout: branch } = await (0, import_tinyexec.x)("git", ["branch", "--show-current"]);
|
|
205
|
+
const ret = await (0, import_prompts.confirm)({
|
|
206
|
+
message: `Current refs ${repo}:refs/for/${branch}`
|
|
207
|
+
});
|
|
208
|
+
return ret;
|
|
209
209
|
}
|
|
210
210
|
async function getReleaseType() {
|
|
211
|
-
const
|
|
212
|
-
|
|
213
|
-
{
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
choices: releaseTypes
|
|
217
|
-
}
|
|
218
|
-
]);
|
|
219
|
-
return ret[name];
|
|
211
|
+
const releaseType = await (0, import_prompts.select)({
|
|
212
|
+
message: "Please select release type",
|
|
213
|
+
choices: releaseTypes.map((type) => ({ name: type, value: type }))
|
|
214
|
+
});
|
|
215
|
+
return releaseType;
|
|
220
216
|
}
|
|
221
217
|
async function getReleaseVersion(currentVersion) {
|
|
222
218
|
let isPreRelease = false;
|
|
@@ -255,7 +251,7 @@ async function release(options) {
|
|
|
255
251
|
}
|
|
256
252
|
updateVersion(expectVersion);
|
|
257
253
|
if (options.task) {
|
|
258
|
-
await options.task();
|
|
254
|
+
await options.task(expectVersion, currentVersion);
|
|
259
255
|
}
|
|
260
256
|
if (!options.skipNpmPublish) {
|
|
261
257
|
await publish({ preRelease: isPreRelease, npmTag: options.npmTag });
|
|
@@ -269,11 +265,15 @@ async function release(options) {
|
|
|
269
265
|
logger_default.success(`Release version ${expectVersion} successfully!`);
|
|
270
266
|
if (isPreRelease) {
|
|
271
267
|
try {
|
|
272
|
-
await (0,
|
|
268
|
+
await (0, import_tinyexec.x)("git", ["restore", "**/package.json"], {
|
|
269
|
+
throwOnError: true
|
|
270
|
+
});
|
|
273
271
|
} catch {
|
|
274
272
|
}
|
|
275
273
|
try {
|
|
276
|
-
await (0,
|
|
274
|
+
await (0, import_tinyexec.x)("git", ["restore", "package.json"], {
|
|
275
|
+
throwOnError: true
|
|
276
|
+
});
|
|
277
277
|
} catch {
|
|
278
278
|
}
|
|
279
279
|
}
|
package/dist/index.d.cts
CHANGED
|
@@ -13,7 +13,7 @@ interface ReleaseCommandOptions {
|
|
|
13
13
|
skipChangelog?: boolean;
|
|
14
14
|
skipGitTag?: boolean;
|
|
15
15
|
checkRemoteVersion?: boolean;
|
|
16
|
-
task?(): Promise<void>;
|
|
16
|
+
task?(newVersion: string, oldVersion: string): Promise<void>;
|
|
17
17
|
}
|
|
18
18
|
declare function release(options: ReleaseCommandOptions): Promise<void>;
|
|
19
19
|
|
package/dist/index.d.ts
CHANGED
|
@@ -13,7 +13,7 @@ interface ReleaseCommandOptions {
|
|
|
13
13
|
skipChangelog?: boolean;
|
|
14
14
|
skipGitTag?: boolean;
|
|
15
15
|
checkRemoteVersion?: boolean;
|
|
16
|
-
task?(): Promise<void>;
|
|
16
|
+
task?(newVersion: string, oldVersion: string): Promise<void>;
|
|
17
17
|
}
|
|
18
18
|
declare function release(options: ReleaseCommandOptions): Promise<void>;
|
|
19
19
|
|
package/dist/index.js
CHANGED
|
@@ -23,8 +23,8 @@ var logger_default = {
|
|
|
23
23
|
|
|
24
24
|
// src/release.ts
|
|
25
25
|
import semver from "semver";
|
|
26
|
-
import
|
|
27
|
-
import {
|
|
26
|
+
import { confirm, select } from "@inquirer/prompts";
|
|
27
|
+
import { x as exec } from "tinyexec";
|
|
28
28
|
import { createSpinner as createSpinner2 } from "nanospinner";
|
|
29
29
|
import { glob } from "glob";
|
|
30
30
|
import { resolve } from "path";
|
|
@@ -51,11 +51,10 @@ function changelog({ releaseCount = 0, file = "CHANGELOG.md" } = {}) {
|
|
|
51
51
|
// src/release.ts
|
|
52
52
|
var cwd = process.cwd();
|
|
53
53
|
var { writeFileSync, readJSONSync } = fse2;
|
|
54
|
-
var { prompt } = inquirer;
|
|
55
54
|
var releaseTypes = ["premajor", "preminor", "prepatch", "major", "minor", "patch"];
|
|
56
55
|
var BACK_HINT = "Back to previous step";
|
|
57
56
|
async function isWorktreeEmpty() {
|
|
58
|
-
const ret = await
|
|
57
|
+
const ret = await exec("git", ["status", "--porcelain"]);
|
|
59
58
|
return !ret.stdout;
|
|
60
59
|
}
|
|
61
60
|
async function isSameVersion(version) {
|
|
@@ -65,7 +64,9 @@ async function isSameVersion(version) {
|
|
|
65
64
|
if (packageJson) {
|
|
66
65
|
const { config } = packageJson;
|
|
67
66
|
try {
|
|
68
|
-
await
|
|
67
|
+
await exec("npm", ["view", `${config.name}@${version ?? config.version}`, "version"], {
|
|
68
|
+
throwOnError: true
|
|
69
|
+
});
|
|
69
70
|
s.warn({
|
|
70
71
|
text: `The npm package has a same remote version ${config.version}.`
|
|
71
72
|
});
|
|
@@ -88,7 +89,7 @@ async function publish({ preRelease, checkRemoteVersion, npmTag }) {
|
|
|
88
89
|
} else if (npmTag) {
|
|
89
90
|
args.push("--tag", npmTag);
|
|
90
91
|
}
|
|
91
|
-
const ret = await
|
|
92
|
+
const ret = await exec("pnpm", args);
|
|
92
93
|
if (ret.stderr && ret.stderr.includes("npm ERR!")) {
|
|
93
94
|
throw new Error("\n" + ret.stderr);
|
|
94
95
|
} else {
|
|
@@ -98,13 +99,23 @@ async function publish({ preRelease, checkRemoteVersion, npmTag }) {
|
|
|
98
99
|
}
|
|
99
100
|
async function pushGit(version, remote = "origin", skipGitTag = false) {
|
|
100
101
|
const s = createSpinner2("Pushing to remote git repository").start();
|
|
101
|
-
await
|
|
102
|
-
|
|
102
|
+
await exec("git", ["add", "."], {
|
|
103
|
+
throwOnError: true
|
|
104
|
+
});
|
|
105
|
+
await exec("git", ["commit", "-m", `v${version}`], {
|
|
106
|
+
throwOnError: true
|
|
107
|
+
});
|
|
103
108
|
if (!skipGitTag) {
|
|
104
|
-
await
|
|
105
|
-
|
|
109
|
+
await exec("git", ["tag", `v${version}`], {
|
|
110
|
+
throwOnError: true
|
|
111
|
+
});
|
|
112
|
+
await exec("git", ["push", remote, `v${version}`], {
|
|
113
|
+
throwOnError: true
|
|
114
|
+
});
|
|
106
115
|
}
|
|
107
|
-
const ret = await
|
|
116
|
+
const ret = await exec("git", ["push"], {
|
|
117
|
+
throwOnError: true
|
|
118
|
+
});
|
|
108
119
|
s.success({ text: "Push remote repository successfully" });
|
|
109
120
|
ret.stdout && logger_default.info(ret.stdout);
|
|
110
121
|
}
|
|
@@ -126,53 +137,38 @@ function updateVersion(version) {
|
|
|
126
137
|
});
|
|
127
138
|
}
|
|
128
139
|
async function confirmRegistry() {
|
|
129
|
-
const registry = (await
|
|
130
|
-
const
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
type: "confirm",
|
|
135
|
-
message: `Current registry is: ${registry}`
|
|
136
|
-
}
|
|
137
|
-
]);
|
|
138
|
-
return ret[name];
|
|
140
|
+
const registry = (await exec("npm", ["config", "get", "registry"])).stdout;
|
|
141
|
+
const ret = await confirm({
|
|
142
|
+
message: `Current registry is: ${registry}`
|
|
143
|
+
});
|
|
144
|
+
return ret;
|
|
139
145
|
}
|
|
140
146
|
async function confirmVersion(currentVersion, expectVersion) {
|
|
141
|
-
const
|
|
142
|
-
|
|
143
|
-
{
|
|
144
|
-
name,
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
return ret[name];
|
|
147
|
+
const ret = await select({
|
|
148
|
+
message: "Version confirm",
|
|
149
|
+
choices: [`All packages version ${currentVersion} -> ${expectVersion}`, BACK_HINT].map((value) => ({
|
|
150
|
+
name: value,
|
|
151
|
+
value
|
|
152
|
+
}))
|
|
153
|
+
});
|
|
154
|
+
return ret;
|
|
150
155
|
}
|
|
151
156
|
async function confirmRefs(remote = "origin") {
|
|
152
|
-
const { stdout } = await
|
|
157
|
+
const { stdout } = await exec("git", ["remote", "-v"]);
|
|
153
158
|
const reg = new RegExp(`${remote} (.*) \\(push`);
|
|
154
159
|
const repo = stdout.match(reg)?.[1];
|
|
155
|
-
const { stdout: branch } = await
|
|
156
|
-
const
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
type: "confirm",
|
|
161
|
-
message: `Current refs ${repo}:refs/for/${branch}`
|
|
162
|
-
}
|
|
163
|
-
]);
|
|
164
|
-
return ret[name];
|
|
160
|
+
const { stdout: branch } = await exec("git", ["branch", "--show-current"]);
|
|
161
|
+
const ret = await confirm({
|
|
162
|
+
message: `Current refs ${repo}:refs/for/${branch}`
|
|
163
|
+
});
|
|
164
|
+
return ret;
|
|
165
165
|
}
|
|
166
166
|
async function getReleaseType() {
|
|
167
|
-
const
|
|
168
|
-
|
|
169
|
-
{
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
choices: releaseTypes
|
|
173
|
-
}
|
|
174
|
-
]);
|
|
175
|
-
return ret[name];
|
|
167
|
+
const releaseType = await select({
|
|
168
|
+
message: "Please select release type",
|
|
169
|
+
choices: releaseTypes.map((type) => ({ name: type, value: type }))
|
|
170
|
+
});
|
|
171
|
+
return releaseType;
|
|
176
172
|
}
|
|
177
173
|
async function getReleaseVersion(currentVersion) {
|
|
178
174
|
let isPreRelease = false;
|
|
@@ -211,7 +207,7 @@ async function release(options) {
|
|
|
211
207
|
}
|
|
212
208
|
updateVersion(expectVersion);
|
|
213
209
|
if (options.task) {
|
|
214
|
-
await options.task();
|
|
210
|
+
await options.task(expectVersion, currentVersion);
|
|
215
211
|
}
|
|
216
212
|
if (!options.skipNpmPublish) {
|
|
217
213
|
await publish({ preRelease: isPreRelease, npmTag: options.npmTag });
|
|
@@ -225,11 +221,15 @@ async function release(options) {
|
|
|
225
221
|
logger_default.success(`Release version ${expectVersion} successfully!`);
|
|
226
222
|
if (isPreRelease) {
|
|
227
223
|
try {
|
|
228
|
-
await
|
|
224
|
+
await exec("git", ["restore", "**/package.json"], {
|
|
225
|
+
throwOnError: true
|
|
226
|
+
});
|
|
229
227
|
} catch {
|
|
230
228
|
}
|
|
231
229
|
try {
|
|
232
|
-
await
|
|
230
|
+
await exec("git", ["restore", "package.json"], {
|
|
231
|
+
throwOnError: true
|
|
232
|
+
});
|
|
233
233
|
} catch {
|
|
234
234
|
}
|
|
235
235
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@varlet/release",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.3.0",
|
|
5
5
|
"description": "release all packages and generate changelogs",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"varlet",
|
|
@@ -46,7 +46,6 @@
|
|
|
46
46
|
"devDependencies": {
|
|
47
47
|
"@types/conventional-changelog": "^3.1.5",
|
|
48
48
|
"@types/fs-extra": "^11.0.4",
|
|
49
|
-
"@types/inquirer": "^9.0.7",
|
|
50
49
|
"@types/node": "^20.9.0",
|
|
51
50
|
"@types/semver": "^7.5.5",
|
|
52
51
|
"@varlet/eslint-config": "^2.18.4",
|
|
@@ -54,19 +53,19 @@
|
|
|
54
53
|
"lint-staged": "^15.2.0",
|
|
55
54
|
"prettier": "^3.1.0",
|
|
56
55
|
"simple-git-hooks": "^2.9.0",
|
|
57
|
-
"tsup": "^8.0
|
|
56
|
+
"tsup": "^8.3.0",
|
|
58
57
|
"typescript": "^5.2.2"
|
|
59
58
|
},
|
|
60
59
|
"dependencies": {
|
|
60
|
+
"@inquirer/prompts": "^6.0.1",
|
|
61
61
|
"commander": "^11.1.0",
|
|
62
62
|
"conventional-changelog": "^5.1.0",
|
|
63
|
-
"execa": "^8.0.1",
|
|
64
63
|
"fs-extra": "^11.1.1",
|
|
65
64
|
"glob": "^10.3.10",
|
|
66
|
-
"inquirer": "^9.2.12",
|
|
67
65
|
"nanospinner": "^1.1.0",
|
|
68
66
|
"picocolors": "^1.0.0",
|
|
69
|
-
"semver": "^7.5.4"
|
|
67
|
+
"semver": "^7.5.4",
|
|
68
|
+
"tinyexec": "^0.3.0"
|
|
70
69
|
},
|
|
71
70
|
"scripts": {
|
|
72
71
|
"dev": "tsup --watch",
|