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