mine-auto-cli 2.8.0 → 2.8.1
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/claude.settings-BShJAaF1.js +24 -0
- package/dist/index.js +495 -382
- package/dist/keyword-Bs4ml7oW.js +134 -0
- package/dist/keyword-latest-Bj5j_G4f.js +95 -0
- package/package.json +8 -8
- package/dist/keyword-CJ3Dr1_B.js +0 -137
- package/dist/keyword-latest-0uZaQMuX.js +0 -98
package/dist/index.js
CHANGED
|
@@ -1,388 +1,501 @@
|
|
|
1
|
-
import { program as
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import { join as
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import { execSync as
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import { parseRange as
|
|
12
|
-
import
|
|
13
|
-
import
|
|
14
|
-
import
|
|
15
|
-
import
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
},
|
|
38
|
-
|
|
1
|
+
import { program as e } from "commander";
|
|
2
|
+
import t from "chalk";
|
|
3
|
+
import { cpSync as n, existsSync as r, readFileSync as i, readdirSync as a, rmSync as o, writeFileSync as s } from "fs";
|
|
4
|
+
import { join as c, resolve as l } from "path";
|
|
5
|
+
import u from "log-symbols";
|
|
6
|
+
import d from "ora";
|
|
7
|
+
import { execSync as f } from "child_process";
|
|
8
|
+
import * as p from "js-yaml";
|
|
9
|
+
import ee from "strip-json-comments";
|
|
10
|
+
import te from "pacote";
|
|
11
|
+
import { parseRange as m } from "semver-utils";
|
|
12
|
+
import ne from "download-git-repo";
|
|
13
|
+
import h from "inquirer";
|
|
14
|
+
import g from "os";
|
|
15
|
+
import re from "update-notifier";
|
|
16
|
+
//#region package.json
|
|
17
|
+
var ie = "mine-auto-cli", ae = "2.8.1", _ = {
|
|
18
|
+
name: ie,
|
|
19
|
+
private: !1,
|
|
20
|
+
version: ae,
|
|
21
|
+
exports: "./dist/index.js",
|
|
22
|
+
main: "./dist/index.js",
|
|
23
|
+
type: "module",
|
|
24
|
+
bin: { auto: "bin/mine-auto-cli.js" },
|
|
25
|
+
author: {
|
|
26
|
+
name: "biaov",
|
|
27
|
+
email: "biaov@qq.com",
|
|
28
|
+
url: "https://biaov.cn"
|
|
29
|
+
},
|
|
30
|
+
description: "一个将多个命令简化成一个命令的工具 😆",
|
|
31
|
+
scripts: {
|
|
32
|
+
start: "npm run dev",
|
|
33
|
+
dev: "npm run build -- --watch",
|
|
34
|
+
build: "vite build",
|
|
35
|
+
prettier: "prettier --write '**/*.{js,ts,md,json}'",
|
|
36
|
+
tag: "node scripts/tag"
|
|
37
|
+
},
|
|
38
|
+
publishConfig: {
|
|
39
|
+
registry: "https://registry.npmjs.org/",
|
|
40
|
+
"engine-strict": !0,
|
|
41
|
+
provenance: !0
|
|
42
|
+
},
|
|
43
|
+
engines: { node: ">=24.18.0" },
|
|
44
|
+
keywords: [
|
|
45
|
+
"auto",
|
|
46
|
+
"cli",
|
|
47
|
+
"vite",
|
|
48
|
+
"typescript"
|
|
49
|
+
],
|
|
50
|
+
repository: {
|
|
51
|
+
type: "git",
|
|
52
|
+
url: "git+https://github.com/biaov/mine-auto-cli.git"
|
|
53
|
+
},
|
|
54
|
+
homepage: "https://github.com/biaov/mine-auto-cli.git",
|
|
55
|
+
bugs: { url: "https://github.com/biaov/mine-auto-cli/issues" },
|
|
56
|
+
license: "ISC",
|
|
57
|
+
contributors: [{
|
|
58
|
+
name: "biaov",
|
|
59
|
+
email: "biaov@qq.com"
|
|
60
|
+
}],
|
|
61
|
+
dependencies: {
|
|
62
|
+
chalk: "^5.6.2",
|
|
63
|
+
commander: "^15.0.0",
|
|
64
|
+
"download-git-repo": "^3.0.2",
|
|
65
|
+
inquirer: "^14.0.2",
|
|
66
|
+
"js-yaml": "^5.1.0",
|
|
67
|
+
"log-symbols": "^7.0.1",
|
|
68
|
+
ora: "^9.4.1",
|
|
69
|
+
pacote: "^22.0.0",
|
|
70
|
+
"semver-utils": "^1.1.4",
|
|
71
|
+
"strip-json-comments": "^5.0.3",
|
|
72
|
+
"update-notifier": "^7.3.1"
|
|
73
|
+
},
|
|
74
|
+
devDependencies: {
|
|
75
|
+
"@types/js-yaml": "^4.0.9",
|
|
76
|
+
"@types/node": "^26.0.0",
|
|
77
|
+
"@types/pacote": "^11.1.8",
|
|
78
|
+
"@types/semver-utils": "^1.1.3",
|
|
79
|
+
"@types/update-notifier": "^6.0.8",
|
|
80
|
+
prettier: "^3.8.4",
|
|
81
|
+
typescript: "^6.0.3",
|
|
82
|
+
vite: "^8.1.0"
|
|
83
|
+
}
|
|
84
|
+
}, v = (e) => {
|
|
85
|
+
console.log(`${u.success} ${t.green("SUCCESS")} ${e}`);
|
|
86
|
+
}, y = (e) => {
|
|
87
|
+
console.log(`${ie} ${u.error} ${t.red("ERROR")} ${e}`);
|
|
88
|
+
}, b = (e) => {
|
|
89
|
+
console.log(e ?? "");
|
|
90
|
+
}, oe = (e) => {
|
|
91
|
+
b(`开始执行 ${t.cyanBright(e)} 命令`);
|
|
92
|
+
let n = d({
|
|
93
|
+
text: "正在执行命令中...",
|
|
94
|
+
color: "yellow"
|
|
95
|
+
});
|
|
96
|
+
n.start(), b(f(e, { cwd: process.cwd() }).toString()), n.succeed(`${t.green(e)} 命令执行成功`), b();
|
|
97
|
+
}, se = (e) => [
|
|
98
|
+
"git add -A",
|
|
99
|
+
`git commit -m ${e}`,
|
|
100
|
+
"git push"
|
|
101
|
+
], ce = (e, t) => [
|
|
102
|
+
`npm run ${e}`,
|
|
103
|
+
"git add -A",
|
|
104
|
+
`git commit -m ${t}`,
|
|
105
|
+
"git push"
|
|
106
|
+
], le = async (e, n = "打包") => {
|
|
107
|
+
b(), b(`${t.yellow(">>")} 开始依次执行命令...`), b(), ce(e, n).map(oe), v("全部命令执行完成"), b();
|
|
108
|
+
}, x = (t) => {
|
|
109
|
+
b(), y(`\`${t}\` 命令错误,请检查你的命令`), b(), e.help();
|
|
39
110
|
}, S = (e) => {
|
|
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
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
},
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
}
|
|
103
|
-
},
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
`, "") : s;
|
|
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
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
};
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
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
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
u.command("check").option("-u, --update", "更新 package.json 依赖内容", !1).description("升级 package.json 依赖版本").action(pt);
|
|
215
|
-
const mt = le(), ue = "comment.md", dt = ["package.json", ue], [Q, W] = dt.map((e) => f(process.cwd(), e)), ut = () => {
|
|
216
|
-
if (!$(Q)) return S("package.json 文件不存在");
|
|
217
|
-
const e = y(Q).toString(), t = JSON.parse(e), s = ["dependencies", "devDependencies", "optionalDependencies"];
|
|
218
|
-
let o = `### 依赖解析
|
|
219
|
-
|
|
220
|
-
`;
|
|
221
|
-
s.forEach((n) => {
|
|
222
|
-
t[n] && (o += `#### ${n}
|
|
223
|
-
|
|
224
|
-
`, Object.keys(t[n]).forEach((r) => {
|
|
225
|
-
o += `- \`${r}\`: ${mt.comment[r] || ""}
|
|
226
|
-
`;
|
|
227
|
-
}), o += `
|
|
228
|
-
`);
|
|
229
|
-
}), o = o.slice(0, -1), v(W, o), a(), h(`${ue} 文件创建成功`), a(), a(p.green(`文件目录 ${W}`));
|
|
111
|
+
let [t, n] = ["package.json", "README.md"].map((e) => {
|
|
112
|
+
let t = c(process.cwd(), e);
|
|
113
|
+
return {
|
|
114
|
+
path: t,
|
|
115
|
+
content: i(t).toString()
|
|
116
|
+
};
|
|
117
|
+
}), r = JSON.parse(t.content);
|
|
118
|
+
e ? r.version = e : r.version = r.version.split(".").reduce((e, t, n, r) => e + (n === r.length - 1 ? +t + 1 : `${t}.`), ""), s(t.path, JSON.stringify(r, null, 2)), n.content = n.content.replace(/version\-v.+\-blue/, () => `version-v${r.version}-blue`), s(n.path, n.content);
|
|
119
|
+
}, ue = async (e) => {
|
|
120
|
+
let t = e.split("version")[1];
|
|
121
|
+
if (!t) return x(e);
|
|
122
|
+
let n = JSON.parse(i(c(process.cwd(), "package.json")).toString());
|
|
123
|
+
if (t === "++") {
|
|
124
|
+
S(n.version.split(".").reduce((e, t, n, r) => e + (n === r.length - 1 ? +t + 1 : `${t}.`), "")), b(), v("命令执行完成");
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
let r = t.split("@")[1];
|
|
128
|
+
r ? (S(r), b(), v("命令执行完成")) : x(e);
|
|
129
|
+
}, de = (n, r) => {
|
|
130
|
+
if (n.includes("build")) return le(n, r);
|
|
131
|
+
if (n.includes("version")) return ue(n);
|
|
132
|
+
y(t.hex("#f56c6c")(`\`auto ${n}${r ? ` ${r}` : ""}\` 命令不存在`)), e.help();
|
|
133
|
+
}, C = "https://gitee.com/biaovorg/project-template.git";
|
|
134
|
+
Object.keys({
|
|
135
|
+
vue: C,
|
|
136
|
+
react: C,
|
|
137
|
+
"uni-app": C,
|
|
138
|
+
electron: C,
|
|
139
|
+
node: C,
|
|
140
|
+
"node-simple": C
|
|
141
|
+
}).reduce((e, t, n) => e + (n ? ", " : "") + t, "");
|
|
142
|
+
var w = (e = "jsonc") => `auto-cli.${e}`;
|
|
143
|
+
l(import.meta.dirname, "./presetData.json");
|
|
144
|
+
var T = (e, t = !1) => {
|
|
145
|
+
if (!r(e)) return t ? {} : "";
|
|
146
|
+
let n = i(e).toString();
|
|
147
|
+
return t ? JSON.parse(ee(n)) : n;
|
|
148
|
+
}, fe = (e) => {
|
|
149
|
+
if (!r(e)) return {};
|
|
150
|
+
let t = i(e).toString();
|
|
151
|
+
try {
|
|
152
|
+
return p.load(t);
|
|
153
|
+
} catch {
|
|
154
|
+
return {};
|
|
155
|
+
}
|
|
156
|
+
}, E = (e = !1) => T(l(import.meta.dirname, w()), e), D = () => {
|
|
157
|
+
let [e, t] = [w(), w("yml")].map((e) => l(process.cwd(), e)), n = E(!0);
|
|
158
|
+
try {
|
|
159
|
+
Object.assign(n, fe(t), T(e, !0));
|
|
160
|
+
} catch {}
|
|
161
|
+
return n;
|
|
162
|
+
}, pe = (e, t = !1) => {
|
|
163
|
+
let n = E(t);
|
|
164
|
+
return t && (n = JSON.stringify(n, null, 2)), e.includes(".yml") ? n.trim().split("\n").slice(1, -1).reduce((e, t) => e + t.trim().replace(/[",]/g, "").replace("// ", "# ") + "\n", "") : n;
|
|
165
|
+
}, O = (e, t, n = " ") => Array.from({ length: t - e }, () => n).join("");
|
|
166
|
+
e.command("init").option("-f, --force", `强制替换 ${w()} 文件内容`, !1).option("--unc, --uncomment", `取消生成 ${w()} 带注释`, !1).option("-y, --yml", `生成 ${w("yml")} 文件`, !1).description("初始化配置文件").action(({ yml: e, uncomment: n, force: i }) => {
|
|
167
|
+
b();
|
|
168
|
+
let a = w(e ? "yml" : "jsonc"), o = l(process.cwd(), a);
|
|
169
|
+
if (r(o) && !i) {
|
|
170
|
+
b(t.yellow(`${a} 文件已存在`)), b(), b(t.yellow(`文件目录 ${o}`));
|
|
171
|
+
return;
|
|
172
|
+
}
|
|
173
|
+
s(o, pe(a, n)), v(`${a} 文件创建成功`), b(), b(t.green(`文件目录 ${o}`));
|
|
174
|
+
}), e.command("git [描述]").description("简化 Git 提交命令").action(async (e = "更新代码") => {
|
|
175
|
+
b(), b(`${t.yellow(">>")} 开始依次执行命令...`), b(), se(e).forEach(oe), v("全部命令执行完成"), b();
|
|
176
|
+
});
|
|
177
|
+
//#endregion
|
|
178
|
+
//#region src/commander/commands/mkdir.ts
|
|
179
|
+
var k = [
|
|
180
|
+
"dist",
|
|
181
|
+
"node_modules",
|
|
182
|
+
".git",
|
|
183
|
+
"miniprogram_npm"
|
|
184
|
+
], A = 0, j = !1, M = !1, N = 20, P = ({ prev: e, i: t, index: n, arr: r, curText: i }) => {
|
|
185
|
+
let a = Array.from({ length: t }).reduce((e) => e + `${t === 1 && n === r.length - 1 ? "└ " : "│ "} `, ""), o = e + a, s = (a + i).length, c = Array.from({ length: N + A - s }).reduce((e) => `${e}-`, " ");
|
|
186
|
+
return !j && (A = Math.max(A, s)), `${o}${i}${M ? c : ""}\n`;
|
|
187
|
+
}, F = (e, t = 0) => e.reduce((e, n, r, i) => {
|
|
188
|
+
let a;
|
|
189
|
+
return n.children ? (a = `├── ${n.name}`, P({
|
|
190
|
+
prev: e,
|
|
191
|
+
i: t,
|
|
192
|
+
index: r,
|
|
193
|
+
arr: i,
|
|
194
|
+
curText: a
|
|
195
|
+
}) + F(n.children, t + 1)) : (a = `${r === i.length - 1 ? "└── " : "├── "}${n.name}`, P({
|
|
196
|
+
prev: e,
|
|
197
|
+
i: t,
|
|
198
|
+
index: r,
|
|
199
|
+
arr: i,
|
|
200
|
+
curText: a
|
|
201
|
+
}));
|
|
202
|
+
}, ""), I = (e) => a(e, { withFileTypes: !0 }).sort((e, t) => t.isDirectory() - +e.isDirectory());
|
|
203
|
+
e.command("mkdir").option("-l, --line [数量]", "数量", !1).option("-n, --name [文件名称]", "文件名称", !1).option("-d, --depth [深度值]", "深度值", "3").description("生成目录结构文件").action(({ line: e, name: t }) => {
|
|
204
|
+
M = !!e, typeof e == "string" && (N = +e);
|
|
205
|
+
let n = process.cwd(), a = c(n, ".gitignore");
|
|
206
|
+
if (r(a)) {
|
|
207
|
+
let e = i(a).toString().split("\r\n");
|
|
208
|
+
k.push(...e);
|
|
209
|
+
}
|
|
210
|
+
let o = [{
|
|
211
|
+
name: n.split("\\").at(-1),
|
|
212
|
+
children: I(n).map((e) => {
|
|
213
|
+
let { name: t } = e, n = { name: t };
|
|
214
|
+
return !k.includes(t) && e.isDirectory() && (n.children = I(c(e.path, t)).map(({ name: e }) => ({ name: e }))), n;
|
|
215
|
+
})
|
|
216
|
+
}];
|
|
217
|
+
M && (F(o), j = !0), s(c(n, `${typeof t == "string" && t || "directory"}.md`), F(o));
|
|
218
|
+
});
|
|
219
|
+
//#endregion
|
|
220
|
+
//#region src/commander/commands/check.ts
|
|
221
|
+
var L = D(), [R] = ["package.json"].map((e) => l(process.cwd(), e)), me = (e, n) => {
|
|
222
|
+
let r = `\r查找进度:[${Array.from({ length: n }, (t, n) => n < e ? "=" : " ").join("")}] ${e}/${n} ${~~(e / n * 100)}%\r`, i = e === n ? t.green(r) : t.yellow(r);
|
|
223
|
+
process.stdout.write(i);
|
|
224
|
+
}, he = (e, t, n) => {
|
|
225
|
+
let r = "latest";
|
|
226
|
+
return L.resolve.some((t) => {
|
|
227
|
+
let n = t.lastIndexOf("@");
|
|
228
|
+
if (n <= 0) return !0;
|
|
229
|
+
let i = t.slice(0, n), a = t.slice(n + 1);
|
|
230
|
+
if (e === i) return r = a, !0;
|
|
231
|
+
}), {
|
|
232
|
+
name: e,
|
|
233
|
+
value: t,
|
|
234
|
+
newVersion: L.prefix + n[r],
|
|
235
|
+
tag: r
|
|
236
|
+
};
|
|
237
|
+
}, ge = (e, t) => (+!t + 1) * e.length, z = (e) => {
|
|
238
|
+
let [{ major: t = 0, minor: n = 0, patch: r = 0, release: i = "" }] = m(e);
|
|
239
|
+
return [
|
|
240
|
+
+t,
|
|
241
|
+
+n,
|
|
242
|
+
+r,
|
|
243
|
+
i
|
|
244
|
+
];
|
|
245
|
+
}, B = (e, n) => e ? "-" + t[n](e) : "", _e = (e, n) => {
|
|
246
|
+
let [r, i, a, o] = z(e), [s, c, l, u] = z(n);
|
|
247
|
+
return s > r ? t.red(n) : s < r ? !1 : c > i ? `${s}.${t.yellow(c)}.${t.yellow(l)}${B(u, "yellow")}` : c < i ? !1 : l > a ? `${s}.${c}.${t.green(l)}${B(u, "green")}` : l === a && u && u !== o ? `${s}.${c}.${l}${B(u, "green")}` : !1;
|
|
248
|
+
}, ve = (e) => {
|
|
249
|
+
let n = {};
|
|
250
|
+
e.forEach((e) => {
|
|
251
|
+
Object.entries(e).forEach(([e, t]) => {
|
|
252
|
+
n[e] = Math.max(t.length, n[e] ?? 0);
|
|
253
|
+
});
|
|
254
|
+
}), e.unshift({
|
|
255
|
+
name: "包名",
|
|
256
|
+
value: "版本",
|
|
257
|
+
newVersion: "新版本",
|
|
258
|
+
tag: "标签"
|
|
259
|
+
});
|
|
260
|
+
let r = [];
|
|
261
|
+
e.forEach(({ name: e, value: i, newVersion: a, tag: o }, s) => {
|
|
262
|
+
let [c, l, u, d] = Object.entries({
|
|
263
|
+
name: e,
|
|
264
|
+
value: i,
|
|
265
|
+
newVersion: a,
|
|
266
|
+
tag: o
|
|
267
|
+
}).map(([e, t]) => O(ge(t, s), n[e])), f = t.yellow("→"), p = !0;
|
|
268
|
+
if (s) {
|
|
269
|
+
let e = _e(i, a);
|
|
270
|
+
e ? a = e : p = !1;
|
|
271
|
+
} else e = t.green(e), i = t.green(i), a = t.green(a), o = t.green(o), f = " ";
|
|
272
|
+
let ee = `${e + c} ${l + i} ${f} ${u + a} ${d + o}`;
|
|
273
|
+
p && r.push(ee);
|
|
274
|
+
}), r.length > 1 ? r.forEach(b) : v("所有版本已是最新");
|
|
275
|
+
}, ye = async (e, t, n) => {
|
|
276
|
+
b();
|
|
277
|
+
let r = 0, i = [], a = Object.entries(e), o = a.map(async ([e, o]) => {
|
|
278
|
+
let s = he(e, o, (await te.packument(e, { registry: L.registry }))["dist-tags"]);
|
|
279
|
+
i.push(s), t.forEach((t) => {
|
|
280
|
+
let r = n[t];
|
|
281
|
+
r && r[e] && (r[e] = s.newVersion);
|
|
282
|
+
}), r++, await me(r, a.length);
|
|
283
|
+
});
|
|
284
|
+
return await Promise.all(o), b(), b(), i;
|
|
230
285
|
};
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
286
|
+
e.command("check").option("-u, --update", "更新 package.json 依赖内容", !1).description("升级 package.json 依赖版本").action(async ({ update: e }) => {
|
|
287
|
+
if (!r(R)) return y("package.json 文件不存在");
|
|
288
|
+
let t = e || L.check, n = i(R).toString(), a = JSON.parse(n), o = [
|
|
289
|
+
"dependencies",
|
|
290
|
+
"devDependencies",
|
|
291
|
+
"optionalDependencies"
|
|
292
|
+
], c = {}, l = JSON.parse(n);
|
|
293
|
+
o.forEach((e) => {
|
|
294
|
+
a[e] && Object.entries(a[e]).forEach(([e, t]) => {
|
|
295
|
+
!L.reject.includes(e) && (c[e] = t);
|
|
296
|
+
});
|
|
297
|
+
});
|
|
298
|
+
let u = await ye(c, o, l);
|
|
299
|
+
t ? (s(R, JSON.stringify(l, null, 2)), v("文件 package.json 已更新"), b()) : ve(u);
|
|
300
|
+
});
|
|
301
|
+
//#endregion
|
|
302
|
+
//#region src/commander/commands/comment.ts
|
|
303
|
+
var be = D(), V = "comment.md", [H, U] = ["package.json", V].map((e) => l(process.cwd(), e));
|
|
304
|
+
e.command("comment").description("生成依赖注释文件").action(() => {
|
|
305
|
+
if (!r(H)) return y("package.json 文件不存在");
|
|
306
|
+
let e = i(H).toString(), n = JSON.parse(e), a = [
|
|
307
|
+
"dependencies",
|
|
308
|
+
"devDependencies",
|
|
309
|
+
"optionalDependencies"
|
|
310
|
+
], o = "### 依赖解析\n\n";
|
|
311
|
+
a.forEach((e) => {
|
|
312
|
+
n[e] && (o += `#### ${e}\n\n`, Object.keys(n[e]).forEach((e) => {
|
|
313
|
+
o += `- \`${e}\`: ${be.comment[e] || ""}\n`;
|
|
314
|
+
}), o += "\n");
|
|
315
|
+
}), o = o.slice(0, -1), s(U, o), b(), v(`${V} 文件创建成功`), b(), b(t.green(`文件目录 ${U}`));
|
|
316
|
+
});
|
|
317
|
+
//#endregion
|
|
318
|
+
//#region src/commander/commands/vscode.ts
|
|
319
|
+
var W = {
|
|
320
|
+
recursive: !0,
|
|
321
|
+
force: !0
|
|
237
322
|
};
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
ee(l.semver);
|
|
256
|
-
else if (a(), a(p.red(`输入的版本 ${e} 不存在`)), a(), i.length) {
|
|
257
|
-
const m = i.map((d) => d.semver);
|
|
258
|
-
H.prompt({
|
|
259
|
-
type: "list",
|
|
260
|
-
name: "preset",
|
|
261
|
-
message: "请选择相似版本或输入版本进行安装:",
|
|
262
|
-
choices: [...m, e, "取消"]
|
|
263
|
-
}).then(({ preset: d }) => {
|
|
264
|
-
if (d !== "取消")
|
|
265
|
-
if (d === e) {
|
|
266
|
-
if (!c) return;
|
|
267
|
-
D(d);
|
|
268
|
-
} else
|
|
269
|
-
ee(d);
|
|
270
|
-
});
|
|
271
|
-
} else {
|
|
272
|
-
if (!c) return;
|
|
273
|
-
if (t.install) {
|
|
274
|
-
D(e);
|
|
275
|
-
return;
|
|
276
|
-
}
|
|
277
|
-
H.prompt({
|
|
278
|
-
type: "confirm",
|
|
279
|
-
name: "isInstall",
|
|
280
|
-
message: `是否安装 ${e}?`
|
|
281
|
-
}).then(({ isInstall: m }) => {
|
|
282
|
-
m && D(e);
|
|
283
|
-
});
|
|
284
|
-
}
|
|
323
|
+
e.command("vscode-config").description("更新 .vscode 配置文件").action(() => {
|
|
324
|
+
let e = `${+/* @__PURE__ */ new Date()}`, t = c(process.cwd()), r = c(t, e);
|
|
325
|
+
ne("direct:https://gitee.com/biaovorg/vscode-config.git#master", r, { clone: !0 }, async (e) => {
|
|
326
|
+
!e && n(c(r, ".vscode"), c(t, ".vscode"), W), o(r, W);
|
|
327
|
+
});
|
|
328
|
+
});
|
|
329
|
+
//#endregion
|
|
330
|
+
//#region src/commander/commands/node.ts
|
|
331
|
+
var G = (e, t, n) => {
|
|
332
|
+
let r = Object.entries(t), i = r.findIndex(([t]) => e === t), [a, o] = r[i];
|
|
333
|
+
if (o) {
|
|
334
|
+
if (n[a] === o) return i === r.length - 1 ? !0 : G(r[i + 1][0], t, n);
|
|
335
|
+
} else return !0;
|
|
336
|
+
}, K = (e) => {
|
|
337
|
+
e && (f(`nvm use ${e}`), b(), v(`切换成功 当前版本:${e}`), b());
|
|
338
|
+
}, q = (e) => {
|
|
339
|
+
e && f(`nvm install ${e}`);
|
|
285
340
|
};
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
},
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
}
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
}
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
341
|
+
e.command("node [版本号]").option("-i, --install", "是否安装此版本", !1).description("切换 node 版本,默认选择第一个版本").action((e, n) => {
|
|
342
|
+
let r = m(f("nvm ls").toString()), [{ major: i, minor: a, patch: o }] = m(e), s = [], c = r.find((e) => {
|
|
343
|
+
if (e.major === i) return s.push(e), G("minor", {
|
|
344
|
+
minor: a,
|
|
345
|
+
patch: o
|
|
346
|
+
}, e);
|
|
347
|
+
});
|
|
348
|
+
if (c) K(c.semver);
|
|
349
|
+
else if (b(), b(t.red(`输入的版本 ${e} 不存在`)), b(), s.length) {
|
|
350
|
+
let t = s.map((e) => e.semver);
|
|
351
|
+
h.prompt({
|
|
352
|
+
type: "list",
|
|
353
|
+
name: "preset",
|
|
354
|
+
message: "请选择相似版本或输入版本进行安装:",
|
|
355
|
+
choices: [
|
|
356
|
+
...t,
|
|
357
|
+
e,
|
|
358
|
+
"取消"
|
|
359
|
+
]
|
|
360
|
+
}).then(({ preset: t }) => {
|
|
361
|
+
if (t !== "取消") if (t === e) {
|
|
362
|
+
if (!o) return;
|
|
363
|
+
q(t);
|
|
364
|
+
} else K(t);
|
|
365
|
+
});
|
|
366
|
+
} else {
|
|
367
|
+
if (!o) return;
|
|
368
|
+
if (n.install) {
|
|
369
|
+
q(e);
|
|
370
|
+
return;
|
|
371
|
+
}
|
|
372
|
+
h.prompt({
|
|
373
|
+
type: "confirm",
|
|
374
|
+
name: "isInstall",
|
|
375
|
+
message: `是否安装 ${e}?`
|
|
376
|
+
}).then(({ isInstall: t }) => {
|
|
377
|
+
t && q(e);
|
|
378
|
+
});
|
|
379
|
+
}
|
|
380
|
+
});
|
|
381
|
+
//#endregion
|
|
382
|
+
//#region src/commander/commands/ai.ts
|
|
383
|
+
var J = [
|
|
384
|
+
"ANTHROPIC_AUTH_TOKEN",
|
|
385
|
+
"ANTHROPIC_BASE_URL",
|
|
386
|
+
"ANTHROPIC_MODEL",
|
|
387
|
+
"ANTHROPIC_SMALL_FAST_MODEL"
|
|
388
|
+
], xe = T(l(import.meta.dirname, "ai.jsonc"), !0), Se = Object.entries(xe)[0], Y = l(g.homedir(), ".claude/settings.json"), X = l(g.homedir(), ".claude/settings.local.json"), Z = l(g.homedir(), ".ai-model.json"), Ce = () => {
|
|
389
|
+
r(Y) || (y(`${Y} 文件不存在,请先检查或者去安装 Claude Code`), process.exit(1));
|
|
390
|
+
let e = JSON.parse(i(Y).toString());
|
|
391
|
+
return !e.env && (e.env = {}), e;
|
|
392
|
+
}, we = () => {
|
|
393
|
+
b(), r(Z) || (y("配置不存在,请先使用 `ai init` 初始化 AI 模型配置"), process.exit(1));
|
|
394
|
+
let e = JSON.parse(i(Z).toString()), n = Object.entries(e).filter(([e, t]) => {
|
|
395
|
+
if (e === Se[0]) return !1;
|
|
396
|
+
let n = t.env, r = Se[1].env;
|
|
397
|
+
return !(!n || J.some((e) => !n[e] || n[e] === r[e]));
|
|
398
|
+
});
|
|
399
|
+
return n.length || (b(`暂无已配置的 AI 模型,请先配置,路径 ${t.green(Z)}`), process.exit(1)), [n, e];
|
|
400
|
+
}, Te = () => {
|
|
401
|
+
if (b(), r(Z)) {
|
|
402
|
+
b(`配置已存在,路径 ${t.green(Z)}`);
|
|
403
|
+
return;
|
|
404
|
+
}
|
|
405
|
+
s(Z, JSON.stringify(xe, null, 2)), v(`配置已初始化,路径 ${t.green(Z)}`);
|
|
406
|
+
}, Ee = (e) => e.replace(/[\u4e00-\u9fa5]/g, "aa").length, De = () => {
|
|
407
|
+
let [e] = we(), n = 0, r = -1, i = Ce();
|
|
408
|
+
e.forEach(([e, t], a) => {
|
|
409
|
+
n = Math.max(n, Ee(e)), r < 0 && !J.some((e) => i.env[e] !== t.env[e]) && (r = a);
|
|
410
|
+
}), e.forEach(([e, i], a) => {
|
|
411
|
+
let { ANTHROPIC_BASE_URL: o } = i.env;
|
|
412
|
+
b(`${a === r ? t.green("*") : " "} ${e} ${O(Ee(e), n + 4, "-")} ${o}`);
|
|
413
|
+
});
|
|
414
|
+
}, Oe = async (e) => {
|
|
415
|
+
let n = Ce(), [r, i] = we();
|
|
416
|
+
r.some(([t]) => t === e) || (b(`模型 ${t.red(e)} 不存在`), process.exit(1)), J.some((t) => n.env[t] !== i[e].env[t]) ? (n.env = i[e].env, s(Y, JSON.stringify(n, null, 2)), v(`模型 ${t.green(e)} 已切换`)) : b(`当前正处于 ${t.green(e)} 模型,无需切换`);
|
|
417
|
+
}, ke = () => {
|
|
418
|
+
let e = "@anthropic-ai/claude-code";
|
|
419
|
+
try {
|
|
420
|
+
f(`npm list -g ${e} --depth=0`).toString().trim().includes(e) || (y(t.red(`请使用 nodejs 安装 ${e}`)), process.exit(1));
|
|
421
|
+
let i = f("npm root -g").toString().trim(), a = l(i, e, "cli.js"), o = l(i, e, "cli.bak.js"), s = l(i, e, "bin/claude.exe"), c = l(i, e, "bin/claude.bak.exe"), u = !1;
|
|
422
|
+
return r(s) ? (!r(c) && n(s, c), u = !0) : !r(o) && n(a, o), {
|
|
423
|
+
cliPath: a,
|
|
424
|
+
cliPathBak: o,
|
|
425
|
+
exePath: s,
|
|
426
|
+
exePathBak: c,
|
|
427
|
+
isExistExe: u
|
|
428
|
+
};
|
|
429
|
+
} catch {
|
|
430
|
+
y(t.red(`请使用 nodejs 安装 ${e}`)), process.exit(1);
|
|
431
|
+
}
|
|
432
|
+
}, Ae = async () => {
|
|
433
|
+
b(), b("开始汉化 Claude Code");
|
|
434
|
+
let { cliPath: e, exePath: t, exePathBak: n, isExistExe: r } = ke();
|
|
435
|
+
if (r) {
|
|
436
|
+
let e = i(n), r = (await import("./keyword-latest-Bj5j_G4f.js")).default;
|
|
437
|
+
Object.entries(r).forEach(([t, n]) => {
|
|
438
|
+
let r = Buffer.from(t, "utf8"), i = Buffer.from(n, "utf8");
|
|
439
|
+
if (!e.includes(r) || i.length > r.length) return;
|
|
440
|
+
let a = 0;
|
|
441
|
+
for (; (a = e.indexOf(r, a)) !== -1;) i.copy(e, a), e.fill(32, a + i.length, a + r.length), a += r.length;
|
|
442
|
+
}), s(t, e);
|
|
443
|
+
} else {
|
|
444
|
+
let t = i(e).toString(), n = (await import("./keyword-Bs4ml7oW.js")).default;
|
|
445
|
+
s(e, Object.entries(n).reduce((e, [t, n]) => {
|
|
446
|
+
let r = t.replace(/\n/g, "\\\\n").replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), i = n.replace(/\n/g, "\\n");
|
|
447
|
+
return ["`", "\\"].includes(r[0]) ? e.replace(new RegExp(r, "g"), n) : e.replace(RegExp(`\"${r}\"`, "g"), `\"${i}\"`).replace(RegExp(`(\'${r}\')`, "g"), `\'${i}\'`);
|
|
448
|
+
}, t));
|
|
449
|
+
}
|
|
450
|
+
v("Claude Code 已汉化");
|
|
451
|
+
}, je = () => {
|
|
452
|
+
b(), b("开始恢复 Claude Code");
|
|
453
|
+
let { cliPath: e, cliPathBak: t, exePath: r, exePathBak: i, isExistExe: a } = ke();
|
|
454
|
+
a ? n(i, r) : n(t, e), v("Claude Code 已恢复成英文");
|
|
455
|
+
}, Me = async () => {
|
|
456
|
+
b();
|
|
457
|
+
let e = (await import("./claude.settings-BShJAaF1.js")).default;
|
|
458
|
+
s(X, JSON.stringify(e, null, 2)), v(`Claude Code 配置成功,请前往查看:${t.yellow(X)}`);
|
|
459
|
+
}, Ne = async () => {
|
|
460
|
+
if (b(), b("开始配置 Claude Code 默认权限"), b(), !r(X)) {
|
|
461
|
+
Me();
|
|
462
|
+
return;
|
|
463
|
+
}
|
|
464
|
+
h.prompt({
|
|
465
|
+
type: "confirm",
|
|
466
|
+
name: "isOk",
|
|
467
|
+
message: "存在本地配置文件,继续配置会直接覆盖本地配置文件,是否继续 ?"
|
|
468
|
+
}).then(({ isOk: e }) => {
|
|
469
|
+
e && Me();
|
|
470
|
+
});
|
|
471
|
+
}, Q = e.command("ai").description("AI 命令,详细操作请查看 ai -h").helpOption("-h, --help", "输出所有命令").helpCommand(!1);
|
|
472
|
+
Q.command("init").description("初始化 AI 模型配置").action(Te), Q.command("ls").description("查看当前已配置的 AI 模型").action(De), Q.command("use <模型>").description("切换 AI 模型").action(Oe), Q.command("zh").description("汉化 Claude Code").action(Ae), Q.command("zh-restore").description("恢复汉化 Claude Code").action(je), Q.command("config").description("配置 Claude Code 默认权限").action(Ne), e.usage("[commands] [options]").version(ae, "-v, --version", "输出版本号").helpOption("-h, --help", "输出所有命令"), e.command("build[:环境] [描述]").description("简化打包提交命令"), e.command("version<[++]|[@<版本号>]>").description("例如:version++ 或者 version@1.0.0;自动更新 package.json 版本号,自动更新 `README.md` 中的 `version-v<version>-blue` 图标版本"), e.arguments("<cmd> [env]").action((e, t) => {
|
|
473
|
+
de(e, t);
|
|
474
|
+
}), process.argv.length < 3 ? e.help() : e.parse(process.argv);
|
|
475
|
+
//#endregion
|
|
476
|
+
//#region src/update.ts
|
|
477
|
+
var $ = re({
|
|
478
|
+
pkg: _,
|
|
479
|
+
updateCheckInterval: 1e3 * 1
|
|
364
480
|
});
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
message: `有更新 ${p.dim("{currentVersion}")}${p.reset(" → ")}${e}
|
|
385
|
-
运行 ${p.cyan("{updateCommand}@latest")} 命令更新
|
|
386
|
-
${p.dim.underline(t)}`
|
|
387
|
-
});
|
|
481
|
+
if ($.update && $.update.latest !== _.version) {
|
|
482
|
+
let e = "";
|
|
483
|
+
switch ($.update.type) {
|
|
484
|
+
case "major":
|
|
485
|
+
e = t.red("{latestVersion}");
|
|
486
|
+
break;
|
|
487
|
+
case "minor":
|
|
488
|
+
e = t.yellow("{latestVersion}");
|
|
489
|
+
break;
|
|
490
|
+
default:
|
|
491
|
+
e = t.green("{latestVersion}");
|
|
492
|
+
break;
|
|
493
|
+
}
|
|
494
|
+
let n = `https://github.com/biaov/${_.name}/compare/v${_.version}...v{latestVersion}`;
|
|
495
|
+
$.notify({
|
|
496
|
+
defer: !1,
|
|
497
|
+
isGlobal: !0,
|
|
498
|
+
message: `有更新 ${t.dim("{currentVersion}")}${t.reset(" → ")}${e}\n运行 ${t.cyan("{updateCommand}@latest")} 命令更新\n${t.dim.underline(n)}`
|
|
499
|
+
});
|
|
388
500
|
}
|
|
501
|
+
//#endregion
|