timonel 0.1.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/LICENSE +22 -0
- package/README.md +256 -0
- package/SECURITY.md +44 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +407 -0
- package/dist/cli.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +20 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/ChartFactory.d.ts +389 -0
- package/dist/lib/ChartFactory.d.ts.map +1 -0
- package/dist/lib/ChartFactory.js +583 -0
- package/dist/lib/ChartFactory.js.map +1 -0
- package/dist/lib/HelmChartWriter.d.ts +67 -0
- package/dist/lib/HelmChartWriter.d.ts.map +1 -0
- package/dist/lib/HelmChartWriter.js +154 -0
- package/dist/lib/HelmChartWriter.js.map +1 -0
- package/dist/lib/helm.d.ts +32 -0
- package/dist/lib/helm.d.ts.map +1 -0
- package/dist/lib/helm.js +74 -0
- package/dist/lib/helm.js.map +1 -0
- package/package.json +101 -0
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
export interface HelmChartMeta {
|
|
2
|
+
name: string;
|
|
3
|
+
version: string;
|
|
4
|
+
description?: string;
|
|
5
|
+
appVersion?: string;
|
|
6
|
+
type?: 'application' | 'library';
|
|
7
|
+
kubeVersion?: string;
|
|
8
|
+
keywords?: string[];
|
|
9
|
+
home?: string;
|
|
10
|
+
sources?: string[];
|
|
11
|
+
maintainers?: {
|
|
12
|
+
name: string;
|
|
13
|
+
email?: string;
|
|
14
|
+
url?: string;
|
|
15
|
+
}[];
|
|
16
|
+
icon?: string;
|
|
17
|
+
dependencies?: Array<{
|
|
18
|
+
name: string;
|
|
19
|
+
version: string;
|
|
20
|
+
repository: string;
|
|
21
|
+
alias?: string;
|
|
22
|
+
condition?: string | string[];
|
|
23
|
+
tags?: string[];
|
|
24
|
+
importValues?: unknown;
|
|
25
|
+
}>;
|
|
26
|
+
}
|
|
27
|
+
export interface EnvValuesMap {
|
|
28
|
+
[env: string]: Record<string, unknown>;
|
|
29
|
+
}
|
|
30
|
+
export interface SynthAsset {
|
|
31
|
+
/** filename or logical id */
|
|
32
|
+
id: string;
|
|
33
|
+
/** YAML string, may contain multiple docs separated by --- */
|
|
34
|
+
yaml: string;
|
|
35
|
+
/** target directory inside chart: templates (default) or crds */
|
|
36
|
+
target?: 'templates' | 'crds';
|
|
37
|
+
}
|
|
38
|
+
export interface HelmChartWriteOptions {
|
|
39
|
+
outDir: string;
|
|
40
|
+
meta: HelmChartMeta;
|
|
41
|
+
defaultValues?: Record<string, unknown> | undefined;
|
|
42
|
+
envValues?: EnvValuesMap | undefined;
|
|
43
|
+
/**
|
|
44
|
+
* Kubernetes manifests to place under templates/
|
|
45
|
+
* Accepts one or multiple documents per SynthAsset.
|
|
46
|
+
*/
|
|
47
|
+
assets: SynthAsset[];
|
|
48
|
+
/**
|
|
49
|
+
* Optional Helm helpers content for templates/_helpers.tpl.
|
|
50
|
+
* If a string is provided, it's written verbatim.
|
|
51
|
+
* If an array is provided, each item becomes a named Helm template
|
|
52
|
+
* block as: {{- define "<name>" -}} ... {{- end }}
|
|
53
|
+
*/
|
|
54
|
+
helpersTpl?: string | HelperDefinition[];
|
|
55
|
+
/** Optional NOTES.txt content under templates/ */
|
|
56
|
+
notesTpl?: string;
|
|
57
|
+
/** Optional values.schema.json object */
|
|
58
|
+
valuesSchema?: Record<string, unknown>;
|
|
59
|
+
}
|
|
60
|
+
export interface HelperDefinition {
|
|
61
|
+
name: string;
|
|
62
|
+
body: string;
|
|
63
|
+
}
|
|
64
|
+
export declare class HelmChartWriter {
|
|
65
|
+
static write(opts: HelmChartWriteOptions): void;
|
|
66
|
+
}
|
|
67
|
+
//# sourceMappingURL=HelmChartWriter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"HelmChartWriter.d.ts","sourceRoot":"","sources":["../../src/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AAC;IACf,IAAI,EAAE,aAAa,CAAC;IACpB,aAAa,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,CAAC;IACpD,SAAS,CAAC,EAAE,YAAY,GAAG,SAAS,CAAC;IACrC;;;OAGG;IACH,MAAM,EAAE,UAAU,EAAE,CAAC;IACrB;;;;;OAKG;IACH,UAAU,CAAC,EAAE,MAAM,GAAG,gBAAgB,EAAE,CAAC;IACzC,kDAAkD;IAClD,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,yCAAyC;IACzC,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACxC;AAED,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACd;AAED,qBAAa,eAAe;IAC1B,MAAM,CAAC,KAAK,CAAC,IAAI,EAAE,qBAAqB;CA4GzC"}
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.HelmChartWriter = void 0;
|
|
40
|
+
const fs = __importStar(require("fs"));
|
|
41
|
+
const path = __importStar(require("path"));
|
|
42
|
+
const yaml_1 = __importDefault(require("yaml"));
|
|
43
|
+
class HelmChartWriter {
|
|
44
|
+
static write(opts) {
|
|
45
|
+
const { outDir, meta, defaultValues = {}, envValues = {}, assets, helpersTpl, notesTpl, valuesSchema, } = opts;
|
|
46
|
+
// Prepare structure
|
|
47
|
+
// eslint-disable-next-line security/detect-non-literal-fs-filename -- Chart writer needs dynamic paths
|
|
48
|
+
fs.mkdirSync(path.join(outDir, 'templates'), { recursive: true });
|
|
49
|
+
// Create crds directory only if needed later
|
|
50
|
+
// Chart.yaml
|
|
51
|
+
const chartYaml = yaml_1.default.stringify({
|
|
52
|
+
apiVersion: 'v2',
|
|
53
|
+
name: meta.name,
|
|
54
|
+
version: meta.version,
|
|
55
|
+
description: meta.description,
|
|
56
|
+
type: meta.type ?? 'application',
|
|
57
|
+
appVersion: meta.appVersion,
|
|
58
|
+
kubeVersion: meta.kubeVersion,
|
|
59
|
+
keywords: meta.keywords,
|
|
60
|
+
home: meta.home,
|
|
61
|
+
sources: meta.sources,
|
|
62
|
+
maintainers: meta.maintainers,
|
|
63
|
+
icon: meta.icon,
|
|
64
|
+
dependencies: meta.dependencies,
|
|
65
|
+
});
|
|
66
|
+
// eslint-disable-next-line security/detect-non-literal-fs-filename -- Chart writer needs dynamic paths
|
|
67
|
+
fs.writeFileSync(path.join(outDir, 'Chart.yaml'), chartYaml);
|
|
68
|
+
// values.yaml and env values files
|
|
69
|
+
// eslint-disable-next-line security/detect-non-literal-fs-filename -- Chart writer needs dynamic paths
|
|
70
|
+
fs.writeFileSync(path.join(outDir, 'values.yaml'), yaml_1.default.stringify(defaultValues));
|
|
71
|
+
for (const [env, values] of Object.entries(envValues)) {
|
|
72
|
+
// eslint-disable-next-line security/detect-non-literal-fs-filename -- Chart writer needs dynamic paths
|
|
73
|
+
fs.writeFileSync(path.join(outDir, `values-${env}.yaml`), yaml_1.default.stringify(values));
|
|
74
|
+
}
|
|
75
|
+
// templates/ and crds/
|
|
76
|
+
writeAssets(outDir, assets);
|
|
77
|
+
// Optional helpers
|
|
78
|
+
if (helpersTpl) {
|
|
79
|
+
let content = '';
|
|
80
|
+
if (typeof helpersTpl === 'string') {
|
|
81
|
+
content = helpersTpl.endsWith('\n') ? helpersTpl : helpersTpl + '\n';
|
|
82
|
+
}
|
|
83
|
+
else if (Array.isArray(helpersTpl)) {
|
|
84
|
+
content = helpersTpl
|
|
85
|
+
.map((h) => [`{{- define "${h.name}" -}}`, h.body.trimEnd(), '{{- end }}', ''].join('\n'))
|
|
86
|
+
.join('\n');
|
|
87
|
+
}
|
|
88
|
+
// eslint-disable-next-line security/detect-non-literal-fs-filename -- Chart writer needs dynamic paths
|
|
89
|
+
fs.writeFileSync(path.join(outDir, 'templates', '_helpers.tpl'), content);
|
|
90
|
+
}
|
|
91
|
+
// Optional NOTES.txt
|
|
92
|
+
if (notesTpl) {
|
|
93
|
+
// eslint-disable-next-line security/detect-non-literal-fs-filename -- Chart writer needs dynamic paths
|
|
94
|
+
fs.writeFileSync(path.join(outDir, 'templates', 'NOTES.txt'), notesTpl.endsWith('\n') ? notesTpl : notesTpl + '\n');
|
|
95
|
+
}
|
|
96
|
+
// Optional values.schema.json
|
|
97
|
+
if (valuesSchema) {
|
|
98
|
+
// eslint-disable-next-line security/detect-non-literal-fs-filename -- Chart writer needs dynamic paths
|
|
99
|
+
fs.writeFileSync(path.join(outDir, 'values.schema.json'), JSON.stringify(valuesSchema, null, 2) + '\n');
|
|
100
|
+
}
|
|
101
|
+
// Emit a default .helmignore if missing
|
|
102
|
+
const helmIgnorePath = path.join(outDir, '.helmignore');
|
|
103
|
+
// eslint-disable-next-line security/detect-non-literal-fs-filename -- Chart writer needs dynamic paths
|
|
104
|
+
if (!fs.existsSync(helmIgnorePath)) {
|
|
105
|
+
const helmIgnore = [
|
|
106
|
+
'# VCS',
|
|
107
|
+
'.git/',
|
|
108
|
+
'.hg/',
|
|
109
|
+
'.svn/',
|
|
110
|
+
'',
|
|
111
|
+
'# OS/editor',
|
|
112
|
+
'.DS_Store',
|
|
113
|
+
'.idea/',
|
|
114
|
+
'.vscode/',
|
|
115
|
+
'',
|
|
116
|
+
'# Backups',
|
|
117
|
+
'*.swp',
|
|
118
|
+
'*.bak',
|
|
119
|
+
'*.tmp',
|
|
120
|
+
'*.orig',
|
|
121
|
+
'',
|
|
122
|
+
'# Chart dependencies and packages',
|
|
123
|
+
'charts/',
|
|
124
|
+
'*.tgz',
|
|
125
|
+
'',
|
|
126
|
+
].join('\n');
|
|
127
|
+
// eslint-disable-next-line security/detect-non-literal-fs-filename -- Chart writer needs dynamic paths
|
|
128
|
+
fs.writeFileSync(helmIgnorePath, helmIgnore);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
exports.HelmChartWriter = HelmChartWriter;
|
|
133
|
+
function splitDocs(yamlStr) {
|
|
134
|
+
return yamlStr
|
|
135
|
+
.split(/^---\s*$/m)
|
|
136
|
+
.map((p) => p.trim())
|
|
137
|
+
.filter((p) => p.length);
|
|
138
|
+
}
|
|
139
|
+
function writeAssets(outDir, assets) {
|
|
140
|
+
let counter = 0;
|
|
141
|
+
for (const asset of assets) {
|
|
142
|
+
const parts = splitDocs(asset.yaml);
|
|
143
|
+
for (const doc of parts) {
|
|
144
|
+
const filename = `${String(counter).padStart(4, '0')}-${asset.id}.yaml`;
|
|
145
|
+
const dir = asset.target === 'crds' ? 'crds' : 'templates';
|
|
146
|
+
// eslint-disable-next-line security/detect-non-literal-fs-filename -- Chart writer needs dynamic paths
|
|
147
|
+
fs.mkdirSync(path.join(outDir, dir), { recursive: true });
|
|
148
|
+
// eslint-disable-next-line security/detect-non-literal-fs-filename -- Chart writer needs dynamic paths
|
|
149
|
+
fs.writeFileSync(path.join(outDir, dir, filename), doc + '\n');
|
|
150
|
+
counter++;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
//# sourceMappingURL=HelmChartWriter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"HelmChartWriter.js","sourceRoot":"","sources":["../../src/lib/HelmChartWriter.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uCAAyB;AACzB,2CAA6B;AAE7B,gDAAwB;AAkExB,MAAa,eAAe;IAC1B,MAAM,CAAC,KAAK,CAAC,IAA2B;QACtC,MAAM,EACJ,MAAM,EACN,IAAI,EACJ,aAAa,GAAG,EAAE,EAClB,SAAS,GAAG,EAAE,EACd,MAAM,EACN,UAAU,EACV,QAAQ,EACR,YAAY,GACb,GAAG,IAAI,CAAC;QACT,oBAAoB;QACpB,uGAAuG;QACvG,EAAE,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,WAAW,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC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,CAAC,MAAM,KAAK,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,WAAW,CAAC;YAC3D,uGAAuG;YACvG,EAAE,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;YAC1D,uGAAuG;YACvG,EAAE,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,EAAE,QAAQ,CAAC,EAAE,GAAG,GAAG,IAAI,CAAC,CAAC;YAC/D,OAAO,EAAE,CAAC;QACZ,CAAC;IACH,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Helpers to embed Helm template expressions while staying type-safe in TS.
|
|
3
|
+
* We treat Helm placeholders as opaque strings that will be preserved in YAML.
|
|
4
|
+
*/
|
|
5
|
+
/** Create a .Values reference like {{ .Values.key }} */
|
|
6
|
+
export declare function valuesRef(path: string): string;
|
|
7
|
+
/** Create a required .Values reference with default: {{ required msg .Values.key }} */
|
|
8
|
+
export declare function requiredValuesRef(path: string, message?: string): string;
|
|
9
|
+
/** Built-in Helm references */
|
|
10
|
+
export declare const helm: {
|
|
11
|
+
releaseName: string;
|
|
12
|
+
chartName: string;
|
|
13
|
+
chartVersion: string;
|
|
14
|
+
namespace: string;
|
|
15
|
+
};
|
|
16
|
+
/** Quote a Helm template expression for safe YAML embedding */
|
|
17
|
+
export declare function quote(expr: string): string;
|
|
18
|
+
/** Indent helper matching Helm indent fn: {{- n indent -}} */
|
|
19
|
+
export declare function indent(n: number, expr: string): string;
|
|
20
|
+
/** Insert a call to a named Helm template: {{ template "name" . }} */
|
|
21
|
+
export declare function template(name: string, context?: string): string;
|
|
22
|
+
/** Insert a call to a named Helm template using include: {{ include "name" . }} */
|
|
23
|
+
export declare function include(name: string, context?: string): string;
|
|
24
|
+
/** Numeric value from .Values with int cast: {{ .Values.path | int }} */
|
|
25
|
+
export declare function numberRef(path: string): string;
|
|
26
|
+
/** Boolean value from .Values with toBool cast: {{ .Values.path | toBool }} */
|
|
27
|
+
export declare function boolRef(path: string): string;
|
|
28
|
+
/** String value from .Values with toString cast: {{ .Values.path | toString }} */
|
|
29
|
+
export declare function stringRef(path: string): string;
|
|
30
|
+
/** Float value from .Values with float64 cast: {{ .Values.path | float64 }} */
|
|
31
|
+
export declare function floatRef(path: string): string;
|
|
32
|
+
//# sourceMappingURL=helm.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"helm.d.ts","sourceRoot":"","sources":["../../src/lib/helm.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,wDAAwD;AACxD,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAE9C;AAED,uFAAuF;AACvF,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,CAGxE;AAED,+BAA+B;AAC/B,eAAO,MAAM,IAAI;;;;;CAKhB,CAAC;AAEF,+DAA+D;AAC/D,wBAAgB,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAM1C;AAED,8DAA8D;AAC9D,wBAAgB,MAAM,CAAC,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAMtD;AAED,sEAAsE;AACtE,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,SAAM,GAAG,MAAM,CAE5D;AAED,mFAAmF;AACnF,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,SAAM,GAAG,MAAM,CAE3D;AAED,yEAAyE;AACzE,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAE9C;AAED,+EAA+E;AAC/E,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAE5C;AAED,kFAAkF;AAClF,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAE9C;AAED,+EAA+E;AAC/E,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAE7C"}
|
package/dist/lib/helm.js
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Helpers to embed Helm template expressions while staying type-safe in TS.
|
|
4
|
+
* We treat Helm placeholders as opaque strings that will be preserved in YAML.
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.helm = void 0;
|
|
8
|
+
exports.valuesRef = valuesRef;
|
|
9
|
+
exports.requiredValuesRef = requiredValuesRef;
|
|
10
|
+
exports.quote = quote;
|
|
11
|
+
exports.indent = indent;
|
|
12
|
+
exports.template = template;
|
|
13
|
+
exports.include = include;
|
|
14
|
+
exports.numberRef = numberRef;
|
|
15
|
+
exports.boolRef = boolRef;
|
|
16
|
+
exports.stringRef = stringRef;
|
|
17
|
+
exports.floatRef = floatRef;
|
|
18
|
+
/** Create a .Values reference like {{ .Values.key }} */
|
|
19
|
+
function valuesRef(path) {
|
|
20
|
+
return `{{ .Values.${path} }}`;
|
|
21
|
+
}
|
|
22
|
+
/** Create a required .Values reference with default: {{ required msg .Values.key }} */
|
|
23
|
+
function requiredValuesRef(path, message) {
|
|
24
|
+
const msg = message ?? `${path} is required`;
|
|
25
|
+
return `{{ required "${msg}" .Values.${path} }}`;
|
|
26
|
+
}
|
|
27
|
+
/** Built-in Helm references */
|
|
28
|
+
exports.helm = {
|
|
29
|
+
releaseName: '{{ .Release.Name }}',
|
|
30
|
+
chartName: '{{ .Chart.Name }}',
|
|
31
|
+
chartVersion: '{{ .Chart.Version }}',
|
|
32
|
+
namespace: '{{ .Release.Namespace }}',
|
|
33
|
+
};
|
|
34
|
+
/** Quote a Helm template expression for safe YAML embedding */
|
|
35
|
+
function quote(expr) {
|
|
36
|
+
// ensure Helm templates are quoted to avoid YAML parsing issues
|
|
37
|
+
if (expr.startsWith('{{') && expr.endsWith('}}')) {
|
|
38
|
+
return `'${expr}'`;
|
|
39
|
+
}
|
|
40
|
+
return expr;
|
|
41
|
+
}
|
|
42
|
+
/** Indent helper matching Helm indent fn: {{- n indent -}} */
|
|
43
|
+
function indent(n, expr) {
|
|
44
|
+
const spaces = ' '.repeat(n);
|
|
45
|
+
return expr
|
|
46
|
+
.split('\n')
|
|
47
|
+
.map((l) => (l.trim().length ? spaces + l : l))
|
|
48
|
+
.join('\n');
|
|
49
|
+
}
|
|
50
|
+
/** Insert a call to a named Helm template: {{ template "name" . }} */
|
|
51
|
+
function template(name, context = '.') {
|
|
52
|
+
return `{{ template "${name}" ${context} }}`;
|
|
53
|
+
}
|
|
54
|
+
/** Insert a call to a named Helm template using include: {{ include "name" . }} */
|
|
55
|
+
function include(name, context = '.') {
|
|
56
|
+
return `{{ include "${name}" ${context} }}`;
|
|
57
|
+
}
|
|
58
|
+
/** Numeric value from .Values with int cast: {{ .Values.path | int }} */
|
|
59
|
+
function numberRef(path) {
|
|
60
|
+
return `{{ .Values.${path} | int }}`;
|
|
61
|
+
}
|
|
62
|
+
/** Boolean value from .Values with toBool cast: {{ .Values.path | toBool }} */
|
|
63
|
+
function boolRef(path) {
|
|
64
|
+
return `{{ .Values.${path} | toBool }}`;
|
|
65
|
+
}
|
|
66
|
+
/** String value from .Values with toString cast: {{ .Values.path | toString }} */
|
|
67
|
+
function stringRef(path) {
|
|
68
|
+
return `{{ .Values.${path} | toString }}`;
|
|
69
|
+
}
|
|
70
|
+
/** Float value from .Values with float64 cast: {{ .Values.path | float64 }} */
|
|
71
|
+
function floatRef(path) {
|
|
72
|
+
return `{{ .Values.${path} | float64 }}`;
|
|
73
|
+
}
|
|
74
|
+
//# sourceMappingURL=helm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"helm.js","sourceRoot":"","sources":["../../src/lib/helm.ts"],"names":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AAsE;AACtE,SAAgB,QAAQ,CAAC,IAAY,EAAE,OAAO,GAAG,GAAG;IAClD,OAAO,gBAAgB,IAAI,KAAK,OAAO,KAAK,CAAC;AAC/C,CAAC;AAED,mFAAmF;AACnF,SAAgB,OAAO,CAAC,IAAY,EAAE,OAAO,GAAG,GAAG;IACjD,OAAO,eAAe,IAAI,KAAK,OAAO,KAAK,CAAC;AAC9C,CAAC;AAED,yEAAyE;AACzE,SAAgB,SAAS,CAAC,IAAY;IACpC,OAAO,cAAc,IAAI,WAAW,CAAC;AACvC,CAAC;AAED,+EAA+E;AAC/E,SAAgB,OAAO,CAAC,IAAY;IAClC,OAAO,cAAc,IAAI,cAAc,CAAC;AAC1C,CAAC;AAED,kFAAkF;AAClF,SAAgB,SAAS,CAAC,IAAY;IACpC,OAAO,cAAc,IAAI,gBAAgB,CAAC;AAC5C,CAAC;AAED,+EAA+E;AAC/E,SAAgB,QAAQ,CAAC,IAAY;IACnC,OAAO,cAAc,IAAI,eAAe,CAAC;AAC3C,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "timonel",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Timonel: programmatic Helm chart factory using cdk8s (TypeScript)",
|
|
5
|
+
"bin": {
|
|
6
|
+
"timonel": "dist/cli.js",
|
|
7
|
+
"tl": "dist/cli.js"
|
|
8
|
+
},
|
|
9
|
+
"main": "dist/index.js",
|
|
10
|
+
"types": "dist/index.d.ts",
|
|
11
|
+
"scripts": {
|
|
12
|
+
"build": "tsc -p tsconfig.json",
|
|
13
|
+
"clean": "rm -rf dist",
|
|
14
|
+
"dev": "tsc -w -p tsconfig.json",
|
|
15
|
+
"prepare": "husky",
|
|
16
|
+
"prepack": "pnpm build",
|
|
17
|
+
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
18
|
+
"lint": "eslint . --ext .ts,.tsx",
|
|
19
|
+
"lint:fix": "eslint . --ext .ts,.tsx --fix",
|
|
20
|
+
"format": "prettier --write .",
|
|
21
|
+
"format:check": "prettier --check .",
|
|
22
|
+
"security:lint": "eslint . --ext .ts,.tsx",
|
|
23
|
+
"security:audit": "pnpm audit --audit-level=moderate",
|
|
24
|
+
"security:check": "pnpm run security:lint && pnpm run security:audit",
|
|
25
|
+
"deps:check": "pnpm outdated",
|
|
26
|
+
"deps:update": "pnpm update --latest",
|
|
27
|
+
"md:lint": "markdownlint \"**/*.md\"",
|
|
28
|
+
"md:fix": "markdownlint --fix \"**/*.md\"",
|
|
29
|
+
"ci:check": "pnpm typecheck && pnpm lint && pnpm format:check && pnpm build"
|
|
30
|
+
},
|
|
31
|
+
"keywords": [
|
|
32
|
+
"helm",
|
|
33
|
+
"charts",
|
|
34
|
+
"cdk8s",
|
|
35
|
+
"kubernetes",
|
|
36
|
+
"iac"
|
|
37
|
+
],
|
|
38
|
+
"author": "Franklin García <KenkoGeek>",
|
|
39
|
+
"license": "MIT",
|
|
40
|
+
"engines": {
|
|
41
|
+
"node": ">=20",
|
|
42
|
+
"pnpm": ">=9.0.0"
|
|
43
|
+
},
|
|
44
|
+
"repository": {
|
|
45
|
+
"type": "git",
|
|
46
|
+
"url": "git+https://github.com/KenkoGeek/timonel.git"
|
|
47
|
+
},
|
|
48
|
+
"bugs": {
|
|
49
|
+
"url": "https://github.com/KenkoGeek/timonel/issues"
|
|
50
|
+
},
|
|
51
|
+
"homepage": "https://github.com/KenkoGeek/timonel#readme",
|
|
52
|
+
"lint-staged": {
|
|
53
|
+
"**/*.{ts,tsx}": [
|
|
54
|
+
"eslint --fix",
|
|
55
|
+
"prettier --write"
|
|
56
|
+
],
|
|
57
|
+
"**/*.{js,cjs,json,yml,yaml}": [
|
|
58
|
+
"prettier --write"
|
|
59
|
+
],
|
|
60
|
+
"**/*.md": [
|
|
61
|
+
"markdownlint --fix"
|
|
62
|
+
]
|
|
63
|
+
},
|
|
64
|
+
"dependencies": {
|
|
65
|
+
"cdk8s": "^2.7.0",
|
|
66
|
+
"cdk8s-plus-28": "^2.5.6",
|
|
67
|
+
"yaml": "^2.4.5",
|
|
68
|
+
"ts-node": "^10.9.2"
|
|
69
|
+
},
|
|
70
|
+
"devDependencies": {
|
|
71
|
+
"@commitlint/cli": "^19.3.0",
|
|
72
|
+
"@commitlint/config-conventional": "^19.2.2",
|
|
73
|
+
"@types/node": "^24.3.0",
|
|
74
|
+
"@typescript-eslint/eslint-plugin": "^7.8.0",
|
|
75
|
+
"@typescript-eslint/parser": "^7.8.0",
|
|
76
|
+
"eslint": "^8.57.0",
|
|
77
|
+
"eslint-config-prettier": "^10.1.8",
|
|
78
|
+
"eslint-import-resolver-typescript": "^4.4.4",
|
|
79
|
+
"eslint-plugin-import": "^2.29.1",
|
|
80
|
+
"eslint-plugin-security": "^3.0.1",
|
|
81
|
+
"eslint-plugin-sonarjs": "^3.0.5",
|
|
82
|
+
"eslint-plugin-unused-imports": "^4.2.0",
|
|
83
|
+
"husky": "^9.1.7",
|
|
84
|
+
"lint-staged": "^16.1.5",
|
|
85
|
+
"markdownlint": "^0.38.0",
|
|
86
|
+
"markdownlint-cli": "^0.45.0",
|
|
87
|
+
"prettier": "^3.3.3",
|
|
88
|
+
"typescript": "^5.4.5"
|
|
89
|
+
},
|
|
90
|
+
"files": [
|
|
91
|
+
"dist",
|
|
92
|
+
"README.md",
|
|
93
|
+
"SECURITY.md",
|
|
94
|
+
"LICENSE"
|
|
95
|
+
],
|
|
96
|
+
"publishConfig": {
|
|
97
|
+
"access": "public",
|
|
98
|
+
"provenance": true
|
|
99
|
+
},
|
|
100
|
+
"packageManager": "pnpm@10.15.0+sha512.486ebc259d3e999a4e8691ce03b5cac4a71cbeca39372a9b762cb500cfdf0873e2cb16abe3d951b1ee2cf012503f027b98b6584e4df22524e0c7450d9ec7aa7b"
|
|
101
|
+
}
|