galaxy-opc 0.5.17 → 0.5.19
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/bin/cli.mjs +51 -42
- package/package.json +1 -1
package/bin/cli.mjs
CHANGED
|
@@ -164,10 +164,11 @@ async function installOpenclawWithFallback() {
|
|
|
164
164
|
try {
|
|
165
165
|
console.log(dim(" 尝试 官方安装脚本(预编译二进制)安装 OpenClaw...\n"));
|
|
166
166
|
if (isWindows) {
|
|
167
|
+
// shell: false 避免 cmd.exe 拦截管道符(否则 iex 会被 cmd 执行而非 PowerShell)
|
|
167
168
|
await runCommand("powershell", [
|
|
168
169
|
"-NoProfile", "-NonInteractive", "-Command",
|
|
169
170
|
"iwr -useb https://openclaw.ai/install.ps1 | iex",
|
|
170
|
-
], { env });
|
|
171
|
+
], { env, shell: false });
|
|
171
172
|
} else {
|
|
172
173
|
await runCommand("bash", [
|
|
173
174
|
"-c", "curl -fsSL https://openclaw.ai/install.sh | bash",
|
|
@@ -395,11 +396,25 @@ ${bold(cyan(" ╚════════════════════
|
|
|
395
396
|
}
|
|
396
397
|
|
|
397
398
|
async function installPlugin() {
|
|
398
|
-
//
|
|
399
|
-
// 清理所有可能导致 openclaw 启动失败的残留插件配置
|
|
399
|
+
// 清理所有可能导致 openclaw 拒绝启动的残留插件配置
|
|
400
400
|
const cfg = readJson(CONFIG_PATH);
|
|
401
|
+
let cfgDirty = false;
|
|
401
402
|
if (cfg.plugins) {
|
|
402
|
-
|
|
403
|
+
// 旧格式
|
|
404
|
+
if (cfg.plugins.load !== undefined) { delete cfg.plugins.load; cfgDirty = true; }
|
|
405
|
+
// plugins.allow 数组中的残留条目
|
|
406
|
+
if (Array.isArray(cfg.plugins.allow)) {
|
|
407
|
+
const before = cfg.plugins.allow.length;
|
|
408
|
+
cfg.plugins.allow = cfg.plugins.allow.filter((p) => p !== "galaxy-opc-plugin");
|
|
409
|
+
if (cfg.plugins.allow.length !== before) cfgDirty = true;
|
|
410
|
+
}
|
|
411
|
+
// plugins.entries 对象中的残留条目
|
|
412
|
+
if (cfg.plugins.entries?.["galaxy-opc-plugin"] !== undefined) {
|
|
413
|
+
delete cfg.plugins.entries["galaxy-opc-plugin"];
|
|
414
|
+
cfgDirty = true;
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
if (cfgDirty) {
|
|
403
418
|
writeJson(CONFIG_PATH, cfg);
|
|
404
419
|
console.log(dim(" 已清理旧插件配置"));
|
|
405
420
|
}
|
|
@@ -496,13 +511,19 @@ async function cmdUpdate() {
|
|
|
496
511
|
console.log(cyan(" npx galaxy-opc start\n"));
|
|
497
512
|
}
|
|
498
513
|
|
|
499
|
-
// ─── uninstall
|
|
514
|
+
// ─── uninstall:卸载插件 + 清除全部用户数据 ─────────────────────────────────
|
|
500
515
|
async function cmdUninstall() {
|
|
501
516
|
separator();
|
|
502
517
|
console.log(bold(" galaxy-opc uninstall — 卸载 OPC Platform 插件"));
|
|
503
518
|
separator();
|
|
504
519
|
|
|
505
|
-
|
|
520
|
+
const pluginDir = path.join(STATE_DIR, "extensions", "galaxy-opc-plugin");
|
|
521
|
+
const dataDir = path.join(STATE_DIR, "opc-platform");
|
|
522
|
+
|
|
523
|
+
console.log(red("\n 警告:此操作将删除以下内容,且不可恢复:"));
|
|
524
|
+
console.log(gray(` · 插件目录 ${pluginDir}`));
|
|
525
|
+
console.log(gray(` · 业务数据 ${dataDir} (公司/财务/合同/员工等数据库)`));
|
|
526
|
+
console.log(gray(` · openclaw.json 中的全部 OPC 插件配置\n`));
|
|
506
527
|
|
|
507
528
|
const confirm = await askYesNo(" 确认继续卸载?", false);
|
|
508
529
|
if (!confirm) {
|
|
@@ -510,14 +531,7 @@ async function cmdUninstall() {
|
|
|
510
531
|
return;
|
|
511
532
|
}
|
|
512
533
|
|
|
513
|
-
// ── 1.
|
|
514
|
-
const keepData = await askYesNo(
|
|
515
|
-
` 保留业务数据(公司/财务/合同等数据库 ${path.join(STATE_DIR, "opc-platform")})?`,
|
|
516
|
-
true,
|
|
517
|
-
);
|
|
518
|
-
|
|
519
|
-
// ── 2. 移除插件目录 ───────────────────────────────────────────────────────
|
|
520
|
-
const pluginDir = path.join(STATE_DIR, "extensions", "galaxy-opc-plugin");
|
|
534
|
+
// ── 1. 移除插件目录 ───────────────────────────────────────────────────────
|
|
521
535
|
if (fs.existsSync(pluginDir)) {
|
|
522
536
|
console.log(dim(`\n 移除插件目录: ${pluginDir}`));
|
|
523
537
|
try {
|
|
@@ -526,42 +540,37 @@ async function cmdUninstall() {
|
|
|
526
540
|
} catch (e) {
|
|
527
541
|
console.log(yellow(` ! 无法移除插件目录: ${e.message}`));
|
|
528
542
|
}
|
|
529
|
-
} else {
|
|
530
|
-
console.log(gray(" 插件目录不存在,跳过"));
|
|
531
543
|
}
|
|
532
544
|
|
|
533
|
-
// ──
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
545
|
+
// ── 2. 删除业务数据 ───────────────────────────────────────────────────────
|
|
546
|
+
if (fs.existsSync(dataDir)) {
|
|
547
|
+
console.log(dim(` 移除业务数据: ${dataDir}`));
|
|
548
|
+
try {
|
|
549
|
+
fs.rmSync(dataDir, { recursive: true, force: true });
|
|
550
|
+
console.log(green(" ✓ 业务数据已删除"));
|
|
551
|
+
} catch (e) {
|
|
552
|
+
console.log(yellow(` ! 无法删除数据目录: ${e.message}`));
|
|
553
|
+
}
|
|
539
554
|
}
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
555
|
+
|
|
556
|
+
// ── 3. 清除 openclaw.json 中全部 OPC 插件配置 ────────────────────────────
|
|
557
|
+
const cfg = readJson(CONFIG_PATH);
|
|
558
|
+
let cfgDirty = false;
|
|
559
|
+
if (cfg.plugins) {
|
|
560
|
+
if (cfg.plugins.load !== undefined) { delete cfg.plugins.load; cfgDirty = true; }
|
|
561
|
+
if (cfg.plugins.entries?.["galaxy-opc-plugin"] !== undefined){ delete cfg.plugins.entries["galaxy-opc-plugin"]; cfgDirty = true; }
|
|
562
|
+
if (Array.isArray(cfg.plugins.allow)) {
|
|
563
|
+
const before = cfg.plugins.allow.length;
|
|
564
|
+
cfg.plugins.allow = cfg.plugins.allow.filter((p) => p !== "galaxy-opc-plugin");
|
|
565
|
+
if (cfg.plugins.allow.length !== before) cfgDirty = true;
|
|
566
|
+
}
|
|
543
567
|
}
|
|
544
|
-
if (
|
|
568
|
+
if (cfgDirty) {
|
|
545
569
|
writeJson(CONFIG_PATH, cfg);
|
|
546
570
|
console.log(green(" ✓ 已从 openclaw.json 清除插件配置"));
|
|
547
571
|
}
|
|
548
572
|
|
|
549
|
-
// ── 4.
|
|
550
|
-
if (!keepData) {
|
|
551
|
-
const dataDir = path.join(STATE_DIR, "opc-platform");
|
|
552
|
-
if (fs.existsSync(dataDir)) {
|
|
553
|
-
try {
|
|
554
|
-
fs.rmSync(dataDir, { recursive: true, force: true });
|
|
555
|
-
console.log(green(" ✓ 业务数据已删除"));
|
|
556
|
-
} catch (e) {
|
|
557
|
-
console.log(yellow(` ! 无法删除数据目录: ${e.message}`));
|
|
558
|
-
}
|
|
559
|
-
}
|
|
560
|
-
} else {
|
|
561
|
-
console.log(dim(` 数据已保留: ${path.join(STATE_DIR, "opc-platform")}`));
|
|
562
|
-
}
|
|
563
|
-
|
|
564
|
-
// ── 5. 询问是否同时卸载 openclaw ────────────────────────────────────────
|
|
573
|
+
// ── 4. 询问是否同时卸载 openclaw ────────────────────────────────────────
|
|
565
574
|
const removeOc = await askYesNo("\n 同时卸载 OpenClaw(npm uninstall -g openclaw)?", false);
|
|
566
575
|
if (removeOc) {
|
|
567
576
|
console.log(dim("\n 卸载 openclaw...\n"));
|