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.
- package/dist/index.js +179 -233
- package/package.json +8 -8
package/dist/index.js
CHANGED
|
@@ -1,350 +1,296 @@
|
|
|
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
|
|
5
|
-
import
|
|
6
|
-
import
|
|
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
|
|
8
|
+
import ue from "js-yaml";
|
|
9
9
|
import de from "strip-json-comments";
|
|
10
|
-
import
|
|
11
|
-
import { parseRange as
|
|
12
|
-
import
|
|
13
|
-
import
|
|
14
|
-
import
|
|
15
|
-
const
|
|
16
|
-
|
|
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:
|
|
73
|
-
exports:
|
|
74
|
-
main:
|
|
75
|
-
type:
|
|
76
|
-
bin:
|
|
77
|
-
author:
|
|
78
|
-
description:
|
|
79
|
-
scripts:
|
|
80
|
-
publishConfig:
|
|
81
|
-
engines:
|
|
82
|
-
keywords:
|
|
83
|
-
repository:
|
|
84
|
-
homepage:
|
|
85
|
-
bugs:
|
|
86
|
-
license:
|
|
87
|
-
contributors:
|
|
88
|
-
dependencies:
|
|
89
|
-
devDependencies:
|
|
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(`${
|
|
37
|
+
console.log(`${K.success} ${l.green("SUCCESS")} ${e}`);
|
|
92
38
|
}, J = (e) => {
|
|
93
|
-
console.log(`${
|
|
39
|
+
console.log(`${Q} ${K.error} ${l.red("ERROR")} ${e}`);
|
|
94
40
|
}, a = (e) => {
|
|
95
41
|
console.log(e ?? "");
|
|
96
|
-
},
|
|
42
|
+
}, X = (e) => {
|
|
97
43
|
a(`开始执行 ${l.cyanBright(e)} 命令`);
|
|
98
|
-
const t =
|
|
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
|
-
},
|
|
103
|
-
a(), a(`${l.yellow(">>")} 开始依次执行命令...`), a(),
|
|
104
|
-
},
|
|
105
|
-
a(), J(`\`${e}\` 命令错误,请检查你的命令`), a(),
|
|
106
|
-
},
|
|
107
|
-
const t = ["package.json", "README.md"].map((
|
|
108
|
-
const r = g(process.cwd(),
|
|
109
|
-
return { path: r, content:
|
|
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
|
|
115
|
-
s.version =
|
|
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
|
-
|
|
118
|
-
},
|
|
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
|
|
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((
|
|
124
|
-
|
|
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 ? (
|
|
129
|
-
},
|
|
130
|
-
if (e.includes("build")) return
|
|
131
|
-
if (e.includes("version")) return
|
|
132
|
-
J(l.hex("#f56c6c")(`\`auto ${e}${t ? ` ${t}` : ""}\` 命令不存在`)),
|
|
133
|
-
}, v = "https://gitee.com/biaovorg/project-template.git",
|
|
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
|
-
},
|
|
141
|
-
|
|
86
|
+
}, qe = Object.keys(Te);
|
|
87
|
+
qe.reduce((e, t, o) => e + (o ? ", " : "") + t, "");
|
|
142
88
|
const h = (e = "jsonc") => `auto-cli.${e}`;
|
|
143
|
-
|
|
144
|
-
const
|
|
145
|
-
if (!
|
|
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
|
-
},
|
|
149
|
-
if (!
|
|
94
|
+
}, Re = (e) => {
|
|
95
|
+
if (!w(e)) return {};
|
|
150
96
|
const t = y(e).toString();
|
|
151
97
|
try {
|
|
152
|
-
return
|
|
98
|
+
return ue.load(t);
|
|
153
99
|
} catch {
|
|
154
100
|
return {};
|
|
155
101
|
}
|
|
156
|
-
},
|
|
157
|
-
const [e, t] = [h(), h("yml")].map((n) =>
|
|
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,
|
|
105
|
+
Object.assign(o, Re(t), Z(e, !0));
|
|
160
106
|
} catch {
|
|
161
107
|
}
|
|
162
108
|
return o;
|
|
163
|
-
},
|
|
164
|
-
let o =
|
|
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
|
-
},
|
|
114
|
+
}, Ge = ({ 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, Ue(n, t)), f(`${n} 文件创建成功`), a(), a(l.green(`文件目录 ${s}`));
|
|
176
122
|
};
|
|
177
|
-
|
|
178
|
-
const
|
|
179
|
-
a(), a(`${l.yellow(">>")} 开始依次执行命令...`), 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
|
-
|
|
182
|
-
const
|
|
183
|
-
let P = 0,
|
|
184
|
-
const
|
|
185
|
-
const
|
|
186
|
-
return !
|
|
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
|
-
},
|
|
134
|
+
}, L = (e, t = 0) => e.reduce((o, n, s, c) => {
|
|
189
135
|
let r;
|
|
190
|
-
return n.children ? (r = `├── ${n.name}`,
|
|
191
|
-
}, ""),
|
|
192
|
-
|
|
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 (
|
|
195
|
-
const
|
|
140
|
+
if (w(n)) {
|
|
141
|
+
const m = y(n).toString().split(`\r
|
|
196
142
|
`);
|
|
197
|
-
|
|
143
|
+
R.push(...m);
|
|
198
144
|
}
|
|
199
|
-
const s = o.split("\\").at(-1), r =
|
|
200
|
-
const { name:
|
|
201
|
-
return !
|
|
202
|
-
}),
|
|
203
|
-
|
|
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
|
-
|
|
206
|
-
const k =
|
|
207
|
-
const o = Array.from({ length: t }, (r,
|
|
208
|
-
process.stdout.write(
|
|
209
|
-
},
|
|
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((
|
|
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 ===
|
|
216
|
-
return n =
|
|
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
|
-
},
|
|
221
|
-
const [{ major: t = 0, minor: o = 0, patch: n = 0, release: s = "" }] =
|
|
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
|
-
},
|
|
224
|
-
const [o, n, s,
|
|
225
|
-
return r > o ? l.red(t) : r < o ? !1 :
|
|
226
|
-
},
|
|
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,
|
|
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 [
|
|
236
|
-
let $ = l.yellow("→"),
|
|
237
|
-
if (
|
|
238
|
-
const C =
|
|
239
|
-
C ?
|
|
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),
|
|
242
|
-
const
|
|
243
|
-
|
|
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
|
-
},
|
|
191
|
+
}, Xe = async (e, t, o) => {
|
|
246
192
|
a();
|
|
247
193
|
let n = 0;
|
|
248
|
-
const s = [],
|
|
249
|
-
const
|
|
250
|
-
s.push(
|
|
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
|
-
$ && $[
|
|
253
|
-
}), n++, await
|
|
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
|
-
},
|
|
257
|
-
if (!
|
|
258
|
-
const t = e || k.check, o = y(D).toString(), n = JSON.parse(o), s = ["dependencies", "devDependencies", "optionalDependencies"],
|
|
259
|
-
s.forEach((
|
|
260
|
-
n[
|
|
261
|
-
!k.reject.includes(
|
|
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
|
|
265
|
-
t ? (
|
|
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
|
-
|
|
268
|
-
const
|
|
269
|
-
if (!
|
|
270
|
-
const e = y(
|
|
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((
|
|
278
|
-
n += `- \`${
|
|
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),
|
|
228
|
+
}), n = n.slice(0, -1), j(Y, n), a(), f(`${se} 文件创建成功`), a(), a(l.green(`文件目录 ${Y}`));
|
|
283
229
|
};
|
|
284
|
-
|
|
285
|
-
const
|
|
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
|
-
|
|
288
|
-
!n &&
|
|
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
|
-
|
|
292
|
-
const
|
|
293
|
-
const n = Object.entries(t), s = n.findIndex(([
|
|
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[
|
|
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
|
-
},
|
|
244
|
+
}, H = (e) => {
|
|
299
245
|
e && (N(`nvm use ${e}`), a(), f(`切换成功 当前版本:${e}`), a());
|
|
300
|
-
},
|
|
246
|
+
}, V = (e) => {
|
|
301
247
|
e && N(`nvm install ${e}`);
|
|
302
|
-
},
|
|
303
|
-
const o = N("nvm ls").toString(), n =
|
|
304
|
-
if (
|
|
305
|
-
return
|
|
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 (
|
|
308
|
-
|
|
309
|
-
else if (a(), a(l.red(`输入的版本 ${e} 不存在`)), a(),
|
|
310
|
-
const
|
|
311
|
-
|
|
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: [...
|
|
316
|
-
}).then(({ preset:
|
|
317
|
-
if (
|
|
318
|
-
if (
|
|
261
|
+
choices: [...p, e, "取消"]
|
|
262
|
+
}).then(({ preset: u }) => {
|
|
263
|
+
if (u !== "取消")
|
|
264
|
+
if (u === e) {
|
|
319
265
|
if (!r) return;
|
|
320
|
-
|
|
266
|
+
V(u);
|
|
321
267
|
} else
|
|
322
|
-
|
|
268
|
+
H(u);
|
|
323
269
|
});
|
|
324
270
|
} else {
|
|
325
271
|
if (!r) return;
|
|
326
272
|
if (t.install) {
|
|
327
|
-
|
|
273
|
+
V(e);
|
|
328
274
|
return;
|
|
329
275
|
}
|
|
330
|
-
|
|
276
|
+
F.prompt({
|
|
331
277
|
type: "confirm",
|
|
332
278
|
name: "isInstall",
|
|
333
279
|
message: `是否安装 ${e}?`
|
|
334
|
-
}).then(({ isInstall:
|
|
335
|
-
|
|
280
|
+
}).then(({ isInstall: p }) => {
|
|
281
|
+
p && V(e);
|
|
336
282
|
});
|
|
337
283
|
}
|
|
338
284
|
};
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
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 ?
|
|
347
|
-
const x =
|
|
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.
|
|
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.
|
|
49
|
-
"commander": "^
|
|
48
|
+
"chalk": "^5.6.2",
|
|
49
|
+
"commander": "^14.0.0",
|
|
50
50
|
"download-git-repo": "^3.0.2",
|
|
51
|
-
"inquirer": "^12.
|
|
51
|
+
"inquirer": "^12.9.4",
|
|
52
52
|
"js-yaml": "^4.1.0",
|
|
53
|
-
"log-symbols": "^7.0.
|
|
54
|
-
"ora": "^8.
|
|
55
|
-
"pacote": "^21.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.
|
|
57
|
+
"strip-json-comments": "^5.0.3",
|
|
58
58
|
"update-notifier": "^7.3.1"
|
|
59
59
|
},
|
|
60
60
|
"devDependencies": {}
|