kubernetes-fluent-client 3.5.6 → 3.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. package/dist/cli.js +11 -16
  2. package/dist/fetch.js +5 -8
  3. package/dist/fluent/index.d.ts +3 -2
  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 +3 -38
  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 +2 -2
  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 +2 -9
  16. package/dist/fluent/watch.d.ts.map +1 -1
  17. package/dist/fluent/watch.js +23 -43
  18. package/dist/generate.d.ts +2 -2
  19. package/dist/generate.d.ts.map +1 -1
  20. package/dist/generate.js +22 -65
  21. package/dist/helpers.js +5 -10
  22. package/dist/index.d.ts +10 -10
  23. package/dist/index.d.ts.map +1 -1
  24. package/dist/index.js +13 -60
  25. package/dist/kinds.d.ts +1 -1
  26. package/dist/kinds.d.ts.map +1 -1
  27. package/dist/kinds.js +2 -7
  28. package/dist/normalization.d.ts +97 -0
  29. package/dist/normalization.d.ts.map +1 -0
  30. package/dist/normalization.js +152 -0
  31. package/dist/patch.js +1 -2
  32. package/dist/postProcessing.d.ts +8 -129
  33. package/dist/postProcessing.d.ts.map +1 -1
  34. package/dist/postProcessing.js +29 -280
  35. package/dist/types.d.ts +3 -2
  36. package/dist/types.d.ts.map +1 -1
  37. package/dist/types.js +1 -5
  38. package/dist/upstream.d.ts +1 -1
  39. package/dist/upstream.d.ts.map +1 -1
  40. package/dist/upstream.js +2 -53
  41. package/package.json +15 -14
  42. package/src/cli.ts +6 -6
  43. package/src/fluent/index.ts +19 -18
  44. package/src/fluent/shared-types.ts +55 -0
  45. package/src/fluent/types.ts +4 -55
  46. package/src/fluent/utils.ts +5 -5
  47. package/src/fluent/watch.ts +11 -24
  48. package/src/generate.ts +4 -4
  49. package/src/index.ts +10 -10
  50. package/src/kinds.ts +1 -1
  51. package/src/normalization.ts +181 -0
  52. package/src/postProcessing.ts +27 -244
  53. package/src/types.ts +3 -4
  54. package/src/upstream.ts +1 -1
  55. package/dist/fileSystem.d.ts +0 -11
  56. package/dist/fileSystem.d.ts.map +0 -1
  57. package/dist/fileSystem.js +0 -52
  58. package/src/fileSystem.ts +0 -25
@@ -3,10 +3,13 @@
3
3
 
4
4
  import * as fs from "fs";
5
5
  import * as path from "path";
6
- import { GenerateOptions } from "./generate";
7
- import { GenericKind } from "./types";
8
- import { CustomResourceDefinition } from "./upstream";
9
- import { FileSystem, NodeFileSystem } from "./fileSystem";
6
+ import { GenerateOptions } from "./generate.js";
7
+ import { GenericKind } from "./types.js";
8
+ import { CustomResourceDefinition } from "./upstream.js";
9
+ import {
10
+ modifyAndNormalizeClassProperties,
11
+ normalizeIndentationAndSpacing,
12
+ } from "./normalization.js";
10
13
 
11
14
  type CRDResult = {
12
15
  name: string;
@@ -14,8 +17,6 @@ type CRDResult = {
14
17
  version: string;
15
18
  };
16
19
 
17
- type CodeLines = string[];
18
-
19
20
  type ClassContextResult = { line: string; insideClass: boolean; braceBalance: number };
20
21
 
21
22
  const genericKindProperties = getGenericKindProperties();
@@ -25,23 +26,18 @@ const genericKindProperties = getGenericKindProperties();
25
26
  *
26
27
  * @param allResults The array of CRD results.
27
28
  * @param opts The options for post-processing.
28
- * @param fileSystem The file system interface for reading and writing files.
29
29
  */
30
- export async function postProcessing(
31
- allResults: CRDResult[],
32
- opts: GenerateOptions,
33
- fileSystem: FileSystem = new NodeFileSystem(),
34
- ) {
30
+ export async function postProcessing(allResults: CRDResult[], opts: GenerateOptions) {
35
31
  if (!opts.directory) {
36
32
  opts.logFn("⚠️ Error: Directory is not defined.");
37
33
  return;
38
34
  }
39
35
 
40
- const files = fileSystem.readdirSync(opts.directory);
36
+ const files = fs.readdirSync(opts.directory);
41
37
  opts.logFn("\n🔧 Post-processing started...");
42
38
 
43
39
  const fileResultMap = mapFilesToCRD(allResults);
44
- await processFiles(files, fileResultMap, opts, fileSystem);
40
+ await processFiles(files, fileResultMap, opts);
45
41
 
46
42
  opts.logFn("🔧 Post-processing completed.\n");
47
43
  }
@@ -73,13 +69,11 @@ export function mapFilesToCRD(allResults: CRDResult[]): Record<string, CRDResult
73
69
  * @param files - The list of file names to process.
74
70
  * @param fileResultMap - A map linking file names to their corresponding CRD results.
75
71
  * @param opts - Options for the generation process.
76
- * @param fileSystem - The file system interface for reading and writing files.
77
72
  */
78
73
  export async function processFiles(
79
74
  files: string[],
80
75
  fileResultMap: Record<string, CRDResult>,
81
76
  opts: GenerateOptions,
82
- fileSystem: FileSystem,
83
77
  ) {
84
78
  for (const file of files) {
85
79
  if (!opts.directory) {
@@ -94,7 +88,7 @@ export async function processFiles(
94
88
  }
95
89
 
96
90
  try {
97
- processAndModifySingleFile(filePath, fileResult, opts, fileSystem);
91
+ processAndModifySingleFile(filePath, fileResult, opts);
98
92
  } catch (error) {
99
93
  logError(error, filePath, opts.logFn);
100
94
  }
@@ -110,20 +104,18 @@ export async function processFiles(
110
104
  * @param fileResult.crd - The CustomResourceDefinition object.
111
105
  * @param fileResult.version - The version of the CRD.
112
106
  * @param opts - Options for the generation process.
113
- * @param fileSystem - The file system interface for reading and writing files.
114
107
  */
115
108
  export function processAndModifySingleFile(
116
109
  filePath: string,
117
110
  fileResult: CRDResult,
118
111
  opts: GenerateOptions,
119
- fileSystem: FileSystem,
120
112
  ) {
121
113
  opts.logFn(`🔍 Processing file: ${filePath}`);
122
114
  const { name, crd, version } = fileResult;
123
115
 
124
116
  let fileContent;
125
117
  try {
126
- fileContent = fileSystem.readFile(filePath);
118
+ fileContent = fs.readFileSync(filePath, "utf8");
127
119
  } catch (error) {
128
120
  logError(error, filePath, opts.logFn);
129
121
  return;
@@ -138,7 +130,7 @@ export function processAndModifySingleFile(
138
130
  }
139
131
 
140
132
  try {
141
- fileSystem.writeFile(filePath, modifiedContent);
133
+ fs.writeFileSync(filePath, modifiedContent);
142
134
  opts.logFn(`✅ Successfully processed and wrote file: ${filePath}`);
143
135
  } catch (error) {
144
136
  logError(error, filePath, opts.logFn);
@@ -166,7 +158,7 @@ export function applyCRDPostProcessing(
166
158
  let lines = content.split("\n");
167
159
 
168
160
  // Wraps with the fluent client if needed
169
- if (shouldWrapWithFluentClient(opts)) {
161
+ if (opts.language === "ts" && !opts.plain) {
170
162
  lines = wrapWithFluentClient(lines, name, crd, version, opts.npmPackage);
171
163
  }
172
164
  const foundInterfaces = collectInterfaceNames(lines);
@@ -183,42 +175,22 @@ export function applyCRDPostProcessing(
183
175
  }
184
176
  }
185
177
 
186
- /**
187
- * Reads the content of a file from disk.
188
- *
189
- * @param filePath The path to the file.
190
- * @returns The file contents as a string.
191
- */
192
- export function readFile(filePath: string): string {
193
- try {
194
- return fs.readFileSync(filePath, "utf8");
195
- } catch (error) {
196
- throw new Error(`Failed to read file at ${filePath}: ${error.message}`);
197
- }
198
- }
199
-
200
- /**
201
- * Writes the modified content back to the file.
202
- *
203
- * @param filePath The path to the file.
204
- * @param content The modified content to write.
205
- */
206
- export function writeFile(filePath: string, content: string): void {
207
- try {
208
- fs.writeFileSync(filePath, content, "utf8");
209
- } catch (error) {
210
- throw new Error(`Failed to write file at ${filePath}: ${error.message}`);
211
- }
212
- }
213
-
214
178
  /**
215
179
  * Retrieves the properties of the `GenericKind` class, excluding dynamic properties like `[key: string]: any`.
216
180
  *
217
181
  * @returns An array of property names that belong to `GenericKind`.
218
182
  */
219
183
  export function getGenericKindProperties(): string[] {
220
- const properties = Object.getOwnPropertyNames(new GenericKind());
221
- return properties.filter(prop => prop !== "[key: string]");
184
+ // Ensure we always include standard Kubernetes resource properties
185
+ const standardProperties = ["kind", "apiVersion", "metadata"];
186
+
187
+ // Get actual properties from GenericKind
188
+ const instanceProperties = Object.getOwnPropertyNames(new GenericKind()).filter(
189
+ prop => prop !== "[key: string]",
190
+ );
191
+
192
+ // Combine both sets of properties, removing duplicates
193
+ return Array.from(new Set([...standardProperties, ...instanceProperties]));
222
194
  }
223
195
 
224
196
  /**
@@ -227,7 +199,7 @@ export function getGenericKindProperties(): string[] {
227
199
  * @param lines The lines of the file content.
228
200
  * @returns A set of found interface names.
229
201
  */
230
- export function collectInterfaceNames(lines: CodeLines): Set<string> {
202
+ export function collectInterfaceNames(lines: string[]): Set<string> {
231
203
  // https://regex101.com/r/S6w8pW/1
232
204
  const interfacePattern = /export interface (?<interfaceName>\w+)/;
233
205
  const foundInterfaces = new Set<string>();
@@ -263,109 +235,6 @@ export function updateBraceBalance(line: string, braceBalance: number): number {
263
235
  return braceBalance + (line.includes("{") ? 1 : 0) - (line.includes("}") ? 1 : 0);
264
236
  }
265
237
 
266
- /**
267
- * Generates a regular expression to match a property pattern in TypeScript.
268
- *
269
- * @param prop The property name to match.
270
- * @returns A regular expression to match the property pattern.
271
- */
272
- export function getPropertyPattern(prop: string): RegExp {
273
- // For prop="kind", the pattern will match "kind ? :" or "kind :"
274
- // https://regex101.com/r/mF8kXn/1
275
- return new RegExp(`\\b${prop}\\b\\s*\\?\\s*:|\\b${prop}\\b\\s*:`);
276
- }
277
-
278
- /**
279
- * Applies ESLint and property modifiers to a line of code.
280
- *
281
- * @param line - The current line of code.
282
- * @param genericKindProperties - The list of properties from `GenericKind`.
283
- * @param foundInterfaces - The set of found interfaces in the file.
284
- * @returns The modified line.
285
- */
286
- export function modifyPropertiesAndAddEslintDirective(
287
- line: string,
288
- genericKindProperties: string[],
289
- foundInterfaces: Set<string>,
290
- ): string {
291
- line = addDeclareAndOptionalModifiersToProperties(line, genericKindProperties, foundInterfaces);
292
- line = processEslintDisable(line, genericKindProperties);
293
- return line;
294
- }
295
-
296
- /**
297
- * Applies property modifiers to a line of code.
298
- *
299
- * @param line The current line of code.
300
- * @param genericKindProperties The list of properties from `GenericKind`.
301
- * @param foundInterfaces The set of found interfaces in the file.
302
- * @returns The modified line.
303
- */
304
- export function addDeclareAndOptionalModifiersToProperties(
305
- line: string,
306
- genericKindProperties: string[],
307
- foundInterfaces: Set<string>,
308
- ): string {
309
- line = addDeclareToGenericKindProperties(line, genericKindProperties);
310
- line = makePropertiesOptional(line, foundInterfaces);
311
- line = normalizeLineIndentation(line);
312
- return line;
313
- }
314
- /**
315
- * Adds the `declare` keyword to `GenericKind` properties.
316
- *
317
- * @param line The current line of code.
318
- * @param genericKindProperties The list of properties from `GenericKind`.
319
- * @returns The modified line with the `declare` keyword, if applicable.
320
- */
321
- export function addDeclareToGenericKindProperties(
322
- line: string,
323
- genericKindProperties: string[],
324
- ): string {
325
- for (const prop of genericKindProperties) {
326
- const propertyPattern = getPropertyPattern(prop);
327
- if (propertyPattern.test(line)) {
328
- return line.replace(prop, `declare ${prop}`);
329
- }
330
- }
331
- return line;
332
- }
333
-
334
- /**
335
- * Makes a property optional if its type matches one of the found interfaces and it is not already optional.
336
- *
337
- * @param line The current line of code.
338
- * @param foundInterfaces The set of found interfaces in the file.
339
- * @returns The modified line with the optional `?` symbol.
340
- */
341
- export function makePropertiesOptional(line: string, foundInterfaces: Set<string>): string {
342
- // https://regex101.com/r/kX8TCj/1
343
- const propertyTypePattern = /:\s*(?<propertyType>\w+)\s*;/;
344
- const match = line.match(propertyTypePattern);
345
-
346
- if (match?.groups?.propertyType) {
347
- const { propertyType } = match.groups;
348
- if (foundInterfaces.has(propertyType) && !line.includes("?")) {
349
- return line.replace(":", "?:");
350
- }
351
- }
352
- return line;
353
- }
354
-
355
- /**
356
- * Adds an ESLint disable comment for `[key: string]: any` if it's not part of `GenericKind`.
357
- *
358
- * @param line The current line of code.
359
- * @param genericKindProperties The list of properties from `GenericKind`.
360
- * @returns The modified line with the ESLint disable comment.
361
- */
362
- export function processEslintDisable(line: string, genericKindProperties: string[]): string {
363
- if (line.includes("[key: string]: any") && !genericKindProperties.includes("[key: string]")) {
364
- return ` // eslint-disable-next-line @typescript-eslint/no-explicit-any\n${line}`;
365
- }
366
- return line;
367
- }
368
-
369
238
  /**
370
239
  * Wraps the generated TypeScript file with fluent client elements (`GenericKind` and `RegisterKind`).
371
240
  *
@@ -377,7 +246,7 @@ export function processEslintDisable(line: string, genericKindProperties: string
377
246
  * @returns The processed TypeScript lines.
378
247
  */
379
248
  export function wrapWithFluentClient(
380
- lines: CodeLines,
249
+ lines: string[],
381
250
  name: string,
382
251
  crd: CustomResourceDefinition,
383
252
  version: string,
@@ -404,61 +273,6 @@ export function wrapWithFluentClient(
404
273
  return lines;
405
274
  }
406
275
 
407
- /**
408
- * Normalizes indentation for TypeScript lines to a consistent format.
409
- *
410
- * @param lines The generated TypeScript lines.
411
- * @returns The lines with normalized indentation.
412
- */
413
- export function normalizeIndentation(lines: CodeLines): string[] {
414
- return lines.map(line => line.replace(/^ {4}/, " "));
415
- }
416
-
417
- /**
418
- * Normalizes the indentation of a single line to use two spaces instead of four.
419
- *
420
- * @param line The line of code to normalize.
421
- * @returns The line with normalized indentation.
422
- */
423
- export function normalizeLineIndentation(line: string): string {
424
- return line.replace(/^ {4}/, " ");
425
- }
426
-
427
- /**
428
- * Normalizes spacing between property names and types in TypeScript lines.
429
- *
430
- * @param lines The generated TypeScript lines.
431
- * @returns The lines with normalized property spacing.
432
- */
433
- export function normalizePropertySpacing(lines: CodeLines): string[] {
434
- // https://regex101.com/r/XEv3pL/1
435
- return lines.map(line => line.replace(/\s*\?\s*:\s*/, "?: "));
436
- }
437
-
438
- /**
439
- * Removes lines containing `[property: string]: any;` from TypeScript files.
440
- *
441
- * @param lines The generated TypeScript lines.
442
- * @param opts The options for processing.
443
- * @returns The lines with `[property: string]: any;` removed.
444
- */
445
- export function removePropertyStringAny(lines: CodeLines, opts: GenerateOptions): string[] {
446
- if (opts.language === "ts" || opts.language === "typescript") {
447
- return lines.filter(line => !line.includes("[property: string]: any;"));
448
- }
449
- return lines;
450
- }
451
-
452
- /**
453
- * Determines if the content should be wrapped with the fluent client.
454
- *
455
- * @param opts The options for generating the content.
456
- * @returns True if the content should be wrapped with the fluent client, false otherwise.
457
- */
458
- export function shouldWrapWithFluentClient(opts: GenerateOptions): boolean {
459
- return opts.language === "ts" && !opts.plain;
460
- }
461
-
462
276
  /**
463
277
  * Processes the lines of the TypeScript file, focusing on classes extending `GenericKind`.
464
278
  *
@@ -468,7 +282,7 @@ export function shouldWrapWithFluentClient(opts: GenerateOptions): boolean {
468
282
  * @returns The processed lines.
469
283
  */
470
284
  export function processLines(
471
- lines: CodeLines,
285
+ lines: string[],
472
286
  genericKindProperties: string[],
473
287
  foundInterfaces: Set<string>,
474
288
  ): string[] {
@@ -524,37 +338,6 @@ export function processClassContext(
524
338
  return { line, insideClass, braceBalance };
525
339
  }
526
340
 
527
- /**
528
- * Processes a single line inside a class extending `GenericKind`.
529
- *
530
- * @param line The current line of code.
531
- * @param genericKindProperties The list of properties from `GenericKind`.
532
- * @param foundInterfaces The set of found interfaces in the file.
533
- * @returns The modified line.
534
- */
535
- export function modifyAndNormalizeClassProperties(
536
- line: string,
537
- genericKindProperties: string[],
538
- foundInterfaces: Set<string>,
539
- ): string {
540
- line = modifyPropertiesAndAddEslintDirective(line, genericKindProperties, foundInterfaces);
541
- line = normalizeLineIndentation(line);
542
- return line;
543
- }
544
-
545
- /**
546
- * Normalizes lines after processing, including indentation, spacing, and removing unnecessary lines.
547
- *
548
- * @param lines The lines of the file content.
549
- * @param opts The options for processing.
550
- * @returns The normalized lines.
551
- */
552
- export function normalizeIndentationAndSpacing(lines: CodeLines, opts: GenerateOptions): string[] {
553
- let normalizedLines = normalizeIndentation(lines);
554
- normalizedLines = normalizePropertySpacing(normalizedLines);
555
- return removePropertyStringAny(normalizedLines, opts);
556
- }
557
-
558
341
  /**
559
342
  * Handles logging for errors with stack trace.
560
343
  *
package/src/types.ts CHANGED
@@ -1,10 +1,9 @@
1
1
  // SPDX-License-Identifier: Apache-2.0
2
2
  // SPDX-FileCopyrightText: 2023-Present The Kubernetes Fluent Client Authors
3
3
 
4
- import { KubernetesObject, V1ObjectMeta } from "@kubernetes/client-node";
5
-
6
- export { KubernetesObject, KubernetesListObject } from "@kubernetes/client-node";
7
-
4
+ import { V1ObjectMeta } from "@kubernetes/client-node";
5
+ import type { KubernetesListObject, KubernetesObject } from "@kubernetes/client-node";
6
+ export type { KubernetesListObject, KubernetesObject };
8
7
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
9
8
  export type GenericClass = abstract new () => any;
10
9
 
package/src/upstream.ts CHANGED
@@ -51,4 +51,4 @@ export {
51
51
  V1ValidatingWebhookConfiguration as ValidatingWebhookConfiguration,
52
52
  V1VolumeAttachment as VolumeAttachment,
53
53
  } from "@kubernetes/client-node";
54
- export { GenericKind } from "./types";
54
+ export { GenericKind } from "./types.js";
@@ -1,11 +0,0 @@
1
- export interface FileSystem {
2
- readFile(filePath: string): string;
3
- writeFile(filePath: string, content: string): void;
4
- readdirSync(directory: string): string[];
5
- }
6
- export declare class NodeFileSystem implements FileSystem {
7
- readFile(filePath: string): string;
8
- writeFile(filePath: string, content: string): void;
9
- readdirSync(directory: string): string[];
10
- }
11
- //# sourceMappingURL=fileSystem.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"fileSystem.d.ts","sourceRoot":"","sources":["../src/fileSystem.ts"],"names":[],"mappings":"AAKA,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAAC;IACnC,SAAS,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACnD,WAAW,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;CAC1C;AAGD,qBAAa,cAAe,YAAW,UAAU;IAC/C,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM;IAIlC,SAAS,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI;IAIlD,WAAW,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,EAAE;CAGzC"}
@@ -1,52 +0,0 @@
1
- "use strict";
2
- // SPDX-License-Identifier: Apache-2.0
3
- // 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.NodeFileSystem = void 0;
39
- const fs = __importStar(require("fs"));
40
- /* eslint class-methods-use-this: "off" */
41
- class NodeFileSystem {
42
- readFile(filePath) {
43
- return fs.readFileSync(filePath, "utf8");
44
- }
45
- writeFile(filePath, content) {
46
- fs.writeFileSync(filePath, content, "utf8");
47
- }
48
- readdirSync(directory) {
49
- return fs.readdirSync(directory);
50
- }
51
- }
52
- exports.NodeFileSystem = NodeFileSystem;
package/src/fileSystem.ts DELETED
@@ -1,25 +0,0 @@
1
- // SPDX-License-Identifier: Apache-2.0
2
- // SPDX-FileCopyrightText: 2023-Present The Kubernetes Fluent Client Authors
3
-
4
- import * as fs from "fs";
5
-
6
- export interface FileSystem {
7
- readFile(filePath: string): string;
8
- writeFile(filePath: string, content: string): void;
9
- readdirSync(directory: string): string[];
10
- }
11
-
12
- /* eslint class-methods-use-this: "off" */
13
- export class NodeFileSystem implements FileSystem {
14
- readFile(filePath: string): string {
15
- return fs.readFileSync(filePath, "utf8");
16
- }
17
-
18
- writeFile(filePath: string, content: string): void {
19
- fs.writeFileSync(filePath, content, "utf8");
20
- }
21
-
22
- readdirSync(directory: string): string[] {
23
- return fs.readdirSync(directory);
24
- }
25
- }