@chc880/everything-antigravity 1.0.0 → 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/bin/cli.js +10 -1
- package/lib/installer.js +39 -3
- package/package.json +1 -1
package/README.md
CHANGED
package/bin/cli.js
CHANGED
|
@@ -6,12 +6,13 @@
|
|
|
6
6
|
* 用法:
|
|
7
7
|
* ea init # 安装全部到当前项目
|
|
8
8
|
* ea init --lang typescript # 仅安装 TypeScript 规则
|
|
9
|
+
* ea update # 更新包并重新安装
|
|
9
10
|
* ea status # 查看安装状态
|
|
10
11
|
* ea uninstall # 卸载(自动备份)
|
|
11
12
|
* ea help # 帮助
|
|
12
13
|
*/
|
|
13
14
|
|
|
14
|
-
const { install, uninstall, status, showHelp } = require('../lib/installer');
|
|
15
|
+
const { install, uninstall, update, status, showHelp } = require('../lib/installer');
|
|
15
16
|
|
|
16
17
|
const args = process.argv.slice(2);
|
|
17
18
|
const command = args[0] || 'help';
|
|
@@ -56,6 +57,14 @@ switch (command) {
|
|
|
56
57
|
uninstall();
|
|
57
58
|
break;
|
|
58
59
|
|
|
60
|
+
case 'update':
|
|
61
|
+
case 'upgrade':
|
|
62
|
+
case 'u': {
|
|
63
|
+
const { lang } = parseFlags(restArgs);
|
|
64
|
+
update(lang);
|
|
65
|
+
break;
|
|
66
|
+
}
|
|
67
|
+
|
|
59
68
|
case 'help':
|
|
60
69
|
case '-h':
|
|
61
70
|
case '--help':
|
package/lib/installer.js
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
const fs = require('fs');
|
|
7
7
|
const path = require('path');
|
|
8
|
+
const { execSync } = require('child_process');
|
|
8
9
|
|
|
9
10
|
// ── 颜色 ─────────────────────────────────────────────
|
|
10
11
|
const C = {
|
|
@@ -16,15 +17,17 @@ const C = {
|
|
|
16
17
|
};
|
|
17
18
|
|
|
18
19
|
// ── 配置 ─────────────────────────────────────────────
|
|
20
|
+
const PKG = require('../package.json');
|
|
19
21
|
const ASSETS_DIR = path.join(__dirname, '..', 'assets');
|
|
20
22
|
const PROJECT_DIR = process.cwd();
|
|
21
23
|
const AGENT_DIR = path.join(PROJECT_DIR, '.agent');
|
|
22
24
|
|
|
23
25
|
// ── 工具函数 ─────────────────────────────────────────
|
|
24
26
|
function banner() {
|
|
27
|
+
const ver = PKG.version;
|
|
25
28
|
console.log(C.cyan(`
|
|
26
29
|
╔══════════════════════════════════════════════════╗
|
|
27
|
-
║ Everything Antigravity
|
|
30
|
+
║ Everything Antigravity v${ver.padEnd(24)}║
|
|
28
31
|
╚══════════════════════════════════════════════════╝
|
|
29
32
|
`));
|
|
30
33
|
console.log(`ℹ 目标项目: ${C.blue(PROJECT_DIR)}`);
|
|
@@ -236,6 +239,38 @@ function uninstall() {
|
|
|
236
239
|
console.log(` 备份位置: ${C.yellow(backupDir)}`);
|
|
237
240
|
}
|
|
238
241
|
|
|
242
|
+
// ── 更新 ─────────────────────────────────────────────
|
|
243
|
+
function update(lang) {
|
|
244
|
+
banner();
|
|
245
|
+
const currentVer = PKG.version;
|
|
246
|
+
console.log(`ℹ 当前版本: ${C.yellow('v' + currentVer)}`);
|
|
247
|
+
console.log('');
|
|
248
|
+
|
|
249
|
+
// Step 1: 更新 npm 包
|
|
250
|
+
console.log(C.cyan('── Step 1/2: 更新 npm 包 ──'));
|
|
251
|
+
try {
|
|
252
|
+
console.log(`ℹ 执行: npm update -g ${PKG.name}`);
|
|
253
|
+
execSync(`npm update -g ${PKG.name}`, { stdio: 'inherit' });
|
|
254
|
+
console.log(C.green('✓ npm 包已更新'));
|
|
255
|
+
} catch (e) {
|
|
256
|
+
console.log(C.yellow('⚠ npm 更新失败,尝试使用本地版本重新安装'));
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
// Step 2: 重新安装到当前项目
|
|
260
|
+
console.log('');
|
|
261
|
+
console.log(C.cyan('── Step 2/2: 重新安装到当前项目 ──'));
|
|
262
|
+
try {
|
|
263
|
+
// 用更新后的 ea init 重新安装
|
|
264
|
+
execSync(`ea init${lang !== 'all' ? ' --lang ' + lang : ''}`, { stdio: 'inherit' });
|
|
265
|
+
} catch (e) {
|
|
266
|
+
// ea 命令在更新过程中可能不可用,回退到直接调用 install
|
|
267
|
+
install(lang);
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
console.log('');
|
|
271
|
+
console.log(C.green('✓ 更新完成!'));
|
|
272
|
+
}
|
|
273
|
+
|
|
239
274
|
// ── 状态 ─────────────────────────────────────────────
|
|
240
275
|
function status() {
|
|
241
276
|
banner();
|
|
@@ -280,6 +315,7 @@ function showHelp() {
|
|
|
280
315
|
console.log('');
|
|
281
316
|
console.log('命令:');
|
|
282
317
|
console.log(' init [--lang <lang>] 安装到当前项目(默认全部语言)');
|
|
318
|
+
console.log(' update 更新包并重新安装');
|
|
283
319
|
console.log(' status 查看安装状态');
|
|
284
320
|
console.log(' uninstall 卸载(自动备份)');
|
|
285
321
|
console.log(' help 显示帮助');
|
|
@@ -291,11 +327,11 @@ function showHelp() {
|
|
|
291
327
|
console.log(' --lang golang Go');
|
|
292
328
|
console.log('');
|
|
293
329
|
console.log('示例:');
|
|
294
|
-
console.log(
|
|
330
|
+
console.log(` npm install -g ${PKG.name}`);
|
|
295
331
|
console.log(' ea init # 安装全部');
|
|
296
332
|
console.log(' ea init --lang ts # 仅 TypeScript');
|
|
297
333
|
console.log(' ea status');
|
|
298
334
|
console.log(' ea uninstall');
|
|
299
335
|
}
|
|
300
336
|
|
|
301
|
-
module.exports = { install, uninstall, status, showHelp };
|
|
337
|
+
module.exports = { install, uninstall, update, status, showHelp };
|