@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.
- package/.build-stamp +1 -1
- package/CodeAgent-awv258wb.js +9 -0
- package/CodeAgentRpcHost-p7h6n2hp.js +7 -0
- package/CodeAgentRpcListener-7p7z5dd7.js +97 -0
- package/CodeTui-1nqh35ez.js +1457 -0
- package/README.md +3 -0
- package/TunnelShare-scf4e4pd.js +9 -0
- package/{agent.command-d2gfxfck.js → agent.command-1s9ag7sb.js} +8 -9
- package/akanCode.js +102 -0
- package/{application.command-pj2m7584.js → application.command-49hwy6va.js} +51 -78
- package/{applicationBuildRunner-kxwbssgn.js → applicationBuildRunner-ybyp97pv.js} +63 -64
- package/{applicationReleasePackager-4yasxwv9.js → applicationReleasePackager-esnrphw8.js} +40 -60
- package/buildBatch.proc.js +19 -24
- package/{capacitorApp-36rbr858.js → capacitorApp-1synz4en.js} +3 -4
- package/cloud.command-d7rqtzt9.js +94 -0
- package/cloud.script-bkbpcr96.js +19 -0
- package/code.command-nn48xzej.js +154 -0
- package/commandManifest.json +1 -1
- package/consoleToStderr-h5bryj94.js +7 -0
- package/context.command-s3mcmvpa.js +48 -0
- package/context.runner-k99nb5pk.js +21 -0
- package/{dependencyScanner-shs82ynp.js → dependencyScanner-ye2e6pdz.js} +2 -2
- package/{devTui-40ggmd99.js → devTui-q7k7bakd.js} +122 -40
- package/fileSys-5ngz93ga.js +9 -0
- package/guideline.command-sct4qnt5.js +42 -0
- package/guidelines/agentRule/agentRule.instruction.md +206 -25
- package/guidelines/conventions/conventions.instruction.md +79 -24
- package/guidelines/fieldRule/fieldRule.instruction.md +1 -0
- package/guidelines/mcpRule/mcpRule.instruction.md +7 -5
- package/guidelines/queryRule/queryRule.instruction.md +17 -7
- package/guidelines/runtimeRule/runtimeRule.instruction.md +74 -0
- package/guidelines/ssrRule/ssrRule.instruction.md +4 -2
- package/guidelines/transportRule/transportRule.instruction.md +51 -0
- package/guidelines/workspaceRecipes/workspaceRecipes.instruction.md +66 -3
- package/incrementalBuilder.proc.js +31 -48
- package/{index-h7yw2z9n.js → index-0bq14vr1.js} +8 -14
- package/index-13ffe9wp.js +69 -0
- package/index-22d57v4c.js +266 -0
- package/{index-fz5q3gd7.js → index-31yr441d.js} +10 -17
- package/index-3hx1z96c.js +87 -0
- package/index-3sq321ak.js +53 -0
- package/{index-kcxmv48c.js → index-3t7g9e4r.js} +45 -79
- package/{index-q0y2jq9j.js → index-5b6tavv3.js} +6 -3
- package/{index-47pj3aee.js → index-5e0n4hqx.js} +11 -12
- package/{index-259dsnz3.js → index-5pc1qrbv.js} +5 -8
- package/index-7md2g9vw.js +6 -0
- package/index-8mna0947.js +187 -0
- package/{index-zry5nz81.js → index-8sf7wmdr.js} +51 -30
- package/{index-2tv3fdx4.js → index-9d9bgcx4.js} +342 -765
- package/index-9dp031by.js +12 -0
- package/{index-ne2qy0nk.js → index-ahemdr5n.js} +12 -12
- package/{index-ws5e0j51.js → index-as7xmyz8.js} +40 -24
- package/index-axzjaqve.js +1118 -0
- package/{index-3d9y066c.js → index-bjwxs904.js} +9 -8
- package/index-c6eggbee.js +123 -0
- package/index-d2242ksy.js +99 -0
- package/{index-a64esmtb.js → index-ddxvdd1p.js} +169 -305
- package/{index-92zztqy1.js → index-dy0jx9ay.js} +2 -17
- package/{index-pnqbkf5p.js → index-dzf3r49a.js} +6 -2
- package/{index-w8kmx1b6.js → index-fgq75haa.js} +198 -290
- package/{index-by5gpp8x.js → index-hj6w4ka1.js} +2 -1
- package/{index-hwkygn9s.js → index-khpfpcsd.js} +302 -33
- package/{index-wt7qrtd4.js → index-mxav6j3c.js} +93 -232
- package/{index-gyd220p2.js → index-myhc3c1j.js} +554 -577
- package/{index-600zhnve.js → index-nv5976x3.js} +56 -197
- package/index-p6pbz9n5.js +25 -0
- package/{index-4edzf1gr.js → index-przybvy5.js} +77 -150
- package/index-smme4r47.js +49 -0
- package/{index-mak3cd28.js → index-w2zdcw3k.js} +137 -255
- package/index-wa5jbxj1.js +760 -0
- package/{index-v0qh106m.js → index-ww4z397j.js} +527 -723
- package/{index-j9yhg404.js → index-xqjwd384.js} +4 -7
- package/{index-7737gxcp.js → index-xqpzbab5.js} +107 -241
- package/index-xsjh6nzh.js +2729 -0
- package/{index-ktb5njgy.js → index-ygn77a5w.js} +47 -99
- package/index-ztp3e73t.js +700 -0
- package/index.js +23 -22
- package/{library.command-nbsky672.js → library.command-1gx04jgn.js} +4 -5
- package/{localRegistry.command-yeq57wjr.js → localRegistry.command-zndxj1q6.js} +22 -42
- package/{module.command-29vqzrh8.js → module.command-3waddk95.js} +8 -11
- package/{package.command-axv0abmn.js → package.command-zrc7br1y.js} +6 -7
- package/package.json +14 -5
- package/{page.command-vs9s3zrh.js → page.command-vpjgardh.js} +4 -5
- package/{primitive.command-cbxmqbtc.js → primitive.command-sz84tk4t.js} +9 -22
- package/prompter-ptaa3nk0.js +8 -0
- package/{quality.command-gmbs7nws.js → quality.command-g869hafs.js} +203 -376
- package/{recipeScanner-fpagtgc1.js → recipeScanner-4b69ybe0.js} +1 -1
- package/{repair.command-bqsjptsj.js → repair.command-chsnjvvv.js} +11 -35
- package/{routeSourceValidator-apyqw7wk.js → routeSourceValidator-7ycnfz0e.js} +0 -6
- package/{scalar.command-6k1vhe9s.js → scalar.command-2v21newx.js} +7 -10
- package/skills/akan-code/SKILL.md +130 -0
- package/skills/akan-debug/SKILL.md +42 -0
- package/skills/akan-deps/SKILL.md +50 -0
- package/skills/akan-err/SKILL.md +39 -0
- package/skills/akan-module/SKILL.md +45 -0
- package/skills/akan-scaffold/SKILL.md +76 -0
- package/skills/akan-scalar/SKILL.md +52 -0
- package/skills/akan-service/SKILL.md +34 -0
- package/skills/akan-store/SKILL.md +67 -0
- package/skills/akan-ui/SKILL.md +63 -0
- package/skills/akan-validate/SKILL.md +44 -0
- package/{subspace.command-fwjfcts7.js → subspace.command-ckcbwfp1.js} +138 -67
- package/templates/__scalar/__model__/__model__.abstract.md.template +8 -0
- package/templates/appSample/lib/__scalar/workHistory/workHistory.abstract.ts +8 -39
- package/templates/appSample/lib/_noti/noti.abstract.ts +6 -29
- package/templates/appSample/lib/task/task.abstract.ts +12 -32
- package/templates/appSample/lib/task/task.signal.spec.ts +15 -18
- package/templates/appSample/lib/task/task.signal.test.ts +15 -1
- package/templates/appSample/lib/task/task.signal.ts +1 -1
- package/templates/appSample/srvkit/{AuthGuard.ts → guards.ts} +7 -4
- package/templates/appSample/srvkit/{SessionInternalArg.ts → internalArgs.ts} +6 -4
- package/templates/client.ts +7 -30
- package/templates/crudPages/[__model__Id]/edit/page.tsx +2 -1
- package/templates/crudPages/[__model__Id]/page.tsx +2 -1
- package/templates/crudPages/new/page.tsx +2 -1
- package/templates/crudPages/page.tsx +2 -1
- package/templates/crudSinglePage/page.tsx +2 -1
- package/templates/lib/__lib/lib.dictionary.ts +0 -2
- package/templates/lib/__lib/lib.document.ts +0 -2
- package/templates/lib/sig.ts +8 -30
- package/templates/localDev/docker-compose.yaml.template +3 -14
- package/templates/module/__model__.signal.ts +12 -4
- package/templates/pkgRoot/tsconfig.json.template +2 -7
- package/templates/server.ts +0 -2
- package/templates/service/__model__.abstract.md.template +8 -0
- package/tunnel.command-kd2yr4fx.js +129 -0
- package/{typeChecker-3xgrzc2v.js → typeChecker-px49mezc.js} +1 -1
- package/typecheck.proc.js +1 -1
- package/workflow.command-44252cqv.js +79 -0
- package/{workspace.command-8s050m0h.js → workspace.command-fqcztt5p.js} +77 -109
- package/abstractCompactor-mjh5ppsq.js +0 -101
- package/cloud.command-jshwdq22.js +0 -93
- package/context.command-ez8a0zyz.js +0 -80
- package/devTuiView-c08ccbat.js +0 -9
- package/getDirname-dr3jz1xg.js +0 -7
- package/guideline.command-xmqwx8zm.js +0 -359
- package/guidelines/agentRule/agentRule.generate.json +0 -31
- package/guidelines/componentRule/componentRule.generate.json +0 -31
- package/guidelines/conventions/conventions.generate.json +0 -25
- package/guidelines/cssRule/cssRule.generate.json +0 -31
- package/guidelines/docPageRule/docPageRule.generate.json +0 -31
- package/guidelines/docPageRule/docPageRule.instruction.md +0 -25
- package/guidelines/docSyncRule/docSyncRule.generate.json +0 -31
- package/guidelines/docSyncRule/docSyncRule.instruction.md +0 -25
- package/guidelines/enumConstant/enumConstant.generate.json +0 -31
- package/guidelines/enumConstant/enumConstant.instruction.md +0 -28
- package/guidelines/fieldRule/fieldRule.generate.json +0 -31
- package/guidelines/framework/framework.generate.json +0 -32
- package/guidelines/mcpRule/mcpRule.generate.json +0 -35
- package/guidelines/modelConstant/modelConstant.generate.json +0 -32
- package/guidelines/modelDictionary/modelDictionary.generate.json +0 -32
- package/guidelines/modelDocument/modelDocument.generate.json +0 -31
- package/guidelines/modelService/modelService.generate.json +0 -31
- package/guidelines/modelSignal/modelSignal.generate.json +0 -31
- package/guidelines/modelStore/modelStore.generate.json +0 -31
- package/guidelines/modelTemplate/modelTemplate.generate.json +0 -31
- package/guidelines/modelUnit/modelUnit.generate.json +0 -31
- package/guidelines/modelUtil/modelUtil.generate.json +0 -31
- package/guidelines/modelView/modelView.generate.json +0 -31
- package/guidelines/modelZone/modelZone.generate.json +0 -31
- package/guidelines/moduleCodegen/moduleCodegen.generate.json +0 -31
- package/guidelines/moduleCodegen/moduleCodegen.instruction.md +0 -28
- package/guidelines/moduleOverview/moduleOverview.generate.json +0 -31
- package/guidelines/queryRule/queryRule.generate.json +0 -31
- package/guidelines/recipeRule/recipeRule.generate.json +0 -31
- package/guidelines/runtimeRule/runtimeRule.generate.json +0 -25
- package/guidelines/scalarConstant/scalarConstant.generate.json +0 -32
- package/guidelines/scalarDictionary/scalarDictionary.generate.json +0 -32
- package/guidelines/scalarModule/scalarModule.generate.json +0 -31
- package/guidelines/sharedUiUsage/sharedUiUsage.generate.json +0 -31
- package/guidelines/sharedUiUsage/sharedUiUsage.instruction.md +0 -25
- package/guidelines/ssrRule/ssrRule.generate.json +0 -31
- package/guidelines/transportRule/transportRule.generate.json +0 -31
- package/guidelines/utilUiUsage/utilUiUsage.generate.json +0 -31
- package/guidelines/utilUiUsage/utilUiUsage.instruction.md +0 -25
- package/guidelines/workspaceOnboarding/workspaceOnboarding.generate.json +0 -24
- package/guidelines/workspaceRecipes/workspaceRecipes.generate.json +0 -33
- package/index-2hq52jq3.js +0 -465
- package/index-6wwzs1bc.js +0 -7
- package/index-8pm30m73.js +0 -841
- package/index-kn1h7p1x.js +0 -560
- package/index-meh558jy.js +0 -65
- package/index-rwg2aa4f.js +0 -229
- package/templates/__scalar/__model__/__model__.abstract.md +0 -28
- package/templates/module/__model__.abstract.md +0 -28
- package/templates/service/__model__.abstract.md +0 -28
- package/workflow.command-nwpcdc8p.js +0 -107
package/README.md
CHANGED
|
@@ -74,6 +74,9 @@ artifact is built last and is not overwritten by the root `akan` bootstrap scrip
|
|
|
74
74
|
- Use `@akanjs/cli` as the user-facing executable package.
|
|
75
75
|
- `@akanjs/devkit` is bundled into the CLI for published CLI usage; it is not required as a separate
|
|
76
76
|
runtime dependency for ordinary CLI users.
|
|
77
|
+
- The `akan code` agent follows that same split: its engine, tools and skills are a devkit facet
|
|
78
|
+
(`@akanjs/devkit/codeAgent`), and `@akanjs/cli/code` is the terminal host plus the SDK entry that
|
|
79
|
+
re-exports both.
|
|
77
80
|
|
|
78
81
|
## Requirements
|
|
79
82
|
|
|
@@ -2,17 +2,16 @@
|
|
|
2
2
|
import {
|
|
3
3
|
Workspace,
|
|
4
4
|
command
|
|
5
|
-
} from "./index-
|
|
6
|
-
import"./index-
|
|
7
|
-
import"./index-
|
|
8
|
-
import"./index-
|
|
9
|
-
import"./index-
|
|
10
|
-
import"./index-
|
|
11
|
-
import"./index-
|
|
12
|
-
import"./index-h7yw2z9n.js";
|
|
5
|
+
} from "./index-w2zdcw3k.js";
|
|
6
|
+
import"./index-5b6tavv3.js";
|
|
7
|
+
import"./index-9d9bgcx4.js";
|
|
8
|
+
import"./index-hj6w4ka1.js";
|
|
9
|
+
import"./index-myhc3c1j.js";
|
|
10
|
+
import"./index-ygn77a5w.js";
|
|
11
|
+
import"./index-0bq14vr1.js";
|
|
13
12
|
import {
|
|
14
13
|
AgentScript
|
|
15
|
-
} from "./index-
|
|
14
|
+
} from "./index-ahemdr5n.js";
|
|
16
15
|
|
|
17
16
|
// pkgs/@akanjs/cli/agent/agent.command.ts
|
|
18
17
|
class AgentCommand extends command("agent", [AgentScript], ({ public: target }) => ({
|
package/akanCode.js
ADDED
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import {
|
|
3
|
+
AkanEditScope2,
|
|
4
|
+
DevLogFeedback2,
|
|
5
|
+
PreviewChrome2,
|
|
6
|
+
PreviewView2,
|
|
7
|
+
PreviewFeedback2,
|
|
8
|
+
TurnFeedback2,
|
|
9
|
+
AkanCli2,
|
|
10
|
+
AkanVerifier2,
|
|
11
|
+
VerifyFeedback2,
|
|
12
|
+
AkanToolPack2,
|
|
13
|
+
MailToolPack2,
|
|
14
|
+
McpUnauthorized2,
|
|
15
|
+
McpClient2,
|
|
16
|
+
McpToolPack2,
|
|
17
|
+
SessionToolPack2,
|
|
18
|
+
WebToolPack2,
|
|
19
|
+
AkanCodePlugins2,
|
|
20
|
+
AkanEnvKeys2,
|
|
21
|
+
akanSystemPrompt2,
|
|
22
|
+
CodeSessionIndex2,
|
|
23
|
+
AkanCodeServices2,
|
|
24
|
+
CodeAgentAsks2,
|
|
25
|
+
CodeAgentEventMapper2,
|
|
26
|
+
CodeAgentGate2,
|
|
27
|
+
CodeAgentUi2,
|
|
28
|
+
CodeMailbox2,
|
|
29
|
+
CodeSessionFork2,
|
|
30
|
+
CodeAgent2
|
|
31
|
+
} from "./index-xsjh6nzh.js";
|
|
32
|
+
import {
|
|
33
|
+
akanCodeDefaultModel2,
|
|
34
|
+
akanCodeModel2,
|
|
35
|
+
akanCodeModelSupportsImages2,
|
|
36
|
+
akanCodeModelWarnings2,
|
|
37
|
+
CodeAgentStreamPrinter2
|
|
38
|
+
} from "./index-c6eggbee.js";
|
|
39
|
+
import {
|
|
40
|
+
SubagentPool2,
|
|
41
|
+
akanCodePaths2
|
|
42
|
+
} from "./index-ztp3e73t.js";
|
|
43
|
+
import"./index-7md2g9vw.js";
|
|
44
|
+
import {
|
|
45
|
+
CodeAgentRpcHost2
|
|
46
|
+
} from "./index-d2242ksy.js";
|
|
47
|
+
import {
|
|
48
|
+
CodeTuiLines2,
|
|
49
|
+
CodeTuiAgents2,
|
|
50
|
+
CodeTuiClipboard2,
|
|
51
|
+
CodeTuiCommands2,
|
|
52
|
+
CodeTuiEditor2,
|
|
53
|
+
CodeTuiFiles2,
|
|
54
|
+
CodeTuiMarkdown2,
|
|
55
|
+
CodeTuiParts2
|
|
56
|
+
} from "./index-wa5jbxj1.js";
|
|
57
|
+
export {
|
|
58
|
+
AkanCli2 as AkanCli,
|
|
59
|
+
AkanCodePlugins2 as AkanCodePlugins,
|
|
60
|
+
AkanCodeServices2 as AkanCodeServices,
|
|
61
|
+
AkanEditScope2 as AkanEditScope,
|
|
62
|
+
AkanEnvKeys2 as AkanEnvKeys,
|
|
63
|
+
AkanToolPack2 as AkanToolPack,
|
|
64
|
+
AkanVerifier2 as AkanVerifier,
|
|
65
|
+
CodeAgent2 as CodeAgent,
|
|
66
|
+
CodeAgentAsks2 as CodeAgentAsks,
|
|
67
|
+
CodeAgentEventMapper2 as CodeAgentEventMapper,
|
|
68
|
+
CodeAgentGate2 as CodeAgentGate,
|
|
69
|
+
CodeAgentRpcHost2 as CodeAgentRpcHost,
|
|
70
|
+
CodeAgentStreamPrinter2 as CodeAgentStreamPrinter,
|
|
71
|
+
CodeAgentUi2 as CodeAgentUi,
|
|
72
|
+
CodeMailbox2 as CodeMailbox,
|
|
73
|
+
CodeSessionFork2 as CodeSessionFork,
|
|
74
|
+
CodeSessionIndex2 as CodeSessionIndex,
|
|
75
|
+
CodeTuiAgents2 as CodeTuiAgents,
|
|
76
|
+
CodeTuiClipboard2 as CodeTuiClipboard,
|
|
77
|
+
CodeTuiCommands2 as CodeTuiCommands,
|
|
78
|
+
CodeTuiEditor2 as CodeTuiEditor,
|
|
79
|
+
CodeTuiFiles2 as CodeTuiFiles,
|
|
80
|
+
CodeTuiLines2 as CodeTuiLines,
|
|
81
|
+
CodeTuiMarkdown2 as CodeTuiMarkdown,
|
|
82
|
+
CodeTuiParts2 as CodeTuiParts,
|
|
83
|
+
DevLogFeedback2 as DevLogFeedback,
|
|
84
|
+
MailToolPack2 as MailToolPack,
|
|
85
|
+
McpClient2 as McpClient,
|
|
86
|
+
McpToolPack2 as McpToolPack,
|
|
87
|
+
McpUnauthorized2 as McpUnauthorized,
|
|
88
|
+
PreviewChrome2 as PreviewChrome,
|
|
89
|
+
PreviewFeedback2 as PreviewFeedback,
|
|
90
|
+
PreviewView2 as PreviewView,
|
|
91
|
+
SessionToolPack2 as SessionToolPack,
|
|
92
|
+
SubagentPool2 as SubagentPool,
|
|
93
|
+
TurnFeedback2 as TurnFeedback,
|
|
94
|
+
VerifyFeedback2 as VerifyFeedback,
|
|
95
|
+
WebToolPack2 as WebToolPack,
|
|
96
|
+
akanCodeDefaultModel2 as akanCodeDefaultModel,
|
|
97
|
+
akanCodeModel2 as akanCodeModel,
|
|
98
|
+
akanCodeModelSupportsImages2 as akanCodeModelSupportsImages,
|
|
99
|
+
akanCodeModelWarnings2 as akanCodeModelWarnings,
|
|
100
|
+
akanCodePaths2 as akanCodePaths,
|
|
101
|
+
akanSystemPrompt2 as akanSystemPrompt
|
|
102
|
+
};
|
|
@@ -6,30 +6,34 @@ import {
|
|
|
6
6
|
Exec,
|
|
7
7
|
Workspace,
|
|
8
8
|
command
|
|
9
|
-
} from "./index-
|
|
10
|
-
import"./index-
|
|
11
|
-
import"./index-
|
|
12
|
-
import"./index-
|
|
9
|
+
} from "./index-w2zdcw3k.js";
|
|
10
|
+
import"./index-5b6tavv3.js";
|
|
11
|
+
import"./index-9d9bgcx4.js";
|
|
12
|
+
import"./index-khpfpcsd.js";
|
|
13
|
+
import"./index-5pc1qrbv.js";
|
|
13
14
|
import {
|
|
14
15
|
ApplicationScript
|
|
15
|
-
} from "./index-
|
|
16
|
-
import"./index-
|
|
17
|
-
import"./index-
|
|
18
|
-
import {
|
|
19
|
-
AbstractDoc
|
|
20
|
-
} from "./index-meh558jy.js";
|
|
21
|
-
import"./index-j9yhg404.js";
|
|
16
|
+
} from "./index-ww4z397j.js";
|
|
17
|
+
import"./index-7md2g9vw.js";
|
|
18
|
+
import"./index-xqjwd384.js";
|
|
22
19
|
import {
|
|
23
20
|
getMobileTargetChoices
|
|
24
|
-
} from "./index-
|
|
21
|
+
} from "./index-5e0n4hqx.js";
|
|
25
22
|
|
|
26
23
|
// pkgs/@akanjs/cli/application/application.command.ts
|
|
27
|
-
import { select } from "@inquirer/prompts";
|
|
28
24
|
var mobileTargetOption = {
|
|
29
25
|
desc: "mobile target name or all",
|
|
30
26
|
ask: "Select mobile target",
|
|
31
27
|
enum: async ({ app }) => await getMobileTargetChoices(app)
|
|
32
28
|
};
|
|
29
|
+
var devEnvs = ["local", "debug", "develop", "main"];
|
|
30
|
+
var buildEnvOption = { enum: devEnvs, desc: "backend environment", default: "debug" };
|
|
31
|
+
var startEnvOption = { enum: devEnvs, desc: "backend environment", default: "local" };
|
|
32
|
+
var releaseEnvOption = {
|
|
33
|
+
enum: ["debug", "develop", "main", "local"],
|
|
34
|
+
desc: "backend environment",
|
|
35
|
+
default: "main"
|
|
36
|
+
};
|
|
33
37
|
|
|
34
38
|
class ApplicationCommand extends command("application", [ApplicationScript], ({ public: target }) => ({
|
|
35
39
|
createApplication: target({ desc: "Create a new application in the workspace" }).arg("appName", String, { desc: "name of application" }).option("start", Boolean, { desc: "start application", default: false }).with(Workspace).exec(async function(appName, start, workspace) {
|
|
@@ -44,13 +48,6 @@ class ApplicationCommand extends command("application", [ApplicationScript], ({
|
|
|
44
48
|
sync: target({ desc: "Sync dependencies and configuration for an app or library" }).with(Sys).exec(async function(sys) {
|
|
45
49
|
await this.applicationScript.sync(sys);
|
|
46
50
|
}),
|
|
47
|
-
compact: target({ desc: "Compact the *.abstract.md files of an app or library with the AI editor" }).with(Sys).option("module", String, { desc: "single module to compact", nullable: true }).option("minLines", Number, {
|
|
48
|
-
flag: "n",
|
|
49
|
-
desc: "only compact abstracts longer than this",
|
|
50
|
-
default: AbstractDoc.compactMinLines
|
|
51
|
-
}).option("interactive", Boolean, { desc: "confirm or refine each rewrite", default: false }).exec(async function(sys, module, minLines, interactive) {
|
|
52
|
-
await this.applicationScript.compact(sys, { module, minLines, interactive });
|
|
53
|
-
}),
|
|
54
51
|
script: target({ desc: "Run a custom script in the application" }).with(App).arg("filename", String, { desc: "name of script", nullable: true }).exec(async function(app, filename) {
|
|
55
52
|
await this.applicationScript.script(app, filename);
|
|
56
53
|
}),
|
|
@@ -60,7 +57,14 @@ class ApplicationCommand extends command("application", [ApplicationScript], ({
|
|
|
60
57
|
logs: target({ desc: "Tail the running application's logs, filtered (attaches to akan-control.sock)" }).with(App).option("level", String, { desc: "minimum level: trace, verbose, debug, info, warn, error", nullable: true }).option("grep", String, { desc: "substring the message must contain", nullable: true }).option("endpoint", String, {
|
|
61
58
|
desc: "endpoint glob(s), comma-separated: mutation:*, query:userList",
|
|
62
59
|
nullable: true
|
|
63
|
-
}).option("trace", String, { desc: "one request's traceId", nullable: true }).option("child", String, { desc: "replica index(es), comma-separated", nullable: true }).option("role", String, {
|
|
60
|
+
}).option("trace", String, { desc: "one request's traceId", nullable: true }).option("child", String, { desc: "replica index(es), comma-separated", nullable: true }).option("role", String, {
|
|
61
|
+
flag: "R",
|
|
62
|
+
desc: "process role(s): gateway, federation, batch, all, rsc-worker",
|
|
63
|
+
nullable: true
|
|
64
|
+
}).option("origin", String, { desc: "call origin(s): http, websocket, mcp, internal, page", nullable: true }).option("since", String, {
|
|
65
|
+
desc: "only records newer than this: a duration ago in ms, s, m, h or d (30s, 5m, 2h), or an epoch-ms timestamp",
|
|
66
|
+
nullable: true
|
|
67
|
+
}).option("replay", Number, { flag: "n", desc: "records to replay from the buffer before following", default: 0 }).option("json", Boolean, { desc: "print NDJSON records instead of rendered lines", default: false }).option("follow", Boolean, { desc: "keep streaming; pass --follow false for history only", default: true }).option("runtimeDir", String, {
|
|
64
68
|
flag: "d",
|
|
65
69
|
desc: "runtime dir holding akan-control.sock (default: local/apps/<app>/runtime)",
|
|
66
70
|
nullable: true
|
|
@@ -89,37 +93,25 @@ class ApplicationCommand extends command("application", [ApplicationScript], ({
|
|
|
89
93
|
test: target({ desc: "Prepare and test an app, library, or package" }).with(Exec).option("write", Boolean, { desc: "write code generation", default: true }).exec(async function(exec, write) {
|
|
90
94
|
await this.applicationScript.test(exec, { write });
|
|
91
95
|
}),
|
|
92
|
-
buildIos: target({ short: true, desc: "Build iOS app with Capacitor" }).with(App).option("target", String, mobileTargetOption).option("env", String, {
|
|
93
|
-
enum: ["local", "debug", "develop", "main"],
|
|
94
|
-
desc: "backend environment",
|
|
95
|
-
default: "debug"
|
|
96
|
-
}).option("write", Boolean, { desc: "write code generation", default: true }).option("regenerate", Boolean, { flag: "g", desc: "delete and regenerate native project", default: false }).exec(async function(app, target, env, write, regenerate) {
|
|
96
|
+
buildIos: target({ short: true, desc: "Build iOS app with Capacitor" }).with(App).option("target", String, mobileTargetOption).option("env", String, buildEnvOption).option("write", Boolean, { desc: "write code generation", default: true }).option("regenerate", Boolean, { flag: "g", desc: "delete and regenerate native project", default: false }).exec(async function(app, target, env, write, regenerate) {
|
|
97
97
|
await this.applicationScript.buildIos(app, { target, env, write, regenerate });
|
|
98
98
|
}),
|
|
99
|
-
buildAndroid: target({ short: true, desc: "Build Android app with Capacitor" }).with(App).option("target", String, mobileTargetOption).option("env", String, {
|
|
100
|
-
enum: ["local", "debug", "develop", "main"],
|
|
101
|
-
desc: "backend environment",
|
|
102
|
-
default: "debug"
|
|
103
|
-
}).option("write", Boolean, { desc: "write code generation", default: true }).option("regenerate", Boolean, { flag: "g", desc: "delete and regenerate native project", default: false }).exec(async function(app, target, env, write, regenerate) {
|
|
99
|
+
buildAndroid: target({ short: true, desc: "Build Android app with Capacitor" }).with(App).option("target", String, mobileTargetOption).option("env", String, buildEnvOption).option("write", Boolean, { desc: "write code generation", default: true }).option("regenerate", Boolean, { flag: "g", desc: "delete and regenerate native project", default: false }).exec(async function(app, target, env, write, regenerate) {
|
|
104
100
|
await this.applicationScript.buildAndroid(app, { target, env, write, regenerate });
|
|
105
101
|
}),
|
|
106
102
|
start: target({ short: true, desc: "Start development server(s) (frontend SSR + backend)" }).with(Apps).option("plain", Boolean, { desc: "print prefixed lines instead of the full-screen view", default: false }).option("kill", Boolean, { flag: "k", desc: "free the dev ports first, whoever is holding them", default: false }).option("concurrency", Number, {
|
|
107
103
|
desc: "apps to boot at a time (default: what this machine's memory and cores allow)",
|
|
108
104
|
nullable: true
|
|
109
|
-
}).option("dbup", Boolean, { desc: "start the local database first", default: true }).option("open", Boolean, { desc: "open web browser?", default: false }).option("write", Boolean, { desc: "write code generation", default: true }).exec(async function(apps, plain, kill, concurrency, dbup, open, write) {
|
|
110
|
-
await this.applicationScript.start(apps, { plain, kill, concurrency, dbup, open, write });
|
|
111
|
-
}),
|
|
112
|
-
startIos: target({ short: true, desc: "Start iOS app in simulator or device" }).with(App).option("target", String, mobileTargetOption).option("env", String, {
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
default: "local"
|
|
116
|
-
}).option("open", Boolean, { desc: "open ios simulator", default: false }).option("release", Boolean, { desc: "release mode", default: false }).option("write", Boolean, { desc: "write code generation", default: true }).option("regenerate", Boolean, { flag: "g", desc: "delete and regenerate native project", default: false }).option("noAllowProvisioningUpdates", Boolean, {
|
|
117
|
-
desc: "disable automatic iOS provisioning updates for physical devices",
|
|
118
|
-
default: false
|
|
105
|
+
}).option("dbup", Boolean, { desc: "start the local database first", default: true }).option("open", Boolean, { desc: "open web browser?", default: false }).option("share", Boolean, { desc: "also share each app on a public URL through an akan tunnel", default: false }).option("write", Boolean, { desc: "write code generation", default: true }).exec(async function(apps, plain, kill, concurrency, dbup, open, share, write) {
|
|
106
|
+
await this.applicationScript.start(apps, { plain, kill, concurrency, dbup, open, share, write });
|
|
107
|
+
}),
|
|
108
|
+
startIos: target({ short: true, desc: "Start iOS app in simulator or device" }).with(App).option("target", String, mobileTargetOption).option("env", String, startEnvOption).option("open", Boolean, { desc: "open ios simulator", default: false }).option("release", Boolean, { desc: "release mode", default: false }).option("write", Boolean, { desc: "write code generation", default: true }).option("regenerate", Boolean, { flag: "g", desc: "delete and regenerate native project", default: false }).option("allowProvisioningUpdates", Boolean, {
|
|
109
|
+
desc: "let Xcode create or update provisioning profiles for a physical device",
|
|
110
|
+
default: true
|
|
119
111
|
}).option("device", String, {
|
|
120
112
|
desc: "run target to select non-interactively: udid, device name, or runtime (e.g. 'iPhone 16' or 'iOS 18')",
|
|
121
113
|
default: ""
|
|
122
|
-
}).exec(async function(app, target, env, open, release, write, regenerate,
|
|
114
|
+
}).exec(async function(app, target, env, open, release, write, regenerate, allowProvisioningUpdates, device) {
|
|
123
115
|
await this.applicationScript.startIos(app, {
|
|
124
116
|
target,
|
|
125
117
|
env,
|
|
@@ -127,15 +119,11 @@ class ApplicationCommand extends command("application", [ApplicationScript], ({
|
|
|
127
119
|
operation: release ? "release" : "local",
|
|
128
120
|
write,
|
|
129
121
|
regenerate,
|
|
130
|
-
noAllowProvisioningUpdates,
|
|
122
|
+
noAllowProvisioningUpdates: !allowProvisioningUpdates,
|
|
131
123
|
device: device || undefined
|
|
132
124
|
});
|
|
133
125
|
}),
|
|
134
|
-
startAndroid: target({ short: true, desc: "Start Android app in emulator or device" }).with(App).option("target", String, mobileTargetOption).option("env", String, {
|
|
135
|
-
enum: ["local", "debug", "develop", "main"],
|
|
136
|
-
desc: "backend environment",
|
|
137
|
-
default: "local"
|
|
138
|
-
}).option("release", Boolean, { desc: "release mode", default: false }).option("open", Boolean, { desc: "open android simulator", default: false }).option("write", Boolean, { desc: "write code generation", default: true }).option("regenerate", Boolean, { flag: "g", desc: "delete and regenerate native project", default: false }).exec(async function(app, target, env, release, open, write, regenerate) {
|
|
126
|
+
startAndroid: target({ short: true, desc: "Start Android app in emulator or device" }).with(App).option("target", String, mobileTargetOption).option("env", String, startEnvOption).option("release", Boolean, { desc: "release mode", default: false }).option("open", Boolean, { desc: "open android simulator", default: false }).option("write", Boolean, { desc: "write code generation", default: true }).option("regenerate", Boolean, { flag: "g", desc: "delete and regenerate native project", default: false }).exec(async function(app, target, env, release, open, write, regenerate) {
|
|
139
127
|
await this.applicationScript.startAndroid(app, {
|
|
140
128
|
target,
|
|
141
129
|
env,
|
|
@@ -145,24 +133,10 @@ class ApplicationCommand extends command("application", [ApplicationScript], ({
|
|
|
145
133
|
regenerate
|
|
146
134
|
});
|
|
147
135
|
}),
|
|
148
|
-
releaseIos: target({ desc: "Build and package iOS app for release (App Store)" }).with(App).option("target", String, mobileTargetOption).option("env", String, {
|
|
149
|
-
|
|
150
|
-
desc: "backend environment",
|
|
151
|
-
default: "main"
|
|
152
|
-
}).option("write", Boolean, { desc: "write code generation", default: true }).option("regenerate", Boolean, { flag: "g", desc: "delete and regenerate native project", default: false }).option("allowLocalRelease", Boolean, { flag: "l", desc: "allow release with --env local", default: false }).exec(async function(app, target, env, write, regenerate, allowLocalRelease) {
|
|
153
|
-
await this.applicationScript.releaseIos(app, {
|
|
154
|
-
target,
|
|
155
|
-
env,
|
|
156
|
-
write,
|
|
157
|
-
regenerate,
|
|
158
|
-
allowLocalRelease
|
|
159
|
-
});
|
|
136
|
+
releaseIos: target({ desc: "Build and package iOS app for release (App Store)" }).with(App).option("target", String, mobileTargetOption).option("env", String, releaseEnvOption).option("write", Boolean, { desc: "write code generation", default: true }).option("regenerate", Boolean, { flag: "g", desc: "delete and regenerate native project", default: false }).option("allowLocalRelease", Boolean, { flag: "l", desc: "allow release with --env local", default: false }).exec(async function(app, target, env, write, regenerate, allowLocalRelease) {
|
|
137
|
+
await this.applicationScript.releaseIos(app, { target, env, write, regenerate, allowLocalRelease });
|
|
160
138
|
}),
|
|
161
|
-
releaseAndroid: target({ desc: "Build and package Android app for release (Play Store)" }).with(App).option("assembleType", String, { enum: ["apk", "aab"], default: "apk" }).option("target", String, mobileTargetOption).option("env", String, {
|
|
162
|
-
enum: ["debug", "develop", "main", "local"],
|
|
163
|
-
desc: "backend environment",
|
|
164
|
-
default: "main"
|
|
165
|
-
}).option("write", Boolean, { desc: "write code generation", default: true }).option("regenerate", Boolean, { flag: "g", desc: "delete and regenerate native project", default: false }).option("allowLocalRelease", Boolean, { flag: "l", desc: "allow release with --env local", default: false }).exec(async function(app, assembleType, target, env, write, regenerate, allowLocalRelease) {
|
|
139
|
+
releaseAndroid: target({ desc: "Build and package Android app for release (Play Store)" }).with(App).option("assembleType", String, { enum: ["apk", "aab"], default: "apk" }).option("target", String, mobileTargetOption).option("env", String, releaseEnvOption).option("write", Boolean, { desc: "write code generation", default: true }).option("regenerate", Boolean, { flag: "g", desc: "delete and regenerate native project", default: false }).option("allowLocalRelease", Boolean, { flag: "l", desc: "allow release with --env local", default: false }).exec(async function(app, assembleType, target, env, write, regenerate, allowLocalRelease) {
|
|
166
140
|
await this.applicationScript.releaseAndroid(app, assembleType, {
|
|
167
141
|
target,
|
|
168
142
|
env,
|
|
@@ -174,22 +148,21 @@ class ApplicationCommand extends command("application", [ApplicationScript], ({
|
|
|
174
148
|
releaseSource: target({ desc: "Release app source code with OTA update support" }).with(App).option("rebuild", Boolean, { desc: "rebuild", default: false }).option("buildNum", Number, { desc: "build number", default: 0 }).option("environment", String, { desc: "environment", default: "debug" }).option("local", Boolean, { desc: "local", default: true }).exec(async function(app, rebuild, buildNum, environment, local) {
|
|
175
149
|
await this.applicationScript.releaseSource(app, { rebuild, buildNum, environment, local });
|
|
176
150
|
}),
|
|
177
|
-
codepush: target({ desc: "
|
|
178
|
-
|
|
179
|
-
message: "Select os",
|
|
180
|
-
choices: [
|
|
181
|
-
{ value: "ios", name: "ios", description: "ios" },
|
|
182
|
-
{ value: "android", name: "android", description: "android" }
|
|
183
|
-
]
|
|
184
|
-
});
|
|
185
|
-
await this.applicationScript.codepush(app, os);
|
|
151
|
+
codepush: target({ desc: "Over-the-air (OTA) update for a mobile app \u2014 in development, deploys nothing yet" }).with(App).exec(async function(app) {
|
|
152
|
+
await this.applicationScript.codepush(app);
|
|
186
153
|
}),
|
|
187
154
|
dbup: target({ desc: "Start local database services for a database mode" }).with(Workspace).option("mode", String, {
|
|
188
|
-
desc: "database mode",
|
|
189
|
-
|
|
190
|
-
|
|
155
|
+
desc: "database mode; left out, every mode the workspace's apps declare",
|
|
156
|
+
enum: ["single", "multiple", "cluster"],
|
|
157
|
+
nullable: true
|
|
191
158
|
}).exec(async function(workspace, mode) {
|
|
192
|
-
await this.applicationScript.
|
|
159
|
+
await this.applicationScript.dbupDeclared(workspace, mode);
|
|
160
|
+
}),
|
|
161
|
+
dbExport: target({ desc: "Write every model table of an app to one NDJSON file each" }).with(App).option("dir", String, { desc: "directory under the workspace to write", default: "local/transfer" }).exec(async function(app, dir) {
|
|
162
|
+
await this.applicationScript.transferDatabase(app, "export", dir);
|
|
163
|
+
}),
|
|
164
|
+
dbImport: target({ desc: "Read files db-export wrote into an app's database, in the mode the shell names" }).with(App).option("dir", String, { desc: "directory under the workspace to read", default: "local/transfer" }).exec(async function(app, dir) {
|
|
165
|
+
await this.applicationScript.transferDatabase(app, "import", dir);
|
|
193
166
|
}),
|
|
194
167
|
dbdown: target({ desc: "Stop local database services" }).with(Workspace).exec(async function(workspace) {
|
|
195
168
|
await this.applicationScript.dbdown(workspace);
|
|
@@ -1,17 +1,16 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
import {
|
|
3
3
|
Spinner
|
|
4
|
-
} from "./index-
|
|
4
|
+
} from "./index-9d9bgcx4.js";
|
|
5
5
|
import {
|
|
6
6
|
AllRoutesBuilder,
|
|
7
7
|
CsrArtifactBuilder,
|
|
8
8
|
FontPruner,
|
|
9
9
|
precompressArtifacts,
|
|
10
10
|
SsrBaseArtifactBuilder
|
|
11
|
-
} from "./index-
|
|
12
|
-
import"./index-
|
|
13
|
-
import"./index-
|
|
14
|
-
import"./index-hwkygn9s.js";
|
|
11
|
+
} from "./index-ddxvdd1p.js";
|
|
12
|
+
import"./index-fgq75haa.js";
|
|
13
|
+
import"./index-5b6tavv3.js";
|
|
15
14
|
import"./index-n68jx79w.js";
|
|
16
15
|
|
|
17
16
|
// pkgs/@akanjs/devkit/applicationBuildRunner.ts
|
|
@@ -51,6 +50,7 @@ class ApplicationBuildRunner {
|
|
|
51
50
|
#app;
|
|
52
51
|
#fast;
|
|
53
52
|
#reporter;
|
|
53
|
+
#spinner;
|
|
54
54
|
#startedAt = Date.now();
|
|
55
55
|
#phases = [];
|
|
56
56
|
constructor(app, { fast = false, reporter } = {}) {
|
|
@@ -59,21 +59,17 @@ class ApplicationBuildRunner {
|
|
|
59
59
|
this.#reporter = reporter;
|
|
60
60
|
}
|
|
61
61
|
async build({ spinner = false } = {}) {
|
|
62
|
-
|
|
62
|
+
this.#spinner = spinner;
|
|
63
63
|
const { web, assets } = await this.#app.getConfig();
|
|
64
|
-
await this.#runPhase("prepare", "Preparing output directory", () => this.#app.prepareCommand("build")
|
|
65
|
-
spinner
|
|
66
|
-
});
|
|
64
|
+
await this.#runPhase("prepare", "Preparing output directory", () => this.#app.prepareCommand("build"));
|
|
67
65
|
if (!this.#fast)
|
|
68
|
-
await this.#runPhase("typecheck", "Typechecking", () => this.typecheck()
|
|
69
|
-
await this.#runPhase("backend", "Compiling backend", () => this.#buildBackend(), (result) => `${result.entrypoints} entrypoints, ${result.outputs} outputs
|
|
70
|
-
await this.#runPhase("ssr", "Building SSR route artifacts", async () => web.ssr ? await this.#buildSsr() : null, (result) => result ? `${result.allRoutes.manifest.routeIds.length} routes, ${result.allRoutes.manifest.knownEntries.length} entries` : web.ssr ? "skipped" : "disabled by akan.config.ts web.ssr"
|
|
71
|
-
await this.#runPhase("csr", "Building CSR assets", async () => web.csr ? await this.#
|
|
72
|
-
await this.#runPhase("assets", "Trimming unread static assets", async () => assets.pruneFonts ? await new FontPruner(this.#app, assets).prune() : null, (result) => result ? `${result.removed.length} font file(s) dropped, ${ApplicationBuildRunner.formatBytes(result.freedBytes)} freed; ${result.kept.length} kept` : "disabled by akan.config.ts assets.pruneFonts"
|
|
73
|
-
await this.#runPhase("compress", "Compressing static assets", () => precompressArtifacts(this.#app), (result) => result.files > 0 ? `${result.files} files, ${ApplicationBuildRunner.formatBytes(result.inputBytes)} -> gzip ${ApplicationBuildRunner.formatBytes(result.outputBytes)} / br ${ApplicationBuildRunner.formatBytes(result.brotliBytes)}` : "no files"
|
|
74
|
-
await this.#runPhase("metadata", "Writing production metadata", () => this.#buildAppMeta()
|
|
75
|
-
spinner
|
|
76
|
-
});
|
|
66
|
+
await this.#runPhase("typecheck", "Typechecking", () => this.typecheck());
|
|
67
|
+
await this.#runPhase("backend", "Compiling backend", () => this.#buildBackend(), (result) => `${result.entrypoints} entrypoints, ${result.outputs} outputs`);
|
|
68
|
+
await this.#runPhase("ssr", "Building SSR route artifacts", async () => web.ssr ? await this.#buildSsr() : null, (result) => result ? `${result.allRoutes.manifest.routeIds.length} routes, ${result.allRoutes.manifest.knownEntries.length} entries` : web.ssr ? "skipped" : "disabled by akan.config.ts web.ssr");
|
|
69
|
+
await this.#runPhase("csr", "Building CSR assets", async () => web.csr ? await new CsrArtifactBuilder(this.#app, "build").build() : null, (result) => result?.outputDir ?? (web.csr ? "skipped" : "disabled by akan.config.ts web.csr"));
|
|
70
|
+
await this.#runPhase("assets", "Trimming unread static assets", async () => assets.pruneFonts ? await new FontPruner(this.#app, assets).prune() : null, (result) => result ? `${result.removed.length} font file(s) dropped, ${ApplicationBuildRunner.formatBytes(result.freedBytes)} freed; ${result.kept.length} kept` : "disabled by akan.config.ts assets.pruneFonts");
|
|
71
|
+
await this.#runPhase("compress", "Compressing static assets", () => precompressArtifacts(this.#app), (result) => result.files > 0 ? `${result.files} files, ${ApplicationBuildRunner.formatBytes(result.inputBytes)} -> gzip ${ApplicationBuildRunner.formatBytes(result.outputBytes)} / br ${ApplicationBuildRunner.formatBytes(result.brotliBytes)}` : "no files");
|
|
72
|
+
await this.#runPhase("metadata", "Writing production metadata", () => this.#buildAppMeta());
|
|
77
73
|
return {
|
|
78
74
|
phases: this.#phases,
|
|
79
75
|
durationMs: Date.now() - this.#startedAt,
|
|
@@ -84,21 +80,20 @@ class ApplicationBuildRunner {
|
|
|
84
80
|
async typecheck(options = {}) {
|
|
85
81
|
const { clean = false, incremental = true } = options;
|
|
86
82
|
await this.#app.getPageKeys({ refresh: true });
|
|
87
|
-
const { typecheckDir, tsconfigPath } = await this.#writeTypecheckTsconfig(
|
|
83
|
+
const { typecheckDir, tsconfigPath } = await this.#writeTypecheckTsconfig(incremental);
|
|
88
84
|
if (clean)
|
|
89
85
|
await rm(path.join(typecheckDir, "tsconfig.tsbuildinfo"), { force: true });
|
|
90
86
|
await this.#checkProjectInChildProcess(tsconfigPath);
|
|
91
87
|
}
|
|
92
|
-
async#runPhase(id, label, task, summarize
|
|
88
|
+
async#runPhase(id, label, task, summarize) {
|
|
93
89
|
this.#reporter?.phaseStart?.({ id, label });
|
|
94
90
|
const phaseStartedAt = Date.now();
|
|
95
|
-
const spinner =
|
|
91
|
+
const spinner = this.#spinner ? new Spinner(label, { prefix: `${BUILD_PHASE_EMOJIS[id]} ${id}` }).start() : undefined;
|
|
96
92
|
try {
|
|
97
93
|
const result = await task();
|
|
98
94
|
const phase = { id, label, durationMs: Date.now() - phaseStartedAt, summary: summarize?.(result) };
|
|
99
95
|
this.#phases.push(phase);
|
|
100
|
-
|
|
101
|
-
spinner?.succeed(`${label}${summary}`);
|
|
96
|
+
spinner?.succeed(`${label}${phase.summary ? `: ${phase.summary}` : ""}`);
|
|
102
97
|
this.#reporter?.phaseDone?.(phase);
|
|
103
98
|
return result;
|
|
104
99
|
} catch (error) {
|
|
@@ -111,59 +106,72 @@ class ApplicationBuildRunner {
|
|
|
111
106
|
const akanConfig = await this.#app.getConfig();
|
|
112
107
|
await Promise.all([
|
|
113
108
|
this.#app.dist.writeJson("package.json", akanConfig.getProductionPackageJson()),
|
|
114
|
-
this.#app.dist.writeFile(`${this.#app.dist.cwdPath}/Dockerfile`, akanConfig.dockerfile)
|
|
109
|
+
this.#app.dist.writeFile(`${this.#app.dist.cwdPath}/Dockerfile`, akanConfig.dockerfile),
|
|
110
|
+
this.#app.dist.writeJson("akan.build.json", {
|
|
111
|
+
buildId: await this.#resolveBuildId(),
|
|
112
|
+
akanVersion: akanConfig.akanVersion,
|
|
113
|
+
builtAt: new Date().toISOString()
|
|
114
|
+
})
|
|
115
115
|
]);
|
|
116
116
|
}
|
|
117
|
+
async#resolveBuildId() {
|
|
118
|
+
const fromEnv = process.env.AKAN_BUILD_ID?.trim();
|
|
119
|
+
if (fromEnv)
|
|
120
|
+
return fromEnv;
|
|
121
|
+
const root = this.#app.workspace.workspaceRoot;
|
|
122
|
+
const sha = Bun.spawnSync(["git", "rev-parse", "--short=12", "HEAD"], { cwd: root, stderr: "ignore" });
|
|
123
|
+
if (sha.exitCode !== 0)
|
|
124
|
+
return null;
|
|
125
|
+
const dirty = Bun.spawnSync(["git", "status", "--porcelain", "--untracked-files=no"], {
|
|
126
|
+
cwd: root,
|
|
127
|
+
stderr: "ignore"
|
|
128
|
+
});
|
|
129
|
+
const suffix = dirty.exitCode === 0 && dirty.stdout.toString().trim() ? "-dirty" : "";
|
|
130
|
+
return `${sha.stdout.toString().trim()}${suffix}`;
|
|
131
|
+
}
|
|
117
132
|
async#buildBackend() {
|
|
118
|
-
const
|
|
119
|
-
const backendExternals = [
|
|
120
|
-
...new Set([...akanConfig.externalLibs, ...SSR_RENDER_EXTERNALS, ...AKAN_OPTIONAL_BACKEND_EXTERNALS])
|
|
121
|
-
];
|
|
122
|
-
const { web } = akanConfig;
|
|
133
|
+
const { externalLibs, web } = await this.#app.getConfig();
|
|
123
134
|
const backendEntryPoints = [`${this.#app.cwdPath}/main.ts`, `${this.#app.cwdPath}/server.ts`];
|
|
124
135
|
for (const entrypoint of backendEntryPoints) {
|
|
125
136
|
if (!await Bun.file(entrypoint).exists())
|
|
126
137
|
throw new Error(`Backend entrypoint not found: ${entrypoint}`);
|
|
127
138
|
}
|
|
128
|
-
const
|
|
129
|
-
entrypoints: backendEntryPoints,
|
|
139
|
+
const sharedConfig = {
|
|
130
140
|
outdir: this.#app.dist.cwdPath,
|
|
131
141
|
target: "bun",
|
|
132
142
|
minify: AKAN_BACKEND_MINIFY,
|
|
133
143
|
naming: { entry: "[name].[ext]", chunk: "chunk-[hash].[ext]" },
|
|
134
|
-
define: { "process.env.NODE_ENV": JSON.stringify("production") }
|
|
135
|
-
|
|
136
|
-
}
|
|
144
|
+
define: { "process.env.NODE_ENV": JSON.stringify("production") }
|
|
145
|
+
};
|
|
146
|
+
const backendConfig = { ...sharedConfig, plugins: [this.#createExternalSpecifiersPlugin(externalLibs)] };
|
|
147
|
+
const [mainResult, serverResult] = [
|
|
148
|
+
await this.#buildOrThrow("backend", { ...backendConfig, entrypoints: [backendEntryPoints[0]] }),
|
|
149
|
+
await this.#buildOrThrow("backend", { ...backendConfig, entrypoints: [backendEntryPoints[1]], splitting: true })
|
|
150
|
+
];
|
|
137
151
|
const rscWorkerResult = web.ssr ? await this.#buildOrThrow("rsc-worker", {
|
|
152
|
+
...backendConfig,
|
|
138
153
|
entrypoints: [this.#resolveRscWorkerBuildEntry()],
|
|
139
|
-
|
|
140
|
-
target: "bun",
|
|
141
|
-
minify: AKAN_BACKEND_MINIFY,
|
|
142
|
-
naming: { entry: "[name].[ext]", chunk: "chunk-[hash].[ext]" },
|
|
143
|
-
conditions: ["react-server"],
|
|
144
|
-
define: { "process.env.NODE_ENV": JSON.stringify("production") },
|
|
145
|
-
plugins: backendExternals.length > 0 ? [this.#createExternalSpecifiersPlugin(backendExternals)] : []
|
|
154
|
+
conditions: ["react-server"]
|
|
146
155
|
}) : null;
|
|
147
156
|
const consoleRuntimeResult = await this.#buildOrThrow("console-runtime", {
|
|
157
|
+
...sharedConfig,
|
|
148
158
|
entrypoints: [this.#resolveConsoleRuntimeBuildEntry()],
|
|
149
|
-
|
|
150
|
-
target: "bun",
|
|
151
|
-
minify: AKAN_BACKEND_MINIFY,
|
|
152
|
-
naming: { entry: "console-runtime.[ext]", chunk: "chunk-[hash].[ext]" },
|
|
153
|
-
define: { "process.env.NODE_ENV": JSON.stringify("production") }
|
|
159
|
+
naming: { entry: "console-runtime.[ext]", chunk: "chunk-[hash].[ext]" }
|
|
154
160
|
});
|
|
155
161
|
await this.#writeConsoleShim();
|
|
162
|
+
const results = [mainResult, serverResult, rscWorkerResult, consoleRuntimeResult];
|
|
156
163
|
return {
|
|
157
164
|
entrypoints: backendEntryPoints.length + (rscWorkerResult ? 2 : 1),
|
|
158
|
-
outputs:
|
|
165
|
+
outputs: results.reduce((sum, result) => sum + (result?.outputs.length ?? 0), 1)
|
|
159
166
|
};
|
|
160
167
|
}
|
|
161
168
|
async#writeConsoleShim() {
|
|
162
|
-
await Bun.write(path.join(this.#app.dist.cwdPath, "console.js"), `
|
|
163
|
-
|
|
169
|
+
await Bun.write(path.join(this.#app.dist.cwdPath, "console.js"), `process.env.AKAN_COMMAND_TYPE = "console";
|
|
170
|
+
const { cnst, db, dict, option, server, sig, srv } = await import("./server.js");
|
|
171
|
+
const { assertAkanConsoleAllowed, startAkanConsole } = await import("./console-runtime.js");
|
|
164
172
|
|
|
165
173
|
const run = async () => {
|
|
166
|
-
assertAkanConsoleAllowed(
|
|
174
|
+
assertAkanConsoleAllowed();
|
|
167
175
|
await server.start({ listen: false, web: false });
|
|
168
176
|
try {
|
|
169
177
|
await startAkanConsole(server, { globals: { cnst, db, dict, option, sig, srv } });
|
|
@@ -192,9 +200,6 @@ void run().catch((error) => {
|
|
|
192
200
|
return path.join(this.#app.workspace.workspaceRoot, "pkgs/akanjs/server/console.ts");
|
|
193
201
|
}
|
|
194
202
|
}
|
|
195
|
-
async#buildCsr() {
|
|
196
|
-
return await new CsrArtifactBuilder(this.#app, "build").build();
|
|
197
|
-
}
|
|
198
203
|
async#buildSsr() {
|
|
199
204
|
const pageKeys = await this.#app.getPageKeys();
|
|
200
205
|
if (pageKeys.length === 0) {
|
|
@@ -205,7 +210,7 @@ void run().catch((error) => {
|
|
|
205
210
|
const allRoutes = await new AllRoutesBuilder(this.#app, base.artifact, "build").build();
|
|
206
211
|
return { base, allRoutes };
|
|
207
212
|
}
|
|
208
|
-
async#writeTypecheckTsconfig(
|
|
213
|
+
async#writeTypecheckTsconfig(incremental) {
|
|
209
214
|
const typecheckDir = path.join(this.#app.cwdPath, ".akan", "typecheck");
|
|
210
215
|
await mkdir(typecheckDir, { recursive: true });
|
|
211
216
|
const libPageIncludes = (await this.#app.getPageRoots()).filter((root) => root.keyPrefix).flatMap((root) => {
|
|
@@ -272,9 +277,9 @@ void run().catch((error) => {
|
|
|
272
277
|
throw new AggregateError(result.logs, `[${label}] Bun.build failed`);
|
|
273
278
|
return result;
|
|
274
279
|
}
|
|
275
|
-
#createExternalSpecifiersPlugin(
|
|
276
|
-
const
|
|
277
|
-
const escaped =
|
|
280
|
+
#createExternalSpecifiersPlugin(externalLibs) {
|
|
281
|
+
const specifiers = new Set([...externalLibs, ...SSR_RENDER_EXTERNALS, ...AKAN_OPTIONAL_BACKEND_EXTERNALS]);
|
|
282
|
+
const escaped = [...specifiers].map((specifier) => specifier.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"));
|
|
278
283
|
const filter = new RegExp(`^(${escaped.join("|")})(?:/.*)?$`);
|
|
279
284
|
return {
|
|
280
285
|
name: "akan-backend-externalize-specifiers",
|
|
@@ -283,13 +288,7 @@ void run().catch((error) => {
|
|
|
283
288
|
}
|
|
284
289
|
};
|
|
285
290
|
}
|
|
286
|
-
static formatBytes
|
|
287
|
-
if (bytes < 1024)
|
|
288
|
-
return `${bytes}B`;
|
|
289
|
-
if (bytes < 1024 * 1024)
|
|
290
|
-
return `${(bytes / 1024).toFixed(1)}KB`;
|
|
291
|
-
return `${(bytes / 1024 / 1024).toFixed(1)}MB`;
|
|
292
|
-
}
|
|
291
|
+
static formatBytes = FontPruner.formatBytes;
|
|
293
292
|
}
|
|
294
293
|
export {
|
|
295
294
|
ApplicationBuildRunner
|