@aipper/aiws 0.0.20 → 0.0.23

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.
@@ -1,3 +1,4 @@
1
+ import fs from "node:fs/promises";
1
2
  import path from "node:path";
2
3
  import { loadTemplate } from "../spec.js";
3
4
  import { loadAiwsPackage } from "../aiws-package.js";
@@ -59,13 +60,32 @@ export async function updateCommand(options) {
59
60
  }
60
61
  }
61
62
 
63
+ const removeFiles = (update.remove || []).map(normalizeRel);
64
+
62
65
  const backup = new BackupSession({ workspaceRoot, operation: "update" });
63
66
  // Backup every file we might touch (including missing, for rollback deletions).
64
67
  await backup.recordFile(".aiws/manifest.json", { recordMissing: true });
65
68
  for (const f of replaceFiles) await backup.recordFile(f, { recordMissing: true });
66
69
  for (const f of Object.keys(managedBlocks)) await backup.recordFile(f, { recordMissing: true });
70
+ for (const f of removeFiles) await backup.recordFile(f);
67
71
  await backup.finalize({ extra: { template_id: tpl.templateId } });
68
72
 
73
+ // Remove deprecated files (backed up above; restorable via `aiws rollback`).
74
+ let removedCount = 0;
75
+ for (const rel of removeFiles) {
76
+ if (!rel) continue;
77
+ const abs = joinRel(workspaceRoot, rel);
78
+ if (await pathExists(abs)) {
79
+ await fs.rm(abs, { force: true });
80
+ removedCount++;
81
+ // Remove empty parent directory (safe: rmdir fails on non-empty).
82
+ try { await fs.rmdir(path.dirname(abs)); } catch { /* non-empty or gone */ }
83
+ }
84
+ }
85
+ if (removedCount > 0) {
86
+ console.log(` removed ${removedCount} deprecated file(s)`);
87
+ }
88
+
69
89
  // Replace files (except manifest, generated later).
70
90
  for (const rel of replaceFiles) {
71
91
  if (!rel || rel === ".aiws/manifest.json") continue;