@danypops/pi-packed 0.28.9 → 0.28.10

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 +1 @@
1
- {"version":3,"file":"isolated-service-install.d.ts","sourceRoot":"","sources":["../../service/src/daemon/isolated-service-install.ts"],"names":[],"mappings":"AAYA,MAAM,WAAW,yBAAyB;IACzC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,MAAM,IAAI,IAAI,CAAC;IACf,QAAQ,IAAI,IAAI,CAAC;CACjB;AAED,MAAM,WAAW,yBAAyB;IACzC,WAAW,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,yBAAyB,CAAC,CAAC;IAChF,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC;CACtC;AAuDD,qBAAa,oCAAqC,YAAW,yBAAyB;IAC/E,WAAW,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,yBAAyB,CAAC;IAIrF,MAAM,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAE7B,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO;CAGtC;AAED;;;;;;GAMG;AACH,qBAAa,iCAAkC,YAAW,yBAAyB;IAEjF,OAAO,CAAC,QAAQ,CAAC,cAAc;IAC/B,OAAO,CAAC,QAAQ,CAAC,MAAM;gBADN,cAAc,EAAE,MAAM,EACtB,MAAM,SAAgE;IAGlF,WAAW,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,yBAAyB,CAAC;IAwFrF,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;IAM5B,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,OA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AkBb"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@danypops/pi-packed",
3
- "version": "0.28.9",
3
+ "version": "0.28.10",
4
4
  "description": "Pi package lifecycle, validation, daemon, tools, profiles, and TUI",
5
5
  "type": "module",
6
6
  "bin": {
@@ -109,7 +109,7 @@ export class IsolatedDaemonPackageMaterializer implements DaemonPackageMateriali
109
109
  if (!VERSION_DIRECTORY_RE.test(version)) throw new Error(`cannot isolate ${packageName}: installed package version is unsafe`);
110
110
 
111
111
  const packageRoot = join(this.stateDirectory, "services", installKey(packageName));
112
- const finalDirectory = join(packageRoot, version);
112
+ const finalDirectory = join(packageRoot, `${version}-f${INSTALL_FORMAT_VERSION}`);
113
113
  const finalPiHome = isolatedPiHome(finalDirectory);
114
114
  const finalPackageJson = resolvedPackageJson(finalPiHome, packageName);
115
115
  mkdirSync(packageRoot, { recursive: true, mode: 0o700 });
@@ -123,7 +123,6 @@ export class IsolatedDaemonPackageMaterializer implements DaemonPackageMateriali
123
123
  };
124
124
  }
125
125
 
126
- if (existsSync(finalDirectory)) rmSync(finalDirectory, { recursive: true, force: true });
127
126
  const temporaryDirectory = join(packageRoot, `.${version}.${process.pid}.${crypto.randomUUID()}.tmp`);
128
127
  const temporaryPiHome = isolatedPiHome(temporaryDirectory);
129
128
  const projectDirectory = join(temporaryPiHome, "npm");
@@ -164,6 +163,10 @@ export class IsolatedDaemonPackageMaterializer implements DaemonPackageMateriali
164
163
  throw new Error(`isolated npm install did not resolve ${packageName}@${version}`);
165
164
  }
166
165
  try {
166
+ // A damaged directory for this exact format is replaced only after the complete
167
+ // candidate exists. Format migrations use a different final path, so the service's
168
+ // currently registered executable remains present throughout installation.
169
+ if (existsSync(finalDirectory)) rmSync(finalDirectory, { recursive: true, force: true });
167
170
  renameSync(temporaryDirectory, finalDirectory);
168
171
  publishedByThisCall = true;
169
172
  } catch (error) {
@@ -118,6 +118,23 @@ describe("IsolatedDaemonPackageMaterializer", () => {
118
118
  expect(existsSync(versionDirectory)).toBe(false);
119
119
  });
120
120
 
121
+ it("uses format-versioned paths so a migration never removes the currently registered executable", async () => {
122
+ const root = temporaryRoot();
123
+ const piHome = join(root, "pi");
124
+ const stateDirectory = join(root, "state");
125
+ const legacyExecutable = join(stateDirectory, "services", "daemon", "1.0.0", "pi-home", "npm", "node_modules", "daemon", "cli.ts");
126
+ mkdirSync(join(legacyExecutable, ".."), { recursive: true });
127
+ writeFileSync(legacyExecutable, "// running legacy executable\n");
128
+ writeInstalledPackage(piHome, "daemon", "1.0.0");
129
+ const materializer = new IsolatedDaemonPackageMaterializer(stateDirectory, writeFakeNpm(root));
130
+
131
+ const installed = await materializer.materialize(piHome, "npm:daemon");
132
+
133
+ expect(existsSync(legacyExecutable)).toBe(true);
134
+ expect(installed.piHome).toContain("1.0.0-f1");
135
+ installed.commit();
136
+ });
137
+
121
138
  it("retains only the active and immediately previous committed versions", async () => {
122
139
  const root = temporaryRoot();
123
140
  const piHome = join(root, "pi");
@@ -130,8 +147,8 @@ describe("IsolatedDaemonPackageMaterializer", () => {
130
147
  }
131
148
 
132
149
  expect(readdirSync(join(stateDirectory, "services", "daemon")).filter((name) => !name.startsWith(".")).sort()).toEqual([
133
- "1.1.0",
134
- "1.2.0",
150
+ "1.1.0-f1",
151
+ "1.2.0-f1",
135
152
  ]);
136
153
  });
137
154