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