@shepherdjerred/helm-types 1.7.0 → 2.0.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/CHANGELOG.md +78 -0
- package/LICENSE +674 -0
- package/README.md +82 -63
- package/demos/argo-cd-cli.cast +50 -0
- package/demos/record-cli-demo.sh +132 -0
- package/dist/chart-fetcher.d.ts +14 -0
- package/dist/chart-fetcher.d.ts.map +1 -0
- package/dist/chart-fetcher.js +105 -0
- package/dist/chart-fetcher.js.map +1 -0
- package/dist/chart-info-parser.d.ts +6 -0
- package/dist/chart-info-parser.d.ts.map +1 -0
- package/dist/chart-info-parser.js +50 -0
- package/dist/chart-info-parser.js.map +1 -0
- package/dist/cli.d.ts +7 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +140 -22841
- package/dist/cli.js.map +1 -0
- package/dist/comment-parser.d.ts +10 -0
- package/dist/comment-parser.d.ts.map +1 -0
- package/dist/comment-parser.js +150 -0
- package/dist/comment-parser.js.map +1 -0
- package/dist/config.d.ts +24 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +169 -0
- package/dist/config.js.map +1 -0
- package/dist/helm-types.d.ts +16 -0
- package/dist/helm-types.d.ts.map +1 -0
- package/{src/helm-types.ts → dist/helm-types.js} +1 -1
- package/dist/helm-types.js.map +1 -0
- package/dist/index.d.ts +25 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +22 -23
- package/dist/index.js.map +1 -0
- package/dist/interface-generator.d.ts +6 -0
- package/dist/interface-generator.d.ts.map +1 -0
- package/dist/interface-generator.js +181 -0
- package/dist/interface-generator.js.map +1 -0
- package/dist/schemas.d.ts +13 -0
- package/dist/schemas.d.ts.map +1 -0
- package/{src/schemas.ts → dist/schemas.js} +12 -23
- package/dist/schemas.js.map +1 -0
- package/dist/type-converter-helpers.d.ts +20 -0
- package/dist/type-converter-helpers.d.ts.map +1 -0
- package/dist/type-converter-helpers.js +75 -0
- package/dist/type-converter-helpers.js.map +1 -0
- package/dist/type-converter.d.ts +26 -0
- package/dist/type-converter.d.ts.map +1 -0
- package/dist/type-converter.js +378 -0
- package/dist/type-converter.js.map +1 -0
- package/dist/types.d.ts +35 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +3 -0
- package/dist/types.js.map +1 -0
- package/dist/utils.d.ts +17 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/utils.js +69 -0
- package/dist/utils.js.map +1 -0
- package/dist/yaml-comment-filters.d.ts +7 -0
- package/dist/yaml-comment-filters.d.ts.map +1 -0
- package/dist/yaml-comment-filters.js +91 -0
- package/dist/yaml-comment-filters.js.map +1 -0
- package/dist/yaml-comment-regex-parser.d.ts +8 -0
- package/dist/yaml-comment-regex-parser.d.ts.map +1 -0
- package/dist/yaml-comment-regex-parser.js +120 -0
- package/dist/yaml-comment-regex-parser.js.map +1 -0
- package/dist/yaml-comments.d.ts +74 -0
- package/dist/yaml-comments.d.ts.map +1 -0
- package/dist/yaml-comments.js +406 -0
- package/dist/yaml-comments.js.map +1 -0
- package/dist/yaml-preprocess.d.ts +15 -0
- package/dist/yaml-preprocess.d.ts.map +1 -0
- package/dist/yaml-preprocess.js +170 -0
- package/dist/yaml-preprocess.js.map +1 -0
- package/examples/argo-cd/generate.mjs +23 -0
- package/package.json +17 -12
- package/src/__fixtures__/sample-chart/Chart.yaml +0 -6
- package/src/__fixtures__/sample-chart/values.schema.json +0 -32
- package/src/__fixtures__/sample-chart/values.yaml +0 -22
- package/src/chart-fetcher.ts +0 -221
- package/src/chart-info-parser.ts +0 -64
- package/src/cli.ts +0 -217
- package/src/code-generator.ts +0 -226
- package/src/comment-parser.ts +0 -180
- package/src/config.ts +0 -195
- package/src/index.ts +0 -28
- package/src/interface-generator.ts +0 -238
- package/src/reset.d.ts +0 -1
- package/src/type-converter-helpers.ts +0 -108
- package/src/type-converter.ts +0 -520
- package/src/type-inference.ts +0 -548
- package/src/types.ts +0 -41
- package/src/utils.ts +0 -76
- package/src/yaml-comment-filters.ts +0 -103
- package/src/yaml-comment-regex-parser.ts +0 -150
- package/src/yaml-comments.ts +0 -507
- package/src/yaml-preprocess.ts +0 -235
package/README.md
CHANGED
|
@@ -1,66 +1,69 @@
|
|
|
1
1
|
# @shepherdjerred/helm-types
|
|
2
2
|
|
|
3
|
-
Generate TypeScript types from Helm chart values.
|
|
3
|
+
Generate TypeScript types from a Helm chart's `values.yaml` and optional
|
|
4
|
+
`values.schema.json`. The CLI and library preserve YAML comments as JSDoc,
|
|
5
|
+
infer nested types, and emit a flattened type for `helm --set` parameters.
|
|
4
6
|
|
|
5
|
-
|
|
7
|
+
Requires Node.js 24 or newer, or Bun, plus the `helm` CLI on `PATH`.
|
|
6
8
|
|
|
7
|
-
|
|
8
|
-
`values.yaml` and `values.schema.json` files. Use it to get type-safe Helm configurations in your
|
|
9
|
-
TypeScript projects.
|
|
9
|
+
## Why use this?
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
Helm charts expose configuration as YAML, so a typo in an override or a string
|
|
12
|
+
where a chart expects a number can survive review and fail late. `helm-types`
|
|
13
|
+
turns one pinned chart version into TypeScript types, including chart comments
|
|
14
|
+
and flattened `--set` keys, so an editor and CI can check those values first.
|
|
12
15
|
|
|
13
|
-
|
|
14
|
-
- Generate nested interfaces with proper types
|
|
15
|
-
- Parse YAML comments for JSDoc documentation
|
|
16
|
-
- Support for arrays, unions, enums, and optional properties
|
|
17
|
-
- Handle reserved keywords and special characters
|
|
16
|
+
Use it when you are building:
|
|
18
17
|
|
|
19
|
-
|
|
18
|
+
- A TypeScript or cdk8s deployment that configures third-party Helm charts.
|
|
19
|
+
- GitOps configuration that should catch renamed keys and wrong value types
|
|
20
|
+
before a Helm render or cluster apply.
|
|
21
|
+
- A deployment CLI that accepts chart settings and needs a checked list of
|
|
22
|
+
supported dotted `--set` parameters.
|
|
23
|
+
|
|
24
|
+
## Quick start
|
|
20
25
|
|
|
21
26
|
```bash
|
|
22
|
-
|
|
23
|
-
# or
|
|
24
|
-
bun add @shepherdjerred/helm-types
|
|
25
|
-
```
|
|
27
|
+
bun add -d @shepherdjerred/helm-types
|
|
26
28
|
|
|
27
|
-
|
|
29
|
+
npx @shepherdjerred/helm-types \
|
|
30
|
+
--name argo-cd \
|
|
31
|
+
--repo https://argoproj.github.io/argo-helm \
|
|
32
|
+
--version 7.7.16 \
|
|
33
|
+
--output src/generated/argo-cd-values.ts
|
|
34
|
+
```
|
|
28
35
|
|
|
29
|
-
|
|
30
|
-
|
|
36
|
+
The command downloads the exact chart version into a temporary directory,
|
|
37
|
+
generates the file, then removes that directory. It does not add, update, or
|
|
38
|
+
remove Helm repositories in your local Helm configuration.
|
|
31
39
|
|
|
32
|
-
|
|
40
|
+
Use `bunx @shepherdjerred/helm-types` instead of `npx` when Bun is your package
|
|
41
|
+
manager.
|
|
33
42
|
|
|
34
|
-
|
|
43
|
+
## Migrating from 1.x
|
|
35
44
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
--repo https://argoproj.github.io/argo-helm \
|
|
41
|
-
--version 8.3.1 \
|
|
42
|
-
--output argo-cd.types.ts
|
|
45
|
+
The 2.0 release requires Node.js 24 or newer (or Bun) and publishes compiled
|
|
46
|
+
ESM JavaScript with declarations from `dist/`. Consumers that imported the
|
|
47
|
+
workspace source path must switch to the package entry point and rebuild their
|
|
48
|
+
workspace dependency before typechecking.
|
|
43
49
|
|
|
44
|
-
|
|
45
|
-
npx @shepherdjerred/helm-types \
|
|
46
|
-
-n argo-cd \
|
|
47
|
-
-r https://argoproj.github.io/argo-helm \
|
|
48
|
-
-v 8.3.1 \
|
|
49
|
-
-o argo-cd.types.ts
|
|
50
|
+
## CLI usage
|
|
50
51
|
|
|
51
|
-
|
|
52
|
+
```bash
|
|
53
|
+
# Print the generated module to stdout.
|
|
52
54
|
npx @shepherdjerred/helm-types \
|
|
53
55
|
-n argo-cd \
|
|
54
56
|
-r https://argoproj.github.io/argo-helm \
|
|
55
|
-
-v
|
|
57
|
+
-v 7.7.16
|
|
56
58
|
|
|
57
|
-
#
|
|
59
|
+
# The chart name can differ from the generated module name.
|
|
58
60
|
npx @shepherdjerred/helm-types \
|
|
59
|
-
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
61
|
+
--name platform-argo-cd \
|
|
62
|
+
--chart argo-cd \
|
|
63
|
+
--repo https://argoproj.github.io/argo-helm \
|
|
64
|
+
--version 7.7.16 \
|
|
65
|
+
--interface PlatformArgoCdValues \
|
|
66
|
+
--output src/generated/platform-argo-cd.ts
|
|
64
67
|
```
|
|
65
68
|
|
|
66
69
|
**Options:**
|
|
@@ -75,9 +78,13 @@ npx @shepherdjerred/helm-types \
|
|
|
75
78
|
| `--interface, -i` | Interface name (auto-generated if not provided) |
|
|
76
79
|
| `--help, -h` | Show help message |
|
|
77
80
|
|
|
81
|
+
`--version` is the Helm chart version, not the package version. Run
|
|
82
|
+
`helm-types --help` to inspect the installed CLI.
|
|
83
|
+
|
|
78
84
|
## Programmatic API
|
|
79
85
|
|
|
80
|
-
```
|
|
86
|
+
```ts
|
|
87
|
+
import { writeFile } from "node:fs/promises";
|
|
81
88
|
import {
|
|
82
89
|
fetchHelmChart,
|
|
83
90
|
convertToTypeScriptInterface,
|
|
@@ -89,24 +96,39 @@ const chart = {
|
|
|
89
96
|
name: "argo-cd",
|
|
90
97
|
chartName: "argo-cd",
|
|
91
98
|
repoUrl: "https://argoproj.github.io/argo-helm",
|
|
92
|
-
version: "
|
|
99
|
+
version: "7.7.16",
|
|
93
100
|
};
|
|
94
101
|
|
|
95
102
|
// 2. Fetch and generate types
|
|
96
103
|
const { values, schema, yamlComments } = await fetchHelmChart(chart);
|
|
97
|
-
const tsInterface = convertToTypeScriptInterface(
|
|
104
|
+
const tsInterface = convertToTypeScriptInterface({
|
|
98
105
|
values,
|
|
99
|
-
"ArgocdHelmValues",
|
|
106
|
+
interfaceName: "ArgocdHelmValues",
|
|
100
107
|
schema,
|
|
101
108
|
yamlComments,
|
|
102
|
-
|
|
109
|
+
chartName: chart.name,
|
|
110
|
+
});
|
|
103
111
|
const code = generateTypeScriptCode(tsInterface, chart.name);
|
|
104
112
|
|
|
105
113
|
// 3. Write output
|
|
106
|
-
await
|
|
114
|
+
await writeFile("argo-cd.types.ts", code);
|
|
107
115
|
```
|
|
108
116
|
|
|
109
|
-
|
|
117
|
+
The runnable [`examples/argo-cd/generate.mjs`](examples/argo-cd/generate.mjs)
|
|
118
|
+
writes the generated module to standard output so callers choose where it
|
|
119
|
+
belongs.
|
|
120
|
+
|
|
121
|
+
## Demo recording
|
|
122
|
+
|
|
123
|
+
The included replayable asciicast starts with the pinned chart's `server`
|
|
124
|
+
values, shows the generated `replicas?: number` contract, then contrasts an
|
|
125
|
+
unsafe override with the typed alternative:
|
|
126
|
+
|
|
127
|
+
```bash
|
|
128
|
+
asciinema play node_modules/@shepherdjerred/helm-types/demos/argo-cd-cli.cast
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
## Generated output
|
|
110
132
|
|
|
111
133
|
### Values Interface
|
|
112
134
|
|
|
@@ -146,7 +168,7 @@ export type ArgocdHelmParameters = {
|
|
|
146
168
|
};
|
|
147
169
|
```
|
|
148
170
|
|
|
149
|
-
## Type
|
|
171
|
+
## Type inference
|
|
150
172
|
|
|
151
173
|
The library intelligently infers types from values:
|
|
152
174
|
|
|
@@ -163,7 +185,7 @@ The library intelligently infers types from values:
|
|
|
163
185
|
|
|
164
186
|
JSON schema takes precedence when available.
|
|
165
187
|
|
|
166
|
-
## API
|
|
188
|
+
## API reference
|
|
167
189
|
|
|
168
190
|
### `fetchHelmChart(chart: ChartInfo)`
|
|
169
191
|
|
|
@@ -185,25 +207,22 @@ type ChartInfo = {
|
|
|
185
207
|
}
|
|
186
208
|
```
|
|
187
209
|
|
|
188
|
-
### `convertToTypeScriptInterface(
|
|
210
|
+
### `convertToTypeScriptInterface(options)`
|
|
189
211
|
|
|
190
|
-
Converts Helm values to TypeScript interface definition.
|
|
212
|
+
Converts Helm values to a TypeScript interface definition.
|
|
191
213
|
|
|
192
|
-
- `values` - Chart values object
|
|
193
|
-
- `
|
|
194
|
-
- `schema?` - Optional JSON schema for type hints
|
|
195
|
-
- `
|
|
196
|
-
- `
|
|
214
|
+
- `options.values` - Chart values object
|
|
215
|
+
- `options.interfaceName` - Interface name
|
|
216
|
+
- `options.schema?` - Optional JSON schema for type hints
|
|
217
|
+
- `options.yamlComments?` - Optional YAML comments for JSDoc
|
|
218
|
+
- `options.keyPrefix?` - Optional key prefix for nested types
|
|
219
|
+
- `options.chartName?` - Chart name used for chart-specific type rules
|
|
197
220
|
|
|
198
221
|
### `generateTypeScriptCode(interface, chartName)`
|
|
199
222
|
|
|
200
223
|
Generates TypeScript code from interface definition. Returns a string containing the main values
|
|
201
224
|
interface, nested type definitions, and flattened parameters type.
|
|
202
225
|
|
|
203
|
-
### `parseYAMLComments(yamlContent)`
|
|
204
|
-
|
|
205
|
-
Extracts YAML comments and associates them with keys.
|
|
206
|
-
|
|
207
226
|
## License
|
|
208
227
|
|
|
209
|
-
GPL-3.0
|
|
228
|
+
GPL-3.0-only.
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
{"version":3,"term":{"cols":100,"rows":28},"timestamp":1788642506,"idle_time_limit":12.0,"command":"./demos/record-cli-demo.sh","title":"Helm values to TypeScript","env":{"SHELL":"/opt/homebrew/bin/fish"}}
|
|
2
|
+
[0.016, "o", "\u001b[2J\u001b[H\u001b[1;36m━━━ Helm values -> a checked TypeScript contract ━━━\u001b[0m\r\n\r\n"]
|
|
3
|
+
[2.011, "o", "\u001b[2J\u001b[H\u001b[1;36m━━━ 1/4 A chart starts as untyped YAML ━━━\u001b[0m\r\nHelm accepts values, but your editor cannot tell a boolean from a quoted string.\r\n"]
|
|
4
|
+
[6.015, "o", "$ helm show values argo-cd \\\r\n --repo https://argoproj.github.io/argo-helm \\\r\n --version 7.7.16 | bat --language yaml\r\n"]
|
|
5
|
+
[0.790, "o", "\u001b[38;2;30;102;245mserver\u001b[0m\u001b[38;2;23;146;153m:\u001b[0m\r\n\u001b[38;2;76;79;105m \u001b[0m\u001b[38;2;124;127;147m#\u001b[0m\u001b[38;2;124;127;147m -- Argo CD server name\u001b[0m\r\n"]
|
|
6
|
+
[0.000, "o", "\u001b[38;2;76;79;105m \u001b[0m\u001b[38;2;30;102;245mname\u001b[0m\u001b[38;2;23;146;153m:\u001b[0m\u001b[38;2;76;79;105m \u001b[0m\u001b[38;2;64;160;43mserver\u001b[0m\r\n\r\n\u001b[38;2;76;79;105m \u001b[0m\u001b[38;2;124;127;147m#\u001b[0m\u001b[38;2;124;127;147m -- The number of server pods to run\u001b[0m\r\n"]
|
|
7
|
+
[0.000, "o", "\u001b[38;2;76;79;105m \u001b[0m\u001b[38;2;30;102;245mreplicas\u001b[0m\u001b[38;2;23;146;153m:\u001b[0m\u001b[38;2;76;79;105m \u001b[0m\u001b[38;2;254;100;11m1\u001b[0m\r\n\r\n\u001b[38;2;76;79;105m \u001b[0m\u001b[38;2;124;127;147m#\u001b[0m\u001b[38;2;124;127;147m -- Runtime class name for the Argo CD server\u001b[0m\r\n"]
|
|
8
|
+
[0.000, "o", "\u001b[38;2;76;79;105m \u001b[0m\u001b[38;2;124;127;147m#\u001b[0m\u001b[38;2;124;127;147m @default -- `\"\"` (defaults to global.runtimeClassName)\u001b[0m\r\n"]
|
|
9
|
+
[0.000, "o", "\u001b[38;2;76;79;105m \u001b[0m\u001b[38;2;30;102;245mruntimeClassName\u001b[0m\u001b[38;2;23;146;153m:\u001b[0m\u001b[38;2;76;79;105m \u001b[0m\u001b[38;2;64;160;43m\"\u001b[0m\u001b[38;2;64;160;43m\"\u001b[0m\r\n\r\n"]
|
|
10
|
+
[0.000, "o", "\u001b[38;2;76;79;105m \u001b[0m\u001b[38;2;124;127;147m#\u001b[0m\u001b[38;2;124;127;147m# Argo CD server Horizontal Pod Autoscaler\u001b[0m\r\n"]
|
|
11
|
+
[0.000, "o", "\u001b[38;2;76;79;105m \u001b[0m\u001b[38;2;30;102;245mautoscaling\u001b[0m\u001b[38;2;23;146;153m:\u001b[0m\r\n\u001b[38;2;76;79;105m \u001b[0m\u001b[38;2;124;127;147m#\u001b[0m\u001b[38;2;124;127;147m -- Enable Horizontal Pod Autoscaler ([HPA]) for the Argo CD server\u001b[0m\r\n"]
|
|
12
|
+
[0.000, "o", "\u001b[38;2;76;79;105m \u001b[0m\u001b[38;2;30;102;245menabled\u001b[0m\u001b[38;2;23;146;153m:\u001b[0m\u001b[38;2;76;79;105m \u001b[0m\u001b[38;2;254;100;11mfalse\u001b[0m\r\n"]
|
|
13
|
+
[0.000, "o", "\u001b[38;2;76;79;105m \u001b[0m\u001b[38;2;124;127;147m#\u001b[0m\u001b[38;2;124;127;147m -- Minimum number of replicas for the Argo CD server [HPA]\u001b[0m\r\n"]
|
|
14
|
+
[12.010, "o", "\u001b[2J\u001b[H\u001b[1;36m━━━ 2/4 Generate the matching server type ━━━\u001b[0m\r\nhelm-types preserves the chart's structure, comments, and boolean fields.\r\n"]
|
|
15
|
+
[4.012, "o", "$ helm-types --name argo-cd \\\r\n --repo https://argoproj.github.io/argo-helm \\\r\n --version 7.7.16 | sed -n 3456,3474p\r\n"]
|
|
16
|
+
[0.091, "o", "Fetching chart: argo-cd@7.7.16\r\n"]
|
|
17
|
+
[0.000, "o", "Repository: https://argoproj.github.io/argo-helm\r\n"]
|
|
18
|
+
[0.000, "o", "\r\n"]
|
|
19
|
+
[0.730, "o", "\r\n"]
|
|
20
|
+
[0.000, "o", "Converting to TypeScript interface: ArgoCdHelmValues\r\n"]
|
|
21
|
+
[0.071, "o", "\u001b[38;2;136;57;239mexport\u001b[0m\u001b[38;2;223;142;29m \u001b[0m\u001b[38;2;136;57;239mtype\u001b[0m\u001b[38;2;223;142;29m \u001b[0m\u001b[38;2;223;142;29mArgoCdHelmValuesServer\u001b[0m\u001b[38;2;223;142;29m \u001b[0m\u001b[38;2;23;146;153m=\u001b[0m\u001b[38;2;223;142;29m \u001b[0m\u001b[38;2;124;127;147m{\u001b[0m\r\n"]
|
|
22
|
+
[0.000, "o", "\u001b[38;2;223;142;29m \u001b[0m\u001b[38;2;124;127;147m/**\u001b[0m\r\n\u001b[38;2;124;127;147m * Argo CD server name\u001b[0m\r\n\u001b[38;2;124;127;147m *\u001b[0m\r\n"]
|
|
23
|
+
[0.000, "o", "\u001b[38;2;124;127;147m * \u001b[0m\u001b[38;2;124;127;147m@\u001b[0m\u001b[38;2;136;57;239mdefault\u001b[0m\u001b[38;2;124;127;147m \u001b[0m\u001b[38;2;64;160;43m\"\u001b[0m\u001b[38;2;230;69;83mserver\u001b[0m\u001b[38;2;64;160;43m\"\u001b[0m\r\n"]
|
|
24
|
+
[0.000, "o", "\u001b[38;2;124;127;147m \u001b[0m\u001b[38;2;124;127;147m*/\u001b[0m\r\n"]
|
|
25
|
+
[0.001, "o", "\u001b[38;2;223;142;29m \u001b[0m\u001b[38;2;76;79;105mname\u001b[0m\u001b[38;2;23;146;153m?\u001b[0m\u001b[38;2;23;146;153m:\u001b[0m\u001b[38;2;223;142;29m \u001b[0m\u001b[38;2;136;57;239mstring\u001b[0m\u001b[38;2;124;127;147m;\u001b[0m\r\n\u001b[38;2;223;142;29m \u001b[0m\u001b[38;2;124;127;147m/**\u001b[0m\r\n"]
|
|
26
|
+
[0.000, "o", "\u001b[38;2;124;127;147m * The number of server pods to run\u001b[0m\r\n\u001b[38;2;124;127;147m *\u001b[0m\r\n"]
|
|
27
|
+
[0.001, "o", "\u001b[38;2;124;127;147m * \u001b[0m\u001b[38;2;124;127;147m@\u001b[0m\u001b[38;2;136;57;239mdefault\u001b[0m\u001b[38;2;124;127;147m \u001b[0m\u001b[38;2;230;69;83m1\u001b[0m\r\n"]
|
|
28
|
+
[0.000, "o", "\u001b[38;2;124;127;147m \u001b[0m\u001b[38;2;124;127;147m*/\u001b[0m\r\n"]
|
|
29
|
+
[0.000, "o", "\u001b[38;2;223;142;29m \u001b[0m\u001b[38;2;76;79;105mreplicas\u001b[0m\u001b[38;2;23;146;153m?\u001b[0m\u001b[38;2;23;146;153m:\u001b[0m\u001b[38;2;223;142;29m \u001b[0m\u001b[38;2;136;57;239mnumber\u001b[0m\u001b[38;2;124;127;147m;\u001b[0m\r\n"]
|
|
30
|
+
[0.000, "o", "\u001b[38;2;223;142;29m \u001b[0m\u001b[38;2;124;127;147m/**\u001b[0m\r\n\u001b[38;2;124;127;147m * Runtime class name for the Argo CD server\u001b[0m\r\n\u001b[38;2;124;127;147m *\u001b[0m\r\n\u001b[38;2;124;127;147m * \u001b[0m\u001b[38;2;124;127;147m@\u001b[0m\u001b[38;2;136;57;239mdefault\u001b[0m\u001b[38;2;124;127;147m \u001b[0m\u001b[38;2;64;160;43m\"\u001b[0m\u001b[38;2;64;160;43m\"\u001b[0m\r\n\u001b[38;2;124;127;147m \u001b[0m\u001b[38;2;124;127;147m*/\u001b[0m\r\n"]
|
|
31
|
+
[0.000, "o", "\u001b[38;2;223;142;29m \u001b[0m\u001b[38;2;76;79;105mruntimeClassName\u001b[0m\u001b[38;2;23;146;153m?\u001b[0m\u001b[38;2;23;146;153m:\u001b[0m\u001b[38;2;223;142;29m \u001b[0m\u001b[38;2;136;57;239mstring\u001b[0m\u001b[38;2;124;127;147m;\u001b[0m\r\n"]
|
|
32
|
+
[12.008, "o", "\u001b[2J\u001b[H\u001b[1;36m━━━ 3/4 See the compiler reject an invalid override ━━━\u001b[0m\r\nThis temporary file imports the generated type and deliberately passes a string for replicas.\r\n"]
|
|
33
|
+
[6.089, "o", "Fetching chart: argo-cd@7.7.16\r\n"]
|
|
34
|
+
[0.000, "o", "Repository: https://argoproj.github.io/argo-helm\r\n\r\n"]
|
|
35
|
+
[0.622, "o", "\r\n"]
|
|
36
|
+
[0.000, "o", "Converting to TypeScript interface: ArgoCdHelmValues\r\n"]
|
|
37
|
+
[0.045, "o", "\r\n✅ Types written to: /var/folders/5m/s7cknqdn5h74c9k26_013kbm0000gn/T/helm-types-demo.cQpSCBCRW0/argo-cd-values.ts\r\n"]
|
|
38
|
+
[0.008, "o", "\u001b[2m$ bat values.ts\u001b[0m\r\n"]
|
|
39
|
+
[0.016, "o", "\u001b[38;2;136;57;239mimport\u001b[0m\u001b[38;2;76;79;105m \u001b[0m\u001b[38;2;136;57;239mtype\u001b[0m\u001b[38;2;76;79;105m \u001b[0m\u001b[38;2;124;127;147m{\u001b[0m\u001b[38;2;76;79;105m \u001b[0m\u001b[38;2;76;79;105mArgoCdHelmValues\u001b[0m\u001b[38;2;76;79;105m \u001b[0m\u001b[38;2;124;127;147m}\u001b[0m\u001b[38;2;76;79;105m \u001b[0m\u001b[38;2;136;57;239mfrom\u001b[0m\u001b[38;2;76;79;105m \u001b[0m\u001b[38;2;64;160;43m\"\u001b[0m\u001b[38;2;64;160;43m./argo-cd-values.js\u001b[0m\u001b[38;2;64;160;43m\"\u001b[0m\u001b[38;2;124;127;147m;\u001b[0m\r\n\r\n"]
|
|
40
|
+
[0.003, "o", "\u001b[38;2;136;57;239mconst\u001b[0m\u001b[38;2;76;79;105m \u001b[0m\u001b[38;2;76;79;105mvalues\u001b[0m\u001b[38;2;23;146;153m:\u001b[0m\u001b[38;2;223;142;29m \u001b[0m\u001b[38;2;223;142;29mArgoCdHelmValues\u001b[0m\u001b[38;2;223;142;29m \u001b[0m\u001b[38;2;23;146;153m=\u001b[0m\u001b[38;2;76;79;105m \u001b[0m\u001b[38;2;124;127;147m{\u001b[0m\u001b[38;2;76;79;105m \u001b[0m\u001b[38;2;76;79;105mserver\u001b[0m\u001b[38;2;23;146;153m:\u001b[0m\u001b[38;2;76;79;105m \u001b[0m\u001b[38;2;124;127;147m{\u001b[0m\u001b[38;2;76;79;105m \u001b[0m\u001b[38;2;76;79;105mreplicas\u001b[0m\u001b[38;2;23;146;153m:\u001b[0m\u001b[38;2;76;79;105m \u001b[0m\u001b[38;2;64;160;43m\"\u001b[0m\u001b[38;2;64;160;43mtwo\u001b[0m\u001b[38;2;64;160;43m\"\u001b[0m\u001b[38;2;76;79;105m \u001b[0m\u001b[38;2;124;127;147m}\u001b[0m\u001b[38;2;76;79;105m \u001b[0m\u001b[38;2;124;127;147m}\u001b[0m\u001b[38;2;124;127;147m;\u001b[0m\r\n"]
|
|
41
|
+
[5.012, "o", "\u001b[2m$ tsc --noEmit values.ts\u001b[0m\r\n"]
|
|
42
|
+
[0.200, "o", "\u001b[38;2;76;79;105mvalues\u001b[0m\u001b[38;2;23;146;153m.\u001b[0m\u001b[38;2;30;102;245mts\u001b[0m\u001b[38;2;76;79;105m(\u001b[0m\u001b[38;2;254;100;11m3\u001b[0m\u001b[38;2;124;127;147m,\u001b[0m\u001b[38;2;254;100;11m46\u001b[0m\u001b[38;2;76;79;105m)\u001b[0m\u001b[38;2;76;79;105m: \u001b[0m\u001b[38;2;76;79;105merror\u001b[0m\u001b[38;2;76;79;105m \u001b[0m\u001b[38;2;23;146;153mTS2322\u001b[0m\u001b[38;2;124;127;147m:\u001b[0m\u001b[38;2;76;79;105m \u001b[0m\u001b[38;2;76;79;105mType\u001b[0m\u001b[38;2;76;79;105m \u001b[0m\u001b[38;2;64;160;43m'\u001b[0m\u001b[38;2;64;160;43mstring\u001b[0m\u001b[38;2;64;160;43m'\u001b[0m\u001b[38;2;76;79;105m \u001b[0m\u001b[38;2;76;79;105mis\u001b[0m\u001b[38;2;76;79;105m \u001b[0m\u001b[38;2;76;79;105mnot\u001b[0m\u001b[38;2;76;79;105m \u001b[0m\u001b[38;2;76;79;105massignable\u001b[0m\u001b[38;2;76;79;105m \u001b[0m\u001b[38;2;76;79;105mto\u001b[0m\u001b[38;2;76;79;105m \u001b[0m\u001b[38;2;76;79;105mtype\u001b[0m\u001b[38;2;76;79;105m \u001b[0m\u001b[38;2;64;160;43m'\u001b[0m\u001b[38;2;64;160;43mnumber\u001b[0m\u001b[38;2;64;160;43m'\u001b[0m\u001b[38;2;23;146;153m.\u001b[0m\r\n"]
|
|
43
|
+
[3.008, "o", "\u001b[2J\u001b[H\u001b[1;36m━━━ 4/4 Correct the value before Helm runs ━━━\u001b[0m\r\nThe generated contract makes the safe edit explicit in the editor and CI.\r\n"]
|
|
44
|
+
[5.011, "o", "\u001b[2m$ delta --color-only --paging never\u001b[0m\r\n"]
|
|
45
|
+
[0.027, "o", "diff --git a/values.ts b/values.ts\r\n--- a/values.ts\r\n+++ b/values.ts\r\n"]
|
|
46
|
+
[0.001, "o", "@@ -1,3 +1,5 @@\r\n"]
|
|
47
|
+
[0.003, "o", "\u001b[1;31m-const values = { server: { replicas: \"two\" } };\u001b[0m\r\n\u001b[1;32m+const values: ArgoCdHelmValues = {\u001b[0m\r\n\u001b[1;32m+ server: { replicas: 2 },\u001b[0m\r\n\u001b[1;32m+};\u001b[0m\r\n\u001b[2m \u001b[0m\r\n"]
|
|
48
|
+
[0.000, "o", "\u001b[1;31m-// Helm only sees a string at apply time.\u001b[0m\r\n\u001b[1;32m+// TypeScript now rejects the quoted number before deployment.\u001b[0m\r\n"]
|
|
49
|
+
[12.012, "o", "\r\n\u001b[1;32m✓ Same chart values, with feedback where you write them.\u001b[0m\r\n"]
|
|
50
|
+
[0.004, "x", "0"]
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
set -euo pipefail
|
|
3
|
+
|
|
4
|
+
cd "$(dirname "$0")/.."
|
|
5
|
+
package_directory="$(pwd)"
|
|
6
|
+
|
|
7
|
+
pause_for() {
|
|
8
|
+
word_count="$(printf '%s' "$1" | wc -w | tr -d '[:space:]')"
|
|
9
|
+
seconds=$(((word_count + 3) / 4))
|
|
10
|
+
|
|
11
|
+
if ((seconds < 2)); then
|
|
12
|
+
seconds=2
|
|
13
|
+
elif ((seconds > 12)); then
|
|
14
|
+
seconds=12
|
|
15
|
+
fi
|
|
16
|
+
|
|
17
|
+
sleep "$seconds"
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
section() {
|
|
21
|
+
printf '\033[2J\033[H\033[1;36m━━━ %s ━━━\033[0m\n%s\n' "$1" "$2"
|
|
22
|
+
pause_for "$1 $2"
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
section \
|
|
26
|
+
"Helm values -> a checked TypeScript contract" \
|
|
27
|
+
""
|
|
28
|
+
|
|
29
|
+
section \
|
|
30
|
+
"1/4 A chart starts as untyped YAML" \
|
|
31
|
+
"Helm accepts values, but your editor cannot tell a boolean from a quoted string."
|
|
32
|
+
printf '%s\n' \
|
|
33
|
+
'$ helm show values argo-cd \' \
|
|
34
|
+
' --repo https://argoproj.github.io/argo-helm \' \
|
|
35
|
+
' --version 7.7.16 | bat --language yaml'
|
|
36
|
+
values_preview="$(helm show values argo-cd \
|
|
37
|
+
--repo https://argoproj.github.io/argo-helm \
|
|
38
|
+
--version 7.7.16 \
|
|
39
|
+
| sed -n '/^server:/,/^repoServer:/p' \
|
|
40
|
+
| sed -n '1,16p')"
|
|
41
|
+
printf '%s\n' "$values_preview" \
|
|
42
|
+
| bat --color=always --language=yaml --paging=never --plain --style=numbers
|
|
43
|
+
pause_for "$values_preview"
|
|
44
|
+
|
|
45
|
+
section \
|
|
46
|
+
"2/4 Generate the matching server type" \
|
|
47
|
+
"helm-types preserves the chart's structure, comments, and boolean fields."
|
|
48
|
+
printf '%s\n' \
|
|
49
|
+
'$ helm-types --name argo-cd \' \
|
|
50
|
+
' --repo https://argoproj.github.io/argo-helm \' \
|
|
51
|
+
' --version 7.7.16 | sed -n 3456,3474p'
|
|
52
|
+
generated_type_preview="$(node dist/cli.js \
|
|
53
|
+
--name argo-cd \
|
|
54
|
+
--repo https://argoproj.github.io/argo-helm \
|
|
55
|
+
--version 7.7.16 \
|
|
56
|
+
| sed -n '3456,3474p')"
|
|
57
|
+
printf '%s\n' "$generated_type_preview" \
|
|
58
|
+
| bat --color=always --language=typescript --paging=never --plain --style=numbers
|
|
59
|
+
pause_for "$generated_type_preview"
|
|
60
|
+
|
|
61
|
+
section \
|
|
62
|
+
"3/4 See the compiler reject an invalid override" \
|
|
63
|
+
"This temporary file imports the generated type and deliberately passes a string for replicas."
|
|
64
|
+
demo_directory="$(mktemp -d -t helm-types-demo)"
|
|
65
|
+
trap 'rm -r -- "$demo_directory"' EXIT
|
|
66
|
+
generated_types="$demo_directory/argo-cd-values.ts"
|
|
67
|
+
invalid_values="$demo_directory/values.ts"
|
|
68
|
+
diagnostics="$demo_directory/diagnostics.txt"
|
|
69
|
+
node dist/cli.js \
|
|
70
|
+
--name argo-cd \
|
|
71
|
+
--repo https://argoproj.github.io/argo-helm \
|
|
72
|
+
--version 7.7.16 \
|
|
73
|
+
--output "$generated_types" \
|
|
74
|
+
>/dev/null
|
|
75
|
+
printf '%s\n' \
|
|
76
|
+
'import type { ArgoCdHelmValues } from "./argo-cd-values.js";' \
|
|
77
|
+
'' \
|
|
78
|
+
'const values: ArgoCdHelmValues = { server: { replicas: "two" } };' \
|
|
79
|
+
>"$invalid_values"
|
|
80
|
+
printf '\033[2m$ bat values.ts\033[0m\n'
|
|
81
|
+
invalid_values_preview="$(<"$invalid_values")"
|
|
82
|
+
printf '%s\n' "$invalid_values_preview" \
|
|
83
|
+
| bat --color=always --language=typescript --paging=never --plain --style=numbers
|
|
84
|
+
pause_for "$invalid_values_preview"
|
|
85
|
+
printf '\033[2m$ tsc --noEmit values.ts\033[0m\n'
|
|
86
|
+
if (
|
|
87
|
+
cd "$demo_directory"
|
|
88
|
+
PATH="$package_directory/node_modules/@typescript/native/bin:$PATH" tsc \
|
|
89
|
+
--noEmit \
|
|
90
|
+
--ignoreConfig \
|
|
91
|
+
--strict \
|
|
92
|
+
--module NodeNext \
|
|
93
|
+
--moduleResolution NodeNext \
|
|
94
|
+
--target ES2024 \
|
|
95
|
+
values.ts
|
|
96
|
+
) >"$diagnostics" 2>&1; then
|
|
97
|
+
printf '\033[1;31mExpected the invalid override to fail type checking.\033[0m\n' >&2
|
|
98
|
+
exit 1
|
|
99
|
+
fi
|
|
100
|
+
diagnostic_preview="$(<"$diagnostics")"
|
|
101
|
+
printf '%s\n' "$diagnostic_preview" \
|
|
102
|
+
| bat --color=always --language=typescript --paging=never --plain --style=numbers
|
|
103
|
+
pause_for "$diagnostic_preview"
|
|
104
|
+
|
|
105
|
+
section \
|
|
106
|
+
"4/4 Correct the value before Helm runs" \
|
|
107
|
+
"The generated contract makes the safe edit explicit in the editor and CI."
|
|
108
|
+
printf '\033[2m$ delta --color-only --paging never\033[0m\n'
|
|
109
|
+
diff_preview="$(printf '%s\n' \
|
|
110
|
+
'diff --git a/values.ts b/values.ts' \
|
|
111
|
+
'--- a/values.ts' \
|
|
112
|
+
'+++ b/values.ts' \
|
|
113
|
+
'@@ -1,3 +1,5 @@' \
|
|
114
|
+
'-const values = { server: { replicas: "two" } };' \
|
|
115
|
+
'+const values: ArgoCdHelmValues = {' \
|
|
116
|
+
'+ server: { replicas: 2 },' \
|
|
117
|
+
'+};' \
|
|
118
|
+
' ' \
|
|
119
|
+
'-// Helm only sees a string at apply time.' \
|
|
120
|
+
'+// TypeScript now rejects the quoted number before deployment.')"
|
|
121
|
+
printf '%s\n' "$diff_preview" \
|
|
122
|
+
| delta \
|
|
123
|
+
--color-only \
|
|
124
|
+
--paging=never \
|
|
125
|
+
--syntax-theme Dracula \
|
|
126
|
+
--minus-style 'red bold' \
|
|
127
|
+
--minus-emph-style 'red bold' \
|
|
128
|
+
--plus-style 'green bold' \
|
|
129
|
+
--plus-emph-style 'green bold' \
|
|
130
|
+
--zero-style dim
|
|
131
|
+
pause_for "$diff_preview"
|
|
132
|
+
printf '\n\033[1;32m✓ Same chart values, with feedback where you write them.\033[0m\n'
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { HelmValue } from "./schemas.js";
|
|
2
|
+
import type { ChartInfo, JSONSchemaProperty } from "./types.js";
|
|
3
|
+
export type FetchedHelmChart = {
|
|
4
|
+
values: HelmValue;
|
|
5
|
+
schema: JSONSchemaProperty | null;
|
|
6
|
+
yamlComments: Map<string, string>;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Download a chart into an isolated temporary directory and read its values,
|
|
10
|
+
* optional JSON schema, and YAML documentation comments. The caller's Helm
|
|
11
|
+
* repository configuration is never modified.
|
|
12
|
+
*/
|
|
13
|
+
export declare function fetchHelmChart(chart: ChartInfo): Promise<FetchedHelmChart>;
|
|
14
|
+
//# sourceMappingURL=chart-fetcher.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chart-fetcher.d.ts","sourceRoot":"","sources":["../src/chart-fetcher.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,KAAK,EAAE,SAAS,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAGhE,MAAM,MAAM,gBAAgB,GAAG;IAC7B,MAAM,EAAE,SAAS,CAAC;IAClB,MAAM,EAAE,kBAAkB,GAAG,IAAI,CAAC;IAClC,YAAY,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACnC,CAAC;AAgFF;;;;GAIG;AACH,wBAAsB,cAAc,CAClC,KAAK,EAAE,SAAS,GACf,OAAO,CAAC,gBAAgB,CAAC,CAiC3B"}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { spawn } from "node:child_process";
|
|
2
|
+
import { mkdtemp, readFile, readdir, rm } from "node:fs/promises";
|
|
3
|
+
import { tmpdir } from "node:os";
|
|
4
|
+
import path from "node:path";
|
|
5
|
+
import { z } from "zod";
|
|
6
|
+
import { parse as yamlParse } from "yaml";
|
|
7
|
+
import { HelmValueSchema, RecordSchema } from "./schemas.js";
|
|
8
|
+
import { parseYAMLComments } from "./yaml-comments.js";
|
|
9
|
+
const MissingFileError = z.object({ code: z.literal("ENOENT") });
|
|
10
|
+
async function loadJsonSchema(chartPath) {
|
|
11
|
+
const schemaPath = path.join(chartPath, "values.schema.json");
|
|
12
|
+
let schemaContent;
|
|
13
|
+
try {
|
|
14
|
+
schemaContent = await readFile(schemaPath, "utf8");
|
|
15
|
+
}
|
|
16
|
+
catch (error) {
|
|
17
|
+
if (MissingFileError.safeParse(error).success) {
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
20
|
+
throw new Error(`Failed to read ${schemaPath}`, { cause: error });
|
|
21
|
+
}
|
|
22
|
+
const parsed = JSON.parse(schemaContent);
|
|
23
|
+
return RecordSchema.parse(parsed);
|
|
24
|
+
}
|
|
25
|
+
async function runCommand(command, args) {
|
|
26
|
+
return new Promise((resolve, reject) => {
|
|
27
|
+
const child = spawn(command, args, { stdio: ["ignore", "pipe", "pipe"] });
|
|
28
|
+
let stdout = "";
|
|
29
|
+
let stderr = "";
|
|
30
|
+
child.stdout.setEncoding("utf8");
|
|
31
|
+
child.stdout.on("data", (chunk) => {
|
|
32
|
+
stdout += chunk;
|
|
33
|
+
});
|
|
34
|
+
child.stderr.setEncoding("utf8");
|
|
35
|
+
child.stderr.on("data", (chunk) => {
|
|
36
|
+
stderr += chunk;
|
|
37
|
+
});
|
|
38
|
+
child.once("error", (error) => {
|
|
39
|
+
reject(new Error(`Failed to start ${command}: ${error.message}`, {
|
|
40
|
+
cause: error,
|
|
41
|
+
}));
|
|
42
|
+
});
|
|
43
|
+
child.once("close", (code, signal) => {
|
|
44
|
+
if (code === 0) {
|
|
45
|
+
resolve(stdout);
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
const status = signal === null ? String(code) : `signal ${signal}`;
|
|
49
|
+
reject(new Error(`${command} ${args.join(" ")} failed with ${status}: ${stderr.trim()}`));
|
|
50
|
+
});
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
async function resolveUntarredChartDir(tempDir, fallbackName) {
|
|
54
|
+
const fallback = path.join(tempDir, fallbackName);
|
|
55
|
+
const entries = await readdir(tempDir, { withFileTypes: true });
|
|
56
|
+
for (const entry of entries) {
|
|
57
|
+
if (entry.isDirectory() && entry.name === fallbackName) {
|
|
58
|
+
return fallback;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
for (const entry of entries) {
|
|
62
|
+
if (entry.isDirectory()) {
|
|
63
|
+
return path.join(tempDir, entry.name);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
throw new Error(`Helm did not extract a chart directory in ${tempDir}`);
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Download a chart into an isolated temporary directory and read its values,
|
|
70
|
+
* optional JSON schema, and YAML documentation comments. The caller's Helm
|
|
71
|
+
* repository configuration is never modified.
|
|
72
|
+
*/
|
|
73
|
+
export async function fetchHelmChart(chart) {
|
|
74
|
+
const tempDir = await mkdtemp(path.join(tmpdir(), "helm-types-"));
|
|
75
|
+
try {
|
|
76
|
+
const chartReference = chart.oci === true
|
|
77
|
+
? `oci://${chart.repoUrl}/${chart.chartName}`
|
|
78
|
+
: chart.chartName;
|
|
79
|
+
const pullArgs = [
|
|
80
|
+
"pull",
|
|
81
|
+
chartReference,
|
|
82
|
+
"--version",
|
|
83
|
+
chart.version,
|
|
84
|
+
"--destination",
|
|
85
|
+
tempDir,
|
|
86
|
+
"--untar",
|
|
87
|
+
];
|
|
88
|
+
if (chart.oci !== true) {
|
|
89
|
+
pullArgs.push("--repo", chart.repoUrl);
|
|
90
|
+
}
|
|
91
|
+
await runCommand("helm", pullArgs);
|
|
92
|
+
const chartDir = await resolveUntarredChartDir(tempDir, chart.chartName);
|
|
93
|
+
const valuesPath = path.join(chartDir, "values.yaml");
|
|
94
|
+
const valuesContent = await readFile(valuesPath, "utf8");
|
|
95
|
+
const yamlComments = parseYAMLComments(valuesContent);
|
|
96
|
+
const parsedValues = yamlParse(valuesContent);
|
|
97
|
+
const values = HelmValueSchema.parse(RecordSchema.parse(parsedValues));
|
|
98
|
+
const schema = await loadJsonSchema(chartDir);
|
|
99
|
+
return { values, schema, yamlComments };
|
|
100
|
+
}
|
|
101
|
+
finally {
|
|
102
|
+
await rm(tempDir, { recursive: true, force: true });
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
//# sour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sourceRoot":"","sources":["../src/chart-info-parser.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAE5C;;GAEG;AACH,wBAAsB,0BAA0B,CAC9C,YAAY,SAAoB,GAC/B,OAAO,CAAC,SAAS,EAAE,CAAC,CAwDtB"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { readFile } from "node:fs/promises";
|
|
2
|
+
/**
|
|
3
|
+
* Parse chart information from versions.ts comments and values
|
|
4
|
+
*/
|
|
5
|
+
export async function parseChartInfoFromVersions(versionsPath = "src/versions.ts") {
|
|
6
|
+
const content = await readFile(versionsPath, "utf8");
|
|
7
|
+
const lines = content.split("\n");
|
|
8
|
+
const charts = [];
|
|
9
|
+
for (let i = 0; i < lines.length; i++) {
|
|
10
|
+
const line = lines[i];
|
|
11
|
+
const nextLine = lines[i + 1];
|
|
12
|
+
// Look for renovate comments that indicate Helm charts
|
|
13
|
+
if (line == null ||
|
|
14
|
+
nextLine == null ||
|
|
15
|
+
nextLine === "" ||
|
|
16
|
+
!line.includes("renovate: datasource=helm")) {
|
|
17
|
+
continue;
|
|
18
|
+
}
|
|
19
|
+
const repoUrlMatch = /registryUrl=(\S+)/.exec(line);
|
|
20
|
+
const versionKeyMatch = /^\s*"?([^":\s]+)"?:/.exec(nextLine);
|
|
21
|
+
if (!repoUrlMatch || !versionKeyMatch) {
|
|
22
|
+
continue;
|
|
23
|
+
}
|
|
24
|
+
const repoUrl = repoUrlMatch[1];
|
|
25
|
+
const versionKey = versionKeyMatch[1];
|
|
26
|
+
if (repoUrl === "" ||
|
|
27
|
+
versionKey === "" ||
|
|
28
|
+
repoUrl == null ||
|
|
29
|
+
versionKey == null) {
|
|
30
|
+
continue;
|
|
31
|
+
}
|
|
32
|
+
// Extract version value
|
|
33
|
+
const versionMatch = /:\s*"([^"]+)"/.exec(nextLine);
|
|
34
|
+
if (!versionMatch) {
|
|
35
|
+
continue;
|
|
36
|
+
}
|
|
37
|
+
const version = versionMatch[1];
|
|
38
|
+
if (version === "" || version == null) {
|
|
39
|
+
continue;
|
|
40
|
+
}
|
|
41
|
+
charts.push({
|
|
42
|
+
name: versionKey,
|
|
43
|
+
repoUrl: repoUrl.replace(/\/$/, ""), // Remove trailing slash
|
|
44
|
+
version,
|
|
45
|
+
chartName: versionKey,
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
return charts;
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=chart-info-parser.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chart-info-parser.js","sourceRoot":"","sources":["../src/chart-info-parser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAG5C;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,0BAA0B,CAC9C,YAAY,GAAG,iBAAiB;IAEhC,MAAM,OAAO,GAAG,MAAM,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC,CAAC;IACrD,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAClC,MAAM,MAAM,GAAgB,EAAE,CAAC;IAE/B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACtC,MAAM,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;QACtB,MAAM,QAAQ,GAAG,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;QAE9B,uDAAuD;QACvD,IACE,IAAI,IAAI,IAAI;YACZ,QAAQ,IAAI,IAAI;YAChB,QAAQ,KAAK,EAAE;YACf,CAAC,IAAI,CAAC,QAAQ,CAAC,2BAA2B,CAAC,EAC3C,CAAC;YACD,SAAS;QACX,CAAC;QAED,MAAM,YAAY,GAAG,mBAAmB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACpD,MAAM,eAAe,GAAG,qBA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