@contractkit/prettier-plugin 0.8.1 → 0.9.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.
Files changed (40) hide show
  1. package/.turbo/turbo-build$colon$ci.log +19 -35
  2. package/.turbo/turbo-test$colon$ci.log +26 -105
  3. package/CHANGELOG.md +32 -0
  4. package/README.md +58 -0
  5. package/coverage/clover.xml +159 -155
  6. package/coverage/coverage-final.json +5 -5
  7. package/coverage/indent.ts.html +1 -1
  8. package/coverage/index.html +27 -27
  9. package/coverage/print-ck.ts.html +111 -57
  10. package/coverage/print-contract.ts.html +1 -1
  11. package/coverage/print-operation.ts.html +58 -37
  12. package/coverage/print-type.ts.html +1 -1
  13. package/dist/index.js +13 -4
  14. package/dist/index.js.map +1 -1
  15. package/dist/print-ck.d.ts +8 -0
  16. package/dist/print-ck.d.ts.map +1 -1
  17. package/dist/print-operation.d.ts.map +1 -1
  18. package/package.json +2 -2
  19. package/src/print-ck.ts +22 -4
  20. package/src/print-operation.ts +7 -0
  21. package/tests/print-ck.test.ts +109 -0
  22. package/.turbo/turbo-build.log +0 -15
  23. package/.turbo/turbo-format.log +0 -29
  24. package/.turbo/turbo-test.log +0 -14
  25. package/dist/__tests__/print-ck.test.d.ts +0 -2
  26. package/dist/__tests__/print-ck.test.d.ts.map +0 -1
  27. package/dist/__tests__/print-op.test.d.ts +0 -2
  28. package/dist/__tests__/print-op.test.d.ts.map +0 -1
  29. package/dist/__tests__/print-op.test.js +0 -359
  30. package/dist/__tests__/print-op.test.js.map +0 -1
  31. package/dist/print-dto.d.ts +0 -3
  32. package/dist/print-dto.d.ts.map +0 -1
  33. package/dist/print-dto.js +0 -100
  34. package/dist/print-dto.js.map +0 -1
  35. package/dist/print-op.d.ts +0 -24
  36. package/dist/print-op.d.ts.map +0 -1
  37. package/dist/print-op.js +0 -224
  38. package/dist/print-op.js.map +0 -1
  39. package/dist/print-type.js +0 -110
  40. package/dist/print-type.js.map +0 -1
@@ -1,35 +1,19 @@
1
-
2
- 
3
- > @contractkit/prettier-plugin@0.8.0 build:ci /Users/robert/projects/contractkit/apps/prettier-plugin
4
- > eslint --max-warnings=0 && pnpm run build
5
-
6
- =============
7
-
8
-
9
- WARNING: You are currently running a version of TypeScript which is not officially supported by @typescript-eslint/typescript-estree.
10
-
11
-
12
- * @typescript-eslint/typescript-estree version: 8.57.2
13
- * Supported TypeScript versions: >=4.8.4 <6.0.0
14
- * Your TypeScript version: 6.0.2
15
-
16
-
17
- Please only submit bug reports when using the officially supported version.
18
-
19
-
20
- =============
21
-
22
- > @contractkit/prettier-plugin@0.8.0 build /Users/robert/projects/contractkit/apps/prettier-plugin
23
- > tsup src/index.ts --format esm --sourcemap --dts && tsc --emitDeclarationOnly --declaration
24
-
25
- CLI Building entry: src/index.ts
26
- CLI Using tsconfig: tsconfig.json
27
- CLI tsup v8.5.1
28
- CLI Target: esnext
29
- ESM Build start
30
- ESM dist/index.js 17.83 KB
31
- ESM dist/index.js.map 42.37 KB
32
- ESM ⚡️ Build success in 43ms
33
- DTS Build start
34
- DTS ⚡️ Build success in 612ms
35
- DTS dist/index.d.ts 157.00 B
1
+
2
+ > @contractkit/prettier-plugin@0.9.1 build:ci /home/runner/work/ContractKit/ContractKit/apps/prettier-plugin
3
+ > eslint --max-warnings=0 && pnpm run build
4
+
5
+
6
+ > @contractkit/prettier-plugin@0.9.1 build /home/runner/work/ContractKit/ContractKit/apps/prettier-plugin
7
+ > tsup src/index.ts --format esm --sourcemap --dts && tsc --emitDeclarationOnly --declaration
8
+
9
+ CLI Building entry: src/index.ts
10
+ CLI Using tsconfig: tsconfig.json
11
+ CLI tsup v8.5.1
12
+ CLI Target: esnext
13
+ ESM Build start
14
+ ESM dist/index.js 18.13 KB
15
+ ESM dist/index.js.map 43.70 KB
16
+ ESM ⚡️ Build success in 123ms
17
+ DTS Build start
18
+ DTS ⚡️ Build success in 3581ms
19
+ DTS dist/index.d.ts 157.00 B
@@ -1,105 +1,26 @@
1
-
2
- 
3
- > @contractkit/prettier-plugin@0.8.0 test:ci /Users/robert/projects/contractkit/apps/prettier-plugin
4
- > vitest run --coverage
5
-
6
- [?25l
7
-  RUN  v4.1.5 /Users/robert/projects/contractkit/apps/prettier-plugin
8
- Coverage enabled with v8
9
-
10
- [?2026h
11
-  tests/print-ck.test.ts [queued]
12
-
13
-  Test Files 0 passed (1)
14
-  Tests 0 passed (0)
15
-  Start at 08:51:09
16
-  Duration 304ms
17
- [?2026l[?2026h
18
-  tests/print-ck.test.ts [queued]
19
-
20
-  Test Files 0 passed (1)
21
-  Tests 0 passed (0)
22
-  Start at 08:51:09
23
-  Duration 916ms
24
- [?2026l[?2026h
25
-  ❯ tests/print-ck.test.ts 1/45
26
-
27
-  Test Files 0 passed (1)
28
-  Tests 1 passed (45)
29
-  Start at 08:51:09
30
-  Duration 1.12s
31
- [?2026l ✓ tests/print-ck.test.ts (45 tests) 99ms
32
- ✓ printCk — route modifiers (5)
33
- ✓ prints route with no modifiers 12ms
34
- ✓ prints route with internal modifier 0ms
35
- ✓ prints route with deprecated modifier 0ms
36
- ✓ treats empty modifiers array same as no modifier 0ms
37
- ✓ preserves description alongside modifier 0ms
38
- ✓ printCk — operation modifiers (6)
39
- ✓ prints operation with no modifiers 0ms
40
- ✓ prints operation with internal modifier 0ms
41
- ✓ prints operation with deprecated modifier 0ms
42
- ✓ treats empty operation modifiers array as no modifiers 0ms
43
- ✓ prints multiple operations with mixed modifiers 0ms
44
- ✓ preserves description alongside modifier on operation 0ms
45
- ✓ printCk — route and operation modifiers combined (2)
46
- ✓ prints both route and operation modifiers independently 0ms
47
- ✓ modifier placement: operation(modifier) before path, verb(modifier) before colon 0ms
48
- ✓ printCk — security (8)
49
- ✓ prints operation-level security: none 0ms
50
- ✓ prints security block with roles only 0ms
51
- ✓ prints security block with multiple roles space-separated 0ms
52
- ✓ prints operation-level signature as its own keyword 0ms
53
- ✓ prints unquoted identifier signature without quotes 0ms
54
- ✓ prints route-level security with shallower indentation 0ms
55
- ✓ prints route-level security: none 0ms
56
- ✓ emits no security line when security is undefined 0ms
57
- ✓ printCk — query and headers descriptions (2)
58
- ✓ emits inline comment on query params that have descriptions 0ms
59
- ✓ emits inline comment on headers params that have descriptions 0ms
60
- ✓ printCk — query and headers optional, nullable, default (7)
61
- ✓ emits ? for optional query params 0ms
62
- ✓ emits | null for nullable query params 0ms
63
- ✓ emits = value for numeric defaults 0ms
64
- ✓ emits = value for boolean defaults 0ms
65
- ✓ emits = "value" for string defaults that need quoting 0ms
66
- ✓ combines optional, default, and description on the same param 0ms
67
- ✓ applies the same rules to headers params 0ms
68
- ✓ printCk — request blocks (3)
69
- ✓ prints a single content-type request 0ms
70
- ✓ round-trips vendor JSON mime types like application/vnd.api+json 0ms
71
- ✓ prints multiple content-types preserving source order 0ms
72
- ✓ printCk — response headers (2)
73
- ✓ prints response headers alongside body 0ms
74
- ✓ prints response headers without a body 0ms
75
- ✓ printCk — options-level header globals (round-trip) (4)
76
- ✓ round-trips options.request.headers 40ms
77
- ✓ round-trips options.response.headers 23ms
78
- ✓ round-trips operation-level headers: none 9ms
79
- ✓ round-trips per-status headers: none 1ms
80
- ✓ printCk — multi-base inheritance and override (round-trip) (3)
81
- ✓ round-trips multi-base inheritance 1ms
82
- ✓ round-trips override modifier on a field 1ms
83
- ✓ emits canonical modifier order: override → deprecated → readonly 0ms
84
- ✓ printCk — typed path params (round-trip) (3)
85
- ✓ round-trips path params with constraint arguments 4ms
86
- ✓ round-trips path params with enum types 1ms
87
- ✓ round-trips path params with regex constraints and a comment 1ms
88
-
89
-  Test Files  1 passed (1)
90
-  Tests  45 passed (45)
91
-  Start at  08:51:09
92
-  Duration  1.20s (transform 258ms, setup 0ms, import 648ms, tests 99ms, environment 0ms)
93
-
94
-  % Coverage report from v8
95
- --------------------|---------|----------|---------|---------|-----------------------------------------------------------
96
- File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
97
- --------------------|---------|----------|---------|---------|-----------------------------------------------------------
98
- All files  |  61.01 |  53.55 |  68 |  67.95 |  
99
-  indent.ts  |  100 |  100 |  100 |  100 |  
100
-  print-ck.ts  |  67.14 |  64.19 |  100 |  78.84 | 23-28,32-37,49 
101
-  print-contract.ts  |  41.93 |  28.57 |  50 |  42.85 | 10,37-68 
102
-  print-operation.ts |  69.64 |  63.19 |  90 |  79.69 | 27-38,47-48,85,102,168,185,193-204,236 
103
-  print-type.ts  |  45.23 |  42.55 |  40 |  47.14 | 12-13,22-30,34-40,44-66,88-93,101-102,108-109,132,135-138
104
- --------------------|---------|----------|---------|---------|-----------------------------------------------------------
105
- [?25h
1
+
2
+ > @contractkit/prettier-plugin@0.9.1 test:ci /home/runner/work/ContractKit/ContractKit/apps/prettier-plugin
3
+ > vitest run --coverage
4
+
5
+
6
+  RUN  v4.1.5 /home/runner/work/ContractKit/ContractKit/apps/prettier-plugin
7
+ Coverage enabled with v8
8
+
9
+ ✓ tests/print-ck.test.ts (55 tests) 215ms
10
+
11
+  Test Files  1 passed (1)
12
+  Tests  55 passed (55)
13
+  Start at  18:49:08
14
+  Duration  5.56s (transform 1.50s, setup 0ms, import 4.05s, tests 215ms, environment 0ms)
15
+
16
+  % Coverage report from v8
17
+ -------------------|---------|----------|---------|---------|-------------------
18
+ File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
19
+ -------------------|---------|----------|---------|---------|-------------------
20
+ All files | 66.02 | 56.81 | 69.23 | 71.87 |
21
+ indent.ts | 100 | 100 | 100 | 100 |
22
+ print-ck.ts | 89.85 | 80 | 100 | 98.03 | 59
23
+ print-contract.ts | 41.93 | 28.57 | 50 | 42.85 | 10,37-68
24
+ ...t-operation.ts | 70.62 | 63.74 | 90 | 80.43 | ...92,200-211,243
25
+ print-type.ts | 45.23 | 42.55 | 40 | 47.14 | ...09,132,135-138
26
+ -------------------|---------|----------|---------|---------|-------------------
package/CHANGELOG.md CHANGED
@@ -1,5 +1,37 @@
1
1
  # @contractkit/prettier-plugin-contractkit
2
2
 
3
+ ## 0.9.1
4
+
5
+ ### Patch Changes
6
+
7
+ - 7555412: Round-trip path-like values in `options.keys` and `options.services` correctly.
8
+
9
+ Values that aren't plain identifiers (paths with slashes, values starting with `.` or `#`, values containing spaces, etc.) are now consistently double-quoted on output. Previously only values starting with `#` or containing spaces were quoted, so a value like `"../../bruno"` lost its quotes on round-trip and re-parsed as a different shape.
10
+
11
+ - Updated dependencies [7555412]
12
+ - @contractkit/core@0.13.0
13
+
14
+ ## 0.9.0
15
+
16
+ ### Minor Changes
17
+
18
+ - 876696f: Add a `plugins` block to operations for attaching external files to individual code-generators.
19
+
20
+ ```
21
+ post: {
22
+ plugins: {
23
+ bruno: "request-token.yml"
24
+ }
25
+ }
26
+ ```
27
+
28
+ Each entry maps a plugin name to a path relative to the contract's `.ck` file. The CLI resolves the path before plugins run and exposes the file content on the AST as `op.pluginFiles[name]`; missing files emit a warning. Plugins keyed by their own `name` can read their entry to override or augment generated output. The raw paths remain on `op.plugins` for round-trip use cases (the prettier plugin and VS Code syntax highlighting consume the raw form).
29
+
30
+ ### Patch Changes
31
+
32
+ - Updated dependencies [876696f]
33
+ - @contractkit/core@0.12.0
34
+
3
35
  ## 0.8.1
4
36
 
5
37
  ### Patch Changes
package/README.md ADDED
@@ -0,0 +1,58 @@
1
+ # @contractkit/prettier-plugin
2
+
3
+ A [Prettier](https://prettier.io) plugin that formats ContractKit `.ck` files. Idempotent: re-formatting an already-formatted file is a no-op.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ pnpm add -D prettier @contractkit/prettier-plugin
9
+ ```
10
+
11
+ ## Configuration
12
+
13
+ Add the plugin to your prettier config:
14
+
15
+ ```json
16
+ {
17
+ "plugins": ["@contractkit/prettier-plugin"]
18
+ }
19
+ ```
20
+
21
+ Prettier registers `.ck` as the `ContractDSL` language and applies the plugin automatically.
22
+
23
+ ## Usage
24
+
25
+ ```bash
26
+ # Format all .ck files in your project
27
+ pnpm prettier --write "**/*.ck"
28
+
29
+ # Or via the editor integration of your choice
30
+ ```
31
+
32
+ Most editors with a Prettier integration (VS Code, JetBrains, Neovim) pick the plugin up from your project's `package.json` automatically.
33
+
34
+ ## What it does
35
+
36
+ The printer round-trips the parser's AST back into canonical `.ck` source:
37
+
38
+ - 4-space indentation (matches Prettier's default `tabWidth`)
39
+ - Canonical modifier order on fields: `override → deprecated → readonly|writeonly`
40
+ - Stable ordering of `options` block items, route bodies, and operation blocks
41
+ - Inline `# comment` placement preserved on field/operation/status lines
42
+ - Multi-base inheritance: `contract C: A & B & { ... }` with the inline block always last
43
+ - Multi-line unions: a leading `|` is preserved on type aliases like `contract X: A | B | C`
44
+ - Discriminated unions render as `discriminated(by=field, A | B | C)`
45
+ - Options-level header globals (`options { request/response: { headers } }`) are emitted in their original un-merged form so the AST round-trips cleanly
46
+
47
+ The plugin honours Prettier's `printWidth` for line-wrapping decisions where applicable, but most CK constructs format to a fixed multi-line shape regardless of width.
48
+
49
+ ## Source layout
50
+
51
+ | Path | Purpose |
52
+ | --- | --- |
53
+ | `src/index.ts` | Prettier plugin entry — parser + printer registration |
54
+ | `src/print-ck.ts` | Top-level dispatcher; renders the `options { ... }` block |
55
+ | `src/print-contract.ts` | Renders `contract` declarations and field blocks |
56
+ | `src/print-operation.ts` | Renders `operation` declarations, params, query, headers, request/response |
57
+ | `src/print-type.ts` | Shared type-expression printer used everywhere a type appears |
58
+ | `src/indent.ts` | Indentation constants and helpers |