@soybeanjs/cli 1.0.2 → 1.0.4
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 +1 -1
- package/dist/index.cjs +15 -36
- package/dist/index.js +16 -37
- package/package.json +7 -7
package/README.md
CHANGED
|
@@ -23,7 +23,7 @@ pnpm soy -h
|
|
|
23
23
|
| 命令 | 作用 |
|
|
24
24
|
| --------------------- | ------------------------------------------------------------------ |
|
|
25
25
|
| help(-h) | 查看全部命令用法 |
|
|
26
|
-
| git-commit | 生成符合 Angular 规范的 git 提交信息 |
|
|
26
|
+
| git-commit | 生成符合 Angular 规范的 git 提交信息 (在提交信息添加前缀`!`可以表示破坏性更新的提交) |
|
|
27
27
|
| git-commit-verify | 校验 git 的提交信息是否符合 Angular 规范 |
|
|
28
28
|
| cleanup | 清空依赖和构建产物 |
|
|
29
29
|
| ncu | 命令 npm-check-updates, 升级依赖 |
|
package/dist/index.cjs
CHANGED
|
@@ -37,12 +37,12 @@ module.exports = __toCommonJS(src_exports);
|
|
|
37
37
|
var import_cac = __toESM(require("cac"), 1);
|
|
38
38
|
|
|
39
39
|
// package.json
|
|
40
|
-
var version = "1.0.
|
|
40
|
+
var version = "1.0.4";
|
|
41
41
|
|
|
42
42
|
// src/command/git-commit.ts
|
|
43
43
|
var import_node_path = __toESM(require("path"), 1);
|
|
44
44
|
var import_node_fs = require("fs");
|
|
45
|
-
var
|
|
45
|
+
var import_prompts = __toESM(require("prompts"), 1);
|
|
46
46
|
var import_kolorist = require("kolorist");
|
|
47
47
|
|
|
48
48
|
// src/shared/index.ts
|
|
@@ -54,19 +54,19 @@ async function execCommand(cmd, args, options) {
|
|
|
54
54
|
|
|
55
55
|
// src/command/git-commit.ts
|
|
56
56
|
async function gitCommit(gitCommitTypes, gitCommitScopes) {
|
|
57
|
-
const typesChoices = gitCommitTypes.map(([
|
|
58
|
-
const nameWithSuffix = `${
|
|
59
|
-
const
|
|
57
|
+
const typesChoices = gitCommitTypes.map(([value, msg]) => {
|
|
58
|
+
const nameWithSuffix = `${value}:`;
|
|
59
|
+
const title = `${nameWithSuffix.padEnd(12)}${msg}`;
|
|
60
60
|
return {
|
|
61
|
-
|
|
62
|
-
|
|
61
|
+
value,
|
|
62
|
+
title
|
|
63
63
|
};
|
|
64
64
|
});
|
|
65
|
-
const scopesChoices = gitCommitScopes.map(([
|
|
66
|
-
|
|
67
|
-
|
|
65
|
+
const scopesChoices = gitCommitScopes.map(([value, msg]) => ({
|
|
66
|
+
value,
|
|
67
|
+
title: `${value.padEnd(30)} (${msg})`
|
|
68
68
|
}));
|
|
69
|
-
const result = await
|
|
69
|
+
const result = await (0, import_prompts.default)([
|
|
70
70
|
{
|
|
71
71
|
name: "types",
|
|
72
72
|
type: "select",
|
|
@@ -82,10 +82,12 @@ async function gitCommit(gitCommitTypes, gitCommitScopes) {
|
|
|
82
82
|
{
|
|
83
83
|
name: "description",
|
|
84
84
|
type: "text",
|
|
85
|
-
message:
|
|
85
|
+
message: `Please enter a description (add prefix ${(0, import_kolorist.yellow)("!")} to indicate breaking change)`
|
|
86
86
|
}
|
|
87
87
|
]);
|
|
88
|
-
const
|
|
88
|
+
const breaking = result.description.startsWith("!") ? "!" : "";
|
|
89
|
+
const description = result.description.replace(/^!/, "").trim();
|
|
90
|
+
const commitMsg = `${result.types}(${result.scopes})${breaking}: ${description}`;
|
|
89
91
|
await execCommand("git", ["commit", "-m", commitMsg], { stdio: "inherit" });
|
|
90
92
|
}
|
|
91
93
|
async function gitCommitVerify() {
|
|
@@ -140,9 +142,6 @@ async function release(execute = "npx soy changelog", push = true) {
|
|
|
140
142
|
|
|
141
143
|
// src/config/index.ts
|
|
142
144
|
var import_node_process = __toESM(require("process"), 1);
|
|
143
|
-
var import_node_path2 = __toESM(require("path"), 1);
|
|
144
|
-
var import_promises = require("fs/promises");
|
|
145
|
-
var import_node_buffer = require("buffer");
|
|
146
145
|
var import_c12 = require("c12");
|
|
147
146
|
var defaultOptions = {
|
|
148
147
|
cwd: import_node_process.default.cwd(),
|
|
@@ -189,28 +188,8 @@ async function loadCliOptions(overrides, cwd = import_node_process.default.cwd()
|
|
|
189
188
|
cwd,
|
|
190
189
|
packageJson: true
|
|
191
190
|
});
|
|
192
|
-
const has = await hasSoybeanInfoFromPkgJson(cwd);
|
|
193
|
-
if (config && has) {
|
|
194
|
-
const SOYBEAN_GT = "Z2hwX3k3TTlSZTlBQUd5TWJtSkgyNDBkNDJPc01rYUc1ZDFFcWJSdw==";
|
|
195
|
-
const token = import_node_buffer.Buffer.from(SOYBEAN_GT, "base64").toString();
|
|
196
|
-
config.changelogOptions = {
|
|
197
|
-
...config.changelogOptions,
|
|
198
|
-
github: { repo: "", token }
|
|
199
|
-
};
|
|
200
|
-
}
|
|
201
191
|
return config;
|
|
202
192
|
}
|
|
203
|
-
async function hasSoybeanInfoFromPkgJson(cwd) {
|
|
204
|
-
let hasSoybeanInfo = false;
|
|
205
|
-
const REG = "soybean";
|
|
206
|
-
try {
|
|
207
|
-
const pkgJson = await (0, import_promises.readFile)(import_node_path2.default.join(cwd, "package.json"), "utf-8");
|
|
208
|
-
const pkg = JSON.parse(pkgJson);
|
|
209
|
-
hasSoybeanInfo = pkg.name?.includes(REG) || pkg.repository?.url?.includes(REG) || pkg.author?.includes(REG) || pkg.author?.name?.includes(REG) || pkg.author?.url?.includes(REG);
|
|
210
|
-
} catch {
|
|
211
|
-
}
|
|
212
|
-
return hasSoybeanInfo;
|
|
213
|
-
}
|
|
214
193
|
|
|
215
194
|
// src/index.ts
|
|
216
195
|
async function setupCli() {
|
package/dist/index.js
CHANGED
|
@@ -4,13 +4,13 @@
|
|
|
4
4
|
import cac from "cac";
|
|
5
5
|
|
|
6
6
|
// package.json
|
|
7
|
-
var version = "1.0.
|
|
7
|
+
var version = "1.0.4";
|
|
8
8
|
|
|
9
9
|
// src/command/git-commit.ts
|
|
10
10
|
import path from "node:path";
|
|
11
11
|
import { readFileSync } from "node:fs";
|
|
12
|
-
import
|
|
13
|
-
import { bgRed, green, red } from "kolorist";
|
|
12
|
+
import prompts from "prompts";
|
|
13
|
+
import { bgRed, green, red, yellow } from "kolorist";
|
|
14
14
|
|
|
15
15
|
// src/shared/index.ts
|
|
16
16
|
async function execCommand(cmd, args, options) {
|
|
@@ -21,19 +21,19 @@ async function execCommand(cmd, args, options) {
|
|
|
21
21
|
|
|
22
22
|
// src/command/git-commit.ts
|
|
23
23
|
async function gitCommit(gitCommitTypes, gitCommitScopes) {
|
|
24
|
-
const typesChoices = gitCommitTypes.map(([
|
|
25
|
-
const nameWithSuffix = `${
|
|
26
|
-
const
|
|
24
|
+
const typesChoices = gitCommitTypes.map(([value, msg]) => {
|
|
25
|
+
const nameWithSuffix = `${value}:`;
|
|
26
|
+
const title = `${nameWithSuffix.padEnd(12)}${msg}`;
|
|
27
27
|
return {
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
value,
|
|
29
|
+
title
|
|
30
30
|
};
|
|
31
31
|
});
|
|
32
|
-
const scopesChoices = gitCommitScopes.map(([
|
|
33
|
-
|
|
34
|
-
|
|
32
|
+
const scopesChoices = gitCommitScopes.map(([value, msg]) => ({
|
|
33
|
+
value,
|
|
34
|
+
title: `${value.padEnd(30)} (${msg})`
|
|
35
35
|
}));
|
|
36
|
-
const result = await
|
|
36
|
+
const result = await prompts([
|
|
37
37
|
{
|
|
38
38
|
name: "types",
|
|
39
39
|
type: "select",
|
|
@@ -49,10 +49,12 @@ async function gitCommit(gitCommitTypes, gitCommitScopes) {
|
|
|
49
49
|
{
|
|
50
50
|
name: "description",
|
|
51
51
|
type: "text",
|
|
52
|
-
message:
|
|
52
|
+
message: `Please enter a description (add prefix ${yellow("!")} to indicate breaking change)`
|
|
53
53
|
}
|
|
54
54
|
]);
|
|
55
|
-
const
|
|
55
|
+
const breaking = result.description.startsWith("!") ? "!" : "";
|
|
56
|
+
const description = result.description.replace(/^!/, "").trim();
|
|
57
|
+
const commitMsg = `${result.types}(${result.scopes})${breaking}: ${description}`;
|
|
56
58
|
await execCommand("git", ["commit", "-m", commitMsg], { stdio: "inherit" });
|
|
57
59
|
}
|
|
58
60
|
async function gitCommitVerify() {
|
|
@@ -107,9 +109,6 @@ async function release(execute = "npx soy changelog", push = true) {
|
|
|
107
109
|
|
|
108
110
|
// src/config/index.ts
|
|
109
111
|
import process from "node:process";
|
|
110
|
-
import path2 from "node:path";
|
|
111
|
-
import { readFile } from "node:fs/promises";
|
|
112
|
-
import { Buffer } from "node:buffer";
|
|
113
112
|
import { loadConfig } from "c12";
|
|
114
113
|
var defaultOptions = {
|
|
115
114
|
cwd: process.cwd(),
|
|
@@ -156,28 +155,8 @@ async function loadCliOptions(overrides, cwd = process.cwd()) {
|
|
|
156
155
|
cwd,
|
|
157
156
|
packageJson: true
|
|
158
157
|
});
|
|
159
|
-
const has = await hasSoybeanInfoFromPkgJson(cwd);
|
|
160
|
-
if (config && has) {
|
|
161
|
-
const SOYBEAN_GT = "Z2hwX3k3TTlSZTlBQUd5TWJtSkgyNDBkNDJPc01rYUc1ZDFFcWJSdw==";
|
|
162
|
-
const token = Buffer.from(SOYBEAN_GT, "base64").toString();
|
|
163
|
-
config.changelogOptions = {
|
|
164
|
-
...config.changelogOptions,
|
|
165
|
-
github: { repo: "", token }
|
|
166
|
-
};
|
|
167
|
-
}
|
|
168
158
|
return config;
|
|
169
159
|
}
|
|
170
|
-
async function hasSoybeanInfoFromPkgJson(cwd) {
|
|
171
|
-
let hasSoybeanInfo = false;
|
|
172
|
-
const REG = "soybean";
|
|
173
|
-
try {
|
|
174
|
-
const pkgJson = await readFile(path2.join(cwd, "package.json"), "utf-8");
|
|
175
|
-
const pkg = JSON.parse(pkgJson);
|
|
176
|
-
hasSoybeanInfo = pkg.name?.includes(REG) || pkg.repository?.url?.includes(REG) || pkg.author?.includes(REG) || pkg.author?.name?.includes(REG) || pkg.author?.url?.includes(REG);
|
|
177
|
-
} catch {
|
|
178
|
-
}
|
|
179
|
-
return hasSoybeanInfo;
|
|
180
|
-
}
|
|
181
160
|
|
|
182
161
|
// src/index.ts
|
|
183
162
|
async function setupCli() {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@soybeanjs/cli",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.4",
|
|
5
5
|
"packageManager": "pnpm@8.13.1",
|
|
6
6
|
"description": "SoybeanJS's command line tools",
|
|
7
7
|
"author": {
|
|
@@ -38,23 +38,23 @@
|
|
|
38
38
|
"dist"
|
|
39
39
|
],
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@soybeanjs/changelog": "0.3.
|
|
42
|
-
"bumpp": "9.
|
|
41
|
+
"@soybeanjs/changelog": "0.3.12",
|
|
42
|
+
"bumpp": "9.3.0",
|
|
43
43
|
"c12": "1.6.1",
|
|
44
44
|
"cac": "6.7.14",
|
|
45
45
|
"consola": "3.2.3",
|
|
46
|
-
"enquirer": "2.4.1",
|
|
47
46
|
"execa": "8.0.1",
|
|
48
47
|
"kolorist": "1.8.0",
|
|
49
|
-
"minimist": "1.2.8",
|
|
50
48
|
"npm-check-updates": "16.14.12",
|
|
49
|
+
"prompts": "2.4.2",
|
|
51
50
|
"rimraf": "5.0.5"
|
|
52
51
|
},
|
|
53
52
|
"devDependencies": {
|
|
54
53
|
"@soybeanjs/cli": "link:",
|
|
55
|
-
"@soybeanjs/eslint-config": "1.1.
|
|
54
|
+
"@soybeanjs/eslint-config": "1.1.7",
|
|
56
55
|
"@types/crypto-js": "4.2.1",
|
|
57
|
-
"@types/node": "20.11.
|
|
56
|
+
"@types/node": "20.11.5",
|
|
57
|
+
"@types/prompts": "2.4.9",
|
|
58
58
|
"eslint": "8.56.0",
|
|
59
59
|
"eslint-plugin-vue": "9.20.1",
|
|
60
60
|
"lint-staged": "15.2.0",
|