kubernetes-fluent-client 3.5.6 → 3.6.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.
Files changed (46) hide show
  1. package/dist/cli.js +9 -16
  2. package/dist/fetch.js +5 -8
  3. package/dist/fluent/index.d.ts +2 -1
  4. package/dist/fluent/index.d.ts.map +1 -1
  5. package/dist/fluent/index.js +27 -29
  6. package/dist/fluent/shared-types.d.ts +49 -0
  7. package/dist/fluent/shared-types.d.ts.map +1 -0
  8. package/dist/fluent/shared-types.js +23 -0
  9. package/dist/fluent/types.d.ts +2 -37
  10. package/dist/fluent/types.d.ts.map +1 -1
  11. package/dist/fluent/types.js +1 -14
  12. package/dist/fluent/utils.d.ts +1 -1
  13. package/dist/fluent/utils.d.ts.map +1 -1
  14. package/dist/fluent/utils.js +25 -35
  15. package/dist/fluent/watch.d.ts +1 -8
  16. package/dist/fluent/watch.d.ts.map +1 -1
  17. package/dist/fluent/watch.js +23 -43
  18. package/dist/generate.js +22 -65
  19. package/dist/helpers.js +5 -10
  20. package/dist/index.js +13 -60
  21. package/dist/kinds.js +2 -7
  22. package/dist/normalization.d.ts +97 -0
  23. package/dist/normalization.d.ts.map +1 -0
  24. package/dist/normalization.js +152 -0
  25. package/dist/patch.js +1 -2
  26. package/dist/postProcessing.d.ts +6 -127
  27. package/dist/postProcessing.d.ts.map +1 -1
  28. package/dist/postProcessing.js +24 -279
  29. package/dist/types.d.ts +3 -2
  30. package/dist/types.d.ts.map +1 -1
  31. package/dist/types.js +1 -5
  32. package/dist/upstream.js +2 -53
  33. package/package.json +11 -8
  34. package/src/cli.ts +1 -3
  35. package/src/fluent/index.ts +12 -11
  36. package/src/fluent/shared-types.ts +55 -0
  37. package/src/fluent/types.ts +3 -54
  38. package/src/fluent/utils.ts +2 -2
  39. package/src/fluent/watch.ts +2 -21
  40. package/src/normalization.ts +181 -0
  41. package/src/postProcessing.ts +11 -239
  42. package/src/types.ts +3 -4
  43. package/dist/fileSystem.d.ts +0 -11
  44. package/dist/fileSystem.d.ts.map +0 -1
  45. package/dist/fileSystem.js +0 -52
  46. package/src/fileSystem.ts +0 -25
@@ -1,89 +1,25 @@
1
- "use strict";
2
1
  // SPDX-License-Identifier: Apache-2.0
3
2
  // SPDX-FileCopyrightText: 2023-Present The Kubernetes Fluent Client Authors
4
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
5
- if (k2 === undefined) k2 = k;
6
- var desc = Object.getOwnPropertyDescriptor(m, k);
7
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
8
- desc = { enumerable: true, get: function() { return m[k]; } };
9
- }
10
- Object.defineProperty(o, k2, desc);
11
- }) : (function(o, m, k, k2) {
12
- if (k2 === undefined) k2 = k;
13
- o[k2] = m[k];
14
- }));
15
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
16
- Object.defineProperty(o, "default", { enumerable: true, value: v });
17
- }) : function(o, v) {
18
- o["default"] = v;
19
- });
20
- var __importStar = (this && this.__importStar) || (function () {
21
- var ownKeys = function(o) {
22
- ownKeys = Object.getOwnPropertyNames || function (o) {
23
- var ar = [];
24
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
25
- return ar;
26
- };
27
- return ownKeys(o);
28
- };
29
- return function (mod) {
30
- if (mod && mod.__esModule) return mod;
31
- var result = {};
32
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
33
- __setModuleDefault(result, mod);
34
- return result;
35
- };
36
- })();
37
- Object.defineProperty(exports, "__esModule", { value: true });
38
- exports.postProcessing = postProcessing;
39
- exports.mapFilesToCRD = mapFilesToCRD;
40
- exports.processFiles = processFiles;
41
- exports.processAndModifySingleFile = processAndModifySingleFile;
42
- exports.applyCRDPostProcessing = applyCRDPostProcessing;
43
- exports.readFile = readFile;
44
- exports.writeFile = writeFile;
45
- exports.getGenericKindProperties = getGenericKindProperties;
46
- exports.collectInterfaceNames = collectInterfaceNames;
47
- exports.isClassExtendingGenericKind = isClassExtendingGenericKind;
48
- exports.updateBraceBalance = updateBraceBalance;
49
- exports.getPropertyPattern = getPropertyPattern;
50
- exports.modifyPropertiesAndAddEslintDirective = modifyPropertiesAndAddEslintDirective;
51
- exports.addDeclareAndOptionalModifiersToProperties = addDeclareAndOptionalModifiersToProperties;
52
- exports.addDeclareToGenericKindProperties = addDeclareToGenericKindProperties;
53
- exports.makePropertiesOptional = makePropertiesOptional;
54
- exports.processEslintDisable = processEslintDisable;
55
- exports.wrapWithFluentClient = wrapWithFluentClient;
56
- exports.normalizeIndentation = normalizeIndentation;
57
- exports.normalizeLineIndentation = normalizeLineIndentation;
58
- exports.normalizePropertySpacing = normalizePropertySpacing;
59
- exports.removePropertyStringAny = removePropertyStringAny;
60
- exports.shouldWrapWithFluentClient = shouldWrapWithFluentClient;
61
- exports.processLines = processLines;
62
- exports.processClassContext = processClassContext;
63
- exports.modifyAndNormalizeClassProperties = modifyAndNormalizeClassProperties;
64
- exports.normalizeIndentationAndSpacing = normalizeIndentationAndSpacing;
65
- exports.logError = logError;
66
- const fs = __importStar(require("fs"));
67
- const path = __importStar(require("path"));
68
- const types_1 = require("./types");
69
- const fileSystem_1 = require("./fileSystem");
3
+ import * as fs from "fs";
4
+ import * as path from "path";
5
+ import { GenericKind } from "./types";
6
+ import { modifyAndNormalizeClassProperties, normalizeIndentationAndSpacing } from "./normalization";
70
7
  const genericKindProperties = getGenericKindProperties();
71
8
  /**
72
9
  * Performs post-processing on generated TypeScript files.
73
10
  *
74
11
  * @param allResults The array of CRD results.
75
12
  * @param opts The options for post-processing.
76
- * @param fileSystem The file system interface for reading and writing files.
77
13
  */
78
- async function postProcessing(allResults, opts, fileSystem = new fileSystem_1.NodeFileSystem()) {
14
+ export async function postProcessing(allResults, opts) {
79
15
  if (!opts.directory) {
80
16
  opts.logFn("⚠️ Error: Directory is not defined.");
81
17
  return;
82
18
  }
83
- const files = fileSystem.readdirSync(opts.directory);
19
+ const files = fs.readdirSync(opts.directory);
84
20
  opts.logFn("\n🔧 Post-processing started...");
85
21
  const fileResultMap = mapFilesToCRD(allResults);
86
- await processFiles(files, fileResultMap, opts, fileSystem);
22
+ await processFiles(files, fileResultMap, opts);
87
23
  opts.logFn("🔧 Post-processing completed.\n");
88
24
  }
89
25
  /**
@@ -92,7 +28,7 @@ async function postProcessing(allResults, opts, fileSystem = new fileSystem_1.No
92
28
  * @param allResults - The array of CRD results.
93
29
  * @returns A map linking file names to their corresponding CRD results.
94
30
  */
95
- function mapFilesToCRD(allResults) {
31
+ export function mapFilesToCRD(allResults) {
96
32
  const fileResultMap = {};
97
33
  for (const { name, crd, version } of allResults) {
98
34
  const expectedFileName = `${name.toLowerCase()}-${version.toLowerCase()}.ts`;
@@ -109,9 +45,8 @@ function mapFilesToCRD(allResults) {
109
45
  * @param files - The list of file names to process.
110
46
  * @param fileResultMap - A map linking file names to their corresponding CRD results.
111
47
  * @param opts - Options for the generation process.
112
- * @param fileSystem - The file system interface for reading and writing files.
113
48
  */
114
- async function processFiles(files, fileResultMap, opts, fileSystem) {
49
+ export async function processFiles(files, fileResultMap, opts) {
115
50
  for (const file of files) {
116
51
  if (!opts.directory) {
117
52
  throw new Error("Directory is not defined.");
@@ -123,7 +58,7 @@ async function processFiles(files, fileResultMap, opts, fileSystem) {
123
58
  continue;
124
59
  }
125
60
  try {
126
- processAndModifySingleFile(filePath, fileResult, opts, fileSystem);
61
+ processAndModifySingleFile(filePath, fileResult, opts);
127
62
  }
128
63
  catch (error) {
129
64
  logError(error, filePath, opts.logFn);
@@ -139,14 +74,13 @@ async function processFiles(files, fileResultMap, opts, fileSystem) {
139
74
  * @param fileResult.crd - The CustomResourceDefinition object.
140
75
  * @param fileResult.version - The version of the CRD.
141
76
  * @param opts - Options for the generation process.
142
- * @param fileSystem - The file system interface for reading and writing files.
143
77
  */
144
- function processAndModifySingleFile(filePath, fileResult, opts, fileSystem) {
78
+ export function processAndModifySingleFile(filePath, fileResult, opts) {
145
79
  opts.logFn(`🔍 Processing file: ${filePath}`);
146
80
  const { name, crd, version } = fileResult;
147
81
  let fileContent;
148
82
  try {
149
- fileContent = fileSystem.readFile(filePath);
83
+ fileContent = fs.readFileSync(filePath, "utf8");
150
84
  }
151
85
  catch (error) {
152
86
  logError(error, filePath, opts.logFn);
@@ -161,7 +95,7 @@ function processAndModifySingleFile(filePath, fileResult, opts, fileSystem) {
161
95
  return;
162
96
  }
163
97
  try {
164
- fileSystem.writeFile(filePath, modifiedContent);
98
+ fs.writeFileSync(filePath, modifiedContent);
165
99
  opts.logFn(`✅ Successfully processed and wrote file: ${filePath}`);
166
100
  }
167
101
  catch (error) {
@@ -178,11 +112,11 @@ function processAndModifySingleFile(filePath, fileResult, opts, fileSystem) {
178
112
  * @param opts The options for processing.
179
113
  * @returns The processed TypeScript file content.
180
114
  */
181
- function applyCRDPostProcessing(content, name, crd, version, opts) {
115
+ export function applyCRDPostProcessing(content, name, crd, version, opts) {
182
116
  try {
183
117
  let lines = content.split("\n");
184
118
  // Wraps with the fluent client if needed
185
- if (shouldWrapWithFluentClient(opts)) {
119
+ if (opts.language === "ts" && !opts.plain) {
186
120
  lines = wrapWithFluentClient(lines, name, crd, version, opts.npmPackage);
187
121
  }
188
122
  const foundInterfaces = collectInterfaceNames(lines);
@@ -196,41 +130,13 @@ function applyCRDPostProcessing(content, name, crd, version, opts) {
196
130
  throw new Error(`Error while applying post-processing for ${name}: ${error.message}`);
197
131
  }
198
132
  }
199
- /**
200
- * Reads the content of a file from disk.
201
- *
202
- * @param filePath The path to the file.
203
- * @returns The file contents as a string.
204
- */
205
- function readFile(filePath) {
206
- try {
207
- return fs.readFileSync(filePath, "utf8");
208
- }
209
- catch (error) {
210
- throw new Error(`Failed to read file at ${filePath}: ${error.message}`);
211
- }
212
- }
213
- /**
214
- * Writes the modified content back to the file.
215
- *
216
- * @param filePath The path to the file.
217
- * @param content The modified content to write.
218
- */
219
- function writeFile(filePath, content) {
220
- try {
221
- fs.writeFileSync(filePath, content, "utf8");
222
- }
223
- catch (error) {
224
- throw new Error(`Failed to write file at ${filePath}: ${error.message}`);
225
- }
226
- }
227
133
  /**
228
134
  * Retrieves the properties of the `GenericKind` class, excluding dynamic properties like `[key: string]: any`.
229
135
  *
230
136
  * @returns An array of property names that belong to `GenericKind`.
231
137
  */
232
- function getGenericKindProperties() {
233
- const properties = Object.getOwnPropertyNames(new types_1.GenericKind());
138
+ export function getGenericKindProperties() {
139
+ const properties = Object.getOwnPropertyNames(new GenericKind());
234
140
  return properties.filter(prop => prop !== "[key: string]");
235
141
  }
236
142
  /**
@@ -239,7 +145,7 @@ function getGenericKindProperties() {
239
145
  * @param lines The lines of the file content.
240
146
  * @returns A set of found interface names.
241
147
  */
242
- function collectInterfaceNames(lines) {
148
+ export function collectInterfaceNames(lines) {
243
149
  // https://regex101.com/r/S6w8pW/1
244
150
  const interfacePattern = /export interface (?<interfaceName>\w+)/;
245
151
  const foundInterfaces = new Set();
@@ -257,7 +163,7 @@ function collectInterfaceNames(lines) {
257
163
  * @param line The current line of code.
258
164
  * @returns True if the line defines a class that extends `GenericKind`, false otherwise.
259
165
  */
260
- function isClassExtendingGenericKind(line) {
166
+ export function isClassExtendingGenericKind(line) {
261
167
  return line.includes("class") && line.includes("extends GenericKind");
262
168
  }
263
169
  /**
@@ -267,95 +173,9 @@ function isClassExtendingGenericKind(line) {
267
173
  * @param braceBalance The current balance of curly braces.
268
174
  * @returns The updated brace balance.
269
175
  */
270
- function updateBraceBalance(line, braceBalance) {
176
+ export function updateBraceBalance(line, braceBalance) {
271
177
  return braceBalance + (line.includes("{") ? 1 : 0) - (line.includes("}") ? 1 : 0);
272
178
  }
273
- /**
274
- * Generates a regular expression to match a property pattern in TypeScript.
275
- *
276
- * @param prop The property name to match.
277
- * @returns A regular expression to match the property pattern.
278
- */
279
- function getPropertyPattern(prop) {
280
- // For prop="kind", the pattern will match "kind ? :" or "kind :"
281
- // https://regex101.com/r/mF8kXn/1
282
- return new RegExp(`\\b${prop}\\b\\s*\\?\\s*:|\\b${prop}\\b\\s*:`);
283
- }
284
- /**
285
- * Applies ESLint and property modifiers to a line of code.
286
- *
287
- * @param line - The current line of code.
288
- * @param genericKindProperties - The list of properties from `GenericKind`.
289
- * @param foundInterfaces - The set of found interfaces in the file.
290
- * @returns The modified line.
291
- */
292
- function modifyPropertiesAndAddEslintDirective(line, genericKindProperties, foundInterfaces) {
293
- line = addDeclareAndOptionalModifiersToProperties(line, genericKindProperties, foundInterfaces);
294
- line = processEslintDisable(line, genericKindProperties);
295
- return line;
296
- }
297
- /**
298
- * Applies property modifiers to a line of code.
299
- *
300
- * @param line The current line of code.
301
- * @param genericKindProperties The list of properties from `GenericKind`.
302
- * @param foundInterfaces The set of found interfaces in the file.
303
- * @returns The modified line.
304
- */
305
- function addDeclareAndOptionalModifiersToProperties(line, genericKindProperties, foundInterfaces) {
306
- line = addDeclareToGenericKindProperties(line, genericKindProperties);
307
- line = makePropertiesOptional(line, foundInterfaces);
308
- line = normalizeLineIndentation(line);
309
- return line;
310
- }
311
- /**
312
- * Adds the `declare` keyword to `GenericKind` properties.
313
- *
314
- * @param line The current line of code.
315
- * @param genericKindProperties The list of properties from `GenericKind`.
316
- * @returns The modified line with the `declare` keyword, if applicable.
317
- */
318
- function addDeclareToGenericKindProperties(line, genericKindProperties) {
319
- for (const prop of genericKindProperties) {
320
- const propertyPattern = getPropertyPattern(prop);
321
- if (propertyPattern.test(line)) {
322
- return line.replace(prop, `declare ${prop}`);
323
- }
324
- }
325
- return line;
326
- }
327
- /**
328
- * Makes a property optional if its type matches one of the found interfaces and it is not already optional.
329
- *
330
- * @param line The current line of code.
331
- * @param foundInterfaces The set of found interfaces in the file.
332
- * @returns The modified line with the optional `?` symbol.
333
- */
334
- function makePropertiesOptional(line, foundInterfaces) {
335
- // https://regex101.com/r/kX8TCj/1
336
- const propertyTypePattern = /:\s*(?<propertyType>\w+)\s*;/;
337
- const match = line.match(propertyTypePattern);
338
- if (match?.groups?.propertyType) {
339
- const { propertyType } = match.groups;
340
- if (foundInterfaces.has(propertyType) && !line.includes("?")) {
341
- return line.replace(":", "?:");
342
- }
343
- }
344
- return line;
345
- }
346
- /**
347
- * Adds an ESLint disable comment for `[key: string]: any` if it's not part of `GenericKind`.
348
- *
349
- * @param line The current line of code.
350
- * @param genericKindProperties The list of properties from `GenericKind`.
351
- * @returns The modified line with the ESLint disable comment.
352
- */
353
- function processEslintDisable(line, genericKindProperties) {
354
- if (line.includes("[key: string]: any") && !genericKindProperties.includes("[key: string]")) {
355
- return ` // eslint-disable-next-line @typescript-eslint/no-explicit-any\n${line}`;
356
- }
357
- return line;
358
- }
359
179
  /**
360
180
  * Wraps the generated TypeScript file with fluent client elements (`GenericKind` and `RegisterKind`).
361
181
  *
@@ -366,7 +186,7 @@ function processEslintDisable(line, genericKindProperties) {
366
186
  * @param npmPackage The NPM package name for the fluent client.
367
187
  * @returns The processed TypeScript lines.
368
188
  */
369
- function wrapWithFluentClient(lines, name, crd, version, npmPackage = "kubernetes-fluent-client") {
189
+ export function wrapWithFluentClient(lines, name, crd, version, npmPackage = "kubernetes-fluent-client") {
370
190
  const autoGenNotice = `// This file is auto-generated by ${npmPackage}, do not edit manually`;
371
191
  const imports = `import { GenericKind, RegisterKind } from "${npmPackage}";`;
372
192
  const classIndex = lines.findIndex(line => line.includes(`export interface ${name} {`));
@@ -377,56 +197,6 @@ function wrapWithFluentClient(lines, name, crd, version, npmPackage = "kubernete
377
197
  lines.push(`RegisterKind(${name}, {`, ` group: "${crd.spec.group}",`, ` version: "${version}",`, ` kind: "${name}",`, ` plural: "${crd.spec.names.plural}",`, `});`);
378
198
  return lines;
379
199
  }
380
- /**
381
- * Normalizes indentation for TypeScript lines to a consistent format.
382
- *
383
- * @param lines The generated TypeScript lines.
384
- * @returns The lines with normalized indentation.
385
- */
386
- function normalizeIndentation(lines) {
387
- return lines.map(line => line.replace(/^ {4}/, " "));
388
- }
389
- /**
390
- * Normalizes the indentation of a single line to use two spaces instead of four.
391
- *
392
- * @param line The line of code to normalize.
393
- * @returns The line with normalized indentation.
394
- */
395
- function normalizeLineIndentation(line) {
396
- return line.replace(/^ {4}/, " ");
397
- }
398
- /**
399
- * Normalizes spacing between property names and types in TypeScript lines.
400
- *
401
- * @param lines The generated TypeScript lines.
402
- * @returns The lines with normalized property spacing.
403
- */
404
- function normalizePropertySpacing(lines) {
405
- // https://regex101.com/r/XEv3pL/1
406
- return lines.map(line => line.replace(/\s*\?\s*:\s*/, "?: "));
407
- }
408
- /**
409
- * Removes lines containing `[property: string]: any;` from TypeScript files.
410
- *
411
- * @param lines The generated TypeScript lines.
412
- * @param opts The options for processing.
413
- * @returns The lines with `[property: string]: any;` removed.
414
- */
415
- function removePropertyStringAny(lines, opts) {
416
- if (opts.language === "ts" || opts.language === "typescript") {
417
- return lines.filter(line => !line.includes("[property: string]: any;"));
418
- }
419
- return lines;
420
- }
421
- /**
422
- * Determines if the content should be wrapped with the fluent client.
423
- *
424
- * @param opts The options for generating the content.
425
- * @returns True if the content should be wrapped with the fluent client, false otherwise.
426
- */
427
- function shouldWrapWithFluentClient(opts) {
428
- return opts.language === "ts" && !opts.plain;
429
- }
430
200
  /**
431
201
  * Processes the lines of the TypeScript file, focusing on classes extending `GenericKind`.
432
202
  *
@@ -435,7 +205,7 @@ function shouldWrapWithFluentClient(opts) {
435
205
  * @param foundInterfaces The set of found interfaces in the file.
436
206
  * @returns The processed lines.
437
207
  */
438
- function processLines(lines, genericKindProperties, foundInterfaces) {
208
+ export function processLines(lines, genericKindProperties, foundInterfaces) {
439
209
  let insideClass = false;
440
210
  let braceBalance = 0;
441
211
  return lines.map(line => {
@@ -455,7 +225,7 @@ function processLines(lines, genericKindProperties, foundInterfaces) {
455
225
  * @param foundInterfaces The set of found interfaces in the file.
456
226
  * @returns An object containing the updated line, updated insideClass flag, and braceBalance.
457
227
  */
458
- function processClassContext(line, insideClass, braceBalance, genericKindProperties, foundInterfaces) {
228
+ export function processClassContext(line, insideClass, braceBalance, genericKindProperties, foundInterfaces) {
459
229
  if (isClassExtendingGenericKind(line)) {
460
230
  insideClass = true;
461
231
  braceBalance = 0;
@@ -469,31 +239,6 @@ function processClassContext(line, insideClass, braceBalance, genericKindPropert
469
239
  }
470
240
  return { line, insideClass, braceBalance };
471
241
  }
472
- /**
473
- * Processes a single line inside a class extending `GenericKind`.
474
- *
475
- * @param line The current line of code.
476
- * @param genericKindProperties The list of properties from `GenericKind`.
477
- * @param foundInterfaces The set of found interfaces in the file.
478
- * @returns The modified line.
479
- */
480
- function modifyAndNormalizeClassProperties(line, genericKindProperties, foundInterfaces) {
481
- line = modifyPropertiesAndAddEslintDirective(line, genericKindProperties, foundInterfaces);
482
- line = normalizeLineIndentation(line);
483
- return line;
484
- }
485
- /**
486
- * Normalizes lines after processing, including indentation, spacing, and removing unnecessary lines.
487
- *
488
- * @param lines The lines of the file content.
489
- * @param opts The options for processing.
490
- * @returns The normalized lines.
491
- */
492
- function normalizeIndentationAndSpacing(lines, opts) {
493
- let normalizedLines = normalizeIndentation(lines);
494
- normalizedLines = normalizePropertySpacing(normalizedLines);
495
- return removePropertyStringAny(normalizedLines, opts);
496
- }
497
242
  /**
498
243
  * Handles logging for errors with stack trace.
499
244
  *
@@ -501,7 +246,7 @@ function normalizeIndentationAndSpacing(lines, opts) {
501
246
  * @param filePath The path of the file being processed.
502
247
  * @param logFn The logging function.
503
248
  */
504
- function logError(error, filePath, logFn) {
249
+ export function logError(error, filePath, logFn) {
505
250
  logFn(`❌ Error processing file: ${filePath} - ${error.message}`);
506
251
  logFn(`Stack trace: ${error.stack}`);
507
252
  }
package/dist/types.d.ts CHANGED
@@ -1,5 +1,6 @@
1
- import { KubernetesObject, V1ObjectMeta } from "@kubernetes/client-node";
2
- export { KubernetesObject, KubernetesListObject } from "@kubernetes/client-node";
1
+ import { V1ObjectMeta } from "@kubernetes/client-node";
2
+ import type { KubernetesListObject, KubernetesObject } from "@kubernetes/client-node";
3
+ export type { KubernetesListObject, KubernetesObject };
3
4
  export type GenericClass = abstract new () => any;
4
5
  /**
5
6
  * GenericKind is a generic Kubernetes object that can be used to represent any Kubernetes object
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAEzE,OAAO,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAGjF,MAAM,MAAM,YAAY,GAAG,QAAQ,WAAW,GAAG,CAAC;AAElD;;;;GAIG;AACH,qBAAa,WAAY,YAAW,gBAAgB;IAClD,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,YAAY,CAAC;IAExB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB;AAED;;;GAGG;AACH,MAAM,WAAW,gBAAgB;IAC/B,yCAAyC;IACzC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAC1B,6EAA6E;IAC7E,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED,MAAM,WAAW,KAAK;IAEpB,CAAC,CAAC,SAAS,MAAM,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,CAAC,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,KAAK,EAAE,GAAG,IAAI,CAAC;IACjE,CAAC,GAAG,EAAE,OAAO,EAAE,GAAG,CAAC,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,KAAK,EAAE,GAAG,IAAI,CAAC;IACrD,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,KAAK,EAAE,GAAG,IAAI,CAAC;CACvC"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,KAAK,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AACtF,YAAY,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,CAAC;AAEvD,MAAM,MAAM,YAAY,GAAG,QAAQ,WAAW,GAAG,CAAC;AAElD;;;;GAIG;AACH,qBAAa,WAAY,YAAW,gBAAgB;IAClD,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,YAAY,CAAC;IAExB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB;AAED;;;GAGG;AACH,MAAM,WAAW,gBAAgB;IAC/B,yCAAyC;IACzC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAC1B,6EAA6E;IAC7E,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED,MAAM,WAAW,KAAK;IAEpB,CAAC,CAAC,SAAS,MAAM,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,CAAC,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,KAAK,EAAE,GAAG,IAAI,CAAC;IACjE,CAAC,GAAG,EAAE,OAAO,EAAE,GAAG,CAAC,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,KAAK,EAAE,GAAG,IAAI,CAAC;IACrD,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,KAAK,EAAE,GAAG,IAAI,CAAC;CACvC"}
package/dist/types.js CHANGED
@@ -1,16 +1,12 @@
1
- "use strict";
2
1
  // SPDX-License-Identifier: Apache-2.0
3
2
  // SPDX-FileCopyrightText: 2023-Present The Kubernetes Fluent Client Authors
4
- Object.defineProperty(exports, "__esModule", { value: true });
5
- exports.GenericKind = void 0;
6
3
  /**
7
4
  * GenericKind is a generic Kubernetes object that can be used to represent any Kubernetes object
8
5
  * that is not explicitly supported. This can be used on its own or as a base class for
9
6
  * other types.
10
7
  */
11
- class GenericKind {
8
+ export class GenericKind {
12
9
  apiVersion;
13
10
  kind;
14
11
  metadata;
15
12
  }
16
- exports.GenericKind = GenericKind;
package/dist/upstream.js CHANGED
@@ -1,56 +1,5 @@
1
- "use strict";
2
1
  // SPDX-License-Identifier: Apache-2.0
3
2
  // SPDX-FileCopyrightText: 2023-Present The Kubernetes Fluent Client Authors
4
- Object.defineProperty(exports, "__esModule", { value: true });
5
- exports.GenericKind = exports.VolumeAttachment = exports.ValidatingWebhookConfiguration = exports.TokenReview = exports.SubjectAccessReview = exports.StorageClass = exports.StatefulSet = exports.ServiceAccount = exports.Service = exports.SelfSubjectRulesReview = exports.SelfSubjectAccessReview = exports.Secret = exports.RuntimeClass = exports.RoleBinding = exports.Role = exports.ResourceQuota = exports.ReplicationController = exports.ReplicaSet = exports.PodTemplate = exports.PodDisruptionBudget = exports.Pod = exports.PersistentVolumeClaim = exports.PersistentVolume = exports.Node = exports.NetworkPolicy = exports.Namespace = exports.MutatingWebhookConfiguration = exports.LocalSubjectAccessReview = exports.LimitRange = exports.Job = exports.IngressClass = exports.Ingress = exports.HorizontalPodAutoscaler = exports.Endpoints = exports.EndpointSlice = exports.Deployment = exports.DaemonSet = exports.CustomResourceDefinition = exports.CronJob = exports.ControllerRevision = exports.ConfigMap = exports.ClusterRoleBinding = exports.ClusterRole = exports.CertificateSigningRequest = exports.CSIDriver = exports.APIService = exports.Event = exports.CoreEvent = void 0;
6
3
  /** a is a collection of K8s types to be used within an action: `When(a.Configmap)` */
7
- var client_node_1 = require("@kubernetes/client-node");
8
- Object.defineProperty(exports, "CoreEvent", { enumerable: true, get: function () { return client_node_1.CoreV1Event; } });
9
- Object.defineProperty(exports, "Event", { enumerable: true, get: function () { return client_node_1.EventsV1Event; } });
10
- Object.defineProperty(exports, "APIService", { enumerable: true, get: function () { return client_node_1.V1APIService; } });
11
- Object.defineProperty(exports, "CSIDriver", { enumerable: true, get: function () { return client_node_1.V1CSIDriver; } });
12
- Object.defineProperty(exports, "CertificateSigningRequest", { enumerable: true, get: function () { return client_node_1.V1CertificateSigningRequest; } });
13
- Object.defineProperty(exports, "ClusterRole", { enumerable: true, get: function () { return client_node_1.V1ClusterRole; } });
14
- Object.defineProperty(exports, "ClusterRoleBinding", { enumerable: true, get: function () { return client_node_1.V1ClusterRoleBinding; } });
15
- Object.defineProperty(exports, "ConfigMap", { enumerable: true, get: function () { return client_node_1.V1ConfigMap; } });
16
- Object.defineProperty(exports, "ControllerRevision", { enumerable: true, get: function () { return client_node_1.V1ControllerRevision; } });
17
- Object.defineProperty(exports, "CronJob", { enumerable: true, get: function () { return client_node_1.V1CronJob; } });
18
- Object.defineProperty(exports, "CustomResourceDefinition", { enumerable: true, get: function () { return client_node_1.V1CustomResourceDefinition; } });
19
- Object.defineProperty(exports, "DaemonSet", { enumerable: true, get: function () { return client_node_1.V1DaemonSet; } });
20
- Object.defineProperty(exports, "Deployment", { enumerable: true, get: function () { return client_node_1.V1Deployment; } });
21
- Object.defineProperty(exports, "EndpointSlice", { enumerable: true, get: function () { return client_node_1.V1EndpointSlice; } });
22
- Object.defineProperty(exports, "Endpoints", { enumerable: true, get: function () { return client_node_1.V1Endpoints; } });
23
- Object.defineProperty(exports, "HorizontalPodAutoscaler", { enumerable: true, get: function () { return client_node_1.V1HorizontalPodAutoscaler; } });
24
- Object.defineProperty(exports, "Ingress", { enumerable: true, get: function () { return client_node_1.V1Ingress; } });
25
- Object.defineProperty(exports, "IngressClass", { enumerable: true, get: function () { return client_node_1.V1IngressClass; } });
26
- Object.defineProperty(exports, "Job", { enumerable: true, get: function () { return client_node_1.V1Job; } });
27
- Object.defineProperty(exports, "LimitRange", { enumerable: true, get: function () { return client_node_1.V1LimitRange; } });
28
- Object.defineProperty(exports, "LocalSubjectAccessReview", { enumerable: true, get: function () { return client_node_1.V1LocalSubjectAccessReview; } });
29
- Object.defineProperty(exports, "MutatingWebhookConfiguration", { enumerable: true, get: function () { return client_node_1.V1MutatingWebhookConfiguration; } });
30
- Object.defineProperty(exports, "Namespace", { enumerable: true, get: function () { return client_node_1.V1Namespace; } });
31
- Object.defineProperty(exports, "NetworkPolicy", { enumerable: true, get: function () { return client_node_1.V1NetworkPolicy; } });
32
- Object.defineProperty(exports, "Node", { enumerable: true, get: function () { return client_node_1.V1Node; } });
33
- Object.defineProperty(exports, "PersistentVolume", { enumerable: true, get: function () { return client_node_1.V1PersistentVolume; } });
34
- Object.defineProperty(exports, "PersistentVolumeClaim", { enumerable: true, get: function () { return client_node_1.V1PersistentVolumeClaim; } });
35
- Object.defineProperty(exports, "Pod", { enumerable: true, get: function () { return client_node_1.V1Pod; } });
36
- Object.defineProperty(exports, "PodDisruptionBudget", { enumerable: true, get: function () { return client_node_1.V1PodDisruptionBudget; } });
37
- Object.defineProperty(exports, "PodTemplate", { enumerable: true, get: function () { return client_node_1.V1PodTemplate; } });
38
- Object.defineProperty(exports, "ReplicaSet", { enumerable: true, get: function () { return client_node_1.V1ReplicaSet; } });
39
- Object.defineProperty(exports, "ReplicationController", { enumerable: true, get: function () { return client_node_1.V1ReplicationController; } });
40
- Object.defineProperty(exports, "ResourceQuota", { enumerable: true, get: function () { return client_node_1.V1ResourceQuota; } });
41
- Object.defineProperty(exports, "Role", { enumerable: true, get: function () { return client_node_1.V1Role; } });
42
- Object.defineProperty(exports, "RoleBinding", { enumerable: true, get: function () { return client_node_1.V1RoleBinding; } });
43
- Object.defineProperty(exports, "RuntimeClass", { enumerable: true, get: function () { return client_node_1.V1RuntimeClass; } });
44
- Object.defineProperty(exports, "Secret", { enumerable: true, get: function () { return client_node_1.V1Secret; } });
45
- Object.defineProperty(exports, "SelfSubjectAccessReview", { enumerable: true, get: function () { return client_node_1.V1SelfSubjectAccessReview; } });
46
- Object.defineProperty(exports, "SelfSubjectRulesReview", { enumerable: true, get: function () { return client_node_1.V1SelfSubjectRulesReview; } });
47
- Object.defineProperty(exports, "Service", { enumerable: true, get: function () { return client_node_1.V1Service; } });
48
- Object.defineProperty(exports, "ServiceAccount", { enumerable: true, get: function () { return client_node_1.V1ServiceAccount; } });
49
- Object.defineProperty(exports, "StatefulSet", { enumerable: true, get: function () { return client_node_1.V1StatefulSet; } });
50
- Object.defineProperty(exports, "StorageClass", { enumerable: true, get: function () { return client_node_1.V1StorageClass; } });
51
- Object.defineProperty(exports, "SubjectAccessReview", { enumerable: true, get: function () { return client_node_1.V1SubjectAccessReview; } });
52
- Object.defineProperty(exports, "TokenReview", { enumerable: true, get: function () { return client_node_1.V1TokenReview; } });
53
- Object.defineProperty(exports, "ValidatingWebhookConfiguration", { enumerable: true, get: function () { return client_node_1.V1ValidatingWebhookConfiguration; } });
54
- Object.defineProperty(exports, "VolumeAttachment", { enumerable: true, get: function () { return client_node_1.V1VolumeAttachment; } });
55
- var types_1 = require("./types");
56
- Object.defineProperty(exports, "GenericKind", { enumerable: true, get: function () { return types_1.GenericKind; } });
4
+ export { CoreV1Event as CoreEvent, EventsV1Event as Event, V1APIService as APIService, V1CSIDriver as CSIDriver, V1CertificateSigningRequest as CertificateSigningRequest, V1ClusterRole as ClusterRole, V1ClusterRoleBinding as ClusterRoleBinding, V1ConfigMap as ConfigMap, V1ControllerRevision as ControllerRevision, V1CronJob as CronJob, V1CustomResourceDefinition as CustomResourceDefinition, V1DaemonSet as DaemonSet, V1Deployment as Deployment, V1EndpointSlice as EndpointSlice, V1Endpoints as Endpoints, V1HorizontalPodAutoscaler as HorizontalPodAutoscaler, V1Ingress as Ingress, V1IngressClass as IngressClass, V1Job as Job, V1LimitRange as LimitRange, V1LocalSubjectAccessReview as LocalSubjectAccessReview, V1MutatingWebhookConfiguration as MutatingWebhookConfiguration, V1Namespace as Namespace, V1NetworkPolicy as NetworkPolicy, V1Node as Node, V1PersistentVolume as PersistentVolume, V1PersistentVolumeClaim as PersistentVolumeClaim, V1Pod as Pod, V1PodDisruptionBudget as PodDisruptionBudget, V1PodTemplate as PodTemplate, V1ReplicaSet as ReplicaSet, V1ReplicationController as ReplicationController, V1ResourceQuota as ResourceQuota, V1Role as Role, V1RoleBinding as RoleBinding, V1RuntimeClass as RuntimeClass, V1Secret as Secret, V1SelfSubjectAccessReview as SelfSubjectAccessReview, V1SelfSubjectRulesReview as SelfSubjectRulesReview, V1Service as Service, V1ServiceAccount as ServiceAccount, V1StatefulSet as StatefulSet, V1StorageClass as StorageClass, V1SubjectAccessReview as SubjectAccessReview, V1TokenReview as TokenReview, V1ValidatingWebhookConfiguration as ValidatingWebhookConfiguration, V1VolumeAttachment as VolumeAttachment, } from "@kubernetes/client-node";
5
+ export { GenericKind } from "./types";
package/package.json CHANGED
@@ -1,10 +1,11 @@
1
1
  {
2
2
  "name": "kubernetes-fluent-client",
3
- "version": "3.5.6",
3
+ "version": "3.6.0",
4
4
  "description": "A @kubernetes/client-node fluent API wrapper that leverages K8s Server Side Apply.",
5
5
  "bin": "./dist/cli.js",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",
8
+ "type": "module",
8
9
  "engines": {
9
10
  "node": ">=20.0.0"
10
11
  },
@@ -38,7 +39,7 @@
38
39
  "build": "tsc",
39
40
  "semantic-release": "semantic-release",
40
41
  "test": "jest src --coverage",
41
- "test:e2e": "jest e2e --runInBand",
42
+ "test:e2e": "npx vitest run e2e/",
42
43
  "test:e2e:prep-crds": "kubectl apply -f test/ && npx ts-node src/cli.ts crd ./test/datastore.crd.yaml e2e && npx ts-node src/cli.ts crd https://raw.githubusercontent.com/defenseunicorns/kubernetes-fluent-client/refs/heads/main/test/webapp.crd.yaml e2e",
43
44
  "test:e2e:prep-cluster": "k3d cluster create kfc-dev --k3s-arg '--debug@server:0' --wait && kubectl rollout status deployment -n kube-system",
44
45
  "test:e2e:prep-image": "npm run build && npm pack && npm i kubernetes-fluent-client-0.0.0-development.tgz --no-save",
@@ -49,7 +50,7 @@
49
50
  "prepare": "if [ \"$NODE_ENV\" != 'production' ]; then husky; fi"
50
51
  },
51
52
  "dependencies": {
52
- "@kubernetes/client-node": "1.0.0-rc7",
53
+ "@kubernetes/client-node": "1.3.0",
53
54
  "fast-json-patch": "3.1.1",
54
55
  "http-status-codes": "2.3.0",
55
56
  "node-fetch": "2.7.0",
@@ -65,12 +66,13 @@
65
66
  "@eslint/js": "^9.14.0",
66
67
  "@jest/globals": "29.7.0",
67
68
  "@types/byline": "4.2.36",
68
- "@types/readable-stream": "4.0.20",
69
+ "@types/readable-stream": "4.0.21",
69
70
  "@types/urijs": "^1.19.25",
71
+ "@types/ws": "^8.18.1",
70
72
  "@types/yargs": "17.0.33",
71
- "@typescript-eslint/eslint-plugin": "8.33.0",
72
- "@typescript-eslint/parser": "8.33.0",
73
- "eslint-plugin-jsdoc": "50.6.17",
73
+ "@typescript-eslint/eslint-plugin": "8.33.1",
74
+ "@typescript-eslint/parser": "8.33.1",
75
+ "eslint-plugin-jsdoc": "50.7.1",
74
76
  "globals": "^16.0.0",
75
77
  "husky": "^9.1.6",
76
78
  "jest": "29.7.0",
@@ -78,7 +80,8 @@
78
80
  "prettier": "3.5.3",
79
81
  "semantic-release": "24.2.5",
80
82
  "ts-jest": "29.3.4",
81
- "typescript": "5.8.3"
83
+ "typescript": "5.8.3",
84
+ "vitest": "^3.2.1"
82
85
  },
83
86
  "overrides": {
84
87
  "semantic-release@24.2.0": {
package/src/cli.ts CHANGED
@@ -8,7 +8,6 @@ import yargs from "yargs/yargs";
8
8
  import { GenerateOptions, generate } from "./generate";
9
9
  import { version } from "../package.json";
10
10
  import { postProcessing } from "./postProcessing";
11
- import { NodeFileSystem } from "./fileSystem"; // Import your new file system
12
11
 
13
12
  void yargs(hideBin(process.argv))
14
13
  .version("version", "Display version number", `kubernetes-fluent-client v${version}`)
@@ -55,7 +54,6 @@ void yargs(hideBin(process.argv))
55
54
  opts.noPost = argv.noPost as boolean;
56
55
 
57
56
  // Use NodeFileSystem as the file system for post-processing
58
- const fileSystem = new NodeFileSystem(); // Create an instance of NodeFileSystem
59
57
 
60
58
  if (!opts.noPost) {
61
59
  console.log("\n✅ Post-processing has been enabled.\n");
@@ -67,7 +65,7 @@ void yargs(hideBin(process.argv))
67
65
 
68
66
  // If noPost is false, run post-processing
69
67
  if (!opts.noPost) {
70
- await postProcessing(allResults, opts, fileSystem); // Pass the file system to postProcessing
68
+ await postProcessing(allResults, opts); // Pass the file system to postProcessing
71
69
  }
72
70
  } catch (e) {
73
71
  console.log(`\n❌ ${e.message}`);