@intentius/chant-lexicon-github 0.18.19 → 0.18.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.
|
@@ -46,6 +46,25 @@
|
|
|
46
46
|
import { type DriverComponent } from "@intentius/chant/components/driver";
|
|
47
47
|
import type { ComponentPipelineJob as GeneratedJob, ComponentPipelineOptions as GenerateGithubOptions, ComponentPipelineResult as GenerateGithubResult } from "@intentius/chant/lexicon";
|
|
48
48
|
export type { GeneratedJob, GenerateGithubOptions, GenerateGithubResult };
|
|
49
|
+
/**
|
|
50
|
+
* The structured pipeline document behind {@link generateGithubPipeline}: the
|
|
51
|
+
* `on`/`env`/`jobs` mappings plus the machine-readable `stages`/`jobs` views,
|
|
52
|
+
* before YAML emission. Exposed so a GitHub-Actions dialect (the forgejo
|
|
53
|
+
* lexicon, #969) can reuse the exact job/`needs:`/artifact structure and only
|
|
54
|
+
* apply its dialect transform + emit, rather than re-deriving the graph.
|
|
55
|
+
*/
|
|
56
|
+
export interface GithubPipelineDoc {
|
|
57
|
+
/** The `on:` trigger mapping (a bare `workflow_dispatch`). */
|
|
58
|
+
on: Record<string, unknown>;
|
|
59
|
+
/** The `env:` mapping, when `options.variables` is set. */
|
|
60
|
+
env?: Record<string, unknown>;
|
|
61
|
+
/** The `jobs:` mapping — one entry per component. */
|
|
62
|
+
jobsDoc: Record<string, unknown>;
|
|
63
|
+
/** Wave-ordered stage names (parity with gitlab's `--format json`). */
|
|
64
|
+
stages: string[];
|
|
65
|
+
/** Every generated job, for the machine-readable view. */
|
|
66
|
+
jobs: GeneratedJob[];
|
|
67
|
+
}
|
|
49
68
|
/**
|
|
50
69
|
* Synthesize a `.github/workflows/*.yml` pipeline from a set of components:
|
|
51
70
|
* one job per component, `needs:` expressing the wave-ordered dependency DAG
|
|
@@ -55,5 +74,17 @@ export type { GeneratedJob, GenerateGithubOptions, GenerateGithubResult };
|
|
|
55
74
|
* resolution. Wired into core's generate mode via the github lexicon plugin's
|
|
56
75
|
* `generateComponentPipeline` (../plugin.ts).
|
|
57
76
|
*/
|
|
77
|
+
export declare function buildGithubPipelineDoc(components: DriverComponent[], options?: GenerateGithubOptions): GithubPipelineDoc;
|
|
78
|
+
/**
|
|
79
|
+
* Emit a `GithubPipelineDoc`'s `on`/`env`/`jobs` mappings as workflow YAML.
|
|
80
|
+
* Shared with the forgejo dialect (#969), which transforms the doc first.
|
|
81
|
+
*/
|
|
82
|
+
export declare function emitPipelineYAML(doc: GithubPipelineDoc): string;
|
|
83
|
+
/**
|
|
84
|
+
* Synthesize a `.github/workflows/*.yml` pipeline from a set of components:
|
|
85
|
+
* one job per component, `needs:` expressing the wave-ordered dependency DAG
|
|
86
|
+
* from `resolveComponentGraph`. Thin wrapper over {@link buildGithubPipelineDoc}
|
|
87
|
+
* + {@link emitPipelineYAML}.
|
|
88
|
+
*/
|
|
58
89
|
export declare function generateGithubPipeline(components: DriverComponent[], options?: GenerateGithubOptions): GenerateGithubResult;
|
|
59
90
|
//# sourceMappingURL=generate-pipeline.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate-pipeline.d.ts","sourceRoot":"","sources":["../../src/components/generate-pipeline.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AAGH,OAAO,EAAyB,KAAK,eAAe,EAAE,MAAM,oCAAoC,CAAC;AACjG,OAAO,KAAK,EACV,oBAAoB,IAAI,YAAY,EACpC,wBAAwB,IAAI,qBAAqB,EACjD,uBAAuB,IAAI,oBAAoB,EAChD,MAAM,0BAA0B,CAAC;AAElC,YAAY,EAAE,YAAY,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"generate-pipeline.d.ts","sourceRoot":"","sources":["../../src/components/generate-pipeline.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AAGH,OAAO,EAAyB,KAAK,eAAe,EAAE,MAAM,oCAAoC,CAAC;AACjG,OAAO,KAAK,EACV,oBAAoB,IAAI,YAAY,EACpC,wBAAwB,IAAI,qBAAqB,EACjD,uBAAuB,IAAI,oBAAoB,EAChD,MAAM,0BAA0B,CAAC;AAElC,YAAY,EAAE,YAAY,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,CAAC;AAE1E;;;;;;GAMG;AACH,MAAM,WAAW,iBAAiB;IAChC,8DAA8D;IAC9D,EAAE,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC5B,2DAA2D;IAC3D,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC9B,qDAAqD;IACrD,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACjC,uEAAuE;IACvE,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,0DAA0D;IAC1D,IAAI,EAAE,YAAY,EAAE,CAAC;CACtB;AAmBD;;;;;;;;GAQG;AACH,wBAAgB,sBAAsB,CACpC,UAAU,EAAE,eAAe,EAAE,EAC7B,OAAO,GAAE,qBAA0B,GAClC,iBAAiB,CAwFnB;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,iBAAiB,GAAG,MAAM,CAQ/D;AAED;;;;;GAKG;AACH,wBAAgB,sBAAsB,CACpC,UAAU,EAAE,eAAe,EAAE,EAC7B,OAAO,GAAE,qBAA0B,GAClC,oBAAoB,CAGtB"}
|
package/dist/integrity.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"algorithm": "sha256",
|
|
3
3
|
"artifacts": {
|
|
4
|
-
"manifest.json": "
|
|
4
|
+
"manifest.json": "58de7bb44695722c5954dafd959a6f54b377bb3e5062fb3d6faac0e1cbd8bccc",
|
|
5
5
|
"meta.json": "798c5f5f37b0174756d2451299acfdc95c014f11d06d32b9153bbdfa9f3a580c",
|
|
6
6
|
"types/index.d.ts": "39c0791f0e58025bcef82e0f7a92240508f899fc2771d5dd51b2369b4d330f13",
|
|
7
7
|
"rules/deprecated-action-version.ts": "d41e6e532ab7f623af1bee4ac5279fcb2baada7defa1c5d022a5bc71983e8797",
|
|
@@ -67,5 +67,5 @@
|
|
|
67
67
|
"skills/chant-github-patterns.md": "bb3abef289a8fdfcf07d6bb2d7289dcb2f38bc0cb0321ea320b78b45a6f548c0",
|
|
68
68
|
"skills/chant-github-security.md": "aab111cb0871cad30281ce48d7da23663689619351029219e2be019a1a61e394"
|
|
69
69
|
},
|
|
70
|
-
"composite": "
|
|
70
|
+
"composite": "f1894e66a85587a72cf0e0c37ea25e889d17d3a2a7bb9d6f3f66332d1761e911"
|
|
71
71
|
}
|
package/dist/manifest.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@intentius/chant-lexicon-github",
|
|
3
|
-
"version": "0.18.
|
|
3
|
+
"version": "0.18.21",
|
|
4
4
|
"description": "GitHub Actions lexicon for chant — declarative IaC in TypeScript",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"homepage": "https://intentius.io/chant",
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
"typescript": "^5.9.3"
|
|
62
62
|
},
|
|
63
63
|
"peerDependencies": {
|
|
64
|
-
"@intentius/chant": "^0.18.
|
|
64
|
+
"@intentius/chant": "^0.18.21",
|
|
65
65
|
"typescript": "^5.9.3"
|
|
66
66
|
}
|
|
67
67
|
}
|
|
@@ -54,6 +54,26 @@ import type {
|
|
|
54
54
|
|
|
55
55
|
export type { GeneratedJob, GenerateGithubOptions, GenerateGithubResult };
|
|
56
56
|
|
|
57
|
+
/**
|
|
58
|
+
* The structured pipeline document behind {@link generateGithubPipeline}: the
|
|
59
|
+
* `on`/`env`/`jobs` mappings plus the machine-readable `stages`/`jobs` views,
|
|
60
|
+
* before YAML emission. Exposed so a GitHub-Actions dialect (the forgejo
|
|
61
|
+
* lexicon, #969) can reuse the exact job/`needs:`/artifact structure and only
|
|
62
|
+
* apply its dialect transform + emit, rather than re-deriving the graph.
|
|
63
|
+
*/
|
|
64
|
+
export interface GithubPipelineDoc {
|
|
65
|
+
/** The `on:` trigger mapping (a bare `workflow_dispatch`). */
|
|
66
|
+
on: Record<string, unknown>;
|
|
67
|
+
/** The `env:` mapping, when `options.variables` is set. */
|
|
68
|
+
env?: Record<string, unknown>;
|
|
69
|
+
/** The `jobs:` mapping — one entry per component. */
|
|
70
|
+
jobsDoc: Record<string, unknown>;
|
|
71
|
+
/** Wave-ordered stage names (parity with gitlab's `--format json`). */
|
|
72
|
+
stages: string[];
|
|
73
|
+
/** Every generated job, for the machine-readable view. */
|
|
74
|
+
jobs: GeneratedJob[];
|
|
75
|
+
}
|
|
76
|
+
|
|
57
77
|
/** GitHub Actions job ids must match `[a-zA-Z_][a-zA-Z0-9_-]*`; component names are already kebab-case in every fixture, but normalize defensively (mirrors gitlab's `toJobName`). */
|
|
58
78
|
function toJobName(componentName: string): string {
|
|
59
79
|
return componentName.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase();
|
|
@@ -80,10 +100,10 @@ function artifactName(name: string): string {
|
|
|
80
100
|
* resolution. Wired into core's generate mode via the github lexicon plugin's
|
|
81
101
|
* `generateComponentPipeline` (../plugin.ts).
|
|
82
102
|
*/
|
|
83
|
-
export function
|
|
103
|
+
export function buildGithubPipelineDoc(
|
|
84
104
|
components: DriverComponent[],
|
|
85
105
|
options: GenerateGithubOptions = {},
|
|
86
|
-
):
|
|
106
|
+
): GithubPipelineDoc {
|
|
87
107
|
const env = options.env ?? "production";
|
|
88
108
|
const image = options.image ?? DEFAULT_IMAGE;
|
|
89
109
|
const runCommand = options.runCommand ?? ["chant", "run", "--components", "{name}", "--env", env];
|
|
@@ -164,12 +184,39 @@ export function generateGithubPipeline(
|
|
|
164
184
|
}
|
|
165
185
|
});
|
|
166
186
|
|
|
187
|
+
return {
|
|
188
|
+
on: { workflow_dispatch: {} },
|
|
189
|
+
...(options.variables && Object.keys(options.variables).length > 0 ? { env: options.variables } : {}),
|
|
190
|
+
jobsDoc,
|
|
191
|
+
stages,
|
|
192
|
+
jobs,
|
|
193
|
+
};
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
/**
|
|
197
|
+
* Emit a `GithubPipelineDoc`'s `on`/`env`/`jobs` mappings as workflow YAML.
|
|
198
|
+
* Shared with the forgejo dialect (#969), which transforms the doc first.
|
|
199
|
+
*/
|
|
200
|
+
export function emitPipelineYAML(doc: GithubPipelineDoc): string {
|
|
167
201
|
const sections: string[] = [];
|
|
168
|
-
sections.push("on:" + emitYAML(
|
|
169
|
-
if (
|
|
170
|
-
sections.push("env:" + emitYAML(
|
|
202
|
+
sections.push("on:" + emitYAML(doc.on, 1));
|
|
203
|
+
if (doc.env && Object.keys(doc.env).length > 0) {
|
|
204
|
+
sections.push("env:" + emitYAML(doc.env, 1));
|
|
171
205
|
}
|
|
172
|
-
sections.push("jobs:" + emitYAML(jobsDoc, 1));
|
|
206
|
+
sections.push("jobs:" + emitYAML(doc.jobsDoc, 1));
|
|
207
|
+
return sections.join("\n\n") + "\n";
|
|
208
|
+
}
|
|
173
209
|
|
|
174
|
-
|
|
210
|
+
/**
|
|
211
|
+
* Synthesize a `.github/workflows/*.yml` pipeline from a set of components:
|
|
212
|
+
* one job per component, `needs:` expressing the wave-ordered dependency DAG
|
|
213
|
+
* from `resolveComponentGraph`. Thin wrapper over {@link buildGithubPipelineDoc}
|
|
214
|
+
* + {@link emitPipelineYAML}.
|
|
215
|
+
*/
|
|
216
|
+
export function generateGithubPipeline(
|
|
217
|
+
components: DriverComponent[],
|
|
218
|
+
options: GenerateGithubOptions = {},
|
|
219
|
+
): GenerateGithubResult {
|
|
220
|
+
const doc = buildGithubPipelineDoc(components, options);
|
|
221
|
+
return { yaml: emitPipelineYAML(doc), stages: doc.stages, jobs: doc.jobs };
|
|
175
222
|
}
|