@akanjs/devkit 3.0.0-alpha.18 → 3.0.0-alpha.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/executors.test.ts CHANGED
@@ -879,3 +879,18 @@ describe("scan info construction", () => {
879
879
  expect(info.file.document.scalars.has("money")).toBe(true);
880
880
  });
881
881
  });
882
+
883
+ describe("AppExecutor.shouldRelaunchForAppEnv", () => {
884
+ test("relaunches when the app name is missing or different at process start", () => {
885
+ expect(AppExecutor.shouldRelaunchForAppEnv("sceny", {})).toBe(true);
886
+ expect(AppExecutor.shouldRelaunchForAppEnv("sceny", { AKAN_PUBLIC_APP_NAME: "other" })).toBe(true);
887
+ });
888
+
889
+ test("runs in place when the name already matches, and never relaunches twice", () => {
890
+ expect(AppExecutor.shouldRelaunchForAppEnv("sceny", { AKAN_PUBLIC_APP_NAME: "sceny" })).toBe(false);
891
+ expect(AppExecutor.shouldRelaunchForAppEnv("sceny", { AKAN_BUILD_RELAUNCHED: "1" })).toBe(false);
892
+ expect(
893
+ AppExecutor.shouldRelaunchForAppEnv("sceny", { AKAN_BUILD_RELAUNCHED: "1", AKAN_PUBLIC_APP_NAME: "other" }),
894
+ ).toBe(false);
895
+ });
896
+ });
package/executors.ts CHANGED
@@ -1342,6 +1342,26 @@ export class AppExecutor extends SysExecutor {
1342
1342
  ...env,
1343
1343
  };
1344
1344
  }
1345
+ /**
1346
+ * Bun macros snapshot `process.env` at process start, so the env `prepareCommand` publishes later is invisible
1347
+ * to them — and any hand-written `@libs/<lib>/server` import puts that lib's env files (module-scope `getEnv()`)
1348
+ * into the `getSerializedSignal` macro graph. `AKAN_PUBLIC_APP_NAME` is the one required key no workspace root
1349
+ * `.env` can carry, so the build relaunches itself once with it in place; the child sees it from birth.
1350
+ */
1351
+ static shouldRelaunchForAppEnv(appName: string, env: Record<string, string | undefined> = process.env) {
1352
+ if (env.AKAN_BUILD_RELAUNCHED === "1") return false;
1353
+ return env.AKAN_PUBLIC_APP_NAME !== appName;
1354
+ }
1355
+ async relaunchWithAppEnv(): Promise<number | null> {
1356
+ if (!AppExecutor.shouldRelaunchForAppEnv(this.name)) return null;
1357
+ const child = Bun.spawn([process.execPath, ...process.argv.slice(1)], {
1358
+ env: { ...this.getCommandEnv(), AKAN_BUILD_RELAUNCHED: "1" },
1359
+ stdin: "inherit",
1360
+ stdout: "inherit",
1361
+ stderr: "inherit",
1362
+ });
1363
+ return await child.exited;
1364
+ }
1345
1365
  async prepareCommand(type: "build" | "start") {
1346
1366
  const akanConfig = await this.getConfig();
1347
1367
  const databaseMode = process.env.AKAN_DATABASE_MODE ?? akanConfig.defaultDatabaseMode ?? "single";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@akanjs/devkit",
3
- "version": "3.0.0-alpha.18",
3
+ "version": "3.0.0-alpha.19",
4
4
  "sourceType": "module",
5
5
  "type": "module",
6
6
  "publishConfig": {
@@ -45,7 +45,7 @@
45
45
  "@langchain/openai": "^1.4.6",
46
46
  "@tailwindcss/node": "^4.3.0",
47
47
  "@trapezedev/project": "^7.1.4",
48
- "akanjs": "3.0.0-alpha.18",
48
+ "akanjs": "3.0.0-alpha.19",
49
49
  "chalk": "^5.6.2",
50
50
  "commander": "^14.0.3",
51
51
  "dayjs": "^1.11.20",