mine-auto-cli 2.8.0 → 2.8.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 +3 -0
- package/dist/claude.settings-D0MSYWxl.js +23 -0
- package/dist/index.js +510 -382
- package/dist/keyword-B5vOiHTH.js +148 -0
- package/package.json +9 -8
- package/dist/keyword-CJ3Dr1_B.js +0 -137
- package/dist/keyword-latest-0uZaQMuX.js +0 -98
package/dist/index.js
CHANGED
|
@@ -1,388 +1,516 @@
|
|
|
1
|
-
import { program as
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import { join as
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import { execSync as
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import { parseRange as
|
|
12
|
-
import
|
|
13
|
-
import
|
|
14
|
-
import
|
|
15
|
-
import
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
1
|
+
import { program as e } from "commander";
|
|
2
|
+
import t from "chalk";
|
|
3
|
+
import { cpSync as n, existsSync as r, readFileSync as i, readdirSync as a, rmSync as o, writeFileSync as s } from "fs";
|
|
4
|
+
import { dirname as c, join as l, resolve as u } from "path";
|
|
5
|
+
import d from "log-symbols";
|
|
6
|
+
import f from "ora";
|
|
7
|
+
import { execSync as p } from "child_process";
|
|
8
|
+
import * as m from "js-yaml";
|
|
9
|
+
import ee from "strip-json-comments";
|
|
10
|
+
import h from "pacote";
|
|
11
|
+
import { parseRange as g } from "semver-utils";
|
|
12
|
+
import _ from "download-git-repo";
|
|
13
|
+
import v from "inquirer";
|
|
14
|
+
import y from "os";
|
|
15
|
+
import { openBinary as te } from "@avmc/bun-extractor";
|
|
16
|
+
import ne from "update-notifier";
|
|
17
|
+
//#region package.json
|
|
18
|
+
var re = "mine-auto-cli", ie = "2.8.2", b = {
|
|
19
|
+
name: re,
|
|
20
|
+
private: !1,
|
|
21
|
+
version: ie,
|
|
22
|
+
exports: "./dist/index.js",
|
|
23
|
+
main: "./dist/index.js",
|
|
24
|
+
type: "module",
|
|
25
|
+
bin: { auto: "bin/mine-auto-cli.js" },
|
|
26
|
+
author: {
|
|
27
|
+
name: "biaov",
|
|
28
|
+
email: "biaov@qq.com",
|
|
29
|
+
url: "https://biaov.cn"
|
|
30
|
+
},
|
|
31
|
+
description: "一个将多个命令简化成一个命令的工具 😆",
|
|
32
|
+
scripts: {
|
|
33
|
+
start: "npm run dev",
|
|
34
|
+
dev: "npm run build -- --watch",
|
|
35
|
+
build: "vite build",
|
|
36
|
+
prettier: "prettier --write '**/*.{js,ts,md,json}'",
|
|
37
|
+
tag: "node scripts/tag"
|
|
38
|
+
},
|
|
39
|
+
publishConfig: {
|
|
40
|
+
registry: "https://registry.npmjs.org/",
|
|
41
|
+
"engine-strict": !0,
|
|
42
|
+
provenance: !0
|
|
43
|
+
},
|
|
44
|
+
engines: { node: ">=24.18.0" },
|
|
45
|
+
keywords: [
|
|
46
|
+
"auto",
|
|
47
|
+
"cli",
|
|
48
|
+
"vite",
|
|
49
|
+
"typescript"
|
|
50
|
+
],
|
|
51
|
+
repository: {
|
|
52
|
+
type: "git",
|
|
53
|
+
url: "git+https://github.com/biaov/mine-auto-cli.git"
|
|
54
|
+
},
|
|
55
|
+
homepage: "https://github.com/biaov/mine-auto-cli.git",
|
|
56
|
+
bugs: { url: "https://github.com/biaov/mine-auto-cli/issues" },
|
|
57
|
+
license: "ISC",
|
|
58
|
+
contributors: [{
|
|
59
|
+
name: "biaov",
|
|
60
|
+
email: "biaov@qq.com"
|
|
61
|
+
}],
|
|
62
|
+
dependencies: {
|
|
63
|
+
"@avmc/bun-extractor": "^0.5.1",
|
|
64
|
+
chalk: "^5.6.2",
|
|
65
|
+
commander: "^15.0.0",
|
|
66
|
+
"download-git-repo": "^3.0.2",
|
|
67
|
+
inquirer: "^14.0.2",
|
|
68
|
+
"js-yaml": "^5.1.0",
|
|
69
|
+
"log-symbols": "^7.0.1",
|
|
70
|
+
ora: "^9.4.1",
|
|
71
|
+
pacote: "^22.0.0",
|
|
72
|
+
"semver-utils": "^1.1.4",
|
|
73
|
+
"strip-json-comments": "^5.0.3",
|
|
74
|
+
"update-notifier": "^7.3.1"
|
|
75
|
+
},
|
|
76
|
+
devDependencies: {
|
|
77
|
+
"@types/js-yaml": "^4.0.9",
|
|
78
|
+
"@types/node": "^26.0.0",
|
|
79
|
+
"@types/pacote": "^11.1.8",
|
|
80
|
+
"@types/semver-utils": "^1.1.3",
|
|
81
|
+
"@types/update-notifier": "^6.0.8",
|
|
82
|
+
prettier: "^3.8.4",
|
|
83
|
+
typescript: "^6.0.3",
|
|
84
|
+
vite: "^8.1.0"
|
|
85
|
+
}
|
|
86
|
+
}, x = (e) => {
|
|
87
|
+
console.log(`${d.success} ${t.green("SUCCESS")} ${e}`);
|
|
39
88
|
}, S = (e) => {
|
|
40
|
-
|
|
41
|
-
},
|
|
42
|
-
|
|
43
|
-
},
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
}, pe = (e, t
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
};
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
89
|
+
console.log(`${re} ${d.error} ${t.red("ERROR")} ${e}`);
|
|
90
|
+
}, C = (e) => {
|
|
91
|
+
console.log(e ?? "");
|
|
92
|
+
}, w = (e) => {
|
|
93
|
+
C(`开始执行 ${t.cyanBright(e)} 命令`);
|
|
94
|
+
let n = f({
|
|
95
|
+
text: "正在执行命令中...",
|
|
96
|
+
color: "yellow"
|
|
97
|
+
});
|
|
98
|
+
n.start(), C(p(e, { cwd: process.cwd() }).toString()), n.succeed(`${t.green(e)} 命令执行成功`), C();
|
|
99
|
+
}, ae = (e) => [
|
|
100
|
+
"git add -A",
|
|
101
|
+
`git commit -m ${e}`,
|
|
102
|
+
"git push"
|
|
103
|
+
], oe = (e, t) => [
|
|
104
|
+
`npm run ${e}`,
|
|
105
|
+
"git add -A",
|
|
106
|
+
`git commit -m ${t}`,
|
|
107
|
+
"git push"
|
|
108
|
+
], se = async (e, n = "打包") => {
|
|
109
|
+
C(), C(`${t.yellow(">>")} 开始依次执行命令...`), C(), oe(e, n).map(w), x("全部命令执行完成"), C();
|
|
110
|
+
}, ce = (t) => {
|
|
111
|
+
C(), S(`\`${t}\` 命令错误,请检查你的命令`), C(), e.help();
|
|
112
|
+
}, le = (e) => {
|
|
113
|
+
let [t, n] = ["package.json", "README.md"].map((e) => {
|
|
114
|
+
let t = l(process.cwd(), e);
|
|
115
|
+
return {
|
|
116
|
+
path: t,
|
|
117
|
+
content: i(t).toString()
|
|
118
|
+
};
|
|
119
|
+
}), r = JSON.parse(t.content);
|
|
120
|
+
e ? r.version = e : r.version = r.version.split(".").reduce((e, t, n, r) => e + (n === r.length - 1 ? +t + 1 : `${t}.`), ""), s(t.path, JSON.stringify(r, null, 2)), n.content = n.content.replace(/version\-v.+\-blue/, () => `version-v${r.version}-blue`), s(n.path, n.content);
|
|
121
|
+
}, ue = async (e) => {
|
|
122
|
+
let t = e.split("version")[1];
|
|
123
|
+
if (!t) return ce(e);
|
|
124
|
+
let n = JSON.parse(i(l(process.cwd(), "package.json")).toString());
|
|
125
|
+
if (t === "++") {
|
|
126
|
+
le(n.version.split(".").reduce((e, t, n, r) => e + (n === r.length - 1 ? +t + 1 : `${t}.`), "")), C(), x("命令执行完成");
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
let r = t.split("@")[1];
|
|
130
|
+
r ? (le(r), C(), x("命令执行完成")) : ce(e);
|
|
131
|
+
}, de = (n, r) => {
|
|
132
|
+
if (n.includes("build")) return se(n, r);
|
|
133
|
+
if (n.includes("version")) return ue(n);
|
|
134
|
+
S(t.hex("#f56c6c")(`\`auto ${n}${r ? ` ${r}` : ""}\` 命令不存在`)), e.help();
|
|
135
|
+
}, T = "https://gitee.com/biaovorg/project-template.git";
|
|
136
|
+
Object.keys({
|
|
137
|
+
vue: T,
|
|
138
|
+
react: T,
|
|
139
|
+
"uni-app": T,
|
|
140
|
+
electron: T,
|
|
141
|
+
node: T,
|
|
142
|
+
"node-simple": T
|
|
143
|
+
}).reduce((e, t, n) => e + (n ? ", " : "") + t, "");
|
|
144
|
+
var E = (e = "jsonc") => `auto-cli.${e}`;
|
|
145
|
+
u(import.meta.dirname, "./presetData.json");
|
|
146
|
+
var D = (e, t = !1) => {
|
|
147
|
+
if (!r(e)) return t ? {} : "";
|
|
148
|
+
let n = i(e).toString();
|
|
149
|
+
return t ? JSON.parse(ee(n)) : n;
|
|
150
|
+
}, fe = (e) => {
|
|
151
|
+
if (!r(e)) return {};
|
|
152
|
+
let t = i(e).toString();
|
|
153
|
+
try {
|
|
154
|
+
return m.load(t);
|
|
155
|
+
} catch {
|
|
156
|
+
return {};
|
|
157
|
+
}
|
|
158
|
+
}, O = (e = !1) => D(u(import.meta.dirname, E()), e), k = () => {
|
|
159
|
+
let [e, t] = [E(), E("yml")].map((e) => u(process.cwd(), e)), n = O(!0);
|
|
160
|
+
try {
|
|
161
|
+
Object.assign(n, fe(t), D(e, !0));
|
|
162
|
+
} catch {}
|
|
163
|
+
return n;
|
|
164
|
+
}, pe = (e, t = !1) => {
|
|
165
|
+
let n = O(t);
|
|
166
|
+
return t && (n = JSON.stringify(n, null, 2)), e.includes(".yml") ? n.trim().split("\n").slice(1, -1).reduce((e, t) => e + t.trim().replace(/[",]/g, "").replace("// ", "# ") + "\n", "") : n;
|
|
167
|
+
}, A = (e, t, n = " ") => Array.from({ length: t - e }, () => n).join(""), me = () => `${+/* @__PURE__ */ new Date()}${Math.random().toString(36).substring(2, 6)}`;
|
|
168
|
+
e.command("init").option("-f, --force", `强制替换 ${E()} 文件内容`, !1).option("--unc, --uncomment", `取消生成 ${E()} 带注释`, !1).option("-y, --yml", `生成 ${E("yml")} 文件`, !1).description("初始化配置文件").action(({ yml: e, uncomment: n, force: i }) => {
|
|
169
|
+
C();
|
|
170
|
+
let a = E(e ? "yml" : "jsonc"), o = u(process.cwd(), a);
|
|
171
|
+
if (r(o) && !i) {
|
|
172
|
+
C(t.yellow(`${a} 文件已存在`)), C(), C(t.yellow(`文件目录 ${o}`));
|
|
173
|
+
return;
|
|
174
|
+
}
|
|
175
|
+
s(o, pe(a, n)), x(`${a} 文件创建成功`), C(), C(t.green(`文件目录 ${o}`));
|
|
176
|
+
}), e.command("git [描述]").description("简化 Git 提交命令").action(async (e = "更新代码") => {
|
|
177
|
+
C(), C(`${t.yellow(">>")} 开始依次执行命令...`), C(), ae(e).forEach(w), x("全部命令执行完成"), C();
|
|
178
|
+
});
|
|
179
|
+
//#endregion
|
|
180
|
+
//#region src/commander/commands/mkdir.ts
|
|
181
|
+
var j = [
|
|
182
|
+
"dist",
|
|
183
|
+
"node_modules",
|
|
184
|
+
".git",
|
|
185
|
+
"miniprogram_npm"
|
|
186
|
+
], M = 0, N = !1, P = !1, F = 20, I = ({ prev: e, i: t, index: n, arr: r, curText: i }) => {
|
|
187
|
+
let a = Array.from({ length: t }).reduce((e) => e + `${t === 1 && n === r.length - 1 ? "└ " : "│ "} `, ""), o = e + a, s = (a + i).length, c = Array.from({ length: F + M - s }).reduce((e) => `${e}-`, " ");
|
|
188
|
+
return !N && (M = Math.max(M, s)), `${o}${i}${P ? c : ""}\n`;
|
|
189
|
+
}, L = (e, t = 0) => e.reduce((e, n, r, i) => {
|
|
190
|
+
let a;
|
|
191
|
+
return n.children ? (a = `├── ${n.name}`, I({
|
|
192
|
+
prev: e,
|
|
193
|
+
i: t,
|
|
194
|
+
index: r,
|
|
195
|
+
arr: i,
|
|
196
|
+
curText: a
|
|
197
|
+
}) + L(n.children, t + 1)) : (a = `${r === i.length - 1 ? "└── " : "├── "}${n.name}`, I({
|
|
198
|
+
prev: e,
|
|
199
|
+
i: t,
|
|
200
|
+
index: r,
|
|
201
|
+
arr: i,
|
|
202
|
+
curText: a
|
|
203
|
+
}));
|
|
204
|
+
}, ""), R = (e) => a(e, { withFileTypes: !0 }).sort((e, t) => t.isDirectory() - +e.isDirectory());
|
|
205
|
+
e.command("mkdir").option("-l, --line [数量]", "数量", !1).option("-n, --name [文件名称]", "文件名称", !1).option("-d, --depth [深度值]", "深度值", "3").description("生成目录结构文件").action(({ line: e, name: t }) => {
|
|
206
|
+
P = !!e, typeof e == "string" && (F = +e);
|
|
207
|
+
let n = process.cwd(), a = l(n, ".gitignore");
|
|
208
|
+
if (r(a)) {
|
|
209
|
+
let e = i(a).toString().split("\r\n");
|
|
210
|
+
j.push(...e);
|
|
211
|
+
}
|
|
212
|
+
let o = [{
|
|
213
|
+
name: n.split("\\").at(-1),
|
|
214
|
+
children: R(n).map((e) => {
|
|
215
|
+
let { name: t } = e, n = { name: t };
|
|
216
|
+
return !j.includes(t) && e.isDirectory() && (n.children = R(l(e.path, t)).map(({ name: e }) => ({ name: e }))), n;
|
|
217
|
+
})
|
|
218
|
+
}];
|
|
219
|
+
P && (L(o), N = !0), s(l(n, `${typeof t == "string" && t || "directory"}.md`), L(o));
|
|
220
|
+
});
|
|
221
|
+
//#endregion
|
|
222
|
+
//#region src/commander/commands/check.ts
|
|
223
|
+
var z = k(), [B] = ["package.json"].map((e) => u(process.cwd(), e)), he = (e, n) => {
|
|
224
|
+
let r = `\r查找进度:[${Array.from({ length: n }, (t, n) => n < e ? "=" : " ").join("")}] ${e}/${n} ${~~(e / n * 100)}%\r`, i = e === n ? t.green(r) : t.yellow(r);
|
|
225
|
+
process.stdout.write(i);
|
|
226
|
+
}, ge = (e, t, n) => {
|
|
227
|
+
let r = "latest";
|
|
228
|
+
return z.resolve.some((t) => {
|
|
229
|
+
let n = t.lastIndexOf("@");
|
|
230
|
+
if (n <= 0) return !0;
|
|
231
|
+
let i = t.slice(0, n), a = t.slice(n + 1);
|
|
232
|
+
if (e === i) return r = a, !0;
|
|
233
|
+
}), {
|
|
234
|
+
name: e,
|
|
235
|
+
value: t,
|
|
236
|
+
newVersion: z.prefix + n[r],
|
|
237
|
+
tag: r
|
|
238
|
+
};
|
|
239
|
+
}, _e = (e, t) => (+!t + 1) * e.length, V = (e) => {
|
|
240
|
+
let [{ major: t = 0, minor: n = 0, patch: r = 0, release: i = "" }] = g(e);
|
|
241
|
+
return [
|
|
242
|
+
+t,
|
|
243
|
+
+n,
|
|
244
|
+
+r,
|
|
245
|
+
i
|
|
246
|
+
];
|
|
247
|
+
}, H = (e, n) => e ? "-" + t[n](e) : "", ve = (e, n) => {
|
|
248
|
+
let [r, i, a, o] = V(e), [s, c, l, u] = V(n);
|
|
249
|
+
return s > r ? t.red(n) : s < r ? !1 : c > i ? `${s}.${t.yellow(c)}.${t.yellow(l)}${H(u, "yellow")}` : c < i ? !1 : l > a ? `${s}.${c}.${t.green(l)}${H(u, "green")}` : l === a && u && u !== o ? `${s}.${c}.${l}${H(u, "green")}` : !1;
|
|
250
|
+
}, ye = (e) => {
|
|
251
|
+
let n = {};
|
|
252
|
+
e.forEach((e) => {
|
|
253
|
+
Object.entries(e).forEach(([e, t]) => {
|
|
254
|
+
n[e] = Math.max(t.length, n[e] ?? 0);
|
|
255
|
+
});
|
|
256
|
+
}), e.unshift({
|
|
257
|
+
name: "包名",
|
|
258
|
+
value: "版本",
|
|
259
|
+
newVersion: "新版本",
|
|
260
|
+
tag: "标签"
|
|
261
|
+
});
|
|
262
|
+
let r = [];
|
|
263
|
+
e.forEach(({ name: e, value: i, newVersion: a, tag: o }, s) => {
|
|
264
|
+
let [c, l, u, d] = Object.entries({
|
|
265
|
+
name: e,
|
|
266
|
+
value: i,
|
|
267
|
+
newVersion: a,
|
|
268
|
+
tag: o
|
|
269
|
+
}).map(([e, t]) => A(_e(t, s), n[e])), f = t.yellow("→"), p = !0;
|
|
270
|
+
if (s) {
|
|
271
|
+
let e = ve(i, a);
|
|
272
|
+
e ? a = e : p = !1;
|
|
273
|
+
} else e = t.green(e), i = t.green(i), a = t.green(a), o = t.green(o), f = " ";
|
|
274
|
+
let m = `${e + c} ${l + i} ${f} ${u + a} ${d + o}`;
|
|
275
|
+
p && r.push(m);
|
|
276
|
+
}), r.length > 1 ? r.forEach(C) : x("所有版本已是最新");
|
|
277
|
+
}, be = async (e, t, n) => {
|
|
278
|
+
C();
|
|
279
|
+
let r = 0, i = [], a = Object.entries(e), o = a.map(async ([e, o]) => {
|
|
280
|
+
let s = ge(e, o, (await h.packument(e, { registry: z.registry }))["dist-tags"]);
|
|
281
|
+
i.push(s), t.forEach((t) => {
|
|
282
|
+
let r = n[t];
|
|
283
|
+
r && r[e] && (r[e] = s.newVersion);
|
|
284
|
+
}), r++, await he(r, a.length);
|
|
285
|
+
});
|
|
286
|
+
return await Promise.all(o), C(), C(), i;
|
|
230
287
|
};
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
288
|
+
e.command("check").option("-u, --update", "更新 package.json 依赖内容", !1).description("升级 package.json 依赖版本").action(async ({ update: e }) => {
|
|
289
|
+
if (!r(B)) return S("package.json 文件不存在");
|
|
290
|
+
let t = e || z.check, n = i(B).toString(), a = JSON.parse(n), o = [
|
|
291
|
+
"dependencies",
|
|
292
|
+
"devDependencies",
|
|
293
|
+
"optionalDependencies"
|
|
294
|
+
], c = {}, l = JSON.parse(n);
|
|
295
|
+
o.forEach((e) => {
|
|
296
|
+
a[e] && Object.entries(a[e]).forEach(([e, t]) => {
|
|
297
|
+
!z.reject.includes(e) && (c[e] = t);
|
|
298
|
+
});
|
|
299
|
+
});
|
|
300
|
+
let u = await be(c, o, l);
|
|
301
|
+
t ? (s(B, JSON.stringify(l, null, 2)), x("文件 package.json 已更新"), C()) : ye(u);
|
|
302
|
+
});
|
|
303
|
+
//#endregion
|
|
304
|
+
//#region src/commander/commands/comment.ts
|
|
305
|
+
var xe = k(), U = "comment.md", [W, G] = ["package.json", U].map((e) => u(process.cwd(), e));
|
|
306
|
+
e.command("comment").description("生成依赖注释文件").action(() => {
|
|
307
|
+
if (!r(W)) return S("package.json 文件不存在");
|
|
308
|
+
let e = i(W).toString(), n = JSON.parse(e), a = [
|
|
309
|
+
"dependencies",
|
|
310
|
+
"devDependencies",
|
|
311
|
+
"optionalDependencies"
|
|
312
|
+
], o = "### 依赖解析\n\n";
|
|
313
|
+
a.forEach((e) => {
|
|
314
|
+
n[e] && (o += `#### ${e}\n\n`, Object.keys(n[e]).forEach((e) => {
|
|
315
|
+
o += `- \`${e}\`: ${xe.comment[e] || ""}\n`;
|
|
316
|
+
}), o += "\n");
|
|
317
|
+
}), o = o.slice(0, -1), s(G, o), C(), x(`${U} 文件创建成功`), C(), C(t.green(`文件目录 ${G}`));
|
|
318
|
+
});
|
|
319
|
+
//#endregion
|
|
320
|
+
//#region src/commander/commands/vscode.ts
|
|
321
|
+
var Se = {
|
|
322
|
+
recursive: !0,
|
|
323
|
+
force: !0
|
|
237
324
|
};
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
ee(l.semver);
|
|
256
|
-
else if (a(), a(p.red(`输入的版本 ${e} 不存在`)), a(), i.length) {
|
|
257
|
-
const m = i.map((d) => d.semver);
|
|
258
|
-
H.prompt({
|
|
259
|
-
type: "list",
|
|
260
|
-
name: "preset",
|
|
261
|
-
message: "请选择相似版本或输入版本进行安装:",
|
|
262
|
-
choices: [...m, e, "取消"]
|
|
263
|
-
}).then(({ preset: d }) => {
|
|
264
|
-
if (d !== "取消")
|
|
265
|
-
if (d === e) {
|
|
266
|
-
if (!c) return;
|
|
267
|
-
D(d);
|
|
268
|
-
} else
|
|
269
|
-
ee(d);
|
|
270
|
-
});
|
|
271
|
-
} else {
|
|
272
|
-
if (!c) return;
|
|
273
|
-
if (t.install) {
|
|
274
|
-
D(e);
|
|
275
|
-
return;
|
|
276
|
-
}
|
|
277
|
-
H.prompt({
|
|
278
|
-
type: "confirm",
|
|
279
|
-
name: "isInstall",
|
|
280
|
-
message: `是否安装 ${e}?`
|
|
281
|
-
}).then(({ isInstall: m }) => {
|
|
282
|
-
m && D(e);
|
|
283
|
-
});
|
|
284
|
-
}
|
|
325
|
+
e.command("vscode-config").description("更新 .vscode 配置文件").action(() => {
|
|
326
|
+
let e = `${+/* @__PURE__ */ new Date()}`, t = l(process.cwd()), r = l(t, e);
|
|
327
|
+
_("direct:https://gitee.com/biaovorg/vscode-config.git#master", r, { clone: !0 }, async (e) => {
|
|
328
|
+
!e && n(l(r, ".vscode"), l(t, ".vscode"), Se), o(r, Se);
|
|
329
|
+
});
|
|
330
|
+
});
|
|
331
|
+
//#endregion
|
|
332
|
+
//#region src/commander/commands/node.ts
|
|
333
|
+
var Ce = (e, t, n) => {
|
|
334
|
+
let r = Object.entries(t), i = r.findIndex(([t]) => e === t), [a, o] = r[i];
|
|
335
|
+
if (o) {
|
|
336
|
+
if (n[a] === o) return i === r.length - 1 ? !0 : Ce(r[i + 1][0], t, n);
|
|
337
|
+
} else return !0;
|
|
338
|
+
}, we = (e) => {
|
|
339
|
+
e && (p(`nvm use ${e}`), C(), x(`切换成功 当前版本:${e}`), C());
|
|
340
|
+
}, K = (e) => {
|
|
341
|
+
e && p(`nvm install ${e}`);
|
|
285
342
|
};
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
},
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
}
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
}
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
343
|
+
e.command("node [版本号]").option("-i, --install", "是否安装此版本", !1).description("切换 node 版本,默认选择第一个版本").action((e, n) => {
|
|
344
|
+
let r = g(p("nvm ls").toString()), [{ major: i, minor: a, patch: o }] = g(e), s = [], c = r.find((e) => {
|
|
345
|
+
if (e.major === i) return s.push(e), Ce("minor", {
|
|
346
|
+
minor: a,
|
|
347
|
+
patch: o
|
|
348
|
+
}, e);
|
|
349
|
+
});
|
|
350
|
+
if (c) we(c.semver);
|
|
351
|
+
else if (C(), C(t.red(`输入的版本 ${e} 不存在`)), C(), s.length) {
|
|
352
|
+
let t = s.map((e) => e.semver);
|
|
353
|
+
v.prompt({
|
|
354
|
+
type: "list",
|
|
355
|
+
name: "preset",
|
|
356
|
+
message: "请选择相似版本或输入版本进行安装:",
|
|
357
|
+
choices: [
|
|
358
|
+
...t,
|
|
359
|
+
e,
|
|
360
|
+
"取消"
|
|
361
|
+
]
|
|
362
|
+
}).then(({ preset: t }) => {
|
|
363
|
+
if (t !== "取消") if (t === e) {
|
|
364
|
+
if (!o) return;
|
|
365
|
+
K(t);
|
|
366
|
+
} else we(t);
|
|
367
|
+
});
|
|
368
|
+
} else {
|
|
369
|
+
if (!o) return;
|
|
370
|
+
if (n.install) {
|
|
371
|
+
K(e);
|
|
372
|
+
return;
|
|
373
|
+
}
|
|
374
|
+
v.prompt({
|
|
375
|
+
type: "confirm",
|
|
376
|
+
name: "isInstall",
|
|
377
|
+
message: `是否安装 ${e}?`
|
|
378
|
+
}).then(({ isInstall: t }) => {
|
|
379
|
+
t && K(e);
|
|
380
|
+
});
|
|
381
|
+
}
|
|
382
|
+
});
|
|
383
|
+
//#endregion
|
|
384
|
+
//#region src/commander/commands/ai.ts
|
|
385
|
+
var q = [
|
|
386
|
+
"ANTHROPIC_AUTH_TOKEN",
|
|
387
|
+
"ANTHROPIC_BASE_URL",
|
|
388
|
+
"ANTHROPIC_MODEL",
|
|
389
|
+
"ANTHROPIC_SMALL_FAST_MODEL"
|
|
390
|
+
], Te = D(u(import.meta.dirname, "ai.jsonc"), !0), Ee = Object.entries(Te)[0], J = u(y.homedir(), ".claude/settings.json"), De = u(y.homedir(), ".claude/settings.local.json"), Y = u(y.homedir(), ".ai-model.json"), X = () => {
|
|
391
|
+
r(J) || (S(`${J} 文件不存在,请先检查或者去安装 Claude Code`), process.exit(1));
|
|
392
|
+
let e = JSON.parse(i(J).toString());
|
|
393
|
+
return !e.env && (e.env = {}), e;
|
|
394
|
+
}, Oe = () => {
|
|
395
|
+
C(), r(Y) || (S("配置不存在,请先使用 `ai init` 初始化 AI 模型配置"), process.exit(1));
|
|
396
|
+
let e = JSON.parse(i(Y).toString()), n = Object.entries(e).filter(([e, t]) => {
|
|
397
|
+
if (e === Ee[0]) return !1;
|
|
398
|
+
let n = t.env, r = Ee[1].env;
|
|
399
|
+
return !(!n || q.some((e) => !n[e] || n[e] === r[e]));
|
|
400
|
+
});
|
|
401
|
+
return n.length || (C(`暂无已配置的 AI 模型,请先配置,路径 ${t.green(Y)}`), process.exit(1)), [n, e];
|
|
402
|
+
}, ke = () => {
|
|
403
|
+
if (C(), r(Y)) {
|
|
404
|
+
C(`配置已存在,路径 ${t.green(Y)}`);
|
|
405
|
+
return;
|
|
406
|
+
}
|
|
407
|
+
s(Y, JSON.stringify(Te, null, 2)), x(`配置已初始化,路径 ${t.green(Y)}`);
|
|
408
|
+
}, Ae = (e) => e.replace(/[\u4e00-\u9fa5]/g, "aa").length, je = () => {
|
|
409
|
+
let [e] = Oe(), n = 0, r = -1, i = X();
|
|
410
|
+
e.forEach(([e, t], a) => {
|
|
411
|
+
n = Math.max(n, Ae(e)), r < 0 && !q.some((e) => i.env[e] !== t.env[e]) && (r = a);
|
|
412
|
+
}), e.forEach(([e, i], a) => {
|
|
413
|
+
let { ANTHROPIC_BASE_URL: o } = i.env;
|
|
414
|
+
C(`${a === r ? t.green("*") : " "} ${e} ${A(Ae(e), n + 4, "-")} ${o}`);
|
|
415
|
+
});
|
|
416
|
+
}, Me = async (e) => {
|
|
417
|
+
let n = X(), [r, i] = Oe();
|
|
418
|
+
r.some(([t]) => t === e) || (C(`模型 ${t.red(e)} 不存在`), process.exit(1)), q.some((t) => n.env[t] !== i[e].env[t]) ? (n.env = i[e].env, s(J, JSON.stringify(n, null, 2)), x(`模型 ${t.green(e)} 已切换`)) : C(`当前正处于 ${t.green(e)} 模型,无需切换`);
|
|
419
|
+
}, Z = () => {
|
|
420
|
+
let e = "@anthropic-ai/claude-code";
|
|
421
|
+
try {
|
|
422
|
+
p(`npm list -g ${e} --depth=0`).toString().trim().includes(e) || (S(t.red(`请使用 nodejs 安装 ${e}`)), process.exit(1));
|
|
423
|
+
let i = p("npm root -g").toString().trim(), a = u(i, e, "cli.js"), o = u(i, e, "cli.bak.js"), s = u(i, e, "bin/claude.exe"), c = u(i, e, "bin/claude.zh.exe"), l = u(i, e, "bin/claude.bak.exe"), d = !1;
|
|
424
|
+
return r(s) ? (!r(l) && n(s, l), d = !0) : !r(o) && n(a, o), {
|
|
425
|
+
cliPath: a,
|
|
426
|
+
cliPathBak: o,
|
|
427
|
+
exePath: s,
|
|
428
|
+
exeZhPath: c,
|
|
429
|
+
exePathBak: l,
|
|
430
|
+
isExistExe: d
|
|
431
|
+
};
|
|
432
|
+
} catch {
|
|
433
|
+
S(t.red(`请使用 nodejs 安装 ${e}`)), process.exit(1);
|
|
434
|
+
}
|
|
435
|
+
}, Ne = async () => {
|
|
436
|
+
C(), C("开始汉化 Claude Code");
|
|
437
|
+
let e = Z(), { cliPath: t, exePath: a, exeZhPath: o, isExistExe: c } = e;
|
|
438
|
+
if (c) {
|
|
439
|
+
if (r(o)) {
|
|
440
|
+
n(o, a);
|
|
441
|
+
return;
|
|
442
|
+
}
|
|
443
|
+
await Le(e), n(o, a);
|
|
444
|
+
} else {
|
|
445
|
+
let e = i(t).toString(), n = (await import("./keyword-B5vOiHTH.js")).default;
|
|
446
|
+
s(t, Object.entries(n).reduce((e, [t, n]) => {
|
|
447
|
+
let r = t.replace(/\n/g, "\\\\n").replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), i = n.replace(/\n/g, "\\n");
|
|
448
|
+
return ["`", "\\"].includes(r[0]) ? e.replace(new RegExp(r, "g"), n) : e.replace(RegExp(`\"${r}\"`, "g"), `\"${i}\"`).replace(RegExp(`(\'${r}\')`, "g"), `\'${i}\'`);
|
|
449
|
+
}, e));
|
|
450
|
+
}
|
|
451
|
+
x("Claude Code 已汉化");
|
|
452
|
+
}, Pe = () => {
|
|
453
|
+
C(), C("开始恢复 Claude Code");
|
|
454
|
+
let { cliPath: e, cliPathBak: t, exePath: r, exePathBak: i, isExistExe: a } = Z();
|
|
455
|
+
a ? n(i, r) : n(t, e), x("Claude Code 已恢复成英文");
|
|
456
|
+
}, Fe = async () => {
|
|
457
|
+
C();
|
|
458
|
+
let e = (await import("./claude.settings-D0MSYWxl.js")).default, n = X();
|
|
459
|
+
Object.assign(n, e), s(J, JSON.stringify(n, null, 2)), x(`Claude Code 配置成功,请前往查看:${t.yellow(J)}`);
|
|
460
|
+
}, Ie = async () => {
|
|
461
|
+
if (C(), C("开始配置 Claude Code 默认权限"), C(), !r(De)) {
|
|
462
|
+
Fe();
|
|
463
|
+
return;
|
|
464
|
+
}
|
|
465
|
+
v.prompt({
|
|
466
|
+
type: "confirm",
|
|
467
|
+
name: "isOk",
|
|
468
|
+
message: "存在本地配置文件,继续配置会直接覆盖本地配置文件里的属性内容,是否继续 ?"
|
|
469
|
+
}).then(({ isOk: e }) => {
|
|
470
|
+
e && Fe();
|
|
471
|
+
});
|
|
472
|
+
}, Le = async ({ cliPath: e, exePath: t, exeZhPath: n, exePathBak: r, isExistExe: a }) => {
|
|
473
|
+
let o = c(t), l = t, d = u(o, me());
|
|
474
|
+
p(`npx bun-extractor "${l}" -o "${d}"`, { stdio: "ignore" });
|
|
475
|
+
let f = u(d, te(i(l)).entryPoint.path), m = i(f).toString(), ee = (await import("./keyword-B5vOiHTH.js")).default, h = Object.entries(ee).reduce((e, [t, n]) => {
|
|
476
|
+
let r = t.replace(/\n/g, "\\\\n").replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), i = n.replace(/\n/g, "\\n");
|
|
477
|
+
return ["`", "\\"].includes(r[0]) ? e.replace(new RegExp(r, "g"), n) : e.replace(RegExp(`\"${r}\"`, "g"), `\"${i}\"`).replace(RegExp(`(\'${r}\')`, "g"), `\'${i}\'`);
|
|
478
|
+
}, m), g = Array.from(h).map((e) => {
|
|
479
|
+
let t = e.charCodeAt(0);
|
|
480
|
+
return t >= 19968 && t <= 40959 ? `\\u${t.toString(16).padStart(4, "0")}` : e;
|
|
481
|
+
}).join(""), _ = f.slice(0, -3) + ".zh.js";
|
|
482
|
+
s(_, g);
|
|
483
|
+
let v = `import { dirname, resolve } from 'node:path'
|
|
484
|
+
await import(resolve(dirname(process.execPath), "${_.replace(/\\/g, "/")}"))`, y = u(d, "entry.js");
|
|
485
|
+
s(y, v), p(`bun build ${y} --compile --icon=claude-code.ico --outfile ${l.slice(0, -4) + ".zh.exe"}`, { stdio: "ignore" });
|
|
486
|
+
}, Q = e.command("ai").description("AI 命令,详细操作请查看 ai -h").helpOption("-h, --help", "输出所有命令").helpCommand(!1);
|
|
487
|
+
Q.command("init").description("初始化 AI 模型配置").action(ke), Q.command("ls").description("查看当前已配置的 AI 模型").action(je), Q.command("use <模型>").description("切换 AI 模型").action(Me), Q.command("zh").description("汉化 Claude Code").action(Ne), Q.command("zh-restore").description("恢复汉化 Claude Code").action(Pe), Q.command("config").description("配置 Claude Code 默认权限").action(Ie), e.usage("[commands] [options]").version(ie, "-v, --version", "输出版本号").helpOption("-h, --help", "输出所有命令"), e.command("build[:环境] [描述]").description("简化打包提交命令"), e.command("version<[++]|[@<版本号>]>").description("例如:version++ 或者 version@1.0.0;自动更新 package.json 版本号,自动更新 `README.md` 中的 `version-v<version>-blue` 图标版本"), e.arguments("<cmd> [env]").action((e, t) => {
|
|
488
|
+
de(e, t);
|
|
489
|
+
}), process.argv.length < 3 ? e.help() : e.parse(process.argv);
|
|
490
|
+
//#endregion
|
|
491
|
+
//#region src/update.ts
|
|
492
|
+
var $ = ne({
|
|
493
|
+
pkg: b,
|
|
494
|
+
updateCheckInterval: 1e3 * 1
|
|
364
495
|
});
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
message: `有更新 ${p.dim("{currentVersion}")}${p.reset(" → ")}${e}
|
|
385
|
-
运行 ${p.cyan("{updateCommand}@latest")} 命令更新
|
|
386
|
-
${p.dim.underline(t)}`
|
|
387
|
-
});
|
|
496
|
+
if ($.update && $.update.latest !== b.version) {
|
|
497
|
+
let e = "";
|
|
498
|
+
switch ($.update.type) {
|
|
499
|
+
case "major":
|
|
500
|
+
e = t.red("{latestVersion}");
|
|
501
|
+
break;
|
|
502
|
+
case "minor":
|
|
503
|
+
e = t.yellow("{latestVersion}");
|
|
504
|
+
break;
|
|
505
|
+
default:
|
|
506
|
+
e = t.green("{latestVersion}");
|
|
507
|
+
break;
|
|
508
|
+
}
|
|
509
|
+
let n = `https://github.com/biaov/${b.name}/compare/v${b.version}...v{latestVersion}`;
|
|
510
|
+
$.notify({
|
|
511
|
+
defer: !1,
|
|
512
|
+
isGlobal: !0,
|
|
513
|
+
message: `有更新 ${t.dim("{currentVersion}")}${t.reset(" → ")}${e}\n运行 ${t.cyan("{updateCommand}@latest")} 命令更新\n${t.dim.underline(n)}`
|
|
514
|
+
});
|
|
388
515
|
}
|
|
516
|
+
//#endregion
|