@solid-stack/mason 1.0.22 → 1.0.23
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 +85 -136
- package/dist/bin.cjs.map +1 -1
- package/dist/bin.js +84 -135
- package/dist/bin.js.map +1 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/commands/lint.d.ts +2 -5
- package/dist/commands/lint.d.ts.map +1 -1
- package/dist/core/lintEngine.d.ts.map +1 -1
- package/dist/index.cjs +85 -136
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +84 -135
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/bin.cjs
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
var cac = require('cac');
|
|
5
5
|
var p14 = require('@clack/prompts');
|
|
6
|
-
var
|
|
6
|
+
var pc14 = require('picocolors');
|
|
7
7
|
var fs9 = require('fs');
|
|
8
8
|
var path2 = require('path');
|
|
9
9
|
var url = require('url');
|
|
@@ -33,7 +33,7 @@ function _interopNamespace(e) {
|
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
var p14__namespace = /*#__PURE__*/_interopNamespace(p14);
|
|
36
|
-
var
|
|
36
|
+
var pc14__default = /*#__PURE__*/_interopDefault(pc14);
|
|
37
37
|
var fs9__default = /*#__PURE__*/_interopDefault(fs9);
|
|
38
38
|
var path2__default = /*#__PURE__*/_interopDefault(path2);
|
|
39
39
|
var Handlebars__default = /*#__PURE__*/_interopDefault(Handlebars);
|
|
@@ -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
|
-
p14__namespace.log.warn(
|
|
79
|
+
p14__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
|
-
p14__namespace.log.success(`${
|
|
83
|
+
p14__namespace.log.success(`${pc14__default.default.bold(f.relativePath)} ${pc14__default.default.dim("(created)")}`);
|
|
84
84
|
} else if (f.action === "overwritten") {
|
|
85
|
-
p14__namespace.log.warn(`${
|
|
85
|
+
p14__namespace.log.warn(`${pc14__default.default.bold(f.relativePath)} ${pc14__default.default.dim("(overwritten)")}`);
|
|
86
86
|
} else if (f.action === "skipped") {
|
|
87
|
-
p14__namespace.log.info(`${
|
|
87
|
+
p14__namespace.log.info(`${pc14__default.default.dim(f.relativePath)} ${pc14__default.default.dim("(skipped - already exists, pass -o to overwrite)")}`);
|
|
88
88
|
} else {
|
|
89
|
-
p14__namespace.log.info(`${
|
|
89
|
+
p14__namespace.log.info(`${pc14__default.default.bold(f.relativePath)} ${pc14__default.default.dim("(preview)")}`);
|
|
90
90
|
}
|
|
91
91
|
}
|
|
92
92
|
}
|
|
@@ -1773,13 +1773,13 @@ function handleCancel(result) {
|
|
|
1773
1773
|
}
|
|
1774
1774
|
function printBanner() {
|
|
1775
1775
|
console.log("");
|
|
1776
|
-
p14__namespace.intro(
|
|
1776
|
+
p14__namespace.intro(pc14__default.default.bgCyan(pc14__default.default.black(" @solid-stack/mason ")));
|
|
1777
1777
|
}
|
|
1778
1778
|
async function promptProperties(options = {}) {
|
|
1779
1779
|
const properties = options.defaults ? [...options.defaults] : [];
|
|
1780
1780
|
if (properties.length > 0) {
|
|
1781
1781
|
const summary = properties.map((p16) => `${p16.name}: ${p16.type}${p16.optional ? "?" : ""}`).join(", ");
|
|
1782
|
-
p14__namespace.log.info(
|
|
1782
|
+
p14__namespace.log.info(pc14__default.default.dim(`Pre-configured fields: ${summary}`));
|
|
1783
1783
|
const addMore = handleCancel(
|
|
1784
1784
|
await p14__namespace.confirm({
|
|
1785
1785
|
message: "Would you like to add custom fields/properties?",
|
|
@@ -1790,7 +1790,7 @@ async function promptProperties(options = {}) {
|
|
|
1790
1790
|
return properties;
|
|
1791
1791
|
}
|
|
1792
1792
|
}
|
|
1793
|
-
p14__namespace.log.info(
|
|
1793
|
+
p14__namespace.log.info(pc14__default.default.cyan("Enter properties (leave name blank when finished):"));
|
|
1794
1794
|
while (true) {
|
|
1795
1795
|
const name = handleCancel(
|
|
1796
1796
|
await p14__namespace.text({
|
|
@@ -1838,7 +1838,7 @@ async function promptProperties(options = {}) {
|
|
|
1838
1838
|
optional
|
|
1839
1839
|
});
|
|
1840
1840
|
p14__namespace.log.success(
|
|
1841
|
-
|
|
1841
|
+
pc14__default.default.green(`Added: ${name.trim()}${optional ? "?" : ""}: ${finalType.trim()}`)
|
|
1842
1842
|
);
|
|
1843
1843
|
}
|
|
1844
1844
|
return properties;
|
|
@@ -2098,7 +2098,7 @@ async function runFeatureCommand(featureNameArg, flags = {}) {
|
|
|
2098
2098
|
}
|
|
2099
2099
|
}
|
|
2100
2100
|
const s = p14__namespace.spinner();
|
|
2101
|
-
s.start(`Generating feature '${
|
|
2101
|
+
s.start(`Generating feature '${pc14__default.default.cyan(normalizedName)}'...`);
|
|
2102
2102
|
const options = {
|
|
2103
2103
|
name: normalizedName,
|
|
2104
2104
|
projectRoot,
|
|
@@ -2145,7 +2145,7 @@ async function runFeatureCommand(featureNameArg, flags = {}) {
|
|
|
2145
2145
|
s.stop("Feature scaffolded successfully!");
|
|
2146
2146
|
printGeneratedFiles(files, options.dryRun);
|
|
2147
2147
|
p14__namespace.outro(
|
|
2148
|
-
|
|
2148
|
+
pc14__default.default.green(
|
|
2149
2149
|
`\u2713 Feature '${normalizedName}' initialized in ${path2__default.default.relative(projectRoot, targetDir)} (uncommitted, unregistered)`
|
|
2150
2150
|
)
|
|
2151
2151
|
);
|
|
@@ -2301,7 +2301,7 @@ async function runSharedCommand(sharedNameArg, flags = {}) {
|
|
|
2301
2301
|
);
|
|
2302
2302
|
}
|
|
2303
2303
|
const s = p14__namespace.spinner();
|
|
2304
|
-
s.start(`Generating shared module '${
|
|
2304
|
+
s.start(`Generating shared module '${pc14__default.default.cyan(normalizedName)}'...`);
|
|
2305
2305
|
const files = generateShared({
|
|
2306
2306
|
name: normalizedName,
|
|
2307
2307
|
description,
|
|
@@ -2315,7 +2315,7 @@ async function runSharedCommand(sharedNameArg, flags = {}) {
|
|
|
2315
2315
|
s.stop("Shared module generated successfully!");
|
|
2316
2316
|
printGeneratedFiles(files, Boolean(flags.dryRun));
|
|
2317
2317
|
p14__namespace.outro(
|
|
2318
|
-
|
|
2318
|
+
pc14__default.default.green(
|
|
2319
2319
|
`\u2713 Shared module '${normalizedName}' initialized in ${path2__default.default.relative(projectRoot, targetDir)} (uncommitted, unregistered)`
|
|
2320
2320
|
)
|
|
2321
2321
|
);
|
|
@@ -2443,7 +2443,7 @@ async function runUseCaseCommand(useCaseNameArg, flags = {}) {
|
|
|
2443
2443
|
}
|
|
2444
2444
|
}
|
|
2445
2445
|
const s = p14__namespace.spinner();
|
|
2446
|
-
s.start(`Generating use case '${
|
|
2446
|
+
s.start(`Generating use case '${pc14__default.default.cyan(ucName)}'...`);
|
|
2447
2447
|
const options = {
|
|
2448
2448
|
name: ucName,
|
|
2449
2449
|
feature,
|
|
@@ -2475,7 +2475,7 @@ async function runUseCaseCommand(useCaseNameArg, flags = {}) {
|
|
|
2475
2475
|
}
|
|
2476
2476
|
s.stop("Use case generated successfully!");
|
|
2477
2477
|
printGeneratedFiles(files, options.dryRun);
|
|
2478
|
-
p14__namespace.outro(
|
|
2478
|
+
p14__namespace.outro(pc14__default.default.green(`Use case '${ucName}' created in feature '${feature}'!`));
|
|
2479
2479
|
}
|
|
2480
2480
|
async function runDomainCommand(domainNameArg, flags = {}) {
|
|
2481
2481
|
const projectRoot = findProjectRoot();
|
|
@@ -2546,7 +2546,7 @@ async function runDomainCommand(domainNameArg, flags = {}) {
|
|
|
2546
2546
|
});
|
|
2547
2547
|
}
|
|
2548
2548
|
const s = p14__namespace.spinner();
|
|
2549
|
-
s.start(`Generating domain model '${
|
|
2549
|
+
s.start(`Generating domain model '${pc14__default.default.cyan(entityName)}'...`);
|
|
2550
2550
|
const options = {
|
|
2551
2551
|
name: entityName,
|
|
2552
2552
|
feature,
|
|
@@ -2559,7 +2559,7 @@ async function runDomainCommand(domainNameArg, flags = {}) {
|
|
|
2559
2559
|
const file = generateDomain(options);
|
|
2560
2560
|
s.stop("Domain model generated successfully!");
|
|
2561
2561
|
printGeneratedFiles([file], options.dryRun);
|
|
2562
|
-
p14__namespace.outro(
|
|
2562
|
+
p14__namespace.outro(pc14__default.default.green(`Domain model '${entityName}' created in feature '${feature}'!`));
|
|
2563
2563
|
}
|
|
2564
2564
|
async function runInfrastructureCommand(classNameArg, flags = {}) {
|
|
2565
2565
|
const projectRoot = findProjectRoot();
|
|
@@ -2728,7 +2728,7 @@ async function runInfrastructureCommand(classNameArg, flags = {}) {
|
|
|
2728
2728
|
registerInProvider = !flags.noProvider;
|
|
2729
2729
|
}
|
|
2730
2730
|
const s = p14__namespace.spinner();
|
|
2731
|
-
s.start(`Generating infrastructure class '${
|
|
2731
|
+
s.start(`Generating infrastructure class '${pc14__default.default.cyan(className)}'...`);
|
|
2732
2732
|
const files = [];
|
|
2733
2733
|
const options = {
|
|
2734
2734
|
name: className,
|
|
@@ -2763,7 +2763,7 @@ async function runInfrastructureCommand(classNameArg, flags = {}) {
|
|
|
2763
2763
|
}
|
|
2764
2764
|
s.stop("Infrastructure class generated successfully!");
|
|
2765
2765
|
printGeneratedFiles(files, options.dryRun);
|
|
2766
|
-
p14__namespace.outro(
|
|
2766
|
+
p14__namespace.outro(pc14__default.default.green(`Infrastructure class '${className}' created!`));
|
|
2767
2767
|
}
|
|
2768
2768
|
async function runInterfaceCommand(interfaceNameArg, flags = {}) {
|
|
2769
2769
|
const projectRoot = findProjectRoot();
|
|
@@ -2876,7 +2876,7 @@ async function runInterfaceCommand(interfaceNameArg, flags = {}) {
|
|
|
2876
2876
|
}
|
|
2877
2877
|
}
|
|
2878
2878
|
const s = p14__namespace.spinner();
|
|
2879
|
-
s.start(`Generating interface '${
|
|
2879
|
+
s.start(`Generating interface '${pc14__default.default.cyan(ifaceName)}'...`);
|
|
2880
2880
|
const files = [];
|
|
2881
2881
|
const options = {
|
|
2882
2882
|
name: ifaceName,
|
|
@@ -2925,7 +2925,7 @@ async function runInterfaceCommand(interfaceNameArg, flags = {}) {
|
|
|
2925
2925
|
}
|
|
2926
2926
|
s.stop("Interface generated successfully!");
|
|
2927
2927
|
printGeneratedFiles(files, options.dryRun);
|
|
2928
|
-
p14__namespace.outro(
|
|
2928
|
+
p14__namespace.outro(pc14__default.default.green(`Interface '${ifaceName}' created in feature '${feature}'!`));
|
|
2929
2929
|
}
|
|
2930
2930
|
async function runHttpHandlerCommand(handlerNameArg, flags = {}) {
|
|
2931
2931
|
const projectRoot = findProjectRoot();
|
|
@@ -3042,7 +3042,7 @@ async function runHttpHandlerCommand(handlerNameArg, flags = {}) {
|
|
|
3042
3042
|
}
|
|
3043
3043
|
}
|
|
3044
3044
|
const s = p14__namespace.spinner();
|
|
3045
|
-
s.start(`Generating HTTP handler '${
|
|
3045
|
+
s.start(`Generating HTTP handler '${pc14__default.default.cyan(className)}'...`);
|
|
3046
3046
|
const options = {
|
|
3047
3047
|
name: className,
|
|
3048
3048
|
feature,
|
|
@@ -3060,7 +3060,7 @@ async function runHttpHandlerCommand(handlerNameArg, flags = {}) {
|
|
|
3060
3060
|
const files = generateHttpHandler(options);
|
|
3061
3061
|
s.stop("HTTP handler generated successfully!");
|
|
3062
3062
|
printGeneratedFiles(files, options.dryRun);
|
|
3063
|
-
p14__namespace.outro(
|
|
3063
|
+
p14__namespace.outro(pc14__default.default.green(`HTTP handler '${className}' created in feature '${feature}'!`));
|
|
3064
3064
|
}
|
|
3065
3065
|
function generateInjectableCode(className, dependencies = [], methods = [], implementsInterface) {
|
|
3066
3066
|
const formattedDeps = dependencies.map((dep) => ({
|
|
@@ -3216,7 +3216,7 @@ async function runInjectableCommand(classNameArg, flags = {}) {
|
|
|
3216
3216
|
);
|
|
3217
3217
|
}
|
|
3218
3218
|
const s = p14__namespace.spinner();
|
|
3219
|
-
s.start(`Generating injectable '${
|
|
3219
|
+
s.start(`Generating injectable '${pc14__default.default.cyan(className)}'...`);
|
|
3220
3220
|
const options = {
|
|
3221
3221
|
name: className,
|
|
3222
3222
|
feature,
|
|
@@ -3230,7 +3230,7 @@ async function runInjectableCommand(classNameArg, flags = {}) {
|
|
|
3230
3230
|
const files = generateInjectable(options);
|
|
3231
3231
|
s.stop("Injectable class generated successfully!");
|
|
3232
3232
|
printGeneratedFiles(files, options.dryRun);
|
|
3233
|
-
p14__namespace.outro(
|
|
3233
|
+
p14__namespace.outro(pc14__default.default.green(`Injectable '${className}' created successfully!`));
|
|
3234
3234
|
}
|
|
3235
3235
|
async function runInteractiveMenu(flags = {}) {
|
|
3236
3236
|
printBanner();
|
|
@@ -3344,7 +3344,7 @@ async function handleCreate(type, name, flags = {}) {
|
|
|
3344
3344
|
break;
|
|
3345
3345
|
default:
|
|
3346
3346
|
p14__namespace.log.error(
|
|
3347
|
-
|
|
3347
|
+
pc14__default.default.red(
|
|
3348
3348
|
`Unknown component type: "${type}". Allowed types: feature, shared, usecase, domain, infrastructure, interface, httpHandler, injectable.`
|
|
3349
3349
|
)
|
|
3350
3350
|
);
|
|
@@ -3580,7 +3580,7 @@ function installNpmPackages(projectRoot, packages, pm) {
|
|
|
3580
3580
|
installCmd = `npm install ${packages.join(" ")}`;
|
|
3581
3581
|
break;
|
|
3582
3582
|
}
|
|
3583
|
-
p14__namespace.log.info(`Installing missing dependencies with ${manager}: ${
|
|
3583
|
+
p14__namespace.log.info(`Installing missing dependencies with ${manager}: ${pc14__default.default.cyan(packages.join(", "))}`);
|
|
3584
3584
|
child_process.execSync(installCmd, {
|
|
3585
3585
|
cwd: projectRoot,
|
|
3586
3586
|
stdio: "inherit"
|
|
@@ -3736,19 +3736,19 @@ async function handleImport(typeArg, nameArg, flags = {}) {
|
|
|
3736
3736
|
);
|
|
3737
3737
|
}
|
|
3738
3738
|
if (type !== "shared" && type !== "feature") {
|
|
3739
|
-
p14__namespace.log.error(
|
|
3739
|
+
p14__namespace.log.error(pc14__default.default.red(`Invalid module type: "${typeArg}". Must be "shared" or "feature".`));
|
|
3740
3740
|
process.exit(1);
|
|
3741
3741
|
}
|
|
3742
3742
|
const registryBase = getRegistryBase(projectRoot, flags.registry);
|
|
3743
3743
|
const s = p14__namespace.spinner();
|
|
3744
|
-
s.start(`Connecting to registry at ${
|
|
3744
|
+
s.start(`Connecting to registry at ${pc14__default.default.dim(registryBase)}...`);
|
|
3745
3745
|
let index;
|
|
3746
3746
|
try {
|
|
3747
3747
|
index = await fetchRegistryIndex(registryBase);
|
|
3748
3748
|
s.stop("Registry index loaded.");
|
|
3749
3749
|
} catch (err) {
|
|
3750
|
-
s.stop(
|
|
3751
|
-
p14__namespace.log.error(
|
|
3750
|
+
s.stop(pc14__default.default.red("Failed to load registry index."));
|
|
3751
|
+
p14__namespace.log.error(pc14__default.default.red(err.message || String(err)));
|
|
3752
3752
|
process.exit(1);
|
|
3753
3753
|
}
|
|
3754
3754
|
const availableList = type === "shared" ? index.shared : index.features;
|
|
@@ -3772,9 +3772,9 @@ async function handleImport(typeArg, nameArg, flags = {}) {
|
|
|
3772
3772
|
}
|
|
3773
3773
|
if (!candidateNames.includes(name)) {
|
|
3774
3774
|
const closest = findClosestMatch(name, candidateNames);
|
|
3775
|
-
p14__namespace.log.error(
|
|
3775
|
+
p14__namespace.log.error(pc14__default.default.red(`\u274C Module '${name}' not found in the ${type} registry.`));
|
|
3776
3776
|
if (closest) {
|
|
3777
|
-
p14__namespace.log.info(
|
|
3777
|
+
p14__namespace.log.info(pc14__default.default.yellow(`Did you mean '${pc14__default.default.cyan(closest)}'?`));
|
|
3778
3778
|
}
|
|
3779
3779
|
process.exit(1);
|
|
3780
3780
|
}
|
|
@@ -3786,7 +3786,7 @@ async function handleImport(typeArg, nameArg, flags = {}) {
|
|
|
3786
3786
|
try {
|
|
3787
3787
|
manifest = await fetchModuleManifest(registryBase, modType, modName);
|
|
3788
3788
|
} catch (err) {
|
|
3789
|
-
p14__namespace.log.error(
|
|
3789
|
+
p14__namespace.log.error(pc14__default.default.red(`Failed to fetch manifest for ${modType} '${modName}': ${err.message}`));
|
|
3790
3790
|
process.exit(1);
|
|
3791
3791
|
}
|
|
3792
3792
|
nodes.set(key, {
|
|
@@ -3826,7 +3826,7 @@ async function handleImport(typeArg, nameArg, flags = {}) {
|
|
|
3826
3826
|
buildTopologicalOrder(rootKey);
|
|
3827
3827
|
const resolutions = /* @__PURE__ */ new Map();
|
|
3828
3828
|
const globalAliasMap = /* @__PURE__ */ new Map();
|
|
3829
|
-
p14__namespace.log.step(`Importing ${type}: ${
|
|
3829
|
+
p14__namespace.log.step(`Importing ${type}: ${pc14__default.default.cyan(name)}...`);
|
|
3830
3830
|
for (const key of orderedKeys) {
|
|
3831
3831
|
const node = nodes.get(key);
|
|
3832
3832
|
const { type: modType, name: registryName, manifest } = node;
|
|
@@ -3859,7 +3859,7 @@ async function handleImport(typeArg, nameArg, flags = {}) {
|
|
|
3859
3859
|
if (programmaticPointTo) {
|
|
3860
3860
|
if (!checkModuleExists(projectRoot, modType, programmaticPointTo)) {
|
|
3861
3861
|
p14__namespace.log.error(
|
|
3862
|
-
|
|
3862
|
+
pc14__default.default.red(
|
|
3863
3863
|
`Module '${programmaticPointTo}' specified in --point-to does not exist in ${folder}.`
|
|
3864
3864
|
)
|
|
3865
3865
|
);
|
|
@@ -3895,7 +3895,7 @@ async function handleImport(typeArg, nameArg, flags = {}) {
|
|
|
3895
3895
|
}
|
|
3896
3896
|
const existingDir = getExistingModuleDir(projectRoot, modType, registryName);
|
|
3897
3897
|
if (!existingDir) {
|
|
3898
|
-
p14__namespace.log.info(` \u21B3 Resolving required ${modType} dependency: ${
|
|
3898
|
+
p14__namespace.log.info(` \u21B3 Resolving required ${modType} dependency: ${pc14__default.default.cyan(registryName)}`);
|
|
3899
3899
|
resolutions.set(key, {
|
|
3900
3900
|
type: modType,
|
|
3901
3901
|
registryName,
|
|
@@ -4126,7 +4126,7 @@ async function handleImport(typeArg, nameArg, flags = {}) {
|
|
|
4126
4126
|
const isOverwrite = Boolean(flags.overwrite || res.action === "overwrite");
|
|
4127
4127
|
if (key !== rootKey) {
|
|
4128
4128
|
p14__namespace.log.step(
|
|
4129
|
-
`Importing ${res.type}: ${
|
|
4129
|
+
`Importing ${res.type}: ${pc14__default.default.cyan(res.targetName)}${res.targetName !== res.registryName ? pc14__default.default.dim(` (from ${res.registryName})`) : ""}...`
|
|
4130
4130
|
);
|
|
4131
4131
|
}
|
|
4132
4132
|
if (res.action === "overwrite" && !flags.dryRun) {
|
|
@@ -4145,7 +4145,7 @@ async function handleImport(typeArg, nameArg, flags = {}) {
|
|
|
4145
4145
|
const localFilePath = path2__default.default.join(targetDir, file);
|
|
4146
4146
|
if (fs9__default.default.existsSync(localFilePath) && !isOverwrite) {
|
|
4147
4147
|
p14__namespace.log.warn(
|
|
4148
|
-
` \u21B3 Skipping existing file: ${
|
|
4148
|
+
` \u21B3 Skipping existing file: ${pc14__default.default.dim(path2__default.default.relative(projectRoot, localFilePath))} (use --overwrite to replace)`
|
|
4149
4149
|
);
|
|
4150
4150
|
continue;
|
|
4151
4151
|
}
|
|
@@ -4157,13 +4157,13 @@ async function handleImport(typeArg, nameArg, flags = {}) {
|
|
|
4157
4157
|
}
|
|
4158
4158
|
const displayPath = path2__default.default.relative(projectRoot, localFilePath);
|
|
4159
4159
|
totalWrittenFiles.push(displayPath);
|
|
4160
|
-
p14__namespace.log.message(` ${
|
|
4160
|
+
p14__namespace.log.message(` ${pc14__default.default.green("+")} ${displayPath}`);
|
|
4161
4161
|
}
|
|
4162
4162
|
}
|
|
4163
4163
|
const missingNpm = getMissingNpmPackages(projectRoot, Array.from(requiredNpmPackages));
|
|
4164
4164
|
if (missingNpm.length > 0) {
|
|
4165
4165
|
if (flags.skipInstall || flags.dryRun) {
|
|
4166
|
-
p14__namespace.log.info(`Required npm dependencies to install: ${
|
|
4166
|
+
p14__namespace.log.info(`Required npm dependencies to install: ${pc14__default.default.cyan(missingNpm.join(", "))}`);
|
|
4167
4167
|
} else {
|
|
4168
4168
|
try {
|
|
4169
4169
|
installNpmPackages(projectRoot, missingNpm);
|
|
@@ -4177,13 +4177,13 @@ async function handleImport(typeArg, nameArg, flags = {}) {
|
|
|
4177
4177
|
}
|
|
4178
4178
|
}
|
|
4179
4179
|
if (flags.dryRun) {
|
|
4180
|
-
p14__namespace.log.info(
|
|
4180
|
+
p14__namespace.log.info(pc14__default.default.yellow("Dry run complete: No files were written to disk."));
|
|
4181
4181
|
} else {
|
|
4182
4182
|
const rootRes = resolutions.get(rootKey);
|
|
4183
4183
|
const baseDir = getModuleBaseDir(projectRoot, type);
|
|
4184
4184
|
const displayTarget = path2__default.default.relative(projectRoot, path2__default.default.join(baseDir, rootRes.targetName));
|
|
4185
4185
|
p14__namespace.log.success(
|
|
4186
|
-
|
|
4186
|
+
pc14__default.default.green(
|
|
4187
4187
|
`Successfully imported ${type} '${name}' (${totalWrittenFiles.length} file${totalWrittenFiles.length === 1 ? "" : "s"} placed in ${displayTarget})`
|
|
4188
4188
|
)
|
|
4189
4189
|
);
|
|
@@ -4449,13 +4449,9 @@ function lintCodebase(options = {}) {
|
|
|
4449
4449
|
featureResult.passed = false;
|
|
4450
4450
|
}
|
|
4451
4451
|
if (failFast) {
|
|
4452
|
-
const errorMsg = `
|
|
4453
|
-
|
|
4454
|
-
|
|
4455
|
-
Rule: ${v.ruleId}
|
|
4456
|
-
Location: ${v.relativePath}:${v.line}
|
|
4457
|
-
Code: ${v.code}
|
|
4458
|
-
Explanation: ${v.advice}`;
|
|
4452
|
+
const errorMsg = `Dependency rule violation detected in ${v.relativePath}:${v.line}:
|
|
4453
|
+
[${v.category}] ${v.advice}
|
|
4454
|
+
Code: ${v.code}`;
|
|
4459
4455
|
throw new DependencyRuleError(errorMsg, [v], true);
|
|
4460
4456
|
}
|
|
4461
4457
|
};
|
|
@@ -4943,87 +4939,23 @@ ${compiledDetails}
|
|
|
4943
4939
|
}
|
|
4944
4940
|
|
|
4945
4941
|
// src/commands/lint.ts
|
|
4946
|
-
function
|
|
4947
|
-
console.log("");
|
|
4948
|
-
const title = " Mason Clean Architecture Dependency Linter ";
|
|
4949
|
-
const line = "\u2501".repeat(title.length + 2);
|
|
4950
|
-
console.log(pc15__default.default.cyan(` \u250F${line}\u2513`));
|
|
4951
|
-
console.log(` ${pc15__default.default.cyan("\u2503")} ${pc15__default.default.bgCyan(pc15__default.default.black(title))} ${pc15__default.default.cyan("\u2503")}`);
|
|
4952
|
-
console.log(pc15__default.default.cyan(` \u2517${line}\u251B`));
|
|
4953
|
-
const modeText = mode === "failFast" ? `${pc15__default.default.yellow("Fail-Fast")} ${pc15__default.default.dim("(default: stops at first error)")}` : `${pc15__default.default.magenta("Complete")} ${pc15__default.default.dim("(--complete: compiles all errors)")}`;
|
|
4954
|
-
console.log(` Mode: ${modeText}`);
|
|
4955
|
-
console.log("");
|
|
4956
|
-
}
|
|
4957
|
-
function formatViolation(v, showFixHint = true) {
|
|
4958
|
-
const lines = [];
|
|
4959
|
-
const categoryBadge = pc15__default.default.red(pc15__default.default.bold(`[${v.category}]`));
|
|
4960
|
-
const location = pc15__default.default.white(`${v.relativePath}:${pc15__default.default.yellow(String(v.line))}`);
|
|
4961
|
-
lines.push(` ${categoryBadge} ${location}`);
|
|
4962
|
-
lines.push(` ${pc15__default.default.dim("Rule ID:")} ${pc15__default.default.yellow(v.ruleId)}`);
|
|
4963
|
-
lines.push(` ${pc15__default.default.dim("Code:")} ${pc15__default.default.magenta(v.code)}`);
|
|
4964
|
-
lines.push(` ${pc15__default.default.dim("Advice:")} ${pc15__default.default.cyan(v.advice)}`);
|
|
4965
|
-
if (showFixHint && v.fixExample) {
|
|
4966
|
-
lines.push(` ${pc15__default.default.dim("Example:")}`);
|
|
4967
|
-
lines.push(` ${pc15__default.default.red(`- ${v.fixExample.bad}`)}`);
|
|
4968
|
-
lines.push(` ${pc15__default.default.green(`+ ${v.fixExample.good}`)}`);
|
|
4969
|
-
}
|
|
4970
|
-
return lines.join("\n");
|
|
4971
|
-
}
|
|
4972
|
-
function formatFeatureResult(res, options = {}) {
|
|
4942
|
+
function formatViolation(v) {
|
|
4973
4943
|
const lines = [];
|
|
4974
|
-
|
|
4975
|
-
|
|
4976
|
-
|
|
4977
|
-
|
|
4978
|
-
|
|
4979
|
-
)
|
|
4980
|
-
return lines.join("\n");
|
|
4981
|
-
}
|
|
4982
|
-
const countBadge = pc15__default.default.red(
|
|
4983
|
-
`(${res.violations.length} violation${res.violations.length > 1 ? "s" : ""})`
|
|
4944
|
+
lines.push(pc14__default.default.underline(pc14__default.default.cyan(v.relativePath)) + pc14__default.default.dim(":") + pc14__default.default.yellow(String(v.line)));
|
|
4945
|
+
const gutter = `${String(v.line).padStart(4, " ")} | `;
|
|
4946
|
+
lines.push(pc14__default.default.dim(gutter) + v.code);
|
|
4947
|
+
const categoryShort = v.category.replace(" Violation", "");
|
|
4948
|
+
lines.push(
|
|
4949
|
+
" " + pc14__default.default.red(pc14__default.default.bold("\u2716")) + " " + pc14__default.default.red(`[${categoryShort}]`) + " " + v.advice
|
|
4984
4950
|
);
|
|
4985
|
-
|
|
4986
|
-
|
|
4987
|
-
lines.push(` ${pc15__default.default.dim("Path:")} ${res.featureDir}`);
|
|
4988
|
-
lines.push("");
|
|
4989
|
-
for (const v of res.violations) {
|
|
4990
|
-
lines.push(formatViolation(v, options.fixHint !== false));
|
|
4991
|
-
lines.push("");
|
|
4951
|
+
if (v.fixExample?.good) {
|
|
4952
|
+
lines.push(" " + pc14__default.default.dim("\u2192") + " " + pc14__default.default.dim(v.fixExample.good));
|
|
4992
4953
|
}
|
|
4993
4954
|
return lines.join("\n");
|
|
4994
4955
|
}
|
|
4995
|
-
function printTerminalReport(summary, options = {}) {
|
|
4996
|
-
for (const res of summary.results) {
|
|
4997
|
-
const formatted = formatFeatureResult(res, options);
|
|
4998
|
-
if (formatted.trim()) {
|
|
4999
|
-
console.log(formatted);
|
|
5000
|
-
}
|
|
5001
|
-
}
|
|
5002
|
-
console.log("\u2501".repeat(70));
|
|
5003
|
-
const statusIcon = summary.totalViolations === 0 ? pc15__default.default.green("\u2714 PASS") : pc15__default.default.red("\u2716 FAIL");
|
|
5004
|
-
console.log(
|
|
5005
|
-
` ${statusIcon} ${pc15__default.default.bold("Dependency Rules Audit Result")} ${pc15__default.default.dim(
|
|
5006
|
-
`(${summary.durationMs}ms)`
|
|
5007
|
-
)}`
|
|
5008
|
-
);
|
|
5009
|
-
console.log(
|
|
5010
|
-
` ${pc15__default.default.bold("Features:")} ${pc15__default.default.cyan(String(summary.totalFeatures))} total | ${pc15__default.default.green(
|
|
5011
|
-
String(summary.cleanFeatures)
|
|
5012
|
-
)} clean | ${summary.violatedFeatures > 0 ? pc15__default.default.red(String(summary.violatedFeatures)) : pc15__default.default.green("0")} with violations`
|
|
5013
|
-
);
|
|
5014
|
-
console.log(
|
|
5015
|
-
` ${pc15__default.default.bold("Violations:")} ${summary.totalViolations > 0 ? pc15__default.default.red(pc15__default.default.bold(String(summary.totalViolations))) : pc15__default.default.green("0")} rule violations found`
|
|
5016
|
-
);
|
|
5017
|
-
console.log("\u2501".repeat(70));
|
|
5018
|
-
console.log("");
|
|
5019
|
-
}
|
|
5020
4956
|
async function handleLint(flags = {}) {
|
|
5021
4957
|
const complete = Boolean(flags.complete);
|
|
5022
|
-
const mode = complete ? "complete" : "failFast";
|
|
5023
4958
|
const quiet = Boolean(flags.quiet);
|
|
5024
|
-
if (!quiet) {
|
|
5025
|
-
printLintBanner(mode);
|
|
5026
|
-
}
|
|
5027
4959
|
const options = {
|
|
5028
4960
|
complete,
|
|
5029
4961
|
quiet,
|
|
@@ -5034,14 +4966,23 @@ async function handleLint(flags = {}) {
|
|
|
5034
4966
|
};
|
|
5035
4967
|
try {
|
|
5036
4968
|
const summary = lintCodebase(options);
|
|
5037
|
-
if (!quiet) {
|
|
5038
|
-
printTerminalReport(summary, options);
|
|
5039
|
-
}
|
|
5040
4969
|
if (summary.totalViolations > 0) {
|
|
4970
|
+
if (!quiet) {
|
|
4971
|
+
console.log("");
|
|
4972
|
+
for (const v of summary.allViolations) {
|
|
4973
|
+
console.log(formatViolation(v));
|
|
4974
|
+
console.log("");
|
|
4975
|
+
}
|
|
4976
|
+
console.log(
|
|
4977
|
+
pc14__default.default.red(
|
|
4978
|
+
`\u2716 Dependency rules check failed with ${summary.totalViolations} error${summary.totalViolations > 1 ? "s" : ""} across ${summary.violatedFeatures} feature${summary.violatedFeatures > 1 ? "s" : ""} (${summary.totalFeatures} features scanned).`
|
|
4979
|
+
)
|
|
4980
|
+
);
|
|
4981
|
+
console.log("");
|
|
4982
|
+
}
|
|
5041
4983
|
const errorHeader = `Dependency rule audit failed with ${summary.totalViolations} violation(s) across ${summary.violatedFeatures} feature(s):`;
|
|
5042
4984
|
const compiledDetails = summary.allViolations.map(
|
|
5043
4985
|
(v, i) => `${i + 1}. [${v.category}] ${v.relativePath}:${v.line}
|
|
5044
|
-
Rule: ${v.ruleId}
|
|
5045
4986
|
Code: ${v.code}
|
|
5046
4987
|
Advice: ${v.advice}`
|
|
5047
4988
|
).join("\n\n");
|
|
@@ -5052,20 +4993,22 @@ ${compiledDetails}
|
|
|
5052
4993
|
}
|
|
5053
4994
|
if (!quiet) {
|
|
5054
4995
|
console.log(
|
|
5055
|
-
|
|
4996
|
+
pc14__default.default.green(
|
|
4997
|
+
`\u2714 Dependency rules verified across ${summary.totalFeatures} feature${summary.totalFeatures === 1 ? "" : "s"}.`
|
|
4998
|
+
)
|
|
5056
4999
|
);
|
|
5057
|
-
console.log("");
|
|
5058
5000
|
}
|
|
5059
5001
|
return summary;
|
|
5060
5002
|
} catch (err) {
|
|
5061
5003
|
if (err instanceof DependencyRuleError && err.isFailFast) {
|
|
5062
5004
|
if (!quiet) {
|
|
5063
|
-
console.log(
|
|
5064
|
-
\u2716 [FAIL FAST] Terminating on first detected dependency rule violation:`));
|
|
5005
|
+
console.log("");
|
|
5065
5006
|
const v = err.violations[0];
|
|
5066
5007
|
if (v) {
|
|
5067
|
-
console.log(formatViolation(v
|
|
5008
|
+
console.log(formatViolation(v));
|
|
5009
|
+
console.log("");
|
|
5068
5010
|
}
|
|
5011
|
+
console.log(pc14__default.default.red(`\u2716 Dependency rules check failed (1 error).`));
|
|
5069
5012
|
console.log("");
|
|
5070
5013
|
}
|
|
5071
5014
|
}
|
|
@@ -5079,7 +5022,7 @@ function createCli() {
|
|
|
5079
5022
|
cli.command("[...args]", "Interactive scaffolding and import wizard").option("-d, --dry-run", "Preview changes without writing to disk").option("-o, --overwrite", "Overwrite existing files").option("-y, --yes", "Accept defaults and skip interactive prompts").option("--registry", "Run in registry mode").option("--point-to <mapping>", "Point a dependency to an existing local module (e.g. --point-to time:mytime)").option("--alias <mapping>", "Import a dependency fresh under an alias name (e.g. --alias time:time-mason)").option("--tests", "Include test files (use --no-tests to exclude)").action(async (args, flags) => {
|
|
5080
5023
|
if (args && args.length > 0) {
|
|
5081
5024
|
p14__namespace.log.error(
|
|
5082
|
-
|
|
5025
|
+
pc14__default.default.red(
|
|
5083
5026
|
`Unknown command: "${args.join(" ")}". Use --help to list available commands.`
|
|
5084
5027
|
)
|
|
5085
5028
|
);
|
|
@@ -5198,6 +5141,12 @@ function createCli() {
|
|
|
5198
5141
|
targetDir: target || flags.target || flags.dest
|
|
5199
5142
|
});
|
|
5200
5143
|
} catch (err) {
|
|
5144
|
+
if (err instanceof DependencyRuleError) {
|
|
5145
|
+
if (process.env.VITEST) {
|
|
5146
|
+
throw err;
|
|
5147
|
+
}
|
|
5148
|
+
process.exit(1);
|
|
5149
|
+
}
|
|
5201
5150
|
handleCliError(err);
|
|
5202
5151
|
}
|
|
5203
5152
|
});
|
|
@@ -5232,7 +5181,7 @@ function handleCliError(err) {
|
|
|
5232
5181
|
process.exit(0);
|
|
5233
5182
|
}
|
|
5234
5183
|
const message = err instanceof Error ? err.message : String(err);
|
|
5235
|
-
p14__namespace.log.error(
|
|
5184
|
+
p14__namespace.log.error(pc14__default.default.red(`Error: ${message}`));
|
|
5236
5185
|
if (process.env.VITEST) {
|
|
5237
5186
|
throw err;
|
|
5238
5187
|
}
|