@intentius/chant-lexicon-docker 0.32.0 → 0.33.1

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,7 +1,7 @@
1
1
  {
2
2
  "algorithm": "sha256",
3
3
  "artifacts": {
4
- "manifest.json": "308e3bacb2e82cad075a01f9ba73af540569ab9a1f1b722710319c81823e086b",
4
+ "manifest.json": "fcfdf631b9f065cc4d7f5e20090827ec78f3162d40539e6d407f9ec987074cbf",
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": "118299174bb77206216858827cba459dbe5b53f055ab2d30231fb5fa1d9bd57a"
18
+ "composite": "a7bee24e3748edc559d615a1fad753c1bf5f80de3b164719d2e2c26a224bd7f3"
19
19
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "docker",
3
- "version": "0.32.0",
3
+ "version": "0.33.1",
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.32.0",
3
+ "version": "0.33.1",
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.32.0",
70
+ "@intentius/chant": "^0.33.1",
71
71
  "typescript": "^5.9.3"
72
72
  }
73
73
  }
@@ -2,33 +2,39 @@ import { describe, test, expect } from "vitest";
2
2
  import { dockerCompletions } from "./completions";
3
3
  import type { CompletionContext } from "@intentius/chant/lsp/types";
4
4
 
5
+ // The context these tests build must match the real CompletionContext.
6
+ // They previously used an older shape (word / isConstructorContext / prefix /
7
+ // fileContent) the interface no longer has — vitest strips types without
8
+ // checking them, so every assertion passed while exercising no completion
9
+ // path at all.
10
+ function ctx(partial: Partial<CompletionContext>): CompletionContext {
11
+ return {
12
+ uri: "file:///infra.ts",
13
+ content: "",
14
+ position: { line: 0, character: 0 },
15
+ wordAtCursor: "",
16
+ linePrefix: "",
17
+ ...partial,
18
+ };
19
+ }
20
+
5
21
  describe("dockerCompletions", () => {
6
- test("is a function", () => {
7
- expect(typeof dockerCompletions).toBe("function");
22
+ test("suggests resource class names after `new `", () => {
23
+ const items = dockerCompletions(ctx({ linePrefix: "const s = new " }));
24
+
25
+ expect(items.length).toBeGreaterThan(0);
26
+ expect(items.map((i) => i.label)).toContain("Service");
27
+ expect(items.every((i) => i.kind === "resource")).toBe(true);
8
28
  });
9
29
 
10
- test("returns array for non-constructor context", () => {
11
- const ctx: CompletionContext = {
12
- word: "Ser",
13
- isConstructorContext: false,
14
- prefix: "",
15
- fileContent: "",
16
- position: { line: 0, character: 3 },
17
- };
18
- // May return [] if generated index not present, but should not throw
19
- const result = dockerCompletions(ctx);
20
- expect(Array.isArray(result)).toBe(true);
30
+ test("narrows on a typed prefix", () => {
31
+ const items = dockerCompletions(ctx({ linePrefix: "new Serv", wordAtCursor: "Serv" }));
32
+
33
+ expect(items.map((i) => i.label)).toContain("Service");
34
+ expect(items.every((i) => i.label.toLowerCase().startsWith("serv"))).toBe(true);
21
35
  });
22
36
 
23
- test("returns array for constructor context", () => {
24
- const ctx: CompletionContext = {
25
- word: "Service",
26
- isConstructorContext: true,
27
- prefix: "new ",
28
- fileContent: "import { Service } from '@intentius/chant-lexicon-docker';",
29
- position: { line: 0, character: 10 },
30
- };
31
- const result = dockerCompletions(ctx);
32
- expect(Array.isArray(result)).toBe(true);
37
+ test("returns nothing in an unrelated position", () => {
38
+ expect(dockerCompletions(ctx({ linePrefix: "const x = 1" }))).toEqual([]);
33
39
  });
34
40
  });
@@ -2,33 +2,34 @@ import { describe, test, expect } from "vitest";
2
2
  import { dockerHover } from "./hover";
3
3
  import type { HoverContext } from "@intentius/chant/lsp/types";
4
4
 
5
+ // Same correction as completions.test.ts: the old shape (word / fileContent /
6
+ // position) no longer matches HoverContext, and the assertions were written to
7
+ // pass either way ("undefined or an object", "if result !== undefined"), so a
8
+ // hover that returned nothing at all still looked healthy.
9
+ function ctx(word: string): HoverContext {
10
+ return {
11
+ uri: "file:///infra.ts",
12
+ content: "",
13
+ position: { line: 0, character: 0 },
14
+ word,
15
+ lineText: "",
16
+ };
17
+ }
18
+
5
19
  describe("dockerHover", () => {
6
- test("is a function", () => {
7
- expect(typeof dockerHover).toBe("function");
20
+ test("returns undefined for an unknown word", () => {
21
+ expect(dockerHover(ctx("NotADockerThing"))).toBeUndefined();
22
+ expect(dockerHover(ctx(""))).toBeUndefined();
8
23
  });
9
24
 
10
- test("returns undefined for unknown word", () => {
11
- const ctx: HoverContext = {
12
- word: "NotADockerThing",
13
- fileContent: "",
14
- position: { line: 0, character: 0 },
15
- };
16
- // Should not throw; returns undefined if not found
17
- const result = dockerHover(ctx);
18
- expect(result === undefined || typeof result === "object").toBe(true);
25
+ test("describes a known resource with its docker type", () => {
26
+ const info = dockerHover(ctx("Service"));
27
+
28
+ expect(info?.contents).toContain("**Service**");
29
+ expect(info?.contents).toContain("Docker::Compose::Service");
19
30
  });
20
31
 
21
- test("returns HoverInfo with content for known resource", () => {
22
- const ctx: HoverContext = {
23
- word: "Service",
24
- fileContent: "import { Service } from '@intentius/chant-lexicon-docker';",
25
- position: { line: 0, character: 10 },
26
- };
27
- const result = dockerHover(ctx);
28
- // If generated index exists, will return content; otherwise undefined
29
- if (result !== undefined) {
30
- expect(result.contents).toBeTruthy();
31
- expect(typeof result.contents).toBe("string");
32
- }
32
+ test("notes which artifact a resource serializes into", () => {
33
+ expect(dockerHover(ctx("Service"))?.contents).toContain("docker-compose.yml");
33
34
  });
34
35
  });