@storm-software/k8s-tools 0.1.0 → 0.2.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/index.js CHANGED
@@ -4,9 +4,6 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
5
5
  var __getProtoOf = Object.getPrototypeOf;
6
6
  var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __commonJS = (cb, mod) => function __require() {
8
- return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
9
- };
10
7
  var __export = (target, all) => {
11
8
  for (var name in all)
12
9
  __defProp(target, name, { get: all[name], enumerable: true });
@@ -37,1025 +34,11 @@ var __decorateClass = (decorators, target, key, kind) => {
37
34
  return result;
38
35
  };
39
36
 
40
- // node_modules/.pnpm/@actions+io@1.1.3/node_modules/@actions/io/lib/io-util.js
41
- var require_io_util = __commonJS({
42
- "node_modules/.pnpm/@actions+io@1.1.3/node_modules/@actions/io/lib/io-util.js"(exports2) {
43
- "use strict";
44
- var __createBinding = exports2 && exports2.__createBinding || (Object.create ? function(o, m, k, k2) {
45
- if (k2 === void 0) k2 = k;
46
- Object.defineProperty(o, k2, { enumerable: true, get: function() {
47
- return m[k];
48
- } });
49
- } : function(o, m, k, k2) {
50
- if (k2 === void 0) k2 = k;
51
- o[k2] = m[k];
52
- });
53
- var __setModuleDefault = exports2 && exports2.__setModuleDefault || (Object.create ? function(o, v) {
54
- Object.defineProperty(o, "default", { enumerable: true, value: v });
55
- } : function(o, v) {
56
- o["default"] = v;
57
- });
58
- var __importStar = exports2 && exports2.__importStar || function(mod) {
59
- if (mod && mod.__esModule) return mod;
60
- var result = {};
61
- if (mod != null) {
62
- for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
63
- }
64
- __setModuleDefault(result, mod);
65
- return result;
66
- };
67
- var __awaiter = exports2 && exports2.__awaiter || function(thisArg, _arguments, P, generator) {
68
- function adopt(value) {
69
- return value instanceof P ? value : new P(function(resolve) {
70
- resolve(value);
71
- });
72
- }
73
- return new (P || (P = Promise))(function(resolve, reject) {
74
- function fulfilled(value) {
75
- try {
76
- step(generator.next(value));
77
- } catch (e) {
78
- reject(e);
79
- }
80
- }
81
- function rejected(value) {
82
- try {
83
- step(generator["throw"](value));
84
- } catch (e) {
85
- reject(e);
86
- }
87
- }
88
- function step(result) {
89
- result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
90
- }
91
- step((generator = generator.apply(thisArg, _arguments || [])).next());
92
- });
93
- };
94
- var _a;
95
- Object.defineProperty(exports2, "__esModule", { value: true });
96
- exports2.getCmdPath = exports2.tryGetExecutablePath = exports2.isRooted = exports2.isDirectory = exports2.exists = exports2.READONLY = exports2.UV_FS_O_EXLOCK = exports2.IS_WINDOWS = exports2.unlink = exports2.symlink = exports2.stat = exports2.rmdir = exports2.rm = exports2.rename = exports2.readlink = exports2.readdir = exports2.open = exports2.mkdir = exports2.lstat = exports2.copyFile = exports2.chmod = void 0;
97
- var fs = __importStar(require("fs"));
98
- var path = __importStar(require("path"));
99
- _a = fs.promises, exports2.chmod = _a.chmod, exports2.copyFile = _a.copyFile, exports2.lstat = _a.lstat, exports2.mkdir = _a.mkdir, exports2.open = _a.open, exports2.readdir = _a.readdir, exports2.readlink = _a.readlink, exports2.rename = _a.rename, exports2.rm = _a.rm, exports2.rmdir = _a.rmdir, exports2.stat = _a.stat, exports2.symlink = _a.symlink, exports2.unlink = _a.unlink;
100
- exports2.IS_WINDOWS = process.platform === "win32";
101
- exports2.UV_FS_O_EXLOCK = 268435456;
102
- exports2.READONLY = fs.constants.O_RDONLY;
103
- function exists(fsPath) {
104
- return __awaiter(this, void 0, void 0, function* () {
105
- try {
106
- yield exports2.stat(fsPath);
107
- } catch (err) {
108
- if (err.code === "ENOENT") {
109
- return false;
110
- }
111
- throw err;
112
- }
113
- return true;
114
- });
115
- }
116
- exports2.exists = exists;
117
- function isDirectory(fsPath, useStat = false) {
118
- return __awaiter(this, void 0, void 0, function* () {
119
- const stats = useStat ? yield exports2.stat(fsPath) : yield exports2.lstat(fsPath);
120
- return stats.isDirectory();
121
- });
122
- }
123
- exports2.isDirectory = isDirectory;
124
- function isRooted(p) {
125
- p = normalizeSeparators(p);
126
- if (!p) {
127
- throw new Error('isRooted() parameter "p" cannot be empty');
128
- }
129
- if (exports2.IS_WINDOWS) {
130
- return p.startsWith("\\") || /^[A-Z]:/i.test(p);
131
- }
132
- return p.startsWith("/");
133
- }
134
- exports2.isRooted = isRooted;
135
- function tryGetExecutablePath(filePath, extensions) {
136
- return __awaiter(this, void 0, void 0, function* () {
137
- let stats = void 0;
138
- try {
139
- stats = yield exports2.stat(filePath);
140
- } catch (err) {
141
- if (err.code !== "ENOENT") {
142
- console.log(`Unexpected error attempting to determine if executable file exists '${filePath}': ${err}`);
143
- }
144
- }
145
- if (stats && stats.isFile()) {
146
- if (exports2.IS_WINDOWS) {
147
- const upperExt = path.extname(filePath).toUpperCase();
148
- if (extensions.some((validExt) => validExt.toUpperCase() === upperExt)) {
149
- return filePath;
150
- }
151
- } else {
152
- if (isUnixExecutable(stats)) {
153
- return filePath;
154
- }
155
- }
156
- }
157
- const originalFilePath = filePath;
158
- for (const extension of extensions) {
159
- filePath = originalFilePath + extension;
160
- stats = void 0;
161
- try {
162
- stats = yield exports2.stat(filePath);
163
- } catch (err) {
164
- if (err.code !== "ENOENT") {
165
- console.log(`Unexpected error attempting to determine if executable file exists '${filePath}': ${err}`);
166
- }
167
- }
168
- if (stats && stats.isFile()) {
169
- if (exports2.IS_WINDOWS) {
170
- try {
171
- const directory = path.dirname(filePath);
172
- const upperName = path.basename(filePath).toUpperCase();
173
- for (const actualName of yield exports2.readdir(directory)) {
174
- if (upperName === actualName.toUpperCase()) {
175
- filePath = path.join(directory, actualName);
176
- break;
177
- }
178
- }
179
- } catch (err) {
180
- console.log(`Unexpected error attempting to determine the actual case of the file '${filePath}': ${err}`);
181
- }
182
- return filePath;
183
- } else {
184
- if (isUnixExecutable(stats)) {
185
- return filePath;
186
- }
187
- }
188
- }
189
- }
190
- return "";
191
- });
192
- }
193
- exports2.tryGetExecutablePath = tryGetExecutablePath;
194
- function normalizeSeparators(p) {
195
- p = p || "";
196
- if (exports2.IS_WINDOWS) {
197
- p = p.replace(/\//g, "\\");
198
- return p.replace(/\\\\+/g, "\\");
199
- }
200
- return p.replace(/\/\/+/g, "/");
201
- }
202
- function isUnixExecutable(stats) {
203
- return (stats.mode & 1) > 0 || (stats.mode & 8) > 0 && stats.gid === process.getgid() || (stats.mode & 64) > 0 && stats.uid === process.getuid();
204
- }
205
- function getCmdPath() {
206
- var _a2;
207
- return (_a2 = process.env["COMSPEC"]) !== null && _a2 !== void 0 ? _a2 : `cmd.exe`;
208
- }
209
- exports2.getCmdPath = getCmdPath;
210
- }
211
- });
212
-
213
- // node_modules/.pnpm/@actions+io@1.1.3/node_modules/@actions/io/lib/io.js
214
- var require_io = __commonJS({
215
- "node_modules/.pnpm/@actions+io@1.1.3/node_modules/@actions/io/lib/io.js"(exports2) {
216
- "use strict";
217
- var __createBinding = exports2 && exports2.__createBinding || (Object.create ? function(o, m, k, k2) {
218
- if (k2 === void 0) k2 = k;
219
- Object.defineProperty(o, k2, { enumerable: true, get: function() {
220
- return m[k];
221
- } });
222
- } : function(o, m, k, k2) {
223
- if (k2 === void 0) k2 = k;
224
- o[k2] = m[k];
225
- });
226
- var __setModuleDefault = exports2 && exports2.__setModuleDefault || (Object.create ? function(o, v) {
227
- Object.defineProperty(o, "default", { enumerable: true, value: v });
228
- } : function(o, v) {
229
- o["default"] = v;
230
- });
231
- var __importStar = exports2 && exports2.__importStar || function(mod) {
232
- if (mod && mod.__esModule) return mod;
233
- var result = {};
234
- if (mod != null) {
235
- for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
236
- }
237
- __setModuleDefault(result, mod);
238
- return result;
239
- };
240
- var __awaiter = exports2 && exports2.__awaiter || function(thisArg, _arguments, P, generator) {
241
- function adopt(value) {
242
- return value instanceof P ? value : new P(function(resolve) {
243
- resolve(value);
244
- });
245
- }
246
- return new (P || (P = Promise))(function(resolve, reject) {
247
- function fulfilled(value) {
248
- try {
249
- step(generator.next(value));
250
- } catch (e) {
251
- reject(e);
252
- }
253
- }
254
- function rejected(value) {
255
- try {
256
- step(generator["throw"](value));
257
- } catch (e) {
258
- reject(e);
259
- }
260
- }
261
- function step(result) {
262
- result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
263
- }
264
- step((generator = generator.apply(thisArg, _arguments || [])).next());
265
- });
266
- };
267
- Object.defineProperty(exports2, "__esModule", { value: true });
268
- exports2.findInPath = exports2.which = exports2.mkdirP = exports2.rmRF = exports2.mv = exports2.cp = void 0;
269
- var assert_1 = require("assert");
270
- var path = __importStar(require("path"));
271
- var ioUtil = __importStar(require_io_util());
272
- function cp(source, dest, options = {}) {
273
- return __awaiter(this, void 0, void 0, function* () {
274
- const { force, recursive, copySourceDirectory } = readCopyOptions(options);
275
- const destStat = (yield ioUtil.exists(dest)) ? yield ioUtil.stat(dest) : null;
276
- if (destStat && destStat.isFile() && !force) {
277
- return;
278
- }
279
- const newDest = destStat && destStat.isDirectory() && copySourceDirectory ? path.join(dest, path.basename(source)) : dest;
280
- if (!(yield ioUtil.exists(source))) {
281
- throw new Error(`no such file or directory: ${source}`);
282
- }
283
- const sourceStat = yield ioUtil.stat(source);
284
- if (sourceStat.isDirectory()) {
285
- if (!recursive) {
286
- throw new Error(`Failed to copy. ${source} is a directory, but tried to copy without recursive flag.`);
287
- } else {
288
- yield cpDirRecursive(source, newDest, 0, force);
289
- }
290
- } else {
291
- if (path.relative(source, newDest) === "") {
292
- throw new Error(`'${newDest}' and '${source}' are the same file`);
293
- }
294
- yield copyFile(source, newDest, force);
295
- }
296
- });
297
- }
298
- exports2.cp = cp;
299
- function mv(source, dest, options = {}) {
300
- return __awaiter(this, void 0, void 0, function* () {
301
- if (yield ioUtil.exists(dest)) {
302
- let destExists = true;
303
- if (yield ioUtil.isDirectory(dest)) {
304
- dest = path.join(dest, path.basename(source));
305
- destExists = yield ioUtil.exists(dest);
306
- }
307
- if (destExists) {
308
- if (options.force == null || options.force) {
309
- yield rmRF(dest);
310
- } else {
311
- throw new Error("Destination already exists");
312
- }
313
- }
314
- }
315
- yield mkdirP(path.dirname(dest));
316
- yield ioUtil.rename(source, dest);
317
- });
318
- }
319
- exports2.mv = mv;
320
- function rmRF(inputPath) {
321
- return __awaiter(this, void 0, void 0, function* () {
322
- if (ioUtil.IS_WINDOWS) {
323
- if (/[*"<>|]/.test(inputPath)) {
324
- throw new Error('File path must not contain `*`, `"`, `<`, `>` or `|` on Windows');
325
- }
326
- }
327
- try {
328
- yield ioUtil.rm(inputPath, {
329
- force: true,
330
- maxRetries: 3,
331
- recursive: true,
332
- retryDelay: 300
333
- });
334
- } catch (err) {
335
- throw new Error(`File was unable to be removed ${err}`);
336
- }
337
- });
338
- }
339
- exports2.rmRF = rmRF;
340
- function mkdirP(fsPath) {
341
- return __awaiter(this, void 0, void 0, function* () {
342
- assert_1.ok(fsPath, "a path argument must be provided");
343
- yield ioUtil.mkdir(fsPath, { recursive: true });
344
- });
345
- }
346
- exports2.mkdirP = mkdirP;
347
- function which(tool, check) {
348
- return __awaiter(this, void 0, void 0, function* () {
349
- if (!tool) {
350
- throw new Error("parameter 'tool' is required");
351
- }
352
- if (check) {
353
- const result = yield which(tool, false);
354
- if (!result) {
355
- if (ioUtil.IS_WINDOWS) {
356
- throw new Error(`Unable to locate executable file: ${tool}. Please verify either the file path exists or the file can be found within a directory specified by the PATH environment variable. Also verify the file has a valid extension for an executable file.`);
357
- } else {
358
- throw new Error(`Unable to locate executable file: ${tool}. Please verify either the file path exists or the file can be found within a directory specified by the PATH environment variable. Also check the file mode to verify the file is executable.`);
359
- }
360
- }
361
- return result;
362
- }
363
- const matches = yield findInPath(tool);
364
- if (matches && matches.length > 0) {
365
- return matches[0];
366
- }
367
- return "";
368
- });
369
- }
370
- exports2.which = which;
371
- function findInPath(tool) {
372
- return __awaiter(this, void 0, void 0, function* () {
373
- if (!tool) {
374
- throw new Error("parameter 'tool' is required");
375
- }
376
- const extensions = [];
377
- if (ioUtil.IS_WINDOWS && process.env["PATHEXT"]) {
378
- for (const extension of process.env["PATHEXT"].split(path.delimiter)) {
379
- if (extension) {
380
- extensions.push(extension);
381
- }
382
- }
383
- }
384
- if (ioUtil.isRooted(tool)) {
385
- const filePath = yield ioUtil.tryGetExecutablePath(tool, extensions);
386
- if (filePath) {
387
- return [filePath];
388
- }
389
- return [];
390
- }
391
- if (tool.includes(path.sep)) {
392
- return [];
393
- }
394
- const directories = [];
395
- if (process.env.PATH) {
396
- for (const p of process.env.PATH.split(path.delimiter)) {
397
- if (p) {
398
- directories.push(p);
399
- }
400
- }
401
- }
402
- const matches = [];
403
- for (const directory of directories) {
404
- const filePath = yield ioUtil.tryGetExecutablePath(path.join(directory, tool), extensions);
405
- if (filePath) {
406
- matches.push(filePath);
407
- }
408
- }
409
- return matches;
410
- });
411
- }
412
- exports2.findInPath = findInPath;
413
- function readCopyOptions(options) {
414
- const force = options.force == null ? true : options.force;
415
- const recursive = Boolean(options.recursive);
416
- const copySourceDirectory = options.copySourceDirectory == null ? true : Boolean(options.copySourceDirectory);
417
- return { force, recursive, copySourceDirectory };
418
- }
419
- function cpDirRecursive(sourceDir, destDir, currentDepth, force) {
420
- return __awaiter(this, void 0, void 0, function* () {
421
- if (currentDepth >= 255)
422
- return;
423
- currentDepth++;
424
- yield mkdirP(destDir);
425
- const files = yield ioUtil.readdir(sourceDir);
426
- for (const fileName of files) {
427
- const srcFile = `${sourceDir}/${fileName}`;
428
- const destFile = `${destDir}/${fileName}`;
429
- const srcFileStat = yield ioUtil.lstat(srcFile);
430
- if (srcFileStat.isDirectory()) {
431
- yield cpDirRecursive(srcFile, destFile, currentDepth, force);
432
- } else {
433
- yield copyFile(srcFile, destFile, force);
434
- }
435
- }
436
- yield ioUtil.chmod(destDir, (yield ioUtil.stat(sourceDir)).mode);
437
- });
438
- }
439
- function copyFile(srcFile, destFile, force) {
440
- return __awaiter(this, void 0, void 0, function* () {
441
- if ((yield ioUtil.lstat(srcFile)).isSymbolicLink()) {
442
- try {
443
- yield ioUtil.lstat(destFile);
444
- yield ioUtil.unlink(destFile);
445
- } catch (e) {
446
- if (e.code === "EPERM") {
447
- yield ioUtil.chmod(destFile, "0666");
448
- yield ioUtil.unlink(destFile);
449
- }
450
- }
451
- const symlinkFull = yield ioUtil.readlink(srcFile);
452
- yield ioUtil.symlink(symlinkFull, destFile, ioUtil.IS_WINDOWS ? "junction" : null);
453
- } else if (!(yield ioUtil.exists(destFile)) || force) {
454
- yield ioUtil.copyFile(srcFile, destFile);
455
- }
456
- });
457
- }
458
- }
459
- });
460
-
461
- // node_modules/.pnpm/@actions+exec@1.1.1/node_modules/@actions/exec/lib/toolrunner.js
462
- var require_toolrunner = __commonJS({
463
- "node_modules/.pnpm/@actions+exec@1.1.1/node_modules/@actions/exec/lib/toolrunner.js"(exports2) {
464
- "use strict";
465
- var __createBinding = exports2 && exports2.__createBinding || (Object.create ? function(o, m, k, k2) {
466
- if (k2 === void 0) k2 = k;
467
- Object.defineProperty(o, k2, { enumerable: true, get: function() {
468
- return m[k];
469
- } });
470
- } : function(o, m, k, k2) {
471
- if (k2 === void 0) k2 = k;
472
- o[k2] = m[k];
473
- });
474
- var __setModuleDefault = exports2 && exports2.__setModuleDefault || (Object.create ? function(o, v) {
475
- Object.defineProperty(o, "default", { enumerable: true, value: v });
476
- } : function(o, v) {
477
- o["default"] = v;
478
- });
479
- var __importStar = exports2 && exports2.__importStar || function(mod) {
480
- if (mod && mod.__esModule) return mod;
481
- var result = {};
482
- if (mod != null) {
483
- for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
484
- }
485
- __setModuleDefault(result, mod);
486
- return result;
487
- };
488
- var __awaiter = exports2 && exports2.__awaiter || function(thisArg, _arguments, P, generator) {
489
- function adopt(value) {
490
- return value instanceof P ? value : new P(function(resolve) {
491
- resolve(value);
492
- });
493
- }
494
- return new (P || (P = Promise))(function(resolve, reject) {
495
- function fulfilled(value) {
496
- try {
497
- step(generator.next(value));
498
- } catch (e) {
499
- reject(e);
500
- }
501
- }
502
- function rejected(value) {
503
- try {
504
- step(generator["throw"](value));
505
- } catch (e) {
506
- reject(e);
507
- }
508
- }
509
- function step(result) {
510
- result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
511
- }
512
- step((generator = generator.apply(thisArg, _arguments || [])).next());
513
- });
514
- };
515
- Object.defineProperty(exports2, "__esModule", { value: true });
516
- exports2.argStringToArray = exports2.ToolRunner = void 0;
517
- var os = __importStar(require("os"));
518
- var events = __importStar(require("events"));
519
- var child = __importStar(require("child_process"));
520
- var path = __importStar(require("path"));
521
- var io = __importStar(require_io());
522
- var ioUtil = __importStar(require_io_util());
523
- var timers_1 = require("timers");
524
- var IS_WINDOWS = process.platform === "win32";
525
- var ToolRunner = class extends events.EventEmitter {
526
- constructor(toolPath, args, options) {
527
- super();
528
- if (!toolPath) {
529
- throw new Error("Parameter 'toolPath' cannot be null or empty.");
530
- }
531
- this.toolPath = toolPath;
532
- this.args = args || [];
533
- this.options = options || {};
534
- }
535
- _debug(message) {
536
- if (this.options.listeners && this.options.listeners.debug) {
537
- this.options.listeners.debug(message);
538
- }
539
- }
540
- _getCommandString(options, noPrefix) {
541
- const toolPath = this._getSpawnFileName();
542
- const args = this._getSpawnArgs(options);
543
- let cmd = noPrefix ? "" : "[command]";
544
- if (IS_WINDOWS) {
545
- if (this._isCmdFile()) {
546
- cmd += toolPath;
547
- for (const a of args) {
548
- cmd += ` ${a}`;
549
- }
550
- } else if (options.windowsVerbatimArguments) {
551
- cmd += `"${toolPath}"`;
552
- for (const a of args) {
553
- cmd += ` ${a}`;
554
- }
555
- } else {
556
- cmd += this._windowsQuoteCmdArg(toolPath);
557
- for (const a of args) {
558
- cmd += ` ${this._windowsQuoteCmdArg(a)}`;
559
- }
560
- }
561
- } else {
562
- cmd += toolPath;
563
- for (const a of args) {
564
- cmd += ` ${a}`;
565
- }
566
- }
567
- return cmd;
568
- }
569
- _processLineBuffer(data, strBuffer, onLine) {
570
- try {
571
- let s = strBuffer + data.toString();
572
- let n = s.indexOf(os.EOL);
573
- while (n > -1) {
574
- const line = s.substring(0, n);
575
- onLine(line);
576
- s = s.substring(n + os.EOL.length);
577
- n = s.indexOf(os.EOL);
578
- }
579
- return s;
580
- } catch (err) {
581
- this._debug(`error processing line. Failed with error ${err}`);
582
- return "";
583
- }
584
- }
585
- _getSpawnFileName() {
586
- if (IS_WINDOWS) {
587
- if (this._isCmdFile()) {
588
- return process.env["COMSPEC"] || "cmd.exe";
589
- }
590
- }
591
- return this.toolPath;
592
- }
593
- _getSpawnArgs(options) {
594
- if (IS_WINDOWS) {
595
- if (this._isCmdFile()) {
596
- let argline = `/D /S /C "${this._windowsQuoteCmdArg(this.toolPath)}`;
597
- for (const a of this.args) {
598
- argline += " ";
599
- argline += options.windowsVerbatimArguments ? a : this._windowsQuoteCmdArg(a);
600
- }
601
- argline += '"';
602
- return [argline];
603
- }
604
- }
605
- return this.args;
606
- }
607
- _endsWith(str2, end) {
608
- return str2.endsWith(end);
609
- }
610
- _isCmdFile() {
611
- const upperToolPath = this.toolPath.toUpperCase();
612
- return this._endsWith(upperToolPath, ".CMD") || this._endsWith(upperToolPath, ".BAT");
613
- }
614
- _windowsQuoteCmdArg(arg) {
615
- if (!this._isCmdFile()) {
616
- return this._uvQuoteCmdArg(arg);
617
- }
618
- if (!arg) {
619
- return '""';
620
- }
621
- const cmdSpecialChars = [
622
- " ",
623
- " ",
624
- "&",
625
- "(",
626
- ")",
627
- "[",
628
- "]",
629
- "{",
630
- "}",
631
- "^",
632
- "=",
633
- ";",
634
- "!",
635
- "'",
636
- "+",
637
- ",",
638
- "`",
639
- "~",
640
- "|",
641
- "<",
642
- ">",
643
- '"'
644
- ];
645
- let needsQuotes = false;
646
- for (const char of arg) {
647
- if (cmdSpecialChars.some((x) => x === char)) {
648
- needsQuotes = true;
649
- break;
650
- }
651
- }
652
- if (!needsQuotes) {
653
- return arg;
654
- }
655
- let reverse = '"';
656
- let quoteHit = true;
657
- for (let i = arg.length; i > 0; i--) {
658
- reverse += arg[i - 1];
659
- if (quoteHit && arg[i - 1] === "\\") {
660
- reverse += "\\";
661
- } else if (arg[i - 1] === '"') {
662
- quoteHit = true;
663
- reverse += '"';
664
- } else {
665
- quoteHit = false;
666
- }
667
- }
668
- reverse += '"';
669
- return reverse.split("").reverse().join("");
670
- }
671
- _uvQuoteCmdArg(arg) {
672
- if (!arg) {
673
- return '""';
674
- }
675
- if (!arg.includes(" ") && !arg.includes(" ") && !arg.includes('"')) {
676
- return arg;
677
- }
678
- if (!arg.includes('"') && !arg.includes("\\")) {
679
- return `"${arg}"`;
680
- }
681
- let reverse = '"';
682
- let quoteHit = true;
683
- for (let i = arg.length; i > 0; i--) {
684
- reverse += arg[i - 1];
685
- if (quoteHit && arg[i - 1] === "\\") {
686
- reverse += "\\";
687
- } else if (arg[i - 1] === '"') {
688
- quoteHit = true;
689
- reverse += "\\";
690
- } else {
691
- quoteHit = false;
692
- }
693
- }
694
- reverse += '"';
695
- return reverse.split("").reverse().join("");
696
- }
697
- _cloneExecOptions(options) {
698
- options = options || {};
699
- const result = {
700
- cwd: options.cwd || process.cwd(),
701
- env: options.env || process.env,
702
- silent: options.silent || false,
703
- windowsVerbatimArguments: options.windowsVerbatimArguments || false,
704
- failOnStdErr: options.failOnStdErr || false,
705
- ignoreReturnCode: options.ignoreReturnCode || false,
706
- delay: options.delay || 1e4
707
- };
708
- result.outStream = options.outStream || process.stdout;
709
- result.errStream = options.errStream || process.stderr;
710
- return result;
711
- }
712
- _getSpawnOptions(options, toolPath) {
713
- options = options || {};
714
- const result = {};
715
- result.cwd = options.cwd;
716
- result.env = options.env;
717
- result["windowsVerbatimArguments"] = options.windowsVerbatimArguments || this._isCmdFile();
718
- if (options.windowsVerbatimArguments) {
719
- result.argv0 = `"${toolPath}"`;
720
- }
721
- return result;
722
- }
723
- /**
724
- * Exec a tool.
725
- * Output will be streamed to the live console.
726
- * Returns promise with return code
727
- *
728
- * @param tool path to tool to exec
729
- * @param options optional exec options. See ExecOptions
730
- * @returns number
731
- */
732
- exec() {
733
- return __awaiter(this, void 0, void 0, function* () {
734
- if (!ioUtil.isRooted(this.toolPath) && (this.toolPath.includes("/") || IS_WINDOWS && this.toolPath.includes("\\"))) {
735
- this.toolPath = path.resolve(process.cwd(), this.options.cwd || process.cwd(), this.toolPath);
736
- }
737
- this.toolPath = yield io.which(this.toolPath, true);
738
- return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
739
- this._debug(`exec tool: ${this.toolPath}`);
740
- this._debug("arguments:");
741
- for (const arg of this.args) {
742
- this._debug(` ${arg}`);
743
- }
744
- const optionsNonNull = this._cloneExecOptions(this.options);
745
- if (!optionsNonNull.silent && optionsNonNull.outStream) {
746
- optionsNonNull.outStream.write(this._getCommandString(optionsNonNull) + os.EOL);
747
- }
748
- const state = new ExecState(optionsNonNull, this.toolPath);
749
- state.on("debug", (message) => {
750
- this._debug(message);
751
- });
752
- if (this.options.cwd && !(yield ioUtil.exists(this.options.cwd))) {
753
- return reject(new Error(`The cwd: ${this.options.cwd} does not exist!`));
754
- }
755
- const fileName = this._getSpawnFileName();
756
- const cp = child.spawn(fileName, this._getSpawnArgs(optionsNonNull), this._getSpawnOptions(this.options, fileName));
757
- let stdbuffer = "";
758
- if (cp.stdout) {
759
- cp.stdout.on("data", (data) => {
760
- if (this.options.listeners && this.options.listeners.stdout) {
761
- this.options.listeners.stdout(data);
762
- }
763
- if (!optionsNonNull.silent && optionsNonNull.outStream) {
764
- optionsNonNull.outStream.write(data);
765
- }
766
- stdbuffer = this._processLineBuffer(data, stdbuffer, (line) => {
767
- if (this.options.listeners && this.options.listeners.stdline) {
768
- this.options.listeners.stdline(line);
769
- }
770
- });
771
- });
772
- }
773
- let errbuffer = "";
774
- if (cp.stderr) {
775
- cp.stderr.on("data", (data) => {
776
- state.processStderr = true;
777
- if (this.options.listeners && this.options.listeners.stderr) {
778
- this.options.listeners.stderr(data);
779
- }
780
- if (!optionsNonNull.silent && optionsNonNull.errStream && optionsNonNull.outStream) {
781
- const s = optionsNonNull.failOnStdErr ? optionsNonNull.errStream : optionsNonNull.outStream;
782
- s.write(data);
783
- }
784
- errbuffer = this._processLineBuffer(data, errbuffer, (line) => {
785
- if (this.options.listeners && this.options.listeners.errline) {
786
- this.options.listeners.errline(line);
787
- }
788
- });
789
- });
790
- }
791
- cp.on("error", (err) => {
792
- state.processError = err.message;
793
- state.processExited = true;
794
- state.processClosed = true;
795
- state.CheckComplete();
796
- });
797
- cp.on("exit", (code) => {
798
- state.processExitCode = code;
799
- state.processExited = true;
800
- this._debug(`Exit code ${code} received from tool '${this.toolPath}'`);
801
- state.CheckComplete();
802
- });
803
- cp.on("close", (code) => {
804
- state.processExitCode = code;
805
- state.processExited = true;
806
- state.processClosed = true;
807
- this._debug(`STDIO streams have closed for tool '${this.toolPath}'`);
808
- state.CheckComplete();
809
- });
810
- state.on("done", (error, exitCode) => {
811
- if (stdbuffer.length > 0) {
812
- this.emit("stdline", stdbuffer);
813
- }
814
- if (errbuffer.length > 0) {
815
- this.emit("errline", errbuffer);
816
- }
817
- cp.removeAllListeners();
818
- if (error) {
819
- reject(error);
820
- } else {
821
- resolve(exitCode);
822
- }
823
- });
824
- if (this.options.input) {
825
- if (!cp.stdin) {
826
- throw new Error("child process missing stdin");
827
- }
828
- cp.stdin.end(this.options.input);
829
- }
830
- }));
831
- });
832
- }
833
- };
834
- exports2.ToolRunner = ToolRunner;
835
- function argStringToArray(argString) {
836
- const args = [];
837
- let inQuotes = false;
838
- let escaped = false;
839
- let arg = "";
840
- function append(c) {
841
- if (escaped && c !== '"') {
842
- arg += "\\";
843
- }
844
- arg += c;
845
- escaped = false;
846
- }
847
- for (let i = 0; i < argString.length; i++) {
848
- const c = argString.charAt(i);
849
- if (c === '"') {
850
- if (!escaped) {
851
- inQuotes = !inQuotes;
852
- } else {
853
- append(c);
854
- }
855
- continue;
856
- }
857
- if (c === "\\" && escaped) {
858
- append(c);
859
- continue;
860
- }
861
- if (c === "\\" && inQuotes) {
862
- escaped = true;
863
- continue;
864
- }
865
- if (c === " " && !inQuotes) {
866
- if (arg.length > 0) {
867
- args.push(arg);
868
- arg = "";
869
- }
870
- continue;
871
- }
872
- append(c);
873
- }
874
- if (arg.length > 0) {
875
- args.push(arg.trim());
876
- }
877
- return args;
878
- }
879
- exports2.argStringToArray = argStringToArray;
880
- var ExecState = class _ExecState extends events.EventEmitter {
881
- constructor(options, toolPath) {
882
- super();
883
- this.processClosed = false;
884
- this.processError = "";
885
- this.processExitCode = 0;
886
- this.processExited = false;
887
- this.processStderr = false;
888
- this.delay = 1e4;
889
- this.done = false;
890
- this.timeout = null;
891
- if (!toolPath) {
892
- throw new Error("toolPath must not be empty");
893
- }
894
- this.options = options;
895
- this.toolPath = toolPath;
896
- if (options.delay) {
897
- this.delay = options.delay;
898
- }
899
- }
900
- CheckComplete() {
901
- if (this.done) {
902
- return;
903
- }
904
- if (this.processClosed) {
905
- this._setResult();
906
- } else if (this.processExited) {
907
- this.timeout = timers_1.setTimeout(_ExecState.HandleTimeout, this.delay, this);
908
- }
909
- }
910
- _debug(message) {
911
- this.emit("debug", message);
912
- }
913
- _setResult() {
914
- let error;
915
- if (this.processExited) {
916
- if (this.processError) {
917
- error = new Error(`There was an error when attempting to execute the process '${this.toolPath}'. This may indicate the process failed to start. Error: ${this.processError}`);
918
- } else if (this.processExitCode !== 0 && !this.options.ignoreReturnCode) {
919
- error = new Error(`The process '${this.toolPath}' failed with exit code ${this.processExitCode}`);
920
- } else if (this.processStderr && this.options.failOnStdErr) {
921
- error = new Error(`The process '${this.toolPath}' failed because one or more lines were written to the STDERR stream`);
922
- }
923
- }
924
- if (this.timeout) {
925
- clearTimeout(this.timeout);
926
- this.timeout = null;
927
- }
928
- this.done = true;
929
- this.emit("done", error, this.processExitCode);
930
- }
931
- static HandleTimeout(state) {
932
- if (state.done) {
933
- return;
934
- }
935
- if (!state.processClosed && state.processExited) {
936
- const message = `The STDIO streams did not close within ${state.delay / 1e3} seconds of the exit event from process '${state.toolPath}'. This may indicate a child process inherited the STDIO streams and has not yet exited.`;
937
- state._debug(message);
938
- }
939
- state._setResult();
940
- }
941
- };
942
- }
943
- });
944
-
945
- // node_modules/.pnpm/@actions+exec@1.1.1/node_modules/@actions/exec/lib/exec.js
946
- var require_exec = __commonJS({
947
- "node_modules/.pnpm/@actions+exec@1.1.1/node_modules/@actions/exec/lib/exec.js"(exports2) {
948
- "use strict";
949
- var __createBinding = exports2 && exports2.__createBinding || (Object.create ? function(o, m, k, k2) {
950
- if (k2 === void 0) k2 = k;
951
- Object.defineProperty(o, k2, { enumerable: true, get: function() {
952
- return m[k];
953
- } });
954
- } : function(o, m, k, k2) {
955
- if (k2 === void 0) k2 = k;
956
- o[k2] = m[k];
957
- });
958
- var __setModuleDefault = exports2 && exports2.__setModuleDefault || (Object.create ? function(o, v) {
959
- Object.defineProperty(o, "default", { enumerable: true, value: v });
960
- } : function(o, v) {
961
- o["default"] = v;
962
- });
963
- var __importStar = exports2 && exports2.__importStar || function(mod) {
964
- if (mod && mod.__esModule) return mod;
965
- var result = {};
966
- if (mod != null) {
967
- for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
968
- }
969
- __setModuleDefault(result, mod);
970
- return result;
971
- };
972
- var __awaiter = exports2 && exports2.__awaiter || function(thisArg, _arguments, P, generator) {
973
- function adopt(value) {
974
- return value instanceof P ? value : new P(function(resolve) {
975
- resolve(value);
976
- });
977
- }
978
- return new (P || (P = Promise))(function(resolve, reject) {
979
- function fulfilled(value) {
980
- try {
981
- step(generator.next(value));
982
- } catch (e) {
983
- reject(e);
984
- }
985
- }
986
- function rejected(value) {
987
- try {
988
- step(generator["throw"](value));
989
- } catch (e) {
990
- reject(e);
991
- }
992
- }
993
- function step(result) {
994
- result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
995
- }
996
- step((generator = generator.apply(thisArg, _arguments || [])).next());
997
- });
998
- };
999
- Object.defineProperty(exports2, "__esModule", { value: true });
1000
- exports2.getExecOutput = exports2.exec = void 0;
1001
- var string_decoder_1 = require("string_decoder");
1002
- var tr = __importStar(require_toolrunner());
1003
- function exec(commandLine, args, options) {
1004
- return __awaiter(this, void 0, void 0, function* () {
1005
- const commandArgs = tr.argStringToArray(commandLine);
1006
- if (commandArgs.length === 0) {
1007
- throw new Error(`Parameter 'commandLine' cannot be null or empty.`);
1008
- }
1009
- const toolPath = commandArgs[0];
1010
- args = commandArgs.slice(1).concat(args || []);
1011
- const runner = new tr.ToolRunner(toolPath, args, options);
1012
- return runner.exec();
1013
- });
1014
- }
1015
- exports2.exec = exec;
1016
- function getExecOutput2(commandLine, args, options) {
1017
- var _a, _b;
1018
- return __awaiter(this, void 0, void 0, function* () {
1019
- let stdout = "";
1020
- let stderr = "";
1021
- const stdoutDecoder = new string_decoder_1.StringDecoder("utf8");
1022
- const stderrDecoder = new string_decoder_1.StringDecoder("utf8");
1023
- const originalStdoutListener = (_a = options === null || options === void 0 ? void 0 : options.listeners) === null || _a === void 0 ? void 0 : _a.stdout;
1024
- const originalStdErrListener = (_b = options === null || options === void 0 ? void 0 : options.listeners) === null || _b === void 0 ? void 0 : _b.stderr;
1025
- const stdErrListener = (data) => {
1026
- stderr += stderrDecoder.write(data);
1027
- if (originalStdErrListener) {
1028
- originalStdErrListener(data);
1029
- }
1030
- };
1031
- const stdOutListener = (data) => {
1032
- stdout += stdoutDecoder.write(data);
1033
- if (originalStdoutListener) {
1034
- originalStdoutListener(data);
1035
- }
1036
- };
1037
- const listeners = Object.assign(Object.assign({}, options === null || options === void 0 ? void 0 : options.listeners), { stdout: stdOutListener, stderr: stdErrListener });
1038
- const exitCode = yield exec(commandLine, args, Object.assign(Object.assign({}, options), { listeners }));
1039
- stdout += stdoutDecoder.end();
1040
- stderr += stderrDecoder.end();
1041
- return {
1042
- exitCode,
1043
- stdout,
1044
- stderr
1045
- };
1046
- });
1047
- }
1048
- exports2.getExecOutput = getExecOutput2;
1049
- }
1050
- });
1051
-
1052
37
  // packages/k8s-tools/index.ts
1053
38
  var k8s_tools_exports = {};
1054
39
  __export(k8s_tools_exports, {
1055
- helmChartGenerator: () => helmChartGenerator,
1056
- helmChartSchematic: () => helmChartSchematic,
1057
- helmDependencyGenerator: () => helmDependencyGenerator,
1058
- helmDependencySchematic: () => helmDependencySchematic,
40
+ helmChartGeneratorFn: () => helmChartGeneratorFn,
41
+ helmDependencyGeneratorFn: () => helmDependencyGeneratorFn,
1059
42
  serveExecutor: () => serveExecutor
1060
43
  });
1061
44
  module.exports = __toCommonJS(k8s_tools_exports);
@@ -1064,7 +47,7 @@ module.exports = __toCommonJS(k8s_tools_exports);
1064
47
  var import_workspace_tools = require("@storm-software/workspace-tools");
1065
48
 
1066
49
  // packages/k8s-tools/src/utils/client.ts
1067
- var import_exec = __toESM(require_exec());
50
+ var import_node_child_process = require("node:child_process");
1068
51
 
1069
52
  // packages/k8s-tools/src/types.ts
1070
53
  var AbstractHelmClient = class {
@@ -1094,84 +77,100 @@ var ensureInitialized = (target, propertyKey, descriptor) => {
1094
77
 
1095
78
  // packages/k8s-tools/src/utils/client.ts
1096
79
  var HelmClient = class extends AbstractHelmClient {
1097
- async package(options) {
80
+ /**
81
+ * Creates an instance of HelmClient
82
+ */
83
+ constructor() {
84
+ super();
85
+ }
86
+ package(options) {
1098
87
  let chartPath = void 0;
1099
- await (0, import_exec.getExecOutput)("helm", [
1100
- "package",
1101
- options.chartFolder,
1102
- "-d",
1103
- options.outputFolder
1104
- ]).then((output) => {
1105
- if (output.stderr.length > 0 && output.exitCode !== 0) {
1106
- throw new Error(`Failed to package chart: ${output.stderr}`);
1107
- }
1108
- const stdout = output.stdout;
1109
- const match = stdout.match(
1110
- /Successfully packaged chart and saved it to: (.+)/
1111
- );
1112
- if (!match) {
1113
- throw new Error("Failed to parse chart path from helm output");
88
+ let output = {};
89
+ try {
90
+ output = this.runCommand([
91
+ "helm",
92
+ "package",
93
+ options.chartFolder,
94
+ "-d",
95
+ options.outputFolder
96
+ ]);
97
+ } catch (err) {
98
+ if (err?.stderr.length > 0 && err?.exitCode !== 0) {
99
+ throw new Error(`Failed to package chart: ${err.stderr}`);
1114
100
  }
1115
- chartPath = match[1]?.trim();
1116
- });
1117
- return chartPath;
1118
- }
1119
- async push(options) {
1120
- await (0, import_exec.getExecOutput)("helm", [
1121
- "push",
1122
- options.chartPath,
1123
- options.remote
1124
- ]).then((output) => {
1125
- if (output.stderr.length > 0 && output.exitCode !== 0) {
1126
- throw new Error(`Failed to push chart: ${output.stderr}`);
101
+ }
102
+ if (output?.stderr.length > 0 && output?.exitCode !== 0) {
103
+ throw new Error(`Failed to package chart: ${output.stderr}`);
104
+ }
105
+ const match = output.stdout?.match(
106
+ /Successfully packaged chart and saved it to: (.+)/
107
+ );
108
+ if (!match || match.length < 2) {
109
+ throw new Error("Failed to parse chart path from helm output");
110
+ }
111
+ chartPath = match[1]?.trim();
112
+ return new Promise((resolve) => resolve(chartPath));
113
+ }
114
+ push(options) {
115
+ try {
116
+ this.runCommand(["helm", "push", options.chartPath, options.remote]);
117
+ } catch (err) {
118
+ if (err?.stderr.length > 0 && err?.exitCode !== 0) {
119
+ throw new Error(`Failed to push chart: ${err.stderr}`);
1127
120
  }
1128
- });
121
+ }
1129
122
  }
1130
- async dependencyUpdate(chartFolder) {
1131
- await (0, import_exec.getExecOutput)("helm", ["dependency", "update", chartFolder]).then(
1132
- (output) => {
1133
- if (output.stderr.length > 0 && output.exitCode !== 0) {
1134
- throw new Error(
1135
- `Failed to update chart dependencies: ${output.stderr}`
1136
- );
1137
- }
123
+ dependencyUpdate(chartFolder) {
124
+ try {
125
+ this.runCommand(["helm", "dependency", "update", chartFolder]);
126
+ } catch (err) {
127
+ if (err?.stderr.length > 0 && err?.exitCode !== 0) {
128
+ throw new Error(`Failed to update chart dependencies: ${err.stderr}`);
1138
129
  }
1139
- );
130
+ }
1140
131
  }
1141
- async dependencyBuild(chartFolder) {
1142
- await (0, import_exec.getExecOutput)("helm", ["dependency", "build", chartFolder]).then(
1143
- (output) => {
1144
- if (output.stderr.length > 0 && output.exitCode !== 0) {
1145
- throw new Error(
1146
- `Failed to build chart dependencies: ${output.stderr}`
1147
- );
1148
- }
132
+ dependencyBuild(chartFolder) {
133
+ try {
134
+ this.runCommand(["helm", "dependency", "build", chartFolder]);
135
+ } catch (err) {
136
+ if (err?.stderr.length > 0 && err?.exitCode !== 0) {
137
+ throw new Error(`Failed to build chart dependencies: ${err.stderr}`);
1149
138
  }
1150
- );
139
+ }
1151
140
  }
1152
- async addRepository(name, url) {
1153
- await (0, import_exec.getExecOutput)("helm", ["repo", "add", name, url]).then((output) => {
1154
- if (output.stderr.length > 0 && output.exitCode !== 0) {
1155
- throw new Error(`Failed to add repository: ${output.stderr}`);
141
+ addRepository(name, url) {
142
+ try {
143
+ this.runCommand(["helm", "repo", "add", name, url]);
144
+ } catch (err) {
145
+ if (err?.stderr.length > 0 && err?.exitCode !== 0) {
146
+ throw new Error(`Failed to add repository: ${err.stderr}`);
1156
147
  }
1157
- });
148
+ }
1158
149
  }
1159
150
  /**
1160
151
  * Initialize Helm
1161
152
  *
1162
- * @returns {Promise<void>}
153
+ * @returns A promise
1163
154
  */
1164
155
  async initialize() {
1165
156
  if (this.initialized) {
1166
157
  return;
1167
158
  }
1168
- await (0, import_exec.getExecOutput)("helm", ["version"]).then((output) => {
1169
- if (output.stderr.length > 0 && output.exitCode !== 0) {
1170
- throw new Error(`Helm is not installed: ${output.stderr}`);
159
+ try {
160
+ this.runCommand(["helm", "version"]);
161
+ } catch (err) {
162
+ if (err?.stderr.length > 0 && err?.exitCode !== 0) {
163
+ throw new Error(`Helm is not installed: ${err.stderr}`);
1171
164
  }
165
+ }
166
+ return new Promise((resolve) => {
1172
167
  this.initialized = true;
168
+ resolve();
1173
169
  });
1174
170
  }
171
+ runCommand(commands) {
172
+ return (0, import_node_child_process.execSync)(commands.filter(Boolean).join(" "), { encoding: "utf8" });
173
+ }
1175
174
  };
1176
175
  __decorateClass([
1177
176
  ensureInitialized
@@ -1202,24 +201,24 @@ async function serveExecutor(options, context, config) {
1202
201
  if (options.dependencies?.repositories) {
1203
202
  for (const repository of options.dependencies.repositories) {
1204
203
  if (repository.name && repository.url) {
1205
- await helm.addRepository(repository.name, repository.url);
204
+ helm.addRepository(repository.name, repository.url);
1206
205
  } else {
1207
206
  throw new Error("Repository name and url are required");
1208
207
  }
1209
208
  }
1210
209
  }
1211
210
  if (options.dependencies?.update) {
1212
- await helm.dependencyUpdate(options.chartFolder);
211
+ helm.dependencyUpdate(options.chartFolder);
1213
212
  }
1214
213
  if (options.dependencies?.build) {
1215
- await helm.dependencyBuild(options.chartFolder);
214
+ helm.dependencyBuild(options.chartFolder);
1216
215
  }
1217
216
  const chartPath = await helm.package({
1218
217
  chartFolder: options.chartFolder,
1219
218
  outputFolder: options.outputFolder
1220
219
  });
1221
220
  if (options.push && chartPath && options.remote) {
1222
- await helm.push({
221
+ helm.push({
1223
222
  chartPath,
1224
223
  remote: options.remote
1225
224
  });
@@ -1246,97 +245,59 @@ var executor_default = (0, import_workspace_tools.withRunExecutor)(
1246
245
 
1247
246
  // packages/k8s-tools/src/generators/helm-chart/generator.ts
1248
247
  var import_devkit = require("@nx/devkit");
248
+ var import_workspace_tools2 = require("@storm-software/workspace-tools");
1249
249
  var import_path = require("path");
1250
- async function helmChartGenerator(tree, options) {
1251
- const {
1252
- getStopwatch,
1253
- writeDebug,
1254
- writeError,
1255
- writeFatal,
1256
- writeInfo,
1257
- writeTrace,
1258
- findWorkspaceRoot,
1259
- loadStormConfig
1260
- } = await import("@storm-software/config-tools");
1261
- const stopwatch = getStopwatch("Storm Helm Chart generator");
1262
- let config;
1263
- try {
1264
- writeInfo(`\u26A1 Running the Storm Helm Chart generator...
1265
-
1266
- `, config);
1267
- const workspaceRoot = findWorkspaceRoot();
1268
- writeDebug(
1269
- `Loading the Storm Config from environment variables and storm.json file...
1270
- - workspaceRoot: ${workspaceRoot}`,
1271
- config
250
+ async function helmChartGeneratorFn(tree, options, config) {
251
+ const { writeTrace } = await import("@storm-software/config-tools");
252
+ writeTrace("\u{1F4DD} Preparing to write Helm Chart", config);
253
+ const project = (0, import_devkit.readProjectConfiguration)(tree, options.project);
254
+ if (project.targets?.["helm-package"]) {
255
+ throw new Error(
256
+ `Project ${options.project} already has a helm target. Please remove it before running this command.`
1272
257
  );
1273
- config = await loadStormConfig(workspaceRoot);
1274
- writeTrace(
1275
- `Loaded Storm config into env:
1276
- ${Object.keys(process.env).map((key) => ` - ${key}=${JSON.stringify(process.env[key])}`).join("\n")}`,
1277
- config
1278
- );
1279
- const tasks = [];
1280
- tasks.push(async () => {
1281
- const project = (0, import_devkit.readProjectConfiguration)(tree, options.project);
1282
- if (project.targets?.["helm-package"]) {
1283
- throw new Error(
1284
- `Project ${options.project} already has a helm target. Please remove it before running this command.`
1285
- );
1286
- }
1287
- (0, import_devkit.updateProjectConfiguration)(tree, options.project, {
1288
- ...project,
1289
- targets: {
1290
- ...project.targets,
1291
- "helm-package": {
1292
- executor: "@storm-software/k8s-tools:helm-package",
1293
- outputs: ["{options.outputFolder}"],
1294
- options: {
1295
- chartFolder: `${project.root}/${options.chartFolder}`,
1296
- outputFolder: "{workspaceRoot}/dist/charts/{projectRoot}",
1297
- push: false,
1298
- remote: "oci://localhost:5000/helm-charts",
1299
- dependencies: {
1300
- update: true,
1301
- build: true,
1302
- repositories: []
1303
- }
1304
- }
258
+ }
259
+ (0, import_devkit.updateProjectConfiguration)(tree, options.project, {
260
+ ...project,
261
+ targets: {
262
+ ...project.targets,
263
+ "helm-package": {
264
+ executor: "@storm-software/k8s-tools:helm-package",
265
+ outputs: ["{options.outputFolder}"],
266
+ options: {
267
+ chartFolder: `${project.root}/${options.chartFolder}`,
268
+ outputFolder: "{workspaceRoot}/dist/charts/{projectRoot}",
269
+ push: false,
270
+ remote: "oci://localhost:5000/helm-charts",
271
+ dependencies: {
272
+ update: true,
273
+ build: true,
274
+ repositories: []
1305
275
  }
1306
276
  }
1307
- });
1308
- (0, import_devkit.generateFiles)(
1309
- tree,
1310
- (0, import_path.join)(__dirname, "files", "chart"),
1311
- (0, import_path.join)(project.root, options.chartFolder ?? ""),
1312
- options
1313
- );
1314
- if (options.format) {
1315
- await (0, import_devkit.formatFiles)(tree);
1316
277
  }
1317
- });
1318
- return (0, import_devkit.runTasksInSerial)(...tasks);
1319
- } catch (error) {
1320
- return () => {
1321
- writeFatal(
1322
- "A fatal error occurred while running the generator - the process was forced to terminate",
1323
- config
1324
- );
1325
- writeError(
1326
- `An exception was thrown in the generator's process
1327
- - Details: ${error.message}
1328
- - Stacktrace: ${error.stack}`,
1329
- config
1330
- );
1331
- };
1332
- } finally {
1333
- stopwatch();
278
+ }
279
+ });
280
+ (0, import_devkit.generateFiles)(
281
+ tree,
282
+ (0, import_path.join)(__dirname, "files", "chart"),
283
+ (0, import_path.join)(project.root, options.chartFolder ?? ""),
284
+ options
285
+ );
286
+ if (options.format) {
287
+ await (0, import_devkit.formatFiles)(tree);
1334
288
  }
289
+ return {
290
+ success: true
291
+ };
1335
292
  }
1336
- var helmChartSchematic = (0, import_devkit.convertNxGenerator)(helmChartGenerator);
293
+ var generator_default = (0, import_workspace_tools2.withRunGenerator)(
294
+ "Helm Chart",
295
+ helmChartGeneratorFn
296
+ );
1337
297
 
1338
298
  // packages/k8s-tools/src/generators/helm-dependency/generator.ts
1339
299
  var import_devkit2 = require("@nx/devkit");
300
+ var import_workspace_tools3 = require("@storm-software/workspace-tools");
1340
301
 
1341
302
  // node_modules/.pnpm/js-yaml@4.1.0/node_modules/js-yaml/dist/js-yaml.mjs
1342
303
  function isNothing(subject) {
@@ -3961,83 +2922,37 @@ var jsYaml = {
3961
2922
  var js_yaml_default = jsYaml;
3962
2923
 
3963
2924
  // packages/k8s-tools/src/generators/helm-dependency/generator.ts
3964
- async function helmDependencyGenerator(tree, options) {
3965
- const {
3966
- getStopwatch,
3967
- writeDebug,
3968
- writeError,
3969
- writeFatal,
3970
- writeInfo,
3971
- writeTrace,
3972
- findWorkspaceRoot,
3973
- loadStormConfig
3974
- } = await import("@storm-software/config-tools");
3975
- const stopwatch = getStopwatch("Storm Worker generator");
3976
- let config;
3977
- try {
3978
- writeInfo(`\u26A1 Running the Storm Worker generator...
3979
-
3980
- `, config);
3981
- const workspaceRoot = findWorkspaceRoot();
3982
- writeDebug(
3983
- `Loading the Storm Config from environment variables and storm.json file...
3984
- - workspaceRoot: ${workspaceRoot}`,
3985
- config
3986
- );
3987
- config = await loadStormConfig(workspaceRoot);
3988
- writeTrace(
3989
- `Loaded Storm config into env:
3990
- ${Object.keys(process.env).map((key) => ` - ${key}=${JSON.stringify(process.env[key])}`).join("\n")}`,
3991
- config
2925
+ async function helmDependencyGeneratorFn(tree, options, config) {
2926
+ const { writeTrace } = await import("@storm-software/config-tools");
2927
+ writeTrace("\u{1F4DD} Preparing to add Helm Dependency", config);
2928
+ const project = (0, import_devkit2.readProjectConfiguration)(tree, options.project);
2929
+ if (!project.targets?.["helm-package"]) {
2930
+ throw new Error(
2931
+ `Project ${options.project} does not have a helm target. Please run the chart generator first.`
3992
2932
  );
3993
- const tasks = [];
3994
- tasks.push(async () => {
3995
- const project = (0, import_devkit2.readProjectConfiguration)(tree, options.project);
3996
- if (!project.targets?.["helm-package"]) {
3997
- throw new Error(
3998
- `Project ${options.project} does not have a helm target. Please run the chart generator first.`
3999
- );
4000
- }
4001
- (0, import_devkit2.updateProjectConfiguration)(
4002
- tree,
4003
- options.project,
4004
- addDependencyToConfig(
4005
- project,
4006
- options.repositoryName,
4007
- options.repository
4008
- )
4009
- );
4010
- updateChartYaml(
4011
- tree,
4012
- project,
4013
- options.chartName,
4014
- options.chartVersion,
4015
- options.repository
4016
- );
4017
- if (options.format) {
4018
- await (0, import_devkit2.formatFiles)(tree);
4019
- }
4020
- });
4021
- return (0, import_devkit2.runTasksInSerial)(...tasks);
4022
- } catch (error) {
4023
- return () => {
4024
- writeFatal(
4025
- "A fatal error occurred while running the generator - the process was forced to terminate",
4026
- config
4027
- );
4028
- writeError(
4029
- `An exception was thrown in the generator's process
4030
- - Details: ${error.message}
4031
- - Stacktrace: ${error.stack}`,
4032
- config
4033
- );
4034
- };
4035
- } finally {
4036
- stopwatch();
4037
2933
  }
2934
+ (0, import_devkit2.updateProjectConfiguration)(
2935
+ tree,
2936
+ options.project,
2937
+ addDependencyToConfig(project, options.repositoryName, options.repository)
2938
+ );
2939
+ updateChartYaml(
2940
+ tree,
2941
+ project,
2942
+ options.chartName,
2943
+ options.chartVersion,
2944
+ options.repository
2945
+ );
2946
+ if (options.format) {
2947
+ await (0, import_devkit2.formatFiles)(tree);
2948
+ }
2949
+ return {
2950
+ success: true
2951
+ };
4038
2952
  }
4039
- var helmDependencySchematic = (0, import_devkit2.convertNxGenerator)(
4040
- helmDependencyGenerator
2953
+ var generator_default2 = (0, import_workspace_tools3.withRunGenerator)(
2954
+ "Helm Dependency",
2955
+ helmDependencyGeneratorFn
4041
2956
  );
4042
2957
  function addDependencyToConfig(project, name, url) {
4043
2958
  return {
@@ -4096,10 +3011,8 @@ function updateChartYaml(tree, project, name, version, repository) {
4096
3011
  }
4097
3012
  // Annotate the CommonJS export names for ESM import in node:
4098
3013
  0 && (module.exports = {
4099
- helmChartGenerator,
4100
- helmChartSchematic,
4101
- helmDependencyGenerator,
4102
- helmDependencySchematic,
3014
+ helmChartGeneratorFn,
3015
+ helmDependencyGeneratorFn,
4103
3016
  serveExecutor
4104
3017
  });
4105
3018
  /*! Bundled license information: