@intentius/chant-lexicon-docker 0.124.98 → 0.124.100
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/docs-cli.d.ts +0 -1
- package/dist/codegen/docs.d.ts +0 -1
- package/dist/codegen/generate-cli.d.ts +0 -1
- package/dist/codegen/generate-compose.d.ts +0 -1
- package/dist/codegen/generate-dockerfile.d.ts +0 -1
- package/dist/codegen/generate.d.ts +0 -1
- package/dist/codegen/naming.d.ts +0 -1
- package/dist/codegen/package.d.ts +0 -1
- package/dist/codegen/patches.d.ts +0 -1
- package/dist/codegen/versions.d.ts +0 -1
- package/dist/compose-key.d.ts +0 -1
- package/dist/composites/catalog.d.ts +0 -1
- package/dist/composites/docker-otel-collector.d.ts +0 -1
- package/dist/composites/docker-web-service.d.ts +0 -1
- package/dist/composites/index.d.ts +0 -1
- package/dist/coverage.d.ts +0 -1
- package/dist/default-labels.d.ts +0 -1
- package/dist/detect.d.ts +0 -1
- package/dist/dockerfile-order.d.ts +0 -1
- package/dist/export-resources.d.ts +0 -1
- package/dist/generated/index.d.ts +0 -1
- package/dist/generated/runtime.d.ts +0 -1
- package/dist/import/adapter.d.ts +0 -1
- package/dist/import/adapter.js +4 -2
- package/dist/import/embedded.d.ts +0 -1
- package/dist/import/engine.d.ts +0 -1
- package/dist/import/generator.d.ts +9 -2
- package/dist/import/generator.js +23 -1
- package/dist/import/live-export.d.ts +0 -1
- package/dist/import/parser.d.ts +0 -1
- package/dist/import/testdata/tar.d.ts +0 -1
- package/dist/index.d.ts +0 -1
- package/dist/integrity.json +2 -2
- package/dist/interpolation.d.ts +0 -1
- package/dist/lint/audit-catalog.d.ts +0 -1
- package/dist/lint/audit-lineage.d.ts +0 -1
- package/dist/lint/post-synth/add-url-checksum.d.ts +0 -1
- package/dist/lint/post-synth/apt-no-recommends.d.ts +0 -1
- package/dist/lint/post-synth/apt-update-alone.d.ts +0 -1
- package/dist/lint/post-synth/cache-busting-copy.d.ts +0 -1
- package/dist/lint/post-synth/copy-from-stage.d.ts +0 -1
- package/dist/lint/post-synth/docker-helpers.d.ts +0 -1
- package/dist/lint/post-synth/index.d.ts +0 -1
- package/dist/lint/post-synth/no-latest-image.d.ts +0 -1
- package/dist/lint/post-synth/no-root-user.d.ts +0 -1
- package/dist/lint/post-synth/prefer-copy.d.ts +0 -1
- package/dist/lint/post-synth/relative-workdir.d.ts +0 -1
- package/dist/lint/post-synth/repeated-cmd.d.ts +0 -1
- package/dist/lint/post-synth/root-after-user.d.ts +0 -1
- package/dist/lint/post-synth/ssh-port-exposed.d.ts +0 -1
- package/dist/lint/post-synth/unused-global-arg.d.ts +0 -1
- package/dist/lint/post-synth/unused-volume.d.ts +0 -1
- package/dist/lint/rules/data/deprecated-images.d.ts +0 -1
- package/dist/lint/rules/data/known-base-images.d.ts +0 -1
- package/dist/lint/rules/index.d.ts +0 -1
- package/dist/lint/rules/no-latest-tag.d.ts +0 -1
- package/dist/lint/rules/per-kind-order.d.ts +0 -1
- package/dist/list-artifacts.d.ts +0 -1
- package/dist/lsp/completions.d.ts +0 -1
- package/dist/lsp/hover.d.ts +0 -1
- package/dist/manifest.json +1 -1
- package/dist/package-cli.d.ts +0 -1
- package/dist/plugin.d.ts +0 -1
- package/dist/serializer.d.ts +0 -1
- package/dist/spec/fetch-compose.d.ts +0 -1
- package/dist/spec/fetch-engine.d.ts +0 -1
- package/dist/spec/parse-compose.d.ts +0 -1
- package/dist/spec/parse-engine.d.ts +0 -1
- package/dist/validate-cli.d.ts +0 -1
- package/dist/validate.d.ts +0 -1
- package/dist/variables.d.ts +0 -1
- package/package.json +8 -9
- package/dist/codegen/docs-cli.d.ts.map +0 -1
- package/dist/codegen/docs.d.ts.map +0 -1
- package/dist/codegen/generate-cli.d.ts.map +0 -1
- package/dist/codegen/generate-compose.d.ts.map +0 -1
- package/dist/codegen/generate-dockerfile.d.ts.map +0 -1
- package/dist/codegen/generate.d.ts.map +0 -1
- package/dist/codegen/naming.d.ts.map +0 -1
- package/dist/codegen/package.d.ts.map +0 -1
- package/dist/codegen/patches.d.ts.map +0 -1
- package/dist/codegen/versions.d.ts.map +0 -1
- package/dist/compose-key.d.ts.map +0 -1
- package/dist/composites/catalog.d.ts.map +0 -1
- package/dist/composites/docker-otel-collector.d.ts.map +0 -1
- package/dist/composites/docker-web-service.d.ts.map +0 -1
- package/dist/composites/index.d.ts.map +0 -1
- package/dist/coverage.d.ts.map +0 -1
- package/dist/default-labels.d.ts.map +0 -1
- package/dist/detect.d.ts.map +0 -1
- package/dist/dockerfile-order.d.ts.map +0 -1
- package/dist/export-resources.d.ts.map +0 -1
- package/dist/generated/index.d.ts.map +0 -1
- package/dist/generated/runtime.d.ts.map +0 -1
- package/dist/import/adapter.d.ts.map +0 -1
- package/dist/import/embedded.d.ts.map +0 -1
- package/dist/import/engine.d.ts.map +0 -1
- package/dist/import/generator.d.ts.map +0 -1
- package/dist/import/live-export.d.ts.map +0 -1
- package/dist/import/parser.d.ts.map +0 -1
- package/dist/import/testdata/tar.d.ts.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/interpolation.d.ts.map +0 -1
- package/dist/lint/audit-catalog.d.ts.map +0 -1
- package/dist/lint/audit-lineage.d.ts.map +0 -1
- package/dist/lint/post-synth/add-url-checksum.d.ts.map +0 -1
- package/dist/lint/post-synth/apt-no-recommends.d.ts.map +0 -1
- package/dist/lint/post-synth/apt-update-alone.d.ts.map +0 -1
- package/dist/lint/post-synth/cache-busting-copy.d.ts.map +0 -1
- package/dist/lint/post-synth/copy-from-stage.d.ts.map +0 -1
- package/dist/lint/post-synth/docker-helpers.d.ts.map +0 -1
- package/dist/lint/post-synth/index.d.ts.map +0 -1
- package/dist/lint/post-synth/no-latest-image.d.ts.map +0 -1
- package/dist/lint/post-synth/no-root-user.d.ts.map +0 -1
- package/dist/lint/post-synth/prefer-copy.d.ts.map +0 -1
- package/dist/lint/post-synth/relative-workdir.d.ts.map +0 -1
- package/dist/lint/post-synth/repeated-cmd.d.ts.map +0 -1
- package/dist/lint/post-synth/root-after-user.d.ts.map +0 -1
- package/dist/lint/post-synth/ssh-port-exposed.d.ts.map +0 -1
- package/dist/lint/post-synth/unused-global-arg.d.ts.map +0 -1
- package/dist/lint/post-synth/unused-volume.d.ts.map +0 -1
- package/dist/lint/rules/data/deprecated-images.d.ts.map +0 -1
- package/dist/lint/rules/data/known-base-images.d.ts.map +0 -1
- package/dist/lint/rules/index.d.ts.map +0 -1
- package/dist/lint/rules/no-latest-tag.d.ts.map +0 -1
- package/dist/lint/rules/per-kind-order.d.ts.map +0 -1
- package/dist/list-artifacts.d.ts.map +0 -1
- package/dist/lsp/completions.d.ts.map +0 -1
- package/dist/lsp/hover.d.ts.map +0 -1
- package/dist/package-cli.d.ts.map +0 -1
- package/dist/plugin.d.ts.map +0 -1
- package/dist/serializer.d.ts.map +0 -1
- package/dist/spec/fetch-compose.d.ts.map +0 -1
- package/dist/spec/fetch-engine.d.ts.map +0 -1
- package/dist/spec/parse-compose.d.ts.map +0 -1
- package/dist/spec/parse-engine.d.ts.map +0 -1
- package/dist/validate-cli.d.ts.map +0 -1
- package/dist/validate.d.ts.map +0 -1
- package/dist/variables.d.ts.map +0 -1
- package/src/codegen/__snapshots__/okf.test.ts.snap +0 -555
- package/src/codegen/docs-cli.ts +0 -10
- package/src/codegen/docs.ts +0 -171
- package/src/codegen/generate-cli.ts +0 -36
- package/src/codegen/generate-compose.ts +0 -21
- package/src/codegen/generate-dockerfile.ts +0 -21
- package/src/codegen/generate.test.ts +0 -115
- package/src/codegen/generate.ts +0 -258
- package/src/codegen/naming.test.ts +0 -81
- package/src/codegen/naming.ts +0 -54
- package/src/codegen/okf.test.ts +0 -36
- package/src/codegen/package.ts +0 -59
- package/src/codegen/patches.ts +0 -42
- package/src/codegen/versions.ts +0 -46
- package/src/compose-key.ts +0 -31
- package/src/composites/catalog.test.ts +0 -39
- package/src/composites/catalog.ts +0 -118
- package/src/composites/docker-otel-collector.ts +0 -83
- package/src/composites/docker-web-service.test.ts +0 -34
- package/src/composites/docker-web-service.ts +0 -75
- package/src/composites/index.ts +0 -9
- package/src/coverage.test.ts +0 -33
- package/src/coverage.ts +0 -54
- package/src/default-labels.test.ts +0 -85
- package/src/default-labels.ts +0 -72
- package/src/detect.ts +0 -7
- package/src/dockerfile-order.ts +0 -20
- package/src/docs-examples.test.ts +0 -141
- package/src/export-resources.ts +0 -90
- package/src/generated/index.d.ts +0 -407
- package/src/generated/index.ts +0 -410
- package/src/generated/runtime.ts +0 -4
- package/src/import/adapter.ts +0 -99
- package/src/import/embedded-live.test.ts +0 -250
- package/src/import/embedded.ts +0 -83
- package/src/import/engine.ts +0 -107
- package/src/import/generator.test.ts +0 -134
- package/src/import/generator.ts +0 -202
- package/src/import/live-export.test.ts +0 -271
- package/src/import/live-export.ts +0 -359
- package/src/import/parser.test.ts +0 -137
- package/src/import/parser.ts +0 -269
- package/src/import/roundtrip.test.ts +0 -257
- package/src/import/testdata/configs-secrets.yaml +0 -15
- package/src/import/testdata/full.yaml +0 -43
- package/src/import/testdata/names-and-fields.yaml +0 -44
- package/src/import/testdata/simple.yaml +0 -9
- package/src/import/testdata/tar.ts +0 -24
- package/src/import/testdata/webapp.yaml +0 -41
- package/src/index.ts +0 -32
- package/src/interpolation.test.ts +0 -41
- package/src/interpolation.ts +0 -76
- package/src/lint/audit-catalog.ts +0 -28
- package/src/lint/audit-lineage.ts +0 -48
- package/src/lint/post-synth/add-url-checksum.ts +0 -38
- package/src/lint/post-synth/apt-no-recommends.ts +0 -43
- package/src/lint/post-synth/apt-update-alone.ts +0 -39
- package/src/lint/post-synth/cache-busting-copy.ts +0 -65
- package/src/lint/post-synth/copy-from-stage.ts +0 -54
- package/src/lint/post-synth/docker-helpers.ts +0 -194
- package/src/lint/post-synth/index.ts +0 -33
- package/src/lint/post-synth/no-latest-image.ts +0 -36
- package/src/lint/post-synth/no-root-user.ts +0 -38
- package/src/lint/post-synth/post-synth.test.ts +0 -330
- package/src/lint/post-synth/prefer-copy.ts +0 -53
- package/src/lint/post-synth/relative-workdir.ts +0 -38
- package/src/lint/post-synth/repeated-cmd.ts +0 -35
- package/src/lint/post-synth/root-after-user.ts +0 -44
- package/src/lint/post-synth/ssh-port-exposed.ts +0 -68
- package/src/lint/post-synth/unused-global-arg.ts +0 -38
- package/src/lint/post-synth/unused-volume.ts +0 -49
- package/src/lint/rules/data/deprecated-images.ts +0 -28
- package/src/lint/rules/data/known-base-images.ts +0 -20
- package/src/lint/rules/index.ts +0 -6
- package/src/lint/rules/no-latest-tag.ts +0 -63
- package/src/lint/rules/per-kind-order.ts +0 -130
- package/src/lint/rules/rules.test.ts +0 -170
- package/src/list-artifacts.test.ts +0 -141
- package/src/list-artifacts.ts +0 -164
- package/src/lsp/completions.test.ts +0 -40
- package/src/lsp/completions.ts +0 -21
- package/src/lsp/hover.test.ts +0 -35
- package/src/lsp/hover.ts +0 -39
- package/src/package-cli.ts +0 -25
- package/src/plugin.test.ts +0 -121
- package/src/plugin.ts +0 -268
- package/src/serializer.test.ts +0 -545
- package/src/serializer.ts +0 -444
- package/src/skills/chant-docker-patterns.md +0 -222
- package/src/skills/chant-docker.md +0 -156
- package/src/spec/fetch-compose.ts +0 -35
- package/src/spec/fetch-engine.ts +0 -25
- package/src/spec/parse-compose.ts +0 -195
- package/src/spec/parse-engine.ts +0 -59
- package/src/typecheck.e2e.test.ts +0 -125
- package/src/typed-props.test.ts +0 -60
- package/src/validate-cli.ts +0 -19
- package/src/validate.test.ts +0 -16
- package/src/validate.ts +0 -44
- package/src/variables.test.ts +0 -32
- package/src/variables.ts +0 -47
- /package/{src → dist}/generated/lexicon-docker.json +0 -0
package/src/plugin.test.ts
DELETED
|
@@ -1,121 +0,0 @@
|
|
|
1
|
-
import { describe, test, expect } from "vitest";
|
|
2
|
-
import { dockerPlugin } from "./plugin";
|
|
3
|
-
|
|
4
|
-
describe("dockerPlugin", () => {
|
|
5
|
-
test("has correct name", () => {
|
|
6
|
-
expect(dockerPlugin.name).toBe("docker");
|
|
7
|
-
});
|
|
8
|
-
|
|
9
|
-
test("has serializer", () => {
|
|
10
|
-
expect(dockerPlugin.serializer).toBeDefined();
|
|
11
|
-
expect(dockerPlugin.serializer.name).toBe("docker");
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
test("provides lint rules", () => {
|
|
15
|
-
const rules = dockerPlugin.lintRules!();
|
|
16
|
-
expect(rules.length).toBeGreaterThanOrEqual(1);
|
|
17
|
-
|
|
18
|
-
const ruleIds = rules.map((r) => r.id);
|
|
19
|
-
expect(ruleIds).toContain("DKRS001");
|
|
20
|
-
expect(ruleIds).toContain("DKRS002");
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
test("provides post-synth checks", () => {
|
|
24
|
-
const checks = dockerPlugin.postSynthChecks!();
|
|
25
|
-
expect(checks.length).toBeGreaterThanOrEqual(1);
|
|
26
|
-
|
|
27
|
-
const checkIds = checks.map((c) => c.id);
|
|
28
|
-
expect(checkIds).toContain("DKRD001");
|
|
29
|
-
expect(checkIds).toContain("DKRD002");
|
|
30
|
-
expect(checkIds).toContain("DKRD003");
|
|
31
|
-
expect(checkIds).toContain("DKRD010");
|
|
32
|
-
expect(checkIds).toContain("DKRD011");
|
|
33
|
-
expect(checkIds).toContain("DKRD012");
|
|
34
|
-
for (const id of ["DKRD013", "DKRD014", "DKRD015", "DKRD016", "DKRD017", "DKRD018", "DKRD019", "DKRD020"]) {
|
|
35
|
-
expect(checkIds).toContain(id);
|
|
36
|
-
}
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
test("provides intrinsics", () => {
|
|
40
|
-
const intrinsics = dockerPlugin.intrinsics!();
|
|
41
|
-
expect(intrinsics.length).toBe(1);
|
|
42
|
-
expect(intrinsics[0].name).toBe("env");
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
test("provides init templates — default", () => {
|
|
46
|
-
const template = dockerPlugin.initTemplates!();
|
|
47
|
-
expect(template.src).toBeDefined();
|
|
48
|
-
expect(template.src["compose.ts"]).toContain("Service");
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
test("provides init templates — webapp", () => {
|
|
52
|
-
const template = dockerPlugin.initTemplates!("webapp");
|
|
53
|
-
expect(template.src["compose.ts"]).toContain("postgres");
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
test("detects Docker Compose template", () => {
|
|
57
|
-
expect(dockerPlugin.detectTemplate!({ services: {}, volumes: {} })).toBe(true);
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
test("rejects non-Docker data", () => {
|
|
61
|
-
expect(dockerPlugin.detectTemplate!({ jobs: {}, on: {} })).toBe(false);
|
|
62
|
-
expect(dockerPlugin.detectTemplate!(null)).toBe(false);
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
test("has completionProvider", () => {
|
|
66
|
-
expect(dockerPlugin.completionProvider).toBeDefined();
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
test("has hoverProvider", () => {
|
|
70
|
-
expect(dockerPlugin.hoverProvider).toBeDefined();
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
test("has templateParser", () => {
|
|
74
|
-
expect(dockerPlugin.templateParser).toBeDefined();
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
test("has templateGenerator", () => {
|
|
78
|
-
expect(dockerPlugin.templateGenerator).toBeDefined();
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
test("has generate method", () => {
|
|
82
|
-
expect(dockerPlugin.generate).toBeDefined();
|
|
83
|
-
});
|
|
84
|
-
|
|
85
|
-
test("has validate method", () => {
|
|
86
|
-
expect(dockerPlugin.validate).toBeDefined();
|
|
87
|
-
});
|
|
88
|
-
|
|
89
|
-
test("has coverage method", () => {
|
|
90
|
-
expect(dockerPlugin.coverage).toBeDefined();
|
|
91
|
-
});
|
|
92
|
-
|
|
93
|
-
test("has package method", () => {
|
|
94
|
-
expect(dockerPlugin.package).toBeDefined();
|
|
95
|
-
});
|
|
96
|
-
|
|
97
|
-
test("has docs method", () => {
|
|
98
|
-
expect(dockerPlugin.docs).toBeDefined();
|
|
99
|
-
});
|
|
100
|
-
|
|
101
|
-
test("provides skills", () => {
|
|
102
|
-
const skills = dockerPlugin.skills!();
|
|
103
|
-
expect(skills.length).toBeGreaterThanOrEqual(2);
|
|
104
|
-
const names = skills.map((s) => s.name);
|
|
105
|
-
expect(names).toContain("chant-docker");
|
|
106
|
-
expect(names).toContain("chant-docker-patterns");
|
|
107
|
-
});
|
|
108
|
-
|
|
109
|
-
test("provides MCP tools", () => {
|
|
110
|
-
const tools = dockerPlugin.mcpTools!();
|
|
111
|
-
expect(tools.length).toBe(1);
|
|
112
|
-
expect(tools[0].name).toBe("docker:diff");
|
|
113
|
-
});
|
|
114
|
-
|
|
115
|
-
test("provides MCP resources", () => {
|
|
116
|
-
const resources = dockerPlugin.mcpResources!();
|
|
117
|
-
expect(resources.length).toBe(2);
|
|
118
|
-
expect(resources[0].uri).toBe("docker:resource-catalog");
|
|
119
|
-
expect(resources[1].uri).toBe("examples/basic-app");
|
|
120
|
-
});
|
|
121
|
-
});
|
package/src/plugin.ts
DELETED
|
@@ -1,268 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Docker lexicon plugin.
|
|
3
|
-
*
|
|
4
|
-
* Provides serializer, lint rules, post-synth checks, intrinsics, LSP support,
|
|
5
|
-
* and code generation for Docker Compose and Dockerfile resources.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
import { compositeCatalog } from "./composites/catalog";
|
|
9
|
-
import type { LexiconPlugin, IntrinsicDef, InitTemplateSet } from "@intentius/chant/lexicon";
|
|
10
|
-
import { detectTemplate } from "./detect";
|
|
11
|
-
import type { LintRule } from "@intentius/chant/lint/rule";
|
|
12
|
-
import { postSynthChecks as postSynthCheckList } from "./lint/post-synth";
|
|
13
|
-
import { dockerAuditCatalog } from "./lint/audit-catalog";
|
|
14
|
-
import { createSkillsLoader, createDiffTool, createCatalogResource } from "@intentius/chant/lexicon-plugin-helpers";
|
|
15
|
-
import { join, dirname } from "path";
|
|
16
|
-
import { fileURLToPath } from "url";
|
|
17
|
-
import { dockerSerializer } from "./serializer";
|
|
18
|
-
import { noLatestTagRule } from "./lint/rules/no-latest-tag";
|
|
19
|
-
import { perKindOrderRule } from "./lint/rules/per-kind-order";
|
|
20
|
-
import { dockerCompletions } from "./lsp/completions";
|
|
21
|
-
import { dockerHover } from "./lsp/hover";
|
|
22
|
-
import { DockerTemplateParser, DockerTemplateGenerator } from "./import/adapter";
|
|
23
|
-
|
|
24
|
-
export const dockerPlugin: LexiconPlugin = {
|
|
25
|
-
name: "docker",
|
|
26
|
-
auditCatalog: () => dockerAuditCatalog,
|
|
27
|
-
// Self-upgrade: the moby/moby tag embedded in the Engine API spec URL + its upstream (#685).
|
|
28
|
-
upstreamPin: {
|
|
29
|
-
file: "src/codegen/versions.ts",
|
|
30
|
-
pattern: /moby\/moby\/([^/]+)\/api\/swagger\.yaml/,
|
|
31
|
-
replace: (v, line) => line.replace(/moby\/moby\/[^/]+\/api\/swagger\.yaml/, `moby/moby/${v}/api/swagger.yaml`),
|
|
32
|
-
upstream: { owner: "moby", repo: "moby", kind: "releases" },
|
|
33
|
-
},
|
|
34
|
-
serializer: dockerSerializer,
|
|
35
|
-
|
|
36
|
-
lintRules(): LintRule[] {
|
|
37
|
-
return [noLatestTagRule, perKindOrderRule];
|
|
38
|
-
},
|
|
39
|
-
|
|
40
|
-
postSynthChecks() {
|
|
41
|
-
return postSynthCheckList;
|
|
42
|
-
},
|
|
43
|
-
|
|
44
|
-
intrinsics(): IntrinsicDef[] {
|
|
45
|
-
return [
|
|
46
|
-
{
|
|
47
|
-
name: "env",
|
|
48
|
-
description: "Docker Compose variable interpolation — ${VAR}, ${VAR:-default}, ${VAR:?error}",
|
|
49
|
-
outputKey: "env",
|
|
50
|
-
isTag: false,
|
|
51
|
-
},
|
|
52
|
-
];
|
|
53
|
-
},
|
|
54
|
-
|
|
55
|
-
initTemplates(template?: string): InitTemplateSet {
|
|
56
|
-
if (template === "webapp") {
|
|
57
|
-
return {
|
|
58
|
-
src: {
|
|
59
|
-
"compose.ts": `import { Service, Volume } from "@intentius/chant-lexicon-docker";
|
|
60
|
-
|
|
61
|
-
export const db = new Service({
|
|
62
|
-
image: "postgres:16-alpine",
|
|
63
|
-
environment: {
|
|
64
|
-
POSTGRES_DB: "myapp",
|
|
65
|
-
POSTGRES_USER: "myapp",
|
|
66
|
-
POSTGRES_PASSWORD: "secret",
|
|
67
|
-
},
|
|
68
|
-
volumes: ["pgdata:/var/lib/postgresql/data"],
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
export const pgdata = new Volume({});
|
|
72
|
-
|
|
73
|
-
export const api = new Service({
|
|
74
|
-
image: "myapp:1.0",
|
|
75
|
-
ports: ["8080:8080"],
|
|
76
|
-
depends_on: ["db"],
|
|
77
|
-
environment: {
|
|
78
|
-
DATABASE_URL: "postgresql://myapp:secret@db:5432/myapp",
|
|
79
|
-
},
|
|
80
|
-
});
|
|
81
|
-
`,
|
|
82
|
-
},
|
|
83
|
-
};
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
// Default template
|
|
87
|
-
return {
|
|
88
|
-
src: {
|
|
89
|
-
"compose.ts": `import { Service } from "@intentius/chant-lexicon-docker";
|
|
90
|
-
|
|
91
|
-
export const api = new Service({
|
|
92
|
-
image: "myapp:1.0",
|
|
93
|
-
ports: ["8080:8080"],
|
|
94
|
-
restart: "unless-stopped",
|
|
95
|
-
});
|
|
96
|
-
`,
|
|
97
|
-
},
|
|
98
|
-
};
|
|
99
|
-
},
|
|
100
|
-
|
|
101
|
-
detectTemplate,
|
|
102
|
-
|
|
103
|
-
completionProvider(ctx: import("@intentius/chant/lsp/types").CompletionContext) {
|
|
104
|
-
return dockerCompletions(ctx);
|
|
105
|
-
},
|
|
106
|
-
|
|
107
|
-
hoverProvider(ctx: import("@intentius/chant/lsp/types").HoverContext) {
|
|
108
|
-
return dockerHover(ctx);
|
|
109
|
-
},
|
|
110
|
-
|
|
111
|
-
templateParser() {
|
|
112
|
-
return new DockerTemplateParser();
|
|
113
|
-
},
|
|
114
|
-
|
|
115
|
-
templateGenerator() {
|
|
116
|
-
return new DockerTemplateGenerator();
|
|
117
|
-
},
|
|
118
|
-
|
|
119
|
-
async generate(options?: { verbose?: boolean }): Promise<void> {
|
|
120
|
-
const { generate, writeGeneratedFiles } = await import("./codegen/generate");
|
|
121
|
-
const { dirname: pathDirname } = await import("path");
|
|
122
|
-
const { fileURLToPath: urlToPath } = await import("url");
|
|
123
|
-
|
|
124
|
-
const result = await generate({ verbose: options?.verbose ?? true });
|
|
125
|
-
const pkgDir = pathDirname(pathDirname(urlToPath(import.meta.url)));
|
|
126
|
-
writeGeneratedFiles(result, pkgDir);
|
|
127
|
-
|
|
128
|
-
console.error(
|
|
129
|
-
`Generated ${result.resources} entities, ${result.properties} property types, ${result.enums} enums`,
|
|
130
|
-
);
|
|
131
|
-
if (result.warnings.length > 0) {
|
|
132
|
-
console.error(`${result.warnings.length} warnings`);
|
|
133
|
-
}
|
|
134
|
-
},
|
|
135
|
-
|
|
136
|
-
async validate(options?: { verbose?: boolean }): Promise<void> {
|
|
137
|
-
const { validate } = await import("./validate");
|
|
138
|
-
const { printValidationResult } = await import("@intentius/chant/codegen/validate");
|
|
139
|
-
const result = await validate();
|
|
140
|
-
printValidationResult(result);
|
|
141
|
-
},
|
|
142
|
-
|
|
143
|
-
async coverage(options?: { verbose?: boolean; minOverall?: number }): Promise<void> {
|
|
144
|
-
const { analyzeDockerCoverage } = await import("./coverage");
|
|
145
|
-
await analyzeDockerCoverage({
|
|
146
|
-
verbose: options?.verbose,
|
|
147
|
-
minOverall: options?.minOverall,
|
|
148
|
-
});
|
|
149
|
-
},
|
|
150
|
-
|
|
151
|
-
async package(options?: { verbose?: boolean; force?: boolean }): Promise<void> {
|
|
152
|
-
const { packageLexicon } = await import("./codegen/package");
|
|
153
|
-
const { writeBundleSpec } = await import("@intentius/chant/codegen/package");
|
|
154
|
-
const { join: pathJoin, dirname: pathDirname } = await import("path");
|
|
155
|
-
const { fileURLToPath: urlToPath } = await import("url");
|
|
156
|
-
|
|
157
|
-
const { spec, stats } = await packageLexicon({ verbose: options?.verbose, force: options?.force });
|
|
158
|
-
|
|
159
|
-
const pkgDir = pathDirname(pathDirname(urlToPath(import.meta.url)));
|
|
160
|
-
const distDir = pathJoin(pkgDir, "dist");
|
|
161
|
-
writeBundleSpec(spec, distDir);
|
|
162
|
-
|
|
163
|
-
console.error(`Packaged ${stats.resources} entities, ${stats.ruleCount} rules, ${stats.skillCount} skills`);
|
|
164
|
-
},
|
|
165
|
-
|
|
166
|
-
composites() {
|
|
167
|
-
return compositeCatalog;
|
|
168
|
-
},
|
|
169
|
-
|
|
170
|
-
mcpTools() {
|
|
171
|
-
return [createDiffTool(dockerSerializer, "Compare current build output against previous output for Docker Compose", "docker")];
|
|
172
|
-
},
|
|
173
|
-
|
|
174
|
-
mcpResources() {
|
|
175
|
-
return [
|
|
176
|
-
createCatalogResource(import.meta.url, "Docker Entity Catalog", "JSON list of all supported Docker entity types", "lexicon-docker.json", "docker"),
|
|
177
|
-
{
|
|
178
|
-
uri: "examples/basic-app",
|
|
179
|
-
name: "Basic App Example",
|
|
180
|
-
description: "A basic Docker Compose application with a service and volume",
|
|
181
|
-
mimeType: "text/typescript",
|
|
182
|
-
async handler(): Promise<string> {
|
|
183
|
-
return `import { Service, Volume } from "@intentius/chant-lexicon-docker";
|
|
184
|
-
|
|
185
|
-
export const db = new Service({
|
|
186
|
-
image: "postgres:16-alpine",
|
|
187
|
-
environment: {
|
|
188
|
-
POSTGRES_DB: "myapp",
|
|
189
|
-
POSTGRES_USER: "myapp",
|
|
190
|
-
POSTGRES_PASSWORD: "secret",
|
|
191
|
-
},
|
|
192
|
-
volumes: ["pgdata:/var/lib/postgresql/data"],
|
|
193
|
-
});
|
|
194
|
-
|
|
195
|
-
export const pgdata = new Volume({});
|
|
196
|
-
|
|
197
|
-
export const api = new Service({
|
|
198
|
-
image: "myapp:1.0",
|
|
199
|
-
ports: ["8080:8080"],
|
|
200
|
-
depends_on: ["db"],
|
|
201
|
-
});
|
|
202
|
-
`;
|
|
203
|
-
},
|
|
204
|
-
},
|
|
205
|
-
];
|
|
206
|
-
},
|
|
207
|
-
|
|
208
|
-
async docs(options?: { verbose?: boolean }): Promise<void> {
|
|
209
|
-
const { generateDocs } = await import("./codegen/docs");
|
|
210
|
-
await generateDocs(options);
|
|
211
|
-
},
|
|
212
|
-
|
|
213
|
-
skills: createSkillsLoader(import.meta.url, [
|
|
214
|
-
{
|
|
215
|
-
file: "chant-docker.md",
|
|
216
|
-
name: "chant-docker",
|
|
217
|
-
description: "Docker Compose service/volume/network lifecycle — build, serialize, deploy",
|
|
218
|
-
triggers: [
|
|
219
|
-
{ type: "file-pattern", value: "**/*.compose.ts" },
|
|
220
|
-
{ type: "file-pattern", value: "**/docker-compose.ts" },
|
|
221
|
-
{ type: "context", value: "docker compose" },
|
|
222
|
-
{ type: "context", value: "docker service" },
|
|
223
|
-
{ type: "context", value: "dockerfile" },
|
|
224
|
-
{ type: "context", value: "container" },
|
|
225
|
-
],
|
|
226
|
-
parameters: [],
|
|
227
|
-
examples: [
|
|
228
|
-
{
|
|
229
|
-
title: "Basic service with database",
|
|
230
|
-
description: "Create a web service and PostgreSQL database",
|
|
231
|
-
input: "Create a Node.js API with a PostgreSQL database",
|
|
232
|
-
output: `new Service({ image: "myapi:1.0", depends_on: ["db"] })`,
|
|
233
|
-
},
|
|
234
|
-
],
|
|
235
|
-
},
|
|
236
|
-
{
|
|
237
|
-
file: "chant-docker-patterns.md",
|
|
238
|
-
name: "chant-docker-patterns",
|
|
239
|
-
description: "Docker Compose patterns — databases, caches, networks, multi-stage builds",
|
|
240
|
-
triggers: [
|
|
241
|
-
{ type: "context", value: "docker compose" },
|
|
242
|
-
{ type: "context", value: "multi-stage" },
|
|
243
|
-
{ type: "context", value: "dockerfile pattern" },
|
|
244
|
-
{ type: "context", value: "docker network" },
|
|
245
|
-
{ type: "context", value: "docker volume" },
|
|
246
|
-
],
|
|
247
|
-
parameters: [],
|
|
248
|
-
examples: [
|
|
249
|
-
{
|
|
250
|
-
title: "Multi-stage Dockerfile",
|
|
251
|
-
input: "Create a multi-stage Dockerfile for Node.js",
|
|
252
|
-
output: `new Dockerfile({ stages: [{ from: "node:20-alpine", as: "build", ... }] })`,
|
|
253
|
-
},
|
|
254
|
-
],
|
|
255
|
-
},
|
|
256
|
-
]),
|
|
257
|
-
|
|
258
|
-
// Live export (#4388): a compose project's services, read from the Engine API.
|
|
259
|
-
async exportResources(options) {
|
|
260
|
-
const { exportResources } = await import("./export-resources");
|
|
261
|
-
return exportResources(options);
|
|
262
|
-
},
|
|
263
|
-
|
|
264
|
-
async listArtifacts(options) {
|
|
265
|
-
const { listArtifacts } = await import("./list-artifacts");
|
|
266
|
-
return listArtifacts(options);
|
|
267
|
-
},
|
|
268
|
-
};
|