mine-auto-cli 2.6.4 → 2.7.1
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 +20 -1
- package/dist/ai.jsonc +13 -0
- package/dist/index.js +259 -223
- package/package.json +8 -8
package/README.md
CHANGED
|
@@ -20,6 +20,7 @@
|
|
|
20
20
|
- [x] [生成依赖注释文件](#生成依赖注释文件)
|
|
21
21
|
- [x] [更新 `.vscode` 文件](#更新-vscode-文件)
|
|
22
22
|
- [x] [切换 Node 版本](#切换-node-版本)
|
|
23
|
+
- [x] [切换 AI 模型](#切换-ai-模型)
|
|
23
24
|
|
|
24
25
|
## 全局安装
|
|
25
26
|
|
|
@@ -53,7 +54,6 @@ auto init
|
|
|
53
54
|
```
|
|
54
55
|
|
|
55
56
|
- 字段解析:
|
|
56
|
-
|
|
57
57
|
- `prefix`: 版本前缀,默认为 `^`
|
|
58
58
|
- `registry`: 依赖来源,默认为 `https://registry.npmmirror.com/`
|
|
59
59
|
- `check`: 是否更新 `package.json` 文件,为 `true` 时等同于 `auto check -u`, `-u` 优先级最高, 默认为 `false`
|
|
@@ -204,6 +204,25 @@ auto node 20
|
|
|
204
204
|
auto node 20.12.1
|
|
205
205
|
```
|
|
206
206
|
|
|
207
|
+
### 切换 AI 模型
|
|
208
|
+
|
|
209
|
+
- 基于 claude code 切换 ai 模型
|
|
210
|
+
- 初始化、切换模型、查看模型
|
|
211
|
+
|
|
212
|
+
```sh
|
|
213
|
+
# 初始化
|
|
214
|
+
auto ai init
|
|
215
|
+
|
|
216
|
+
# 查看已配置的模型
|
|
217
|
+
auto ai ls
|
|
218
|
+
|
|
219
|
+
# 切换模型
|
|
220
|
+
auto ai use deepseek
|
|
221
|
+
|
|
222
|
+
# 查看命令更多帮助信息
|
|
223
|
+
auto ai -h
|
|
224
|
+
```
|
|
225
|
+
|
|
207
226
|
### 技术栈
|
|
208
227
|
|
|
209
228
|
- `Vite` + `TypeScript` + `NodeJs`
|
package/dist/ai.jsonc
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
{
|
|
2
|
+
"你的模型": {
|
|
3
|
+
// 模型环境变量配置
|
|
4
|
+
"env": {
|
|
5
|
+
"ANTHROPIC_BASE_URL": "https://api.你的模型.com/anthropic", // 模型 API 基础 URL
|
|
6
|
+
"ANTHROPIC_AUTH_TOKEN": "你的 token", // 模型 API 认证 token
|
|
7
|
+
"API_TIMEOUT_MS": "600000", // API 请求超时时间,单位毫秒,默认为 10 分钟
|
|
8
|
+
"ANTHROPIC_MODEL": "你的模型名称", // 模型名称
|
|
9
|
+
"ANTHROPIC_SMALL_FAST_MODEL": "你的模型名称", // 小模型名称
|
|
10
|
+
"CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC": "1" // 是否禁用非必要流量,默认为 `1`
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
}
|
package/dist/index.js
CHANGED
|
@@ -1,297 +1,333 @@
|
|
|
1
|
-
import { program as
|
|
1
|
+
import { program as u } from "commander";
|
|
2
2
|
import l from "chalk";
|
|
3
|
-
import { readFileSync as
|
|
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
|
-
|
|
16
|
-
|
|
3
|
+
import { readFileSync as h, writeFileSync as v, existsSync as $, readdirSync as ve, cpSync as Se, rmSync as je } from "fs";
|
|
4
|
+
import { join as f, resolve as y } from "path";
|
|
5
|
+
import ne from "log-symbols";
|
|
6
|
+
import be from "ora";
|
|
7
|
+
import { execSync as P } from "child_process";
|
|
8
|
+
import we from "js-yaml";
|
|
9
|
+
import Ce from "strip-json-comments";
|
|
10
|
+
import Oe from "pacote";
|
|
11
|
+
import { parseRange as D } from "semver-utils";
|
|
12
|
+
import ke from "download-git-repo";
|
|
13
|
+
import q from "inquirer";
|
|
14
|
+
import oe from "os";
|
|
15
|
+
import Ae from "update-notifier";
|
|
16
|
+
const se = "mine-auto-cli", re = "2.7.0", xe = "./dist/index.js", Ne = "./dist/index.js", Ie = "module", Pe = { auto: "bin/mine-auto-cli.js" }, Ee = { name: "biaov", email: "biaov@qq.com", url: "https://biaov.cn" }, Je = "一个将多个命令简化成一个命令的工具 😆", Me = { start: "npm run dev", dev: "npm run build -- --watch", build: "vite build", prettier: "prettier --write '**/*.{js,ts,md,json}'", tag: "node scripts/tag" }, Le = { registry: "https://registry.npmjs.org/", "engine-strict": !0, provenance: !0 }, De = { node: ">=24.x" }, Te = ["auto", "cli", "vite", "typescript"], Ve = { type: "git", url: "git+https://github.com/biaov/mine-auto-cli.git" }, Re = "https://github.com/biaov/mine-auto-cli.git", _e = { url: "https://github.com/biaov/mine-auto-cli/issues" }, Fe = "ISC", Ue = [{ name: "biaov", email: "biaov@qq.com" }], qe = { chalk: "^5.6.2", commander: "^14.0.3", "download-git-repo": "^3.0.2", inquirer: "^13.3.0", "js-yaml": "^4.1.1", "log-symbols": "^7.0.1", ora: "^9.3.0", pacote: "^21.4.0", "semver-utils": "^1.1.4", "strip-json-comments": "^5.0.3", "update-notifier": "^7.3.1" }, He = { "@types/js-yaml": "^4.0.9", "@types/node": "^25.3.3", "@types/pacote": "^11.1.8", "@types/semver-utils": "^1.1.3", "@types/update-notifier": "^6.0.8", prettier: "^3.8.1", typescript: "^5.9.3", vite: "^7.3.1" }, N = {
|
|
17
|
+
name: se,
|
|
17
18
|
private: !1,
|
|
18
|
-
version:
|
|
19
|
-
exports:
|
|
20
|
-
main:
|
|
21
|
-
type:
|
|
22
|
-
bin:
|
|
23
|
-
author:
|
|
24
|
-
description:
|
|
25
|
-
scripts:
|
|
26
|
-
publishConfig:
|
|
27
|
-
engines:
|
|
28
|
-
keywords:
|
|
29
|
-
repository:
|
|
30
|
-
homepage:
|
|
31
|
-
bugs:
|
|
32
|
-
license:
|
|
33
|
-
contributors:
|
|
34
|
-
dependencies:
|
|
35
|
-
devDependencies:
|
|
36
|
-
},
|
|
37
|
-
console.log(`${
|
|
38
|
-
},
|
|
39
|
-
console.log(`${
|
|
19
|
+
version: re,
|
|
20
|
+
exports: xe,
|
|
21
|
+
main: Ne,
|
|
22
|
+
type: Ie,
|
|
23
|
+
bin: Pe,
|
|
24
|
+
author: Ee,
|
|
25
|
+
description: Je,
|
|
26
|
+
scripts: Me,
|
|
27
|
+
publishConfig: Le,
|
|
28
|
+
engines: De,
|
|
29
|
+
keywords: Te,
|
|
30
|
+
repository: Ve,
|
|
31
|
+
homepage: Re,
|
|
32
|
+
bugs: _e,
|
|
33
|
+
license: Fe,
|
|
34
|
+
contributors: Ue,
|
|
35
|
+
dependencies: qe,
|
|
36
|
+
devDependencies: He
|
|
37
|
+
}, g = (e) => {
|
|
38
|
+
console.log(`${ne.success} ${l.green("SUCCESS")} ${e}`);
|
|
39
|
+
}, C = (e) => {
|
|
40
|
+
console.log(`${se} ${ne.error} ${l.red("ERROR")} ${e}`);
|
|
40
41
|
}, a = (e) => {
|
|
41
42
|
console.log(e ?? "");
|
|
42
|
-
},
|
|
43
|
+
}, ie = (e) => {
|
|
43
44
|
a(`开始执行 ${l.cyanBright(e)} 命令`);
|
|
44
|
-
const t =
|
|
45
|
+
const t = be({ text: "正在执行命令中...", color: "yellow" });
|
|
45
46
|
t.start();
|
|
46
|
-
const
|
|
47
|
-
a(
|
|
48
|
-
},
|
|
49
|
-
a(), a(`${l.yellow(">>")} 开始依次执行命令...`), a(),
|
|
50
|
-
},
|
|
51
|
-
a(),
|
|
52
|
-
},
|
|
53
|
-
const t = ["package.json", "README.md"].map((
|
|
54
|
-
const
|
|
55
|
-
return { path:
|
|
56
|
-
}), [
|
|
47
|
+
const n = P(e, { cwd: process.cwd() });
|
|
48
|
+
a(n.toString()), t.succeed(`${l.green(e)} 命令执行成功`), a();
|
|
49
|
+
}, Be = (e) => ["git add -A", `git commit -m ${e}`, "git push"], Ge = (e, t) => [`npm run ${e}`, "git add -A", `git commit -m ${t}`, "git push"], Ye = async (e, t = "打包") => {
|
|
50
|
+
a(), a(`${l.yellow(">>")} 开始依次执行命令...`), a(), Ge(e, t).map(ie), g("全部命令执行完成"), a();
|
|
51
|
+
}, H = (e) => {
|
|
52
|
+
a(), C(`\`${e}\` 命令错误,请检查你的命令`), a(), u.help();
|
|
53
|
+
}, B = (e) => {
|
|
54
|
+
const t = ["package.json", "README.md"].map((r) => {
|
|
55
|
+
const i = f(process.cwd(), r), c = h(i).toString();
|
|
56
|
+
return { path: i, content: c };
|
|
57
|
+
}), [n, o] = t, s = JSON.parse(n.content);
|
|
57
58
|
if (e)
|
|
58
59
|
s.version = e;
|
|
59
60
|
else {
|
|
60
|
-
const
|
|
61
|
-
s.version =
|
|
61
|
+
const r = s.version.split(".").reduce((i, c, m, p) => i + (m === p.length - 1 ? +c + 1 : `${c}.`), "");
|
|
62
|
+
s.version = r;
|
|
62
63
|
}
|
|
63
|
-
|
|
64
|
-
},
|
|
64
|
+
v(n.path, JSON.stringify(s, null, 2)), o.content = o.content.replace(/version\-v.+\-blue/, () => `version-v${s.version}-blue`), v(o.path, o.content);
|
|
65
|
+
}, Ke = async (e) => {
|
|
65
66
|
const t = e.split("version")[1];
|
|
66
|
-
if (!t) return
|
|
67
|
-
const
|
|
67
|
+
if (!t) return H(e);
|
|
68
|
+
const n = JSON.parse(h(f(process.cwd(), "package.json")).toString());
|
|
68
69
|
if (t === "++") {
|
|
69
|
-
const s =
|
|
70
|
-
|
|
70
|
+
const s = n.version.split(".").reduce((r, i, c, m) => r + (c === m.length - 1 ? +i + 1 : `${i}.`), "");
|
|
71
|
+
B(s), a(), g("命令执行完成");
|
|
71
72
|
return;
|
|
72
73
|
}
|
|
73
|
-
const
|
|
74
|
-
|
|
75
|
-
},
|
|
76
|
-
if (e.includes("build")) return
|
|
77
|
-
if (e.includes("version")) return
|
|
78
|
-
|
|
79
|
-
},
|
|
80
|
-
vue:
|
|
81
|
-
react:
|
|
82
|
-
"uni-app":
|
|
83
|
-
electron:
|
|
84
|
-
node:
|
|
85
|
-
"node-simple":
|
|
86
|
-
},
|
|
87
|
-
|
|
88
|
-
const
|
|
89
|
-
|
|
90
|
-
const
|
|
91
|
-
if (
|
|
92
|
-
const
|
|
93
|
-
return t ? JSON.parse(
|
|
94
|
-
},
|
|
95
|
-
if (
|
|
96
|
-
const t =
|
|
74
|
+
const o = t.split("@")[1];
|
|
75
|
+
o ? (B(o), a(), g("命令执行完成")) : H(e);
|
|
76
|
+
}, ze = (e, t) => {
|
|
77
|
+
if (e.includes("build")) return Ye(e, t);
|
|
78
|
+
if (e.includes("version")) return Ke(e);
|
|
79
|
+
C(l.hex("#f56c6c")(`\`auto ${e}${t ? ` ${t}` : ""}\` 命令不存在`)), u.help();
|
|
80
|
+
}, w = "https://gitee.com/biaovorg/project-template.git", Qe = {
|
|
81
|
+
vue: w,
|
|
82
|
+
react: w,
|
|
83
|
+
"uni-app": w,
|
|
84
|
+
electron: w,
|
|
85
|
+
node: w,
|
|
86
|
+
"node-simple": w
|
|
87
|
+
}, We = Object.keys(Qe);
|
|
88
|
+
We.reduce((e, t, n) => e + (n ? ", " : "") + t, "");
|
|
89
|
+
const j = (e = "jsonc") => `auto-cli.${e}`;
|
|
90
|
+
y(import.meta.dirname, "./presetData.json");
|
|
91
|
+
const R = (e, t = !1) => {
|
|
92
|
+
if (!$(e)) return t ? {} : "";
|
|
93
|
+
const n = h(e).toString();
|
|
94
|
+
return t ? JSON.parse(Ce(n)) : n;
|
|
95
|
+
}, Xe = (e) => {
|
|
96
|
+
if (!$(e)) return {};
|
|
97
|
+
const t = h(e).toString();
|
|
97
98
|
try {
|
|
98
|
-
return
|
|
99
|
+
return we.load(t);
|
|
99
100
|
} catch {
|
|
100
101
|
return {};
|
|
101
102
|
}
|
|
102
|
-
},
|
|
103
|
-
const [e, t] = [
|
|
103
|
+
}, ce = (e = !1) => R(y(import.meta.dirname, j()), e), ae = () => {
|
|
104
|
+
const [e, t] = [j(), j("yml")].map((o) => y(process.cwd(), o)), n = ce(!0);
|
|
104
105
|
try {
|
|
105
|
-
Object.assign(
|
|
106
|
+
Object.assign(n, Xe(t), R(e, !0));
|
|
106
107
|
} catch {
|
|
107
108
|
}
|
|
108
|
-
return
|
|
109
|
-
},
|
|
110
|
-
let
|
|
111
|
-
return t && (
|
|
112
|
-
`).slice(1, -1).reduce((
|
|
113
|
-
`, "") :
|
|
114
|
-
},
|
|
109
|
+
return n;
|
|
110
|
+
}, Ze = (e, t = !1) => {
|
|
111
|
+
let n = ce(t);
|
|
112
|
+
return t && (n = JSON.stringify(n, null, 2)), e.includes(".yml") ? n.trim().split(`
|
|
113
|
+
`).slice(1, -1).reduce((o, s) => o + s.trim().replace(/[",]/g, "").replace("// ", "# ") + `
|
|
114
|
+
`, "") : n;
|
|
115
|
+
}, le = (e, t, n = " ") => Array.from({ length: t - e }, () => n).join(""), et = ({ yml: e, uncomment: t, force: n }) => {
|
|
115
116
|
a();
|
|
116
|
-
const
|
|
117
|
-
if (
|
|
118
|
-
a(l.yellow(`${
|
|
117
|
+
const o = j(e ? "yml" : "jsonc"), s = y(process.cwd(), o);
|
|
118
|
+
if ($(s) && !n) {
|
|
119
|
+
a(l.yellow(`${o} 文件已存在`)), a(), a(l.yellow(`文件目录 ${s}`));
|
|
119
120
|
return;
|
|
120
121
|
}
|
|
121
|
-
|
|
122
|
+
v(s, Ze(o, t)), g(`${o} 文件创建成功`), a(), a(l.green(`文件目录 ${s}`));
|
|
122
123
|
};
|
|
123
|
-
|
|
124
|
-
const
|
|
125
|
-
a(), a(`${l.yellow(">>")} 开始依次执行命令...`), a(),
|
|
124
|
+
u.command("init").option("-f, --force", `强制替换 ${j()} 文件内容`, !1).option("--unc, --uncomment", `取消生成 ${j()} 带注释`, !1).option("-y, --yml", `生成 ${j("yml")} 文件`, !1).description("初始化配置文件").action(et);
|
|
125
|
+
const tt = async (e = "更新代码") => {
|
|
126
|
+
a(), a(`${l.yellow(">>")} 开始依次执行命令...`), a(), Be(e).forEach(ie), g("全部命令执行完成"), a();
|
|
126
127
|
};
|
|
127
|
-
|
|
128
|
-
const
|
|
129
|
-
let
|
|
130
|
-
const
|
|
131
|
-
const
|
|
132
|
-
return !
|
|
128
|
+
u.command("git [描述]").description("简化 Git 提交命令").action(tt);
|
|
129
|
+
const G = ["dist", "node_modules", ".git", "miniprogram_npm"];
|
|
130
|
+
let E = 0, pe = !1, T = !1, me = 20;
|
|
131
|
+
const Y = ({ prev: e, i: t, index: n, arr: o, curText: s }) => {
|
|
132
|
+
const r = Array.from({ length: t }).reduce((p) => p + `${t === 1 && n === o.length - 1 ? "└ " : "│ "} `, ""), i = e + r, c = (r + s).length, m = Array.from({ length: me + E - c }).reduce((p) => `${p}-`, " ");
|
|
133
|
+
return !pe && (E = Math.max(E, c)), `${i}${s}${T ? m : ""}
|
|
133
134
|
`;
|
|
134
|
-
},
|
|
135
|
-
let
|
|
136
|
-
return
|
|
137
|
-
}, ""),
|
|
138
|
-
|
|
139
|
-
const
|
|
140
|
-
if (
|
|
141
|
-
const m =
|
|
135
|
+
}, V = (e, t = 0) => e.reduce((n, o, s, r) => {
|
|
136
|
+
let i;
|
|
137
|
+
return o.children ? (i = `├── ${o.name}`, Y({ prev: n, i: t, index: s, arr: r, curText: i }) + V(o.children, t + 1)) : (i = `${s === r.length - 1 ? "└── " : "├── "}${o.name}`, Y({ prev: n, i: t, index: s, arr: r, curText: i }));
|
|
138
|
+
}, ""), K = (e) => ve(e, { withFileTypes: !0 }).sort((t, n) => +n.isDirectory() - +t.isDirectory()), nt = ({ line: e, name: t }) => {
|
|
139
|
+
T = !!e, typeof e == "string" && (me = +e);
|
|
140
|
+
const n = process.cwd(), o = f(n, ".gitignore");
|
|
141
|
+
if ($(o)) {
|
|
142
|
+
const m = h(o).toString().split(`\r
|
|
142
143
|
`);
|
|
143
|
-
|
|
144
|
+
G.push(...m);
|
|
144
145
|
}
|
|
145
|
-
const s =
|
|
146
|
-
const { name: p } = m,
|
|
147
|
-
return !
|
|
148
|
-
}),
|
|
149
|
-
|
|
146
|
+
const s = n.split("\\").at(-1), i = K(n).map((m) => {
|
|
147
|
+
const { name: p } = m, d = { name: p };
|
|
148
|
+
return !G.includes(p) && m.isDirectory() && (d.children = K(f(m.path, p)).map(({ name: O }) => ({ name: O }))), d;
|
|
149
|
+
}), c = [{ name: s, children: i }];
|
|
150
|
+
T && (V(c), pe = !0), v(f(n, `${typeof t == "string" && t || "directory"}.md`), V(c));
|
|
150
151
|
};
|
|
151
|
-
|
|
152
|
-
const k =
|
|
153
|
-
const
|
|
154
|
-
process.stdout.write(
|
|
155
|
-
},
|
|
156
|
-
let
|
|
157
|
-
k.resolve.some((
|
|
158
|
-
const
|
|
159
|
-
if (
|
|
160
|
-
const
|
|
161
|
-
if (e ===
|
|
162
|
-
return
|
|
152
|
+
u.command("mkdir").option("-l, --line [数量]", "数量", !1).option("-n, --name [文件名称]", "文件名称", !1).option("-d, --depth [深度值]", "深度值", "3").description("生成目录结构文件").action(nt);
|
|
153
|
+
const k = ae(), [J] = ["package.json"].map((e) => y(process.cwd(), e)), ot = (e, t) => {
|
|
154
|
+
const n = Array.from({ length: t }, (i, c) => c < e ? "=" : " ").join(""), o = ~~(e / t * 100), s = `\r查找进度:[${n}] ${e}/${t} ${o}%\r`, r = e === t ? l.green(s) : l.yellow(s);
|
|
155
|
+
process.stdout.write(r);
|
|
156
|
+
}, st = (e, t, n) => {
|
|
157
|
+
let o = "latest";
|
|
158
|
+
k.resolve.some((r) => {
|
|
159
|
+
const i = r.lastIndexOf("@");
|
|
160
|
+
if (i <= 0) return !0;
|
|
161
|
+
const c = r.slice(0, i), m = r.slice(i + 1);
|
|
162
|
+
if (e === c)
|
|
163
|
+
return o = m, !0;
|
|
163
164
|
});
|
|
164
|
-
const s = k.prefix + o
|
|
165
|
-
return { name: e, value: t, newVersion: s, tag:
|
|
166
|
-
},
|
|
167
|
-
const [{ major: t = 0, minor:
|
|
168
|
-
return [+t, +
|
|
169
|
-
},
|
|
170
|
-
const [
|
|
171
|
-
return
|
|
172
|
-
},
|
|
165
|
+
const s = k.prefix + n[o];
|
|
166
|
+
return { name: e, value: t, newVersion: s, tag: o };
|
|
167
|
+
}, rt = (e, t) => (+!t + 1) * e.length, z = (e) => {
|
|
168
|
+
const [{ major: t = 0, minor: n = 0, patch: o = 0, release: s = "" }] = D(e);
|
|
169
|
+
return [+t, +n, +o, s];
|
|
170
|
+
}, M = (e, t) => e ? "-" + l[t](e) : "", it = (e, t) => {
|
|
171
|
+
const [n, o, s, r] = z(e), [i, c, m, p] = z(t);
|
|
172
|
+
return i > n ? l.red(t) : i < n ? !1 : c > o ? `${i}.${l.yellow(c)}.${l.yellow(m)}${M(p, "yellow")}` : c < o ? !1 : m > s ? `${i}.${c}.${l.green(m)}${M(p, "green")}` : m === s && p && p !== r ? `${i}.${c}.${m}${M(p, "green")}` : !1;
|
|
173
|
+
}, ct = (e) => {
|
|
173
174
|
const t = {};
|
|
174
|
-
e.forEach((
|
|
175
|
-
Object.entries(
|
|
176
|
-
t[s] = Math.max(
|
|
175
|
+
e.forEach((o) => {
|
|
176
|
+
Object.entries(o).forEach(([s, r]) => {
|
|
177
|
+
t[s] = Math.max(r.length, t[s] ?? 0);
|
|
177
178
|
});
|
|
178
179
|
}), e.unshift({ name: "包名", value: "版本", newVersion: "新版本", tag: "标签" });
|
|
179
|
-
const
|
|
180
|
-
e.forEach(({ name:
|
|
181
|
-
const [m, p,
|
|
182
|
-
let
|
|
183
|
-
if (
|
|
184
|
-
const
|
|
185
|
-
|
|
180
|
+
const n = [];
|
|
181
|
+
e.forEach(({ name: o, value: s, newVersion: r, tag: i }, c) => {
|
|
182
|
+
const [m, p, d, O] = Object.entries({ name: o, value: s, newVersion: r, tag: i }).map(([A, ye]) => le(rt(ye, c), t[A]));
|
|
183
|
+
let b = l.yellow("→"), U = !0;
|
|
184
|
+
if (c) {
|
|
185
|
+
const A = it(s, r);
|
|
186
|
+
A ? r = A : U = !1;
|
|
186
187
|
} else
|
|
187
|
-
|
|
188
|
-
const
|
|
189
|
-
|
|
190
|
-
}),
|
|
191
|
-
},
|
|
188
|
+
o = l.green(o), s = l.green(s), r = l.green(r), i = l.green(i), b = " ";
|
|
189
|
+
const $e = `${o + m} ${p + s} ${b} ${d + r} ${O + i}`;
|
|
190
|
+
U && n.push($e);
|
|
191
|
+
}), n.length > 1 ? n.forEach(a) : g("所有版本已是最新");
|
|
192
|
+
}, at = async (e, t, n) => {
|
|
192
193
|
a();
|
|
193
|
-
let
|
|
194
|
-
const s = [],
|
|
195
|
-
const p = await
|
|
196
|
-
s.push(
|
|
197
|
-
const
|
|
198
|
-
|
|
199
|
-
}),
|
|
194
|
+
let o = 0;
|
|
195
|
+
const s = [], r = Object.entries(e), i = r.map(async ([c, m]) => {
|
|
196
|
+
const p = await Oe.packument(c, { registry: k.registry }), d = st(c, m, p["dist-tags"]);
|
|
197
|
+
s.push(d), t.forEach((O) => {
|
|
198
|
+
const b = n[O];
|
|
199
|
+
b && b[c] && (b[c] = d.newVersion);
|
|
200
|
+
}), o++, await ot(o, r.length);
|
|
200
201
|
});
|
|
201
|
-
return await Promise.all(
|
|
202
|
-
},
|
|
203
|
-
if (
|
|
204
|
-
const t = e || k.check,
|
|
202
|
+
return await Promise.all(i), a(), a(), s;
|
|
203
|
+
}, lt = async ({ update: e }) => {
|
|
204
|
+
if (!$(J)) return C("package.json 文件不存在");
|
|
205
|
+
const t = e || k.check, n = h(J).toString(), o = JSON.parse(n), s = ["dependencies", "devDependencies", "optionalDependencies"], r = {}, i = JSON.parse(n);
|
|
205
206
|
s.forEach((m) => {
|
|
206
|
-
|
|
207
|
-
!k.reject.includes(p) && (
|
|
207
|
+
o[m] && Object.entries(o[m]).forEach(([p, d]) => {
|
|
208
|
+
!k.reject.includes(p) && (r[p] = d);
|
|
208
209
|
});
|
|
209
210
|
});
|
|
210
|
-
const
|
|
211
|
-
t ? (
|
|
211
|
+
const c = await at(r, s, i);
|
|
212
|
+
t ? (v(J, JSON.stringify(i, null, 2)), g("文件 package.json 已更新"), a()) : ct(c);
|
|
212
213
|
};
|
|
213
|
-
|
|
214
|
-
const
|
|
215
|
-
if (
|
|
216
|
-
const e =
|
|
217
|
-
let
|
|
214
|
+
u.command("check").option("-u, --update", "更新 package.json 依赖内容", !1).description("升级 package.json 依赖版本").action(lt);
|
|
215
|
+
const pt = ae(), de = "comment.md", mt = ["package.json", de], [Q, W] = mt.map((e) => y(process.cwd(), e)), dt = () => {
|
|
216
|
+
if (!$(Q)) return C("package.json 文件不存在");
|
|
217
|
+
const e = h(Q).toString(), t = JSON.parse(e), n = ["dependencies", "devDependencies", "optionalDependencies"];
|
|
218
|
+
let o = `### 依赖解析
|
|
218
219
|
|
|
219
220
|
`;
|
|
220
|
-
|
|
221
|
-
t[s] && (
|
|
221
|
+
n.forEach((s) => {
|
|
222
|
+
t[s] && (o += `#### ${s}
|
|
222
223
|
|
|
223
|
-
`, Object.keys(t[s]).forEach((
|
|
224
|
-
|
|
224
|
+
`, Object.keys(t[s]).forEach((r) => {
|
|
225
|
+
o += `- \`${r}\`: ${pt.comment[r] || ""}
|
|
225
226
|
`;
|
|
226
|
-
}),
|
|
227
|
+
}), o += `
|
|
227
228
|
`);
|
|
228
|
-
}),
|
|
229
|
+
}), o = o.slice(0, -1), v(W, o), a(), g(`${de} 文件创建成功`), a(), a(l.green(`文件目录 ${W}`));
|
|
229
230
|
};
|
|
230
|
-
|
|
231
|
-
const
|
|
232
|
-
const e = `${+/* @__PURE__ */ new Date()}`, t =
|
|
233
|
-
|
|
234
|
-
!
|
|
231
|
+
u.command("comment").description("生成依赖注释文件").action(dt);
|
|
232
|
+
const X = { recursive: !0, force: !0 }, ut = () => {
|
|
233
|
+
const e = `${+/* @__PURE__ */ new Date()}`, t = f(process.cwd()), n = f(t, e);
|
|
234
|
+
ke("direct:https://gitee.com/biaovorg/vscode-config.git#master", n, { clone: !0 }, async (o) => {
|
|
235
|
+
!o && Se(f(n, ".vscode"), f(t, ".vscode"), X), je(n, X);
|
|
235
236
|
});
|
|
236
237
|
};
|
|
237
|
-
|
|
238
|
-
const
|
|
239
|
-
const
|
|
240
|
-
if (
|
|
241
|
-
if (
|
|
238
|
+
u.command("vscode-config").description("更新 .vscode 配置文件").action(ut);
|
|
239
|
+
const ue = (e, t, n) => {
|
|
240
|
+
const o = Object.entries(t), s = o.findIndex(([c]) => e === c), [r, i] = o[s];
|
|
241
|
+
if (i) {
|
|
242
|
+
if (n[r] === i) return s === o.length - 1 ? !0 : ue(o[s + 1][0], t, n);
|
|
242
243
|
} else
|
|
243
244
|
return !0;
|
|
244
|
-
},
|
|
245
|
-
e && (
|
|
246
|
-
},
|
|
247
|
-
e &&
|
|
248
|
-
},
|
|
249
|
-
const
|
|
245
|
+
}, Z = (e) => {
|
|
246
|
+
e && (P(`nvm use ${e}`), a(), g(`切换成功 当前版本:${e}`), a());
|
|
247
|
+
}, L = (e) => {
|
|
248
|
+
e && P(`nvm install ${e}`);
|
|
249
|
+
}, gt = (e, t) => {
|
|
250
|
+
const n = P("nvm ls").toString(), o = D(n), [{ major: s, minor: r, patch: i }] = D(e), c = [], m = o.find((p) => {
|
|
250
251
|
if (p.major === s)
|
|
251
|
-
return
|
|
252
|
+
return c.push(p), ue("minor", { minor: r, patch: i }, p);
|
|
252
253
|
});
|
|
253
254
|
if (m)
|
|
254
|
-
|
|
255
|
-
else if (a(), a(l.red(`输入的版本 ${e} 不存在`)), a(),
|
|
256
|
-
const p =
|
|
257
|
-
|
|
255
|
+
Z(m.semver);
|
|
256
|
+
else if (a(), a(l.red(`输入的版本 ${e} 不存在`)), a(), c.length) {
|
|
257
|
+
const p = c.map((d) => d.semver);
|
|
258
|
+
q.prompt({
|
|
258
259
|
type: "list",
|
|
259
260
|
name: "preset",
|
|
260
261
|
message: "请选择相似版本或输入版本进行安装:",
|
|
261
262
|
choices: [...p, e, "取消"]
|
|
262
|
-
}).then(({ preset:
|
|
263
|
-
if (
|
|
264
|
-
if (
|
|
265
|
-
if (!
|
|
266
|
-
|
|
263
|
+
}).then(({ preset: d }) => {
|
|
264
|
+
if (d !== "取消")
|
|
265
|
+
if (d === e) {
|
|
266
|
+
if (!i) return;
|
|
267
|
+
L(d);
|
|
267
268
|
} else
|
|
268
|
-
|
|
269
|
+
Z(d);
|
|
269
270
|
});
|
|
270
271
|
} else {
|
|
271
|
-
if (!
|
|
272
|
+
if (!i) return;
|
|
272
273
|
if (t.install) {
|
|
273
|
-
|
|
274
|
+
L(e);
|
|
274
275
|
return;
|
|
275
276
|
}
|
|
276
|
-
|
|
277
|
+
q.prompt({
|
|
277
278
|
type: "confirm",
|
|
278
279
|
name: "isInstall",
|
|
279
280
|
message: `是否安装 ${e}?`
|
|
280
281
|
}).then(({ isInstall: p }) => {
|
|
281
|
-
p &&
|
|
282
|
+
p && L(e);
|
|
282
283
|
});
|
|
283
284
|
}
|
|
284
285
|
};
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
286
|
+
u.command("node [版本号]").option("-i, --install", "是否安装此版本", !1).description("切换 node 版本,默认选择第一个版本").action(gt);
|
|
287
|
+
const _ = ["ANTHROPIC_AUTH_TOKEN", "ANTHROPIC_BASE_URL", "ANTHROPIC_MODEL", "ANTHROPIC_SMALL_FAST_MODEL"], ge = R(y(import.meta.dirname, "ai.jsonc"), !0), ee = Object.entries(ge)[0], I = y(oe.homedir(), ".claude/settings.json"), S = y(oe.homedir(), ".ai-model.json"), fe = () => {
|
|
288
|
+
$(I) || (C(`${I} 文件不存在,请先检查或者去安装 Claude Code`), process.exit(1));
|
|
289
|
+
const e = JSON.parse(h(I).toString());
|
|
290
|
+
return !e.env && (e.env = {}), e;
|
|
291
|
+
}, he = () => {
|
|
292
|
+
a(), $(S) || (C("配置不存在,请先使用 `ai init` 初始化 AI 模型配置"), process.exit(1));
|
|
293
|
+
const e = JSON.parse(h(S).toString()), t = Object.entries(e).filter(([n, o]) => {
|
|
294
|
+
if (n === ee[0]) return !1;
|
|
295
|
+
const s = o.env, r = ee[1].env;
|
|
296
|
+
return !(!s || _.some((c) => !s[c] || s[c] === r[c]));
|
|
297
|
+
});
|
|
298
|
+
return t.length || (a(`暂无已配置的 AI 模型,请先配置,路径 ${l.green(S)}`), process.exit(1)), [t, e];
|
|
299
|
+
}, ft = () => {
|
|
300
|
+
if (a(), $(S)) {
|
|
301
|
+
a(`配置已存在,路径 ${l.green(S)}`);
|
|
302
|
+
return;
|
|
303
|
+
}
|
|
304
|
+
v(S, JSON.stringify(ge, null, 2)), g(`配置已初始化,路径 ${l.green(S)}`);
|
|
305
|
+
}, te = (e) => e.replace(/[\u4e00-\u9fa5]/g, "aa").length, ht = () => {
|
|
306
|
+
const [e] = he();
|
|
307
|
+
let t = 0, n = -1;
|
|
308
|
+
const o = fe();
|
|
309
|
+
e.forEach(([s, r], i) => {
|
|
310
|
+
t = Math.max(t, te(s)), n < 0 && !_.some((c) => o.env[c] !== r.env[c]) && (n = i);
|
|
311
|
+
}), e.forEach(([s, r], i) => {
|
|
312
|
+
const { ANTHROPIC_BASE_URL: c } = r.env, m = i === n ? l.green("*") : " ", p = le(te(s), t + 4, "-"), d = `${m} ${s} ${p} ${c}`;
|
|
313
|
+
a(d);
|
|
314
|
+
});
|
|
315
|
+
}, $t = async (e) => {
|
|
316
|
+
const t = fe(), [n, o] = he();
|
|
317
|
+
n.some(([s]) => s === e) || (a(`模型 ${l.red(e)} 不存在`), process.exit(1)), _.some((s) => t.env[s] !== o[e].env[s]) ? (t.env = o[e].env, v(I, JSON.stringify(t, null, 2)), g(`模型 ${l.green(e)} 已切换`)) : a(`当前正处于 ${l.green(e)} 模型,无需切换`);
|
|
318
|
+
}, F = u.command("ai").description("AI 命令,详细操作请查看 ai -h").helpOption("-h, --help", "输出所有命令").helpCommand(!1);
|
|
319
|
+
F.command("init").description("初始化 AI 模型配置").action(ft);
|
|
320
|
+
F.command("ls").description("查看当前已配置的 AI 模型").action(ht);
|
|
321
|
+
F.command("use <模型>").description("切换 AI 模型").action($t);
|
|
322
|
+
u.usage("[commands] [options]").version(re, "-v, --version", "输出版本号").helpOption("-h, --help", "输出所有命令");
|
|
323
|
+
u.command("build[:环境] [描述]").description("简化打包提交命令");
|
|
324
|
+
u.command("version<[++]|[@<版本号>]>").description("例如:version++ 或者 version@1.0.0;自动更新 package.json 版本号,自动更新 `README.md` 中的 `version-v<version>-blue` 图标版本");
|
|
325
|
+
u.arguments("<cmd> [env]").action((e, t) => {
|
|
326
|
+
ze(e, t);
|
|
291
327
|
});
|
|
292
|
-
process.argv.length < 3 ?
|
|
293
|
-
const x =
|
|
294
|
-
if (x.update && x.update.latest !==
|
|
328
|
+
process.argv.length < 3 ? u.help() : u.parse(process.argv);
|
|
329
|
+
const x = Ae({ pkg: N, updateCheckInterval: 1e3 * 1 });
|
|
330
|
+
if (x.update && x.update.latest !== N.version) {
|
|
295
331
|
let e = "";
|
|
296
332
|
switch (x.update.type) {
|
|
297
333
|
case "major":
|
|
@@ -304,7 +340,7 @@ if (x.update && x.update.latest !== O.version) {
|
|
|
304
340
|
e = l.green("{latestVersion}");
|
|
305
341
|
break;
|
|
306
342
|
}
|
|
307
|
-
const t = `https://github.com/biaov/${
|
|
343
|
+
const t = `https://github.com/biaov/${N.name}/compare/v${N.version}...v{latestVersion}`;
|
|
308
344
|
x.notify({
|
|
309
345
|
defer: !1,
|
|
310
346
|
isGlobal: !0,
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mine-auto-cli",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "2.
|
|
4
|
+
"version": "2.7.1",
|
|
5
5
|
"exports": "./dist/index.js",
|
|
6
6
|
"main": "./dist/index.js",
|
|
7
7
|
"type": "module",
|
|
@@ -18,10 +18,10 @@
|
|
|
18
18
|
"publishConfig": {
|
|
19
19
|
"registry": "https://registry.npmjs.org/",
|
|
20
20
|
"engine-strict": true,
|
|
21
|
-
"provenance":
|
|
21
|
+
"provenance": false
|
|
22
22
|
},
|
|
23
23
|
"engines": {
|
|
24
|
-
"node": ">=
|
|
24
|
+
"node": ">=24.x"
|
|
25
25
|
},
|
|
26
26
|
"keywords": [
|
|
27
27
|
"auto",
|
|
@@ -46,13 +46,13 @@
|
|
|
46
46
|
],
|
|
47
47
|
"dependencies": {
|
|
48
48
|
"chalk": "^5.6.2",
|
|
49
|
-
"commander": "^14.0.
|
|
49
|
+
"commander": "^14.0.3",
|
|
50
50
|
"download-git-repo": "^3.0.2",
|
|
51
|
-
"inquirer": "^
|
|
52
|
-
"js-yaml": "^4.1.
|
|
51
|
+
"inquirer": "^13.3.0",
|
|
52
|
+
"js-yaml": "^4.1.1",
|
|
53
53
|
"log-symbols": "^7.0.1",
|
|
54
|
-
"ora": "^
|
|
55
|
-
"pacote": "^21.0
|
|
54
|
+
"ora": "^9.3.0",
|
|
55
|
+
"pacote": "^21.4.0",
|
|
56
56
|
"semver-utils": "^1.1.4",
|
|
57
57
|
"strip-json-comments": "^5.0.3",
|
|
58
58
|
"update-notifier": "^7.3.1"
|