@akanjs/cli 3.0.0-beta.2 → 3.0.0-beta.20

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 (187) hide show
  1. package/.build-stamp +1 -1
  2. package/CodeAgent-awv258wb.js +9 -0
  3. package/CodeAgentRpcHost-p7h6n2hp.js +7 -0
  4. package/CodeAgentRpcListener-7p7z5dd7.js +97 -0
  5. package/CodeTui-1nqh35ez.js +1457 -0
  6. package/README.md +3 -0
  7. package/TunnelShare-scf4e4pd.js +9 -0
  8. package/{agent.command-d2gfxfck.js → agent.command-1s9ag7sb.js} +8 -9
  9. package/akanCode.js +102 -0
  10. package/{application.command-pj2m7584.js → application.command-49hwy6va.js} +51 -78
  11. package/{applicationBuildRunner-kxwbssgn.js → applicationBuildRunner-ybyp97pv.js} +63 -64
  12. package/{applicationReleasePackager-4yasxwv9.js → applicationReleasePackager-esnrphw8.js} +40 -60
  13. package/buildBatch.proc.js +19 -24
  14. package/{capacitorApp-36rbr858.js → capacitorApp-1synz4en.js} +3 -4
  15. package/cloud.command-d7rqtzt9.js +94 -0
  16. package/cloud.script-bkbpcr96.js +19 -0
  17. package/code.command-nn48xzej.js +154 -0
  18. package/commandManifest.json +1 -1
  19. package/consoleToStderr-h5bryj94.js +7 -0
  20. package/context.command-s3mcmvpa.js +48 -0
  21. package/context.runner-k99nb5pk.js +21 -0
  22. package/{dependencyScanner-shs82ynp.js → dependencyScanner-ye2e6pdz.js} +2 -2
  23. package/{devTui-40ggmd99.js → devTui-q7k7bakd.js} +122 -40
  24. package/fileSys-5ngz93ga.js +9 -0
  25. package/guideline.command-sct4qnt5.js +42 -0
  26. package/guidelines/agentRule/agentRule.instruction.md +206 -25
  27. package/guidelines/conventions/conventions.instruction.md +79 -24
  28. package/guidelines/fieldRule/fieldRule.instruction.md +1 -0
  29. package/guidelines/mcpRule/mcpRule.instruction.md +7 -5
  30. package/guidelines/queryRule/queryRule.instruction.md +17 -7
  31. package/guidelines/runtimeRule/runtimeRule.instruction.md +74 -0
  32. package/guidelines/ssrRule/ssrRule.instruction.md +4 -2
  33. package/guidelines/transportRule/transportRule.instruction.md +51 -0
  34. package/guidelines/workspaceRecipes/workspaceRecipes.instruction.md +66 -3
  35. package/incrementalBuilder.proc.js +31 -48
  36. package/{index-h7yw2z9n.js → index-0bq14vr1.js} +8 -14
  37. package/index-13ffe9wp.js +69 -0
  38. package/index-22d57v4c.js +266 -0
  39. package/{index-fz5q3gd7.js → index-31yr441d.js} +10 -17
  40. package/index-3hx1z96c.js +87 -0
  41. package/index-3sq321ak.js +53 -0
  42. package/{index-kcxmv48c.js → index-3t7g9e4r.js} +45 -79
  43. package/{index-q0y2jq9j.js → index-5b6tavv3.js} +6 -3
  44. package/{index-47pj3aee.js → index-5e0n4hqx.js} +11 -12
  45. package/{index-259dsnz3.js → index-5pc1qrbv.js} +5 -8
  46. package/index-7md2g9vw.js +6 -0
  47. package/index-8mna0947.js +187 -0
  48. package/{index-zry5nz81.js → index-8sf7wmdr.js} +51 -30
  49. package/{index-2tv3fdx4.js → index-9d9bgcx4.js} +342 -765
  50. package/index-9dp031by.js +12 -0
  51. package/{index-ne2qy0nk.js → index-ahemdr5n.js} +12 -12
  52. package/{index-ws5e0j51.js → index-as7xmyz8.js} +40 -24
  53. package/index-axzjaqve.js +1118 -0
  54. package/{index-3d9y066c.js → index-bjwxs904.js} +9 -8
  55. package/index-c6eggbee.js +123 -0
  56. package/index-d2242ksy.js +99 -0
  57. package/{index-a64esmtb.js → index-ddxvdd1p.js} +169 -305
  58. package/{index-92zztqy1.js → index-dy0jx9ay.js} +2 -17
  59. package/{index-pnqbkf5p.js → index-dzf3r49a.js} +6 -2
  60. package/{index-w8kmx1b6.js → index-fgq75haa.js} +198 -290
  61. package/{index-by5gpp8x.js → index-hj6w4ka1.js} +2 -1
  62. package/{index-hwkygn9s.js → index-khpfpcsd.js} +302 -33
  63. package/{index-wt7qrtd4.js → index-mxav6j3c.js} +93 -232
  64. package/{index-gyd220p2.js → index-myhc3c1j.js} +554 -577
  65. package/{index-600zhnve.js → index-nv5976x3.js} +56 -197
  66. package/index-p6pbz9n5.js +25 -0
  67. package/{index-4edzf1gr.js → index-przybvy5.js} +77 -150
  68. package/index-smme4r47.js +49 -0
  69. package/{index-mak3cd28.js → index-w2zdcw3k.js} +137 -255
  70. package/index-wa5jbxj1.js +760 -0
  71. package/{index-v0qh106m.js → index-ww4z397j.js} +527 -723
  72. package/{index-j9yhg404.js → index-xqjwd384.js} +4 -7
  73. package/{index-7737gxcp.js → index-xqpzbab5.js} +107 -241
  74. package/index-xsjh6nzh.js +2729 -0
  75. package/{index-ktb5njgy.js → index-ygn77a5w.js} +47 -99
  76. package/index-ztp3e73t.js +700 -0
  77. package/index.js +23 -22
  78. package/{library.command-nbsky672.js → library.command-1gx04jgn.js} +4 -5
  79. package/{localRegistry.command-yeq57wjr.js → localRegistry.command-zndxj1q6.js} +22 -42
  80. package/{module.command-29vqzrh8.js → module.command-3waddk95.js} +8 -11
  81. package/{package.command-axv0abmn.js → package.command-zrc7br1y.js} +6 -7
  82. package/package.json +14 -5
  83. package/{page.command-vs9s3zrh.js → page.command-vpjgardh.js} +4 -5
  84. package/{primitive.command-cbxmqbtc.js → primitive.command-sz84tk4t.js} +9 -22
  85. package/prompter-ptaa3nk0.js +8 -0
  86. package/{quality.command-gmbs7nws.js → quality.command-g869hafs.js} +203 -376
  87. package/{recipeScanner-fpagtgc1.js → recipeScanner-4b69ybe0.js} +1 -1
  88. package/{repair.command-bqsjptsj.js → repair.command-chsnjvvv.js} +11 -35
  89. package/{routeSourceValidator-apyqw7wk.js → routeSourceValidator-7ycnfz0e.js} +0 -6
  90. package/{scalar.command-6k1vhe9s.js → scalar.command-2v21newx.js} +7 -10
  91. package/skills/akan-code/SKILL.md +130 -0
  92. package/skills/akan-debug/SKILL.md +42 -0
  93. package/skills/akan-deps/SKILL.md +50 -0
  94. package/skills/akan-err/SKILL.md +39 -0
  95. package/skills/akan-module/SKILL.md +45 -0
  96. package/skills/akan-scaffold/SKILL.md +76 -0
  97. package/skills/akan-scalar/SKILL.md +52 -0
  98. package/skills/akan-service/SKILL.md +34 -0
  99. package/skills/akan-store/SKILL.md +67 -0
  100. package/skills/akan-ui/SKILL.md +63 -0
  101. package/skills/akan-validate/SKILL.md +44 -0
  102. package/{subspace.command-fwjfcts7.js → subspace.command-ckcbwfp1.js} +138 -67
  103. package/templates/__scalar/__model__/__model__.abstract.md.template +8 -0
  104. package/templates/appSample/lib/__scalar/workHistory/workHistory.abstract.ts +8 -39
  105. package/templates/appSample/lib/_noti/noti.abstract.ts +6 -29
  106. package/templates/appSample/lib/task/task.abstract.ts +12 -32
  107. package/templates/appSample/lib/task/task.signal.spec.ts +15 -18
  108. package/templates/appSample/lib/task/task.signal.test.ts +15 -1
  109. package/templates/appSample/lib/task/task.signal.ts +1 -1
  110. package/templates/appSample/srvkit/{AuthGuard.ts → guards.ts} +7 -4
  111. package/templates/appSample/srvkit/{SessionInternalArg.ts → internalArgs.ts} +6 -4
  112. package/templates/client.ts +7 -30
  113. package/templates/crudPages/[__model__Id]/edit/page.tsx +2 -1
  114. package/templates/crudPages/[__model__Id]/page.tsx +2 -1
  115. package/templates/crudPages/new/page.tsx +2 -1
  116. package/templates/crudPages/page.tsx +2 -1
  117. package/templates/crudSinglePage/page.tsx +2 -1
  118. package/templates/lib/__lib/lib.dictionary.ts +0 -2
  119. package/templates/lib/__lib/lib.document.ts +0 -2
  120. package/templates/lib/sig.ts +8 -30
  121. package/templates/localDev/docker-compose.yaml.template +3 -14
  122. package/templates/module/__model__.signal.ts +12 -4
  123. package/templates/pkgRoot/tsconfig.json.template +2 -7
  124. package/templates/server.ts +0 -2
  125. package/templates/service/__model__.abstract.md.template +8 -0
  126. package/tunnel.command-kd2yr4fx.js +129 -0
  127. package/{typeChecker-3xgrzc2v.js → typeChecker-px49mezc.js} +1 -1
  128. package/typecheck.proc.js +1 -1
  129. package/workflow.command-44252cqv.js +79 -0
  130. package/{workspace.command-8s050m0h.js → workspace.command-fqcztt5p.js} +77 -109
  131. package/abstractCompactor-mjh5ppsq.js +0 -101
  132. package/cloud.command-jshwdq22.js +0 -93
  133. package/context.command-ez8a0zyz.js +0 -80
  134. package/devTuiView-c08ccbat.js +0 -9
  135. package/getDirname-dr3jz1xg.js +0 -7
  136. package/guideline.command-xmqwx8zm.js +0 -359
  137. package/guidelines/agentRule/agentRule.generate.json +0 -31
  138. package/guidelines/componentRule/componentRule.generate.json +0 -31
  139. package/guidelines/conventions/conventions.generate.json +0 -25
  140. package/guidelines/cssRule/cssRule.generate.json +0 -31
  141. package/guidelines/docPageRule/docPageRule.generate.json +0 -31
  142. package/guidelines/docPageRule/docPageRule.instruction.md +0 -25
  143. package/guidelines/docSyncRule/docSyncRule.generate.json +0 -31
  144. package/guidelines/docSyncRule/docSyncRule.instruction.md +0 -25
  145. package/guidelines/enumConstant/enumConstant.generate.json +0 -31
  146. package/guidelines/enumConstant/enumConstant.instruction.md +0 -28
  147. package/guidelines/fieldRule/fieldRule.generate.json +0 -31
  148. package/guidelines/framework/framework.generate.json +0 -32
  149. package/guidelines/mcpRule/mcpRule.generate.json +0 -35
  150. package/guidelines/modelConstant/modelConstant.generate.json +0 -32
  151. package/guidelines/modelDictionary/modelDictionary.generate.json +0 -32
  152. package/guidelines/modelDocument/modelDocument.generate.json +0 -31
  153. package/guidelines/modelService/modelService.generate.json +0 -31
  154. package/guidelines/modelSignal/modelSignal.generate.json +0 -31
  155. package/guidelines/modelStore/modelStore.generate.json +0 -31
  156. package/guidelines/modelTemplate/modelTemplate.generate.json +0 -31
  157. package/guidelines/modelUnit/modelUnit.generate.json +0 -31
  158. package/guidelines/modelUtil/modelUtil.generate.json +0 -31
  159. package/guidelines/modelView/modelView.generate.json +0 -31
  160. package/guidelines/modelZone/modelZone.generate.json +0 -31
  161. package/guidelines/moduleCodegen/moduleCodegen.generate.json +0 -31
  162. package/guidelines/moduleCodegen/moduleCodegen.instruction.md +0 -28
  163. package/guidelines/moduleOverview/moduleOverview.generate.json +0 -31
  164. package/guidelines/queryRule/queryRule.generate.json +0 -31
  165. package/guidelines/recipeRule/recipeRule.generate.json +0 -31
  166. package/guidelines/runtimeRule/runtimeRule.generate.json +0 -25
  167. package/guidelines/scalarConstant/scalarConstant.generate.json +0 -32
  168. package/guidelines/scalarDictionary/scalarDictionary.generate.json +0 -32
  169. package/guidelines/scalarModule/scalarModule.generate.json +0 -31
  170. package/guidelines/sharedUiUsage/sharedUiUsage.generate.json +0 -31
  171. package/guidelines/sharedUiUsage/sharedUiUsage.instruction.md +0 -25
  172. package/guidelines/ssrRule/ssrRule.generate.json +0 -31
  173. package/guidelines/transportRule/transportRule.generate.json +0 -31
  174. package/guidelines/utilUiUsage/utilUiUsage.generate.json +0 -31
  175. package/guidelines/utilUiUsage/utilUiUsage.instruction.md +0 -25
  176. package/guidelines/workspaceOnboarding/workspaceOnboarding.generate.json +0 -24
  177. package/guidelines/workspaceRecipes/workspaceRecipes.generate.json +0 -33
  178. package/index-2hq52jq3.js +0 -465
  179. package/index-6wwzs1bc.js +0 -7
  180. package/index-8pm30m73.js +0 -841
  181. package/index-kn1h7p1x.js +0 -560
  182. package/index-meh558jy.js +0 -65
  183. package/index-rwg2aa4f.js +0 -229
  184. package/templates/__scalar/__model__/__model__.abstract.md +0 -28
  185. package/templates/module/__model__.abstract.md +0 -28
  186. package/templates/service/__model__.abstract.md +0 -28
  187. package/workflow.command-nwpcdc8p.js +0 -107
@@ -1,9 +1,12 @@
1
1
  // @bun
2
2
  // pkgs/@akanjs/devkit/fileSys.ts
3
3
  import { lstat, rename, rm, stat } from "fs/promises";
4
+ import nodePath from "path";
5
+ import { fileURLToPath } from "url";
4
6
  import { Logger } from "akanjs/common";
7
+ var getDirname2 = (url) => nodePath.dirname(fileURLToPath(url));
5
8
 
6
- class FileSys {
9
+ class FileSys2 {
7
10
  static logger = new Logger("FileSys");
8
11
  static async fileExists(path) {
9
12
  return await Bun.file(path).exists();
@@ -24,7 +27,7 @@ class FileSys {
24
27
  try {
25
28
  return await Bun.file(path).json();
26
29
  } catch (error) {
27
- FileSys.logger.error(`Failed to read JSON file: ${path}`);
30
+ FileSys2.logger.error(`Failed to read JSON file: ${path}`);
28
31
  throw error;
29
32
  }
30
33
  }
@@ -52,4 +55,4 @@ class FileSys {
52
55
  }
53
56
  }
54
57
 
55
- export { FileSys };
58
+ export { getDirname2, FileSys2 };
@@ -1,5 +1,6 @@
1
1
  // @bun
2
2
  // pkgs/@akanjs/devkit/mobile/mobileTarget.ts
3
+ var trimSlashes = (value) => value.replace(/^\/+|\/+$/g, "");
3
4
  var getMobileTargets = async (app) => {
4
5
  const config = await app.getConfig();
5
6
  return Object.entries(config.mobile.targets).map(([name, target]) => ({ name, config: target }));
@@ -9,12 +10,11 @@ var getMobileTargetChoices = async (app) => {
9
10
  const targetNames = Object.keys(config.mobile.targets);
10
11
  if (targetNames.length > 0)
11
12
  return targetNames;
12
- const basePaths = [...config.basePaths];
13
- return basePaths;
13
+ return [...config.basePaths];
14
14
  };
15
15
  var resolveMobileTargetByBasePath = (targets, basePath) => {
16
- const normalizedBasePath = basePath.replace(/^\/+|\/+$/g, "");
17
- const byBasePath = targets.find((target) => target.config.basePath?.replace(/^\/+|\/+$/g, "") === normalizedBasePath);
16
+ const normalizedBasePath = trimSlashes(basePath);
17
+ const byBasePath = targets.find(({ config }) => config.basePath !== undefined && trimSlashes(config.basePath) === normalizedBasePath);
18
18
  if (byBasePath)
19
19
  return byBasePath;
20
20
  const [template] = targets;
@@ -22,11 +22,7 @@ var resolveMobileTargetByBasePath = (targets, basePath) => {
22
22
  return;
23
23
  return {
24
24
  name: normalizedBasePath,
25
- config: {
26
- ...template.config,
27
- name: normalizedBasePath,
28
- basePath: normalizedBasePath
29
- }
25
+ config: { ...template.config, name: normalizedBasePath, basePath: normalizedBasePath }
30
26
  };
31
27
  };
32
28
  var resolveMobileTargets = async (app, selection) => {
@@ -58,13 +54,13 @@ var resolveMobileTargets = async (app, selection) => {
58
54
  if (target)
59
55
  return [target];
60
56
  const basePathTarget = resolveMobileTargetByBasePath(targets, selection);
61
- if (basePathTarget && config.basePaths.has(selection.replace(/^\/+|\/+$/g, "")))
57
+ if (basePathTarget && config.basePaths.has(trimSlashes(selection)))
62
58
  return [basePathTarget];
63
59
  const choices = await getMobileTargetChoices(app);
64
60
  throw new Error(`Mobile target '${selection}' was not found. Available: ${choices.join(", ")}`);
65
61
  };
66
62
  var resolveMobilePath = (target, pathname) => {
67
- const basePath = target.basePath?.replace(/^\/+|\/+$/g, "");
63
+ const basePath = trimSlashes(target.basePath ?? "");
68
64
  const normalizedPath = `/${pathname.replace(/^\/+/, "")}`;
69
65
  if (!basePath)
70
66
  return normalizedPath;
@@ -72,5 +68,8 @@ var resolveMobilePath = (target, pathname) => {
72
68
  return normalizedPath;
73
69
  return `/${basePath}${normalizedPath === "/" ? "" : normalizedPath}`;
74
70
  };
75
- var targetHtmlFilename = (target) => target.basePath?.replace(/^\/+|\/+$/g, "") ? `${target.basePath.replace(/^\/+|\/+$/g, "")}.html` : "index.html";
71
+ var targetHtmlFilename = (target) => {
72
+ const basePath = trimSlashes(target.basePath ?? "");
73
+ return basePath ? `${basePath}.html` : "index.html";
74
+ };
76
75
  export { getMobileTargets, getMobileTargetChoices, resolveMobileTargets, resolveMobilePath, targetHtmlFilename };
@@ -2,23 +2,21 @@
2
2
  import {
3
3
  runner,
4
4
  script
5
- } from "./index-mak3cd28.js";
5
+ } from "./index-w2zdcw3k.js";
6
6
  import {
7
7
  LibExecutor
8
- } from "./index-2tv3fdx4.js";
8
+ } from "./index-9d9bgcx4.js";
9
9
  import {
10
10
  LibSource,
11
11
  formatLibStatuses
12
- } from "./index-3d9y066c.js";
12
+ } from "./index-bjwxs904.js";
13
13
 
14
14
  // pkgs/@akanjs/cli/library/library.script.ts
15
15
  import { Logger } from "akanjs/common";
16
16
 
17
17
  // pkgs/@akanjs/devkit/semver.ts
18
18
  var stripRangeOperator = (version) => version.replace(/^[\s^~>=<v]+/, "").trim();
19
- var parseVersion = (version) => {
20
- return version.replace(/^[^\d]*/, "").split(/[.-]/).map((part) => Number.parseInt(part, 10)).map((part) => Number.isFinite(part) ? part : 0);
21
- };
19
+ var parseVersion = (version) => version.replace(/^[^\d]*/, "").split(/[.-]/).map((part) => Number.parseInt(part, 10)).map((part) => Number.isFinite(part) ? part : 0);
22
20
  var compareNumeric = (a, b) => {
23
21
  const left = parseVersion(a);
24
22
  const right = parseVersion(b);
@@ -44,8 +42,7 @@ class LibraryRunner extends runner("library") {
44
42
  async createLibrary(libName, workspace) {
45
43
  await workspace.mkdir(`libs/${libName}`);
46
44
  await workspace.applyTemplate({ basePath: `libs/${libName}`, template: "libRoot", dict: { libName } });
47
- const lib = LibExecutor.from(workspace, libName);
48
- return lib;
45
+ return LibExecutor.from(workspace, libName);
49
46
  }
50
47
  async removeLibrary(lib) {
51
48
  await lib.workspace.removeDir(`libs/${lib.name}`);
@@ -0,0 +1,6 @@
1
+ // @bun
2
+ // pkgs/@akanjs/devkit/stripAnsi.ts
3
+ var ansi = new RegExp(`${String.fromCharCode(27)}(?:[@-Z\\\\-_]|\\[[\\s\\S]*?[@-~])`, "g");
4
+ var stripAnsi = (text) => text.replace(ansi, "");
5
+
6
+ export { stripAnsi };
@@ -0,0 +1,187 @@
1
+ // @bun
2
+ import {
3
+ runner,
4
+ script
5
+ } from "./index-w2zdcw3k.js";
6
+ import {
7
+ ModuleExecutor
8
+ } from "./index-9d9bgcx4.js";
9
+ import {
10
+ sourceFile,
11
+ moduleSourcePaths,
12
+ generatedFilesForSync,
13
+ createPassedPrimitiveReport,
14
+ bilingualLabelForField,
15
+ bilingualDescriptionForField
16
+ } from "./index-myhc3c1j.js";
17
+ import {
18
+ PageScript
19
+ } from "./index-dzf3r49a.js";
20
+ import {
21
+ pluralizeName
22
+ } from "./index-nz8prx9g.js";
23
+
24
+ // pkgs/@akanjs/cli/module/module.script.ts
25
+ import { capitalize as capitalize2 } from "akanjs/common";
26
+
27
+ // pkgs/@akanjs/cli/module/module.runner.ts
28
+ import { capitalize } from "akanjs/common";
29
+ var purposeByModule = {
30
+ budget: "Budget represents planned or actual money allocated inside the app.",
31
+ project: "Project represents a project workspace or business initiative managed by the app.",
32
+ task: "Task represents work items that move through the app workflow."
33
+ };
34
+ var moduleAbstractContent = (moduleName, sharedGuards) => {
35
+ const title = capitalize(moduleName);
36
+ const noun = bilingualLabelForField(moduleName).en.toLowerCase();
37
+ const purpose = purposeByModule[moduleName] ?? `${title} represents ${noun} records managed by the app.`;
38
+ const writeRule = sharedGuards ? `Anyone may read a ${noun}; only an admin creates, updates or removes one.` : `Anyone may read a ${noun}; nobody creates, updates or removes one until the slice names a guard.`;
39
+ return `# ${moduleName} Abstract
40
+ ${purpose}
41
+
42
+ ## Rules
43
+ - ${writeRule}
44
+ - Removal is soft: a removed ${noun} keeps its row with \`removedAt\` set.
45
+ `;
46
+ };
47
+ var moduleFileKeys = [
48
+ "abstract",
49
+ "constant",
50
+ "dictionary",
51
+ "service",
52
+ "store",
53
+ "signal",
54
+ "unit",
55
+ "view",
56
+ "template",
57
+ "zone",
58
+ "util"
59
+ ];
60
+
61
+ class ModuleRunner extends runner("module") {
62
+ async createService(module) {
63
+ const serviceName = module.name.replace(/^_+/, "");
64
+ await module.applyTemplate({
65
+ basePath: `.`,
66
+ template: "service",
67
+ dict: { model: serviceName, sysName: module.sys.name }
68
+ });
69
+ return await this.#readFiles(module, {
70
+ abstract: `${serviceName}.abstract.md`,
71
+ dictionary: `${serviceName}.dictionary.ts`,
72
+ service: `${serviceName}.service.ts`,
73
+ signal: `${serviceName}.signal.ts`,
74
+ store: `${serviceName}.store.ts`
75
+ });
76
+ }
77
+ async#readFiles(module, filenames) {
78
+ const files = await Promise.all(Object.entries(filenames).map(async ([key, filename]) => [
79
+ key,
80
+ { filename, content: await module.readFile(filename) }
81
+ ]));
82
+ return Object.fromEntries(files);
83
+ }
84
+ async removeModule(module) {
85
+ await module.sys.removeDir(`lib/${module.name}`);
86
+ }
87
+ async#hasSharedGuards(module) {
88
+ const { sys } = module;
89
+ if (sys.type === "lib" && sys.name === "shared")
90
+ return true;
91
+ if (!await sys.exists("lib/srv.ts"))
92
+ return false;
93
+ return (await sys.readFile("lib/srv.ts")).includes('"@libs/shared/lib/srv"');
94
+ }
95
+ async createComponentTemplate(module, type) {
96
+ await module.sys.applyTemplate({
97
+ basePath: `./lib/${module.name}`,
98
+ template: `module/__Model__.${capitalize(type)}.tsx`,
99
+ dict: { model: module.name, sysName: module.sys.name, sysType: module.sys.type }
100
+ });
101
+ return {
102
+ component: {
103
+ filename: `${capitalize(module.name)}.${capitalize(type)}.tsx`,
104
+ content: await module.sys.readFile(`lib/${module.name}/${capitalize(module.name)}.${capitalize(type)}.tsx`)
105
+ }
106
+ };
107
+ }
108
+ async createModuleTemplate(module) {
109
+ const names = pluralizeName(module.name);
110
+ const modelLabel = bilingualLabelForField(module.name);
111
+ const modelDescription = bilingualDescriptionForField(module.name);
112
+ const paths = moduleSourcePaths(module.name);
113
+ const filenames = Object.fromEntries(moduleFileKeys.map((key) => [key, paths[key].replace(`lib/${module.name}/`, "")]));
114
+ const sharedGuards = await this.#hasSharedGuards(module);
115
+ await module.applyTemplate({
116
+ basePath: `.`,
117
+ template: "module",
118
+ options: { sharedGuards },
119
+ dict: {
120
+ model: module.name,
121
+ models: names,
122
+ sysName: module.sys.name,
123
+ sysType: module.sys.type,
124
+ modelLabelEn: modelLabel.en,
125
+ modelLabelKo: modelLabel.ko,
126
+ modelDescEn: modelDescription.en,
127
+ modelDescKo: modelDescription.ko
128
+ }
129
+ });
130
+ await module.writeFile(filenames.abstract, moduleAbstractContent(module.name, sharedGuards));
131
+ return await this.#readFiles(module, filenames);
132
+ }
133
+ }
134
+
135
+ // pkgs/@akanjs/cli/module/module.script.ts
136
+ var moduleChangedFiles = (sys, moduleName, files) => Object.values(files).map((file) => sourceFile(sys, `lib/${moduleName}/${file.filename}`, "create", "Module source file was created."));
137
+
138
+ class ModuleScript extends script("module", [ModuleRunner, PageScript]) {
139
+ async createModuleTemplate(sys, name, { page = false } = {}) {
140
+ const mod = ModuleExecutor.from(sys, name);
141
+ const files = await this.moduleRunner.createModuleTemplate(mod);
142
+ if (page && sys.type === "app")
143
+ await this.pageScript.createCrudPage(mod, { app: sys, basePath: null, single: false });
144
+ await sys.scan();
145
+ return createPassedPrimitiveReport({
146
+ command: "create-module",
147
+ changedFiles: moduleChangedFiles(sys, name, files),
148
+ generatedFiles: generatedFilesForSync(sys, "Generated files were refreshed after module creation."),
149
+ target: sys.name
150
+ });
151
+ }
152
+ async removeModule(mod) {
153
+ await this.moduleRunner.removeModule(mod);
154
+ }
155
+ async createService(sys, name) {
156
+ const service = ModuleExecutor.from(sys, `_${name}`);
157
+ const files = await this.moduleRunner.createService(service);
158
+ await sys.scan();
159
+ return createPassedPrimitiveReport({
160
+ command: "create-service",
161
+ changedFiles: moduleChangedFiles(sys, `_${name}`, files),
162
+ generatedFiles: generatedFilesForSync(sys, "Generated files were refreshed after service creation."),
163
+ target: sys.name
164
+ });
165
+ }
166
+ async createTemplate(mod) {
167
+ return await this.#createComponent(mod, "template");
168
+ }
169
+ async createUnit(mod) {
170
+ return await this.#createComponent(mod, "unit");
171
+ }
172
+ async createView(mod) {
173
+ return await this.#createComponent(mod, "view");
174
+ }
175
+ async#createComponent(mod, type) {
176
+ const { component } = await this.moduleRunner.createComponentTemplate(mod, type);
177
+ return createPassedPrimitiveReport({
178
+ command: `create-${type}`,
179
+ changedFiles: [
180
+ sourceFile(mod.sys, `lib/${mod.name}/${component.filename}`, "create", `${capitalize2(type)} UI source was created.`)
181
+ ],
182
+ target: mod.sys.name
183
+ });
184
+ }
185
+ }
186
+
187
+ export { ModuleScript };
@@ -1,44 +1,33 @@
1
1
  // @bun
2
2
  import {
3
3
  GlobalConfig,
4
- CloudApi,
5
- AiSession
6
- } from "./index-kn1h7p1x.js";
7
- import {
8
- PkgExecutor
9
- } from "./index-2tv3fdx4.js";
4
+ CloudApi
5
+ } from "./index-22d57v4c.js";
10
6
  import {
11
7
  script
12
- } from "./index-mak3cd28.js";
8
+ } from "./index-w2zdcw3k.js";
9
+ import {
10
+ PkgExecutor
11
+ } from "./index-9d9bgcx4.js";
13
12
  import {
14
13
  ApplicationScript
15
- } from "./index-v0qh106m.js";
14
+ } from "./index-ww4z397j.js";
16
15
  import {
17
16
  PackageScript
18
- } from "./index-ws5e0j51.js";
17
+ } from "./index-as7xmyz8.js";
19
18
  import {
20
19
  CloudRunner
21
- } from "./index-2hq52jq3.js";
20
+ } from "./index-axzjaqve.js";
22
21
 
23
22
  // pkgs/@akanjs/cli/cloud/cloud.script.ts
24
23
  import { Logger } from "akanjs/common";
25
- class CloudScript extends script("cloud", [CloudRunner, ApplicationScript, PackageScript]) {
24
+ class CloudScript2 extends script("cloud", [CloudRunner, ApplicationScript, PackageScript]) {
26
25
  async login(workspace, host = GlobalConfig.akanCloudHost) {
27
26
  await this.cloudRunner.login(host, workspace);
28
27
  }
29
28
  async logout(workspace, host = GlobalConfig.akanCloudHost) {
30
29
  await this.cloudRunner.logout(host);
31
30
  }
32
- async setLlm(workspace) {
33
- await this.cloudRunner.setLlm();
34
- }
35
- resetLlm(workspace) {
36
- this.cloudRunner.resetLlm();
37
- }
38
- async ask(question, workspace) {
39
- const session = new AiSession("general", { workspace, isContinued: true });
40
- await session.ask(question);
41
- }
42
31
  async downloadEnv(workspace, workspaceId = workspace.getWorkspaceId({ allowEmpty: true }), { host = GlobalConfig.akanCloudHost } = {}) {
43
32
  if (workspaceId) {
44
33
  await this.login(workspace, host);
@@ -48,29 +37,61 @@ class CloudScript extends script("cloud", [CloudRunner, ApplicationScript, Packa
48
37
  }
49
38
  await this.cloudRunner.downloadEnvByScp(workspace);
50
39
  }
51
- async uploadEnv(workspace, { host = GlobalConfig.akanCloudHost } = {}) {
52
- const workspaceId = workspace.getWorkspaceId({ allowEmpty: true });
53
- const { path } = await this.cloudRunner.gatherEnvFiles(workspace);
40
+ async uploadEnv(workspace, {
41
+ host = GlobalConfig.akanCloudHost,
42
+ workspaceId = workspace.getWorkspaceId({ allowEmpty: true }),
43
+ scope,
44
+ archivePath
45
+ } = {}) {
46
+ if (scope && !workspaceId)
47
+ throw new Error("A scoped env upload needs a cloud workspace id \u2014 the scp target is workspace-wide.");
48
+ const { files, path } = await this.cloudRunner.gatherEnvFiles(workspace, { scope, archivePath });
54
49
  if (workspaceId) {
55
50
  await this.login(workspace, host);
56
51
  const cloudApi = await CloudApi.fromHost(workspace, host);
57
52
  await this.cloudRunner.uploadEnv(cloudApi, workspaceId, path);
58
- return;
53
+ return { workspaceId, files };
59
54
  }
60
55
  await this.cloudRunner.uploadEnvByScp(workspace, path);
56
+ return { workspaceId: null, files };
61
57
  }
62
- async deployAkan(workspace, { test = true, registryUrl } = {}) {
58
+ async deployAkan(workspace, {
59
+ test = true,
60
+ registryUrl,
61
+ platforms = []
62
+ } = {}) {
63
63
  const akanPkgs = await this.cloudRunner.getAkanPkgs(workspace);
64
64
  await this.packageScript.updateWorskpaceRootPackageJson(workspace);
65
65
  const pkgs = akanPkgs.map((pkgName) => PkgExecutor.from(workspace, pkgName));
66
- if (test)
67
- for (const pkg of pkgs)
68
- await this.applicationScript.test(pkg);
66
+ if (test) {
67
+ const platformRun = platforms.length ? await this.cloudRunner.startPlatformTests(workspace, platforms, akanPkgs) : null;
68
+ let localFailure = null;
69
+ try {
70
+ for (const pkg of pkgs)
71
+ await this.applicationScript.test(pkg);
72
+ } catch (error) {
73
+ localFailure = error;
74
+ }
75
+ if (platformRun)
76
+ await this.cloudRunner.settlePlatformTests(platformRun, {
77
+ interactive: !localFailure,
78
+ recordStreaks: !localFailure,
79
+ checkDrift: true
80
+ });
81
+ if (localFailure)
82
+ throw localFailure;
83
+ }
69
84
  for (const pkg of pkgs)
70
85
  await this.packageScript.buildPackage(pkg);
71
86
  await this.packageScript.verifyAkanPublishPackages(workspace);
72
87
  await this.cloudRunner.deployAkan(workspace, akanPkgs, { registryUrl });
73
88
  }
89
+ async testPlatforms(workspace, { platforms, pkgs }) {
90
+ if (!platforms.length)
91
+ throw new Error("No platform to test on \u2014 pass --platforms linux,windows");
92
+ const run = await this.cloudRunner.startPlatformTests(workspace, platforms, pkgs ?? await this.cloudRunner.getAkanPkgs(workspace));
93
+ await this.cloudRunner.settlePlatformTests(run, { interactive: false, recordStreaks: false, checkDrift: false });
94
+ }
74
95
  async update(workspace, tag = "latest", { registryUrl } = {}) {
75
96
  const spinner = workspace.spinning("Updating Akan.js packages and CLI...");
76
97
  await this.cloudRunner.update(workspace, tag, { registryUrl });
@@ -80,4 +101,4 @@ class CloudScript extends script("cloud", [CloudRunner, ApplicationScript, Packa
80
101
  }
81
102
  }
82
103
 
83
- export { CloudScript };
104
+ export { CloudScript2 };