nest-hex 0.2.0 → 0.2.2

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 (51) hide show
  1. package/README.md +183 -4
  2. package/dist/src/cli/bin.js +2630 -0
  3. package/dist/src/cli/commands/index.d.ts +23 -0
  4. package/dist/src/cli/commands/index.js +2595 -0
  5. package/dist/src/cli/config/defaults.d.ts +74 -0
  6. package/dist/src/cli/config/defaults.js +76 -0
  7. package/dist/src/cli/config/define-config.d.ts +74 -0
  8. package/dist/src/cli/config/define-config.js +62 -0
  9. package/dist/src/cli/config/loader.d.ts +74 -0
  10. package/dist/src/cli/config/loader.js +106 -0
  11. package/dist/src/cli/config/validator.d.ts +81 -0
  12. package/dist/src/cli/config/validator.js +108 -0
  13. package/dist/src/cli/generators/adapter.generator.d.ts +235 -0
  14. package/dist/src/cli/generators/adapter.generator.js +377 -0
  15. package/dist/src/cli/generators/base.generator.d.ts +190 -0
  16. package/dist/src/cli/generators/base.generator.js +312 -0
  17. package/dist/src/cli/generators/index.d.ts +264 -0
  18. package/dist/src/cli/generators/index.js +467 -0
  19. package/dist/src/cli/generators/port.generator.d.ts +211 -0
  20. package/dist/src/cli/generators/port.generator.js +364 -0
  21. package/dist/src/cli/generators/service.generator.d.ts +208 -0
  22. package/dist/src/cli/generators/service.generator.js +340 -0
  23. package/dist/src/cli/index.d.ts +74 -0
  24. package/dist/src/cli/index.js +69 -0
  25. package/dist/src/cli/types/config.types.d.ts +73 -0
  26. package/dist/src/cli/types/config.types.js +56 -0
  27. package/dist/src/cli/types/generator.types.d.ts +46 -0
  28. package/dist/src/cli/types/generator.types.js +56 -0
  29. package/dist/src/cli/types/index.d.ts +121 -0
  30. package/dist/src/cli/types/index.js +56 -0
  31. package/dist/src/cli/types/template.types.d.ts +28 -0
  32. package/dist/src/cli/types/template.types.js +56 -0
  33. package/dist/src/cli/ui/components/index.d.ts +97 -0
  34. package/dist/src/cli/ui/components/index.js +1493 -0
  35. package/dist/src/cli/utils/file-writer.d.ts +17 -0
  36. package/dist/src/cli/utils/file-writer.js +100 -0
  37. package/dist/src/cli/utils/linter-detector.d.ts +12 -0
  38. package/dist/src/cli/utils/linter-detector.js +128 -0
  39. package/dist/src/cli/utils/linter-runner.d.ts +17 -0
  40. package/dist/src/cli/utils/linter-runner.js +101 -0
  41. package/dist/src/cli/utils/name-transformer.d.ts +18 -0
  42. package/dist/src/cli/utils/name-transformer.js +90 -0
  43. package/dist/src/cli/utils/path-resolver.d.ts +5 -0
  44. package/dist/src/cli/utils/path-resolver.js +78 -0
  45. package/dist/src/cli/utils/port-scanner.d.ts +93 -0
  46. package/dist/src/cli/utils/port-scanner.js +104 -0
  47. package/dist/src/cli/utils/template-renderer.d.ts +30 -0
  48. package/dist/src/cli/utils/template-renderer.js +95 -0
  49. package/dist/{index.js → src/index.js} +14 -0
  50. package/package.json +10 -10
  51. /package/dist/{index.d.ts → src/index.d.ts} +0 -0
@@ -0,0 +1,2595 @@
1
+ var import_node_module = require("node:module");
2
+ var __create = Object.create;
3
+ var __getProtoOf = Object.getPrototypeOf;
4
+ var __defProp = Object.defineProperty;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __toESM = (mod, isNodeMode, target) => {
9
+ target = mod != null ? __create(__getProtoOf(mod)) : {};
10
+ const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
11
+ for (let key of __getOwnPropNames(mod))
12
+ if (!__hasOwnProp.call(to, key))
13
+ __defProp(to, key, {
14
+ get: () => mod[key],
15
+ enumerable: true
16
+ });
17
+ return to;
18
+ };
19
+ var __moduleCache = /* @__PURE__ */ new WeakMap;
20
+ var __toCommonJS = (from) => {
21
+ var entry = __moduleCache.get(from), desc;
22
+ if (entry)
23
+ return entry;
24
+ entry = __defProp({}, "__esModule", { value: true });
25
+ if (from && typeof from === "object" || typeof from === "function")
26
+ __getOwnPropNames(from).map((key) => !__hasOwnProp.call(entry, key) && __defProp(entry, key, {
27
+ get: () => from[key],
28
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
29
+ }));
30
+ __moduleCache.set(from, entry);
31
+ return entry;
32
+ };
33
+ var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
34
+ var __export = (target, all) => {
35
+ for (var name in all)
36
+ __defProp(target, name, {
37
+ get: all[name],
38
+ enumerable: true,
39
+ configurable: true,
40
+ set: (newValue) => all[name] = () => newValue
41
+ });
42
+ };
43
+ var __legacyDecorateClassTS = function(decorators, target, key, desc) {
44
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
45
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
46
+ r = Reflect.decorate(decorators, target, key, desc);
47
+ else
48
+ for (var i = decorators.length - 1;i >= 0; i--)
49
+ if (d = decorators[i])
50
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
51
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
52
+ };
53
+
54
+ // node_modules/react/cjs/react-jsx-dev-runtime.development.js
55
+ var require_react_jsx_dev_runtime_development = __commonJS((exports2) => {
56
+ if (true) {
57
+ (function() {
58
+ var React = require("react");
59
+ var REACT_ELEMENT_TYPE = Symbol.for("react.element");
60
+ var REACT_PORTAL_TYPE = Symbol.for("react.portal");
61
+ var REACT_FRAGMENT_TYPE = Symbol.for("react.fragment");
62
+ var REACT_STRICT_MODE_TYPE = Symbol.for("react.strict_mode");
63
+ var REACT_PROFILER_TYPE = Symbol.for("react.profiler");
64
+ var REACT_PROVIDER_TYPE = Symbol.for("react.provider");
65
+ var REACT_CONTEXT_TYPE = Symbol.for("react.context");
66
+ var REACT_FORWARD_REF_TYPE = Symbol.for("react.forward_ref");
67
+ var REACT_SUSPENSE_TYPE = Symbol.for("react.suspense");
68
+ var REACT_SUSPENSE_LIST_TYPE = Symbol.for("react.suspense_list");
69
+ var REACT_MEMO_TYPE = Symbol.for("react.memo");
70
+ var REACT_LAZY_TYPE = Symbol.for("react.lazy");
71
+ var REACT_OFFSCREEN_TYPE = Symbol.for("react.offscreen");
72
+ var MAYBE_ITERATOR_SYMBOL = Symbol.iterator;
73
+ var FAUX_ITERATOR_SYMBOL = "@@iterator";
74
+ function getIteratorFn(maybeIterable) {
75
+ if (maybeIterable === null || typeof maybeIterable !== "object") {
76
+ return null;
77
+ }
78
+ var maybeIterator = MAYBE_ITERATOR_SYMBOL && maybeIterable[MAYBE_ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL];
79
+ if (typeof maybeIterator === "function") {
80
+ return maybeIterator;
81
+ }
82
+ return null;
83
+ }
84
+ var ReactSharedInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
85
+ function error(format) {
86
+ {
87
+ {
88
+ for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1;_key2 < _len2; _key2++) {
89
+ args[_key2 - 1] = arguments[_key2];
90
+ }
91
+ printWarning("error", format, args);
92
+ }
93
+ }
94
+ }
95
+ function printWarning(level, format, args) {
96
+ {
97
+ var ReactDebugCurrentFrame2 = ReactSharedInternals.ReactDebugCurrentFrame;
98
+ var stack = ReactDebugCurrentFrame2.getStackAddendum();
99
+ if (stack !== "") {
100
+ format += "%s";
101
+ args = args.concat([stack]);
102
+ }
103
+ var argsWithFormat = args.map(function(item) {
104
+ return String(item);
105
+ });
106
+ argsWithFormat.unshift("Warning: " + format);
107
+ Function.prototype.apply.call(console[level], console, argsWithFormat);
108
+ }
109
+ }
110
+ var enableScopeAPI = false;
111
+ var enableCacheElement = false;
112
+ var enableTransitionTracing = false;
113
+ var enableLegacyHidden = false;
114
+ var enableDebugTracing = false;
115
+ var REACT_MODULE_REFERENCE;
116
+ {
117
+ REACT_MODULE_REFERENCE = Symbol.for("react.module.reference");
118
+ }
119
+ function isValidElementType(type) {
120
+ if (typeof type === "string" || typeof type === "function") {
121
+ return true;
122
+ }
123
+ if (type === REACT_FRAGMENT_TYPE || type === REACT_PROFILER_TYPE || enableDebugTracing || type === REACT_STRICT_MODE_TYPE || type === REACT_SUSPENSE_TYPE || type === REACT_SUSPENSE_LIST_TYPE || enableLegacyHidden || type === REACT_OFFSCREEN_TYPE || enableScopeAPI || enableCacheElement || enableTransitionTracing) {
124
+ return true;
125
+ }
126
+ if (typeof type === "object" && type !== null) {
127
+ if (type.$$typeof === REACT_LAZY_TYPE || type.$$typeof === REACT_MEMO_TYPE || type.$$typeof === REACT_PROVIDER_TYPE || type.$$typeof === REACT_CONTEXT_TYPE || type.$$typeof === REACT_FORWARD_REF_TYPE || type.$$typeof === REACT_MODULE_REFERENCE || type.getModuleId !== undefined) {
128
+ return true;
129
+ }
130
+ }
131
+ return false;
132
+ }
133
+ function getWrappedName(outerType, innerType, wrapperName) {
134
+ var displayName = outerType.displayName;
135
+ if (displayName) {
136
+ return displayName;
137
+ }
138
+ var functionName = innerType.displayName || innerType.name || "";
139
+ return functionName !== "" ? wrapperName + "(" + functionName + ")" : wrapperName;
140
+ }
141
+ function getContextName(type) {
142
+ return type.displayName || "Context";
143
+ }
144
+ function getComponentNameFromType(type) {
145
+ if (type == null) {
146
+ return null;
147
+ }
148
+ {
149
+ if (typeof type.tag === "number") {
150
+ error("Received an unexpected object in getComponentNameFromType(). " + "This is likely a bug in React. Please file an issue.");
151
+ }
152
+ }
153
+ if (typeof type === "function") {
154
+ return type.displayName || type.name || null;
155
+ }
156
+ if (typeof type === "string") {
157
+ return type;
158
+ }
159
+ switch (type) {
160
+ case REACT_FRAGMENT_TYPE:
161
+ return "Fragment";
162
+ case REACT_PORTAL_TYPE:
163
+ return "Portal";
164
+ case REACT_PROFILER_TYPE:
165
+ return "Profiler";
166
+ case REACT_STRICT_MODE_TYPE:
167
+ return "StrictMode";
168
+ case REACT_SUSPENSE_TYPE:
169
+ return "Suspense";
170
+ case REACT_SUSPENSE_LIST_TYPE:
171
+ return "SuspenseList";
172
+ }
173
+ if (typeof type === "object") {
174
+ switch (type.$$typeof) {
175
+ case REACT_CONTEXT_TYPE:
176
+ var context = type;
177
+ return getContextName(context) + ".Consumer";
178
+ case REACT_PROVIDER_TYPE:
179
+ var provider = type;
180
+ return getContextName(provider._context) + ".Provider";
181
+ case REACT_FORWARD_REF_TYPE:
182
+ return getWrappedName(type, type.render, "ForwardRef");
183
+ case REACT_MEMO_TYPE:
184
+ var outerName = type.displayName || null;
185
+ if (outerName !== null) {
186
+ return outerName;
187
+ }
188
+ return getComponentNameFromType(type.type) || "Memo";
189
+ case REACT_LAZY_TYPE: {
190
+ var lazyComponent = type;
191
+ var payload = lazyComponent._payload;
192
+ var init = lazyComponent._init;
193
+ try {
194
+ return getComponentNameFromType(init(payload));
195
+ } catch (x) {
196
+ return null;
197
+ }
198
+ }
199
+ }
200
+ }
201
+ return null;
202
+ }
203
+ var assign = Object.assign;
204
+ var disabledDepth = 0;
205
+ var prevLog;
206
+ var prevInfo;
207
+ var prevWarn;
208
+ var prevError;
209
+ var prevGroup;
210
+ var prevGroupCollapsed;
211
+ var prevGroupEnd;
212
+ function disabledLog() {}
213
+ disabledLog.__reactDisabledLog = true;
214
+ function disableLogs() {
215
+ {
216
+ if (disabledDepth === 0) {
217
+ prevLog = console.log;
218
+ prevInfo = console.info;
219
+ prevWarn = console.warn;
220
+ prevError = console.error;
221
+ prevGroup = console.group;
222
+ prevGroupCollapsed = console.groupCollapsed;
223
+ prevGroupEnd = console.groupEnd;
224
+ var props = {
225
+ configurable: true,
226
+ enumerable: true,
227
+ value: disabledLog,
228
+ writable: true
229
+ };
230
+ Object.defineProperties(console, {
231
+ info: props,
232
+ log: props,
233
+ warn: props,
234
+ error: props,
235
+ group: props,
236
+ groupCollapsed: props,
237
+ groupEnd: props
238
+ });
239
+ }
240
+ disabledDepth++;
241
+ }
242
+ }
243
+ function reenableLogs() {
244
+ {
245
+ disabledDepth--;
246
+ if (disabledDepth === 0) {
247
+ var props = {
248
+ configurable: true,
249
+ enumerable: true,
250
+ writable: true
251
+ };
252
+ Object.defineProperties(console, {
253
+ log: assign({}, props, {
254
+ value: prevLog
255
+ }),
256
+ info: assign({}, props, {
257
+ value: prevInfo
258
+ }),
259
+ warn: assign({}, props, {
260
+ value: prevWarn
261
+ }),
262
+ error: assign({}, props, {
263
+ value: prevError
264
+ }),
265
+ group: assign({}, props, {
266
+ value: prevGroup
267
+ }),
268
+ groupCollapsed: assign({}, props, {
269
+ value: prevGroupCollapsed
270
+ }),
271
+ groupEnd: assign({}, props, {
272
+ value: prevGroupEnd
273
+ })
274
+ });
275
+ }
276
+ if (disabledDepth < 0) {
277
+ error("disabledDepth fell below zero. " + "This is a bug in React. Please file an issue.");
278
+ }
279
+ }
280
+ }
281
+ var ReactCurrentDispatcher = ReactSharedInternals.ReactCurrentDispatcher;
282
+ var prefix;
283
+ function describeBuiltInComponentFrame(name, source, ownerFn) {
284
+ {
285
+ if (prefix === undefined) {
286
+ try {
287
+ throw Error();
288
+ } catch (x) {
289
+ var match = x.stack.trim().match(/\n( *(at )?)/);
290
+ prefix = match && match[1] || "";
291
+ }
292
+ }
293
+ return `
294
+ ` + prefix + name;
295
+ }
296
+ }
297
+ var reentry = false;
298
+ var componentFrameCache;
299
+ {
300
+ var PossiblyWeakMap = typeof WeakMap === "function" ? WeakMap : Map;
301
+ componentFrameCache = new PossiblyWeakMap;
302
+ }
303
+ function describeNativeComponentFrame(fn, construct) {
304
+ if (!fn || reentry) {
305
+ return "";
306
+ }
307
+ {
308
+ var frame = componentFrameCache.get(fn);
309
+ if (frame !== undefined) {
310
+ return frame;
311
+ }
312
+ }
313
+ var control;
314
+ reentry = true;
315
+ var previousPrepareStackTrace = Error.prepareStackTrace;
316
+ Error.prepareStackTrace = undefined;
317
+ var previousDispatcher;
318
+ {
319
+ previousDispatcher = ReactCurrentDispatcher.current;
320
+ ReactCurrentDispatcher.current = null;
321
+ disableLogs();
322
+ }
323
+ try {
324
+ if (construct) {
325
+ var Fake = function() {
326
+ throw Error();
327
+ };
328
+ Object.defineProperty(Fake.prototype, "props", {
329
+ set: function() {
330
+ throw Error();
331
+ }
332
+ });
333
+ if (typeof Reflect === "object" && Reflect.construct) {
334
+ try {
335
+ Reflect.construct(Fake, []);
336
+ } catch (x) {
337
+ control = x;
338
+ }
339
+ Reflect.construct(fn, [], Fake);
340
+ } else {
341
+ try {
342
+ Fake.call();
343
+ } catch (x) {
344
+ control = x;
345
+ }
346
+ fn.call(Fake.prototype);
347
+ }
348
+ } else {
349
+ try {
350
+ throw Error();
351
+ } catch (x) {
352
+ control = x;
353
+ }
354
+ fn();
355
+ }
356
+ } catch (sample) {
357
+ if (sample && control && typeof sample.stack === "string") {
358
+ var sampleLines = sample.stack.split(`
359
+ `);
360
+ var controlLines = control.stack.split(`
361
+ `);
362
+ var s = sampleLines.length - 1;
363
+ var c = controlLines.length - 1;
364
+ while (s >= 1 && c >= 0 && sampleLines[s] !== controlLines[c]) {
365
+ c--;
366
+ }
367
+ for (;s >= 1 && c >= 0; s--, c--) {
368
+ if (sampleLines[s] !== controlLines[c]) {
369
+ if (s !== 1 || c !== 1) {
370
+ do {
371
+ s--;
372
+ c--;
373
+ if (c < 0 || sampleLines[s] !== controlLines[c]) {
374
+ var _frame = `
375
+ ` + sampleLines[s].replace(" at new ", " at ");
376
+ if (fn.displayName && _frame.includes("<anonymous>")) {
377
+ _frame = _frame.replace("<anonymous>", fn.displayName);
378
+ }
379
+ {
380
+ if (typeof fn === "function") {
381
+ componentFrameCache.set(fn, _frame);
382
+ }
383
+ }
384
+ return _frame;
385
+ }
386
+ } while (s >= 1 && c >= 0);
387
+ }
388
+ break;
389
+ }
390
+ }
391
+ }
392
+ } finally {
393
+ reentry = false;
394
+ {
395
+ ReactCurrentDispatcher.current = previousDispatcher;
396
+ reenableLogs();
397
+ }
398
+ Error.prepareStackTrace = previousPrepareStackTrace;
399
+ }
400
+ var name = fn ? fn.displayName || fn.name : "";
401
+ var syntheticFrame = name ? describeBuiltInComponentFrame(name) : "";
402
+ {
403
+ if (typeof fn === "function") {
404
+ componentFrameCache.set(fn, syntheticFrame);
405
+ }
406
+ }
407
+ return syntheticFrame;
408
+ }
409
+ function describeFunctionComponentFrame(fn, source, ownerFn) {
410
+ {
411
+ return describeNativeComponentFrame(fn, false);
412
+ }
413
+ }
414
+ function shouldConstruct(Component) {
415
+ var prototype = Component.prototype;
416
+ return !!(prototype && prototype.isReactComponent);
417
+ }
418
+ function describeUnknownElementTypeFrameInDEV(type, source, ownerFn) {
419
+ if (type == null) {
420
+ return "";
421
+ }
422
+ if (typeof type === "function") {
423
+ {
424
+ return describeNativeComponentFrame(type, shouldConstruct(type));
425
+ }
426
+ }
427
+ if (typeof type === "string") {
428
+ return describeBuiltInComponentFrame(type);
429
+ }
430
+ switch (type) {
431
+ case REACT_SUSPENSE_TYPE:
432
+ return describeBuiltInComponentFrame("Suspense");
433
+ case REACT_SUSPENSE_LIST_TYPE:
434
+ return describeBuiltInComponentFrame("SuspenseList");
435
+ }
436
+ if (typeof type === "object") {
437
+ switch (type.$$typeof) {
438
+ case REACT_FORWARD_REF_TYPE:
439
+ return describeFunctionComponentFrame(type.render);
440
+ case REACT_MEMO_TYPE:
441
+ return describeUnknownElementTypeFrameInDEV(type.type, source, ownerFn);
442
+ case REACT_LAZY_TYPE: {
443
+ var lazyComponent = type;
444
+ var payload = lazyComponent._payload;
445
+ var init = lazyComponent._init;
446
+ try {
447
+ return describeUnknownElementTypeFrameInDEV(init(payload), source, ownerFn);
448
+ } catch (x) {}
449
+ }
450
+ }
451
+ }
452
+ return "";
453
+ }
454
+ var hasOwnProperty = Object.prototype.hasOwnProperty;
455
+ var loggedTypeFailures = {};
456
+ var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame;
457
+ function setCurrentlyValidatingElement(element) {
458
+ {
459
+ if (element) {
460
+ var owner = element._owner;
461
+ var stack = describeUnknownElementTypeFrameInDEV(element.type, element._source, owner ? owner.type : null);
462
+ ReactDebugCurrentFrame.setExtraStackFrame(stack);
463
+ } else {
464
+ ReactDebugCurrentFrame.setExtraStackFrame(null);
465
+ }
466
+ }
467
+ }
468
+ function checkPropTypes(typeSpecs, values, location, componentName, element) {
469
+ {
470
+ var has = Function.call.bind(hasOwnProperty);
471
+ for (var typeSpecName in typeSpecs) {
472
+ if (has(typeSpecs, typeSpecName)) {
473
+ var error$1 = undefined;
474
+ try {
475
+ if (typeof typeSpecs[typeSpecName] !== "function") {
476
+ var err = Error((componentName || "React class") + ": " + location + " type `" + typeSpecName + "` is invalid; " + "it must be a function, usually from the `prop-types` package, but received `" + typeof typeSpecs[typeSpecName] + "`." + "This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");
477
+ err.name = "Invariant Violation";
478
+ throw err;
479
+ }
480
+ error$1 = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, "SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED");
481
+ } catch (ex) {
482
+ error$1 = ex;
483
+ }
484
+ if (error$1 && !(error$1 instanceof Error)) {
485
+ setCurrentlyValidatingElement(element);
486
+ error("%s: type specification of %s" + " `%s` is invalid; the type checker " + "function must return `null` or an `Error` but returned a %s. " + "You may have forgotten to pass an argument to the type checker " + "creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and " + "shape all require an argument).", componentName || "React class", location, typeSpecName, typeof error$1);
487
+ setCurrentlyValidatingElement(null);
488
+ }
489
+ if (error$1 instanceof Error && !(error$1.message in loggedTypeFailures)) {
490
+ loggedTypeFailures[error$1.message] = true;
491
+ setCurrentlyValidatingElement(element);
492
+ error("Failed %s type: %s", location, error$1.message);
493
+ setCurrentlyValidatingElement(null);
494
+ }
495
+ }
496
+ }
497
+ }
498
+ }
499
+ var isArrayImpl = Array.isArray;
500
+ function isArray(a) {
501
+ return isArrayImpl(a);
502
+ }
503
+ function typeName(value) {
504
+ {
505
+ var hasToStringTag = typeof Symbol === "function" && Symbol.toStringTag;
506
+ var type = hasToStringTag && value[Symbol.toStringTag] || value.constructor.name || "Object";
507
+ return type;
508
+ }
509
+ }
510
+ function willCoercionThrow(value) {
511
+ {
512
+ try {
513
+ testStringCoercion(value);
514
+ return false;
515
+ } catch (e) {
516
+ return true;
517
+ }
518
+ }
519
+ }
520
+ function testStringCoercion(value) {
521
+ return "" + value;
522
+ }
523
+ function checkKeyStringCoercion(value) {
524
+ {
525
+ if (willCoercionThrow(value)) {
526
+ error("The provided key is an unsupported type %s." + " This value must be coerced to a string before before using it here.", typeName(value));
527
+ return testStringCoercion(value);
528
+ }
529
+ }
530
+ }
531
+ var ReactCurrentOwner = ReactSharedInternals.ReactCurrentOwner;
532
+ var RESERVED_PROPS = {
533
+ key: true,
534
+ ref: true,
535
+ __self: true,
536
+ __source: true
537
+ };
538
+ var specialPropKeyWarningShown;
539
+ var specialPropRefWarningShown;
540
+ var didWarnAboutStringRefs;
541
+ {
542
+ didWarnAboutStringRefs = {};
543
+ }
544
+ function hasValidRef(config) {
545
+ {
546
+ if (hasOwnProperty.call(config, "ref")) {
547
+ var getter = Object.getOwnPropertyDescriptor(config, "ref").get;
548
+ if (getter && getter.isReactWarning) {
549
+ return false;
550
+ }
551
+ }
552
+ }
553
+ return config.ref !== undefined;
554
+ }
555
+ function hasValidKey(config) {
556
+ {
557
+ if (hasOwnProperty.call(config, "key")) {
558
+ var getter = Object.getOwnPropertyDescriptor(config, "key").get;
559
+ if (getter && getter.isReactWarning) {
560
+ return false;
561
+ }
562
+ }
563
+ }
564
+ return config.key !== undefined;
565
+ }
566
+ function warnIfStringRefCannotBeAutoConverted(config, self) {
567
+ {
568
+ if (typeof config.ref === "string" && ReactCurrentOwner.current && self && ReactCurrentOwner.current.stateNode !== self) {
569
+ var componentName = getComponentNameFromType(ReactCurrentOwner.current.type);
570
+ if (!didWarnAboutStringRefs[componentName]) {
571
+ error('Component "%s" contains the string ref "%s". ' + "Support for string refs will be removed in a future major release. " + "This case cannot be automatically converted to an arrow function. " + "We ask you to manually fix this case by using useRef() or createRef() instead. " + "Learn more about using refs safely here: " + "https://reactjs.org/link/strict-mode-string-ref", getComponentNameFromType(ReactCurrentOwner.current.type), config.ref);
572
+ didWarnAboutStringRefs[componentName] = true;
573
+ }
574
+ }
575
+ }
576
+ }
577
+ function defineKeyPropWarningGetter(props, displayName) {
578
+ {
579
+ var warnAboutAccessingKey = function() {
580
+ if (!specialPropKeyWarningShown) {
581
+ specialPropKeyWarningShown = true;
582
+ error("%s: `key` is not a prop. Trying to access it will result " + "in `undefined` being returned. If you need to access the same " + "value within the child component, you should pass it as a different " + "prop. (https://reactjs.org/link/special-props)", displayName);
583
+ }
584
+ };
585
+ warnAboutAccessingKey.isReactWarning = true;
586
+ Object.defineProperty(props, "key", {
587
+ get: warnAboutAccessingKey,
588
+ configurable: true
589
+ });
590
+ }
591
+ }
592
+ function defineRefPropWarningGetter(props, displayName) {
593
+ {
594
+ var warnAboutAccessingRef = function() {
595
+ if (!specialPropRefWarningShown) {
596
+ specialPropRefWarningShown = true;
597
+ error("%s: `ref` is not a prop. Trying to access it will result " + "in `undefined` being returned. If you need to access the same " + "value within the child component, you should pass it as a different " + "prop. (https://reactjs.org/link/special-props)", displayName);
598
+ }
599
+ };
600
+ warnAboutAccessingRef.isReactWarning = true;
601
+ Object.defineProperty(props, "ref", {
602
+ get: warnAboutAccessingRef,
603
+ configurable: true
604
+ });
605
+ }
606
+ }
607
+ var ReactElement = function(type, key, ref, self, source, owner, props) {
608
+ var element = {
609
+ $$typeof: REACT_ELEMENT_TYPE,
610
+ type,
611
+ key,
612
+ ref,
613
+ props,
614
+ _owner: owner
615
+ };
616
+ {
617
+ element._store = {};
618
+ Object.defineProperty(element._store, "validated", {
619
+ configurable: false,
620
+ enumerable: false,
621
+ writable: true,
622
+ value: false
623
+ });
624
+ Object.defineProperty(element, "_self", {
625
+ configurable: false,
626
+ enumerable: false,
627
+ writable: false,
628
+ value: self
629
+ });
630
+ Object.defineProperty(element, "_source", {
631
+ configurable: false,
632
+ enumerable: false,
633
+ writable: false,
634
+ value: source
635
+ });
636
+ if (Object.freeze) {
637
+ Object.freeze(element.props);
638
+ Object.freeze(element);
639
+ }
640
+ }
641
+ return element;
642
+ };
643
+ function jsxDEV(type, config, maybeKey, source, self) {
644
+ {
645
+ var propName;
646
+ var props = {};
647
+ var key = null;
648
+ var ref = null;
649
+ if (maybeKey !== undefined) {
650
+ {
651
+ checkKeyStringCoercion(maybeKey);
652
+ }
653
+ key = "" + maybeKey;
654
+ }
655
+ if (hasValidKey(config)) {
656
+ {
657
+ checkKeyStringCoercion(config.key);
658
+ }
659
+ key = "" + config.key;
660
+ }
661
+ if (hasValidRef(config)) {
662
+ ref = config.ref;
663
+ warnIfStringRefCannotBeAutoConverted(config, self);
664
+ }
665
+ for (propName in config) {
666
+ if (hasOwnProperty.call(config, propName) && !RESERVED_PROPS.hasOwnProperty(propName)) {
667
+ props[propName] = config[propName];
668
+ }
669
+ }
670
+ if (type && type.defaultProps) {
671
+ var defaultProps = type.defaultProps;
672
+ for (propName in defaultProps) {
673
+ if (props[propName] === undefined) {
674
+ props[propName] = defaultProps[propName];
675
+ }
676
+ }
677
+ }
678
+ if (key || ref) {
679
+ var displayName = typeof type === "function" ? type.displayName || type.name || "Unknown" : type;
680
+ if (key) {
681
+ defineKeyPropWarningGetter(props, displayName);
682
+ }
683
+ if (ref) {
684
+ defineRefPropWarningGetter(props, displayName);
685
+ }
686
+ }
687
+ return ReactElement(type, key, ref, self, source, ReactCurrentOwner.current, props);
688
+ }
689
+ }
690
+ var ReactCurrentOwner$1 = ReactSharedInternals.ReactCurrentOwner;
691
+ var ReactDebugCurrentFrame$1 = ReactSharedInternals.ReactDebugCurrentFrame;
692
+ function setCurrentlyValidatingElement$1(element) {
693
+ {
694
+ if (element) {
695
+ var owner = element._owner;
696
+ var stack = describeUnknownElementTypeFrameInDEV(element.type, element._source, owner ? owner.type : null);
697
+ ReactDebugCurrentFrame$1.setExtraStackFrame(stack);
698
+ } else {
699
+ ReactDebugCurrentFrame$1.setExtraStackFrame(null);
700
+ }
701
+ }
702
+ }
703
+ var propTypesMisspellWarningShown;
704
+ {
705
+ propTypesMisspellWarningShown = false;
706
+ }
707
+ function isValidElement(object) {
708
+ {
709
+ return typeof object === "object" && object !== null && object.$$typeof === REACT_ELEMENT_TYPE;
710
+ }
711
+ }
712
+ function getDeclarationErrorAddendum() {
713
+ {
714
+ if (ReactCurrentOwner$1.current) {
715
+ var name = getComponentNameFromType(ReactCurrentOwner$1.current.type);
716
+ if (name) {
717
+ return `
718
+
719
+ Check the render method of \`` + name + "`.";
720
+ }
721
+ }
722
+ return "";
723
+ }
724
+ }
725
+ function getSourceInfoErrorAddendum(source) {
726
+ {
727
+ if (source !== undefined) {
728
+ var fileName = source.fileName.replace(/^.*[\\\/]/, "");
729
+ var lineNumber = source.lineNumber;
730
+ return `
731
+
732
+ Check your code at ` + fileName + ":" + lineNumber + ".";
733
+ }
734
+ return "";
735
+ }
736
+ }
737
+ var ownerHasKeyUseWarning = {};
738
+ function getCurrentComponentErrorInfo(parentType) {
739
+ {
740
+ var info = getDeclarationErrorAddendum();
741
+ if (!info) {
742
+ var parentName = typeof parentType === "string" ? parentType : parentType.displayName || parentType.name;
743
+ if (parentName) {
744
+ info = `
745
+
746
+ Check the top-level render call using <` + parentName + ">.";
747
+ }
748
+ }
749
+ return info;
750
+ }
751
+ }
752
+ function validateExplicitKey(element, parentType) {
753
+ {
754
+ if (!element._store || element._store.validated || element.key != null) {
755
+ return;
756
+ }
757
+ element._store.validated = true;
758
+ var currentComponentErrorInfo = getCurrentComponentErrorInfo(parentType);
759
+ if (ownerHasKeyUseWarning[currentComponentErrorInfo]) {
760
+ return;
761
+ }
762
+ ownerHasKeyUseWarning[currentComponentErrorInfo] = true;
763
+ var childOwner = "";
764
+ if (element && element._owner && element._owner !== ReactCurrentOwner$1.current) {
765
+ childOwner = " It was passed a child from " + getComponentNameFromType(element._owner.type) + ".";
766
+ }
767
+ setCurrentlyValidatingElement$1(element);
768
+ error('Each child in a list should have a unique "key" prop.' + "%s%s See https://reactjs.org/link/warning-keys for more information.", currentComponentErrorInfo, childOwner);
769
+ setCurrentlyValidatingElement$1(null);
770
+ }
771
+ }
772
+ function validateChildKeys(node, parentType) {
773
+ {
774
+ if (typeof node !== "object") {
775
+ return;
776
+ }
777
+ if (isArray(node)) {
778
+ for (var i = 0;i < node.length; i++) {
779
+ var child = node[i];
780
+ if (isValidElement(child)) {
781
+ validateExplicitKey(child, parentType);
782
+ }
783
+ }
784
+ } else if (isValidElement(node)) {
785
+ if (node._store) {
786
+ node._store.validated = true;
787
+ }
788
+ } else if (node) {
789
+ var iteratorFn = getIteratorFn(node);
790
+ if (typeof iteratorFn === "function") {
791
+ if (iteratorFn !== node.entries) {
792
+ var iterator = iteratorFn.call(node);
793
+ var step;
794
+ while (!(step = iterator.next()).done) {
795
+ if (isValidElement(step.value)) {
796
+ validateExplicitKey(step.value, parentType);
797
+ }
798
+ }
799
+ }
800
+ }
801
+ }
802
+ }
803
+ }
804
+ function validatePropTypes(element) {
805
+ {
806
+ var type = element.type;
807
+ if (type === null || type === undefined || typeof type === "string") {
808
+ return;
809
+ }
810
+ var propTypes;
811
+ if (typeof type === "function") {
812
+ propTypes = type.propTypes;
813
+ } else if (typeof type === "object" && (type.$$typeof === REACT_FORWARD_REF_TYPE || type.$$typeof === REACT_MEMO_TYPE)) {
814
+ propTypes = type.propTypes;
815
+ } else {
816
+ return;
817
+ }
818
+ if (propTypes) {
819
+ var name = getComponentNameFromType(type);
820
+ checkPropTypes(propTypes, element.props, "prop", name, element);
821
+ } else if (type.PropTypes !== undefined && !propTypesMisspellWarningShown) {
822
+ propTypesMisspellWarningShown = true;
823
+ var _name = getComponentNameFromType(type);
824
+ error("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?", _name || "Unknown");
825
+ }
826
+ if (typeof type.getDefaultProps === "function" && !type.getDefaultProps.isReactClassApproved) {
827
+ error("getDefaultProps is only used on classic React.createClass " + "definitions. Use a static property named `defaultProps` instead.");
828
+ }
829
+ }
830
+ }
831
+ function validateFragmentProps(fragment) {
832
+ {
833
+ var keys = Object.keys(fragment.props);
834
+ for (var i = 0;i < keys.length; i++) {
835
+ var key = keys[i];
836
+ if (key !== "children" && key !== "key") {
837
+ setCurrentlyValidatingElement$1(fragment);
838
+ error("Invalid prop `%s` supplied to `React.Fragment`. " + "React.Fragment can only have `key` and `children` props.", key);
839
+ setCurrentlyValidatingElement$1(null);
840
+ break;
841
+ }
842
+ }
843
+ if (fragment.ref !== null) {
844
+ setCurrentlyValidatingElement$1(fragment);
845
+ error("Invalid attribute `ref` supplied to `React.Fragment`.");
846
+ setCurrentlyValidatingElement$1(null);
847
+ }
848
+ }
849
+ }
850
+ var didWarnAboutKeySpread = {};
851
+ function jsxWithValidation(type, props, key, isStaticChildren, source, self) {
852
+ {
853
+ var validType = isValidElementType(type);
854
+ if (!validType) {
855
+ var info = "";
856
+ if (type === undefined || typeof type === "object" && type !== null && Object.keys(type).length === 0) {
857
+ info += " You likely forgot to export your component from the file " + "it's defined in, or you might have mixed up default and named imports.";
858
+ }
859
+ var sourceInfo = getSourceInfoErrorAddendum(source);
860
+ if (sourceInfo) {
861
+ info += sourceInfo;
862
+ } else {
863
+ info += getDeclarationErrorAddendum();
864
+ }
865
+ var typeString;
866
+ if (type === null) {
867
+ typeString = "null";
868
+ } else if (isArray(type)) {
869
+ typeString = "array";
870
+ } else if (type !== undefined && type.$$typeof === REACT_ELEMENT_TYPE) {
871
+ typeString = "<" + (getComponentNameFromType(type.type) || "Unknown") + " />";
872
+ info = " Did you accidentally export a JSX literal instead of a component?";
873
+ } else {
874
+ typeString = typeof type;
875
+ }
876
+ error("React.jsx: type is invalid -- expected a string (for " + "built-in components) or a class/function (for composite " + "components) but got: %s.%s", typeString, info);
877
+ }
878
+ var element = jsxDEV(type, props, key, source, self);
879
+ if (element == null) {
880
+ return element;
881
+ }
882
+ if (validType) {
883
+ var children = props.children;
884
+ if (children !== undefined) {
885
+ if (isStaticChildren) {
886
+ if (isArray(children)) {
887
+ for (var i = 0;i < children.length; i++) {
888
+ validateChildKeys(children[i], type);
889
+ }
890
+ if (Object.freeze) {
891
+ Object.freeze(children);
892
+ }
893
+ } else {
894
+ error("React.jsx: Static children should always be an array. " + "You are likely explicitly calling React.jsxs or React.jsxDEV. " + "Use the Babel transform instead.");
895
+ }
896
+ } else {
897
+ validateChildKeys(children, type);
898
+ }
899
+ }
900
+ }
901
+ {
902
+ if (hasOwnProperty.call(props, "key")) {
903
+ var componentName = getComponentNameFromType(type);
904
+ var keys = Object.keys(props).filter(function(k) {
905
+ return k !== "key";
906
+ });
907
+ var beforeExample = keys.length > 0 ? "{key: someKey, " + keys.join(": ..., ") + ": ...}" : "{key: someKey}";
908
+ if (!didWarnAboutKeySpread[componentName + beforeExample]) {
909
+ var afterExample = keys.length > 0 ? "{" + keys.join(": ..., ") + ": ...}" : "{}";
910
+ error(`A props object containing a "key" prop is being spread into JSX:
911
+ ` + ` let props = %s;
912
+ ` + ` <%s {...props} />
913
+ ` + `React keys must be passed directly to JSX without using spread:
914
+ ` + ` let props = %s;
915
+ ` + " <%s key={someKey} {...props} />", beforeExample, componentName, afterExample, componentName);
916
+ didWarnAboutKeySpread[componentName + beforeExample] = true;
917
+ }
918
+ }
919
+ }
920
+ if (type === REACT_FRAGMENT_TYPE) {
921
+ validateFragmentProps(element);
922
+ } else {
923
+ validatePropTypes(element);
924
+ }
925
+ return element;
926
+ }
927
+ }
928
+ var jsxDEV$1 = jsxWithValidation;
929
+ exports2.Fragment = REACT_FRAGMENT_TYPE;
930
+ exports2.jsxDEV = jsxDEV$1;
931
+ })();
932
+ }
933
+ });
934
+
935
+ // node_modules/react/jsx-dev-runtime.js
936
+ var require_jsx_dev_runtime = __commonJS((exports2, module2) => {
937
+ if (false) {} else {
938
+ module2.exports = require_react_jsx_dev_runtime_development();
939
+ }
940
+ });
941
+
942
+ // src/cli/config/defaults.ts
943
+ var exports_defaults = {};
944
+ __export(exports_defaults, {
945
+ defaultConfig: () => defaultConfig
946
+ });
947
+ module.exports = __toCommonJS(exports_defaults);
948
+ var defaultConfig = {
949
+ output: {
950
+ portsDir: "src/ports",
951
+ adaptersDir: "src/adapters"
952
+ },
953
+ naming: {
954
+ portSuffix: "PORT",
955
+ adapterSuffix: "Adapter",
956
+ fileCase: "kebab"
957
+ },
958
+ style: {
959
+ indent: "tab",
960
+ quotes: "single",
961
+ semicolons: true
962
+ },
963
+ templates: {}
964
+ };
965
+
966
+ // src/cli/config/loader.ts
967
+ var exports_loader = {};
968
+ __export(exports_loader, {
969
+ loadConfig: () => loadConfig
970
+ });
971
+ module.exports = __toCommonJS(exports_loader);
972
+ var import_node_path = require("node:path");
973
+ var import_ts_deepmerge = require("ts-deepmerge");
974
+ async function loadConfig(cwd = process.cwd()) {
975
+ const configPath = import_node_path.join(cwd, "nest-hex.config.ts");
976
+ const configFile = Bun.file(configPath);
977
+ if (!await configFile.exists()) {
978
+ return defaultConfig;
979
+ }
980
+ try {
981
+ const config = await import(configPath);
982
+ return import_ts_deepmerge.merge(defaultConfig, config.default ?? {});
983
+ } catch (error) {
984
+ console.error(`
985
+ Warning: Failed to load configuration from ${configPath}`);
986
+ console.error(`Using default configuration instead.
987
+ `);
988
+ if (error instanceof Error) {
989
+ console.error(`Error: ${error.message}
990
+ `);
991
+ }
992
+ return defaultConfig;
993
+ }
994
+ }
995
+
996
+ // src/cli/utils/file-writer.ts
997
+ var exports_file_writer = {};
998
+ __export(exports_file_writer, {
999
+ writeFile: () => writeFile
1000
+ });
1001
+ module.exports = __toCommonJS(exports_file_writer);
1002
+ async function writeFile(filePath, content, options = {}) {
1003
+ const { force = false, dryRun = false } = options;
1004
+ const file = Bun.file(filePath);
1005
+ const existed = await file.exists();
1006
+ if (existed && !force && !dryRun) {
1007
+ return {
1008
+ success: false,
1009
+ path: filePath,
1010
+ existed: true,
1011
+ written: false,
1012
+ message: "File already exists. Use --force to overwrite."
1013
+ };
1014
+ }
1015
+ if (dryRun) {
1016
+ return {
1017
+ success: true,
1018
+ path: filePath,
1019
+ existed,
1020
+ written: false,
1021
+ message: "Dry run - file not written"
1022
+ };
1023
+ }
1024
+ try {
1025
+ await Bun.write(filePath, content);
1026
+ return {
1027
+ success: true,
1028
+ path: filePath,
1029
+ existed,
1030
+ written: true,
1031
+ message: existed ? "File overwritten" : "File created"
1032
+ };
1033
+ } catch (error) {
1034
+ return {
1035
+ success: false,
1036
+ path: filePath,
1037
+ existed,
1038
+ written: false,
1039
+ message: `Failed to write file: ${error instanceof Error ? error.message : String(error)}`
1040
+ };
1041
+ }
1042
+ }
1043
+
1044
+ // src/cli/utils/name-transformer.ts
1045
+ var exports_name_transformer = {};
1046
+ __export(exports_name_transformer, {
1047
+ toSnakeCase: () => toSnakeCase,
1048
+ toScreamingSnakeCase: () => toScreamingSnakeCase,
1049
+ toPascalCase: () => toPascalCase,
1050
+ toKebabCase: () => toKebabCase,
1051
+ toCamelCase: () => toCamelCase,
1052
+ generateNameVariations: () => generateNameVariations
1053
+ });
1054
+ module.exports = __toCommonJS(exports_name_transformer);
1055
+ function toKebabCase(str) {
1056
+ return str.replace(/([a-z0-9])([A-Z])/g, "$1-$2").replace(/[\s_]+/g, "-").toLowerCase();
1057
+ }
1058
+ function toCamelCase(str) {
1059
+ return str.replace(/[-_\s]+(.)?/g, (_, c) => c ? c.toUpperCase() : "").replace(/^[A-Z]/, (c) => c.toLowerCase());
1060
+ }
1061
+ function toPascalCase(str) {
1062
+ const camel = toCamelCase(str);
1063
+ return camel.charAt(0).toUpperCase() + camel.slice(1);
1064
+ }
1065
+ function toSnakeCase(str) {
1066
+ return str.replace(/([a-z0-9])([A-Z])/g, "$1_$2").replace(/[\s-]+/g, "_").toLowerCase();
1067
+ }
1068
+ function toScreamingSnakeCase(str) {
1069
+ return toSnakeCase(str).toUpperCase();
1070
+ }
1071
+ function generateNameVariations(name) {
1072
+ return {
1073
+ original: name,
1074
+ kebab: toKebabCase(name),
1075
+ camel: toCamelCase(name),
1076
+ pascal: toPascalCase(name),
1077
+ snake: toSnakeCase(name),
1078
+ screamingSnake: toScreamingSnakeCase(name)
1079
+ };
1080
+ }
1081
+
1082
+ // src/cli/utils/path-resolver.ts
1083
+ var exports_path_resolver = {};
1084
+ __export(exports_path_resolver, {
1085
+ resolvePath: () => resolvePath,
1086
+ joinPaths: () => joinPaths,
1087
+ getRelativePath: () => getRelativePath,
1088
+ getImportPath: () => getImportPath
1089
+ });
1090
+ module.exports = __toCommonJS(exports_path_resolver);
1091
+ var import_node_path2 = require("node:path");
1092
+ function resolvePath(...segments) {
1093
+ return import_node_path2.resolve(...segments);
1094
+ }
1095
+ function joinPaths(...segments) {
1096
+ return import_node_path2.join(...segments);
1097
+ }
1098
+ function getRelativePath(from, to) {
1099
+ const relativePath = import_node_path2.relative(from, to);
1100
+ return relativePath.replace(/\\/g, "/");
1101
+ }
1102
+ function getImportPath(from, to) {
1103
+ const relPath = getRelativePath(import_node_path2.dirname(from), to);
1104
+ const withoutExt = relPath.replace(/\.(ts|js)$/, "");
1105
+ return withoutExt.startsWith(".") ? withoutExt : `./${withoutExt}`;
1106
+ }
1107
+
1108
+ // src/cli/utils/template-renderer.ts
1109
+ var exports_template_renderer = {};
1110
+ __export(exports_template_renderer, {
1111
+ renderTemplateString: () => renderTemplateString,
1112
+ renderTemplate: () => renderTemplate
1113
+ });
1114
+ module.exports = __toCommonJS(exports_template_renderer);
1115
+ var import_handlebars = __toESM(require("handlebars"));
1116
+ async function renderTemplate(templatePath, context) {
1117
+ try {
1118
+ const file = Bun.file(templatePath);
1119
+ if (!await file.exists()) {
1120
+ throw new Error(`Template file not found: ${templatePath}
1121
+ ` + "Please ensure the template exists or report this as a bug.");
1122
+ }
1123
+ const templateSource = await file.text();
1124
+ try {
1125
+ const template = import_handlebars.default.compile(templateSource);
1126
+ return template(context);
1127
+ } catch (compileError) {
1128
+ throw new Error(`Failed to compile template ${templatePath}: ` + `${compileError instanceof Error ? compileError.message : String(compileError)}
1129
+ ` + "This may indicate invalid Handlebars syntax in the template.");
1130
+ }
1131
+ } catch (error) {
1132
+ if (error instanceof Error && error.message.includes("Template file not found")) {
1133
+ throw error;
1134
+ }
1135
+ if (error instanceof Error && error.message.includes("Failed to compile template")) {
1136
+ throw error;
1137
+ }
1138
+ throw new Error(`Failed to read template ${templatePath}: ` + `${error instanceof Error ? error.message : String(error)}`);
1139
+ }
1140
+ }
1141
+ async function renderTemplateString(templateString, context) {
1142
+ try {
1143
+ const template = import_handlebars.default.compile(templateString);
1144
+ return template(context);
1145
+ } catch (error) {
1146
+ throw new Error("Failed to compile template string: " + `${error instanceof Error ? error.message : String(error)}
1147
+ ` + "This may indicate invalid Handlebars syntax.");
1148
+ }
1149
+ }
1150
+
1151
+ // src/cli/generators/base.generator.ts
1152
+ var exports_base_generator = {};
1153
+ __export(exports_base_generator, {
1154
+ BaseGenerator: () => BaseGenerator
1155
+ });
1156
+ module.exports = __toCommonJS(exports_base_generator);
1157
+ var import_node_path3 = require("node:path");
1158
+ var __dirname = "C:\\Users\\liorv\\OneDrive\\Desktop\\Projects\\Personal\\nestjs-adapter\\src\\cli\\generators";
1159
+
1160
+ class BaseGenerator {
1161
+ config;
1162
+ constructor(config) {
1163
+ this.config = config;
1164
+ }
1165
+ async renderTemplate(templatePath, context) {
1166
+ return renderTemplate(templatePath, context);
1167
+ }
1168
+ async writeFile(filePath, content, dryRun = false) {
1169
+ return writeFile(filePath, content, {
1170
+ dryRun,
1171
+ force: false
1172
+ });
1173
+ }
1174
+ getNameVariations(name) {
1175
+ return generateNameVariations(name);
1176
+ }
1177
+ resolvePath(relativePath) {
1178
+ return resolvePath(relativePath);
1179
+ }
1180
+ getTemplateDir(type) {
1181
+ const templatesRoot = import_node_path3.join(__dirname, "..", "templates");
1182
+ return import_node_path3.join(templatesRoot, type);
1183
+ }
1184
+ createTemplateContext(options, additionalContext = {}) {
1185
+ const names = this.getNameVariations(options.name);
1186
+ return {
1187
+ ...names,
1188
+ nameKebab: names.kebab,
1189
+ nameCamel: names.camel,
1190
+ namePascal: names.pascal,
1191
+ nameSnake: names.snake,
1192
+ nameScreamingSnake: names.screamingSnake,
1193
+ portSuffix: this.config.naming?.portSuffix ?? defaultConfig.naming.portSuffix,
1194
+ adapterSuffix: this.config.naming?.adapterSuffix ?? defaultConfig.naming.adapterSuffix,
1195
+ fileCase: this.config.naming?.fileCase ?? defaultConfig.naming.fileCase,
1196
+ indent: this.config.style?.indent ?? defaultConfig.style.indent,
1197
+ quotes: this.config.style?.quotes ?? defaultConfig.style.quotes,
1198
+ semicolons: this.config.style?.semicolons ?? defaultConfig.style.semicolons,
1199
+ includeModule: options.includeModule ?? true,
1200
+ includeService: options.includeService ?? true,
1201
+ registrationType: options.registrationType ?? "sync",
1202
+ generateExample: options.generateExample ?? false,
1203
+ coreImportPath: "nest-hex",
1204
+ ...additionalContext
1205
+ };
1206
+ }
1207
+ async generateFiles(files, dryRun = false) {
1208
+ const generatedFiles = [];
1209
+ const failures = [];
1210
+ for (const file of files) {
1211
+ const result = await this.writeFile(file.path, file.content, dryRun);
1212
+ if (result.success) {
1213
+ generatedFiles.push(file.path);
1214
+ } else {
1215
+ failures.push({
1216
+ path: file.path,
1217
+ error: result.message || "Unknown error"
1218
+ });
1219
+ console.error(`Failed to write ${file.path}: ${result.message}`);
1220
+ }
1221
+ }
1222
+ if (failures.length > 0) {
1223
+ const errorMsg = `Failed to generate ${failures.length} file(s):
1224
+ ` + failures.map((f) => ` - ${f.path}: ${f.error}`).join(`
1225
+ `);
1226
+ throw new Error(errorMsg);
1227
+ }
1228
+ return generatedFiles;
1229
+ }
1230
+ }
1231
+
1232
+ // src/cli/generators/adapter.generator.ts
1233
+ var exports_adapter_generator = {};
1234
+ __export(exports_adapter_generator, {
1235
+ AdapterGenerator: () => AdapterGenerator
1236
+ });
1237
+ module.exports = __toCommonJS(exports_adapter_generator);
1238
+ var import_node_path4 = require("node:path");
1239
+ class AdapterGenerator extends BaseGenerator {
1240
+ async generate(options) {
1241
+ const portNameVariations = options.portName ? this.getNameVariations(options.portName) : undefined;
1242
+ let portImportPath;
1243
+ if (portNameVariations && !options.portPath) {
1244
+ const portsDir = this.config.output?.portsDir || "ports";
1245
+ const adaptersDir = this.config.output?.adaptersDir || "adapters";
1246
+ const portsDirName = import_node_path4.basename(portsDir);
1247
+ const _adaptersDirName = import_node_path4.basename(adaptersDir);
1248
+ portImportPath = `../../${portsDirName}/${portNameVariations.kebab}`;
1249
+ }
1250
+ const context = this.createTemplateContext(options, {
1251
+ portName: options.portName,
1252
+ portPath: options.portPath,
1253
+ technology: options.technology,
1254
+ ...portNameVariations ? {
1255
+ portNameKebab: portNameVariations.kebab,
1256
+ portNamePascal: portNameVariations.pascal,
1257
+ portNameCamel: portNameVariations.camel,
1258
+ portNameScreamingSnake: portNameVariations.screamingSnake,
1259
+ portTokenName: options.portTokenName || `${portNameVariations.screamingSnake}_${this.config.naming?.portSuffix || "PORT"}`,
1260
+ portInterfaceName: `${portNameVariations.pascal}Port`,
1261
+ portImportPath: options.portPath || portImportPath
1262
+ } : {}
1263
+ });
1264
+ const templateDir = this.getTemplateDir("adapter");
1265
+ const outputDir = options.outputPath || this.resolvePath(this.config.output?.adaptersDir || "src/adapters");
1266
+ const adapterDir = import_node_path4.join(outputDir, context.nameKebab);
1267
+ const files = [];
1268
+ const adapterContent = await this.renderTemplate(import_node_path4.join(templateDir, "adapter.hbs"), context);
1269
+ files.push({
1270
+ path: import_node_path4.join(adapterDir, `${context.nameKebab}.adapter.ts`),
1271
+ content: adapterContent
1272
+ });
1273
+ const serviceContent = await this.renderTemplate(import_node_path4.join(templateDir, "service.hbs"), context);
1274
+ files.push({
1275
+ path: import_node_path4.join(adapterDir, `${context.nameKebab}.service.ts`),
1276
+ content: serviceContent
1277
+ });
1278
+ const typesContent = await this.renderTemplate(import_node_path4.join(templateDir, "types.hbs"), context);
1279
+ files.push({
1280
+ path: import_node_path4.join(adapterDir, `${context.nameKebab}.types.ts`),
1281
+ content: typesContent
1282
+ });
1283
+ const indexContent = await this.renderTemplate(import_node_path4.join(templateDir, "index.hbs"), context);
1284
+ files.push({
1285
+ path: import_node_path4.join(adapterDir, "index.ts"),
1286
+ content: indexContent
1287
+ });
1288
+ const generatedFiles = await this.generateFiles(files, options.dryRun);
1289
+ return {
1290
+ success: true,
1291
+ files: generatedFiles,
1292
+ message: `Successfully generated adapter files for ${context.namePascal}`
1293
+ };
1294
+ }
1295
+ }
1296
+
1297
+ // src/cli/generators/port.generator.ts
1298
+ var exports_port_generator = {};
1299
+ __export(exports_port_generator, {
1300
+ PortGenerator: () => PortGenerator
1301
+ });
1302
+ module.exports = __toCommonJS(exports_port_generator);
1303
+ var import_node_path5 = require("node:path");
1304
+ class PortGenerator extends BaseGenerator {
1305
+ async generate(options) {
1306
+ const context = this.createTemplateContext(options);
1307
+ const templateDir = this.getTemplateDir("port");
1308
+ const outputDir = options.outputPath || this.resolvePath(this.config.output?.portsDir || "src/ports");
1309
+ const portDir = import_node_path5.join(outputDir, context.nameKebab);
1310
+ const files = [];
1311
+ const interfaceContent = await this.renderTemplate(import_node_path5.join(templateDir, "interface.hbs"), context);
1312
+ files.push({
1313
+ path: import_node_path5.join(portDir, `${context.nameKebab}.port.ts`),
1314
+ content: interfaceContent
1315
+ });
1316
+ const tokenContent = await this.renderTemplate(import_node_path5.join(templateDir, "token.hbs"), context);
1317
+ files.push({
1318
+ path: import_node_path5.join(portDir, `${context.nameKebab}.token.ts`),
1319
+ content: tokenContent
1320
+ });
1321
+ if (context.includeService) {
1322
+ const serviceContent = await this.renderTemplate(import_node_path5.join(templateDir, "service.hbs"), context);
1323
+ files.push({
1324
+ path: import_node_path5.join(portDir, `${context.nameKebab}.service.ts`),
1325
+ content: serviceContent
1326
+ });
1327
+ }
1328
+ if (context.includeModule) {
1329
+ const moduleContent = await this.renderTemplate(import_node_path5.join(templateDir, "module.hbs"), context);
1330
+ files.push({
1331
+ path: import_node_path5.join(portDir, `${context.nameKebab}.module.ts`),
1332
+ content: moduleContent
1333
+ });
1334
+ }
1335
+ const indexContent = await this.renderTemplate(import_node_path5.join(templateDir, "index.hbs"), context);
1336
+ files.push({
1337
+ path: import_node_path5.join(portDir, "index.ts"),
1338
+ content: indexContent
1339
+ });
1340
+ const generatedFiles = await this.generateFiles(files, options.dryRun);
1341
+ return {
1342
+ success: true,
1343
+ files: generatedFiles,
1344
+ message: `Successfully generated port files for ${context.namePascal}`
1345
+ };
1346
+ }
1347
+ }
1348
+
1349
+ // src/cli/generators/service.generator.ts
1350
+ var exports_service_generator = {};
1351
+ __export(exports_service_generator, {
1352
+ ServiceGenerator: () => ServiceGenerator
1353
+ });
1354
+ module.exports = __toCommonJS(exports_service_generator);
1355
+ var import_node_path6 = require("node:path");
1356
+ class ServiceGenerator extends BaseGenerator {
1357
+ async generate(options) {
1358
+ const context = this.createTemplateContext(options);
1359
+ const templateDir = this.getTemplateDir("service");
1360
+ const outputDir = options.outputPath || this.resolvePath(this.config.output?.portsDir || "src/services");
1361
+ const serviceDir = import_node_path6.join(outputDir, context.nameKebab);
1362
+ const files = [];
1363
+ const serviceContent = await this.renderTemplate(import_node_path6.join(templateDir, "injectable-service.hbs"), context);
1364
+ files.push({
1365
+ path: import_node_path6.join(serviceDir, `${context.nameKebab}.service.ts`),
1366
+ content: serviceContent
1367
+ });
1368
+ const generatedFiles = await this.generateFiles(files, options.dryRun);
1369
+ return {
1370
+ success: true,
1371
+ files: generatedFiles,
1372
+ message: `Successfully generated ${generatedFiles.length} service file${generatedFiles.length !== 1 ? "s" : ""}`
1373
+ };
1374
+ }
1375
+ }
1376
+
1377
+ // src/cli/generators/index.ts
1378
+ var exports_generators = {};
1379
+ __export(exports_generators, {
1380
+ ServiceGenerator: () => ServiceGenerator,
1381
+ PortGenerator: () => PortGenerator,
1382
+ BaseGenerator: () => BaseGenerator,
1383
+ AdapterGenerator: () => AdapterGenerator
1384
+ });
1385
+ module.exports = __toCommonJS(exports_generators);
1386
+
1387
+ // src/cli/ui/components/index.ts
1388
+ var exports_components = {};
1389
+ __export(exports_components, {
1390
+ TypeSelector: () => TypeSelector,
1391
+ Summary: () => Summary,
1392
+ ProgressIndicator: () => ProgressIndicator,
1393
+ PortSelector: () => PortSelector,
1394
+ NameInput: () => NameInput,
1395
+ FileProgress: () => FileProgress,
1396
+ Confirm: () => Confirm,
1397
+ ComponentSelector: () => ComponentSelector
1398
+ });
1399
+ module.exports = __toCommonJS(exports_components);
1400
+
1401
+ // src/cli/ui/components/ComponentSelector.tsx
1402
+ var import_ui = require("@inkjs/ui");
1403
+ var import_ink = require("ink");
1404
+ var import_react = require("react");
1405
+ var jsx_dev_runtime = __toESM(require_jsx_dev_runtime(), 1);
1406
+ function ComponentSelector({
1407
+ options,
1408
+ onSubmit,
1409
+ title
1410
+ }) {
1411
+ const [selected, setSelected] = import_react.useState([]);
1412
+ return /* @__PURE__ */ jsx_dev_runtime.jsxDEV(import_ink.Box, {
1413
+ flexDirection: "column",
1414
+ children: [
1415
+ title && /* @__PURE__ */ jsx_dev_runtime.jsxDEV(import_ink.Box, {
1416
+ marginBottom: 1,
1417
+ children: /* @__PURE__ */ jsx_dev_runtime.jsxDEV(import_ink.Text, {
1418
+ bold: true,
1419
+ children: title
1420
+ }, undefined, false, undefined, this)
1421
+ }, undefined, false, undefined, this),
1422
+ /* @__PURE__ */ jsx_dev_runtime.jsxDEV(import_ui.MultiSelect, {
1423
+ options: options.map((opt) => ({
1424
+ label: opt.label,
1425
+ value: opt.value
1426
+ })),
1427
+ onChange: (values) => setSelected(values),
1428
+ onSubmit: () => onSubmit(selected)
1429
+ }, undefined, false, undefined, this),
1430
+ /* @__PURE__ */ jsx_dev_runtime.jsxDEV(import_ink.Box, {
1431
+ marginTop: 1,
1432
+ children: /* @__PURE__ */ jsx_dev_runtime.jsxDEV(import_ink.Text, {
1433
+ dimColor: true,
1434
+ children: [
1435
+ "Use ",
1436
+ /* @__PURE__ */ jsx_dev_runtime.jsxDEV(import_ink.Text, {
1437
+ bold: true,
1438
+ children: "space"
1439
+ }, undefined, false, undefined, this),
1440
+ " to select, ",
1441
+ /* @__PURE__ */ jsx_dev_runtime.jsxDEV(import_ink.Text, {
1442
+ bold: true,
1443
+ children: "enter"
1444
+ }, undefined, false, undefined, this),
1445
+ " to confirm"
1446
+ ]
1447
+ }, undefined, true, undefined, this)
1448
+ }, undefined, false, undefined, this)
1449
+ ]
1450
+ }, undefined, true, undefined, this);
1451
+ }
1452
+ // src/cli/ui/components/Confirm.tsx
1453
+ var import_ui2 = require("@inkjs/ui");
1454
+ var import_ink2 = require("ink");
1455
+ var jsx_dev_runtime2 = __toESM(require_jsx_dev_runtime(), 1);
1456
+ function Confirm({
1457
+ message,
1458
+ defaultValue = true,
1459
+ onSubmit
1460
+ }) {
1461
+ const options = [
1462
+ { label: "Yes", value: "yes" },
1463
+ { label: "No", value: "no" }
1464
+ ];
1465
+ return /* @__PURE__ */ jsx_dev_runtime2.jsxDEV(import_ink2.Box, {
1466
+ flexDirection: "column",
1467
+ children: [
1468
+ /* @__PURE__ */ jsx_dev_runtime2.jsxDEV(import_ink2.Box, {
1469
+ marginBottom: 1,
1470
+ children: /* @__PURE__ */ jsx_dev_runtime2.jsxDEV(import_ink2.Text, {
1471
+ children: message
1472
+ }, undefined, false, undefined, this)
1473
+ }, undefined, false, undefined, this),
1474
+ /* @__PURE__ */ jsx_dev_runtime2.jsxDEV(import_ui2.Select, {
1475
+ options,
1476
+ defaultValue: defaultValue ? "yes" : "no",
1477
+ onChange: (value) => onSubmit(value === "yes")
1478
+ }, undefined, false, undefined, this)
1479
+ ]
1480
+ }, undefined, true, undefined, this);
1481
+ }
1482
+ // src/cli/ui/components/FileProgress.tsx
1483
+ var import_ink3 = require("ink");
1484
+ var jsx_dev_runtime3 = __toESM(require_jsx_dev_runtime(), 1);
1485
+ function FileProgress({ fileName, status, error }) {
1486
+ const getStatusIcon = () => {
1487
+ switch (status) {
1488
+ case "completed":
1489
+ return /* @__PURE__ */ jsx_dev_runtime3.jsxDEV(import_ink3.Text, {
1490
+ color: "green",
1491
+ children: "✓"
1492
+ }, undefined, false, undefined, this);
1493
+ case "failed":
1494
+ return /* @__PURE__ */ jsx_dev_runtime3.jsxDEV(import_ink3.Text, {
1495
+ color: "red",
1496
+ children: "✗"
1497
+ }, undefined, false, undefined, this);
1498
+ case "skipped":
1499
+ return /* @__PURE__ */ jsx_dev_runtime3.jsxDEV(import_ink3.Text, {
1500
+ color: "yellow",
1501
+ children: "○"
1502
+ }, undefined, false, undefined, this);
1503
+ case "generating":
1504
+ return /* @__PURE__ */ jsx_dev_runtime3.jsxDEV(import_ink3.Text, {
1505
+ color: "cyan",
1506
+ children: "●"
1507
+ }, undefined, false, undefined, this);
1508
+ case "pending":
1509
+ return /* @__PURE__ */ jsx_dev_runtime3.jsxDEV(import_ink3.Text, {
1510
+ dimColor: true,
1511
+ children: "○"
1512
+ }, undefined, false, undefined, this);
1513
+ }
1514
+ };
1515
+ const getStatusColor = () => {
1516
+ switch (status) {
1517
+ case "completed":
1518
+ return "green";
1519
+ case "failed":
1520
+ return "red";
1521
+ case "skipped":
1522
+ return "yellow";
1523
+ case "generating":
1524
+ return "cyan";
1525
+ case "pending":
1526
+ return "gray";
1527
+ }
1528
+ };
1529
+ return /* @__PURE__ */ jsx_dev_runtime3.jsxDEV(import_ink3.Box, {
1530
+ flexDirection: "column",
1531
+ children: [
1532
+ /* @__PURE__ */ jsx_dev_runtime3.jsxDEV(import_ink3.Box, {
1533
+ flexDirection: "row",
1534
+ gap: 1,
1535
+ children: [
1536
+ getStatusIcon(),
1537
+ /* @__PURE__ */ jsx_dev_runtime3.jsxDEV(import_ink3.Text, {
1538
+ color: getStatusColor(),
1539
+ children: fileName
1540
+ }, undefined, false, undefined, this)
1541
+ ]
1542
+ }, undefined, true, undefined, this),
1543
+ error && /* @__PURE__ */ jsx_dev_runtime3.jsxDEV(import_ink3.Box, {
1544
+ marginLeft: 2,
1545
+ children: /* @__PURE__ */ jsx_dev_runtime3.jsxDEV(import_ink3.Text, {
1546
+ color: "red",
1547
+ children: [
1548
+ "Error: ",
1549
+ error
1550
+ ]
1551
+ }, undefined, true, undefined, this)
1552
+ }, undefined, false, undefined, this)
1553
+ ]
1554
+ }, undefined, true, undefined, this);
1555
+ }
1556
+ // src/cli/ui/components/NameInput.tsx
1557
+ var import_ui3 = require("@inkjs/ui");
1558
+ var import_ink4 = require("ink");
1559
+ var jsx_dev_runtime4 = __toESM(require_jsx_dev_runtime(), 1);
1560
+ function NameInput({ type, step, onSubmit }) {
1561
+ if (type === "full") {
1562
+ const currentStep = step || "port";
1563
+ const labels = {
1564
+ port: "Enter the PORT name",
1565
+ adapter: "Enter the ADAPTER name"
1566
+ };
1567
+ const placeholders2 = {
1568
+ port: "e.g., ObjectStorage, CurrencyRates",
1569
+ adapter: "e.g., S3, HttpRates"
1570
+ };
1571
+ return /* @__PURE__ */ jsx_dev_runtime4.jsxDEV(import_ink4.Box, {
1572
+ flexDirection: "column",
1573
+ padding: 1,
1574
+ children: [
1575
+ /* @__PURE__ */ jsx_dev_runtime4.jsxDEV(import_ink4.Box, {
1576
+ marginBottom: 1,
1577
+ children: /* @__PURE__ */ jsx_dev_runtime4.jsxDEV(import_ink4.Text, {
1578
+ bold: true,
1579
+ color: "cyan",
1580
+ children: [
1581
+ labels[currentStep],
1582
+ ":"
1583
+ ]
1584
+ }, undefined, true, undefined, this)
1585
+ }, undefined, false, undefined, this),
1586
+ /* @__PURE__ */ jsx_dev_runtime4.jsxDEV(import_ui3.TextInput, {
1587
+ placeholder: placeholders2[currentStep],
1588
+ onSubmit: (value) => {
1589
+ if (value.trim()) {
1590
+ onSubmit(value.trim());
1591
+ }
1592
+ }
1593
+ }, undefined, false, undefined, this),
1594
+ /* @__PURE__ */ jsx_dev_runtime4.jsxDEV(import_ink4.Box, {
1595
+ marginTop: 1,
1596
+ children: /* @__PURE__ */ jsx_dev_runtime4.jsxDEV(import_ink4.Text, {
1597
+ dimColor: true,
1598
+ children: "Press ← to go back"
1599
+ }, undefined, false, undefined, this)
1600
+ }, undefined, false, undefined, this)
1601
+ ]
1602
+ }, undefined, true, undefined, this);
1603
+ }
1604
+ const placeholders = {
1605
+ port: "e.g., ObjectStorage, CurrencyRates",
1606
+ adapter: "e.g., S3, HttpRates",
1607
+ service: "e.g., FileUpload, UserRegistration",
1608
+ full: ""
1609
+ };
1610
+ return /* @__PURE__ */ jsx_dev_runtime4.jsxDEV(import_ink4.Box, {
1611
+ flexDirection: "column",
1612
+ padding: 1,
1613
+ children: [
1614
+ /* @__PURE__ */ jsx_dev_runtime4.jsxDEV(import_ink4.Box, {
1615
+ marginBottom: 1,
1616
+ children: /* @__PURE__ */ jsx_dev_runtime4.jsxDEV(import_ink4.Text, {
1617
+ bold: true,
1618
+ color: "cyan",
1619
+ children: [
1620
+ "Enter the name for your ",
1621
+ type,
1622
+ ":"
1623
+ ]
1624
+ }, undefined, true, undefined, this)
1625
+ }, undefined, false, undefined, this),
1626
+ /* @__PURE__ */ jsx_dev_runtime4.jsxDEV(import_ui3.TextInput, {
1627
+ placeholder: placeholders[type],
1628
+ onSubmit: (value) => {
1629
+ if (value.trim()) {
1630
+ onSubmit(value.trim());
1631
+ }
1632
+ }
1633
+ }, undefined, false, undefined, this),
1634
+ /* @__PURE__ */ jsx_dev_runtime4.jsxDEV(import_ink4.Box, {
1635
+ marginTop: 1,
1636
+ children: /* @__PURE__ */ jsx_dev_runtime4.jsxDEV(import_ink4.Text, {
1637
+ dimColor: true,
1638
+ children: [
1639
+ "Press ← to go back",
1640
+ type === "adapter" && " to port selection"
1641
+ ]
1642
+ }, undefined, true, undefined, this)
1643
+ }, undefined, false, undefined, this)
1644
+ ]
1645
+ }, undefined, true, undefined, this);
1646
+ }
1647
+ // src/cli/ui/components/PortSelector.tsx
1648
+ var import_ui4 = require("@inkjs/ui");
1649
+ var import_ink5 = require("ink");
1650
+ var jsx_dev_runtime5 = __toESM(require_jsx_dev_runtime(), 1);
1651
+ function PortSelector({ ports, onSubmit }) {
1652
+ if (ports.length === 0) {
1653
+ return /* @__PURE__ */ jsx_dev_runtime5.jsxDEV(import_ink5.Box, {
1654
+ flexDirection: "column",
1655
+ padding: 1,
1656
+ children: [
1657
+ /* @__PURE__ */ jsx_dev_runtime5.jsxDEV(import_ink5.Text, {
1658
+ color: "yellow",
1659
+ bold: true,
1660
+ children: "⚠ No ports found"
1661
+ }, undefined, false, undefined, this),
1662
+ /* @__PURE__ */ jsx_dev_runtime5.jsxDEV(import_ink5.Box, {
1663
+ marginTop: 1,
1664
+ children: /* @__PURE__ */ jsx_dev_runtime5.jsxDEV(import_ink5.Text, {
1665
+ children: "You must create a port before generating an adapter."
1666
+ }, undefined, false, undefined, this)
1667
+ }, undefined, false, undefined, this),
1668
+ /* @__PURE__ */ jsx_dev_runtime5.jsxDEV(import_ink5.Box, {
1669
+ marginTop: 1,
1670
+ children: [
1671
+ /* @__PURE__ */ jsx_dev_runtime5.jsxDEV(import_ink5.Text, {
1672
+ dimColor: true,
1673
+ children: "Generate a port first:"
1674
+ }, undefined, false, undefined, this),
1675
+ /* @__PURE__ */ jsx_dev_runtime5.jsxDEV(import_ink5.Text, {
1676
+ color: "cyan",
1677
+ children: " nest-hex generate port"
1678
+ }, undefined, false, undefined, this)
1679
+ ]
1680
+ }, undefined, true, undefined, this),
1681
+ /* @__PURE__ */ jsx_dev_runtime5.jsxDEV(import_ink5.Box, {
1682
+ marginTop: 1,
1683
+ children: /* @__PURE__ */ jsx_dev_runtime5.jsxDEV(import_ink5.Text, {
1684
+ dimColor: true,
1685
+ children: "Press ← to go back"
1686
+ }, undefined, false, undefined, this)
1687
+ }, undefined, false, undefined, this)
1688
+ ]
1689
+ }, undefined, true, undefined, this);
1690
+ }
1691
+ const options = ports.map((port2) => ({
1692
+ label: port2.pascalName,
1693
+ value: port2.name
1694
+ }));
1695
+ return /* @__PURE__ */ jsx_dev_runtime5.jsxDEV(import_ink5.Box, {
1696
+ flexDirection: "column",
1697
+ padding: 1,
1698
+ children: [
1699
+ /* @__PURE__ */ jsx_dev_runtime5.jsxDEV(import_ink5.Box, {
1700
+ marginBottom: 1,
1701
+ children: /* @__PURE__ */ jsx_dev_runtime5.jsxDEV(import_ink5.Text, {
1702
+ bold: true,
1703
+ children: "Select Port to Implement"
1704
+ }, undefined, false, undefined, this)
1705
+ }, undefined, false, undefined, this),
1706
+ /* @__PURE__ */ jsx_dev_runtime5.jsxDEV(import_ui4.Select, {
1707
+ options,
1708
+ onChange: (selectedValue) => {
1709
+ const selectedPort = ports.find((p) => p.name === selectedValue);
1710
+ if (selectedPort) {
1711
+ onSubmit(selectedPort);
1712
+ }
1713
+ }
1714
+ }, undefined, false, undefined, this),
1715
+ /* @__PURE__ */ jsx_dev_runtime5.jsxDEV(import_ink5.Box, {
1716
+ marginTop: 1,
1717
+ flexDirection: "column",
1718
+ children: [
1719
+ /* @__PURE__ */ jsx_dev_runtime5.jsxDEV(import_ink5.Text, {
1720
+ dimColor: true,
1721
+ children: "This adapter will implement the selected port interface"
1722
+ }, undefined, false, undefined, this),
1723
+ /* @__PURE__ */ jsx_dev_runtime5.jsxDEV(import_ink5.Text, {
1724
+ dimColor: true,
1725
+ children: "Press ← to go back to type selection"
1726
+ }, undefined, false, undefined, this)
1727
+ ]
1728
+ }, undefined, true, undefined, this)
1729
+ ]
1730
+ }, undefined, true, undefined, this);
1731
+ }
1732
+ // src/cli/ui/components/ProgressIndicator.tsx
1733
+ var import_ui5 = require("@inkjs/ui");
1734
+ var import_ink6 = require("ink");
1735
+ var jsx_dev_runtime6 = __toESM(require_jsx_dev_runtime(), 1);
1736
+ function ProgressIndicator({ steps, title }) {
1737
+ return /* @__PURE__ */ jsx_dev_runtime6.jsxDEV(import_ink6.Box, {
1738
+ flexDirection: "column",
1739
+ paddingY: 1,
1740
+ children: [
1741
+ title && /* @__PURE__ */ jsx_dev_runtime6.jsxDEV(import_ink6.Box, {
1742
+ marginBottom: 1,
1743
+ children: /* @__PURE__ */ jsx_dev_runtime6.jsxDEV(import_ink6.Text, {
1744
+ bold: true,
1745
+ children: title
1746
+ }, undefined, false, undefined, this)
1747
+ }, undefined, false, undefined, this),
1748
+ steps.map((step) => /* @__PURE__ */ jsx_dev_runtime6.jsxDEV(import_ink6.Box, {
1749
+ flexDirection: "row",
1750
+ gap: 1,
1751
+ children: [
1752
+ step.status === "in_progress" && /* @__PURE__ */ jsx_dev_runtime6.jsxDEV(import_ui5.Spinner, {
1753
+ type: "dots"
1754
+ }, undefined, false, undefined, this),
1755
+ step.status === "completed" && /* @__PURE__ */ jsx_dev_runtime6.jsxDEV(import_ink6.Text, {
1756
+ color: "green",
1757
+ children: "✓"
1758
+ }, undefined, false, undefined, this),
1759
+ step.status === "failed" && /* @__PURE__ */ jsx_dev_runtime6.jsxDEV(import_ink6.Text, {
1760
+ color: "red",
1761
+ children: "✗"
1762
+ }, undefined, false, undefined, this),
1763
+ step.status === "pending" && /* @__PURE__ */ jsx_dev_runtime6.jsxDEV(import_ink6.Text, {
1764
+ dimColor: true,
1765
+ children: "○"
1766
+ }, undefined, false, undefined, this),
1767
+ /* @__PURE__ */ jsx_dev_runtime6.jsxDEV(import_ink6.Text, {
1768
+ color: step.status === "completed" ? "green" : step.status === "failed" ? "red" : step.status === "in_progress" ? "cyan" : "gray",
1769
+ children: step.label
1770
+ }, undefined, false, undefined, this),
1771
+ step.message && /* @__PURE__ */ jsx_dev_runtime6.jsxDEV(import_ink6.Text, {
1772
+ dimColor: true,
1773
+ children: [
1774
+ " - ",
1775
+ step.message
1776
+ ]
1777
+ }, undefined, true, undefined, this)
1778
+ ]
1779
+ }, step.id, true, undefined, this))
1780
+ ]
1781
+ }, undefined, true, undefined, this);
1782
+ }
1783
+ // src/cli/ui/components/Summary.tsx
1784
+ var import_node_path7 = require("node:path");
1785
+ var import_ink7 = require("ink");
1786
+ var jsx_dev_runtime7 = __toESM(require_jsx_dev_runtime(), 1);
1787
+ function toFileUrl(absolutePath) {
1788
+ const normalizedPath = absolutePath.replace(/\\/g, "/");
1789
+ if (normalizedPath.match(/^[A-Za-z]:/)) {
1790
+ return `file:///${normalizedPath}`;
1791
+ }
1792
+ return `file://${normalizedPath}`;
1793
+ }
1794
+ function createHyperlink(text, url) {
1795
+ const OSC = "\x1B]";
1796
+ const BEL = "\x07";
1797
+ const SEP = ";";
1798
+ return `${OSC}8${SEP}${SEP}${url}${BEL}${text}${OSC}8${SEP}${SEP}${BEL}`;
1799
+ }
1800
+ function Summary({
1801
+ success,
1802
+ filesGenerated,
1803
+ totalFiles,
1804
+ duration,
1805
+ outputPath,
1806
+ files,
1807
+ tips
1808
+ }) {
1809
+ return /* @__PURE__ */ jsx_dev_runtime7.jsxDEV(import_ink7.Box, {
1810
+ flexDirection: "column",
1811
+ paddingY: 1,
1812
+ children: [
1813
+ /* @__PURE__ */ jsx_dev_runtime7.jsxDEV(import_ink7.Box, {
1814
+ marginBottom: 1,
1815
+ children: success ? /* @__PURE__ */ jsx_dev_runtime7.jsxDEV(import_ink7.Text, {
1816
+ color: "green",
1817
+ bold: true,
1818
+ children: [
1819
+ "✅ Successfully generated ",
1820
+ filesGenerated,
1821
+ "/",
1822
+ totalFiles,
1823
+ " files",
1824
+ duration ? ` in ${(duration / 1000).toFixed(1)}s` : ""
1825
+ ]
1826
+ }, undefined, true, undefined, this) : /* @__PURE__ */ jsx_dev_runtime7.jsxDEV(import_ink7.Text, {
1827
+ color: "red",
1828
+ bold: true,
1829
+ children: "❌ Generation failed"
1830
+ }, undefined, false, undefined, this)
1831
+ }, undefined, false, undefined, this),
1832
+ outputPath && /* @__PURE__ */ jsx_dev_runtime7.jsxDEV(import_ink7.Box, {
1833
+ marginBottom: 1,
1834
+ children: /* @__PURE__ */ jsx_dev_runtime7.jsxDEV(import_ink7.Text, {
1835
+ dimColor: true,
1836
+ children: [
1837
+ "Output: ",
1838
+ outputPath
1839
+ ]
1840
+ }, undefined, true, undefined, this)
1841
+ }, undefined, false, undefined, this),
1842
+ files && files.length > 0 && /* @__PURE__ */ jsx_dev_runtime7.jsxDEV(import_ink7.Box, {
1843
+ flexDirection: "column",
1844
+ marginTop: 1,
1845
+ marginBottom: 1,
1846
+ children: [
1847
+ /* @__PURE__ */ jsx_dev_runtime7.jsxDEV(import_ink7.Text, {
1848
+ bold: true,
1849
+ children: "\uD83D\uDCC1 Generated files:"
1850
+ }, undefined, false, undefined, this),
1851
+ files.map((file, index) => {
1852
+ const relativePath = import_node_path7.relative(process.cwd(), file);
1853
+ const fileUrl = toFileUrl(file);
1854
+ const linkText = createHyperlink(relativePath, fileUrl);
1855
+ return /* @__PURE__ */ jsx_dev_runtime7.jsxDEV(import_ink7.Box, {
1856
+ marginLeft: 2,
1857
+ children: [
1858
+ /* @__PURE__ */ jsx_dev_runtime7.jsxDEV(import_ink7.Text, {
1859
+ dimColor: true,
1860
+ children: "• "
1861
+ }, undefined, false, undefined, this),
1862
+ /* @__PURE__ */ jsx_dev_runtime7.jsxDEV(import_ink7.Text, {
1863
+ color: "cyan",
1864
+ children: linkText
1865
+ }, undefined, false, undefined, this)
1866
+ ]
1867
+ }, index, true, undefined, this);
1868
+ })
1869
+ ]
1870
+ }, undefined, true, undefined, this),
1871
+ tips && tips.length > 0 && /* @__PURE__ */ jsx_dev_runtime7.jsxDEV(import_ink7.Box, {
1872
+ flexDirection: "column",
1873
+ marginTop: 1,
1874
+ children: [
1875
+ /* @__PURE__ */ jsx_dev_runtime7.jsxDEV(import_ink7.Text, {
1876
+ bold: true,
1877
+ children: "\uD83D\uDCA1 Next steps:"
1878
+ }, undefined, false, undefined, this),
1879
+ tips.map((tip, index) => /* @__PURE__ */ jsx_dev_runtime7.jsxDEV(import_ink7.Box, {
1880
+ marginLeft: 2,
1881
+ children: /* @__PURE__ */ jsx_dev_runtime7.jsxDEV(import_ink7.Text, {
1882
+ children: [
1883
+ "• ",
1884
+ tip
1885
+ ]
1886
+ }, undefined, true, undefined, this)
1887
+ }, index, false, undefined, this))
1888
+ ]
1889
+ }, undefined, true, undefined, this)
1890
+ ]
1891
+ }, undefined, true, undefined, this);
1892
+ }
1893
+ // src/cli/ui/components/TypeSelector.tsx
1894
+ var import_ui6 = require("@inkjs/ui");
1895
+ var import_ink8 = require("ink");
1896
+ var import_react2 = require("react");
1897
+ var jsx_dev_runtime8 = __toESM(require_jsx_dev_runtime(), 1);
1898
+ function TypeSelector({ onSubmit }) {
1899
+ const [_selectedType, setSelectedType] = import_react2.useState();
1900
+ const options = [
1901
+ {
1902
+ label: "Port - Create domain capability (token, interface, service, module)",
1903
+ value: "port"
1904
+ },
1905
+ {
1906
+ label: "Adapter - Create infrastructure implementation for a port",
1907
+ value: "adapter"
1908
+ },
1909
+ {
1910
+ label: "Service - Create service with @InjectPort usage",
1911
+ value: "service"
1912
+ },
1913
+ {
1914
+ label: "Full - Generate both port and adapter together",
1915
+ value: "full"
1916
+ }
1917
+ ];
1918
+ return /* @__PURE__ */ jsx_dev_runtime8.jsxDEV(import_ink8.Box, {
1919
+ flexDirection: "column",
1920
+ children: [
1921
+ /* @__PURE__ */ jsx_dev_runtime8.jsxDEV(import_ink8.Box, {
1922
+ marginBottom: 1,
1923
+ children: /* @__PURE__ */ jsx_dev_runtime8.jsxDEV(import_ink8.Text, {
1924
+ bold: true,
1925
+ color: "cyan",
1926
+ children: "What do you want to generate?"
1927
+ }, undefined, false, undefined, this)
1928
+ }, undefined, false, undefined, this),
1929
+ /* @__PURE__ */ jsx_dev_runtime8.jsxDEV(import_ui6.Select, {
1930
+ options,
1931
+ onChange: (value) => {
1932
+ setSelectedType(value);
1933
+ onSubmit(value);
1934
+ }
1935
+ }, undefined, false, undefined, this)
1936
+ ]
1937
+ }, undefined, true, undefined, this);
1938
+ }
1939
+ // src/cli/utils/linter-detector.ts
1940
+ var exports_linter_detector = {};
1941
+ __export(exports_linter_detector, {
1942
+ detectLinter: () => detectLinter
1943
+ });
1944
+ module.exports = __toCommonJS(exports_linter_detector);
1945
+ var import_node_fs = require("node:fs");
1946
+ var import_node_path8 = require("node:path");
1947
+ async function detectLinter(projectRoot) {
1948
+ const biomeConfigExists = import_node_fs.existsSync(import_node_path8.join(projectRoot, "biome.json")) || import_node_fs.existsSync(import_node_path8.join(projectRoot, "biome.jsonc"));
1949
+ const packageJsonPath = import_node_path8.join(projectRoot, "package.json");
1950
+ let packageJson = {};
1951
+ if (import_node_fs.existsSync(packageJsonPath)) {
1952
+ try {
1953
+ packageJson = JSON.parse(import_node_fs.readFileSync(packageJsonPath, "utf-8"));
1954
+ } catch (error) {
1955
+ console.warn(`Warning: Failed to parse package.json at ${packageJsonPath}`);
1956
+ console.warn(`Error: ${error instanceof Error ? error.message : String(error)}`);
1957
+ console.warn(`Continuing with linter detection using config files only...
1958
+ `);
1959
+ }
1960
+ }
1961
+ const hasBiomeDep = packageJson.devDependencies?.["@biomejs/biome"] || packageJson.devDependencies?.biome;
1962
+ if (biomeConfigExists || hasBiomeDep) {
1963
+ return {
1964
+ type: "biome",
1965
+ command: "biome",
1966
+ args: ["check", "--write"],
1967
+ description: "Formatting with Biome"
1968
+ };
1969
+ }
1970
+ const prettierConfigFiles = [
1971
+ ".prettierrc",
1972
+ ".prettierrc.json",
1973
+ ".prettierrc.yml",
1974
+ ".prettierrc.yaml",
1975
+ ".prettierrc.js",
1976
+ ".prettierrc.cjs",
1977
+ "prettier.config.js",
1978
+ "prettier.config.cjs"
1979
+ ];
1980
+ const prettierConfigExists = prettierConfigFiles.some((file) => import_node_fs.existsSync(import_node_path8.join(projectRoot, file)));
1981
+ const hasPrettierDep = packageJson.devDependencies?.prettier;
1982
+ if (prettierConfigExists || hasPrettierDep) {
1983
+ return {
1984
+ type: "prettier",
1985
+ command: "prettier",
1986
+ args: ["--write"],
1987
+ description: "Formatting with Prettier"
1988
+ };
1989
+ }
1990
+ const lintScripts = packageJson.scripts;
1991
+ if (lintScripts) {
1992
+ if (lintScripts["lint:fix"]) {
1993
+ return {
1994
+ type: "script",
1995
+ command: "bun",
1996
+ args: ["run", "lint:fix"],
1997
+ description: "Running lint:fix script"
1998
+ };
1999
+ }
2000
+ if (lintScripts.lint) {
2001
+ return {
2002
+ type: "script",
2003
+ command: "bun",
2004
+ args: ["run", "lint"],
2005
+ description: "Running lint script"
2006
+ };
2007
+ }
2008
+ }
2009
+ return {
2010
+ type: "none",
2011
+ description: "No linter detected"
2012
+ };
2013
+ }
2014
+
2015
+ // src/cli/utils/linter-runner.ts
2016
+ var exports_linter_runner = {};
2017
+ __export(exports_linter_runner, {
2018
+ runLinter: () => runLinter
2019
+ });
2020
+ module.exports = __toCommonJS(exports_linter_runner);
2021
+ var import_node_child_process = require("node:child_process");
2022
+ async function runLinter(linterConfig, files, cwd) {
2023
+ if (linterConfig.type === "none" || !linterConfig.command || !linterConfig.args) {
2024
+ return {
2025
+ success: true,
2026
+ stdout: "",
2027
+ stderr: "",
2028
+ code: 0
2029
+ };
2030
+ }
2031
+ return new Promise((resolve2) => {
2032
+ const args = linterConfig.args || [];
2033
+ const command = `${linterConfig.command} ${args.join(" ")} ${files.join(" ")}`;
2034
+ import_node_child_process.exec(command, { cwd }, (error, stdout, stderr) => {
2035
+ const noFilesProcessed = stderr.includes("No files were processed") || stdout.includes("No files were processed") || stdout.includes("Checked 0 files");
2036
+ if (error) {
2037
+ if (noFilesProcessed) {
2038
+ resolve2({
2039
+ success: true,
2040
+ stdout,
2041
+ stderr,
2042
+ code: 0
2043
+ });
2044
+ } else {
2045
+ resolve2({
2046
+ success: false,
2047
+ stdout,
2048
+ stderr,
2049
+ code: error.code ?? null
2050
+ });
2051
+ }
2052
+ } else {
2053
+ resolve2({
2054
+ success: true,
2055
+ stdout,
2056
+ stderr,
2057
+ code: 0
2058
+ });
2059
+ }
2060
+ });
2061
+ });
2062
+ }
2063
+
2064
+ // src/cli/utils/port-scanner.ts
2065
+ var exports_port_scanner = {};
2066
+ __export(exports_port_scanner, {
2067
+ scanAvailablePorts: () => scanAvailablePorts,
2068
+ findPortByName: () => findPortByName
2069
+ });
2070
+ module.exports = __toCommonJS(exports_port_scanner);
2071
+ var import_node_fs2 = require("node:fs");
2072
+ var import_node_path9 = require("node:path");
2073
+ function scanAvailablePorts(config, projectRoot = process.cwd()) {
2074
+ const portsDir = config.output?.portsDir || "src/ports";
2075
+ const portsDirPath = import_node_path9.join(projectRoot, portsDir);
2076
+ if (!import_node_fs2.existsSync(portsDirPath)) {
2077
+ return [];
2078
+ }
2079
+ const ports = [];
2080
+ const entries = import_node_fs2.readdirSync(portsDirPath, { withFileTypes: true });
2081
+ for (const entry of entries) {
2082
+ if (!entry.isDirectory()) {
2083
+ continue;
2084
+ }
2085
+ const portName = entry.name;
2086
+ const portPath = import_node_path9.join(portsDirPath, portName);
2087
+ const tokenFileName = `${portName}.token.ts`;
2088
+ const tokenFilePath = import_node_path9.join(portPath, tokenFileName);
2089
+ if (!import_node_fs2.existsSync(tokenFilePath)) {
2090
+ continue;
2091
+ }
2092
+ const tokenFileContent = import_node_fs2.readFileSync(tokenFilePath, "utf-8");
2093
+ const tokenMatch = tokenFileContent.match(/export\s+const\s+([A-Z_]+)\s*=\s*Symbol/);
2094
+ if (!tokenMatch || !tokenMatch[1]) {
2095
+ continue;
2096
+ }
2097
+ const tokenName = tokenMatch[1];
2098
+ const pascalName = portName.split("-").map((part) => part.charAt(0).toUpperCase() + part.slice(1)).join("");
2099
+ const portsDirName = portsDir.split("/").pop() || "ports";
2100
+ const tokenImportPath = `../../${portsDirName}/${portName}`;
2101
+ ports.push({
2102
+ name: portName,
2103
+ pascalName,
2104
+ tokenName,
2105
+ tokenImportPath,
2106
+ portPath
2107
+ });
2108
+ }
2109
+ return ports;
2110
+ }
2111
+ function findPortByName(portName, config, projectRoot = process.cwd()) {
2112
+ const ports = scanAvailablePorts(config, projectRoot);
2113
+ return ports.find((p) => p.name === portName) || null;
2114
+ }
2115
+
2116
+ // src/cli/commands/index.ts
2117
+ var exports_commands = {};
2118
+ __export(exports_commands, {
2119
+ initCommand: () => initCommand,
2120
+ generateCommand: () => generateCommand
2121
+ });
2122
+ module.exports = __toCommonJS(exports_commands);
2123
+
2124
+ // src/cli/commands/generate.command.tsx
2125
+ var import_ink9 = require("ink");
2126
+ var import_react3 = require("react");
2127
+ var jsx_dev_runtime9 = __toESM(require_jsx_dev_runtime(), 1);
2128
+ function GenerateUI({ options }) {
2129
+ const [selectedType, setSelectedType] = import_react3.useState(options.type);
2130
+ const [selectedName, setSelectedName] = import_react3.useState(options.name);
2131
+ const [portName, setPortName] = import_react3.useState(options.portName);
2132
+ const [adapterName, setAdapterName] = import_react3.useState(options.adapterName);
2133
+ const [selectedPortInfo, setSelectedPortInfo] = import_react3.useState(null);
2134
+ const [availablePorts, setAvailablePorts] = import_react3.useState([]);
2135
+ const [portsLoaded, setPortsLoaded] = import_react3.useState(false);
2136
+ const [showTypeSelector, setShowTypeSelector] = import_react3.useState(!options.type);
2137
+ const [showPortSelector, setShowPortSelector] = import_react3.useState(false);
2138
+ const [showNameInput, setShowNameInput] = import_react3.useState(() => {
2139
+ if (!options.type)
2140
+ return false;
2141
+ if (options.type === "full") {
2142
+ return !options.portName || !options.adapterName;
2143
+ }
2144
+ return !options.name;
2145
+ });
2146
+ const [nameInputStep, setNameInputStep] = import_react3.useState(() => {
2147
+ if (options.type === "full" && options.portName && !options.adapterName) {
2148
+ return "adapter";
2149
+ }
2150
+ return "port";
2151
+ });
2152
+ const [steps, setSteps] = import_react3.useState([]);
2153
+ const [_files, _setFiles] = import_react3.useState([]);
2154
+ const [result, setResult] = import_react3.useState(null);
2155
+ const [error, setError] = import_react3.useState(null);
2156
+ const handleTypeSelect = (type) => {
2157
+ setSelectedType(type);
2158
+ setShowTypeSelector(false);
2159
+ if (type === "adapter" && !options.name) {
2160
+ setShowPortSelector(true);
2161
+ } else if (!options.name) {
2162
+ setShowNameInput(true);
2163
+ if (type === "full") {
2164
+ setNameInputStep("port");
2165
+ }
2166
+ }
2167
+ };
2168
+ const handlePortSelect = (portInfo) => {
2169
+ setSelectedPortInfo(portInfo);
2170
+ setShowPortSelector(false);
2171
+ setShowNameInput(true);
2172
+ };
2173
+ const handlePortBack = () => {
2174
+ setShowPortSelector(false);
2175
+ setShowTypeSelector(true);
2176
+ setSelectedType(undefined);
2177
+ };
2178
+ import_ink9.useInput((_input, key) => {
2179
+ if (key.leftArrow) {
2180
+ if (showPortSelector) {
2181
+ handlePortBack();
2182
+ } else if (showNameInput && !result && !error) {
2183
+ if (selectedType === "adapter") {
2184
+ setShowNameInput(false);
2185
+ setShowPortSelector(true);
2186
+ } else if (selectedType === "full") {
2187
+ if (nameInputStep === "adapter") {
2188
+ setNameInputStep("port");
2189
+ setAdapterName(undefined);
2190
+ } else {
2191
+ setShowNameInput(false);
2192
+ setShowTypeSelector(true);
2193
+ setSelectedType(undefined);
2194
+ }
2195
+ } else {
2196
+ setShowNameInput(false);
2197
+ setShowTypeSelector(true);
2198
+ setSelectedType(undefined);
2199
+ }
2200
+ }
2201
+ }
2202
+ });
2203
+ const handleNameInput = (name) => {
2204
+ if (selectedType === "full") {
2205
+ if (nameInputStep === "port") {
2206
+ setPortName(name);
2207
+ setNameInputStep("adapter");
2208
+ } else {
2209
+ setAdapterName(name);
2210
+ setShowNameInput(false);
2211
+ }
2212
+ } else {
2213
+ setSelectedName(name);
2214
+ setShowNameInput(false);
2215
+ }
2216
+ };
2217
+ import_react3.useEffect(() => {
2218
+ if (showPortSelector && !portsLoaded) {
2219
+ loadConfig().then((cfg) => {
2220
+ const ports = scanAvailablePorts(cfg);
2221
+ setAvailablePorts(ports);
2222
+ setPortsLoaded(true);
2223
+ });
2224
+ }
2225
+ }, [showPortSelector, portsLoaded]);
2226
+ import_react3.useEffect(() => {
2227
+ if (!selectedType) {
2228
+ return;
2229
+ }
2230
+ if (selectedType === "full") {
2231
+ if (!portName || !adapterName) {
2232
+ return;
2233
+ }
2234
+ } else {
2235
+ if (!selectedName) {
2236
+ return;
2237
+ }
2238
+ }
2239
+ async function generate() {
2240
+ try {
2241
+ setSteps([
2242
+ {
2243
+ id: "config",
2244
+ label: "Loading configuration",
2245
+ status: "in_progress"
2246
+ }
2247
+ ]);
2248
+ const config = await loadConfig();
2249
+ setSteps((prev) => prev.map((s) => s.id === "config" ? { ...s, status: "completed" } : s));
2250
+ setSteps((prev) => [
2251
+ ...prev,
2252
+ {
2253
+ id: "generate",
2254
+ label: "Generating files",
2255
+ status: "in_progress"
2256
+ }
2257
+ ]);
2258
+ const type = selectedType;
2259
+ let genResult;
2260
+ if (type === "full" && portName && adapterName) {
2261
+ const port2 = portName;
2262
+ const adapter2 = adapterName;
2263
+ const portGenerator = new PortGenerator(config);
2264
+ const portResult = await portGenerator.generate({
2265
+ name: port2,
2266
+ outputPath: options.outputPath,
2267
+ dryRun: options.dryRun
2268
+ });
2269
+ const adapterGenerator = new AdapterGenerator(config);
2270
+ const adapterResult = await adapterGenerator.generate({
2271
+ name: adapter2,
2272
+ portName: port2,
2273
+ outputPath: options.outputPath,
2274
+ dryRun: options.dryRun
2275
+ });
2276
+ genResult = {
2277
+ success: portResult.success && adapterResult.success,
2278
+ files: [
2279
+ ...portResult.files || [],
2280
+ ...adapterResult.files || []
2281
+ ],
2282
+ message: portResult.success && adapterResult.success ? `Generated port '${port2}' and adapter '${adapter2}'` : "Some files failed to generate"
2283
+ };
2284
+ } else if (selectedName) {
2285
+ const name = selectedName;
2286
+ let generator;
2287
+ switch (type) {
2288
+ case "port": {
2289
+ generator = new PortGenerator(config);
2290
+ const portOptions = {
2291
+ name,
2292
+ outputPath: options.outputPath,
2293
+ dryRun: options.dryRun
2294
+ };
2295
+ genResult = await generator.generate(portOptions);
2296
+ break;
2297
+ }
2298
+ case "adapter": {
2299
+ generator = new AdapterGenerator(config);
2300
+ const adapterOptions = {
2301
+ name,
2302
+ portName: selectedPortInfo?.name || options.port,
2303
+ portPath: selectedPortInfo?.tokenImportPath,
2304
+ portTokenName: selectedPortInfo?.tokenName,
2305
+ outputPath: options.outputPath,
2306
+ dryRun: options.dryRun
2307
+ };
2308
+ genResult = await generator.generate(adapterOptions);
2309
+ break;
2310
+ }
2311
+ case "service": {
2312
+ generator = new ServiceGenerator(config);
2313
+ const serviceOptions = {
2314
+ name,
2315
+ outputPath: options.outputPath,
2316
+ dryRun: options.dryRun
2317
+ };
2318
+ genResult = await generator.generate(serviceOptions);
2319
+ break;
2320
+ }
2321
+ default:
2322
+ throw new Error(`Unknown generator type: ${type}`);
2323
+ }
2324
+ } else {
2325
+ throw new Error("Invalid state: selectedName is required for non-full generator types");
2326
+ }
2327
+ setResult(genResult);
2328
+ setSteps((prev) => prev.map((s) => s.id === "generate" ? { ...s, status: "completed" } : s));
2329
+ if (!options.noLint && !options.dryRun && genResult.success) {
2330
+ setSteps((prev) => [
2331
+ ...prev,
2332
+ {
2333
+ id: "lint",
2334
+ label: "Linting files",
2335
+ status: "in_progress"
2336
+ }
2337
+ ]);
2338
+ const linterConfig = await detectLinter(process.cwd());
2339
+ if (linterConfig.type !== "none" && genResult.files) {
2340
+ const lintResult = await runLinter(linterConfig, genResult.files, process.cwd());
2341
+ setSteps((prev) => prev.map((s) => s.id === "lint" ? {
2342
+ ...s,
2343
+ status: lintResult.success ? "completed" : "failed",
2344
+ message: lintResult.success ? "Passed" : "Failed (see output)"
2345
+ } : s));
2346
+ } else {
2347
+ setSteps((prev) => prev.map((s) => s.id === "lint" ? {
2348
+ ...s,
2349
+ status: "completed",
2350
+ message: "No linter detected"
2351
+ } : s));
2352
+ }
2353
+ }
2354
+ } catch (err) {
2355
+ setError(err instanceof Error ? err : new Error(String(err)));
2356
+ setSteps((prev) => prev.map((s) => s.status === "in_progress" ? { ...s, status: "failed" } : s));
2357
+ }
2358
+ }
2359
+ generate();
2360
+ }, [
2361
+ selectedType,
2362
+ selectedName,
2363
+ portName,
2364
+ adapterName,
2365
+ options,
2366
+ selectedPortInfo?.name,
2367
+ selectedPortInfo?.tokenImportPath,
2368
+ selectedPortInfo?.tokenName
2369
+ ]);
2370
+ if (showTypeSelector) {
2371
+ return /* @__PURE__ */ jsx_dev_runtime9.jsxDEV(TypeSelector, {
2372
+ onSubmit: handleTypeSelect
2373
+ }, undefined, false, undefined, this);
2374
+ }
2375
+ if (showPortSelector && selectedType === "adapter") {
2376
+ if (!portsLoaded) {
2377
+ return /* @__PURE__ */ jsx_dev_runtime9.jsxDEV(import_ink9.Text, {
2378
+ children: "Loading available ports..."
2379
+ }, undefined, false, undefined, this);
2380
+ }
2381
+ return /* @__PURE__ */ jsx_dev_runtime9.jsxDEV(PortSelector, {
2382
+ ports: availablePorts,
2383
+ onSubmit: handlePortSelect,
2384
+ onBack: handlePortBack
2385
+ }, undefined, false, undefined, this);
2386
+ }
2387
+ if (showNameInput && selectedType) {
2388
+ return /* @__PURE__ */ jsx_dev_runtime9.jsxDEV(NameInput, {
2389
+ type: selectedType,
2390
+ step: selectedType === "full" ? nameInputStep : undefined,
2391
+ onSubmit: handleNameInput
2392
+ }, undefined, false, undefined, this);
2393
+ }
2394
+ if (error) {
2395
+ return /* @__PURE__ */ jsx_dev_runtime9.jsxDEV(import_ink9.Box, {
2396
+ flexDirection: "column",
2397
+ children: [
2398
+ /* @__PURE__ */ jsx_dev_runtime9.jsxDEV(import_ink9.Text, {
2399
+ color: "red",
2400
+ bold: true,
2401
+ children: "❌ Generation failed"
2402
+ }, undefined, false, undefined, this),
2403
+ /* @__PURE__ */ jsx_dev_runtime9.jsxDEV(import_ink9.Text, {
2404
+ color: "red",
2405
+ children: error.message
2406
+ }, undefined, false, undefined, this)
2407
+ ]
2408
+ }, undefined, true, undefined, this);
2409
+ }
2410
+ const getTitle = () => {
2411
+ if (!selectedType)
2412
+ return "Generating...";
2413
+ if (selectedType === "full") {
2414
+ if (portName && adapterName) {
2415
+ return `Generating port '${portName}' and adapter '${adapterName}'`;
2416
+ }
2417
+ return "Generating full module";
2418
+ }
2419
+ return `Generating ${selectedType}: ${selectedName || ""}`;
2420
+ };
2421
+ if (result && selectedType && (selectedType === "full" ? portName && adapterName : selectedName)) {
2422
+ return /* @__PURE__ */ jsx_dev_runtime9.jsxDEV(import_ink9.Box, {
2423
+ flexDirection: "column",
2424
+ children: [
2425
+ /* @__PURE__ */ jsx_dev_runtime9.jsxDEV(ProgressIndicator, {
2426
+ steps,
2427
+ title: getTitle()
2428
+ }, undefined, false, undefined, this),
2429
+ /* @__PURE__ */ jsx_dev_runtime9.jsxDEV(Summary, {
2430
+ success: result.success,
2431
+ filesGenerated: result.files?.length || 0,
2432
+ totalFiles: result.files?.length || 0,
2433
+ outputPath: options.outputPath,
2434
+ files: result.files,
2435
+ tips: [
2436
+ "Import generated files in your modules",
2437
+ selectedType === "port" && selectedName ? "Generate an adapter with: npx nest-hex generate adapter <name> --port " + selectedName : undefined
2438
+ ].filter((t) => t !== undefined)
2439
+ }, undefined, false, undefined, this)
2440
+ ]
2441
+ }, undefined, true, undefined, this);
2442
+ }
2443
+ return /* @__PURE__ */ jsx_dev_runtime9.jsxDEV(ProgressIndicator, {
2444
+ steps,
2445
+ title: getTitle()
2446
+ }, undefined, false, undefined, this);
2447
+ }
2448
+ async function generateCommand(options) {
2449
+ const isInteractive = process.stdin.isTTY && typeof process.stdin.setRawMode === "function";
2450
+ const missingArgs = !options.type || (options.type === "full" ? !options.portName || !options.adapterName : !options.name);
2451
+ if (!isInteractive && missingArgs) {
2452
+ console.error("Error: Interactive mode is not supported in this environment.");
2453
+ console.error("");
2454
+ console.error("Usage:");
2455
+ console.error(" nest-hex generate <type> <name>");
2456
+ console.error(" nest-hex generate full <portName> <adapterName>");
2457
+ console.error("");
2458
+ console.error("Types:");
2459
+ console.error(" port - Create domain capability (token, interface, service, module)");
2460
+ console.error(" adapter - Create infrastructure implementation for a port");
2461
+ console.error(" service - Create service with @InjectPort usage");
2462
+ console.error(" full - Generate both port and adapter together");
2463
+ console.error("");
2464
+ console.error("Examples:");
2465
+ console.error(" nest-hex generate port ObjectStorage");
2466
+ console.error(" nest-hex generate adapter S3 --port ObjectStorage");
2467
+ console.error(" nest-hex generate full ObjectStorage S3");
2468
+ process.exit(1);
2469
+ }
2470
+ const { waitUntilExit } = import_ink9.render(/* @__PURE__ */ jsx_dev_runtime9.jsxDEV(GenerateUI, {
2471
+ options
2472
+ }, undefined, false, undefined, this));
2473
+ await waitUntilExit();
2474
+ }
2475
+ // src/cli/commands/init.command.tsx
2476
+ var import_node_fs3 = require("node:fs");
2477
+ var import_node_path10 = require("node:path");
2478
+ var import_ink10 = require("ink");
2479
+ var jsx_dev_runtime10 = __toESM(require_jsx_dev_runtime(), 1);
2480
+ var CONFIG_TEMPLATE = `import { defineConfig } from 'nest-hex/cli'
2481
+
2482
+ export default defineConfig({
2483
+ output: {
2484
+ portsDir: 'src/ports',
2485
+ adaptersDir: 'src/adapters',
2486
+ },
2487
+ naming: {
2488
+ portSuffix: 'PORT',
2489
+ adapterSuffix: 'Adapter',
2490
+ fileCase: 'kebab',
2491
+ },
2492
+ style: {
2493
+ indent: 'tab',
2494
+ quotes: 'single',
2495
+ semicolons: true,
2496
+ },
2497
+ templates: {
2498
+ // Optionally override default templates
2499
+ // portModule: './templates/custom-port.hbs',
2500
+ },
2501
+ })
2502
+ `;
2503
+ function isInternalDevelopment() {
2504
+ try {
2505
+ const packageJsonPath = import_node_path10.join(process.cwd(), "package.json");
2506
+ if (!import_node_fs3.existsSync(packageJsonPath))
2507
+ return false;
2508
+ const packageJsonContent = import_node_fs3.readFileSync(packageJsonPath, "utf-8");
2509
+ const pkg = JSON.parse(packageJsonContent);
2510
+ return pkg.name === "nest-hex";
2511
+ } catch {
2512
+ return false;
2513
+ }
2514
+ }
2515
+ async function initCommand(options = {}) {
2516
+ const configPath = import_node_path10.join(process.cwd(), "nest-hex.config.ts");
2517
+ const configExists = import_node_fs3.existsSync(configPath);
2518
+ const importPath = isInternalDevelopment() ? "./src/cli" : "nest-hex/cli";
2519
+ const configContent = CONFIG_TEMPLATE.replace("nest-hex/cli", importPath);
2520
+ if (configExists && !options.force) {
2521
+ const { waitUntilExit } = import_ink10.render(/* @__PURE__ */ jsx_dev_runtime10.jsxDEV(import_ink10.Box, {
2522
+ flexDirection: "column",
2523
+ children: [
2524
+ /* @__PURE__ */ jsx_dev_runtime10.jsxDEV(import_ink10.Text, {
2525
+ color: "yellow",
2526
+ children: "⚠️ Configuration file already exists"
2527
+ }, undefined, false, undefined, this),
2528
+ /* @__PURE__ */ jsx_dev_runtime10.jsxDEV(import_ink10.Text, {
2529
+ dimColor: true,
2530
+ children: "Use --force to overwrite"
2531
+ }, undefined, false, undefined, this)
2532
+ ]
2533
+ }, undefined, true, undefined, this));
2534
+ await waitUntilExit();
2535
+ process.exit(1);
2536
+ }
2537
+ try {
2538
+ import_node_fs3.writeFileSync(configPath, configContent, "utf-8");
2539
+ const { waitUntilExit } = import_ink10.render(/* @__PURE__ */ jsx_dev_runtime10.jsxDEV(import_ink10.Box, {
2540
+ flexDirection: "column",
2541
+ paddingY: 1,
2542
+ children: [
2543
+ /* @__PURE__ */ jsx_dev_runtime10.jsxDEV(import_ink10.Text, {
2544
+ color: "green",
2545
+ bold: true,
2546
+ children: "✅ Created nest-hex.config.ts"
2547
+ }, undefined, false, undefined, this),
2548
+ /* @__PURE__ */ jsx_dev_runtime10.jsxDEV(import_ink10.Text, {
2549
+ dimColor: true,
2550
+ children: [
2551
+ "Configuration file created at: ",
2552
+ configPath
2553
+ ]
2554
+ }, undefined, true, undefined, this),
2555
+ /* @__PURE__ */ jsx_dev_runtime10.jsxDEV(import_ink10.Box, {
2556
+ marginTop: 1,
2557
+ children: /* @__PURE__ */ jsx_dev_runtime10.jsxDEV(import_ink10.Text, {
2558
+ bold: true,
2559
+ children: "\uD83D\uDCA1 Next steps:"
2560
+ }, undefined, false, undefined, this)
2561
+ }, undefined, false, undefined, this),
2562
+ /* @__PURE__ */ jsx_dev_runtime10.jsxDEV(import_ink10.Box, {
2563
+ marginLeft: 2,
2564
+ children: /* @__PURE__ */ jsx_dev_runtime10.jsxDEV(import_ink10.Text, {
2565
+ children: "• Edit nest-hex.config.ts to customize settings"
2566
+ }, undefined, false, undefined, this)
2567
+ }, undefined, false, undefined, this),
2568
+ /* @__PURE__ */ jsx_dev_runtime10.jsxDEV(import_ink10.Box, {
2569
+ marginLeft: 2,
2570
+ children: /* @__PURE__ */ jsx_dev_runtime10.jsxDEV(import_ink10.Text, {
2571
+ children: "• Run `npx nest-hex generate` to create components"
2572
+ }, undefined, false, undefined, this)
2573
+ }, undefined, false, undefined, this)
2574
+ ]
2575
+ }, undefined, true, undefined, this));
2576
+ await waitUntilExit();
2577
+ } catch (error) {
2578
+ const { waitUntilExit } = import_ink10.render(/* @__PURE__ */ jsx_dev_runtime10.jsxDEV(import_ink10.Box, {
2579
+ flexDirection: "column",
2580
+ children: [
2581
+ /* @__PURE__ */ jsx_dev_runtime10.jsxDEV(import_ink10.Text, {
2582
+ color: "red",
2583
+ bold: true,
2584
+ children: "❌ Failed to create configuration file"
2585
+ }, undefined, false, undefined, this),
2586
+ /* @__PURE__ */ jsx_dev_runtime10.jsxDEV(import_ink10.Text, {
2587
+ color: "red",
2588
+ children: error instanceof Error ? error.message : String(error)
2589
+ }, undefined, false, undefined, this)
2590
+ ]
2591
+ }, undefined, true, undefined, this));
2592
+ await waitUntilExit();
2593
+ process.exit(1);
2594
+ }
2595
+ }