@iola_adm/iola-cli 0.2.12 → 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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/cli.js +29 -2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@iola_adm/iola-cli",
3
- "version": "0.2.12",
3
+ "version": "0.2.13",
4
4
  "description": "CLI и AI-агент городского округа Йошкар-Ола.",
5
5
  "license": "MIT",
6
6
  "homepage": "https://github.com/adm-iola/iola-cli#readme",
package/src/cli.js CHANGED
@@ -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
- if (!isUserConfig && !isProjectConfig) {
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
  }
@@ -2472,10 +2475,34 @@ async function handleUninstall(args = []) {
2472
2475
  return { deleted: true };
2473
2476
  }
2474
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
+
2475
2499
  async function removeGlobalNpmPackage(npmPackage) {
2476
2500
  if (process.platform === "win32") {
2477
2501
  const command = quoteWindowsCommand(getNpmCommand(), ["remove", "-g", npmPackage]);
2478
- const script = `ping 127.0.0.1 -n 3 > nul & ${command}`;
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}`;
2479
2506
  const child = spawn(process.env.ComSpec || "cmd.exe", ["/d", "/s", "/c", script], {
2480
2507
  detached: true,
2481
2508
  stdio: "ignore",