mine-auto-cli 2.9.0 → 2.9.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.
Files changed (2) hide show
  1. package/dist/index.js +263 -254
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1,26 +1,26 @@
1
- import { Help as e, program as t } from "commander";
2
- import n from "chalk";
3
- import { copyFileSync as r, cpSync as i, existsSync as a, mkdirSync as o, readFileSync as s, readdirSync as c, renameSync as l, rmSync as u, statSync as d, unlinkSync as f, writeFileSync as p } from "fs";
4
- import { basename as m, dirname as ee, extname as h, join as g, relative as te, resolve as _ } from "path";
5
- import v from "log-symbols";
6
- import y from "ora";
7
- import { execSync as b } from "child_process";
8
- import * as x from "js-yaml";
9
- import S from "strip-json-comments";
10
- import C from "pacote";
11
- import { parseRange as w } from "semver-utils";
12
- import T from "download-git-repo";
13
- import E from "inquirer";
14
- import D from "os";
15
- import { openBinary as ne } from "@avmc/bun-extractor";
16
- import O from "string-width";
17
- import re from "sharp";
18
- import ie from "update-notifier";
1
+ import { Command as e, Help as t, program as n } from "commander";
2
+ import r from "string-width";
3
+ import i from "chalk";
4
+ import { copyFileSync as a, cpSync as o, existsSync as s, mkdirSync as c, readFileSync as l, readdirSync as u, renameSync as d, rmSync as f, statSync as p, unlinkSync as m, writeFileSync as h } from "fs";
5
+ import { basename as g, dirname as ee, extname as _, join as v, relative as te, resolve as y } from "path";
6
+ import b from "log-symbols";
7
+ import x from "ora";
8
+ import { execSync as S } from "child_process";
9
+ import * as C from "js-yaml";
10
+ import w from "strip-json-comments";
11
+ import T from "pacote";
12
+ import { parseRange as E } from "semver-utils";
13
+ import D from "download-git-repo";
14
+ import O from "inquirer";
15
+ import ne from "os";
16
+ import { openBinary as re } from "@avmc/bun-extractor";
17
+ import ie from "sharp";
18
+ import ae from "update-notifier";
19
19
  // package.json
20
- var ae = "mine-auto-cli", oe = "2.9.0", k = {
21
- name: ae,
20
+ var oe = "mine-auto-cli", se = "2.9.1", k = {
21
+ name: oe,
22
22
  private: !1,
23
- version: oe,
23
+ version: se,
24
24
  exports: "./dist/index.js",
25
25
  main: "./dist/index.js",
26
26
  type: "module",
@@ -88,142 +88,142 @@ var ae = "mine-auto-cli", oe = "2.9.0", k = {
88
88
  vite: "^8.3.5"
89
89
  }
90
90
  }, A = (e) => {
91
- console.log(`${v.success} ${n.green("SUCCESS")} ${e}`);
91
+ console.log(`${b.success} ${i.green("SUCCESS")} ${e}`);
92
92
  }, j = (e) => {
93
- console.log(`${ae} ${v.error} ${n.red("ERROR")} ${e}`);
93
+ console.log(`${oe} ${b.error} ${i.red("ERROR")} ${e}`);
94
94
  }, M = (e) => {
95
95
  console.log(e ?? "");
96
- }, se = (e) => {
97
- M(`开始执行 ${n.cyanBright(e)} 命令`);
98
- let t = y({
96
+ }, ce = (e) => {
97
+ M(`开始执行 ${i.cyanBright(e)} 命令`);
98
+ let t = x({
99
99
  text: "正在执行命令中...",
100
100
  color: "yellow"
101
101
  });
102
- t.start(), M(b(e, { cwd: process.cwd() }).toString()), t.succeed(`${n.green(e)} 命令执行成功`), M();
103
- }, ce = (e) => [
102
+ t.start(), M(S(e, { cwd: process.cwd() }).toString()), t.succeed(`${i.green(e)} 命令执行成功`), M();
103
+ }, le = (e) => [
104
104
  "git add -A",
105
105
  `git commit -m ${e}`,
106
106
  "git push"
107
- ], le = (e, t) => [
107
+ ], ue = (e, t) => [
108
108
  `npm run ${e}`,
109
109
  "git add -A",
110
110
  `git commit -m ${t}`,
111
111
  "git push"
112
- ], ue = async (e, t = "打包") => {
113
- M(), M(`${n.yellow(">>")} 开始依次执行命令...`), M(), le(e, t).map(se), A("全部命令执行完成"), M();
114
- }, de = (e) => {
115
- M(), j(`\`${e}\` 命令错误,请检查你的命令`), M(), t.help();
112
+ ], de = async (e, t = "打包") => {
113
+ M(), M(`${i.yellow(">>")} 开始依次执行命令...`), M(), ue(e, t).map(ce), A("全部命令执行完成"), M();
114
+ }, N = (e) => {
115
+ M(), j(`\`${e}\` 命令错误,请检查你的命令`), M(), n.help();
116
116
  }, fe = (e) => {
117
117
  let [t, n] = ["package.json", "README.md"].map((e) => {
118
- let t = g(process.cwd(), e);
118
+ let t = v(process.cwd(), e);
119
119
  return {
120
120
  path: t,
121
- content: s(t).toString()
121
+ content: l(t).toString()
122
122
  };
123
123
  }), r = JSON.parse(t.content);
124
- r.version = e || r.version.split(".").reduce((e, t, n, r) => e + (n === r.length - 1 ? +t + 1 : `${t}.`), ""), p(t.path, JSON.stringify(r, null, 2)), n.content = n.content.replace(/version\-v.+\-blue/, () => `version-v${r.version}-blue`), p(n.path, n.content);
124
+ r.version = e || r.version.split(".").reduce((e, t, n, r) => e + (n === r.length - 1 ? +t + 1 : `${t}.`), ""), h(t.path, JSON.stringify(r, null, 2)), n.content = n.content.replace(/version\-v.+\-blue/, () => `version-v${r.version}-blue`), h(n.path, n.content);
125
125
  }, pe = async (e) => {
126
126
  let t = e.split("version")[1];
127
- if (!t) return de(e);
128
- let n = JSON.parse(s(g(process.cwd(), "package.json")).toString());
127
+ if (!t) return N(e);
128
+ let n = JSON.parse(l(v(process.cwd(), "package.json")).toString());
129
129
  if (t === "++") {
130
130
  fe(n.version.split(".").reduce((e, t, n, r) => e + (n === r.length - 1 ? +t + 1 : `${t}.`), "")), M(), A("命令执行完成");
131
131
  return;
132
132
  }
133
133
  let r = t.split("@")[1];
134
- r ? (fe(r), M(), A("命令执行完成")) : de(e);
135
- }, me = (e, r) => {
136
- if (e.includes("build")) return ue(e, r);
134
+ r ? (fe(r), M(), A("命令执行完成")) : N(e);
135
+ }, me = (e, t) => {
136
+ if (e.includes("build")) return de(e, t);
137
137
  if (e.includes("version")) return pe(e);
138
- j(n.hex("#f56c6c")(`\`auto ${e}${r ? ` ${r}` : ""}\` 命令不存在`)), t.help();
139
- }, N = "https://gitee.com/biaovorg/project-template.git";
138
+ j(i.hex("#f56c6c")(`\`auto ${e}${t ? ` ${t}` : ""}\` 命令不存在`)), n.help();
139
+ }, P = "https://gitee.com/biaovorg/project-template.git";
140
140
  Object.keys({
141
- vue: N,
142
- react: N,
143
- "uni-app": N,
144
- electron: N,
145
- node: N,
146
- "node-simple": N
141
+ vue: P,
142
+ react: P,
143
+ "uni-app": P,
144
+ electron: P,
145
+ node: P,
146
+ "node-simple": P
147
147
  }).reduce((e, t, n) => e + (n ? ", " : "") + t, "");
148
- var P = (e = "jsonc") => `auto-cli.${e}`;
149
- _(import.meta.dirname, "./presetData.json");
150
- var F = (e, t = !1) => {
151
- if (!a(e)) return t ? {} : "";
152
- let n = s(e).toString();
153
- return t ? JSON.parse(S(n)) : n;
148
+ var F = (e = "jsonc") => `auto-cli.${e}`;
149
+ y(import.meta.dirname, "./presetData.json");
150
+ var I = (e, t = !1) => {
151
+ if (!s(e)) return t ? {} : "";
152
+ let n = l(e).toString();
153
+ return t ? JSON.parse(w(n)) : n;
154
154
  }, he = (e) => {
155
- if (!a(e)) return {};
156
- let t = s(e).toString();
155
+ if (!s(e)) return {};
156
+ let t = l(e).toString();
157
157
  try {
158
- return x.load(t);
158
+ return C.load(t);
159
159
  } catch {
160
160
  return {};
161
161
  }
162
- }, I = (e = !1) => F(_(import.meta.dirname, P()), e), L = () => {
163
- let [e, t] = [P(), P("yml")].map((e) => _(process.cwd(), e)), n = I(!0);
162
+ }, ge = (e = !1) => I(y(import.meta.dirname, F()), e), _e = () => {
163
+ let [e, t] = [F(), F("yml")].map((e) => y(process.cwd(), e)), n = ge(!0);
164
164
  try {
165
- Object.assign(n, he(t), F(e, !0));
165
+ Object.assign(n, he(t), I(e, !0));
166
166
  } catch {}
167
167
  return n;
168
- }, ge = (e, t = !1) => {
169
- let n = I(t);
168
+ }, ve = (e, t = !1) => {
169
+ let n = ge(t);
170
170
  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;
171
- }, R = (e, t, n = " ") => Array.from({ length: t - e }, () => n).join(""), _e = () => `${+/* @__PURE__ */ new Date()}${Math.random().toString(36).substring(2, 6)}`;
172
- t.command("init").option("-f, --force", `强制替换 ${P()} 文件内容`, !1).option("--unc, --uncomment", `取消生成 ${P()} 带注释`, !1).option("-y, --yml", `生成 ${P("yml")} 文件`, !1).description("初始化配置文件").action(({ yml: e, uncomment: t, force: r }) => {
171
+ }, ye = (e, t, n = " ") => Array.from({ length: t - e }, () => n).join(""), be = () => `${+/* @__PURE__ */ new Date()}${Math.random().toString(36).substring(2, 6)}`;
172
+ n.command("init").option("-f, --force", `强制替换 ${F()} 文件内容`, !1).option("--unc, --uncomment", `取消生成 ${F()} 带注释`, !1).option("-y, --yml", `生成 ${F("yml")} 文件`, !1).description("初始化配置文件").action(({ yml: e, uncomment: t, force: n }) => {
173
173
  M();
174
- let i = P(e ? "yml" : "jsonc"), o = _(process.cwd(), i);
175
- a(o) && !r ? (M(n.yellow(`${i} 文件已存在`)), M(), M(n.yellow(`文件目录 ${o}`))) : (p(o, ge(i, t)), A(`${i} 文件创建成功`), M(), M(n.green(`文件目录 ${o}`)));
176
- }), t.command("git [描述]").description("简化 Git 提交命令").action(async (e = "更新代码") => {
177
- M(), M(`${n.yellow(">>")} 开始依次执行命令...`), M(), ce(e).forEach(se), A("全部命令执行完成"), M();
174
+ let r = F(e ? "yml" : "jsonc"), a = y(process.cwd(), r);
175
+ s(a) && !n ? (M(i.yellow(`${r} 文件已存在`)), M(), M(i.yellow(`文件目录 ${a}`))) : (h(a, ve(r, t)), A(`${r} 文件创建成功`), M(), M(i.green(`文件目录 ${a}`)));
176
+ }), n.command("git [描述]").description("简化 Git 提交命令").action(async (e = "更新代码") => {
177
+ M(), M(`${i.yellow(">>")} 开始依次执行命令...`), M(), le(e).forEach(ce), A("全部命令执行完成"), M();
178
178
  });
179
179
  // src/commander/commands/mkdir.ts
180
- var ve = [
180
+ var xe = [
181
181
  "dist",
182
182
  "node_modules",
183
183
  ".git",
184
184
  "miniprogram_npm"
185
- ], z = 0, ye = !1, B = !1, be = 20, xe = ({ prev: e, i: t, index: n, arr: r, curText: i }) => {
186
- 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: be + z - s }).reduce((e) => `${e}-`, " ");
187
- return !ye && (z = Math.max(z, s)), `${o}${i}${B ? c : ""}\n`;
188
- }, V = (e, t = 0) => e.reduce((e, n, r, i) => {
185
+ ], L = 0, Se = !1, R = !1, Ce = 20, z = ({ prev: e, i: t, index: n, arr: r, curText: i }) => {
186
+ 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: Ce + L - s }).reduce((e) => `${e}-`, " ");
187
+ return !Se && (L = Math.max(L, s)), `${o}${i}${R ? c : ""}\n`;
188
+ }, B = (e, t = 0) => e.reduce((e, n, r, i) => {
189
189
  let a;
190
- return n.children ? (a = `├── ${n.name}`, xe({
190
+ return n.children ? (a = `├── ${n.name}`, z({
191
191
  prev: e,
192
192
  i: t,
193
193
  index: r,
194
194
  arr: i,
195
195
  curText: a
196
- }) + V(n.children, t + 1)) : (a = `${r === i.length - 1 ? "└── " : "├── "}${n.name}`, xe({
196
+ }) + B(n.children, t + 1)) : (a = `${r === i.length - 1 ? "└── " : "├── "}${n.name}`, z({
197
197
  prev: e,
198
198
  i: t,
199
199
  index: r,
200
200
  arr: i,
201
201
  curText: a
202
202
  }));
203
- }, ""), Se = (e) => c(e, { withFileTypes: !0 }).sort((e, t) => +t.isDirectory() - e.isDirectory());
204
- t.command("mkdir").option("-l, --line [数量]", "数量", !1).option("-n, --name [文件名称]", "文件名称", !1).option("-d, --depth [深度值]", "深度值", "3").description("生成目录结构文件").action(({ line: e, name: t }) => {
205
- B = !!e, typeof e == "string" && (be = +e);
206
- let n = process.cwd(), r = g(n, ".gitignore");
207
- if (a(r)) {
208
- let e = s(r).toString().split("\r\n");
209
- ve.push(...e);
203
+ }, ""), we = (e) => u(e, { withFileTypes: !0 }).sort((e, t) => +t.isDirectory() - e.isDirectory());
204
+ n.command("mkdir").option("-l, --line [数量]", "数量", !1).option("-n, --name [文件名称]", "文件名称", !1).option("-d, --depth [深度值]", "深度值", "3").description("生成目录结构文件").action(({ line: e, name: t }) => {
205
+ R = !!e, typeof e == "string" && (Ce = +e);
206
+ let n = process.cwd(), r = v(n, ".gitignore");
207
+ if (s(r)) {
208
+ let e = l(r).toString().split("\r\n");
209
+ xe.push(...e);
210
210
  }
211
211
  let i = [{
212
212
  name: n.split("\\").at(-1),
213
- children: Se(n).map((e) => {
213
+ children: we(n).map((e) => {
214
214
  let { name: t } = e, n = { name: t };
215
- return !ve.includes(t) && e.isDirectory() && (n.children = Se(g(e.path, t)).map(({ name: e }) => ({ name: e }))), n;
215
+ return !xe.includes(t) && e.isDirectory() && (n.children = we(v(e.path, t)).map(({ name: e }) => ({ name: e }))), n;
216
216
  })
217
217
  }];
218
- B && (V(i), ye = !0), p(g(n, `${typeof t == "string" && t || "directory"}.md`), V(i));
218
+ R && (B(i), Se = !0), h(v(n, `${typeof t == "string" && t || "directory"}.md`), B(i));
219
219
  });
220
220
  // src/commander/commands/check.ts
221
- var H = L(), [U] = ["package.json"].map((e) => _(process.cwd(), e)), Ce = (e, t) => {
222
- let r = `\r查找进度:[${Array.from({ length: t }, (t, n) => n < e ? "=" : " ").join("")}] ${e}/${t} ${~~(e / t * 100)}%\r`, i = e === t ? n.green(r) : n.yellow(r);
223
- process.stdout.write(i);
224
- }, we = (e, t, n) => {
221
+ var V = _e(), [H] = ["package.json"].map((e) => y(process.cwd(), e)), Te = (e, t) => {
222
+ let n = `\r查找进度:[${Array.from({ length: t }, (t, n) => n < e ? "=" : " ").join("")}] ${e}/${t} ${~~(e / t * 100)}%\r`, r = e === t ? i.green(n) : i.yellow(n);
223
+ process.stdout.write(r);
224
+ }, Ee = (e, t, n) => {
225
225
  let r = "latest";
226
- return H.resolve.some((t) => {
226
+ return V.resolve.some((t) => {
227
227
  let n = t.lastIndexOf("@");
228
228
  if (n <= 0) return !0;
229
229
  let i = t.slice(0, n), a = t.slice(n + 1);
@@ -231,21 +231,21 @@ var H = L(), [U] = ["package.json"].map((e) => _(process.cwd(), e)), Ce = (e, t)
231
231
  }), {
232
232
  name: e,
233
233
  value: t,
234
- newVersion: H.prefix + n[r],
234
+ newVersion: V.prefix + n[r],
235
235
  tag: r
236
236
  };
237
- }, Te = (e, t) => (+!t + 1) * e.length, Ee = (e) => {
238
- let [{ major: t = 0, minor: n = 0, patch: r = 0, release: i = "" }] = w(e);
237
+ }, De = (e, t) => (+!t + 1) * e.length, Oe = (e) => {
238
+ let [{ major: t = 0, minor: n = 0, patch: r = 0, release: i = "" }] = E(e);
239
239
  return [
240
240
  +t,
241
241
  +n,
242
242
  +r,
243
243
  i
244
244
  ];
245
- }, W = (e, t) => e ? "-" + n[t](e) : "", De = (e, t) => {
246
- let [r, i, a, o] = Ee(e), [s, c, l, u] = Ee(t);
247
- return s > r ? n.red(t) : s < r ? !1 : c > i ? `${s}.${n.yellow(c)}.${n.yellow(l)}${W(u, "yellow")}` : c < i ? !1 : l > a ? `${s}.${c}.${n.green(l)}${W(u, "green")}` : l === a && u && u !== o ? `${s}.${c}.${l}${W(u, "green")}` : !1;
248
- }, Oe = (e) => {
245
+ }, U = (e, t) => e ? "-" + i[t](e) : "", ke = (e, t) => {
246
+ let [n, r, a, o] = Oe(e), [s, c, l, u] = Oe(t);
247
+ return s > n ? i.red(t) : s < n ? !1 : c > r ? `${s}.${i.yellow(c)}.${i.yellow(l)}${U(u, "yellow")}` : c < r ? !1 : l > a ? `${s}.${c}.${i.green(l)}${U(u, "green")}` : l === a && u && u !== o ? `${s}.${c}.${l}${U(u, "green")}` : !1;
248
+ }, Ae = (e) => {
249
249
  let t = {};
250
250
  e.forEach((e) => {
251
251
  Object.entries(e).forEach(([e, n]) => {
@@ -257,95 +257,95 @@ var H = L(), [U] = ["package.json"].map((e) => _(process.cwd(), e)), Ce = (e, t)
257
257
  newVersion: "新版本",
258
258
  tag: "标签"
259
259
  });
260
- let r = [];
261
- e.forEach(({ name: e, value: i, newVersion: a, tag: o }, s) => {
260
+ let n = [];
261
+ e.forEach(({ name: e, value: r, newVersion: a, tag: o }, s) => {
262
262
  let [c, l, u, d] = Object.entries({
263
263
  name: e,
264
- value: i,
264
+ value: r,
265
265
  newVersion: a,
266
266
  tag: o
267
- }).map(([e, n]) => R(Te(n, s), t[e])), f = n.yellow("→"), p = !0;
267
+ }).map(([e, n]) => ye(De(n, s), t[e])), f = i.yellow("→"), p = !0;
268
268
  if (s) {
269
- let e = De(i, a);
269
+ let e = ke(r, a);
270
270
  e ? a = e : p = !1;
271
- } else e = n.green(e), i = n.green(i), a = n.green(a), o = n.green(o), f = " ";
272
- let m = `${e + c} ${l + i} ${f} ${u + a} ${d + o}`;
273
- p && r.push(m);
274
- }), r.length > 1 ? r.forEach(M) : A("所有版本已是最新");
275
- }, ke = async (e, t, n) => {
271
+ } else e = i.green(e), r = i.green(r), a = i.green(a), o = i.green(o), f = " ";
272
+ let m = `${e + c} ${l + r} ${f} ${u + a} ${d + o}`;
273
+ p && n.push(m);
274
+ }), n.length > 1 ? n.forEach(M) : A("所有版本已是最新");
275
+ }, je = async (e, t, n) => {
276
276
  M();
277
277
  let r = 0, i = [], a = Object.entries(e), o = a.map(async ([e, o]) => {
278
- let s = we(e, o, (await C.packument(e, { registry: H.registry }))["dist-tags"]);
278
+ let s = Ee(e, o, (await T.packument(e, { registry: V.registry }))["dist-tags"]);
279
279
  i.push(s), t.forEach((t) => {
280
280
  let r = n[t];
281
281
  r && r[e] && (r[e] = s.newVersion);
282
- }), r++, await Ce(r, a.length);
282
+ }), r++, await Te(r, a.length);
283
283
  });
284
284
  return await Promise.all(o), M(), M(), i;
285
285
  };
286
- t.command("check").option("-u, --update", "更新 package.json 依赖内容", !1).description("升级 package.json 依赖版本").action(async ({ update: e }) => {
287
- if (!a(U)) return j("package.json 文件不存在");
288
- let t = e || H.check, n = s(U).toString(), r = JSON.parse(n), i = [
286
+ n.command("check").option("-u, --update", "更新 package.json 依赖内容", !1).description("升级 package.json 依赖版本").action(async ({ update: e }) => {
287
+ if (!s(H)) return j("package.json 文件不存在");
288
+ let t = e || V.check, n = l(H).toString(), r = JSON.parse(n), i = [
289
289
  "dependencies",
290
290
  "devDependencies",
291
291
  "optionalDependencies"
292
- ], o = {}, c = JSON.parse(n);
292
+ ], a = {}, o = JSON.parse(n);
293
293
  i.forEach((e) => {
294
294
  r[e] && Object.entries(r[e]).forEach(([e, t]) => {
295
- !H.reject.includes(e) && (o[e] = t);
295
+ !V.reject.includes(e) && (a[e] = t);
296
296
  });
297
297
  });
298
- let l = await ke(o, i, c);
299
- t ? (p(U, JSON.stringify(c, null, 2)), A("文件 package.json 已更新"), M()) : Oe(l);
298
+ let c = await je(a, i, o);
299
+ t ? (h(H, JSON.stringify(o, null, 2)), A("文件 package.json 已更新"), M()) : Ae(c);
300
300
  });
301
301
  // src/commander/commands/comment.ts
302
- var Ae = L(), je = "comment.md", [Me, Ne] = ["package.json", je].map((e) => _(process.cwd(), e));
303
- t.command("comment").description("生成依赖注释文件").action(() => {
304
- if (!a(Me)) return j("package.json 文件不存在");
305
- let e = s(Me).toString(), t = JSON.parse(e), r = [
302
+ var Me = _e(), Ne = "comment.md", [W, Pe] = ["package.json", Ne].map((e) => y(process.cwd(), e));
303
+ n.command("comment").description("生成依赖注释文件").action(() => {
304
+ if (!s(W)) return j("package.json 文件不存在");
305
+ let e = l(W).toString(), t = JSON.parse(e), n = [
306
306
  "dependencies",
307
307
  "devDependencies",
308
308
  "optionalDependencies"
309
- ], i = "### 依赖解析\n\n";
310
- r.forEach((e) => {
311
- t[e] && (i += `#### ${e}\n\n`, Object.keys(t[e]).forEach((e) => {
312
- i += `- \`${e}\`: ${Ae.comment[e] || ""}\n`;
313
- }), i += "\n");
314
- }), i = i.slice(0, -1), p(Ne, i), M(), A(`${je} 文件创建成功`), M(), M(n.green(`文件目录 ${Ne}`));
309
+ ], r = "### 依赖解析\n\n";
310
+ n.forEach((e) => {
311
+ t[e] && (r += `#### ${e}\n\n`, Object.keys(t[e]).forEach((e) => {
312
+ r += `- \`${e}\`: ${Me.comment[e] || ""}\n`;
313
+ }), r += "\n");
314
+ }), r = r.slice(0, -1), h(Pe, r), M(), A(`${Ne} 文件创建成功`), M(), M(i.green(`文件目录 ${Pe}`));
315
315
  });
316
316
  // src/commander/commands/vscode.ts
317
- var Pe = {
317
+ var Fe = {
318
318
  recursive: !0,
319
319
  force: !0
320
320
  };
321
- t.command("vscode-config").description("更新 .vscode 配置文件").action(() => {
322
- let e = `${+/* @__PURE__ */ new Date()}`, t = g(process.cwd()), n = g(t, e);
323
- T("direct:https://gitee.com/biaovorg/vscode-config.git#master", n, { clone: !0 }, async (e) => {
324
- !e && i(g(n, ".vscode"), g(t, ".vscode"), Pe), u(n, Pe);
321
+ n.command("vscode-config").description("更新 .vscode 配置文件").action(() => {
322
+ let e = `${+/* @__PURE__ */ new Date()}`, t = v(process.cwd()), n = v(t, e);
323
+ D("direct:https://gitee.com/biaovorg/vscode-config.git#master", n, { clone: !0 }, async (e) => {
324
+ !e && o(v(n, ".vscode"), v(t, ".vscode"), Fe), f(n, Fe);
325
325
  });
326
326
  });
327
327
  // src/commander/commands/node.ts
328
- var Fe = (e, t, n) => {
328
+ var Ie = (e, t, n) => {
329
329
  let r = Object.entries(t), i = r.findIndex(([t]) => e === t), [a, o] = r[i];
330
330
  if (o) {
331
- if (n[a] === o) return i === r.length - 1 || Fe(r[i + 1][0], t, n);
331
+ if (n[a] === o) return i === r.length - 1 || Ie(r[i + 1][0], t, n);
332
332
  } else return !0;
333
- }, Ie = (e) => {
334
- e && (b(`nvm use ${e}`), M(), A(`切换成功 当前版本:${e}`), M());
333
+ }, Le = (e) => {
334
+ e && (S(`nvm use ${e}`), M(), A(`切换成功 当前版本:${e}`), M());
335
335
  }, G = (e) => {
336
- e && b(`nvm install ${e}`);
336
+ e && S(`nvm install ${e}`);
337
337
  };
338
- t.command("node [版本号]").option("-i, --install", "是否安装此版本", !1).description("切换 node 版本,默认选择第一个版本").action((e, t) => {
339
- let r = b("nvm ls").toString(), i = w(r), [{ major: a, minor: o, patch: s }] = w(e), c = [], l = i.find((e) => {
340
- if (e.major === a) return c.push(e), Fe("minor", {
338
+ n.command("node [版本号]").option("-i, --install", "是否安装此版本", !1).description("切换 node 版本,默认选择第一个版本").action((e, t) => {
339
+ let n = S("nvm ls").toString(), r = E(n), [{ major: a, minor: o, patch: s }] = E(e), c = [], l = r.find((e) => {
340
+ if (e.major === a) return c.push(e), Ie("minor", {
341
341
  minor: o,
342
342
  patch: s
343
343
  }, e);
344
344
  });
345
- if (l) Ie(l.semver);
346
- else if (M(), M(n.red(`输入的版本 ${e} 不存在`)), M(), c.length) {
345
+ if (l) Le(l.semver);
346
+ else if (M(), M(i.red(`输入的版本 ${e} 不存在`)), M(), c.length) {
347
347
  let t = c.map((e) => e.semver);
348
- E.prompt({
348
+ O.prompt({
349
349
  type: "list",
350
350
  name: "preset",
351
351
  message: "请选择相似版本或输入版本进行安装:",
@@ -359,7 +359,7 @@ t.command("node [版本号]").option("-i, --install", "是否安装此版本", !
359
359
  if (t === e) {
360
360
  if (!s) return;
361
361
  G(t);
362
- } else Ie(t);
362
+ } else Le(t);
363
363
  }
364
364
  });
365
365
  } else {
@@ -368,7 +368,7 @@ t.command("node [版本号]").option("-i, --install", "是否安装此版本", !
368
368
  G(e);
369
369
  return;
370
370
  }
371
- E.prompt({
371
+ O.prompt({
372
372
  type: "confirm",
373
373
  name: "isInstall",
374
374
  message: `是否安装 ${e}?`
@@ -383,100 +383,100 @@ var K = [
383
383
  "ANTHROPIC_BASE_URL",
384
384
  "ANTHROPIC_MODEL",
385
385
  "ANTHROPIC_SMALL_FAST_MODEL"
386
- ], Le = F(_(import.meta.dirname, "ai.jsonc"), !0), Re = Object.entries(Le)[0], q = _(D.homedir(), ".claude/settings.json"), J = _(D.homedir(), ".ai-model.json"), Y = () => {
387
- a(q) || (j(`${q} 文件不存在,请先检查或者去安装 Claude Code`), process.exit(1));
388
- let e = JSON.parse(s(q).toString());
386
+ ], Re = I(y(import.meta.dirname, "ai.jsonc"), !0), ze = Object.entries(Re)[0], q = y(ne.homedir(), ".claude/settings.json"), J = y(ne.homedir(), ".ai-model.json"), Y = () => {
387
+ s(q) || (j(`${q} 文件不存在,请先检查或者去安装 Claude Code`), process.exit(1));
388
+ let e = JSON.parse(l(q).toString());
389
389
  return !e.env && (e.env = {}), e;
390
- }, ze = () => {
391
- M(), a(J) || (j("配置不存在,请先使用 `ai init` 初始化 AI 模型配置"), process.exit(1));
392
- let e = JSON.parse(s(J).toString()), t = Object.entries(e).filter(([e, t]) => {
393
- if (e === Re[0]) return !1;
394
- let n = t.env, r = Re[1].env;
390
+ }, Be = () => {
391
+ M(), s(J) || (j("配置不存在,请先使用 `ai init` 初始化 AI 模型配置"), process.exit(1));
392
+ let e = JSON.parse(l(J).toString()), t = Object.entries(e).filter(([e, t]) => {
393
+ if (e === ze[0]) return !1;
394
+ let n = t.env, r = ze[1].env;
395
395
  return !(!n || K.some((e) => !n[e] || n[e] === r[e]));
396
396
  });
397
- return t.length || (M(`暂无已配置的 AI 模型,请先配置,路径 ${n.green(J)}`), process.exit(1)), [t, e];
398
- }, Be = () => {
399
- M(), a(J) ? M(`配置已存在,路径 ${n.green(J)}`) : (p(J, JSON.stringify(Le, null, 2)), A(`配置已初始化,路径 ${n.green(J)}`));
400
- }, Ve = (e) => e.replace(/[\u4e00-\u9fa5]/g, "aa").length, He = () => {
401
- let [e] = ze(), t = 0, r = -1, i = Y();
402
- e.forEach(([e, n], a) => {
403
- t = Math.max(t, Ve(e)), r < 0 && !K.some((e) => i.env[e] !== n.env[e]) && (r = a);
404
- }), e.forEach(([e, i], a) => {
405
- let { ANTHROPIC_BASE_URL: o } = i.env;
406
- M(`${a === r ? n.green("*") : " "} ${e} ${R(Ve(e), t + 4, "-")} ${o}`);
397
+ return t.length || (M(`暂无已配置的 AI 模型,请先配置,路径 ${i.green(J)}`), process.exit(1)), [t, e];
398
+ }, Ve = () => {
399
+ M(), s(J) ? M(`配置已存在,路径 ${i.green(J)}`) : (h(J, JSON.stringify(Re, null, 2)), A(`配置已初始化,路径 ${i.green(J)}`));
400
+ }, He = (e) => e.replace(/[\u4e00-\u9fa5]/g, "aa").length, Ue = () => {
401
+ let [e] = Be(), t = 0, n = -1, r = Y();
402
+ e.forEach(([e, i], a) => {
403
+ t = Math.max(t, He(e)), n < 0 && !K.some((e) => r.env[e] !== i.env[e]) && (n = a);
404
+ }), e.forEach(([e, r], a) => {
405
+ let { ANTHROPIC_BASE_URL: o } = r.env;
406
+ M(`${a === n ? i.green("*") : " "} ${e} ${ye(He(e), t + 4, "-")} ${o}`);
407
407
  });
408
- }, Ue = async (e) => {
409
- let t = Y(), [r, i] = ze();
410
- r.some(([t]) => t === e) || (M(`模型 ${n.red(e)} 不存在`), process.exit(1)), K.some((n) => t.env[n] !== i[e].env[n]) ? (t.env = i[e].env, p(q, JSON.stringify(t, null, 2)), A(`模型 ${n.green(e)} 已切换`)) : M(`当前正处于 ${n.green(e)} 模型,无需切换`);
411
- }, We = () => {
408
+ }, We = async (e) => {
409
+ let t = Y(), [n, r] = Be();
410
+ n.some(([t]) => t === e) || (M(`模型 ${i.red(e)} 不存在`), process.exit(1)), K.some((n) => t.env[n] !== r[e].env[n]) ? (t.env = r[e].env, h(q, JSON.stringify(t, null, 2)), A(`模型 ${i.green(e)} 已切换`)) : M(`当前正处于 ${i.green(e)} 模型,无需切换`);
411
+ }, Ge = () => {
412
412
  let e = "@anthropic-ai/claude-code";
413
413
  try {
414
- b(`npm list -g ${e} --depth=0`).toString().trim().includes(e) || (j(n.red(`请使用 nodejs 安装 ${e}`)), process.exit(1));
415
- let t = b("npm root -g").toString().trim(), r = _(t, e, "cli.js"), o = _(t, e, "cli.bak.js"), s = _(t, e, "bin/claude.exe"), c = _(t, e, "bin/claude.zh.exe"), l = _(t, e, "bin/claude.bak.exe"), u = !1;
416
- return a(s) ? (!a(l) && i(s, l), u = !0) : !a(o) && i(r, o), {
417
- cliPath: r,
418
- cliPathBak: o,
419
- exePath: s,
414
+ S(`npm list -g ${e} --depth=0`).toString().trim().includes(e) || (j(i.red(`请使用 nodejs 安装 ${e}`)), process.exit(1));
415
+ let t = S("npm root -g").toString().trim(), n = y(t, e, "cli.js"), r = y(t, e, "cli.bak.js"), a = y(t, e, "bin/claude.exe"), c = y(t, e, "bin/claude.zh.exe"), l = y(t, e, "bin/claude.bak.exe"), u = !1;
416
+ return s(a) ? (!s(l) && o(a, l), u = !0) : !s(r) && o(n, r), {
417
+ cliPath: n,
418
+ cliPathBak: r,
419
+ exePath: a,
420
420
  exeZhPath: c,
421
421
  exePathBak: l,
422
422
  isExistExe: u
423
423
  };
424
424
  } catch {
425
- j(n.red(`请使用 nodejs 安装 ${e}`)), process.exit(1);
425
+ j(i.red(`请使用 nodejs 安装 ${e}`)), process.exit(1);
426
426
  }
427
- }, Ge = async () => {
427
+ }, Ke = async () => {
428
428
  M(), M("开始汉化 Claude Code");
429
- let e = We(), { cliPath: t, exePath: n, exeZhPath: r, isExistExe: o } = e;
430
- if (o) {
431
- if (a(r)) {
432
- i(r, n);
429
+ let e = Ge(), { cliPath: t, exePath: n, exeZhPath: r, isExistExe: i } = e;
430
+ if (i) {
431
+ if (s(r)) {
432
+ o(r, n);
433
433
  return;
434
434
  }
435
- await Ye(e), i(r, n);
435
+ await Xe(e), o(r, n);
436
436
  } else {
437
- let e = s(t).toString(), n = (await import("./keyword-CgLMNoOo.js")).default, r = Object.entries(n).reduce((e, [t, n]) => {
437
+ let e = l(t).toString(), n = (await import("./keyword-CgLMNoOo.js")).default, r = Object.entries(n).reduce((e, [t, n]) => {
438
438
  let r = t.replace(/\n/g, "\\\\n").replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), i = n.replace(/\n/g, "\\n");
439
439
  return ["`", "\\"].includes(r[0]) ? e.replace(new RegExp(r, "g"), n) : e.replace(RegExp(`\"${r}\"`, "g"), `\"${i}\"`).replace(RegExp(`(\'${r}\')`, "g"), `\'${i}\'`);
440
440
  }, e);
441
- p(t, r);
441
+ h(t, r);
442
442
  }
443
443
  A("Claude Code 已汉化");
444
- }, Ke = () => {
444
+ }, qe = () => {
445
445
  M(), M("开始恢复 Claude Code");
446
- let { cliPath: e, cliPathBak: t, exePath: n, exePathBak: r, isExistExe: a } = We();
447
- a ? i(r, n) : i(t, e), A("Claude Code 已恢复成英文");
448
- }, qe = async () => {
446
+ let { cliPath: e, cliPathBak: t, exePath: n, exePathBak: r, isExistExe: i } = Ge();
447
+ i ? o(r, n) : o(t, e), A("Claude Code 已恢复成英文");
448
+ }, Je = async () => {
449
449
  M();
450
450
  let e = (await import("./claude.settings-D209xJfD.js")).default, t = Y();
451
- e.env && Object.assign(e.env, t.env), Object.assign(t, e), p(q, JSON.stringify(t, null, 2)), A(`Claude Code 配置成功,请前往查看:${n.yellow(q)}`);
452
- }, Je = async () => {
453
- M(), M("开始配置 Claude Code 默认权限"), M(), a(q) ? E.prompt({
451
+ e.env && Object.assign(e.env, t.env), Object.assign(t, e), h(q, JSON.stringify(t, null, 2)), A(`Claude Code 配置成功,请前往查看:${i.yellow(q)}`);
452
+ }, Ye = async () => {
453
+ M(), M("开始配置 Claude Code 默认权限"), M(), s(q) ? O.prompt({
454
454
  type: "confirm",
455
455
  name: "isOk",
456
456
  message: "存在本地配置文件,继续配置会直接覆盖本地配置文件里的属性内容,是否继续 ?"
457
457
  }).then(({ isOk: e }) => {
458
- e && qe();
459
- }) : qe();
460
- }, Ye = async ({ cliPath: e, exePath: t, exeZhPath: n, exePathBak: r, isExistExe: i }) => {
461
- let a = ee(t), o = t, c = _(a, _e());
462
- b(`npx bun-extractor "${o}" -o "${c}"`, { stdio: "ignore" });
463
- let l = ne(s(o)), u = _(c, l.entryPoint.path), d = s(u).toString(), f = (await import("./keyword-CgLMNoOo.js")).default, m = Object.entries(f).reduce((e, [t, n]) => {
458
+ e && Je();
459
+ }) : Je();
460
+ }, Xe = async ({ cliPath: e, exePath: t, exeZhPath: n, exePathBak: r, isExistExe: i }) => {
461
+ let a = ee(t), o = t, s = y(a, be());
462
+ S(`npx bun-extractor "${o}" -o "${s}"`, { stdio: "ignore" });
463
+ let c = re(l(o)), u = y(s, c.entryPoint.path), d = l(u).toString(), f = (await import("./keyword-CgLMNoOo.js")).default, p = Object.entries(f).reduce((e, [t, n]) => {
464
464
  let r = t.replace(/\n/g, "\\\\n").replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), i = n.replace(/\n/g, "\\n");
465
465
  return ["`", "\\"].includes(r[0]) ? e.replace(new RegExp(r, "g"), n) : e.replace(RegExp(`\"${r}\"`, "g"), `\"${i}\"`).replace(RegExp(`(\'${r}\')`, "g"), `\'${i}\'`);
466
- }, d), h = Array.from(m).map((e) => {
466
+ }, d), m = Array.from(p).map((e) => {
467
467
  let t = e.charCodeAt(0);
468
468
  return t >= 19968 && t <= 40959 ? `\\u${t.toString(16).padStart(4, "0")}` : e;
469
469
  }).join(""), g = u.slice(0, -3) + ".zh.js";
470
- p(g, h);
471
- let te = `import { dirname, resolve } from 'node:path'
472
- await import(resolve(dirname(process.execPath), "${g.replace(/\\/g, "/")}"))`, v = _(c, "entry.js");
473
- p(v, te), b(`bun build ${v} --compile --icon=claude-code.ico --outfile ${o.slice(0, -4) + ".zh.exe"}`, { stdio: "ignore" });
474
- }, Xe = async () => {
475
- M(), M("查看 Claude Code 默认配置"), M(), a(q) ? M(JSON.parse(s(q).toString())) : j("Claude Code 未配置,默认配置文件不存在");
476
- }, X = t.command("ai").description("AI 命令,详细操作请查看 ai -h").helpOption("-h, --help", "输出所有命令").helpCommand(!1);
477
- X.command("init").description("初始化 AI 模型配置").action(Be), X.command("ls").description("查看当前已配置的 AI 模型").action(He), X.command("use <模型>").description("切换 AI 模型").action(Ue), X.command("zh").description("汉化 Claude Code").action(Ge), X.command("zh-restore").description("恢复汉化 Claude Code").action(Ke), X.command("config").description("配置 Claude Code 默认权限").action(Je), X.command("config-ls").description("查看 Claude Code 默认配置").action(Xe);
470
+ h(g, m);
471
+ let _ = `import { dirname, resolve } from 'node:path'
472
+ await import(resolve(dirname(process.execPath), "${g.replace(/\\/g, "/")}"))`, v = y(s, "entry.js");
473
+ h(v, _), S(`bun build ${v} --compile --icon=claude-code.ico --outfile ${o.slice(0, -4) + ".zh.exe"}`, { stdio: "ignore" });
474
+ }, Ze = async () => {
475
+ M(), M("查看 Claude Code 默认配置"), M(), s(q) ? M(JSON.parse(l(q).toString())) : j("Claude Code 未配置,默认配置文件不存在");
476
+ }, X = n.command("ai").description("AI 命令,详细操作请查看 ai -h").helpCommand(!1);
477
+ X.command("init").description("初始化 AI 模型配置").action(Ve), X.command("ls").description("查看当前已配置的 AI 模型").action(Ue), X.command("use <模型>").description("切换 AI 模型").action(We), X.command("zh").description("汉化 Claude Code").action(Ke), X.command("zh-restore").description("恢复汉化 Claude Code").action(qe), X.command("config").description("配置 Claude Code 默认权限").action(Ye), X.command("config-ls").description("查看 Claude Code 默认配置").action(Ze);
478
478
  // src/commander/commands/mini.ts
479
- var Ze = [
479
+ var Qe = [
480
480
  "jpg",
481
481
  "jpeg",
482
482
  "png",
@@ -484,7 +484,7 @@ var Ze = [
484
484
  "avif",
485
485
  "tiff",
486
486
  "tif"
487
- ], Qe = [
487
+ ], $e = [
488
488
  "jpg",
489
489
  "jpeg",
490
490
  "png",
@@ -492,7 +492,7 @@ var Ze = [
492
492
  "avif",
493
493
  "tiff",
494
494
  "tif"
495
- ], Z = (e) => d(e).size, Q = (e) => {
495
+ ], Z = (e) => p(e).size, Q = (e) => {
496
496
  let t = [
497
497
  "B",
498
498
  "KB",
@@ -501,11 +501,11 @@ var Ze = [
501
501
  ], n = 0, r = e;
502
502
  for (; r >= 1024 && n < t.length - 1;) r /= 1024, n++;
503
503
  return `${r.toFixed(n === 0 ? 0 : 2)} ${t[n]}`;
504
- }, $e = (e, t) => c(e, { withFileTypes: !0 }).reduce((n, r) => {
505
- let i = g(e, r.name);
506
- return r.isDirectory() ? (t.includes(_(i)) || n.push(...$e(i, t)), n) : (Ze.includes(h(r.name).slice(1).toLowerCase()) && n.push(i), n);
507
- }, []), et = async (e, t, n, r) => {
508
- let i = re(e);
504
+ }, et = (e, t) => u(e, { withFileTypes: !0 }).reduce((n, r) => {
505
+ let i = v(e, r.name);
506
+ return r.isDirectory() ? (t.includes(y(i)) || n.push(...et(i, t)), n) : (Qe.includes(_(r.name).slice(1).toLowerCase()) && n.push(i), n);
507
+ }, []), tt = async (e, t, n, r) => {
508
+ let i = ie(e);
509
509
  if (((await i.metadata()).pages ?? 1) > 1) return !1;
510
510
  let a = i.rotate();
511
511
  switch (n) {
@@ -556,7 +556,7 @@ var Ze = [
556
556
  }).toFile(t);
557
557
  }
558
558
  return !0;
559
- }, tt = (e) => {
559
+ }, nt = (e) => {
560
560
  if (!e.length) return;
561
561
  let t = e.map(({ file: e, from: t, to: n, status: r }) => {
562
562
  let i = r === "失败" ? "-" : `${t ? ((t - n) / t * 100).toFixed(1) : "0.0"}%`;
@@ -567,78 +567,87 @@ var Ze = [
567
567
  saved: i,
568
568
  status: r
569
569
  };
570
- }), r = {
570
+ }), n = {
571
571
  file: "文件",
572
572
  from: "原大小",
573
573
  to: "新大小",
574
574
  saved: "节省",
575
575
  status: "状态"
576
- }, i = Object.keys(r).reduce((e, n) => (e[n] = Math.max(O(r[n]), ...t.map((e) => O(e[n]))), e), {}), a = (e, t) => e + " ".repeat(t - O(e)), o = (e) => e === "压缩" ? n.green(e) : e === "转换" ? n.cyan(e) : e === "跳过" ? n.yellow(e) : n.red(e);
577
- M(), M(n.bold(`${a(r.file, i.file)} ${a(r.from, i.from)} ${a(r.to, i.to)} ${a(r.saved, i.saved)} ${r.status}`)), M(n.gray("─".repeat(i.file + i.from + i.to + i.saved + i.status + 8))), t.forEach(({ file: e, from: t, to: n, saved: r, status: s }) => {
578
- M(`${a(e, i.file)} ${a(t, i.from)} ${a(n, i.to)} ${a(r, i.saved)} ${o(s)}`);
576
+ }, a = Object.keys(n).reduce((e, i) => (e[i] = Math.max(r(n[i]), ...t.map((e) => r(e[i]))), e), {}), o = (e, t) => e + " ".repeat(t - r(e)), s = (e) => e === "压缩" ? i.green(e) : e === "转换" ? i.cyan(e) : e === "跳过" ? i.yellow(e) : i.red(e);
577
+ M(), M(i.bold(`${o(n.file, a.file)} ${o(n.from, a.from)} ${o(n.to, a.to)} ${o(n.saved, a.saved)} ${n.status}`)), M(i.gray("─".repeat(a.file + a.from + a.to + a.saved + a.status + 8))), t.forEach(({ file: e, from: t, to: n, saved: r, status: i }) => {
578
+ M(`${o(e, a.file)} ${o(t, a.from)} ${o(n, a.to)} ${o(r, a.saved)} ${s(i)}`);
579
579
  });
580
580
  };
581
- t.command("mini <图片目录> [输出目录]").option("-e, --extension [扩展名]", "目标扩展名,如 png / jpg / webp / avif / tiff,默认保持原格式", "").option("--lossless", "使用无损压缩(体积更大,画质完全不变)", !1).description("压缩图片(默认 TinyPNG 风格智能有损,支持格式转换)").action(async (e, t, i) => {
582
- let s = _(process.cwd(), e);
583
- if (!a(s) || !d(s).isDirectory()) return j(`图片目录不存在:${s}`);
584
- let c = !!i?.lossless, u = typeof i?.extension == "string" ? i.extension.replace(/^\./, "").trim().toLowerCase() : "";
585
- if (u && !Qe.includes(u)) return j(`不支持的扩展名:${u},可选值:${Qe.join(" / ")}`);
586
- let p = _(process.cwd(), t || g(s, "mini")), v = $e(s, [p, _(s, "mini")]);
587
- if (!v.length) return M("未找到可处理的图片");
588
- let b = y({
581
+ n.command("mini <图片目录> [输出目录]").option("-e, --extension [扩展名]", "目标扩展名,如 png / jpg / webp / avif / tiff,默认保持原格式", "").option("--lossless", "使用无损压缩(体积更大,画质完全不变)", !1).description("压缩图片(默认 TinyPNG 风格智能有损,支持格式转换)").action(async (e, t, n) => {
582
+ let r = y(process.cwd(), e);
583
+ if (!s(r) || !p(r).isDirectory()) return j(`图片目录不存在:${r}`);
584
+ let o = !!n?.lossless, l = typeof n?.extension == "string" ? n.extension.replace(/^\./, "").trim().toLowerCase() : "";
585
+ if (l && !$e.includes(l)) return j(`不支持的扩展名:${l},可选值:${$e.join(" / ")}`);
586
+ let u = y(process.cwd(), t || v(r, "mini")), f = et(r, [u, y(r, "mini")]);
587
+ if (!f.length) return M("未找到可处理的图片");
588
+ let h = x({
589
589
  text: "正在压缩图片...",
590
590
  color: "yellow"
591
- }).start(), x = [];
592
- for (let e of v) {
593
- let t = Z(e), i = te(s, e), d = g(p, ee(i)), v = h(e).slice(1).toLowerCase(), y = u || v, S = y !== v, C = g(d, `${m(e, h(e))}.${y}`), w = _(C) === _(e), T = `${C}.mini-temp`, E = w ? T : C;
594
- b.text = `正在处理 ${n.cyan(i)}`;
591
+ }).start(), b = [];
592
+ for (let e of f) {
593
+ let t = Z(e), n = te(r, e), f = v(u, ee(n)), p = _(e).slice(1).toLowerCase(), x = l || p, S = x !== p, C = v(f, `${g(e, _(e))}.${x}`), w = y(C) === y(e), T = `${C}.mini-temp`, E = w ? T : C;
594
+ h.text = `正在处理 ${i.cyan(n)}`;
595
595
  try {
596
- o(d, { recursive: !0 });
597
- let n = await et(e, E, y, c);
598
- if (n && (S || Z(E) < t)) w && l(T, C), x.push({
599
- file: i,
596
+ c(f, { recursive: !0 });
597
+ let r = await tt(e, E, x, o);
598
+ if (r && (S || Z(E) < t)) w && d(T, C), b.push({
599
+ file: n,
600
600
  from: t,
601
601
  to: Z(C),
602
602
  status: S ? "转换" : "压缩"
603
603
  });
604
- else if (a(T) && f(T), n || w) x.push({
605
- file: i,
604
+ else if (s(T) && m(T), r || w) b.push({
605
+ file: n,
606
606
  from: t,
607
607
  to: t,
608
608
  status: "跳过"
609
609
  });
610
610
  else {
611
- let n = S ? g(d, m(e)) : C;
612
- _(n) !== _(e) && r(e, n), x.push({
613
- file: i,
611
+ let r = S ? v(f, g(e)) : C;
612
+ y(r) !== y(e) && a(e, r), b.push({
613
+ file: n,
614
614
  from: t,
615
615
  to: t,
616
616
  status: "跳过"
617
617
  });
618
618
  }
619
619
  } catch (e) {
620
- a(T) && f(T), x.push({
621
- file: i,
620
+ s(T) && m(T), b.push({
621
+ file: n,
622
622
  from: t,
623
623
  to: 0,
624
624
  status: "失败"
625
- }), b.stop(), j(`${i} 处理失败:${e?.message || e}`), b.start();
625
+ }), h.stop(), j(`${n} 处理失败:${e?.message || e}`), h.start();
626
626
  }
627
627
  }
628
- b.stop(), tt(x);
629
- let S = x.filter(({ status: e }) => e === "压缩"), C = x.filter(({ status: e }) => e === "转换"), w = x.filter(({ status: e }) => e === "跳过"), T = x.filter(({ status: e }) => e === "失败"), E = x.reduce((e, { from: t }) => e + t, 0), D = x.reduce((e, { from: t, to: n, status: r }) => e + (r === "失败" ? t : n), 0), ne = E ? ((E - D) / E * 100).toFixed(1) : "0.0";
630
- M(), A(`共 ${x.length} 张图片,压缩 ${S.length} 张,转换 ${C.length} 张,跳过 ${w.length} 张,失败 ${T.length} 张`), M(`${n.gray("模式")} ${c ? "无损" : "智能有损(TinyPNG 风格)"}`), M(`${n.gray("总计")} ${Q(E)} ${n.gray("→")} ${Q(D)} ${n.green(`节省 ${ne}%`)}`), M(n.green(`输出目录 ${p}`));
631
- }), t.usage("[commands] [options]").version(oe, "-v, --version", "输出版本号").helpOption("-h, --help", "输出所有命令"), t.command("build[:环境] [描述]").description("简化打包提交命令"), t.command("version<[++]|[@<版本号>]>").description("例如:version++ 或者 version@1.0.0;自动更新 package.json 版本号,自动更新 `README.md` 中的 `version-v<version>-blue` 图标版本");
632
- var nt = class extends e {
628
+ h.stop(), nt(b);
629
+ let S = b.filter(({ status: e }) => e === "压缩"), C = b.filter(({ status: e }) => e === "转换"), w = b.filter(({ status: e }) => e === "跳过"), T = b.filter(({ status: e }) => e === "失败"), E = b.reduce((e, { from: t }) => e + t, 0), D = b.reduce((e, { from: t, to: n, status: r }) => e + (r === "失败" ? t : n), 0), O = E ? ((E - D) / E * 100).toFixed(1) : "0.0";
630
+ M(), A(`共 ${b.length} 张图片,压缩 ${S.length} 张,转换 ${C.length} 张,跳过 ${w.length} 张,失败 ${T.length} 张`), M(`${i.gray("模式")} ${o ? "无损" : "智能有损(TinyPNG 风格)"}`), M(`${i.gray("总计")} ${Q(E)} ${i.gray("→")} ${Q(D)} ${i.green(`节省 ${O}%`)}`), M(i.green(`输出目录 ${u}`));
631
+ }), n.usage("[commands] [options]").version(se, "-v, --version", "输出版本号"), n.command("build[:环境] [描述]").description("简化打包提交命令"), n.command("version<[++]|[@<版本号>]>").description("例如:version++ 或者 version@1.0.0;自动更新 package.json 版本号,自动更新 `README.md` 中的 `version-v<version>-blue` 图标版本");
632
+ var rt = class extends t {
633
633
  displayWidth(e) {
634
- return O(e);
634
+ return r(e);
635
+ }
636
+ formatItem(e, t, n, r) {
637
+ return super.formatItem(e, t, n, r) + "\n";
635
638
  }
636
639
  };
637
- t.createHelp = () => new nt(), t.configureHelp({ sortSubcommands: !1 }), t.arguments("<cmd> [env]").action((e, t) => {
640
+ e.prototype.createHelp = function() {
641
+ return Object.assign(new rt(), this.configureHelp());
642
+ };
643
+ var it = (e) => {
644
+ e.helpOption("-h, --help", "输出帮助信息"), e.commands.forEach(it);
645
+ };
646
+ it(n), n.arguments("<cmd> [env]").action((e, t) => {
638
647
  me(e, t);
639
- }), process.argv.length < 3 ? t.help() : t.parse(process.argv);
648
+ }), process.argv.length < 3 ? n.help() : n.parse(process.argv);
640
649
  // src/update.ts
641
- var $ = ie({
650
+ var $ = ae({
642
651
  pkg: k,
643
652
  updateCheckInterval: 1e3
644
653
  });
@@ -646,17 +655,17 @@ if ($.update && $.update.latest !== k.version) {
646
655
  let e = "";
647
656
  switch ($.update.type) {
648
657
  case "major":
649
- e = n.red("{latestVersion}");
658
+ e = i.red("{latestVersion}");
650
659
  break;
651
660
  case "minor":
652
- e = n.yellow("{latestVersion}");
661
+ e = i.yellow("{latestVersion}");
653
662
  break;
654
- default: e = n.green("{latestVersion}");
663
+ default: e = i.green("{latestVersion}");
655
664
  }
656
665
  let t = `https://github.com/biaov/${k.name}/compare/v${k.version}...v{latestVersion}`;
657
666
  $.notify({
658
667
  defer: !1,
659
668
  isGlobal: !0,
660
- message: `有更新 ${n.dim("{currentVersion}")}${n.reset(" → ")}${e}\n运行 ${n.cyan("{updateCommand}@latest")} 命令更新\n${n.dim.underline(t)}`
669
+ message: `有更新 ${i.dim("{currentVersion}")}${i.reset(" → ")}${e}\n运行 ${i.cyan("{updateCommand}@latest")} 命令更新\n${i.dim.underline(t)}`
661
670
  });
662
671
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "mine-auto-cli",
3
3
  "private": false,
4
- "version": "2.9.0",
4
+ "version": "2.9.1",
5
5
  "exports": "./dist/index.js",
6
6
  "main": "./dist/index.js",
7
7
  "type": "module",