@akanjs/cli 3.0.0-beta.1 → 3.0.0-beta.11

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 (60) hide show
  1. package/.build-stamp +1 -1
  2. package/TunnelShare-sbsaggmb.js +9 -0
  3. package/{abstractCompactor-mjh5ppsq.js → abstractCompactor-bqh31fk5.js} +2 -1
  4. package/{agent.command-d2gfxfck.js → agent.command-7357vxd8.js} +5 -5
  5. package/{application.command-pj2m7584.js → application.command-pc8mdn3w.js} +10 -10
  6. package/{applicationBuildRunner-kxwbssgn.js → applicationBuildRunner-4f1wrba0.js} +2 -2
  7. package/{applicationReleasePackager-4yasxwv9.js → applicationReleasePackager-jkjmy5ee.js} +1 -1
  8. package/buildBatch.proc.js +2 -2
  9. package/{capacitorApp-36rbr858.js → capacitorApp-hqvsrec4.js} +2 -2
  10. package/{cloud.command-jshwdq22.js → cloud.command-cawrd5nq.js} +12 -11
  11. package/cloud.script-1bmptvw0.js +20 -0
  12. package/commandManifest.json +1 -1
  13. package/{context.command-ez8a0zyz.js → context.command-982b6kdp.js} +14 -13
  14. package/{devTui-40ggmd99.js → devTui-hmteztv3.js} +4 -24
  15. package/{devTuiView-c08ccbat.js → devTuiView-40jvjnyz.js} +1 -1
  16. package/{guideline.command-xmqwx8zm.js → guideline.command-jn0vwszx.js} +4 -3
  17. package/guidelines/agentRule/agentRule.instruction.md +109 -4
  18. package/guidelines/conventions/conventions.instruction.md +19 -0
  19. package/guidelines/fieldRule/fieldRule.instruction.md +1 -0
  20. package/guidelines/transportRule/transportRule.instruction.md +49 -0
  21. package/incrementalBuilder.proc.js +1 -1
  22. package/{index-ktb5njgy.js → index-15r9a10e.js} +2 -2
  23. package/{index-259dsnz3.js → index-1nwxbr2y.js} +2 -2
  24. package/{index-600zhnve.js → index-3pvkjza8.js} +10 -10
  25. package/{index-2tv3fdx4.js → index-5nyznra1.js} +1 -0
  26. package/{index-wt7qrtd4.js → index-7f4dsf9v.js} +1 -1
  27. package/{index-7737gxcp.js → index-8pkvrcv1.js} +3 -3
  28. package/{index-2hq52jq3.js → index-8tfmh0v6.js} +25 -19
  29. package/{index-zry5nz81.js → index-ay8wj00x.js} +23 -14
  30. package/{index-mak3cd28.js → index-b3ae16mg.js} +25 -25
  31. package/index-bw2marpf.js +237 -0
  32. package/{index-rwg2aa4f.js → index-ceph7zqj.js} +3 -3
  33. package/{index-fz5q3gd7.js → index-em4swemt.js} +3 -3
  34. package/{index-8pm30m73.js → index-fr2x3qvv.js} +7 -7
  35. package/index-jcekapz4.js +49 -0
  36. package/{index-gyd220p2.js → index-jwjaf9fy.js} +1 -1
  37. package/{index-4edzf1gr.js → index-kbsach1y.js} +4 -4
  38. package/index-p6pbz9n5.js +25 -0
  39. package/{index-v0qh106m.js → index-r8bd61d9.js} +46 -11
  40. package/{index-ne2qy0nk.js → index-s3fvrydw.js} +3 -3
  41. package/{index-pnqbkf5p.js → index-sh88vtye.js} +1 -1
  42. package/{index-ws5e0j51.js → index-t8gvwcrx.js} +2 -2
  43. package/{index-a64esmtb.js → index-vrwdx0zx.js} +1 -1
  44. package/{index-kn1h7p1x.js → index-yc1keaer.js} +4 -226
  45. package/{index-j9yhg404.js → index-ys7dvdb3.js} +1 -1
  46. package/index.js +20 -19
  47. package/{library.command-nbsky672.js → library.command-1f9h2ex6.js} +3 -3
  48. package/{localRegistry.command-yeq57wjr.js → localRegistry.command-rx758ajg.js} +9 -8
  49. package/{module.command-29vqzrh8.js → module.command-c2eve036.js} +7 -6
  50. package/{package.command-axv0abmn.js → package.command-y2rh4np7.js} +3 -3
  51. package/package.json +2 -2
  52. package/{page.command-vs9s3zrh.js → page.command-e5h29fyt.js} +3 -3
  53. package/{primitive.command-cbxmqbtc.js → primitive.command-c44f7z1s.js} +8 -7
  54. package/{quality.command-gmbs7nws.js → quality.command-5evdd263.js} +2 -2
  55. package/{repair.command-bqsjptsj.js → repair.command-c2amvt74.js} +5 -5
  56. package/{scalar.command-6k1vhe9s.js → scalar.command-xyzerygj.js} +6 -5
  57. package/{subspace.command-fwjfcts7.js → subspace.command-ebfwzypw.js} +92 -12
  58. package/tunnel.command-v6a7at16.js +130 -0
  59. package/{workflow.command-nwpcdc8p.js → workflow.command-t174m6sy.js} +11 -10
  60. package/{workspace.command-8s050m0h.js → workspace.command-bg3eveth.js} +23 -22
@@ -3,18 +3,19 @@ import {
3
3
  Sys,
4
4
  Module,
5
5
  command
6
- } from "./index-mak3cd28.js";
6
+ } from "./index-b3ae16mg.js";
7
7
  import"./index-q0y2jq9j.js";
8
- import"./index-2tv3fdx4.js";
8
+ import"./index-5nyznra1.js";
9
9
  import"./index-6wwzs1bc.js";
10
10
  import {
11
11
  renderPrimitiveReport
12
- } from "./index-gyd220p2.js";
13
- import"./index-kn1h7p1x.js";
12
+ } from "./index-jwjaf9fy.js";
13
+ import"./index-bw2marpf.js";
14
+ import"./index-yc1keaer.js";
14
15
  import {
15
16
  ModuleScript
16
- } from "./index-8pm30m73.js";
17
- import"./index-pnqbkf5p.js";
17
+ } from "./index-fr2x3qvv.js";
18
+ import"./index-sh88vtye.js";
18
19
  import"./index-h7yw2z9n.js";
19
20
 
20
21
  // pkgs/@akanjs/cli/module/module.command.ts
@@ -3,14 +3,14 @@ import {
3
3
  Pkg,
4
4
  Workspace,
5
5
  command
6
- } from "./index-mak3cd28.js";
6
+ } from "./index-b3ae16mg.js";
7
7
  import"./index-q0y2jq9j.js";
8
- import"./index-2tv3fdx4.js";
8
+ import"./index-5nyznra1.js";
9
9
  import"./index-6wwzs1bc.js";
10
10
  import"./index-kcxmv48c.js";
11
11
  import {
12
12
  PackageScript
13
- } from "./index-ws5e0j51.js";
13
+ } from "./index-t8gvwcrx.js";
14
14
 
15
15
  // pkgs/@akanjs/cli/package/package.command.ts
16
16
  class PackageCommand extends command("package", [PackageScript], ({ public: target }) => ({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@akanjs/cli",
3
- "version": "3.0.0-beta.1",
3
+ "version": "3.0.0-beta.11",
4
4
  "sourceType": "module",
5
5
  "type": "module",
6
6
  "publishConfig": {
@@ -33,7 +33,7 @@
33
33
  "@langchain/openai": "^1.4.6",
34
34
  "@tailwindcss/node": "^4.3.0",
35
35
  "@trapezedev/project": "^7.1.4",
36
- "akanjs": "3.0.0-beta.1",
36
+ "akanjs": "3.0.0-beta.11",
37
37
  "chalk": "^5.6.2",
38
38
  "commander": "^14.0.3",
39
39
  "dayjs": "^1.11.20",
@@ -3,13 +3,13 @@ import {
3
3
  App,
4
4
  Module,
5
5
  command
6
- } from "./index-mak3cd28.js";
6
+ } from "./index-b3ae16mg.js";
7
7
  import"./index-q0y2jq9j.js";
8
- import"./index-2tv3fdx4.js";
8
+ import"./index-5nyznra1.js";
9
9
  import"./index-6wwzs1bc.js";
10
10
  import {
11
11
  PageScript
12
- } from "./index-pnqbkf5p.js";
12
+ } from "./index-sh88vtye.js";
13
13
 
14
14
  // pkgs/@akanjs/cli/page/page.command.ts
15
15
  class PageCommand extends command("page", [PageScript], ({ public: target }) => ({
@@ -2,20 +2,21 @@
2
2
  import {
3
3
  Workspace,
4
4
  command
5
- } from "./index-mak3cd28.js";
5
+ } from "./index-b3ae16mg.js";
6
6
  import"./index-q0y2jq9j.js";
7
- import"./index-2tv3fdx4.js";
7
+ import"./index-5nyznra1.js";
8
8
  import"./index-6wwzs1bc.js";
9
9
  import {
10
10
  renderPrimitiveReport
11
- } from "./index-gyd220p2.js";
12
- import"./index-kn1h7p1x.js";
13
- import"./index-8pm30m73.js";
14
- import"./index-pnqbkf5p.js";
11
+ } from "./index-jwjaf9fy.js";
12
+ import"./index-bw2marpf.js";
13
+ import"./index-yc1keaer.js";
14
+ import"./index-fr2x3qvv.js";
15
+ import"./index-sh88vtye.js";
15
16
  import"./index-h7yw2z9n.js";
16
17
  import {
17
18
  PrimitiveScript
18
- } from "./index-4edzf1gr.js";
19
+ } from "./index-kbsach1y.js";
19
20
 
20
21
  // pkgs/@akanjs/cli/primitive/primitive.command.ts
21
22
  import { Logger } from "akanjs/common";
@@ -4,13 +4,13 @@ import {
4
4
  runner,
5
5
  script,
6
6
  command
7
- } from "./index-mak3cd28.js";
7
+ } from "./index-b3ae16mg.js";
8
8
  import"./index-q0y2jq9j.js";
9
9
  import {
10
10
  rootAllowedFiles,
11
11
  rootAllowedDirs,
12
12
  isAllowedLibFacetRootFile
13
- } from "./index-2tv3fdx4.js";
13
+ } from "./index-5nyznra1.js";
14
14
  import"./index-6wwzs1bc.js";
15
15
  import {
16
16
  AbstractDoc
@@ -3,16 +3,16 @@ import {
3
3
  Workspace,
4
4
  script,
5
5
  command
6
- } from "./index-mak3cd28.js";
6
+ } from "./index-b3ae16mg.js";
7
7
  import"./index-q0y2jq9j.js";
8
- import"./index-2tv3fdx4.js";
8
+ import"./index-5nyznra1.js";
9
9
  import"./index-6wwzs1bc.js";
10
10
  import"./index-by5gpp8x.js";
11
- import"./index-gyd220p2.js";
12
- import"./index-ktb5njgy.js";
11
+ import"./index-jwjaf9fy.js";
12
+ import"./index-15r9a10e.js";
13
13
  import {
14
14
  RepairRunner
15
- } from "./index-fz5q3gd7.js";
15
+ } from "./index-em4swemt.js";
16
16
 
17
17
  // pkgs/@akanjs/cli/repair/repair.script.ts
18
18
  import { Logger } from "akanjs/common";
@@ -2,18 +2,19 @@
2
2
  import {
3
3
  Sys,
4
4
  command
5
- } from "./index-mak3cd28.js";
5
+ } from "./index-b3ae16mg.js";
6
6
  import"./index-q0y2jq9j.js";
7
- import"./index-2tv3fdx4.js";
7
+ import"./index-5nyznra1.js";
8
8
  import"./index-6wwzs1bc.js";
9
9
  import {
10
10
  renderPrimitiveReport
11
- } from "./index-gyd220p2.js";
12
- import"./index-kn1h7p1x.js";
11
+ } from "./index-jwjaf9fy.js";
12
+ import"./index-bw2marpf.js";
13
+ import"./index-yc1keaer.js";
13
14
  import"./index-h7yw2z9n.js";
14
15
  import {
15
16
  ScalarScript
16
- } from "./index-rwg2aa4f.js";
17
+ } from "./index-ceph7zqj.js";
17
18
 
18
19
  // pkgs/@akanjs/cli/scalar/scalar.command.ts
19
20
  import { Logger, lowerlize } from "akanjs/common";
@@ -1,22 +1,26 @@
1
1
  // @bun
2
+ import {
3
+ FileSys
4
+ } from "./index-q0y2jq9j.js";
5
+ import {
6
+ GlobalConfig
7
+ } from "./index-bw2marpf.js";
2
8
  import {
3
9
  Workspace,
10
+ CommandContainer,
4
11
  runner,
5
12
  script,
6
13
  command
7
- } from "./index-mak3cd28.js";
8
- import {
9
- FileSys
10
- } from "./index-q0y2jq9j.js";
14
+ } from "./index-b3ae16mg.js";
11
15
  import {
12
16
  Executor,
13
17
  WorkspaceExecutor,
14
18
  AppExecutor
15
- } from "./index-2tv3fdx4.js";
19
+ } from "./index-5nyznra1.js";
16
20
  import"./index-6wwzs1bc.js";
17
21
  import {
18
22
  SlicePlanner
19
- } from "./index-j9yhg404.js";
23
+ } from "./index-ys7dvdb3.js";
20
24
  import {
21
25
  LibSource
22
26
  } from "./index-3d9y066c.js";
@@ -45,6 +49,9 @@ class Subspace {
45
49
  get apps() {
46
50
  return this.#declaration.apps;
47
51
  }
52
+ get workspaceId() {
53
+ return this.#declaration.workspaceId;
54
+ }
48
55
  get #remote() {
49
56
  return `subspace-${this.#declaration.name}`;
50
57
  }
@@ -522,6 +529,23 @@ function formatSubspacePullResult(result) {
522
529
  return sections.join(`
523
530
  `);
524
531
  }
532
+ function formatSubspaceEnvUpload(result) {
533
+ const sections = [
534
+ `Akan Subspace Env Upload \u2014 ${result.name}`,
535
+ `cloud workspace: ${result.workspaceId} \xB7 host: ${result.host}`,
536
+ "",
537
+ ...result.outcome === "cancelled" ? [" cancelled \u2014 the subspace's env archive is untouched."] : [
538
+ `Uploaded (${result.files.length}), replacing that workspace's whole archive:`,
539
+ "",
540
+ ...result.files.map((file) => ` ${file}`),
541
+ "",
542
+ ` apps: ${result.apps.join(", ")}`,
543
+ ` libs: ${result.libs.join(", ") || "(none)"}`
544
+ ]
545
+ ];
546
+ return sections.join(`
547
+ `);
548
+ }
525
549
  function formatSubspaceDiff(result) {
526
550
  const total = result.app.files.length + result.libs.files.length;
527
551
  const sections = [
@@ -575,6 +599,7 @@ class SubspaceConfig {
575
599
  #assertValid() {
576
600
  const seenNames = new Set;
577
601
  const appOwners = new Map;
602
+ const idOwners = new Map;
578
603
  for (const subspace of this.subspaces) {
579
604
  if (!subspace.name || !subspace.repo)
580
605
  throw new Error(`${SubspaceConfig.fileName}: every subspace needs a name and a repo`);
@@ -589,6 +614,12 @@ class SubspaceConfig {
589
614
  throw new Error(`${SubspaceConfig.fileName}: app "${app}" is claimed by both "${owner}" and "${subspace.name}"`);
590
615
  appOwners.set(app, subspace.name);
591
616
  }
617
+ if (!subspace.workspaceId)
618
+ continue;
619
+ const idOwner = idOwners.get(subspace.workspaceId);
620
+ if (idOwner)
621
+ throw new Error(`${SubspaceConfig.fileName}: subspaces "${idOwner}" and "${subspace.name}" declare the same workspaceId`);
622
+ idOwners.set(subspace.workspaceId, subspace.name);
592
623
  }
593
624
  }
594
625
  select(names) {
@@ -625,10 +656,12 @@ class SubspaceRunner extends runner("subspace") {
625
656
  const branch = (await workspace.spawn("git", ["rev-parse", "--abbrev-ref", "HEAD"])).trim();
626
657
  return { config, subspaces, branch };
627
658
  }
659
+ static #isInteractive() {
660
+ return process.stdin.isTTY === true && process.stdout.isTTY === true;
661
+ }
628
662
  async selectNames(workspace, action) {
629
663
  const config = await this.config(workspace);
630
- const interactive = process.stdin.isTTY === true && process.stdout.isTTY === true;
631
- return await SubspaceRunner.chooseNames(config, action, { interactive });
664
+ return await SubspaceRunner.chooseNames(config, action, { interactive: SubspaceRunner.#isInteractive() });
632
665
  }
633
666
  static async chooseNames(config, action, { interactive, prompts }) {
634
667
  const multiple = SubspaceRunner.multiTargetActions.includes(action);
@@ -676,6 +709,43 @@ class SubspaceRunner extends runner("subspace") {
676
709
  throw new Error(`Unknown subspace "${name}"`);
677
710
  return await subspace.pull(branch, { adoptLibs });
678
711
  }
712
+ async uploadEnv(workspace, name, { host, force }) {
713
+ const config = await this.config(workspace);
714
+ const [declaration] = config.select([name]);
715
+ if (!declaration)
716
+ throw new Error(`Unknown subspace "${name}"`);
717
+ const subspace = new Subspace(workspace, config, declaration);
718
+ const { workspaceId } = subspace;
719
+ if (!workspaceId)
720
+ throw new Error(`Subspace "${subspace.name}" declares no workspaceId. Add its cloud workspace id to ${SubspaceConfig.fileName}.`);
721
+ if (workspaceId === workspace.getWorkspaceId({ allowEmpty: true }))
722
+ throw new Error(`Subspace "${subspace.name}" declares this workspace's own id. Uploading a slice there would replace the workspace's env archive with a subset of it.`);
723
+ const apps = subspace.apps;
724
+ const asked = await SubspaceRunner.confirmEnvUpload({ name: subspace.name, workspaceId, apps, force }, { interactive: SubspaceRunner.#isInteractive() });
725
+ if (!asked)
726
+ return { name: subspace.name, workspaceId, host, apps, libs: [], outcome: "cancelled", files: [] };
727
+ const { libs } = await subspace.slice();
728
+ const { CloudScript } = await import("./cloud.script-1bmptvw0.js");
729
+ const { files } = await CommandContainer.get(CloudScript).uploadEnv(workspace, {
730
+ host,
731
+ workspaceId,
732
+ scope: { apps, libs },
733
+ archivePath: `local/env.${subspace.name}.tar`
734
+ });
735
+ return { name: subspace.name, workspaceId, host, apps, libs, outcome: "uploaded", files };
736
+ }
737
+ static async confirmEnvUpload({ name, workspaceId, apps, force }, { interactive, prompts }) {
738
+ if (force)
739
+ return true;
740
+ const target = `subspace "${name}" (cloud workspace ${workspaceId})`;
741
+ if (!interactive)
742
+ throw new Error(`Refusing to replace the env archive of ${target} with no terminal to ask in. Pass --force.`);
743
+ const { confirm } = prompts ?? await loadPrompts();
744
+ return await confirm({
745
+ message: `Replace the env archive of ${target} with this workspace's env for ${apps.join(", ")} and the libraries they pull in?`,
746
+ default: false
747
+ });
748
+ }
679
749
  }
680
750
 
681
751
  // pkgs/@akanjs/cli/subspace/subspace.script.ts
@@ -706,6 +776,10 @@ class SubspaceScript extends script("subspace", [SubspaceRunner]) {
706
776
  spinner.succeed(`${total} file(s) differ (${result.libs.files.length} in shared libraries)`);
707
777
  Logger.rawLog(format === "json" ? JSON.stringify(result, null, 2) : formatSubspaceDiff(result));
708
778
  }
779
+ async uploadEnv(workspace, name, { host, force, format }) {
780
+ const result = await this.subspaceRunner.uploadEnv(workspace, name, { host, force });
781
+ Logger.rawLog(format === "json" ? JSON.stringify(result, null, 2) : formatSubspaceEnvUpload(result));
782
+ }
709
783
  async pull(workspace, name, { adoptLibs, format }) {
710
784
  const spinner = workspace.spinning(`Pulling customer commits from ${name}...`);
711
785
  const result = await this.subspaceRunner.pull(workspace, name, { adoptLibs });
@@ -719,7 +793,7 @@ class SubspaceCommand extends command("subspace", [SubspaceScript], ({ public: t
719
793
  subspace: target({ desc: "Mirror apps and libraries between this workspace and the customer repos it serves" }).arg("action", String, {
720
794
  desc: "subspace action; status-all and push-all take every declared subspace",
721
795
  default: "status",
722
- enum: ["status", "status-all", "diff", "push", "push-all", "pull"]
796
+ enum: ["status", "status-all", "diff", "push", "push-all", "pull", "upload-env"]
723
797
  }).arg("subspace", String, {
724
798
  desc: "subspace name; asks which one(s) when omitted, and is refused by status-all / push-all",
725
799
  nullable: true
@@ -727,12 +801,16 @@ class SubspaceCommand extends command("subspace", [SubspaceScript], ({ public: t
727
801
  flag: "y",
728
802
  desc: "run bun install + akan sync in the subspace before committing",
729
803
  default: true
730
- }).option("adoptLibs", Boolean, { desc: "pull: also apply the subspace's library edits", default: false }).option("path", String, { desc: "diff: limit to one path", nullable: true }).exec(async function(action, subspace, workspace, format, verify, adoptLibs, filePath) {
804
+ }).option("adoptLibs", Boolean, { desc: "pull: also apply the subspace's library edits", default: false }).option("path", String, { desc: "diff: limit to one path", nullable: true }).option("host", String, { desc: "upload-env: host of the cloud to target", default: GlobalConfig.akanCloudHost }).option("force", Boolean, {
805
+ flag: "F",
806
+ desc: "upload-env: replace the subspace's env archive without asking",
807
+ default: false
808
+ }).exec(async function(action, subspace, workspace, format, verify, adoptLibs, filePath, host, force) {
731
809
  const output = format;
732
810
  const all = action === "status-all" || action === "push-all";
733
811
  const base = all ? action.slice(0, -"-all".length) : action;
734
- if (base !== "status" && base !== "diff" && base !== "push" && base !== "pull")
735
- throw new Error(`Unknown subspace action: ${action}. Use status, status-all, diff, push, push-all or pull.`);
812
+ if (base !== "status" && base !== "diff" && base !== "push" && base !== "pull" && base !== "upload-env")
813
+ throw new Error(`Unknown subspace action: ${action}. Use status, status-all, diff, push, push-all, pull or upload-env.`);
736
814
  if (all && subspace)
737
815
  throw new Error(`\`akan subspace ${action}\` takes no name. Run \`akan subspace ${base} ${subspace}\` instead.`);
738
816
  const names = subspace ? [subspace] : all ? [] : await this.subspaceScript.select(workspace, base);
@@ -746,6 +824,8 @@ class SubspaceCommand extends command("subspace", [SubspaceScript], ({ public: t
746
824
  throw new Error(`\`akan subspace ${base}\` needs a name \u2014 it is reviewed one repo at a time.`);
747
825
  if (base === "diff")
748
826
  await this.subspaceScript.diff(workspace, name, filePath, output);
827
+ else if (base === "upload-env")
828
+ await this.subspaceScript.uploadEnv(workspace, name, { host, force, format: output });
749
829
  else
750
830
  await this.subspaceScript.pull(workspace, name, { adoptLibs, format: output });
751
831
  }
@@ -0,0 +1,130 @@
1
+ // @bun
2
+ import"./index-q0y2jq9j.js";
3
+ import {
4
+ GlobalConfig,
5
+ CloudApi
6
+ } from "./index-bw2marpf.js";
7
+ import {
8
+ Workspace,
9
+ runner,
10
+ script,
11
+ command
12
+ } from "./index-b3ae16mg.js";
13
+ import {
14
+ AppExecutor
15
+ } from "./index-5nyznra1.js";
16
+ import"./index-6wwzs1bc.js";
17
+ import {
18
+ TunnelShare2
19
+ } from "./index-jcekapz4.js";
20
+ import {
21
+ writeClipboard
22
+ } from "./index-p6pbz9n5.js";
23
+
24
+ // pkgs/@akanjs/cli/tunnel/tunnel.script.ts
25
+ import { select } from "@inquirer/prompts";
26
+
27
+ // pkgs/@akanjs/cli/tunnel/tunnel.runner.ts
28
+ import { Logger } from "akanjs/common";
29
+ import chalk from "chalk";
30
+ class TunnelRunner extends runner("tunnel") {
31
+ async share(app, options) {
32
+ const spinner = app.spinning("Requesting a tunnel...");
33
+ const share = await TunnelShare2.open(app, {
34
+ ...options,
35
+ onLost: (reason) => Logger.rawLog(`tunnel disconnected (${reason}); reconnecting`, undefined, "error")
36
+ }).catch((error) => {
37
+ spinner.fail("Could not open the tunnel");
38
+ throw error;
39
+ });
40
+ spinner.succeed(`${app.name} is shared`);
41
+ const copied = await writeClipboard(share.url);
42
+ Logger.rawLog(`
43
+ ${chalk.bold(share.url)}${copied ? chalk.dim(" (copied)") : ""}`);
44
+ if (share.grant.expiresAt)
45
+ Logger.rawLog(chalk.dim(` expires ${share.grant.expiresAt}`));
46
+ Logger.rawLog(chalk.dim(` code ${share.grant.code} \u2014 stop it with: akan tunnel --stop ${share.grant.code}
47
+ `));
48
+ await TunnelRunner.holdUntilInterrupt(() => share.close());
49
+ }
50
+ async list(workspace, host = GlobalConfig.akanCloudHost) {
51
+ const api = await CloudApi.fromHost(workspace, host);
52
+ const tunnels = await api.tunnelListInSelf();
53
+ if (!tunnels.length) {
54
+ Logger.rawLog("No tunnels are open.");
55
+ return;
56
+ }
57
+ for (const tunnel of tunnels)
58
+ Logger.rawLog(`${tunnel.connected ? chalk.green("\u25CF") : chalk.dim("\u25CB")} ${tunnel.code} ${tunnel.url}` + `${tunnel.name ? ` ${chalk.dim(tunnel.name)}` : ""}` + `${tunnel.expiresAt ? chalk.dim(` expires ${tunnel.expiresAt}`) : ""}`);
59
+ }
60
+ async stop(code, workspace, host = GlobalConfig.akanCloudHost) {
61
+ const api = await CloudApi.fromHost(workspace, host);
62
+ const stopped = await api.revokeTunnel(code);
63
+ if (stopped)
64
+ Logger.rawLog(`Stopped ${code}.`);
65
+ else
66
+ Logger.rawLog(`No tunnel named ${code} is open.`, undefined, "error");
67
+ }
68
+ static holdUntilInterrupt(onInterrupt) {
69
+ return new Promise((resolve) => {
70
+ let closing = false;
71
+ const stop = () => {
72
+ if (closing) {
73
+ Logger.rawLog("Abandoning the tunnel release; it will expire on its own.", undefined, "error");
74
+ process.exit(130);
75
+ }
76
+ closing = true;
77
+ onInterrupt().then(() => resolve());
78
+ };
79
+ process.on("SIGINT", stop);
80
+ process.on("SIGTERM", stop);
81
+ });
82
+ }
83
+ }
84
+
85
+ // pkgs/@akanjs/cli/tunnel/tunnel.script.ts
86
+ class TunnelScript extends script("tunnel", [TunnelRunner]) {
87
+ static async resolveApp(workspace, name) {
88
+ const appNames = await workspace.getApps();
89
+ if (!appNames.length)
90
+ throw new Error("No apps found in this workspace (apps/<appName>/akan.config.ts)");
91
+ if (name && !appNames.includes(name))
92
+ throw new Error(`Unknown app: ${name}. Available: ${appNames.join(", ")}`);
93
+ if (name)
94
+ return AppExecutor.from(workspace, name);
95
+ const only = appNames.length === 1 ? appNames[0] : null;
96
+ if (only)
97
+ return AppExecutor.from(workspace, only);
98
+ return AppExecutor.from(workspace, await select({ message: "Select the app to share", choices: appNames }));
99
+ }
100
+ async share(name, { workspace, host, port, ttl }) {
101
+ const app = await TunnelScript.resolveApp(workspace, name);
102
+ await this.tunnelRunner.share(app, {
103
+ workspace,
104
+ ...host ? { host } : {},
105
+ ...port ? { port } : {},
106
+ ...ttl ? { ttlMinutes: ttl } : {}
107
+ });
108
+ }
109
+ async list(workspace, host) {
110
+ await this.tunnelRunner.list(workspace, host);
111
+ }
112
+ async stop(code, workspace, host) {
113
+ await this.tunnelRunner.stop(code, workspace, host);
114
+ }
115
+ }
116
+
117
+ // pkgs/@akanjs/cli/tunnel/tunnel.command.ts
118
+ class TunnelCommand extends command("tunnel", [TunnelScript], ({ public: target }) => ({
119
+ tunnel: target({ desc: "Share a locally running app on a public URL" }).arg("app", String, { desc: "app to share", nullable: true }).option("list", Boolean, { desc: "list the shares this account is holding", default: false }).option("stop", String, { desc: "stop the share with this code", default: "" }).option("host", String, { desc: "host of the cloud", default: GlobalConfig.akanCloudHost }).option("port", Number, { desc: "local port to share (default: the app's dev port)", nullable: true }).option("ttl", Number, { desc: "minutes before the share expires", nullable: true }).with(Workspace).exec(async function(app, list, stop, host, port, ttl, workspace) {
120
+ if (list)
121
+ return await this.tunnelScript.list(workspace, host);
122
+ if (stop)
123
+ return await this.tunnelScript.stop(stop, workspace, host);
124
+ await this.tunnelScript.share(app, { workspace, host, ...port ? { port } : {}, ...ttl ? { ttl } : {} });
125
+ })
126
+ })) {
127
+ }
128
+ export {
129
+ TunnelCommand
130
+ };
@@ -3,30 +3,31 @@ import {
3
3
  Workspace,
4
4
  script,
5
5
  command
6
- } from "./index-mak3cd28.js";
6
+ } from "./index-b3ae16mg.js";
7
7
  import"./index-q0y2jq9j.js";
8
- import"./index-2tv3fdx4.js";
8
+ import"./index-5nyznra1.js";
9
9
  import"./index-6wwzs1bc.js";
10
10
  import {
11
11
  createWorkflowStepRegistry
12
- } from "./index-gyd220p2.js";
13
- import"./index-kn1h7p1x.js";
12
+ } from "./index-jwjaf9fy.js";
13
+ import"./index-bw2marpf.js";
14
+ import"./index-yc1keaer.js";
14
15
  import {
15
16
  ModuleScript
16
- } from "./index-8pm30m73.js";
17
- import"./index-pnqbkf5p.js";
17
+ } from "./index-fr2x3qvv.js";
18
+ import"./index-sh88vtye.js";
18
19
  import"./index-h7yw2z9n.js";
19
20
  import {
20
21
  PrimitiveScript
21
- } from "./index-4edzf1gr.js";
22
+ } from "./index-kbsach1y.js";
22
23
  import {
23
24
  ScalarScript
24
- } from "./index-rwg2aa4f.js";
25
+ } from "./index-ceph7zqj.js";
25
26
  import"./index-by5gpp8x.js";
26
- import"./index-ktb5njgy.js";
27
+ import"./index-15r9a10e.js";
27
28
  import {
28
29
  WorkflowRunner
29
- } from "./index-7737gxcp.js";
30
+ } from "./index-8pkvrcv1.js";
30
31
 
31
32
  // pkgs/@akanjs/cli/workflow/workflow.script.ts
32
33
  import { Logger } from "akanjs/common";
@@ -4,14 +4,14 @@ import {
4
4
  } from "./index-q0y2jq9j.js";
5
5
  import {
6
6
  GlobalConfig
7
- } from "./index-kn1h7p1x.js";
7
+ } from "./index-bw2marpf.js";
8
8
  import {
9
9
  Exec,
10
10
  Workspace,
11
11
  runner,
12
12
  script,
13
13
  command
14
- } from "./index-mak3cd28.js";
14
+ } from "./index-b3ae16mg.js";
15
15
  import {
16
16
  extractAgentBlock,
17
17
  collectScopeRecipeSources,
@@ -21,7 +21,7 @@ import {
21
21
  AppExecutor,
22
22
  LibExecutor,
23
23
  PkgExecutor
24
- } from "./index-2tv3fdx4.js";
24
+ } from "./index-5nyznra1.js";
25
25
  import"./index-6wwzs1bc.js";
26
26
  import {
27
27
  countBlocking,
@@ -32,41 +32,42 @@ import {
32
32
  collectRecipeSources2,
33
33
  scanRecipes2
34
34
  } from "./index-by5gpp8x.js";
35
- import"./index-gyd220p2.js";
36
- import"./index-ktb5njgy.js";
35
+ import"./index-jwjaf9fy.js";
36
+ import"./index-15r9a10e.js";
37
37
  import"./index-h7yw2z9n.js";
38
38
  import {
39
39
  AgentScript
40
- } from "./index-ne2qy0nk.js";
40
+ } from "./index-s3fvrydw.js";
41
41
  import {
42
42
  ApplicationScript
43
- } from "./index-v0qh106m.js";
43
+ } from "./index-r8bd61d9.js";
44
44
  import {
45
45
  LibraryScript
46
- } from "./index-259dsnz3.js";
46
+ } from "./index-1nwxbr2y.js";
47
47
  import"./index-hwkygn9s.js";
48
+ import"./index-yc1keaer.js";
48
49
  import"./index-kcxmv48c.js";
49
50
  import {
50
51
  PackageScript
51
- } from "./index-ws5e0j51.js";
52
+ } from "./index-t8gvwcrx.js";
52
53
  import {
53
54
  getNpmRegistryUrl,
54
55
  getLatestPackageVersion
55
- } from "./index-2hq52jq3.js";
56
+ } from "./index-8tfmh0v6.js";
56
57
  import {
57
- CloudScript
58
- } from "./index-zry5nz81.js";
58
+ CloudScript2
59
+ } from "./index-ay8wj00x.js";
59
60
  import {
60
61
  ContextScript
61
- } from "./index-600zhnve.js";
62
- import"./index-wt7qrtd4.js";
63
- import"./index-fz5q3gd7.js";
64
- import"./index-7737gxcp.js";
65
- import"./index-8pm30m73.js";
66
- import"./index-pnqbkf5p.js";
67
- import"./index-4edzf1gr.js";
68
- import"./index-rwg2aa4f.js";
69
- import"./index-j9yhg404.js";
62
+ } from "./index-3pvkjza8.js";
63
+ import"./index-7f4dsf9v.js";
64
+ import"./index-em4swemt.js";
65
+ import"./index-8pkvrcv1.js";
66
+ import"./index-fr2x3qvv.js";
67
+ import"./index-sh88vtye.js";
68
+ import"./index-kbsach1y.js";
69
+ import"./index-ceph7zqj.js";
70
+ import"./index-ys7dvdb3.js";
70
71
 
71
72
  // pkgs/@akanjs/cli/workspace/workspace.runner.ts
72
73
  import path from "path";
@@ -327,7 +328,7 @@ class WorkspaceScript extends script("workspace", [
327
328
  ApplicationScript,
328
329
  LibraryScript,
329
330
  PackageScript,
330
- CloudScript,
331
+ CloudScript2,
331
332
  ContextScript,
332
333
  AgentScript
333
334
  ]) {