@solid-stack/mason 1.0.24 → 1.0.26
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/dist/bin.cjs +429 -272
- package/dist/bin.cjs.map +1 -1
- package/dist/bin.js +426 -269
- package/dist/bin.js.map +1 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/commands/env.d.ts +3 -0
- package/dist/commands/env.d.ts.map +1 -0
- package/dist/commands/envExamples.d.ts +3 -0
- package/dist/commands/envExamples.d.ts.map +1 -0
- package/dist/commands/init.d.ts +2 -0
- package/dist/commands/init.d.ts.map +1 -0
- package/dist/commands/menu.d.ts.map +1 -1
- package/dist/index.cjs +358 -198
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +354 -197
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
var fs4 = require('fs');
|
|
4
4
|
var path2 = require('path');
|
|
5
|
-
var
|
|
6
|
-
var
|
|
5
|
+
var p16 = require('@clack/prompts');
|
|
6
|
+
var pc16 = require('picocolors');
|
|
7
7
|
var url = require('url');
|
|
8
8
|
var child_process = require('child_process');
|
|
9
9
|
var crypto = require('crypto');
|
|
@@ -33,8 +33,8 @@ function _interopNamespace(e) {
|
|
|
33
33
|
|
|
34
34
|
var fs4__default = /*#__PURE__*/_interopDefault(fs4);
|
|
35
35
|
var path2__default = /*#__PURE__*/_interopDefault(path2);
|
|
36
|
-
var
|
|
37
|
-
var
|
|
36
|
+
var p16__namespace = /*#__PURE__*/_interopNamespace(p16);
|
|
37
|
+
var pc16__default = /*#__PURE__*/_interopDefault(pc16);
|
|
38
38
|
var Handlebars__default = /*#__PURE__*/_interopDefault(Handlebars);
|
|
39
39
|
|
|
40
40
|
// src/utils/formatting.ts
|
|
@@ -141,17 +141,17 @@ function writeFileSafely(absolutePath, content, options = {}) {
|
|
|
141
141
|
function printGeneratedFiles(files, isDryRun = false) {
|
|
142
142
|
console.log("");
|
|
143
143
|
if (isDryRun) {
|
|
144
|
-
|
|
144
|
+
p16__namespace.log.warn(pc16__default.default.yellow(pc16__default.default.bold("[DRY RUN PREVIEW] No files were written to disk.")));
|
|
145
145
|
}
|
|
146
146
|
for (const f of files) {
|
|
147
147
|
if (f.action === "created") {
|
|
148
|
-
|
|
148
|
+
p16__namespace.log.success(`${pc16__default.default.bold(f.relativePath)} ${pc16__default.default.dim("(created)")}`);
|
|
149
149
|
} else if (f.action === "overwritten") {
|
|
150
|
-
|
|
150
|
+
p16__namespace.log.warn(`${pc16__default.default.bold(f.relativePath)} ${pc16__default.default.dim("(overwritten)")}`);
|
|
151
151
|
} else if (f.action === "skipped") {
|
|
152
|
-
|
|
152
|
+
p16__namespace.log.info(`${pc16__default.default.dim(f.relativePath)} ${pc16__default.default.dim("(skipped - already exists, pass -o to overwrite)")}`);
|
|
153
153
|
} else {
|
|
154
|
-
|
|
154
|
+
p16__namespace.log.info(`${pc16__default.default.bold(f.relativePath)} ${pc16__default.default.dim("(preview)")}`);
|
|
155
155
|
}
|
|
156
156
|
}
|
|
157
157
|
}
|
|
@@ -353,23 +353,23 @@ var PromptCancelledError = class extends Error {
|
|
|
353
353
|
}
|
|
354
354
|
};
|
|
355
355
|
function handleCancel(result) {
|
|
356
|
-
if (
|
|
357
|
-
|
|
356
|
+
if (p16__namespace.isCancel(result)) {
|
|
357
|
+
p16__namespace.cancel("Operation cancelled.");
|
|
358
358
|
throw new PromptCancelledError();
|
|
359
359
|
}
|
|
360
360
|
return result;
|
|
361
361
|
}
|
|
362
362
|
function printBanner() {
|
|
363
363
|
console.log("");
|
|
364
|
-
|
|
364
|
+
p16__namespace.intro(pc16__default.default.bgCyan(pc16__default.default.black(" @solid-stack/mason ")));
|
|
365
365
|
}
|
|
366
366
|
async function promptProperties(options = {}) {
|
|
367
367
|
const properties = options.defaults ? [...options.defaults] : [];
|
|
368
368
|
if (properties.length > 0) {
|
|
369
|
-
const summary = properties.map((
|
|
370
|
-
|
|
369
|
+
const summary = properties.map((p19) => `${p19.name}: ${p19.type}${p19.optional ? "?" : ""}`).join(", ");
|
|
370
|
+
p16__namespace.log.info(pc16__default.default.dim(`Pre-configured fields: ${summary}`));
|
|
371
371
|
const addMore = handleCancel(
|
|
372
|
-
await
|
|
372
|
+
await p16__namespace.confirm({
|
|
373
373
|
message: "Would you like to add custom fields/properties?",
|
|
374
374
|
initialValue: false
|
|
375
375
|
})
|
|
@@ -378,10 +378,10 @@ async function promptProperties(options = {}) {
|
|
|
378
378
|
return properties;
|
|
379
379
|
}
|
|
380
380
|
}
|
|
381
|
-
|
|
381
|
+
p16__namespace.log.info(pc16__default.default.cyan("Enter properties (leave name blank when finished):"));
|
|
382
382
|
while (true) {
|
|
383
383
|
const name = handleCancel(
|
|
384
|
-
await
|
|
384
|
+
await p16__namespace.text({
|
|
385
385
|
message: "Property name (or press Enter to finish):",
|
|
386
386
|
placeholder: "e.g. title, email, status"
|
|
387
387
|
})
|
|
@@ -390,7 +390,7 @@ async function promptProperties(options = {}) {
|
|
|
390
390
|
break;
|
|
391
391
|
}
|
|
392
392
|
const type = handleCancel(
|
|
393
|
-
await
|
|
393
|
+
await p16__namespace.select({
|
|
394
394
|
message: `Type for property "${name.trim()}":`,
|
|
395
395
|
options: [
|
|
396
396
|
{ value: "string", label: "string" },
|
|
@@ -407,7 +407,7 @@ async function promptProperties(options = {}) {
|
|
|
407
407
|
let finalType = type;
|
|
408
408
|
if (type === "custom") {
|
|
409
409
|
finalType = handleCancel(
|
|
410
|
-
await
|
|
410
|
+
await p16__namespace.text({
|
|
411
411
|
message: `Enter custom type for "${name.trim()}":`,
|
|
412
412
|
placeholder: "e.g. UserRole, string | null",
|
|
413
413
|
validate: (val) => val && val.trim() ? void 0 : "Type cannot be empty"
|
|
@@ -415,7 +415,7 @@ async function promptProperties(options = {}) {
|
|
|
415
415
|
);
|
|
416
416
|
}
|
|
417
417
|
const optional = handleCancel(
|
|
418
|
-
await
|
|
418
|
+
await p16__namespace.confirm({
|
|
419
419
|
message: `Is "${name.trim()}" optional?`,
|
|
420
420
|
initialValue: false
|
|
421
421
|
})
|
|
@@ -425,8 +425,8 @@ async function promptProperties(options = {}) {
|
|
|
425
425
|
type: finalType.trim(),
|
|
426
426
|
optional
|
|
427
427
|
});
|
|
428
|
-
|
|
429
|
-
|
|
428
|
+
p16__namespace.log.success(
|
|
429
|
+
pc16__default.default.green(`Added: ${name.trim()}${optional ? "?" : ""}: ${finalType.trim()}`)
|
|
430
430
|
);
|
|
431
431
|
}
|
|
432
432
|
return properties;
|
|
@@ -634,8 +634,8 @@ function getMissingNpmPackages(projectRoot, requiredPackages) {
|
|
|
634
634
|
...Object.keys(pkg.devDependencies || {}),
|
|
635
635
|
...Object.keys(pkg.peerDependencies || {})
|
|
636
636
|
]);
|
|
637
|
-
return requiredPackages.filter((
|
|
638
|
-
const nameOnly =
|
|
637
|
+
return requiredPackages.filter((p19) => {
|
|
638
|
+
const nameOnly = p19.startsWith("@") ? `@${p19.slice(1).split("@")[0] || ""}` : p19.split("@")[0] || p19;
|
|
639
639
|
return !installed.has(nameOnly);
|
|
640
640
|
});
|
|
641
641
|
} catch {
|
|
@@ -660,7 +660,7 @@ function installNpmPackages(projectRoot, packages, pm) {
|
|
|
660
660
|
installCmd = `npm install ${packages.join(" ")}`;
|
|
661
661
|
break;
|
|
662
662
|
}
|
|
663
|
-
|
|
663
|
+
p16__namespace.log.info(`Installing missing dependencies with ${manager}: ${pc16__default.default.cyan(packages.join(", "))}`);
|
|
664
664
|
child_process.execSync(installCmd, {
|
|
665
665
|
cwd: projectRoot,
|
|
666
666
|
stdio: "inherit"
|
|
@@ -862,7 +862,7 @@ function generateInterfaceCode(ifaceName, kind = "abstractClass", entityName, me
|
|
|
862
862
|
const idKey = `${entityKey}Id`;
|
|
863
863
|
const listKey = `${entityKey}s`;
|
|
864
864
|
const formattedCustomMethods = customMethods.map((m) => {
|
|
865
|
-
const params = m.params && m.params.length > 0 ? m.params.map((
|
|
865
|
+
const params = m.params && m.params.length > 0 ? m.params.map((p19) => `${p19.name}: ${p19.type}`).join("; ") : "";
|
|
866
866
|
const returnType = m.returnType ? `Promise<${m.returnType}>` : "Promise<void>";
|
|
867
867
|
return {
|
|
868
868
|
name: m.name,
|
|
@@ -1443,22 +1443,22 @@ function generateUseCaseCode(useCaseName, dependencies = [], inputProps = [], ou
|
|
|
1443
1443
|
from: /^I[A-Z]/.test(dep) ? `../domain/${dep}.js` : `./${dep}.js`
|
|
1444
1444
|
}));
|
|
1445
1445
|
const domainTypesToImport = new Set(domainImports);
|
|
1446
|
-
for (const
|
|
1447
|
-
const rawType =
|
|
1446
|
+
for (const p19 of [...inputProps, ...outputProps]) {
|
|
1447
|
+
const rawType = p19.type.trim();
|
|
1448
1448
|
const baseType = rawType.replace(/\[\]$/, "").trim();
|
|
1449
1449
|
if (!primitiveTypes.has(baseType) && /^[A-Z][A-Za-z0-9_]*$/.test(baseType) && !dependencies.includes(baseType)) {
|
|
1450
1450
|
domainTypesToImport.add(baseType);
|
|
1451
1451
|
}
|
|
1452
1452
|
}
|
|
1453
|
-
const formattedInputProps = inputProps.map((
|
|
1454
|
-
name:
|
|
1455
|
-
optional:
|
|
1456
|
-
type:
|
|
1453
|
+
const formattedInputProps = inputProps.map((p19) => ({
|
|
1454
|
+
name: p19.name,
|
|
1455
|
+
optional: p19.optional,
|
|
1456
|
+
type: p19.optional && !p19.type.includes("undefined") ? `${p19.type} | undefined` : p19.type
|
|
1457
1457
|
}));
|
|
1458
|
-
const formattedOutputProps = outputProps.map((
|
|
1459
|
-
name:
|
|
1460
|
-
optional:
|
|
1461
|
-
type:
|
|
1458
|
+
const formattedOutputProps = outputProps.map((p19) => ({
|
|
1459
|
+
name: p19.name,
|
|
1460
|
+
optional: p19.optional,
|
|
1461
|
+
type: p19.optional && !p19.type.includes("undefined") ? `${p19.type} | undefined` : p19.type
|
|
1462
1462
|
}));
|
|
1463
1463
|
const formattedDeps = dependencies.map((dep) => ({
|
|
1464
1464
|
key: toCamelCase(dep),
|
|
@@ -2133,7 +2133,7 @@ async function runFeatureCommand(featureNameArg, flags = {}) {
|
|
|
2133
2133
|
}
|
|
2134
2134
|
if (!name) {
|
|
2135
2135
|
name = handleCancel(
|
|
2136
|
-
await
|
|
2136
|
+
await p16__namespace.text({
|
|
2137
2137
|
message: "What is the feature name?",
|
|
2138
2138
|
placeholder: "e.g. users, auth, orders, billing",
|
|
2139
2139
|
validate: (val) => {
|
|
@@ -2149,7 +2149,7 @@ async function runFeatureCommand(featureNameArg, flags = {}) {
|
|
|
2149
2149
|
let targetDirRel = defaultDir;
|
|
2150
2150
|
if (!flags.yes && !flags.target && !flags.dest) {
|
|
2151
2151
|
targetDirRel = handleCancel(
|
|
2152
|
-
await
|
|
2152
|
+
await p16__namespace.text({
|
|
2153
2153
|
message: "Target directory for the feature:",
|
|
2154
2154
|
initialValue: defaultDir,
|
|
2155
2155
|
defaultValue: defaultDir
|
|
@@ -2171,14 +2171,14 @@ async function runFeatureCommand(featureNameArg, flags = {}) {
|
|
|
2171
2171
|
const customUseCases = [];
|
|
2172
2172
|
if (!flags.yes) {
|
|
2173
2173
|
includeExpress = handleCancel(
|
|
2174
|
-
await
|
|
2174
|
+
await p16__namespace.confirm({
|
|
2175
2175
|
message: "Include Express Presentation layer (pxExpress routes & handlers)?",
|
|
2176
2176
|
initialValue: true
|
|
2177
2177
|
})
|
|
2178
2178
|
);
|
|
2179
2179
|
if (includeExpress) {
|
|
2180
2180
|
routePath = handleCancel(
|
|
2181
|
-
await
|
|
2181
|
+
await p16__namespace.text({
|
|
2182
2182
|
message: "Express route prefix:",
|
|
2183
2183
|
initialValue: `/${normalizedName}`,
|
|
2184
2184
|
defaultValue: `/${normalizedName}`
|
|
@@ -2186,14 +2186,14 @@ async function runFeatureCommand(featureNameArg, flags = {}) {
|
|
|
2186
2186
|
).trim();
|
|
2187
2187
|
}
|
|
2188
2188
|
includeDomain = handleCancel(
|
|
2189
|
-
await
|
|
2189
|
+
await p16__namespace.confirm({
|
|
2190
2190
|
message: "Include Domain Entity/Entities?",
|
|
2191
2191
|
initialValue: true
|
|
2192
2192
|
})
|
|
2193
2193
|
);
|
|
2194
2194
|
if (includeDomain) {
|
|
2195
2195
|
const domainInput = handleCancel(
|
|
2196
|
-
await
|
|
2196
|
+
await p16__namespace.text({
|
|
2197
2197
|
message: "Domain entity name(s) (comma-separated):",
|
|
2198
2198
|
initialValue: defaultEntity,
|
|
2199
2199
|
defaultValue: defaultEntity,
|
|
@@ -2212,21 +2212,21 @@ async function runFeatureCommand(featureNameArg, flags = {}) {
|
|
|
2212
2212
|
entityNames = [defaultEntity];
|
|
2213
2213
|
}
|
|
2214
2214
|
includeInterface = handleCancel(
|
|
2215
|
-
await
|
|
2215
|
+
await p16__namespace.confirm({
|
|
2216
2216
|
message: `Include Domain Repository interface(s) for ${entityNames.join(", ")}?`,
|
|
2217
2217
|
initialValue: true
|
|
2218
2218
|
})
|
|
2219
2219
|
);
|
|
2220
2220
|
if (includeInterface) {
|
|
2221
2221
|
includeInfra = handleCancel(
|
|
2222
|
-
await
|
|
2222
|
+
await p16__namespace.confirm({
|
|
2223
2223
|
message: `Include Infrastructure Stub implementation(s) for ${entityNames.join(", ")}?`,
|
|
2224
2224
|
initialValue: true
|
|
2225
2225
|
})
|
|
2226
2226
|
);
|
|
2227
2227
|
}
|
|
2228
2228
|
includeUseCase = handleCancel(
|
|
2229
|
-
await
|
|
2229
|
+
await p16__namespace.confirm({
|
|
2230
2230
|
message: "Include Domain Use Cases?",
|
|
2231
2231
|
initialValue: true
|
|
2232
2232
|
})
|
|
@@ -2240,7 +2240,7 @@ async function runFeatureCommand(featureNameArg, flags = {}) {
|
|
|
2240
2240
|
{ value: "delete", label: "Delete (Delete<Entity>)", hint: "DELETE /:id" }
|
|
2241
2241
|
];
|
|
2242
2242
|
crudOperations = handleCancel(
|
|
2243
|
-
await
|
|
2243
|
+
await p16__namespace.multiselect({
|
|
2244
2244
|
message: "Select standard CRUD use cases to generate:",
|
|
2245
2245
|
options: crudChoices,
|
|
2246
2246
|
initialValues: ["create", "read", "list", "update", "delete"],
|
|
@@ -2248,13 +2248,13 @@ async function runFeatureCommand(featureNameArg, flags = {}) {
|
|
|
2248
2248
|
})
|
|
2249
2249
|
);
|
|
2250
2250
|
includeTests = handleCancel(
|
|
2251
|
-
await
|
|
2251
|
+
await p16__namespace.confirm({
|
|
2252
2252
|
message: "Generate Vitest unit tests for use cases?",
|
|
2253
2253
|
initialValue: true
|
|
2254
2254
|
})
|
|
2255
2255
|
);
|
|
2256
2256
|
const wantCustom = handleCancel(
|
|
2257
|
-
await
|
|
2257
|
+
await p16__namespace.confirm({
|
|
2258
2258
|
message: "Do you want to add any custom use cases to this feature?",
|
|
2259
2259
|
initialValue: false
|
|
2260
2260
|
})
|
|
@@ -2264,7 +2264,7 @@ async function runFeatureCommand(featureNameArg, flags = {}) {
|
|
|
2264
2264
|
const availableIfaces = entityNames.map((e) => `I${e}Repository`);
|
|
2265
2265
|
while (addMore) {
|
|
2266
2266
|
const customName = handleCancel(
|
|
2267
|
-
await
|
|
2267
|
+
await p16__namespace.text({
|
|
2268
2268
|
message: "Custom Use Case name:",
|
|
2269
2269
|
placeholder: "e.g. ResetPassword, VerifyEmail, AssignRole",
|
|
2270
2270
|
validate: (v) => v && v.trim() ? void 0 : "Use Case name cannot be empty"
|
|
@@ -2274,7 +2274,7 @@ async function runFeatureCommand(featureNameArg, flags = {}) {
|
|
|
2274
2274
|
let selectedDeps = [];
|
|
2275
2275
|
if (availableIfaces.length > 0) {
|
|
2276
2276
|
selectedDeps = handleCancel(
|
|
2277
|
-
await
|
|
2277
|
+
await p16__namespace.multiselect({
|
|
2278
2278
|
message: `Select domain interfaces to inject into ${customUcName}:`,
|
|
2279
2279
|
options: availableIfaces.map((i) => ({ value: i, label: i })),
|
|
2280
2280
|
required: false
|
|
@@ -2283,7 +2283,7 @@ async function runFeatureCommand(featureNameArg, flags = {}) {
|
|
|
2283
2283
|
}
|
|
2284
2284
|
let customInputProps = [];
|
|
2285
2285
|
const hasInput = handleCancel(
|
|
2286
|
-
await
|
|
2286
|
+
await p16__namespace.confirm({
|
|
2287
2287
|
message: `Does ${customUcName} accept input arguments?`,
|
|
2288
2288
|
initialValue: true
|
|
2289
2289
|
})
|
|
@@ -2294,7 +2294,7 @@ async function runFeatureCommand(featureNameArg, flags = {}) {
|
|
|
2294
2294
|
}
|
|
2295
2295
|
let customOutputProps = [];
|
|
2296
2296
|
const hasCustomOutput = handleCancel(
|
|
2297
|
-
await
|
|
2297
|
+
await p16__namespace.confirm({
|
|
2298
2298
|
message: `Does ${customUcName} return custom output data?`,
|
|
2299
2299
|
initialValue: false
|
|
2300
2300
|
})
|
|
@@ -2304,7 +2304,7 @@ async function runFeatureCommand(featureNameArg, flags = {}) {
|
|
|
2304
2304
|
});
|
|
2305
2305
|
}
|
|
2306
2306
|
const customIncludeTest = handleCancel(
|
|
2307
|
-
await
|
|
2307
|
+
await p16__namespace.confirm({
|
|
2308
2308
|
message: `Generate Vitest unit test for ${customUcName}?`,
|
|
2309
2309
|
initialValue: true
|
|
2310
2310
|
})
|
|
@@ -2314,14 +2314,14 @@ async function runFeatureCommand(featureNameArg, flags = {}) {
|
|
|
2314
2314
|
let customHttpPath = `/${toKebabCase(customUcName)}`;
|
|
2315
2315
|
if (includeExpress) {
|
|
2316
2316
|
customCreateHttp = handleCancel(
|
|
2317
|
-
await
|
|
2317
|
+
await p16__namespace.confirm({
|
|
2318
2318
|
message: `Generate a matching ExpressRoute HTTP handler for ${customUcName}?`,
|
|
2319
2319
|
initialValue: true
|
|
2320
2320
|
})
|
|
2321
2321
|
);
|
|
2322
2322
|
if (customCreateHttp) {
|
|
2323
2323
|
customHttpMethod = handleCancel(
|
|
2324
|
-
await
|
|
2324
|
+
await p16__namespace.select({
|
|
2325
2325
|
message: "HTTP method for route:",
|
|
2326
2326
|
options: [
|
|
2327
2327
|
{ value: "post", label: "POST" },
|
|
@@ -2334,7 +2334,7 @@ async function runFeatureCommand(featureNameArg, flags = {}) {
|
|
|
2334
2334
|
})
|
|
2335
2335
|
);
|
|
2336
2336
|
customHttpPath = handleCancel(
|
|
2337
|
-
await
|
|
2337
|
+
await p16__namespace.text({
|
|
2338
2338
|
message: "Route subpath (relative to feature prefix):",
|
|
2339
2339
|
initialValue: `/${toKebabCase(customUcName)}`,
|
|
2340
2340
|
defaultValue: `/${toKebabCase(customUcName)}`
|
|
@@ -2355,7 +2355,7 @@ async function runFeatureCommand(featureNameArg, flags = {}) {
|
|
|
2355
2355
|
validationFields: customInputProps
|
|
2356
2356
|
});
|
|
2357
2357
|
addMore = handleCancel(
|
|
2358
|
-
await
|
|
2358
|
+
await p16__namespace.confirm({
|
|
2359
2359
|
message: "Add another custom use case?",
|
|
2360
2360
|
initialValue: false
|
|
2361
2361
|
})
|
|
@@ -2364,7 +2364,7 @@ async function runFeatureCommand(featureNameArg, flags = {}) {
|
|
|
2364
2364
|
}
|
|
2365
2365
|
}
|
|
2366
2366
|
includeDiProvider = handleCancel(
|
|
2367
|
-
await
|
|
2367
|
+
await p16__namespace.confirm({
|
|
2368
2368
|
message: "Generate / update feature DI provider (diProvider.ts)?",
|
|
2369
2369
|
initialValue: true
|
|
2370
2370
|
})
|
|
@@ -2376,8 +2376,8 @@ async function runFeatureCommand(featureNameArg, flags = {}) {
|
|
|
2376
2376
|
entityNames = [defaultEntity];
|
|
2377
2377
|
}
|
|
2378
2378
|
}
|
|
2379
|
-
const s =
|
|
2380
|
-
s.start(`Generating feature '${
|
|
2379
|
+
const s = p16__namespace.spinner();
|
|
2380
|
+
s.start(`Generating feature '${pc16__default.default.cyan(normalizedName)}'...`);
|
|
2381
2381
|
const options = {
|
|
2382
2382
|
name: normalizedName,
|
|
2383
2383
|
projectRoot,
|
|
@@ -2423,8 +2423,8 @@ async function runFeatureCommand(featureNameArg, flags = {}) {
|
|
|
2423
2423
|
}
|
|
2424
2424
|
s.stop("Feature scaffolded successfully!");
|
|
2425
2425
|
printGeneratedFiles(files, options.dryRun);
|
|
2426
|
-
|
|
2427
|
-
|
|
2426
|
+
p16__namespace.outro(
|
|
2427
|
+
pc16__default.default.green(
|
|
2428
2428
|
`\u2713 Feature '${normalizedName}' initialized in ${path2__default.default.relative(projectRoot, targetDir)} (uncommitted, unregistered)`
|
|
2429
2429
|
)
|
|
2430
2430
|
);
|
|
@@ -2538,7 +2538,7 @@ async function runSharedCommand(sharedNameArg, flags = {}) {
|
|
|
2538
2538
|
}
|
|
2539
2539
|
if (!name) {
|
|
2540
2540
|
name = handleCancel(
|
|
2541
|
-
await
|
|
2541
|
+
await p16__namespace.text({
|
|
2542
2542
|
message: "What is the shared module name?",
|
|
2543
2543
|
placeholder: "e.g. hasher, time, uuid, cache, logger",
|
|
2544
2544
|
validate: (val) => {
|
|
@@ -2554,7 +2554,7 @@ async function runSharedCommand(sharedNameArg, flags = {}) {
|
|
|
2554
2554
|
let targetDirRel = defaultDir;
|
|
2555
2555
|
if (!flags.yes && !flags.target && !flags.dest) {
|
|
2556
2556
|
targetDirRel = handleCancel(
|
|
2557
|
-
await
|
|
2557
|
+
await p16__namespace.text({
|
|
2558
2558
|
message: "Target directory for the shared module:",
|
|
2559
2559
|
initialValue: defaultDir,
|
|
2560
2560
|
defaultValue: defaultDir
|
|
@@ -2566,21 +2566,21 @@ async function runSharedCommand(sharedNameArg, flags = {}) {
|
|
|
2566
2566
|
let includeStub = true;
|
|
2567
2567
|
if (!flags.yes) {
|
|
2568
2568
|
description = handleCancel(
|
|
2569
|
-
await
|
|
2569
|
+
await p16__namespace.text({
|
|
2570
2570
|
message: "Module description (optional):",
|
|
2571
2571
|
placeholder: "e.g. In-memory caching and Redis port abstraction",
|
|
2572
2572
|
initialValue: ""
|
|
2573
2573
|
})
|
|
2574
2574
|
).trim();
|
|
2575
2575
|
includeStub = handleCancel(
|
|
2576
|
-
await
|
|
2576
|
+
await p16__namespace.confirm({
|
|
2577
2577
|
message: "Include stub implementation in infrastructure/?",
|
|
2578
2578
|
initialValue: true
|
|
2579
2579
|
})
|
|
2580
2580
|
);
|
|
2581
2581
|
}
|
|
2582
|
-
const s =
|
|
2583
|
-
s.start(`Generating shared module '${
|
|
2582
|
+
const s = p16__namespace.spinner();
|
|
2583
|
+
s.start(`Generating shared module '${pc16__default.default.cyan(normalizedName)}'...`);
|
|
2584
2584
|
const files = generateShared({
|
|
2585
2585
|
name: normalizedName,
|
|
2586
2586
|
description,
|
|
@@ -2593,8 +2593,8 @@ async function runSharedCommand(sharedNameArg, flags = {}) {
|
|
|
2593
2593
|
});
|
|
2594
2594
|
s.stop("Shared module generated successfully!");
|
|
2595
2595
|
printGeneratedFiles(files, Boolean(flags.dryRun));
|
|
2596
|
-
|
|
2597
|
-
|
|
2596
|
+
p16__namespace.outro(
|
|
2597
|
+
pc16__default.default.green(
|
|
2598
2598
|
`\u2713 Shared module '${normalizedName}' initialized in ${path2__default.default.relative(projectRoot, targetDir)} (uncommitted, unregistered)`
|
|
2599
2599
|
)
|
|
2600
2600
|
);
|
|
@@ -2608,14 +2608,14 @@ async function runUseCaseCommand(useCaseNameArg, flags = {}) {
|
|
|
2608
2608
|
const featureOptions = existingFeatures.map((f) => ({ value: f, label: f }));
|
|
2609
2609
|
featureOptions.push({ value: "__custom__", label: "\u270F\uFE0F Enter custom feature name..." });
|
|
2610
2610
|
const selected = handleCancel(
|
|
2611
|
-
await
|
|
2611
|
+
await p16__namespace.select({
|
|
2612
2612
|
message: "Select target feature:",
|
|
2613
2613
|
options: featureOptions
|
|
2614
2614
|
})
|
|
2615
2615
|
);
|
|
2616
2616
|
if (selected === "__custom__") {
|
|
2617
2617
|
feature = handleCancel(
|
|
2618
|
-
await
|
|
2618
|
+
await p16__namespace.text({
|
|
2619
2619
|
message: "Enter feature name:",
|
|
2620
2620
|
validate: (v) => v && v.trim() ? void 0 : "Feature name cannot be empty"
|
|
2621
2621
|
})
|
|
@@ -2625,7 +2625,7 @@ async function runUseCaseCommand(useCaseNameArg, flags = {}) {
|
|
|
2625
2625
|
}
|
|
2626
2626
|
} else {
|
|
2627
2627
|
feature = handleCancel(
|
|
2628
|
-
await
|
|
2628
|
+
await p16__namespace.text({
|
|
2629
2629
|
message: "Enter target feature name:",
|
|
2630
2630
|
validate: (v) => v && v.trim() ? void 0 : "Feature name cannot be empty"
|
|
2631
2631
|
})
|
|
@@ -2636,7 +2636,7 @@ async function runUseCaseCommand(useCaseNameArg, flags = {}) {
|
|
|
2636
2636
|
let name = useCaseNameArg?.trim();
|
|
2637
2637
|
if (!name) {
|
|
2638
2638
|
name = handleCancel(
|
|
2639
|
-
await
|
|
2639
|
+
await p16__namespace.text({
|
|
2640
2640
|
message: "Use Case name:",
|
|
2641
2641
|
placeholder: "e.g. CreateUser, GetUser, CancelOrder",
|
|
2642
2642
|
validate: (v) => v && v.trim() ? void 0 : "Use Case name cannot be empty"
|
|
@@ -2652,7 +2652,7 @@ async function runUseCaseCommand(useCaseNameArg, flags = {}) {
|
|
|
2652
2652
|
label: i.name
|
|
2653
2653
|
}));
|
|
2654
2654
|
selectedDeps = handleCancel(
|
|
2655
|
-
await
|
|
2655
|
+
await p16__namespace.multiselect({
|
|
2656
2656
|
message: "Select domain interfaces to inject into use case:",
|
|
2657
2657
|
options: multiOptions,
|
|
2658
2658
|
required: false
|
|
@@ -2667,7 +2667,7 @@ async function runUseCaseCommand(useCaseNameArg, flags = {}) {
|
|
|
2667
2667
|
let httpPath = "/";
|
|
2668
2668
|
if (!flags.yes) {
|
|
2669
2669
|
const hasInput = handleCancel(
|
|
2670
|
-
await
|
|
2670
|
+
await p16__namespace.confirm({
|
|
2671
2671
|
message: "Does this use case accept input arguments?",
|
|
2672
2672
|
initialValue: true
|
|
2673
2673
|
})
|
|
@@ -2677,7 +2677,7 @@ async function runUseCaseCommand(useCaseNameArg, flags = {}) {
|
|
|
2677
2677
|
});
|
|
2678
2678
|
}
|
|
2679
2679
|
const hasCustomOutput = handleCancel(
|
|
2680
|
-
await
|
|
2680
|
+
await p16__namespace.confirm({
|
|
2681
2681
|
message: "Does this use case return custom output data?",
|
|
2682
2682
|
initialValue: false
|
|
2683
2683
|
})
|
|
@@ -2687,20 +2687,20 @@ async function runUseCaseCommand(useCaseNameArg, flags = {}) {
|
|
|
2687
2687
|
});
|
|
2688
2688
|
}
|
|
2689
2689
|
includeTest = handleCancel(
|
|
2690
|
-
await
|
|
2690
|
+
await p16__namespace.confirm({
|
|
2691
2691
|
message: "Generate Vitest unit test skeleton (.test.ts)?",
|
|
2692
2692
|
initialValue: true
|
|
2693
2693
|
})
|
|
2694
2694
|
);
|
|
2695
2695
|
createHttp = handleCancel(
|
|
2696
|
-
await
|
|
2696
|
+
await p16__namespace.confirm({
|
|
2697
2697
|
message: "Generate a matching ExpressRoute HTTP handler?",
|
|
2698
2698
|
initialValue: false
|
|
2699
2699
|
})
|
|
2700
2700
|
);
|
|
2701
2701
|
if (createHttp) {
|
|
2702
2702
|
httpMethod = handleCancel(
|
|
2703
|
-
await
|
|
2703
|
+
await p16__namespace.select({
|
|
2704
2704
|
message: "HTTP method for route:",
|
|
2705
2705
|
options: [
|
|
2706
2706
|
{ value: "post", label: "POST" },
|
|
@@ -2713,7 +2713,7 @@ async function runUseCaseCommand(useCaseNameArg, flags = {}) {
|
|
|
2713
2713
|
})
|
|
2714
2714
|
);
|
|
2715
2715
|
httpPath = handleCancel(
|
|
2716
|
-
await
|
|
2716
|
+
await p16__namespace.text({
|
|
2717
2717
|
message: "Route subpath (relative to feature prefix):",
|
|
2718
2718
|
initialValue: "/",
|
|
2719
2719
|
defaultValue: "/"
|
|
@@ -2721,8 +2721,8 @@ async function runUseCaseCommand(useCaseNameArg, flags = {}) {
|
|
|
2721
2721
|
).trim();
|
|
2722
2722
|
}
|
|
2723
2723
|
}
|
|
2724
|
-
const s =
|
|
2725
|
-
s.start(`Generating use case '${
|
|
2724
|
+
const s = p16__namespace.spinner();
|
|
2725
|
+
s.start(`Generating use case '${pc16__default.default.cyan(ucName)}'...`);
|
|
2726
2726
|
const options = {
|
|
2727
2727
|
name: ucName,
|
|
2728
2728
|
feature,
|
|
@@ -2754,7 +2754,7 @@ async function runUseCaseCommand(useCaseNameArg, flags = {}) {
|
|
|
2754
2754
|
}
|
|
2755
2755
|
s.stop("Use case generated successfully!");
|
|
2756
2756
|
printGeneratedFiles(files, options.dryRun);
|
|
2757
|
-
|
|
2757
|
+
p16__namespace.outro(pc16__default.default.green(`Use case '${ucName}' created in feature '${feature}'!`));
|
|
2758
2758
|
}
|
|
2759
2759
|
async function runDomainCommand(domainNameArg, flags = {}) {
|
|
2760
2760
|
const projectRoot = findProjectRoot();
|
|
@@ -2765,14 +2765,14 @@ async function runDomainCommand(domainNameArg, flags = {}) {
|
|
|
2765
2765
|
const featureOptions = existingFeatures.map((f) => ({ value: f, label: f }));
|
|
2766
2766
|
featureOptions.push({ value: "__custom__", label: "\u270F\uFE0F Enter custom feature name..." });
|
|
2767
2767
|
const selected = handleCancel(
|
|
2768
|
-
await
|
|
2768
|
+
await p16__namespace.select({
|
|
2769
2769
|
message: "Select target feature:",
|
|
2770
2770
|
options: featureOptions
|
|
2771
2771
|
})
|
|
2772
2772
|
);
|
|
2773
2773
|
if (selected === "__custom__") {
|
|
2774
2774
|
feature = handleCancel(
|
|
2775
|
-
await
|
|
2775
|
+
await p16__namespace.text({
|
|
2776
2776
|
message: "Enter feature name:",
|
|
2777
2777
|
validate: (v) => v && v.trim() ? void 0 : "Feature name cannot be empty"
|
|
2778
2778
|
})
|
|
@@ -2782,7 +2782,7 @@ async function runDomainCommand(domainNameArg, flags = {}) {
|
|
|
2782
2782
|
}
|
|
2783
2783
|
} else {
|
|
2784
2784
|
feature = handleCancel(
|
|
2785
|
-
await
|
|
2785
|
+
await p16__namespace.text({
|
|
2786
2786
|
message: "Enter target feature name:",
|
|
2787
2787
|
validate: (v) => v && v.trim() ? void 0 : "Feature name cannot be empty"
|
|
2788
2788
|
})
|
|
@@ -2793,7 +2793,7 @@ async function runDomainCommand(domainNameArg, flags = {}) {
|
|
|
2793
2793
|
let name = domainNameArg?.trim();
|
|
2794
2794
|
if (!name) {
|
|
2795
2795
|
name = handleCancel(
|
|
2796
|
-
await
|
|
2796
|
+
await p16__namespace.text({
|
|
2797
2797
|
message: "Domain model / entity name:",
|
|
2798
2798
|
placeholder: "e.g. User, Order, Product, Address",
|
|
2799
2799
|
validate: (v) => v && v.trim() ? void 0 : "Domain name cannot be empty"
|
|
@@ -2805,7 +2805,7 @@ async function runDomainCommand(domainNameArg, flags = {}) {
|
|
|
2805
2805
|
let properties = [];
|
|
2806
2806
|
if (!flags.yes) {
|
|
2807
2807
|
kind = handleCancel(
|
|
2808
|
-
await
|
|
2808
|
+
await p16__namespace.select({
|
|
2809
2809
|
message: "Select domain model type:",
|
|
2810
2810
|
options: [
|
|
2811
2811
|
{ value: "interface", label: "TypeScript Interface (pure data structure)" },
|
|
@@ -2824,8 +2824,8 @@ async function runDomainCommand(domainNameArg, flags = {}) {
|
|
|
2824
2824
|
defaults: kind === "valueObject" ? [{ name: "value", type: "string" }] : defaultProps
|
|
2825
2825
|
});
|
|
2826
2826
|
}
|
|
2827
|
-
const s =
|
|
2828
|
-
s.start(`Generating domain model '${
|
|
2827
|
+
const s = p16__namespace.spinner();
|
|
2828
|
+
s.start(`Generating domain model '${pc16__default.default.cyan(entityName)}'...`);
|
|
2829
2829
|
const options = {
|
|
2830
2830
|
name: entityName,
|
|
2831
2831
|
feature,
|
|
@@ -2838,7 +2838,7 @@ async function runDomainCommand(domainNameArg, flags = {}) {
|
|
|
2838
2838
|
const file = generateDomain(options);
|
|
2839
2839
|
s.stop("Domain model generated successfully!");
|
|
2840
2840
|
printGeneratedFiles([file], options.dryRun);
|
|
2841
|
-
|
|
2841
|
+
p16__namespace.outro(pc16__default.default.green(`Domain model '${entityName}' created in feature '${feature}'!`));
|
|
2842
2842
|
}
|
|
2843
2843
|
async function runInfrastructureCommand(classNameArg, flags = {}) {
|
|
2844
2844
|
const projectRoot = findProjectRoot();
|
|
@@ -2847,7 +2847,7 @@ async function runInfrastructureCommand(classNameArg, flags = {}) {
|
|
|
2847
2847
|
let feature = flags.feature?.trim();
|
|
2848
2848
|
if (!flags.yes && !flags.global && !flags.feature) {
|
|
2849
2849
|
scope = handleCancel(
|
|
2850
|
-
await
|
|
2850
|
+
await p16__namespace.select({
|
|
2851
2851
|
message: "Where should this infrastructure implementation be placed?",
|
|
2852
2852
|
options: [
|
|
2853
2853
|
{ value: "feature", label: "Feature-level (features/<feature>/infrastructure)" },
|
|
@@ -2862,14 +2862,14 @@ async function runInfrastructureCommand(classNameArg, flags = {}) {
|
|
|
2862
2862
|
const featureOptions = existingFeatures.map((f) => ({ value: f, label: f }));
|
|
2863
2863
|
featureOptions.push({ value: "__custom__", label: "\u270F\uFE0F Enter custom feature name..." });
|
|
2864
2864
|
const selected = handleCancel(
|
|
2865
|
-
await
|
|
2865
|
+
await p16__namespace.select({
|
|
2866
2866
|
message: "Select target feature:",
|
|
2867
2867
|
options: featureOptions
|
|
2868
2868
|
})
|
|
2869
2869
|
);
|
|
2870
2870
|
if (selected === "__custom__") {
|
|
2871
2871
|
feature = handleCancel(
|
|
2872
|
-
await
|
|
2872
|
+
await p16__namespace.text({
|
|
2873
2873
|
message: "Enter feature name:",
|
|
2874
2874
|
validate: (v) => v && v.trim() ? void 0 : "Feature name cannot be empty"
|
|
2875
2875
|
})
|
|
@@ -2879,7 +2879,7 @@ async function runInfrastructureCommand(classNameArg, flags = {}) {
|
|
|
2879
2879
|
}
|
|
2880
2880
|
} else {
|
|
2881
2881
|
feature = handleCancel(
|
|
2882
|
-
await
|
|
2882
|
+
await p16__namespace.text({
|
|
2883
2883
|
message: "Enter target feature name:",
|
|
2884
2884
|
validate: (v) => v && v.trim() ? void 0 : "Feature name cannot be empty"
|
|
2885
2885
|
})
|
|
@@ -2892,7 +2892,7 @@ async function runInfrastructureCommand(classNameArg, flags = {}) {
|
|
|
2892
2892
|
let name = classNameArg?.trim();
|
|
2893
2893
|
if (!name) {
|
|
2894
2894
|
name = handleCancel(
|
|
2895
|
-
await
|
|
2895
|
+
await p16__namespace.text({
|
|
2896
2896
|
message: "Infrastructure class name:",
|
|
2897
2897
|
placeholder: "e.g. StubUserRepository, PostgresUserRepository, S3FileStorage",
|
|
2898
2898
|
validate: (v) => v && v.trim() ? void 0 : "Class name cannot be empty"
|
|
@@ -2911,7 +2911,7 @@ async function runInfrastructureCommand(classNameArg, flags = {}) {
|
|
|
2911
2911
|
(i) => className.toLowerCase().includes(removeInterfacePrefix(i.name).toLowerCase())
|
|
2912
2912
|
);
|
|
2913
2913
|
const ifaceChoice = handleCancel(
|
|
2914
|
-
await
|
|
2914
|
+
await p16__namespace.select({
|
|
2915
2915
|
message: "Does this class implement a domain interface or abstract class?",
|
|
2916
2916
|
options: [
|
|
2917
2917
|
...interfaces.map((i) => ({ value: i.name, label: i.name })),
|
|
@@ -2923,7 +2923,7 @@ async function runInfrastructureCommand(classNameArg, flags = {}) {
|
|
|
2923
2923
|
);
|
|
2924
2924
|
if (ifaceChoice === "__custom__") {
|
|
2925
2925
|
implementsInterface = handleCancel(
|
|
2926
|
-
await
|
|
2926
|
+
await p16__namespace.text({
|
|
2927
2927
|
message: "Enter interface or abstract class name:",
|
|
2928
2928
|
placeholder: "e.g. IUserRepository, BaseStorageAdapter",
|
|
2929
2929
|
validate: (v) => v && v.trim() ? void 0 : "Name cannot be empty"
|
|
@@ -2934,14 +2934,14 @@ async function runInfrastructureCommand(classNameArg, flags = {}) {
|
|
|
2934
2934
|
}
|
|
2935
2935
|
} else {
|
|
2936
2936
|
const wantImpl = handleCancel(
|
|
2937
|
-
await
|
|
2937
|
+
await p16__namespace.confirm({
|
|
2938
2938
|
message: "Does this class implement a domain interface or abstract class?",
|
|
2939
2939
|
initialValue: false
|
|
2940
2940
|
})
|
|
2941
2941
|
);
|
|
2942
2942
|
if (wantImpl) {
|
|
2943
2943
|
implementsInterface = handleCancel(
|
|
2944
|
-
await
|
|
2944
|
+
await p16__namespace.text({
|
|
2945
2945
|
message: "Enter interface or abstract class name:",
|
|
2946
2946
|
placeholder: "e.g. IUserRepository, BaseStorageAdapter",
|
|
2947
2947
|
validate: (v) => v && v.trim() ? void 0 : "Name cannot be empty"
|
|
@@ -2961,7 +2961,7 @@ async function runInfrastructureCommand(classNameArg, flags = {}) {
|
|
|
2961
2961
|
const allInterfaces = listDomainInterfaces(projectRoot);
|
|
2962
2962
|
if (allInterfaces.length > 0) {
|
|
2963
2963
|
const ifaceChoice = handleCancel(
|
|
2964
|
-
await
|
|
2964
|
+
await p16__namespace.select({
|
|
2965
2965
|
message: "Does this class implement an interface or abstract class?",
|
|
2966
2966
|
options: [
|
|
2967
2967
|
...allInterfaces.map((i) => ({ value: i.name, label: `${i.name} (${i.feature})` })),
|
|
@@ -2973,7 +2973,7 @@ async function runInfrastructureCommand(classNameArg, flags = {}) {
|
|
|
2973
2973
|
);
|
|
2974
2974
|
if (ifaceChoice === "__custom__") {
|
|
2975
2975
|
implementsInterface = handleCancel(
|
|
2976
|
-
await
|
|
2976
|
+
await p16__namespace.text({
|
|
2977
2977
|
message: "Enter interface or abstract class name:",
|
|
2978
2978
|
placeholder: "e.g. IAuthRepository",
|
|
2979
2979
|
validate: (v) => v && v.trim() ? void 0 : "Name cannot be empty"
|
|
@@ -2986,7 +2986,7 @@ async function runInfrastructureCommand(classNameArg, flags = {}) {
|
|
|
2986
2986
|
}
|
|
2987
2987
|
if (!flags.yes && !flags.kind) {
|
|
2988
2988
|
kind = handleCancel(
|
|
2989
|
-
await
|
|
2989
|
+
await p16__namespace.select({
|
|
2990
2990
|
message: "Select implementation kind:",
|
|
2991
2991
|
options: [
|
|
2992
2992
|
{ value: "stub", label: "In-Memory Stub (with in-memory store and test helper methods)" },
|
|
@@ -2997,7 +2997,7 @@ async function runInfrastructureCommand(classNameArg, flags = {}) {
|
|
|
2997
2997
|
);
|
|
2998
2998
|
if (scope === "feature" && feature && implementsInterface) {
|
|
2999
2999
|
registerInProvider = handleCancel(
|
|
3000
|
-
await
|
|
3000
|
+
await p16__namespace.confirm({
|
|
3001
3001
|
message: "Register this implementation in feature diProvider.ts?",
|
|
3002
3002
|
initialValue: true
|
|
3003
3003
|
})
|
|
@@ -3006,8 +3006,8 @@ async function runInfrastructureCommand(classNameArg, flags = {}) {
|
|
|
3006
3006
|
} else if (flags.yes && scope === "feature" && feature && implementsInterface) {
|
|
3007
3007
|
registerInProvider = !flags.noProvider;
|
|
3008
3008
|
}
|
|
3009
|
-
const s =
|
|
3010
|
-
s.start(`Generating infrastructure class '${
|
|
3009
|
+
const s = p16__namespace.spinner();
|
|
3010
|
+
s.start(`Generating infrastructure class '${pc16__default.default.cyan(className)}'...`);
|
|
3011
3011
|
const files = [];
|
|
3012
3012
|
const options = {
|
|
3013
3013
|
name: className,
|
|
@@ -3042,7 +3042,7 @@ async function runInfrastructureCommand(classNameArg, flags = {}) {
|
|
|
3042
3042
|
}
|
|
3043
3043
|
s.stop("Infrastructure class generated successfully!");
|
|
3044
3044
|
printGeneratedFiles(files, options.dryRun);
|
|
3045
|
-
|
|
3045
|
+
p16__namespace.outro(pc16__default.default.green(`Infrastructure class '${className}' created!`));
|
|
3046
3046
|
}
|
|
3047
3047
|
async function runInterfaceCommand(interfaceNameArg, flags = {}) {
|
|
3048
3048
|
const projectRoot = findProjectRoot();
|
|
@@ -3053,14 +3053,14 @@ async function runInterfaceCommand(interfaceNameArg, flags = {}) {
|
|
|
3053
3053
|
const featureOptions = existingFeatures.map((f) => ({ value: f, label: f }));
|
|
3054
3054
|
featureOptions.push({ value: "__custom__", label: "\u270F\uFE0F Enter custom feature name..." });
|
|
3055
3055
|
const selected = handleCancel(
|
|
3056
|
-
await
|
|
3056
|
+
await p16__namespace.select({
|
|
3057
3057
|
message: "Select target feature:",
|
|
3058
3058
|
options: featureOptions
|
|
3059
3059
|
})
|
|
3060
3060
|
);
|
|
3061
3061
|
if (selected === "__custom__") {
|
|
3062
3062
|
feature = handleCancel(
|
|
3063
|
-
await
|
|
3063
|
+
await p16__namespace.text({
|
|
3064
3064
|
message: "Enter feature name:",
|
|
3065
3065
|
validate: (v) => v && v.trim() ? void 0 : "Feature name cannot be empty"
|
|
3066
3066
|
})
|
|
@@ -3070,7 +3070,7 @@ async function runInterfaceCommand(interfaceNameArg, flags = {}) {
|
|
|
3070
3070
|
}
|
|
3071
3071
|
} else {
|
|
3072
3072
|
feature = handleCancel(
|
|
3073
|
-
await
|
|
3073
|
+
await p16__namespace.text({
|
|
3074
3074
|
message: "Enter target feature name:",
|
|
3075
3075
|
validate: (v) => v && v.trim() ? void 0 : "Feature name cannot be empty"
|
|
3076
3076
|
})
|
|
@@ -3081,7 +3081,7 @@ async function runInterfaceCommand(interfaceNameArg, flags = {}) {
|
|
|
3081
3081
|
let name = interfaceNameArg?.trim();
|
|
3082
3082
|
if (!name) {
|
|
3083
3083
|
name = handleCancel(
|
|
3084
|
-
await
|
|
3084
|
+
await p16__namespace.text({
|
|
3085
3085
|
message: "Domain interface name:",
|
|
3086
3086
|
placeholder: "e.g. IUserRepository, IPaymentService",
|
|
3087
3087
|
validate: (v) => v && v.trim() ? void 0 : "Interface name cannot be empty"
|
|
@@ -3099,7 +3099,7 @@ async function runInterfaceCommand(interfaceNameArg, flags = {}) {
|
|
|
3099
3099
|
if (!flags.yes) {
|
|
3100
3100
|
if (existingEntities.length > 0) {
|
|
3101
3101
|
const selectedEntity = handleCancel(
|
|
3102
|
-
await
|
|
3102
|
+
await p16__namespace.select({
|
|
3103
3103
|
message: "Select domain entity associated with this interface:",
|
|
3104
3104
|
options: [
|
|
3105
3105
|
...existingEntities.map((e) => ({ value: e.name, label: e.name })),
|
|
@@ -3110,7 +3110,7 @@ async function runInterfaceCommand(interfaceNameArg, flags = {}) {
|
|
|
3110
3110
|
);
|
|
3111
3111
|
if (selectedEntity === "__custom__") {
|
|
3112
3112
|
entityName = handleCancel(
|
|
3113
|
-
await
|
|
3113
|
+
await p16__namespace.text({
|
|
3114
3114
|
message: "Enter entity name:",
|
|
3115
3115
|
defaultValue: removeInterfacePrefix(ifaceName).replace(/Repository$|Service$/, "")
|
|
3116
3116
|
})
|
|
@@ -3120,7 +3120,7 @@ async function runInterfaceCommand(interfaceNameArg, flags = {}) {
|
|
|
3120
3120
|
}
|
|
3121
3121
|
}
|
|
3122
3122
|
kind = handleCancel(
|
|
3123
|
-
await
|
|
3123
|
+
await p16__namespace.select({
|
|
3124
3124
|
message: "Interface definition style:",
|
|
3125
3125
|
options: [
|
|
3126
3126
|
{ value: "abstractClass", label: "Abstract Class (Recommended - acts as DI token & type)" },
|
|
@@ -3130,7 +3130,7 @@ async function runInterfaceCommand(interfaceNameArg, flags = {}) {
|
|
|
3130
3130
|
})
|
|
3131
3131
|
);
|
|
3132
3132
|
methodsPreset = handleCancel(
|
|
3133
|
-
await
|
|
3133
|
+
await p16__namespace.select({
|
|
3134
3134
|
message: "Method signature preset:",
|
|
3135
3135
|
options: [
|
|
3136
3136
|
{ value: "crud", label: "Standard CRUD (GetById, List, Create, Update, Delete)" },
|
|
@@ -3140,22 +3140,22 @@ async function runInterfaceCommand(interfaceNameArg, flags = {}) {
|
|
|
3140
3140
|
})
|
|
3141
3141
|
);
|
|
3142
3142
|
generateStub = handleCancel(
|
|
3143
|
-
await
|
|
3143
|
+
await p16__namespace.confirm({
|
|
3144
3144
|
message: "Auto-generate Infrastructure Stub implementation?",
|
|
3145
3145
|
initialValue: true
|
|
3146
3146
|
})
|
|
3147
3147
|
);
|
|
3148
3148
|
if (generateStub) {
|
|
3149
3149
|
registerInProvider = handleCancel(
|
|
3150
|
-
await
|
|
3150
|
+
await p16__namespace.confirm({
|
|
3151
3151
|
message: "Auto-register interface & stub in feature diProvider.ts?",
|
|
3152
3152
|
initialValue: true
|
|
3153
3153
|
})
|
|
3154
3154
|
);
|
|
3155
3155
|
}
|
|
3156
3156
|
}
|
|
3157
|
-
const s =
|
|
3158
|
-
s.start(`Generating interface '${
|
|
3157
|
+
const s = p16__namespace.spinner();
|
|
3158
|
+
s.start(`Generating interface '${pc16__default.default.cyan(ifaceName)}'...`);
|
|
3159
3159
|
const files = [];
|
|
3160
3160
|
const options = {
|
|
3161
3161
|
name: ifaceName,
|
|
@@ -3204,7 +3204,7 @@ async function runInterfaceCommand(interfaceNameArg, flags = {}) {
|
|
|
3204
3204
|
}
|
|
3205
3205
|
s.stop("Interface generated successfully!");
|
|
3206
3206
|
printGeneratedFiles(files, options.dryRun);
|
|
3207
|
-
|
|
3207
|
+
p16__namespace.outro(pc16__default.default.green(`Interface '${ifaceName}' created in feature '${feature}'!`));
|
|
3208
3208
|
}
|
|
3209
3209
|
async function runHttpHandlerCommand(handlerNameArg, flags = {}) {
|
|
3210
3210
|
const projectRoot = findProjectRoot();
|
|
@@ -3215,14 +3215,14 @@ async function runHttpHandlerCommand(handlerNameArg, flags = {}) {
|
|
|
3215
3215
|
const featureOptions = existingFeatures.map((f) => ({ value: f, label: f }));
|
|
3216
3216
|
featureOptions.push({ value: "__custom__", label: "\u270F\uFE0F Enter custom feature name..." });
|
|
3217
3217
|
const selected = handleCancel(
|
|
3218
|
-
await
|
|
3218
|
+
await p16__namespace.select({
|
|
3219
3219
|
message: "Select target feature:",
|
|
3220
3220
|
options: featureOptions
|
|
3221
3221
|
})
|
|
3222
3222
|
);
|
|
3223
3223
|
if (selected === "__custom__") {
|
|
3224
3224
|
feature = handleCancel(
|
|
3225
|
-
await
|
|
3225
|
+
await p16__namespace.text({
|
|
3226
3226
|
message: "Enter feature name:",
|
|
3227
3227
|
validate: (v) => v && v.trim() ? void 0 : "Feature name cannot be empty"
|
|
3228
3228
|
})
|
|
@@ -3232,7 +3232,7 @@ async function runHttpHandlerCommand(handlerNameArg, flags = {}) {
|
|
|
3232
3232
|
}
|
|
3233
3233
|
} else {
|
|
3234
3234
|
feature = handleCancel(
|
|
3235
|
-
await
|
|
3235
|
+
await p16__namespace.text({
|
|
3236
3236
|
message: "Enter target feature name:",
|
|
3237
3237
|
validate: (v) => v && v.trim() ? void 0 : "Feature name cannot be empty"
|
|
3238
3238
|
})
|
|
@@ -3243,7 +3243,7 @@ async function runHttpHandlerCommand(handlerNameArg, flags = {}) {
|
|
|
3243
3243
|
let name = handlerNameArg?.trim();
|
|
3244
3244
|
if (!name) {
|
|
3245
3245
|
name = handleCancel(
|
|
3246
|
-
await
|
|
3246
|
+
await p16__namespace.text({
|
|
3247
3247
|
message: "HTTP Route Handler class name:",
|
|
3248
3248
|
placeholder: "e.g. CreateUserHttp, GetUserHttp, HealthHttp",
|
|
3249
3249
|
validate: (v) => v && v.trim() ? void 0 : "Handler name cannot be empty"
|
|
@@ -3262,7 +3262,7 @@ async function runHttpHandlerCommand(handlerNameArg, flags = {}) {
|
|
|
3262
3262
|
let validationFields = [];
|
|
3263
3263
|
if (!flags.yes) {
|
|
3264
3264
|
method = handleCancel(
|
|
3265
|
-
await
|
|
3265
|
+
await p16__namespace.select({
|
|
3266
3266
|
message: "HTTP Method:",
|
|
3267
3267
|
options: [
|
|
3268
3268
|
{ value: "get", label: "GET" },
|
|
@@ -3276,7 +3276,7 @@ async function runHttpHandlerCommand(handlerNameArg, flags = {}) {
|
|
|
3276
3276
|
);
|
|
3277
3277
|
const defaultPath = method === "get" ? "/" : "/";
|
|
3278
3278
|
subPath = handleCancel(
|
|
3279
|
-
await
|
|
3279
|
+
await p16__namespace.text({
|
|
3280
3280
|
message: "Route subpath (relative to feature prefix):",
|
|
3281
3281
|
initialValue: defaultPath,
|
|
3282
3282
|
defaultValue: defaultPath
|
|
@@ -3287,7 +3287,7 @@ async function runHttpHandlerCommand(handlerNameArg, flags = {}) {
|
|
|
3287
3287
|
const ucOptions = useCases.map((u) => ({ value: u.name, label: u.name }));
|
|
3288
3288
|
ucOptions.push({ value: "__none__", label: "None / Standalone Handler" });
|
|
3289
3289
|
const chosenUc = handleCancel(
|
|
3290
|
-
await
|
|
3290
|
+
await p16__namespace.select({
|
|
3291
3291
|
message: "Connect this handler to a domain Use Case?",
|
|
3292
3292
|
options: ucOptions,
|
|
3293
3293
|
initialValue: ucOptions[0]?.value
|
|
@@ -3298,7 +3298,7 @@ async function runHttpHandlerCommand(handlerNameArg, flags = {}) {
|
|
|
3298
3298
|
}
|
|
3299
3299
|
}
|
|
3300
3300
|
includeValidation = handleCancel(
|
|
3301
|
-
await
|
|
3301
|
+
await p16__namespace.confirm({
|
|
3302
3302
|
message: "Include Zod inbound request validation?",
|
|
3303
3303
|
initialValue: method !== "delete"
|
|
3304
3304
|
})
|
|
@@ -3306,7 +3306,7 @@ async function runHttpHandlerCommand(handlerNameArg, flags = {}) {
|
|
|
3306
3306
|
if (includeValidation) {
|
|
3307
3307
|
const defaultSource = method === "get" ? "query" : "body";
|
|
3308
3308
|
validationSource = handleCancel(
|
|
3309
|
-
await
|
|
3309
|
+
await p16__namespace.select({
|
|
3310
3310
|
message: "Validation data source:",
|
|
3311
3311
|
options: [
|
|
3312
3312
|
{ value: "body", label: "req.body (for POST / PUT / PATCH payloads)" },
|
|
@@ -3320,8 +3320,8 @@ async function runHttpHandlerCommand(handlerNameArg, flags = {}) {
|
|
|
3320
3320
|
});
|
|
3321
3321
|
}
|
|
3322
3322
|
}
|
|
3323
|
-
const s =
|
|
3324
|
-
s.start(`Generating HTTP handler '${
|
|
3323
|
+
const s = p16__namespace.spinner();
|
|
3324
|
+
s.start(`Generating HTTP handler '${pc16__default.default.cyan(className)}'...`);
|
|
3325
3325
|
const options = {
|
|
3326
3326
|
name: className,
|
|
3327
3327
|
feature,
|
|
@@ -3339,7 +3339,7 @@ async function runHttpHandlerCommand(handlerNameArg, flags = {}) {
|
|
|
3339
3339
|
const files = generateHttpHandler(options);
|
|
3340
3340
|
s.stop("HTTP handler generated successfully!");
|
|
3341
3341
|
printGeneratedFiles(files, options.dryRun);
|
|
3342
|
-
|
|
3342
|
+
p16__namespace.outro(pc16__default.default.green(`HTTP handler '${className}' created in feature '${feature}'!`));
|
|
3343
3343
|
}
|
|
3344
3344
|
function generateInjectableCode(className, dependencies = [], methods = [], implementsInterface) {
|
|
3345
3345
|
const formattedDeps = dependencies.map((dep) => ({
|
|
@@ -3349,7 +3349,7 @@ function generateInjectableCode(className, dependencies = [], methods = [], impl
|
|
|
3349
3349
|
const formattedMethods = methods.map((m) => {
|
|
3350
3350
|
const isAsync = m.async !== false;
|
|
3351
3351
|
const retType = m.returnType ? isAsync ? `Promise<${m.returnType}>` : m.returnType : isAsync ? "Promise<void>" : "void";
|
|
3352
|
-
const params = m.params && m.params.length > 0 ? m.params.map((
|
|
3352
|
+
const params = m.params && m.params.length > 0 ? m.params.map((p19) => `${p19.name}: ${p19.type}`).join(", ") : "";
|
|
3353
3353
|
return {
|
|
3354
3354
|
name: m.name,
|
|
3355
3355
|
isAsync,
|
|
@@ -3419,7 +3419,7 @@ async function runInjectableCommand(classNameArg, flags = {}) {
|
|
|
3419
3419
|
let name = classNameArg?.trim();
|
|
3420
3420
|
if (!name) {
|
|
3421
3421
|
name = handleCancel(
|
|
3422
|
-
await
|
|
3422
|
+
await p16__namespace.text({
|
|
3423
3423
|
message: "Injectable class name:",
|
|
3424
3424
|
placeholder: "e.g. PasswordHasher, TokenService, UserTransformer",
|
|
3425
3425
|
validate: (v) => v && v.trim() ? void 0 : "Class name cannot be empty"
|
|
@@ -3432,7 +3432,7 @@ async function runInjectableCommand(classNameArg, flags = {}) {
|
|
|
3432
3432
|
let customPath;
|
|
3433
3433
|
if (!flags.yes) {
|
|
3434
3434
|
location = handleCancel(
|
|
3435
|
-
await
|
|
3435
|
+
await p16__namespace.select({
|
|
3436
3436
|
message: "Select target architectural location:",
|
|
3437
3437
|
options: [
|
|
3438
3438
|
{ value: "feature-service", label: "Feature Service (features/<feature>/services/)" },
|
|
@@ -3450,14 +3450,14 @@ async function runInjectableCommand(classNameArg, flags = {}) {
|
|
|
3450
3450
|
const featureOptions = existingFeatures.map((f) => ({ value: f, label: f }));
|
|
3451
3451
|
featureOptions.push({ value: "__custom__", label: "\u270F\uFE0F Enter custom feature name..." });
|
|
3452
3452
|
const selected = handleCancel(
|
|
3453
|
-
await
|
|
3453
|
+
await p16__namespace.select({
|
|
3454
3454
|
message: "Select target feature:",
|
|
3455
3455
|
options: featureOptions
|
|
3456
3456
|
})
|
|
3457
3457
|
);
|
|
3458
3458
|
if (selected === "__custom__") {
|
|
3459
3459
|
feature = handleCancel(
|
|
3460
|
-
await
|
|
3460
|
+
await p16__namespace.text({
|
|
3461
3461
|
message: "Enter feature name:",
|
|
3462
3462
|
validate: (v) => v && v.trim() ? void 0 : "Feature name cannot be empty"
|
|
3463
3463
|
})
|
|
@@ -3467,7 +3467,7 @@ async function runInjectableCommand(classNameArg, flags = {}) {
|
|
|
3467
3467
|
}
|
|
3468
3468
|
} else {
|
|
3469
3469
|
feature = handleCancel(
|
|
3470
|
-
await
|
|
3470
|
+
await p16__namespace.text({
|
|
3471
3471
|
message: "Enter target feature name:",
|
|
3472
3472
|
validate: (v) => v && v.trim() ? void 0 : "Feature name cannot be empty"
|
|
3473
3473
|
})
|
|
@@ -3477,7 +3477,7 @@ async function runInjectableCommand(classNameArg, flags = {}) {
|
|
|
3477
3477
|
feature = toCamelCase(feature);
|
|
3478
3478
|
} else if (location === "custom") {
|
|
3479
3479
|
customPath = handleCancel(
|
|
3480
|
-
await
|
|
3480
|
+
await p16__namespace.text({
|
|
3481
3481
|
message: "Enter destination directory path:",
|
|
3482
3482
|
placeholder: "e.g. src/services or lib/utils",
|
|
3483
3483
|
validate: (v) => v && v.trim() ? void 0 : "Path cannot be empty"
|
|
@@ -3488,14 +3488,14 @@ async function runInjectableCommand(classNameArg, flags = {}) {
|
|
|
3488
3488
|
let generateInterface2 = false;
|
|
3489
3489
|
if (!flags.yes) {
|
|
3490
3490
|
generateInterface2 = handleCancel(
|
|
3491
|
-
await
|
|
3491
|
+
await p16__namespace.confirm({
|
|
3492
3492
|
message: `Generate abstract class interface (I${className}) as runtime DI token?`,
|
|
3493
3493
|
initialValue: false
|
|
3494
3494
|
})
|
|
3495
3495
|
);
|
|
3496
3496
|
}
|
|
3497
|
-
const s =
|
|
3498
|
-
s.start(`Generating injectable '${
|
|
3497
|
+
const s = p16__namespace.spinner();
|
|
3498
|
+
s.start(`Generating injectable '${pc16__default.default.cyan(className)}'...`);
|
|
3499
3499
|
const options = {
|
|
3500
3500
|
name: className,
|
|
3501
3501
|
feature,
|
|
@@ -3509,12 +3509,83 @@ async function runInjectableCommand(classNameArg, flags = {}) {
|
|
|
3509
3509
|
const files = generateInjectable(options);
|
|
3510
3510
|
s.stop("Injectable class generated successfully!");
|
|
3511
3511
|
printGeneratedFiles(files, options.dryRun);
|
|
3512
|
-
|
|
3512
|
+
p16__namespace.outro(pc16__default.default.green(`Injectable '${className}' created successfully!`));
|
|
3513
3513
|
}
|
|
3514
|
+
async function runEnvCommand(flags = {}) {
|
|
3515
|
+
const projectRoot = flags.cwd || flags.targetDir || findProjectRoot();
|
|
3516
|
+
const s = p16__namespace.spinner();
|
|
3517
|
+
s.start("Scanning for .example environment files...");
|
|
3518
|
+
const files = fs4__default.default.readdirSync(projectRoot);
|
|
3519
|
+
const exampleFiles = files.filter((file) => file.startsWith(".env") && file.endsWith(".example")).sort();
|
|
3520
|
+
if (exampleFiles.length === 0) {
|
|
3521
|
+
s.stop("No .example files found.");
|
|
3522
|
+
p16__namespace.log.info(pc16__default.default.yellow(`No files matching '.env*.example' were found in ${projectRoot}`));
|
|
3523
|
+
return [];
|
|
3524
|
+
}
|
|
3525
|
+
s.message(`Found ${exampleFiles.length} template(s). Generating...`);
|
|
3526
|
+
const generatedFiles = [];
|
|
3527
|
+
for (const exampleFile of exampleFiles) {
|
|
3528
|
+
const sourcePath = path2__default.default.join(projectRoot, exampleFile);
|
|
3529
|
+
const targetFile = exampleFile.replace(/\.example$/, "");
|
|
3530
|
+
const targetPath = path2__default.default.join(projectRoot, targetFile);
|
|
3531
|
+
const content = fs4__default.default.readFileSync(sourcePath, "utf-8");
|
|
3532
|
+
const genFile = writeFileSafely(targetPath, content, {
|
|
3533
|
+
projectRoot,
|
|
3534
|
+
dryRun: Boolean(flags.dryRun),
|
|
3535
|
+
overwrite: Boolean(flags.overwrite)
|
|
3536
|
+
});
|
|
3537
|
+
generatedFiles.push(genFile);
|
|
3538
|
+
}
|
|
3539
|
+
s.stop("Environment files processed!");
|
|
3540
|
+
printGeneratedFiles(generatedFiles, Boolean(flags.dryRun));
|
|
3541
|
+
p16__namespace.outro(pc16__default.default.green("\u2713 Local environment files are ready!"));
|
|
3542
|
+
return generatedFiles;
|
|
3543
|
+
}
|
|
3544
|
+
async function runEnvExamplesCommand(flags = {}) {
|
|
3545
|
+
const projectRoot = flags.cwd || flags.targetDir || findProjectRoot();
|
|
3546
|
+
const s = p16__namespace.spinner();
|
|
3547
|
+
s.start("Scanning for local environment files...");
|
|
3548
|
+
const files = fs4__default.default.readdirSync(projectRoot, { withFileTypes: true });
|
|
3549
|
+
const envFiles = files.filter((dirent) => dirent.isFile() && dirent.name.startsWith(".env") && !dirent.name.endsWith(".example")).map((dirent) => dirent.name).sort();
|
|
3550
|
+
if (envFiles.length === 0) {
|
|
3551
|
+
s.stop("No local .env files found.");
|
|
3552
|
+
p16__namespace.log.info(pc16__default.default.yellow(`No files matching '.env*' were found in ${projectRoot}`));
|
|
3553
|
+
return [];
|
|
3554
|
+
}
|
|
3555
|
+
s.message(`Found ${envFiles.length} local .env file(s). Generating templates...`);
|
|
3556
|
+
const generatedFiles = [];
|
|
3557
|
+
for (const envFile of envFiles) {
|
|
3558
|
+
const sourcePath = path2__default.default.join(projectRoot, envFile);
|
|
3559
|
+
const targetFile = `${envFile}.example`;
|
|
3560
|
+
const targetPath = path2__default.default.join(projectRoot, targetFile);
|
|
3561
|
+
const content = fs4__default.default.readFileSync(sourcePath, "utf-8");
|
|
3562
|
+
const redactedContent = content.split(/\r?\n/).map((line) => {
|
|
3563
|
+
const trimmed = line.trim();
|
|
3564
|
+
if (trimmed.startsWith("#") || !trimmed) return line;
|
|
3565
|
+
const eqIndex = line.indexOf("=");
|
|
3566
|
+
if (eqIndex !== -1) {
|
|
3567
|
+
return line.substring(0, eqIndex + 1);
|
|
3568
|
+
}
|
|
3569
|
+
return line;
|
|
3570
|
+
}).join("\n");
|
|
3571
|
+
const genFile = writeFileSafely(targetPath, redactedContent, {
|
|
3572
|
+
projectRoot,
|
|
3573
|
+
dryRun: Boolean(flags.dryRun),
|
|
3574
|
+
overwrite: Boolean(flags.overwrite)
|
|
3575
|
+
});
|
|
3576
|
+
generatedFiles.push(genFile);
|
|
3577
|
+
}
|
|
3578
|
+
s.stop("Environment example templates generated!");
|
|
3579
|
+
printGeneratedFiles(generatedFiles, Boolean(flags.dryRun));
|
|
3580
|
+
p16__namespace.outro(pc16__default.default.green("\u2713 .env*.example files are up to date and safely redacted!"));
|
|
3581
|
+
return generatedFiles;
|
|
3582
|
+
}
|
|
3583
|
+
|
|
3584
|
+
// src/commands/menu.ts
|
|
3514
3585
|
async function runInteractiveMenu(flags = {}) {
|
|
3515
3586
|
printBanner();
|
|
3516
3587
|
const choice = handleCancel(
|
|
3517
|
-
await
|
|
3588
|
+
await p16__namespace.select({
|
|
3518
3589
|
message: "What would you like to create in your architecture?",
|
|
3519
3590
|
options: [
|
|
3520
3591
|
{
|
|
@@ -3556,6 +3627,16 @@ async function runInteractiveMenu(flags = {}) {
|
|
|
3556
3627
|
value: "injectable",
|
|
3557
3628
|
label: "Injectable Service",
|
|
3558
3629
|
hint: "Generic @MakeInjectable class for services, transformers, or modules"
|
|
3630
|
+
},
|
|
3631
|
+
{
|
|
3632
|
+
value: "env",
|
|
3633
|
+
label: "Generate Env Files",
|
|
3634
|
+
hint: "Clone .env*.example files to local .env equivalents (Setup)"
|
|
3635
|
+
},
|
|
3636
|
+
{
|
|
3637
|
+
value: "envExamples",
|
|
3638
|
+
label: "Sync Env Examples",
|
|
3639
|
+
hint: "Safely clone and redact local .env files to .example templates (Sync)"
|
|
3559
3640
|
}
|
|
3560
3641
|
]
|
|
3561
3642
|
})
|
|
@@ -3585,6 +3666,12 @@ async function runInteractiveMenu(flags = {}) {
|
|
|
3585
3666
|
case "injectable":
|
|
3586
3667
|
await runInjectableCommand(void 0, flags);
|
|
3587
3668
|
break;
|
|
3669
|
+
case "env":
|
|
3670
|
+
await runEnvCommand(flags);
|
|
3671
|
+
break;
|
|
3672
|
+
case "envExamples":
|
|
3673
|
+
await runEnvExamplesCommand({ ...flags, overwrite: flags.overwrite ?? true });
|
|
3674
|
+
break;
|
|
3588
3675
|
}
|
|
3589
3676
|
}
|
|
3590
3677
|
|
|
@@ -3622,8 +3709,8 @@ async function handleCreate(type, name, flags = {}) {
|
|
|
3622
3709
|
await runInjectableCommand(name, flags);
|
|
3623
3710
|
break;
|
|
3624
3711
|
default:
|
|
3625
|
-
|
|
3626
|
-
|
|
3712
|
+
p16__namespace.log.error(
|
|
3713
|
+
pc16__default.default.red(
|
|
3627
3714
|
`Unknown component type: "${type}". Allowed types: feature, shared, usecase, domain, infrastructure, interface, httpHandler, injectable.`
|
|
3628
3715
|
)
|
|
3629
3716
|
);
|
|
@@ -3631,9 +3718,9 @@ async function handleCreate(type, name, flags = {}) {
|
|
|
3631
3718
|
}
|
|
3632
3719
|
}
|
|
3633
3720
|
var importPrompts = {
|
|
3634
|
-
select:
|
|
3635
|
-
text:
|
|
3636
|
-
confirm:
|
|
3721
|
+
select: p16__namespace.select,
|
|
3722
|
+
text: p16__namespace.text,
|
|
3723
|
+
confirm: p16__namespace.confirm
|
|
3637
3724
|
};
|
|
3638
3725
|
function isTestFile(filePath) {
|
|
3639
3726
|
const normalized = filePath.replace(/\\/g, "/");
|
|
@@ -3743,19 +3830,19 @@ async function handleImport(typeArg, nameArg, flags = {}) {
|
|
|
3743
3830
|
);
|
|
3744
3831
|
}
|
|
3745
3832
|
if (type !== "shared" && type !== "feature") {
|
|
3746
|
-
|
|
3833
|
+
p16__namespace.log.error(pc16__default.default.red(`Invalid module type: "${typeArg}". Must be "shared" or "feature".`));
|
|
3747
3834
|
process.exit(1);
|
|
3748
3835
|
}
|
|
3749
3836
|
const registryBase = getRegistryBase(projectRoot, flags.registry);
|
|
3750
|
-
const s =
|
|
3751
|
-
s.start(`Connecting to registry at ${
|
|
3837
|
+
const s = p16__namespace.spinner();
|
|
3838
|
+
s.start(`Connecting to registry at ${pc16__default.default.dim(registryBase)}...`);
|
|
3752
3839
|
let index;
|
|
3753
3840
|
try {
|
|
3754
3841
|
index = await fetchRegistryIndex(registryBase);
|
|
3755
3842
|
s.stop("Registry index loaded.");
|
|
3756
3843
|
} catch (err) {
|
|
3757
|
-
s.stop(
|
|
3758
|
-
|
|
3844
|
+
s.stop(pc16__default.default.red("Failed to load registry index."));
|
|
3845
|
+
p16__namespace.log.error(pc16__default.default.red(err.message || String(err)));
|
|
3759
3846
|
process.exit(1);
|
|
3760
3847
|
}
|
|
3761
3848
|
const availableList = type === "shared" ? index.shared : index.features;
|
|
@@ -3763,7 +3850,7 @@ async function handleImport(typeArg, nameArg, flags = {}) {
|
|
|
3763
3850
|
let name = nameArg?.trim();
|
|
3764
3851
|
if (!name) {
|
|
3765
3852
|
if (availableList.length === 0) {
|
|
3766
|
-
|
|
3853
|
+
p16__namespace.log.warn(`No ${type} modules available in the registry.`);
|
|
3767
3854
|
return;
|
|
3768
3855
|
}
|
|
3769
3856
|
name = handleCancel(
|
|
@@ -3779,9 +3866,9 @@ async function handleImport(typeArg, nameArg, flags = {}) {
|
|
|
3779
3866
|
}
|
|
3780
3867
|
if (!candidateNames.includes(name)) {
|
|
3781
3868
|
const closest = findClosestMatch(name, candidateNames);
|
|
3782
|
-
|
|
3869
|
+
p16__namespace.log.error(pc16__default.default.red(`\u274C Module '${name}' not found in the ${type} registry.`));
|
|
3783
3870
|
if (closest) {
|
|
3784
|
-
|
|
3871
|
+
p16__namespace.log.info(pc16__default.default.yellow(`Did you mean '${pc16__default.default.cyan(closest)}'?`));
|
|
3785
3872
|
}
|
|
3786
3873
|
process.exit(1);
|
|
3787
3874
|
}
|
|
@@ -3793,7 +3880,7 @@ async function handleImport(typeArg, nameArg, flags = {}) {
|
|
|
3793
3880
|
try {
|
|
3794
3881
|
manifest = await fetchModuleManifest(registryBase, modType, modName);
|
|
3795
3882
|
} catch (err) {
|
|
3796
|
-
|
|
3883
|
+
p16__namespace.log.error(pc16__default.default.red(`Failed to fetch manifest for ${modType} '${modName}': ${err.message}`));
|
|
3797
3884
|
process.exit(1);
|
|
3798
3885
|
}
|
|
3799
3886
|
nodes.set(key, {
|
|
@@ -3833,7 +3920,7 @@ async function handleImport(typeArg, nameArg, flags = {}) {
|
|
|
3833
3920
|
buildTopologicalOrder(rootKey);
|
|
3834
3921
|
const resolutions = /* @__PURE__ */ new Map();
|
|
3835
3922
|
const globalAliasMap = /* @__PURE__ */ new Map();
|
|
3836
|
-
|
|
3923
|
+
p16__namespace.log.step(`Importing ${type}: ${pc16__default.default.cyan(name)}...`);
|
|
3837
3924
|
for (const key of orderedKeys) {
|
|
3838
3925
|
const node = nodes.get(key);
|
|
3839
3926
|
const { type: modType, name: registryName, manifest } = node;
|
|
@@ -3865,8 +3952,8 @@ async function handleImport(typeArg, nameArg, flags = {}) {
|
|
|
3865
3952
|
const programmaticPointTo = pointToMap[registryName] || pointToMap[`${modType}/${registryName}`];
|
|
3866
3953
|
if (programmaticPointTo) {
|
|
3867
3954
|
if (!checkModuleExists(projectRoot, modType, programmaticPointTo)) {
|
|
3868
|
-
|
|
3869
|
-
|
|
3955
|
+
p16__namespace.log.error(
|
|
3956
|
+
pc16__default.default.red(
|
|
3870
3957
|
`Module '${programmaticPointTo}' specified in --point-to does not exist in ${folder}.`
|
|
3871
3958
|
)
|
|
3872
3959
|
);
|
|
@@ -3874,7 +3961,7 @@ async function handleImport(typeArg, nameArg, flags = {}) {
|
|
|
3874
3961
|
}
|
|
3875
3962
|
globalAliasMap.set(`@/${folder}/${registryName}/`, `@/${folder}/${programmaticPointTo}/`);
|
|
3876
3963
|
globalAliasMap.set(`@/${folder}/${registryName}`, `@/${folder}/${programmaticPointTo}`);
|
|
3877
|
-
|
|
3964
|
+
p16__namespace.log.step(`Pointing '${modType}/${registryName}' to existing '${folder}/${programmaticPointTo}'`);
|
|
3878
3965
|
resolutions.set(key, {
|
|
3879
3966
|
type: modType,
|
|
3880
3967
|
registryName,
|
|
@@ -3890,7 +3977,7 @@ async function handleImport(typeArg, nameArg, flags = {}) {
|
|
|
3890
3977
|
globalAliasMap.set(`@/${folder}/${registryName}`, `@/${folder}/${programmaticAlias}`);
|
|
3891
3978
|
const baseDir = getModuleBaseDir(projectRoot, modType);
|
|
3892
3979
|
const displayDest = path2__default.default.relative(projectRoot, path2__default.default.join(baseDir, programmaticAlias));
|
|
3893
|
-
|
|
3980
|
+
p16__namespace.log.step(`Importing '${registryName}' into '${displayDest}'...`);
|
|
3894
3981
|
resolutions.set(key, {
|
|
3895
3982
|
type: modType,
|
|
3896
3983
|
registryName,
|
|
@@ -3902,7 +3989,7 @@ async function handleImport(typeArg, nameArg, flags = {}) {
|
|
|
3902
3989
|
}
|
|
3903
3990
|
const existingDir = getExistingModuleDir(projectRoot, modType, registryName);
|
|
3904
3991
|
if (!existingDir) {
|
|
3905
|
-
|
|
3992
|
+
p16__namespace.log.info(` \u21B3 Resolving required ${modType} dependency: ${pc16__default.default.cyan(registryName)}`);
|
|
3906
3993
|
resolutions.set(key, {
|
|
3907
3994
|
type: modType,
|
|
3908
3995
|
registryName,
|
|
@@ -3918,7 +4005,7 @@ async function handleImport(typeArg, nameArg, flags = {}) {
|
|
|
3918
4005
|
const remoteIntegrity = manifest.integrity || entry?.integrity;
|
|
3919
4006
|
const localHash = computeDirectoryHash(existingDir);
|
|
3920
4007
|
if (remoteIntegrity && localHash === remoteIntegrity) {
|
|
3921
|
-
|
|
4008
|
+
p16__namespace.log.step(`\u2713 ${modType}/${registryName} is up to date (reusing existing)`);
|
|
3922
4009
|
resolutions.set(key, {
|
|
3923
4010
|
type: modType,
|
|
3924
4011
|
registryName,
|
|
@@ -3929,7 +4016,7 @@ async function handleImport(typeArg, nameArg, flags = {}) {
|
|
|
3929
4016
|
continue;
|
|
3930
4017
|
}
|
|
3931
4018
|
if (flags.overwrite) {
|
|
3932
|
-
|
|
4019
|
+
p16__namespace.log.step(`Overwriting '${modType}/${registryName}' with registry version (--overwrite)...`);
|
|
3933
4020
|
resolutions.set(key, {
|
|
3934
4021
|
type: modType,
|
|
3935
4022
|
registryName,
|
|
@@ -3940,7 +4027,7 @@ async function handleImport(typeArg, nameArg, flags = {}) {
|
|
|
3940
4027
|
continue;
|
|
3941
4028
|
}
|
|
3942
4029
|
if (flags.yes) {
|
|
3943
|
-
|
|
4030
|
+
p16__namespace.log.info(`Using existing '${modType}/${registryName}'`);
|
|
3944
4031
|
resolutions.set(key, {
|
|
3945
4032
|
type: modType,
|
|
3946
4033
|
registryName,
|
|
@@ -3974,7 +4061,7 @@ async function handleImport(typeArg, nameArg, flags = {}) {
|
|
|
3974
4061
|
})
|
|
3975
4062
|
);
|
|
3976
4063
|
if (choice === "keep_existing" || choice === "use_existing") {
|
|
3977
|
-
|
|
4064
|
+
p16__namespace.log.step(`Skipping '${modType}/${registryName}' (keeping existing)`);
|
|
3978
4065
|
resolutions.set(key, {
|
|
3979
4066
|
type: modType,
|
|
3980
4067
|
registryName,
|
|
@@ -4046,7 +4133,7 @@ async function handleImport(typeArg, nameArg, flags = {}) {
|
|
|
4046
4133
|
chosenName = chosenName.replace(/^@\/(shared|features)\//, "").replace(/^(src\/)?(shared|features)\//, "").replace(/^\/+|\/+$/g, "").trim();
|
|
4047
4134
|
globalAliasMap.set(`@/${folder}/${registryName}/`, `@/${folder}/${chosenName}/`);
|
|
4048
4135
|
globalAliasMap.set(`@/${folder}/${registryName}`, `@/${folder}/${chosenName}`);
|
|
4049
|
-
|
|
4136
|
+
p16__namespace.log.step(`Pointing '${modType}/${registryName}' to existing '${folder}/${chosenName}'`);
|
|
4050
4137
|
resolutions.set(key, {
|
|
4051
4138
|
type: modType,
|
|
4052
4139
|
registryName,
|
|
@@ -4078,7 +4165,7 @@ async function handleImport(typeArg, nameArg, flags = {}) {
|
|
|
4078
4165
|
globalAliasMap.set(`@/${folder}/${registryName}`, `@/${folder}/${newName}`);
|
|
4079
4166
|
const baseDir = getModuleBaseDir(projectRoot, modType);
|
|
4080
4167
|
const displayDest = path2__default.default.relative(projectRoot, path2__default.default.join(baseDir, newName));
|
|
4081
|
-
|
|
4168
|
+
p16__namespace.log.step(`Importing '${registryName}' into '${displayDest}'...`);
|
|
4082
4169
|
resolutions.set(key, {
|
|
4083
4170
|
type: modType,
|
|
4084
4171
|
registryName,
|
|
@@ -4089,7 +4176,7 @@ async function handleImport(typeArg, nameArg, flags = {}) {
|
|
|
4089
4176
|
continue;
|
|
4090
4177
|
}
|
|
4091
4178
|
if (choice === "overwrite") {
|
|
4092
|
-
|
|
4179
|
+
p16__namespace.log.step(`Overwriting '${modType}/${registryName}' with registry version...`);
|
|
4093
4180
|
resolutions.set(key, {
|
|
4094
4181
|
type: modType,
|
|
4095
4182
|
registryName,
|
|
@@ -4132,8 +4219,8 @@ async function handleImport(typeArg, nameArg, flags = {}) {
|
|
|
4132
4219
|
const targetDir = path2__default.default.join(getModuleBaseDir(projectRoot, res.type), res.targetName);
|
|
4133
4220
|
const isOverwrite = Boolean(flags.overwrite || res.action === "overwrite");
|
|
4134
4221
|
if (key !== rootKey) {
|
|
4135
|
-
|
|
4136
|
-
`Importing ${res.type}: ${
|
|
4222
|
+
p16__namespace.log.step(
|
|
4223
|
+
`Importing ${res.type}: ${pc16__default.default.cyan(res.targetName)}${res.targetName !== res.registryName ? pc16__default.default.dim(` (from ${res.registryName})`) : ""}...`
|
|
4137
4224
|
);
|
|
4138
4225
|
}
|
|
4139
4226
|
if (res.action === "overwrite" && !flags.dryRun) {
|
|
@@ -4151,8 +4238,8 @@ async function handleImport(typeArg, nameArg, flags = {}) {
|
|
|
4151
4238
|
const remoteFilePath = `${folder}/${res.registryName}/${file}`;
|
|
4152
4239
|
const localFilePath = path2__default.default.join(targetDir, file);
|
|
4153
4240
|
if (fs4__default.default.existsSync(localFilePath) && !isOverwrite) {
|
|
4154
|
-
|
|
4155
|
-
` \u21B3 Skipping existing file: ${
|
|
4241
|
+
p16__namespace.log.warn(
|
|
4242
|
+
` \u21B3 Skipping existing file: ${pc16__default.default.dim(path2__default.default.relative(projectRoot, localFilePath))} (use --overwrite to replace)`
|
|
4156
4243
|
);
|
|
4157
4244
|
continue;
|
|
4158
4245
|
}
|
|
@@ -4164,18 +4251,18 @@ async function handleImport(typeArg, nameArg, flags = {}) {
|
|
|
4164
4251
|
}
|
|
4165
4252
|
const displayPath = path2__default.default.relative(projectRoot, localFilePath);
|
|
4166
4253
|
totalWrittenFiles.push(displayPath);
|
|
4167
|
-
|
|
4254
|
+
p16__namespace.log.message(` ${pc16__default.default.green("+")} ${displayPath}`);
|
|
4168
4255
|
}
|
|
4169
4256
|
}
|
|
4170
4257
|
const missingNpm = getMissingNpmPackages(projectRoot, Array.from(requiredNpmPackages));
|
|
4171
4258
|
if (missingNpm.length > 0) {
|
|
4172
4259
|
if (flags.skipInstall || flags.dryRun) {
|
|
4173
|
-
|
|
4260
|
+
p16__namespace.log.info(`Required npm dependencies to install: ${pc16__default.default.cyan(missingNpm.join(", "))}`);
|
|
4174
4261
|
} else {
|
|
4175
4262
|
try {
|
|
4176
4263
|
installNpmPackages(projectRoot, missingNpm);
|
|
4177
4264
|
} catch (err) {
|
|
4178
|
-
|
|
4265
|
+
p16__namespace.log.warn(
|
|
4179
4266
|
`Could not automatically install packages (${err.message}). Please run: npm install ${missingNpm.join(
|
|
4180
4267
|
" "
|
|
4181
4268
|
)}`
|
|
@@ -4184,13 +4271,13 @@ async function handleImport(typeArg, nameArg, flags = {}) {
|
|
|
4184
4271
|
}
|
|
4185
4272
|
}
|
|
4186
4273
|
if (flags.dryRun) {
|
|
4187
|
-
|
|
4274
|
+
p16__namespace.log.info(pc16__default.default.yellow("Dry run complete: No files were written to disk."));
|
|
4188
4275
|
} else {
|
|
4189
4276
|
const rootRes = resolutions.get(rootKey);
|
|
4190
4277
|
const baseDir = getModuleBaseDir(projectRoot, type);
|
|
4191
4278
|
const displayTarget = path2__default.default.relative(projectRoot, path2__default.default.join(baseDir, rootRes.targetName));
|
|
4192
|
-
|
|
4193
|
-
|
|
4279
|
+
p16__namespace.log.success(
|
|
4280
|
+
pc16__default.default.green(
|
|
4194
4281
|
`Successfully imported ${type} '${name}' (${totalWrittenFiles.length} file${totalWrittenFiles.length === 1 ? "" : "s"} placed in ${displayTarget})`
|
|
4195
4282
|
)
|
|
4196
4283
|
);
|
|
@@ -4413,10 +4500,10 @@ var FeatureDependencyGraph = class {
|
|
|
4413
4500
|
if (cycle) return cycle;
|
|
4414
4501
|
} else if (inStack.has(next)) {
|
|
4415
4502
|
const cycle = [next];
|
|
4416
|
-
let
|
|
4417
|
-
while (
|
|
4418
|
-
cycle.push(
|
|
4419
|
-
|
|
4503
|
+
let p19 = curr;
|
|
4504
|
+
while (p19 !== next) {
|
|
4505
|
+
cycle.push(p19);
|
|
4506
|
+
p19 = parent.get(p19) || next;
|
|
4420
4507
|
}
|
|
4421
4508
|
cycle.push(next);
|
|
4422
4509
|
cycle.reverse();
|
|
@@ -5318,15 +5405,15 @@ ${compiledDetails}
|
|
|
5318
5405
|
// src/commands/lint.ts
|
|
5319
5406
|
function formatViolation(v) {
|
|
5320
5407
|
const lines = [];
|
|
5321
|
-
lines.push(
|
|
5408
|
+
lines.push(pc16__default.default.underline(pc16__default.default.cyan(v.relativePath)) + pc16__default.default.dim(":") + pc16__default.default.yellow(String(v.line)));
|
|
5322
5409
|
const gutter = `${String(v.line).padStart(4, " ")} | `;
|
|
5323
|
-
lines.push(
|
|
5410
|
+
lines.push(pc16__default.default.dim(gutter) + v.code);
|
|
5324
5411
|
const categoryShort = v.category.replace(" Violation", "");
|
|
5325
5412
|
lines.push(
|
|
5326
|
-
" " +
|
|
5413
|
+
" " + pc16__default.default.red(pc16__default.default.bold("\u2716")) + " " + pc16__default.default.red(`[${categoryShort}]`) + " " + v.advice
|
|
5327
5414
|
);
|
|
5328
5415
|
if (v.fixExample?.good) {
|
|
5329
|
-
lines.push(" " +
|
|
5416
|
+
lines.push(" " + pc16__default.default.dim("\u2192") + " " + pc16__default.default.dim(v.fixExample.good));
|
|
5330
5417
|
}
|
|
5331
5418
|
return lines.join("\n");
|
|
5332
5419
|
}
|
|
@@ -5351,7 +5438,7 @@ async function handleLint(flags = {}) {
|
|
|
5351
5438
|
console.log("");
|
|
5352
5439
|
}
|
|
5353
5440
|
console.log(
|
|
5354
|
-
|
|
5441
|
+
pc16__default.default.red(
|
|
5355
5442
|
`\u2716 Dependency rules check failed with ${summary.totalViolations} error${summary.totalViolations > 1 ? "s" : ""} across ${summary.violatedFeatures} feature${summary.violatedFeatures > 1 ? "s" : ""} (${summary.totalFeatures} features scanned).`
|
|
5356
5443
|
)
|
|
5357
5444
|
);
|
|
@@ -5370,7 +5457,7 @@ ${compiledDetails}
|
|
|
5370
5457
|
}
|
|
5371
5458
|
if (!quiet) {
|
|
5372
5459
|
console.log(
|
|
5373
|
-
|
|
5460
|
+
pc16__default.default.green(
|
|
5374
5461
|
`\u2714 Dependency rules verified across ${summary.totalFeatures} feature${summary.totalFeatures === 1 ? "" : "s"}.`
|
|
5375
5462
|
)
|
|
5376
5463
|
);
|
|
@@ -5385,21 +5472,64 @@ ${compiledDetails}
|
|
|
5385
5472
|
console.log(formatViolation(v));
|
|
5386
5473
|
console.log("");
|
|
5387
5474
|
}
|
|
5388
|
-
console.log(
|
|
5475
|
+
console.log(pc16__default.default.red(`\u2716 Dependency rules check failed (1 error).`));
|
|
5389
5476
|
console.log("");
|
|
5390
5477
|
}
|
|
5391
5478
|
}
|
|
5392
5479
|
throw err;
|
|
5393
5480
|
}
|
|
5394
5481
|
}
|
|
5482
|
+
async function handleInit(type, flags = {}) {
|
|
5483
|
+
if (!type) {
|
|
5484
|
+
const choice = handleCancel(
|
|
5485
|
+
await p16__namespace.select({
|
|
5486
|
+
message: "What would you like to initialize?",
|
|
5487
|
+
options: [
|
|
5488
|
+
{
|
|
5489
|
+
value: "env",
|
|
5490
|
+
label: "Environment Files",
|
|
5491
|
+
hint: "Generate local .env files from .env*.example templates"
|
|
5492
|
+
},
|
|
5493
|
+
{
|
|
5494
|
+
value: "env-examples",
|
|
5495
|
+
label: "Sync Env Examples",
|
|
5496
|
+
hint: "Safely clone and redact local .env files to .example templates"
|
|
5497
|
+
}
|
|
5498
|
+
]
|
|
5499
|
+
})
|
|
5500
|
+
);
|
|
5501
|
+
if (choice === "env") {
|
|
5502
|
+
await runEnvCommand(flags);
|
|
5503
|
+
} else if (choice === "env-examples") {
|
|
5504
|
+
await runEnvExamplesCommand(flags);
|
|
5505
|
+
}
|
|
5506
|
+
return;
|
|
5507
|
+
}
|
|
5508
|
+
const normalized = type.trim().toLowerCase();
|
|
5509
|
+
if (normalized === "env") {
|
|
5510
|
+
await runEnvCommand(flags);
|
|
5511
|
+
} else if (normalized === "env-examples" || normalized === "envexamples") {
|
|
5512
|
+
await runEnvExamplesCommand(flags);
|
|
5513
|
+
} else {
|
|
5514
|
+
p16__namespace.log.error(
|
|
5515
|
+
pc16__default.default.red(
|
|
5516
|
+
`Unknown init target: "${type}". Allowed targets: env, env-examples.`
|
|
5517
|
+
)
|
|
5518
|
+
);
|
|
5519
|
+
if (process.env.VITEST) {
|
|
5520
|
+
throw new Error(`Unknown init target: "${type}". Allowed targets: env, env-examples.`);
|
|
5521
|
+
}
|
|
5522
|
+
process.exit(1);
|
|
5523
|
+
}
|
|
5524
|
+
}
|
|
5395
5525
|
|
|
5396
5526
|
// src/cli.ts
|
|
5397
5527
|
function createCli() {
|
|
5398
5528
|
const cli = cac.cac("mason");
|
|
5399
5529
|
cli.command("[...args]", "Interactive scaffolding and import wizard").option("-d, --dry-run", "Preview changes without writing to disk").option("-o, --overwrite", "Overwrite existing files").option("-y, --yes", "Accept defaults and skip interactive prompts").option("--registry", "Run in registry mode").option("--point-to <mapping>", "Point a dependency to an existing local module (e.g. --point-to time:mytime)").option("--alias <mapping>", "Import a dependency fresh under an alias name (e.g. --alias time:time-mason)").option("--tests", "Include test files (use --no-tests to exclude)").action(async (args, flags) => {
|
|
5400
5530
|
if (args && args.length > 0) {
|
|
5401
|
-
|
|
5402
|
-
|
|
5531
|
+
p16__namespace.log.error(
|
|
5532
|
+
pc16__default.default.red(
|
|
5403
5533
|
`Unknown command: "${args.join(" ")}". Use --help to list available commands.`
|
|
5404
5534
|
)
|
|
5405
5535
|
);
|
|
@@ -5410,7 +5540,7 @@ function createCli() {
|
|
|
5410
5540
|
const mode = getEffectiveMode(projectRoot, flags);
|
|
5411
5541
|
if (mode === "registry") {
|
|
5412
5542
|
const choice2 = handleCancel(
|
|
5413
|
-
await
|
|
5543
|
+
await p16__namespace.select({
|
|
5414
5544
|
message: "\u{1F3DB}\uFE0F Mason (Registry Mode): What would you like to scaffold?",
|
|
5415
5545
|
options: [
|
|
5416
5546
|
{
|
|
@@ -5453,7 +5583,7 @@ function createCli() {
|
|
|
5453
5583
|
return;
|
|
5454
5584
|
}
|
|
5455
5585
|
const choice = handleCancel(
|
|
5456
|
-
await
|
|
5586
|
+
await p16__namespace.select({
|
|
5457
5587
|
message: "\u{1F9F1} Mason: What would you like to do?",
|
|
5458
5588
|
options: [
|
|
5459
5589
|
{
|
|
@@ -5470,6 +5600,11 @@ function createCli() {
|
|
|
5470
5600
|
value: "lint",
|
|
5471
5601
|
label: "Lint dependency rules",
|
|
5472
5602
|
hint: "Scan codebase and verify Clean Architecture dependency rules"
|
|
5603
|
+
},
|
|
5604
|
+
{
|
|
5605
|
+
value: "init",
|
|
5606
|
+
label: "Initialize environment",
|
|
5607
|
+
hint: "Generate local .env files from .env*.example templates"
|
|
5473
5608
|
}
|
|
5474
5609
|
]
|
|
5475
5610
|
})
|
|
@@ -5480,6 +5615,8 @@ function createCli() {
|
|
|
5480
5615
|
await handleImport(void 0, void 0, flags);
|
|
5481
5616
|
} else if (choice === "lint") {
|
|
5482
5617
|
await handleLint(flags);
|
|
5618
|
+
} else if (choice === "init") {
|
|
5619
|
+
await handleInit("env", flags);
|
|
5483
5620
|
}
|
|
5484
5621
|
} catch (err) {
|
|
5485
5622
|
handleCliError(err);
|
|
@@ -5527,6 +5664,26 @@ function createCli() {
|
|
|
5527
5664
|
handleCliError(err);
|
|
5528
5665
|
}
|
|
5529
5666
|
});
|
|
5667
|
+
cli.command(
|
|
5668
|
+
"init [type]",
|
|
5669
|
+
"Initialize project configurations and resources (e.g. 'mason init env', 'mason init env-examples')"
|
|
5670
|
+
).option("-d, --dry-run", "Preview changes without writing to disk").option("-o, --overwrite", "Overwrite existing files").example("mason init env").example("mason init env --overwrite").example("mason init env --dry-run").example("mason init env-examples").example("mason init env-examples --overwrite").example("mason init env-examples --dry-run").action(async (type, flags = {}) => {
|
|
5671
|
+
try {
|
|
5672
|
+
await handleInit(type, flags);
|
|
5673
|
+
} catch (err) {
|
|
5674
|
+
handleCliError(err);
|
|
5675
|
+
}
|
|
5676
|
+
});
|
|
5677
|
+
cli.command(
|
|
5678
|
+
"env-examples",
|
|
5679
|
+
"Shorthand for 'mason init env-examples'"
|
|
5680
|
+
).option("-d, --dry-run", "Preview changes without writing to disk").option("-o, --overwrite", "Overwrite existing .env*.example files").action(async (flags = {}) => {
|
|
5681
|
+
try {
|
|
5682
|
+
await handleInit("env-examples", flags);
|
|
5683
|
+
} catch (err) {
|
|
5684
|
+
handleCliError(err);
|
|
5685
|
+
}
|
|
5686
|
+
});
|
|
5530
5687
|
const createSubtypes = [
|
|
5531
5688
|
"feature",
|
|
5532
5689
|
"shared",
|
|
@@ -5558,7 +5715,7 @@ function handleCliError(err) {
|
|
|
5558
5715
|
process.exit(0);
|
|
5559
5716
|
}
|
|
5560
5717
|
const message = err instanceof Error ? err.message : String(err);
|
|
5561
|
-
|
|
5718
|
+
p16__namespace.log.error(pc16__default.default.red(`Error: ${message}`));
|
|
5562
5719
|
if (process.env.VITEST) {
|
|
5563
5720
|
throw err;
|
|
5564
5721
|
}
|
|
@@ -5616,6 +5773,7 @@ exports.getTemplatesDir = getTemplatesDir;
|
|
|
5616
5773
|
exports.handleCancel = handleCancel;
|
|
5617
5774
|
exports.handleCreate = handleCreate;
|
|
5618
5775
|
exports.handleImport = handleImport;
|
|
5776
|
+
exports.handleInit = handleInit;
|
|
5619
5777
|
exports.handleLint = handleLint;
|
|
5620
5778
|
exports.hbs = hbs;
|
|
5621
5779
|
exports.httpHandlerTemplate = httpHandlerTemplate;
|
|
@@ -5645,6 +5803,8 @@ exports.renderTemplateFile = renderTemplateFile;
|
|
|
5645
5803
|
exports.resolveFeaturesDir = resolveFeaturesDir;
|
|
5646
5804
|
exports.resolveSharedDir = resolveSharedDir;
|
|
5647
5805
|
exports.runCli = runCli;
|
|
5806
|
+
exports.runEnvCommand = runEnvCommand;
|
|
5807
|
+
exports.runEnvExamplesCommand = runEnvExamplesCommand;
|
|
5648
5808
|
exports.runSharedCommand = runSharedCommand;
|
|
5649
5809
|
exports.stubInfraTemplate = stubInfraTemplate;
|
|
5650
5810
|
exports.synthesizeCrudMethods = synthesizeCrudMethods;
|