@iola_adm/iola-cli 0.2.11 → 0.2.13
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/package.json +1 -1
- package/src/cli.js +60 -5
package/package.json
CHANGED
package/src/cli.js
CHANGED
|
@@ -1085,9 +1085,9 @@ async function startAgentRawInput() {
|
|
|
1085
1085
|
const shouldExit = await handleAgentLine(line, state);
|
|
1086
1086
|
stopActivity();
|
|
1087
1087
|
flushPendingAgentOutput(state);
|
|
1088
|
-
await refreshAgentAiStatus(state);
|
|
1089
|
-
if (!shouldExit) restoreRawInput();
|
|
1090
1088
|
if (shouldExit) break;
|
|
1089
|
+
await refreshAgentAiStatus(state);
|
|
1090
|
+
restoreRawInput();
|
|
1091
1091
|
} catch (error) {
|
|
1092
1092
|
stopActivity();
|
|
1093
1093
|
restoreRawInput();
|
|
@@ -2398,6 +2398,7 @@ async function handleUninstall(args = []) {
|
|
|
2398
2398
|
description: "локальная папка .iola текущего проекта",
|
|
2399
2399
|
});
|
|
2400
2400
|
}
|
|
2401
|
+
targets.push(...getIolaTempCleanupTargets());
|
|
2401
2402
|
const npmPackage = "@iola_adm/iola-cli";
|
|
2402
2403
|
|
|
2403
2404
|
const safeTargets = targets.map((target) => ({
|
|
@@ -2405,10 +2406,12 @@ async function handleUninstall(args = []) {
|
|
|
2405
2406
|
path: path.resolve(target.path),
|
|
2406
2407
|
}));
|
|
2407
2408
|
const home = path.resolve(os.homedir());
|
|
2409
|
+
const temp = path.resolve(os.tmpdir());
|
|
2408
2410
|
for (const target of safeTargets) {
|
|
2409
2411
|
const isUserConfig = target.path === path.resolve(CONFIG_DIR) && target.path.startsWith(home);
|
|
2410
2412
|
const isProjectConfig = target.path === path.resolve(PROJECT_IOLA_DIR) && target.path.startsWith(path.resolve(process.cwd()));
|
|
2411
|
-
|
|
2413
|
+
const isTemp = target.path.startsWith(temp + path.sep) && path.basename(target.path).startsWith("iola-");
|
|
2414
|
+
if (!isUserConfig && !isProjectConfig && !isTemp) {
|
|
2412
2415
|
throw new Error(`Небезопасный путь удаления: ${target.path}`);
|
|
2413
2416
|
}
|
|
2414
2417
|
}
|
|
@@ -2452,14 +2455,66 @@ async function handleUninstall(args = []) {
|
|
|
2452
2455
|
|
|
2453
2456
|
console.log("Локальные данные iola-cli удалены.");
|
|
2454
2457
|
console.log(`Удаляю npm-пакет ${npmPackage}...`);
|
|
2455
|
-
await
|
|
2456
|
-
|
|
2458
|
+
const packageRemoval = await removeGlobalNpmPackage(npmPackage).catch((error) => ({
|
|
2459
|
+
status: "failed",
|
|
2460
|
+
error: error instanceof Error ? error.message : String(error),
|
|
2461
|
+
}));
|
|
2462
|
+
if (packageRemoval.status === "scheduled") {
|
|
2463
|
+
console.log("Удаление npm-пакета запланировано после выхода из CLI.");
|
|
2464
|
+
} else if (packageRemoval.status === "removed") {
|
|
2465
|
+
console.log("npm-пакет iola-cli удален.");
|
|
2466
|
+
} else {
|
|
2467
|
+
console.log(`Не удалось удалить npm-пакет автоматически: ${packageRemoval.error}`);
|
|
2468
|
+
console.log("Локальные данные уже удалены, CLI сейчас выйдет.");
|
|
2469
|
+
console.log("После выхода выполните вручную:");
|
|
2470
|
+
console.log(` npm remove -g ${npmPackage}`);
|
|
2471
|
+
}
|
|
2457
2472
|
console.log("Codex CLI не тронут.");
|
|
2458
2473
|
console.log("Для повторной установки:");
|
|
2459
2474
|
console.log(" npm install -g @iola_adm/iola-cli@latest");
|
|
2460
2475
|
return { deleted: true };
|
|
2461
2476
|
}
|
|
2462
2477
|
|
|
2478
|
+
function getIolaTempCleanupTargets() {
|
|
2479
|
+
const tempDir = os.tmpdir();
|
|
2480
|
+
const names = [
|
|
2481
|
+
"iola-cli-test",
|
|
2482
|
+
"iola-model-check.txt",
|
|
2483
|
+
];
|
|
2484
|
+
let dynamicNames = [];
|
|
2485
|
+
try {
|
|
2486
|
+
dynamicNames = readdirSync(tempDir)
|
|
2487
|
+
.filter((name) => /^iola-(archive|codex|browser)-/u.test(name))
|
|
2488
|
+
.slice(0, 100);
|
|
2489
|
+
} catch {
|
|
2490
|
+
dynamicNames = [];
|
|
2491
|
+
}
|
|
2492
|
+
return [...new Set([...names, ...dynamicNames])].map((name) => ({
|
|
2493
|
+
label: "temp",
|
|
2494
|
+
path: path.join(tempDir, name),
|
|
2495
|
+
description: "временные файлы iola-cli",
|
|
2496
|
+
}));
|
|
2497
|
+
}
|
|
2498
|
+
|
|
2499
|
+
async function removeGlobalNpmPackage(npmPackage) {
|
|
2500
|
+
if (process.platform === "win32") {
|
|
2501
|
+
const command = quoteWindowsCommand(getNpmCommand(), ["remove", "-g", npmPackage]);
|
|
2502
|
+
const cleanupConfig = quoteWindowsCommand("rmdir", ["/s", "/q", CONFIG_DIR]);
|
|
2503
|
+
const cleanupTempTest = quoteWindowsCommand("rmdir", ["/s", "/q", path.join(os.tmpdir(), "iola-cli-test")]);
|
|
2504
|
+
const cleanupTempModel = quoteWindowsCommand("del", ["/f", "/q", path.join(os.tmpdir(), "iola-model-check.txt")]);
|
|
2505
|
+
const script = `ping 127.0.0.1 -n 3 > nul & ${cleanupConfig} 2> nul & ${cleanupTempTest} 2> nul & ${cleanupTempModel} 2> nul & ${command}`;
|
|
2506
|
+
const child = spawn(process.env.ComSpec || "cmd.exe", ["/d", "/s", "/c", script], {
|
|
2507
|
+
detached: true,
|
|
2508
|
+
stdio: "ignore",
|
|
2509
|
+
windowsHide: true,
|
|
2510
|
+
});
|
|
2511
|
+
child.unref();
|
|
2512
|
+
return { status: "scheduled" };
|
|
2513
|
+
}
|
|
2514
|
+
await runCommand(getNpmCommand(), ["remove", "-g", npmPackage], { inherit: true });
|
|
2515
|
+
return { status: "removed" };
|
|
2516
|
+
}
|
|
2517
|
+
|
|
2463
2518
|
async function handleDb(args) {
|
|
2464
2519
|
const [action = "status"] = args;
|
|
2465
2520
|
const options = parseOptions(args);
|