@varlet/release 2.1.1 → 2.2.1-alpha.1776224189096
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 +73 -47
- package/README.zh-CN.md +73 -47
- package/dist/cli.js +12 -12
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/{src-DJEBh4nv.js → src-DwRUa0a2.js} +6 -7
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -20,12 +20,36 @@
|
|
|
20
20
|
|
|
21
21
|
> `Varlet Release` requires `Node.js` ^20.19.0 || >=22.12.0 and `esm` only.
|
|
22
22
|
|
|
23
|
-
##
|
|
23
|
+
## Quick Start
|
|
24
|
+
|
|
25
|
+
Install dependencies:
|
|
24
26
|
|
|
25
27
|
```shell
|
|
26
|
-
pnpm add @varlet/release -D
|
|
28
|
+
pnpm add @varlet/release simple-git-hooks -D
|
|
27
29
|
```
|
|
28
30
|
|
|
31
|
+
Add the following configuration to `package.json`:
|
|
32
|
+
|
|
33
|
+
```json
|
|
34
|
+
{
|
|
35
|
+
"scripts": {
|
|
36
|
+
"prepare": "simple-git-hooks",
|
|
37
|
+
"release": "vr release",
|
|
38
|
+
"changelog": "vr changelog"
|
|
39
|
+
},
|
|
40
|
+
"simple-git-hooks": {
|
|
41
|
+
"commit-msg": "pnpm exec vr commit-lint $1",
|
|
42
|
+
"post-merge": "pnpm exec vr lockfile-check --install"
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
Now you can:
|
|
48
|
+
|
|
49
|
+
- Write commits following the [Conventional Commits](https://www.conventionalcommits.org/) format, `commit-lint` will automatically validate them.
|
|
50
|
+
- After pulling or merging code, `lockfile-check` will automatically detect lockfile changes (`pnpm-lock.yaml`, `yarn.lock`, `package-lock.json`) and reinstall dependencies.
|
|
51
|
+
- Run `pnpm release` to start the interactive release workflow.
|
|
52
|
+
|
|
29
53
|
## Usage
|
|
30
54
|
|
|
31
55
|
### Features Overview
|
|
@@ -61,29 +85,29 @@ _Flags Reference_:
|
|
|
61
85
|
Usage: vr release [flags...]
|
|
62
86
|
|
|
63
87
|
Flags:
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
--skip-changelog
|
|
67
|
-
--skip-git-tag
|
|
68
|
-
|
|
69
|
-
|
|
88
|
+
--remote string Remote repository name # default: 'origin'
|
|
89
|
+
--skip-npm-publish Skip npm publish
|
|
90
|
+
--skip-changelog Skip generating changelog
|
|
91
|
+
--skip-git-tag Skip git tag
|
|
92
|
+
--npm-tag string npm tag
|
|
93
|
+
--check-remote-version Check remote version
|
|
70
94
|
```
|
|
71
95
|
|
|
72
96
|
_Example_:
|
|
73
97
|
|
|
74
98
|
```shell
|
|
75
99
|
# Release all packages and execute the full workflow
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
# Specify remote repository name (default origin)
|
|
79
|
-
npx vr release -r origin
|
|
100
|
+
pnpm exec vr release
|
|
80
101
|
|
|
81
102
|
# Skip npm publishing
|
|
82
|
-
|
|
103
|
+
pnpm exec vr release --skip-npm-publish
|
|
83
104
|
# Skip generating changelog
|
|
84
|
-
|
|
105
|
+
pnpm exec vr release --skip-changelog
|
|
85
106
|
# Check remote version, interrupt execution if the identical version already exists
|
|
86
|
-
|
|
107
|
+
pnpm exec vr release --check-remote-version
|
|
108
|
+
|
|
109
|
+
# Specify the git remote name for pushing tags (useful when multiple remotes are configured, e.g. upstream, fork)
|
|
110
|
+
pnpm exec vr release --remote upstream
|
|
87
111
|
```
|
|
88
112
|
|
|
89
113
|
**Node API**:
|
|
@@ -134,20 +158,20 @@ _Flags Reference_:
|
|
|
134
158
|
Usage: vr publish [flags...]
|
|
135
159
|
|
|
136
160
|
Flags:
|
|
137
|
-
|
|
138
|
-
|
|
161
|
+
--check-remote-version Check remote version
|
|
162
|
+
--npm-tag string npm tag
|
|
139
163
|
```
|
|
140
164
|
|
|
141
165
|
_Example_:
|
|
142
166
|
|
|
143
167
|
```shell
|
|
144
168
|
# Publish directly to npm
|
|
145
|
-
|
|
169
|
+
pnpm exec vr publish
|
|
146
170
|
|
|
147
171
|
# Check if the same version already exists due to network or other reasons, and abort if so
|
|
148
|
-
|
|
172
|
+
pnpm exec vr publish --check-remote-version
|
|
149
173
|
# Specify the npm dist-tag
|
|
150
|
-
|
|
174
|
+
pnpm exec vr publish --npm-tag alpha
|
|
151
175
|
```
|
|
152
176
|
|
|
153
177
|
**Node API**:
|
|
@@ -181,20 +205,20 @@ _Flags Reference_:
|
|
|
181
205
|
Usage: vr changelog [flags...]
|
|
182
206
|
|
|
183
207
|
Flags:
|
|
184
|
-
|
|
185
|
-
|
|
208
|
+
--release-count number Release count # default: 0
|
|
209
|
+
--file string Changelog filename # default: 'CHANGELOG.md'
|
|
186
210
|
```
|
|
187
211
|
|
|
188
212
|
_Example_:
|
|
189
213
|
|
|
190
214
|
```shell
|
|
191
215
|
# Generate changelogs for all history and output as CHANGELOG.md in the current directory
|
|
192
|
-
|
|
216
|
+
pnpm exec vr changelog
|
|
193
217
|
|
|
194
218
|
# Specify the generated changelog filename
|
|
195
|
-
|
|
219
|
+
pnpm exec vr changelog --file my-changelog.md
|
|
196
220
|
# Limit the range of release versions to generate changelogs for (0 means all)
|
|
197
|
-
|
|
221
|
+
pnpm exec vr changelog --release-count 0
|
|
198
222
|
```
|
|
199
223
|
|
|
200
224
|
**Node API**:
|
|
@@ -224,26 +248,28 @@ changelog({
|
|
|
224
248
|
|
|
225
249
|
**CLI Commands**:
|
|
226
250
|
|
|
227
|
-
|
|
251
|
+
_Parameters Reference_:
|
|
228
252
|
|
|
229
253
|
```text
|
|
230
|
-
Usage: vr commit-lint [flags...]
|
|
254
|
+
Usage: vr commit-lint <commit-message-path> [flags...]
|
|
255
|
+
|
|
256
|
+
Parameters:
|
|
257
|
+
<commit-message-path> Git commit message path (required)
|
|
231
258
|
|
|
232
259
|
Flags:
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
-w, --warning-message <string> Warning message displayed on validation failure
|
|
260
|
+
--commit-message-re string Validate the regex for commit message
|
|
261
|
+
--error-message string Error message displayed on validation failure
|
|
262
|
+
--warning-message string Warning message displayed on validation failure
|
|
237
263
|
```
|
|
238
264
|
|
|
239
265
|
_Example_:
|
|
240
266
|
|
|
241
267
|
```shell
|
|
242
268
|
# Check if the commit message at the given path is standard
|
|
243
|
-
|
|
269
|
+
pnpm exec vr commit-lint .git/COMMIT_EDITMSG
|
|
244
270
|
|
|
245
271
|
# Customize regex validation and prompt message
|
|
246
|
-
|
|
272
|
+
pnpm exec vr commit-lint .git/COMMIT_EDITMSG --commit-message-re "^feat: .*" --error-message "Commit validation failed"
|
|
247
273
|
```
|
|
248
274
|
|
|
249
275
|
_It is recommended to integrate with `simple-git-hooks` or `husky` in `package.json`:_
|
|
@@ -251,7 +277,7 @@ _It is recommended to integrate with `simple-git-hooks` or `husky` in `package.j
|
|
|
251
277
|
```json
|
|
252
278
|
{
|
|
253
279
|
"simple-git-hooks": {
|
|
254
|
-
"commit-msg": "
|
|
280
|
+
"commit-msg": "pnpm exec vr commit-lint $1"
|
|
255
281
|
}
|
|
256
282
|
}
|
|
257
283
|
```
|
|
@@ -273,11 +299,11 @@ commitLint({
|
|
|
273
299
|
|
|
274
300
|
### lockfile-check
|
|
275
301
|
|
|
276
|
-
**Description**: Detect and visually output in the console whether the lockfile of frontend dependencies has been modified.
|
|
302
|
+
**Description**: Detect and visually output in the console whether the lockfile of frontend dependencies has been modified, and automatically install dependencies by default to keep in sync.
|
|
277
303
|
|
|
278
|
-
**Use cases**: Recommended to use after Git operations such as pulling updates (`git pull`), switching branches (`git checkout`), or merging code. It helps detect if upstream dependency lockfiles (like `pnpm-lock.yaml`) have changed. If a change is detected,
|
|
304
|
+
**Use cases**: Recommended to use after Git operations such as pulling updates (`git pull`), switching branches (`git checkout`), or merging code. It helps detect if upstream dependency lockfiles (like `pnpm-lock.yaml`) have changed. If a change is detected, it will automatically invoke a package manager's installation command to synchronize the local environment with upstream instantly, preventing obscure bugs caused by outdated dependencies.
|
|
279
305
|
|
|
280
|
-
**Core Workflow**: Execute a Git diff comparing the project's lockfile (e.g. `pnpm-lock.yaml` or corresponding environment lockfile) from the original HEAD. Print its modification status in the console. Furthermore, trigger the package manager to reinstall dependencies to sync with upstream if directed by the command options.
|
|
306
|
+
**Core Workflow**: Execute a Git diff comparing the project's lockfile (e.g. `pnpm-lock.yaml` or corresponding environment lockfile) from the original HEAD. Print its modification status in the console. Furthermore, trigger the package manager to reinstall dependencies to sync with upstream by default, or skip installation if directed by the command options.
|
|
281
307
|
|
|
282
308
|
**CLI Commands**:
|
|
283
309
|
|
|
@@ -287,21 +313,21 @@ _Flags Reference_:
|
|
|
287
313
|
Usage: vr lockfile-check [flags...]
|
|
288
314
|
|
|
289
315
|
Flags:
|
|
290
|
-
|
|
291
|
-
|
|
316
|
+
--package-manager string Package manager (npm, yarn, pnpm) # default: 'pnpm'
|
|
317
|
+
--skip-install Skip install dependencies when lockfile changed
|
|
292
318
|
```
|
|
293
319
|
|
|
294
320
|
_Example_:
|
|
295
321
|
|
|
296
322
|
```shell
|
|
297
|
-
# Check the synchronization status of the current lockfile
|
|
298
|
-
|
|
323
|
+
# Check the synchronization status of the current lockfile and install dependencies if changed
|
|
324
|
+
pnpm exec vr lockfile-check
|
|
299
325
|
|
|
300
|
-
# Check current status
|
|
301
|
-
|
|
326
|
+
# Check current status but skip installation even if updates exist
|
|
327
|
+
pnpm exec vr lockfile-check --skip-install
|
|
302
328
|
|
|
303
|
-
# Specify other package managers for checking
|
|
304
|
-
|
|
329
|
+
# Specify other package managers for checking
|
|
330
|
+
pnpm exec vr lockfile-check --package-manager npm
|
|
305
331
|
```
|
|
306
332
|
|
|
307
333
|
_It is also recommended to integrate with `simple-git-hooks` or `husky` in `package.json` (e.g. trigger checks and installations automatically during the `post-merge` or `post-checkout` hooks):_
|
|
@@ -309,7 +335,7 @@ _It is also recommended to integrate with `simple-git-hooks` or `husky` in `pack
|
|
|
309
335
|
```json
|
|
310
336
|
{
|
|
311
337
|
"simple-git-hooks": {
|
|
312
|
-
"post-merge": "
|
|
338
|
+
"post-merge": "pnpm exec vr lockfile-check"
|
|
313
339
|
}
|
|
314
340
|
}
|
|
315
341
|
```
|
|
@@ -321,7 +347,7 @@ import { lockfileCheck } from '@varlet/release'
|
|
|
321
347
|
|
|
322
348
|
lockfileCheck({
|
|
323
349
|
packageManager?: 'npm' | 'yarn' | 'pnpm' // Choose package manager, defaults to 'pnpm'
|
|
324
|
-
|
|
350
|
+
skipInstall?: boolean // Whether to skip installation if lockfile is out of sync
|
|
325
351
|
})
|
|
326
352
|
```
|
|
327
353
|
|
package/README.zh-CN.md
CHANGED
|
@@ -20,12 +20,36 @@
|
|
|
20
20
|
|
|
21
21
|
> `Varlet Release` 需要 `Node.js` ^20.19.0 || >=22.12.0,并且仅支持 `esm`。
|
|
22
22
|
|
|
23
|
-
##
|
|
23
|
+
## 快速开始
|
|
24
|
+
|
|
25
|
+
安装依赖:
|
|
24
26
|
|
|
25
27
|
```shell
|
|
26
|
-
pnpm add @varlet/release -D
|
|
28
|
+
pnpm add @varlet/release simple-git-hooks -D
|
|
27
29
|
```
|
|
28
30
|
|
|
31
|
+
在 `package.json` 中添加以下配置:
|
|
32
|
+
|
|
33
|
+
```json
|
|
34
|
+
{
|
|
35
|
+
"scripts": {
|
|
36
|
+
"prepare": "simple-git-hooks",
|
|
37
|
+
"release": "vr release",
|
|
38
|
+
"changelog": "vr changelog"
|
|
39
|
+
},
|
|
40
|
+
"simple-git-hooks": {
|
|
41
|
+
"commit-msg": "pnpm exec vr commit-lint $1",
|
|
42
|
+
"post-merge": "pnpm exec vr lockfile-check --install"
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
现在你可以:
|
|
48
|
+
|
|
49
|
+
- 按照 [Conventional Commits](https://www.conventionalcommits.org/) 规范编写提交信息,`commit-lint` 会自动校验。
|
|
50
|
+
- 拉取或合并代码后,`lockfile-check` 会自动检测 lockfile 变化(`pnpm-lock.yaml`、`yarn.lock`、`package-lock.json`)并重新安装依赖。
|
|
51
|
+
- 运行 `pnpm release` 启动交互式发布流程。
|
|
52
|
+
|
|
29
53
|
## 使用
|
|
30
54
|
|
|
31
55
|
### 功能概览
|
|
@@ -61,29 +85,29 @@ _标志参考_:
|
|
|
61
85
|
用法: vr release [标志...]
|
|
62
86
|
|
|
63
87
|
标志:
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
--skip-changelog
|
|
67
|
-
--skip-git-tag
|
|
68
|
-
|
|
69
|
-
|
|
88
|
+
--remote string 远程仓库名称 # 默认: 'origin'
|
|
89
|
+
--skip-npm-publish 跳过 npm 发布
|
|
90
|
+
--skip-changelog 跳过生成变更日志
|
|
91
|
+
--skip-git-tag 跳过 git tag
|
|
92
|
+
--npm-tag string npm tag
|
|
93
|
+
--check-remote-version 检查远程版本
|
|
70
94
|
```
|
|
71
95
|
|
|
72
96
|
_使用示例_:
|
|
73
97
|
|
|
74
98
|
```shell
|
|
75
99
|
# 发布所有包并执行完整工作流程
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
# 指定远程仓库名称 (默认 origin)
|
|
79
|
-
npx vr release -r origin
|
|
100
|
+
pnpm exec vr release
|
|
80
101
|
|
|
81
102
|
# 跳过 npm 发布
|
|
82
|
-
|
|
103
|
+
pnpm exec vr release --skip-npm-publish
|
|
83
104
|
# 跳过生成变更日志
|
|
84
|
-
|
|
105
|
+
pnpm exec vr release --skip-changelog
|
|
85
106
|
# 检查远程版本,若已存在相同版本则中断执行
|
|
86
|
-
|
|
107
|
+
pnpm exec vr release --check-remote-version
|
|
108
|
+
|
|
109
|
+
# 指定推送 tag 的 git remote 名称(适用于配置了多个 remote 的场景,如 upstream、fork 等)
|
|
110
|
+
pnpm exec vr release --remote upstream
|
|
87
111
|
```
|
|
88
112
|
|
|
89
113
|
**Node 调用**:
|
|
@@ -134,20 +158,20 @@ _标志参考_:
|
|
|
134
158
|
用法: vr publish [标志...]
|
|
135
159
|
|
|
136
160
|
标志:
|
|
137
|
-
|
|
138
|
-
|
|
161
|
+
--check-remote-version 检查远程版本
|
|
162
|
+
--npm-tag string npm tag
|
|
139
163
|
```
|
|
140
164
|
|
|
141
165
|
_使用示例_:
|
|
142
166
|
|
|
143
167
|
```shell
|
|
144
168
|
# 直接发布到 npm
|
|
145
|
-
|
|
169
|
+
pnpm exec vr publish
|
|
146
170
|
|
|
147
171
|
# 检查由于网络等原因是否已存在相同版本,存在则放弃发布
|
|
148
|
-
|
|
172
|
+
pnpm exec vr publish --check-remote-version
|
|
149
173
|
# 指定 npm 的 dist-tag
|
|
150
|
-
|
|
174
|
+
pnpm exec vr publish --npm-tag alpha
|
|
151
175
|
```
|
|
152
176
|
|
|
153
177
|
**Node 调用**:
|
|
@@ -181,20 +205,20 @@ _标志参考_:
|
|
|
181
205
|
用法: vr changelog [标志...]
|
|
182
206
|
|
|
183
207
|
标志:
|
|
184
|
-
|
|
185
|
-
|
|
208
|
+
--release-count number 发布数量 # 默认: 0
|
|
209
|
+
--file string 变更日志文件名 # 默认: 'CHANGELOG.md'
|
|
186
210
|
```
|
|
187
211
|
|
|
188
212
|
_使用示例_:
|
|
189
213
|
|
|
190
214
|
```shell
|
|
191
215
|
# 生成所有历史的变更日志并在当前目录输出为 CHANGELOG.md
|
|
192
|
-
|
|
216
|
+
pnpm exec vr changelog
|
|
193
217
|
|
|
194
218
|
# 指定生成的变更日志文件名
|
|
195
|
-
|
|
219
|
+
pnpm exec vr changelog --file my-changelog.md
|
|
196
220
|
# 限定发布版本的范围数量以生成变更日志 (0 为全量)
|
|
197
|
-
|
|
221
|
+
pnpm exec vr changelog --release-count 0
|
|
198
222
|
```
|
|
199
223
|
|
|
200
224
|
**Node 调用**:
|
|
@@ -224,26 +248,28 @@ changelog({
|
|
|
224
248
|
|
|
225
249
|
**CMD 命令**:
|
|
226
250
|
|
|
227
|
-
_
|
|
251
|
+
_参数参考_:
|
|
228
252
|
|
|
229
253
|
```text
|
|
230
|
-
用法: vr commit-lint [标志...]
|
|
254
|
+
用法: vr commit-lint <commit-message-path> [标志...]
|
|
255
|
+
|
|
256
|
+
参数:
|
|
257
|
+
<commit-message-path> Git commit message 路径(必填)
|
|
231
258
|
|
|
232
259
|
标志:
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
-w, --warning-message <string> 验证失败时显示的警告信息
|
|
260
|
+
--commit-message-re string 验证 commit message 是否通过的正则表达式
|
|
261
|
+
--error-message string 验证失败时显示的错误信息
|
|
262
|
+
--warning-message string 验证失败时显示的警告信息
|
|
237
263
|
```
|
|
238
264
|
|
|
239
265
|
_使用示例_:
|
|
240
266
|
|
|
241
267
|
```shell
|
|
242
268
|
# 检测指路径的 commit message 是否符合规范
|
|
243
|
-
|
|
269
|
+
pnpm exec vr commit-lint .git/COMMIT_EDITMSG
|
|
244
270
|
|
|
245
271
|
# 定制指定的校验正则表达式和提示信息
|
|
246
|
-
|
|
272
|
+
pnpm exec vr commit-lint .git/COMMIT_EDITMSG --commit-message-re "^feat: .*" --error-message "提交校验失败"
|
|
247
273
|
```
|
|
248
274
|
|
|
249
275
|
_建议配合并在 `package.json` 中的 `simple-git-hooks` 或 `husky` 一同集成运作:_
|
|
@@ -251,7 +277,7 @@ _建议配合并在 `package.json` 中的 `simple-git-hooks` 或 `husky` 一同
|
|
|
251
277
|
```json
|
|
252
278
|
{
|
|
253
279
|
"simple-git-hooks": {
|
|
254
|
-
"commit-msg": "
|
|
280
|
+
"commit-msg": "pnpm exec vr commit-lint $1"
|
|
255
281
|
}
|
|
256
282
|
}
|
|
257
283
|
```
|
|
@@ -273,11 +299,11 @@ commitLint({
|
|
|
273
299
|
|
|
274
300
|
### lockfile-check
|
|
275
301
|
|
|
276
|
-
**作用**:检测并在控制台直观地输出前端依赖包的 lockfile
|
|
302
|
+
**作用**:检测并在控制台直观地输出前端依赖包的 lockfile 文件是否发生变更,并默认自动安装依赖以保持同步。
|
|
277
303
|
|
|
278
|
-
**使用场景**:通常在进行 `git 操作` (如 `git pull`拉取最新代码、`git checkout`切换分支、或合并代码) 之后使用。它能帮助你检测上游的依赖锁文件(如 `pnpm-lock.yaml
|
|
304
|
+
**使用场景**:通常在进行 `git 操作` (如 `git pull`拉取最新代码、`git checkout`切换分支、或合并代码) 之后使用。它能帮助你检测上游的依赖锁文件(如 `pnpm-lock.yaml`)是否发生了变动。如果检测到有变更,默认会自动执行 install 安装命令,从而确保本地环境快速与上游依赖保持一致,避免因依赖版本陈旧导致的疑难 bug。
|
|
279
305
|
|
|
280
|
-
**核心流程**:比对项目原始游标的锁文件(如 pnpm-lock.yaml 或对应环境的 lockfile)的 Git diff
|
|
306
|
+
**核心流程**:比对项目原始游标的锁文件(如 pnpm-lock.yaml 或对应环境的 lockfile)的 Git diff,在控制台输出其是否存在变动;默认会触发包管理器的依赖重装程序以同步上游,也可以通过指令跳过安装。
|
|
281
307
|
|
|
282
308
|
**CMD 命令**:
|
|
283
309
|
|
|
@@ -287,21 +313,21 @@ _标志参考_:
|
|
|
287
313
|
用法: vr lockfile-check [标志...]
|
|
288
314
|
|
|
289
315
|
标志:
|
|
290
|
-
|
|
291
|
-
|
|
316
|
+
--package-manager string 包管理器 (npm, yarn, pnpm) # 默认: 'pnpm'
|
|
317
|
+
--skip-install 当 lockfile 发生变化时跳过安装依赖
|
|
292
318
|
```
|
|
293
319
|
|
|
294
320
|
_使用示例_:
|
|
295
321
|
|
|
296
322
|
```shell
|
|
297
|
-
# 检查当前 lockfile
|
|
298
|
-
|
|
323
|
+
# 检查当前 lockfile 的同步状态,若有变化则自动安装依赖
|
|
324
|
+
pnpm exec vr lockfile-check
|
|
299
325
|
|
|
300
|
-
#
|
|
301
|
-
|
|
326
|
+
# 检查当前状态,即使有更新也跳过安装
|
|
327
|
+
pnpm exec vr lockfile-check --skip-install
|
|
302
328
|
|
|
303
|
-
#
|
|
304
|
-
|
|
329
|
+
# 指定其他包管理器进行检查
|
|
330
|
+
pnpm exec vr lockfile-check --package-manager npm
|
|
305
331
|
```
|
|
306
332
|
|
|
307
333
|
_建议配合并在 `package.json` 中的 `simple-git-hooks` 或 `husky` 一同集成运作(例如在拉取代码的 `post-merge` 或 `post-checkout` 阶段自动触发检查与安装):_
|
|
@@ -309,7 +335,7 @@ _建议配合并在 `package.json` 中的 `simple-git-hooks` 或 `husky` 一同
|
|
|
309
335
|
```json
|
|
310
336
|
{
|
|
311
337
|
"simple-git-hooks": {
|
|
312
|
-
"post-merge": "
|
|
338
|
+
"post-merge": "pnpm exec vr lockfile-check"
|
|
313
339
|
}
|
|
314
340
|
}
|
|
315
341
|
```
|
|
@@ -321,7 +347,7 @@ import { lockfileCheck } from '@varlet/release'
|
|
|
321
347
|
|
|
322
348
|
lockfileCheck({
|
|
323
349
|
packageManager?: 'npm' | 'yarn' | 'pnpm' // 选择包管理器,默认为 'pnpm'
|
|
324
|
-
|
|
350
|
+
skipInstall?: boolean // 检测到 lock 不同步时是否跳过安装
|
|
325
351
|
})
|
|
326
352
|
```
|
|
327
353
|
|
package/dist/cli.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { c as release, i as lockfileCheck, p as commitLint, s as publish, u as changelog } from "./src-
|
|
2
|
+
import { c as release, i as lockfileCheck, p as commitLint, s as publish, u as changelog } from "./src-DwRUa0a2.js";
|
|
3
3
|
import { cli, command } from "cleye";
|
|
4
4
|
//#endregion
|
|
5
5
|
//#region src/cli.ts
|
|
6
6
|
cli({
|
|
7
7
|
name: "vr",
|
|
8
|
-
version: "2.1.
|
|
8
|
+
version: "2.2.1-alpha.1776224189096",
|
|
9
9
|
commands: [
|
|
10
10
|
command({
|
|
11
11
|
name: "release",
|
|
@@ -76,13 +76,8 @@ cli({
|
|
|
76
76
|
}, (argv) => changelog(argv.flags)),
|
|
77
77
|
command({
|
|
78
78
|
name: "commit-lint",
|
|
79
|
+
parameters: ["<commitMessagePath>"],
|
|
79
80
|
flags: {
|
|
80
|
-
commitMessagePath: {
|
|
81
|
-
type: String,
|
|
82
|
-
alias: "p",
|
|
83
|
-
default: "",
|
|
84
|
-
description: "Git commit message path"
|
|
85
|
-
},
|
|
86
81
|
commitMessageRe: {
|
|
87
82
|
type: String,
|
|
88
83
|
alias: "r",
|
|
@@ -100,7 +95,12 @@ cli({
|
|
|
100
95
|
}
|
|
101
96
|
},
|
|
102
97
|
help: { description: "Lint commit message" }
|
|
103
|
-
}, (argv) => commitLint(
|
|
98
|
+
}, (argv) => commitLint({
|
|
99
|
+
commitMessagePath: argv._.commitMessagePath,
|
|
100
|
+
commitMessageRe: argv.flags.commitMessageRe,
|
|
101
|
+
errorMessage: argv.flags.errorMessage,
|
|
102
|
+
warningMessage: argv.flags.warningMessage
|
|
103
|
+
})),
|
|
104
104
|
command({
|
|
105
105
|
name: "lockfile-check",
|
|
106
106
|
flags: {
|
|
@@ -110,10 +110,10 @@ cli({
|
|
|
110
110
|
default: "pnpm",
|
|
111
111
|
description: "Package manager (npm, yarn, pnpm), default pnpm"
|
|
112
112
|
},
|
|
113
|
-
|
|
113
|
+
skipInstall: {
|
|
114
114
|
type: Boolean,
|
|
115
|
-
alias: "
|
|
116
|
-
description: "
|
|
115
|
+
alias: "s",
|
|
116
|
+
description: "Skip install dependencies when lockfile changed"
|
|
117
117
|
}
|
|
118
118
|
},
|
|
119
119
|
help: { description: "Check if lockfile has been updated and optionally install dependencies" }
|
package/dist/index.d.ts
CHANGED
|
@@ -84,7 +84,7 @@ declare function commitLint(options: CommitLintCommandOptions): void;
|
|
|
84
84
|
type PackageManager = "npm" | "yarn" | "pnpm";
|
|
85
85
|
interface LockfileCheckOptions {
|
|
86
86
|
packageManager?: PackageManager;
|
|
87
|
-
|
|
87
|
+
skipInstall?: boolean;
|
|
88
88
|
}
|
|
89
89
|
declare function getLockfilePath(packageManager: PackageManager): string;
|
|
90
90
|
declare function checkLockfileSync(packageManager: PackageManager): Promise<boolean>;
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as getPackageJsons, c as release, d as COMMIT_HEADER_RE, f as COMMIT_MESSAGE_RE, h as isVersionCommitMessage, i as lockfileCheck, l as updateVersion, m as getCommitMessage, n as getLockfilePath, o as isSameVersion, p as commitLint, r as installDependencies, s as publish, t as checkLockfileSync, u as changelog } from "./src-
|
|
1
|
+
import { a as getPackageJsons, c as release, d as COMMIT_HEADER_RE, f as COMMIT_MESSAGE_RE, h as isVersionCommitMessage, i as lockfileCheck, l as updateVersion, m as getCommitMessage, n as getLockfilePath, o as isSameVersion, p as commitLint, r as installDependencies, s as publish, t as checkLockfileSync, u as changelog } from "./src-DwRUa0a2.js";
|
|
2
2
|
export { COMMIT_HEADER_RE, COMMIT_MESSAGE_RE, changelog, checkLockfileSync, commitLint, getCommitMessage, getLockfilePath, getPackageJsons, installDependencies, isSameVersion, isVersionCommitMessage, lockfileCheck, publish, release, updateVersion };
|
|
@@ -371,10 +371,9 @@ async function getReleaseVersion(currentVersion) {
|
|
|
371
371
|
};
|
|
372
372
|
}
|
|
373
373
|
}
|
|
374
|
-
async function restorePackageJsons() {
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
} catch {}
|
|
374
|
+
async function restorePackageJsons(cwd = process.cwd()) {
|
|
375
|
+
const paths = getPackageJsons(cwd).map(({ filePath }) => filePath);
|
|
376
|
+
if (paths.length > 0) await execGit("restore", ...paths);
|
|
378
377
|
}
|
|
379
378
|
async function release(options) {
|
|
380
379
|
const cwd = options.cwd ?? process.cwd();
|
|
@@ -407,7 +406,7 @@ async function release(options) {
|
|
|
407
406
|
await pushGit(expectVersion, options.remote, options.skipGitTag);
|
|
408
407
|
}
|
|
409
408
|
logger.success(`Release version ${expectVersion} successfully!`);
|
|
410
|
-
if (isPreRelease) await restorePackageJsons();
|
|
409
|
+
if (isPreRelease) await restorePackageJsons(cwd);
|
|
411
410
|
} catch (error) {
|
|
412
411
|
logger.error(error);
|
|
413
412
|
process.exit(1);
|
|
@@ -458,7 +457,7 @@ async function installDependencies(packageManager) {
|
|
|
458
457
|
async function lockfileCheck(options = {}) {
|
|
459
458
|
try {
|
|
460
459
|
const pkgManager = options.packageManager || "pnpm";
|
|
461
|
-
const
|
|
460
|
+
const skipInstallFlag = options.skipInstall || false;
|
|
462
461
|
if (![
|
|
463
462
|
"npm",
|
|
464
463
|
"yarn",
|
|
@@ -469,7 +468,7 @@ async function lockfileCheck(options = {}) {
|
|
|
469
468
|
}
|
|
470
469
|
if (await checkLockfileSync(pkgManager)) {
|
|
471
470
|
logger.warn("Lockfile has been updated!");
|
|
472
|
-
if (
|
|
471
|
+
if (!skipInstallFlag) await installDependencies(pkgManager);
|
|
473
472
|
}
|
|
474
473
|
} catch (error) {
|
|
475
474
|
logger.error("Error checking lockfile sync:", error);
|