@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
|
@@ -1,23 +1,25 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
import {
|
|
3
3
|
script
|
|
4
|
-
} from "./index-
|
|
4
|
+
} from "./index-rmcw8yc8.js";
|
|
5
5
|
import {
|
|
6
6
|
AppExecutor,
|
|
7
7
|
LibExecutor,
|
|
8
8
|
ModuleExecutor
|
|
9
|
-
} from "./index-
|
|
9
|
+
} from "./index-ga6hygxr.js";
|
|
10
10
|
import {
|
|
11
|
+
workflowStatus,
|
|
11
12
|
compactDiagnostics,
|
|
12
|
-
createPrimitiveWriteReport,
|
|
13
13
|
sourceFile,
|
|
14
14
|
moduleComponentName,
|
|
15
15
|
moduleSourcePaths,
|
|
16
16
|
generatedFilesForSync,
|
|
17
17
|
validationCommandsForTarget,
|
|
18
18
|
nextActionsForTarget,
|
|
19
|
-
|
|
19
|
+
createPrimitiveWriteReport,
|
|
20
20
|
normalizeFieldType,
|
|
21
|
+
ensureNamedImport,
|
|
22
|
+
ensureBaseImport,
|
|
21
23
|
ensureBaseTypeImport,
|
|
22
24
|
coerceFieldDefault,
|
|
23
25
|
fieldExpression,
|
|
@@ -39,13 +41,13 @@ import {
|
|
|
39
41
|
hasSignalFactoryEntry,
|
|
40
42
|
insertSignalFactoryEntry,
|
|
41
43
|
addFieldUiPolicyForType
|
|
42
|
-
} from "./index-
|
|
44
|
+
} from "./index-yy4s1j72.js";
|
|
43
45
|
import {
|
|
44
46
|
ModuleScript
|
|
45
|
-
} from "./index-
|
|
47
|
+
} from "./index-tgjy8xf3.js";
|
|
46
48
|
|
|
47
49
|
// pkgs/@akanjs/cli/primitive/primitive.script.ts
|
|
48
|
-
import { capitalize } from "akanjs/common";
|
|
50
|
+
import { capitalize, lowerlize } from "akanjs/common";
|
|
49
51
|
class PrimitiveScript extends script("primitive", [ModuleScript]) {
|
|
50
52
|
async resolveSys(workspace, target) {
|
|
51
53
|
if (!target)
|
|
@@ -59,28 +61,11 @@ class PrimitiveScript extends script("primitive", [ModuleScript]) {
|
|
|
59
61
|
}
|
|
60
62
|
async createUi(workspace, input) {
|
|
61
63
|
const sys = await this.resolveSys(workspace, input.app);
|
|
62
|
-
if (!sys || !input.module)
|
|
63
|
-
return
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
validationCommands: [],
|
|
68
|
-
diagnostics: compactDiagnostics([
|
|
69
|
-
!sys && {
|
|
70
|
-
severity: "error",
|
|
71
|
-
code: "primitive-target-missing",
|
|
72
|
-
message: "Target app or library was not found."
|
|
73
|
-
},
|
|
74
|
-
!input.module && {
|
|
75
|
-
severity: "error",
|
|
76
|
-
code: "primitive-input-missing",
|
|
77
|
-
message: "Module is required.",
|
|
78
|
-
input: "module"
|
|
79
|
-
}
|
|
80
|
-
]),
|
|
81
|
-
nextActions: []
|
|
82
|
-
});
|
|
83
|
-
}
|
|
64
|
+
if (!sys || !input.module)
|
|
65
|
+
return PrimitiveScript.#refuse("create-ui", compactDiagnostics([
|
|
66
|
+
!sys && PrimitiveScript.#targetMissing(),
|
|
67
|
+
!input.module && PrimitiveScript.#inputMissing("module")
|
|
68
|
+
]));
|
|
84
69
|
const mod = ModuleExecutor.from(sys, input.module);
|
|
85
70
|
if (input.surface === "view")
|
|
86
71
|
return await this.moduleScript.createView(mod);
|
|
@@ -96,30 +81,16 @@ class PrimitiveScript extends script("primitive", [ModuleScript]) {
|
|
|
96
81
|
return await this.addFieldToSources(workspace, { ...input, type: `${capitalize(input.field ?? "")}` }, { enumValues: values });
|
|
97
82
|
}
|
|
98
83
|
async addFieldToSources(workspace, input, { enumValues }) {
|
|
84
|
+
const command = enumValues ? "add-enum-field" : "add-field";
|
|
99
85
|
const sys = await this.resolveSys(workspace, input.app);
|
|
100
86
|
const ambiguousNumberTypes = new Set(["number", "numeric"]);
|
|
101
87
|
const normalizedType = input.type ? normalizeFieldType(input.type) : null;
|
|
102
88
|
const diagnostics = compactDiagnostics([
|
|
103
|
-
!sys &&
|
|
104
|
-
!input.module &&
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
input: "module"
|
|
109
|
-
},
|
|
110
|
-
!input.field && {
|
|
111
|
-
severity: "error",
|
|
112
|
-
code: "primitive-input-missing",
|
|
113
|
-
message: "Field is required.",
|
|
114
|
-
input: "field"
|
|
115
|
-
},
|
|
116
|
-
!input.type && {
|
|
117
|
-
severity: "error",
|
|
118
|
-
code: "primitive-input-missing",
|
|
119
|
-
message: "Type is required.",
|
|
120
|
-
input: "type"
|
|
121
|
-
},
|
|
122
|
-
enumValues && enumValues.length === 0 ? { severity: "error", code: "primitive-input-missing", message: "Enum values are required.", input: "values" } : null,
|
|
89
|
+
!sys && PrimitiveScript.#targetMissing(),
|
|
90
|
+
!input.module && PrimitiveScript.#inputMissing("module"),
|
|
91
|
+
!input.field && PrimitiveScript.#inputMissing("field"),
|
|
92
|
+
!input.type && PrimitiveScript.#inputMissing("type"),
|
|
93
|
+
enumValues?.length === 0 && PrimitiveScript.#inputMissing("values", "Enum values are required."),
|
|
123
94
|
input.type && ambiguousNumberTypes.has(input.type.toLowerCase()) ? {
|
|
124
95
|
severity: "error",
|
|
125
96
|
code: "primitive-field-type-unsupported",
|
|
@@ -133,16 +104,8 @@ class PrimitiveScript extends script("primitive", [ModuleScript]) {
|
|
|
133
104
|
input: "type"
|
|
134
105
|
} : null
|
|
135
106
|
]);
|
|
136
|
-
if (!sys || !input.module || !input.field || !input.type || diagnostics
|
|
137
|
-
return
|
|
138
|
-
command: enumValues ? "add-enum-field" : "add-field",
|
|
139
|
-
changedFiles: [],
|
|
140
|
-
generatedFiles: [],
|
|
141
|
-
validationCommands: [],
|
|
142
|
-
diagnostics,
|
|
143
|
-
nextActions: []
|
|
144
|
-
});
|
|
145
|
-
}
|
|
107
|
+
if (!sys || !input.module || !input.field || !input.type || workflowStatus(diagnostics) === "failed")
|
|
108
|
+
return PrimitiveScript.#refuse(command, diagnostics);
|
|
146
109
|
const moduleClassName = moduleComponentName(input.module);
|
|
147
110
|
const inputClassName = `${moduleClassName}Input`;
|
|
148
111
|
const paths = moduleSourcePaths(input.module);
|
|
@@ -150,32 +113,13 @@ class PrimitiveScript extends script("primitive", [ModuleScript]) {
|
|
|
150
113
|
const dictionaryPath = paths.dictionary;
|
|
151
114
|
const templatePath = paths.template;
|
|
152
115
|
const changedFiles = [];
|
|
153
|
-
const generatedFiles = generatedFilesForSync(sys);
|
|
154
116
|
const [hasConstant, hasDictionary] = await Promise.all([sys.exists(constantPath), sys.exists(dictionaryPath)]);
|
|
155
|
-
if (!hasConstant)
|
|
156
|
-
diagnostics.push(
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
}
|
|
162
|
-
if (!hasDictionary) {
|
|
163
|
-
diagnostics.push({
|
|
164
|
-
severity: "error",
|
|
165
|
-
code: "primitive-source-missing",
|
|
166
|
-
message: `Dictionary source file was not found: ${dictionaryPath}.`
|
|
167
|
-
});
|
|
168
|
-
}
|
|
169
|
-
if (diagnostics.some((diagnostic) => diagnostic.severity === "error")) {
|
|
170
|
-
return createPrimitiveWriteReport({
|
|
171
|
-
command: enumValues ? "add-enum-field" : "add-field",
|
|
172
|
-
changedFiles,
|
|
173
|
-
generatedFiles,
|
|
174
|
-
validationCommands: validationCommandsForTarget(sys.name),
|
|
175
|
-
diagnostics,
|
|
176
|
-
nextActions: nextActionsForTarget(sys.name)
|
|
177
|
-
});
|
|
178
|
-
}
|
|
117
|
+
if (!hasConstant)
|
|
118
|
+
diagnostics.push(PrimitiveScript.#sourceMissing("Constant", constantPath));
|
|
119
|
+
if (!hasDictionary)
|
|
120
|
+
diagnostics.push(PrimitiveScript.#sourceMissing("Dictionary", dictionaryPath));
|
|
121
|
+
if (workflowStatus(diagnostics) === "failed")
|
|
122
|
+
return PrimitiveScript.#report(command, sys, changedFiles, diagnostics);
|
|
179
123
|
let constantContent = await sys.readFile(constantPath);
|
|
180
124
|
let dictionaryContent = await sys.readFile(dictionaryPath);
|
|
181
125
|
const fieldBuilderName = viaBuilderParameterName(constantContent, inputClassName) ?? "field";
|
|
@@ -210,6 +154,8 @@ class PrimitiveScript extends script("primitive", [ModuleScript]) {
|
|
|
210
154
|
if (defaultCoercion.diagnostic)
|
|
211
155
|
diagnostics.push(defaultCoercion.diagnostic);
|
|
212
156
|
constantContent = ensureBaseTypeImport(constantContent, input.type);
|
|
157
|
+
if (input.type === "Date" && defaultCoercion.expression)
|
|
158
|
+
constantContent = ensureBaseImport(constantContent, "dayjs");
|
|
213
159
|
}
|
|
214
160
|
if (enumValues) {
|
|
215
161
|
const defaultCoercion = coerceFieldDefault("enum", input.defaultValue, { enumValues });
|
|
@@ -311,7 +257,7 @@ class PrimitiveScript extends script("primitive", [ModuleScript]) {
|
|
|
311
257
|
}
|
|
312
258
|
}
|
|
313
259
|
}
|
|
314
|
-
if (
|
|
260
|
+
if (workflowStatus(diagnostics) === "passed" && nextConstantContentWithLight && nextDictionaryContent) {
|
|
315
261
|
await sys.writeFile(constantPath, nextConstantContentWithLight);
|
|
316
262
|
await sys.writeFile(dictionaryPath, nextDictionaryContent);
|
|
317
263
|
changedFiles.push(sourceFile(sys, constantPath, "modify", "Field source shape was updated."), sourceFile(sys, dictionaryPath, "modify", "Field dictionary labels were updated."));
|
|
@@ -320,14 +266,7 @@ class PrimitiveScript extends script("primitive", [ModuleScript]) {
|
|
|
320
266
|
changedFiles.push(sourceFile(sys, templatePath, "modify", "Template field surface was updated."));
|
|
321
267
|
}
|
|
322
268
|
}
|
|
323
|
-
return
|
|
324
|
-
command: enumValues ? "add-enum-field" : "add-field",
|
|
325
|
-
changedFiles,
|
|
326
|
-
generatedFiles,
|
|
327
|
-
validationCommands: validationCommandsForTarget(sys.name),
|
|
328
|
-
diagnostics,
|
|
329
|
-
nextActions: nextActionsForTarget(sys.name)
|
|
330
|
-
});
|
|
269
|
+
return PrimitiveScript.#report(command, sys, changedFiles, diagnostics);
|
|
331
270
|
}
|
|
332
271
|
async addMutation(workspace, input) {
|
|
333
272
|
const moduleClassName = input.module ? moduleComponentName(input.module) : "";
|
|
@@ -353,7 +292,7 @@ class PrimitiveScript extends script("primitive", [ModuleScript]) {
|
|
|
353
292
|
signal: name ? {
|
|
354
293
|
className: `${moduleClassName}Endpoint`,
|
|
355
294
|
entryLine: [
|
|
356
|
-
`${name}: mutation(Boolean)`,
|
|
295
|
+
`${name}: mutation(Boolean, { guards: [None] })`,
|
|
357
296
|
` .exec(async function () {`,
|
|
358
297
|
` return await this.${serviceRef}Service.${name}();`,
|
|
359
298
|
` }),`
|
|
@@ -388,7 +327,7 @@ class PrimitiveScript extends script("primitive", [ModuleScript]) {
|
|
|
388
327
|
signal: name && queryName ? {
|
|
389
328
|
className: `${moduleClassName}Slice`,
|
|
390
329
|
entryLine: [
|
|
391
|
-
`${name}: init()`,
|
|
330
|
+
`${name}: init({ guards: [None] })`,
|
|
392
331
|
` .exec(function () {`,
|
|
393
332
|
` return this.${serviceRef}Service.${queryName}();`,
|
|
394
333
|
` }),`
|
|
@@ -401,60 +340,21 @@ class PrimitiveScript extends script("primitive", [ModuleScript]) {
|
|
|
401
340
|
async#writeServiceSignalEntry(workspace, spec) {
|
|
402
341
|
const sys = await this.resolveSys(workspace, spec.app);
|
|
403
342
|
const diagnostics = compactDiagnostics([
|
|
404
|
-
!sys &&
|
|
405
|
-
!spec.module &&
|
|
406
|
-
|
|
407
|
-
code: "primitive-input-missing",
|
|
408
|
-
message: "Module is required.",
|
|
409
|
-
input: "module"
|
|
410
|
-
},
|
|
411
|
-
!spec.entryName && {
|
|
412
|
-
severity: "error",
|
|
413
|
-
code: "primitive-input-missing",
|
|
414
|
-
message: `${capitalize(spec.requiredInput)} name is required.`,
|
|
415
|
-
input: spec.requiredInput
|
|
416
|
-
}
|
|
343
|
+
!sys && PrimitiveScript.#targetMissing(),
|
|
344
|
+
!spec.module && PrimitiveScript.#inputMissing("module"),
|
|
345
|
+
!spec.entryName && PrimitiveScript.#inputMissing(spec.requiredInput, `${capitalize(spec.requiredInput)} name is required.`)
|
|
417
346
|
]);
|
|
418
|
-
if (!sys || !spec.module || !spec.entryName || !spec.serviceMethod || !spec.signal)
|
|
419
|
-
return
|
|
420
|
-
|
|
421
|
-
changedFiles: [],
|
|
422
|
-
generatedFiles: [],
|
|
423
|
-
validationCommands: [],
|
|
424
|
-
diagnostics,
|
|
425
|
-
nextActions: []
|
|
426
|
-
});
|
|
427
|
-
}
|
|
428
|
-
const paths = moduleSourcePaths(spec.module);
|
|
429
|
-
const servicePath = paths.service;
|
|
430
|
-
const signalPath = paths.signal;
|
|
347
|
+
if (!sys || !spec.module || !spec.entryName || !spec.serviceMethod || !spec.signal)
|
|
348
|
+
return PrimitiveScript.#refuse(spec.command, diagnostics);
|
|
349
|
+
const { service: servicePath, signal: signalPath } = moduleSourcePaths(spec.module);
|
|
431
350
|
const changedFiles = [];
|
|
432
|
-
const generatedFiles = generatedFilesForSync(sys);
|
|
433
351
|
const [hasServiceFile, hasSignalFile] = await Promise.all([sys.exists(servicePath), sys.exists(signalPath)]);
|
|
434
|
-
if (!hasServiceFile)
|
|
435
|
-
diagnostics.push(
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
}
|
|
441
|
-
if (!hasSignalFile) {
|
|
442
|
-
diagnostics.push({
|
|
443
|
-
severity: "error",
|
|
444
|
-
code: "primitive-source-missing",
|
|
445
|
-
message: `Signal source file was not found: ${signalPath}.`
|
|
446
|
-
});
|
|
447
|
-
}
|
|
448
|
-
if (diagnostics.some((diagnostic) => diagnostic.severity === "error")) {
|
|
449
|
-
return createPrimitiveWriteReport({
|
|
450
|
-
command: spec.command,
|
|
451
|
-
changedFiles,
|
|
452
|
-
generatedFiles,
|
|
453
|
-
validationCommands: validationCommandsForTarget(sys.name),
|
|
454
|
-
diagnostics,
|
|
455
|
-
nextActions: nextActionsForTarget(sys.name)
|
|
456
|
-
});
|
|
457
|
-
}
|
|
352
|
+
if (!hasServiceFile)
|
|
353
|
+
diagnostics.push(PrimitiveScript.#sourceMissing("Service", servicePath));
|
|
354
|
+
if (!hasSignalFile)
|
|
355
|
+
diagnostics.push(PrimitiveScript.#sourceMissing("Signal", signalPath));
|
|
356
|
+
if (workflowStatus(diagnostics) === "failed")
|
|
357
|
+
return PrimitiveScript.#report(spec.command, sys, changedFiles, diagnostics);
|
|
458
358
|
const serviceClassName = `${moduleComponentName(spec.module)}Service`;
|
|
459
359
|
const serviceContent = await sys.readFile(servicePath);
|
|
460
360
|
const signalContent = await sys.readFile(signalPath);
|
|
@@ -476,7 +376,8 @@ class PrimitiveScript extends script("primitive", [ModuleScript]) {
|
|
|
476
376
|
});
|
|
477
377
|
}
|
|
478
378
|
const nextServiceContent = serviceMethodExists ? serviceContent : insertClassMethod(serviceContent, serviceClassName, spec.serviceMethod.block);
|
|
479
|
-
const
|
|
379
|
+
const insertedSignalContent = insertSignalFactoryEntry(signalContent, spec.signal.className, spec.entryName, spec.signal.entryLine, spec.signal.param);
|
|
380
|
+
const nextSignalContent = insertedSignalContent ? ensureNamedImport(insertedSignalContent, "akanjs/signal", "None") : insertedSignalContent;
|
|
480
381
|
if (!nextServiceContent) {
|
|
481
382
|
diagnostics.push({
|
|
482
383
|
severity: "error",
|
|
@@ -515,20 +416,46 @@ class PrimitiveScript extends script("primitive", [ModuleScript]) {
|
|
|
515
416
|
message: `Edited ${signalPath} did not contain entry "${spec.entryName}" in ${spec.signal.className}.`
|
|
516
417
|
});
|
|
517
418
|
}
|
|
518
|
-
if (
|
|
419
|
+
if (workflowStatus(diagnostics) === "passed" && nextServiceContent && nextSignalContent) {
|
|
519
420
|
await sys.writeFile(servicePath, nextServiceContent);
|
|
520
421
|
await sys.writeFile(signalPath, nextSignalContent);
|
|
521
422
|
changedFiles.push(sourceFile(sys, servicePath, "modify", `Service ${spec.entryKind} was added.`), sourceFile(sys, signalPath, "modify", `Signal ${spec.entryKind} was added.`));
|
|
522
423
|
}
|
|
424
|
+
return PrimitiveScript.#report(spec.command, sys, changedFiles, diagnostics);
|
|
425
|
+
}
|
|
426
|
+
static #refuse(command, diagnostics) {
|
|
427
|
+
return createPrimitiveWriteReport({
|
|
428
|
+
command,
|
|
429
|
+
changedFiles: [],
|
|
430
|
+
generatedFiles: [],
|
|
431
|
+
validationCommands: [],
|
|
432
|
+
diagnostics,
|
|
433
|
+
nextActions: []
|
|
434
|
+
});
|
|
435
|
+
}
|
|
436
|
+
static #report(command, sys, changedFiles, diagnostics) {
|
|
523
437
|
return createPrimitiveWriteReport({
|
|
524
|
-
command
|
|
438
|
+
command,
|
|
525
439
|
changedFiles,
|
|
526
|
-
generatedFiles,
|
|
440
|
+
generatedFiles: generatedFilesForSync(sys),
|
|
527
441
|
validationCommands: validationCommandsForTarget(sys.name),
|
|
528
442
|
diagnostics,
|
|
529
443
|
nextActions: nextActionsForTarget(sys.name)
|
|
530
444
|
});
|
|
531
445
|
}
|
|
446
|
+
static #targetMissing() {
|
|
447
|
+
return { severity: "error", code: "primitive-target-missing", message: "Target app or library was not found." };
|
|
448
|
+
}
|
|
449
|
+
static #inputMissing(input, message = `${capitalize(input)} is required.`) {
|
|
450
|
+
return { severity: "error", code: "primitive-input-missing", message, input };
|
|
451
|
+
}
|
|
452
|
+
static #sourceMissing(kind, path) {
|
|
453
|
+
return {
|
|
454
|
+
severity: "error",
|
|
455
|
+
code: "primitive-source-missing",
|
|
456
|
+
message: `${kind} source file was not found: ${path}.`
|
|
457
|
+
};
|
|
458
|
+
}
|
|
532
459
|
}
|
|
533
460
|
|
|
534
461
|
export { PrimitiveScript };
|
|
@@ -5,33 +5,26 @@ import {
|
|
|
5
5
|
writeGeneratedSyncState,
|
|
6
6
|
createRepairReport,
|
|
7
7
|
renderRepairReport
|
|
8
|
-
} from "./index-
|
|
8
|
+
} from "./index-yy4s1j72.js";
|
|
9
9
|
import {
|
|
10
10
|
AkanContextAnalyzer
|
|
11
|
-
} from "./index-
|
|
11
|
+
} from "./index-9629w7ns.js";
|
|
12
12
|
import {
|
|
13
13
|
runner
|
|
14
|
-
} from "./index-
|
|
14
|
+
} from "./index-rmcw8yc8.js";
|
|
15
15
|
|
|
16
16
|
// pkgs/@akanjs/cli/repair/repair.runner.ts
|
|
17
|
-
var
|
|
17
|
+
var spawnShell = async (workspace, command) => await workspace.spawn("bash", ["-lc", command.startsWith("akan ") ? `bun run ${command}` : command], {
|
|
18
|
+
cwd: workspace.workspaceRoot
|
|
19
|
+
});
|
|
18
20
|
var defaultExecutor = (workspace) => async (command) => {
|
|
21
|
+
const base = { command: command.command, reason: command.reason };
|
|
19
22
|
try {
|
|
20
|
-
|
|
21
|
-
cwd: workspace.workspaceRoot
|
|
22
|
-
});
|
|
23
|
-
return {
|
|
24
|
-
command: command.command,
|
|
25
|
-
reason: command.reason,
|
|
26
|
-
status: "passed",
|
|
27
|
-
exitCode: 0,
|
|
28
|
-
stdout
|
|
29
|
-
};
|
|
23
|
+
return { ...base, status: "passed", exitCode: 0, stdout: await spawnShell(workspace, command.command) };
|
|
30
24
|
} catch (error) {
|
|
31
25
|
const commandError = error;
|
|
32
26
|
return {
|
|
33
|
-
|
|
34
|
-
reason: command.reason,
|
|
27
|
+
...base,
|
|
35
28
|
status: "failed",
|
|
36
29
|
exitCode: commandError.code ?? 1,
|
|
37
30
|
stdout: commandError.stdout,
|
|
@@ -158,4 +151,4 @@ class RepairRunner extends runner("repair") {
|
|
|
158
151
|
}
|
|
159
152
|
}
|
|
160
153
|
|
|
161
|
-
export { RepairRunner };
|
|
154
|
+
export { spawnShell, RepairRunner };
|