mine-auto-cli 2.4.3 → 2.5.0

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