@varlet/release 0.2.8 → 0.2.10
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 +11 -24
- package/README.zh-CN.md +10 -23
- package/bin/index.js +41 -40
- package/dist/index.cjs +31 -13
- package/dist/index.d.cts +3 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +30 -13
- package/package.json +2 -3
package/README.md
CHANGED
|
@@ -11,24 +11,10 @@
|
|
|
11
11
|
|
|
12
12
|
## Intro
|
|
13
13
|
|
|
14
|
-
`Varlet Release` is a tool
|
|
14
|
+
`Varlet Release` is a tool used for publishing all packages, generating change logs, and checking `commit messages`, relying on `pnpm`.
|
|
15
15
|
|
|
16
16
|
## Installation
|
|
17
17
|
|
|
18
|
-
### npm
|
|
19
|
-
|
|
20
|
-
```shell
|
|
21
|
-
npm i @varlet/release -D
|
|
22
|
-
```
|
|
23
|
-
|
|
24
|
-
### yarn
|
|
25
|
-
|
|
26
|
-
```shell
|
|
27
|
-
yarn add @varlet/release -D
|
|
28
|
-
```
|
|
29
|
-
|
|
30
|
-
### pnpm
|
|
31
|
-
|
|
32
18
|
```shell
|
|
33
19
|
pnpm add @varlet/release -D
|
|
34
20
|
```
|
|
@@ -65,13 +51,14 @@ npx vr publish
|
|
|
65
51
|
|
|
66
52
|
#### release
|
|
67
53
|
|
|
68
|
-
| Params
|
|
69
|
-
|
|
|
70
|
-
| -r --remote \<remote\>
|
|
71
|
-
| -s --skip-npm-publish
|
|
72
|
-
| -
|
|
73
|
-
| -
|
|
74
|
-
| -
|
|
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 |
|
|
75
62
|
|
|
76
63
|
#### changelog
|
|
77
64
|
|
|
@@ -91,10 +78,10 @@ npx vr publish
|
|
|
91
78
|
|
|
92
79
|
#### publish
|
|
93
80
|
|
|
94
|
-
| Params
|
|
81
|
+
| Params | Instructions |
|
|
95
82
|
| ------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
96
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 |
|
|
97
|
-
| -nt --npm-tag \<npmTag\>
|
|
84
|
+
| -nt --npm-tag \<npmTag\> | npm tag |
|
|
98
85
|
|
|
99
86
|
### Custom Handle
|
|
100
87
|
|
package/README.zh-CN.md
CHANGED
|
@@ -11,24 +11,10 @@
|
|
|
11
11
|
|
|
12
12
|
## 介绍
|
|
13
13
|
|
|
14
|
-
`Varlet Release` 是一个用于发布所有包、生成变更日志和检测 `commit message`
|
|
14
|
+
`Varlet Release` 是一个用于发布所有包、生成变更日志和检测 `commit message` 的工具,依赖于 `pnpm`。
|
|
15
15
|
|
|
16
16
|
## 安装
|
|
17
17
|
|
|
18
|
-
### npm
|
|
19
|
-
|
|
20
|
-
```shell
|
|
21
|
-
npm i @varlet/release -D
|
|
22
|
-
```
|
|
23
|
-
|
|
24
|
-
### yarn
|
|
25
|
-
|
|
26
|
-
```shell
|
|
27
|
-
yarn add @varlet/release -D
|
|
28
|
-
```
|
|
29
|
-
|
|
30
|
-
### pnpm
|
|
31
|
-
|
|
32
18
|
```shell
|
|
33
19
|
pnpm add @varlet/release -D
|
|
34
20
|
```
|
|
@@ -65,13 +51,14 @@ npx vr publish
|
|
|
65
51
|
|
|
66
52
|
#### release
|
|
67
53
|
|
|
68
|
-
| 参数
|
|
69
|
-
|
|
|
70
|
-
| -r --remote \<remote\>
|
|
71
|
-
| -s --skip-npm-publish
|
|
72
|
-
| -
|
|
73
|
-
| -
|
|
74
|
-
| -
|
|
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 |
|
|
75
62
|
|
|
76
63
|
#### changelog
|
|
77
64
|
|
|
@@ -94,7 +81,7 @@ npx vr publish
|
|
|
94
81
|
| 参数 | 说明 |
|
|
95
82
|
| ------------------------- | --------------------------------------------------------------------- |
|
|
96
83
|
| -c --check-remote-version | 检测npm包的远程版本是否与要在本地发布的包版本相同,如果是,则跳过发布 |
|
|
97
|
-
| -nt --npm-tag \<npmTag\>
|
|
84
|
+
| -nt --npm-tag \<npmTag\> | npm tag |
|
|
98
85
|
|
|
99
86
|
### 自定义处理
|
|
100
87
|
|
package/bin/index.js
CHANGED
|
@@ -1,40 +1,41 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import { release, publish, changelog, commitLint } from '../dist/index.js'
|
|
3
|
-
import { Command } from 'commander'
|
|
4
|
-
|
|
5
|
-
const program = new Command()
|
|
6
|
-
|
|
7
|
-
program
|
|
8
|
-
.command('release')
|
|
9
|
-
.option('-r --remote <remote>', 'Remote name')
|
|
10
|
-
.option('-s --skip-npm-publish', 'Skip npm publish')
|
|
11
|
-
.option('-sc --skip-changelog', 'Skip generate changelog')
|
|
12
|
-
.option('-sgt --skip-git-tag', 'Skip git tag')
|
|
13
|
-
.option('-nt --npm-tag <npmTag>', 'Npm tag')
|
|
14
|
-
.
|
|
15
|
-
.
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
.
|
|
20
|
-
.option('-
|
|
21
|
-
.
|
|
22
|
-
.
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
.
|
|
27
|
-
.option('-
|
|
28
|
-
.
|
|
29
|
-
.
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
.
|
|
34
|
-
.option('-
|
|
35
|
-
.option('-
|
|
36
|
-
.option('-
|
|
37
|
-
.
|
|
38
|
-
.
|
|
39
|
-
|
|
40
|
-
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { release, publish, changelog, commitLint } from '../dist/index.js'
|
|
3
|
+
import { Command } from 'commander'
|
|
4
|
+
|
|
5
|
+
const program = new Command()
|
|
6
|
+
|
|
7
|
+
program
|
|
8
|
+
.command('release')
|
|
9
|
+
.option('-r --remote <remote>', 'Remote name')
|
|
10
|
+
.option('-s --skip-npm-publish', 'Skip npm publish')
|
|
11
|
+
.option('-sc --skip-changelog', 'Skip generate changelog')
|
|
12
|
+
.option('-sgt --skip-git-tag', 'Skip git tag')
|
|
13
|
+
.option('-nt --npm-tag <npmTag>', 'Npm tag')
|
|
14
|
+
.option('-c --check-remote-version', 'Check remote version')
|
|
15
|
+
.description('Release all packages and generate changelogs')
|
|
16
|
+
.action(async (options) => release(options))
|
|
17
|
+
|
|
18
|
+
program
|
|
19
|
+
.command('publish')
|
|
20
|
+
.option('-c --check-remote-version', 'Check remote version')
|
|
21
|
+
.option('-nt --npm-tag <npmTag>', 'Npm tag')
|
|
22
|
+
.description('Publish to npm')
|
|
23
|
+
.action(async (options) => publish(options))
|
|
24
|
+
|
|
25
|
+
program
|
|
26
|
+
.command('changelog')
|
|
27
|
+
.option('-rc --releaseCount <releaseCount>', 'Release count')
|
|
28
|
+
.option('-f --file <file>', 'Changelog filename')
|
|
29
|
+
.description('Generate changelog')
|
|
30
|
+
.action(async (options) => changelog(options))
|
|
31
|
+
|
|
32
|
+
program
|
|
33
|
+
.command('commit-lint')
|
|
34
|
+
.option('-p --commitMessagePath <path>', 'Git commit message path')
|
|
35
|
+
.option('-r --commitMessageRe <reg>', 'Validate the regular of whether the commit message passes')
|
|
36
|
+
.option('-e --errorMessage <message>', 'Validation failed to display error messages')
|
|
37
|
+
.option('-w --warningMessage <message>', 'Validation failed to display warning messages')
|
|
38
|
+
.description('Lint commit message')
|
|
39
|
+
.action(async (option) => commitLint(option))
|
|
40
|
+
|
|
41
|
+
program.parse()
|
package/dist/index.cjs
CHANGED
|
@@ -34,6 +34,7 @@ __export(src_exports, {
|
|
|
34
34
|
changelog: () => changelog,
|
|
35
35
|
commitLint: () => commitLint,
|
|
36
36
|
getCommitMessage: () => getCommitMessage,
|
|
37
|
+
isSameVersion: () => isSameVersion,
|
|
37
38
|
isVersionCommitMessage: () => isVersionCommitMessage,
|
|
38
39
|
publish: () => publish,
|
|
39
40
|
release: () => release,
|
|
@@ -101,22 +102,30 @@ async function isWorktreeEmpty() {
|
|
|
101
102
|
const ret = await (0, import_execa.execa)("git", ["status", "--porcelain"]);
|
|
102
103
|
return !ret.stdout;
|
|
103
104
|
}
|
|
105
|
+
async function isSameVersion(version) {
|
|
106
|
+
const s = (0, import_nanospinner2.createSpinner)("Check remote version...").start();
|
|
107
|
+
const packageJsones = getPackageJsons();
|
|
108
|
+
const packageJson = packageJsones.find((packageJson2) => !packageJson2.config.private) || packageJsones[0];
|
|
109
|
+
if (packageJson) {
|
|
110
|
+
const { config } = packageJson;
|
|
111
|
+
try {
|
|
112
|
+
await (0, import_execa.execa)("npm", ["view", `${config.name}@${version ?? config.version}`, "version"]);
|
|
113
|
+
s.warn({
|
|
114
|
+
text: `The npm package has a same remote version ${config.version}.`
|
|
115
|
+
});
|
|
116
|
+
return true;
|
|
117
|
+
} catch {
|
|
118
|
+
s.success();
|
|
119
|
+
return false;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}
|
|
104
123
|
async function publish({ preRelease, checkRemoteVersion, npmTag }) {
|
|
105
124
|
const s = (0, import_nanospinner2.createSpinner)("Publishing all packages").start();
|
|
106
125
|
const args = ["-r", "publish", "--no-git-checks", "--access", "public"];
|
|
107
|
-
if (checkRemoteVersion) {
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
const { config } = packageJson;
|
|
111
|
-
try {
|
|
112
|
-
await (0, import_execa.execa)("npm", ["view", `${config.name}@${config.version}`, "version"]);
|
|
113
|
-
s.warn({
|
|
114
|
-
text: `The npm package has a same remote version ${config.version}, publishing automatically skipped.`
|
|
115
|
-
});
|
|
116
|
-
return;
|
|
117
|
-
} catch {
|
|
118
|
-
}
|
|
119
|
-
}
|
|
126
|
+
if (checkRemoteVersion && await isSameVersion()) {
|
|
127
|
+
logger_default.error("publishing automatically skipped.");
|
|
128
|
+
return;
|
|
120
129
|
}
|
|
121
130
|
if (preRelease) {
|
|
122
131
|
args.push("--tag", "alpha");
|
|
@@ -240,6 +249,10 @@ async function release(options) {
|
|
|
240
249
|
return;
|
|
241
250
|
}
|
|
242
251
|
const { isPreRelease, expectVersion } = await getReleaseVersion(currentVersion);
|
|
252
|
+
if (options.checkRemoteVersion && await isSameVersion(expectVersion)) {
|
|
253
|
+
logger_default.error("Please check remote version.");
|
|
254
|
+
return;
|
|
255
|
+
}
|
|
243
256
|
updateVersion(expectVersion);
|
|
244
257
|
if (options.task) {
|
|
245
258
|
await options.task();
|
|
@@ -320,6 +333,10 @@ function commitLint(options) {
|
|
|
320
333
|
errorMessage = ERROR_MESSAGE,
|
|
321
334
|
warningMessage = WARNING_MESSAGE
|
|
322
335
|
} = options;
|
|
336
|
+
if (!commitMessagePath) {
|
|
337
|
+
logger_default.error("commitMessagePath is required");
|
|
338
|
+
process.exit(1);
|
|
339
|
+
}
|
|
323
340
|
const commitMessage = getCommitMessage(commitMessagePath);
|
|
324
341
|
const isValidCommitMessage = new RegExp(commitMessageRe).test(commitMessage);
|
|
325
342
|
if (!isVersionCommitMessage(commitMessage) && !isValidCommitMessage) {
|
|
@@ -334,6 +351,7 @@ function commitLint(options) {
|
|
|
334
351
|
changelog,
|
|
335
352
|
commitLint,
|
|
336
353
|
getCommitMessage,
|
|
354
|
+
isSameVersion,
|
|
337
355
|
isVersionCommitMessage,
|
|
338
356
|
publish,
|
|
339
357
|
release,
|
package/dist/index.d.cts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
declare function isSameVersion(version?: string): Promise<boolean | undefined>;
|
|
1
2
|
interface PublishCommandOptions {
|
|
2
3
|
preRelease?: boolean;
|
|
3
4
|
checkRemoteVersion?: boolean;
|
|
@@ -11,6 +12,7 @@ interface ReleaseCommandOptions {
|
|
|
11
12
|
skipNpmPublish?: boolean;
|
|
12
13
|
skipChangelog?: boolean;
|
|
13
14
|
skipGitTag?: boolean;
|
|
15
|
+
checkRemoteVersion?: boolean;
|
|
14
16
|
task?(): Promise<void>;
|
|
15
17
|
}
|
|
16
18
|
declare function release(options: ReleaseCommandOptions): Promise<void>;
|
|
@@ -32,4 +34,4 @@ interface CommitLintCommandOptions {
|
|
|
32
34
|
}
|
|
33
35
|
declare function commitLint(options: CommitLintCommandOptions): void;
|
|
34
36
|
|
|
35
|
-
export { COMMIT_MESSAGE_RE, type ChangelogCommandOptions, type CommitLintCommandOptions, type PublishCommandOptions, type ReleaseCommandOptions, changelog, commitLint, getCommitMessage, isVersionCommitMessage, publish, release, updateVersion };
|
|
37
|
+
export { COMMIT_MESSAGE_RE, type ChangelogCommandOptions, type CommitLintCommandOptions, type PublishCommandOptions, type ReleaseCommandOptions, changelog, commitLint, getCommitMessage, isSameVersion, isVersionCommitMessage, publish, release, updateVersion };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
declare function isSameVersion(version?: string): Promise<boolean | undefined>;
|
|
1
2
|
interface PublishCommandOptions {
|
|
2
3
|
preRelease?: boolean;
|
|
3
4
|
checkRemoteVersion?: boolean;
|
|
@@ -11,6 +12,7 @@ interface ReleaseCommandOptions {
|
|
|
11
12
|
skipNpmPublish?: boolean;
|
|
12
13
|
skipChangelog?: boolean;
|
|
13
14
|
skipGitTag?: boolean;
|
|
15
|
+
checkRemoteVersion?: boolean;
|
|
14
16
|
task?(): Promise<void>;
|
|
15
17
|
}
|
|
16
18
|
declare function release(options: ReleaseCommandOptions): Promise<void>;
|
|
@@ -32,4 +34,4 @@ interface CommitLintCommandOptions {
|
|
|
32
34
|
}
|
|
33
35
|
declare function commitLint(options: CommitLintCommandOptions): void;
|
|
34
36
|
|
|
35
|
-
export { COMMIT_MESSAGE_RE, type ChangelogCommandOptions, type CommitLintCommandOptions, type PublishCommandOptions, type ReleaseCommandOptions, changelog, commitLint, getCommitMessage, isVersionCommitMessage, publish, release, updateVersion };
|
|
37
|
+
export { COMMIT_MESSAGE_RE, type ChangelogCommandOptions, type CommitLintCommandOptions, type PublishCommandOptions, type ReleaseCommandOptions, changelog, commitLint, getCommitMessage, isSameVersion, isVersionCommitMessage, publish, release, updateVersion };
|
package/dist/index.js
CHANGED
|
@@ -58,22 +58,30 @@ async function isWorktreeEmpty() {
|
|
|
58
58
|
const ret = await execa("git", ["status", "--porcelain"]);
|
|
59
59
|
return !ret.stdout;
|
|
60
60
|
}
|
|
61
|
+
async function isSameVersion(version) {
|
|
62
|
+
const s = createSpinner2("Check remote version...").start();
|
|
63
|
+
const packageJsones = getPackageJsons();
|
|
64
|
+
const packageJson = packageJsones.find((packageJson2) => !packageJson2.config.private) || packageJsones[0];
|
|
65
|
+
if (packageJson) {
|
|
66
|
+
const { config } = packageJson;
|
|
67
|
+
try {
|
|
68
|
+
await execa("npm", ["view", `${config.name}@${version ?? config.version}`, "version"]);
|
|
69
|
+
s.warn({
|
|
70
|
+
text: `The npm package has a same remote version ${config.version}.`
|
|
71
|
+
});
|
|
72
|
+
return true;
|
|
73
|
+
} catch {
|
|
74
|
+
s.success();
|
|
75
|
+
return false;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
61
79
|
async function publish({ preRelease, checkRemoteVersion, npmTag }) {
|
|
62
80
|
const s = createSpinner2("Publishing all packages").start();
|
|
63
81
|
const args = ["-r", "publish", "--no-git-checks", "--access", "public"];
|
|
64
|
-
if (checkRemoteVersion) {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
const { config } = packageJson;
|
|
68
|
-
try {
|
|
69
|
-
await execa("npm", ["view", `${config.name}@${config.version}`, "version"]);
|
|
70
|
-
s.warn({
|
|
71
|
-
text: `The npm package has a same remote version ${config.version}, publishing automatically skipped.`
|
|
72
|
-
});
|
|
73
|
-
return;
|
|
74
|
-
} catch {
|
|
75
|
-
}
|
|
76
|
-
}
|
|
82
|
+
if (checkRemoteVersion && await isSameVersion()) {
|
|
83
|
+
logger_default.error("publishing automatically skipped.");
|
|
84
|
+
return;
|
|
77
85
|
}
|
|
78
86
|
if (preRelease) {
|
|
79
87
|
args.push("--tag", "alpha");
|
|
@@ -197,6 +205,10 @@ async function release(options) {
|
|
|
197
205
|
return;
|
|
198
206
|
}
|
|
199
207
|
const { isPreRelease, expectVersion } = await getReleaseVersion(currentVersion);
|
|
208
|
+
if (options.checkRemoteVersion && await isSameVersion(expectVersion)) {
|
|
209
|
+
logger_default.error("Please check remote version.");
|
|
210
|
+
return;
|
|
211
|
+
}
|
|
200
212
|
updateVersion(expectVersion);
|
|
201
213
|
if (options.task) {
|
|
202
214
|
await options.task();
|
|
@@ -277,6 +289,10 @@ function commitLint(options) {
|
|
|
277
289
|
errorMessage = ERROR_MESSAGE,
|
|
278
290
|
warningMessage = WARNING_MESSAGE
|
|
279
291
|
} = options;
|
|
292
|
+
if (!commitMessagePath) {
|
|
293
|
+
logger_default.error("commitMessagePath is required");
|
|
294
|
+
process.exit(1);
|
|
295
|
+
}
|
|
280
296
|
const commitMessage = getCommitMessage(commitMessagePath);
|
|
281
297
|
const isValidCommitMessage = new RegExp(commitMessageRe).test(commitMessage);
|
|
282
298
|
if (!isVersionCommitMessage(commitMessage) && !isValidCommitMessage) {
|
|
@@ -290,6 +306,7 @@ export {
|
|
|
290
306
|
changelog,
|
|
291
307
|
commitLint,
|
|
292
308
|
getCommitMessage,
|
|
309
|
+
isSameVersion,
|
|
293
310
|
isVersionCommitMessage,
|
|
294
311
|
publish,
|
|
295
312
|
release,
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@varlet/release",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.2.
|
|
4
|
+
"version": "0.2.10",
|
|
5
5
|
"description": "release all packages and generate changelogs",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"varlet",
|
|
@@ -39,7 +39,6 @@
|
|
|
39
39
|
"*.{ts,tsx,js,vue,less}": "prettier --write",
|
|
40
40
|
"*.{ts,tsx,js,vue}": "eslint --fix"
|
|
41
41
|
},
|
|
42
|
-
"packageManager": "pnpm@8.7.5",
|
|
43
42
|
"engines": {
|
|
44
43
|
"node": ">=16.0.0",
|
|
45
44
|
"pnpm": ">=8.0"
|
|
@@ -72,7 +71,7 @@
|
|
|
72
71
|
"scripts": {
|
|
73
72
|
"dev": "tsup --watch",
|
|
74
73
|
"build": "tsup",
|
|
75
|
-
"release": "pnpm build && node bin/index.js release",
|
|
74
|
+
"release": "pnpm build && node bin/index.js release -c",
|
|
76
75
|
"lint": "eslint --ext .ts,.js",
|
|
77
76
|
"commit-lint": "node bin/index.js commit-lint"
|
|
78
77
|
}
|