@solid-stack/mason 1.0.13 → 1.0.14
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 +249 -844
- package/dist/bin.cjs.map +1 -1
- package/dist/bin.js +246 -841
- package/dist/bin.js.map +1 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/index.cjs +250 -846
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +248 -843
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/commands/registry.d.ts +0 -64
- package/dist/commands/registry.d.ts.map +0 -1
package/dist/bin.cjs
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
4
|
var cac = require('cac');
|
|
5
|
-
var
|
|
6
|
-
var
|
|
7
|
-
var
|
|
5
|
+
var p3 = require('@clack/prompts');
|
|
6
|
+
var pc14 = require('picocolors');
|
|
7
|
+
var fs9 = require('fs');
|
|
8
8
|
var path2 = require('path');
|
|
9
9
|
var url = require('url');
|
|
10
10
|
var Handlebars = require('handlebars');
|
|
@@ -32,16 +32,16 @@ function _interopNamespace(e) {
|
|
|
32
32
|
return Object.freeze(n);
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
var
|
|
36
|
-
var
|
|
37
|
-
var
|
|
35
|
+
var p3__namespace = /*#__PURE__*/_interopNamespace(p3);
|
|
36
|
+
var pc14__default = /*#__PURE__*/_interopDefault(pc14);
|
|
37
|
+
var fs9__default = /*#__PURE__*/_interopDefault(fs9);
|
|
38
38
|
var path2__default = /*#__PURE__*/_interopDefault(path2);
|
|
39
39
|
var Handlebars__default = /*#__PURE__*/_interopDefault(Handlebars);
|
|
40
40
|
|
|
41
41
|
function writeFileSafely(absolutePath, content, options = {}) {
|
|
42
42
|
const projectRoot = options.projectRoot || process.cwd();
|
|
43
43
|
const relPath = path2__default.default.relative(projectRoot, absolutePath).replace(/\\/g, "/");
|
|
44
|
-
const existedBefore =
|
|
44
|
+
const existedBefore = fs9__default.default.existsSync(absolutePath);
|
|
45
45
|
if (options.dryRun) {
|
|
46
46
|
return {
|
|
47
47
|
relativePath: relPath,
|
|
@@ -61,10 +61,10 @@ function writeFileSafely(absolutePath, content, options = {}) {
|
|
|
61
61
|
};
|
|
62
62
|
}
|
|
63
63
|
const dir = path2__default.default.dirname(absolutePath);
|
|
64
|
-
if (!
|
|
65
|
-
|
|
64
|
+
if (!fs9__default.default.existsSync(dir)) {
|
|
65
|
+
fs9__default.default.mkdirSync(dir, { recursive: true });
|
|
66
66
|
}
|
|
67
|
-
|
|
67
|
+
fs9__default.default.writeFileSync(absolutePath, content, "utf-8");
|
|
68
68
|
return {
|
|
69
69
|
relativePath: relPath,
|
|
70
70
|
absolutePath,
|
|
@@ -76,17 +76,17 @@ function writeFileSafely(absolutePath, content, options = {}) {
|
|
|
76
76
|
function printGeneratedFiles(files, isDryRun = false) {
|
|
77
77
|
console.log("");
|
|
78
78
|
if (isDryRun) {
|
|
79
|
-
|
|
79
|
+
p3__namespace.log.warn(pc14__default.default.yellow(pc14__default.default.bold("[DRY RUN PREVIEW] No files were written to disk.")));
|
|
80
80
|
}
|
|
81
81
|
for (const f of files) {
|
|
82
82
|
if (f.action === "created") {
|
|
83
|
-
|
|
83
|
+
p3__namespace.log.success(`${pc14__default.default.bold(f.relativePath)} ${pc14__default.default.dim("(created)")}`);
|
|
84
84
|
} else if (f.action === "overwritten") {
|
|
85
|
-
|
|
85
|
+
p3__namespace.log.warn(`${pc14__default.default.bold(f.relativePath)} ${pc14__default.default.dim("(overwritten)")}`);
|
|
86
86
|
} else if (f.action === "skipped") {
|
|
87
|
-
|
|
87
|
+
p3__namespace.log.info(`${pc14__default.default.dim(f.relativePath)} ${pc14__default.default.dim("(skipped - already exists, pass -o to overwrite)")}`);
|
|
88
88
|
} else {
|
|
89
|
-
|
|
89
|
+
p3__namespace.log.info(`${pc14__default.default.bold(f.relativePath)} ${pc14__default.default.dim("(preview)")}`);
|
|
90
90
|
}
|
|
91
91
|
}
|
|
92
92
|
}
|
|
@@ -158,9 +158,9 @@ function loadMasonConfig(startDir = process.cwd()) {
|
|
|
158
158
|
let current = path2__default.default.resolve(startDir);
|
|
159
159
|
while (true) {
|
|
160
160
|
const configPath = path2__default.default.join(current, "mason.config.json");
|
|
161
|
-
if (
|
|
161
|
+
if (fs9__default.default.existsSync(configPath)) {
|
|
162
162
|
try {
|
|
163
|
-
return JSON.parse(
|
|
163
|
+
return JSON.parse(fs9__default.default.readFileSync(configPath, "utf-8"));
|
|
164
164
|
} catch {
|
|
165
165
|
return null;
|
|
166
166
|
}
|
|
@@ -175,7 +175,7 @@ function getEffectiveMode(projectRoot, flags) {
|
|
|
175
175
|
if (flags?.registry) return "registry";
|
|
176
176
|
const config = loadMasonConfig(projectRoot);
|
|
177
177
|
if (config?.mode) return config.mode;
|
|
178
|
-
if (
|
|
178
|
+
if (fs9__default.default.existsSync(path2__default.default.join(projectRoot, "index.json")) && (fs9__default.default.existsSync(path2__default.default.join(projectRoot, "features")) || fs9__default.default.existsSync(path2__default.default.join(projectRoot, "shared"))) && !fs9__default.default.existsSync(path2__default.default.join(projectRoot, "src"))) {
|
|
179
179
|
return "registry";
|
|
180
180
|
}
|
|
181
181
|
return "app";
|
|
@@ -191,7 +191,7 @@ function getConfiguredFeaturesDir(projectRoot, flags) {
|
|
|
191
191
|
if (mode === "registry") {
|
|
192
192
|
return path2__default.default.join(projectRoot, "features");
|
|
193
193
|
}
|
|
194
|
-
if (
|
|
194
|
+
if (fs9__default.default.existsSync(path2__default.default.join(projectRoot, "src/features"))) {
|
|
195
195
|
return path2__default.default.join(projectRoot, "src/features");
|
|
196
196
|
}
|
|
197
197
|
return path2__default.default.join(projectRoot, "features");
|
|
@@ -207,7 +207,7 @@ function getConfiguredSharedDir(projectRoot, flags) {
|
|
|
207
207
|
if (mode === "registry") {
|
|
208
208
|
return path2__default.default.join(projectRoot, "shared");
|
|
209
209
|
}
|
|
210
|
-
if (
|
|
210
|
+
if (fs9__default.default.existsSync(path2__default.default.join(projectRoot, "src/shared"))) {
|
|
211
211
|
return path2__default.default.join(projectRoot, "src/shared");
|
|
212
212
|
}
|
|
213
213
|
return path2__default.default.join(projectRoot, "shared");
|
|
@@ -217,7 +217,7 @@ function getConfiguredSharedDir(projectRoot, flags) {
|
|
|
217
217
|
function findProjectRoot(startDir = process.cwd()) {
|
|
218
218
|
let current = path2__default.default.resolve(startDir);
|
|
219
219
|
while (true) {
|
|
220
|
-
if (
|
|
220
|
+
if (fs9__default.default.existsSync(path2__default.default.join(current, "package.json"))) {
|
|
221
221
|
return current;
|
|
222
222
|
}
|
|
223
223
|
const parent = path2__default.default.dirname(current);
|
|
@@ -235,9 +235,9 @@ function resolveSharedDir(projectRoot, flags) {
|
|
|
235
235
|
}
|
|
236
236
|
function listExistingFeatures(projectRoot) {
|
|
237
237
|
const featuresDir = resolveFeaturesDir(projectRoot);
|
|
238
|
-
if (!
|
|
238
|
+
if (!fs9__default.default.existsSync(featuresDir)) return [];
|
|
239
239
|
try {
|
|
240
|
-
const entries =
|
|
240
|
+
const entries = fs9__default.default.readdirSync(featuresDir, { withFileTypes: true });
|
|
241
241
|
return entries.filter((e) => e.isDirectory()).map((e) => e.name).sort();
|
|
242
242
|
} catch {
|
|
243
243
|
return [];
|
|
@@ -248,9 +248,9 @@ function listDomainInterfaces(projectRoot, featureName) {
|
|
|
248
248
|
const features = featureName ? [featureName] : listExistingFeatures(projectRoot);
|
|
249
249
|
for (const feat of features) {
|
|
250
250
|
const domainDir = path2__default.default.join(resolveFeaturesDir(projectRoot), feat, "domain");
|
|
251
|
-
if (!
|
|
251
|
+
if (!fs9__default.default.existsSync(domainDir)) continue;
|
|
252
252
|
try {
|
|
253
|
-
const files =
|
|
253
|
+
const files = fs9__default.default.readdirSync(domainDir);
|
|
254
254
|
for (const file of files) {
|
|
255
255
|
if (file.endsWith(".ts") && !file.endsWith(".test.ts") && !file.endsWith(".d.ts")) {
|
|
256
256
|
const name = file.replace(/\.ts$/, "");
|
|
@@ -263,7 +263,7 @@ function listDomainInterfaces(projectRoot, featureName) {
|
|
|
263
263
|
});
|
|
264
264
|
} else {
|
|
265
265
|
try {
|
|
266
|
-
const content =
|
|
266
|
+
const content = fs9__default.default.readFileSync(fullPath, "utf-8");
|
|
267
267
|
if (/export\s+(?:abstract\s+class|interface)\s+(\w+)/.test(content)) {
|
|
268
268
|
results.push({
|
|
269
269
|
name,
|
|
@@ -286,9 +286,9 @@ function listDomainEntities(projectRoot, featureName) {
|
|
|
286
286
|
const features = featureName ? [featureName] : listExistingFeatures(projectRoot);
|
|
287
287
|
for (const feat of features) {
|
|
288
288
|
const domainDir = path2__default.default.join(resolveFeaturesDir(projectRoot), feat, "domain");
|
|
289
|
-
if (!
|
|
289
|
+
if (!fs9__default.default.existsSync(domainDir)) continue;
|
|
290
290
|
try {
|
|
291
|
-
const files =
|
|
291
|
+
const files = fs9__default.default.readdirSync(domainDir);
|
|
292
292
|
for (const file of files) {
|
|
293
293
|
if (file.endsWith(".ts") && !file.endsWith(".test.ts") && !file.endsWith(".d.ts")) {
|
|
294
294
|
const name = file.replace(/\.ts$/, "");
|
|
@@ -311,9 +311,9 @@ function listUseCases(projectRoot, featureName) {
|
|
|
311
311
|
const features = featureName ? [featureName] : listExistingFeatures(projectRoot);
|
|
312
312
|
for (const feat of features) {
|
|
313
313
|
const useCasesDir = path2__default.default.join(resolveFeaturesDir(projectRoot), feat, "useCases");
|
|
314
|
-
if (!
|
|
314
|
+
if (!fs9__default.default.existsSync(useCasesDir)) continue;
|
|
315
315
|
try {
|
|
316
|
-
const files =
|
|
316
|
+
const files = fs9__default.default.readdirSync(useCasesDir);
|
|
317
317
|
for (const file of files) {
|
|
318
318
|
if (file.endsWith(".ts") && !file.endsWith(".test.ts") && !file.endsWith(".d.ts")) {
|
|
319
319
|
const name = file.replace(/\.ts$/, "");
|
|
@@ -345,29 +345,29 @@ hbs.registerHelper("join", (arr, sep) => {
|
|
|
345
345
|
});
|
|
346
346
|
var cachedTemplatesDir = null;
|
|
347
347
|
function getTemplatesDir() {
|
|
348
|
-
if (cachedTemplatesDir &&
|
|
348
|
+
if (cachedTemplatesDir && fs9__default.default.existsSync(cachedTemplatesDir)) {
|
|
349
349
|
return cachedTemplatesDir;
|
|
350
350
|
}
|
|
351
351
|
const currentDir = typeof __dirname !== "undefined" ? __dirname : path2__default.default.dirname(url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('bin.cjs', document.baseURI).href))));
|
|
352
352
|
const cand1 = path2__default.default.resolve(currentDir, "../../templates");
|
|
353
|
-
if (
|
|
353
|
+
if (fs9__default.default.existsSync(cand1)) {
|
|
354
354
|
cachedTemplatesDir = cand1;
|
|
355
355
|
return cand1;
|
|
356
356
|
}
|
|
357
357
|
const cand2 = path2__default.default.resolve(currentDir, "../templates");
|
|
358
|
-
if (
|
|
358
|
+
if (fs9__default.default.existsSync(cand2)) {
|
|
359
359
|
cachedTemplatesDir = cand2;
|
|
360
360
|
return cand2;
|
|
361
361
|
}
|
|
362
362
|
const cand3 = path2__default.default.resolve(currentDir, "templates");
|
|
363
|
-
if (
|
|
363
|
+
if (fs9__default.default.existsSync(cand3)) {
|
|
364
364
|
cachedTemplatesDir = cand3;
|
|
365
365
|
return cand3;
|
|
366
366
|
}
|
|
367
367
|
let curr = currentDir;
|
|
368
368
|
while (true) {
|
|
369
369
|
const candTemplates = path2__default.default.join(curr, "templates");
|
|
370
|
-
if (
|
|
370
|
+
if (fs9__default.default.existsSync(candTemplates)) {
|
|
371
371
|
cachedTemplatesDir = candTemplates;
|
|
372
372
|
return candTemplates;
|
|
373
373
|
}
|
|
@@ -380,7 +380,7 @@ function getTemplatesDir() {
|
|
|
380
380
|
var templateCache = /* @__PURE__ */ new Map();
|
|
381
381
|
function loadTemplate(relativePath) {
|
|
382
382
|
const fullPath = path2__default.default.isAbsolute(relativePath) ? relativePath : path2__default.default.join(getTemplatesDir(), relativePath);
|
|
383
|
-
return
|
|
383
|
+
return fs9__default.default.readFileSync(fullPath, "utf-8");
|
|
384
384
|
}
|
|
385
385
|
function renderTemplateFile(relativePath, context) {
|
|
386
386
|
let compiled = templateCache.get(relativePath);
|
|
@@ -492,7 +492,7 @@ function generateInterfaceCode(ifaceName, kind = "abstractClass", entityName, me
|
|
|
492
492
|
const idKey = `${entityKey}Id`;
|
|
493
493
|
const listKey = `${entityKey}s`;
|
|
494
494
|
const formattedCustomMethods = customMethods.map((m) => {
|
|
495
|
-
const params = m.params && m.params.length > 0 ? m.params.map((
|
|
495
|
+
const params = m.params && m.params.length > 0 ? m.params.map((p16) => `${p16.name}: ${p16.type}`).join("; ") : "";
|
|
496
496
|
const returnType = m.returnType ? `Promise<${m.returnType}>` : "Promise<void>";
|
|
497
497
|
return {
|
|
498
498
|
name: m.name,
|
|
@@ -753,7 +753,7 @@ function parseInterfaceMethodsAndImports(content, targetIfaceName) {
|
|
|
753
753
|
};
|
|
754
754
|
}
|
|
755
755
|
function findInterfaceFile(projectRoot, ifaceName, featureName, customPath) {
|
|
756
|
-
if (customPath &&
|
|
756
|
+
if (customPath && fs9__default.default.existsSync(customPath)) {
|
|
757
757
|
return { filePath: customPath, ifaceName };
|
|
758
758
|
}
|
|
759
759
|
const candidateNames = [
|
|
@@ -764,21 +764,21 @@ function findInterfaceFile(projectRoot, ifaceName, featureName, customPath) {
|
|
|
764
764
|
const features = featureName ? [featureName, ...listExistingFeatures(projectRoot).filter((f) => f !== featureName)] : listExistingFeatures(projectRoot);
|
|
765
765
|
for (const feat of features) {
|
|
766
766
|
const domainDir = path2__default.default.join(resolveFeaturesDir(projectRoot), feat, "domain");
|
|
767
|
-
if (!
|
|
767
|
+
if (!fs9__default.default.existsSync(domainDir)) continue;
|
|
768
768
|
for (const cand of candidateNames) {
|
|
769
769
|
const p1 = path2__default.default.join(domainDir, `${cand}.ts`);
|
|
770
|
-
if (
|
|
770
|
+
if (fs9__default.default.existsSync(p1)) {
|
|
771
771
|
return { filePath: p1, ifaceName: cand, feature: feat };
|
|
772
772
|
}
|
|
773
773
|
}
|
|
774
774
|
}
|
|
775
775
|
for (const cand of candidateNames) {
|
|
776
776
|
const p1 = path2__default.default.join(projectRoot, "domain", `${cand}.ts`);
|
|
777
|
-
if (
|
|
777
|
+
if (fs9__default.default.existsSync(p1)) return { filePath: p1, ifaceName: cand };
|
|
778
778
|
const p22 = path2__default.default.join(projectRoot, "src", "domain", `${cand}.ts`);
|
|
779
|
-
if (
|
|
779
|
+
if (fs9__default.default.existsSync(p22)) return { filePath: p22, ifaceName: cand };
|
|
780
780
|
const p32 = path2__default.default.join(projectRoot, "interfaces", `${cand}.ts`);
|
|
781
|
-
if (
|
|
781
|
+
if (fs9__default.default.existsSync(p32)) return { filePath: p32, ifaceName: cand };
|
|
782
782
|
}
|
|
783
783
|
return null;
|
|
784
784
|
}
|
|
@@ -801,7 +801,7 @@ function loadInterfaceHierarchy(projectRoot, initialIfaceName, featureName, cust
|
|
|
801
801
|
while (currentFile && !visited.has(currentFile)) {
|
|
802
802
|
visited.add(currentFile);
|
|
803
803
|
try {
|
|
804
|
-
const content =
|
|
804
|
+
const content = fs9__default.default.readFileSync(currentFile, "utf-8");
|
|
805
805
|
const parsed = parseInterfaceMethodsAndImports(content, currentName);
|
|
806
806
|
for (const m of parsed.methods) {
|
|
807
807
|
if (!allMethods.some((existing) => existing.name === m.name)) {
|
|
@@ -1073,22 +1073,22 @@ function generateUseCaseCode(useCaseName, dependencies = [], inputProps = [], ou
|
|
|
1073
1073
|
from: /^I[A-Z]/.test(dep) ? `../domain/${dep}.js` : `./${dep}.js`
|
|
1074
1074
|
}));
|
|
1075
1075
|
const domainTypesToImport = new Set(domainImports);
|
|
1076
|
-
for (const
|
|
1077
|
-
const rawType =
|
|
1076
|
+
for (const p16 of [...inputProps, ...outputProps]) {
|
|
1077
|
+
const rawType = p16.type.trim();
|
|
1078
1078
|
const baseType = rawType.replace(/\[\]$/, "").trim();
|
|
1079
1079
|
if (!primitiveTypes.has(baseType) && /^[A-Z][A-Za-z0-9_]*$/.test(baseType) && !dependencies.includes(baseType)) {
|
|
1080
1080
|
domainTypesToImport.add(baseType);
|
|
1081
1081
|
}
|
|
1082
1082
|
}
|
|
1083
|
-
const formattedInputProps = inputProps.map((
|
|
1084
|
-
name:
|
|
1085
|
-
optional:
|
|
1086
|
-
type:
|
|
1083
|
+
const formattedInputProps = inputProps.map((p16) => ({
|
|
1084
|
+
name: p16.name,
|
|
1085
|
+
optional: p16.optional,
|
|
1086
|
+
type: p16.optional && !p16.type.includes("undefined") ? `${p16.type} | undefined` : p16.type
|
|
1087
1087
|
}));
|
|
1088
|
-
const formattedOutputProps = outputProps.map((
|
|
1089
|
-
name:
|
|
1090
|
-
optional:
|
|
1091
|
-
type:
|
|
1088
|
+
const formattedOutputProps = outputProps.map((p16) => ({
|
|
1089
|
+
name: p16.name,
|
|
1090
|
+
optional: p16.optional,
|
|
1091
|
+
type: p16.optional && !p16.type.includes("undefined") ? `${p16.type} | undefined` : p16.type
|
|
1092
1092
|
}));
|
|
1093
1093
|
const formattedDeps = dependencies.map((dep) => ({
|
|
1094
1094
|
key: toCamelCase(dep),
|
|
@@ -1275,7 +1275,7 @@ function generateHttpHandler(options) {
|
|
|
1275
1275
|
const pxDir = path2__default.default.join(resolveFeaturesDir(projectRoot), options.feature, "pxExpress");
|
|
1276
1276
|
const handlersDir = path2__default.default.join(pxDir, "handlers");
|
|
1277
1277
|
const pxIndexPath = path2__default.default.join(pxDir, "index.ts");
|
|
1278
|
-
if (!
|
|
1278
|
+
if (!fs9__default.default.existsSync(pxIndexPath)) {
|
|
1279
1279
|
const featurePath = options.routePrefix || `/${options.feature.toLowerCase()}`;
|
|
1280
1280
|
const pxIndexContent = renderTemplate(expressIndexTemplate, {
|
|
1281
1281
|
routePath: featurePath
|
|
@@ -1312,8 +1312,8 @@ function updateOrGenerateDiProvider(featureDir, featureName, bindings = [], opti
|
|
|
1312
1312
|
const providerPath = path2__default.default.join(featureDir, "diProvider.ts");
|
|
1313
1313
|
const pascalFeature = toPascalCase(featureName);
|
|
1314
1314
|
const providerModuleName = `${pascalFeature}Provider`;
|
|
1315
|
-
if (
|
|
1316
|
-
let content =
|
|
1315
|
+
if (fs9__default.default.existsSync(providerPath) && !options.overwrite) {
|
|
1316
|
+
let content = fs9__default.default.readFileSync(providerPath, "utf-8");
|
|
1317
1317
|
content = content.replace(/\n*export\s+const\s+ScaffoldProvider\s*=[^;]+;?/g, "");
|
|
1318
1318
|
for (const b of bindings) {
|
|
1319
1319
|
const ifaceImp = b.ifaceImportPath || `./domain/${b.ifaceName}.js`;
|
|
@@ -1759,23 +1759,23 @@ var PromptCancelledError = class extends Error {
|
|
|
1759
1759
|
}
|
|
1760
1760
|
};
|
|
1761
1761
|
function handleCancel(result) {
|
|
1762
|
-
if (
|
|
1763
|
-
|
|
1762
|
+
if (p3__namespace.isCancel(result)) {
|
|
1763
|
+
p3__namespace.cancel("Operation cancelled.");
|
|
1764
1764
|
throw new PromptCancelledError();
|
|
1765
1765
|
}
|
|
1766
1766
|
return result;
|
|
1767
1767
|
}
|
|
1768
1768
|
function printBanner() {
|
|
1769
1769
|
console.log("");
|
|
1770
|
-
|
|
1770
|
+
p3__namespace.intro(pc14__default.default.bgCyan(pc14__default.default.black(" @solid-stack/mason ")));
|
|
1771
1771
|
}
|
|
1772
1772
|
async function promptProperties(options = {}) {
|
|
1773
1773
|
const properties = options.defaults ? [...options.defaults] : [];
|
|
1774
1774
|
if (properties.length > 0) {
|
|
1775
|
-
const summary = properties.map((
|
|
1776
|
-
|
|
1775
|
+
const summary = properties.map((p16) => `${p16.name}: ${p16.type}${p16.optional ? "?" : ""}`).join(", ");
|
|
1776
|
+
p3__namespace.log.info(pc14__default.default.dim(`Pre-configured fields: ${summary}`));
|
|
1777
1777
|
const addMore = handleCancel(
|
|
1778
|
-
await
|
|
1778
|
+
await p3__namespace.confirm({
|
|
1779
1779
|
message: "Would you like to add custom fields/properties?",
|
|
1780
1780
|
initialValue: false
|
|
1781
1781
|
})
|
|
@@ -1784,10 +1784,10 @@ async function promptProperties(options = {}) {
|
|
|
1784
1784
|
return properties;
|
|
1785
1785
|
}
|
|
1786
1786
|
}
|
|
1787
|
-
|
|
1787
|
+
p3__namespace.log.info(pc14__default.default.cyan("Enter properties (leave name blank when finished):"));
|
|
1788
1788
|
while (true) {
|
|
1789
1789
|
const name = handleCancel(
|
|
1790
|
-
await
|
|
1790
|
+
await p3__namespace.text({
|
|
1791
1791
|
message: "Property name (or press Enter to finish):",
|
|
1792
1792
|
placeholder: "e.g. title, email, status"
|
|
1793
1793
|
})
|
|
@@ -1796,7 +1796,7 @@ async function promptProperties(options = {}) {
|
|
|
1796
1796
|
break;
|
|
1797
1797
|
}
|
|
1798
1798
|
const type = handleCancel(
|
|
1799
|
-
await
|
|
1799
|
+
await p3__namespace.select({
|
|
1800
1800
|
message: `Type for property "${name.trim()}":`,
|
|
1801
1801
|
options: [
|
|
1802
1802
|
{ value: "string", label: "string" },
|
|
@@ -1813,7 +1813,7 @@ async function promptProperties(options = {}) {
|
|
|
1813
1813
|
let finalType = type;
|
|
1814
1814
|
if (type === "custom") {
|
|
1815
1815
|
finalType = handleCancel(
|
|
1816
|
-
await
|
|
1816
|
+
await p3__namespace.text({
|
|
1817
1817
|
message: `Enter custom type for "${name.trim()}":`,
|
|
1818
1818
|
placeholder: "e.g. UserRole, string | null",
|
|
1819
1819
|
validate: (val) => val && val.trim() ? void 0 : "Type cannot be empty"
|
|
@@ -1821,7 +1821,7 @@ async function promptProperties(options = {}) {
|
|
|
1821
1821
|
);
|
|
1822
1822
|
}
|
|
1823
1823
|
const optional = handleCancel(
|
|
1824
|
-
await
|
|
1824
|
+
await p3__namespace.confirm({
|
|
1825
1825
|
message: `Is "${name.trim()}" optional?`,
|
|
1826
1826
|
initialValue: false
|
|
1827
1827
|
})
|
|
@@ -1831,8 +1831,8 @@ async function promptProperties(options = {}) {
|
|
|
1831
1831
|
type: finalType.trim(),
|
|
1832
1832
|
optional
|
|
1833
1833
|
});
|
|
1834
|
-
|
|
1835
|
-
|
|
1834
|
+
p3__namespace.log.success(
|
|
1835
|
+
pc14__default.default.green(`Added: ${name.trim()}${optional ? "?" : ""}: ${finalType.trim()}`)
|
|
1836
1836
|
);
|
|
1837
1837
|
}
|
|
1838
1838
|
return properties;
|
|
@@ -1848,7 +1848,7 @@ async function runFeatureCommand(featureNameArg, flags = {}) {
|
|
|
1848
1848
|
}
|
|
1849
1849
|
if (!name) {
|
|
1850
1850
|
name = handleCancel(
|
|
1851
|
-
await
|
|
1851
|
+
await p3__namespace.text({
|
|
1852
1852
|
message: "What is the feature name?",
|
|
1853
1853
|
placeholder: "e.g. users, auth, orders, billing",
|
|
1854
1854
|
validate: (val) => {
|
|
@@ -1864,7 +1864,7 @@ async function runFeatureCommand(featureNameArg, flags = {}) {
|
|
|
1864
1864
|
let targetDirRel = defaultDir;
|
|
1865
1865
|
if (!flags.yes && !flags.target && !flags.dest) {
|
|
1866
1866
|
targetDirRel = handleCancel(
|
|
1867
|
-
await
|
|
1867
|
+
await p3__namespace.text({
|
|
1868
1868
|
message: "Target directory for the feature:",
|
|
1869
1869
|
initialValue: defaultDir,
|
|
1870
1870
|
defaultValue: defaultDir
|
|
@@ -1886,14 +1886,14 @@ async function runFeatureCommand(featureNameArg, flags = {}) {
|
|
|
1886
1886
|
const customUseCases = [];
|
|
1887
1887
|
if (!flags.yes) {
|
|
1888
1888
|
includeExpress = handleCancel(
|
|
1889
|
-
await
|
|
1889
|
+
await p3__namespace.confirm({
|
|
1890
1890
|
message: "Include Express Presentation layer (pxExpress routes & handlers)?",
|
|
1891
1891
|
initialValue: true
|
|
1892
1892
|
})
|
|
1893
1893
|
);
|
|
1894
1894
|
if (includeExpress) {
|
|
1895
1895
|
routePath = handleCancel(
|
|
1896
|
-
await
|
|
1896
|
+
await p3__namespace.text({
|
|
1897
1897
|
message: "Express route prefix:",
|
|
1898
1898
|
initialValue: `/${normalizedName}`,
|
|
1899
1899
|
defaultValue: `/${normalizedName}`
|
|
@@ -1901,14 +1901,14 @@ async function runFeatureCommand(featureNameArg, flags = {}) {
|
|
|
1901
1901
|
).trim();
|
|
1902
1902
|
}
|
|
1903
1903
|
includeDomain = handleCancel(
|
|
1904
|
-
await
|
|
1904
|
+
await p3__namespace.confirm({
|
|
1905
1905
|
message: "Include Domain Entity/Entities?",
|
|
1906
1906
|
initialValue: true
|
|
1907
1907
|
})
|
|
1908
1908
|
);
|
|
1909
1909
|
if (includeDomain) {
|
|
1910
1910
|
const domainInput = handleCancel(
|
|
1911
|
-
await
|
|
1911
|
+
await p3__namespace.text({
|
|
1912
1912
|
message: "Domain entity name(s) (comma-separated):",
|
|
1913
1913
|
initialValue: defaultEntity,
|
|
1914
1914
|
defaultValue: defaultEntity,
|
|
@@ -1927,21 +1927,21 @@ async function runFeatureCommand(featureNameArg, flags = {}) {
|
|
|
1927
1927
|
entityNames = [defaultEntity];
|
|
1928
1928
|
}
|
|
1929
1929
|
includeInterface = handleCancel(
|
|
1930
|
-
await
|
|
1930
|
+
await p3__namespace.confirm({
|
|
1931
1931
|
message: `Include Domain Repository interface(s) for ${entityNames.join(", ")}?`,
|
|
1932
1932
|
initialValue: true
|
|
1933
1933
|
})
|
|
1934
1934
|
);
|
|
1935
1935
|
if (includeInterface) {
|
|
1936
1936
|
includeInfra = handleCancel(
|
|
1937
|
-
await
|
|
1937
|
+
await p3__namespace.confirm({
|
|
1938
1938
|
message: `Include Infrastructure Stub implementation(s) for ${entityNames.join(", ")}?`,
|
|
1939
1939
|
initialValue: true
|
|
1940
1940
|
})
|
|
1941
1941
|
);
|
|
1942
1942
|
}
|
|
1943
1943
|
includeUseCase = handleCancel(
|
|
1944
|
-
await
|
|
1944
|
+
await p3__namespace.confirm({
|
|
1945
1945
|
message: "Include Domain Use Cases?",
|
|
1946
1946
|
initialValue: true
|
|
1947
1947
|
})
|
|
@@ -1955,7 +1955,7 @@ async function runFeatureCommand(featureNameArg, flags = {}) {
|
|
|
1955
1955
|
{ value: "delete", label: "Delete (Delete<Entity>)", hint: "DELETE /:id" }
|
|
1956
1956
|
];
|
|
1957
1957
|
crudOperations = handleCancel(
|
|
1958
|
-
await
|
|
1958
|
+
await p3__namespace.multiselect({
|
|
1959
1959
|
message: "Select standard CRUD use cases to generate:",
|
|
1960
1960
|
options: crudChoices,
|
|
1961
1961
|
initialValues: ["create", "read", "list", "update", "delete"],
|
|
@@ -1963,13 +1963,13 @@ async function runFeatureCommand(featureNameArg, flags = {}) {
|
|
|
1963
1963
|
})
|
|
1964
1964
|
);
|
|
1965
1965
|
includeTests = handleCancel(
|
|
1966
|
-
await
|
|
1966
|
+
await p3__namespace.confirm({
|
|
1967
1967
|
message: "Generate Vitest unit tests for use cases?",
|
|
1968
1968
|
initialValue: true
|
|
1969
1969
|
})
|
|
1970
1970
|
);
|
|
1971
1971
|
const wantCustom = handleCancel(
|
|
1972
|
-
await
|
|
1972
|
+
await p3__namespace.confirm({
|
|
1973
1973
|
message: "Do you want to add any custom use cases to this feature?",
|
|
1974
1974
|
initialValue: false
|
|
1975
1975
|
})
|
|
@@ -1979,7 +1979,7 @@ async function runFeatureCommand(featureNameArg, flags = {}) {
|
|
|
1979
1979
|
const availableIfaces = entityNames.map((e) => `I${e}Repository`);
|
|
1980
1980
|
while (addMore) {
|
|
1981
1981
|
const customName = handleCancel(
|
|
1982
|
-
await
|
|
1982
|
+
await p3__namespace.text({
|
|
1983
1983
|
message: "Custom Use Case name:",
|
|
1984
1984
|
placeholder: "e.g. ResetPassword, VerifyEmail, AssignRole",
|
|
1985
1985
|
validate: (v) => v && v.trim() ? void 0 : "Use Case name cannot be empty"
|
|
@@ -1989,7 +1989,7 @@ async function runFeatureCommand(featureNameArg, flags = {}) {
|
|
|
1989
1989
|
let selectedDeps = [];
|
|
1990
1990
|
if (availableIfaces.length > 0) {
|
|
1991
1991
|
selectedDeps = handleCancel(
|
|
1992
|
-
await
|
|
1992
|
+
await p3__namespace.multiselect({
|
|
1993
1993
|
message: `Select domain interfaces to inject into ${customUcName}:`,
|
|
1994
1994
|
options: availableIfaces.map((i) => ({ value: i, label: i })),
|
|
1995
1995
|
required: false
|
|
@@ -1998,7 +1998,7 @@ async function runFeatureCommand(featureNameArg, flags = {}) {
|
|
|
1998
1998
|
}
|
|
1999
1999
|
let customInputProps = [];
|
|
2000
2000
|
const hasInput = handleCancel(
|
|
2001
|
-
await
|
|
2001
|
+
await p3__namespace.confirm({
|
|
2002
2002
|
message: `Does ${customUcName} accept input arguments?`,
|
|
2003
2003
|
initialValue: true
|
|
2004
2004
|
})
|
|
@@ -2009,7 +2009,7 @@ async function runFeatureCommand(featureNameArg, flags = {}) {
|
|
|
2009
2009
|
}
|
|
2010
2010
|
let customOutputProps = [];
|
|
2011
2011
|
const hasCustomOutput = handleCancel(
|
|
2012
|
-
await
|
|
2012
|
+
await p3__namespace.confirm({
|
|
2013
2013
|
message: `Does ${customUcName} return custom output data?`,
|
|
2014
2014
|
initialValue: false
|
|
2015
2015
|
})
|
|
@@ -2019,7 +2019,7 @@ async function runFeatureCommand(featureNameArg, flags = {}) {
|
|
|
2019
2019
|
});
|
|
2020
2020
|
}
|
|
2021
2021
|
const customIncludeTest = handleCancel(
|
|
2022
|
-
await
|
|
2022
|
+
await p3__namespace.confirm({
|
|
2023
2023
|
message: `Generate Vitest unit test for ${customUcName}?`,
|
|
2024
2024
|
initialValue: true
|
|
2025
2025
|
})
|
|
@@ -2029,14 +2029,14 @@ async function runFeatureCommand(featureNameArg, flags = {}) {
|
|
|
2029
2029
|
let customHttpPath = `/${toKebabCase(customUcName)}`;
|
|
2030
2030
|
if (includeExpress) {
|
|
2031
2031
|
customCreateHttp = handleCancel(
|
|
2032
|
-
await
|
|
2032
|
+
await p3__namespace.confirm({
|
|
2033
2033
|
message: `Generate a matching ExpressRoute HTTP handler for ${customUcName}?`,
|
|
2034
2034
|
initialValue: true
|
|
2035
2035
|
})
|
|
2036
2036
|
);
|
|
2037
2037
|
if (customCreateHttp) {
|
|
2038
2038
|
customHttpMethod = handleCancel(
|
|
2039
|
-
await
|
|
2039
|
+
await p3__namespace.select({
|
|
2040
2040
|
message: "HTTP method for route:",
|
|
2041
2041
|
options: [
|
|
2042
2042
|
{ value: "post", label: "POST" },
|
|
@@ -2049,7 +2049,7 @@ async function runFeatureCommand(featureNameArg, flags = {}) {
|
|
|
2049
2049
|
})
|
|
2050
2050
|
);
|
|
2051
2051
|
customHttpPath = handleCancel(
|
|
2052
|
-
await
|
|
2052
|
+
await p3__namespace.text({
|
|
2053
2053
|
message: "Route subpath (relative to feature prefix):",
|
|
2054
2054
|
initialValue: `/${toKebabCase(customUcName)}`,
|
|
2055
2055
|
defaultValue: `/${toKebabCase(customUcName)}`
|
|
@@ -2070,7 +2070,7 @@ async function runFeatureCommand(featureNameArg, flags = {}) {
|
|
|
2070
2070
|
validationFields: customInputProps
|
|
2071
2071
|
});
|
|
2072
2072
|
addMore = handleCancel(
|
|
2073
|
-
await
|
|
2073
|
+
await p3__namespace.confirm({
|
|
2074
2074
|
message: "Add another custom use case?",
|
|
2075
2075
|
initialValue: false
|
|
2076
2076
|
})
|
|
@@ -2079,7 +2079,7 @@ async function runFeatureCommand(featureNameArg, flags = {}) {
|
|
|
2079
2079
|
}
|
|
2080
2080
|
}
|
|
2081
2081
|
includeDiProvider = handleCancel(
|
|
2082
|
-
await
|
|
2082
|
+
await p3__namespace.confirm({
|
|
2083
2083
|
message: "Generate / update feature DI provider (diProvider.ts)?",
|
|
2084
2084
|
initialValue: true
|
|
2085
2085
|
})
|
|
@@ -2091,8 +2091,8 @@ async function runFeatureCommand(featureNameArg, flags = {}) {
|
|
|
2091
2091
|
entityNames = [defaultEntity];
|
|
2092
2092
|
}
|
|
2093
2093
|
}
|
|
2094
|
-
const s =
|
|
2095
|
-
s.start(`Generating feature '${
|
|
2094
|
+
const s = p3__namespace.spinner();
|
|
2095
|
+
s.start(`Generating feature '${pc14__default.default.cyan(normalizedName)}'...`);
|
|
2096
2096
|
const options = {
|
|
2097
2097
|
name: normalizedName,
|
|
2098
2098
|
projectRoot,
|
|
@@ -2114,7 +2114,7 @@ async function runFeatureCommand(featureNameArg, flags = {}) {
|
|
|
2114
2114
|
const files = generateFeature(options);
|
|
2115
2115
|
if (isRegistry) {
|
|
2116
2116
|
const registryPath = path2__default.default.join(targetDir, "registry.json");
|
|
2117
|
-
if (!
|
|
2117
|
+
if (!fs9__default.default.existsSync(registryPath)) {
|
|
2118
2118
|
const manifest = {
|
|
2119
2119
|
name: toKebabCase(normalizedName),
|
|
2120
2120
|
type: "feature",
|
|
@@ -2138,8 +2138,8 @@ async function runFeatureCommand(featureNameArg, flags = {}) {
|
|
|
2138
2138
|
}
|
|
2139
2139
|
s.stop("Feature scaffolded successfully!");
|
|
2140
2140
|
printGeneratedFiles(files, options.dryRun);
|
|
2141
|
-
|
|
2142
|
-
|
|
2141
|
+
p3__namespace.outro(
|
|
2142
|
+
pc14__default.default.green(
|
|
2143
2143
|
`\u2713 Feature '${normalizedName}' initialized in ${path2__default.default.relative(projectRoot, targetDir)} (uncommitted, unregistered)`
|
|
2144
2144
|
)
|
|
2145
2145
|
);
|
|
@@ -2253,7 +2253,7 @@ async function runSharedCommand(sharedNameArg, flags = {}) {
|
|
|
2253
2253
|
}
|
|
2254
2254
|
if (!name) {
|
|
2255
2255
|
name = handleCancel(
|
|
2256
|
-
await
|
|
2256
|
+
await p3__namespace.text({
|
|
2257
2257
|
message: "What is the shared module name?",
|
|
2258
2258
|
placeholder: "e.g. hasher, time, uuid, cache, logger",
|
|
2259
2259
|
validate: (val) => {
|
|
@@ -2269,7 +2269,7 @@ async function runSharedCommand(sharedNameArg, flags = {}) {
|
|
|
2269
2269
|
let targetDirRel = defaultDir;
|
|
2270
2270
|
if (!flags.yes && !flags.target && !flags.dest) {
|
|
2271
2271
|
targetDirRel = handleCancel(
|
|
2272
|
-
await
|
|
2272
|
+
await p3__namespace.text({
|
|
2273
2273
|
message: "Target directory for the shared module:",
|
|
2274
2274
|
initialValue: defaultDir,
|
|
2275
2275
|
defaultValue: defaultDir
|
|
@@ -2281,21 +2281,21 @@ async function runSharedCommand(sharedNameArg, flags = {}) {
|
|
|
2281
2281
|
let includeStub = true;
|
|
2282
2282
|
if (!flags.yes) {
|
|
2283
2283
|
description = handleCancel(
|
|
2284
|
-
await
|
|
2284
|
+
await p3__namespace.text({
|
|
2285
2285
|
message: "Module description (optional):",
|
|
2286
2286
|
placeholder: "e.g. In-memory caching and Redis port abstraction",
|
|
2287
2287
|
initialValue: ""
|
|
2288
2288
|
})
|
|
2289
2289
|
).trim();
|
|
2290
2290
|
includeStub = handleCancel(
|
|
2291
|
-
await
|
|
2291
|
+
await p3__namespace.confirm({
|
|
2292
2292
|
message: "Include stub implementation in infrastructure/?",
|
|
2293
2293
|
initialValue: true
|
|
2294
2294
|
})
|
|
2295
2295
|
);
|
|
2296
2296
|
}
|
|
2297
|
-
const s =
|
|
2298
|
-
s.start(`Generating shared module '${
|
|
2297
|
+
const s = p3__namespace.spinner();
|
|
2298
|
+
s.start(`Generating shared module '${pc14__default.default.cyan(normalizedName)}'...`);
|
|
2299
2299
|
const files = generateShared({
|
|
2300
2300
|
name: normalizedName,
|
|
2301
2301
|
description,
|
|
@@ -2308,8 +2308,8 @@ async function runSharedCommand(sharedNameArg, flags = {}) {
|
|
|
2308
2308
|
});
|
|
2309
2309
|
s.stop("Shared module generated successfully!");
|
|
2310
2310
|
printGeneratedFiles(files, Boolean(flags.dryRun));
|
|
2311
|
-
|
|
2312
|
-
|
|
2311
|
+
p3__namespace.outro(
|
|
2312
|
+
pc14__default.default.green(
|
|
2313
2313
|
`\u2713 Shared module '${normalizedName}' initialized in ${path2__default.default.relative(projectRoot, targetDir)} (uncommitted, unregistered)`
|
|
2314
2314
|
)
|
|
2315
2315
|
);
|
|
@@ -2323,14 +2323,14 @@ async function runUseCaseCommand(useCaseNameArg, flags = {}) {
|
|
|
2323
2323
|
const featureOptions = existingFeatures.map((f) => ({ value: f, label: f }));
|
|
2324
2324
|
featureOptions.push({ value: "__custom__", label: "\u270F\uFE0F Enter custom feature name..." });
|
|
2325
2325
|
const selected = handleCancel(
|
|
2326
|
-
await
|
|
2326
|
+
await p3__namespace.select({
|
|
2327
2327
|
message: "Select target feature:",
|
|
2328
2328
|
options: featureOptions
|
|
2329
2329
|
})
|
|
2330
2330
|
);
|
|
2331
2331
|
if (selected === "__custom__") {
|
|
2332
2332
|
feature = handleCancel(
|
|
2333
|
-
await
|
|
2333
|
+
await p3__namespace.text({
|
|
2334
2334
|
message: "Enter feature name:",
|
|
2335
2335
|
validate: (v) => v && v.trim() ? void 0 : "Feature name cannot be empty"
|
|
2336
2336
|
})
|
|
@@ -2340,7 +2340,7 @@ async function runUseCaseCommand(useCaseNameArg, flags = {}) {
|
|
|
2340
2340
|
}
|
|
2341
2341
|
} else {
|
|
2342
2342
|
feature = handleCancel(
|
|
2343
|
-
await
|
|
2343
|
+
await p3__namespace.text({
|
|
2344
2344
|
message: "Enter target feature name:",
|
|
2345
2345
|
validate: (v) => v && v.trim() ? void 0 : "Feature name cannot be empty"
|
|
2346
2346
|
})
|
|
@@ -2351,7 +2351,7 @@ async function runUseCaseCommand(useCaseNameArg, flags = {}) {
|
|
|
2351
2351
|
let name = useCaseNameArg?.trim();
|
|
2352
2352
|
if (!name) {
|
|
2353
2353
|
name = handleCancel(
|
|
2354
|
-
await
|
|
2354
|
+
await p3__namespace.text({
|
|
2355
2355
|
message: "Use Case name:",
|
|
2356
2356
|
placeholder: "e.g. CreateUser, GetUser, CancelOrder",
|
|
2357
2357
|
validate: (v) => v && v.trim() ? void 0 : "Use Case name cannot be empty"
|
|
@@ -2367,7 +2367,7 @@ async function runUseCaseCommand(useCaseNameArg, flags = {}) {
|
|
|
2367
2367
|
label: i.name
|
|
2368
2368
|
}));
|
|
2369
2369
|
selectedDeps = handleCancel(
|
|
2370
|
-
await
|
|
2370
|
+
await p3__namespace.multiselect({
|
|
2371
2371
|
message: "Select domain interfaces to inject into use case:",
|
|
2372
2372
|
options: multiOptions,
|
|
2373
2373
|
required: false
|
|
@@ -2382,7 +2382,7 @@ async function runUseCaseCommand(useCaseNameArg, flags = {}) {
|
|
|
2382
2382
|
let httpPath = "/";
|
|
2383
2383
|
if (!flags.yes) {
|
|
2384
2384
|
const hasInput = handleCancel(
|
|
2385
|
-
await
|
|
2385
|
+
await p3__namespace.confirm({
|
|
2386
2386
|
message: "Does this use case accept input arguments?",
|
|
2387
2387
|
initialValue: true
|
|
2388
2388
|
})
|
|
@@ -2392,7 +2392,7 @@ async function runUseCaseCommand(useCaseNameArg, flags = {}) {
|
|
|
2392
2392
|
});
|
|
2393
2393
|
}
|
|
2394
2394
|
const hasCustomOutput = handleCancel(
|
|
2395
|
-
await
|
|
2395
|
+
await p3__namespace.confirm({
|
|
2396
2396
|
message: "Does this use case return custom output data?",
|
|
2397
2397
|
initialValue: false
|
|
2398
2398
|
})
|
|
@@ -2402,20 +2402,20 @@ async function runUseCaseCommand(useCaseNameArg, flags = {}) {
|
|
|
2402
2402
|
});
|
|
2403
2403
|
}
|
|
2404
2404
|
includeTest = handleCancel(
|
|
2405
|
-
await
|
|
2405
|
+
await p3__namespace.confirm({
|
|
2406
2406
|
message: "Generate Vitest unit test skeleton (.test.ts)?",
|
|
2407
2407
|
initialValue: true
|
|
2408
2408
|
})
|
|
2409
2409
|
);
|
|
2410
2410
|
createHttp = handleCancel(
|
|
2411
|
-
await
|
|
2411
|
+
await p3__namespace.confirm({
|
|
2412
2412
|
message: "Generate a matching ExpressRoute HTTP handler?",
|
|
2413
2413
|
initialValue: false
|
|
2414
2414
|
})
|
|
2415
2415
|
);
|
|
2416
2416
|
if (createHttp) {
|
|
2417
2417
|
httpMethod = handleCancel(
|
|
2418
|
-
await
|
|
2418
|
+
await p3__namespace.select({
|
|
2419
2419
|
message: "HTTP method for route:",
|
|
2420
2420
|
options: [
|
|
2421
2421
|
{ value: "post", label: "POST" },
|
|
@@ -2428,7 +2428,7 @@ async function runUseCaseCommand(useCaseNameArg, flags = {}) {
|
|
|
2428
2428
|
})
|
|
2429
2429
|
);
|
|
2430
2430
|
httpPath = handleCancel(
|
|
2431
|
-
await
|
|
2431
|
+
await p3__namespace.text({
|
|
2432
2432
|
message: "Route subpath (relative to feature prefix):",
|
|
2433
2433
|
initialValue: "/",
|
|
2434
2434
|
defaultValue: "/"
|
|
@@ -2436,8 +2436,8 @@ async function runUseCaseCommand(useCaseNameArg, flags = {}) {
|
|
|
2436
2436
|
).trim();
|
|
2437
2437
|
}
|
|
2438
2438
|
}
|
|
2439
|
-
const s =
|
|
2440
|
-
s.start(`Generating use case '${
|
|
2439
|
+
const s = p3__namespace.spinner();
|
|
2440
|
+
s.start(`Generating use case '${pc14__default.default.cyan(ucName)}'...`);
|
|
2441
2441
|
const options = {
|
|
2442
2442
|
name: ucName,
|
|
2443
2443
|
feature,
|
|
@@ -2469,7 +2469,7 @@ async function runUseCaseCommand(useCaseNameArg, flags = {}) {
|
|
|
2469
2469
|
}
|
|
2470
2470
|
s.stop("Use case generated successfully!");
|
|
2471
2471
|
printGeneratedFiles(files, options.dryRun);
|
|
2472
|
-
|
|
2472
|
+
p3__namespace.outro(pc14__default.default.green(`Use case '${ucName}' created in feature '${feature}'!`));
|
|
2473
2473
|
}
|
|
2474
2474
|
async function runDomainCommand(domainNameArg, flags = {}) {
|
|
2475
2475
|
const projectRoot = findProjectRoot();
|
|
@@ -2480,14 +2480,14 @@ async function runDomainCommand(domainNameArg, flags = {}) {
|
|
|
2480
2480
|
const featureOptions = existingFeatures.map((f) => ({ value: f, label: f }));
|
|
2481
2481
|
featureOptions.push({ value: "__custom__", label: "\u270F\uFE0F Enter custom feature name..." });
|
|
2482
2482
|
const selected = handleCancel(
|
|
2483
|
-
await
|
|
2483
|
+
await p3__namespace.select({
|
|
2484
2484
|
message: "Select target feature:",
|
|
2485
2485
|
options: featureOptions
|
|
2486
2486
|
})
|
|
2487
2487
|
);
|
|
2488
2488
|
if (selected === "__custom__") {
|
|
2489
2489
|
feature = handleCancel(
|
|
2490
|
-
await
|
|
2490
|
+
await p3__namespace.text({
|
|
2491
2491
|
message: "Enter feature name:",
|
|
2492
2492
|
validate: (v) => v && v.trim() ? void 0 : "Feature name cannot be empty"
|
|
2493
2493
|
})
|
|
@@ -2497,7 +2497,7 @@ async function runDomainCommand(domainNameArg, flags = {}) {
|
|
|
2497
2497
|
}
|
|
2498
2498
|
} else {
|
|
2499
2499
|
feature = handleCancel(
|
|
2500
|
-
await
|
|
2500
|
+
await p3__namespace.text({
|
|
2501
2501
|
message: "Enter target feature name:",
|
|
2502
2502
|
validate: (v) => v && v.trim() ? void 0 : "Feature name cannot be empty"
|
|
2503
2503
|
})
|
|
@@ -2508,7 +2508,7 @@ async function runDomainCommand(domainNameArg, flags = {}) {
|
|
|
2508
2508
|
let name = domainNameArg?.trim();
|
|
2509
2509
|
if (!name) {
|
|
2510
2510
|
name = handleCancel(
|
|
2511
|
-
await
|
|
2511
|
+
await p3__namespace.text({
|
|
2512
2512
|
message: "Domain model / entity name:",
|
|
2513
2513
|
placeholder: "e.g. User, Order, Product, Address",
|
|
2514
2514
|
validate: (v) => v && v.trim() ? void 0 : "Domain name cannot be empty"
|
|
@@ -2520,7 +2520,7 @@ async function runDomainCommand(domainNameArg, flags = {}) {
|
|
|
2520
2520
|
let properties = [];
|
|
2521
2521
|
if (!flags.yes) {
|
|
2522
2522
|
kind = handleCancel(
|
|
2523
|
-
await
|
|
2523
|
+
await p3__namespace.select({
|
|
2524
2524
|
message: "Select domain model type:",
|
|
2525
2525
|
options: [
|
|
2526
2526
|
{ value: "interface", label: "TypeScript Interface (pure data structure)" },
|
|
@@ -2539,8 +2539,8 @@ async function runDomainCommand(domainNameArg, flags = {}) {
|
|
|
2539
2539
|
defaults: kind === "valueObject" ? [{ name: "value", type: "string" }] : defaultProps
|
|
2540
2540
|
});
|
|
2541
2541
|
}
|
|
2542
|
-
const s =
|
|
2543
|
-
s.start(`Generating domain model '${
|
|
2542
|
+
const s = p3__namespace.spinner();
|
|
2543
|
+
s.start(`Generating domain model '${pc14__default.default.cyan(entityName)}'...`);
|
|
2544
2544
|
const options = {
|
|
2545
2545
|
name: entityName,
|
|
2546
2546
|
feature,
|
|
@@ -2553,7 +2553,7 @@ async function runDomainCommand(domainNameArg, flags = {}) {
|
|
|
2553
2553
|
const file = generateDomain(options);
|
|
2554
2554
|
s.stop("Domain model generated successfully!");
|
|
2555
2555
|
printGeneratedFiles([file], options.dryRun);
|
|
2556
|
-
|
|
2556
|
+
p3__namespace.outro(pc14__default.default.green(`Domain model '${entityName}' created in feature '${feature}'!`));
|
|
2557
2557
|
}
|
|
2558
2558
|
async function runInfrastructureCommand(classNameArg, flags = {}) {
|
|
2559
2559
|
const projectRoot = findProjectRoot();
|
|
@@ -2562,7 +2562,7 @@ async function runInfrastructureCommand(classNameArg, flags = {}) {
|
|
|
2562
2562
|
let feature = flags.feature?.trim();
|
|
2563
2563
|
if (!flags.yes && !flags.global && !flags.feature) {
|
|
2564
2564
|
scope = handleCancel(
|
|
2565
|
-
await
|
|
2565
|
+
await p3__namespace.select({
|
|
2566
2566
|
message: "Where should this infrastructure implementation be placed?",
|
|
2567
2567
|
options: [
|
|
2568
2568
|
{ value: "feature", label: "Feature-level (features/<feature>/infrastructure)" },
|
|
@@ -2577,14 +2577,14 @@ async function runInfrastructureCommand(classNameArg, flags = {}) {
|
|
|
2577
2577
|
const featureOptions = existingFeatures.map((f) => ({ value: f, label: f }));
|
|
2578
2578
|
featureOptions.push({ value: "__custom__", label: "\u270F\uFE0F Enter custom feature name..." });
|
|
2579
2579
|
const selected = handleCancel(
|
|
2580
|
-
await
|
|
2580
|
+
await p3__namespace.select({
|
|
2581
2581
|
message: "Select target feature:",
|
|
2582
2582
|
options: featureOptions
|
|
2583
2583
|
})
|
|
2584
2584
|
);
|
|
2585
2585
|
if (selected === "__custom__") {
|
|
2586
2586
|
feature = handleCancel(
|
|
2587
|
-
await
|
|
2587
|
+
await p3__namespace.text({
|
|
2588
2588
|
message: "Enter feature name:",
|
|
2589
2589
|
validate: (v) => v && v.trim() ? void 0 : "Feature name cannot be empty"
|
|
2590
2590
|
})
|
|
@@ -2594,7 +2594,7 @@ async function runInfrastructureCommand(classNameArg, flags = {}) {
|
|
|
2594
2594
|
}
|
|
2595
2595
|
} else {
|
|
2596
2596
|
feature = handleCancel(
|
|
2597
|
-
await
|
|
2597
|
+
await p3__namespace.text({
|
|
2598
2598
|
message: "Enter target feature name:",
|
|
2599
2599
|
validate: (v) => v && v.trim() ? void 0 : "Feature name cannot be empty"
|
|
2600
2600
|
})
|
|
@@ -2607,7 +2607,7 @@ async function runInfrastructureCommand(classNameArg, flags = {}) {
|
|
|
2607
2607
|
let name = classNameArg?.trim();
|
|
2608
2608
|
if (!name) {
|
|
2609
2609
|
name = handleCancel(
|
|
2610
|
-
await
|
|
2610
|
+
await p3__namespace.text({
|
|
2611
2611
|
message: "Infrastructure class name:",
|
|
2612
2612
|
placeholder: "e.g. StubUserRepository, PostgresUserRepository, S3FileStorage",
|
|
2613
2613
|
validate: (v) => v && v.trim() ? void 0 : "Class name cannot be empty"
|
|
@@ -2626,7 +2626,7 @@ async function runInfrastructureCommand(classNameArg, flags = {}) {
|
|
|
2626
2626
|
(i) => className.toLowerCase().includes(removeInterfacePrefix(i.name).toLowerCase())
|
|
2627
2627
|
);
|
|
2628
2628
|
const ifaceChoice = handleCancel(
|
|
2629
|
-
await
|
|
2629
|
+
await p3__namespace.select({
|
|
2630
2630
|
message: "Does this class implement a domain interface or abstract class?",
|
|
2631
2631
|
options: [
|
|
2632
2632
|
...interfaces.map((i) => ({ value: i.name, label: i.name })),
|
|
@@ -2638,7 +2638,7 @@ async function runInfrastructureCommand(classNameArg, flags = {}) {
|
|
|
2638
2638
|
);
|
|
2639
2639
|
if (ifaceChoice === "__custom__") {
|
|
2640
2640
|
implementsInterface = handleCancel(
|
|
2641
|
-
await
|
|
2641
|
+
await p3__namespace.text({
|
|
2642
2642
|
message: "Enter interface or abstract class name:",
|
|
2643
2643
|
placeholder: "e.g. IUserRepository, BaseStorageAdapter",
|
|
2644
2644
|
validate: (v) => v && v.trim() ? void 0 : "Name cannot be empty"
|
|
@@ -2649,14 +2649,14 @@ async function runInfrastructureCommand(classNameArg, flags = {}) {
|
|
|
2649
2649
|
}
|
|
2650
2650
|
} else {
|
|
2651
2651
|
const wantImpl = handleCancel(
|
|
2652
|
-
await
|
|
2652
|
+
await p3__namespace.confirm({
|
|
2653
2653
|
message: "Does this class implement a domain interface or abstract class?",
|
|
2654
2654
|
initialValue: false
|
|
2655
2655
|
})
|
|
2656
2656
|
);
|
|
2657
2657
|
if (wantImpl) {
|
|
2658
2658
|
implementsInterface = handleCancel(
|
|
2659
|
-
await
|
|
2659
|
+
await p3__namespace.text({
|
|
2660
2660
|
message: "Enter interface or abstract class name:",
|
|
2661
2661
|
placeholder: "e.g. IUserRepository, BaseStorageAdapter",
|
|
2662
2662
|
validate: (v) => v && v.trim() ? void 0 : "Name cannot be empty"
|
|
@@ -2676,7 +2676,7 @@ async function runInfrastructureCommand(classNameArg, flags = {}) {
|
|
|
2676
2676
|
const allInterfaces = listDomainInterfaces(projectRoot);
|
|
2677
2677
|
if (allInterfaces.length > 0) {
|
|
2678
2678
|
const ifaceChoice = handleCancel(
|
|
2679
|
-
await
|
|
2679
|
+
await p3__namespace.select({
|
|
2680
2680
|
message: "Does this class implement an interface or abstract class?",
|
|
2681
2681
|
options: [
|
|
2682
2682
|
...allInterfaces.map((i) => ({ value: i.name, label: `${i.name} (${i.feature})` })),
|
|
@@ -2688,7 +2688,7 @@ async function runInfrastructureCommand(classNameArg, flags = {}) {
|
|
|
2688
2688
|
);
|
|
2689
2689
|
if (ifaceChoice === "__custom__") {
|
|
2690
2690
|
implementsInterface = handleCancel(
|
|
2691
|
-
await
|
|
2691
|
+
await p3__namespace.text({
|
|
2692
2692
|
message: "Enter interface or abstract class name:",
|
|
2693
2693
|
placeholder: "e.g. IAuthRepository",
|
|
2694
2694
|
validate: (v) => v && v.trim() ? void 0 : "Name cannot be empty"
|
|
@@ -2701,7 +2701,7 @@ async function runInfrastructureCommand(classNameArg, flags = {}) {
|
|
|
2701
2701
|
}
|
|
2702
2702
|
if (!flags.yes && !flags.kind) {
|
|
2703
2703
|
kind = handleCancel(
|
|
2704
|
-
await
|
|
2704
|
+
await p3__namespace.select({
|
|
2705
2705
|
message: "Select implementation kind:",
|
|
2706
2706
|
options: [
|
|
2707
2707
|
{ value: "stub", label: "In-Memory Stub (with in-memory store and test helper methods)" },
|
|
@@ -2712,7 +2712,7 @@ async function runInfrastructureCommand(classNameArg, flags = {}) {
|
|
|
2712
2712
|
);
|
|
2713
2713
|
if (scope === "feature" && feature && implementsInterface) {
|
|
2714
2714
|
registerInProvider = handleCancel(
|
|
2715
|
-
await
|
|
2715
|
+
await p3__namespace.confirm({
|
|
2716
2716
|
message: "Register this implementation in feature diProvider.ts?",
|
|
2717
2717
|
initialValue: true
|
|
2718
2718
|
})
|
|
@@ -2721,8 +2721,8 @@ async function runInfrastructureCommand(classNameArg, flags = {}) {
|
|
|
2721
2721
|
} else if (flags.yes && scope === "feature" && feature && implementsInterface) {
|
|
2722
2722
|
registerInProvider = !flags.noProvider;
|
|
2723
2723
|
}
|
|
2724
|
-
const s =
|
|
2725
|
-
s.start(`Generating infrastructure class '${
|
|
2724
|
+
const s = p3__namespace.spinner();
|
|
2725
|
+
s.start(`Generating infrastructure class '${pc14__default.default.cyan(className)}'...`);
|
|
2726
2726
|
const files = [];
|
|
2727
2727
|
const options = {
|
|
2728
2728
|
name: className,
|
|
@@ -2757,7 +2757,7 @@ async function runInfrastructureCommand(classNameArg, flags = {}) {
|
|
|
2757
2757
|
}
|
|
2758
2758
|
s.stop("Infrastructure class generated successfully!");
|
|
2759
2759
|
printGeneratedFiles(files, options.dryRun);
|
|
2760
|
-
|
|
2760
|
+
p3__namespace.outro(pc14__default.default.green(`Infrastructure class '${className}' created!`));
|
|
2761
2761
|
}
|
|
2762
2762
|
async function runInterfaceCommand(interfaceNameArg, flags = {}) {
|
|
2763
2763
|
const projectRoot = findProjectRoot();
|
|
@@ -2768,14 +2768,14 @@ async function runInterfaceCommand(interfaceNameArg, flags = {}) {
|
|
|
2768
2768
|
const featureOptions = existingFeatures.map((f) => ({ value: f, label: f }));
|
|
2769
2769
|
featureOptions.push({ value: "__custom__", label: "\u270F\uFE0F Enter custom feature name..." });
|
|
2770
2770
|
const selected = handleCancel(
|
|
2771
|
-
await
|
|
2771
|
+
await p3__namespace.select({
|
|
2772
2772
|
message: "Select target feature:",
|
|
2773
2773
|
options: featureOptions
|
|
2774
2774
|
})
|
|
2775
2775
|
);
|
|
2776
2776
|
if (selected === "__custom__") {
|
|
2777
2777
|
feature = handleCancel(
|
|
2778
|
-
await
|
|
2778
|
+
await p3__namespace.text({
|
|
2779
2779
|
message: "Enter feature name:",
|
|
2780
2780
|
validate: (v) => v && v.trim() ? void 0 : "Feature name cannot be empty"
|
|
2781
2781
|
})
|
|
@@ -2785,7 +2785,7 @@ async function runInterfaceCommand(interfaceNameArg, flags = {}) {
|
|
|
2785
2785
|
}
|
|
2786
2786
|
} else {
|
|
2787
2787
|
feature = handleCancel(
|
|
2788
|
-
await
|
|
2788
|
+
await p3__namespace.text({
|
|
2789
2789
|
message: "Enter target feature name:",
|
|
2790
2790
|
validate: (v) => v && v.trim() ? void 0 : "Feature name cannot be empty"
|
|
2791
2791
|
})
|
|
@@ -2796,7 +2796,7 @@ async function runInterfaceCommand(interfaceNameArg, flags = {}) {
|
|
|
2796
2796
|
let name = interfaceNameArg?.trim();
|
|
2797
2797
|
if (!name) {
|
|
2798
2798
|
name = handleCancel(
|
|
2799
|
-
await
|
|
2799
|
+
await p3__namespace.text({
|
|
2800
2800
|
message: "Domain interface name:",
|
|
2801
2801
|
placeholder: "e.g. IUserRepository, IPaymentService",
|
|
2802
2802
|
validate: (v) => v && v.trim() ? void 0 : "Interface name cannot be empty"
|
|
@@ -2814,7 +2814,7 @@ async function runInterfaceCommand(interfaceNameArg, flags = {}) {
|
|
|
2814
2814
|
if (!flags.yes) {
|
|
2815
2815
|
if (existingEntities.length > 0) {
|
|
2816
2816
|
const selectedEntity = handleCancel(
|
|
2817
|
-
await
|
|
2817
|
+
await p3__namespace.select({
|
|
2818
2818
|
message: "Select domain entity associated with this interface:",
|
|
2819
2819
|
options: [
|
|
2820
2820
|
...existingEntities.map((e) => ({ value: e.name, label: e.name })),
|
|
@@ -2825,7 +2825,7 @@ async function runInterfaceCommand(interfaceNameArg, flags = {}) {
|
|
|
2825
2825
|
);
|
|
2826
2826
|
if (selectedEntity === "__custom__") {
|
|
2827
2827
|
entityName = handleCancel(
|
|
2828
|
-
await
|
|
2828
|
+
await p3__namespace.text({
|
|
2829
2829
|
message: "Enter entity name:",
|
|
2830
2830
|
defaultValue: removeInterfacePrefix(ifaceName).replace(/Repository$|Service$/, "")
|
|
2831
2831
|
})
|
|
@@ -2835,7 +2835,7 @@ async function runInterfaceCommand(interfaceNameArg, flags = {}) {
|
|
|
2835
2835
|
}
|
|
2836
2836
|
}
|
|
2837
2837
|
kind = handleCancel(
|
|
2838
|
-
await
|
|
2838
|
+
await p3__namespace.select({
|
|
2839
2839
|
message: "Interface definition style:",
|
|
2840
2840
|
options: [
|
|
2841
2841
|
{ value: "abstractClass", label: "Abstract Class (Recommended - acts as DI token & type)" },
|
|
@@ -2845,7 +2845,7 @@ async function runInterfaceCommand(interfaceNameArg, flags = {}) {
|
|
|
2845
2845
|
})
|
|
2846
2846
|
);
|
|
2847
2847
|
methodsPreset = handleCancel(
|
|
2848
|
-
await
|
|
2848
|
+
await p3__namespace.select({
|
|
2849
2849
|
message: "Method signature preset:",
|
|
2850
2850
|
options: [
|
|
2851
2851
|
{ value: "crud", label: "Standard CRUD (GetById, List, Create, Update, Delete)" },
|
|
@@ -2855,22 +2855,22 @@ async function runInterfaceCommand(interfaceNameArg, flags = {}) {
|
|
|
2855
2855
|
})
|
|
2856
2856
|
);
|
|
2857
2857
|
generateStub = handleCancel(
|
|
2858
|
-
await
|
|
2858
|
+
await p3__namespace.confirm({
|
|
2859
2859
|
message: "Auto-generate Infrastructure Stub implementation?",
|
|
2860
2860
|
initialValue: true
|
|
2861
2861
|
})
|
|
2862
2862
|
);
|
|
2863
2863
|
if (generateStub) {
|
|
2864
2864
|
registerInProvider = handleCancel(
|
|
2865
|
-
await
|
|
2865
|
+
await p3__namespace.confirm({
|
|
2866
2866
|
message: "Auto-register interface & stub in feature diProvider.ts?",
|
|
2867
2867
|
initialValue: true
|
|
2868
2868
|
})
|
|
2869
2869
|
);
|
|
2870
2870
|
}
|
|
2871
2871
|
}
|
|
2872
|
-
const s =
|
|
2873
|
-
s.start(`Generating interface '${
|
|
2872
|
+
const s = p3__namespace.spinner();
|
|
2873
|
+
s.start(`Generating interface '${pc14__default.default.cyan(ifaceName)}'...`);
|
|
2874
2874
|
const files = [];
|
|
2875
2875
|
const options = {
|
|
2876
2876
|
name: ifaceName,
|
|
@@ -2919,7 +2919,7 @@ async function runInterfaceCommand(interfaceNameArg, flags = {}) {
|
|
|
2919
2919
|
}
|
|
2920
2920
|
s.stop("Interface generated successfully!");
|
|
2921
2921
|
printGeneratedFiles(files, options.dryRun);
|
|
2922
|
-
|
|
2922
|
+
p3__namespace.outro(pc14__default.default.green(`Interface '${ifaceName}' created in feature '${feature}'!`));
|
|
2923
2923
|
}
|
|
2924
2924
|
async function runHttpHandlerCommand(handlerNameArg, flags = {}) {
|
|
2925
2925
|
const projectRoot = findProjectRoot();
|
|
@@ -2930,14 +2930,14 @@ async function runHttpHandlerCommand(handlerNameArg, flags = {}) {
|
|
|
2930
2930
|
const featureOptions = existingFeatures.map((f) => ({ value: f, label: f }));
|
|
2931
2931
|
featureOptions.push({ value: "__custom__", label: "\u270F\uFE0F Enter custom feature name..." });
|
|
2932
2932
|
const selected = handleCancel(
|
|
2933
|
-
await
|
|
2933
|
+
await p3__namespace.select({
|
|
2934
2934
|
message: "Select target feature:",
|
|
2935
2935
|
options: featureOptions
|
|
2936
2936
|
})
|
|
2937
2937
|
);
|
|
2938
2938
|
if (selected === "__custom__") {
|
|
2939
2939
|
feature = handleCancel(
|
|
2940
|
-
await
|
|
2940
|
+
await p3__namespace.text({
|
|
2941
2941
|
message: "Enter feature name:",
|
|
2942
2942
|
validate: (v) => v && v.trim() ? void 0 : "Feature name cannot be empty"
|
|
2943
2943
|
})
|
|
@@ -2947,7 +2947,7 @@ async function runHttpHandlerCommand(handlerNameArg, flags = {}) {
|
|
|
2947
2947
|
}
|
|
2948
2948
|
} else {
|
|
2949
2949
|
feature = handleCancel(
|
|
2950
|
-
await
|
|
2950
|
+
await p3__namespace.text({
|
|
2951
2951
|
message: "Enter target feature name:",
|
|
2952
2952
|
validate: (v) => v && v.trim() ? void 0 : "Feature name cannot be empty"
|
|
2953
2953
|
})
|
|
@@ -2958,7 +2958,7 @@ async function runHttpHandlerCommand(handlerNameArg, flags = {}) {
|
|
|
2958
2958
|
let name = handlerNameArg?.trim();
|
|
2959
2959
|
if (!name) {
|
|
2960
2960
|
name = handleCancel(
|
|
2961
|
-
await
|
|
2961
|
+
await p3__namespace.text({
|
|
2962
2962
|
message: "HTTP Route Handler class name:",
|
|
2963
2963
|
placeholder: "e.g. CreateUserHttp, GetUserHttp, HealthHttp",
|
|
2964
2964
|
validate: (v) => v && v.trim() ? void 0 : "Handler name cannot be empty"
|
|
@@ -2977,7 +2977,7 @@ async function runHttpHandlerCommand(handlerNameArg, flags = {}) {
|
|
|
2977
2977
|
let validationFields = [];
|
|
2978
2978
|
if (!flags.yes) {
|
|
2979
2979
|
method = handleCancel(
|
|
2980
|
-
await
|
|
2980
|
+
await p3__namespace.select({
|
|
2981
2981
|
message: "HTTP Method:",
|
|
2982
2982
|
options: [
|
|
2983
2983
|
{ value: "get", label: "GET" },
|
|
@@ -2991,7 +2991,7 @@ async function runHttpHandlerCommand(handlerNameArg, flags = {}) {
|
|
|
2991
2991
|
);
|
|
2992
2992
|
const defaultPath = method === "get" ? "/" : "/";
|
|
2993
2993
|
subPath = handleCancel(
|
|
2994
|
-
await
|
|
2994
|
+
await p3__namespace.text({
|
|
2995
2995
|
message: "Route subpath (relative to feature prefix):",
|
|
2996
2996
|
initialValue: defaultPath,
|
|
2997
2997
|
defaultValue: defaultPath
|
|
@@ -3002,7 +3002,7 @@ async function runHttpHandlerCommand(handlerNameArg, flags = {}) {
|
|
|
3002
3002
|
const ucOptions = useCases.map((u) => ({ value: u.name, label: u.name }));
|
|
3003
3003
|
ucOptions.push({ value: "__none__", label: "None / Standalone Handler" });
|
|
3004
3004
|
const chosenUc = handleCancel(
|
|
3005
|
-
await
|
|
3005
|
+
await p3__namespace.select({
|
|
3006
3006
|
message: "Connect this handler to a domain Use Case?",
|
|
3007
3007
|
options: ucOptions,
|
|
3008
3008
|
initialValue: ucOptions[0]?.value
|
|
@@ -3013,7 +3013,7 @@ async function runHttpHandlerCommand(handlerNameArg, flags = {}) {
|
|
|
3013
3013
|
}
|
|
3014
3014
|
}
|
|
3015
3015
|
includeValidation = handleCancel(
|
|
3016
|
-
await
|
|
3016
|
+
await p3__namespace.confirm({
|
|
3017
3017
|
message: "Include Zod inbound request validation?",
|
|
3018
3018
|
initialValue: method !== "delete"
|
|
3019
3019
|
})
|
|
@@ -3021,7 +3021,7 @@ async function runHttpHandlerCommand(handlerNameArg, flags = {}) {
|
|
|
3021
3021
|
if (includeValidation) {
|
|
3022
3022
|
const defaultSource = method === "get" ? "query" : "body";
|
|
3023
3023
|
validationSource = handleCancel(
|
|
3024
|
-
await
|
|
3024
|
+
await p3__namespace.select({
|
|
3025
3025
|
message: "Validation data source:",
|
|
3026
3026
|
options: [
|
|
3027
3027
|
{ value: "body", label: "req.body (for POST / PUT / PATCH payloads)" },
|
|
@@ -3035,8 +3035,8 @@ async function runHttpHandlerCommand(handlerNameArg, flags = {}) {
|
|
|
3035
3035
|
});
|
|
3036
3036
|
}
|
|
3037
3037
|
}
|
|
3038
|
-
const s =
|
|
3039
|
-
s.start(`Generating HTTP handler '${
|
|
3038
|
+
const s = p3__namespace.spinner();
|
|
3039
|
+
s.start(`Generating HTTP handler '${pc14__default.default.cyan(className)}'...`);
|
|
3040
3040
|
const options = {
|
|
3041
3041
|
name: className,
|
|
3042
3042
|
feature,
|
|
@@ -3054,7 +3054,7 @@ async function runHttpHandlerCommand(handlerNameArg, flags = {}) {
|
|
|
3054
3054
|
const files = generateHttpHandler(options);
|
|
3055
3055
|
s.stop("HTTP handler generated successfully!");
|
|
3056
3056
|
printGeneratedFiles(files, options.dryRun);
|
|
3057
|
-
|
|
3057
|
+
p3__namespace.outro(pc14__default.default.green(`HTTP handler '${className}' created in feature '${feature}'!`));
|
|
3058
3058
|
}
|
|
3059
3059
|
function generateInjectableCode(className, dependencies = [], methods = [], implementsInterface) {
|
|
3060
3060
|
const formattedDeps = dependencies.map((dep) => ({
|
|
@@ -3064,7 +3064,7 @@ function generateInjectableCode(className, dependencies = [], methods = [], impl
|
|
|
3064
3064
|
const formattedMethods = methods.map((m) => {
|
|
3065
3065
|
const isAsync = m.async !== false;
|
|
3066
3066
|
const retType = m.returnType ? isAsync ? `Promise<${m.returnType}>` : m.returnType : isAsync ? "Promise<void>" : "void";
|
|
3067
|
-
const params = m.params && m.params.length > 0 ? m.params.map((
|
|
3067
|
+
const params = m.params && m.params.length > 0 ? m.params.map((p16) => `${p16.name}: ${p16.type}`).join(", ") : "";
|
|
3068
3068
|
return {
|
|
3069
3069
|
name: m.name,
|
|
3070
3070
|
isAsync,
|
|
@@ -3134,7 +3134,7 @@ async function runInjectableCommand(classNameArg, flags = {}) {
|
|
|
3134
3134
|
let name = classNameArg?.trim();
|
|
3135
3135
|
if (!name) {
|
|
3136
3136
|
name = handleCancel(
|
|
3137
|
-
await
|
|
3137
|
+
await p3__namespace.text({
|
|
3138
3138
|
message: "Injectable class name:",
|
|
3139
3139
|
placeholder: "e.g. PasswordHasher, TokenService, UserTransformer",
|
|
3140
3140
|
validate: (v) => v && v.trim() ? void 0 : "Class name cannot be empty"
|
|
@@ -3147,7 +3147,7 @@ async function runInjectableCommand(classNameArg, flags = {}) {
|
|
|
3147
3147
|
let customPath;
|
|
3148
3148
|
if (!flags.yes) {
|
|
3149
3149
|
location = handleCancel(
|
|
3150
|
-
await
|
|
3150
|
+
await p3__namespace.select({
|
|
3151
3151
|
message: "Select target architectural location:",
|
|
3152
3152
|
options: [
|
|
3153
3153
|
{ value: "feature-service", label: "Feature Service (features/<feature>/services/)" },
|
|
@@ -3165,14 +3165,14 @@ async function runInjectableCommand(classNameArg, flags = {}) {
|
|
|
3165
3165
|
const featureOptions = existingFeatures.map((f) => ({ value: f, label: f }));
|
|
3166
3166
|
featureOptions.push({ value: "__custom__", label: "\u270F\uFE0F Enter custom feature name..." });
|
|
3167
3167
|
const selected = handleCancel(
|
|
3168
|
-
await
|
|
3168
|
+
await p3__namespace.select({
|
|
3169
3169
|
message: "Select target feature:",
|
|
3170
3170
|
options: featureOptions
|
|
3171
3171
|
})
|
|
3172
3172
|
);
|
|
3173
3173
|
if (selected === "__custom__") {
|
|
3174
3174
|
feature = handleCancel(
|
|
3175
|
-
await
|
|
3175
|
+
await p3__namespace.text({
|
|
3176
3176
|
message: "Enter feature name:",
|
|
3177
3177
|
validate: (v) => v && v.trim() ? void 0 : "Feature name cannot be empty"
|
|
3178
3178
|
})
|
|
@@ -3182,7 +3182,7 @@ async function runInjectableCommand(classNameArg, flags = {}) {
|
|
|
3182
3182
|
}
|
|
3183
3183
|
} else {
|
|
3184
3184
|
feature = handleCancel(
|
|
3185
|
-
await
|
|
3185
|
+
await p3__namespace.text({
|
|
3186
3186
|
message: "Enter target feature name:",
|
|
3187
3187
|
validate: (v) => v && v.trim() ? void 0 : "Feature name cannot be empty"
|
|
3188
3188
|
})
|
|
@@ -3192,7 +3192,7 @@ async function runInjectableCommand(classNameArg, flags = {}) {
|
|
|
3192
3192
|
feature = toCamelCase(feature);
|
|
3193
3193
|
} else if (location === "custom") {
|
|
3194
3194
|
customPath = handleCancel(
|
|
3195
|
-
await
|
|
3195
|
+
await p3__namespace.text({
|
|
3196
3196
|
message: "Enter destination directory path:",
|
|
3197
3197
|
placeholder: "e.g. src/services or lib/utils",
|
|
3198
3198
|
validate: (v) => v && v.trim() ? void 0 : "Path cannot be empty"
|
|
@@ -3203,14 +3203,14 @@ async function runInjectableCommand(classNameArg, flags = {}) {
|
|
|
3203
3203
|
let generateInterface2 = false;
|
|
3204
3204
|
if (!flags.yes) {
|
|
3205
3205
|
generateInterface2 = handleCancel(
|
|
3206
|
-
await
|
|
3206
|
+
await p3__namespace.confirm({
|
|
3207
3207
|
message: `Generate abstract class interface (I${className}) as runtime DI token?`,
|
|
3208
3208
|
initialValue: false
|
|
3209
3209
|
})
|
|
3210
3210
|
);
|
|
3211
3211
|
}
|
|
3212
|
-
const s =
|
|
3213
|
-
s.start(`Generating injectable '${
|
|
3212
|
+
const s = p3__namespace.spinner();
|
|
3213
|
+
s.start(`Generating injectable '${pc14__default.default.cyan(className)}'...`);
|
|
3214
3214
|
const options = {
|
|
3215
3215
|
name: className,
|
|
3216
3216
|
feature,
|
|
@@ -3224,12 +3224,12 @@ async function runInjectableCommand(classNameArg, flags = {}) {
|
|
|
3224
3224
|
const files = generateInjectable(options);
|
|
3225
3225
|
s.stop("Injectable class generated successfully!");
|
|
3226
3226
|
printGeneratedFiles(files, options.dryRun);
|
|
3227
|
-
|
|
3227
|
+
p3__namespace.outro(pc14__default.default.green(`Injectable '${className}' created successfully!`));
|
|
3228
3228
|
}
|
|
3229
3229
|
async function runInteractiveMenu(flags = {}) {
|
|
3230
3230
|
printBanner();
|
|
3231
3231
|
const choice = handleCancel(
|
|
3232
|
-
await
|
|
3232
|
+
await p3__namespace.select({
|
|
3233
3233
|
message: "What would you like to create in your architecture?",
|
|
3234
3234
|
options: [
|
|
3235
3235
|
{
|
|
@@ -3337,8 +3337,8 @@ async function handleCreate(type, name, flags = {}) {
|
|
|
3337
3337
|
await runInjectableCommand(name, flags);
|
|
3338
3338
|
break;
|
|
3339
3339
|
default:
|
|
3340
|
-
|
|
3341
|
-
|
|
3340
|
+
p3__namespace.log.error(
|
|
3341
|
+
pc14__default.default.red(
|
|
3342
3342
|
`Unknown component type: "${type}". Allowed types: feature, shared, usecase, domain, infrastructure, interface, httpHandler, injectable.`
|
|
3343
3343
|
)
|
|
3344
3344
|
);
|
|
@@ -3370,7 +3370,7 @@ function findLocalRegistry(startDir = process.cwd()) {
|
|
|
3370
3370
|
let current = path2__default.default.resolve(startDir);
|
|
3371
3371
|
while (true) {
|
|
3372
3372
|
const candidate = path2__default.default.join(current, "mason-registry");
|
|
3373
|
-
if (
|
|
3373
|
+
if (fs9__default.default.existsSync(candidate) && fs9__default.default.existsSync(path2__default.default.join(candidate, "index.json"))) {
|
|
3374
3374
|
return candidate;
|
|
3375
3375
|
}
|
|
3376
3376
|
const parent = path2__default.default.dirname(current);
|
|
@@ -3392,9 +3392,9 @@ function getRegistryBase(projectRoot, override) {
|
|
|
3392
3392
|
path2__default.default.join(process.cwd(), "mason.config.json")
|
|
3393
3393
|
];
|
|
3394
3394
|
for (const configPath of configLocations) {
|
|
3395
|
-
if (
|
|
3395
|
+
if (fs9__default.default.existsSync(configPath)) {
|
|
3396
3396
|
try {
|
|
3397
|
-
const config = JSON.parse(
|
|
3397
|
+
const config = JSON.parse(fs9__default.default.readFileSync(configPath, "utf-8"));
|
|
3398
3398
|
if (config.registry && typeof config.registry === "string") {
|
|
3399
3399
|
return normalizeRegistryUrl(config.registry.trim(), path2__default.default.dirname(configPath));
|
|
3400
3400
|
}
|
|
@@ -3407,9 +3407,9 @@ function getRegistryBase(projectRoot, override) {
|
|
|
3407
3407
|
path2__default.default.join(process.cwd(), "package.json")
|
|
3408
3408
|
];
|
|
3409
3409
|
for (const pkgPath of pkgLocations) {
|
|
3410
|
-
if (
|
|
3410
|
+
if (fs9__default.default.existsSync(pkgPath)) {
|
|
3411
3411
|
try {
|
|
3412
|
-
const pkg = JSON.parse(
|
|
3412
|
+
const pkg = JSON.parse(fs9__default.default.readFileSync(pkgPath, "utf-8"));
|
|
3413
3413
|
if (pkg.mason?.registry && typeof pkg.mason.registry === "string") {
|
|
3414
3414
|
return normalizeRegistryUrl(pkg.mason.registry.trim(), path2__default.default.dirname(pkgPath));
|
|
3415
3415
|
}
|
|
@@ -3453,10 +3453,10 @@ async function fetchRegistryFile(registryBase, relPath) {
|
|
|
3453
3453
|
baseDir = url.fileURLToPath(baseDir);
|
|
3454
3454
|
}
|
|
3455
3455
|
const filePath = path2__default.default.resolve(baseDir, cleanRelPath);
|
|
3456
|
-
if (!
|
|
3456
|
+
if (!fs9__default.default.existsSync(filePath)) {
|
|
3457
3457
|
throw new Error(`Registry file not found at ${filePath}`);
|
|
3458
3458
|
}
|
|
3459
|
-
return
|
|
3459
|
+
return fs9__default.default.promises.readFile(filePath, "utf-8");
|
|
3460
3460
|
}
|
|
3461
3461
|
async function fetchRegistryIndex(registryBase) {
|
|
3462
3462
|
const content = await fetchRegistryFile(registryBase, "index.json");
|
|
@@ -3518,26 +3518,26 @@ function findClosestMatch(target, candidates) {
|
|
|
3518
3518
|
return null;
|
|
3519
3519
|
}
|
|
3520
3520
|
function detectPackageManager(projectRoot) {
|
|
3521
|
-
if (
|
|
3522
|
-
if (
|
|
3523
|
-
if (
|
|
3521
|
+
if (fs9__default.default.existsSync(path2__default.default.join(projectRoot, "pnpm-lock.yaml"))) return "pnpm";
|
|
3522
|
+
if (fs9__default.default.existsSync(path2__default.default.join(projectRoot, "yarn.lock"))) return "yarn";
|
|
3523
|
+
if (fs9__default.default.existsSync(path2__default.default.join(projectRoot, "bun.lockb")) || fs9__default.default.existsSync(path2__default.default.join(projectRoot, "bun.lock"))) return "bun";
|
|
3524
3524
|
return "npm";
|
|
3525
3525
|
}
|
|
3526
3526
|
function getMissingNpmPackages(projectRoot, requiredPackages) {
|
|
3527
3527
|
if (!requiredPackages || requiredPackages.length === 0) return [];
|
|
3528
3528
|
const pkgJsonPath = path2__default.default.join(projectRoot, "package.json");
|
|
3529
|
-
if (!
|
|
3529
|
+
if (!fs9__default.default.existsSync(pkgJsonPath)) {
|
|
3530
3530
|
return requiredPackages;
|
|
3531
3531
|
}
|
|
3532
3532
|
try {
|
|
3533
|
-
const pkg = JSON.parse(
|
|
3533
|
+
const pkg = JSON.parse(fs9__default.default.readFileSync(pkgJsonPath, "utf-8"));
|
|
3534
3534
|
const installed = /* @__PURE__ */ new Set([
|
|
3535
3535
|
...Object.keys(pkg.dependencies || {}),
|
|
3536
3536
|
...Object.keys(pkg.devDependencies || {}),
|
|
3537
3537
|
...Object.keys(pkg.peerDependencies || {})
|
|
3538
3538
|
]);
|
|
3539
|
-
return requiredPackages.filter((
|
|
3540
|
-
const nameOnly =
|
|
3539
|
+
return requiredPackages.filter((p16) => {
|
|
3540
|
+
const nameOnly = p16.startsWith("@") ? `@${p16.slice(1).split("@")[0] || ""}` : p16.split("@")[0] || p16;
|
|
3541
3541
|
return !installed.has(nameOnly);
|
|
3542
3542
|
});
|
|
3543
3543
|
} catch {
|
|
@@ -3562,15 +3562,15 @@ function installNpmPackages(projectRoot, packages, pm) {
|
|
|
3562
3562
|
installCmd = `npm install ${packages.join(" ")}`;
|
|
3563
3563
|
break;
|
|
3564
3564
|
}
|
|
3565
|
-
|
|
3565
|
+
p3__namespace.log.info(`Installing missing dependencies with ${manager}: ${pc14__default.default.cyan(packages.join(", "))}`);
|
|
3566
3566
|
child_process.execSync(installCmd, {
|
|
3567
3567
|
cwd: projectRoot,
|
|
3568
3568
|
stdio: "inherit"
|
|
3569
3569
|
});
|
|
3570
3570
|
}
|
|
3571
3571
|
function getAllFiles(dir, baseDir = dir) {
|
|
3572
|
-
if (!
|
|
3573
|
-
const entries =
|
|
3572
|
+
if (!fs9__default.default.existsSync(dir)) return [];
|
|
3573
|
+
const entries = fs9__default.default.readdirSync(dir, { withFileTypes: true });
|
|
3574
3574
|
const files = [];
|
|
3575
3575
|
for (const entry of entries) {
|
|
3576
3576
|
const fullPath = path2__default.default.join(dir, entry.name);
|
|
@@ -3590,13 +3590,13 @@ function getAllFiles(dir, baseDir = dir) {
|
|
|
3590
3590
|
return files.sort();
|
|
3591
3591
|
}
|
|
3592
3592
|
function computeDirectoryHash(dirPath, files) {
|
|
3593
|
-
if (!
|
|
3593
|
+
if (!fs9__default.default.existsSync(dirPath)) return "";
|
|
3594
3594
|
const hash = crypto.createHash("sha256");
|
|
3595
|
-
const fileList = (
|
|
3595
|
+
const fileList = (getAllFiles(dirPath)).sort();
|
|
3596
3596
|
for (const relativePath of fileList) {
|
|
3597
3597
|
const absolutePath = path2__default.default.join(dirPath, relativePath);
|
|
3598
|
-
if (!
|
|
3599
|
-
const content =
|
|
3598
|
+
if (!fs9__default.default.existsSync(absolutePath)) continue;
|
|
3599
|
+
const content = fs9__default.default.readFileSync(absolutePath, "utf8");
|
|
3600
3600
|
const normalizedContent = content.replace(/\r\n/g, "\n");
|
|
3601
3601
|
hash.update(relativePath);
|
|
3602
3602
|
hash.update(normalizedContent);
|
|
@@ -3606,8 +3606,8 @@ function computeDirectoryHash(dirPath, files) {
|
|
|
3606
3606
|
|
|
3607
3607
|
// src/commands/import.ts
|
|
3608
3608
|
var importPrompts = {
|
|
3609
|
-
select:
|
|
3610
|
-
text:
|
|
3609
|
+
select: p3__namespace.select,
|
|
3610
|
+
text: p3__namespace.text
|
|
3611
3611
|
};
|
|
3612
3612
|
function rewriteImports(content, aliasMap) {
|
|
3613
3613
|
if (aliasMap.size === 0) return content;
|
|
@@ -3628,9 +3628,9 @@ function getModuleBaseDir(projectRoot, modType) {
|
|
|
3628
3628
|
function getExistingModuleDir(projectRoot, modType, modName) {
|
|
3629
3629
|
const folder = modType === "shared" ? "shared" : "features";
|
|
3630
3630
|
const inSrc = path2__default.default.join(projectRoot, "src", folder, modName);
|
|
3631
|
-
if (
|
|
3631
|
+
if (fs9__default.default.existsSync(inSrc)) return inSrc;
|
|
3632
3632
|
const inRoot = path2__default.default.join(projectRoot, folder, modName);
|
|
3633
|
-
if (
|
|
3633
|
+
if (fs9__default.default.existsSync(inRoot)) return inRoot;
|
|
3634
3634
|
return null;
|
|
3635
3635
|
}
|
|
3636
3636
|
function checkModuleExists(projectRoot, modType, modName) {
|
|
@@ -3648,13 +3648,13 @@ async function resolveDependency(depType, depName, aliasMap, projectRoot, flags,
|
|
|
3648
3648
|
projectRoot,
|
|
3649
3649
|
path2__default.default.join(baseDir, programmaticAlias)
|
|
3650
3650
|
);
|
|
3651
|
-
|
|
3651
|
+
p3__namespace.log.step(`Importing '${depName}' into '${displayDest}'...`);
|
|
3652
3652
|
await importModuleRecursive(depType, depName, programmaticAlias);
|
|
3653
3653
|
return;
|
|
3654
3654
|
}
|
|
3655
3655
|
const existingDir = getExistingModuleDir(projectRoot, depType, depName);
|
|
3656
3656
|
if (!existingDir) {
|
|
3657
|
-
|
|
3657
|
+
p3__namespace.log.info(` \u21B3 Resolving required ${depType} dependency: ${pc14__default.default.cyan(depName)}`);
|
|
3658
3658
|
await importModuleRecursive(depType, depName, depName);
|
|
3659
3659
|
return;
|
|
3660
3660
|
}
|
|
@@ -3671,25 +3671,25 @@ async function resolveDependency(depType, depName, aliasMap, projectRoot, flags,
|
|
|
3671
3671
|
}
|
|
3672
3672
|
const localHash = computeDirectoryHash(existingDir);
|
|
3673
3673
|
if (remoteIntegrity && localHash === remoteIntegrity) {
|
|
3674
|
-
|
|
3674
|
+
p3__namespace.log.step(`\u2713 ${depType}/${depName} is up to date (reusing existing)`);
|
|
3675
3675
|
importedModules.add(`${depType}:${depName}`);
|
|
3676
3676
|
return;
|
|
3677
3677
|
}
|
|
3678
3678
|
if (flags.overwrite) {
|
|
3679
|
-
|
|
3679
|
+
p3__namespace.log.step(`Overwriting '${depType}/${depName}' with registry version (--overwrite)...`);
|
|
3680
3680
|
const baseDir = getModuleBaseDir(projectRoot, depType);
|
|
3681
3681
|
const targetDir = path2__default.default.join(baseDir, depName);
|
|
3682
3682
|
if (!flags.dryRun) {
|
|
3683
3683
|
if (existingDir !== targetDir) {
|
|
3684
|
-
|
|
3684
|
+
fs9__default.default.rmSync(existingDir, { recursive: true, force: true });
|
|
3685
3685
|
}
|
|
3686
|
-
|
|
3686
|
+
fs9__default.default.rmSync(targetDir, { recursive: true, force: true });
|
|
3687
3687
|
}
|
|
3688
3688
|
await importModuleRecursive(depType, depName, depName, { overwrite: true });
|
|
3689
3689
|
return;
|
|
3690
3690
|
}
|
|
3691
3691
|
if (flags.yes) {
|
|
3692
|
-
|
|
3692
|
+
p3__namespace.log.info(`Using existing '${depType}/${depName}'`);
|
|
3693
3693
|
importedModules.add(`${depType}:${depName}`);
|
|
3694
3694
|
return;
|
|
3695
3695
|
}
|
|
@@ -3713,7 +3713,7 @@ async function resolveDependency(depType, depName, aliasMap, projectRoot, flags,
|
|
|
3713
3713
|
})
|
|
3714
3714
|
);
|
|
3715
3715
|
if (choice === "keep_existing" || choice === "use_existing") {
|
|
3716
|
-
|
|
3716
|
+
p3__namespace.log.step(`Skipping '${depType}/${depName}' (keeping existing)`);
|
|
3717
3717
|
importedModules.add(`${depType}:${depName}`);
|
|
3718
3718
|
return;
|
|
3719
3719
|
}
|
|
@@ -3738,19 +3738,19 @@ async function resolveDependency(depType, depName, aliasMap, projectRoot, flags,
|
|
|
3738
3738
|
aliasMap.set(`@/${folder}/${depName}/`, `@/${folder}/${newName}/`);
|
|
3739
3739
|
const baseDir = getModuleBaseDir(projectRoot, depType);
|
|
3740
3740
|
const displayDest = path2__default.default.relative(projectRoot, path2__default.default.join(baseDir, newName));
|
|
3741
|
-
|
|
3741
|
+
p3__namespace.log.step(`Importing '${depName}' into '${displayDest}'...`);
|
|
3742
3742
|
await importModuleRecursive(depType, depName, newName);
|
|
3743
3743
|
return;
|
|
3744
3744
|
}
|
|
3745
3745
|
if (choice === "overwrite") {
|
|
3746
|
-
|
|
3746
|
+
p3__namespace.log.step(`Overwriting '${depType}/${depName}' with registry version...`);
|
|
3747
3747
|
const baseDir = getModuleBaseDir(projectRoot, depType);
|
|
3748
3748
|
const targetDir = path2__default.default.join(baseDir, depName);
|
|
3749
3749
|
if (!flags.dryRun) {
|
|
3750
3750
|
if (existingDir !== targetDir) {
|
|
3751
|
-
|
|
3751
|
+
fs9__default.default.rmSync(existingDir, { recursive: true, force: true });
|
|
3752
3752
|
}
|
|
3753
|
-
|
|
3753
|
+
fs9__default.default.rmSync(targetDir, { recursive: true, force: true });
|
|
3754
3754
|
}
|
|
3755
3755
|
await importModuleRecursive(depType, depName, depName, { overwrite: true });
|
|
3756
3756
|
return;
|
|
@@ -3780,19 +3780,19 @@ async function handleImport(typeArg, nameArg, flags = {}) {
|
|
|
3780
3780
|
);
|
|
3781
3781
|
}
|
|
3782
3782
|
if (type !== "shared" && type !== "feature") {
|
|
3783
|
-
|
|
3783
|
+
p3__namespace.log.error(pc14__default.default.red(`Invalid module type: "${typeArg}". Must be "shared" or "feature".`));
|
|
3784
3784
|
process.exit(1);
|
|
3785
3785
|
}
|
|
3786
3786
|
const registryBase = getRegistryBase(projectRoot, flags.registry);
|
|
3787
|
-
const s =
|
|
3788
|
-
s.start(`Connecting to registry at ${
|
|
3787
|
+
const s = p3__namespace.spinner();
|
|
3788
|
+
s.start(`Connecting to registry at ${pc14__default.default.dim(registryBase)}...`);
|
|
3789
3789
|
let index;
|
|
3790
3790
|
try {
|
|
3791
3791
|
index = await fetchRegistryIndex(registryBase);
|
|
3792
3792
|
s.stop("Registry index loaded.");
|
|
3793
3793
|
} catch (err) {
|
|
3794
|
-
s.stop(
|
|
3795
|
-
|
|
3794
|
+
s.stop(pc14__default.default.red("Failed to load registry index."));
|
|
3795
|
+
p3__namespace.log.error(pc14__default.default.red(err.message || String(err)));
|
|
3796
3796
|
process.exit(1);
|
|
3797
3797
|
}
|
|
3798
3798
|
const availableList = type === "shared" ? index.shared : index.features;
|
|
@@ -3800,7 +3800,7 @@ async function handleImport(typeArg, nameArg, flags = {}) {
|
|
|
3800
3800
|
let name = nameArg?.trim();
|
|
3801
3801
|
if (!name) {
|
|
3802
3802
|
if (availableList.length === 0) {
|
|
3803
|
-
|
|
3803
|
+
p3__namespace.log.warn(`No ${type} modules available in the registry.`);
|
|
3804
3804
|
return;
|
|
3805
3805
|
}
|
|
3806
3806
|
name = handleCancel(
|
|
@@ -3816,9 +3816,9 @@ async function handleImport(typeArg, nameArg, flags = {}) {
|
|
|
3816
3816
|
}
|
|
3817
3817
|
if (!candidateNames.includes(name)) {
|
|
3818
3818
|
const closest = findClosestMatch(name, candidateNames);
|
|
3819
|
-
|
|
3819
|
+
p3__namespace.log.error(pc14__default.default.red(`\u274C Module '${name}' not found in the ${type} registry.`));
|
|
3820
3820
|
if (closest) {
|
|
3821
|
-
|
|
3821
|
+
p3__namespace.log.info(pc14__default.default.yellow(`Did you mean '${pc14__default.default.cyan(closest)}'?`));
|
|
3822
3822
|
}
|
|
3823
3823
|
process.exit(1);
|
|
3824
3824
|
}
|
|
@@ -3828,14 +3828,14 @@ async function handleImport(typeArg, nameArg, flags = {}) {
|
|
|
3828
3828
|
async function importModuleRecursive(modType, registryName, targetName = registryName, options) {
|
|
3829
3829
|
const modKey = `${modType}:${targetName}`;
|
|
3830
3830
|
if (importedModules.has(modKey)) return;
|
|
3831
|
-
|
|
3832
|
-
`Importing ${modType}: ${
|
|
3831
|
+
p3__namespace.log.step(
|
|
3832
|
+
`Importing ${modType}: ${pc14__default.default.cyan(targetName)}${targetName !== registryName ? pc14__default.default.dim(` (from ${registryName})`) : ""}...`
|
|
3833
3833
|
);
|
|
3834
3834
|
let manifest;
|
|
3835
3835
|
try {
|
|
3836
3836
|
manifest = await fetchModuleManifest(registryBase, modType, registryName);
|
|
3837
3837
|
} catch (err) {
|
|
3838
|
-
|
|
3838
|
+
p3__namespace.log.error(pc14__default.default.red(`Failed to fetch manifest for ${modType} '${registryName}': ${err.message}`));
|
|
3839
3839
|
process.exit(1);
|
|
3840
3840
|
}
|
|
3841
3841
|
const aliasMap = /* @__PURE__ */ new Map();
|
|
@@ -3881,21 +3881,21 @@ async function handleImport(typeArg, nameArg, flags = {}) {
|
|
|
3881
3881
|
if (file === "registry.json") continue;
|
|
3882
3882
|
const remoteFilePath = `${folder}/${registryName}/${file}`;
|
|
3883
3883
|
const localFilePath = path2__default.default.join(targetDir, file);
|
|
3884
|
-
if (
|
|
3885
|
-
|
|
3886
|
-
` \u21B3 Skipping existing file: ${
|
|
3884
|
+
if (fs9__default.default.existsSync(localFilePath) && !isOverwrite) {
|
|
3885
|
+
p3__namespace.log.warn(
|
|
3886
|
+
` \u21B3 Skipping existing file: ${pc14__default.default.dim(path2__default.default.relative(projectRoot, localFilePath))} (use --overwrite to replace)`
|
|
3887
3887
|
);
|
|
3888
3888
|
continue;
|
|
3889
3889
|
}
|
|
3890
3890
|
let content = await fetchRegistryFile(registryBase, remoteFilePath);
|
|
3891
3891
|
content = rewriteImports(content, aliasMap);
|
|
3892
3892
|
if (!flags.dryRun) {
|
|
3893
|
-
|
|
3894
|
-
|
|
3893
|
+
fs9__default.default.mkdirSync(path2__default.default.dirname(localFilePath), { recursive: true });
|
|
3894
|
+
fs9__default.default.writeFileSync(localFilePath, content, "utf-8");
|
|
3895
3895
|
}
|
|
3896
3896
|
const displayPath = path2__default.default.relative(projectRoot, localFilePath);
|
|
3897
3897
|
totalWrittenFiles.push(displayPath);
|
|
3898
|
-
|
|
3898
|
+
p3__namespace.log.message(` ${pc14__default.default.green("+")} ${displayPath}`);
|
|
3899
3899
|
}
|
|
3900
3900
|
importedModules.add(modKey);
|
|
3901
3901
|
}
|
|
@@ -3903,564 +3903,35 @@ async function handleImport(typeArg, nameArg, flags = {}) {
|
|
|
3903
3903
|
const missingNpm = getMissingNpmPackages(projectRoot, Array.from(requiredNpmPackages));
|
|
3904
3904
|
if (missingNpm.length > 0) {
|
|
3905
3905
|
if (flags.skipInstall || flags.dryRun) {
|
|
3906
|
-
|
|
3906
|
+
p3__namespace.log.info(`Required npm dependencies to install: ${pc14__default.default.cyan(missingNpm.join(", "))}`);
|
|
3907
3907
|
} else {
|
|
3908
3908
|
try {
|
|
3909
3909
|
installNpmPackages(projectRoot, missingNpm);
|
|
3910
3910
|
} catch (err) {
|
|
3911
|
-
|
|
3911
|
+
p3__namespace.log.warn(`Could not automatically install packages (${err.message}). Please run: npm install ${missingNpm.join(" ")}`);
|
|
3912
3912
|
}
|
|
3913
3913
|
}
|
|
3914
3914
|
}
|
|
3915
3915
|
if (flags.dryRun) {
|
|
3916
|
-
|
|
3916
|
+
p3__namespace.log.info(pc14__default.default.yellow("Dry run complete: No files were written to disk."));
|
|
3917
3917
|
} else {
|
|
3918
3918
|
const baseDir = getModuleBaseDir(projectRoot, type);
|
|
3919
3919
|
const displayTarget = path2__default.default.relative(projectRoot, path2__default.default.join(baseDir, name));
|
|
3920
|
-
|
|
3921
|
-
|
|
3920
|
+
p3__namespace.log.success(
|
|
3921
|
+
pc14__default.default.green(
|
|
3922
3922
|
`Successfully imported ${type} '${name}' (${totalWrittenFiles.length} file${totalWrittenFiles.length === 1 ? "" : "s"} placed in ${displayTarget})`
|
|
3923
3923
|
)
|
|
3924
3924
|
);
|
|
3925
3925
|
}
|
|
3926
3926
|
}
|
|
3927
|
-
function loadMasterIndex(projectRoot) {
|
|
3928
|
-
const indexPath = path2__default.default.join(projectRoot, "index.json");
|
|
3929
|
-
if (!fs12__default.default.existsSync(indexPath)) {
|
|
3930
|
-
const initialIndex = { shared: [], features: [] };
|
|
3931
|
-
fs12__default.default.writeFileSync(indexPath, JSON.stringify(initialIndex, null, 2) + "\n", "utf-8");
|
|
3932
|
-
return initialIndex;
|
|
3933
|
-
}
|
|
3934
|
-
return JSON.parse(fs12__default.default.readFileSync(indexPath, "utf-8"));
|
|
3935
|
-
}
|
|
3936
|
-
function saveMasterIndex(projectRoot, index) {
|
|
3937
|
-
const indexPath = path2__default.default.join(projectRoot, "index.json");
|
|
3938
|
-
index.shared.sort((a, b) => a.name.localeCompare(b.name));
|
|
3939
|
-
index.features.sort((a, b) => a.name.localeCompare(b.name));
|
|
3940
|
-
fs12__default.default.writeFileSync(indexPath, JSON.stringify(index, null, 2) + "\n", "utf-8");
|
|
3941
|
-
}
|
|
3942
|
-
function discoverDiskModules(projectRoot) {
|
|
3943
|
-
const results = [];
|
|
3944
|
-
const sharedDir = resolveSharedDir(projectRoot);
|
|
3945
|
-
if (fs12__default.default.existsSync(sharedDir)) {
|
|
3946
|
-
const entries = fs12__default.default.readdirSync(sharedDir, { withFileTypes: true });
|
|
3947
|
-
for (const entry of entries) {
|
|
3948
|
-
if (entry.isDirectory() && !entry.name.startsWith(".")) {
|
|
3949
|
-
results.push({ name: entry.name, type: "shared", dir: path2__default.default.join(sharedDir, entry.name) });
|
|
3950
|
-
}
|
|
3951
|
-
}
|
|
3952
|
-
}
|
|
3953
|
-
const featuresDir = resolveFeaturesDir(projectRoot);
|
|
3954
|
-
if (fs12__default.default.existsSync(featuresDir)) {
|
|
3955
|
-
const entries = fs12__default.default.readdirSync(featuresDir, { withFileTypes: true });
|
|
3956
|
-
for (const entry of entries) {
|
|
3957
|
-
if (entry.isDirectory() && !entry.name.startsWith(".")) {
|
|
3958
|
-
results.push({ name: entry.name, type: "feature", dir: path2__default.default.join(featuresDir, entry.name) });
|
|
3959
|
-
}
|
|
3960
|
-
}
|
|
3961
|
-
}
|
|
3962
|
-
return results;
|
|
3963
|
-
}
|
|
3964
|
-
function checkGitStatusForDir(projectRoot, dirPath) {
|
|
3965
|
-
try {
|
|
3966
|
-
const relPath = path2__default.default.relative(projectRoot, dirPath);
|
|
3967
|
-
const output = child_process.execSync(`git status --porcelain -- "${relPath}"`, {
|
|
3968
|
-
cwd: projectRoot,
|
|
3969
|
-
stdio: ["ignore", "pipe", "ignore"],
|
|
3970
|
-
encoding: "utf-8"
|
|
3971
|
-
}).trim();
|
|
3972
|
-
if (!output) {
|
|
3973
|
-
return { hasChanges: false, filesCount: 0 };
|
|
3974
|
-
}
|
|
3975
|
-
const lines = output.split("\n").filter((l) => l.trim().length > 0);
|
|
3976
|
-
return { hasChanges: true, filesCount: lines.length };
|
|
3977
|
-
} catch {
|
|
3978
|
-
return { hasChanges: false, filesCount: 0 };
|
|
3979
|
-
}
|
|
3980
|
-
}
|
|
3981
|
-
function getRegistryDiff(projectRoot) {
|
|
3982
|
-
const index = loadMasterIndex(projectRoot);
|
|
3983
|
-
const diskModules = discoverDiskModules(projectRoot);
|
|
3984
|
-
const diskMap = /* @__PURE__ */ new Map();
|
|
3985
|
-
for (const mod of diskModules) {
|
|
3986
|
-
diskMap.set(`${mod.type}:${mod.name}`, mod);
|
|
3987
|
-
}
|
|
3988
|
-
const allKeys = /* @__PURE__ */ new Set();
|
|
3989
|
-
for (const item of index.shared) {
|
|
3990
|
-
allKeys.add(`shared:${item.name}`);
|
|
3991
|
-
}
|
|
3992
|
-
for (const item of index.features) {
|
|
3993
|
-
allKeys.add(`feature:${item.name}`);
|
|
3994
|
-
}
|
|
3995
|
-
for (const mod of diskModules) {
|
|
3996
|
-
allKeys.add(`${mod.type}:${mod.name}`);
|
|
3997
|
-
}
|
|
3998
|
-
const statuses = [];
|
|
3999
|
-
for (const key of allKeys) {
|
|
4000
|
-
const [typeStr, name] = key.split(":");
|
|
4001
|
-
const type = typeStr;
|
|
4002
|
-
const registeredEntry = (type === "shared" ? index.shared : index.features).find(
|
|
4003
|
-
(e) => e.name === name
|
|
4004
|
-
);
|
|
4005
|
-
const isRegistered = Boolean(registeredEntry);
|
|
4006
|
-
const diskInfo = diskMap.get(key);
|
|
4007
|
-
const existsOnDisk = Boolean(diskInfo && fs12__default.default.existsSync(diskInfo.dir));
|
|
4008
|
-
let hasUncommittedGitChanges = false;
|
|
4009
|
-
let uncommittedFilesCount = 0;
|
|
4010
|
-
let hasIntegrityDrift = false;
|
|
4011
|
-
let localIntegrity;
|
|
4012
|
-
if (existsOnDisk && diskInfo) {
|
|
4013
|
-
const git = checkGitStatusForDir(projectRoot, diskInfo.dir);
|
|
4014
|
-
hasUncommittedGitChanges = git.hasChanges;
|
|
4015
|
-
uncommittedFilesCount = git.filesCount;
|
|
4016
|
-
localIntegrity = computeDirectoryHash(diskInfo.dir);
|
|
4017
|
-
if (isRegistered && registeredEntry?.integrity) {
|
|
4018
|
-
hasIntegrityDrift = localIntegrity !== registeredEntry.integrity;
|
|
4019
|
-
}
|
|
4020
|
-
}
|
|
4021
|
-
statuses.push({
|
|
4022
|
-
name,
|
|
4023
|
-
type,
|
|
4024
|
-
isRegistered,
|
|
4025
|
-
existsOnDisk,
|
|
4026
|
-
hasUncommittedGitChanges,
|
|
4027
|
-
uncommittedFilesCount,
|
|
4028
|
-
hasIntegrityDrift,
|
|
4029
|
-
localIntegrity,
|
|
4030
|
-
registeredIntegrity: registeredEntry?.integrity
|
|
4031
|
-
});
|
|
4032
|
-
}
|
|
4033
|
-
return statuses.sort((a, b) => a.type.localeCompare(b.type) || a.name.localeCompare(b.name));
|
|
4034
|
-
}
|
|
4035
|
-
async function registerModule(typeArg, nameArg, flags = {}) {
|
|
4036
|
-
const projectRoot = findProjectRoot();
|
|
4037
|
-
const index = loadMasterIndex(projectRoot);
|
|
4038
|
-
let type = typeArg?.trim();
|
|
4039
|
-
if (!type) {
|
|
4040
|
-
type = handleCancel(
|
|
4041
|
-
await p15__namespace.select({
|
|
4042
|
-
message: "Module type to register:",
|
|
4043
|
-
options: [
|
|
4044
|
-
{ value: "feature", label: "Feature" },
|
|
4045
|
-
{ value: "shared", label: "Shared Module" }
|
|
4046
|
-
]
|
|
4047
|
-
})
|
|
4048
|
-
);
|
|
4049
|
-
}
|
|
4050
|
-
const diskModules = discoverDiskModules(projectRoot).filter((m) => m.type === type);
|
|
4051
|
-
const registeredNames = new Set((type === "shared" ? index.shared : index.features).map((m) => m.name));
|
|
4052
|
-
const unregistered = diskModules.filter((m) => !registeredNames.has(m.name));
|
|
4053
|
-
let name = nameArg?.trim();
|
|
4054
|
-
if (!name) {
|
|
4055
|
-
if (unregistered.length > 0) {
|
|
4056
|
-
const opts = unregistered.map((m) => ({ value: m.name, label: m.name, hint: "unregistered on disk" }));
|
|
4057
|
-
opts.push({ value: "__custom__", label: "\u270F\uFE0F Enter custom name...", hint: "" });
|
|
4058
|
-
const choice = handleCancel(
|
|
4059
|
-
await p15__namespace.select({
|
|
4060
|
-
message: `Select a ${type} to register:`,
|
|
4061
|
-
options: opts
|
|
4062
|
-
})
|
|
4063
|
-
);
|
|
4064
|
-
if (choice === "__custom__") {
|
|
4065
|
-
name = handleCancel(
|
|
4066
|
-
await p15__namespace.text({
|
|
4067
|
-
message: `Enter ${type} name:`,
|
|
4068
|
-
validate: (v) => v && v.trim() ? void 0 : "Name cannot be empty"
|
|
4069
|
-
})
|
|
4070
|
-
).trim();
|
|
4071
|
-
} else {
|
|
4072
|
-
name = choice;
|
|
4073
|
-
}
|
|
4074
|
-
} else {
|
|
4075
|
-
name = handleCancel(
|
|
4076
|
-
await p15__namespace.text({
|
|
4077
|
-
message: `Enter ${type} name to register:`,
|
|
4078
|
-
validate: (v) => v && v.trim() ? void 0 : "Name cannot be empty"
|
|
4079
|
-
})
|
|
4080
|
-
).trim();
|
|
4081
|
-
}
|
|
4082
|
-
}
|
|
4083
|
-
const folder = type === "shared" ? resolveSharedDir(projectRoot) : resolveFeaturesDir(projectRoot);
|
|
4084
|
-
const modDir = path2__default.default.join(folder, name);
|
|
4085
|
-
if (!fs12__default.default.existsSync(modDir)) {
|
|
4086
|
-
p15__namespace.log.error(pc15__default.default.red(`Module directory does not exist: ${path2__default.default.relative(projectRoot, modDir)}`));
|
|
4087
|
-
process.exit(1);
|
|
4088
|
-
}
|
|
4089
|
-
const files = getAllFiles(modDir);
|
|
4090
|
-
const integrity = computeDirectoryHash(modDir, files);
|
|
4091
|
-
const manifestPath = path2__default.default.join(modDir, "registry.json");
|
|
4092
|
-
let manifest;
|
|
4093
|
-
if (fs12__default.default.existsSync(manifestPath)) {
|
|
4094
|
-
manifest = JSON.parse(fs12__default.default.readFileSync(manifestPath, "utf-8"));
|
|
4095
|
-
} else {
|
|
4096
|
-
manifest = {
|
|
4097
|
-
name,
|
|
4098
|
-
type,
|
|
4099
|
-
description: `${name} ${type} module`,
|
|
4100
|
-
version: "1.0.0",
|
|
4101
|
-
dependencies: {
|
|
4102
|
-
npm: [],
|
|
4103
|
-
shared: [],
|
|
4104
|
-
features: []
|
|
4105
|
-
},
|
|
4106
|
-
files: []
|
|
4107
|
-
};
|
|
4108
|
-
}
|
|
4109
|
-
manifest.name = name;
|
|
4110
|
-
manifest.type = type;
|
|
4111
|
-
manifest.files = files;
|
|
4112
|
-
manifest.integrity = integrity;
|
|
4113
|
-
fs12__default.default.writeFileSync(manifestPath, JSON.stringify(manifest, null, 2) + "\n", "utf-8");
|
|
4114
|
-
const targetList = type === "shared" ? index.shared : index.features;
|
|
4115
|
-
const existingIdx = targetList.findIndex((item) => item.name === name);
|
|
4116
|
-
if (existingIdx >= 0) {
|
|
4117
|
-
targetList[existingIdx] = {
|
|
4118
|
-
name,
|
|
4119
|
-
description: manifest.description,
|
|
4120
|
-
version: manifest.version,
|
|
4121
|
-
integrity
|
|
4122
|
-
};
|
|
4123
|
-
} else {
|
|
4124
|
-
targetList.push({
|
|
4125
|
-
name,
|
|
4126
|
-
description: manifest.description,
|
|
4127
|
-
version: manifest.version,
|
|
4128
|
-
integrity
|
|
4129
|
-
});
|
|
4130
|
-
}
|
|
4131
|
-
saveMasterIndex(projectRoot, index);
|
|
4132
|
-
p15__namespace.log.success(
|
|
4133
|
-
pc15__default.default.green(
|
|
4134
|
-
`\u2713 Module '${type}/${name}' registered in index.json (${files.length} files, ${integrity.slice(0, 18)}...)`
|
|
4135
|
-
)
|
|
4136
|
-
);
|
|
4137
|
-
}
|
|
4138
|
-
async function commitModule(typeArg, nameArg, flags = {}) {
|
|
4139
|
-
const projectRoot = findProjectRoot();
|
|
4140
|
-
let type = typeArg?.trim();
|
|
4141
|
-
if (!type) {
|
|
4142
|
-
type = handleCancel(
|
|
4143
|
-
await p15__namespace.select({
|
|
4144
|
-
message: "Module type to commit:",
|
|
4145
|
-
options: [
|
|
4146
|
-
{ value: "feature", label: "Feature" },
|
|
4147
|
-
{ value: "shared", label: "Shared Module" }
|
|
4148
|
-
]
|
|
4149
|
-
})
|
|
4150
|
-
);
|
|
4151
|
-
}
|
|
4152
|
-
let name = nameArg?.trim();
|
|
4153
|
-
if (!name) {
|
|
4154
|
-
const diskModules = discoverDiskModules(projectRoot).filter((m) => m.type === type);
|
|
4155
|
-
const opts = diskModules.map((m) => {
|
|
4156
|
-
const git = checkGitStatusForDir(projectRoot, m.dir);
|
|
4157
|
-
return {
|
|
4158
|
-
value: m.name,
|
|
4159
|
-
label: m.name,
|
|
4160
|
-
hint: git.hasChanges ? `${git.filesCount} uncommitted files` : "clean working tree"
|
|
4161
|
-
};
|
|
4162
|
-
});
|
|
4163
|
-
name = handleCancel(
|
|
4164
|
-
await p15__namespace.select({
|
|
4165
|
-
message: `Select ${type} to commit:`,
|
|
4166
|
-
options: opts
|
|
4167
|
-
})
|
|
4168
|
-
);
|
|
4169
|
-
}
|
|
4170
|
-
const folder = type === "shared" ? resolveSharedDir(projectRoot) : resolveFeaturesDir(projectRoot);
|
|
4171
|
-
const modDir = path2__default.default.join(folder, name);
|
|
4172
|
-
if (!fs12__default.default.existsSync(modDir)) {
|
|
4173
|
-
p15__namespace.log.error(pc15__default.default.red(`Module directory does not exist: ${path2__default.default.relative(projectRoot, modDir)}`));
|
|
4174
|
-
process.exit(1);
|
|
4175
|
-
}
|
|
4176
|
-
const relModDir = path2__default.default.relative(projectRoot, modDir);
|
|
4177
|
-
const gitStatus = checkGitStatusForDir(projectRoot, modDir);
|
|
4178
|
-
if (!gitStatus.hasChanges) {
|
|
4179
|
-
p15__namespace.log.warn(pc15__default.default.yellow(`No uncommitted git changes found in '${type}/${name}'.`));
|
|
4180
|
-
return;
|
|
4181
|
-
}
|
|
4182
|
-
let message = flags.message?.trim();
|
|
4183
|
-
if (!message) {
|
|
4184
|
-
message = handleCancel(
|
|
4185
|
-
await p15__namespace.text({
|
|
4186
|
-
message: `Commit message for ${type}/${name}:`,
|
|
4187
|
-
placeholder: `e.g. feat(${name}): update use cases and dependencies`,
|
|
4188
|
-
validate: (v) => v && v.trim() ? void 0 : "Commit message cannot be empty"
|
|
4189
|
-
})
|
|
4190
|
-
).trim();
|
|
4191
|
-
}
|
|
4192
|
-
const s = p15__namespace.spinner();
|
|
4193
|
-
s.start(`Committing '${type}/${name}' to git repository...`);
|
|
4194
|
-
try {
|
|
4195
|
-
child_process.execSync(`git add "${relModDir}"`, { cwd: projectRoot, stdio: ["ignore", "pipe", "pipe"] });
|
|
4196
|
-
child_process.execSync(`git commit -m "${message.replace(/"/g, '\\"')}" -- "${relModDir}"`, {
|
|
4197
|
-
cwd: projectRoot,
|
|
4198
|
-
stdio: ["ignore", "pipe", "pipe"]
|
|
4199
|
-
});
|
|
4200
|
-
s.stop(`Changes for '${type}/${name}' committed to git.`);
|
|
4201
|
-
p15__namespace.log.success(pc15__default.default.green(`\u2713 Committed '${type}/${name}': "${message}"`));
|
|
4202
|
-
} catch (err) {
|
|
4203
|
-
s.stop(pc15__default.default.red("Git commit failed."));
|
|
4204
|
-
p15__namespace.log.error(pc15__default.default.red(err.message || String(err)));
|
|
4205
|
-
process.exit(1);
|
|
4206
|
-
}
|
|
4207
|
-
}
|
|
4208
|
-
async function registerModuleChanges(typeArg, nameArg, flags = {}) {
|
|
4209
|
-
const projectRoot = findProjectRoot();
|
|
4210
|
-
const index = loadMasterIndex(projectRoot);
|
|
4211
|
-
let type = typeArg?.trim();
|
|
4212
|
-
if (!type) {
|
|
4213
|
-
type = handleCancel(
|
|
4214
|
-
await p15__namespace.select({
|
|
4215
|
-
message: "Module type to update:",
|
|
4216
|
-
options: [
|
|
4217
|
-
{ value: "feature", label: "Feature" },
|
|
4218
|
-
{ value: "shared", label: "Shared Module" }
|
|
4219
|
-
]
|
|
4220
|
-
})
|
|
4221
|
-
);
|
|
4222
|
-
}
|
|
4223
|
-
let name = nameArg?.trim();
|
|
4224
|
-
if (!name) {
|
|
4225
|
-
const diskModules = discoverDiskModules(projectRoot).filter((m) => m.type === type);
|
|
4226
|
-
const diffs = getRegistryDiff(projectRoot).filter((d) => d.type === type && d.isRegistered);
|
|
4227
|
-
const opts = diskModules.map((m) => {
|
|
4228
|
-
const d = diffs.find((item) => item.name === m.name);
|
|
4229
|
-
return {
|
|
4230
|
-
value: m.name,
|
|
4231
|
-
label: m.name,
|
|
4232
|
-
hint: d?.hasIntegrityDrift ? "drift detected (needs register)" : "up to date"
|
|
4233
|
-
};
|
|
4234
|
-
});
|
|
4235
|
-
name = handleCancel(
|
|
4236
|
-
await p15__namespace.select({
|
|
4237
|
-
message: `Select ${type} to register changes:`,
|
|
4238
|
-
options: opts
|
|
4239
|
-
})
|
|
4240
|
-
);
|
|
4241
|
-
}
|
|
4242
|
-
const folder = type === "shared" ? resolveSharedDir(projectRoot) : resolveFeaturesDir(projectRoot);
|
|
4243
|
-
const modDir = path2__default.default.join(folder, name);
|
|
4244
|
-
if (!fs12__default.default.existsSync(modDir)) {
|
|
4245
|
-
p15__namespace.log.error(pc15__default.default.red(`Module directory does not exist: ${path2__default.default.relative(projectRoot, modDir)}`));
|
|
4246
|
-
process.exit(1);
|
|
4247
|
-
}
|
|
4248
|
-
const files = getAllFiles(modDir);
|
|
4249
|
-
const integrity = computeDirectoryHash(modDir, files);
|
|
4250
|
-
const manifestPath = path2__default.default.join(modDir, "registry.json");
|
|
4251
|
-
let manifest;
|
|
4252
|
-
if (fs12__default.default.existsSync(manifestPath)) {
|
|
4253
|
-
manifest = JSON.parse(fs12__default.default.readFileSync(manifestPath, "utf-8"));
|
|
4254
|
-
} else {
|
|
4255
|
-
manifest = {
|
|
4256
|
-
name,
|
|
4257
|
-
type,
|
|
4258
|
-
description: `${name} ${type} module`,
|
|
4259
|
-
version: "1.0.0",
|
|
4260
|
-
dependencies: { npm: [], shared: [], features: [] },
|
|
4261
|
-
files: []
|
|
4262
|
-
};
|
|
4263
|
-
}
|
|
4264
|
-
manifest.files = files;
|
|
4265
|
-
manifest.integrity = integrity;
|
|
4266
|
-
if (flags.version) {
|
|
4267
|
-
manifest.version = flags.version;
|
|
4268
|
-
}
|
|
4269
|
-
fs12__default.default.writeFileSync(manifestPath, JSON.stringify(manifest, null, 2) + "\n", "utf-8");
|
|
4270
|
-
const targetList = type === "shared" ? index.shared : index.features;
|
|
4271
|
-
const existingIdx = targetList.findIndex((item) => item.name === name);
|
|
4272
|
-
if (existingIdx >= 0) {
|
|
4273
|
-
targetList[existingIdx] = {
|
|
4274
|
-
name,
|
|
4275
|
-
description: manifest.description,
|
|
4276
|
-
version: manifest.version,
|
|
4277
|
-
integrity
|
|
4278
|
-
};
|
|
4279
|
-
} else {
|
|
4280
|
-
targetList.push({
|
|
4281
|
-
name,
|
|
4282
|
-
description: manifest.description,
|
|
4283
|
-
version: manifest.version,
|
|
4284
|
-
integrity
|
|
4285
|
-
});
|
|
4286
|
-
}
|
|
4287
|
-
saveMasterIndex(projectRoot, index);
|
|
4288
|
-
p15__namespace.log.success(
|
|
4289
|
-
pc15__default.default.green(`\u2713 Registered changes for '${type}/${name}' (new integrity: ${integrity.slice(0, 18)}...)`)
|
|
4290
|
-
);
|
|
4291
|
-
}
|
|
4292
|
-
async function unregisterModule(typeArg, nameArg, flags = {}) {
|
|
4293
|
-
const projectRoot = findProjectRoot();
|
|
4294
|
-
const index = loadMasterIndex(projectRoot);
|
|
4295
|
-
let type = typeArg?.trim();
|
|
4296
|
-
if (!type) {
|
|
4297
|
-
type = handleCancel(
|
|
4298
|
-
await p15__namespace.select({
|
|
4299
|
-
message: "Module type to unregister:",
|
|
4300
|
-
options: [
|
|
4301
|
-
{ value: "feature", label: "Feature" },
|
|
4302
|
-
{ value: "shared", label: "Shared Module" }
|
|
4303
|
-
]
|
|
4304
|
-
})
|
|
4305
|
-
);
|
|
4306
|
-
}
|
|
4307
|
-
const registeredList = type === "shared" ? index.shared : index.features;
|
|
4308
|
-
if (registeredList.length === 0) {
|
|
4309
|
-
p15__namespace.log.warn(`No registered ${type} modules found in index.json.`);
|
|
4310
|
-
return;
|
|
4311
|
-
}
|
|
4312
|
-
let name = nameArg?.trim();
|
|
4313
|
-
if (!name) {
|
|
4314
|
-
name = handleCancel(
|
|
4315
|
-
await p15__namespace.select({
|
|
4316
|
-
message: `Select ${type} to unregister from index.json:`,
|
|
4317
|
-
options: registeredList.map((item) => ({
|
|
4318
|
-
value: item.name,
|
|
4319
|
-
label: item.name,
|
|
4320
|
-
hint: item.description
|
|
4321
|
-
}))
|
|
4322
|
-
})
|
|
4323
|
-
);
|
|
4324
|
-
}
|
|
4325
|
-
if (type === "shared") {
|
|
4326
|
-
index.shared = index.shared.filter((item) => item.name !== name);
|
|
4327
|
-
} else {
|
|
4328
|
-
index.features = index.features.filter((item) => item.name !== name);
|
|
4329
|
-
}
|
|
4330
|
-
saveMasterIndex(projectRoot, index);
|
|
4331
|
-
p15__namespace.log.success(
|
|
4332
|
-
pc15__default.default.green(
|
|
4333
|
-
`\u2713 Unregistered module '${type}/${name}' from index.json (source code retained on disk in ${type === "shared" ? "shared" : "features"}/${name})`
|
|
4334
|
-
)
|
|
4335
|
-
);
|
|
4336
|
-
}
|
|
4337
|
-
function diffRegistry(flags = {}) {
|
|
4338
|
-
const projectRoot = findProjectRoot();
|
|
4339
|
-
const diffs = getRegistryDiff(projectRoot);
|
|
4340
|
-
p15__namespace.log.step(pc15__default.default.bold("\u{1F4CB} Mason Registry Diff & Status Summary"));
|
|
4341
|
-
const unregistered = diffs.filter((d) => d.existsOnDisk && !d.isRegistered);
|
|
4342
|
-
const uncommitted = diffs.filter((d) => d.existsOnDisk && d.hasUncommittedGitChanges);
|
|
4343
|
-
const committedDrift = diffs.filter(
|
|
4344
|
-
(d) => d.existsOnDisk && d.isRegistered && !d.hasUncommittedGitChanges && d.hasIntegrityDrift
|
|
4345
|
-
);
|
|
4346
|
-
const upToDate = diffs.filter(
|
|
4347
|
-
(d) => d.existsOnDisk && d.isRegistered && !d.hasUncommittedGitChanges && !d.hasIntegrityDrift
|
|
4348
|
-
);
|
|
4349
|
-
const missing = diffs.filter((d) => !d.existsOnDisk && d.isRegistered);
|
|
4350
|
-
if (unregistered.length > 0) {
|
|
4351
|
-
p15__namespace.log.message(pc15__default.default.yellow(`
|
|
4352
|
-
\u{1F4E6} Unregistered Modules (${unregistered.length}):`));
|
|
4353
|
-
for (const mod of unregistered) {
|
|
4354
|
-
p15__namespace.log.message(` ${pc15__default.default.red("\u25CF")} ${pc15__default.default.bold(`${mod.type}/${mod.name}`)} ${pc15__default.default.dim("(not registered in index.json)")}`);
|
|
4355
|
-
}
|
|
4356
|
-
}
|
|
4357
|
-
if (uncommitted.length > 0) {
|
|
4358
|
-
p15__namespace.log.message(pc15__default.default.yellow(`
|
|
4359
|
-
\u{1F4BE} Uncommitted Changes in Git (${uncommitted.length}):`));
|
|
4360
|
-
for (const mod of uncommitted) {
|
|
4361
|
-
p15__namespace.log.message(
|
|
4362
|
-
` ${pc15__default.default.yellow("\u25B2")} ${pc15__default.default.bold(`${mod.type}/${mod.name}`)} ${pc15__default.default.dim(`(${mod.uncommittedFilesCount} modified/untracked files)`)}`
|
|
4363
|
-
);
|
|
4364
|
-
}
|
|
4365
|
-
}
|
|
4366
|
-
if (committedDrift.length > 0) {
|
|
4367
|
-
p15__namespace.log.message(pc15__default.default.cyan(`
|
|
4368
|
-
\u{1F680} Committed But Unregistered Changes (${committedDrift.length}):`));
|
|
4369
|
-
for (const mod of committedDrift) {
|
|
4370
|
-
p15__namespace.log.message(
|
|
4371
|
-
` ${pc15__default.default.cyan("\u25C6")} ${pc15__default.default.bold(`${mod.type}/${mod.name}`)} ${pc15__default.default.dim(
|
|
4372
|
-
`local: ${mod.localIntegrity?.slice(0, 16)}... != registered: ${mod.registeredIntegrity?.slice(0, 16)}...`
|
|
4373
|
-
)}`
|
|
4374
|
-
);
|
|
4375
|
-
}
|
|
4376
|
-
}
|
|
4377
|
-
if (missing.length > 0) {
|
|
4378
|
-
p15__namespace.log.message(pc15__default.default.red(`
|
|
4379
|
-
\u26A0\uFE0F Missing on Disk (${missing.length}):`));
|
|
4380
|
-
for (const mod of missing) {
|
|
4381
|
-
p15__namespace.log.message(` ${pc15__default.default.red("\u2715")} ${pc15__default.default.bold(`${mod.type}/${mod.name}`)} ${pc15__default.default.dim("(in index.json, but folder missing)")}`);
|
|
4382
|
-
}
|
|
4383
|
-
}
|
|
4384
|
-
if (upToDate.length > 0) {
|
|
4385
|
-
p15__namespace.log.message(pc15__default.default.green(`
|
|
4386
|
-
\u2713 Up to Date & Registered (${upToDate.length}):`));
|
|
4387
|
-
for (const mod of upToDate) {
|
|
4388
|
-
p15__namespace.log.message(` ${pc15__default.default.green("\u2714")} ${mod.type}/${mod.name} ${pc15__default.default.dim(`(${mod.registeredIntegrity?.slice(0, 18)}...)`)}`);
|
|
4389
|
-
}
|
|
4390
|
-
}
|
|
4391
|
-
p15__namespace.log.message("");
|
|
4392
|
-
}
|
|
4393
|
-
async function handleRegistry(actionArg, typeArg, nameArg, flags = {}) {
|
|
4394
|
-
let action = actionArg?.trim().toLowerCase();
|
|
4395
|
-
if (!action) {
|
|
4396
|
-
action = handleCancel(
|
|
4397
|
-
await p15__namespace.select({
|
|
4398
|
-
message: "\u{1F3DB}\uFE0F Mason Registry: What would you like to do?",
|
|
4399
|
-
options: [
|
|
4400
|
-
{
|
|
4401
|
-
value: "diff",
|
|
4402
|
-
label: "Inspect Diff & Status",
|
|
4403
|
-
hint: "Summary of unregistered, uncommitted, and drifted modules"
|
|
4404
|
-
},
|
|
4405
|
-
{
|
|
4406
|
-
value: "register",
|
|
4407
|
-
label: "Register Module",
|
|
4408
|
-
hint: "Add an existing module to index.json with integrity checksum"
|
|
4409
|
-
},
|
|
4410
|
-
{
|
|
4411
|
-
value: "commit",
|
|
4412
|
-
label: "Commit Changes",
|
|
4413
|
-
hint: "Commit a module's working changes to git in the background"
|
|
4414
|
-
},
|
|
4415
|
-
{
|
|
4416
|
-
value: "register-changes",
|
|
4417
|
-
label: "Register Changes",
|
|
4418
|
-
hint: "Update index.json & registry.json with latest checksums"
|
|
4419
|
-
},
|
|
4420
|
-
{
|
|
4421
|
-
value: "unregister",
|
|
4422
|
-
label: "Unregister Module",
|
|
4423
|
-
hint: "Remove module from index.json (source code stays on disk)"
|
|
4424
|
-
}
|
|
4425
|
-
]
|
|
4426
|
-
})
|
|
4427
|
-
);
|
|
4428
|
-
}
|
|
4429
|
-
switch (action) {
|
|
4430
|
-
case "diff":
|
|
4431
|
-
case "status":
|
|
4432
|
-
diffRegistry(flags);
|
|
4433
|
-
break;
|
|
4434
|
-
case "register":
|
|
4435
|
-
await registerModule(typeArg, nameArg, flags);
|
|
4436
|
-
break;
|
|
4437
|
-
case "commit":
|
|
4438
|
-
await commitModule(typeArg, nameArg, flags);
|
|
4439
|
-
break;
|
|
4440
|
-
case "register-changes":
|
|
4441
|
-
case "update":
|
|
4442
|
-
await registerModuleChanges(typeArg, nameArg, flags);
|
|
4443
|
-
break;
|
|
4444
|
-
case "unregister":
|
|
4445
|
-
await unregisterModule(typeArg, nameArg, flags);
|
|
4446
|
-
break;
|
|
4447
|
-
default:
|
|
4448
|
-
p15__namespace.log.error(
|
|
4449
|
-
pc15__default.default.red(
|
|
4450
|
-
`Unknown registry action: "${action}". Valid actions: diff, register, commit, register-changes, unregister.`
|
|
4451
|
-
)
|
|
4452
|
-
);
|
|
4453
|
-
process.exit(1);
|
|
4454
|
-
}
|
|
4455
|
-
}
|
|
4456
3927
|
|
|
4457
3928
|
// src/cli.ts
|
|
4458
3929
|
function createCli() {
|
|
4459
3930
|
const cli = cac.cac("mason");
|
|
4460
3931
|
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").action(async (args, flags) => {
|
|
4461
3932
|
if (args && args.length > 0) {
|
|
4462
|
-
|
|
4463
|
-
|
|
3933
|
+
p3__namespace.log.error(
|
|
3934
|
+
pc14__default.default.red(
|
|
4464
3935
|
`Unknown command: "${args.join(" ")}". Use --help to list available commands.`
|
|
4465
3936
|
)
|
|
4466
3937
|
);
|
|
@@ -4471,14 +3942,9 @@ function createCli() {
|
|
|
4471
3942
|
const mode = getEffectiveMode(projectRoot, flags);
|
|
4472
3943
|
if (mode === "registry") {
|
|
4473
3944
|
const choice2 = handleCancel(
|
|
4474
|
-
await
|
|
4475
|
-
message: "\u{1F3DB}\uFE0F Mason Registry
|
|
3945
|
+
await p3__namespace.select({
|
|
3946
|
+
message: "\u{1F3DB}\uFE0F Mason (Registry Mode): What would you like to scaffold?",
|
|
4476
3947
|
options: [
|
|
4477
|
-
{
|
|
4478
|
-
value: "diff",
|
|
4479
|
-
label: "Inspect Diff & Status",
|
|
4480
|
-
hint: "Overview of unregistered, uncommitted, or drifted modules"
|
|
4481
|
-
},
|
|
4482
3948
|
{
|
|
4483
3949
|
value: "create_feature",
|
|
4484
3950
|
label: "Initialize New Feature",
|
|
@@ -4494,26 +3960,6 @@ function createCli() {
|
|
|
4494
3960
|
label: "Create New Use Case",
|
|
4495
3961
|
hint: "Add a new use case to an existing feature"
|
|
4496
3962
|
},
|
|
4497
|
-
{
|
|
4498
|
-
value: "register",
|
|
4499
|
-
label: "Register Module",
|
|
4500
|
-
hint: "Add a module to index.json with integrity checksum"
|
|
4501
|
-
},
|
|
4502
|
-
{
|
|
4503
|
-
value: "commit",
|
|
4504
|
-
label: "Commit Module Changes",
|
|
4505
|
-
hint: "Commit working changes in a module to git"
|
|
4506
|
-
},
|
|
4507
|
-
{
|
|
4508
|
-
value: "register_changes",
|
|
4509
|
-
label: "Register Changes",
|
|
4510
|
-
hint: "Recompute checksums and update index.json"
|
|
4511
|
-
},
|
|
4512
|
-
{
|
|
4513
|
-
value: "unregister",
|
|
4514
|
-
label: "Unregister Module",
|
|
4515
|
-
hint: "Remove from index.json but keep source on disk"
|
|
4516
|
-
},
|
|
4517
3963
|
{
|
|
4518
3964
|
value: "import",
|
|
4519
3965
|
label: "Import from Remote Registry",
|
|
@@ -4523,9 +3969,6 @@ function createCli() {
|
|
|
4523
3969
|
})
|
|
4524
3970
|
);
|
|
4525
3971
|
switch (choice2) {
|
|
4526
|
-
case "diff":
|
|
4527
|
-
await handleRegistry("diff", void 0, void 0, flags);
|
|
4528
|
-
break;
|
|
4529
3972
|
case "create_feature":
|
|
4530
3973
|
await handleCreate("feature", void 0, flags);
|
|
4531
3974
|
break;
|
|
@@ -4535,18 +3978,6 @@ function createCli() {
|
|
|
4535
3978
|
case "create_usecase":
|
|
4536
3979
|
await handleCreate("usecase", void 0, flags);
|
|
4537
3980
|
break;
|
|
4538
|
-
case "register":
|
|
4539
|
-
await handleRegistry("register", void 0, void 0, flags);
|
|
4540
|
-
break;
|
|
4541
|
-
case "commit":
|
|
4542
|
-
await handleRegistry("commit", void 0, void 0, flags);
|
|
4543
|
-
break;
|
|
4544
|
-
case "register_changes":
|
|
4545
|
-
await handleRegistry("register-changes", void 0, void 0, flags);
|
|
4546
|
-
break;
|
|
4547
|
-
case "unregister":
|
|
4548
|
-
await handleRegistry("unregister", void 0, void 0, flags);
|
|
4549
|
-
break;
|
|
4550
3981
|
case "import":
|
|
4551
3982
|
await handleImport(void 0, void 0, flags);
|
|
4552
3983
|
break;
|
|
@@ -4554,31 +3985,24 @@ function createCli() {
|
|
|
4554
3985
|
return;
|
|
4555
3986
|
}
|
|
4556
3987
|
const choice = handleCancel(
|
|
4557
|
-
await
|
|
3988
|
+
await p3__namespace.select({
|
|
4558
3989
|
message: "\u{1F9F1} Mason: What would you like to do?",
|
|
4559
3990
|
options: [
|
|
4560
3991
|
{
|
|
4561
3992
|
value: "create",
|
|
4562
|
-
label: "Create
|
|
3993
|
+
label: "Create component",
|
|
4563
3994
|
hint: "Scaffold a new feature, shared module, use case, domain entity, etc."
|
|
4564
3995
|
},
|
|
4565
3996
|
{
|
|
4566
3997
|
value: "import",
|
|
4567
3998
|
label: "Import from registry",
|
|
4568
3999
|
hint: "Download and link pre-built shared modules or features from the registry"
|
|
4569
|
-
},
|
|
4570
|
-
{
|
|
4571
|
-
value: "registry",
|
|
4572
|
-
label: "Registry management",
|
|
4573
|
-
hint: "Inspect diff, register modules, or commit module changes"
|
|
4574
4000
|
}
|
|
4575
4001
|
]
|
|
4576
4002
|
})
|
|
4577
4003
|
);
|
|
4578
4004
|
if (choice === "create") {
|
|
4579
4005
|
await handleCreate(void 0, void 0, flags);
|
|
4580
|
-
} else if (choice === "registry") {
|
|
4581
|
-
await handleRegistry(void 0, void 0, void 0, flags);
|
|
4582
4006
|
} else {
|
|
4583
4007
|
await handleImport(void 0, void 0, flags);
|
|
4584
4008
|
}
|
|
@@ -4606,25 +4030,6 @@ function createCli() {
|
|
|
4606
4030
|
handleCliError(err);
|
|
4607
4031
|
}
|
|
4608
4032
|
});
|
|
4609
|
-
cli.command(
|
|
4610
|
-
"registry [action] [type] [name]",
|
|
4611
|
-
"Registry & version management (diff, register, commit, register-changes, unregister)"
|
|
4612
|
-
).option("-m, --message <message>", "Commit message for 'commit' command").option("-y, --yes", "Accept defaults and skip interactive prompts").example("mason registry diff").example("mason registry register feature authn").example("mason registry commit shared hasher -m 'Add bcrypt engine'").example("mason registry register-changes shared hasher").example("mason registry unregister feature oldFeature").action(
|
|
4613
|
-
async (action, type, name, flags = {}) => {
|
|
4614
|
-
try {
|
|
4615
|
-
await handleRegistry(action, type, name, flags);
|
|
4616
|
-
} catch (err) {
|
|
4617
|
-
handleCliError(err);
|
|
4618
|
-
}
|
|
4619
|
-
}
|
|
4620
|
-
);
|
|
4621
|
-
cli.command("diff", "Inspect registry status and diff (alias for 'mason registry diff')").allowUnknownOptions().action(async (flags = {}) => {
|
|
4622
|
-
try {
|
|
4623
|
-
await handleRegistry("diff", void 0, void 0, flags);
|
|
4624
|
-
} catch (err) {
|
|
4625
|
-
handleCliError(err);
|
|
4626
|
-
}
|
|
4627
|
-
});
|
|
4628
4033
|
const createSubtypes = [
|
|
4629
4034
|
"feature",
|
|
4630
4035
|
"shared",
|
|
@@ -4648,7 +4053,7 @@ function createCli() {
|
|
|
4648
4053
|
});
|
|
4649
4054
|
}
|
|
4650
4055
|
cli.help();
|
|
4651
|
-
cli.version("1.0.
|
|
4056
|
+
cli.version("1.0.14");
|
|
4652
4057
|
return cli;
|
|
4653
4058
|
}
|
|
4654
4059
|
function handleCliError(err) {
|
|
@@ -4656,7 +4061,7 @@ function handleCliError(err) {
|
|
|
4656
4061
|
process.exit(0);
|
|
4657
4062
|
}
|
|
4658
4063
|
const message = err instanceof Error ? err.message : String(err);
|
|
4659
|
-
|
|
4064
|
+
p3__namespace.log.error(pc14__default.default.red(`Error: ${message}`));
|
|
4660
4065
|
process.exit(1);
|
|
4661
4066
|
}
|
|
4662
4067
|
async function runCli(argv = process.argv) {
|