@akanjs/cli 3.1.1-rc.9 → 3.1.2-rc.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.build-stamp +1 -1
- package/CodeAgent-dyc45f5w.js +11 -0
- package/{CodeAgentRpcHost-9g27hmer.js → CodeAgentRpcHost-6dzfkvsc.js} +1 -1
- package/CodeAgentRpcListener-tcwrdvst.js +182 -0
- package/{CodeTui-z5vkm9ea.js → CodeTui-q55b2zrn.js} +25 -8
- package/TunnelShare-hdq9h1hr.js +14 -0
- package/agent.command-20zaqe60.js +49 -0
- package/akanCode.js +13 -8
- package/{application.command-wthg8nn9.js → application.command-nd0fshsk.js} +45 -12
- package/{applicationBuildRunner-t2r84sz6.js → applicationBuildRunner-s13x3zqb.js} +14 -10
- package/buildBatch.proc.js +7 -7
- package/{cloud.command-sz11hpre.js → cloud.command-8kbddsz9.js} +28 -19
- package/cloud.script-hgvvajm3.js +27 -0
- package/code.command-625bg8s8.js +345 -0
- package/commandManifest.json +1 -1
- package/{context.command-15j9b7c0.js → context.command-p6haqjay.js} +20 -18
- package/context.runner-rsnqnk9j.js +27 -0
- package/{dependencyScanner-3afj2vt1.js → dependencyScanner-78sq8m4q.js} +2 -2
- package/{devTui-q7k7bakd.js → devTui-evr3b35y.js} +1 -1
- package/{fileSys-wzzrntkw.js → fileSys-zpvt5gtf.js} +1 -1
- package/{guideline.command-snh85ctf.js → guideline.command-195g0h9a.js} +4 -4
- package/guidelines/agentRule/agentRule.instruction.md +22 -8
- package/guidelines/conventions/core.md +106 -0
- package/guidelines/conventions/rules/app.md +83 -0
- package/guidelines/conventions/rules/auth.md +46 -0
- package/guidelines/conventions/rules/config.md +60 -0
- package/guidelines/conventions/rules/constant.md +24 -0
- package/guidelines/conventions/rules/gates.md +32 -0
- package/guidelines/conventions/rules/layer.md +25 -0
- package/guidelines/conventions/rules/migration.md +27 -0
- package/guidelines/conventions/rules/module.md +90 -0
- package/guidelines/conventions/rules/page.md +56 -0
- package/guidelines/conventions/rules/sensitive.md +16 -0
- package/guidelines/conventions/rules/server.md +91 -0
- package/guidelines/conventions/rules/ssr.md +47 -0
- package/guidelines/conventions/rules/style.md +43 -0
- package/guidelines/conventions/rules/test.md +34 -0
- package/guidelines/conventions/rules/ts.md +95 -0
- package/guidelines/conventions/rules/tsx.md +76 -0
- package/guidelines/mcpRule/mcpRule.instruction.md +1 -1
- package/guidelines/pageRule/pageRule.instruction.md +8 -7
- package/guidelines/queryRule/queryRule.instruction.md +4 -0
- package/guidelines/runtimeRule/runtimeRule.instruction.md +35 -25
- package/guidelines/ssrRule/ssrRule.instruction.md +11 -10
- package/guidelines/transportRule/transportRule.instruction.md +5 -4
- package/guidelines/workspaceRecipes/workspaceRecipes.instruction.md +4 -4
- package/incrementalBuilder.proc.js +7 -7
- package/{index-301pdbzz.js → index-00a7j05x.js} +7 -7
- package/{index-js6geqjn.js → index-0j1t1h2b.js} +3 -1
- package/{index-6txx6a9p.js → index-1h2jc0x3.js} +154 -88
- package/{index-55j120r8.js → index-1qsd8ft1.js} +65 -145
- package/{index-9th4gszy.js → index-2mwjshz5.js} +233 -1271
- package/index-2nxk8wgs.js +266 -0
- package/{index-j9vyj3dj.js → index-2phm56a1.js} +49 -8
- package/index-35j83zkd.js +61 -0
- package/index-4am4dvmf.js +29 -0
- package/index-75y7bcz4.js +28 -0
- package/index-7apsdr5g.js +487 -0
- package/{index-42j4a8zq.js → index-84h43kg6.js} +8 -6
- package/index-9bv479q5.js +1 -0
- package/{index-3wypz6xj.js → index-9zy8479y.js} +11 -5
- package/{index-a5dhqkdr.js → index-a1vb3x7t.js} +273 -259
- package/{index-52w0fvh8.js → index-bns3wcpc.js} +15 -0
- package/index-cjmjvg4r.js +3622 -0
- package/{index-pcwzkdqb.js → index-defp4gmb.js} +1 -1
- package/index-ewbmfarf.js +1606 -0
- package/index-fbewhg4g.js +590 -0
- package/index-fhw7yq2d.js +653 -0
- package/{index-wcej7g4z.js → index-g500c5j9.js} +271 -105
- package/{index-74tjjsnc.js → index-g841cap9.js} +33 -37
- package/{index-2azahjaw.js → index-gr9thy79.js} +5 -5
- package/{index-4pf8g7ff.js → index-h7hehkw6.js} +3 -0
- package/{index-xjf5j657.js → index-hm0tn7qv.js} +1001 -91
- package/index-j6eeh5d7.js +138 -0
- package/{index-31es1yev.js → index-j7hwy56s.js} +108 -7
- package/{index-skk9zc1x.js → index-jc2zbwra.js} +2 -2
- package/{index-905qdgqp.js → index-khk05tsf.js} +1 -1
- package/{index-5nd1wtkv.js → index-p6x5b7hr.js} +1 -1
- package/{index-tvehn2sp.js → index-qd7xn2bk.js} +1 -1
- package/{index-a58emady.js → index-qw6814m4.js} +55 -17
- package/index-raz588b3.js +445 -0
- package/{index-at7bz0xq.js → index-s4nvxpzm.js} +2 -0
- package/{index-bt438yxm.js → index-sp0qsr7a.js} +116 -13
- package/{index-xb8809yb.js → index-sveq36gh.js} +40 -43
- package/{index-hmt54t45.js → index-t1t9wq9a.js} +4 -4
- package/index-t78230d7.js +191 -0
- package/index-tenw3mah.js +225 -0
- package/{index-qfp55x1y.js → index-tgqameyb.js} +4 -4
- package/{index-espk51ah.js → index-tp56652m.js} +6 -6
- package/index-w15mg3km.js +389 -0
- package/{index-dy0jx9ay.js → index-wwe9rsrx.js} +14 -0
- package/{index-2xcc2ax5.js → index-y4kcmbt2.js} +2 -2
- package/index-yf9wc28h.js +52 -0
- package/{index-0fz95kxe.js → index-zbrwnmf1.js} +9 -7
- package/{index-40brg4px.js → index-zttm13c3.js} +5 -5
- package/index.js +24 -23
- package/{library.command-gycrwhf1.js → library.command-63hgt9te.js} +4 -4
- package/{localRegistry.command-jtd8gaes.js → localRegistry.command-g3f8k25t.js} +46 -22
- package/{module.command-v6hgs1bc.js → module.command-r4sa2khp.js} +7 -6
- package/{package.command-shzpcfph.js → package.command-96eheyvd.js} +5 -5
- package/package.json +2 -2
- package/{page.command-ptxn5kqk.js → page.command-gs6d841d.js} +4 -4
- package/{pipeline.command-zz31pgax.js → pipeline.command-wdfvdbfj.js} +3 -3
- package/{primitive.command-a1vse91z.js → primitive.command-dfsv4mpe.js} +8 -7
- package/{projectTypecheck-2ztky9cf.js → projectTypecheck-kqj1t6hb.js} +1 -1
- package/{prompter-76k56b37.js → prompter-qrwx1p17.js} +2 -2
- package/quality.command-webzxee2.js +78 -0
- package/{repair.command-cvazbz99.js → repair.command-3r3j1xre.js} +7 -6
- package/{routeSourceValidator-6jd0q6r6.js → routeSourceValidator-4h947v7c.js} +13 -3
- package/{scalar.command-0acvyp26.js → scalar.command-e8y47j6d.js} +6 -5
- package/skills/akan-agent/SKILL.md +43 -0
- package/skills/akan-code/SKILL.md +38 -11
- package/skills/akan-debug/SKILL.md +41 -6
- package/skills/akan-deps/SKILL.md +1 -2
- package/skills/akan-err/SKILL.md +2 -1
- package/skills/akan-mcp/SKILL.md +40 -0
- package/skills/akan-page/SKILL.md +44 -0
- package/skills/akan-query/SKILL.md +39 -0
- package/skills/akan-runtime/SKILL.md +43 -0
- package/skills/akan-scaffold/SKILL.md +16 -6
- package/skills/akan-transport/SKILL.md +40 -0
- package/skills/akan-validate/SKILL.md +13 -11
- package/{subspace.command-822qx2bx.js → subspace.command-a1sf9n5a.js} +12 -10
- package/templates/__scalar/__model__/__model__.constant.ts +3 -5
- package/templates/__scalar/__model__/__model__.dictionary.ts +6 -5
- package/templates/__scalar/__model__/__model__.document.ts +3 -3
- package/templates/app/akan.config.ts +2 -3
- package/templates/app/env/env.client.ts +2 -4
- package/templates/app/env/env.client.type.ts +2 -3
- package/templates/app/env/env.server.ts +2 -3
- package/templates/app/lib/___appName__/__appName__.dictionary.ts +1 -2
- package/templates/app/lib/___appName__/__appName__.service.ts +3 -3
- package/templates/app/lib/___appName__/__appName__.signal.ts +5 -5
- package/templates/app/lib/___appName__/__appName__.store.ts +4 -6
- package/templates/app/lib/option.ts +2 -3
- package/templates/app/main.ts +2 -4
- package/templates/app/page/_index.tsx +3 -3
- package/templates/app/page/_layout.tsx +13 -10
- package/templates/appSample/lib/__scalar/workHistory/workHistory.constant.ts +1 -5
- package/templates/appSample/lib/__scalar/workHistory/workHistory.dictionary.ts +1 -1
- package/templates/appSample/lib/_noti/noti.signal.ts +1 -1
- package/templates/appSample/lib/task/Task.Template.tsx +2 -1
- package/templates/appSample/lib/task/Task.Unit.tsx +3 -2
- package/templates/appSample/lib/task/Task.Util.tsx +16 -4
- package/templates/appSample/lib/task/task.constant.ts +1 -5
- package/templates/appSample/lib/task/task.dictionary.ts +2 -8
- package/templates/appSample/lib/task/task.document.ts +1 -1
- package/templates/appSample/lib/task/task.signal.ts +14 -9
- package/templates/appSample/page/task/_index.tsx +2 -1
- package/templates/appSample/page/task/new.tsx +2 -1
- package/templates/appSample/srvkit/guards.ts +11 -0
- package/templates/appSample/ui/QuantityControl.tsx +5 -9
- package/templates/biomeForm.ts +144 -0
- package/templates/crudPages/[__model__Id]/edit/page.tsx +3 -3
- package/templates/crudPages/[__model__Id]/page.tsx +5 -5
- package/templates/crudPages/new/page.tsx +4 -3
- package/templates/crudPages/page.tsx +3 -3
- package/templates/crudSinglePage/page.tsx +9 -5
- package/templates/libRoot/akan.config.ts +2 -3
- package/templates/libRoot/lib/___libName__/__libName__.dictionary.ts +1 -2
- package/templates/libRoot/lib/___libName__/__libName__.service.ts +5 -4
- package/templates/libRoot/lib/___libName__/__libName__.signal.ts +6 -5
- package/templates/libRoot/lib/___libName__/__libName__.store.ts +5 -6
- package/templates/libRoot/lib/option.ts +1 -2
- package/templates/module/__Model__.Template.tsx +11 -10
- package/templates/module/__Model__.Unit.tsx +18 -5
- package/templates/module/__Model__.Util.tsx +9 -7
- package/templates/module/__Model__.View.tsx +9 -6
- package/templates/module/__Model__.Zone.tsx +25 -17
- package/templates/module/__model__.constant.ts +8 -9
- package/templates/module/__model__.dictionary.ts +16 -17
- package/templates/module/__model__.document.ts +6 -8
- package/templates/module/__model__.service.ts +3 -3
- package/templates/module/__model__.signal.ts +11 -10
- package/templates/module/__model__.store.ts +3 -5
- package/templates/service/__model__.dictionary.ts +5 -6
- package/templates/service/__model__.service.ts +3 -3
- package/templates/service/__model__.signal.ts +5 -4
- package/templates/service/__model__.store.ts +3 -5
- package/templates/workspaceRoot/.gitignore.template +4 -0
- package/templates/workspaceRoot/.vscode/settings.json.template +21 -21
- package/templates/workspaceRoot/AGENTS.md.template +4 -10
- package/{tunnel.command-ycmja19q.js → tunnel.command-dcb0wg93.js} +25 -13
- package/{typeChecker-px49mezc.js → typeChecker-j2jdnqsr.js} +1 -1
- package/typecheck.proc.js +6 -1
- package/verify.command-yyepccbh.js +93 -0
- package/{workflow.command-abb1d5xy.js → workflow.command-z5pg9ay0.js} +49 -14
- package/workspace.command-d7x5jttw.js +290 -0
- package/CodeAgent-8d5qs787.js +0 -9
- package/CodeAgentRpcListener-7p7z5dd7.js +0 -97
- package/TunnelShare-qkm8zp03.js +0 -14
- package/agent.command-ydftceda.js +0 -25
- package/cloud.script-nqevg5qw.js +0 -24
- package/code.command-9h3yrzhe.js +0 -167
- package/context.runner-8gg030b0.js +0 -25
- package/guidelines/conventions/conventions.instruction.md +0 -617
- package/guidelines/workspaceOnboarding/workspaceOnboarding.instruction.md +0 -291
- package/index-2mwc0g0d.js +0 -49
- package/index-4vgbysa0.js +0 -279
- package/index-7md2g9vw.js +0 -6
- package/index-b70zct19.js +0 -856
- package/index-c6eggbee.js +0 -123
- package/index-zzvvc845.js +0 -74
- package/quality.command-ah8qcakd.js +0 -1478
- package/templates/workspaceRoot/docs/AI-DEVELOPMENT.md.template +0 -69
- package/templates/workspaceRoot/docs/GENERATED.md.template +0 -55
- package/workspace.command-qm7cw29v.js +0 -521
|
@@ -6,46 +6,34 @@ import {
|
|
|
6
6
|
CloudApi,
|
|
7
7
|
CloudUpdates,
|
|
8
8
|
PipelineSecrets
|
|
9
|
-
} from "./index-
|
|
9
|
+
} from "./index-gr9thy79.js";
|
|
10
10
|
import {
|
|
11
11
|
resolveMobileTargets
|
|
12
12
|
} from "./index-m9jj544v.js";
|
|
13
13
|
import {
|
|
14
14
|
WorkspaceExecutor,
|
|
15
15
|
AppExecutor
|
|
16
|
-
} from "./index-
|
|
16
|
+
} from "./index-g500c5j9.js";
|
|
17
17
|
import {
|
|
18
18
|
NativeApp
|
|
19
|
-
} from "./index-
|
|
19
|
+
} from "./index-sp0qsr7a.js";
|
|
20
20
|
import {
|
|
21
21
|
runner,
|
|
22
22
|
assertPromptable
|
|
23
|
-
} from "./index-
|
|
23
|
+
} from "./index-9zy8479y.js";
|
|
24
|
+
import {
|
|
25
|
+
getNpmRegistryUrl,
|
|
26
|
+
getLatestPackageVersion
|
|
27
|
+
} from "./index-4am4dvmf.js";
|
|
24
28
|
import {
|
|
25
29
|
SubspaceConfig
|
|
26
|
-
} from "./index-
|
|
30
|
+
} from "./index-h7hehkw6.js";
|
|
27
31
|
import {
|
|
28
32
|
openBrowser
|
|
29
33
|
} from "./index-9dp031by.js";
|
|
30
34
|
|
|
31
|
-
// pkgs/@akanjs/cli/npmRegistry.ts
|
|
32
|
-
var defaultNpmRegistry = "https://registry.npmjs.org";
|
|
33
|
-
var getNpmRegistryUrl = (registryUrl = process.env.AKAN_NPM_REGISTRY ?? defaultNpmRegistry) => registryUrl.replace(/\/+$/, "");
|
|
34
|
-
async function getLatestPackageVersion(packageName, tag = "latest", registryUrl) {
|
|
35
|
-
const registry = getNpmRegistryUrl(registryUrl);
|
|
36
|
-
const url = `${registry}/${encodeURIComponent(packageName).replace(/^%40/, "@")}`;
|
|
37
|
-
const res = await fetch(url);
|
|
38
|
-
if (!res.ok)
|
|
39
|
-
throw new Error(`Failed to fetch ${packageName} metadata from ${registry}`);
|
|
40
|
-
const metadata = await res.json();
|
|
41
|
-
const version = metadata["dist-tags"]?.[tag];
|
|
42
|
-
if (!version)
|
|
43
|
-
throw new Error(`No npm dist-tag "${tag}" found for ${packageName}`);
|
|
44
|
-
return version;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
35
|
// pkgs/@akanjs/cli/cloud/cloud.runner.ts
|
|
48
|
-
import
|
|
36
|
+
import path8 from "path";
|
|
49
37
|
|
|
50
38
|
// pkgs/@akanjs/devkit/platformTest/PlatformTestRun.ts
|
|
51
39
|
import path6 from "path";
|
|
@@ -294,6 +282,7 @@ class LinuxDockerTarget extends PlatformTestTarget {
|
|
|
294
282
|
"run",
|
|
295
283
|
"-d",
|
|
296
284
|
"--rm",
|
|
285
|
+
"--init",
|
|
297
286
|
"--name",
|
|
298
287
|
container,
|
|
299
288
|
"--cpus",
|
|
@@ -682,11 +671,74 @@ class PlatformTestRun {
|
|
|
682
671
|
|
|
683
672
|
// pkgs/@akanjs/cli/cloud/cloud.runner.ts
|
|
684
673
|
import { confirm, input, select } from "@inquirer/prompts";
|
|
685
|
-
import { Logger as
|
|
674
|
+
import { Logger as Logger3 } from "akanjs/common";
|
|
686
675
|
import chalk3 from "chalk";
|
|
687
676
|
|
|
677
|
+
// pkgs/@akanjs/cli/cloud/envArchive.ts
|
|
678
|
+
import { copyFile, mkdir as mkdir3, mkdtemp, readdir, rm } from "fs/promises";
|
|
679
|
+
import path7 from "path";
|
|
680
|
+
import { Logger } from "akanjs/common";
|
|
681
|
+
|
|
682
|
+
class EnvArchive {
|
|
683
|
+
static envFilePattern = /^env\.(client|server)\.(?!(type|example)\.ts$).+\.ts$/;
|
|
684
|
+
static async extract(workspace, archivePath) {
|
|
685
|
+
const root = workspace.workspaceRoot;
|
|
686
|
+
await mkdir3(path7.join(root, "local"), { recursive: true });
|
|
687
|
+
const staging = await mkdtemp(path7.join(root, "local", "env-extract-"));
|
|
688
|
+
try {
|
|
689
|
+
const relativeArchive = path7.relative(staging, path7.resolve(root, archivePath)).split(path7.sep).join("/");
|
|
690
|
+
await workspace.spawn("tar", ["-xf", relativeArchive], { cwd: staging });
|
|
691
|
+
const secretGlobs = await EnvArchive.#secretGlobs(workspace);
|
|
692
|
+
const { files, others } = await EnvArchive.#walk(staging);
|
|
693
|
+
const kept = files.filter((file) => EnvArchive.#isEnvFile(file, secretGlobs));
|
|
694
|
+
const skipped = [...files.filter((file) => !kept.includes(file)), ...others];
|
|
695
|
+
for (const file of kept) {
|
|
696
|
+
const target = path7.join(root, file);
|
|
697
|
+
await mkdir3(path7.dirname(target), { recursive: true });
|
|
698
|
+
await copyFile(path7.join(staging, file), target);
|
|
699
|
+
}
|
|
700
|
+
if (skipped.length)
|
|
701
|
+
Logger.warn(`Left out of the env archive what is no env or declared secret file: ${skipped.join(", ")}`);
|
|
702
|
+
return { kept, skipped };
|
|
703
|
+
} finally {
|
|
704
|
+
await rm(staging, { recursive: true, force: true });
|
|
705
|
+
}
|
|
706
|
+
}
|
|
707
|
+
static #isEnvFile(file, secretGlobs) {
|
|
708
|
+
const [scope = "", name = "", ...rest] = file.split("/");
|
|
709
|
+
const [folder, fileName = ""] = rest;
|
|
710
|
+
if ((scope === "apps" || scope === "libs") && rest.length === 2 && folder === "env")
|
|
711
|
+
return EnvArchive.envFilePattern.test(fileName);
|
|
712
|
+
return scope === "apps" && !!secretGlobs.get(name)?.some((glob) => glob.match(rest.join("/")));
|
|
713
|
+
}
|
|
714
|
+
static async#secretGlobs(workspace) {
|
|
715
|
+
const [appNames] = await workspace.getExecs();
|
|
716
|
+
const entries = await Promise.all(appNames.map(async (appName) => {
|
|
717
|
+
const { secrets = [] } = await AppExecutor.from(workspace, appName).getConfig();
|
|
718
|
+
return [appName, secrets.map((pattern) => new Bun.Glob(pattern))];
|
|
719
|
+
}));
|
|
720
|
+
return new Map(entries);
|
|
721
|
+
}
|
|
722
|
+
static async#walk(dir, prefix = "") {
|
|
723
|
+
const files = [];
|
|
724
|
+
const others = [];
|
|
725
|
+
for (const entry of await readdir(dir, { withFileTypes: true })) {
|
|
726
|
+
const relative = prefix ? `${prefix}/${entry.name}` : entry.name;
|
|
727
|
+
if (entry.isDirectory()) {
|
|
728
|
+
const nested = await EnvArchive.#walk(path7.join(dir, entry.name), relative);
|
|
729
|
+
files.push(...nested.files);
|
|
730
|
+
others.push(...nested.others);
|
|
731
|
+
} else if (entry.isFile())
|
|
732
|
+
files.push(relative);
|
|
733
|
+
else
|
|
734
|
+
others.push(relative);
|
|
735
|
+
}
|
|
736
|
+
return { files, others };
|
|
737
|
+
}
|
|
738
|
+
}
|
|
739
|
+
|
|
688
740
|
// pkgs/@akanjs/cli/cloud/remoteLogin.ts
|
|
689
|
-
import { Backoff, Logger, RemoteAuthCode, sleep } from "akanjs/common";
|
|
741
|
+
import { Backoff, Logger as Logger2, RemoteAuthCode, sleep } from "akanjs/common";
|
|
690
742
|
import chalk2 from "chalk";
|
|
691
743
|
import * as QRcode from "qrcode";
|
|
692
744
|
class RemoteLogin {
|
|
@@ -729,33 +781,37 @@ class RemoteLogin {
|
|
|
729
781
|
}
|
|
730
782
|
async#prompt(remoteId, loginId) {
|
|
731
783
|
const signinUrl = `${this.#api.host}/remoteAuth?remoteId=${encodeURIComponent(loginId)}`;
|
|
732
|
-
|
|
784
|
+
Logger2.rawLog(chalk2.bold(`
|
|
733
785
|
${chalk2.green("\u27A4")} Authentication Required`));
|
|
734
|
-
|
|
735
|
-
|
|
786
|
+
Logger2.rawLog(chalk2.dim("Please visit or click the following URL:"));
|
|
787
|
+
Logger2.rawLog(`${chalk2.cyan.underline(signinUrl)}
|
|
736
788
|
`);
|
|
737
789
|
try {
|
|
738
|
-
|
|
790
|
+
Logger2.rawLog(await QRcode.toString(signinUrl, { type: "terminal", small: true }));
|
|
739
791
|
await this.#open(signinUrl);
|
|
740
|
-
|
|
792
|
+
Logger2.rawLog(chalk2.dim("Opening browser..."));
|
|
741
793
|
} catch {
|
|
742
|
-
|
|
794
|
+
Logger2.rawLog(chalk2.yellow("Could not open browser. Please visit the URL manually."));
|
|
743
795
|
}
|
|
744
|
-
|
|
796
|
+
Logger2.rawLog(`
|
|
745
797
|
${chalk2.bold("Your code:")} ${chalk2.bold.inverse(` ${await RemoteAuthCode.of(remoteId)} `)}`);
|
|
746
|
-
|
|
798
|
+
Logger2.rawLog(chalk2.dim(`Enter this code on the sign-in page. Never enter a code that did not come from your own terminal.
|
|
747
799
|
`));
|
|
748
800
|
}
|
|
749
801
|
async#awaitApproval(remoteId, loginId) {
|
|
750
|
-
|
|
802
|
+
Logger2.rawLog(chalk2.dim("Waiting for authentication..."));
|
|
751
803
|
const deadline = this.#now() + this.#limitMs;
|
|
752
804
|
const ids = [remoteId, loginId];
|
|
753
805
|
let failures = 0;
|
|
754
806
|
while (this.#now() < deadline) {
|
|
755
807
|
const answers = await Promise.allSettled(ids.map((id) => this.#api.getRemoteAuthToken(id)));
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
808
|
+
const [deviceAnswer, legacyAnswer] = answers;
|
|
809
|
+
if (deviceAnswer?.status === "fulfilled" && deviceAnswer.value)
|
|
810
|
+
return deviceAnswer.value;
|
|
811
|
+
if (legacyAnswer?.status === "fulfilled" && legacyAnswer.value) {
|
|
812
|
+
Logger2.rawLog(chalk2.yellow(`${this.#api.host} handed the session out for the sign-in URL's id; it should answer by the device code alone.`));
|
|
813
|
+
return legacyAnswer.value;
|
|
814
|
+
}
|
|
759
815
|
const [device, legacy] = answers.map((answer) => answer.status === "rejected" ? answer.reason : null);
|
|
760
816
|
if (RemoteLogin.#isFinal(device))
|
|
761
817
|
throw this.#refusal(device);
|
|
@@ -768,7 +824,7 @@ ${chalk2.bold("Your code:")} ${chalk2.bold.inverse(` ${await RemoteAuthCode.of(r
|
|
|
768
824
|
failures = 0;
|
|
769
825
|
else {
|
|
770
826
|
if (failures++ === 0)
|
|
771
|
-
|
|
827
|
+
Logger2.rawLog(chalk2.yellow(`Could not check the sign-in (${RemoteLogin.#reasonOf(errors[0])}); retrying...`));
|
|
772
828
|
waitMs = Math.max(retryAfterMs, Backoff.delay(failures + 1, { min: this.#pollMs, max: this.#maxBackoffMs }));
|
|
773
829
|
}
|
|
774
830
|
await this.#wait(Math.min(waitMs, Math.max(0, deadline - this.#now())));
|
|
@@ -778,19 +834,22 @@ ${chalk2.bold("Your code:")} ${chalk2.bold.inverse(` ${await RemoteAuthCode.of(r
|
|
|
778
834
|
async#readSelf() {
|
|
779
835
|
let reason = "";
|
|
780
836
|
for (let attempt = 1;attempt <= this.#selfAttempts; attempt++) {
|
|
837
|
+
let self;
|
|
781
838
|
try {
|
|
782
|
-
|
|
783
|
-
if (self)
|
|
784
|
-
return self;
|
|
785
|
-
reason = "the server did not take the new session";
|
|
786
|
-
break;
|
|
839
|
+
self = await this.#api.getRemoteSelf();
|
|
787
840
|
} catch (error) {
|
|
788
841
|
reason = RemoteLogin.#reasonOf(error);
|
|
842
|
+
if (attempt < this.#selfAttempts)
|
|
843
|
+
await this.#wait(Backoff.delay(attempt, { min: 1000, max: 8000 }));
|
|
844
|
+
continue;
|
|
789
845
|
}
|
|
790
|
-
if (
|
|
791
|
-
|
|
846
|
+
if (self)
|
|
847
|
+
return self;
|
|
848
|
+
const { host } = this.#api;
|
|
849
|
+
await GlobalConfig.setHostConfig(getDefaultHostConfig(host));
|
|
850
|
+
throw new Error(chalk2.red(`\u2716 ${host} did not take the session it handed out. Run akan login again.`));
|
|
792
851
|
}
|
|
793
|
-
|
|
852
|
+
Logger2.rawLog(chalk2.yellow(`Could not read the signed-in account (${reason}).`));
|
|
794
853
|
return null;
|
|
795
854
|
}
|
|
796
855
|
static #isFinal(error) {
|
|
@@ -816,7 +875,13 @@ var addRemoteEnvServerValue = "__addRemoteEnvServer";
|
|
|
816
875
|
var removeRemoteEnvServerValue = "__removeRemoteEnvServer";
|
|
817
876
|
|
|
818
877
|
class CloudRunner extends runner("cloud") {
|
|
819
|
-
#akanFrameworkPackages = new Set([
|
|
878
|
+
#akanFrameworkPackages = new Set([
|
|
879
|
+
"akanjs",
|
|
880
|
+
"@akanjs/devkit",
|
|
881
|
+
"@akanjs/cli",
|
|
882
|
+
"@akanjs/language",
|
|
883
|
+
"create-akan-workspace"
|
|
884
|
+
]);
|
|
820
885
|
#getRegistryArgs(registryUrl) {
|
|
821
886
|
return registryUrl ? ["--registry", getNpmRegistryUrl(registryUrl)] : [];
|
|
822
887
|
}
|
|
@@ -860,7 +925,7 @@ class CloudRunner extends runner("cloud") {
|
|
|
860
925
|
const servers = await GlobalConfig.getRemoteEnvServers();
|
|
861
926
|
const serverEntries = Object.entries(servers).sort(([nameA], [nameB]) => nameA.localeCompare(nameB));
|
|
862
927
|
if (serverEntries.length === 0) {
|
|
863
|
-
|
|
928
|
+
Logger3.info("No remote env servers configured. Add the first remote server for SCP mode.");
|
|
864
929
|
return await this.#addRemoteEnvServer();
|
|
865
930
|
}
|
|
866
931
|
const selectedName = await select({
|
|
@@ -890,7 +955,7 @@ class CloudRunner extends runner("cloud") {
|
|
|
890
955
|
if (!await confirm({ message: `Remove remote env server "${selectedName}"?`, default: false }))
|
|
891
956
|
return;
|
|
892
957
|
await GlobalConfig.removeRemoteEnvServer(selectedName);
|
|
893
|
-
|
|
958
|
+
Logger3.info(`Removed remote env server "${selectedName}"`);
|
|
894
959
|
}
|
|
895
960
|
#serverChoice([name, config]) {
|
|
896
961
|
return { name: `${name} (${this.#getSshTarget(config)}${config.port ? `:${config.port}` : ""})`, value: name };
|
|
@@ -910,6 +975,8 @@ class CloudRunner extends runner("cloud") {
|
|
|
910
975
|
}
|
|
911
976
|
#getRemoteEnvArchiveDir() {
|
|
912
977
|
const { repoName } = WorkspaceExecutor.getBaseDevEnv();
|
|
978
|
+
if (!/^[A-Za-z0-9][\w.-]*$/.test(repoName))
|
|
979
|
+
throw new Error(`The repository name "${repoName}" cannot name the remote env folder ~/secrets/<name>: it takes letters, digits, ".", "_" and "-". Set AKAN_PUBLIC_REPO_NAME in the workspace .env to such a name.`);
|
|
913
980
|
return `~/secrets/${repoName}`;
|
|
914
981
|
}
|
|
915
982
|
#getScpTarget(config, remotePath) {
|
|
@@ -928,21 +995,21 @@ class CloudRunner extends runner("cloud") {
|
|
|
928
995
|
const cloudApi = await CloudApi.fromHost(workspace, host);
|
|
929
996
|
const signedIn = await cloudApi.getRemoteSelf().catch(() => null);
|
|
930
997
|
if (signedIn) {
|
|
931
|
-
|
|
998
|
+
Logger3.rawLog(chalk3.green(`
|
|
932
999
|
\u2713 Already logged in akan cloud as ${signedIn.nickname}
|
|
933
1000
|
`));
|
|
934
1001
|
return true;
|
|
935
1002
|
}
|
|
936
1003
|
const self = await new RemoteLogin(cloudApi).signIn();
|
|
937
|
-
|
|
1004
|
+
Logger3.rawLog(chalk3.green(`\r\u2713 Authentication successful!`));
|
|
938
1005
|
if (!self) {
|
|
939
|
-
|
|
1006
|
+
Logger3.rawLog(chalk3.yellow(`The session is saved; run akan login again to check which account it signed in.
|
|
940
1007
|
`));
|
|
941
1008
|
return true;
|
|
942
1009
|
}
|
|
943
|
-
|
|
1010
|
+
Logger3.rawLog(chalk3.green.bold(`
|
|
944
1011
|
\u2728 Welcome aboard, ${self.nickname ?? "anonymous"}!`));
|
|
945
|
-
|
|
1012
|
+
Logger3.rawLog(chalk3.dim(`You're now ready to use Akan CLI!
|
|
946
1013
|
`));
|
|
947
1014
|
return true;
|
|
948
1015
|
}
|
|
@@ -950,17 +1017,17 @@ class CloudRunner extends runner("cloud") {
|
|
|
950
1017
|
const config = await GlobalConfig.getHostConfig(host);
|
|
951
1018
|
if (config.auth?.self || config.auth?.accessToken) {
|
|
952
1019
|
await GlobalConfig.setHostConfig(getDefaultHostConfig(config.host));
|
|
953
|
-
|
|
1020
|
+
Logger3.rawLog(chalk3.magenta.bold(`
|
|
954
1021
|
\uD83D\uDC4B Goodbye, ${config.auth.self?.nickname ?? "anonymous"}!`));
|
|
955
|
-
|
|
1022
|
+
Logger3.rawLog(chalk3.dim(`\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500
|
|
956
1023
|
`));
|
|
957
|
-
|
|
958
|
-
|
|
1024
|
+
Logger3.rawLog(chalk3.cyan("You have been successfully logged out."));
|
|
1025
|
+
Logger3.rawLog(chalk3.dim(`Thank you for using Akan CLI. Come back soon! \uD83C\uDF1F
|
|
959
1026
|
`));
|
|
960
1027
|
} else {
|
|
961
|
-
|
|
1028
|
+
Logger3.rawLog(chalk3.yellow.bold(`
|
|
962
1029
|
\u26A0\uFE0F No active session found`));
|
|
963
|
-
|
|
1030
|
+
Logger3.rawLog(chalk3.dim(`You were not logged in to begin with
|
|
964
1031
|
`));
|
|
965
1032
|
}
|
|
966
1033
|
}
|
|
@@ -970,24 +1037,24 @@ class CloudRunner extends runner("cloud") {
|
|
|
970
1037
|
targets.windows = await this.#askWindowsTestTarget();
|
|
971
1038
|
await GlobalConfig.setTestTargets({ windows: targets.windows });
|
|
972
1039
|
}
|
|
973
|
-
|
|
1040
|
+
Logger3.info(`Testing ${pkgs.join(", ")} on ${platforms.join(", ")} in the background...`);
|
|
974
1041
|
return await PlatformTestRun.start({
|
|
975
1042
|
workspaceRoot: workspace.workspaceRoot,
|
|
976
1043
|
platforms,
|
|
977
1044
|
pkgs,
|
|
978
1045
|
targets,
|
|
979
|
-
onProgress: (message) =>
|
|
1046
|
+
onProgress: (message) => Logger3.info(message)
|
|
980
1047
|
});
|
|
981
1048
|
}
|
|
982
1049
|
async settlePlatformTests(run, { interactive, recordStreaks, checkDrift }) {
|
|
983
1050
|
const results = await run.results();
|
|
984
|
-
|
|
1051
|
+
Logger3.rawLog(`
|
|
985
1052
|
${run.format(results)}
|
|
986
1053
|
`);
|
|
987
1054
|
if (recordStreaks) {
|
|
988
1055
|
const streak = await PlatformTestRun.recordStreaks(results);
|
|
989
1056
|
if (streak?.promoted)
|
|
990
|
-
|
|
1057
|
+
Logger3.info(`${streak.platform} passed ${streak.greenStreak} deploys in a row and now gates every deploy`);
|
|
991
1058
|
}
|
|
992
1059
|
const { blocking, warning } = PlatformTestRun.verdict(results);
|
|
993
1060
|
const unreachable = blocking.filter((result) => result.infraError && !result.packages.length);
|
|
@@ -1022,7 +1089,7 @@ ${run.format(results)}
|
|
|
1022
1089
|
assertPromptable("No Windows test target is configured", {
|
|
1023
1090
|
remedy: "run it once in a terminal, which saves the target to ~/.akan/config.json"
|
|
1024
1091
|
});
|
|
1025
|
-
|
|
1092
|
+
Logger3.info("No Windows test target is configured yet; it is saved to ~/.akan/config.json once entered.");
|
|
1026
1093
|
const required = (value) => !!value.trim();
|
|
1027
1094
|
const host = await this.#ask("Windows host (ip or name): ", required);
|
|
1028
1095
|
const user = await this.#ask("SSH user: ", required);
|
|
@@ -1052,8 +1119,8 @@ ${run.format(results)}
|
|
|
1052
1119
|
const latestPublishedVersion = await getLatestPackageVersion("akanjs", tag, registry).catch(() => null);
|
|
1053
1120
|
const latestPatch = latestPublishedVersion?.startsWith(targetVersionPrefix) ? parseInt(latestPublishedVersion.split(".").at(-1) ?? "-1") : -1;
|
|
1054
1121
|
const nextVersion = `${targetVersionPrefix}.${latestPatch + 1}`;
|
|
1055
|
-
|
|
1056
|
-
|
|
1122
|
+
Logger3.info(`Latest published version of akanjs: ${latestPublishedVersion ?? "none"}`);
|
|
1123
|
+
Logger3.info(`Next version of akanjs: ${nextVersion}`);
|
|
1057
1124
|
for (const library of akanPkgs) {
|
|
1058
1125
|
const packageJson = await workspace.readJson(`pkgs/${library}/package.json`);
|
|
1059
1126
|
const newPackageJson = this.#normalizeAkanPackageJson(packageJson, library, nextVersion);
|
|
@@ -1067,24 +1134,24 @@ ${run.format(results)}
|
|
|
1067
1134
|
remedy: "run it in a terminal"
|
|
1068
1135
|
});
|
|
1069
1136
|
if (confirmPublish && !await confirm({ message: "Are you sure you want to deploy the libraries?" })) {
|
|
1070
|
-
|
|
1137
|
+
Logger3.error("Deployment cancelled");
|
|
1071
1138
|
return;
|
|
1072
1139
|
}
|
|
1073
1140
|
if (!registry) {
|
|
1074
|
-
|
|
1141
|
+
Logger3.info("Logging in to npm...");
|
|
1075
1142
|
await workspace.spawn("npm", ["login"], { stdio: "inherit" });
|
|
1076
|
-
|
|
1143
|
+
Logger3.info("Logged in to npm");
|
|
1077
1144
|
}
|
|
1078
1145
|
for (const library of akanPkgs) {
|
|
1079
|
-
|
|
1146
|
+
Logger3.info(`Publishing ${library}@${nextVersion} to ${registry ?? "npm"}...`);
|
|
1080
1147
|
await workspace.spawn("npm", ["publish", "--tag", tag, ...this.#getRegistryArgs(registry), ...this.#getLocalRegistryAuthArgs(registry)], {
|
|
1081
|
-
cwd:
|
|
1148
|
+
cwd: path8.join(workspace.workspaceRoot, "dist/pkgs", library),
|
|
1082
1149
|
env: this.#getRegistryEnv(registry),
|
|
1083
1150
|
stdio: "inherit"
|
|
1084
1151
|
});
|
|
1085
|
-
|
|
1152
|
+
Logger3.info(`${library}@${nextVersion} is published to ${registry ?? "npm"}`);
|
|
1086
1153
|
}
|
|
1087
|
-
|
|
1154
|
+
Logger3.info(`All libraries are published to ${registry ?? "npm"}`);
|
|
1088
1155
|
}
|
|
1089
1156
|
async update(workspace, tag = "latest", { registryUrl } = {}) {
|
|
1090
1157
|
const registry = registryUrl ? getNpmRegistryUrl(registryUrl) : undefined;
|
|
@@ -1104,7 +1171,7 @@ ${run.format(results)}
|
|
|
1104
1171
|
const rootPackageJson = await workspace.getPackageJson();
|
|
1105
1172
|
if (!rootPackageJson.dependencies)
|
|
1106
1173
|
throw new Error("No dependencies found in package.json");
|
|
1107
|
-
for (const name of ["akanjs", "@akanjs/devkit", "@akanjs/cli"]) {
|
|
1174
|
+
for (const name of ["akanjs", "@akanjs/devkit", "@akanjs/cli", "@akanjs/language"]) {
|
|
1108
1175
|
if (rootPackageJson.dependencies[name])
|
|
1109
1176
|
rootPackageJson.dependencies[name] = latestPublishedVersion;
|
|
1110
1177
|
if (rootPackageJson.devDependencies?.[name])
|
|
@@ -1133,46 +1200,45 @@ ${run.format(results)}
|
|
|
1133
1200
|
const localPath = await cloudApi.downloadEnv(workspaceId).catch((error) => {
|
|
1134
1201
|
throw CloudApi.refusal(error, "downloading its env archive takes the project owner's own `akan login`");
|
|
1135
1202
|
});
|
|
1136
|
-
|
|
1137
|
-
await workspace.spawn("tar", ["-xf", relativePath], { cwd: workspace.workspaceRoot });
|
|
1203
|
+
await EnvArchive.extract(workspace, localPath);
|
|
1138
1204
|
await workspace.remove(localPath);
|
|
1139
1205
|
}
|
|
1140
1206
|
async uploadEnv(cloudApi, workspaceId, filePath) {
|
|
1141
|
-
const file = new File([Bun.file(filePath)],
|
|
1207
|
+
const file = new File([Bun.file(filePath)], path8.basename(filePath));
|
|
1142
1208
|
await cloudApi.uploadEnv(workspaceId, file).catch((error) => {
|
|
1143
1209
|
throw CloudApi.refusal(error, "an env archive is uploaded by a project member signed in with `akan login`");
|
|
1144
1210
|
});
|
|
1145
1211
|
}
|
|
1146
1212
|
async downloadEnvByScp(workspace) {
|
|
1147
1213
|
const envArchivePath = "local/env.tar";
|
|
1148
|
-
const remoteServer = await this.#getRemoteEnvServerWithUsername();
|
|
1149
1214
|
const remoteArchivePath = this.#getRemoteEnvArchivePath();
|
|
1215
|
+
const remoteServer = await this.#getRemoteEnvServerWithUsername();
|
|
1150
1216
|
const remoteTarget = this.#getScpTarget(remoteServer.config, remoteArchivePath);
|
|
1151
1217
|
await workspace.mkdir("local");
|
|
1152
1218
|
await workspace.remove(envArchivePath);
|
|
1153
1219
|
try {
|
|
1154
|
-
|
|
1220
|
+
Logger3.info(`Downloading env archive from remote server "${remoteServer.name}"...`);
|
|
1155
1221
|
await workspace.spawn("scp", this.#getScpArgs(remoteServer.config, remoteTarget, envArchivePath), {
|
|
1156
1222
|
cwd: workspace.workspaceRoot,
|
|
1157
1223
|
stdio: "inherit"
|
|
1158
1224
|
});
|
|
1159
|
-
await
|
|
1225
|
+
await EnvArchive.extract(workspace, envArchivePath);
|
|
1160
1226
|
await workspace.remove(envArchivePath);
|
|
1161
1227
|
} catch (error) {
|
|
1162
1228
|
throw new Error(`Failed to download env archive from remote server "${remoteServer.name}"`, { cause: error });
|
|
1163
1229
|
}
|
|
1164
1230
|
}
|
|
1165
1231
|
async uploadEnvByScp(workspace, filePath) {
|
|
1166
|
-
const remoteServer = await this.#getRemoteEnvServerWithUsername();
|
|
1167
1232
|
const remoteArchiveDir = this.#getRemoteEnvArchiveDir();
|
|
1168
1233
|
const remoteArchivePath = this.#getRemoteEnvArchivePath();
|
|
1234
|
+
const remoteServer = await this.#getRemoteEnvServerWithUsername();
|
|
1169
1235
|
const remoteTarget = this.#getScpTarget(remoteServer.config, remoteArchivePath);
|
|
1170
1236
|
try {
|
|
1171
1237
|
await workspace.spawn("ssh", this.#getSshArgs(remoteServer.config, `mkdir -p ${remoteArchiveDir}`), {
|
|
1172
1238
|
cwd: workspace.workspaceRoot,
|
|
1173
1239
|
stdio: "inherit"
|
|
1174
1240
|
});
|
|
1175
|
-
|
|
1241
|
+
Logger3.info(`Uploading env archive to remote server "${remoteServer.name}"...`);
|
|
1176
1242
|
await workspace.spawn("scp", this.#getScpArgs(remoteServer.config, filePath, remoteTarget), {
|
|
1177
1243
|
cwd: workspace.workspaceRoot,
|
|
1178
1244
|
stdio: "inherit"
|
|
@@ -1182,7 +1248,7 @@ ${run.format(results)}
|
|
|
1182
1248
|
}
|
|
1183
1249
|
}
|
|
1184
1250
|
async gatherEnvFiles(workspace, { scope, archivePath = "local/env.tar" } = {}) {
|
|
1185
|
-
const envFilePattern =
|
|
1251
|
+
const { envFilePattern } = EnvArchive;
|
|
1186
1252
|
const [workspaceAppNames, workspaceLibNames] = await workspace.getExecs();
|
|
1187
1253
|
const appNames = scope?.apps ?? workspaceAppNames;
|
|
1188
1254
|
const libNames = scope?.libs ?? workspaceLibNames;
|
|
@@ -1199,7 +1265,7 @@ ${run.format(results)}
|
|
|
1199
1265
|
if (envFilePaths.length === 0)
|
|
1200
1266
|
throw new Error(scope ? `No environment files found to archive for ${appNames.join(", ") || "(no apps)"}` : "No environment files found to archive");
|
|
1201
1267
|
await workspace.spawn("tar", ["-cf", archivePath, ...envFilePaths], { cwd: workspace.workspaceRoot });
|
|
1202
|
-
|
|
1268
|
+
Logger3.info(`Archived ${envFilePaths.length} environment files to ${archivePath}`);
|
|
1203
1269
|
return { files: envFilePaths, path: archivePath };
|
|
1204
1270
|
}
|
|
1205
1271
|
async#gatherCustomSecretFiles(workspace, appNames) {
|
|
@@ -1208,8 +1274,8 @@ ${run.format(results)}
|
|
|
1208
1274
|
const secretGlobs = config.secrets ?? [];
|
|
1209
1275
|
if (secretGlobs.length === 0)
|
|
1210
1276
|
return [];
|
|
1211
|
-
const appDir =
|
|
1212
|
-
return secretGlobs.flatMap((pattern) => Array.from(new Bun.Glob(pattern).scanSync({ cwd: appDir, onlyFiles: true })).map((match) => `apps/${appName}/${match.split(
|
|
1277
|
+
const appDir = path8.join(workspace.workspaceRoot, "apps", appName);
|
|
1278
|
+
return secretGlobs.flatMap((pattern) => Array.from(new Bun.Glob(pattern).scanSync({ cwd: appDir, onlyFiles: true })).map((match) => `apps/${appName}/${match.split(path8.sep).join("/")}`));
|
|
1213
1279
|
}));
|
|
1214
1280
|
return secretPaths.flat();
|
|
1215
1281
|
}
|
|
@@ -1297,7 +1363,7 @@ ${run.format(results)}
|
|
|
1297
1363
|
if (nextContent === existing)
|
|
1298
1364
|
return;
|
|
1299
1365
|
await workspace.writeFile(".gitignore", nextContent);
|
|
1300
|
-
|
|
1366
|
+
Logger3.info(uniquePatterns.length ? `Synced ${uniquePatterns.length} secret pattern(s) from akan.config.ts to .gitignore` : "Removed managed secret patterns from .gitignore");
|
|
1301
1367
|
}
|
|
1302
1368
|
#applySecretGitignoreBlock(content, patterns) {
|
|
1303
1369
|
const beginMarker = "# akan:secrets (managed by akan.config.ts \u2014 do not edit)";
|
|
@@ -1323,4 +1389,4 @@ ${run.format(results)}
|
|
|
1323
1389
|
}
|
|
1324
1390
|
}
|
|
1325
1391
|
|
|
1326
|
-
export {
|
|
1392
|
+
export { PlatformTestRun, CloudRunner };
|