@intentius/chant-lexicon-docker 0.44.13 → 0.45.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.
@@ -1,10 +1,14 @@
1
1
  /**
2
2
  * Docker lexicon docs generation.
3
3
  *
4
- * The docker site is hand-authored under docs/src/content/docs/, unlike every
5
- * other lexicon's generated Starlight site. The rules table is the exception:
6
- * a hand-maintained one can fall behind the rules in src/lint/ without anything
7
- * catching it, so it is generated from source here (#1312).
4
+ * Uses the shared docsPipeline/writeDocsSite flow like every other lexicon
5
+ * (chant #1731, #1755). Hand-written prose lives under docs/pages/, each
6
+ * page tagged with a Diátaxis quadrant; index.mdx and serialization.mdx are
7
+ * generated from the overview/outputFormat strings below, and rules.mdx is
8
+ * generated from the rule sources under src/lint/ the same way it always
9
+ * was — this used to be the one lexicon whose rules table could drift from
10
+ * source without anything catching it (#1312), and the shared pipeline
11
+ * keeps that guarantee.
8
12
  */
9
13
  export declare function generateDocs(opts?: {
10
14
  verbose?: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"docs.d.ts","sourceRoot":"","sources":["../../src/codegen/docs.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAOH,wBAAsB,YAAY,CAAC,IAAI,CAAC,EAAE;IAAE,OAAO,CAAC,EAAE,OAAO,CAAA;CAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CA2B9E"}
1
+ {"version":3,"file":"docs.d.ts","sourceRoot":"","sources":["../../src/codegen/docs.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AA4HH,wBAAsB,YAAY,CAAC,IAAI,CAAC,EAAE;IAAE,OAAO,CAAC,EAAE,OAAO,CAAA;CAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAoB9E"}
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "algorithm": "sha256",
3
3
  "artifacts": {
4
- "manifest.json": "faf1f56b8a1192234d62f1f8468af193d87d9b47a928631385eb0b404be65027",
4
+ "manifest.json": "adf1925bb04b7eda3e2e189025e6e821bc3773b15cdaae533d162ccde15d599e",
5
5
  "meta.json": "ae27dc809e705d37a645ee83b9789c50051282f7891d21d6b9e6ce8d111624ff",
6
6
  "types/index.d.ts": "758f989ff86af54284d7f841a2db2259038d51ce1f3ed839a5d8e83fa20d95b8",
7
7
  "rules/no-latest-tag.ts": "efd060453d8ca3d5b85c3972906c6650b6f63eb5f67cb6cdb0f16a41cad91228",
@@ -15,5 +15,5 @@
15
15
  "skills/chant-docker.md": "3ff0708e3c76e245f202948949c768464563af2b60cc9aa2ca52f494ef8357f1",
16
16
  "skills/chant-docker-patterns.md": "ad1b0196d8150b2df579a699ff107f604340c799c04f3460ebf65003e287b12a"
17
17
  },
18
- "composite": "747eca502c828510a77462ea94c2fefe43147c9da2cdcae8049fa4e2713b1c51"
18
+ "composite": "3137d93f8573cd0064ab9cb409c8aee458634cc8f4d06c512ae2e0f1bfff9a89"
19
19
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "docker",
3
- "version": "0.44.13",
3
+ "version": "0.45.0",
4
4
  "chantVersion": ">=0.1.0",
5
5
  "namespace": "Docker",
6
6
  "intrinsics": [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@intentius/chant-lexicon-docker",
3
- "version": "0.44.13",
3
+ "version": "0.45.0",
4
4
  "description": "Docker lexicon for chant — declarative IaC in TypeScript",
5
5
  "license": "Apache-2.0",
6
6
  "homepage": "https://intentius.io/chant",
@@ -67,7 +67,7 @@
67
67
  "typescript": "^5.9.3"
68
68
  },
69
69
  "peerDependencies": {
70
- "@intentius/chant": "^0.44.13",
70
+ "@intentius/chant": "^0.45.0",
71
71
  "typescript": "^5.9.3"
72
72
  }
73
73
  }
@@ -1,42 +1,156 @@
1
1
  /**
2
2
  * Docker lexicon docs generation.
3
3
  *
4
- * The docker site is hand-authored under docs/src/content/docs/, unlike every
5
- * other lexicon's generated Starlight site. The rules table is the exception:
6
- * a hand-maintained one can fall behind the rules in src/lint/ without anything
7
- * catching it, so it is generated from source here (#1312).
4
+ * Uses the shared docsPipeline/writeDocsSite flow like every other lexicon
5
+ * (chant #1731, #1755). Hand-written prose lives under docs/pages/, each
6
+ * page tagged with a Diátaxis quadrant; index.mdx and serialization.mdx are
7
+ * generated from the overview/outputFormat strings below, and rules.mdx is
8
+ * generated from the rule sources under src/lint/ the same way it always
9
+ * was — this used to be the one lexicon whose rules table could drift from
10
+ * source without anything catching it (#1312), and the shared pipeline
11
+ * keeps that guarantee.
8
12
  */
9
13
 
10
14
  import { dirname, join } from "path";
11
15
  import { fileURLToPath } from "url";
12
- import { writeFileSync } from "fs";
13
- import { generateRulesPage, type DocsConfig } from "@intentius/chant/codegen/docs";
16
+ import { docsPipeline, writeDocsSite, type DocsConfig } from "@intentius/chant/codegen/docs";
17
+
18
+ const overview = `
19
+ The **Docker** lexicon provides typed constructors for Docker Compose services
20
+ and Dockerfile build instructions — services, volumes, networks, configs, secrets,
21
+ and multi-stage Dockerfiles.
22
+
23
+ \`\`\`bash
24
+ npm install --save-dev @intentius/chant-lexicon-docker
25
+ \`\`\`
26
+
27
+ ## Quick Start
28
+
29
+ \`\`\`typescript
30
+ import { Service, Volume, Dockerfile, env } from "@intentius/chant-lexicon-docker";
31
+
32
+ export const db = new Service({
33
+ image: "postgres:16-alpine",
34
+ environment: {
35
+ POSTGRES_DB: "myapp",
36
+ POSTGRES_PASSWORD: env("DB_PASSWORD", { required: true }),
37
+ },
38
+ volumes: ["pgdata:/var/lib/postgresql/data"],
39
+ });
40
+
41
+ export const pgdata = new Volume({});
42
+
43
+ export const api = new Service({
44
+ image: "myapp:1.0",
45
+ ports: ["8080:8080"],
46
+ depends_on: ["db"],
47
+ });
48
+ \`\`\`
49
+
50
+ Build:
51
+
52
+ \`\`\`bash
53
+ chant build src --lexicon docker -o docker-compose.yml
54
+ \`\`\`
55
+
56
+ ## Output Domains
57
+
58
+ | Entity | Output file | Section |
59
+ |--------|-------------|---------|
60
+ | \`Service\` | \`docker-compose.yml\` | \`services:\` |
61
+ | \`Volume\` | \`docker-compose.yml\` | \`volumes:\` |
62
+ | \`Network\` | \`docker-compose.yml\` | \`networks:\` |
63
+ | \`Config\` | \`docker-compose.yml\` | \`configs:\` |
64
+ | \`Secret\` | \`docker-compose.yml\` | \`secrets:\` |
65
+ | \`Dockerfile\` | \`Dockerfile.{name}\` | — |`;
66
+
67
+ const outputFormat = `
68
+ The Docker lexicon serializes to two output formats.
69
+
70
+ ## docker-compose.yml
71
+
72
+ \`\`\`bash
73
+ chant build src --lexicon docker -o docker-compose.yml
74
+ \`\`\`
75
+
76
+ Each entity type maps to a top-level Compose section. The TypeScript export name becomes the key within that section.
77
+
78
+ \`\`\`typescript
79
+ export const db = new Service({ image: "postgres:16-alpine" });
80
+ export const pgdata = new Volume({});
81
+ export const backend = new Network({ driver: "bridge" });
82
+ \`\`\`
83
+
84
+ Produces:
85
+
86
+ \`\`\`yaml
87
+ services:
88
+ db:
89
+ image: postgres:16-alpine
90
+
91
+ volumes:
92
+ pgdata: null
93
+
94
+ networks:
95
+ backend:
96
+ driver: bridge
97
+ \`\`\`
98
+
99
+ \`defaultLabels()\` entities are not emitted as separate keys — their labels are merged into each service.
100
+
101
+ ## Dockerfile.\\{name\\}
102
+
103
+ \`\`\`bash
104
+ chant build src --lexicon docker
105
+ # Writes Dockerfile.app, Dockerfile.builder, etc.
106
+ \`\`\`
107
+
108
+ Each \`Dockerfile\` entity produces a separate file. The export name is the suffix.
109
+
110
+ \`\`\`typescript
111
+ export const builder = new Dockerfile({ from: "node:20-alpine", ... });
112
+ // → Dockerfile.builder
113
+ \`\`\`
114
+
115
+ ## Field mapping
116
+
117
+ | TypeScript | docker-compose.yml | Notes |
118
+ |-----------|-------------------|-------|
119
+ | \`env("X", { required: true })\` | \`\${X:?X is required}\` | Compose interpolation |
120
+ | \`env("X", { default: "v" })\` | \`\${X:-v}\` | Compose interpolation |
121
+ | \`env("X")\` | \`\${X}\` | Compose interpolation |
122
+ | \`external: true\` | \`external: true\` | Volume/Network |
123
+
124
+ ## Specifying lexicon at build time
125
+
126
+ The \`--lexicon docker\` flag restricts output to Docker entities only — useful in mixed-lexicon projects:
127
+
128
+ \`\`\`bash
129
+ # Only Docker output
130
+ chant build src --lexicon docker -o docker-compose.yml
131
+
132
+ # Other lexicons still get their own outputs
133
+ chant build src --lexicon aws -o template.json
134
+ \`\`\``;
14
135
 
15
136
  export async function generateDocs(opts?: { verbose?: boolean }): Promise<void> {
16
137
  const pkgDir = dirname(dirname(dirname(fileURLToPath(import.meta.url))));
17
138
 
18
- if (opts?.verbose) {
19
- console.error("Generating Docker lexicon docs...");
20
- }
21
-
22
- const config = {
139
+ const config: DocsConfig = {
23
140
  name: "docker",
24
141
  displayName: "Docker",
25
- description: "Typed constructors for Docker Compose files and Dockerfiles",
142
+ description: "Typed constructors for Docker Compose and Dockerfile configuration",
26
143
  distDir: join(pkgDir, "dist"),
27
144
  outDir: join(pkgDir, "docs"),
28
- } as DocsConfig;
29
-
30
- const rules = generateRulesPage(config, join(pkgDir, "src"));
31
- if (rules) {
32
- const out = join(pkgDir, "docs", "src", "content", "docs", "rules.mdx");
33
- writeFileSync(out, rules);
34
- if (opts?.verbose) {
35
- console.error(`Wrote ${out}`);
36
- }
37
- }
145
+ basePath: "/chant/lexicons/docker/",
146
+ overview,
147
+ outputFormat,
148
+ };
149
+
150
+ const result = docsPipeline(config);
151
+ writeDocsSite(config, result);
38
152
 
39
- // Every other page is hand-authored in docs/src/content/docs/.
40
- // Future: auto-generate entity reference pages from lexicon-docker.json
41
- console.error("Docker docs: rules.mdx generated; prose pages are hand-authored");
153
+ if (opts?.verbose) {
154
+ console.error("Documentation generated");
155
+ }
42
156
  }