mine-auto-cli 2.6.3 → 2.6.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.js +141 -141
  2. package/package.json +5 -5
package/dist/index.js CHANGED
@@ -1,55 +1,55 @@
1
1
  import { program as d } from "commander";
2
2
  import l from "chalk";
3
- import { readFileSync as y, writeFileSync as j, existsSync as w, readdirSync as ie, cpSync as ae, rmSync as le } from "fs";
3
+ import { readFileSync as y, writeFileSync as j, existsSync as w, readdirSync as ae, cpSync as le, rmSync as pe } from "fs";
4
4
  import { join as g, resolve as b } from "path";
5
- import H from "log-symbols";
6
- import pe from "ora";
5
+ import K from "log-symbols";
6
+ import me from "ora";
7
7
  import { execSync as N } from "child_process";
8
- import me from "js-yaml";
9
- import ue from "strip-json-comments";
10
- import de from "pacote";
11
- import { parseRange as V } from "semver-utils";
12
- import ge from "download-git-repo";
13
- import A from "inquirer";
14
- import fe from "update-notifier";
15
- const K = "mine-auto-cli", Q = "2.6.3", he = "./dist/index.js", ye = "./dist/index.js", $e = "module", ve = { auto: "bin/mine-auto-cli.js" }, je = { name: "biaov", email: "biaov@qq.com", url: "https://biaov.cn" }, we = "一个将多个命令简化成一个命令的工具 😆", be = { start: "npm run dev", dev: "npm run build -- --watch", build: "vite build", prettier: "prettier --write '**/*.{js,ts,md,json}'", tag: "node scripts/tag" }, Se = { registry: "https://registry.npmjs.org/", "engine-strict": !0, provenance: !0 }, ke = { node: ">=22.11" }, Ce = ["auto", "cli", "vite", "typescript"], xe = { type: "git", url: "git+https://github.com/biaov/mine-auto-cli.git" }, Oe = "https://github.com/biaov/mine-auto-cli.git", Ne = { url: "https://github.com/biaov/mine-auto-cli/issues" }, Je = "ISC", Pe = [{ name: "biaov", email: "biaov@qq.com" }], De = { chalk: "^5.4.1", commander: "^14.0.0", "download-git-repo": "^3.0.2", inquirer: "^12.6.3", "js-yaml": "^4.1.0", "log-symbols": "^7.0.1", ora: "^8.2.0", pacote: "^21.0.0", "semver-utils": "^1.1.4", "strip-json-comments": "^5.0.2", "update-notifier": "^7.3.1" }, Ee = { "@types/js-yaml": "^4.0.9", "@types/node": "^22.15.21", "@types/pacote": "^11.1.8", "@types/semver-utils": "^1.1.3", "@types/update-notifier": "^6.0.8", prettier: "^3.5.3", typescript: "^5.8.3", vite: "^6.3.5" }, O = {
16
- name: K,
8
+ import ue from "js-yaml";
9
+ import de from "strip-json-comments";
10
+ import ge from "pacote";
11
+ import { parseRange as M } from "semver-utils";
12
+ import fe from "download-git-repo";
13
+ import F from "inquirer";
14
+ import he from "update-notifier";
15
+ const Q = "mine-auto-cli", W = "2.6.4", ye = "./dist/index.js", $e = "./dist/index.js", ve = "module", je = { auto: "bin/mine-auto-cli.js" }, we = { name: "biaov", email: "biaov@qq.com", url: "https://biaov.cn" }, be = "一个将多个命令简化成一个命令的工具 😆", Se = { start: "npm run dev", dev: "npm run build -- --watch", build: "vite build", prettier: "prettier --write '**/*.{js,ts,md,json}'", tag: "node scripts/tag" }, ke = { registry: "https://registry.npmjs.org/", "engine-strict": !0, provenance: !0 }, Ce = { node: ">=22.11" }, xe = ["auto", "cli", "vite", "typescript"], Oe = { type: "git", url: "git+https://github.com/biaov/mine-auto-cli.git" }, Ne = "https://github.com/biaov/mine-auto-cli.git", Je = { url: "https://github.com/biaov/mine-auto-cli/issues" }, Pe = "ISC", De = [{ name: "biaov", email: "biaov@qq.com" }], Ee = { chalk: "^5.6.2", commander: "^14.0.0", "download-git-repo": "^3.0.2", inquirer: "^12.9.4", "js-yaml": "^4.1.0", "log-symbols": "^7.0.1", ora: "^8.2.0", pacote: "^21.0.1", "semver-utils": "^1.1.4", "strip-json-comments": "^5.0.3", "update-notifier": "^7.3.1" }, Ve = { "@types/js-yaml": "^4.0.9", "@types/node": "^24.3.1", "@types/pacote": "^11.1.8", "@types/semver-utils": "^1.1.3", "@types/update-notifier": "^6.0.8", prettier: "^3.6.2", typescript: "^5.9.2", vite: "^7.1.5" }, O = {
16
+ name: Q,
17
17
  private: !1,
18
- version: Q,
19
- exports: he,
20
- main: ye,
21
- type: $e,
22
- bin: ve,
23
- author: je,
24
- description: we,
25
- scripts: be,
26
- publishConfig: Se,
27
- engines: ke,
28
- keywords: Ce,
29
- repository: xe,
30
- homepage: Oe,
31
- bugs: Ne,
32
- license: Je,
33
- contributors: Pe,
34
- dependencies: De,
35
- devDependencies: Ee
18
+ version: W,
19
+ exports: ye,
20
+ main: $e,
21
+ type: ve,
22
+ bin: je,
23
+ author: we,
24
+ description: be,
25
+ scripts: Se,
26
+ publishConfig: ke,
27
+ engines: Ce,
28
+ keywords: xe,
29
+ repository: Oe,
30
+ homepage: Ne,
31
+ bugs: Je,
32
+ license: Pe,
33
+ contributors: De,
34
+ dependencies: Ee,
35
+ devDependencies: Ve
36
36
  }, f = (e) => {
37
- console.log(`${H.success} ${l.green("SUCCESS")} ${e}`);
37
+ console.log(`${K.success} ${l.green("SUCCESS")} ${e}`);
38
38
  }, J = (e) => {
39
- console.log(`${K} ${H.error} ${l.red("ERROR")} ${e}`);
39
+ console.log(`${Q} ${K.error} ${l.red("ERROR")} ${e}`);
40
40
  }, a = (e) => {
41
41
  console.log(e ?? "");
42
- }, W = (e) => {
42
+ }, X = (e) => {
43
43
  a(`开始执行 ${l.cyanBright(e)} 命令`);
44
- const t = pe({ text: "正在执行命令中...", color: "yellow" });
44
+ const t = me({ text: "正在执行命令中...", color: "yellow" });
45
45
  t.start();
46
46
  const o = N(e, { cwd: process.cwd() });
47
47
  a(o.toString()), t.succeed(`${l.green(e)} 命令执行成功`), a();
48
- }, Ve = (e) => ["git add -A", `git commit -m ${e}`, "git push"], Me = (e, t) => [`npm run ${e}`, "git add -A", `git commit -m ${t}`, "git push"], Ie = async (e, t = "打包") => {
49
- a(), a(`${l.yellow(">>")} 开始依次执行命令...`), a(), Me(e, t).map(W), f("全部命令执行完成"), a();
50
- }, F = (e) => {
48
+ }, Me = (e) => ["git add -A", `git commit -m ${e}`, "git push"], Ie = (e, t) => [`npm run ${e}`, "git add -A", `git commit -m ${t}`, "git push"], Le = async (e, t = "打包") => {
49
+ a(), a(`${l.yellow(">>")} 开始依次执行命令...`), a(), Ie(e, t).map(X), f("全部命令执行完成"), a();
50
+ }, T = (e) => {
51
51
  a(), J(`\`${e}\` 命令错误,请检查你的命令`), a(), d.help();
52
- }, R = (e) => {
52
+ }, q = (e) => {
53
53
  const t = ["package.json", "README.md"].map((c) => {
54
54
  const r = g(process.cwd(), c), i = y(r).toString();
55
55
  return { path: r, content: i };
@@ -57,119 +57,119 @@ const K = "mine-auto-cli", Q = "2.6.3", he = "./dist/index.js", ye = "./dist/ind
57
57
  if (e)
58
58
  s.version = e;
59
59
  else {
60
- const c = s.version.split(".").reduce((r, i, p, m) => r + (p === m.length - 1 ? +i + 1 : `${i}.`), "");
60
+ const c = s.version.split(".").reduce((r, i, m, p) => r + (m === p.length - 1 ? +i + 1 : `${i}.`), "");
61
61
  s.version = c;
62
62
  }
63
63
  j(o.path, JSON.stringify(s, null, 2)), n.content = n.content.replace(/version\-v.+\-blue/, () => `version-v${s.version}-blue`), j(n.path, n.content);
64
- }, Le = async (e) => {
64
+ }, Ae = async (e) => {
65
65
  const t = e.split("version")[1];
66
- if (!t) return F(e);
66
+ if (!t) return T(e);
67
67
  const o = JSON.parse(y(g(process.cwd(), "package.json")).toString());
68
68
  if (t === "++") {
69
- const s = o.version.split(".").reduce((c, r, i, p) => c + (i === p.length - 1 ? +r + 1 : `${r}.`), "");
70
- R(s), a(), f("命令执行完成");
69
+ const s = o.version.split(".").reduce((c, r, i, m) => c + (i === m.length - 1 ? +r + 1 : `${r}.`), "");
70
+ q(s), a(), f("命令执行完成");
71
71
  return;
72
72
  }
73
73
  const n = t.split("@")[1];
74
- n ? (R(n), a(), f("命令执行完成")) : F(e);
75
- }, Ae = (e, t) => {
76
- if (e.includes("build")) return Ie(e, t);
77
- if (e.includes("version")) return Le(e);
74
+ n ? (q(n), a(), f("命令执行完成")) : T(e);
75
+ }, Fe = (e, t) => {
76
+ if (e.includes("build")) return Le(e, t);
77
+ if (e.includes("version")) return Ae(e);
78
78
  J(l.hex("#f56c6c")(`\`auto ${e}${t ? ` ${t}` : ""}\` 命令不存在`)), d.help();
79
- }, v = "https://gitee.com/biaovorg/project-template.git", Fe = {
79
+ }, v = "https://gitee.com/biaovorg/project-template.git", Te = {
80
80
  vue: v,
81
81
  react: v,
82
82
  "uni-app": v,
83
83
  electron: v,
84
84
  node: v,
85
85
  "node-simple": v
86
- }, Re = Object.keys(Fe);
87
- Re.reduce((e, t, o) => e + (o ? ", " : "") + t, "");
86
+ }, qe = Object.keys(Te);
87
+ qe.reduce((e, t, o) => e + (o ? ", " : "") + t, "");
88
88
  const h = (e = "jsonc") => `auto-cli.${e}`;
89
89
  b(import.meta.dirname, "./presetData.json");
90
- const X = (e, t = !1) => {
90
+ const Z = (e, t = !1) => {
91
91
  if (!w(e)) return t ? {} : "";
92
92
  const o = y(e).toString();
93
- return t ? JSON.parse(ue(o)) : o;
94
- }, Te = (e) => {
93
+ return t ? JSON.parse(de(o)) : o;
94
+ }, Re = (e) => {
95
95
  if (!w(e)) return {};
96
96
  const t = y(e).toString();
97
97
  try {
98
- return me.load(t);
98
+ return ue.load(t);
99
99
  } catch {
100
100
  return {};
101
101
  }
102
- }, Z = (e = !1) => X(b(import.meta.dirname, h()), e), ee = () => {
103
- const [e, t] = [h(), h("yml")].map((n) => b(process.cwd(), n)), o = Z(!0);
102
+ }, ee = (e = !1) => Z(b(import.meta.dirname, h()), e), te = () => {
103
+ const [e, t] = [h(), h("yml")].map((n) => b(process.cwd(), n)), o = ee(!0);
104
104
  try {
105
- Object.assign(o, Te(t), X(e, !0));
105
+ Object.assign(o, Re(t), Z(e, !0));
106
106
  } catch {
107
107
  }
108
108
  return o;
109
- }, qe = (e, t = !1) => {
110
- let o = Z(t);
109
+ }, Ue = (e, t = !1) => {
110
+ let o = ee(t);
111
111
  return t && (o = JSON.stringify(o, null, 2)), e.includes(".yml") ? o.trim().split(`
112
112
  `).slice(1, -1).reduce((n, s) => n + s.trim().replace(/[",]/g, "").replace("// ", "# ") + `
113
113
  `, "") : o;
114
- }, Ue = ({ yml: e, uncomment: t, force: o }) => {
114
+ }, Ge = ({ yml: e, uncomment: t, force: o }) => {
115
115
  a();
116
116
  const n = h(e ? "yml" : "jsonc"), s = b(process.cwd(), n);
117
117
  if (w(s) && !o) {
118
118
  a(l.yellow(`${n} 文件已存在`)), a(), a(l.yellow(`文件目录 ${s}`));
119
119
  return;
120
120
  }
121
- j(s, qe(n, t)), f(`${n} 文件创建成功`), a(), a(l.green(`文件目录 ${s}`));
121
+ j(s, Ue(n, t)), f(`${n} 文件创建成功`), a(), a(l.green(`文件目录 ${s}`));
122
122
  };
123
- d.command("init").option("-f, --force", `强制替换 ${h()} 文件内容`, !1).option("--unc, --uncomment", `取消生成 ${h()} 带注释`, !1).option("-y, --yml", `生成 ${h("yml")} 文件`, !1).description("初始化配置文件").action(Ue);
124
- const Ge = async (e = "更新代码") => {
125
- a(), a(`${l.yellow(">>")} 开始依次执行命令...`), a(), Ve(e).forEach(W), f("全部命令执行完成"), a();
123
+ d.command("init").option("-f, --force", `强制替换 ${h()} 文件内容`, !1).option("--unc, --uncomment", `取消生成 ${h()} 带注释`, !1).option("-y, --yml", `生成 ${h("yml")} 文件`, !1).description("初始化配置文件").action(Ge);
124
+ const _e = async (e = "更新代码") => {
125
+ a(), a(`${l.yellow(">>")} 开始依次执行命令...`), a(), Me(e).forEach(X), f("全部命令执行完成"), a();
126
126
  };
127
- d.command("git [描述]").description("简化 Git 提交命令").action(Ge);
128
- const T = ["dist", "node_modules", ".git", "miniprogram_npm"];
129
- let P = 0, te = !1, M = !1, ne = 20;
130
- const q = ({ prev: e, i: t, index: o, arr: n, curText: s }) => {
131
- const c = Array.from({ length: t }).reduce((m) => m + `${t === 1 && o === n.length - 1 ? "└ " : "│ "} `, ""), r = e + c, i = (c + s).length, p = Array.from({ length: ne + P - i }).reduce((m) => `${m}-`, " ");
132
- return !te && (P = Math.max(P, i)), `${r}${s}${M ? p : ""}
127
+ d.command("git [描述]").description("简化 Git 提交命令").action(_e);
128
+ const R = ["dist", "node_modules", ".git", "miniprogram_npm"];
129
+ let P = 0, ne = !1, I = !1, oe = 20;
130
+ const U = ({ prev: e, i: t, index: o, arr: n, curText: s }) => {
131
+ const c = Array.from({ length: t }).reduce((p) => p + `${t === 1 && o === n.length - 1 ? "└ " : "│ "} `, ""), r = e + c, i = (c + s).length, m = Array.from({ length: oe + P - i }).reduce((p) => `${p}-`, " ");
132
+ return !ne && (P = Math.max(P, i)), `${r}${s}${I ? m : ""}
133
133
  `;
134
- }, I = (e, t = 0) => e.reduce((o, n, s, c) => {
134
+ }, L = (e, t = 0) => e.reduce((o, n, s, c) => {
135
135
  let r;
136
- return n.children ? (r = `├── ${n.name}`, q({ prev: o, i: t, index: s, arr: c, curText: r }) + I(n.children, t + 1)) : (r = `${s === c.length - 1 ? "└── " : "├── "}${n.name}`, q({ prev: o, i: t, index: s, arr: c, curText: r }));
137
- }, ""), U = (e) => ie(e, { withFileTypes: !0 }).sort((t, o) => +o.isDirectory() - +t.isDirectory()), _e = ({ line: e, name: t }) => {
138
- M = !!e, typeof e == "string" && (ne = +e);
136
+ return n.children ? (r = `├── ${n.name}`, U({ prev: o, i: t, index: s, arr: c, curText: r }) + L(n.children, t + 1)) : (r = `${s === c.length - 1 ? "└── " : "├── "}${n.name}`, U({ prev: o, i: t, index: s, arr: c, curText: r }));
137
+ }, ""), G = (e) => ae(e, { withFileTypes: !0 }).sort((t, o) => +o.isDirectory() - +t.isDirectory()), Be = ({ line: e, name: t }) => {
138
+ I = !!e, typeof e == "string" && (oe = +e);
139
139
  const o = process.cwd(), n = g(o, ".gitignore");
140
140
  if (w(n)) {
141
- const p = y(n).toString().split(`\r
141
+ const m = y(n).toString().split(`\r
142
142
  `);
143
- T.push(...p);
143
+ R.push(...m);
144
144
  }
145
- const s = o.split("\\").at(-1), r = U(o).map((p) => {
146
- const { name: m } = p, u = { name: m };
147
- return !T.includes(m) && p.isDirectory() && (u.children = U(g(p.path, m)).map(({ name: S }) => ({ name: S }))), u;
145
+ const s = o.split("\\").at(-1), r = G(o).map((m) => {
146
+ const { name: p } = m, u = { name: p };
147
+ return !R.includes(p) && m.isDirectory() && (u.children = G(g(m.path, p)).map(({ name: S }) => ({ name: S }))), u;
148
148
  }), i = [{ name: s, children: r }];
149
- M && (I(i), te = !0), j(g(o, `${typeof t == "string" && t || "directory"}.md`), I(i));
149
+ I && (L(i), ne = !0), j(g(o, `${typeof t == "string" && t || "directory"}.md`), L(i));
150
150
  };
151
- d.command("mkdir").option("-l, --line [数量]", "数量", !1).option("-n, --name [文件名称]", "文件名称", !1).option("-d, --depth [深度值]", "深度值", "3").description("生成目录结构文件").action(_e);
152
- const k = ee(), [D] = ["package.json"].map((e) => b(process.cwd(), e)), Be = (e, t) => {
151
+ d.command("mkdir").option("-l, --line [数量]", "数量", !1).option("-n, --name [文件名称]", "文件名称", !1).option("-d, --depth [深度值]", "深度值", "3").description("生成目录结构文件").action(Be);
152
+ const k = te(), [D] = ["package.json"].map((e) => b(process.cwd(), e)), Ye = (e, t) => {
153
153
  const o = Array.from({ length: t }, (r, i) => i < e ? "=" : " ").join(""), n = ~~(e / t * 100), s = `\r查找进度:[${o}] ${e}/${t} ${n}%\r`, c = e === t ? l.green(s) : l.yellow(s);
154
154
  process.stdout.write(c);
155
- }, Ye = (e, t, o) => {
155
+ }, ze = (e, t, o) => {
156
156
  let n = "latest";
157
157
  k.resolve.some((c) => {
158
158
  const r = c.lastIndexOf("@");
159
159
  if (r <= 0) return !0;
160
- const i = c.slice(0, r), p = c.slice(r + 1);
160
+ const i = c.slice(0, r), m = c.slice(r + 1);
161
161
  if (e === i)
162
- return n = p, !0;
162
+ return n = m, !0;
163
163
  });
164
164
  const s = k.prefix + o[n];
165
165
  return { name: e, value: t, newVersion: s, tag: n };
166
- }, ze = (e, t) => Array.from({ length: t - e }, () => " ").join(""), He = (e, t) => (+!t + 1) * e.length, G = (e) => {
167
- const [{ major: t = 0, minor: o = 0, patch: n = 0, release: s = "" }] = V(e);
166
+ }, He = (e, t) => Array.from({ length: t - e }, () => " ").join(""), Ke = (e, t) => (+!t + 1) * e.length, _ = (e) => {
167
+ const [{ major: t = 0, minor: o = 0, patch: n = 0, release: s = "" }] = M(e);
168
168
  return [+t, +o, +n, s];
169
- }, Ke = (e, t) => {
170
- const [o, n, s, c] = G(e), [r, i, p, m] = G(t);
171
- return r > o ? l.red(t) : r < o ? !1 : i > n ? `${r}.${l.yellow(i)}.${l.yellow(p)}` : i < n ? !1 : p > s ? `${r}.${i}.${l.green(p)}` : p === s && m && m !== c ? `${r}.${i}.${p}-${l.green(m)}` : !1;
172
- }, Qe = (e) => {
169
+ }, E = (e, t) => e ? "-" + l[t](e) : "", Qe = (e, t) => {
170
+ const [o, n, s, c] = _(e), [r, i, m, p] = _(t);
171
+ return r > o ? l.red(t) : r < o ? !1 : i > n ? `${r}.${l.yellow(i)}.${l.yellow(m)}${E(p, "yellow")}` : i < n ? !1 : m > s ? `${r}.${i}.${l.green(m)}${E(p, "green")}` : m === s && p && p !== c ? `${r}.${i}.${m}${E(p, "green")}` : !1;
172
+ }, We = (e) => {
173
173
  const t = {};
174
174
  e.forEach((n) => {
175
175
  Object.entries(n).forEach(([s, c]) => {
@@ -178,42 +178,42 @@ const k = ee(), [D] = ["package.json"].map((e) => b(process.cwd(), e)), Be = (e,
178
178
  }), e.unshift({ name: "包名", value: "版本", newVersion: "新版本", tag: "标签" });
179
179
  const o = [];
180
180
  e.forEach(({ name: n, value: s, newVersion: c, tag: r }, i) => {
181
- const [p, m, u, S] = Object.entries({ name: n, value: s, newVersion: c, tag: r }).map(([C, ce]) => ze(He(ce, i), t[C]));
182
- let $ = l.yellow("→"), L = !0;
181
+ const [m, p, u, S] = Object.entries({ name: n, value: s, newVersion: c, tag: r }).map(([C, ie]) => He(Ke(ie, i), t[C]));
182
+ let $ = l.yellow("→"), A = !0;
183
183
  if (i) {
184
- const C = Ke(s, c);
185
- C ? c = C : L = !1;
184
+ const C = Qe(s, c);
185
+ C ? c = C : A = !1;
186
186
  } else
187
187
  n = l.green(n), s = l.green(s), c = l.green(c), r = l.green(r), $ = " ";
188
- const re = `${n + p} ${m + s} ${$} ${u + c} ${S + r}`;
189
- L && o.push(re);
188
+ const ce = `${n + m} ${p + s} ${$} ${u + c} ${S + r}`;
189
+ A && o.push(ce);
190
190
  }), o.length > 1 ? o.forEach(a) : f("所有版本已是最新");
191
- }, We = async (e, t, o) => {
191
+ }, Xe = async (e, t, o) => {
192
192
  a();
193
193
  let n = 0;
194
- const s = [], c = Object.entries(e), r = c.map(async ([i, p]) => {
195
- const m = await de.packument(i, { registry: k.registry }), u = Ye(i, p, m["dist-tags"]);
194
+ const s = [], c = Object.entries(e), r = c.map(async ([i, m]) => {
195
+ const p = await ge.packument(i, { registry: k.registry }), u = ze(i, m, p["dist-tags"]);
196
196
  s.push(u), t.forEach((S) => {
197
197
  const $ = o[S];
198
198
  $ && $[i] && ($[i] = u.newVersion);
199
- }), n++, await Be(n, c.length);
199
+ }), n++, await Ye(n, c.length);
200
200
  });
201
201
  return await Promise.all(r), a(), a(), s;
202
- }, Xe = async ({ update: e }) => {
202
+ }, Ze = async ({ update: e }) => {
203
203
  if (!w(D)) return J("package.json 文件不存在");
204
204
  const t = e || k.check, o = y(D).toString(), n = JSON.parse(o), s = ["dependencies", "devDependencies", "optionalDependencies"], c = {}, r = JSON.parse(o);
205
- s.forEach((p) => {
206
- n[p] && Object.entries(n[p]).forEach(([m, u]) => {
207
- !k.reject.includes(m) && (c[m] = u);
205
+ s.forEach((m) => {
206
+ n[m] && Object.entries(n[m]).forEach(([p, u]) => {
207
+ !k.reject.includes(p) && (c[p] = u);
208
208
  });
209
209
  });
210
- const i = await We(c, s, r);
211
- t ? (j(D, JSON.stringify(r, null, 2)), f("文件 package.json 已更新"), a()) : Qe(i);
210
+ const i = await Xe(c, s, r);
211
+ t ? (j(D, JSON.stringify(r, null, 2)), f("文件 package.json 已更新"), a()) : We(i);
212
212
  };
213
- d.command("check").option("-u, --update", "更新 package.json 依赖内容", !1).description("升级 package.json 依赖版本").action(Xe);
214
- const Ze = ee(), oe = "comment.md", et = ["package.json", oe], [_, B] = et.map((e) => b(process.cwd(), e)), tt = () => {
215
- if (!w(_)) return J("package.json 文件不存在");
216
- const e = y(_).toString(), t = JSON.parse(e), o = ["dependencies", "devDependencies", "optionalDependencies"];
213
+ d.command("check").option("-u, --update", "更新 package.json 依赖内容", !1).description("升级 package.json 依赖版本").action(Ze);
214
+ const et = te(), se = "comment.md", tt = ["package.json", se], [B, Y] = tt.map((e) => b(process.cwd(), e)), nt = () => {
215
+ if (!w(B)) return J("package.json 文件不存在");
216
+ const e = y(B).toString(), t = JSON.parse(e), o = ["dependencies", "devDependencies", "optionalDependencies"];
217
217
  let n = `### 依赖解析
218
218
 
219
219
  `;
@@ -221,76 +221,76 @@ const Ze = ee(), oe = "comment.md", et = ["package.json", oe], [_, B] = et.map((
221
221
  t[s] && (n += `#### ${s}
222
222
 
223
223
  `, Object.keys(t[s]).forEach((c) => {
224
- n += `- \`${c}\`: ${Ze.comment[c] || ""}
224
+ n += `- \`${c}\`: ${et.comment[c] || ""}
225
225
  `;
226
226
  }), n += `
227
227
  `);
228
- }), n = n.slice(0, -1), j(B, n), a(), f(`${oe} 文件创建成功`), a(), a(l.green(`文件目录 ${B}`));
228
+ }), n = n.slice(0, -1), j(Y, n), a(), f(`${se} 文件创建成功`), a(), a(l.green(`文件目录 ${Y}`));
229
229
  };
230
- d.command("comment").description("生成依赖注释文件").action(tt);
231
- const Y = { recursive: !0, force: !0 }, nt = () => {
230
+ d.command("comment").description("生成依赖注释文件").action(nt);
231
+ const z = { recursive: !0, force: !0 }, ot = () => {
232
232
  const e = `${+/* @__PURE__ */ new Date()}`, t = g(process.cwd()), o = g(t, e);
233
- ge("direct:https://gitee.com/biaovorg/vscode-config.git#master", o, { clone: !0 }, async (n) => {
234
- !n && ae(g(o, ".vscode"), g(t, ".vscode"), Y), le(o, Y);
233
+ fe("direct:https://gitee.com/biaovorg/vscode-config.git#master", o, { clone: !0 }, async (n) => {
234
+ !n && le(g(o, ".vscode"), g(t, ".vscode"), z), pe(o, z);
235
235
  });
236
236
  };
237
- d.command("vscode-config").description("更新 .vscode 配置文件").action(nt);
238
- const se = (e, t, o) => {
237
+ d.command("vscode-config").description("更新 .vscode 配置文件").action(ot);
238
+ const re = (e, t, o) => {
239
239
  const n = Object.entries(t), s = n.findIndex(([i]) => e === i), [c, r] = n[s];
240
240
  if (r) {
241
- if (o[c] === r) return s === n.length - 1 ? !0 : se(n[s + 1][0], t, o);
241
+ if (o[c] === r) return s === n.length - 1 ? !0 : re(n[s + 1][0], t, o);
242
242
  } else
243
243
  return !0;
244
- }, z = (e) => {
244
+ }, H = (e) => {
245
245
  e && (N(`nvm use ${e}`), a(), f(`切换成功 当前版本:${e}`), a());
246
- }, E = (e) => {
246
+ }, V = (e) => {
247
247
  e && N(`nvm install ${e}`);
248
- }, ot = (e, t) => {
249
- const o = N("nvm ls").toString(), n = V(o), [{ major: s, minor: c, patch: r }] = V(e), i = [], p = n.find((m) => {
250
- if (m.major === s)
251
- return i.push(m), se("minor", { minor: c, patch: r }, m);
248
+ }, st = (e, t) => {
249
+ const o = N("nvm ls").toString(), n = M(o), [{ major: s, minor: c, patch: r }] = M(e), i = [], m = n.find((p) => {
250
+ if (p.major === s)
251
+ return i.push(p), re("minor", { minor: c, patch: r }, p);
252
252
  });
253
- if (p)
254
- z(p.semver);
253
+ if (m)
254
+ H(m.semver);
255
255
  else if (a(), a(l.red(`输入的版本 ${e} 不存在`)), a(), i.length) {
256
- const m = i.map((u) => u.semver);
257
- A.prompt({
256
+ const p = i.map((u) => u.semver);
257
+ F.prompt({
258
258
  type: "list",
259
259
  name: "preset",
260
260
  message: "请选择相似版本或输入版本进行安装:",
261
- choices: [...m, e, "取消"]
261
+ choices: [...p, e, "取消"]
262
262
  }).then(({ preset: u }) => {
263
263
  if (u !== "取消")
264
264
  if (u === e) {
265
265
  if (!r) return;
266
- E(u);
266
+ V(u);
267
267
  } else
268
- z(u);
268
+ H(u);
269
269
  });
270
270
  } else {
271
271
  if (!r) return;
272
272
  if (t.install) {
273
- E(e);
273
+ V(e);
274
274
  return;
275
275
  }
276
- A.prompt({
276
+ F.prompt({
277
277
  type: "confirm",
278
278
  name: "isInstall",
279
279
  message: `是否安装 ${e}?`
280
- }).then(({ isInstall: m }) => {
281
- m && E(e);
280
+ }).then(({ isInstall: p }) => {
281
+ p && V(e);
282
282
  });
283
283
  }
284
284
  };
285
- d.command("node [版本号]").option("-i, --install", "是否安装此版本", !1).description("切换 node 版本,默认选择第一个版本").action(ot);
286
- d.usage("[commands] [options]").version(Q, "-v, --version", "输出版本号").helpOption("-h, --help", "输出所有命令");
285
+ d.command("node [版本号]").option("-i, --install", "是否安装此版本", !1).description("切换 node 版本,默认选择第一个版本").action(st);
286
+ d.usage("[commands] [options]").version(W, "-v, --version", "输出版本号").helpOption("-h, --help", "输出所有命令");
287
287
  d.command("build[:环境] [描述]").description("简化打包提交命令");
288
288
  d.command("version<[++]|[@<版本号>]>").description("例如:version++ 或者 version@1.0.0;自动更新 package.json 版本号,自动更新 `README.md` 中的 `version-v<version>-blue` 图标版本");
289
289
  d.arguments("<cmd> [env]").action((e, t) => {
290
- Ae(e, t);
290
+ Fe(e, t);
291
291
  });
292
292
  process.argv.length < 3 ? d.help() : d.parse(process.argv);
293
- const x = fe({ pkg: O, updateCheckInterval: 1e3 * 1 });
293
+ const x = he({ pkg: O, updateCheckInterval: 1e3 * 1 });
294
294
  if (x.update && x.update.latest !== O.version) {
295
295
  let e = "";
296
296
  switch (x.update.type) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "mine-auto-cli",
3
3
  "private": false,
4
- "version": "2.6.3",
4
+ "version": "2.6.4",
5
5
  "exports": "./dist/index.js",
6
6
  "main": "./dist/index.js",
7
7
  "type": "module",
@@ -45,16 +45,16 @@
45
45
  }
46
46
  ],
47
47
  "dependencies": {
48
- "chalk": "^5.4.1",
48
+ "chalk": "^5.6.2",
49
49
  "commander": "^14.0.0",
50
50
  "download-git-repo": "^3.0.2",
51
- "inquirer": "^12.6.3",
51
+ "inquirer": "^12.9.4",
52
52
  "js-yaml": "^4.1.0",
53
53
  "log-symbols": "^7.0.1",
54
54
  "ora": "^8.2.0",
55
- "pacote": "^21.0.0",
55
+ "pacote": "^21.0.1",
56
56
  "semver-utils": "^1.1.4",
57
- "strip-json-comments": "^5.0.2",
57
+ "strip-json-comments": "^5.0.3",
58
58
  "update-notifier": "^7.3.1"
59
59
  },
60
60
  "devDependencies": {}