@intentius/chant-lexicon-gitlab 0.13.1 → 0.15.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/dist/codegen/fetch.d.ts +21 -2
- package/dist/codegen/fetch.d.ts.map +1 -1
- package/dist/components/generate-pipeline.d.ts +46 -0
- package/dist/components/generate-pipeline.d.ts.map +1 -0
- package/dist/integrity.json +2 -2
- package/dist/lint/audit-catalog.d.ts +7 -0
- package/dist/lint/audit-catalog.d.ts.map +1 -0
- package/dist/manifest.json +1 -1
- package/dist/plugin.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/codegen/fetch.test.ts +1 -1
- package/src/codegen/fetch.ts +35 -3
- package/src/codegen/vendored/gitlab-ci-schema.json +2753 -0
- package/src/components/generate-pipeline.test.ts +238 -0
- package/src/components/generate-pipeline.ts +137 -0
- package/src/lint/audit-catalog.ts +47 -0
- package/src/plugin.ts +13 -0
package/dist/codegen/fetch.d.ts
CHANGED
|
@@ -15,15 +15,34 @@ export declare const GITLAB_SCHEMA_VERSION = "v17.8.1-ee";
|
|
|
15
15
|
* Get the cache file path for the CI schema.
|
|
16
16
|
*/
|
|
17
17
|
export declare function getCachePath(): string;
|
|
18
|
+
/**
|
|
19
|
+
* Path to the vendored CI schema committed in this lexicon. Reading it offline
|
|
20
|
+
* is the default so `generate` never depends on gitlab.com — which aggressively
|
|
21
|
+
* 429-rate-limits the raw endpoint and chronically flaked CI (#574). The
|
|
22
|
+
* `GITLAB_SCHEMA_VERSION` pin already makes the fetch deterministic, so a
|
|
23
|
+
* committed copy is equivalent and network-free.
|
|
24
|
+
*/
|
|
25
|
+
export declare function getVendoredSchemaPath(): string;
|
|
18
26
|
/**
|
|
19
27
|
* Fetch the GitLab CI JSON Schema, returning the raw JSON buffer.
|
|
20
|
-
* Uses local file caching with 24-hour TTL.
|
|
21
28
|
*
|
|
22
|
-
*
|
|
29
|
+
* Default (pinned version, no force): read the vendored, committed schema —
|
|
30
|
+
* offline, deterministic, no gitlab.com 429s (#574). Pass `force` or a custom
|
|
31
|
+
* `version` to fetch live — used to verify against upstream or to refresh the
|
|
32
|
+
* vendored copy when bumping the pin (see {@link refreshVendoredSchema}).
|
|
33
|
+
*
|
|
34
|
+
* @param force Bypass the vendored copy and download fresh.
|
|
23
35
|
* @param version GitLab ref (tag, branch, or SHA) to fetch from.
|
|
24
36
|
* Defaults to {@link GITLAB_SCHEMA_VERSION}.
|
|
25
37
|
*/
|
|
26
38
|
export declare function fetchCISchema(force?: boolean, version?: string): Promise<Buffer>;
|
|
39
|
+
/**
|
|
40
|
+
* Refresh the vendored schema from upstream. Call this when bumping
|
|
41
|
+
* `GITLAB_SCHEMA_VERSION` so the committed copy tracks the new pin — the
|
|
42
|
+
* lexicon-upgrade pipeline (#523) runs it as part of a gitlab pin bump.
|
|
43
|
+
* Fetches the given version live and overwrites the vendored file.
|
|
44
|
+
*/
|
|
45
|
+
export declare function refreshVendoredSchema(version?: string): Promise<void>;
|
|
27
46
|
/**
|
|
28
47
|
* Fetch the CI schema and return it as a Map<typeName, Buffer>
|
|
29
48
|
* compatible with the generatePipeline fetchSchemas callback.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetch.d.ts","sourceRoot":"","sources":["../../src/codegen/fetch.ts"],"names":[],"mappings":"AAAA;;;GAGG;
|
|
1
|
+
{"version":3,"file":"fetch.d.ts","sourceRoot":"","sources":["../../src/codegen/fetch.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAQH;;;;;;;GAOG;AACH,eAAO,MAAM,qBAAqB,eAAe,CAAC;AASlD;;GAEG;AACH,wBAAgB,YAAY,IAAI,MAAM,CAErC;AAED;;;;;;GAMG;AACH,wBAAgB,qBAAqB,IAAI,MAAM,CAE9C;AAED;;;;;;;;;;;GAWG;AACH,wBAAsB,aAAa,CAAC,KAAK,CAAC,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAYtF;AAED;;;;;GAKG;AACH,wBAAsB,qBAAqB,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAI3E;AAED;;;;;;;GAOG;AACH,wBAAsB,YAAY,CAAC,KAAK,CAAC,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAKlG;AAED;;GAEG;AACH,wBAAgB,UAAU,IAAI,IAAI,CAEjC"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generate mode — component → GitLab CI YAML (#563, epic #551, Phase 3).
|
|
3
|
+
*
|
|
4
|
+
* The other half of "two modes, both anti-sprawl" (see
|
|
5
|
+
* docs/src/content/docs/components/orchestration.mdx#generate-mode and epic
|
|
6
|
+
* #551 §"5. Orchestrator → generate mode"): interpret mode (`../driver.ts`,
|
|
7
|
+
* #556) runs components directly; generate mode synthesizes a **thin**
|
|
8
|
+
* `.gitlab-ci.yml` from the same declarations for teams who want plain CI as
|
|
9
|
+
* the trigger/runner.
|
|
10
|
+
*
|
|
11
|
+
* The generated pipeline is a trigger, not the deploy logic:
|
|
12
|
+
* - Ordering + parallel-safe waves are resolved once, generically, by
|
|
13
|
+
* `resolveComponentGraph` (../driver.ts) — the exact function the local
|
|
14
|
+
* interpret driver uses. Generate mode does not re-derive or duplicate
|
|
15
|
+
* that graph logic.
|
|
16
|
+
* - Each wave becomes one GitLab CI `stage`; every component in a wave
|
|
17
|
+
* becomes one job in that stage, so independent components run in
|
|
18
|
+
* parallel and dependents wait for their dependencies via natural stage
|
|
19
|
+
* ordering (mirrored explicitly with `needs:` for direct edges, so GitLab
|
|
20
|
+
* can still parallelize across non-adjacent stages when safe).
|
|
21
|
+
* - Each job's `script` is exactly one invocation that hands off to the
|
|
22
|
+
* component's own composition (`chant run --components <name> ...` by
|
|
23
|
+
* default) — never inlined build/publish/apply steps. The deploy logic
|
|
24
|
+
* lives in the component's `deploy` phases and the capabilities they
|
|
25
|
+
* reference, not in this YAML.
|
|
26
|
+
*
|
|
27
|
+
* Cross-cutting changes (e.g. "sign every image before deploy") are made by
|
|
28
|
+
* editing `GenerateGitlabOptions.extraScript`/`beforeScript` (or the
|
|
29
|
+
* component's own composition) ONCE here — never per generated job. See
|
|
30
|
+
* `generate-gitlab.test.ts`'s "cross-cutting change" case for a
|
|
31
|
+
* demonstration: one generator-option edit reflects in every job without
|
|
32
|
+
* touching the component declarations.
|
|
33
|
+
*/
|
|
34
|
+
import { type DriverComponent } from "@intentius/chant/components/driver";
|
|
35
|
+
import type { ComponentPipelineJob as GeneratedJob, ComponentPipelineOptions as GenerateGitlabOptions, ComponentPipelineResult as GenerateGitlabResult } from "@intentius/chant/lexicon";
|
|
36
|
+
export type { GeneratedJob, GenerateGitlabOptions, GenerateGitlabResult };
|
|
37
|
+
/**
|
|
38
|
+
* Synthesize a `.gitlab-ci.yml` pipeline from a set of components: one stage
|
|
39
|
+
* per parallel-safe wave (`resolveComponentGraph`), one thin trigger job per
|
|
40
|
+
* component. Throws `DependencyCycleError`/`UnknownDependencyError` (from
|
|
41
|
+
* core's driver) exactly like the interpret driver does, since both consume
|
|
42
|
+
* the same graph resolution. Wired into core's generate mode via the gitlab
|
|
43
|
+
* lexicon plugin's `generateComponentPipeline` (../plugin.ts).
|
|
44
|
+
*/
|
|
45
|
+
export declare function generateGitlabPipeline(components: DriverComponent[], options?: GenerateGitlabOptions): GenerateGitlabResult;
|
|
46
|
+
//# sourceMappingURL=generate-pipeline.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate-pipeline.d.ts","sourceRoot":"","sources":["../../src/components/generate-pipeline.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;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;AAS1E;;;;;;;GAOG;AACH,wBAAgB,sBAAsB,CACpC,UAAU,EAAE,eAAe,EAAE,EAC7B,OAAO,GAAE,qBAA0B,GAClC,oBAAoB,CA0EtB"}
|
package/dist/integrity.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"algorithm": "sha256",
|
|
3
3
|
"artifacts": {
|
|
4
|
-
"manifest.json": "
|
|
4
|
+
"manifest.json": "13b637c8dab06c761181a88812696e9dc09aca30b39d106c3816e58bb280f89b",
|
|
5
5
|
"meta.json": "931fc3246a55645b1493080bbeb160e5d205e42349e8bdca96ca243adb5f0da3",
|
|
6
6
|
"types/index.d.ts": "5cd2e99f135a929b72bdd822d00d780d39b1cd407ba0cfb3d511c7ac9d667b58",
|
|
7
7
|
"rules/artifact-no-expiry.ts": "3f3cabf9792cbf8207e53a25f506715466b19ec25e9c3b4d0d77fed6b2eb4542",
|
|
@@ -52,5 +52,5 @@
|
|
|
52
52
|
"skills/chant-gitlab-migrate.md": "4853d04980560b379e5b0f7267dcb0a1e5d5879cb9e9931681ce76b2a5fe69d8",
|
|
53
53
|
"skills/chant-gitlab-patterns.md": "6d9a44e9e8de4c3820be9d65381b0d2ede4cb3626aaaf0011e21838a9fbf556e"
|
|
54
54
|
},
|
|
55
|
-
"composite": "
|
|
55
|
+
"composite": "6dc26e7c6720bda599259130d3097d5f8d6e711dd864d3cbbc873bcbe910b004"
|
|
56
56
|
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The gitlab lexicon's chant audit catalog — metadata for its post-synth rules
|
|
3
|
+
* (WGL GitLab CI rules). Contributed via gitlabPlugin.auditCatalog() (#687).
|
|
4
|
+
*/
|
|
5
|
+
import { type RuleMeta } from "@intentius/chant/audit/catalog";
|
|
6
|
+
export declare const gitlabAuditCatalog: Record<string, RuleMeta>;
|
|
7
|
+
//# sourceMappingURL=audit-catalog.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"audit-catalog.d.ts","sourceRoot":"","sources":["../../src/lint/audit-catalog.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAA0E,KAAK,QAAQ,EAAE,MAAM,gCAAgC,CAAC;AAEvI,eAAO,MAAM,kBAAkB,EAAE,MAAM,CAAC,MAAM,EAAE,QAAQ,CAwCvD,CAAC"}
|
package/dist/manifest.json
CHANGED
package/dist/plugin.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAiC,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAiC,MAAM,0BAA0B,CAAC;AAmB7F,eAAO,MAAM,YAAY,EAAE,aAsgB1B,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@intentius/chant-lexicon-gitlab",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.15.0",
|
|
4
4
|
"description": "GitLab CI lexicon for chant — declarative IaC in TypeScript",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"homepage": "https://intentius.io/chant",
|
|
@@ -62,8 +62,8 @@
|
|
|
62
62
|
"typescript": "^5.9.3"
|
|
63
63
|
},
|
|
64
64
|
"peerDependencies": {
|
|
65
|
-
"@intentius/chant": "^0.
|
|
66
|
-
"@intentius/chant-lexicon-github": "^0.
|
|
65
|
+
"@intentius/chant": "^0.15.0",
|
|
66
|
+
"@intentius/chant-lexicon-github": "^0.15.0"
|
|
67
67
|
},
|
|
68
68
|
"peerDependenciesMeta": {
|
|
69
69
|
"@intentius/chant-lexicon-github": {
|
|
@@ -21,7 +21,7 @@ describe("fetch", () => {
|
|
|
21
21
|
expect(cachePath).toContain("gitlab-ci-schema.json");
|
|
22
22
|
});
|
|
23
23
|
|
|
24
|
-
test
|
|
24
|
+
test("fetchCISchema reads the vendored schema offline (no network)", async () => {
|
|
25
25
|
const data = await fetchCISchema();
|
|
26
26
|
expect(data).toBeInstanceOf(Buffer);
|
|
27
27
|
const parsed = JSON.parse(data.toString("utf-8"));
|
package/src/codegen/fetch.ts
CHANGED
|
@@ -3,8 +3,10 @@
|
|
|
3
3
|
* and caches it locally.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import { join } from "path";
|
|
6
|
+
import { join, dirname } from "path";
|
|
7
7
|
import { homedir } from "os";
|
|
8
|
+
import { readFileSync, writeFileSync } from "fs";
|
|
9
|
+
import { fileURLToPath } from "url";
|
|
8
10
|
import { fetchWithCache, clearCacheFile } from "@intentius/chant/codegen/fetch";
|
|
9
11
|
|
|
10
12
|
/**
|
|
@@ -31,16 +33,34 @@ export function getCachePath(): string {
|
|
|
31
33
|
return join(homedir(), ".chant", "gitlab-ci-schema.json");
|
|
32
34
|
}
|
|
33
35
|
|
|
36
|
+
/**
|
|
37
|
+
* Path to the vendored CI schema committed in this lexicon. Reading it offline
|
|
38
|
+
* is the default so `generate` never depends on gitlab.com — which aggressively
|
|
39
|
+
* 429-rate-limits the raw endpoint and chronically flaked CI (#574). The
|
|
40
|
+
* `GITLAB_SCHEMA_VERSION` pin already makes the fetch deterministic, so a
|
|
41
|
+
* committed copy is equivalent and network-free.
|
|
42
|
+
*/
|
|
43
|
+
export function getVendoredSchemaPath(): string {
|
|
44
|
+
return join(dirname(fileURLToPath(import.meta.url)), "vendored", "gitlab-ci-schema.json");
|
|
45
|
+
}
|
|
46
|
+
|
|
34
47
|
/**
|
|
35
48
|
* Fetch the GitLab CI JSON Schema, returning the raw JSON buffer.
|
|
36
|
-
* Uses local file caching with 24-hour TTL.
|
|
37
49
|
*
|
|
38
|
-
*
|
|
50
|
+
* Default (pinned version, no force): read the vendored, committed schema —
|
|
51
|
+
* offline, deterministic, no gitlab.com 429s (#574). Pass `force` or a custom
|
|
52
|
+
* `version` to fetch live — used to verify against upstream or to refresh the
|
|
53
|
+
* vendored copy when bumping the pin (see {@link refreshVendoredSchema}).
|
|
54
|
+
*
|
|
55
|
+
* @param force Bypass the vendored copy and download fresh.
|
|
39
56
|
* @param version GitLab ref (tag, branch, or SHA) to fetch from.
|
|
40
57
|
* Defaults to {@link GITLAB_SCHEMA_VERSION}.
|
|
41
58
|
*/
|
|
42
59
|
export async function fetchCISchema(force?: boolean, version?: string): Promise<Buffer> {
|
|
43
60
|
const ref = version ?? GITLAB_SCHEMA_VERSION;
|
|
61
|
+
if (!force && ref === GITLAB_SCHEMA_VERSION) {
|
|
62
|
+
return readFileSync(getVendoredSchemaPath());
|
|
63
|
+
}
|
|
44
64
|
return fetchWithCache(
|
|
45
65
|
{
|
|
46
66
|
url: schemaUrl(ref),
|
|
@@ -50,6 +70,18 @@ export async function fetchCISchema(force?: boolean, version?: string): Promise<
|
|
|
50
70
|
);
|
|
51
71
|
}
|
|
52
72
|
|
|
73
|
+
/**
|
|
74
|
+
* Refresh the vendored schema from upstream. Call this when bumping
|
|
75
|
+
* `GITLAB_SCHEMA_VERSION` so the committed copy tracks the new pin — the
|
|
76
|
+
* lexicon-upgrade pipeline (#523) runs it as part of a gitlab pin bump.
|
|
77
|
+
* Fetches the given version live and overwrites the vendored file.
|
|
78
|
+
*/
|
|
79
|
+
export async function refreshVendoredSchema(version?: string): Promise<void> {
|
|
80
|
+
const ref = version ?? GITLAB_SCHEMA_VERSION;
|
|
81
|
+
const data = await fetchWithCache({ url: schemaUrl(ref), cacheFile: getCachePath() }, true);
|
|
82
|
+
writeFileSync(getVendoredSchemaPath(), data);
|
|
83
|
+
}
|
|
84
|
+
|
|
53
85
|
/**
|
|
54
86
|
* Fetch the CI schema and return it as a Map<typeName, Buffer>
|
|
55
87
|
* compatible with the generatePipeline fetchSchemas callback.
|