@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.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import fs4 from 'fs';
|
|
2
2
|
import path2 from 'path';
|
|
3
|
-
import * as
|
|
4
|
-
import
|
|
3
|
+
import * as p16 from '@clack/prompts';
|
|
4
|
+
import pc16 from 'picocolors';
|
|
5
5
|
import { fileURLToPath } from 'url';
|
|
6
6
|
import { execSync } from 'child_process';
|
|
7
7
|
import { createHash } from 'crypto';
|
|
@@ -112,17 +112,17 @@ function writeFileSafely(absolutePath, content, options = {}) {
|
|
|
112
112
|
function printGeneratedFiles(files, isDryRun = false) {
|
|
113
113
|
console.log("");
|
|
114
114
|
if (isDryRun) {
|
|
115
|
-
|
|
115
|
+
p16.log.warn(pc16.yellow(pc16.bold("[DRY RUN PREVIEW] No files were written to disk.")));
|
|
116
116
|
}
|
|
117
117
|
for (const f of files) {
|
|
118
118
|
if (f.action === "created") {
|
|
119
|
-
|
|
119
|
+
p16.log.success(`${pc16.bold(f.relativePath)} ${pc16.dim("(created)")}`);
|
|
120
120
|
} else if (f.action === "overwritten") {
|
|
121
|
-
|
|
121
|
+
p16.log.warn(`${pc16.bold(f.relativePath)} ${pc16.dim("(overwritten)")}`);
|
|
122
122
|
} else if (f.action === "skipped") {
|
|
123
|
-
|
|
123
|
+
p16.log.info(`${pc16.dim(f.relativePath)} ${pc16.dim("(skipped - already exists, pass -o to overwrite)")}`);
|
|
124
124
|
} else {
|
|
125
|
-
|
|
125
|
+
p16.log.info(`${pc16.bold(f.relativePath)} ${pc16.dim("(preview)")}`);
|
|
126
126
|
}
|
|
127
127
|
}
|
|
128
128
|
}
|
|
@@ -324,23 +324,23 @@ var PromptCancelledError = class extends Error {
|
|
|
324
324
|
}
|
|
325
325
|
};
|
|
326
326
|
function handleCancel(result) {
|
|
327
|
-
if (
|
|
328
|
-
|
|
327
|
+
if (p16.isCancel(result)) {
|
|
328
|
+
p16.cancel("Operation cancelled.");
|
|
329
329
|
throw new PromptCancelledError();
|
|
330
330
|
}
|
|
331
331
|
return result;
|
|
332
332
|
}
|
|
333
333
|
function printBanner() {
|
|
334
334
|
console.log("");
|
|
335
|
-
|
|
335
|
+
p16.intro(pc16.bgCyan(pc16.black(" @solid-stack/mason ")));
|
|
336
336
|
}
|
|
337
337
|
async function promptProperties(options = {}) {
|
|
338
338
|
const properties = options.defaults ? [...options.defaults] : [];
|
|
339
339
|
if (properties.length > 0) {
|
|
340
|
-
const summary = properties.map((
|
|
341
|
-
|
|
340
|
+
const summary = properties.map((p19) => `${p19.name}: ${p19.type}${p19.optional ? "?" : ""}`).join(", ");
|
|
341
|
+
p16.log.info(pc16.dim(`Pre-configured fields: ${summary}`));
|
|
342
342
|
const addMore = handleCancel(
|
|
343
|
-
await
|
|
343
|
+
await p16.confirm({
|
|
344
344
|
message: "Would you like to add custom fields/properties?",
|
|
345
345
|
initialValue: false
|
|
346
346
|
})
|
|
@@ -349,10 +349,10 @@ async function promptProperties(options = {}) {
|
|
|
349
349
|
return properties;
|
|
350
350
|
}
|
|
351
351
|
}
|
|
352
|
-
|
|
352
|
+
p16.log.info(pc16.cyan("Enter properties (leave name blank when finished):"));
|
|
353
353
|
while (true) {
|
|
354
354
|
const name = handleCancel(
|
|
355
|
-
await
|
|
355
|
+
await p16.text({
|
|
356
356
|
message: "Property name (or press Enter to finish):",
|
|
357
357
|
placeholder: "e.g. title, email, status"
|
|
358
358
|
})
|
|
@@ -361,7 +361,7 @@ async function promptProperties(options = {}) {
|
|
|
361
361
|
break;
|
|
362
362
|
}
|
|
363
363
|
const type = handleCancel(
|
|
364
|
-
await
|
|
364
|
+
await p16.select({
|
|
365
365
|
message: `Type for property "${name.trim()}":`,
|
|
366
366
|
options: [
|
|
367
367
|
{ value: "string", label: "string" },
|
|
@@ -378,7 +378,7 @@ async function promptProperties(options = {}) {
|
|
|
378
378
|
let finalType = type;
|
|
379
379
|
if (type === "custom") {
|
|
380
380
|
finalType = handleCancel(
|
|
381
|
-
await
|
|
381
|
+
await p16.text({
|
|
382
382
|
message: `Enter custom type for "${name.trim()}":`,
|
|
383
383
|
placeholder: "e.g. UserRole, string | null",
|
|
384
384
|
validate: (val) => val && val.trim() ? void 0 : "Type cannot be empty"
|
|
@@ -386,7 +386,7 @@ async function promptProperties(options = {}) {
|
|
|
386
386
|
);
|
|
387
387
|
}
|
|
388
388
|
const optional = handleCancel(
|
|
389
|
-
await
|
|
389
|
+
await p16.confirm({
|
|
390
390
|
message: `Is "${name.trim()}" optional?`,
|
|
391
391
|
initialValue: false
|
|
392
392
|
})
|
|
@@ -396,8 +396,8 @@ async function promptProperties(options = {}) {
|
|
|
396
396
|
type: finalType.trim(),
|
|
397
397
|
optional
|
|
398
398
|
});
|
|
399
|
-
|
|
400
|
-
|
|
399
|
+
p16.log.success(
|
|
400
|
+
pc16.green(`Added: ${name.trim()}${optional ? "?" : ""}: ${finalType.trim()}`)
|
|
401
401
|
);
|
|
402
402
|
}
|
|
403
403
|
return properties;
|
|
@@ -605,8 +605,8 @@ function getMissingNpmPackages(projectRoot, requiredPackages) {
|
|
|
605
605
|
...Object.keys(pkg.devDependencies || {}),
|
|
606
606
|
...Object.keys(pkg.peerDependencies || {})
|
|
607
607
|
]);
|
|
608
|
-
return requiredPackages.filter((
|
|
609
|
-
const nameOnly =
|
|
608
|
+
return requiredPackages.filter((p19) => {
|
|
609
|
+
const nameOnly = p19.startsWith("@") ? `@${p19.slice(1).split("@")[0] || ""}` : p19.split("@")[0] || p19;
|
|
610
610
|
return !installed.has(nameOnly);
|
|
611
611
|
});
|
|
612
612
|
} catch {
|
|
@@ -631,7 +631,7 @@ function installNpmPackages(projectRoot, packages, pm) {
|
|
|
631
631
|
installCmd = `npm install ${packages.join(" ")}`;
|
|
632
632
|
break;
|
|
633
633
|
}
|
|
634
|
-
|
|
634
|
+
p16.log.info(`Installing missing dependencies with ${manager}: ${pc16.cyan(packages.join(", "))}`);
|
|
635
635
|
execSync(installCmd, {
|
|
636
636
|
cwd: projectRoot,
|
|
637
637
|
stdio: "inherit"
|
|
@@ -833,7 +833,7 @@ function generateInterfaceCode(ifaceName, kind = "abstractClass", entityName, me
|
|
|
833
833
|
const idKey = `${entityKey}Id`;
|
|
834
834
|
const listKey = `${entityKey}s`;
|
|
835
835
|
const formattedCustomMethods = customMethods.map((m) => {
|
|
836
|
-
const params = m.params && m.params.length > 0 ? m.params.map((
|
|
836
|
+
const params = m.params && m.params.length > 0 ? m.params.map((p19) => `${p19.name}: ${p19.type}`).join("; ") : "";
|
|
837
837
|
const returnType = m.returnType ? `Promise<${m.returnType}>` : "Promise<void>";
|
|
838
838
|
return {
|
|
839
839
|
name: m.name,
|
|
@@ -1414,22 +1414,22 @@ function generateUseCaseCode(useCaseName, dependencies = [], inputProps = [], ou
|
|
|
1414
1414
|
from: /^I[A-Z]/.test(dep) ? `../domain/${dep}.js` : `./${dep}.js`
|
|
1415
1415
|
}));
|
|
1416
1416
|
const domainTypesToImport = new Set(domainImports);
|
|
1417
|
-
for (const
|
|
1418
|
-
const rawType =
|
|
1417
|
+
for (const p19 of [...inputProps, ...outputProps]) {
|
|
1418
|
+
const rawType = p19.type.trim();
|
|
1419
1419
|
const baseType = rawType.replace(/\[\]$/, "").trim();
|
|
1420
1420
|
if (!primitiveTypes.has(baseType) && /^[A-Z][A-Za-z0-9_]*$/.test(baseType) && !dependencies.includes(baseType)) {
|
|
1421
1421
|
domainTypesToImport.add(baseType);
|
|
1422
1422
|
}
|
|
1423
1423
|
}
|
|
1424
|
-
const formattedInputProps = inputProps.map((
|
|
1425
|
-
name:
|
|
1426
|
-
optional:
|
|
1427
|
-
type:
|
|
1424
|
+
const formattedInputProps = inputProps.map((p19) => ({
|
|
1425
|
+
name: p19.name,
|
|
1426
|
+
optional: p19.optional,
|
|
1427
|
+
type: p19.optional && !p19.type.includes("undefined") ? `${p19.type} | undefined` : p19.type
|
|
1428
1428
|
}));
|
|
1429
|
-
const formattedOutputProps = outputProps.map((
|
|
1430
|
-
name:
|
|
1431
|
-
optional:
|
|
1432
|
-
type:
|
|
1429
|
+
const formattedOutputProps = outputProps.map((p19) => ({
|
|
1430
|
+
name: p19.name,
|
|
1431
|
+
optional: p19.optional,
|
|
1432
|
+
type: p19.optional && !p19.type.includes("undefined") ? `${p19.type} | undefined` : p19.type
|
|
1433
1433
|
}));
|
|
1434
1434
|
const formattedDeps = dependencies.map((dep) => ({
|
|
1435
1435
|
key: toCamelCase(dep),
|
|
@@ -2104,7 +2104,7 @@ async function runFeatureCommand(featureNameArg, flags = {}) {
|
|
|
2104
2104
|
}
|
|
2105
2105
|
if (!name) {
|
|
2106
2106
|
name = handleCancel(
|
|
2107
|
-
await
|
|
2107
|
+
await p16.text({
|
|
2108
2108
|
message: "What is the feature name?",
|
|
2109
2109
|
placeholder: "e.g. users, auth, orders, billing",
|
|
2110
2110
|
validate: (val) => {
|
|
@@ -2120,7 +2120,7 @@ async function runFeatureCommand(featureNameArg, flags = {}) {
|
|
|
2120
2120
|
let targetDirRel = defaultDir;
|
|
2121
2121
|
if (!flags.yes && !flags.target && !flags.dest) {
|
|
2122
2122
|
targetDirRel = handleCancel(
|
|
2123
|
-
await
|
|
2123
|
+
await p16.text({
|
|
2124
2124
|
message: "Target directory for the feature:",
|
|
2125
2125
|
initialValue: defaultDir,
|
|
2126
2126
|
defaultValue: defaultDir
|
|
@@ -2142,14 +2142,14 @@ async function runFeatureCommand(featureNameArg, flags = {}) {
|
|
|
2142
2142
|
const customUseCases = [];
|
|
2143
2143
|
if (!flags.yes) {
|
|
2144
2144
|
includeExpress = handleCancel(
|
|
2145
|
-
await
|
|
2145
|
+
await p16.confirm({
|
|
2146
2146
|
message: "Include Express Presentation layer (pxExpress routes & handlers)?",
|
|
2147
2147
|
initialValue: true
|
|
2148
2148
|
})
|
|
2149
2149
|
);
|
|
2150
2150
|
if (includeExpress) {
|
|
2151
2151
|
routePath = handleCancel(
|
|
2152
|
-
await
|
|
2152
|
+
await p16.text({
|
|
2153
2153
|
message: "Express route prefix:",
|
|
2154
2154
|
initialValue: `/${normalizedName}`,
|
|
2155
2155
|
defaultValue: `/${normalizedName}`
|
|
@@ -2157,14 +2157,14 @@ async function runFeatureCommand(featureNameArg, flags = {}) {
|
|
|
2157
2157
|
).trim();
|
|
2158
2158
|
}
|
|
2159
2159
|
includeDomain = handleCancel(
|
|
2160
|
-
await
|
|
2160
|
+
await p16.confirm({
|
|
2161
2161
|
message: "Include Domain Entity/Entities?",
|
|
2162
2162
|
initialValue: true
|
|
2163
2163
|
})
|
|
2164
2164
|
);
|
|
2165
2165
|
if (includeDomain) {
|
|
2166
2166
|
const domainInput = handleCancel(
|
|
2167
|
-
await
|
|
2167
|
+
await p16.text({
|
|
2168
2168
|
message: "Domain entity name(s) (comma-separated):",
|
|
2169
2169
|
initialValue: defaultEntity,
|
|
2170
2170
|
defaultValue: defaultEntity,
|
|
@@ -2183,21 +2183,21 @@ async function runFeatureCommand(featureNameArg, flags = {}) {
|
|
|
2183
2183
|
entityNames = [defaultEntity];
|
|
2184
2184
|
}
|
|
2185
2185
|
includeInterface = handleCancel(
|
|
2186
|
-
await
|
|
2186
|
+
await p16.confirm({
|
|
2187
2187
|
message: `Include Domain Repository interface(s) for ${entityNames.join(", ")}?`,
|
|
2188
2188
|
initialValue: true
|
|
2189
2189
|
})
|
|
2190
2190
|
);
|
|
2191
2191
|
if (includeInterface) {
|
|
2192
2192
|
includeInfra = handleCancel(
|
|
2193
|
-
await
|
|
2193
|
+
await p16.confirm({
|
|
2194
2194
|
message: `Include Infrastructure Stub implementation(s) for ${entityNames.join(", ")}?`,
|
|
2195
2195
|
initialValue: true
|
|
2196
2196
|
})
|
|
2197
2197
|
);
|
|
2198
2198
|
}
|
|
2199
2199
|
includeUseCase = handleCancel(
|
|
2200
|
-
await
|
|
2200
|
+
await p16.confirm({
|
|
2201
2201
|
message: "Include Domain Use Cases?",
|
|
2202
2202
|
initialValue: true
|
|
2203
2203
|
})
|
|
@@ -2211,7 +2211,7 @@ async function runFeatureCommand(featureNameArg, flags = {}) {
|
|
|
2211
2211
|
{ value: "delete", label: "Delete (Delete<Entity>)", hint: "DELETE /:id" }
|
|
2212
2212
|
];
|
|
2213
2213
|
crudOperations = handleCancel(
|
|
2214
|
-
await
|
|
2214
|
+
await p16.multiselect({
|
|
2215
2215
|
message: "Select standard CRUD use cases to generate:",
|
|
2216
2216
|
options: crudChoices,
|
|
2217
2217
|
initialValues: ["create", "read", "list", "update", "delete"],
|
|
@@ -2219,13 +2219,13 @@ async function runFeatureCommand(featureNameArg, flags = {}) {
|
|
|
2219
2219
|
})
|
|
2220
2220
|
);
|
|
2221
2221
|
includeTests = handleCancel(
|
|
2222
|
-
await
|
|
2222
|
+
await p16.confirm({
|
|
2223
2223
|
message: "Generate Vitest unit tests for use cases?",
|
|
2224
2224
|
initialValue: true
|
|
2225
2225
|
})
|
|
2226
2226
|
);
|
|
2227
2227
|
const wantCustom = handleCancel(
|
|
2228
|
-
await
|
|
2228
|
+
await p16.confirm({
|
|
2229
2229
|
message: "Do you want to add any custom use cases to this feature?",
|
|
2230
2230
|
initialValue: false
|
|
2231
2231
|
})
|
|
@@ -2235,7 +2235,7 @@ async function runFeatureCommand(featureNameArg, flags = {}) {
|
|
|
2235
2235
|
const availableIfaces = entityNames.map((e) => `I${e}Repository`);
|
|
2236
2236
|
while (addMore) {
|
|
2237
2237
|
const customName = handleCancel(
|
|
2238
|
-
await
|
|
2238
|
+
await p16.text({
|
|
2239
2239
|
message: "Custom Use Case name:",
|
|
2240
2240
|
placeholder: "e.g. ResetPassword, VerifyEmail, AssignRole",
|
|
2241
2241
|
validate: (v) => v && v.trim() ? void 0 : "Use Case name cannot be empty"
|
|
@@ -2245,7 +2245,7 @@ async function runFeatureCommand(featureNameArg, flags = {}) {
|
|
|
2245
2245
|
let selectedDeps = [];
|
|
2246
2246
|
if (availableIfaces.length > 0) {
|
|
2247
2247
|
selectedDeps = handleCancel(
|
|
2248
|
-
await
|
|
2248
|
+
await p16.multiselect({
|
|
2249
2249
|
message: `Select domain interfaces to inject into ${customUcName}:`,
|
|
2250
2250
|
options: availableIfaces.map((i) => ({ value: i, label: i })),
|
|
2251
2251
|
required: false
|
|
@@ -2254,7 +2254,7 @@ async function runFeatureCommand(featureNameArg, flags = {}) {
|
|
|
2254
2254
|
}
|
|
2255
2255
|
let customInputProps = [];
|
|
2256
2256
|
const hasInput = handleCancel(
|
|
2257
|
-
await
|
|
2257
|
+
await p16.confirm({
|
|
2258
2258
|
message: `Does ${customUcName} accept input arguments?`,
|
|
2259
2259
|
initialValue: true
|
|
2260
2260
|
})
|
|
@@ -2265,7 +2265,7 @@ async function runFeatureCommand(featureNameArg, flags = {}) {
|
|
|
2265
2265
|
}
|
|
2266
2266
|
let customOutputProps = [];
|
|
2267
2267
|
const hasCustomOutput = handleCancel(
|
|
2268
|
-
await
|
|
2268
|
+
await p16.confirm({
|
|
2269
2269
|
message: `Does ${customUcName} return custom output data?`,
|
|
2270
2270
|
initialValue: false
|
|
2271
2271
|
})
|
|
@@ -2275,7 +2275,7 @@ async function runFeatureCommand(featureNameArg, flags = {}) {
|
|
|
2275
2275
|
});
|
|
2276
2276
|
}
|
|
2277
2277
|
const customIncludeTest = handleCancel(
|
|
2278
|
-
await
|
|
2278
|
+
await p16.confirm({
|
|
2279
2279
|
message: `Generate Vitest unit test for ${customUcName}?`,
|
|
2280
2280
|
initialValue: true
|
|
2281
2281
|
})
|
|
@@ -2285,14 +2285,14 @@ async function runFeatureCommand(featureNameArg, flags = {}) {
|
|
|
2285
2285
|
let customHttpPath = `/${toKebabCase(customUcName)}`;
|
|
2286
2286
|
if (includeExpress) {
|
|
2287
2287
|
customCreateHttp = handleCancel(
|
|
2288
|
-
await
|
|
2288
|
+
await p16.confirm({
|
|
2289
2289
|
message: `Generate a matching ExpressRoute HTTP handler for ${customUcName}?`,
|
|
2290
2290
|
initialValue: true
|
|
2291
2291
|
})
|
|
2292
2292
|
);
|
|
2293
2293
|
if (customCreateHttp) {
|
|
2294
2294
|
customHttpMethod = handleCancel(
|
|
2295
|
-
await
|
|
2295
|
+
await p16.select({
|
|
2296
2296
|
message: "HTTP method for route:",
|
|
2297
2297
|
options: [
|
|
2298
2298
|
{ value: "post", label: "POST" },
|
|
@@ -2305,7 +2305,7 @@ async function runFeatureCommand(featureNameArg, flags = {}) {
|
|
|
2305
2305
|
})
|
|
2306
2306
|
);
|
|
2307
2307
|
customHttpPath = handleCancel(
|
|
2308
|
-
await
|
|
2308
|
+
await p16.text({
|
|
2309
2309
|
message: "Route subpath (relative to feature prefix):",
|
|
2310
2310
|
initialValue: `/${toKebabCase(customUcName)}`,
|
|
2311
2311
|
defaultValue: `/${toKebabCase(customUcName)}`
|
|
@@ -2326,7 +2326,7 @@ async function runFeatureCommand(featureNameArg, flags = {}) {
|
|
|
2326
2326
|
validationFields: customInputProps
|
|
2327
2327
|
});
|
|
2328
2328
|
addMore = handleCancel(
|
|
2329
|
-
await
|
|
2329
|
+
await p16.confirm({
|
|
2330
2330
|
message: "Add another custom use case?",
|
|
2331
2331
|
initialValue: false
|
|
2332
2332
|
})
|
|
@@ -2335,7 +2335,7 @@ async function runFeatureCommand(featureNameArg, flags = {}) {
|
|
|
2335
2335
|
}
|
|
2336
2336
|
}
|
|
2337
2337
|
includeDiProvider = handleCancel(
|
|
2338
|
-
await
|
|
2338
|
+
await p16.confirm({
|
|
2339
2339
|
message: "Generate / update feature DI provider (diProvider.ts)?",
|
|
2340
2340
|
initialValue: true
|
|
2341
2341
|
})
|
|
@@ -2347,8 +2347,8 @@ async function runFeatureCommand(featureNameArg, flags = {}) {
|
|
|
2347
2347
|
entityNames = [defaultEntity];
|
|
2348
2348
|
}
|
|
2349
2349
|
}
|
|
2350
|
-
const s =
|
|
2351
|
-
s.start(`Generating feature '${
|
|
2350
|
+
const s = p16.spinner();
|
|
2351
|
+
s.start(`Generating feature '${pc16.cyan(normalizedName)}'...`);
|
|
2352
2352
|
const options = {
|
|
2353
2353
|
name: normalizedName,
|
|
2354
2354
|
projectRoot,
|
|
@@ -2394,8 +2394,8 @@ async function runFeatureCommand(featureNameArg, flags = {}) {
|
|
|
2394
2394
|
}
|
|
2395
2395
|
s.stop("Feature scaffolded successfully!");
|
|
2396
2396
|
printGeneratedFiles(files, options.dryRun);
|
|
2397
|
-
|
|
2398
|
-
|
|
2397
|
+
p16.outro(
|
|
2398
|
+
pc16.green(
|
|
2399
2399
|
`\u2713 Feature '${normalizedName}' initialized in ${path2.relative(projectRoot, targetDir)} (uncommitted, unregistered)`
|
|
2400
2400
|
)
|
|
2401
2401
|
);
|
|
@@ -2509,7 +2509,7 @@ async function runSharedCommand(sharedNameArg, flags = {}) {
|
|
|
2509
2509
|
}
|
|
2510
2510
|
if (!name) {
|
|
2511
2511
|
name = handleCancel(
|
|
2512
|
-
await
|
|
2512
|
+
await p16.text({
|
|
2513
2513
|
message: "What is the shared module name?",
|
|
2514
2514
|
placeholder: "e.g. hasher, time, uuid, cache, logger",
|
|
2515
2515
|
validate: (val) => {
|
|
@@ -2525,7 +2525,7 @@ async function runSharedCommand(sharedNameArg, flags = {}) {
|
|
|
2525
2525
|
let targetDirRel = defaultDir;
|
|
2526
2526
|
if (!flags.yes && !flags.target && !flags.dest) {
|
|
2527
2527
|
targetDirRel = handleCancel(
|
|
2528
|
-
await
|
|
2528
|
+
await p16.text({
|
|
2529
2529
|
message: "Target directory for the shared module:",
|
|
2530
2530
|
initialValue: defaultDir,
|
|
2531
2531
|
defaultValue: defaultDir
|
|
@@ -2537,21 +2537,21 @@ async function runSharedCommand(sharedNameArg, flags = {}) {
|
|
|
2537
2537
|
let includeStub = true;
|
|
2538
2538
|
if (!flags.yes) {
|
|
2539
2539
|
description = handleCancel(
|
|
2540
|
-
await
|
|
2540
|
+
await p16.text({
|
|
2541
2541
|
message: "Module description (optional):",
|
|
2542
2542
|
placeholder: "e.g. In-memory caching and Redis port abstraction",
|
|
2543
2543
|
initialValue: ""
|
|
2544
2544
|
})
|
|
2545
2545
|
).trim();
|
|
2546
2546
|
includeStub = handleCancel(
|
|
2547
|
-
await
|
|
2547
|
+
await p16.confirm({
|
|
2548
2548
|
message: "Include stub implementation in infrastructure/?",
|
|
2549
2549
|
initialValue: true
|
|
2550
2550
|
})
|
|
2551
2551
|
);
|
|
2552
2552
|
}
|
|
2553
|
-
const s =
|
|
2554
|
-
s.start(`Generating shared module '${
|
|
2553
|
+
const s = p16.spinner();
|
|
2554
|
+
s.start(`Generating shared module '${pc16.cyan(normalizedName)}'...`);
|
|
2555
2555
|
const files = generateShared({
|
|
2556
2556
|
name: normalizedName,
|
|
2557
2557
|
description,
|
|
@@ -2564,8 +2564,8 @@ async function runSharedCommand(sharedNameArg, flags = {}) {
|
|
|
2564
2564
|
});
|
|
2565
2565
|
s.stop("Shared module generated successfully!");
|
|
2566
2566
|
printGeneratedFiles(files, Boolean(flags.dryRun));
|
|
2567
|
-
|
|
2568
|
-
|
|
2567
|
+
p16.outro(
|
|
2568
|
+
pc16.green(
|
|
2569
2569
|
`\u2713 Shared module '${normalizedName}' initialized in ${path2.relative(projectRoot, targetDir)} (uncommitted, unregistered)`
|
|
2570
2570
|
)
|
|
2571
2571
|
);
|
|
@@ -2579,14 +2579,14 @@ async function runUseCaseCommand(useCaseNameArg, flags = {}) {
|
|
|
2579
2579
|
const featureOptions = existingFeatures.map((f) => ({ value: f, label: f }));
|
|
2580
2580
|
featureOptions.push({ value: "__custom__", label: "\u270F\uFE0F Enter custom feature name..." });
|
|
2581
2581
|
const selected = handleCancel(
|
|
2582
|
-
await
|
|
2582
|
+
await p16.select({
|
|
2583
2583
|
message: "Select target feature:",
|
|
2584
2584
|
options: featureOptions
|
|
2585
2585
|
})
|
|
2586
2586
|
);
|
|
2587
2587
|
if (selected === "__custom__") {
|
|
2588
2588
|
feature = handleCancel(
|
|
2589
|
-
await
|
|
2589
|
+
await p16.text({
|
|
2590
2590
|
message: "Enter feature name:",
|
|
2591
2591
|
validate: (v) => v && v.trim() ? void 0 : "Feature name cannot be empty"
|
|
2592
2592
|
})
|
|
@@ -2596,7 +2596,7 @@ async function runUseCaseCommand(useCaseNameArg, flags = {}) {
|
|
|
2596
2596
|
}
|
|
2597
2597
|
} else {
|
|
2598
2598
|
feature = handleCancel(
|
|
2599
|
-
await
|
|
2599
|
+
await p16.text({
|
|
2600
2600
|
message: "Enter target feature name:",
|
|
2601
2601
|
validate: (v) => v && v.trim() ? void 0 : "Feature name cannot be empty"
|
|
2602
2602
|
})
|
|
@@ -2607,7 +2607,7 @@ async function runUseCaseCommand(useCaseNameArg, flags = {}) {
|
|
|
2607
2607
|
let name = useCaseNameArg?.trim();
|
|
2608
2608
|
if (!name) {
|
|
2609
2609
|
name = handleCancel(
|
|
2610
|
-
await
|
|
2610
|
+
await p16.text({
|
|
2611
2611
|
message: "Use Case name:",
|
|
2612
2612
|
placeholder: "e.g. CreateUser, GetUser, CancelOrder",
|
|
2613
2613
|
validate: (v) => v && v.trim() ? void 0 : "Use Case name cannot be empty"
|
|
@@ -2623,7 +2623,7 @@ async function runUseCaseCommand(useCaseNameArg, flags = {}) {
|
|
|
2623
2623
|
label: i.name
|
|
2624
2624
|
}));
|
|
2625
2625
|
selectedDeps = handleCancel(
|
|
2626
|
-
await
|
|
2626
|
+
await p16.multiselect({
|
|
2627
2627
|
message: "Select domain interfaces to inject into use case:",
|
|
2628
2628
|
options: multiOptions,
|
|
2629
2629
|
required: false
|
|
@@ -2638,7 +2638,7 @@ async function runUseCaseCommand(useCaseNameArg, flags = {}) {
|
|
|
2638
2638
|
let httpPath = "/";
|
|
2639
2639
|
if (!flags.yes) {
|
|
2640
2640
|
const hasInput = handleCancel(
|
|
2641
|
-
await
|
|
2641
|
+
await p16.confirm({
|
|
2642
2642
|
message: "Does this use case accept input arguments?",
|
|
2643
2643
|
initialValue: true
|
|
2644
2644
|
})
|
|
@@ -2648,7 +2648,7 @@ async function runUseCaseCommand(useCaseNameArg, flags = {}) {
|
|
|
2648
2648
|
});
|
|
2649
2649
|
}
|
|
2650
2650
|
const hasCustomOutput = handleCancel(
|
|
2651
|
-
await
|
|
2651
|
+
await p16.confirm({
|
|
2652
2652
|
message: "Does this use case return custom output data?",
|
|
2653
2653
|
initialValue: false
|
|
2654
2654
|
})
|
|
@@ -2658,20 +2658,20 @@ async function runUseCaseCommand(useCaseNameArg, flags = {}) {
|
|
|
2658
2658
|
});
|
|
2659
2659
|
}
|
|
2660
2660
|
includeTest = handleCancel(
|
|
2661
|
-
await
|
|
2661
|
+
await p16.confirm({
|
|
2662
2662
|
message: "Generate Vitest unit test skeleton (.test.ts)?",
|
|
2663
2663
|
initialValue: true
|
|
2664
2664
|
})
|
|
2665
2665
|
);
|
|
2666
2666
|
createHttp = handleCancel(
|
|
2667
|
-
await
|
|
2667
|
+
await p16.confirm({
|
|
2668
2668
|
message: "Generate a matching ExpressRoute HTTP handler?",
|
|
2669
2669
|
initialValue: false
|
|
2670
2670
|
})
|
|
2671
2671
|
);
|
|
2672
2672
|
if (createHttp) {
|
|
2673
2673
|
httpMethod = handleCancel(
|
|
2674
|
-
await
|
|
2674
|
+
await p16.select({
|
|
2675
2675
|
message: "HTTP method for route:",
|
|
2676
2676
|
options: [
|
|
2677
2677
|
{ value: "post", label: "POST" },
|
|
@@ -2684,7 +2684,7 @@ async function runUseCaseCommand(useCaseNameArg, flags = {}) {
|
|
|
2684
2684
|
})
|
|
2685
2685
|
);
|
|
2686
2686
|
httpPath = handleCancel(
|
|
2687
|
-
await
|
|
2687
|
+
await p16.text({
|
|
2688
2688
|
message: "Route subpath (relative to feature prefix):",
|
|
2689
2689
|
initialValue: "/",
|
|
2690
2690
|
defaultValue: "/"
|
|
@@ -2692,8 +2692,8 @@ async function runUseCaseCommand(useCaseNameArg, flags = {}) {
|
|
|
2692
2692
|
).trim();
|
|
2693
2693
|
}
|
|
2694
2694
|
}
|
|
2695
|
-
const s =
|
|
2696
|
-
s.start(`Generating use case '${
|
|
2695
|
+
const s = p16.spinner();
|
|
2696
|
+
s.start(`Generating use case '${pc16.cyan(ucName)}'...`);
|
|
2697
2697
|
const options = {
|
|
2698
2698
|
name: ucName,
|
|
2699
2699
|
feature,
|
|
@@ -2725,7 +2725,7 @@ async function runUseCaseCommand(useCaseNameArg, flags = {}) {
|
|
|
2725
2725
|
}
|
|
2726
2726
|
s.stop("Use case generated successfully!");
|
|
2727
2727
|
printGeneratedFiles(files, options.dryRun);
|
|
2728
|
-
|
|
2728
|
+
p16.outro(pc16.green(`Use case '${ucName}' created in feature '${feature}'!`));
|
|
2729
2729
|
}
|
|
2730
2730
|
async function runDomainCommand(domainNameArg, flags = {}) {
|
|
2731
2731
|
const projectRoot = findProjectRoot();
|
|
@@ -2736,14 +2736,14 @@ async function runDomainCommand(domainNameArg, flags = {}) {
|
|
|
2736
2736
|
const featureOptions = existingFeatures.map((f) => ({ value: f, label: f }));
|
|
2737
2737
|
featureOptions.push({ value: "__custom__", label: "\u270F\uFE0F Enter custom feature name..." });
|
|
2738
2738
|
const selected = handleCancel(
|
|
2739
|
-
await
|
|
2739
|
+
await p16.select({
|
|
2740
2740
|
message: "Select target feature:",
|
|
2741
2741
|
options: featureOptions
|
|
2742
2742
|
})
|
|
2743
2743
|
);
|
|
2744
2744
|
if (selected === "__custom__") {
|
|
2745
2745
|
feature = handleCancel(
|
|
2746
|
-
await
|
|
2746
|
+
await p16.text({
|
|
2747
2747
|
message: "Enter feature name:",
|
|
2748
2748
|
validate: (v) => v && v.trim() ? void 0 : "Feature name cannot be empty"
|
|
2749
2749
|
})
|
|
@@ -2753,7 +2753,7 @@ async function runDomainCommand(domainNameArg, flags = {}) {
|
|
|
2753
2753
|
}
|
|
2754
2754
|
} else {
|
|
2755
2755
|
feature = handleCancel(
|
|
2756
|
-
await
|
|
2756
|
+
await p16.text({
|
|
2757
2757
|
message: "Enter target feature name:",
|
|
2758
2758
|
validate: (v) => v && v.trim() ? void 0 : "Feature name cannot be empty"
|
|
2759
2759
|
})
|
|
@@ -2764,7 +2764,7 @@ async function runDomainCommand(domainNameArg, flags = {}) {
|
|
|
2764
2764
|
let name = domainNameArg?.trim();
|
|
2765
2765
|
if (!name) {
|
|
2766
2766
|
name = handleCancel(
|
|
2767
|
-
await
|
|
2767
|
+
await p16.text({
|
|
2768
2768
|
message: "Domain model / entity name:",
|
|
2769
2769
|
placeholder: "e.g. User, Order, Product, Address",
|
|
2770
2770
|
validate: (v) => v && v.trim() ? void 0 : "Domain name cannot be empty"
|
|
@@ -2776,7 +2776,7 @@ async function runDomainCommand(domainNameArg, flags = {}) {
|
|
|
2776
2776
|
let properties = [];
|
|
2777
2777
|
if (!flags.yes) {
|
|
2778
2778
|
kind = handleCancel(
|
|
2779
|
-
await
|
|
2779
|
+
await p16.select({
|
|
2780
2780
|
message: "Select domain model type:",
|
|
2781
2781
|
options: [
|
|
2782
2782
|
{ value: "interface", label: "TypeScript Interface (pure data structure)" },
|
|
@@ -2795,8 +2795,8 @@ async function runDomainCommand(domainNameArg, flags = {}) {
|
|
|
2795
2795
|
defaults: kind === "valueObject" ? [{ name: "value", type: "string" }] : defaultProps
|
|
2796
2796
|
});
|
|
2797
2797
|
}
|
|
2798
|
-
const s =
|
|
2799
|
-
s.start(`Generating domain model '${
|
|
2798
|
+
const s = p16.spinner();
|
|
2799
|
+
s.start(`Generating domain model '${pc16.cyan(entityName)}'...`);
|
|
2800
2800
|
const options = {
|
|
2801
2801
|
name: entityName,
|
|
2802
2802
|
feature,
|
|
@@ -2809,7 +2809,7 @@ async function runDomainCommand(domainNameArg, flags = {}) {
|
|
|
2809
2809
|
const file = generateDomain(options);
|
|
2810
2810
|
s.stop("Domain model generated successfully!");
|
|
2811
2811
|
printGeneratedFiles([file], options.dryRun);
|
|
2812
|
-
|
|
2812
|
+
p16.outro(pc16.green(`Domain model '${entityName}' created in feature '${feature}'!`));
|
|
2813
2813
|
}
|
|
2814
2814
|
async function runInfrastructureCommand(classNameArg, flags = {}) {
|
|
2815
2815
|
const projectRoot = findProjectRoot();
|
|
@@ -2818,7 +2818,7 @@ async function runInfrastructureCommand(classNameArg, flags = {}) {
|
|
|
2818
2818
|
let feature = flags.feature?.trim();
|
|
2819
2819
|
if (!flags.yes && !flags.global && !flags.feature) {
|
|
2820
2820
|
scope = handleCancel(
|
|
2821
|
-
await
|
|
2821
|
+
await p16.select({
|
|
2822
2822
|
message: "Where should this infrastructure implementation be placed?",
|
|
2823
2823
|
options: [
|
|
2824
2824
|
{ value: "feature", label: "Feature-level (features/<feature>/infrastructure)" },
|
|
@@ -2833,14 +2833,14 @@ async function runInfrastructureCommand(classNameArg, flags = {}) {
|
|
|
2833
2833
|
const featureOptions = existingFeatures.map((f) => ({ value: f, label: f }));
|
|
2834
2834
|
featureOptions.push({ value: "__custom__", label: "\u270F\uFE0F Enter custom feature name..." });
|
|
2835
2835
|
const selected = handleCancel(
|
|
2836
|
-
await
|
|
2836
|
+
await p16.select({
|
|
2837
2837
|
message: "Select target feature:",
|
|
2838
2838
|
options: featureOptions
|
|
2839
2839
|
})
|
|
2840
2840
|
);
|
|
2841
2841
|
if (selected === "__custom__") {
|
|
2842
2842
|
feature = handleCancel(
|
|
2843
|
-
await
|
|
2843
|
+
await p16.text({
|
|
2844
2844
|
message: "Enter feature name:",
|
|
2845
2845
|
validate: (v) => v && v.trim() ? void 0 : "Feature name cannot be empty"
|
|
2846
2846
|
})
|
|
@@ -2850,7 +2850,7 @@ async function runInfrastructureCommand(classNameArg, flags = {}) {
|
|
|
2850
2850
|
}
|
|
2851
2851
|
} else {
|
|
2852
2852
|
feature = handleCancel(
|
|
2853
|
-
await
|
|
2853
|
+
await p16.text({
|
|
2854
2854
|
message: "Enter target feature name:",
|
|
2855
2855
|
validate: (v) => v && v.trim() ? void 0 : "Feature name cannot be empty"
|
|
2856
2856
|
})
|
|
@@ -2863,7 +2863,7 @@ async function runInfrastructureCommand(classNameArg, flags = {}) {
|
|
|
2863
2863
|
let name = classNameArg?.trim();
|
|
2864
2864
|
if (!name) {
|
|
2865
2865
|
name = handleCancel(
|
|
2866
|
-
await
|
|
2866
|
+
await p16.text({
|
|
2867
2867
|
message: "Infrastructure class name:",
|
|
2868
2868
|
placeholder: "e.g. StubUserRepository, PostgresUserRepository, S3FileStorage",
|
|
2869
2869
|
validate: (v) => v && v.trim() ? void 0 : "Class name cannot be empty"
|
|
@@ -2882,7 +2882,7 @@ async function runInfrastructureCommand(classNameArg, flags = {}) {
|
|
|
2882
2882
|
(i) => className.toLowerCase().includes(removeInterfacePrefix(i.name).toLowerCase())
|
|
2883
2883
|
);
|
|
2884
2884
|
const ifaceChoice = handleCancel(
|
|
2885
|
-
await
|
|
2885
|
+
await p16.select({
|
|
2886
2886
|
message: "Does this class implement a domain interface or abstract class?",
|
|
2887
2887
|
options: [
|
|
2888
2888
|
...interfaces.map((i) => ({ value: i.name, label: i.name })),
|
|
@@ -2894,7 +2894,7 @@ async function runInfrastructureCommand(classNameArg, flags = {}) {
|
|
|
2894
2894
|
);
|
|
2895
2895
|
if (ifaceChoice === "__custom__") {
|
|
2896
2896
|
implementsInterface = handleCancel(
|
|
2897
|
-
await
|
|
2897
|
+
await p16.text({
|
|
2898
2898
|
message: "Enter interface or abstract class name:",
|
|
2899
2899
|
placeholder: "e.g. IUserRepository, BaseStorageAdapter",
|
|
2900
2900
|
validate: (v) => v && v.trim() ? void 0 : "Name cannot be empty"
|
|
@@ -2905,14 +2905,14 @@ async function runInfrastructureCommand(classNameArg, flags = {}) {
|
|
|
2905
2905
|
}
|
|
2906
2906
|
} else {
|
|
2907
2907
|
const wantImpl = handleCancel(
|
|
2908
|
-
await
|
|
2908
|
+
await p16.confirm({
|
|
2909
2909
|
message: "Does this class implement a domain interface or abstract class?",
|
|
2910
2910
|
initialValue: false
|
|
2911
2911
|
})
|
|
2912
2912
|
);
|
|
2913
2913
|
if (wantImpl) {
|
|
2914
2914
|
implementsInterface = handleCancel(
|
|
2915
|
-
await
|
|
2915
|
+
await p16.text({
|
|
2916
2916
|
message: "Enter interface or abstract class name:",
|
|
2917
2917
|
placeholder: "e.g. IUserRepository, BaseStorageAdapter",
|
|
2918
2918
|
validate: (v) => v && v.trim() ? void 0 : "Name cannot be empty"
|
|
@@ -2932,7 +2932,7 @@ async function runInfrastructureCommand(classNameArg, flags = {}) {
|
|
|
2932
2932
|
const allInterfaces = listDomainInterfaces(projectRoot);
|
|
2933
2933
|
if (allInterfaces.length > 0) {
|
|
2934
2934
|
const ifaceChoice = handleCancel(
|
|
2935
|
-
await
|
|
2935
|
+
await p16.select({
|
|
2936
2936
|
message: "Does this class implement an interface or abstract class?",
|
|
2937
2937
|
options: [
|
|
2938
2938
|
...allInterfaces.map((i) => ({ value: i.name, label: `${i.name} (${i.feature})` })),
|
|
@@ -2944,7 +2944,7 @@ async function runInfrastructureCommand(classNameArg, flags = {}) {
|
|
|
2944
2944
|
);
|
|
2945
2945
|
if (ifaceChoice === "__custom__") {
|
|
2946
2946
|
implementsInterface = handleCancel(
|
|
2947
|
-
await
|
|
2947
|
+
await p16.text({
|
|
2948
2948
|
message: "Enter interface or abstract class name:",
|
|
2949
2949
|
placeholder: "e.g. IAuthRepository",
|
|
2950
2950
|
validate: (v) => v && v.trim() ? void 0 : "Name cannot be empty"
|
|
@@ -2957,7 +2957,7 @@ async function runInfrastructureCommand(classNameArg, flags = {}) {
|
|
|
2957
2957
|
}
|
|
2958
2958
|
if (!flags.yes && !flags.kind) {
|
|
2959
2959
|
kind = handleCancel(
|
|
2960
|
-
await
|
|
2960
|
+
await p16.select({
|
|
2961
2961
|
message: "Select implementation kind:",
|
|
2962
2962
|
options: [
|
|
2963
2963
|
{ value: "stub", label: "In-Memory Stub (with in-memory store and test helper methods)" },
|
|
@@ -2968,7 +2968,7 @@ async function runInfrastructureCommand(classNameArg, flags = {}) {
|
|
|
2968
2968
|
);
|
|
2969
2969
|
if (scope === "feature" && feature && implementsInterface) {
|
|
2970
2970
|
registerInProvider = handleCancel(
|
|
2971
|
-
await
|
|
2971
|
+
await p16.confirm({
|
|
2972
2972
|
message: "Register this implementation in feature diProvider.ts?",
|
|
2973
2973
|
initialValue: true
|
|
2974
2974
|
})
|
|
@@ -2977,8 +2977,8 @@ async function runInfrastructureCommand(classNameArg, flags = {}) {
|
|
|
2977
2977
|
} else if (flags.yes && scope === "feature" && feature && implementsInterface) {
|
|
2978
2978
|
registerInProvider = !flags.noProvider;
|
|
2979
2979
|
}
|
|
2980
|
-
const s =
|
|
2981
|
-
s.start(`Generating infrastructure class '${
|
|
2980
|
+
const s = p16.spinner();
|
|
2981
|
+
s.start(`Generating infrastructure class '${pc16.cyan(className)}'...`);
|
|
2982
2982
|
const files = [];
|
|
2983
2983
|
const options = {
|
|
2984
2984
|
name: className,
|
|
@@ -3013,7 +3013,7 @@ async function runInfrastructureCommand(classNameArg, flags = {}) {
|
|
|
3013
3013
|
}
|
|
3014
3014
|
s.stop("Infrastructure class generated successfully!");
|
|
3015
3015
|
printGeneratedFiles(files, options.dryRun);
|
|
3016
|
-
|
|
3016
|
+
p16.outro(pc16.green(`Infrastructure class '${className}' created!`));
|
|
3017
3017
|
}
|
|
3018
3018
|
async function runInterfaceCommand(interfaceNameArg, flags = {}) {
|
|
3019
3019
|
const projectRoot = findProjectRoot();
|
|
@@ -3024,14 +3024,14 @@ async function runInterfaceCommand(interfaceNameArg, flags = {}) {
|
|
|
3024
3024
|
const featureOptions = existingFeatures.map((f) => ({ value: f, label: f }));
|
|
3025
3025
|
featureOptions.push({ value: "__custom__", label: "\u270F\uFE0F Enter custom feature name..." });
|
|
3026
3026
|
const selected = handleCancel(
|
|
3027
|
-
await
|
|
3027
|
+
await p16.select({
|
|
3028
3028
|
message: "Select target feature:",
|
|
3029
3029
|
options: featureOptions
|
|
3030
3030
|
})
|
|
3031
3031
|
);
|
|
3032
3032
|
if (selected === "__custom__") {
|
|
3033
3033
|
feature = handleCancel(
|
|
3034
|
-
await
|
|
3034
|
+
await p16.text({
|
|
3035
3035
|
message: "Enter feature name:",
|
|
3036
3036
|
validate: (v) => v && v.trim() ? void 0 : "Feature name cannot be empty"
|
|
3037
3037
|
})
|
|
@@ -3041,7 +3041,7 @@ async function runInterfaceCommand(interfaceNameArg, flags = {}) {
|
|
|
3041
3041
|
}
|
|
3042
3042
|
} else {
|
|
3043
3043
|
feature = handleCancel(
|
|
3044
|
-
await
|
|
3044
|
+
await p16.text({
|
|
3045
3045
|
message: "Enter target feature name:",
|
|
3046
3046
|
validate: (v) => v && v.trim() ? void 0 : "Feature name cannot be empty"
|
|
3047
3047
|
})
|
|
@@ -3052,7 +3052,7 @@ async function runInterfaceCommand(interfaceNameArg, flags = {}) {
|
|
|
3052
3052
|
let name = interfaceNameArg?.trim();
|
|
3053
3053
|
if (!name) {
|
|
3054
3054
|
name = handleCancel(
|
|
3055
|
-
await
|
|
3055
|
+
await p16.text({
|
|
3056
3056
|
message: "Domain interface name:",
|
|
3057
3057
|
placeholder: "e.g. IUserRepository, IPaymentService",
|
|
3058
3058
|
validate: (v) => v && v.trim() ? void 0 : "Interface name cannot be empty"
|
|
@@ -3070,7 +3070,7 @@ async function runInterfaceCommand(interfaceNameArg, flags = {}) {
|
|
|
3070
3070
|
if (!flags.yes) {
|
|
3071
3071
|
if (existingEntities.length > 0) {
|
|
3072
3072
|
const selectedEntity = handleCancel(
|
|
3073
|
-
await
|
|
3073
|
+
await p16.select({
|
|
3074
3074
|
message: "Select domain entity associated with this interface:",
|
|
3075
3075
|
options: [
|
|
3076
3076
|
...existingEntities.map((e) => ({ value: e.name, label: e.name })),
|
|
@@ -3081,7 +3081,7 @@ async function runInterfaceCommand(interfaceNameArg, flags = {}) {
|
|
|
3081
3081
|
);
|
|
3082
3082
|
if (selectedEntity === "__custom__") {
|
|
3083
3083
|
entityName = handleCancel(
|
|
3084
|
-
await
|
|
3084
|
+
await p16.text({
|
|
3085
3085
|
message: "Enter entity name:",
|
|
3086
3086
|
defaultValue: removeInterfacePrefix(ifaceName).replace(/Repository$|Service$/, "")
|
|
3087
3087
|
})
|
|
@@ -3091,7 +3091,7 @@ async function runInterfaceCommand(interfaceNameArg, flags = {}) {
|
|
|
3091
3091
|
}
|
|
3092
3092
|
}
|
|
3093
3093
|
kind = handleCancel(
|
|
3094
|
-
await
|
|
3094
|
+
await p16.select({
|
|
3095
3095
|
message: "Interface definition style:",
|
|
3096
3096
|
options: [
|
|
3097
3097
|
{ value: "abstractClass", label: "Abstract Class (Recommended - acts as DI token & type)" },
|
|
@@ -3101,7 +3101,7 @@ async function runInterfaceCommand(interfaceNameArg, flags = {}) {
|
|
|
3101
3101
|
})
|
|
3102
3102
|
);
|
|
3103
3103
|
methodsPreset = handleCancel(
|
|
3104
|
-
await
|
|
3104
|
+
await p16.select({
|
|
3105
3105
|
message: "Method signature preset:",
|
|
3106
3106
|
options: [
|
|
3107
3107
|
{ value: "crud", label: "Standard CRUD (GetById, List, Create, Update, Delete)" },
|
|
@@ -3111,22 +3111,22 @@ async function runInterfaceCommand(interfaceNameArg, flags = {}) {
|
|
|
3111
3111
|
})
|
|
3112
3112
|
);
|
|
3113
3113
|
generateStub = handleCancel(
|
|
3114
|
-
await
|
|
3114
|
+
await p16.confirm({
|
|
3115
3115
|
message: "Auto-generate Infrastructure Stub implementation?",
|
|
3116
3116
|
initialValue: true
|
|
3117
3117
|
})
|
|
3118
3118
|
);
|
|
3119
3119
|
if (generateStub) {
|
|
3120
3120
|
registerInProvider = handleCancel(
|
|
3121
|
-
await
|
|
3121
|
+
await p16.confirm({
|
|
3122
3122
|
message: "Auto-register interface & stub in feature diProvider.ts?",
|
|
3123
3123
|
initialValue: true
|
|
3124
3124
|
})
|
|
3125
3125
|
);
|
|
3126
3126
|
}
|
|
3127
3127
|
}
|
|
3128
|
-
const s =
|
|
3129
|
-
s.start(`Generating interface '${
|
|
3128
|
+
const s = p16.spinner();
|
|
3129
|
+
s.start(`Generating interface '${pc16.cyan(ifaceName)}'...`);
|
|
3130
3130
|
const files = [];
|
|
3131
3131
|
const options = {
|
|
3132
3132
|
name: ifaceName,
|
|
@@ -3175,7 +3175,7 @@ async function runInterfaceCommand(interfaceNameArg, flags = {}) {
|
|
|
3175
3175
|
}
|
|
3176
3176
|
s.stop("Interface generated successfully!");
|
|
3177
3177
|
printGeneratedFiles(files, options.dryRun);
|
|
3178
|
-
|
|
3178
|
+
p16.outro(pc16.green(`Interface '${ifaceName}' created in feature '${feature}'!`));
|
|
3179
3179
|
}
|
|
3180
3180
|
async function runHttpHandlerCommand(handlerNameArg, flags = {}) {
|
|
3181
3181
|
const projectRoot = findProjectRoot();
|
|
@@ -3186,14 +3186,14 @@ async function runHttpHandlerCommand(handlerNameArg, flags = {}) {
|
|
|
3186
3186
|
const featureOptions = existingFeatures.map((f) => ({ value: f, label: f }));
|
|
3187
3187
|
featureOptions.push({ value: "__custom__", label: "\u270F\uFE0F Enter custom feature name..." });
|
|
3188
3188
|
const selected = handleCancel(
|
|
3189
|
-
await
|
|
3189
|
+
await p16.select({
|
|
3190
3190
|
message: "Select target feature:",
|
|
3191
3191
|
options: featureOptions
|
|
3192
3192
|
})
|
|
3193
3193
|
);
|
|
3194
3194
|
if (selected === "__custom__") {
|
|
3195
3195
|
feature = handleCancel(
|
|
3196
|
-
await
|
|
3196
|
+
await p16.text({
|
|
3197
3197
|
message: "Enter feature name:",
|
|
3198
3198
|
validate: (v) => v && v.trim() ? void 0 : "Feature name cannot be empty"
|
|
3199
3199
|
})
|
|
@@ -3203,7 +3203,7 @@ async function runHttpHandlerCommand(handlerNameArg, flags = {}) {
|
|
|
3203
3203
|
}
|
|
3204
3204
|
} else {
|
|
3205
3205
|
feature = handleCancel(
|
|
3206
|
-
await
|
|
3206
|
+
await p16.text({
|
|
3207
3207
|
message: "Enter target feature name:",
|
|
3208
3208
|
validate: (v) => v && v.trim() ? void 0 : "Feature name cannot be empty"
|
|
3209
3209
|
})
|
|
@@ -3214,7 +3214,7 @@ async function runHttpHandlerCommand(handlerNameArg, flags = {}) {
|
|
|
3214
3214
|
let name = handlerNameArg?.trim();
|
|
3215
3215
|
if (!name) {
|
|
3216
3216
|
name = handleCancel(
|
|
3217
|
-
await
|
|
3217
|
+
await p16.text({
|
|
3218
3218
|
message: "HTTP Route Handler class name:",
|
|
3219
3219
|
placeholder: "e.g. CreateUserHttp, GetUserHttp, HealthHttp",
|
|
3220
3220
|
validate: (v) => v && v.trim() ? void 0 : "Handler name cannot be empty"
|
|
@@ -3233,7 +3233,7 @@ async function runHttpHandlerCommand(handlerNameArg, flags = {}) {
|
|
|
3233
3233
|
let validationFields = [];
|
|
3234
3234
|
if (!flags.yes) {
|
|
3235
3235
|
method = handleCancel(
|
|
3236
|
-
await
|
|
3236
|
+
await p16.select({
|
|
3237
3237
|
message: "HTTP Method:",
|
|
3238
3238
|
options: [
|
|
3239
3239
|
{ value: "get", label: "GET" },
|
|
@@ -3247,7 +3247,7 @@ async function runHttpHandlerCommand(handlerNameArg, flags = {}) {
|
|
|
3247
3247
|
);
|
|
3248
3248
|
const defaultPath = method === "get" ? "/" : "/";
|
|
3249
3249
|
subPath = handleCancel(
|
|
3250
|
-
await
|
|
3250
|
+
await p16.text({
|
|
3251
3251
|
message: "Route subpath (relative to feature prefix):",
|
|
3252
3252
|
initialValue: defaultPath,
|
|
3253
3253
|
defaultValue: defaultPath
|
|
@@ -3258,7 +3258,7 @@ async function runHttpHandlerCommand(handlerNameArg, flags = {}) {
|
|
|
3258
3258
|
const ucOptions = useCases.map((u) => ({ value: u.name, label: u.name }));
|
|
3259
3259
|
ucOptions.push({ value: "__none__", label: "None / Standalone Handler" });
|
|
3260
3260
|
const chosenUc = handleCancel(
|
|
3261
|
-
await
|
|
3261
|
+
await p16.select({
|
|
3262
3262
|
message: "Connect this handler to a domain Use Case?",
|
|
3263
3263
|
options: ucOptions,
|
|
3264
3264
|
initialValue: ucOptions[0]?.value
|
|
@@ -3269,7 +3269,7 @@ async function runHttpHandlerCommand(handlerNameArg, flags = {}) {
|
|
|
3269
3269
|
}
|
|
3270
3270
|
}
|
|
3271
3271
|
includeValidation = handleCancel(
|
|
3272
|
-
await
|
|
3272
|
+
await p16.confirm({
|
|
3273
3273
|
message: "Include Zod inbound request validation?",
|
|
3274
3274
|
initialValue: method !== "delete"
|
|
3275
3275
|
})
|
|
@@ -3277,7 +3277,7 @@ async function runHttpHandlerCommand(handlerNameArg, flags = {}) {
|
|
|
3277
3277
|
if (includeValidation) {
|
|
3278
3278
|
const defaultSource = method === "get" ? "query" : "body";
|
|
3279
3279
|
validationSource = handleCancel(
|
|
3280
|
-
await
|
|
3280
|
+
await p16.select({
|
|
3281
3281
|
message: "Validation data source:",
|
|
3282
3282
|
options: [
|
|
3283
3283
|
{ value: "body", label: "req.body (for POST / PUT / PATCH payloads)" },
|
|
@@ -3291,8 +3291,8 @@ async function runHttpHandlerCommand(handlerNameArg, flags = {}) {
|
|
|
3291
3291
|
});
|
|
3292
3292
|
}
|
|
3293
3293
|
}
|
|
3294
|
-
const s =
|
|
3295
|
-
s.start(`Generating HTTP handler '${
|
|
3294
|
+
const s = p16.spinner();
|
|
3295
|
+
s.start(`Generating HTTP handler '${pc16.cyan(className)}'...`);
|
|
3296
3296
|
const options = {
|
|
3297
3297
|
name: className,
|
|
3298
3298
|
feature,
|
|
@@ -3310,7 +3310,7 @@ async function runHttpHandlerCommand(handlerNameArg, flags = {}) {
|
|
|
3310
3310
|
const files = generateHttpHandler(options);
|
|
3311
3311
|
s.stop("HTTP handler generated successfully!");
|
|
3312
3312
|
printGeneratedFiles(files, options.dryRun);
|
|
3313
|
-
|
|
3313
|
+
p16.outro(pc16.green(`HTTP handler '${className}' created in feature '${feature}'!`));
|
|
3314
3314
|
}
|
|
3315
3315
|
function generateInjectableCode(className, dependencies = [], methods = [], implementsInterface) {
|
|
3316
3316
|
const formattedDeps = dependencies.map((dep) => ({
|
|
@@ -3320,7 +3320,7 @@ function generateInjectableCode(className, dependencies = [], methods = [], impl
|
|
|
3320
3320
|
const formattedMethods = methods.map((m) => {
|
|
3321
3321
|
const isAsync = m.async !== false;
|
|
3322
3322
|
const retType = m.returnType ? isAsync ? `Promise<${m.returnType}>` : m.returnType : isAsync ? "Promise<void>" : "void";
|
|
3323
|
-
const params = m.params && m.params.length > 0 ? m.params.map((
|
|
3323
|
+
const params = m.params && m.params.length > 0 ? m.params.map((p19) => `${p19.name}: ${p19.type}`).join(", ") : "";
|
|
3324
3324
|
return {
|
|
3325
3325
|
name: m.name,
|
|
3326
3326
|
isAsync,
|
|
@@ -3390,7 +3390,7 @@ async function runInjectableCommand(classNameArg, flags = {}) {
|
|
|
3390
3390
|
let name = classNameArg?.trim();
|
|
3391
3391
|
if (!name) {
|
|
3392
3392
|
name = handleCancel(
|
|
3393
|
-
await
|
|
3393
|
+
await p16.text({
|
|
3394
3394
|
message: "Injectable class name:",
|
|
3395
3395
|
placeholder: "e.g. PasswordHasher, TokenService, UserTransformer",
|
|
3396
3396
|
validate: (v) => v && v.trim() ? void 0 : "Class name cannot be empty"
|
|
@@ -3403,7 +3403,7 @@ async function runInjectableCommand(classNameArg, flags = {}) {
|
|
|
3403
3403
|
let customPath;
|
|
3404
3404
|
if (!flags.yes) {
|
|
3405
3405
|
location = handleCancel(
|
|
3406
|
-
await
|
|
3406
|
+
await p16.select({
|
|
3407
3407
|
message: "Select target architectural location:",
|
|
3408
3408
|
options: [
|
|
3409
3409
|
{ value: "feature-service", label: "Feature Service (features/<feature>/services/)" },
|
|
@@ -3421,14 +3421,14 @@ async function runInjectableCommand(classNameArg, flags = {}) {
|
|
|
3421
3421
|
const featureOptions = existingFeatures.map((f) => ({ value: f, label: f }));
|
|
3422
3422
|
featureOptions.push({ value: "__custom__", label: "\u270F\uFE0F Enter custom feature name..." });
|
|
3423
3423
|
const selected = handleCancel(
|
|
3424
|
-
await
|
|
3424
|
+
await p16.select({
|
|
3425
3425
|
message: "Select target feature:",
|
|
3426
3426
|
options: featureOptions
|
|
3427
3427
|
})
|
|
3428
3428
|
);
|
|
3429
3429
|
if (selected === "__custom__") {
|
|
3430
3430
|
feature = handleCancel(
|
|
3431
|
-
await
|
|
3431
|
+
await p16.text({
|
|
3432
3432
|
message: "Enter feature name:",
|
|
3433
3433
|
validate: (v) => v && v.trim() ? void 0 : "Feature name cannot be empty"
|
|
3434
3434
|
})
|
|
@@ -3438,7 +3438,7 @@ async function runInjectableCommand(classNameArg, flags = {}) {
|
|
|
3438
3438
|
}
|
|
3439
3439
|
} else {
|
|
3440
3440
|
feature = handleCancel(
|
|
3441
|
-
await
|
|
3441
|
+
await p16.text({
|
|
3442
3442
|
message: "Enter target feature name:",
|
|
3443
3443
|
validate: (v) => v && v.trim() ? void 0 : "Feature name cannot be empty"
|
|
3444
3444
|
})
|
|
@@ -3448,7 +3448,7 @@ async function runInjectableCommand(classNameArg, flags = {}) {
|
|
|
3448
3448
|
feature = toCamelCase(feature);
|
|
3449
3449
|
} else if (location === "custom") {
|
|
3450
3450
|
customPath = handleCancel(
|
|
3451
|
-
await
|
|
3451
|
+
await p16.text({
|
|
3452
3452
|
message: "Enter destination directory path:",
|
|
3453
3453
|
placeholder: "e.g. src/services or lib/utils",
|
|
3454
3454
|
validate: (v) => v && v.trim() ? void 0 : "Path cannot be empty"
|
|
@@ -3459,14 +3459,14 @@ async function runInjectableCommand(classNameArg, flags = {}) {
|
|
|
3459
3459
|
let generateInterface2 = false;
|
|
3460
3460
|
if (!flags.yes) {
|
|
3461
3461
|
generateInterface2 = handleCancel(
|
|
3462
|
-
await
|
|
3462
|
+
await p16.confirm({
|
|
3463
3463
|
message: `Generate abstract class interface (I${className}) as runtime DI token?`,
|
|
3464
3464
|
initialValue: false
|
|
3465
3465
|
})
|
|
3466
3466
|
);
|
|
3467
3467
|
}
|
|
3468
|
-
const s =
|
|
3469
|
-
s.start(`Generating injectable '${
|
|
3468
|
+
const s = p16.spinner();
|
|
3469
|
+
s.start(`Generating injectable '${pc16.cyan(className)}'...`);
|
|
3470
3470
|
const options = {
|
|
3471
3471
|
name: className,
|
|
3472
3472
|
feature,
|
|
@@ -3480,12 +3480,83 @@ async function runInjectableCommand(classNameArg, flags = {}) {
|
|
|
3480
3480
|
const files = generateInjectable(options);
|
|
3481
3481
|
s.stop("Injectable class generated successfully!");
|
|
3482
3482
|
printGeneratedFiles(files, options.dryRun);
|
|
3483
|
-
|
|
3483
|
+
p16.outro(pc16.green(`Injectable '${className}' created successfully!`));
|
|
3484
3484
|
}
|
|
3485
|
+
async function runEnvCommand(flags = {}) {
|
|
3486
|
+
const projectRoot = flags.cwd || flags.targetDir || findProjectRoot();
|
|
3487
|
+
const s = p16.spinner();
|
|
3488
|
+
s.start("Scanning for .example environment files...");
|
|
3489
|
+
const files = fs4.readdirSync(projectRoot);
|
|
3490
|
+
const exampleFiles = files.filter((file) => file.startsWith(".env") && file.endsWith(".example")).sort();
|
|
3491
|
+
if (exampleFiles.length === 0) {
|
|
3492
|
+
s.stop("No .example files found.");
|
|
3493
|
+
p16.log.info(pc16.yellow(`No files matching '.env*.example' were found in ${projectRoot}`));
|
|
3494
|
+
return [];
|
|
3495
|
+
}
|
|
3496
|
+
s.message(`Found ${exampleFiles.length} template(s). Generating...`);
|
|
3497
|
+
const generatedFiles = [];
|
|
3498
|
+
for (const exampleFile of exampleFiles) {
|
|
3499
|
+
const sourcePath = path2.join(projectRoot, exampleFile);
|
|
3500
|
+
const targetFile = exampleFile.replace(/\.example$/, "");
|
|
3501
|
+
const targetPath = path2.join(projectRoot, targetFile);
|
|
3502
|
+
const content = fs4.readFileSync(sourcePath, "utf-8");
|
|
3503
|
+
const genFile = writeFileSafely(targetPath, content, {
|
|
3504
|
+
projectRoot,
|
|
3505
|
+
dryRun: Boolean(flags.dryRun),
|
|
3506
|
+
overwrite: Boolean(flags.overwrite)
|
|
3507
|
+
});
|
|
3508
|
+
generatedFiles.push(genFile);
|
|
3509
|
+
}
|
|
3510
|
+
s.stop("Environment files processed!");
|
|
3511
|
+
printGeneratedFiles(generatedFiles, Boolean(flags.dryRun));
|
|
3512
|
+
p16.outro(pc16.green("\u2713 Local environment files are ready!"));
|
|
3513
|
+
return generatedFiles;
|
|
3514
|
+
}
|
|
3515
|
+
async function runEnvExamplesCommand(flags = {}) {
|
|
3516
|
+
const projectRoot = flags.cwd || flags.targetDir || findProjectRoot();
|
|
3517
|
+
const s = p16.spinner();
|
|
3518
|
+
s.start("Scanning for local environment files...");
|
|
3519
|
+
const files = fs4.readdirSync(projectRoot, { withFileTypes: true });
|
|
3520
|
+
const envFiles = files.filter((dirent) => dirent.isFile() && dirent.name.startsWith(".env") && !dirent.name.endsWith(".example")).map((dirent) => dirent.name).sort();
|
|
3521
|
+
if (envFiles.length === 0) {
|
|
3522
|
+
s.stop("No local .env files found.");
|
|
3523
|
+
p16.log.info(pc16.yellow(`No files matching '.env*' were found in ${projectRoot}`));
|
|
3524
|
+
return [];
|
|
3525
|
+
}
|
|
3526
|
+
s.message(`Found ${envFiles.length} local .env file(s). Generating templates...`);
|
|
3527
|
+
const generatedFiles = [];
|
|
3528
|
+
for (const envFile of envFiles) {
|
|
3529
|
+
const sourcePath = path2.join(projectRoot, envFile);
|
|
3530
|
+
const targetFile = `${envFile}.example`;
|
|
3531
|
+
const targetPath = path2.join(projectRoot, targetFile);
|
|
3532
|
+
const content = fs4.readFileSync(sourcePath, "utf-8");
|
|
3533
|
+
const redactedContent = content.split(/\r?\n/).map((line) => {
|
|
3534
|
+
const trimmed = line.trim();
|
|
3535
|
+
if (trimmed.startsWith("#") || !trimmed) return line;
|
|
3536
|
+
const eqIndex = line.indexOf("=");
|
|
3537
|
+
if (eqIndex !== -1) {
|
|
3538
|
+
return line.substring(0, eqIndex + 1);
|
|
3539
|
+
}
|
|
3540
|
+
return line;
|
|
3541
|
+
}).join("\n");
|
|
3542
|
+
const genFile = writeFileSafely(targetPath, redactedContent, {
|
|
3543
|
+
projectRoot,
|
|
3544
|
+
dryRun: Boolean(flags.dryRun),
|
|
3545
|
+
overwrite: Boolean(flags.overwrite)
|
|
3546
|
+
});
|
|
3547
|
+
generatedFiles.push(genFile);
|
|
3548
|
+
}
|
|
3549
|
+
s.stop("Environment example templates generated!");
|
|
3550
|
+
printGeneratedFiles(generatedFiles, Boolean(flags.dryRun));
|
|
3551
|
+
p16.outro(pc16.green("\u2713 .env*.example files are up to date and safely redacted!"));
|
|
3552
|
+
return generatedFiles;
|
|
3553
|
+
}
|
|
3554
|
+
|
|
3555
|
+
// src/commands/menu.ts
|
|
3485
3556
|
async function runInteractiveMenu(flags = {}) {
|
|
3486
3557
|
printBanner();
|
|
3487
3558
|
const choice = handleCancel(
|
|
3488
|
-
await
|
|
3559
|
+
await p16.select({
|
|
3489
3560
|
message: "What would you like to create in your architecture?",
|
|
3490
3561
|
options: [
|
|
3491
3562
|
{
|
|
@@ -3527,6 +3598,16 @@ async function runInteractiveMenu(flags = {}) {
|
|
|
3527
3598
|
value: "injectable",
|
|
3528
3599
|
label: "Injectable Service",
|
|
3529
3600
|
hint: "Generic @MakeInjectable class for services, transformers, or modules"
|
|
3601
|
+
},
|
|
3602
|
+
{
|
|
3603
|
+
value: "env",
|
|
3604
|
+
label: "Generate Env Files",
|
|
3605
|
+
hint: "Clone .env*.example files to local .env equivalents (Setup)"
|
|
3606
|
+
},
|
|
3607
|
+
{
|
|
3608
|
+
value: "envExamples",
|
|
3609
|
+
label: "Sync Env Examples",
|
|
3610
|
+
hint: "Safely clone and redact local .env files to .example templates (Sync)"
|
|
3530
3611
|
}
|
|
3531
3612
|
]
|
|
3532
3613
|
})
|
|
@@ -3556,6 +3637,12 @@ async function runInteractiveMenu(flags = {}) {
|
|
|
3556
3637
|
case "injectable":
|
|
3557
3638
|
await runInjectableCommand(void 0, flags);
|
|
3558
3639
|
break;
|
|
3640
|
+
case "env":
|
|
3641
|
+
await runEnvCommand(flags);
|
|
3642
|
+
break;
|
|
3643
|
+
case "envExamples":
|
|
3644
|
+
await runEnvExamplesCommand({ ...flags, overwrite: flags.overwrite ?? true });
|
|
3645
|
+
break;
|
|
3559
3646
|
}
|
|
3560
3647
|
}
|
|
3561
3648
|
|
|
@@ -3593,8 +3680,8 @@ async function handleCreate(type, name, flags = {}) {
|
|
|
3593
3680
|
await runInjectableCommand(name, flags);
|
|
3594
3681
|
break;
|
|
3595
3682
|
default:
|
|
3596
|
-
|
|
3597
|
-
|
|
3683
|
+
p16.log.error(
|
|
3684
|
+
pc16.red(
|
|
3598
3685
|
`Unknown component type: "${type}". Allowed types: feature, shared, usecase, domain, infrastructure, interface, httpHandler, injectable.`
|
|
3599
3686
|
)
|
|
3600
3687
|
);
|
|
@@ -3602,9 +3689,9 @@ async function handleCreate(type, name, flags = {}) {
|
|
|
3602
3689
|
}
|
|
3603
3690
|
}
|
|
3604
3691
|
var importPrompts = {
|
|
3605
|
-
select:
|
|
3606
|
-
text:
|
|
3607
|
-
confirm:
|
|
3692
|
+
select: p16.select,
|
|
3693
|
+
text: p16.text,
|
|
3694
|
+
confirm: p16.confirm
|
|
3608
3695
|
};
|
|
3609
3696
|
function isTestFile(filePath) {
|
|
3610
3697
|
const normalized = filePath.replace(/\\/g, "/");
|
|
@@ -3714,19 +3801,19 @@ async function handleImport(typeArg, nameArg, flags = {}) {
|
|
|
3714
3801
|
);
|
|
3715
3802
|
}
|
|
3716
3803
|
if (type !== "shared" && type !== "feature") {
|
|
3717
|
-
|
|
3804
|
+
p16.log.error(pc16.red(`Invalid module type: "${typeArg}". Must be "shared" or "feature".`));
|
|
3718
3805
|
process.exit(1);
|
|
3719
3806
|
}
|
|
3720
3807
|
const registryBase = getRegistryBase(projectRoot, flags.registry);
|
|
3721
|
-
const s =
|
|
3722
|
-
s.start(`Connecting to registry at ${
|
|
3808
|
+
const s = p16.spinner();
|
|
3809
|
+
s.start(`Connecting to registry at ${pc16.dim(registryBase)}...`);
|
|
3723
3810
|
let index;
|
|
3724
3811
|
try {
|
|
3725
3812
|
index = await fetchRegistryIndex(registryBase);
|
|
3726
3813
|
s.stop("Registry index loaded.");
|
|
3727
3814
|
} catch (err) {
|
|
3728
|
-
s.stop(
|
|
3729
|
-
|
|
3815
|
+
s.stop(pc16.red("Failed to load registry index."));
|
|
3816
|
+
p16.log.error(pc16.red(err.message || String(err)));
|
|
3730
3817
|
process.exit(1);
|
|
3731
3818
|
}
|
|
3732
3819
|
const availableList = type === "shared" ? index.shared : index.features;
|
|
@@ -3734,7 +3821,7 @@ async function handleImport(typeArg, nameArg, flags = {}) {
|
|
|
3734
3821
|
let name = nameArg?.trim();
|
|
3735
3822
|
if (!name) {
|
|
3736
3823
|
if (availableList.length === 0) {
|
|
3737
|
-
|
|
3824
|
+
p16.log.warn(`No ${type} modules available in the registry.`);
|
|
3738
3825
|
return;
|
|
3739
3826
|
}
|
|
3740
3827
|
name = handleCancel(
|
|
@@ -3750,9 +3837,9 @@ async function handleImport(typeArg, nameArg, flags = {}) {
|
|
|
3750
3837
|
}
|
|
3751
3838
|
if (!candidateNames.includes(name)) {
|
|
3752
3839
|
const closest = findClosestMatch(name, candidateNames);
|
|
3753
|
-
|
|
3840
|
+
p16.log.error(pc16.red(`\u274C Module '${name}' not found in the ${type} registry.`));
|
|
3754
3841
|
if (closest) {
|
|
3755
|
-
|
|
3842
|
+
p16.log.info(pc16.yellow(`Did you mean '${pc16.cyan(closest)}'?`));
|
|
3756
3843
|
}
|
|
3757
3844
|
process.exit(1);
|
|
3758
3845
|
}
|
|
@@ -3764,7 +3851,7 @@ async function handleImport(typeArg, nameArg, flags = {}) {
|
|
|
3764
3851
|
try {
|
|
3765
3852
|
manifest = await fetchModuleManifest(registryBase, modType, modName);
|
|
3766
3853
|
} catch (err) {
|
|
3767
|
-
|
|
3854
|
+
p16.log.error(pc16.red(`Failed to fetch manifest for ${modType} '${modName}': ${err.message}`));
|
|
3768
3855
|
process.exit(1);
|
|
3769
3856
|
}
|
|
3770
3857
|
nodes.set(key, {
|
|
@@ -3804,7 +3891,7 @@ async function handleImport(typeArg, nameArg, flags = {}) {
|
|
|
3804
3891
|
buildTopologicalOrder(rootKey);
|
|
3805
3892
|
const resolutions = /* @__PURE__ */ new Map();
|
|
3806
3893
|
const globalAliasMap = /* @__PURE__ */ new Map();
|
|
3807
|
-
|
|
3894
|
+
p16.log.step(`Importing ${type}: ${pc16.cyan(name)}...`);
|
|
3808
3895
|
for (const key of orderedKeys) {
|
|
3809
3896
|
const node = nodes.get(key);
|
|
3810
3897
|
const { type: modType, name: registryName, manifest } = node;
|
|
@@ -3836,8 +3923,8 @@ async function handleImport(typeArg, nameArg, flags = {}) {
|
|
|
3836
3923
|
const programmaticPointTo = pointToMap[registryName] || pointToMap[`${modType}/${registryName}`];
|
|
3837
3924
|
if (programmaticPointTo) {
|
|
3838
3925
|
if (!checkModuleExists(projectRoot, modType, programmaticPointTo)) {
|
|
3839
|
-
|
|
3840
|
-
|
|
3926
|
+
p16.log.error(
|
|
3927
|
+
pc16.red(
|
|
3841
3928
|
`Module '${programmaticPointTo}' specified in --point-to does not exist in ${folder}.`
|
|
3842
3929
|
)
|
|
3843
3930
|
);
|
|
@@ -3845,7 +3932,7 @@ async function handleImport(typeArg, nameArg, flags = {}) {
|
|
|
3845
3932
|
}
|
|
3846
3933
|
globalAliasMap.set(`@/${folder}/${registryName}/`, `@/${folder}/${programmaticPointTo}/`);
|
|
3847
3934
|
globalAliasMap.set(`@/${folder}/${registryName}`, `@/${folder}/${programmaticPointTo}`);
|
|
3848
|
-
|
|
3935
|
+
p16.log.step(`Pointing '${modType}/${registryName}' to existing '${folder}/${programmaticPointTo}'`);
|
|
3849
3936
|
resolutions.set(key, {
|
|
3850
3937
|
type: modType,
|
|
3851
3938
|
registryName,
|
|
@@ -3861,7 +3948,7 @@ async function handleImport(typeArg, nameArg, flags = {}) {
|
|
|
3861
3948
|
globalAliasMap.set(`@/${folder}/${registryName}`, `@/${folder}/${programmaticAlias}`);
|
|
3862
3949
|
const baseDir = getModuleBaseDir(projectRoot, modType);
|
|
3863
3950
|
const displayDest = path2.relative(projectRoot, path2.join(baseDir, programmaticAlias));
|
|
3864
|
-
|
|
3951
|
+
p16.log.step(`Importing '${registryName}' into '${displayDest}'...`);
|
|
3865
3952
|
resolutions.set(key, {
|
|
3866
3953
|
type: modType,
|
|
3867
3954
|
registryName,
|
|
@@ -3873,7 +3960,7 @@ async function handleImport(typeArg, nameArg, flags = {}) {
|
|
|
3873
3960
|
}
|
|
3874
3961
|
const existingDir = getExistingModuleDir(projectRoot, modType, registryName);
|
|
3875
3962
|
if (!existingDir) {
|
|
3876
|
-
|
|
3963
|
+
p16.log.info(` \u21B3 Resolving required ${modType} dependency: ${pc16.cyan(registryName)}`);
|
|
3877
3964
|
resolutions.set(key, {
|
|
3878
3965
|
type: modType,
|
|
3879
3966
|
registryName,
|
|
@@ -3889,7 +3976,7 @@ async function handleImport(typeArg, nameArg, flags = {}) {
|
|
|
3889
3976
|
const remoteIntegrity = manifest.integrity || entry?.integrity;
|
|
3890
3977
|
const localHash = computeDirectoryHash(existingDir);
|
|
3891
3978
|
if (remoteIntegrity && localHash === remoteIntegrity) {
|
|
3892
|
-
|
|
3979
|
+
p16.log.step(`\u2713 ${modType}/${registryName} is up to date (reusing existing)`);
|
|
3893
3980
|
resolutions.set(key, {
|
|
3894
3981
|
type: modType,
|
|
3895
3982
|
registryName,
|
|
@@ -3900,7 +3987,7 @@ async function handleImport(typeArg, nameArg, flags = {}) {
|
|
|
3900
3987
|
continue;
|
|
3901
3988
|
}
|
|
3902
3989
|
if (flags.overwrite) {
|
|
3903
|
-
|
|
3990
|
+
p16.log.step(`Overwriting '${modType}/${registryName}' with registry version (--overwrite)...`);
|
|
3904
3991
|
resolutions.set(key, {
|
|
3905
3992
|
type: modType,
|
|
3906
3993
|
registryName,
|
|
@@ -3911,7 +3998,7 @@ async function handleImport(typeArg, nameArg, flags = {}) {
|
|
|
3911
3998
|
continue;
|
|
3912
3999
|
}
|
|
3913
4000
|
if (flags.yes) {
|
|
3914
|
-
|
|
4001
|
+
p16.log.info(`Using existing '${modType}/${registryName}'`);
|
|
3915
4002
|
resolutions.set(key, {
|
|
3916
4003
|
type: modType,
|
|
3917
4004
|
registryName,
|
|
@@ -3945,7 +4032,7 @@ async function handleImport(typeArg, nameArg, flags = {}) {
|
|
|
3945
4032
|
})
|
|
3946
4033
|
);
|
|
3947
4034
|
if (choice === "keep_existing" || choice === "use_existing") {
|
|
3948
|
-
|
|
4035
|
+
p16.log.step(`Skipping '${modType}/${registryName}' (keeping existing)`);
|
|
3949
4036
|
resolutions.set(key, {
|
|
3950
4037
|
type: modType,
|
|
3951
4038
|
registryName,
|
|
@@ -4017,7 +4104,7 @@ async function handleImport(typeArg, nameArg, flags = {}) {
|
|
|
4017
4104
|
chosenName = chosenName.replace(/^@\/(shared|features)\//, "").replace(/^(src\/)?(shared|features)\//, "").replace(/^\/+|\/+$/g, "").trim();
|
|
4018
4105
|
globalAliasMap.set(`@/${folder}/${registryName}/`, `@/${folder}/${chosenName}/`);
|
|
4019
4106
|
globalAliasMap.set(`@/${folder}/${registryName}`, `@/${folder}/${chosenName}`);
|
|
4020
|
-
|
|
4107
|
+
p16.log.step(`Pointing '${modType}/${registryName}' to existing '${folder}/${chosenName}'`);
|
|
4021
4108
|
resolutions.set(key, {
|
|
4022
4109
|
type: modType,
|
|
4023
4110
|
registryName,
|
|
@@ -4049,7 +4136,7 @@ async function handleImport(typeArg, nameArg, flags = {}) {
|
|
|
4049
4136
|
globalAliasMap.set(`@/${folder}/${registryName}`, `@/${folder}/${newName}`);
|
|
4050
4137
|
const baseDir = getModuleBaseDir(projectRoot, modType);
|
|
4051
4138
|
const displayDest = path2.relative(projectRoot, path2.join(baseDir, newName));
|
|
4052
|
-
|
|
4139
|
+
p16.log.step(`Importing '${registryName}' into '${displayDest}'...`);
|
|
4053
4140
|
resolutions.set(key, {
|
|
4054
4141
|
type: modType,
|
|
4055
4142
|
registryName,
|
|
@@ -4060,7 +4147,7 @@ async function handleImport(typeArg, nameArg, flags = {}) {
|
|
|
4060
4147
|
continue;
|
|
4061
4148
|
}
|
|
4062
4149
|
if (choice === "overwrite") {
|
|
4063
|
-
|
|
4150
|
+
p16.log.step(`Overwriting '${modType}/${registryName}' with registry version...`);
|
|
4064
4151
|
resolutions.set(key, {
|
|
4065
4152
|
type: modType,
|
|
4066
4153
|
registryName,
|
|
@@ -4103,8 +4190,8 @@ async function handleImport(typeArg, nameArg, flags = {}) {
|
|
|
4103
4190
|
const targetDir = path2.join(getModuleBaseDir(projectRoot, res.type), res.targetName);
|
|
4104
4191
|
const isOverwrite = Boolean(flags.overwrite || res.action === "overwrite");
|
|
4105
4192
|
if (key !== rootKey) {
|
|
4106
|
-
|
|
4107
|
-
`Importing ${res.type}: ${
|
|
4193
|
+
p16.log.step(
|
|
4194
|
+
`Importing ${res.type}: ${pc16.cyan(res.targetName)}${res.targetName !== res.registryName ? pc16.dim(` (from ${res.registryName})`) : ""}...`
|
|
4108
4195
|
);
|
|
4109
4196
|
}
|
|
4110
4197
|
if (res.action === "overwrite" && !flags.dryRun) {
|
|
@@ -4122,8 +4209,8 @@ async function handleImport(typeArg, nameArg, flags = {}) {
|
|
|
4122
4209
|
const remoteFilePath = `${folder}/${res.registryName}/${file}`;
|
|
4123
4210
|
const localFilePath = path2.join(targetDir, file);
|
|
4124
4211
|
if (fs4.existsSync(localFilePath) && !isOverwrite) {
|
|
4125
|
-
|
|
4126
|
-
` \u21B3 Skipping existing file: ${
|
|
4212
|
+
p16.log.warn(
|
|
4213
|
+
` \u21B3 Skipping existing file: ${pc16.dim(path2.relative(projectRoot, localFilePath))} (use --overwrite to replace)`
|
|
4127
4214
|
);
|
|
4128
4215
|
continue;
|
|
4129
4216
|
}
|
|
@@ -4135,18 +4222,18 @@ async function handleImport(typeArg, nameArg, flags = {}) {
|
|
|
4135
4222
|
}
|
|
4136
4223
|
const displayPath = path2.relative(projectRoot, localFilePath);
|
|
4137
4224
|
totalWrittenFiles.push(displayPath);
|
|
4138
|
-
|
|
4225
|
+
p16.log.message(` ${pc16.green("+")} ${displayPath}`);
|
|
4139
4226
|
}
|
|
4140
4227
|
}
|
|
4141
4228
|
const missingNpm = getMissingNpmPackages(projectRoot, Array.from(requiredNpmPackages));
|
|
4142
4229
|
if (missingNpm.length > 0) {
|
|
4143
4230
|
if (flags.skipInstall || flags.dryRun) {
|
|
4144
|
-
|
|
4231
|
+
p16.log.info(`Required npm dependencies to install: ${pc16.cyan(missingNpm.join(", "))}`);
|
|
4145
4232
|
} else {
|
|
4146
4233
|
try {
|
|
4147
4234
|
installNpmPackages(projectRoot, missingNpm);
|
|
4148
4235
|
} catch (err) {
|
|
4149
|
-
|
|
4236
|
+
p16.log.warn(
|
|
4150
4237
|
`Could not automatically install packages (${err.message}). Please run: npm install ${missingNpm.join(
|
|
4151
4238
|
" "
|
|
4152
4239
|
)}`
|
|
@@ -4155,13 +4242,13 @@ async function handleImport(typeArg, nameArg, flags = {}) {
|
|
|
4155
4242
|
}
|
|
4156
4243
|
}
|
|
4157
4244
|
if (flags.dryRun) {
|
|
4158
|
-
|
|
4245
|
+
p16.log.info(pc16.yellow("Dry run complete: No files were written to disk."));
|
|
4159
4246
|
} else {
|
|
4160
4247
|
const rootRes = resolutions.get(rootKey);
|
|
4161
4248
|
const baseDir = getModuleBaseDir(projectRoot, type);
|
|
4162
4249
|
const displayTarget = path2.relative(projectRoot, path2.join(baseDir, rootRes.targetName));
|
|
4163
|
-
|
|
4164
|
-
|
|
4250
|
+
p16.log.success(
|
|
4251
|
+
pc16.green(
|
|
4165
4252
|
`Successfully imported ${type} '${name}' (${totalWrittenFiles.length} file${totalWrittenFiles.length === 1 ? "" : "s"} placed in ${displayTarget})`
|
|
4166
4253
|
)
|
|
4167
4254
|
);
|
|
@@ -4384,10 +4471,10 @@ var FeatureDependencyGraph = class {
|
|
|
4384
4471
|
if (cycle) return cycle;
|
|
4385
4472
|
} else if (inStack.has(next)) {
|
|
4386
4473
|
const cycle = [next];
|
|
4387
|
-
let
|
|
4388
|
-
while (
|
|
4389
|
-
cycle.push(
|
|
4390
|
-
|
|
4474
|
+
let p19 = curr;
|
|
4475
|
+
while (p19 !== next) {
|
|
4476
|
+
cycle.push(p19);
|
|
4477
|
+
p19 = parent.get(p19) || next;
|
|
4391
4478
|
}
|
|
4392
4479
|
cycle.push(next);
|
|
4393
4480
|
cycle.reverse();
|
|
@@ -5289,15 +5376,15 @@ ${compiledDetails}
|
|
|
5289
5376
|
// src/commands/lint.ts
|
|
5290
5377
|
function formatViolation(v) {
|
|
5291
5378
|
const lines = [];
|
|
5292
|
-
lines.push(
|
|
5379
|
+
lines.push(pc16.underline(pc16.cyan(v.relativePath)) + pc16.dim(":") + pc16.yellow(String(v.line)));
|
|
5293
5380
|
const gutter = `${String(v.line).padStart(4, " ")} | `;
|
|
5294
|
-
lines.push(
|
|
5381
|
+
lines.push(pc16.dim(gutter) + v.code);
|
|
5295
5382
|
const categoryShort = v.category.replace(" Violation", "");
|
|
5296
5383
|
lines.push(
|
|
5297
|
-
" " +
|
|
5384
|
+
" " + pc16.red(pc16.bold("\u2716")) + " " + pc16.red(`[${categoryShort}]`) + " " + v.advice
|
|
5298
5385
|
);
|
|
5299
5386
|
if (v.fixExample?.good) {
|
|
5300
|
-
lines.push(" " +
|
|
5387
|
+
lines.push(" " + pc16.dim("\u2192") + " " + pc16.dim(v.fixExample.good));
|
|
5301
5388
|
}
|
|
5302
5389
|
return lines.join("\n");
|
|
5303
5390
|
}
|
|
@@ -5322,7 +5409,7 @@ async function handleLint(flags = {}) {
|
|
|
5322
5409
|
console.log("");
|
|
5323
5410
|
}
|
|
5324
5411
|
console.log(
|
|
5325
|
-
|
|
5412
|
+
pc16.red(
|
|
5326
5413
|
`\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).`
|
|
5327
5414
|
)
|
|
5328
5415
|
);
|
|
@@ -5341,7 +5428,7 @@ ${compiledDetails}
|
|
|
5341
5428
|
}
|
|
5342
5429
|
if (!quiet) {
|
|
5343
5430
|
console.log(
|
|
5344
|
-
|
|
5431
|
+
pc16.green(
|
|
5345
5432
|
`\u2714 Dependency rules verified across ${summary.totalFeatures} feature${summary.totalFeatures === 1 ? "" : "s"}.`
|
|
5346
5433
|
)
|
|
5347
5434
|
);
|
|
@@ -5356,21 +5443,64 @@ ${compiledDetails}
|
|
|
5356
5443
|
console.log(formatViolation(v));
|
|
5357
5444
|
console.log("");
|
|
5358
5445
|
}
|
|
5359
|
-
console.log(
|
|
5446
|
+
console.log(pc16.red(`\u2716 Dependency rules check failed (1 error).`));
|
|
5360
5447
|
console.log("");
|
|
5361
5448
|
}
|
|
5362
5449
|
}
|
|
5363
5450
|
throw err;
|
|
5364
5451
|
}
|
|
5365
5452
|
}
|
|
5453
|
+
async function handleInit(type, flags = {}) {
|
|
5454
|
+
if (!type) {
|
|
5455
|
+
const choice = handleCancel(
|
|
5456
|
+
await p16.select({
|
|
5457
|
+
message: "What would you like to initialize?",
|
|
5458
|
+
options: [
|
|
5459
|
+
{
|
|
5460
|
+
value: "env",
|
|
5461
|
+
label: "Environment Files",
|
|
5462
|
+
hint: "Generate local .env files from .env*.example templates"
|
|
5463
|
+
},
|
|
5464
|
+
{
|
|
5465
|
+
value: "env-examples",
|
|
5466
|
+
label: "Sync Env Examples",
|
|
5467
|
+
hint: "Safely clone and redact local .env files to .example templates"
|
|
5468
|
+
}
|
|
5469
|
+
]
|
|
5470
|
+
})
|
|
5471
|
+
);
|
|
5472
|
+
if (choice === "env") {
|
|
5473
|
+
await runEnvCommand(flags);
|
|
5474
|
+
} else if (choice === "env-examples") {
|
|
5475
|
+
await runEnvExamplesCommand(flags);
|
|
5476
|
+
}
|
|
5477
|
+
return;
|
|
5478
|
+
}
|
|
5479
|
+
const normalized = type.trim().toLowerCase();
|
|
5480
|
+
if (normalized === "env") {
|
|
5481
|
+
await runEnvCommand(flags);
|
|
5482
|
+
} else if (normalized === "env-examples" || normalized === "envexamples") {
|
|
5483
|
+
await runEnvExamplesCommand(flags);
|
|
5484
|
+
} else {
|
|
5485
|
+
p16.log.error(
|
|
5486
|
+
pc16.red(
|
|
5487
|
+
`Unknown init target: "${type}". Allowed targets: env, env-examples.`
|
|
5488
|
+
)
|
|
5489
|
+
);
|
|
5490
|
+
if (process.env.VITEST) {
|
|
5491
|
+
throw new Error(`Unknown init target: "${type}". Allowed targets: env, env-examples.`);
|
|
5492
|
+
}
|
|
5493
|
+
process.exit(1);
|
|
5494
|
+
}
|
|
5495
|
+
}
|
|
5366
5496
|
|
|
5367
5497
|
// src/cli.ts
|
|
5368
5498
|
function createCli() {
|
|
5369
5499
|
const cli = cac("mason");
|
|
5370
5500
|
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) => {
|
|
5371
5501
|
if (args && args.length > 0) {
|
|
5372
|
-
|
|
5373
|
-
|
|
5502
|
+
p16.log.error(
|
|
5503
|
+
pc16.red(
|
|
5374
5504
|
`Unknown command: "${args.join(" ")}". Use --help to list available commands.`
|
|
5375
5505
|
)
|
|
5376
5506
|
);
|
|
@@ -5381,7 +5511,7 @@ function createCli() {
|
|
|
5381
5511
|
const mode = getEffectiveMode(projectRoot, flags);
|
|
5382
5512
|
if (mode === "registry") {
|
|
5383
5513
|
const choice2 = handleCancel(
|
|
5384
|
-
await
|
|
5514
|
+
await p16.select({
|
|
5385
5515
|
message: "\u{1F3DB}\uFE0F Mason (Registry Mode): What would you like to scaffold?",
|
|
5386
5516
|
options: [
|
|
5387
5517
|
{
|
|
@@ -5424,7 +5554,7 @@ function createCli() {
|
|
|
5424
5554
|
return;
|
|
5425
5555
|
}
|
|
5426
5556
|
const choice = handleCancel(
|
|
5427
|
-
await
|
|
5557
|
+
await p16.select({
|
|
5428
5558
|
message: "\u{1F9F1} Mason: What would you like to do?",
|
|
5429
5559
|
options: [
|
|
5430
5560
|
{
|
|
@@ -5441,6 +5571,11 @@ function createCli() {
|
|
|
5441
5571
|
value: "lint",
|
|
5442
5572
|
label: "Lint dependency rules",
|
|
5443
5573
|
hint: "Scan codebase and verify Clean Architecture dependency rules"
|
|
5574
|
+
},
|
|
5575
|
+
{
|
|
5576
|
+
value: "init",
|
|
5577
|
+
label: "Initialize environment",
|
|
5578
|
+
hint: "Generate local .env files from .env*.example templates"
|
|
5444
5579
|
}
|
|
5445
5580
|
]
|
|
5446
5581
|
})
|
|
@@ -5451,6 +5586,8 @@ function createCli() {
|
|
|
5451
5586
|
await handleImport(void 0, void 0, flags);
|
|
5452
5587
|
} else if (choice === "lint") {
|
|
5453
5588
|
await handleLint(flags);
|
|
5589
|
+
} else if (choice === "init") {
|
|
5590
|
+
await handleInit("env", flags);
|
|
5454
5591
|
}
|
|
5455
5592
|
} catch (err) {
|
|
5456
5593
|
handleCliError(err);
|
|
@@ -5498,6 +5635,26 @@ function createCli() {
|
|
|
5498
5635
|
handleCliError(err);
|
|
5499
5636
|
}
|
|
5500
5637
|
});
|
|
5638
|
+
cli.command(
|
|
5639
|
+
"init [type]",
|
|
5640
|
+
"Initialize project configurations and resources (e.g. 'mason init env', 'mason init env-examples')"
|
|
5641
|
+
).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 = {}) => {
|
|
5642
|
+
try {
|
|
5643
|
+
await handleInit(type, flags);
|
|
5644
|
+
} catch (err) {
|
|
5645
|
+
handleCliError(err);
|
|
5646
|
+
}
|
|
5647
|
+
});
|
|
5648
|
+
cli.command(
|
|
5649
|
+
"env-examples",
|
|
5650
|
+
"Shorthand for 'mason init env-examples'"
|
|
5651
|
+
).option("-d, --dry-run", "Preview changes without writing to disk").option("-o, --overwrite", "Overwrite existing .env*.example files").action(async (flags = {}) => {
|
|
5652
|
+
try {
|
|
5653
|
+
await handleInit("env-examples", flags);
|
|
5654
|
+
} catch (err) {
|
|
5655
|
+
handleCliError(err);
|
|
5656
|
+
}
|
|
5657
|
+
});
|
|
5501
5658
|
const createSubtypes = [
|
|
5502
5659
|
"feature",
|
|
5503
5660
|
"shared",
|
|
@@ -5529,7 +5686,7 @@ function handleCliError(err) {
|
|
|
5529
5686
|
process.exit(0);
|
|
5530
5687
|
}
|
|
5531
5688
|
const message = err instanceof Error ? err.message : String(err);
|
|
5532
|
-
|
|
5689
|
+
p16.log.error(pc16.red(`Error: ${message}`));
|
|
5533
5690
|
if (process.env.VITEST) {
|
|
5534
5691
|
throw err;
|
|
5535
5692
|
}
|
|
@@ -5540,6 +5697,6 @@ async function runCli(argv = process.argv) {
|
|
|
5540
5697
|
cli.parse(argv, { run: true });
|
|
5541
5698
|
}
|
|
5542
5699
|
|
|
5543
|
-
export { DEFAULT_REGISTRY_BASE, DependencyRuleError, FeatureDependencyGraph, PromptCancelledError, computeDirectoryHash, concreteInfraTemplate, createCli, detectPackageManager, diProviderTemplate, domainClassTemplate, domainInterfaceTemplate, domainValueObjectTemplate, ensureInterfacePrefix, expressIndexTemplate, fetchModuleManifest, fetchRegistryFile, fetchRegistryIndex, findClosestMatch, findInterfaceFile, findLocalRegistry, findProjectRoot, generateConcreteInfraCode, generateDomain, generateDomainEntityCode, generateFeature, generateHttpHandler, generateHttpHandlerCode, generateInfrastructure, generateInjectable, generateInjectableCode, generateInterface, generateInterfaceCode, generateShared, generateStubCode, generateUseCase, generateUseCaseCode, generateUseCaseTestCode, getAllFiles, getConfiguredFeaturesDir, getConfiguredSharedDir, getEffectiveMode, getMissingNpmPackages, getRegistryBase, getTemplatesDir, handleCancel, handleCreate, handleImport, handleLint, hbs, httpHandlerTemplate, injectableInterfaceTemplate, injectableTemplate, installNpmPackages, interfaceTemplate, isValidIdentifier, levenshteinDistance, lintCodebase, listDomainEntities, listDomainInterfaces, listExistingFeatures, listExistingShared, listUseCases, loadInterfaceHierarchy, loadMasonConfig, loadTemplate, normalizeRegistryUrl, parseInterfaceMethodsAndImports, printBanner, printGeneratedFiles, promptProperties, removeInterfacePrefix, renderTemplate, renderTemplateFile, resolveFeaturesDir, resolveSharedDir, runCli, runSharedCommand, stubInfraTemplate, synthesizeCrudMethods, toCamelCase, toKebabCase, toPascalCase, toPlural, toSingular, toStubName, updateOrGenerateDiProvider, useCaseTemplate, useCaseTestTemplate, writeFileSafely };
|
|
5700
|
+
export { DEFAULT_REGISTRY_BASE, DependencyRuleError, FeatureDependencyGraph, PromptCancelledError, computeDirectoryHash, concreteInfraTemplate, createCli, detectPackageManager, diProviderTemplate, domainClassTemplate, domainInterfaceTemplate, domainValueObjectTemplate, ensureInterfacePrefix, expressIndexTemplate, fetchModuleManifest, fetchRegistryFile, fetchRegistryIndex, findClosestMatch, findInterfaceFile, findLocalRegistry, findProjectRoot, generateConcreteInfraCode, generateDomain, generateDomainEntityCode, generateFeature, generateHttpHandler, generateHttpHandlerCode, generateInfrastructure, generateInjectable, generateInjectableCode, generateInterface, generateInterfaceCode, generateShared, generateStubCode, generateUseCase, generateUseCaseCode, generateUseCaseTestCode, getAllFiles, getConfiguredFeaturesDir, getConfiguredSharedDir, getEffectiveMode, getMissingNpmPackages, getRegistryBase, getTemplatesDir, handleCancel, handleCreate, handleImport, handleInit, handleLint, hbs, httpHandlerTemplate, injectableInterfaceTemplate, injectableTemplate, installNpmPackages, interfaceTemplate, isValidIdentifier, levenshteinDistance, lintCodebase, listDomainEntities, listDomainInterfaces, listExistingFeatures, listExistingShared, listUseCases, loadInterfaceHierarchy, loadMasonConfig, loadTemplate, normalizeRegistryUrl, parseInterfaceMethodsAndImports, printBanner, printGeneratedFiles, promptProperties, removeInterfacePrefix, renderTemplate, renderTemplateFile, resolveFeaturesDir, resolveSharedDir, runCli, runEnvCommand, runEnvExamplesCommand, runSharedCommand, stubInfraTemplate, synthesizeCrudMethods, toCamelCase, toKebabCase, toPascalCase, toPlural, toSingular, toStubName, updateOrGenerateDiProvider, useCaseTemplate, useCaseTestTemplate, writeFileSafely };
|
|
5544
5701
|
//# sourceMappingURL=index.js.map
|
|
5545
5702
|
//# sourceMappingURL=index.js.map
|