@akanjs/cli 3.1.2-rc.4 → 3.2.0-rc.1

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 (120) hide show
  1. package/.build-stamp +1 -1
  2. package/{CodeAgent-z34p8m91.js → CodeAgent-vmd9k4ak.js} +3 -3
  3. package/{CodeTui-nvd9fk3g.js → CodeTui-zka44v52.js} +1 -1
  4. package/README.ko.md +9 -0
  5. package/README.md +9 -0
  6. package/TunnelShare-k3ja4w9x.js +14 -0
  7. package/{agent.command-962mp3kg.js → agent.command-2f657613.js} +19 -17
  8. package/akanCode.js +6 -6
  9. package/{application.command-1nr0bqq1.js → application.command-q6skd3am.js} +36 -22
  10. package/{applicationBuildRunner-xy7hnfzq.js → applicationBuildRunner-sctcmkyx.js} +55 -16
  11. package/buildBatch.proc.js +7 -7
  12. package/{cloud.command-cj7b3m6y.js → cloud.command-7642pks6.js} +36 -19
  13. package/cloud.script-1sfseznn.js +30 -0
  14. package/{code.command-asq7xrr6.js → code.command-7s4ndq2k.js} +6 -6
  15. package/commandManifest.json +1 -1
  16. package/{context.command-fw4g2pw1.js → context.command-569z0rqf.js} +20 -19
  17. package/context.runner-ms8v1rxy.js +29 -0
  18. package/{devTui-evr3b35y.js → devTui-w38ch13a.js} +1 -1
  19. package/{guideline.command-43gfjsjv.js → guideline.command-gnv3e8p8.js} +2 -2
  20. package/guidelines/akanApi/akanApi.instruction.md +317 -0
  21. package/guidelines/conventions/rules/app.md +5 -5
  22. package/guidelines/conventions/rules/config.md +1 -1
  23. package/guidelines/conventions/rules/gates.md +10 -5
  24. package/incrementalBuilder.proc.js +69 -39
  25. package/{index-0tkj05cz.js → index-0fb3cpbt.js} +3 -3
  26. package/{index-6t7fkx73.js → index-1q1cjn8s.js} +21 -11
  27. package/{index-tenw3mah.js → index-23860fej.js} +16 -6
  28. package/{index-6zgt7zmx.js → index-48d5qsj3.js} +4 -4
  29. package/{index-z47rw9ez.js → index-5w9my9qe.js} +8 -8
  30. package/{index-qwe079ww.js → index-6wpaq392.js} +61 -15
  31. package/{index-kc871vpc.js → index-7xdpww43.js} +69 -12
  32. package/index-7y5yghjg.js +2969 -0
  33. package/{index-38patcx6.js → index-8g7tdsk4.js} +249 -696
  34. package/{index-90q0w90q.js → index-8kczhnmv.js} +1 -1
  35. package/{index-kdswbvys.js → index-8pb9yvp8.js} +63 -21
  36. package/{index-hmj94es2.js → index-8ts9774g.js} +4 -4
  37. package/{index-r0q2ka2b.js → index-93ewzmp6.js} +43 -14
  38. package/{index-y0y0pnx8.js → index-9tbgb4d8.js} +1 -1
  39. package/{index-jzpeny42.js → index-a8a9ede9.js} +7 -7
  40. package/index-abgh0jve.js +126 -0
  41. package/{index-t0hk1kxq.js → index-aj3ehkcx.js} +1 -1
  42. package/{index-demt944k.js → index-d4n1wmrz.js} +37 -4
  43. package/{index-sra1a5f8.js → index-drz9e84d.js} +22 -8
  44. package/{index-gfh90r3t.js → index-e3vmjtph.js} +2 -2
  45. package/{index-k64mhwbw.js → index-eajbmk10.js} +2 -1
  46. package/{index-g0yds382.js → index-ed6ea0qp.js} +1 -1
  47. package/{index-ap6ac70m.js → index-fjr4d6yd.js} +444 -368
  48. package/index-hqrkqxx2.js +176 -0
  49. package/{index-ampz4vgv.js → index-kpdv34rq.js} +4 -4
  50. package/{index-kc6ffq0s.js → index-ktb3wcqz.js} +73 -34
  51. package/{index-dcm66hss.js → index-mmym5xmb.js} +4 -2
  52. package/{index-8d9r465x.js → index-mqntfzv5.js} +2 -2
  53. package/{index-4am4dvmf.js → index-ny2k80mv.js} +15 -3
  54. package/index-p6hjwt2d.js +1668 -0
  55. package/{index-53h0053j.js → index-rc5fvqj2.js} +12 -14
  56. package/{index-jzz6ye8x.js → index-s2grpzef.js} +40 -8
  57. package/{index-38by07nw.js → index-sr5da35e.js} +32 -9
  58. package/{index-qev8p5wp.js → index-sy481q2x.js} +1 -1
  59. package/{index-ck64kxrn.js → index-thckcabc.js} +2 -2
  60. package/{index-2yan1ajk.js → index-v4p1zye8.js} +18 -9
  61. package/{index-wymcdsas.js → index-vkzfk7qt.js} +25 -23
  62. package/{index-r8t5sq7z.js → index-vr68mxj5.js} +68 -21
  63. package/{index-vkpqe29t.js → index-w639tvkd.js} +24 -125
  64. package/index-ygdbn9jn.js +122 -0
  65. package/{index-w60zxxye.js → index-zpv14wpy.js} +3 -3
  66. package/index.js +24 -23
  67. package/{library.command-zh29tjdd.js → library.command-1gp5qe3r.js} +3 -3
  68. package/{localRegistry.command-k9pn9ahj.js → localRegistry.command-x7jptkd3.js} +26 -17
  69. package/{module.command-dgpqs9fz.js → module.command-4xz9he6h.js} +6 -6
  70. package/{package.command-1je4hsca.js → package.command-s7qpnn1g.js} +12 -3
  71. package/package.json +2 -2
  72. package/{page.command-cgsasanh.js → page.command-fan34c49.js} +3 -3
  73. package/{pipeline.command-tb46sa8v.js → pipeline.command-ph4fnn9w.js} +2 -2
  74. package/{primitive.command-bzsy23x5.js → primitive.command-3fqh8emf.js} +7 -7
  75. package/{projectTypecheck-h8rgaczy.js → projectTypecheck-vkb40hjc.js} +1 -1
  76. package/{quality.command-120m9h6v.js → quality.command-ecj6exsh.js} +15 -10
  77. package/{repair.command-6m4wd0qv.js → repair.command-fe9jw719.js} +6 -6
  78. package/{scalar.command-3dn5hsc6.js → scalar.command-cnvfhk0n.js} +5 -5
  79. package/skills/akan-debug/SKILL.md +2 -1
  80. package/skills/akan-page/SKILL.md +16 -7
  81. package/skills/akan-service/SKILL.md +48 -19
  82. package/{subspace.command-s8nyfqbn.js → subspace.command-qw5ddd6y.js} +8 -8
  83. package/templates/app/lib/___appName__/__appName__.abstract.md.template +6 -0
  84. package/templates/app/page/_index.tsx +4 -284
  85. package/templates/app/page/_layout.tsx +1 -26
  86. package/templates/app/page/styles.css.template +58 -318
  87. package/templates/appSample/page/_index.tsx +281 -0
  88. package/templates/appSample/page/_layout.tsx +55 -0
  89. package/templates/appSample/page/styles.css.template +327 -0
  90. package/templates/libRoot/lib/___libName__/__libName__.abstract.md.template +6 -0
  91. package/templates/workspaceRoot/package.json.template +1 -12
  92. package/{tunnel.command-8mwrqkr3.js → tunnel.command-ggj38mqf.js} +7 -7
  93. package/{verify.command-2pspfy7k.js → verify.command-w9ttxkdz.js} +16 -14
  94. package/{workflow.command-7sy5vnsj.js → workflow.command-ss8devj0.js} +12 -12
  95. package/{workspace.command-x518tdv4.js → workspace.command-6z2rh8ze.js} +51 -39
  96. package/TunnelShare-jwbb50kz.js +0 -14
  97. package/cloud.script-8kr7qgfa.js +0 -27
  98. package/context.runner-p6m5cxk3.js +0 -28
  99. package/index-d894868w.js +0 -842
  100. package/index-re2kfscb.js +0 -1363
  101. /package/templates/{app → appSample}/page/_overrides.tsx +0 -0
  102. /package/templates/{app → appSample}/public/fonts/Pretendard-Black.woff2 +0 -0
  103. /package/templates/{app → appSample}/public/fonts/Pretendard-Bold.woff2 +0 -0
  104. /package/templates/{app → appSample}/public/fonts/Pretendard-ExtraBold.woff2 +0 -0
  105. /package/templates/{app → appSample}/public/fonts/Pretendard-ExtraLight.woff2 +0 -0
  106. /package/templates/{app → appSample}/public/fonts/Pretendard-Light.woff2 +0 -0
  107. /package/templates/{app → appSample}/public/fonts/Pretendard-Medium.woff2 +0 -0
  108. /package/templates/{app → appSample}/public/fonts/Pretendard-Regular.woff2 +0 -0
  109. /package/templates/{app → appSample}/public/fonts/Pretendard-SemiBold.woff2 +0 -0
  110. /package/templates/{app → appSample}/public/fonts/Pretendard-Thin.woff2 +0 -0
  111. /package/templates/{app → appSample}/public/jelly/cloud.webp +0 -0
  112. /package/templates/{app → appSample}/public/jelly/comet.webp +0 -0
  113. /package/templates/{app → appSample}/public/jelly/moon.webp +0 -0
  114. /package/templates/{app → appSample}/public/jelly/planet.webp +0 -0
  115. /package/templates/{app → appSample}/public/jelly/rocket.webp +0 -0
  116. /package/templates/{app → appSample}/public/jelly/star.webp +0 -0
  117. /package/templates/{app → appSample}/public/jelly/sugar.webp +0 -0
  118. /package/templates/{app → appSample}/public/logo.png +0 -0
  119. /package/templates/{app → appSample}/ui/Recipe/index.ts +0 -0
  120. /package/templates/{app → appSample}/ui/Recipe/jellyButton.ts +0 -0
@@ -1,46 +1,48 @@
1
1
  // @bun
2
2
  import {
3
3
  ApplicationBuildReporter
4
- } from "./index-d894868w.js";
4
+ } from "./index-p6hjwt2d.js";
5
5
  import {
6
6
  script,
7
7
  ExitCodeError,
8
8
  markCliErrorPrinted,
9
9
  assertPromptable
10
- } from "./index-r0q2ka2b.js";
10
+ } from "./index-93ewzmp6.js";
11
11
  import {
12
+ SysExecutor,
12
13
  AppExecutor,
13
14
  LibExecutor,
14
15
  PkgExecutor
15
- } from "./index-38by07nw.js";
16
+ } from "./index-sr5da35e.js";
16
17
  import {
17
18
  DesktopServerStage
18
- } from "./index-g0yds382.js";
19
+ } from "./index-ed6ea0qp.js";
19
20
  import {
20
21
  LibraryScript
21
- } from "./index-8d9r465x.js";
22
+ } from "./index-mqntfzv5.js";
22
23
  import {
23
24
  ApplicationRunner,
24
25
  VerifyScope
25
- } from "./index-kc6ffq0s.js";
26
+ } from "./index-ktb3wcqz.js";
26
27
  import {
27
28
  PreviewChrome2,
28
29
  PreviewView2,
29
30
  stripAnsi
30
- } from "./index-tenw3mah.js";
31
+ } from "./index-23860fej.js";
31
32
  import {
32
33
  formatSlicePlan
33
- } from "./index-qev8p5wp.js";
34
+ } from "./index-sy481q2x.js";
34
35
  import {
35
36
  openBrowser
36
37
  } from "./index-9dp031by.js";
37
38
 
38
39
  // pkgs/@akanjs/cli/application/application.script.ts
40
+ import path3 from "path";
39
41
  import { confirm } from "@inquirer/prompts";
40
42
  import { Logger as Logger3, toError } from "akanjs/common";
41
43
 
42
44
  // pkgs/@akanjs/cli/application/appPreview.ts
43
- import { closeSync, openSync, realpathSync } from "fs";
45
+ import { closeSync, openSync, realpathSync, statSync } from "fs";
44
46
  import { mkdir as mkdir2 } from "fs/promises";
45
47
  import path2 from "path";
46
48
  import { parseRouteModuleKey } from "akanjs/common";
@@ -628,11 +630,15 @@ class AppPreview {
628
630
  const unavailable = PreviewView2.unavailableReason(engine);
629
631
  if (unavailable)
630
632
  throw new Error(unavailable);
631
- const { i18n } = await app.getConfig();
633
+ const { i18n, api } = await app.getConfig();
632
634
  const changed = options.changed ? await AppPreview.#changedPages(app) : { paths: [], skipped: [] };
633
635
  if (options.changed && !changed.paths.length && !options.paths?.length)
634
636
  throw new Error(`No page to open: ${changed.skipped.join("; ")}. Pass a concrete path, e.g. \`akan preview ${app.name} /memo/1\`.`);
635
- const paths = AppPreview.pagePaths([...options.paths ?? [], ...changed.paths], i18n, { csr: !!options.csr });
637
+ const paths = AppPreview.pagePaths([...options.paths ?? [], ...changed.paths], i18n, {
638
+ csr: !!options.csr,
639
+ apiPrefix: api.prefix,
640
+ publicDir: path2.join(app.cwdPath, "public")
641
+ });
636
642
  const port = await app.getDevPort();
637
643
  const origin = `http://localhost:${port}`;
638
644
  const root = app.workspace.workspaceRoot;
@@ -684,10 +690,12 @@ class AppPreview {
684
690
  started?.proc.unref();
685
691
  }
686
692
  }
687
- static pagePaths(paths, i18n, { csr }) {
693
+ static pagePaths(paths, i18n, { csr, apiPrefix = "/api", publicDir = null }) {
688
694
  const keepsUnprefixed = i18n.localePrefix === "as-needed" && !csr;
689
695
  const pages = (paths.length ? paths : ["/"]).map((raw) => {
690
696
  const url = new URL(/^https?:\/\//.test(raw) ? raw : `http://localhost${raw.startsWith("/") ? "" : "/"}${raw}`);
697
+ if (!AppPreview.#isPagePath(url.pathname, i18n, { apiPrefix, publicDir }))
698
+ return `${url.pathname}${url.search}`;
691
699
  const [first] = url.pathname.split("/").filter(Boolean);
692
700
  if (!keepsUnprefixed && (!first || !i18n.locales.includes(first)))
693
701
  url.pathname = `/${i18n.defaultLocale}${url.pathname === "/" ? "/" : url.pathname}`;
@@ -699,6 +707,31 @@ class AppPreview {
699
707
  });
700
708
  return [...new Set(pages)];
701
709
  }
710
+ static #serverFiles = new Set(["/favicon.ico", "/robots.txt", "/sitemap.xml", "/manifest.webmanifest"]);
711
+ static #basePathFiles = new Set(["sitemap.xml", "manifest.webmanifest"]);
712
+ static #isPagePath(pathname, i18n, { apiPrefix, publicDir }) {
713
+ const segments = pathname.split("/").filter(Boolean);
714
+ const [first] = segments;
715
+ if (first && i18n.locales.includes(first))
716
+ return true;
717
+ const prefixes = ["/_akan", "/__csr", "/__rsc", "/.well-known", apiPrefix.replace(/\/+$/, "")].filter(Boolean);
718
+ if (prefixes.some((prefix) => pathname === prefix || pathname.startsWith(`${prefix}/`)))
719
+ return false;
720
+ if (AppPreview.#serverFiles.has(pathname))
721
+ return false;
722
+ if (segments.length === 2 && AppPreview.#basePathFiles.has(segments[1] ?? ""))
723
+ return false;
724
+ return !(publicDir && AppPreview.#isPublicFile(publicDir, pathname));
725
+ }
726
+ static #isPublicFile(publicDir, pathname) {
727
+ try {
728
+ const root = path2.resolve(publicDir);
729
+ const filePath = path2.resolve(root, `.${decodeURIComponent(pathname)}`);
730
+ return filePath.startsWith(`${root}${path2.sep}`) && statSync(filePath).isFile();
731
+ } catch {
732
+ return false;
733
+ }
734
+ }
702
735
  static changedPageLimit = 8;
703
736
  static changedPages(sources, changedFiles) {
704
737
  const realOf = (file) => {
@@ -1224,9 +1257,9 @@ class ApplicationScript extends script("application", [ApplicationRunner, Librar
1224
1257
  throw error;
1225
1258
  }
1226
1259
  }
1227
- async createApplication(appName, workspace, { start = false, libs = [], sample = false } = {}) {
1260
+ async createApplication(appName, workspace, { start = false, libs = [] } = {}) {
1228
1261
  const spinner = workspace.spinning("Creating application...");
1229
- const app = await this.applicationRunner.createApplication(appName, workspace, libs, { sample });
1262
+ const app = await this.applicationRunner.createApplication(appName, workspace, libs);
1230
1263
  spinner.succeed(`Application created in apps/${app.name}`);
1231
1264
  await app.scanSync();
1232
1265
  if (start)
@@ -1305,13 +1338,21 @@ class ApplicationScript extends script("application", [ApplicationRunner, Librar
1305
1338
  write = true,
1306
1339
  fast = false,
1307
1340
  quiet = false,
1308
- profile
1341
+ profile,
1342
+ env,
1343
+ updateBudget = false
1309
1344
  } = {}) {
1310
1345
  await app.scanSync({ write });
1311
1346
  if (!quiet)
1312
1347
  Logger3.rawLog(`Creating an optimized production build for ${app.name}...`);
1313
1348
  try {
1314
- const result = await this.applicationRunner.build(app, { fast, spinner: !quiet, envProfile: profile });
1349
+ const result = await this.applicationRunner.build(app, {
1350
+ fast,
1351
+ spinner: !quiet,
1352
+ envProfile: profile,
1353
+ environment: env,
1354
+ budget: updateBudget ? "update" : "enforce"
1355
+ });
1315
1356
  Logger3.rawLog(`${app.name} built in dist/apps/${app.name}`);
1316
1357
  if (!quiet)
1317
1358
  ApplicationBuildReporter.printSummary(result);
@@ -1345,15 +1386,16 @@ class ApplicationScript extends script("application", [ApplicationRunner, Librar
1345
1386
  throw error;
1346
1387
  }
1347
1388
  }
1348
- async test(exec, { write = true, files = [] } = {}) {
1389
+ async test(exec, { write = true, files = [], coverage = false } = {}) {
1349
1390
  const testPaths = this.applicationRunner.resolveTestPaths(exec, files);
1391
+ const flags = coverage ? ApplicationScript.#coverageFlagsOf(exec) : [];
1350
1392
  if (exec instanceof LibExecutor) {
1351
1393
  if (write)
1352
1394
  await this.libraryScript.syncLibrary(exec);
1353
1395
  else
1354
1396
  await exec.scan({ write: false });
1355
1397
  exec.spinning(`Preparing ${exec.name}...`).succeed(`${exec.name} prepared`);
1356
- await this.applicationRunner.test(exec, testPaths);
1398
+ await this.applicationRunner.test(exec, testPaths, flags);
1357
1399
  return;
1358
1400
  }
1359
1401
  const spinner = exec.spinning(`Preparing ${exec.name}...`);
@@ -1367,7 +1409,12 @@ class ApplicationScript extends script("application", [ApplicationRunner, Librar
1367
1409
  spinner.fail(`${exec.name} prepare failed`);
1368
1410
  throw error;
1369
1411
  }
1370
- await this.applicationRunner.test(exec, testPaths);
1412
+ await this.applicationRunner.test(exec, testPaths, flags);
1413
+ }
1414
+ static #coverageFlagsOf(exec) {
1415
+ const root = exec instanceof SysExecutor || exec instanceof PkgExecutor ? exec.workspace.workspaceRoot : null;
1416
+ const dir = root ? path3.join(root, "local", "coverage", path3.relative(root, exec.cwdPath)) : "local/coverage";
1417
+ return ["--coverage", "--coverage-reporter=text", "--coverage-reporter=lcov", `--coverage-dir=${dir}`];
1371
1418
  }
1372
1419
  async start(apps, {
1373
1420
  open = false,
@@ -1436,7 +1483,7 @@ class ApplicationScript extends script("application", [ApplicationRunner, Librar
1436
1483
  throw new Error("No app selected to start");
1437
1484
  const startedDatabase = dbup ? await this.#prepareSharedDatabase(apps) : false;
1438
1485
  const supervisor = new DevSupervisor({ apps, mode, concurrency, open, write, shares });
1439
- const view = mode === "tui" ? new (await import("./devTui-evr3b35y.js")).DevTui(supervisor) : new DevStreamView(apps.map((app) => app.name));
1486
+ const view = mode === "tui" ? new (await import("./devTui-w38ch13a.js")).DevTui(supervisor) : new DevStreamView(apps.map((app) => app.name));
1440
1487
  await supervisor.run(view);
1441
1488
  if (startedDatabase)
1442
1489
  await this.#stopDatabase(workspace);
@@ -1600,7 +1647,7 @@ class ApplicationScript extends script("application", [ApplicationRunner, Librar
1600
1647
  await Promise.all(shares.map(async (share) => await share.close()));
1601
1648
  }, "Abandoning the tunnel release; the shares expire on their own.");
1602
1649
  await Promise.all(apps.map(async (app) => {
1603
- const { TunnelShare } = await import("./TunnelShare-jwbb50kz.js");
1650
+ const { TunnelShare } = await import("./TunnelShare-k3ja4w9x.js");
1604
1651
  const share = await TunnelShare.open(app, { workspace: app.workspace });
1605
1652
  shares.push(share);
1606
1653
  urls.set(app.name, share.url);
@@ -2,127 +2,10 @@
2
2
  import {
3
3
  AkanGraphDiff,
4
4
  AkanIndex
5
- } from "./index-re2kfscb.js";
6
-
7
- // pkgs/@akanjs/devkit/gitRevision.ts
8
- var systemPaths = ["apps", "libs"];
9
- var changeOfStatus = { A: "added", D: "removed" };
10
-
11
- class GitRevision {
12
- static #defaultBranches = ["upstream/HEAD", "upstream/main", "origin/HEAD", "origin/main", "main", "master"];
13
- static #env = { ...process.env, GIT_OPTIONAL_LOCKS: "0" };
14
- #root;
15
- constructor(root) {
16
- this.#root = root;
17
- }
18
- async forkPointOf(since) {
19
- if ((await this.#git(["rev-parse", "--is-inside-work-tree"]))?.trim() !== "true")
20
- return { error: "The Change Map compares with git history, and this workspace is not in a git repository." };
21
- if (since !== null) {
22
- const sha = /^[^-\s][^\s]*$/.test(since) ? (await this.#git(["rev-parse", "--verify", "--quiet", `${since}^{commit}`]))?.trim() : undefined;
23
- if (!sha)
24
- return { error: `${since} is not a commit in this repository.` };
25
- return await this.#mergeBase(since, sha);
26
- }
27
- for (const branch of GitRevision.#defaultBranches)
28
- if (await this.#git(["rev-parse", "--verify", "--quiet", `${branch}^{commit}`]) !== null)
29
- return await this.#mergeBase(branch, branch);
30
- const head = (await this.#git(["rev-parse", "--verify", "--quiet", "HEAD^{commit}"]))?.trim();
31
- return head ? { sha: head } : { error: "The repository has no commit to compare with yet." };
32
- }
33
- async#mergeBase(name, revision) {
34
- const sha = (await this.#git(["merge-base", "HEAD", revision]))?.trim();
35
- if (sha)
36
- return { sha };
37
- return {
38
- error: `HEAD shares no commit with ${name} here. In a shallow clone, \`git fetch --unshallow\` brings the history in.`
39
- };
40
- }
41
- async filesAt(sha, isWanted) {
42
- const listed = await this.#git(["ls-tree", "-r", "-z", "--name-only", sha, "--", ...systemPaths]);
43
- if (listed === null)
44
- throw new Error(`git ls-tree failed for ${sha}`);
45
- const files = listed.split("\x00").filter((file) => file && isWanted(file));
46
- const texts = new Map;
47
- if (!files.length)
48
- return texts;
49
- const proc = Bun.spawn(["git", "cat-file", "--batch"], {
50
- cwd: this.#root,
51
- env: GitRevision.#env,
52
- stdin: "pipe",
53
- stdout: "pipe",
54
- stderr: "ignore"
55
- });
56
- const output = new Response(proc.stdout).arrayBuffer();
57
- proc.stdin.write(files.map((file) => `${sha}:./${file}
58
- `).join(""));
59
- await proc.stdin.end();
60
- const bytes = new Uint8Array(await output);
61
- if (await proc.exited !== 0)
62
- throw new Error(`git cat-file failed for ${sha}`);
63
- const decoder = new TextDecoder;
64
- let offset = 0;
65
- for (const file of files) {
66
- const lineEnd = bytes.indexOf(10, offset);
67
- if (lineEnd < 0)
68
- throw new Error(`git cat-file ended before ${file} at ${sha}`);
69
- const header = decoder.decode(bytes.subarray(offset, lineEnd));
70
- offset = lineEnd + 1;
71
- if (header.endsWith(" missing"))
72
- continue;
73
- const [, type, size] = header.split(" ");
74
- const length = Number(size);
75
- if (type === "blob")
76
- texts.set(file, decoder.decode(bytes.subarray(offset, offset + length)));
77
- offset += length + 1;
78
- }
79
- return texts;
80
- }
81
- async changedFilesSince(sha) {
82
- const [tracked, untracked] = await Promise.all([
83
- this.#git(["diff", "--name-status", "--no-renames", "--relative", "-z", sha, "--", ...systemPaths]),
84
- this.#git(["ls-files", "-z", "--others", "--exclude-standard", "--", ...systemPaths])
85
- ]);
86
- if (tracked === null || untracked === null)
87
- throw new Error(`git could not list the changes since ${sha}`);
88
- const changes = new Map;
89
- const fields = tracked.split("\x00");
90
- for (let idx = 0;idx + 1 < fields.length; idx += 2)
91
- changes.set(fields[idx + 1], changeOfStatus[fields[idx]] ?? "changed");
92
- for (const file of untracked.split("\x00"))
93
- if (file)
94
- changes.set(file, "added");
95
- return [...changes].sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0).map(([file, change]) => ({ file, change }));
96
- }
97
- async workingFiles() {
98
- const listed = await this.#git([
99
- "ls-files",
100
- "-z",
101
- "--cached",
102
- "--others",
103
- "--exclude-standard",
104
- "--",
105
- ...systemPaths
106
- ]);
107
- if (listed === null)
108
- throw new Error("git ls-files failed");
109
- return [...new Set(listed.split("\x00").filter(Boolean))];
110
- }
111
- async#git(args) {
112
- try {
113
- const proc = Bun.spawn(["git", ...args], {
114
- cwd: this.#root,
115
- env: GitRevision.#env,
116
- stdout: "pipe",
117
- stderr: "ignore"
118
- });
119
- const [text, exitCode] = await Promise.all([new Response(proc.stdout).text(), proc.exited]);
120
- return exitCode === 0 ? text : null;
121
- } catch {
122
- return null;
123
- }
124
- }
125
- }
5
+ } from "./index-7y5yghjg.js";
6
+ import {
7
+ GitRevision
8
+ } from "./index-ygdbn9jn.js";
126
9
 
127
10
  // pkgs/@akanjs/devkit/workspaceGraph.ts
128
11
  import { readFile } from "fs/promises";
@@ -131,6 +14,7 @@ import ts from "typescript";
131
14
  var indexedPath = /^(apps|libs)\/(?!(?:.*\/)?(?:node_modules|dist|\.akan|env)\/).*\.tsx?$/;
132
15
  var hiddenPath = /(?:^|\/)(?:node_modules|dist|\.akan|env)\//;
133
16
  var unscopedNodeLimit = 600;
17
+ var pageKinds = new Set(["route", "layout"]);
134
18
  var cachedBaseLimit = 4;
135
19
  var slashed = (fileName) => fileName.replace(/\\/g, "/");
136
20
 
@@ -198,10 +82,22 @@ ${sha}`;
198
82
  return graph;
199
83
  const owners = app ? new Set([`apps/${app}`, `libs/${app}`]) : null;
200
84
  const seeds = new Set(graph.nodes.filter((node) => (!owners || owners.has(node.owner ?? "")) && (!module || node.module === module)).map((node) => node.id));
201
- const edges = graph.edges.filter((edge) => seeds.has(edge.from) || seeds.has(edge.to));
85
+ const guards = new Set(graph.nodes.filter((node) => node.kind === "guard").map((node) => node.id));
86
+ const reaches = (id) => seeds.has(id) && !guards.has(id);
87
+ const edges = graph.edges.filter((edge) => reaches(edge.from) || reaches(edge.to));
202
88
  const ids = new Set([...seeds, ...edges.flatMap((edge) => [edge.from, edge.to])]);
203
89
  return { version: 1, nodes: graph.nodes.filter((node) => ids.has(node.id)), edges };
204
90
  }
91
+ static #withoutPages(graph) {
92
+ const changed = new Set(graph.nodes.filter((node) => node.change).map((node) => node.id));
93
+ const touching = new Set(graph.edges.filter((edge) => edge.kind !== "wraps" && (changed.has(edge.from) || changed.has(edge.to))).flatMap((edge) => [edge.from, edge.to]));
94
+ const dropped = new Set(graph.nodes.filter((node) => pageKinds.has(node.kind) && !node.change && !touching.has(node.id)).map((node) => node.id));
95
+ const edges = graph.edges.filter((edge) => !dropped.has(edge.from) && !dropped.has(edge.to));
96
+ const linked = new Set(edges.flatMap((edge) => [edge.from, edge.to]));
97
+ const isRouteOnly = (node) => node.kind === "guard" && node.detail.includes("route") && !node.change && !linked.has(node.id);
98
+ const nodes = graph.nodes.filter((node) => !dropped.has(node.id) && !isRouteOnly(node));
99
+ return { version: 1, nodes, edges };
100
+ }
205
101
  static visibleTo(graph, app) {
206
102
  const appOwner = `apps/${app}`;
207
103
  const isVisible = ({ owner }) => !owner || owner === appOwner || owner.startsWith("libs/");
@@ -246,16 +142,19 @@ ${sha}`;
246
142
  static answer(graph, scope, counted = graph.nodes) {
247
143
  if (scope.app || scope.module || graph.nodes.length <= unscopedNodeLimit)
248
144
  return WorkspaceGraph.scope(graph, scope);
145
+ const unscoped = WorkspaceGraph.#withoutPages(graph);
146
+ if (unscoped.nodes.length <= unscopedNodeLimit)
147
+ return unscoped;
249
148
  const owners = new Map;
250
149
  for (const node of counted)
251
- if (node.owner)
150
+ if (node.owner && !pageKinds.has(node.kind))
252
151
  owners.set(node.owner, (owners.get(node.owner) ?? 0) + 1);
253
152
  return {
254
153
  diagnostics: [
255
154
  {
256
155
  severity: "error",
257
156
  code: "graph-scope-required",
258
- message: `The graph has ${graph.nodes.length} nodes. Pass app, module or both to scope it.`,
157
+ message: `The graph has ${unscoped.nodes.length} nodes besides its pages. Pass app, module or both to scope it.`,
259
158
  input: "app"
260
159
  }
261
160
  ],
@@ -264,4 +163,4 @@ ${sha}`;
264
163
  }
265
164
  }
266
165
 
267
- export { GitRevision, WorkspaceGraph };
166
+ export { WorkspaceGraph };
@@ -0,0 +1,122 @@
1
+ // @bun
2
+ // pkgs/@akanjs/devkit/gitRevision.ts
3
+ var systemPaths = ["apps", "libs"];
4
+ var changeOfStatus = { A: "added", D: "removed" };
5
+
6
+ class GitRevision {
7
+ static #defaultBranches = ["upstream/HEAD", "upstream/main", "origin/HEAD", "origin/main", "main", "master"];
8
+ static #env = { ...process.env, GIT_OPTIONAL_LOCKS: "0" };
9
+ #root;
10
+ constructor(root) {
11
+ this.#root = root;
12
+ }
13
+ async forkPointOf(since) {
14
+ if ((await this.#git(["rev-parse", "--is-inside-work-tree"]))?.trim() !== "true")
15
+ return { error: "The Change Map compares with git history, and this workspace is not in a git repository." };
16
+ if (since !== null) {
17
+ const sha = /^[^-\s][^\s]*$/.test(since) ? (await this.#git(["rev-parse", "--verify", "--quiet", `${since}^{commit}`]))?.trim() : undefined;
18
+ if (!sha)
19
+ return { error: `${since} is not a commit in this repository.` };
20
+ return await this.#mergeBase(since, sha);
21
+ }
22
+ for (const branch of GitRevision.#defaultBranches)
23
+ if (await this.#git(["rev-parse", "--verify", "--quiet", `${branch}^{commit}`]) !== null)
24
+ return await this.#mergeBase(branch, branch);
25
+ const head = (await this.#git(["rev-parse", "--verify", "--quiet", "HEAD^{commit}"]))?.trim();
26
+ return head ? { sha: head } : { error: "The repository has no commit to compare with yet." };
27
+ }
28
+ async#mergeBase(name, revision) {
29
+ const sha = (await this.#git(["merge-base", "HEAD", revision]))?.trim();
30
+ if (sha)
31
+ return { sha };
32
+ return {
33
+ error: `HEAD shares no commit with ${name} here. In a shallow clone, \`git fetch --unshallow\` brings the history in.`
34
+ };
35
+ }
36
+ async filesAt(sha, isWanted, paths = systemPaths) {
37
+ const listed = await this.#git(["ls-tree", "-r", "-z", "--name-only", sha, "--", ...paths]);
38
+ if (listed === null)
39
+ throw new Error(`git ls-tree failed for ${sha}`);
40
+ const files = listed.split("\x00").filter((file) => file && isWanted(file));
41
+ const texts = new Map;
42
+ if (!files.length)
43
+ return texts;
44
+ const proc = Bun.spawn(["git", "cat-file", "--batch"], {
45
+ cwd: this.#root,
46
+ env: GitRevision.#env,
47
+ stdin: "pipe",
48
+ stdout: "pipe",
49
+ stderr: "ignore"
50
+ });
51
+ const output = new Response(proc.stdout).arrayBuffer();
52
+ proc.stdin.write(files.map((file) => `${sha}:./${file}
53
+ `).join(""));
54
+ await proc.stdin.end();
55
+ const bytes = new Uint8Array(await output);
56
+ if (await proc.exited !== 0)
57
+ throw new Error(`git cat-file failed for ${sha}`);
58
+ const decoder = new TextDecoder;
59
+ let offset = 0;
60
+ for (const file of files) {
61
+ const lineEnd = bytes.indexOf(10, offset);
62
+ if (lineEnd < 0)
63
+ throw new Error(`git cat-file ended before ${file} at ${sha}`);
64
+ const header = decoder.decode(bytes.subarray(offset, lineEnd));
65
+ offset = lineEnd + 1;
66
+ if (header.endsWith(" missing"))
67
+ continue;
68
+ const [, type, size] = header.split(" ");
69
+ const length = Number(size);
70
+ if (type === "blob")
71
+ texts.set(file, decoder.decode(bytes.subarray(offset, offset + length)));
72
+ offset += length + 1;
73
+ }
74
+ return texts;
75
+ }
76
+ async changedFilesSince(sha) {
77
+ const [tracked, untracked] = await Promise.all([
78
+ this.#git(["diff", "--name-status", "--no-renames", "--relative", "-z", sha, "--", ...systemPaths]),
79
+ this.#git(["ls-files", "-z", "--others", "--exclude-standard", "--", ...systemPaths])
80
+ ]);
81
+ if (tracked === null || untracked === null)
82
+ throw new Error(`git could not list the changes since ${sha}`);
83
+ const changes = new Map;
84
+ const fields = tracked.split("\x00");
85
+ for (let idx = 0;idx + 1 < fields.length; idx += 2)
86
+ changes.set(fields[idx + 1], changeOfStatus[fields[idx]] ?? "changed");
87
+ for (const file of untracked.split("\x00"))
88
+ if (file)
89
+ changes.set(file, "added");
90
+ return [...changes].sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0).map(([file, change]) => ({ file, change }));
91
+ }
92
+ async workingFiles() {
93
+ const listed = await this.#git([
94
+ "ls-files",
95
+ "-z",
96
+ "--cached",
97
+ "--others",
98
+ "--exclude-standard",
99
+ "--",
100
+ ...systemPaths
101
+ ]);
102
+ if (listed === null)
103
+ throw new Error("git ls-files failed");
104
+ return [...new Set(listed.split("\x00").filter(Boolean))];
105
+ }
106
+ async#git(args) {
107
+ try {
108
+ const proc = Bun.spawn(["git", ...args], {
109
+ cwd: this.#root,
110
+ env: GitRevision.#env,
111
+ stdout: "pipe",
112
+ stderr: "ignore"
113
+ });
114
+ const [text, exitCode] = await Promise.all([new Response(proc.stdout).text(), proc.exited]);
115
+ return exitCode === 0 ? text : null;
116
+ } catch {
117
+ return null;
118
+ }
119
+ }
120
+ }
121
+
122
+ export { GitRevision };
@@ -5,17 +5,17 @@ import {
5
5
  AkanAppConfig,
6
6
  Executor,
7
7
  WorkspaceExecutor
8
- } from "./index-38by07nw.js";
8
+ } from "./index-sr5da35e.js";
9
9
  import {
10
10
  resolveAppId,
11
11
  targetHtmlFilename
12
12
  } from "./index-m9jj544v.js";
13
13
  import {
14
14
  CsrArtifactBuilder
15
- } from "./index-dcm66hss.js";
15
+ } from "./index-mmym5xmb.js";
16
16
  import {
17
17
  ExitCodeError
18
- } from "./index-r0q2ka2b.js";
18
+ } from "./index-93ewzmp6.js";
19
19
 
20
20
  // pkgs/@akanjs/devkit/mobile/desktopBin.ts
21
21
  import { chmod, mkdir, rename, rm, writeFile } from "fs/promises";
package/index.js CHANGED
@@ -4,9 +4,9 @@ import {
4
4
  getTargetMetas,
5
5
  getTargetCommandNames,
6
6
  runCommands
7
- } from "./index-r0q2ka2b.js";
7
+ } from "./index-93ewzmp6.js";
8
8
  import"./index-bns3wcpc.js";
9
- import"./index-38by07nw.js";
9
+ import"./index-sr5da35e.js";
10
10
 
11
11
  // pkgs/@akanjs/cli/bunVersionGuard.ts
12
12
  class BunVersionGuard {
@@ -22,27 +22,27 @@ import path from "path";
22
22
 
23
23
  // pkgs/@akanjs/cli/commandModules.ts
24
24
  var commandModules = {
25
- workspace: async () => (await import("./workspace.command-x518tdv4.js")).WorkspaceCommand,
26
- agent: async () => (await import("./agent.command-962mp3kg.js")).AgentCommand,
27
- code: async () => (await import("./code.command-asq7xrr6.js")).CodeCommand,
28
- application: async () => (await import("./application.command-1nr0bqq1.js")).ApplicationCommand,
29
- library: async () => (await import("./library.command-zh29tjdd.js")).LibraryCommand,
30
- localRegistry: async () => (await import("./localRegistry.command-k9pn9ahj.js")).LocalRegistryCommand,
31
- package: async () => (await import("./package.command-1je4hsca.js")).PackageCommand,
32
- module: async () => (await import("./module.command-dgpqs9fz.js")).ModuleCommand,
33
- page: async () => (await import("./page.command-cgsasanh.js")).PageCommand,
34
- context: async () => (await import("./context.command-fw4g2pw1.js")).ContextCommand,
35
- cloud: async () => (await import("./cloud.command-cj7b3m6y.js")).CloudCommand,
36
- subspace: async () => (await import("./subspace.command-s8nyfqbn.js")).SubspaceCommand,
37
- guideline: async () => (await import("./guideline.command-43gfjsjv.js")).GuidelineCommand,
38
- scalar: async () => (await import("./scalar.command-3dn5hsc6.js")).ScalarCommand,
39
- primitive: async () => (await import("./primitive.command-bzsy23x5.js")).PrimitiveCommand,
40
- quality: async () => (await import("./quality.command-120m9h6v.js")).QualityCommand,
41
- verify: async () => (await import("./verify.command-2pspfy7k.js")).VerifyCommand,
42
- repair: async () => (await import("./repair.command-6m4wd0qv.js")).RepairCommand,
43
- workflow: async () => (await import("./workflow.command-7sy5vnsj.js")).WorkflowCommand,
44
- pipeline: async () => (await import("./pipeline.command-tb46sa8v.js")).PipelineCommand,
45
- tunnel: async () => (await import("./tunnel.command-8mwrqkr3.js")).TunnelCommand
25
+ workspace: async () => (await import("./workspace.command-6z2rh8ze.js")).WorkspaceCommand,
26
+ agent: async () => (await import("./agent.command-2f657613.js")).AgentCommand,
27
+ code: async () => (await import("./code.command-7s4ndq2k.js")).CodeCommand,
28
+ application: async () => (await import("./application.command-q6skd3am.js")).ApplicationCommand,
29
+ library: async () => (await import("./library.command-1gp5qe3r.js")).LibraryCommand,
30
+ localRegistry: async () => (await import("./localRegistry.command-x7jptkd3.js")).LocalRegistryCommand,
31
+ package: async () => (await import("./package.command-s7qpnn1g.js")).PackageCommand,
32
+ module: async () => (await import("./module.command-4xz9he6h.js")).ModuleCommand,
33
+ page: async () => (await import("./page.command-fan34c49.js")).PageCommand,
34
+ context: async () => (await import("./context.command-569z0rqf.js")).ContextCommand,
35
+ cloud: async () => (await import("./cloud.command-7642pks6.js")).CloudCommand,
36
+ subspace: async () => (await import("./subspace.command-qw5ddd6y.js")).SubspaceCommand,
37
+ guideline: async () => (await import("./guideline.command-gnv3e8p8.js")).GuidelineCommand,
38
+ scalar: async () => (await import("./scalar.command-cnvfhk0n.js")).ScalarCommand,
39
+ primitive: async () => (await import("./primitive.command-3fqh8emf.js")).PrimitiveCommand,
40
+ quality: async () => (await import("./quality.command-ecj6exsh.js")).QualityCommand,
41
+ verify: async () => (await import("./verify.command-w9ttxkdz.js")).VerifyCommand,
42
+ repair: async () => (await import("./repair.command-fe9jw719.js")).RepairCommand,
43
+ workflow: async () => (await import("./workflow.command-ss8devj0.js")).WorkflowCommand,
44
+ pipeline: async () => (await import("./pipeline.command-ph4fnn9w.js")).PipelineCommand,
45
+ tunnel: async () => (await import("./tunnel.command-ggj38mqf.js")).TunnelCommand
46
46
  };
47
47
  var commandModuleIds = Object.keys(commandModules);
48
48
 
@@ -87,6 +87,7 @@ if (bunRefusal) {
87
87
  console.error(bunRefusal);
88
88
  process.exit(1);
89
89
  }
90
+ delete process.env.AKAN_CLI_FORCE_BUILD;
90
91
  var ids = CommandManifest.resolve(await CommandManifest.read(), process.argv) ?? commandModuleIds;
91
92
  var commands = await Promise.all(ids.map(async (id) => await commandModules[id]()));
92
93
  await runCommands(...commands);
@@ -3,12 +3,12 @@ import {
3
3
  Lib,
4
4
  Workspace,
5
5
  command
6
- } from "./index-r0q2ka2b.js";
6
+ } from "./index-93ewzmp6.js";
7
7
  import"./index-bns3wcpc.js";
8
- import"./index-38by07nw.js";
8
+ import"./index-sr5da35e.js";
9
9
  import {
10
10
  LibraryScript
11
- } from "./index-8d9r465x.js";
11
+ } from "./index-mqntfzv5.js";
12
12
 
13
13
  // pkgs/@akanjs/cli/library/library.command.ts
14
14
  class LibraryCommand extends command("library", [LibraryScript], ({ public: target }) => ({