@akanjs/cli 2.4.0 → 2.4.1-rc.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/agent.command-h4afc69n.js +26 -0
- package/application.command-4ctkfdan.js +165 -0
- package/applicationBuildRunner-esa1kj7v.js +284 -0
- package/applicationReleasePackager-brvth6rs.js +245 -0
- package/capacitorApp-y0h6cgft.js +58 -0
- package/cloud.command-rpztn4fh.js +94 -0
- package/commandManifest.json +1 -0
- package/context.command-nqbtak4f.js +82 -0
- package/dependencyScanner-m4x5maek.js +9 -0
- package/guideline.command-ya0dh44f.js +356 -0
- package/incrementalBuilder.proc.js +89 -17394
- package/index-1xdrsbry.js +1447 -0
- package/index-45aj5ry0.js +990 -0
- package/index-5vvwc0cz.js +559 -0
- package/index-61keag0s.js +40 -0
- package/index-6pz1j0zj.js +62 -0
- package/index-73pr2cmy.js +534 -0
- package/index-76rn3g2c.js +76 -0
- package/index-85msc0wg.js +161 -0
- package/index-8pkbzj26.js +840 -0
- package/index-8rc0bm04.js +514 -0
- package/index-9sp6fsc5.js +1884 -0
- package/index-a6sbyy0b.js +2769 -0
- package/index-b0brjbp3.js +83 -0
- package/index-fgc8r6dj.js +33 -0
- package/index-h6ca6qg0.js +2777 -0
- package/index-hdqztm58.js +758 -0
- package/index-hwzpw9c1.js +202 -0
- package/index-pmm9e2jf.js +120 -0
- package/index-qaq13qk3.js +80 -0
- package/index-qhtr07v8.js +1072 -0
- package/index-r24hmh0q.js +4 -0
- package/index-ss469dec.js +11 -0
- package/index-swf4bmbg.js +25 -0
- package/index-w7fyqjrw.js +462 -0
- package/index-wnp7hwq7.js +193 -0
- package/index-wq8jwx8z.js +224 -0
- package/index-x53a5nya.js +301 -0
- package/index-xmc2w32q.js +4359 -0
- package/index-y3hdhy4p.js +229 -0
- package/index.js +54 -23340
- package/library.command-r15zdqvp.js +33 -0
- package/localRegistry.command-5tcahs3f.js +178 -0
- package/module.command-qrj3kmyz.js +54 -0
- package/package.command-r8sq5kzp.js +43 -0
- package/package.json +2 -2
- package/page.command-c6xdx0xm.js +24 -0
- package/primitive.command-pv9ssmtf.js +62 -0
- package/quality.command-es67wvdp.js +809 -0
- package/repair.command-677675vw.js +67 -0
- package/routeSourceValidator-wbhmbwpj.js +132 -0
- package/scalar.command-kabkd6wd.js +35 -0
- package/templates/facetIndex/index.ts +1 -1
- package/typeChecker-kravn7ns.js +8 -0
- package/typecheck.proc.js +4 -194
- package/workflow.command-64r6cw0w.js +108 -0
- package/workspace.command-vrws0rgx.js +435 -0
- package/README.ko.md +0 -72
- package/README.md +0 -85
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import {
|
|
3
|
+
AkanContextAnalyzer
|
|
4
|
+
} from "./index-8rc0bm04.js";
|
|
5
|
+
import {
|
|
6
|
+
createRepairReport,
|
|
7
|
+
generatedFilePathsForTarget,
|
|
8
|
+
renderRepairReport,
|
|
9
|
+
writeGeneratedSyncState,
|
|
10
|
+
writeWorkflowRunArtifact
|
|
11
|
+
} from "./index-h6ca6qg0.js";
|
|
12
|
+
import {
|
|
13
|
+
runner
|
|
14
|
+
} from "./index-hdqztm58.js";
|
|
15
|
+
|
|
16
|
+
// pkgs/@akanjs/cli/repair/repair.runner.ts
|
|
17
|
+
var commandForShell = (command) => command.startsWith("akan ") ? `bun run ${command}` : command;
|
|
18
|
+
var defaultExecutor = (workspace) => async (command) => {
|
|
19
|
+
try {
|
|
20
|
+
const stdout = await workspace.spawn("bash", ["-lc", commandForShell(command.command)], {
|
|
21
|
+
cwd: workspace.workspaceRoot
|
|
22
|
+
});
|
|
23
|
+
return {
|
|
24
|
+
command: command.command,
|
|
25
|
+
reason: command.reason,
|
|
26
|
+
status: "passed",
|
|
27
|
+
exitCode: 0,
|
|
28
|
+
stdout
|
|
29
|
+
};
|
|
30
|
+
} catch (error) {
|
|
31
|
+
const commandError = error;
|
|
32
|
+
return {
|
|
33
|
+
command: command.command,
|
|
34
|
+
reason: command.reason,
|
|
35
|
+
status: "failed",
|
|
36
|
+
exitCode: commandError.code ?? 1,
|
|
37
|
+
stdout: commandError.stdout,
|
|
38
|
+
stderr: commandError.stderr ?? commandError.message
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
var targetMissing = (input) => ({
|
|
43
|
+
severity: "error",
|
|
44
|
+
code: "repair-input-missing",
|
|
45
|
+
input,
|
|
46
|
+
message: `Repair command requires "${input}".`
|
|
47
|
+
});
|
|
48
|
+
var repairAction = (kind, command, reason, safeToRun) => ({
|
|
49
|
+
kind,
|
|
50
|
+
command,
|
|
51
|
+
reason,
|
|
52
|
+
safeToRun
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
class RepairRunner extends runner("repair") {
|
|
56
|
+
async repair(kind, {
|
|
57
|
+
workspace,
|
|
58
|
+
app = null,
|
|
59
|
+
module = null,
|
|
60
|
+
target = null,
|
|
61
|
+
format = "markdown",
|
|
62
|
+
execute
|
|
63
|
+
}) {
|
|
64
|
+
const executor = execute ?? defaultExecutor(workspace);
|
|
65
|
+
const report = await this.createRepairReport(kind, { workspace, app, module, target, execute: executor });
|
|
66
|
+
const { artifact, runId } = await writeWorkflowRunArtifact(workspace, report);
|
|
67
|
+
const reportWithArtifact = artifact;
|
|
68
|
+
if (kind === "generated" && reportWithArtifact.status === "passed" && reportWithArtifact.target) {
|
|
69
|
+
await writeGeneratedSyncState(workspace, {
|
|
70
|
+
schemaVersion: 1,
|
|
71
|
+
target: reportWithArtifact.target,
|
|
72
|
+
status: "passed",
|
|
73
|
+
syncedAt: reportWithArtifact.syncedAt ?? new Date().toISOString(),
|
|
74
|
+
command: `akan sync ${reportWithArtifact.target}`,
|
|
75
|
+
runId,
|
|
76
|
+
generatedFiles: reportWithArtifact.generatedFiles ?? []
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
return renderRepairReport(reportWithArtifact, format);
|
|
80
|
+
}
|
|
81
|
+
async createRepairReport(kind, {
|
|
82
|
+
workspace,
|
|
83
|
+
app = null,
|
|
84
|
+
module = null,
|
|
85
|
+
target = null,
|
|
86
|
+
execute
|
|
87
|
+
}) {
|
|
88
|
+
if (kind === "generated") {
|
|
89
|
+
if (!app) {
|
|
90
|
+
return createRepairReport({ command: "repair generated", kind, diagnostics: [targetMissing("app")] });
|
|
91
|
+
}
|
|
92
|
+
const command = { command: `akan sync ${app}`, reason: "Refresh generated Akan files from source conventions." };
|
|
93
|
+
const result = await execute(command);
|
|
94
|
+
const [apps] = await workspace.getSyss();
|
|
95
|
+
const targetRoot = `${apps.includes(app) ? "apps" : "libs"}/${app}`;
|
|
96
|
+
return createRepairReport({
|
|
97
|
+
command: "repair generated",
|
|
98
|
+
kind,
|
|
99
|
+
target: app,
|
|
100
|
+
repairActions: [repairAction(kind, command.command, command.reason, true)],
|
|
101
|
+
nextActions: [
|
|
102
|
+
{ command: `akan doctor --strict --format json`, reason: "Re-run doctor after generated files refresh." }
|
|
103
|
+
],
|
|
104
|
+
commands: [result],
|
|
105
|
+
generatedFiles: generatedFilePathsForTarget(targetRoot),
|
|
106
|
+
...result.status === "passed" ? { syncedAt: new Date().toISOString() } : {}
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
if (kind === "format" || kind === "imports") {
|
|
110
|
+
if (!target) {
|
|
111
|
+
return createRepairReport({ command: `repair ${kind}`, kind, diagnostics: [targetMissing("target")] });
|
|
112
|
+
}
|
|
113
|
+
const command = { command: `akan lint ${target}`, reason: "Run Biome lint/fix path for formatting and imports." };
|
|
114
|
+
return createRepairReport({
|
|
115
|
+
command: `repair ${kind}`,
|
|
116
|
+
kind,
|
|
117
|
+
target,
|
|
118
|
+
repairActions: [repairAction(kind, command.command, command.reason, true)],
|
|
119
|
+
nextActions: [{ command: `akan doctor --strict --format json`, reason: "Re-run doctor after lint repair." }],
|
|
120
|
+
commands: [await execute(command)]
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
if (!app || !module) {
|
|
124
|
+
return createRepairReport({
|
|
125
|
+
command: `repair ${kind}`,
|
|
126
|
+
kind,
|
|
127
|
+
target: app,
|
|
128
|
+
diagnostics: [!app ? targetMissing("app") : targetMissing("module")]
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
const doctor = await AkanContextAnalyzer.doctor(workspace, { strict: true });
|
|
132
|
+
const diagnostics = doctor.diagnostics.filter((diagnostic) => {
|
|
133
|
+
if (kind === "dictionary")
|
|
134
|
+
return diagnostic.code === "dictionary-label-missing" && diagnostic.path?.includes(module);
|
|
135
|
+
return (diagnostic.code === "module-shape-invalid" || diagnostic.code === "module-abstract-missing") && diagnostic.path?.includes(module);
|
|
136
|
+
});
|
|
137
|
+
const actionCommand = kind === "dictionary" ? `akan add-field --app ${app} --module ${module} --field <field> --type <type> --format json` : `akan create-module ${module} --app ${app} --format json`;
|
|
138
|
+
return createRepairReport({
|
|
139
|
+
command: `repair ${kind}`,
|
|
140
|
+
kind,
|
|
141
|
+
target: `${app}:${module}`,
|
|
142
|
+
diagnostics: diagnostics.length > 0 ? diagnostics : [
|
|
143
|
+
{
|
|
144
|
+
severity: "warning",
|
|
145
|
+
code: `repair-${kind}-no-automatic-change`,
|
|
146
|
+
message: `No safe automatic ${kind} repair was applied for ${app}:${module}.`
|
|
147
|
+
}
|
|
148
|
+
],
|
|
149
|
+
repairActions: [
|
|
150
|
+
repairAction(kind, actionCommand, "Use an explicit primitive command for source-safe repair.", false)
|
|
151
|
+
],
|
|
152
|
+
nextActions: [
|
|
153
|
+
{ command: actionCommand, reason: "Run a source-aware primitive if this repair is needed." },
|
|
154
|
+
{ command: "akan doctor --strict --format json", reason: "Re-run doctor after manual or primitive repair." }
|
|
155
|
+
],
|
|
156
|
+
commands: []
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
export { RepairRunner };
|