@akanjs/cli 3.0.0-beta.2 → 3.0.0-beta.21
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-q2m47rqp.js +9 -0
- package/CodeAgentRpcHost-p7h6n2hp.js +7 -0
- package/CodeAgentRpcListener-7p7z5dd7.js +97 -0
- package/CodeTui-pdqhc3sn.js +1457 -0
- package/README.md +3 -0
- package/TunnelShare-scf4e4pd.js +9 -0
- package/{agent.command-d2gfxfck.js → agent.command-ttn09rx3.js} +8 -9
- package/akanCode.js +102 -0
- package/application.command-7gweenv7.js +179 -0
- package/{applicationBuildRunner-kxwbssgn.js → applicationBuildRunner-38exmejd.js} +63 -64
- package/buildBatch.proc.js +26 -25
- package/cloud.command-bhztw7c2.js +95 -0
- package/cloud.script-aabyhgba.js +20 -0
- package/code.command-6s8c0k91.js +154 -0
- package/commandManifest.json +1 -1
- package/consoleToStderr-h5bryj94.js +7 -0
- package/context.command-phmgywt2.js +48 -0
- package/context.runner-yvyw5g2d.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-7jk47fgq.js +42 -0
- package/guidelines/agentRule/agentRule.instruction.md +209 -28
- package/guidelines/conventions/conventions.instruction.md +96 -29
- 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 +77 -3
- 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-259dsnz3.js → index-1db2cw0y.js} +5 -8
- package/index-22d57v4c.js +266 -0
- package/index-3hx1z96c.js +87 -0
- package/{index-kcxmv48c.js → index-3t7g9e4r.js} +45 -79
- package/{index-ne2qy0nk.js → index-4dn1p115.js} +12 -12
- package/{index-q0y2jq9j.js → index-5b6tavv3.js} +6 -3
- package/index-7cqjvraf.js +69 -0
- package/index-7md2g9vw.js +6 -0
- package/{index-zry5nz81.js → index-8kb5p54p.js} +51 -30
- package/{index-ktb5njgy.js → index-9629w7ns.js} +49 -99
- package/index-9dp031by.js +12 -0
- package/{index-a64esmtb.js → index-aadpbnt2.js} +172 -308
- package/{index-3d9y066c.js → index-bjwxs904.js} +9 -8
- package/index-c6eggbee.js +123 -0
- package/index-d0arnrm8.js +700 -0
- package/index-d2242ksy.js +99 -0
- package/{index-600zhnve.js → index-dg97qp24.js} +70 -200
- package/{index-92zztqy1.js → index-dy0jx9ay.js} +2 -17
- package/{index-w8kmx1b6.js → index-fgq75haa.js} +198 -290
- package/{index-2tv3fdx4.js → index-ga6hygxr.js} +944 -1333
- package/{index-by5gpp8x.js → index-hj6w4ka1.js} +2 -1
- package/index-hr5n7t4x.js +465 -0
- package/{index-hwkygn9s.js → index-khpfpcsd.js} +302 -33
- package/{index-7737gxcp.js → index-m0ms3n1c.js} +107 -241
- package/{index-ws5e0j51.js → index-mgfx3mfs.js} +43 -26
- package/index-p6pbz9n5.js +25 -0
- package/index-pp54p5zk.js +53 -0
- package/{index-j9yhg404.js → index-q44jbw48.js} +4 -7
- package/{index-mak3cd28.js → index-rmcw8yc8.js} +137 -255
- package/{index-pnqbkf5p.js → index-rnt66vym.js} +6 -2
- package/index-smme4r47.js +49 -0
- package/index-tgjy8xf3.js +187 -0
- package/index-v5eayqqw.js +2729 -0
- package/index-wa5jbxj1.js +760 -0
- package/{index-4edzf1gr.js → index-wp43xrjv.js} +77 -150
- package/{index-fz5q3gd7.js → index-ya5qbmyg.js} +10 -17
- package/index-yjkte9aj.js +1119 -0
- package/{index-gyd220p2.js → index-yy4s1j72.js} +554 -577
- package/{index-v0qh106m.js → index-z50k041j.js} +580 -862
- package/index.js +23 -22
- package/{library.command-nbsky672.js → library.command-ccb1cp92.js} +4 -5
- package/{localRegistry.command-yeq57wjr.js → localRegistry.command-ajb9n87j.js} +23 -42
- package/{module.command-29vqzrh8.js → module.command-5k6h407d.js} +8 -11
- package/{package.command-axv0abmn.js → package.command-e6ntvpez.js} +6 -7
- package/package.json +14 -6
- package/{page.command-vs9s3zrh.js → page.command-v4f90wb8.js} +4 -5
- package/{primitive.command-cbxmqbtc.js → primitive.command-g6km57q5.js} +9 -22
- package/prompter-ptaa3nk0.js +8 -0
- package/{quality.command-gmbs7nws.js → quality.command-de3p36pz.js} +205 -377
- package/{recipeScanner-fpagtgc1.js → recipeScanner-4b69ybe0.js} +1 -1
- package/{repair.command-bqsjptsj.js → repair.command-d3x1javq.js} +11 -35
- package/{routeSourceValidator-apyqw7wk.js → routeSourceValidator-7ycnfz0e.js} +0 -6
- package/{scalar.command-6k1vhe9s.js → scalar.command-7ezrac2b.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-ps71ynp6.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/templates/workspaceRoot/.gitignore.template +0 -1
- package/tunnel.command-hsrv2mny.js +129 -0
- package/{typeChecker-3xgrzc2v.js → typeChecker-px49mezc.js} +1 -1
- package/typecheck.proc.js +1 -1
- package/workflow.command-z2p32nmf.js +79 -0
- package/{workspace.command-8s050m0h.js → workspace.command-tmdqkrh0.js} +77 -109
- package/abstractCompactor-mjh5ppsq.js +0 -101
- package/application.command-pj2m7584.js +0 -204
- package/applicationReleasePackager-4yasxwv9.js +0 -244
- package/capacitorApp-36rbr858.js +0 -12
- 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-47pj3aee.js +0 -76
- 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/index-wt7qrtd4.js +0 -1516
- 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-rmcw8yc8.js";
|
|
6
|
+
import"./index-5b6tavv3.js";
|
|
7
|
+
import"./index-ga6hygxr.js";
|
|
8
|
+
import"./index-hj6w4ka1.js";
|
|
9
|
+
import"./index-yy4s1j72.js";
|
|
10
|
+
import"./index-9629w7ns.js";
|
|
11
|
+
import"./index-0bq14vr1.js";
|
|
13
12
|
import {
|
|
14
13
|
AgentScript
|
|
15
|
-
} from "./index-
|
|
14
|
+
} from "./index-4dn1p115.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-v5eayqqw.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-d0arnrm8.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
|
+
};
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import {
|
|
3
|
+
App,
|
|
4
|
+
Apps,
|
|
5
|
+
Sys,
|
|
6
|
+
Exec,
|
|
7
|
+
Workspace,
|
|
8
|
+
command
|
|
9
|
+
} from "./index-rmcw8yc8.js";
|
|
10
|
+
import"./index-5b6tavv3.js";
|
|
11
|
+
import"./index-ga6hygxr.js";
|
|
12
|
+
import {
|
|
13
|
+
getMobileTargetChoices
|
|
14
|
+
} from "./index-hr5n7t4x.js";
|
|
15
|
+
import"./index-khpfpcsd.js";
|
|
16
|
+
import"./index-1db2cw0y.js";
|
|
17
|
+
import {
|
|
18
|
+
ApplicationScript
|
|
19
|
+
} from "./index-z50k041j.js";
|
|
20
|
+
import"./index-7md2g9vw.js";
|
|
21
|
+
import"./index-q44jbw48.js";
|
|
22
|
+
|
|
23
|
+
// pkgs/@akanjs/cli/application/application.command.ts
|
|
24
|
+
var mobileTargetOption = {
|
|
25
|
+
desc: "mobile target name or all",
|
|
26
|
+
ask: "Select mobile target",
|
|
27
|
+
enum: async ({ app }) => await getMobileTargetChoices(app)
|
|
28
|
+
};
|
|
29
|
+
var deviceOption = {
|
|
30
|
+
desc: "simulator, emulator or device to run on: its id or name (e.g. 'iPhone 17' or 'Pixel_10')",
|
|
31
|
+
default: ""
|
|
32
|
+
};
|
|
33
|
+
var teamOption = { flag: "T", desc: "Apple team id the signing is narrowed to", default: "" };
|
|
34
|
+
var devEnvs = ["local", "debug", "develop", "main"];
|
|
35
|
+
var buildEnvOption = { enum: devEnvs, desc: "backend environment", default: "debug" };
|
|
36
|
+
var startEnvOption = { enum: devEnvs, desc: "backend environment", default: "local" };
|
|
37
|
+
var releaseEnvOption = {
|
|
38
|
+
enum: ["debug", "develop", "main", "local"],
|
|
39
|
+
desc: "backend environment",
|
|
40
|
+
default: "main"
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
class ApplicationCommand extends command("application", [ApplicationScript], ({ public: target }) => ({
|
|
44
|
+
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) {
|
|
45
|
+
await this.applicationScript.createApplication(appName.toLowerCase().replace(/ /g, "-"), workspace, { start });
|
|
46
|
+
}),
|
|
47
|
+
removeApplication: target({ desc: "Remove an application from the workspace" }).with(App).exec(async function(app) {
|
|
48
|
+
await this.applicationScript.removeApplication(app);
|
|
49
|
+
}),
|
|
50
|
+
planSlice: target({ desc: "List the exact files an app needs to live in a workspace of its own" }).with(App).option("format", String, { desc: "output format", default: "text", enum: ["text", "json"] }).exec(async function(app, format) {
|
|
51
|
+
await this.applicationScript.planSlice(app, format);
|
|
52
|
+
}),
|
|
53
|
+
sync: target({ desc: "Sync dependencies and configuration for an app or library" }).with(Sys).exec(async function(sys) {
|
|
54
|
+
await this.applicationScript.sync(sys);
|
|
55
|
+
}),
|
|
56
|
+
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) {
|
|
57
|
+
await this.applicationScript.script(app, filename);
|
|
58
|
+
}),
|
|
59
|
+
console: target({ desc: "Open an interactive server console for the application" }).with(App).exec(async function(app) {
|
|
60
|
+
await this.applicationScript.console(app);
|
|
61
|
+
}),
|
|
62
|
+
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, {
|
|
63
|
+
desc: "endpoint glob(s), comma-separated: mutation:*, query:userList",
|
|
64
|
+
nullable: true
|
|
65
|
+
}).option("trace", String, { desc: "one request's traceId", nullable: true }).option("child", String, { desc: "replica index(es), comma-separated", nullable: true }).option("role", String, {
|
|
66
|
+
flag: "R",
|
|
67
|
+
desc: "process role(s): gateway, federation, batch, all, rsc-worker",
|
|
68
|
+
nullable: true
|
|
69
|
+
}).option("origin", String, { desc: "call origin(s): http, websocket, mcp, internal, page", nullable: true }).option("since", String, {
|
|
70
|
+
desc: "only records newer than this: a duration ago in ms, s, m, h or d (30s, 5m, 2h), or an epoch-ms timestamp",
|
|
71
|
+
nullable: true
|
|
72
|
+
}).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, {
|
|
73
|
+
flag: "d",
|
|
74
|
+
desc: "runtime dir holding akan-control.sock (default: local/apps/<app>/runtime)",
|
|
75
|
+
nullable: true
|
|
76
|
+
}).exec(async function(app, level, grep, endpoint, trace, child, role, origin, since, replay, json, follow, runtimeDir) {
|
|
77
|
+
await this.applicationScript.logs(app, {
|
|
78
|
+
level,
|
|
79
|
+
grep,
|
|
80
|
+
endpoint,
|
|
81
|
+
trace,
|
|
82
|
+
child,
|
|
83
|
+
role,
|
|
84
|
+
origin,
|
|
85
|
+
since,
|
|
86
|
+
replay,
|
|
87
|
+
json,
|
|
88
|
+
follow,
|
|
89
|
+
runtimeDir
|
|
90
|
+
});
|
|
91
|
+
}),
|
|
92
|
+
build: target({ short: true, desc: "Build the application for production (frontend + backend)" }).with(App).option("write", Boolean, { desc: "write code generation", default: true }).option("fast", Boolean, { desc: "fast build", default: false }).option("quiet", Boolean, { desc: "hide build progress output", default: false }).exec(async function(app, write, fast, quiet) {
|
|
93
|
+
await this.applicationScript.build(app, { write, fast, quiet });
|
|
94
|
+
}),
|
|
95
|
+
typecheck: target({ short: true, desc: "Typecheck the application" }).with(App).option("write", Boolean, { desc: "write code generation", default: true }).option("clean", Boolean, { desc: "clear typecheck cache before running", default: false }).option("incremental", Boolean, { desc: "reuse TypeScript incremental cache", default: true }).exec(async function(app, write, clean, incremental) {
|
|
96
|
+
await this.applicationScript.typecheck(app, { write, clean, incremental });
|
|
97
|
+
}),
|
|
98
|
+
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) {
|
|
99
|
+
await this.applicationScript.test(exec, { write });
|
|
100
|
+
}),
|
|
101
|
+
buildIos: target({ short: true, desc: "Build the iOS app on the native runtime" }).with(App).option("target", String, mobileTargetOption).option("env", String, buildEnvOption).option("debug", Boolean, { desc: "debug build instead of release", default: false }).option("write", Boolean, { desc: "write code generation", default: true }).exec(async function(app, target, env, debug, write) {
|
|
102
|
+
await this.applicationScript.buildIos(app, { target, env, profile: debug ? "debug" : "release", write });
|
|
103
|
+
}),
|
|
104
|
+
buildAndroid: target({ short: true, desc: "Build the Android app (apk) on the native runtime" }).with(App).option("target", String, mobileTargetOption).option("env", String, buildEnvOption).option("debug", Boolean, { desc: "debug build instead of release", default: false }).option("write", Boolean, { desc: "write code generation", default: true }).exec(async function(app, target, env, debug, write) {
|
|
105
|
+
await this.applicationScript.buildAndroid(app, { target, env, profile: debug ? "debug" : "release", write });
|
|
106
|
+
}),
|
|
107
|
+
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, {
|
|
108
|
+
desc: "apps to boot at a time (default: what this machine's memory and cores allow)",
|
|
109
|
+
nullable: true
|
|
110
|
+
}).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) {
|
|
111
|
+
await this.applicationScript.start(apps, { plain, kill, concurrency, dbup, open, share, write });
|
|
112
|
+
}),
|
|
113
|
+
startIos: target({ short: true, desc: "Run the iOS app in a simulator or on an iPhone, following `akan start`" }).with(App).option("target", String, mobileTargetOption).option("env", String, startEnvOption).option("release", Boolean, { desc: "run a release build of its own bundle instead", default: false }).option("device", String, deviceOption).option("team", String, teamOption).option("write", Boolean, { desc: "write code generation", default: true }).exec(async function(app, target, env, release, device, team, write) {
|
|
114
|
+
await this.applicationScript.startIos(app, {
|
|
115
|
+
target,
|
|
116
|
+
env,
|
|
117
|
+
operation: release ? "release" : "local",
|
|
118
|
+
device: device || undefined,
|
|
119
|
+
teamId: team || undefined,
|
|
120
|
+
write
|
|
121
|
+
});
|
|
122
|
+
}),
|
|
123
|
+
startAndroid: target({
|
|
124
|
+
short: true,
|
|
125
|
+
desc: "Run the Android app in an emulator or on a device, following `akan start`"
|
|
126
|
+
}).with(App).option("target", String, mobileTargetOption).option("env", String, startEnvOption).option("release", Boolean, { desc: "run a release build of its own bundle instead", default: false }).option("device", String, deviceOption).option("write", Boolean, { desc: "write code generation", default: true }).exec(async function(app, target, env, release, device, write) {
|
|
127
|
+
await this.applicationScript.startAndroid(app, {
|
|
128
|
+
target,
|
|
129
|
+
env,
|
|
130
|
+
operation: release ? "release" : "local",
|
|
131
|
+
device: device || undefined,
|
|
132
|
+
write
|
|
133
|
+
});
|
|
134
|
+
}),
|
|
135
|
+
startDesktop: target({
|
|
136
|
+
short: true,
|
|
137
|
+
desc: "Run the desktop app on this computer (macOS, Windows or Linux), following `akan start`"
|
|
138
|
+
}).with(App).option("target", String, mobileTargetOption).option("env", String, startEnvOption).option("release", Boolean, { desc: "run a release build of its own bundle instead", default: false }).option("write", Boolean, { desc: "write code generation", default: true }).exec(async function(app, target, env, release, write) {
|
|
139
|
+
await this.applicationScript.startDesktop(app, { target, env, operation: release ? "release" : "local", write });
|
|
140
|
+
}),
|
|
141
|
+
releaseIos: target({ desc: "Build and sign the iOS app for the App Store (.ipa)" }).with(App).option("target", String, mobileTargetOption).option("env", String, releaseEnvOption).option("team", String, teamOption).option("adHoc", Boolean, { desc: "sign with an ad-hoc profile instead of app-store", default: false }).option("write", Boolean, { desc: "write code generation", default: true }).option("allowLocalRelease", Boolean, { flag: "l", desc: "allow release with --env local", default: false }).exec(async function(app, target, env, team, adHoc, write, allowLocalRelease) {
|
|
142
|
+
await this.applicationScript.releaseIos(app, {
|
|
143
|
+
target,
|
|
144
|
+
env,
|
|
145
|
+
teamId: team || undefined,
|
|
146
|
+
adHoc,
|
|
147
|
+
write,
|
|
148
|
+
allowLocalRelease
|
|
149
|
+
});
|
|
150
|
+
}),
|
|
151
|
+
releaseAndroid: target({ desc: "Build and sign the Android app for the Play Store (aab, or apk)" }).with(App).option("assembleType", String, { enum: ["aab", "apk"], default: "aab" }).option("target", String, mobileTargetOption).option("env", String, releaseEnvOption).option("write", Boolean, { desc: "write code generation", default: true }).option("allowLocalRelease", Boolean, { flag: "l", desc: "allow release with --env local", default: false }).exec(async function(app, assembleType, target, env, write, allowLocalRelease) {
|
|
152
|
+
await this.applicationScript.releaseAndroid(app, assembleType, {
|
|
153
|
+
target,
|
|
154
|
+
env,
|
|
155
|
+
write,
|
|
156
|
+
allowLocalRelease
|
|
157
|
+
});
|
|
158
|
+
}),
|
|
159
|
+
dbup: target({ desc: "Start local database services for a database mode" }).with(Workspace).option("mode", String, {
|
|
160
|
+
desc: "database mode; left out, every mode the workspace's apps declare",
|
|
161
|
+
enum: ["single", "multiple", "cluster"],
|
|
162
|
+
nullable: true
|
|
163
|
+
}).exec(async function(workspace, mode) {
|
|
164
|
+
await this.applicationScript.dbupDeclared(workspace, mode);
|
|
165
|
+
}),
|
|
166
|
+
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) {
|
|
167
|
+
await this.applicationScript.transferDatabase(app, "export", dir);
|
|
168
|
+
}),
|
|
169
|
+
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) {
|
|
170
|
+
await this.applicationScript.transferDatabase(app, "import", dir);
|
|
171
|
+
}),
|
|
172
|
+
dbdown: target({ desc: "Stop local database services" }).with(Workspace).exec(async function(workspace) {
|
|
173
|
+
await this.applicationScript.dbdown(workspace);
|
|
174
|
+
})
|
|
175
|
+
})) {
|
|
176
|
+
}
|
|
177
|
+
export {
|
|
178
|
+
ApplicationCommand
|
|
179
|
+
};
|
|
@@ -1,17 +1,16 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
import {
|
|
3
3
|
Spinner
|
|
4
|
-
} from "./index-
|
|
4
|
+
} from "./index-ga6hygxr.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-aadpbnt2.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
|