@akanjs/devkit 3.3.0-rc.54 → 3.3.0-rc.55

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.
@@ -417,6 +417,11 @@ export class AkanAppConfig implements AppConfigResult {
417
417
  throw new Error(
418
418
  `A route in apps/${this.app.name}/akan.config.ts sets syncPageLibs without a basePath: only a basePath has lib pages of its own, so set the app's syncPageLibs.`,
419
419
  );
420
+ const earlier = this.routePageLibs.get(basePath);
421
+ if (earlier !== undefined && JSON.stringify(earlier) !== JSON.stringify(route.syncPageLibs))
422
+ throw new Error(
423
+ `Two routes in apps/${this.app.name}/akan.config.ts share basePath "${basePath}" and set different syncPageLibs: a basePath mounts one set of lib pages, so set it on one of them.`,
424
+ );
420
425
  this.routePageLibs.set(basePath, route.syncPageLibs);
421
426
  }
422
427
  const domains = basePath !== null ? this.subRoutes.getOrInsert(basePath, new Set()) : this.domains;
@@ -322,15 +322,13 @@ export class AppExecutor extends SysExecutor {
322
322
  async syncPages(libDeps: string[]): Promise<boolean> {
323
323
  const akanConfig = await this.getConfig();
324
324
  const parents = AppExecutor.#pageLibParents(akanConfig.basePaths);
325
+ const appLibs = await this.#resolvePageLibs(akanConfig.syncPageLibs, libDeps);
325
326
  const libsOf = new Map<string, string[]>();
326
- for (const parent of parents)
327
- libsOf.set(
328
- parent,
329
- await this.#resolvePageLibs(
330
- akanConfig.routePageLibs.get(parent.slice(0, -1)) ?? akanConfig.syncPageLibs,
331
- libDeps,
332
- ),
333
- );
327
+ for (const parent of parents) {
328
+ const basePath = parent.slice(0, -1);
329
+ const routeLibs = akanConfig.routePageLibs.get(basePath);
330
+ libsOf.set(parent, routeLibs === undefined ? appLibs : await this.#resolvePageLibs(routeLibs, libDeps, basePath));
331
+ }
334
332
  //* Not `getPageRoots`: it drops links whose target is gone, exactly the ones a sync must clean up.
335
333
  const linked = (
336
334
  await Promise.all(
@@ -365,8 +363,9 @@ export class AppExecutor extends SysExecutor {
365
363
  this.#pageKeys = null;
366
364
  return true;
367
365
  }
368
- async #resolvePageLibs(syncPageLibs: string[] | boolean, libDeps: string[]): Promise<string[]> {
366
+ async #resolvePageLibs(syncPageLibs: string[] | boolean, libDeps: string[], basePath?: string): Promise<string[]> {
369
367
  if (!syncPageLibs) return [];
368
+ const owner = basePath === undefined ? `app "${this.name}"` : `app "${this.name}"'s route "${basePath}"`;
370
369
  const hasPageDir = async (lib: string) =>
371
370
  await FileSys.dirExists(`${this.workspace.workspaceRoot}/libs/${lib}/page`);
372
371
  if (syncPageLibs === true) {
@@ -377,10 +376,10 @@ export class AppExecutor extends SysExecutor {
377
376
  for (const lib of syncPageLibs) {
378
377
  if (!libDeps.includes(lib))
379
378
  throw new Error(
380
- `[syncPageLibs] app "${this.name}" lists lib "${lib}" but does not depend on it (deps: ${libDeps.join(", ") || "none"})`,
379
+ `[syncPageLibs] ${owner} lists lib "${lib}" but the app does not depend on it (deps: ${libDeps.join(", ") || "none"})`,
381
380
  );
382
381
  if (!(await hasPageDir(lib)))
383
- throw new Error(`[syncPageLibs] app "${this.name}" lists lib "${lib}" but libs/${lib}/page does not exist`);
382
+ throw new Error(`[syncPageLibs] ${owner} lists lib "${lib}" but libs/${lib}/page does not exist`);
384
383
  }
385
384
  return [...syncPageLibs];
386
385
  }
@@ -811,6 +811,43 @@ describe("Workspace and app executor environment contracts", () => {
811
811
  await expect(app.syncPages(["shared"])).rejects.toThrow("sets syncPageLibs without a basePath");
812
812
  });
813
813
 
814
+ test("refuses two routes of one basePath that set different syncPageLibs", async () => {
815
+ const { app } = await makeAppWithLibPages("pages-route-libs-twice", {
816
+ config: [
817
+ "export default {",
818
+ " routes: [",
819
+ ' { basePath: "shop", domains: {}, syncPageLibs: ["shared"] },',
820
+ ' { basePath: "shop", domains: {}, syncPageLibs: false },',
821
+ " ],",
822
+ "};",
823
+ "",
824
+ ].join("\n"),
825
+ });
826
+ await expect(app.syncPages(["shared"])).rejects.toThrow('share basePath "shop" and set different syncPageLibs');
827
+ });
828
+
829
+ test("names the route whose syncPageLibs lists an unknown lib, and checks the app's list no route uses", async () => {
830
+ const { app } = await makeAppWithLibPages("pages-route-libs-unknown", {
831
+ config: 'export default { routes: [{ basePath: "shop", domains: {}, syncPageLibs: ["missing"] }] };\n',
832
+ });
833
+ await expect(app.syncPages(["shared"])).rejects.toThrow(
834
+ `app "pages-route-libs-unknown"'s route "shop" lists lib "missing"`,
835
+ );
836
+
837
+ const { app: unused } = await makeAppWithLibPages("pages-route-libs-unused", {
838
+ config: [
839
+ "export default {",
840
+ ' syncPageLibs: ["missing"],',
841
+ ' routes: [{ basePath: "shop", domains: {}, syncPageLibs: false }],',
842
+ "};",
843
+ "",
844
+ ].join("\n"),
845
+ });
846
+ await expect(unused.syncPages(["shared"])).rejects.toThrow(
847
+ 'app "pages-route-libs-unused" lists lib "missing" but the app does not depend on it',
848
+ );
849
+ });
850
+
814
851
  test("rejects a lib route that collides with an app route", async () => {
815
852
  const { app, appRoot } = await makeAppWithLibPages("pages-collide", {
816
853
  config: "export default { syncPageLibs: true };\n",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@akanjs/devkit",
3
- "version": "3.3.0-rc.54",
3
+ "version": "3.3.0-rc.55",
4
4
  "sourceType": "module",
5
5
  "type": "module",
6
6
  "publishConfig": {
@@ -50,7 +50,7 @@
50
50
  "./workspace/getRelatedCnsts": "./workspace/getRelatedCnsts.ts"
51
51
  },
52
52
  "dependencies": {
53
- "@akanjs/language": "3.3.0-rc.54",
53
+ "@akanjs/language": "3.3.0-rc.55",
54
54
  "@earendil-works/pi-agent-core": "1.5.2",
55
55
  "@earendil-works/pi-ai": "1.5.2",
56
56
  "@earendil-works/pi-codemode": "1.5.2",
@@ -59,7 +59,7 @@
59
59
  "@earendil-works/pi-tui": "1.5.2",
60
60
  "@inquirer/prompts": "^8.7.3",
61
61
  "@tailwindcss/node": "^4.3.3",
62
- "akanjs": "3.3.0-rc.54",
62
+ "akanjs": "3.3.0-rc.55",
63
63
  "chalk": "^6.0.1",
64
64
  "commander": "^15.0.0",
65
65
  "dayjs": "^1.11.23",