mine-auto-cli 2.6.2 → 2.6.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +94 -148
- package/package.json +6 -6
package/dist/index.js
CHANGED
|
@@ -1,72 +1,18 @@
|
|
|
1
|
-
import { program as
|
|
1
|
+
import { program as d } from "commander";
|
|
2
2
|
import l from "chalk";
|
|
3
|
-
import { readFileSync as y, writeFileSync as
|
|
4
|
-
import { join as g, resolve as
|
|
3
|
+
import { readFileSync as y, writeFileSync as j, existsSync as w, readdirSync as ie, cpSync as ae, rmSync as le } from "fs";
|
|
4
|
+
import { join as g, resolve as b } from "path";
|
|
5
5
|
import H from "log-symbols";
|
|
6
6
|
import pe from "ora";
|
|
7
7
|
import { execSync as N } from "child_process";
|
|
8
8
|
import me from "js-yaml";
|
|
9
|
-
import
|
|
10
|
-
import
|
|
9
|
+
import ue from "strip-json-comments";
|
|
10
|
+
import de from "pacote";
|
|
11
11
|
import { parseRange as V } from "semver-utils";
|
|
12
12
|
import ge from "download-git-repo";
|
|
13
13
|
import A from "inquirer";
|
|
14
14
|
import fe from "update-notifier";
|
|
15
|
-
const K = "mine-auto-cli", Q = "2.6.
|
|
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 = {
|
|
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 = {
|
|
70
16
|
name: K,
|
|
71
17
|
private: !1,
|
|
72
18
|
version: Q,
|
|
@@ -74,9 +20,9 @@ const K = "mine-auto-cli", Q = "2.6.2", he = "./dist/index.js", ye = "./dist/ind
|
|
|
74
20
|
main: ye,
|
|
75
21
|
type: $e,
|
|
76
22
|
bin: ve,
|
|
77
|
-
author:
|
|
78
|
-
description:
|
|
79
|
-
scripts:
|
|
23
|
+
author: je,
|
|
24
|
+
description: we,
|
|
25
|
+
scripts: be,
|
|
80
26
|
publishConfig: Se,
|
|
81
27
|
engines: ke,
|
|
82
28
|
keywords: Ce,
|
|
@@ -102,25 +48,25 @@ const K = "mine-auto-cli", Q = "2.6.2", he = "./dist/index.js", ye = "./dist/ind
|
|
|
102
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 = "打包") => {
|
|
103
49
|
a(), a(`${l.yellow(">>")} 开始依次执行命令...`), a(), Me(e, t).map(W), f("全部命令执行完成"), a();
|
|
104
50
|
}, F = (e) => {
|
|
105
|
-
a(), J(`\`${e}\` 命令错误,请检查你的命令`), a(),
|
|
51
|
+
a(), J(`\`${e}\` 命令错误,请检查你的命令`), a(), d.help();
|
|
106
52
|
}, R = (e) => {
|
|
107
|
-
const t = ["package.json", "README.md"].map((
|
|
108
|
-
const r = g(process.cwd(),
|
|
109
|
-
return { path: r, content:
|
|
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
|
|
115
|
-
s.version =
|
|
60
|
+
const c = s.version.split(".").reduce((r, i, p, m) => r + (p === m.length - 1 ? +i + 1 : `${i}.`), "");
|
|
61
|
+
s.version = c;
|
|
116
62
|
}
|
|
117
|
-
|
|
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);
|
|
118
64
|
}, Le = async (e) => {
|
|
119
65
|
const t = e.split("version")[1];
|
|
120
66
|
if (!t) return F(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((
|
|
69
|
+
const s = o.version.split(".").reduce((c, r, i, p) => c + (i === p.length - 1 ? +r + 1 : `${r}.`), "");
|
|
124
70
|
R(s), a(), f("命令执行完成");
|
|
125
71
|
return;
|
|
126
72
|
}
|
|
@@ -129,7 +75,7 @@ const K = "mine-auto-cli", Q = "2.6.2", he = "./dist/index.js", ye = "./dist/ind
|
|
|
129
75
|
}, Ae = (e, t) => {
|
|
130
76
|
if (e.includes("build")) return Ie(e, t);
|
|
131
77
|
if (e.includes("version")) return Le(e);
|
|
132
|
-
J(l.hex("#f56c6c")(`\`auto ${e}${t ? ` ${t}` : ""}\` 命令不存在`)),
|
|
78
|
+
J(l.hex("#f56c6c")(`\`auto ${e}${t ? ` ${t}` : ""}\` 命令不存在`)), d.help();
|
|
133
79
|
}, v = "https://gitee.com/biaovorg/project-template.git", Fe = {
|
|
134
80
|
vue: v,
|
|
135
81
|
react: v,
|
|
@@ -140,21 +86,21 @@ const K = "mine-auto-cli", Q = "2.6.2", he = "./dist/index.js", ye = "./dist/ind
|
|
|
140
86
|
}, Re = Object.keys(Fe);
|
|
141
87
|
Re.reduce((e, t, o) => e + (o ? ", " : "") + t, "");
|
|
142
88
|
const h = (e = "jsonc") => `auto-cli.${e}`;
|
|
143
|
-
|
|
89
|
+
b(import.meta.dirname, "./presetData.json");
|
|
144
90
|
const X = (e, t = !1) => {
|
|
145
|
-
if (!
|
|
91
|
+
if (!w(e)) return t ? {} : "";
|
|
146
92
|
const o = y(e).toString();
|
|
147
|
-
return t ? JSON.parse(
|
|
93
|
+
return t ? JSON.parse(ue(o)) : o;
|
|
148
94
|
}, Te = (e) => {
|
|
149
|
-
if (!
|
|
95
|
+
if (!w(e)) return {};
|
|
150
96
|
const t = y(e).toString();
|
|
151
97
|
try {
|
|
152
98
|
return me.load(t);
|
|
153
99
|
} catch {
|
|
154
100
|
return {};
|
|
155
101
|
}
|
|
156
|
-
}, Z = (e = !1) => X(
|
|
157
|
-
const [e, t] = [h(), h("yml")].map((n) =>
|
|
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);
|
|
158
104
|
try {
|
|
159
105
|
Object.assign(o, Te(t), X(e, !0));
|
|
160
106
|
} catch {
|
|
@@ -167,52 +113,52 @@ const X = (e, t = !1) => {
|
|
|
167
113
|
`, "") : o;
|
|
168
114
|
}, Ue = ({ yml: e, uncomment: t, force: o }) => {
|
|
169
115
|
a();
|
|
170
|
-
const n = h(e ? "yml" : "jsonc"), s =
|
|
171
|
-
if (
|
|
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
|
-
|
|
121
|
+
j(s, qe(n, t)), f(`${n} 文件创建成功`), a(), a(l.green(`文件目录 ${s}`));
|
|
176
122
|
};
|
|
177
|
-
|
|
123
|
+
d.command("init").option("-f, --force", `强制替换 ${h()} 文件内容`, !1).option("--unc, --uncomment", `取消生成 ${h()} 带注释`, !1).option("-y, --yml", `生成 ${h("yml")} 文件`, !1).description("初始化配置文件").action(Ue);
|
|
178
124
|
const Ge = async (e = "更新代码") => {
|
|
179
125
|
a(), a(`${l.yellow(">>")} 开始依次执行命令...`), a(), Ve(e).forEach(W), f("全部命令执行完成"), a();
|
|
180
126
|
};
|
|
181
|
-
|
|
127
|
+
d.command("git [描述]").description("简化 Git 提交命令").action(Ge);
|
|
182
128
|
const T = ["dist", "node_modules", ".git", "miniprogram_npm"];
|
|
183
129
|
let P = 0, te = !1, M = !1, ne = 20;
|
|
184
130
|
const q = ({ prev: e, i: t, index: o, arr: n, curText: s }) => {
|
|
185
|
-
const
|
|
186
|
-
return !te && (P = Math.max(P,
|
|
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 : ""}
|
|
187
133
|
`;
|
|
188
|
-
}, I = (e, t = 0) => e.reduce((o, n, s,
|
|
134
|
+
}, I = (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:
|
|
191
|
-
}, ""), U = (e) =>
|
|
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 }) => {
|
|
192
138
|
M = !!e, typeof e == "string" && (ne = +e);
|
|
193
139
|
const o = process.cwd(), n = g(o, ".gitignore");
|
|
194
|
-
if (
|
|
140
|
+
if (w(n)) {
|
|
195
141
|
const p = y(n).toString().split(`\r
|
|
196
142
|
`);
|
|
197
143
|
T.push(...p);
|
|
198
144
|
}
|
|
199
145
|
const s = o.split("\\").at(-1), r = U(o).map((p) => {
|
|
200
|
-
const { name: m } = p,
|
|
201
|
-
return !T.includes(m) && p.isDirectory() && (
|
|
202
|
-
}),
|
|
203
|
-
M && (I(
|
|
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;
|
|
148
|
+
}), i = [{ name: s, children: r }];
|
|
149
|
+
M && (I(i), te = !0), j(g(o, `${typeof t == "string" && t || "directory"}.md`), I(i));
|
|
204
150
|
};
|
|
205
|
-
|
|
206
|
-
const k = ee(), [D] = ["package.json"].map((e) =>
|
|
207
|
-
const o = Array.from({ length: t }, (r,
|
|
208
|
-
process.stdout.write(
|
|
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) => {
|
|
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);
|
|
209
155
|
}, Ye = (e, t, o) => {
|
|
210
156
|
let n = "latest";
|
|
211
|
-
k.resolve.some((
|
|
212
|
-
const r =
|
|
157
|
+
k.resolve.some((c) => {
|
|
158
|
+
const r = c.lastIndexOf("@");
|
|
213
159
|
if (r <= 0) return !0;
|
|
214
|
-
const
|
|
215
|
-
if (e ===
|
|
160
|
+
const i = c.slice(0, r), p = c.slice(r + 1);
|
|
161
|
+
if (e === i)
|
|
216
162
|
return n = p, !0;
|
|
217
163
|
});
|
|
218
164
|
const s = k.prefix + o[n];
|
|
@@ -221,52 +167,52 @@ const k = ee(), [D] = ["package.json"].map((e) => w(process.cwd(), e)), Be = (e,
|
|
|
221
167
|
const [{ major: t = 0, minor: o = 0, patch: n = 0, release: s = "" }] = V(e);
|
|
222
168
|
return [+t, +o, +n, s];
|
|
223
169
|
}, Ke = (e, t) => {
|
|
224
|
-
const [o, n, s,
|
|
225
|
-
return r > o ? l.red(t) : r < o ? !1 :
|
|
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;
|
|
226
172
|
}, Qe = (e) => {
|
|
227
173
|
const t = {};
|
|
228
174
|
e.forEach((n) => {
|
|
229
|
-
Object.entries(n).forEach(([s,
|
|
230
|
-
t[s] = Math.max(
|
|
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:
|
|
235
|
-
const [p, m,
|
|
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]));
|
|
236
182
|
let $ = l.yellow("→"), L = !0;
|
|
237
|
-
if (
|
|
238
|
-
const C = Ke(s,
|
|
239
|
-
C ?
|
|
183
|
+
if (i) {
|
|
184
|
+
const C = Ke(s, c);
|
|
185
|
+
C ? c = C : L = !1;
|
|
240
186
|
} else
|
|
241
|
-
n = l.green(n), s = l.green(s),
|
|
242
|
-
const re = `${n + p} ${m + s} ${$} ${
|
|
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}`;
|
|
243
189
|
L && o.push(re);
|
|
244
190
|
}), o.length > 1 ? o.forEach(a) : f("所有版本已是最新");
|
|
245
191
|
}, We = async (e, t, o) => {
|
|
246
192
|
a();
|
|
247
193
|
let n = 0;
|
|
248
|
-
const s = [],
|
|
249
|
-
const m = await
|
|
250
|
-
s.push(
|
|
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"]);
|
|
196
|
+
s.push(u), t.forEach((S) => {
|
|
251
197
|
const $ = o[S];
|
|
252
|
-
$ && $[
|
|
253
|
-
}), n++, await Be(n,
|
|
198
|
+
$ && $[i] && ($[i] = u.newVersion);
|
|
199
|
+
}), n++, await Be(n, c.length);
|
|
254
200
|
});
|
|
255
201
|
return await Promise.all(r), a(), a(), s;
|
|
256
202
|
}, Xe = async ({ update: e }) => {
|
|
257
|
-
if (!
|
|
258
|
-
const t = e || k.check, o = y(D).toString(), n = JSON.parse(o), s = ["dependencies", "devDependencies", "optionalDependencies"],
|
|
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);
|
|
259
205
|
s.forEach((p) => {
|
|
260
|
-
n[p] && Object.entries(n[p]).forEach(([m,
|
|
261
|
-
!k.reject.includes(m) && (
|
|
206
|
+
n[p] && Object.entries(n[p]).forEach(([m, u]) => {
|
|
207
|
+
!k.reject.includes(m) && (c[m] = u);
|
|
262
208
|
});
|
|
263
209
|
});
|
|
264
|
-
const
|
|
265
|
-
t ? (
|
|
210
|
+
const i = await We(c, s, r);
|
|
211
|
+
t ? (j(D, JSON.stringify(r, null, 2)), f("文件 package.json 已更新"), a()) : Qe(i);
|
|
266
212
|
};
|
|
267
|
-
|
|
268
|
-
const Ze = ee(), oe = "comment.md", et = ["package.json", oe], [_, B] = et.map((e) =>
|
|
269
|
-
if (!
|
|
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 文件不存在");
|
|
270
216
|
const e = y(_).toString(), t = JSON.parse(e), o = ["dependencies", "devDependencies", "optionalDependencies"];
|
|
271
217
|
let n = `### 依赖解析
|
|
272
218
|
|
|
@@ -274,25 +220,25 @@ const Ze = ee(), oe = "comment.md", et = ["package.json", oe], [_, B] = et.map((
|
|
|
274
220
|
o.forEach((s) => {
|
|
275
221
|
t[s] && (n += `#### ${s}
|
|
276
222
|
|
|
277
|
-
`, Object.keys(t[s]).forEach((
|
|
278
|
-
n += `- \`${
|
|
223
|
+
`, Object.keys(t[s]).forEach((c) => {
|
|
224
|
+
n += `- \`${c}\`: ${Ze.comment[c] || ""}
|
|
279
225
|
`;
|
|
280
226
|
}), n += `
|
|
281
227
|
`);
|
|
282
|
-
}), n = n.slice(0, -1),
|
|
228
|
+
}), n = n.slice(0, -1), j(B, n), a(), f(`${oe} 文件创建成功`), a(), a(l.green(`文件目录 ${B}`));
|
|
283
229
|
};
|
|
284
|
-
|
|
230
|
+
d.command("comment").description("生成依赖注释文件").action(tt);
|
|
285
231
|
const Y = { recursive: !0, force: !0 }, nt = () => {
|
|
286
232
|
const e = `${+/* @__PURE__ */ new Date()}`, t = g(process.cwd()), o = g(t, e);
|
|
287
233
|
ge("direct:https://gitee.com/biaovorg/vscode-config.git#master", o, { clone: !0 }, async (n) => {
|
|
288
234
|
!n && ae(g(o, ".vscode"), g(t, ".vscode"), Y), le(o, Y);
|
|
289
235
|
});
|
|
290
236
|
};
|
|
291
|
-
|
|
237
|
+
d.command("vscode-config").description("更新 .vscode 配置文件").action(nt);
|
|
292
238
|
const se = (e, t, o) => {
|
|
293
|
-
const n = Object.entries(t), s = n.findIndex(([
|
|
239
|
+
const n = Object.entries(t), s = n.findIndex(([i]) => e === i), [c, r] = n[s];
|
|
294
240
|
if (r) {
|
|
295
|
-
if (o[
|
|
241
|
+
if (o[c] === r) return s === n.length - 1 ? !0 : se(n[s + 1][0], t, o);
|
|
296
242
|
} else
|
|
297
243
|
return !0;
|
|
298
244
|
}, z = (e) => {
|
|
@@ -300,26 +246,26 @@ const se = (e, t, o) => {
|
|
|
300
246
|
}, E = (e) => {
|
|
301
247
|
e && N(`nvm install ${e}`);
|
|
302
248
|
}, ot = (e, t) => {
|
|
303
|
-
const o = N("nvm ls").toString(), n = V(o), [{ major: s, minor:
|
|
249
|
+
const o = N("nvm ls").toString(), n = V(o), [{ major: s, minor: c, patch: r }] = V(e), i = [], p = n.find((m) => {
|
|
304
250
|
if (m.major === s)
|
|
305
|
-
return
|
|
251
|
+
return i.push(m), se("minor", { minor: c, patch: r }, m);
|
|
306
252
|
});
|
|
307
253
|
if (p)
|
|
308
254
|
z(p.semver);
|
|
309
|
-
else if (a(), a(l.red(`输入的版本 ${e} 不存在`)), a(),
|
|
310
|
-
const m =
|
|
255
|
+
else if (a(), a(l.red(`输入的版本 ${e} 不存在`)), a(), i.length) {
|
|
256
|
+
const m = i.map((u) => u.semver);
|
|
311
257
|
A.prompt({
|
|
312
258
|
type: "list",
|
|
313
259
|
name: "preset",
|
|
314
260
|
message: "请选择相似版本或输入版本进行安装:",
|
|
315
261
|
choices: [...m, e, "取消"]
|
|
316
|
-
}).then(({ preset:
|
|
317
|
-
if (
|
|
318
|
-
if (
|
|
262
|
+
}).then(({ preset: u }) => {
|
|
263
|
+
if (u !== "取消")
|
|
264
|
+
if (u === e) {
|
|
319
265
|
if (!r) return;
|
|
320
|
-
E(
|
|
266
|
+
E(u);
|
|
321
267
|
} else
|
|
322
|
-
z(
|
|
268
|
+
z(u);
|
|
323
269
|
});
|
|
324
270
|
} else {
|
|
325
271
|
if (!r) return;
|
|
@@ -336,14 +282,14 @@ const se = (e, t, o) => {
|
|
|
336
282
|
});
|
|
337
283
|
}
|
|
338
284
|
};
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
285
|
+
d.command("node [版本号]").option("-i, --install", "是否安装此版本", !1).description("切换 node 版本,默认选择第一个版本").action(ot);
|
|
286
|
+
d.usage("[commands] [options]").version(Q, "-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) => {
|
|
344
290
|
Ae(e, t);
|
|
345
291
|
});
|
|
346
|
-
process.argv.length < 3 ?
|
|
292
|
+
process.argv.length < 3 ? d.help() : d.parse(process.argv);
|
|
347
293
|
const x = fe({ pkg: O, updateCheckInterval: 1e3 * 1 });
|
|
348
294
|
if (x.update && x.update.latest !== O.version) {
|
|
349
295
|
let e = "";
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mine-auto-cli",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "2.6.
|
|
4
|
+
"version": "2.6.3",
|
|
5
5
|
"exports": "./dist/index.js",
|
|
6
6
|
"main": "./dist/index.js",
|
|
7
7
|
"type": "module",
|
|
@@ -46,15 +46,15 @@
|
|
|
46
46
|
],
|
|
47
47
|
"dependencies": {
|
|
48
48
|
"chalk": "^5.4.1",
|
|
49
|
-
"commander": "^
|
|
49
|
+
"commander": "^14.0.0",
|
|
50
50
|
"download-git-repo": "^3.0.2",
|
|
51
|
-
"inquirer": "^12.3
|
|
51
|
+
"inquirer": "^12.6.3",
|
|
52
52
|
"js-yaml": "^4.1.0",
|
|
53
|
-
"log-symbols": "^7.0.
|
|
54
|
-
"ora": "^8.
|
|
53
|
+
"log-symbols": "^7.0.1",
|
|
54
|
+
"ora": "^8.2.0",
|
|
55
55
|
"pacote": "^21.0.0",
|
|
56
56
|
"semver-utils": "^1.1.4",
|
|
57
|
-
"strip-json-comments": "^5.0.
|
|
57
|
+
"strip-json-comments": "^5.0.2",
|
|
58
58
|
"update-notifier": "^7.3.1"
|
|
59
59
|
},
|
|
60
60
|
"devDependencies": {}
|