@soybeanjs/cli 1.3.1 → 1.4.0-beta.2
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/dist/index.d.ts +33 -31
- package/dist/index.js +257 -260
- package/package.json +23 -22
- package/dist/index.cjs +0 -329
- package/dist/index.d.cts +0 -36
package/dist/index.d.ts
CHANGED
|
@@ -1,36 +1,38 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { ChangelogOption } from
|
|
2
|
+
import { ChangelogOption } from "@soybeanjs/changelog";
|
|
3
3
|
|
|
4
|
+
//#region src/types/index.d.ts
|
|
4
5
|
interface CliOption {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
6
|
+
/** The project root directory */
|
|
7
|
+
cwd: string;
|
|
8
|
+
/**
|
|
9
|
+
* Cleanup dirs
|
|
10
|
+
*
|
|
11
|
+
* Glob pattern syntax {@link https://github.com/isaacs/minimatch}
|
|
12
|
+
*
|
|
13
|
+
* @default
|
|
14
|
+
* ```json
|
|
15
|
+
* ["** /dist", "** /pnpm-lock.yaml", "** /node_modules", "!node_modules/**"]
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
cleanupDirs: string[];
|
|
19
|
+
/**
|
|
20
|
+
* Npm-check-updates command args
|
|
21
|
+
*
|
|
22
|
+
* @default ['--deep', '-u']
|
|
23
|
+
*/
|
|
24
|
+
ncuCommandArgs: string[];
|
|
25
|
+
/**
|
|
26
|
+
* Options of generate changelog
|
|
27
|
+
*
|
|
28
|
+
* @link https://github.com/soybeanjs/changelog
|
|
29
|
+
*/
|
|
30
|
+
changelogOptions: Partial<ChangelogOption>;
|
|
31
|
+
/** The ignore pattern list of git commit verify */
|
|
32
|
+
gitCommitVerifyIgnores: RegExp[];
|
|
32
33
|
}
|
|
33
|
-
|
|
34
|
+
//#endregion
|
|
35
|
+
//#region src/index.d.ts
|
|
34
36
|
declare function defineConfig(config?: Partial<CliOption>): Partial<CliOption> | undefined;
|
|
35
|
-
|
|
36
|
-
export { type CliOption, defineConfig };
|
|
37
|
+
//#endregion
|
|
38
|
+
export { type CliOption, defineConfig };
|
package/dist/index.js
CHANGED
|
@@ -1,295 +1,292 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
// src/index.ts
|
|
4
2
|
import cac from "cac";
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
var version = "1.3.1";
|
|
8
|
-
|
|
9
|
-
// src/command/git-commit.ts
|
|
10
|
-
import path from "path";
|
|
11
|
-
import { readFileSync } from "fs";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import { readFileSync } from "node:fs";
|
|
12
5
|
import { prompt } from "enquirer";
|
|
6
|
+
import { bgRed, green, red, yellow } from "kolorist";
|
|
7
|
+
import { rimraf } from "rimraf";
|
|
8
|
+
import { generateChangelog, generateTotalChangelog } from "@soybeanjs/changelog";
|
|
9
|
+
import { versionBump } from "bumpp";
|
|
10
|
+
import process from "node:process";
|
|
11
|
+
import { loadConfig } from "c12";
|
|
12
|
+
|
|
13
|
+
//#region package.json
|
|
14
|
+
var version = "1.4.0-beta.2";
|
|
13
15
|
|
|
14
|
-
|
|
16
|
+
//#endregion
|
|
17
|
+
//#region src/shared/index.ts
|
|
15
18
|
async function execCommand(cmd, args, options) {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
+
const { execa } = await import("execa");
|
|
20
|
+
const res = await execa(cmd, args, options);
|
|
21
|
+
return (res?.stdout)?.trim() || "";
|
|
19
22
|
}
|
|
20
23
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
["other", "other changes"]
|
|
93
|
-
],
|
|
94
|
-
gitCommitVerify: `${bgRed(" ERROR ")} ${red("git commit message must match the Conventional Commits standard!")}
|
|
95
|
-
|
|
96
|
-
${green(
|
|
97
|
-
"Recommended to use the command `pnpm commit` to generate Conventional Commits compliant commit information.\nGet more info about Conventional Commits, follow this link: https://conventionalcommits.org"
|
|
98
|
-
)}`
|
|
99
|
-
}
|
|
24
|
+
//#endregion
|
|
25
|
+
//#region src/locales/index.ts
|
|
26
|
+
const locales = {
|
|
27
|
+
"zh-cn": {
|
|
28
|
+
gitCommitMessages: {
|
|
29
|
+
types: "请选择提交类型",
|
|
30
|
+
scopes: "请选择提交范围",
|
|
31
|
+
description: `请输入描述信息(${yellow("!")}开头表示破坏性改动`
|
|
32
|
+
},
|
|
33
|
+
gitCommitTypes: [
|
|
34
|
+
["feat", "新功能"],
|
|
35
|
+
["fix", "修复Bug"],
|
|
36
|
+
["docs", "只涉及文档更新"],
|
|
37
|
+
["style", "修改代码风格,不影响代码含义的变更"],
|
|
38
|
+
["refactor", "代码重构,既不修复 bug 也不添加功能的代码变更"],
|
|
39
|
+
["perf", "可提高性能的代码更改"],
|
|
40
|
+
["optimize", "优化代码质量的代码更改"],
|
|
41
|
+
["test", "添加缺失的测试或更正现有测试"],
|
|
42
|
+
["build", "影响构建系统或外部依赖项的更改"],
|
|
43
|
+
["ci", "对 CI 配置文件和脚本的更改"],
|
|
44
|
+
["chore", "没有修改src或测试文件的其他变更"],
|
|
45
|
+
["revert", "还原先前的提交"]
|
|
46
|
+
],
|
|
47
|
+
gitCommitScopes: [
|
|
48
|
+
["projects", "项目"],
|
|
49
|
+
["packages", "包"],
|
|
50
|
+
["components", "组件"],
|
|
51
|
+
["hooks", "钩子函数"],
|
|
52
|
+
["utils", "工具函数"],
|
|
53
|
+
["types", "TS类型声明"],
|
|
54
|
+
["styles", "代码风格"],
|
|
55
|
+
["deps", "项目依赖"],
|
|
56
|
+
["release", "发布项目新版本"],
|
|
57
|
+
["other", "其他的变更"]
|
|
58
|
+
],
|
|
59
|
+
gitCommitVerify: `${bgRed(" 错误 ")} ${red("git 提交信息必须符合 Conventional Commits 标准!")}\n\n${green("推荐使用命令 `pnpm commit` 生成符合 Conventional Commits 标准的提交信息。\n获取有关 Conventional Commits 的更多信息,请访问此链接: https://conventionalcommits.org")}`
|
|
60
|
+
},
|
|
61
|
+
"en-us": {
|
|
62
|
+
gitCommitMessages: {
|
|
63
|
+
types: "Please select a type",
|
|
64
|
+
scopes: "Please select a scope",
|
|
65
|
+
description: `Please enter a description (add prefix ${yellow("!")} to indicate breaking change)`
|
|
66
|
+
},
|
|
67
|
+
gitCommitTypes: [
|
|
68
|
+
["feat", "A new feature"],
|
|
69
|
+
["fix", "A bug fix"],
|
|
70
|
+
["docs", "Documentation only changes"],
|
|
71
|
+
["style", "Changes that do not affect the meaning of the code"],
|
|
72
|
+
["refactor", "A code change that neither fixes a bug nor adds a feature"],
|
|
73
|
+
["perf", "A code change that improves performance"],
|
|
74
|
+
["optimize", "A code change that optimizes code quality"],
|
|
75
|
+
["test", "Adding missing tests or correcting existing tests"],
|
|
76
|
+
["build", "Changes that affect the build system or external dependencies"],
|
|
77
|
+
["ci", "Changes to our CI configuration files and scripts"],
|
|
78
|
+
["chore", "Other changes that don't modify src or test files"],
|
|
79
|
+
["revert", "Reverts a previous commit"]
|
|
80
|
+
],
|
|
81
|
+
gitCommitScopes: [
|
|
82
|
+
["projects", "project"],
|
|
83
|
+
["packages", "packages"],
|
|
84
|
+
["components", "components"],
|
|
85
|
+
["hooks", "hook functions"],
|
|
86
|
+
["utils", "utils functions"],
|
|
87
|
+
["types", "TS declaration"],
|
|
88
|
+
["styles", "style"],
|
|
89
|
+
["deps", "project dependencies"],
|
|
90
|
+
["release", "release project"],
|
|
91
|
+
["other", "other changes"]
|
|
92
|
+
],
|
|
93
|
+
gitCommitVerify: `${bgRed(" ERROR ")} ${red("git commit message must match the Conventional Commits standard!")}\n\n${green("Recommended to use the command `pnpm commit` to generate Conventional Commits compliant commit information.\nGet more info about Conventional Commits, follow this link: https://conventionalcommits.org")}`
|
|
94
|
+
}
|
|
100
95
|
};
|
|
101
96
|
|
|
102
|
-
|
|
97
|
+
//#endregion
|
|
98
|
+
//#region src/command/git-commit.ts
|
|
99
|
+
/**
|
|
100
|
+
* Git commit with Conventional Commits standard
|
|
101
|
+
*
|
|
102
|
+
* @param lang
|
|
103
|
+
*/
|
|
103
104
|
async function gitCommit(lang = "en-us") {
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
105
|
+
const { gitCommitMessages, gitCommitTypes, gitCommitScopes } = locales[lang];
|
|
106
|
+
const typesChoices = gitCommitTypes.map(([value, msg]) => {
|
|
107
|
+
const nameWithSuffix = `${value}:`;
|
|
108
|
+
const message = `${nameWithSuffix.padEnd(12)}${msg}`;
|
|
109
|
+
return {
|
|
110
|
+
name: value,
|
|
111
|
+
message
|
|
112
|
+
};
|
|
113
|
+
});
|
|
114
|
+
const scopesChoices = gitCommitScopes.map(([value, msg]) => ({
|
|
115
|
+
name: value,
|
|
116
|
+
message: `${value.padEnd(30)} (${msg})`
|
|
117
|
+
}));
|
|
118
|
+
const result = await prompt([
|
|
119
|
+
{
|
|
120
|
+
name: "types",
|
|
121
|
+
type: "select",
|
|
122
|
+
message: gitCommitMessages.types,
|
|
123
|
+
choices: typesChoices
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
name: "scopes",
|
|
127
|
+
type: "select",
|
|
128
|
+
message: gitCommitMessages.scopes,
|
|
129
|
+
choices: scopesChoices
|
|
130
|
+
},
|
|
131
|
+
{
|
|
132
|
+
name: "description",
|
|
133
|
+
type: "text",
|
|
134
|
+
message: gitCommitMessages.description
|
|
135
|
+
}
|
|
136
|
+
]);
|
|
137
|
+
const breaking = result.description.startsWith("!") ? "!" : "";
|
|
138
|
+
const description = result.description.replace(/^!/, "").trim();
|
|
139
|
+
const commitMsg = `${result.types}(${result.scopes})${breaking}: ${description}`;
|
|
140
|
+
await execCommand("git", [
|
|
141
|
+
"commit",
|
|
142
|
+
"-m",
|
|
143
|
+
commitMsg
|
|
144
|
+
], { stdio: "inherit" });
|
|
140
145
|
}
|
|
146
|
+
/** Git commit message verify */
|
|
141
147
|
async function gitCommitVerify(lang = "en-us", ignores = []) {
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
148
|
+
const gitPath = await execCommand("git", ["rev-parse", "--show-toplevel"]);
|
|
149
|
+
const gitMsgPath = path.join(gitPath, ".git", "COMMIT_EDITMSG");
|
|
150
|
+
const commitMsg = readFileSync(gitMsgPath, "utf8").trim();
|
|
151
|
+
if (ignores.some((regExp) => regExp.test(commitMsg))) return;
|
|
152
|
+
const REG_EXP = /(?<type>[a-z]+)(?:\((?<scope>.+)\))?(?<breaking>!)?: (?<description>.+)/i;
|
|
153
|
+
if (!REG_EXP.test(commitMsg)) {
|
|
154
|
+
const errorMsg = locales[lang].gitCommitVerify;
|
|
155
|
+
throw new Error(errorMsg);
|
|
156
|
+
}
|
|
151
157
|
}
|
|
152
158
|
|
|
153
|
-
|
|
154
|
-
|
|
159
|
+
//#endregion
|
|
160
|
+
//#region src/command/cleanup.ts
|
|
155
161
|
async function cleanup(paths) {
|
|
156
|
-
|
|
162
|
+
await rimraf(paths, { glob: true });
|
|
157
163
|
}
|
|
158
164
|
|
|
159
|
-
|
|
165
|
+
//#endregion
|
|
166
|
+
//#region src/command/ncu.ts
|
|
160
167
|
async function ncu(args = ["--deep", "-u"]) {
|
|
161
|
-
|
|
168
|
+
execCommand("npx", ["ncu", ...args], { stdio: "inherit" });
|
|
162
169
|
}
|
|
163
170
|
|
|
164
|
-
|
|
165
|
-
|
|
171
|
+
//#endregion
|
|
172
|
+
//#region src/command/changelog.ts
|
|
166
173
|
async function genChangelog(options, total = false) {
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
} else {
|
|
170
|
-
await generateChangelog(options);
|
|
171
|
-
}
|
|
174
|
+
if (total) await generateTotalChangelog(options);
|
|
175
|
+
else await generateChangelog(options);
|
|
172
176
|
}
|
|
173
177
|
|
|
174
|
-
|
|
175
|
-
|
|
178
|
+
//#endregion
|
|
179
|
+
//#region src/command/release.ts
|
|
176
180
|
async function release(execute = "npx soy changelog", push = true) {
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
181
|
+
await versionBump({
|
|
182
|
+
files: ["**/package.json", "!**/node_modules"],
|
|
183
|
+
execute,
|
|
184
|
+
all: true,
|
|
185
|
+
tag: true,
|
|
186
|
+
commit: "chore(projects): release v%s",
|
|
187
|
+
push
|
|
188
|
+
});
|
|
185
189
|
}
|
|
186
190
|
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
]
|
|
191
|
+
//#endregion
|
|
192
|
+
//#region src/config/index.ts
|
|
193
|
+
const defaultOptions = {
|
|
194
|
+
cwd: process.cwd(),
|
|
195
|
+
cleanupDirs: [
|
|
196
|
+
"**/dist",
|
|
197
|
+
"**/package-lock.json",
|
|
198
|
+
"**/yarn.lock",
|
|
199
|
+
"**/pnpm-lock.yaml",
|
|
200
|
+
"**/node_modules",
|
|
201
|
+
"!node_modules/**"
|
|
202
|
+
],
|
|
203
|
+
ncuCommandArgs: ["--deep", "-u"],
|
|
204
|
+
changelogOptions: {},
|
|
205
|
+
gitCommitVerifyIgnores: [
|
|
206
|
+
/^((Merge pull request)|(Merge (.*?) into (.*?)|(Merge branch (.*?)))(?:\r?\n)*$)/m,
|
|
207
|
+
/^(Merge tag (.*?))(?:\r?\n)*$/m,
|
|
208
|
+
/^(R|r)evert (.*)/,
|
|
209
|
+
/^(amend|fixup|squash)!/,
|
|
210
|
+
/^(Merged (.*?)(in|into) (.*)|Merged PR (.*): (.*))/,
|
|
211
|
+
/^Merge remote-tracking branch(\s*)(.*)/,
|
|
212
|
+
/^Automatic merge(.*)/,
|
|
213
|
+
/^Auto-merged (.*?) into (.*)/
|
|
214
|
+
]
|
|
212
215
|
};
|
|
213
216
|
async function loadCliOptions(overrides, cwd = process.cwd()) {
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
217
|
+
const { config } = await loadConfig({
|
|
218
|
+
name: "soybean",
|
|
219
|
+
defaults: defaultOptions,
|
|
220
|
+
overrides,
|
|
221
|
+
cwd,
|
|
222
|
+
packageJson: true
|
|
223
|
+
});
|
|
224
|
+
return config;
|
|
222
225
|
}
|
|
223
226
|
|
|
224
|
-
|
|
227
|
+
//#endregion
|
|
228
|
+
//#region src/index.ts
|
|
225
229
|
async function setupCli() {
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
}
|
|
282
|
-
}
|
|
283
|
-
};
|
|
284
|
-
for await (const [command, { desc, action }] of Object.entries(commands)) {
|
|
285
|
-
cli.command(command, desc).action(action);
|
|
286
|
-
}
|
|
287
|
-
cli.parse();
|
|
230
|
+
const cliOptions = await loadCliOptions();
|
|
231
|
+
const cli = cac("soybean");
|
|
232
|
+
cli.version(version).option("-e, --execute [command]", "Execute additional command after bumping and before git commit. Defaults to 'npx soy changelog'").option("-p, --push", "Indicates whether to push the git commit and tag").option("-t, --total", "Generate changelog by total tags").option("-c, --cleanupDir <dir>", "The glob pattern of dirs to cleanup, If not set, it will use the default value, Multiple values use \",\" to separate them").option("-l, --lang <lang>", "display lang of cli", {
|
|
233
|
+
default: "en-us",
|
|
234
|
+
type: [String]
|
|
235
|
+
}).help();
|
|
236
|
+
const commands = {
|
|
237
|
+
cleanup: {
|
|
238
|
+
desc: "delete dirs: node_modules, dist, etc.",
|
|
239
|
+
action: async (args) => {
|
|
240
|
+
const cleanupDirs = args?.cleanupDir?.split(",") || [];
|
|
241
|
+
const formattedDirs = cleanupDirs.map((dir) => dir.trim()).filter(Boolean);
|
|
242
|
+
if (formattedDirs.length) cliOptions.cleanupDirs = formattedDirs;
|
|
243
|
+
await cleanup(cliOptions.cleanupDirs);
|
|
244
|
+
}
|
|
245
|
+
},
|
|
246
|
+
ncu: {
|
|
247
|
+
desc: "npm-check-updates, it can update package.json dependencies to the latest version",
|
|
248
|
+
action: async () => {
|
|
249
|
+
await ncu(cliOptions.ncuCommandArgs);
|
|
250
|
+
}
|
|
251
|
+
},
|
|
252
|
+
"update-pkg": {
|
|
253
|
+
desc: "equal to command \"ncu\"",
|
|
254
|
+
action: async () => {
|
|
255
|
+
await ncu();
|
|
256
|
+
}
|
|
257
|
+
},
|
|
258
|
+
"git-commit": {
|
|
259
|
+
desc: "git commit, generate commit message which match Conventional Commits standard",
|
|
260
|
+
action: async (args) => {
|
|
261
|
+
await gitCommit(args?.lang);
|
|
262
|
+
}
|
|
263
|
+
},
|
|
264
|
+
"git-commit-verify": {
|
|
265
|
+
desc: "verify git commit message, make sure it match Conventional Commits standard",
|
|
266
|
+
action: async (args) => {
|
|
267
|
+
await gitCommitVerify(args?.lang, cliOptions.gitCommitVerifyIgnores);
|
|
268
|
+
}
|
|
269
|
+
},
|
|
270
|
+
changelog: {
|
|
271
|
+
desc: "generate changelog",
|
|
272
|
+
action: async (args) => {
|
|
273
|
+
await genChangelog(cliOptions.changelogOptions, args?.total);
|
|
274
|
+
}
|
|
275
|
+
},
|
|
276
|
+
release: {
|
|
277
|
+
desc: "release: update version, generate changelog, commit code",
|
|
278
|
+
action: async (args) => {
|
|
279
|
+
await release(args?.execute, args?.push);
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
};
|
|
283
|
+
for await (const [command, { desc, action }] of Object.entries(commands)) cli.command(command, desc).action(action);
|
|
284
|
+
cli.parse();
|
|
288
285
|
}
|
|
289
286
|
setupCli();
|
|
290
287
|
function defineConfig(config) {
|
|
291
|
-
|
|
288
|
+
return config;
|
|
292
289
|
}
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
};
|
|
290
|
+
|
|
291
|
+
//#endregion
|
|
292
|
+
export { defineConfig };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@soybeanjs/cli",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.4.0-beta.2",
|
|
5
5
|
"description": "SoybeanJS's command line tools",
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "Soybean",
|
|
@@ -21,46 +21,47 @@
|
|
|
21
21
|
},
|
|
22
22
|
"bin": {
|
|
23
23
|
"soybean": "dist/index.js",
|
|
24
|
-
"soy": "dist/index.
|
|
24
|
+
"soy": "dist/index.js"
|
|
25
25
|
},
|
|
26
26
|
"exports": {
|
|
27
27
|
".": {
|
|
28
28
|
"types": "./dist/index.d.ts",
|
|
29
29
|
"import": "./dist/index.js",
|
|
30
|
-
"require": "./dist/index.
|
|
30
|
+
"require": "./dist/index.js"
|
|
31
31
|
}
|
|
32
32
|
},
|
|
33
|
-
"main": "dist/index.
|
|
34
|
-
"module": "dist/index.js",
|
|
35
|
-
"types": "dist/index.d.ts",
|
|
33
|
+
"main": "./dist/index.js",
|
|
34
|
+
"module": "./dist/index.js",
|
|
35
|
+
"types": "./dist/index.d.ts",
|
|
36
36
|
"files": [
|
|
37
37
|
"dist"
|
|
38
38
|
],
|
|
39
39
|
"dependencies": {
|
|
40
40
|
"@soybeanjs/changelog": "0.3.24",
|
|
41
|
-
"bumpp": "10.
|
|
42
|
-
"c12": "3.0
|
|
41
|
+
"bumpp": "10.2.3",
|
|
42
|
+
"c12": "3.2.0",
|
|
43
43
|
"cac": "6.7.14",
|
|
44
44
|
"consola": "3.4.2",
|
|
45
45
|
"enquirer": "2.4.1",
|
|
46
46
|
"execa": "9.6.0",
|
|
47
47
|
"kolorist": "1.8.0",
|
|
48
|
-
"npm-check-updates": "18.0.
|
|
49
|
-
"
|
|
48
|
+
"npm-check-updates": "18.0.3",
|
|
49
|
+
"picomatch": "4.0.3",
|
|
50
|
+
"rimraf": "6.0.1",
|
|
51
|
+
"tinyglobby": "0.2.14"
|
|
50
52
|
},
|
|
51
53
|
"devDependencies": {
|
|
52
54
|
"@soybeanjs/cli": "link:",
|
|
53
|
-
"@soybeanjs/eslint-config": "1.
|
|
54
|
-
"@types/node": "
|
|
55
|
-
"eslint": "9.
|
|
56
|
-
"eslint-plugin-vue": "10.
|
|
57
|
-
"
|
|
58
|
-
"
|
|
59
|
-
"
|
|
60
|
-
"
|
|
61
|
-
"
|
|
62
|
-
"
|
|
63
|
-
"vue-eslint-parser": "10.1.3"
|
|
55
|
+
"@soybeanjs/eslint-config": "1.7.1",
|
|
56
|
+
"@types/node": "24.3.0",
|
|
57
|
+
"eslint": "9.34.0",
|
|
58
|
+
"eslint-plugin-vue": "10.4.0",
|
|
59
|
+
"lint-staged": "16.1.5",
|
|
60
|
+
"simple-git-hooks": "2.13.1",
|
|
61
|
+
"tsdown": "0.14.2",
|
|
62
|
+
"tsx": "4.20.5",
|
|
63
|
+
"typescript": "5.9.2",
|
|
64
|
+
"vue-eslint-parser": "10.2.0"
|
|
64
65
|
},
|
|
65
66
|
"simple-git-hooks": {
|
|
66
67
|
"commit-msg": "pnpm soy git-commit-verify",
|
|
@@ -70,7 +71,7 @@
|
|
|
70
71
|
"*": "eslint --fix"
|
|
71
72
|
},
|
|
72
73
|
"scripts": {
|
|
73
|
-
"build": "
|
|
74
|
+
"build": "tsdown && pnpm build-pkg",
|
|
74
75
|
"build-pkg": "pnpm -r --filter='./packages/*' run build",
|
|
75
76
|
"cleanup": "soy cleanup",
|
|
76
77
|
"commit": "soy git-commit",
|
package/dist/index.cjs
DELETED
|
@@ -1,329 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
"use strict";
|
|
3
|
-
var __create = Object.create;
|
|
4
|
-
var __defProp = Object.defineProperty;
|
|
5
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
8
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
-
var __export = (target, all) => {
|
|
10
|
-
for (var name in all)
|
|
11
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
12
|
-
};
|
|
13
|
-
var __copyProps = (to, from, except, desc) => {
|
|
14
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
-
for (let key of __getOwnPropNames(from))
|
|
16
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
17
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
18
|
-
}
|
|
19
|
-
return to;
|
|
20
|
-
};
|
|
21
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
22
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
23
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
24
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
25
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
26
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
27
|
-
mod
|
|
28
|
-
));
|
|
29
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
30
|
-
|
|
31
|
-
// src/index.ts
|
|
32
|
-
var index_exports = {};
|
|
33
|
-
__export(index_exports, {
|
|
34
|
-
defineConfig: () => defineConfig
|
|
35
|
-
});
|
|
36
|
-
module.exports = __toCommonJS(index_exports);
|
|
37
|
-
var import_cac = __toESM(require("cac"), 1);
|
|
38
|
-
|
|
39
|
-
// package.json
|
|
40
|
-
var version = "1.3.1";
|
|
41
|
-
|
|
42
|
-
// src/command/git-commit.ts
|
|
43
|
-
var import_node_path = __toESM(require("path"), 1);
|
|
44
|
-
var import_node_fs = require("fs");
|
|
45
|
-
var import_enquirer = require("enquirer");
|
|
46
|
-
|
|
47
|
-
// src/shared/index.ts
|
|
48
|
-
async function execCommand(cmd, args, options) {
|
|
49
|
-
const { execa } = await import("execa");
|
|
50
|
-
const res = await execa(cmd, args, options);
|
|
51
|
-
return res?.stdout?.trim() || "";
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
// src/locales/index.ts
|
|
55
|
-
var import_kolorist = require("kolorist");
|
|
56
|
-
var locales = {
|
|
57
|
-
"zh-cn": {
|
|
58
|
-
gitCommitMessages: {
|
|
59
|
-
types: "\u8BF7\u9009\u62E9\u63D0\u4EA4\u7C7B\u578B",
|
|
60
|
-
scopes: "\u8BF7\u9009\u62E9\u63D0\u4EA4\u8303\u56F4",
|
|
61
|
-
description: `\u8BF7\u8F93\u5165\u63CF\u8FF0\u4FE1\u606F\uFF08${(0, import_kolorist.yellow)("!")}\u5F00\u5934\u8868\u793A\u7834\u574F\u6027\u6539\u52A8`
|
|
62
|
-
},
|
|
63
|
-
gitCommitTypes: [
|
|
64
|
-
["feat", "\u65B0\u529F\u80FD"],
|
|
65
|
-
["fix", "\u4FEE\u590DBug"],
|
|
66
|
-
["docs", "\u53EA\u6D89\u53CA\u6587\u6863\u66F4\u65B0"],
|
|
67
|
-
["style", "\u4FEE\u6539\u4EE3\u7801\u98CE\u683C\uFF0C\u4E0D\u5F71\u54CD\u4EE3\u7801\u542B\u4E49\u7684\u53D8\u66F4"],
|
|
68
|
-
["refactor", "\u4EE3\u7801\u91CD\u6784\uFF0C\u65E2\u4E0D\u4FEE\u590D bug \u4E5F\u4E0D\u6DFB\u52A0\u529F\u80FD\u7684\u4EE3\u7801\u53D8\u66F4"],
|
|
69
|
-
["perf", "\u53EF\u63D0\u9AD8\u6027\u80FD\u7684\u4EE3\u7801\u66F4\u6539"],
|
|
70
|
-
["optimize", "\u4F18\u5316\u4EE3\u7801\u8D28\u91CF\u7684\u4EE3\u7801\u66F4\u6539"],
|
|
71
|
-
["test", "\u6DFB\u52A0\u7F3A\u5931\u7684\u6D4B\u8BD5\u6216\u66F4\u6B63\u73B0\u6709\u6D4B\u8BD5"],
|
|
72
|
-
["build", "\u5F71\u54CD\u6784\u5EFA\u7CFB\u7EDF\u6216\u5916\u90E8\u4F9D\u8D56\u9879\u7684\u66F4\u6539"],
|
|
73
|
-
["ci", "\u5BF9 CI \u914D\u7F6E\u6587\u4EF6\u548C\u811A\u672C\u7684\u66F4\u6539"],
|
|
74
|
-
["chore", "\u6CA1\u6709\u4FEE\u6539src\u6216\u6D4B\u8BD5\u6587\u4EF6\u7684\u5176\u4ED6\u53D8\u66F4"],
|
|
75
|
-
["revert", "\u8FD8\u539F\u5148\u524D\u7684\u63D0\u4EA4"]
|
|
76
|
-
],
|
|
77
|
-
gitCommitScopes: [
|
|
78
|
-
["projects", "\u9879\u76EE"],
|
|
79
|
-
["packages", "\u5305"],
|
|
80
|
-
["components", "\u7EC4\u4EF6"],
|
|
81
|
-
["hooks", "\u94A9\u5B50\u51FD\u6570"],
|
|
82
|
-
["utils", "\u5DE5\u5177\u51FD\u6570"],
|
|
83
|
-
["types", "TS\u7C7B\u578B\u58F0\u660E"],
|
|
84
|
-
["styles", "\u4EE3\u7801\u98CE\u683C"],
|
|
85
|
-
["deps", "\u9879\u76EE\u4F9D\u8D56"],
|
|
86
|
-
["release", "\u53D1\u5E03\u9879\u76EE\u65B0\u7248\u672C"],
|
|
87
|
-
["other", "\u5176\u4ED6\u7684\u53D8\u66F4"]
|
|
88
|
-
],
|
|
89
|
-
gitCommitVerify: `${(0, import_kolorist.bgRed)(" \u9519\u8BEF ")} ${(0, import_kolorist.red)("git \u63D0\u4EA4\u4FE1\u606F\u5FC5\u987B\u7B26\u5408 Conventional Commits \u6807\u51C6!")}
|
|
90
|
-
|
|
91
|
-
${(0, import_kolorist.green)(
|
|
92
|
-
"\u63A8\u8350\u4F7F\u7528\u547D\u4EE4 `pnpm commit` \u751F\u6210\u7B26\u5408 Conventional Commits \u6807\u51C6\u7684\u63D0\u4EA4\u4FE1\u606F\u3002\n\u83B7\u53D6\u6709\u5173 Conventional Commits \u7684\u66F4\u591A\u4FE1\u606F\uFF0C\u8BF7\u8BBF\u95EE\u6B64\u94FE\u63A5: https://conventionalcommits.org"
|
|
93
|
-
)}`
|
|
94
|
-
},
|
|
95
|
-
"en-us": {
|
|
96
|
-
gitCommitMessages: {
|
|
97
|
-
types: "Please select a type",
|
|
98
|
-
scopes: "Please select a scope",
|
|
99
|
-
description: `Please enter a description (add prefix ${(0, import_kolorist.yellow)("!")} to indicate breaking change)`
|
|
100
|
-
},
|
|
101
|
-
gitCommitTypes: [
|
|
102
|
-
["feat", "A new feature"],
|
|
103
|
-
["fix", "A bug fix"],
|
|
104
|
-
["docs", "Documentation only changes"],
|
|
105
|
-
["style", "Changes that do not affect the meaning of the code"],
|
|
106
|
-
["refactor", "A code change that neither fixes a bug nor adds a feature"],
|
|
107
|
-
["perf", "A code change that improves performance"],
|
|
108
|
-
["optimize", "A code change that optimizes code quality"],
|
|
109
|
-
["test", "Adding missing tests or correcting existing tests"],
|
|
110
|
-
["build", "Changes that affect the build system or external dependencies"],
|
|
111
|
-
["ci", "Changes to our CI configuration files and scripts"],
|
|
112
|
-
["chore", "Other changes that don't modify src or test files"],
|
|
113
|
-
["revert", "Reverts a previous commit"]
|
|
114
|
-
],
|
|
115
|
-
gitCommitScopes: [
|
|
116
|
-
["projects", "project"],
|
|
117
|
-
["packages", "packages"],
|
|
118
|
-
["components", "components"],
|
|
119
|
-
["hooks", "hook functions"],
|
|
120
|
-
["utils", "utils functions"],
|
|
121
|
-
["types", "TS declaration"],
|
|
122
|
-
["styles", "style"],
|
|
123
|
-
["deps", "project dependencies"],
|
|
124
|
-
["release", "release project"],
|
|
125
|
-
["other", "other changes"]
|
|
126
|
-
],
|
|
127
|
-
gitCommitVerify: `${(0, import_kolorist.bgRed)(" ERROR ")} ${(0, import_kolorist.red)("git commit message must match the Conventional Commits standard!")}
|
|
128
|
-
|
|
129
|
-
${(0, import_kolorist.green)(
|
|
130
|
-
"Recommended to use the command `pnpm commit` to generate Conventional Commits compliant commit information.\nGet more info about Conventional Commits, follow this link: https://conventionalcommits.org"
|
|
131
|
-
)}`
|
|
132
|
-
}
|
|
133
|
-
};
|
|
134
|
-
|
|
135
|
-
// src/command/git-commit.ts
|
|
136
|
-
async function gitCommit(lang = "en-us") {
|
|
137
|
-
const { gitCommitMessages, gitCommitTypes, gitCommitScopes } = locales[lang];
|
|
138
|
-
const typesChoices = gitCommitTypes.map(([value, msg]) => {
|
|
139
|
-
const nameWithSuffix = `${value}:`;
|
|
140
|
-
const message = `${nameWithSuffix.padEnd(12)}${msg}`;
|
|
141
|
-
return {
|
|
142
|
-
name: value,
|
|
143
|
-
message
|
|
144
|
-
};
|
|
145
|
-
});
|
|
146
|
-
const scopesChoices = gitCommitScopes.map(([value, msg]) => ({
|
|
147
|
-
name: value,
|
|
148
|
-
message: `${value.padEnd(30)} (${msg})`
|
|
149
|
-
}));
|
|
150
|
-
const result = await (0, import_enquirer.prompt)([
|
|
151
|
-
{
|
|
152
|
-
name: "types",
|
|
153
|
-
type: "select",
|
|
154
|
-
message: gitCommitMessages.types,
|
|
155
|
-
choices: typesChoices
|
|
156
|
-
},
|
|
157
|
-
{
|
|
158
|
-
name: "scopes",
|
|
159
|
-
type: "select",
|
|
160
|
-
message: gitCommitMessages.scopes,
|
|
161
|
-
choices: scopesChoices
|
|
162
|
-
},
|
|
163
|
-
{
|
|
164
|
-
name: "description",
|
|
165
|
-
type: "text",
|
|
166
|
-
message: gitCommitMessages.description
|
|
167
|
-
}
|
|
168
|
-
]);
|
|
169
|
-
const breaking = result.description.startsWith("!") ? "!" : "";
|
|
170
|
-
const description = result.description.replace(/^!/, "").trim();
|
|
171
|
-
const commitMsg = `${result.types}(${result.scopes})${breaking}: ${description}`;
|
|
172
|
-
await execCommand("git", ["commit", "-m", commitMsg], { stdio: "inherit" });
|
|
173
|
-
}
|
|
174
|
-
async function gitCommitVerify(lang = "en-us", ignores = []) {
|
|
175
|
-
const gitPath = await execCommand("git", ["rev-parse", "--show-toplevel"]);
|
|
176
|
-
const gitMsgPath = import_node_path.default.join(gitPath, ".git", "COMMIT_EDITMSG");
|
|
177
|
-
const commitMsg = (0, import_node_fs.readFileSync)(gitMsgPath, "utf8").trim();
|
|
178
|
-
if (ignores.some((regExp) => regExp.test(commitMsg))) return;
|
|
179
|
-
const REG_EXP = /(?<type>[a-z]+)(?:\((?<scope>.+)\))?(?<breaking>!)?: (?<description>.+)/i;
|
|
180
|
-
if (!REG_EXP.test(commitMsg)) {
|
|
181
|
-
const errorMsg = locales[lang].gitCommitVerify;
|
|
182
|
-
throw new Error(errorMsg);
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
// src/command/cleanup.ts
|
|
187
|
-
var import_rimraf = require("rimraf");
|
|
188
|
-
async function cleanup(paths) {
|
|
189
|
-
await (0, import_rimraf.rimraf)(paths, { glob: true });
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
// src/command/ncu.ts
|
|
193
|
-
async function ncu(args = ["--deep", "-u"]) {
|
|
194
|
-
execCommand("npx", ["ncu", ...args], { stdio: "inherit" });
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
// src/command/changelog.ts
|
|
198
|
-
var import_changelog = require("@soybeanjs/changelog");
|
|
199
|
-
async function genChangelog(options, total = false) {
|
|
200
|
-
if (total) {
|
|
201
|
-
await (0, import_changelog.generateTotalChangelog)(options);
|
|
202
|
-
} else {
|
|
203
|
-
await (0, import_changelog.generateChangelog)(options);
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
// src/command/release.ts
|
|
208
|
-
var import_bumpp = require("bumpp");
|
|
209
|
-
async function release(execute = "npx soy changelog", push = true) {
|
|
210
|
-
await (0, import_bumpp.versionBump)({
|
|
211
|
-
files: ["**/package.json", "!**/node_modules"],
|
|
212
|
-
execute,
|
|
213
|
-
all: true,
|
|
214
|
-
tag: true,
|
|
215
|
-
commit: "chore(projects): release v%s",
|
|
216
|
-
push
|
|
217
|
-
});
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
// src/config/index.ts
|
|
221
|
-
var import_node_process = __toESM(require("process"), 1);
|
|
222
|
-
var import_c12 = require("c12");
|
|
223
|
-
var defaultOptions = {
|
|
224
|
-
cwd: import_node_process.default.cwd(),
|
|
225
|
-
cleanupDirs: [
|
|
226
|
-
"**/dist",
|
|
227
|
-
"**/package-lock.json",
|
|
228
|
-
"**/yarn.lock",
|
|
229
|
-
"**/pnpm-lock.yaml",
|
|
230
|
-
"**/node_modules",
|
|
231
|
-
"!node_modules/**"
|
|
232
|
-
],
|
|
233
|
-
ncuCommandArgs: ["--deep", "-u"],
|
|
234
|
-
changelogOptions: {},
|
|
235
|
-
gitCommitVerifyIgnores: [
|
|
236
|
-
/^((Merge pull request)|(Merge (.*?) into (.*?)|(Merge branch (.*?)))(?:\r?\n)*$)/m,
|
|
237
|
-
/^(Merge tag (.*?))(?:\r?\n)*$/m,
|
|
238
|
-
/^(R|r)evert (.*)/,
|
|
239
|
-
/^(amend|fixup|squash)!/,
|
|
240
|
-
/^(Merged (.*?)(in|into) (.*)|Merged PR (.*): (.*))/,
|
|
241
|
-
/^Merge remote-tracking branch(\s*)(.*)/,
|
|
242
|
-
/^Automatic merge(.*)/,
|
|
243
|
-
/^Auto-merged (.*?) into (.*)/
|
|
244
|
-
]
|
|
245
|
-
};
|
|
246
|
-
async function loadCliOptions(overrides, cwd = import_node_process.default.cwd()) {
|
|
247
|
-
const { config } = await (0, import_c12.loadConfig)({
|
|
248
|
-
name: "soybean",
|
|
249
|
-
defaults: defaultOptions,
|
|
250
|
-
overrides,
|
|
251
|
-
cwd,
|
|
252
|
-
packageJson: true
|
|
253
|
-
});
|
|
254
|
-
return config;
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
// src/index.ts
|
|
258
|
-
async function setupCli() {
|
|
259
|
-
const cliOptions = await loadCliOptions();
|
|
260
|
-
const cli = (0, import_cac.default)("soybean");
|
|
261
|
-
cli.version(version).option(
|
|
262
|
-
"-e, --execute [command]",
|
|
263
|
-
"Execute additional command after bumping and before git commit. Defaults to 'npx soy changelog'"
|
|
264
|
-
).option("-p, --push", "Indicates whether to push the git commit and tag").option("-t, --total", "Generate changelog by total tags").option(
|
|
265
|
-
"-c, --cleanupDir <dir>",
|
|
266
|
-
'The glob pattern of dirs to cleanup, If not set, it will use the default value, Multiple values use "," to separate them'
|
|
267
|
-
).option("-l, --lang <lang>", "display lang of cli", { default: "en-us", type: [String] }).help();
|
|
268
|
-
const commands = {
|
|
269
|
-
cleanup: {
|
|
270
|
-
desc: "delete dirs: node_modules, dist, etc.",
|
|
271
|
-
action: async (args) => {
|
|
272
|
-
const cleanupDirs = args?.cleanupDir?.split(",") || [];
|
|
273
|
-
const formattedDirs = cleanupDirs.map((dir) => dir.trim()).filter(Boolean);
|
|
274
|
-
if (formattedDirs.length) {
|
|
275
|
-
cliOptions.cleanupDirs = formattedDirs;
|
|
276
|
-
}
|
|
277
|
-
await cleanup(cliOptions.cleanupDirs);
|
|
278
|
-
}
|
|
279
|
-
},
|
|
280
|
-
ncu: {
|
|
281
|
-
desc: "npm-check-updates, it can update package.json dependencies to the latest version",
|
|
282
|
-
action: async () => {
|
|
283
|
-
await ncu(cliOptions.ncuCommandArgs);
|
|
284
|
-
}
|
|
285
|
-
},
|
|
286
|
-
"update-pkg": {
|
|
287
|
-
desc: 'equal to command "ncu"',
|
|
288
|
-
action: async () => {
|
|
289
|
-
await ncu();
|
|
290
|
-
}
|
|
291
|
-
},
|
|
292
|
-
"git-commit": {
|
|
293
|
-
desc: "git commit, generate commit message which match Conventional Commits standard",
|
|
294
|
-
action: async (args) => {
|
|
295
|
-
await gitCommit(args?.lang);
|
|
296
|
-
}
|
|
297
|
-
},
|
|
298
|
-
"git-commit-verify": {
|
|
299
|
-
desc: "verify git commit message, make sure it match Conventional Commits standard",
|
|
300
|
-
action: async (args) => {
|
|
301
|
-
await gitCommitVerify(args?.lang, cliOptions.gitCommitVerifyIgnores);
|
|
302
|
-
}
|
|
303
|
-
},
|
|
304
|
-
changelog: {
|
|
305
|
-
desc: "generate changelog",
|
|
306
|
-
action: async (args) => {
|
|
307
|
-
await genChangelog(cliOptions.changelogOptions, args?.total);
|
|
308
|
-
}
|
|
309
|
-
},
|
|
310
|
-
release: {
|
|
311
|
-
desc: "release: update version, generate changelog, commit code",
|
|
312
|
-
action: async (args) => {
|
|
313
|
-
await release(args?.execute, args?.push);
|
|
314
|
-
}
|
|
315
|
-
}
|
|
316
|
-
};
|
|
317
|
-
for await (const [command, { desc, action }] of Object.entries(commands)) {
|
|
318
|
-
cli.command(command, desc).action(action);
|
|
319
|
-
}
|
|
320
|
-
cli.parse();
|
|
321
|
-
}
|
|
322
|
-
setupCli();
|
|
323
|
-
function defineConfig(config) {
|
|
324
|
-
return config;
|
|
325
|
-
}
|
|
326
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
327
|
-
0 && (module.exports = {
|
|
328
|
-
defineConfig
|
|
329
|
-
});
|
package/dist/index.d.cts
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import { ChangelogOption } from '@soybeanjs/changelog';
|
|
3
|
-
|
|
4
|
-
interface CliOption {
|
|
5
|
-
/** The project root directory */
|
|
6
|
-
cwd: string;
|
|
7
|
-
/**
|
|
8
|
-
* Cleanup dirs
|
|
9
|
-
*
|
|
10
|
-
* Glob pattern syntax {@link https://github.com/isaacs/minimatch}
|
|
11
|
-
*
|
|
12
|
-
* @default
|
|
13
|
-
* ```json
|
|
14
|
-
* ["** /dist", "** /pnpm-lock.yaml", "** /node_modules", "!node_modules/**"]
|
|
15
|
-
* ```
|
|
16
|
-
*/
|
|
17
|
-
cleanupDirs: string[];
|
|
18
|
-
/**
|
|
19
|
-
* Npm-check-updates command args
|
|
20
|
-
*
|
|
21
|
-
* @default ['--deep', '-u']
|
|
22
|
-
*/
|
|
23
|
-
ncuCommandArgs: string[];
|
|
24
|
-
/**
|
|
25
|
-
* Options of generate changelog
|
|
26
|
-
*
|
|
27
|
-
* @link https://github.com/soybeanjs/changelog
|
|
28
|
-
*/
|
|
29
|
-
changelogOptions: Partial<ChangelogOption>;
|
|
30
|
-
/** The ignore pattern list of git commit verify */
|
|
31
|
-
gitCommitVerifyIgnores: RegExp[];
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
declare function defineConfig(config?: Partial<CliOption>): Partial<CliOption> | undefined;
|
|
35
|
-
|
|
36
|
-
export { type CliOption, defineConfig };
|