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