kubernetes-fluent-client 3.7.0-nightly.0 → 3.7.0-nightly.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.
- package/dist/cli.js +5 -0
- package/dist/generate.d.ts +1 -0
- package/dist/generate.d.ts.map +1 -1
- package/dist/generate.js +3 -2
- package/dist/postProcessing.d.ts +2 -2
- package/dist/postProcessing.d.ts.map +1 -1
- package/dist/postProcessing.js +7 -7
- package/package.json +1 -1
- package/src/cli.ts +6 -0
- package/src/generate.ts +4 -2
- package/src/postProcessing.ts +7 -8
package/dist/cli.js
CHANGED
|
@@ -20,6 +20,10 @@ void yargs(hideBin(process.argv))
|
|
|
20
20
|
.positional("directory", {
|
|
21
21
|
describe: "the directory to output the generated types to",
|
|
22
22
|
type: "string",
|
|
23
|
+
})
|
|
24
|
+
.option("overrideClassName", {
|
|
25
|
+
type: "string",
|
|
26
|
+
description: "override the class name for the generated types, useful for generating types when multiple CRDs have the same kind",
|
|
23
27
|
})
|
|
24
28
|
.option("plain", {
|
|
25
29
|
alias: "p",
|
|
@@ -42,6 +46,7 @@ void yargs(hideBin(process.argv))
|
|
|
42
46
|
}, async (argv) => {
|
|
43
47
|
const opts = argv;
|
|
44
48
|
opts.logFn = console.log;
|
|
49
|
+
opts.npmPackage = "kubernetes-fluent-client";
|
|
45
50
|
// Pass the `post` flag to opts
|
|
46
51
|
opts.noPost = argv.noPost;
|
|
47
52
|
// Use NodeFileSystem as the file system for post-processing
|
package/dist/generate.d.ts
CHANGED
package/dist/generate.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate.d.ts","sourceRoot":"","sources":["../src/generate.ts"],"names":[],"mappings":"AAMA,OAAO,EAEL,SAAS,EAET,cAAc,EACd,SAAS,EACV,MAAM,gBAAgB,CAAC;AAIxB,OAAO,EAAE,wBAAwB,EAAE,MAAM,eAAe,CAAC;AACzD,OAAO,EAAE,KAAK,EAAE,MAAM,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M,CAAC;IACb,GAAG,EAAE,wBAAwB,CAAC;IAC9B,OAAO,EAAE,MAAM,CAAC;CACjB,EAAE,CACJ,CA8BA"}
|
package/dist/generate.js
CHANGED
|
@@ -15,7 +15,8 @@ import { CustomResourceDefinition } from "./upstream.js";
|
|
|
15
15
|
* @returns A promise that resolves to a record of generated TypeScript types.
|
|
16
16
|
*/
|
|
17
17
|
export async function convertCRDtoTS(crd, opts) {
|
|
18
|
-
const name = crd.spec.names.kind;
|
|
18
|
+
const name = opts.overrideClassName || crd.spec.names.kind;
|
|
19
|
+
const originalKind = crd.spec.names.kind;
|
|
19
20
|
const results = {};
|
|
20
21
|
const output = [];
|
|
21
22
|
// Check for missing versions or empty schema
|
|
@@ -33,7 +34,7 @@ export async function convertCRDtoTS(crd, opts) {
|
|
|
33
34
|
opts.logFn(`- Generating ${crd.spec.group}/${match.name} types for ${name}`);
|
|
34
35
|
const inputData = await prepareInputData(name, schema);
|
|
35
36
|
const generatedTypes = await generateTypes(inputData, opts);
|
|
36
|
-
const fileName = `${
|
|
37
|
+
const fileName = `${originalKind.toLowerCase()}-${match.name.toLowerCase()}`;
|
|
37
38
|
writeGeneratedFile(fileName, opts.directory || "", generatedTypes, opts.language || "ts");
|
|
38
39
|
results[fileName] = generatedTypes;
|
|
39
40
|
output.push({ results, name, crd, version: match.name });
|
package/dist/postProcessing.d.ts
CHANGED
|
@@ -89,10 +89,10 @@ export declare function updateBraceBalance(line: string, braceBalance: number):
|
|
|
89
89
|
* @param name The name of the schema.
|
|
90
90
|
* @param crd The CustomResourceDefinition object.
|
|
91
91
|
* @param version The version of the CRD.
|
|
92
|
-
* @param
|
|
92
|
+
* @param opts the options for the generation process.
|
|
93
93
|
* @returns The processed TypeScript lines.
|
|
94
94
|
*/
|
|
95
|
-
export declare function wrapWithFluentClient(lines: string[], name: string, crd: CustomResourceDefinition, version: string,
|
|
95
|
+
export declare function wrapWithFluentClient(lines: string[], name: string, crd: CustomResourceDefinition, version: string, opts: GenerateOptions): string[];
|
|
96
96
|
/**
|
|
97
97
|
* Processes the lines of the TypeScript file, focusing on classes extending `GenericKind`.
|
|
98
98
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"postProcessing.d.ts","sourceRoot":"","sources":["../src/postProcessing.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAEhD,OAAO,EAAE,wBAAwB,EAAE,MAAM,eAAe,CAAC;AAMzD,KAAK,SAAS,GAAG;IACf,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,wBAAwB,CAAC;IAC9B,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,KAAK,kBAAkB,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,OAAO,CAAC;IAAC,YAAY,EAAE,MAAM,CAAA;CAAE,CAAC;AAIvF;;;;;GAKG;AACH,wBAAsB,cAAc,CAAC,UAAU,EAAE,SAAS,EAAE,EAAE,IAAI,EAAE,eAAe,iBAalF;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,UAAU,EAAE,SAAS,EAAE,GAAG,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAahF;AAED;;;;;;GAMG;AACH,wBAAsB,YAAY,CAChC,KAAK,EAAE,MAAM,EAAE,EACf,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,EACxC,IAAI,EAAE,eAAe,iBAoBtB;AAED;;;;;;;;;GASG;AACH,wBAAgB,0BAA0B,CACxC,QAAQ,EAAE,MAAM,EAChB,UAAU,EAAE,SAAS,EACrB,IAAI,EAAE,eAAe,QA2BtB;AAED;;;;;;;;;GASG;AACH,wBAAgB,sBAAsB,CACpC,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,MAAM,EACZ,GAAG,EAAE,wBAAwB,EAC7B,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,eAAe,GACpB,MAAM,CAoBR;AAED;;;;GAIG;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eAAe,EAAE,GAAG,CAAC,MAAM,CAAC,GAC3B,kBAAkB,CAgBpB;AAED;;;;;;GAMG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,QAGpF"}
|
package/dist/postProcessing.js
CHANGED
|
@@ -31,7 +31,7 @@ export async function postProcessing(allResults, opts) {
|
|
|
31
31
|
export function mapFilesToCRD(allResults) {
|
|
32
32
|
const fileResultMap = {};
|
|
33
33
|
for (const { name, crd, version } of allResults) {
|
|
34
|
-
const expectedFileName = `${
|
|
34
|
+
const expectedFileName = `${crd.spec.names.kind.toLowerCase()}-${version.toLowerCase()}.ts`;
|
|
35
35
|
fileResultMap[expectedFileName] = { name, crd, version };
|
|
36
36
|
}
|
|
37
37
|
if (Object.keys(fileResultMap).length === 0) {
|
|
@@ -117,7 +117,7 @@ export function applyCRDPostProcessing(content, name, crd, version, opts) {
|
|
|
117
117
|
let lines = content.split("\n");
|
|
118
118
|
// Wraps with the fluent client if needed
|
|
119
119
|
if (opts.language === "ts" && !opts.plain) {
|
|
120
|
-
lines = wrapWithFluentClient(lines, name, crd, version, opts
|
|
120
|
+
lines = wrapWithFluentClient(lines, name, crd, version, opts);
|
|
121
121
|
}
|
|
122
122
|
const foundInterfaces = collectInterfaceNames(lines);
|
|
123
123
|
// Process the lines, focusing on classes extending `GenericKind`
|
|
@@ -187,18 +187,18 @@ export function updateBraceBalance(line, braceBalance) {
|
|
|
187
187
|
* @param name The name of the schema.
|
|
188
188
|
* @param crd The CustomResourceDefinition object.
|
|
189
189
|
* @param version The version of the CRD.
|
|
190
|
-
* @param
|
|
190
|
+
* @param opts the options for the generation process.
|
|
191
191
|
* @returns The processed TypeScript lines.
|
|
192
192
|
*/
|
|
193
|
-
export function wrapWithFluentClient(lines, name, crd, version,
|
|
194
|
-
const autoGenNotice = `// This file is auto-generated by ${npmPackage}, do not edit manually`;
|
|
195
|
-
const imports = `import { GenericKind, RegisterKind } from "${npmPackage}";`;
|
|
193
|
+
export function wrapWithFluentClient(lines, name, crd, version, opts) {
|
|
194
|
+
const autoGenNotice = `// This file is auto-generated by ${opts.npmPackage}, do not edit manually`;
|
|
195
|
+
const imports = `import { GenericKind, RegisterKind } from "${opts.npmPackage}";`;
|
|
196
196
|
const classIndex = lines.findIndex(line => line.includes(`export interface ${name} {`));
|
|
197
197
|
if (classIndex !== -1) {
|
|
198
198
|
lines[classIndex] = `export class ${name} extends GenericKind {`;
|
|
199
199
|
}
|
|
200
200
|
lines.unshift(autoGenNotice, imports);
|
|
201
|
-
lines.push(`RegisterKind(${name}, {`, ` group: "${crd.spec.group}",`, ` version: "${version}",`, ` kind: "${
|
|
201
|
+
lines.push(`RegisterKind(${name}, {`, ` group: "${crd.spec.group}",`, ` version: "${version}",`, ` kind: "${crd.spec.names.kind}",`, ` plural: "${crd.spec.names.plural}",`, `});`);
|
|
202
202
|
return lines;
|
|
203
203
|
}
|
|
204
204
|
/**
|
package/package.json
CHANGED
package/src/cli.ts
CHANGED
|
@@ -27,6 +27,11 @@ void yargs(hideBin(process.argv))
|
|
|
27
27
|
describe: "the directory to output the generated types to",
|
|
28
28
|
type: "string",
|
|
29
29
|
})
|
|
30
|
+
.option("overrideClassName", {
|
|
31
|
+
type: "string",
|
|
32
|
+
description:
|
|
33
|
+
"override the class name for the generated types, useful for generating types when multiple CRDs have the same kind",
|
|
34
|
+
})
|
|
30
35
|
.option("plain", {
|
|
31
36
|
alias: "p",
|
|
32
37
|
type: "boolean",
|
|
@@ -51,6 +56,7 @@ void yargs(hideBin(process.argv))
|
|
|
51
56
|
async argv => {
|
|
52
57
|
const opts = argv as unknown as GenerateOptions;
|
|
53
58
|
opts.logFn = console.log;
|
|
59
|
+
opts.npmPackage = "kubernetes-fluent-client";
|
|
54
60
|
|
|
55
61
|
// Pass the `post` flag to opts
|
|
56
62
|
opts.noPost = argv.noPost as boolean;
|
package/src/generate.ts
CHANGED
|
@@ -20,6 +20,7 @@ export type QuicktypeLang = Parameters<typeof quicktype>[0]["lang"];
|
|
|
20
20
|
export interface GenerateOptions {
|
|
21
21
|
source: string; // URL, file path, or K8s CRD name
|
|
22
22
|
directory?: string; // Output directory path
|
|
23
|
+
overrideClassName?: string; // Override class name for generated types
|
|
23
24
|
plain?: boolean; // Disable fluent client wrapping
|
|
24
25
|
language: QuicktypeLang; // Language for type generation (default: "ts")
|
|
25
26
|
npmPackage?: string; // Override NPM package
|
|
@@ -45,7 +46,8 @@ export async function convertCRDtoTS(
|
|
|
45
46
|
version: string;
|
|
46
47
|
}[]
|
|
47
48
|
> {
|
|
48
|
-
const name = crd.spec.names.kind;
|
|
49
|
+
const name = opts.overrideClassName || crd.spec.names.kind;
|
|
50
|
+
const originalKind = crd.spec.names.kind;
|
|
49
51
|
const results: Record<string, string[]> = {};
|
|
50
52
|
const output: {
|
|
51
53
|
results: Record<string, string[]>;
|
|
@@ -75,7 +77,7 @@ export async function convertCRDtoTS(
|
|
|
75
77
|
const inputData = await prepareInputData(name, schema);
|
|
76
78
|
const generatedTypes = await generateTypes(inputData, opts);
|
|
77
79
|
|
|
78
|
-
const fileName = `${
|
|
80
|
+
const fileName = `${originalKind.toLowerCase()}-${match.name.toLowerCase()}`;
|
|
79
81
|
writeGeneratedFile(fileName, opts.directory || "", generatedTypes, opts.language || "ts");
|
|
80
82
|
|
|
81
83
|
results[fileName] = generatedTypes;
|
package/src/postProcessing.ts
CHANGED
|
@@ -52,7 +52,7 @@ export function mapFilesToCRD(allResults: CRDResult[]): Record<string, CRDResult
|
|
|
52
52
|
const fileResultMap: Record<string, CRDResult> = {};
|
|
53
53
|
|
|
54
54
|
for (const { name, crd, version } of allResults) {
|
|
55
|
-
const expectedFileName = `${
|
|
55
|
+
const expectedFileName = `${crd.spec.names.kind.toLowerCase()}-${version.toLowerCase()}.ts`;
|
|
56
56
|
fileResultMap[expectedFileName] = { name, crd, version };
|
|
57
57
|
}
|
|
58
58
|
|
|
@@ -159,7 +159,7 @@ export function applyCRDPostProcessing(
|
|
|
159
159
|
|
|
160
160
|
// Wraps with the fluent client if needed
|
|
161
161
|
if (opts.language === "ts" && !opts.plain) {
|
|
162
|
-
lines = wrapWithFluentClient(lines, name, crd, version, opts
|
|
162
|
+
lines = wrapWithFluentClient(lines, name, crd, version, opts);
|
|
163
163
|
}
|
|
164
164
|
const foundInterfaces = collectInterfaceNames(lines);
|
|
165
165
|
|
|
@@ -242,7 +242,7 @@ export function updateBraceBalance(line: string, braceBalance: number): number {
|
|
|
242
242
|
* @param name The name of the schema.
|
|
243
243
|
* @param crd The CustomResourceDefinition object.
|
|
244
244
|
* @param version The version of the CRD.
|
|
245
|
-
* @param
|
|
245
|
+
* @param opts the options for the generation process.
|
|
246
246
|
* @returns The processed TypeScript lines.
|
|
247
247
|
*/
|
|
248
248
|
export function wrapWithFluentClient(
|
|
@@ -250,11 +250,10 @@ export function wrapWithFluentClient(
|
|
|
250
250
|
name: string,
|
|
251
251
|
crd: CustomResourceDefinition,
|
|
252
252
|
version: string,
|
|
253
|
-
|
|
253
|
+
opts: GenerateOptions,
|
|
254
254
|
): string[] {
|
|
255
|
-
const autoGenNotice = `// This file is auto-generated by ${npmPackage}, do not edit manually`;
|
|
256
|
-
const imports = `import { GenericKind, RegisterKind } from "${npmPackage}";`;
|
|
257
|
-
|
|
255
|
+
const autoGenNotice = `// This file is auto-generated by ${opts.npmPackage}, do not edit manually`;
|
|
256
|
+
const imports = `import { GenericKind, RegisterKind } from "${opts.npmPackage}";`;
|
|
258
257
|
const classIndex = lines.findIndex(line => line.includes(`export interface ${name} {`));
|
|
259
258
|
if (classIndex !== -1) {
|
|
260
259
|
lines[classIndex] = `export class ${name} extends GenericKind {`;
|
|
@@ -265,7 +264,7 @@ export function wrapWithFluentClient(
|
|
|
265
264
|
`RegisterKind(${name}, {`,
|
|
266
265
|
` group: "${crd.spec.group}",`,
|
|
267
266
|
` version: "${version}",`,
|
|
268
|
-
` kind: "${
|
|
267
|
+
` kind: "${crd.spec.names.kind}",`,
|
|
269
268
|
` plural: "${crd.spec.names.plural}",`,
|
|
270
269
|
`});`,
|
|
271
270
|
);
|