@varlet/release 0.0.5 → 0.1.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 +19 -9
- package/README.zh-CN.md +19 -9
- package/bin/index.js +29 -25
- package/dist/index.cjs +21 -12
- package/dist/index.d.cts +9 -3
- package/dist/index.d.ts +9 -3
- package/dist/index.js +21 -12
- package/package.json +3 -2
package/README.md
CHANGED
|
@@ -42,20 +42,20 @@ pnpm add @varlet/release -D
|
|
|
42
42
|
npx vr release
|
|
43
43
|
|
|
44
44
|
# Specify remote name
|
|
45
|
-
npx vr release -r
|
|
45
|
+
npx vr release -r https://github.com/varletjs/varlet-release
|
|
46
46
|
# or
|
|
47
|
-
npx vr release --remote
|
|
47
|
+
npx vr release --remote https://github.com/varletjs/varlet-release
|
|
48
48
|
|
|
49
49
|
# Just generate changelogs
|
|
50
50
|
npx vr changelog
|
|
51
51
|
|
|
52
52
|
# Specify changelog filename
|
|
53
|
-
npx vr changelog -f
|
|
53
|
+
npx vr changelog -f changelog.md
|
|
54
54
|
# or
|
|
55
|
-
npx vr changelog --file
|
|
55
|
+
npx vr changelog --file changelog.md
|
|
56
56
|
|
|
57
57
|
# Lint commit message
|
|
58
|
-
npx vr lint-commit
|
|
58
|
+
npx vr lint-commit -p .git/COMMIT_EDITMSG
|
|
59
59
|
```
|
|
60
60
|
|
|
61
61
|
### Configuration
|
|
@@ -75,9 +75,12 @@ npx vr lint-commit <gitMessagePath>
|
|
|
75
75
|
|
|
76
76
|
#### lint-commit
|
|
77
77
|
|
|
78
|
-
| Params
|
|
79
|
-
|
|
|
80
|
-
| \<
|
|
78
|
+
| Params | Instructions |
|
|
79
|
+
| ------------------------------- | ---------------------------------------------------------------------------------------------------------------------- |
|
|
80
|
+
| -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 |
|
|
81
|
+
| -r --commitMessageRe \<reg\> | Validate the regular of whether the commit message passes |
|
|
82
|
+
| -e --errorMessage \<message\> | Validation failed to display error messages |
|
|
83
|
+
| -w --warningMessage \<message\> | Validation failed to display warning messages |
|
|
81
84
|
|
|
82
85
|
### Custom Handle
|
|
83
86
|
|
|
@@ -117,7 +120,14 @@ interface ChangelogCommandOptions {
|
|
|
117
120
|
releaseCount?: number
|
|
118
121
|
}
|
|
119
122
|
function changelog({ releaseCount, file }?: ChangelogCommandOptions): Promise<void>
|
|
120
|
-
|
|
123
|
+
|
|
124
|
+
interface CommitLintCommandOptions {
|
|
125
|
+
commitMessagePath: string
|
|
126
|
+
commitMessageRe?: string | RegExp
|
|
127
|
+
errorMessage?: string
|
|
128
|
+
warningMessage?: string
|
|
129
|
+
}
|
|
130
|
+
function commitLint(options: CommitLintCommandOptions): void
|
|
121
131
|
```
|
|
122
132
|
|
|
123
133
|
## License
|
package/README.zh-CN.md
CHANGED
|
@@ -42,20 +42,20 @@ pnpm add @varlet/release -D
|
|
|
42
42
|
npx vr release
|
|
43
43
|
|
|
44
44
|
# 指定远程仓库名称
|
|
45
|
-
npx vr release -r
|
|
45
|
+
npx vr release -r https://github.com/varletjs/varlet-release
|
|
46
46
|
# or
|
|
47
|
-
npx vr release --remote
|
|
47
|
+
npx vr release --remote https://github.com/varletjs/varlet-release
|
|
48
48
|
|
|
49
49
|
# 仅生成变更日志
|
|
50
50
|
npx vr changelog
|
|
51
51
|
|
|
52
52
|
# 指定变更日志文件名
|
|
53
|
-
npx vr changelog -f
|
|
53
|
+
npx vr changelog -f changelog.md
|
|
54
54
|
# or
|
|
55
|
-
npx vr changelog --file
|
|
55
|
+
npx vr changelog --file changelog.md
|
|
56
56
|
|
|
57
57
|
# 检测 commit message
|
|
58
|
-
npx vr lint-commit
|
|
58
|
+
npx vr lint-commit -p .git/COMMIT_EDITMSG
|
|
59
59
|
```
|
|
60
60
|
|
|
61
61
|
### 配置
|
|
@@ -75,9 +75,12 @@ npx vr lint-commit <gitMessagePath>
|
|
|
75
75
|
|
|
76
76
|
#### lint-commit
|
|
77
77
|
|
|
78
|
-
| 参数
|
|
79
|
-
|
|
|
80
|
-
| \<
|
|
78
|
+
| 参数 | 说明 |
|
|
79
|
+
| ------------------------------- | --------------------------------------------------------------------------- |
|
|
80
|
+
| -p --commitMessagePath \<path\> | 提交 `git message` 的临时文件路径。`git` 钩子 `commit-msg` 会传递这个参数。 |
|
|
81
|
+
| -r --commitMessageRe \<reg\> | 验证 `commit message` 是否通过的正则 |
|
|
82
|
+
| -e --errorMessage \<message\> | 验证失败展示的错误信息 |
|
|
83
|
+
| -w --warningMessage \<message\> | 验证失败展示的提示信息 |
|
|
81
84
|
|
|
82
85
|
### 自定义处理
|
|
83
86
|
|
|
@@ -117,7 +120,14 @@ interface ChangelogCommandOptions {
|
|
|
117
120
|
releaseCount?: number
|
|
118
121
|
}
|
|
119
122
|
function changelog({ releaseCount, file }?: ChangelogCommandOptions): Promise<void>
|
|
120
|
-
|
|
123
|
+
|
|
124
|
+
interface CommitLintCommandOptions {
|
|
125
|
+
commitMessagePath: string
|
|
126
|
+
commitMessageRe?: string | RegExp
|
|
127
|
+
errorMessage?: string
|
|
128
|
+
warningMessage?: string
|
|
129
|
+
}
|
|
130
|
+
function commitLint(options: CommitLintCommandOptions): void
|
|
121
131
|
```
|
|
122
132
|
|
|
123
133
|
## License
|
package/bin/index.js
CHANGED
|
@@ -1,25 +1,29 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import { release, 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
|
-
.description('Release all packages and generate changelogs')
|
|
11
|
-
.action(async (options) => release(options))
|
|
12
|
-
|
|
13
|
-
program
|
|
14
|
-
.command('changelog')
|
|
15
|
-
.option('-rc --releaseCount <releaseCount>', 'Release count')
|
|
16
|
-
.option('-f --file <file>', 'Changelog filename')
|
|
17
|
-
.description('Generate changelog')
|
|
18
|
-
.action(async (options) => changelog(options))
|
|
19
|
-
|
|
20
|
-
program
|
|
21
|
-
.command('commit-lint
|
|
22
|
-
.
|
|
23
|
-
.
|
|
24
|
-
|
|
25
|
-
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { release, 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
|
+
.description('Release all packages and generate changelogs')
|
|
11
|
+
.action(async (options) => release(options))
|
|
12
|
+
|
|
13
|
+
program
|
|
14
|
+
.command('changelog')
|
|
15
|
+
.option('-rc --releaseCount <releaseCount>', 'Release count')
|
|
16
|
+
.option('-f --file <file>', 'Changelog filename')
|
|
17
|
+
.description('Generate changelog')
|
|
18
|
+
.action(async (options) => changelog(options))
|
|
19
|
+
|
|
20
|
+
program
|
|
21
|
+
.command('commit-lint')
|
|
22
|
+
.option('-p --commitMessagePath <commitMessagePath>', 'Git commit message path')
|
|
23
|
+
.option('-r --commitMessageRe <reg>', 'Validate the regular of whether the commit message passes')
|
|
24
|
+
.option('-e --errorMessage <message>', 'Validation failed to display error messages')
|
|
25
|
+
.option('-w --warningMessage <message>', 'Validation failed to display warning messages')
|
|
26
|
+
.description('Lint commit message')
|
|
27
|
+
.action(async (option) => commitLint(option))
|
|
28
|
+
|
|
29
|
+
program.parse()
|
package/dist/index.cjs
CHANGED
|
@@ -236,17 +236,8 @@ var import_semver2 = __toESM(require("semver"), 1);
|
|
|
236
236
|
var import_fs_extra3 = __toESM(require("fs-extra"), 1);
|
|
237
237
|
var { readFileSync } = import_fs_extra3.default;
|
|
238
238
|
var COMMIT_MESSAGE_RE = /^(revert|fix|feat|docs|perf|test|types|style|build|chore|release|refactor)(\(.+\))?!?: (.|\n)+/;
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
}
|
|
242
|
-
function getCommitMessage(gitMessagePath) {
|
|
243
|
-
return readFileSync(gitMessagePath, "utf-8").trim();
|
|
244
|
-
}
|
|
245
|
-
function commitLint(gitMessagePath) {
|
|
246
|
-
const commitMessage = getCommitMessage(gitMessagePath);
|
|
247
|
-
if (!isVersionCommitMessage(commitMessage) && !COMMIT_MESSAGE_RE.test(commitMessage)) {
|
|
248
|
-
logger_default.error(`Commit message invalid`);
|
|
249
|
-
logger_default.warning(`The rules for commit messages are as follows
|
|
239
|
+
var ERROR_MESSAGE = "Commit message invalid.";
|
|
240
|
+
var WARNING_MESSAGE = `The rules for commit messages are as follows
|
|
250
241
|
|
|
251
242
|
Example:
|
|
252
243
|
|
|
@@ -274,7 +265,25 @@ Allowed types:
|
|
|
274
265
|
- revert
|
|
275
266
|
|
|
276
267
|
Commit message reference: https://docs.google.com/document/d/1QrDFcIiPjSLDn3EL15IJygNPiHORgU1_OOAqWjiDU5Y
|
|
277
|
-
\u53C2\u8003\u962E\u4E00\u5CF0Commit message\u7F16\u5199\u6307\u5357: https://www.ruanyifeng.com/blog/2016/01/commit_message_change_log.html
|
|
268
|
+
\u53C2\u8003\u962E\u4E00\u5CF0Commit message\u7F16\u5199\u6307\u5357: https://www.ruanyifeng.com/blog/2016/01/commit_message_change_log.html`;
|
|
269
|
+
function isVersionCommitMessage(message) {
|
|
270
|
+
return message.startsWith("v") && import_semver2.default.valid(message.slice(1));
|
|
271
|
+
}
|
|
272
|
+
function getCommitMessage(commitMessagePath) {
|
|
273
|
+
return readFileSync(commitMessagePath, "utf-8").trim();
|
|
274
|
+
}
|
|
275
|
+
function commitLint(options) {
|
|
276
|
+
const {
|
|
277
|
+
commitMessagePath,
|
|
278
|
+
commitMessageRe = COMMIT_MESSAGE_RE,
|
|
279
|
+
errorMessage = ERROR_MESSAGE,
|
|
280
|
+
warningMessage = WARNING_MESSAGE
|
|
281
|
+
} = options;
|
|
282
|
+
const commitMessage = getCommitMessage(commitMessagePath);
|
|
283
|
+
const isValidCommitMessage = new RegExp(commitMessageRe).test(commitMessage);
|
|
284
|
+
if (!isVersionCommitMessage(commitMessage) && !isValidCommitMessage) {
|
|
285
|
+
logger_default.error(errorMessage);
|
|
286
|
+
logger_default.warning(warningMessage);
|
|
278
287
|
process.exit(1);
|
|
279
288
|
}
|
|
280
289
|
}
|
package/dist/index.d.cts
CHANGED
|
@@ -12,7 +12,13 @@ declare function changelog({ releaseCount, file }?: ChangelogCommandOptions): Pr
|
|
|
12
12
|
|
|
13
13
|
declare const COMMIT_MESSAGE_RE: RegExp;
|
|
14
14
|
declare function isVersionCommitMessage(message: string): string | false | null;
|
|
15
|
-
declare function getCommitMessage(
|
|
16
|
-
|
|
15
|
+
declare function getCommitMessage(commitMessagePath: string): string;
|
|
16
|
+
interface CommitLintCommandOptions {
|
|
17
|
+
commitMessagePath: string;
|
|
18
|
+
commitMessageRe?: string | RegExp;
|
|
19
|
+
errorMessage?: string;
|
|
20
|
+
warningMessage?: string;
|
|
21
|
+
}
|
|
22
|
+
declare function commitLint(options: CommitLintCommandOptions): void;
|
|
17
23
|
|
|
18
|
-
export { COMMIT_MESSAGE_RE, type ChangelogCommandOptions, type ReleaseCommandOptions, changelog, commitLint, getCommitMessage, isVersionCommitMessage, release };
|
|
24
|
+
export { COMMIT_MESSAGE_RE, type ChangelogCommandOptions, type CommitLintCommandOptions, type ReleaseCommandOptions, changelog, commitLint, getCommitMessage, isVersionCommitMessage, release };
|
package/dist/index.d.ts
CHANGED
|
@@ -12,7 +12,13 @@ declare function changelog({ releaseCount, file }?: ChangelogCommandOptions): Pr
|
|
|
12
12
|
|
|
13
13
|
declare const COMMIT_MESSAGE_RE: RegExp;
|
|
14
14
|
declare function isVersionCommitMessage(message: string): string | false | null;
|
|
15
|
-
declare function getCommitMessage(
|
|
16
|
-
|
|
15
|
+
declare function getCommitMessage(commitMessagePath: string): string;
|
|
16
|
+
interface CommitLintCommandOptions {
|
|
17
|
+
commitMessagePath: string;
|
|
18
|
+
commitMessageRe?: string | RegExp;
|
|
19
|
+
errorMessage?: string;
|
|
20
|
+
warningMessage?: string;
|
|
21
|
+
}
|
|
22
|
+
declare function commitLint(options: CommitLintCommandOptions): void;
|
|
17
23
|
|
|
18
|
-
export { COMMIT_MESSAGE_RE, type ChangelogCommandOptions, type ReleaseCommandOptions, changelog, commitLint, getCommitMessage, isVersionCommitMessage, release };
|
|
24
|
+
export { COMMIT_MESSAGE_RE, type ChangelogCommandOptions, type CommitLintCommandOptions, type ReleaseCommandOptions, changelog, commitLint, getCommitMessage, isVersionCommitMessage, release };
|
package/dist/index.js
CHANGED
|
@@ -195,17 +195,8 @@ import semver2 from "semver";
|
|
|
195
195
|
import fse3 from "fs-extra";
|
|
196
196
|
var { readFileSync } = fse3;
|
|
197
197
|
var COMMIT_MESSAGE_RE = /^(revert|fix|feat|docs|perf|test|types|style|build|chore|release|refactor)(\(.+\))?!?: (.|\n)+/;
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
}
|
|
201
|
-
function getCommitMessage(gitMessagePath) {
|
|
202
|
-
return readFileSync(gitMessagePath, "utf-8").trim();
|
|
203
|
-
}
|
|
204
|
-
function commitLint(gitMessagePath) {
|
|
205
|
-
const commitMessage = getCommitMessage(gitMessagePath);
|
|
206
|
-
if (!isVersionCommitMessage(commitMessage) && !COMMIT_MESSAGE_RE.test(commitMessage)) {
|
|
207
|
-
logger_default.error(`Commit message invalid`);
|
|
208
|
-
logger_default.warning(`The rules for commit messages are as follows
|
|
198
|
+
var ERROR_MESSAGE = "Commit message invalid.";
|
|
199
|
+
var WARNING_MESSAGE = `The rules for commit messages are as follows
|
|
209
200
|
|
|
210
201
|
Example:
|
|
211
202
|
|
|
@@ -233,7 +224,25 @@ Allowed types:
|
|
|
233
224
|
- revert
|
|
234
225
|
|
|
235
226
|
Commit message reference: https://docs.google.com/document/d/1QrDFcIiPjSLDn3EL15IJygNPiHORgU1_OOAqWjiDU5Y
|
|
236
|
-
\u53C2\u8003\u962E\u4E00\u5CF0Commit message\u7F16\u5199\u6307\u5357: https://www.ruanyifeng.com/blog/2016/01/commit_message_change_log.html
|
|
227
|
+
\u53C2\u8003\u962E\u4E00\u5CF0Commit message\u7F16\u5199\u6307\u5357: https://www.ruanyifeng.com/blog/2016/01/commit_message_change_log.html`;
|
|
228
|
+
function isVersionCommitMessage(message) {
|
|
229
|
+
return message.startsWith("v") && semver2.valid(message.slice(1));
|
|
230
|
+
}
|
|
231
|
+
function getCommitMessage(commitMessagePath) {
|
|
232
|
+
return readFileSync(commitMessagePath, "utf-8").trim();
|
|
233
|
+
}
|
|
234
|
+
function commitLint(options) {
|
|
235
|
+
const {
|
|
236
|
+
commitMessagePath,
|
|
237
|
+
commitMessageRe = COMMIT_MESSAGE_RE,
|
|
238
|
+
errorMessage = ERROR_MESSAGE,
|
|
239
|
+
warningMessage = WARNING_MESSAGE
|
|
240
|
+
} = options;
|
|
241
|
+
const commitMessage = getCommitMessage(commitMessagePath);
|
|
242
|
+
const isValidCommitMessage = new RegExp(commitMessageRe).test(commitMessage);
|
|
243
|
+
if (!isVersionCommitMessage(commitMessage) && !isValidCommitMessage) {
|
|
244
|
+
logger_default.error(errorMessage);
|
|
245
|
+
logger_default.warning(warningMessage);
|
|
237
246
|
process.exit(1);
|
|
238
247
|
}
|
|
239
248
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@varlet/release",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0
|
|
4
|
+
"version": "0.1.0",
|
|
5
5
|
"description": "release all packages and generate changelogs",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"varlet",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
],
|
|
34
34
|
"simple-git-hooks": {
|
|
35
35
|
"pre-commit": "pnpm exec lint-staged --allow-empty --concurrent false",
|
|
36
|
-
"commit-msg": "pnpm run commit-lint $1"
|
|
36
|
+
"commit-msg": "pnpm run commit-lint -p $1"
|
|
37
37
|
},
|
|
38
38
|
"lint-staged": {
|
|
39
39
|
"*.{ts,tsx,js,vue,less}": "prettier --write",
|
|
@@ -72,6 +72,7 @@
|
|
|
72
72
|
},
|
|
73
73
|
"scripts": {
|
|
74
74
|
"preinstall": "npx only-allow pnpm",
|
|
75
|
+
"postinstall": "simple-git-hooks",
|
|
75
76
|
"dev": "tsup --watch",
|
|
76
77
|
"build": "tsup",
|
|
77
78
|
"release": "pnpm build && node bin/index.js release",
|