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