@soybeanjs/cli 0.6.6 → 0.7.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/dist/index.cjs +30 -26
- package/dist/index.mjs +30 -26
- package/package.json +8 -8
package/dist/index.cjs
CHANGED
|
@@ -19,7 +19,7 @@ const enquirer__default = /*#__PURE__*/_interopDefaultCompat(enquirer);
|
|
|
19
19
|
const path__default = /*#__PURE__*/_interopDefaultCompat(path);
|
|
20
20
|
const versionBump__default = /*#__PURE__*/_interopDefaultCompat(versionBump);
|
|
21
21
|
|
|
22
|
-
const version = "0.
|
|
22
|
+
const version = "0.7.0";
|
|
23
23
|
|
|
24
24
|
async function execCommand(cmd, args, options) {
|
|
25
25
|
const { execa } = await import('execa');
|
|
@@ -65,7 +65,7 @@ async function gitCommit(gitCommitTypes, gitCommitScopes) {
|
|
|
65
65
|
|
|
66
66
|
async function gitCommitVerify() {
|
|
67
67
|
const gitPath = await execCommand("git", ["rev-parse", "--show-toplevel"]);
|
|
68
|
-
const gitMsgPath = path__default.join(gitPath, ".git
|
|
68
|
+
const gitMsgPath = path__default.join(gitPath, ".git", "COMMIT_EDITMSG");
|
|
69
69
|
const commitMsg = fs.readFileSync(gitMsgPath, "utf-8").trim();
|
|
70
70
|
const REG_EXP = /(?<type>[a-z]+)(\((?<scope>.+)\))?(?<breaking>!)?: (?<description>.+)/i;
|
|
71
71
|
if (!REG_EXP.test(commitMsg)) {
|
|
@@ -84,7 +84,7 @@ async function cleanup(paths) {
|
|
|
84
84
|
async function initSimpleGitHooks(cwd = process.cwd()) {
|
|
85
85
|
const huskyDir = path__default.join(cwd, ".husky");
|
|
86
86
|
const existHusky = fs.existsSync(huskyDir);
|
|
87
|
-
const gitHooksDir = path__default.join(cwd, ".git
|
|
87
|
+
const gitHooksDir = path__default.join(cwd, ".git", "hooks");
|
|
88
88
|
if (existHusky) {
|
|
89
89
|
await rimraf.rimraf(huskyDir);
|
|
90
90
|
await execCommand("git", ["config", "core.hooksPath", gitHooksDir], { stdio: "inherit" });
|
|
@@ -119,9 +119,9 @@ async function execLintStaged(config) {
|
|
|
119
119
|
|
|
120
120
|
async function genChangelog(options, total = false) {
|
|
121
121
|
if (total) {
|
|
122
|
-
changelog.generateTotalChangelog(options);
|
|
122
|
+
await changelog.generateTotalChangelog(options);
|
|
123
123
|
} else {
|
|
124
|
-
changelog.generateChangelog(options);
|
|
124
|
+
await changelog.generateChangelog(options);
|
|
125
125
|
}
|
|
126
126
|
}
|
|
127
127
|
|
|
@@ -197,7 +197,7 @@ const defaultOptions = {
|
|
|
197
197
|
"*": "soy prettier-write"
|
|
198
198
|
}
|
|
199
199
|
};
|
|
200
|
-
const SOYBEAN_GITHUB_TOKEN = "
|
|
200
|
+
const SOYBEAN_GITHUB_TOKEN = "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";
|
|
201
201
|
async function loadCliOptions(overrides, cwd = process.cwd()) {
|
|
202
202
|
const { config } = await c12.loadConfig({
|
|
203
203
|
name: "soybean",
|
|
@@ -231,38 +231,38 @@ async function setupCli() {
|
|
|
231
231
|
const commands = {
|
|
232
232
|
"git-commit": {
|
|
233
233
|
desc: "\u751F\u6210\u7B26\u5408 Conventional Commits \u89C4\u8303\u7684\u63D0\u4EA4\u4FE1\u606F",
|
|
234
|
-
action: () => {
|
|
235
|
-
gitCommit(cliOptions.gitCommitTypes, cliOptions.gitCommitScopes);
|
|
234
|
+
action: async () => {
|
|
235
|
+
await gitCommit(cliOptions.gitCommitTypes, cliOptions.gitCommitScopes);
|
|
236
236
|
}
|
|
237
237
|
},
|
|
238
238
|
"git-commit-verify": {
|
|
239
239
|
desc: "\u6821\u9A8C git \u63D0\u4EA4\u4FE1\u606F\u662F\u5426\u7B26\u5408 Conventional Commits \u89C4\u8303",
|
|
240
|
-
action: () => {
|
|
241
|
-
gitCommitVerify();
|
|
240
|
+
action: async () => {
|
|
241
|
+
await gitCommitVerify();
|
|
242
242
|
}
|
|
243
243
|
},
|
|
244
244
|
cleanup: {
|
|
245
245
|
desc: "\u6E05\u7A7A\u4F9D\u8D56\u548C\u6784\u5EFA\u4EA7\u7269",
|
|
246
|
-
action: () => {
|
|
247
|
-
cleanup(cliOptions.cleanupDirs);
|
|
246
|
+
action: async () => {
|
|
247
|
+
await cleanup(cliOptions.cleanupDirs);
|
|
248
248
|
}
|
|
249
249
|
},
|
|
250
250
|
"init-simple-git-hooks": {
|
|
251
251
|
desc: "\u521D\u59CB\u5316 simple-git-hooks \u94A9\u5B50",
|
|
252
|
-
action: () => {
|
|
253
|
-
initSimpleGitHooks(cliOptions.cwd);
|
|
252
|
+
action: async () => {
|
|
253
|
+
await initSimpleGitHooks(cliOptions.cwd);
|
|
254
254
|
}
|
|
255
255
|
},
|
|
256
256
|
ncu: {
|
|
257
257
|
desc: "\u547D\u4EE4 npm-check-updates, \u5347\u7EA7\u4F9D\u8D56",
|
|
258
|
-
action: () => {
|
|
259
|
-
ncu(cliOptions.ncuCommandArgs);
|
|
258
|
+
action: async () => {
|
|
259
|
+
await ncu(cliOptions.ncuCommandArgs);
|
|
260
260
|
}
|
|
261
261
|
},
|
|
262
262
|
"prettier-write": {
|
|
263
263
|
desc: "\u6267\u884C prettier --write \u683C\u5F0F\u5316",
|
|
264
|
-
action: () => {
|
|
265
|
-
prettierWrite(cliOptions.prettierWriteGlob);
|
|
264
|
+
action: async () => {
|
|
265
|
+
await prettierWrite(cliOptions.prettierWriteGlob);
|
|
266
266
|
}
|
|
267
267
|
},
|
|
268
268
|
"lint-staged": {
|
|
@@ -282,15 +282,17 @@ async function setupCli() {
|
|
|
282
282
|
},
|
|
283
283
|
release: {
|
|
284
284
|
desc: "\u53D1\u5E03\uFF1A\u66F4\u65B0\u7248\u672C\u53F7\u3001\u751F\u6210changelog\u3001\u63D0\u4EA4\u4EE3\u7801",
|
|
285
|
-
action:
|
|
285
|
+
action: async () => {
|
|
286
|
+
await release();
|
|
287
|
+
}
|
|
286
288
|
},
|
|
287
289
|
/**
|
|
288
290
|
* @deprecated
|
|
289
291
|
*/
|
|
290
292
|
"init-git-hooks": {
|
|
291
293
|
desc: "\u8BE5\u547D\u4EE4\u5DF2\u5E9F\u5F03\uFF0C\u8BF7\u4F7F\u7528 init-simple-git-hooks",
|
|
292
|
-
action: () => {
|
|
293
|
-
initSimpleGitHooks(cliOptions.cwd);
|
|
294
|
+
action: async () => {
|
|
295
|
+
await initSimpleGitHooks(cliOptions.cwd);
|
|
294
296
|
}
|
|
295
297
|
},
|
|
296
298
|
/**
|
|
@@ -298,8 +300,8 @@ async function setupCli() {
|
|
|
298
300
|
*/
|
|
299
301
|
"update-pkg": {
|
|
300
302
|
desc: "\u8BE5\u547D\u4EE4\u5DF2\u5E9F\u5F03\uFF0C\u8BF7\u4F7F\u7528 ncu",
|
|
301
|
-
action: () => {
|
|
302
|
-
ncu(cliOptions.ncuCommandArgs);
|
|
303
|
+
action: async () => {
|
|
304
|
+
await ncu(cliOptions.ncuCommandArgs);
|
|
303
305
|
}
|
|
304
306
|
},
|
|
305
307
|
/**
|
|
@@ -307,8 +309,8 @@ async function setupCli() {
|
|
|
307
309
|
*/
|
|
308
310
|
"prettier-format": {
|
|
309
311
|
desc: "\u8BE5\u547D\u4EE4\u5DF2\u5E9F\u5F03\uFF0C\u8BF7\u4F7F\u7528 prettier-write",
|
|
310
|
-
action: () => {
|
|
311
|
-
prettierWrite(cliOptions.prettierWriteGlob);
|
|
312
|
+
action: async () => {
|
|
313
|
+
await prettierWrite(cliOptions.prettierWriteGlob);
|
|
312
314
|
}
|
|
313
315
|
},
|
|
314
316
|
/**
|
|
@@ -316,7 +318,9 @@ async function setupCli() {
|
|
|
316
318
|
*/
|
|
317
319
|
"eslint-prettier": {
|
|
318
320
|
desc: "\u8BE5\u547D\u4EE4\u5DF2\u5E9F\u5F03",
|
|
319
|
-
action:
|
|
321
|
+
action: async () => {
|
|
322
|
+
await eslintPrettier();
|
|
323
|
+
}
|
|
320
324
|
}
|
|
321
325
|
};
|
|
322
326
|
for await (const [command, { desc, action }] of Object.entries(commands)) {
|
package/dist/index.mjs
CHANGED
|
@@ -10,7 +10,7 @@ import versionBump from 'bumpp';
|
|
|
10
10
|
import { loadConfig } from 'c12';
|
|
11
11
|
import { readFile } from 'fs/promises';
|
|
12
12
|
|
|
13
|
-
const version = "0.
|
|
13
|
+
const version = "0.7.0";
|
|
14
14
|
|
|
15
15
|
async function execCommand(cmd, args, options) {
|
|
16
16
|
const { execa } = await import('execa');
|
|
@@ -56,7 +56,7 @@ async function gitCommit(gitCommitTypes, gitCommitScopes) {
|
|
|
56
56
|
|
|
57
57
|
async function gitCommitVerify() {
|
|
58
58
|
const gitPath = await execCommand("git", ["rev-parse", "--show-toplevel"]);
|
|
59
|
-
const gitMsgPath = path.join(gitPath, ".git
|
|
59
|
+
const gitMsgPath = path.join(gitPath, ".git", "COMMIT_EDITMSG");
|
|
60
60
|
const commitMsg = readFileSync(gitMsgPath, "utf-8").trim();
|
|
61
61
|
const REG_EXP = /(?<type>[a-z]+)(\((?<scope>.+)\))?(?<breaking>!)?: (?<description>.+)/i;
|
|
62
62
|
if (!REG_EXP.test(commitMsg)) {
|
|
@@ -75,7 +75,7 @@ async function cleanup(paths) {
|
|
|
75
75
|
async function initSimpleGitHooks(cwd = process.cwd()) {
|
|
76
76
|
const huskyDir = path.join(cwd, ".husky");
|
|
77
77
|
const existHusky = existsSync(huskyDir);
|
|
78
|
-
const gitHooksDir = path.join(cwd, ".git
|
|
78
|
+
const gitHooksDir = path.join(cwd, ".git", "hooks");
|
|
79
79
|
if (existHusky) {
|
|
80
80
|
await rimraf(huskyDir);
|
|
81
81
|
await execCommand("git", ["config", "core.hooksPath", gitHooksDir], { stdio: "inherit" });
|
|
@@ -110,9 +110,9 @@ async function execLintStaged(config) {
|
|
|
110
110
|
|
|
111
111
|
async function genChangelog(options, total = false) {
|
|
112
112
|
if (total) {
|
|
113
|
-
generateTotalChangelog(options);
|
|
113
|
+
await generateTotalChangelog(options);
|
|
114
114
|
} else {
|
|
115
|
-
generateChangelog(options);
|
|
115
|
+
await generateChangelog(options);
|
|
116
116
|
}
|
|
117
117
|
}
|
|
118
118
|
|
|
@@ -188,7 +188,7 @@ const defaultOptions = {
|
|
|
188
188
|
"*": "soy prettier-write"
|
|
189
189
|
}
|
|
190
190
|
};
|
|
191
|
-
const SOYBEAN_GITHUB_TOKEN = "
|
|
191
|
+
const SOYBEAN_GITHUB_TOKEN = "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";
|
|
192
192
|
async function loadCliOptions(overrides, cwd = process.cwd()) {
|
|
193
193
|
const { config } = await loadConfig({
|
|
194
194
|
name: "soybean",
|
|
@@ -222,38 +222,38 @@ async function setupCli() {
|
|
|
222
222
|
const commands = {
|
|
223
223
|
"git-commit": {
|
|
224
224
|
desc: "\u751F\u6210\u7B26\u5408 Conventional Commits \u89C4\u8303\u7684\u63D0\u4EA4\u4FE1\u606F",
|
|
225
|
-
action: () => {
|
|
226
|
-
gitCommit(cliOptions.gitCommitTypes, cliOptions.gitCommitScopes);
|
|
225
|
+
action: async () => {
|
|
226
|
+
await gitCommit(cliOptions.gitCommitTypes, cliOptions.gitCommitScopes);
|
|
227
227
|
}
|
|
228
228
|
},
|
|
229
229
|
"git-commit-verify": {
|
|
230
230
|
desc: "\u6821\u9A8C git \u63D0\u4EA4\u4FE1\u606F\u662F\u5426\u7B26\u5408 Conventional Commits \u89C4\u8303",
|
|
231
|
-
action: () => {
|
|
232
|
-
gitCommitVerify();
|
|
231
|
+
action: async () => {
|
|
232
|
+
await gitCommitVerify();
|
|
233
233
|
}
|
|
234
234
|
},
|
|
235
235
|
cleanup: {
|
|
236
236
|
desc: "\u6E05\u7A7A\u4F9D\u8D56\u548C\u6784\u5EFA\u4EA7\u7269",
|
|
237
|
-
action: () => {
|
|
238
|
-
cleanup(cliOptions.cleanupDirs);
|
|
237
|
+
action: async () => {
|
|
238
|
+
await cleanup(cliOptions.cleanupDirs);
|
|
239
239
|
}
|
|
240
240
|
},
|
|
241
241
|
"init-simple-git-hooks": {
|
|
242
242
|
desc: "\u521D\u59CB\u5316 simple-git-hooks \u94A9\u5B50",
|
|
243
|
-
action: () => {
|
|
244
|
-
initSimpleGitHooks(cliOptions.cwd);
|
|
243
|
+
action: async () => {
|
|
244
|
+
await initSimpleGitHooks(cliOptions.cwd);
|
|
245
245
|
}
|
|
246
246
|
},
|
|
247
247
|
ncu: {
|
|
248
248
|
desc: "\u547D\u4EE4 npm-check-updates, \u5347\u7EA7\u4F9D\u8D56",
|
|
249
|
-
action: () => {
|
|
250
|
-
ncu(cliOptions.ncuCommandArgs);
|
|
249
|
+
action: async () => {
|
|
250
|
+
await ncu(cliOptions.ncuCommandArgs);
|
|
251
251
|
}
|
|
252
252
|
},
|
|
253
253
|
"prettier-write": {
|
|
254
254
|
desc: "\u6267\u884C prettier --write \u683C\u5F0F\u5316",
|
|
255
|
-
action: () => {
|
|
256
|
-
prettierWrite(cliOptions.prettierWriteGlob);
|
|
255
|
+
action: async () => {
|
|
256
|
+
await prettierWrite(cliOptions.prettierWriteGlob);
|
|
257
257
|
}
|
|
258
258
|
},
|
|
259
259
|
"lint-staged": {
|
|
@@ -273,15 +273,17 @@ async function setupCli() {
|
|
|
273
273
|
},
|
|
274
274
|
release: {
|
|
275
275
|
desc: "\u53D1\u5E03\uFF1A\u66F4\u65B0\u7248\u672C\u53F7\u3001\u751F\u6210changelog\u3001\u63D0\u4EA4\u4EE3\u7801",
|
|
276
|
-
action:
|
|
276
|
+
action: async () => {
|
|
277
|
+
await release();
|
|
278
|
+
}
|
|
277
279
|
},
|
|
278
280
|
/**
|
|
279
281
|
* @deprecated
|
|
280
282
|
*/
|
|
281
283
|
"init-git-hooks": {
|
|
282
284
|
desc: "\u8BE5\u547D\u4EE4\u5DF2\u5E9F\u5F03\uFF0C\u8BF7\u4F7F\u7528 init-simple-git-hooks",
|
|
283
|
-
action: () => {
|
|
284
|
-
initSimpleGitHooks(cliOptions.cwd);
|
|
285
|
+
action: async () => {
|
|
286
|
+
await initSimpleGitHooks(cliOptions.cwd);
|
|
285
287
|
}
|
|
286
288
|
},
|
|
287
289
|
/**
|
|
@@ -289,8 +291,8 @@ async function setupCli() {
|
|
|
289
291
|
*/
|
|
290
292
|
"update-pkg": {
|
|
291
293
|
desc: "\u8BE5\u547D\u4EE4\u5DF2\u5E9F\u5F03\uFF0C\u8BF7\u4F7F\u7528 ncu",
|
|
292
|
-
action: () => {
|
|
293
|
-
ncu(cliOptions.ncuCommandArgs);
|
|
294
|
+
action: async () => {
|
|
295
|
+
await ncu(cliOptions.ncuCommandArgs);
|
|
294
296
|
}
|
|
295
297
|
},
|
|
296
298
|
/**
|
|
@@ -298,8 +300,8 @@ async function setupCli() {
|
|
|
298
300
|
*/
|
|
299
301
|
"prettier-format": {
|
|
300
302
|
desc: "\u8BE5\u547D\u4EE4\u5DF2\u5E9F\u5F03\uFF0C\u8BF7\u4F7F\u7528 prettier-write",
|
|
301
|
-
action: () => {
|
|
302
|
-
prettierWrite(cliOptions.prettierWriteGlob);
|
|
303
|
+
action: async () => {
|
|
304
|
+
await prettierWrite(cliOptions.prettierWriteGlob);
|
|
303
305
|
}
|
|
304
306
|
},
|
|
305
307
|
/**
|
|
@@ -307,7 +309,9 @@ async function setupCli() {
|
|
|
307
309
|
*/
|
|
308
310
|
"eslint-prettier": {
|
|
309
311
|
desc: "\u8BE5\u547D\u4EE4\u5DF2\u5E9F\u5F03",
|
|
310
|
-
action:
|
|
312
|
+
action: async () => {
|
|
313
|
+
await eslintPrettier();
|
|
314
|
+
}
|
|
311
315
|
}
|
|
312
316
|
};
|
|
313
317
|
for await (const [command, { desc, action }] of Object.entries(commands)) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@soybeanjs/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"description": "SoybeanJS's command line tools",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Soybean",
|
|
@@ -36,24 +36,24 @@
|
|
|
36
36
|
"dist"
|
|
37
37
|
],
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@soybeanjs/changelog": "0.
|
|
39
|
+
"@soybeanjs/changelog": "0.3.2",
|
|
40
40
|
"bumpp": "9.1.1",
|
|
41
41
|
"c12": "1.4.2",
|
|
42
42
|
"cac": "6.7.14",
|
|
43
43
|
"consola": "3.2.3",
|
|
44
44
|
"enquirer": "2.4.1",
|
|
45
|
-
"execa": "
|
|
45
|
+
"execa": "8.0.1",
|
|
46
46
|
"kolorist": "1.8.0",
|
|
47
|
-
"lint-staged": "
|
|
47
|
+
"lint-staged": "14.0.1",
|
|
48
48
|
"minimist": "1.2.8",
|
|
49
|
-
"npm-check-updates": "16.
|
|
49
|
+
"npm-check-updates": "16.13.0",
|
|
50
50
|
"rimraf": "5.0.1"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
53
|
"@soybeanjs/cli": "link:",
|
|
54
|
-
"@types/node": "20.
|
|
55
|
-
"eslint": "8.
|
|
56
|
-
"eslint-config-soybeanjs": "0.5.
|
|
54
|
+
"@types/node": "20.5.2",
|
|
55
|
+
"eslint": "8.47.0",
|
|
56
|
+
"eslint-config-soybeanjs": "0.5.5",
|
|
57
57
|
"simple-git-hooks": "2.9.0",
|
|
58
58
|
"tsx": "3.12.7",
|
|
59
59
|
"typescript": "5.1.6",
|