@intentius/chant 0.3.0 → 0.4.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/package.json +1 -1
- package/src/build.ts +15 -4
- package/src/cli/commands/build.ts +11 -4
- package/src/serializer.ts +14 -0
package/package.json
CHANGED
package/src/build.ts
CHANGED
|
@@ -143,6 +143,12 @@ export interface BuildOptions {
|
|
|
143
143
|
* native metadata channel. Resolved from project config by the caller.
|
|
144
144
|
*/
|
|
145
145
|
ownership?: OwnershipMarker;
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* The resolved project configuration, passed through to each serializer's
|
|
149
|
+
* {@link SerializeContext} so a dialect can read its lexicon-scoped settings.
|
|
150
|
+
*/
|
|
151
|
+
config?: Record<string, unknown>;
|
|
146
152
|
}
|
|
147
153
|
|
|
148
154
|
export interface BuildResult {
|
|
@@ -553,10 +559,15 @@ export async function build(
|
|
|
553
559
|
...(outputsByLexicon.get(lexiconName) ?? []),
|
|
554
560
|
...unassignedOutputs,
|
|
555
561
|
];
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
);
|
|
562
|
+
const serialized = serializer.serialize(lexiconEntities, lexiconLexiconOutputs, {
|
|
563
|
+
ownership: options?.ownership,
|
|
564
|
+
config: options?.config,
|
|
565
|
+
});
|
|
566
|
+
// Collect any non-fatal serializer diagnostics into the build warnings.
|
|
567
|
+
if (typeof serialized !== "string" && serialized.warnings) {
|
|
568
|
+
for (const w of serialized.warnings) warnings.push(w);
|
|
569
|
+
}
|
|
570
|
+
outputs.set(lexiconName, serialized);
|
|
560
571
|
} else {
|
|
561
572
|
warnings.push(`No serializer found for lexicon "${lexiconName}"`);
|
|
562
573
|
}
|
|
@@ -111,7 +111,10 @@ export async function buildCommand(options: BuildOptions): Promise<BuildResult>
|
|
|
111
111
|
: [];
|
|
112
112
|
|
|
113
113
|
// Run the build
|
|
114
|
-
const result = await build(infraPath, options.serializers, undefined, {
|
|
114
|
+
const result = await build(infraPath, options.serializers, undefined, {
|
|
115
|
+
ownership,
|
|
116
|
+
config: config as unknown as Record<string, unknown>,
|
|
117
|
+
});
|
|
115
118
|
|
|
116
119
|
// Format errors
|
|
117
120
|
for (const error of result.errors) {
|
|
@@ -137,11 +140,15 @@ export async function buildCommand(options: BuildOptions): Promise<BuildResult>
|
|
|
137
140
|
const checks = plugin.postSynthChecks();
|
|
138
141
|
if (checks.length === 0) continue;
|
|
139
142
|
|
|
140
|
-
// Scope outputs to this plugin's lexicon so cross-lexicon outputs don't
|
|
143
|
+
// Scope outputs to this plugin's lexicon so cross-lexicon outputs don't
|
|
144
|
+
// interfere. Outputs are keyed by the serializer's lexicon name (the
|
|
145
|
+
// build partition key), which differs from plugin.name for a dialect like
|
|
146
|
+
// forgejo (plugin "forgejo", serializer "github").
|
|
147
|
+
const outputKey = plugin.serializer.name;
|
|
141
148
|
const scopedOutputs = new Map<string, string | SerializerResult>();
|
|
142
|
-
const pluginOutput = result.outputs.get(
|
|
149
|
+
const pluginOutput = result.outputs.get(outputKey);
|
|
143
150
|
if (pluginOutput !== undefined) {
|
|
144
|
-
scopedOutputs.set(
|
|
151
|
+
scopedOutputs.set(outputKey, pluginOutput);
|
|
145
152
|
}
|
|
146
153
|
|
|
147
154
|
const scopedResult = { ...result, outputs: scopedOutputs };
|
package/src/serializer.ts
CHANGED
|
@@ -12,6 +12,14 @@ export interface SerializeContext {
|
|
|
12
12
|
* native metadata channel (AWS/Azure tags, K8s/GCP labels).
|
|
13
13
|
*/
|
|
14
14
|
ownership?: OwnershipMarker;
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* The resolved project configuration, when a build was driven from a project
|
|
18
|
+
* with a `chant.config.*`. Lets a serializer read its own lexicon-scoped
|
|
19
|
+
* settings (e.g. the forgejo dialect's `forgejo.runnerLabels`). Undefined for
|
|
20
|
+
* ad-hoc builds (e.g. context tools) that pass no config.
|
|
21
|
+
*/
|
|
22
|
+
config?: Record<string, unknown>;
|
|
15
23
|
}
|
|
16
24
|
|
|
17
25
|
/**
|
|
@@ -22,6 +30,12 @@ export interface SerializerResult {
|
|
|
22
30
|
primary: string;
|
|
23
31
|
/** Additional files keyed by filename (e.g. "network.template.json" → content) */
|
|
24
32
|
files?: Record<string, string>;
|
|
33
|
+
/**
|
|
34
|
+
* Non-fatal diagnostics produced during serialization (e.g. a dialect
|
|
35
|
+
* dropping keys the target platform ignores). The build pipeline collects
|
|
36
|
+
* these into its `warnings` array.
|
|
37
|
+
*/
|
|
38
|
+
warnings?: string[];
|
|
25
39
|
}
|
|
26
40
|
|
|
27
41
|
/**
|