@solid-stack/mason 1.0.15 → 1.0.17
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 +516 -302
- package/dist/bin.cjs.map +1 -1
- package/dist/bin.js +515 -301
- package/dist/bin.js.map +1 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/commands/import.d.ts +11 -1
- package/dist/commands/import.d.ts.map +1 -1
- package/dist/index.cjs +515 -301
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +515 -301
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/bin.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { cac } from 'cac';
|
|
3
|
-
import * as
|
|
3
|
+
import * as p14 from '@clack/prompts';
|
|
4
4
|
import pc14 from 'picocolors';
|
|
5
5
|
import fs9 from 'fs';
|
|
6
6
|
import path2 from 'path';
|
|
@@ -47,17 +47,17 @@ function writeFileSafely(absolutePath, content, options = {}) {
|
|
|
47
47
|
function printGeneratedFiles(files, isDryRun = false) {
|
|
48
48
|
console.log("");
|
|
49
49
|
if (isDryRun) {
|
|
50
|
-
|
|
50
|
+
p14.log.warn(pc14.yellow(pc14.bold("[DRY RUN PREVIEW] No files were written to disk.")));
|
|
51
51
|
}
|
|
52
52
|
for (const f of files) {
|
|
53
53
|
if (f.action === "created") {
|
|
54
|
-
|
|
54
|
+
p14.log.success(`${pc14.bold(f.relativePath)} ${pc14.dim("(created)")}`);
|
|
55
55
|
} else if (f.action === "overwritten") {
|
|
56
|
-
|
|
56
|
+
p14.log.warn(`${pc14.bold(f.relativePath)} ${pc14.dim("(overwritten)")}`);
|
|
57
57
|
} else if (f.action === "skipped") {
|
|
58
|
-
|
|
58
|
+
p14.log.info(`${pc14.dim(f.relativePath)} ${pc14.dim("(skipped - already exists, pass -o to overwrite)")}`);
|
|
59
59
|
} else {
|
|
60
|
-
|
|
60
|
+
p14.log.info(`${pc14.bold(f.relativePath)} ${pc14.dim("(preview)")}`);
|
|
61
61
|
}
|
|
62
62
|
}
|
|
63
63
|
}
|
|
@@ -1730,23 +1730,23 @@ var PromptCancelledError = class extends Error {
|
|
|
1730
1730
|
}
|
|
1731
1731
|
};
|
|
1732
1732
|
function handleCancel(result) {
|
|
1733
|
-
if (
|
|
1734
|
-
|
|
1733
|
+
if (p14.isCancel(result)) {
|
|
1734
|
+
p14.cancel("Operation cancelled.");
|
|
1735
1735
|
throw new PromptCancelledError();
|
|
1736
1736
|
}
|
|
1737
1737
|
return result;
|
|
1738
1738
|
}
|
|
1739
1739
|
function printBanner() {
|
|
1740
1740
|
console.log("");
|
|
1741
|
-
|
|
1741
|
+
p14.intro(pc14.bgCyan(pc14.black(" @solid-stack/mason ")));
|
|
1742
1742
|
}
|
|
1743
1743
|
async function promptProperties(options = {}) {
|
|
1744
1744
|
const properties = options.defaults ? [...options.defaults] : [];
|
|
1745
1745
|
if (properties.length > 0) {
|
|
1746
1746
|
const summary = properties.map((p16) => `${p16.name}: ${p16.type}${p16.optional ? "?" : ""}`).join(", ");
|
|
1747
|
-
|
|
1747
|
+
p14.log.info(pc14.dim(`Pre-configured fields: ${summary}`));
|
|
1748
1748
|
const addMore = handleCancel(
|
|
1749
|
-
await
|
|
1749
|
+
await p14.confirm({
|
|
1750
1750
|
message: "Would you like to add custom fields/properties?",
|
|
1751
1751
|
initialValue: false
|
|
1752
1752
|
})
|
|
@@ -1755,10 +1755,10 @@ async function promptProperties(options = {}) {
|
|
|
1755
1755
|
return properties;
|
|
1756
1756
|
}
|
|
1757
1757
|
}
|
|
1758
|
-
|
|
1758
|
+
p14.log.info(pc14.cyan("Enter properties (leave name blank when finished):"));
|
|
1759
1759
|
while (true) {
|
|
1760
1760
|
const name = handleCancel(
|
|
1761
|
-
await
|
|
1761
|
+
await p14.text({
|
|
1762
1762
|
message: "Property name (or press Enter to finish):",
|
|
1763
1763
|
placeholder: "e.g. title, email, status"
|
|
1764
1764
|
})
|
|
@@ -1767,7 +1767,7 @@ async function promptProperties(options = {}) {
|
|
|
1767
1767
|
break;
|
|
1768
1768
|
}
|
|
1769
1769
|
const type = handleCancel(
|
|
1770
|
-
await
|
|
1770
|
+
await p14.select({
|
|
1771
1771
|
message: `Type for property "${name.trim()}":`,
|
|
1772
1772
|
options: [
|
|
1773
1773
|
{ value: "string", label: "string" },
|
|
@@ -1784,7 +1784,7 @@ async function promptProperties(options = {}) {
|
|
|
1784
1784
|
let finalType = type;
|
|
1785
1785
|
if (type === "custom") {
|
|
1786
1786
|
finalType = handleCancel(
|
|
1787
|
-
await
|
|
1787
|
+
await p14.text({
|
|
1788
1788
|
message: `Enter custom type for "${name.trim()}":`,
|
|
1789
1789
|
placeholder: "e.g. UserRole, string | null",
|
|
1790
1790
|
validate: (val) => val && val.trim() ? void 0 : "Type cannot be empty"
|
|
@@ -1792,7 +1792,7 @@ async function promptProperties(options = {}) {
|
|
|
1792
1792
|
);
|
|
1793
1793
|
}
|
|
1794
1794
|
const optional = handleCancel(
|
|
1795
|
-
await
|
|
1795
|
+
await p14.confirm({
|
|
1796
1796
|
message: `Is "${name.trim()}" optional?`,
|
|
1797
1797
|
initialValue: false
|
|
1798
1798
|
})
|
|
@@ -1802,7 +1802,7 @@ async function promptProperties(options = {}) {
|
|
|
1802
1802
|
type: finalType.trim(),
|
|
1803
1803
|
optional
|
|
1804
1804
|
});
|
|
1805
|
-
|
|
1805
|
+
p14.log.success(
|
|
1806
1806
|
pc14.green(`Added: ${name.trim()}${optional ? "?" : ""}: ${finalType.trim()}`)
|
|
1807
1807
|
);
|
|
1808
1808
|
}
|
|
@@ -1819,7 +1819,7 @@ async function runFeatureCommand(featureNameArg, flags = {}) {
|
|
|
1819
1819
|
}
|
|
1820
1820
|
if (!name) {
|
|
1821
1821
|
name = handleCancel(
|
|
1822
|
-
await
|
|
1822
|
+
await p14.text({
|
|
1823
1823
|
message: "What is the feature name?",
|
|
1824
1824
|
placeholder: "e.g. users, auth, orders, billing",
|
|
1825
1825
|
validate: (val) => {
|
|
@@ -1835,7 +1835,7 @@ async function runFeatureCommand(featureNameArg, flags = {}) {
|
|
|
1835
1835
|
let targetDirRel = defaultDir;
|
|
1836
1836
|
if (!flags.yes && !flags.target && !flags.dest) {
|
|
1837
1837
|
targetDirRel = handleCancel(
|
|
1838
|
-
await
|
|
1838
|
+
await p14.text({
|
|
1839
1839
|
message: "Target directory for the feature:",
|
|
1840
1840
|
initialValue: defaultDir,
|
|
1841
1841
|
defaultValue: defaultDir
|
|
@@ -1857,14 +1857,14 @@ async function runFeatureCommand(featureNameArg, flags = {}) {
|
|
|
1857
1857
|
const customUseCases = [];
|
|
1858
1858
|
if (!flags.yes) {
|
|
1859
1859
|
includeExpress = handleCancel(
|
|
1860
|
-
await
|
|
1860
|
+
await p14.confirm({
|
|
1861
1861
|
message: "Include Express Presentation layer (pxExpress routes & handlers)?",
|
|
1862
1862
|
initialValue: true
|
|
1863
1863
|
})
|
|
1864
1864
|
);
|
|
1865
1865
|
if (includeExpress) {
|
|
1866
1866
|
routePath = handleCancel(
|
|
1867
|
-
await
|
|
1867
|
+
await p14.text({
|
|
1868
1868
|
message: "Express route prefix:",
|
|
1869
1869
|
initialValue: `/${normalizedName}`,
|
|
1870
1870
|
defaultValue: `/${normalizedName}`
|
|
@@ -1872,14 +1872,14 @@ async function runFeatureCommand(featureNameArg, flags = {}) {
|
|
|
1872
1872
|
).trim();
|
|
1873
1873
|
}
|
|
1874
1874
|
includeDomain = handleCancel(
|
|
1875
|
-
await
|
|
1875
|
+
await p14.confirm({
|
|
1876
1876
|
message: "Include Domain Entity/Entities?",
|
|
1877
1877
|
initialValue: true
|
|
1878
1878
|
})
|
|
1879
1879
|
);
|
|
1880
1880
|
if (includeDomain) {
|
|
1881
1881
|
const domainInput = handleCancel(
|
|
1882
|
-
await
|
|
1882
|
+
await p14.text({
|
|
1883
1883
|
message: "Domain entity name(s) (comma-separated):",
|
|
1884
1884
|
initialValue: defaultEntity,
|
|
1885
1885
|
defaultValue: defaultEntity,
|
|
@@ -1898,21 +1898,21 @@ async function runFeatureCommand(featureNameArg, flags = {}) {
|
|
|
1898
1898
|
entityNames = [defaultEntity];
|
|
1899
1899
|
}
|
|
1900
1900
|
includeInterface = handleCancel(
|
|
1901
|
-
await
|
|
1901
|
+
await p14.confirm({
|
|
1902
1902
|
message: `Include Domain Repository interface(s) for ${entityNames.join(", ")}?`,
|
|
1903
1903
|
initialValue: true
|
|
1904
1904
|
})
|
|
1905
1905
|
);
|
|
1906
1906
|
if (includeInterface) {
|
|
1907
1907
|
includeInfra = handleCancel(
|
|
1908
|
-
await
|
|
1908
|
+
await p14.confirm({
|
|
1909
1909
|
message: `Include Infrastructure Stub implementation(s) for ${entityNames.join(", ")}?`,
|
|
1910
1910
|
initialValue: true
|
|
1911
1911
|
})
|
|
1912
1912
|
);
|
|
1913
1913
|
}
|
|
1914
1914
|
includeUseCase = handleCancel(
|
|
1915
|
-
await
|
|
1915
|
+
await p14.confirm({
|
|
1916
1916
|
message: "Include Domain Use Cases?",
|
|
1917
1917
|
initialValue: true
|
|
1918
1918
|
})
|
|
@@ -1926,7 +1926,7 @@ async function runFeatureCommand(featureNameArg, flags = {}) {
|
|
|
1926
1926
|
{ value: "delete", label: "Delete (Delete<Entity>)", hint: "DELETE /:id" }
|
|
1927
1927
|
];
|
|
1928
1928
|
crudOperations = handleCancel(
|
|
1929
|
-
await
|
|
1929
|
+
await p14.multiselect({
|
|
1930
1930
|
message: "Select standard CRUD use cases to generate:",
|
|
1931
1931
|
options: crudChoices,
|
|
1932
1932
|
initialValues: ["create", "read", "list", "update", "delete"],
|
|
@@ -1934,13 +1934,13 @@ async function runFeatureCommand(featureNameArg, flags = {}) {
|
|
|
1934
1934
|
})
|
|
1935
1935
|
);
|
|
1936
1936
|
includeTests = handleCancel(
|
|
1937
|
-
await
|
|
1937
|
+
await p14.confirm({
|
|
1938
1938
|
message: "Generate Vitest unit tests for use cases?",
|
|
1939
1939
|
initialValue: true
|
|
1940
1940
|
})
|
|
1941
1941
|
);
|
|
1942
1942
|
const wantCustom = handleCancel(
|
|
1943
|
-
await
|
|
1943
|
+
await p14.confirm({
|
|
1944
1944
|
message: "Do you want to add any custom use cases to this feature?",
|
|
1945
1945
|
initialValue: false
|
|
1946
1946
|
})
|
|
@@ -1950,7 +1950,7 @@ async function runFeatureCommand(featureNameArg, flags = {}) {
|
|
|
1950
1950
|
const availableIfaces = entityNames.map((e) => `I${e}Repository`);
|
|
1951
1951
|
while (addMore) {
|
|
1952
1952
|
const customName = handleCancel(
|
|
1953
|
-
await
|
|
1953
|
+
await p14.text({
|
|
1954
1954
|
message: "Custom Use Case name:",
|
|
1955
1955
|
placeholder: "e.g. ResetPassword, VerifyEmail, AssignRole",
|
|
1956
1956
|
validate: (v) => v && v.trim() ? void 0 : "Use Case name cannot be empty"
|
|
@@ -1960,7 +1960,7 @@ async function runFeatureCommand(featureNameArg, flags = {}) {
|
|
|
1960
1960
|
let selectedDeps = [];
|
|
1961
1961
|
if (availableIfaces.length > 0) {
|
|
1962
1962
|
selectedDeps = handleCancel(
|
|
1963
|
-
await
|
|
1963
|
+
await p14.multiselect({
|
|
1964
1964
|
message: `Select domain interfaces to inject into ${customUcName}:`,
|
|
1965
1965
|
options: availableIfaces.map((i) => ({ value: i, label: i })),
|
|
1966
1966
|
required: false
|
|
@@ -1969,7 +1969,7 @@ async function runFeatureCommand(featureNameArg, flags = {}) {
|
|
|
1969
1969
|
}
|
|
1970
1970
|
let customInputProps = [];
|
|
1971
1971
|
const hasInput = handleCancel(
|
|
1972
|
-
await
|
|
1972
|
+
await p14.confirm({
|
|
1973
1973
|
message: `Does ${customUcName} accept input arguments?`,
|
|
1974
1974
|
initialValue: true
|
|
1975
1975
|
})
|
|
@@ -1980,7 +1980,7 @@ async function runFeatureCommand(featureNameArg, flags = {}) {
|
|
|
1980
1980
|
}
|
|
1981
1981
|
let customOutputProps = [];
|
|
1982
1982
|
const hasCustomOutput = handleCancel(
|
|
1983
|
-
await
|
|
1983
|
+
await p14.confirm({
|
|
1984
1984
|
message: `Does ${customUcName} return custom output data?`,
|
|
1985
1985
|
initialValue: false
|
|
1986
1986
|
})
|
|
@@ -1990,7 +1990,7 @@ async function runFeatureCommand(featureNameArg, flags = {}) {
|
|
|
1990
1990
|
});
|
|
1991
1991
|
}
|
|
1992
1992
|
const customIncludeTest = handleCancel(
|
|
1993
|
-
await
|
|
1993
|
+
await p14.confirm({
|
|
1994
1994
|
message: `Generate Vitest unit test for ${customUcName}?`,
|
|
1995
1995
|
initialValue: true
|
|
1996
1996
|
})
|
|
@@ -2000,14 +2000,14 @@ async function runFeatureCommand(featureNameArg, flags = {}) {
|
|
|
2000
2000
|
let customHttpPath = `/${toKebabCase(customUcName)}`;
|
|
2001
2001
|
if (includeExpress) {
|
|
2002
2002
|
customCreateHttp = handleCancel(
|
|
2003
|
-
await
|
|
2003
|
+
await p14.confirm({
|
|
2004
2004
|
message: `Generate a matching ExpressRoute HTTP handler for ${customUcName}?`,
|
|
2005
2005
|
initialValue: true
|
|
2006
2006
|
})
|
|
2007
2007
|
);
|
|
2008
2008
|
if (customCreateHttp) {
|
|
2009
2009
|
customHttpMethod = handleCancel(
|
|
2010
|
-
await
|
|
2010
|
+
await p14.select({
|
|
2011
2011
|
message: "HTTP method for route:",
|
|
2012
2012
|
options: [
|
|
2013
2013
|
{ value: "post", label: "POST" },
|
|
@@ -2020,7 +2020,7 @@ async function runFeatureCommand(featureNameArg, flags = {}) {
|
|
|
2020
2020
|
})
|
|
2021
2021
|
);
|
|
2022
2022
|
customHttpPath = handleCancel(
|
|
2023
|
-
await
|
|
2023
|
+
await p14.text({
|
|
2024
2024
|
message: "Route subpath (relative to feature prefix):",
|
|
2025
2025
|
initialValue: `/${toKebabCase(customUcName)}`,
|
|
2026
2026
|
defaultValue: `/${toKebabCase(customUcName)}`
|
|
@@ -2041,7 +2041,7 @@ async function runFeatureCommand(featureNameArg, flags = {}) {
|
|
|
2041
2041
|
validationFields: customInputProps
|
|
2042
2042
|
});
|
|
2043
2043
|
addMore = handleCancel(
|
|
2044
|
-
await
|
|
2044
|
+
await p14.confirm({
|
|
2045
2045
|
message: "Add another custom use case?",
|
|
2046
2046
|
initialValue: false
|
|
2047
2047
|
})
|
|
@@ -2050,7 +2050,7 @@ async function runFeatureCommand(featureNameArg, flags = {}) {
|
|
|
2050
2050
|
}
|
|
2051
2051
|
}
|
|
2052
2052
|
includeDiProvider = handleCancel(
|
|
2053
|
-
await
|
|
2053
|
+
await p14.confirm({
|
|
2054
2054
|
message: "Generate / update feature DI provider (diProvider.ts)?",
|
|
2055
2055
|
initialValue: true
|
|
2056
2056
|
})
|
|
@@ -2062,7 +2062,7 @@ async function runFeatureCommand(featureNameArg, flags = {}) {
|
|
|
2062
2062
|
entityNames = [defaultEntity];
|
|
2063
2063
|
}
|
|
2064
2064
|
}
|
|
2065
|
-
const s =
|
|
2065
|
+
const s = p14.spinner();
|
|
2066
2066
|
s.start(`Generating feature '${pc14.cyan(normalizedName)}'...`);
|
|
2067
2067
|
const options = {
|
|
2068
2068
|
name: normalizedName,
|
|
@@ -2109,7 +2109,7 @@ async function runFeatureCommand(featureNameArg, flags = {}) {
|
|
|
2109
2109
|
}
|
|
2110
2110
|
s.stop("Feature scaffolded successfully!");
|
|
2111
2111
|
printGeneratedFiles(files, options.dryRun);
|
|
2112
|
-
|
|
2112
|
+
p14.outro(
|
|
2113
2113
|
pc14.green(
|
|
2114
2114
|
`\u2713 Feature '${normalizedName}' initialized in ${path2.relative(projectRoot, targetDir)} (uncommitted, unregistered)`
|
|
2115
2115
|
)
|
|
@@ -2224,7 +2224,7 @@ async function runSharedCommand(sharedNameArg, flags = {}) {
|
|
|
2224
2224
|
}
|
|
2225
2225
|
if (!name) {
|
|
2226
2226
|
name = handleCancel(
|
|
2227
|
-
await
|
|
2227
|
+
await p14.text({
|
|
2228
2228
|
message: "What is the shared module name?",
|
|
2229
2229
|
placeholder: "e.g. hasher, time, uuid, cache, logger",
|
|
2230
2230
|
validate: (val) => {
|
|
@@ -2240,7 +2240,7 @@ async function runSharedCommand(sharedNameArg, flags = {}) {
|
|
|
2240
2240
|
let targetDirRel = defaultDir;
|
|
2241
2241
|
if (!flags.yes && !flags.target && !flags.dest) {
|
|
2242
2242
|
targetDirRel = handleCancel(
|
|
2243
|
-
await
|
|
2243
|
+
await p14.text({
|
|
2244
2244
|
message: "Target directory for the shared module:",
|
|
2245
2245
|
initialValue: defaultDir,
|
|
2246
2246
|
defaultValue: defaultDir
|
|
@@ -2252,20 +2252,20 @@ async function runSharedCommand(sharedNameArg, flags = {}) {
|
|
|
2252
2252
|
let includeStub = true;
|
|
2253
2253
|
if (!flags.yes) {
|
|
2254
2254
|
description = handleCancel(
|
|
2255
|
-
await
|
|
2255
|
+
await p14.text({
|
|
2256
2256
|
message: "Module description (optional):",
|
|
2257
2257
|
placeholder: "e.g. In-memory caching and Redis port abstraction",
|
|
2258
2258
|
initialValue: ""
|
|
2259
2259
|
})
|
|
2260
2260
|
).trim();
|
|
2261
2261
|
includeStub = handleCancel(
|
|
2262
|
-
await
|
|
2262
|
+
await p14.confirm({
|
|
2263
2263
|
message: "Include stub implementation in infrastructure/?",
|
|
2264
2264
|
initialValue: true
|
|
2265
2265
|
})
|
|
2266
2266
|
);
|
|
2267
2267
|
}
|
|
2268
|
-
const s =
|
|
2268
|
+
const s = p14.spinner();
|
|
2269
2269
|
s.start(`Generating shared module '${pc14.cyan(normalizedName)}'...`);
|
|
2270
2270
|
const files = generateShared({
|
|
2271
2271
|
name: normalizedName,
|
|
@@ -2279,7 +2279,7 @@ async function runSharedCommand(sharedNameArg, flags = {}) {
|
|
|
2279
2279
|
});
|
|
2280
2280
|
s.stop("Shared module generated successfully!");
|
|
2281
2281
|
printGeneratedFiles(files, Boolean(flags.dryRun));
|
|
2282
|
-
|
|
2282
|
+
p14.outro(
|
|
2283
2283
|
pc14.green(
|
|
2284
2284
|
`\u2713 Shared module '${normalizedName}' initialized in ${path2.relative(projectRoot, targetDir)} (uncommitted, unregistered)`
|
|
2285
2285
|
)
|
|
@@ -2294,14 +2294,14 @@ async function runUseCaseCommand(useCaseNameArg, flags = {}) {
|
|
|
2294
2294
|
const featureOptions = existingFeatures.map((f) => ({ value: f, label: f }));
|
|
2295
2295
|
featureOptions.push({ value: "__custom__", label: "\u270F\uFE0F Enter custom feature name..." });
|
|
2296
2296
|
const selected = handleCancel(
|
|
2297
|
-
await
|
|
2297
|
+
await p14.select({
|
|
2298
2298
|
message: "Select target feature:",
|
|
2299
2299
|
options: featureOptions
|
|
2300
2300
|
})
|
|
2301
2301
|
);
|
|
2302
2302
|
if (selected === "__custom__") {
|
|
2303
2303
|
feature = handleCancel(
|
|
2304
|
-
await
|
|
2304
|
+
await p14.text({
|
|
2305
2305
|
message: "Enter feature name:",
|
|
2306
2306
|
validate: (v) => v && v.trim() ? void 0 : "Feature name cannot be empty"
|
|
2307
2307
|
})
|
|
@@ -2311,7 +2311,7 @@ async function runUseCaseCommand(useCaseNameArg, flags = {}) {
|
|
|
2311
2311
|
}
|
|
2312
2312
|
} else {
|
|
2313
2313
|
feature = handleCancel(
|
|
2314
|
-
await
|
|
2314
|
+
await p14.text({
|
|
2315
2315
|
message: "Enter target feature name:",
|
|
2316
2316
|
validate: (v) => v && v.trim() ? void 0 : "Feature name cannot be empty"
|
|
2317
2317
|
})
|
|
@@ -2322,7 +2322,7 @@ async function runUseCaseCommand(useCaseNameArg, flags = {}) {
|
|
|
2322
2322
|
let name = useCaseNameArg?.trim();
|
|
2323
2323
|
if (!name) {
|
|
2324
2324
|
name = handleCancel(
|
|
2325
|
-
await
|
|
2325
|
+
await p14.text({
|
|
2326
2326
|
message: "Use Case name:",
|
|
2327
2327
|
placeholder: "e.g. CreateUser, GetUser, CancelOrder",
|
|
2328
2328
|
validate: (v) => v && v.trim() ? void 0 : "Use Case name cannot be empty"
|
|
@@ -2338,7 +2338,7 @@ async function runUseCaseCommand(useCaseNameArg, flags = {}) {
|
|
|
2338
2338
|
label: i.name
|
|
2339
2339
|
}));
|
|
2340
2340
|
selectedDeps = handleCancel(
|
|
2341
|
-
await
|
|
2341
|
+
await p14.multiselect({
|
|
2342
2342
|
message: "Select domain interfaces to inject into use case:",
|
|
2343
2343
|
options: multiOptions,
|
|
2344
2344
|
required: false
|
|
@@ -2353,7 +2353,7 @@ async function runUseCaseCommand(useCaseNameArg, flags = {}) {
|
|
|
2353
2353
|
let httpPath = "/";
|
|
2354
2354
|
if (!flags.yes) {
|
|
2355
2355
|
const hasInput = handleCancel(
|
|
2356
|
-
await
|
|
2356
|
+
await p14.confirm({
|
|
2357
2357
|
message: "Does this use case accept input arguments?",
|
|
2358
2358
|
initialValue: true
|
|
2359
2359
|
})
|
|
@@ -2363,7 +2363,7 @@ async function runUseCaseCommand(useCaseNameArg, flags = {}) {
|
|
|
2363
2363
|
});
|
|
2364
2364
|
}
|
|
2365
2365
|
const hasCustomOutput = handleCancel(
|
|
2366
|
-
await
|
|
2366
|
+
await p14.confirm({
|
|
2367
2367
|
message: "Does this use case return custom output data?",
|
|
2368
2368
|
initialValue: false
|
|
2369
2369
|
})
|
|
@@ -2373,20 +2373,20 @@ async function runUseCaseCommand(useCaseNameArg, flags = {}) {
|
|
|
2373
2373
|
});
|
|
2374
2374
|
}
|
|
2375
2375
|
includeTest = handleCancel(
|
|
2376
|
-
await
|
|
2376
|
+
await p14.confirm({
|
|
2377
2377
|
message: "Generate Vitest unit test skeleton (.test.ts)?",
|
|
2378
2378
|
initialValue: true
|
|
2379
2379
|
})
|
|
2380
2380
|
);
|
|
2381
2381
|
createHttp = handleCancel(
|
|
2382
|
-
await
|
|
2382
|
+
await p14.confirm({
|
|
2383
2383
|
message: "Generate a matching ExpressRoute HTTP handler?",
|
|
2384
2384
|
initialValue: false
|
|
2385
2385
|
})
|
|
2386
2386
|
);
|
|
2387
2387
|
if (createHttp) {
|
|
2388
2388
|
httpMethod = handleCancel(
|
|
2389
|
-
await
|
|
2389
|
+
await p14.select({
|
|
2390
2390
|
message: "HTTP method for route:",
|
|
2391
2391
|
options: [
|
|
2392
2392
|
{ value: "post", label: "POST" },
|
|
@@ -2399,7 +2399,7 @@ async function runUseCaseCommand(useCaseNameArg, flags = {}) {
|
|
|
2399
2399
|
})
|
|
2400
2400
|
);
|
|
2401
2401
|
httpPath = handleCancel(
|
|
2402
|
-
await
|
|
2402
|
+
await p14.text({
|
|
2403
2403
|
message: "Route subpath (relative to feature prefix):",
|
|
2404
2404
|
initialValue: "/",
|
|
2405
2405
|
defaultValue: "/"
|
|
@@ -2407,7 +2407,7 @@ async function runUseCaseCommand(useCaseNameArg, flags = {}) {
|
|
|
2407
2407
|
).trim();
|
|
2408
2408
|
}
|
|
2409
2409
|
}
|
|
2410
|
-
const s =
|
|
2410
|
+
const s = p14.spinner();
|
|
2411
2411
|
s.start(`Generating use case '${pc14.cyan(ucName)}'...`);
|
|
2412
2412
|
const options = {
|
|
2413
2413
|
name: ucName,
|
|
@@ -2440,7 +2440,7 @@ async function runUseCaseCommand(useCaseNameArg, flags = {}) {
|
|
|
2440
2440
|
}
|
|
2441
2441
|
s.stop("Use case generated successfully!");
|
|
2442
2442
|
printGeneratedFiles(files, options.dryRun);
|
|
2443
|
-
|
|
2443
|
+
p14.outro(pc14.green(`Use case '${ucName}' created in feature '${feature}'!`));
|
|
2444
2444
|
}
|
|
2445
2445
|
async function runDomainCommand(domainNameArg, flags = {}) {
|
|
2446
2446
|
const projectRoot = findProjectRoot();
|
|
@@ -2451,14 +2451,14 @@ async function runDomainCommand(domainNameArg, flags = {}) {
|
|
|
2451
2451
|
const featureOptions = existingFeatures.map((f) => ({ value: f, label: f }));
|
|
2452
2452
|
featureOptions.push({ value: "__custom__", label: "\u270F\uFE0F Enter custom feature name..." });
|
|
2453
2453
|
const selected = handleCancel(
|
|
2454
|
-
await
|
|
2454
|
+
await p14.select({
|
|
2455
2455
|
message: "Select target feature:",
|
|
2456
2456
|
options: featureOptions
|
|
2457
2457
|
})
|
|
2458
2458
|
);
|
|
2459
2459
|
if (selected === "__custom__") {
|
|
2460
2460
|
feature = handleCancel(
|
|
2461
|
-
await
|
|
2461
|
+
await p14.text({
|
|
2462
2462
|
message: "Enter feature name:",
|
|
2463
2463
|
validate: (v) => v && v.trim() ? void 0 : "Feature name cannot be empty"
|
|
2464
2464
|
})
|
|
@@ -2468,7 +2468,7 @@ async function runDomainCommand(domainNameArg, flags = {}) {
|
|
|
2468
2468
|
}
|
|
2469
2469
|
} else {
|
|
2470
2470
|
feature = handleCancel(
|
|
2471
|
-
await
|
|
2471
|
+
await p14.text({
|
|
2472
2472
|
message: "Enter target feature name:",
|
|
2473
2473
|
validate: (v) => v && v.trim() ? void 0 : "Feature name cannot be empty"
|
|
2474
2474
|
})
|
|
@@ -2479,7 +2479,7 @@ async function runDomainCommand(domainNameArg, flags = {}) {
|
|
|
2479
2479
|
let name = domainNameArg?.trim();
|
|
2480
2480
|
if (!name) {
|
|
2481
2481
|
name = handleCancel(
|
|
2482
|
-
await
|
|
2482
|
+
await p14.text({
|
|
2483
2483
|
message: "Domain model / entity name:",
|
|
2484
2484
|
placeholder: "e.g. User, Order, Product, Address",
|
|
2485
2485
|
validate: (v) => v && v.trim() ? void 0 : "Domain name cannot be empty"
|
|
@@ -2491,7 +2491,7 @@ async function runDomainCommand(domainNameArg, flags = {}) {
|
|
|
2491
2491
|
let properties = [];
|
|
2492
2492
|
if (!flags.yes) {
|
|
2493
2493
|
kind = handleCancel(
|
|
2494
|
-
await
|
|
2494
|
+
await p14.select({
|
|
2495
2495
|
message: "Select domain model type:",
|
|
2496
2496
|
options: [
|
|
2497
2497
|
{ value: "interface", label: "TypeScript Interface (pure data structure)" },
|
|
@@ -2510,7 +2510,7 @@ async function runDomainCommand(domainNameArg, flags = {}) {
|
|
|
2510
2510
|
defaults: kind === "valueObject" ? [{ name: "value", type: "string" }] : defaultProps
|
|
2511
2511
|
});
|
|
2512
2512
|
}
|
|
2513
|
-
const s =
|
|
2513
|
+
const s = p14.spinner();
|
|
2514
2514
|
s.start(`Generating domain model '${pc14.cyan(entityName)}'...`);
|
|
2515
2515
|
const options = {
|
|
2516
2516
|
name: entityName,
|
|
@@ -2524,7 +2524,7 @@ async function runDomainCommand(domainNameArg, flags = {}) {
|
|
|
2524
2524
|
const file = generateDomain(options);
|
|
2525
2525
|
s.stop("Domain model generated successfully!");
|
|
2526
2526
|
printGeneratedFiles([file], options.dryRun);
|
|
2527
|
-
|
|
2527
|
+
p14.outro(pc14.green(`Domain model '${entityName}' created in feature '${feature}'!`));
|
|
2528
2528
|
}
|
|
2529
2529
|
async function runInfrastructureCommand(classNameArg, flags = {}) {
|
|
2530
2530
|
const projectRoot = findProjectRoot();
|
|
@@ -2533,7 +2533,7 @@ async function runInfrastructureCommand(classNameArg, flags = {}) {
|
|
|
2533
2533
|
let feature = flags.feature?.trim();
|
|
2534
2534
|
if (!flags.yes && !flags.global && !flags.feature) {
|
|
2535
2535
|
scope = handleCancel(
|
|
2536
|
-
await
|
|
2536
|
+
await p14.select({
|
|
2537
2537
|
message: "Where should this infrastructure implementation be placed?",
|
|
2538
2538
|
options: [
|
|
2539
2539
|
{ value: "feature", label: "Feature-level (features/<feature>/infrastructure)" },
|
|
@@ -2548,14 +2548,14 @@ async function runInfrastructureCommand(classNameArg, flags = {}) {
|
|
|
2548
2548
|
const featureOptions = existingFeatures.map((f) => ({ value: f, label: f }));
|
|
2549
2549
|
featureOptions.push({ value: "__custom__", label: "\u270F\uFE0F Enter custom feature name..." });
|
|
2550
2550
|
const selected = handleCancel(
|
|
2551
|
-
await
|
|
2551
|
+
await p14.select({
|
|
2552
2552
|
message: "Select target feature:",
|
|
2553
2553
|
options: featureOptions
|
|
2554
2554
|
})
|
|
2555
2555
|
);
|
|
2556
2556
|
if (selected === "__custom__") {
|
|
2557
2557
|
feature = handleCancel(
|
|
2558
|
-
await
|
|
2558
|
+
await p14.text({
|
|
2559
2559
|
message: "Enter feature name:",
|
|
2560
2560
|
validate: (v) => v && v.trim() ? void 0 : "Feature name cannot be empty"
|
|
2561
2561
|
})
|
|
@@ -2565,7 +2565,7 @@ async function runInfrastructureCommand(classNameArg, flags = {}) {
|
|
|
2565
2565
|
}
|
|
2566
2566
|
} else {
|
|
2567
2567
|
feature = handleCancel(
|
|
2568
|
-
await
|
|
2568
|
+
await p14.text({
|
|
2569
2569
|
message: "Enter target feature name:",
|
|
2570
2570
|
validate: (v) => v && v.trim() ? void 0 : "Feature name cannot be empty"
|
|
2571
2571
|
})
|
|
@@ -2578,7 +2578,7 @@ async function runInfrastructureCommand(classNameArg, flags = {}) {
|
|
|
2578
2578
|
let name = classNameArg?.trim();
|
|
2579
2579
|
if (!name) {
|
|
2580
2580
|
name = handleCancel(
|
|
2581
|
-
await
|
|
2581
|
+
await p14.text({
|
|
2582
2582
|
message: "Infrastructure class name:",
|
|
2583
2583
|
placeholder: "e.g. StubUserRepository, PostgresUserRepository, S3FileStorage",
|
|
2584
2584
|
validate: (v) => v && v.trim() ? void 0 : "Class name cannot be empty"
|
|
@@ -2597,7 +2597,7 @@ async function runInfrastructureCommand(classNameArg, flags = {}) {
|
|
|
2597
2597
|
(i) => className.toLowerCase().includes(removeInterfacePrefix(i.name).toLowerCase())
|
|
2598
2598
|
);
|
|
2599
2599
|
const ifaceChoice = handleCancel(
|
|
2600
|
-
await
|
|
2600
|
+
await p14.select({
|
|
2601
2601
|
message: "Does this class implement a domain interface or abstract class?",
|
|
2602
2602
|
options: [
|
|
2603
2603
|
...interfaces.map((i) => ({ value: i.name, label: i.name })),
|
|
@@ -2609,7 +2609,7 @@ async function runInfrastructureCommand(classNameArg, flags = {}) {
|
|
|
2609
2609
|
);
|
|
2610
2610
|
if (ifaceChoice === "__custom__") {
|
|
2611
2611
|
implementsInterface = handleCancel(
|
|
2612
|
-
await
|
|
2612
|
+
await p14.text({
|
|
2613
2613
|
message: "Enter interface or abstract class name:",
|
|
2614
2614
|
placeholder: "e.g. IUserRepository, BaseStorageAdapter",
|
|
2615
2615
|
validate: (v) => v && v.trim() ? void 0 : "Name cannot be empty"
|
|
@@ -2620,14 +2620,14 @@ async function runInfrastructureCommand(classNameArg, flags = {}) {
|
|
|
2620
2620
|
}
|
|
2621
2621
|
} else {
|
|
2622
2622
|
const wantImpl = handleCancel(
|
|
2623
|
-
await
|
|
2623
|
+
await p14.confirm({
|
|
2624
2624
|
message: "Does this class implement a domain interface or abstract class?",
|
|
2625
2625
|
initialValue: false
|
|
2626
2626
|
})
|
|
2627
2627
|
);
|
|
2628
2628
|
if (wantImpl) {
|
|
2629
2629
|
implementsInterface = handleCancel(
|
|
2630
|
-
await
|
|
2630
|
+
await p14.text({
|
|
2631
2631
|
message: "Enter interface or abstract class name:",
|
|
2632
2632
|
placeholder: "e.g. IUserRepository, BaseStorageAdapter",
|
|
2633
2633
|
validate: (v) => v && v.trim() ? void 0 : "Name cannot be empty"
|
|
@@ -2647,7 +2647,7 @@ async function runInfrastructureCommand(classNameArg, flags = {}) {
|
|
|
2647
2647
|
const allInterfaces = listDomainInterfaces(projectRoot);
|
|
2648
2648
|
if (allInterfaces.length > 0) {
|
|
2649
2649
|
const ifaceChoice = handleCancel(
|
|
2650
|
-
await
|
|
2650
|
+
await p14.select({
|
|
2651
2651
|
message: "Does this class implement an interface or abstract class?",
|
|
2652
2652
|
options: [
|
|
2653
2653
|
...allInterfaces.map((i) => ({ value: i.name, label: `${i.name} (${i.feature})` })),
|
|
@@ -2659,7 +2659,7 @@ async function runInfrastructureCommand(classNameArg, flags = {}) {
|
|
|
2659
2659
|
);
|
|
2660
2660
|
if (ifaceChoice === "__custom__") {
|
|
2661
2661
|
implementsInterface = handleCancel(
|
|
2662
|
-
await
|
|
2662
|
+
await p14.text({
|
|
2663
2663
|
message: "Enter interface or abstract class name:",
|
|
2664
2664
|
placeholder: "e.g. IAuthRepository",
|
|
2665
2665
|
validate: (v) => v && v.trim() ? void 0 : "Name cannot be empty"
|
|
@@ -2672,7 +2672,7 @@ async function runInfrastructureCommand(classNameArg, flags = {}) {
|
|
|
2672
2672
|
}
|
|
2673
2673
|
if (!flags.yes && !flags.kind) {
|
|
2674
2674
|
kind = handleCancel(
|
|
2675
|
-
await
|
|
2675
|
+
await p14.select({
|
|
2676
2676
|
message: "Select implementation kind:",
|
|
2677
2677
|
options: [
|
|
2678
2678
|
{ value: "stub", label: "In-Memory Stub (with in-memory store and test helper methods)" },
|
|
@@ -2683,7 +2683,7 @@ async function runInfrastructureCommand(classNameArg, flags = {}) {
|
|
|
2683
2683
|
);
|
|
2684
2684
|
if (scope === "feature" && feature && implementsInterface) {
|
|
2685
2685
|
registerInProvider = handleCancel(
|
|
2686
|
-
await
|
|
2686
|
+
await p14.confirm({
|
|
2687
2687
|
message: "Register this implementation in feature diProvider.ts?",
|
|
2688
2688
|
initialValue: true
|
|
2689
2689
|
})
|
|
@@ -2692,7 +2692,7 @@ async function runInfrastructureCommand(classNameArg, flags = {}) {
|
|
|
2692
2692
|
} else if (flags.yes && scope === "feature" && feature && implementsInterface) {
|
|
2693
2693
|
registerInProvider = !flags.noProvider;
|
|
2694
2694
|
}
|
|
2695
|
-
const s =
|
|
2695
|
+
const s = p14.spinner();
|
|
2696
2696
|
s.start(`Generating infrastructure class '${pc14.cyan(className)}'...`);
|
|
2697
2697
|
const files = [];
|
|
2698
2698
|
const options = {
|
|
@@ -2728,7 +2728,7 @@ async function runInfrastructureCommand(classNameArg, flags = {}) {
|
|
|
2728
2728
|
}
|
|
2729
2729
|
s.stop("Infrastructure class generated successfully!");
|
|
2730
2730
|
printGeneratedFiles(files, options.dryRun);
|
|
2731
|
-
|
|
2731
|
+
p14.outro(pc14.green(`Infrastructure class '${className}' created!`));
|
|
2732
2732
|
}
|
|
2733
2733
|
async function runInterfaceCommand(interfaceNameArg, flags = {}) {
|
|
2734
2734
|
const projectRoot = findProjectRoot();
|
|
@@ -2739,14 +2739,14 @@ async function runInterfaceCommand(interfaceNameArg, flags = {}) {
|
|
|
2739
2739
|
const featureOptions = existingFeatures.map((f) => ({ value: f, label: f }));
|
|
2740
2740
|
featureOptions.push({ value: "__custom__", label: "\u270F\uFE0F Enter custom feature name..." });
|
|
2741
2741
|
const selected = handleCancel(
|
|
2742
|
-
await
|
|
2742
|
+
await p14.select({
|
|
2743
2743
|
message: "Select target feature:",
|
|
2744
2744
|
options: featureOptions
|
|
2745
2745
|
})
|
|
2746
2746
|
);
|
|
2747
2747
|
if (selected === "__custom__") {
|
|
2748
2748
|
feature = handleCancel(
|
|
2749
|
-
await
|
|
2749
|
+
await p14.text({
|
|
2750
2750
|
message: "Enter feature name:",
|
|
2751
2751
|
validate: (v) => v && v.trim() ? void 0 : "Feature name cannot be empty"
|
|
2752
2752
|
})
|
|
@@ -2756,7 +2756,7 @@ async function runInterfaceCommand(interfaceNameArg, flags = {}) {
|
|
|
2756
2756
|
}
|
|
2757
2757
|
} else {
|
|
2758
2758
|
feature = handleCancel(
|
|
2759
|
-
await
|
|
2759
|
+
await p14.text({
|
|
2760
2760
|
message: "Enter target feature name:",
|
|
2761
2761
|
validate: (v) => v && v.trim() ? void 0 : "Feature name cannot be empty"
|
|
2762
2762
|
})
|
|
@@ -2767,7 +2767,7 @@ async function runInterfaceCommand(interfaceNameArg, flags = {}) {
|
|
|
2767
2767
|
let name = interfaceNameArg?.trim();
|
|
2768
2768
|
if (!name) {
|
|
2769
2769
|
name = handleCancel(
|
|
2770
|
-
await
|
|
2770
|
+
await p14.text({
|
|
2771
2771
|
message: "Domain interface name:",
|
|
2772
2772
|
placeholder: "e.g. IUserRepository, IPaymentService",
|
|
2773
2773
|
validate: (v) => v && v.trim() ? void 0 : "Interface name cannot be empty"
|
|
@@ -2785,7 +2785,7 @@ async function runInterfaceCommand(interfaceNameArg, flags = {}) {
|
|
|
2785
2785
|
if (!flags.yes) {
|
|
2786
2786
|
if (existingEntities.length > 0) {
|
|
2787
2787
|
const selectedEntity = handleCancel(
|
|
2788
|
-
await
|
|
2788
|
+
await p14.select({
|
|
2789
2789
|
message: "Select domain entity associated with this interface:",
|
|
2790
2790
|
options: [
|
|
2791
2791
|
...existingEntities.map((e) => ({ value: e.name, label: e.name })),
|
|
@@ -2796,7 +2796,7 @@ async function runInterfaceCommand(interfaceNameArg, flags = {}) {
|
|
|
2796
2796
|
);
|
|
2797
2797
|
if (selectedEntity === "__custom__") {
|
|
2798
2798
|
entityName = handleCancel(
|
|
2799
|
-
await
|
|
2799
|
+
await p14.text({
|
|
2800
2800
|
message: "Enter entity name:",
|
|
2801
2801
|
defaultValue: removeInterfacePrefix(ifaceName).replace(/Repository$|Service$/, "")
|
|
2802
2802
|
})
|
|
@@ -2806,7 +2806,7 @@ async function runInterfaceCommand(interfaceNameArg, flags = {}) {
|
|
|
2806
2806
|
}
|
|
2807
2807
|
}
|
|
2808
2808
|
kind = handleCancel(
|
|
2809
|
-
await
|
|
2809
|
+
await p14.select({
|
|
2810
2810
|
message: "Interface definition style:",
|
|
2811
2811
|
options: [
|
|
2812
2812
|
{ value: "abstractClass", label: "Abstract Class (Recommended - acts as DI token & type)" },
|
|
@@ -2816,7 +2816,7 @@ async function runInterfaceCommand(interfaceNameArg, flags = {}) {
|
|
|
2816
2816
|
})
|
|
2817
2817
|
);
|
|
2818
2818
|
methodsPreset = handleCancel(
|
|
2819
|
-
await
|
|
2819
|
+
await p14.select({
|
|
2820
2820
|
message: "Method signature preset:",
|
|
2821
2821
|
options: [
|
|
2822
2822
|
{ value: "crud", label: "Standard CRUD (GetById, List, Create, Update, Delete)" },
|
|
@@ -2826,21 +2826,21 @@ async function runInterfaceCommand(interfaceNameArg, flags = {}) {
|
|
|
2826
2826
|
})
|
|
2827
2827
|
);
|
|
2828
2828
|
generateStub = handleCancel(
|
|
2829
|
-
await
|
|
2829
|
+
await p14.confirm({
|
|
2830
2830
|
message: "Auto-generate Infrastructure Stub implementation?",
|
|
2831
2831
|
initialValue: true
|
|
2832
2832
|
})
|
|
2833
2833
|
);
|
|
2834
2834
|
if (generateStub) {
|
|
2835
2835
|
registerInProvider = handleCancel(
|
|
2836
|
-
await
|
|
2836
|
+
await p14.confirm({
|
|
2837
2837
|
message: "Auto-register interface & stub in feature diProvider.ts?",
|
|
2838
2838
|
initialValue: true
|
|
2839
2839
|
})
|
|
2840
2840
|
);
|
|
2841
2841
|
}
|
|
2842
2842
|
}
|
|
2843
|
-
const s =
|
|
2843
|
+
const s = p14.spinner();
|
|
2844
2844
|
s.start(`Generating interface '${pc14.cyan(ifaceName)}'...`);
|
|
2845
2845
|
const files = [];
|
|
2846
2846
|
const options = {
|
|
@@ -2890,7 +2890,7 @@ async function runInterfaceCommand(interfaceNameArg, flags = {}) {
|
|
|
2890
2890
|
}
|
|
2891
2891
|
s.stop("Interface generated successfully!");
|
|
2892
2892
|
printGeneratedFiles(files, options.dryRun);
|
|
2893
|
-
|
|
2893
|
+
p14.outro(pc14.green(`Interface '${ifaceName}' created in feature '${feature}'!`));
|
|
2894
2894
|
}
|
|
2895
2895
|
async function runHttpHandlerCommand(handlerNameArg, flags = {}) {
|
|
2896
2896
|
const projectRoot = findProjectRoot();
|
|
@@ -2901,14 +2901,14 @@ async function runHttpHandlerCommand(handlerNameArg, flags = {}) {
|
|
|
2901
2901
|
const featureOptions = existingFeatures.map((f) => ({ value: f, label: f }));
|
|
2902
2902
|
featureOptions.push({ value: "__custom__", label: "\u270F\uFE0F Enter custom feature name..." });
|
|
2903
2903
|
const selected = handleCancel(
|
|
2904
|
-
await
|
|
2904
|
+
await p14.select({
|
|
2905
2905
|
message: "Select target feature:",
|
|
2906
2906
|
options: featureOptions
|
|
2907
2907
|
})
|
|
2908
2908
|
);
|
|
2909
2909
|
if (selected === "__custom__") {
|
|
2910
2910
|
feature = handleCancel(
|
|
2911
|
-
await
|
|
2911
|
+
await p14.text({
|
|
2912
2912
|
message: "Enter feature name:",
|
|
2913
2913
|
validate: (v) => v && v.trim() ? void 0 : "Feature name cannot be empty"
|
|
2914
2914
|
})
|
|
@@ -2918,7 +2918,7 @@ async function runHttpHandlerCommand(handlerNameArg, flags = {}) {
|
|
|
2918
2918
|
}
|
|
2919
2919
|
} else {
|
|
2920
2920
|
feature = handleCancel(
|
|
2921
|
-
await
|
|
2921
|
+
await p14.text({
|
|
2922
2922
|
message: "Enter target feature name:",
|
|
2923
2923
|
validate: (v) => v && v.trim() ? void 0 : "Feature name cannot be empty"
|
|
2924
2924
|
})
|
|
@@ -2929,7 +2929,7 @@ async function runHttpHandlerCommand(handlerNameArg, flags = {}) {
|
|
|
2929
2929
|
let name = handlerNameArg?.trim();
|
|
2930
2930
|
if (!name) {
|
|
2931
2931
|
name = handleCancel(
|
|
2932
|
-
await
|
|
2932
|
+
await p14.text({
|
|
2933
2933
|
message: "HTTP Route Handler class name:",
|
|
2934
2934
|
placeholder: "e.g. CreateUserHttp, GetUserHttp, HealthHttp",
|
|
2935
2935
|
validate: (v) => v && v.trim() ? void 0 : "Handler name cannot be empty"
|
|
@@ -2948,7 +2948,7 @@ async function runHttpHandlerCommand(handlerNameArg, flags = {}) {
|
|
|
2948
2948
|
let validationFields = [];
|
|
2949
2949
|
if (!flags.yes) {
|
|
2950
2950
|
method = handleCancel(
|
|
2951
|
-
await
|
|
2951
|
+
await p14.select({
|
|
2952
2952
|
message: "HTTP Method:",
|
|
2953
2953
|
options: [
|
|
2954
2954
|
{ value: "get", label: "GET" },
|
|
@@ -2962,7 +2962,7 @@ async function runHttpHandlerCommand(handlerNameArg, flags = {}) {
|
|
|
2962
2962
|
);
|
|
2963
2963
|
const defaultPath = method === "get" ? "/" : "/";
|
|
2964
2964
|
subPath = handleCancel(
|
|
2965
|
-
await
|
|
2965
|
+
await p14.text({
|
|
2966
2966
|
message: "Route subpath (relative to feature prefix):",
|
|
2967
2967
|
initialValue: defaultPath,
|
|
2968
2968
|
defaultValue: defaultPath
|
|
@@ -2973,7 +2973,7 @@ async function runHttpHandlerCommand(handlerNameArg, flags = {}) {
|
|
|
2973
2973
|
const ucOptions = useCases.map((u) => ({ value: u.name, label: u.name }));
|
|
2974
2974
|
ucOptions.push({ value: "__none__", label: "None / Standalone Handler" });
|
|
2975
2975
|
const chosenUc = handleCancel(
|
|
2976
|
-
await
|
|
2976
|
+
await p14.select({
|
|
2977
2977
|
message: "Connect this handler to a domain Use Case?",
|
|
2978
2978
|
options: ucOptions,
|
|
2979
2979
|
initialValue: ucOptions[0]?.value
|
|
@@ -2984,7 +2984,7 @@ async function runHttpHandlerCommand(handlerNameArg, flags = {}) {
|
|
|
2984
2984
|
}
|
|
2985
2985
|
}
|
|
2986
2986
|
includeValidation = handleCancel(
|
|
2987
|
-
await
|
|
2987
|
+
await p14.confirm({
|
|
2988
2988
|
message: "Include Zod inbound request validation?",
|
|
2989
2989
|
initialValue: method !== "delete"
|
|
2990
2990
|
})
|
|
@@ -2992,7 +2992,7 @@ async function runHttpHandlerCommand(handlerNameArg, flags = {}) {
|
|
|
2992
2992
|
if (includeValidation) {
|
|
2993
2993
|
const defaultSource = method === "get" ? "query" : "body";
|
|
2994
2994
|
validationSource = handleCancel(
|
|
2995
|
-
await
|
|
2995
|
+
await p14.select({
|
|
2996
2996
|
message: "Validation data source:",
|
|
2997
2997
|
options: [
|
|
2998
2998
|
{ value: "body", label: "req.body (for POST / PUT / PATCH payloads)" },
|
|
@@ -3006,7 +3006,7 @@ async function runHttpHandlerCommand(handlerNameArg, flags = {}) {
|
|
|
3006
3006
|
});
|
|
3007
3007
|
}
|
|
3008
3008
|
}
|
|
3009
|
-
const s =
|
|
3009
|
+
const s = p14.spinner();
|
|
3010
3010
|
s.start(`Generating HTTP handler '${pc14.cyan(className)}'...`);
|
|
3011
3011
|
const options = {
|
|
3012
3012
|
name: className,
|
|
@@ -3025,7 +3025,7 @@ async function runHttpHandlerCommand(handlerNameArg, flags = {}) {
|
|
|
3025
3025
|
const files = generateHttpHandler(options);
|
|
3026
3026
|
s.stop("HTTP handler generated successfully!");
|
|
3027
3027
|
printGeneratedFiles(files, options.dryRun);
|
|
3028
|
-
|
|
3028
|
+
p14.outro(pc14.green(`HTTP handler '${className}' created in feature '${feature}'!`));
|
|
3029
3029
|
}
|
|
3030
3030
|
function generateInjectableCode(className, dependencies = [], methods = [], implementsInterface) {
|
|
3031
3031
|
const formattedDeps = dependencies.map((dep) => ({
|
|
@@ -3105,7 +3105,7 @@ async function runInjectableCommand(classNameArg, flags = {}) {
|
|
|
3105
3105
|
let name = classNameArg?.trim();
|
|
3106
3106
|
if (!name) {
|
|
3107
3107
|
name = handleCancel(
|
|
3108
|
-
await
|
|
3108
|
+
await p14.text({
|
|
3109
3109
|
message: "Injectable class name:",
|
|
3110
3110
|
placeholder: "e.g. PasswordHasher, TokenService, UserTransformer",
|
|
3111
3111
|
validate: (v) => v && v.trim() ? void 0 : "Class name cannot be empty"
|
|
@@ -3118,7 +3118,7 @@ async function runInjectableCommand(classNameArg, flags = {}) {
|
|
|
3118
3118
|
let customPath;
|
|
3119
3119
|
if (!flags.yes) {
|
|
3120
3120
|
location = handleCancel(
|
|
3121
|
-
await
|
|
3121
|
+
await p14.select({
|
|
3122
3122
|
message: "Select target architectural location:",
|
|
3123
3123
|
options: [
|
|
3124
3124
|
{ value: "feature-service", label: "Feature Service (features/<feature>/services/)" },
|
|
@@ -3136,14 +3136,14 @@ async function runInjectableCommand(classNameArg, flags = {}) {
|
|
|
3136
3136
|
const featureOptions = existingFeatures.map((f) => ({ value: f, label: f }));
|
|
3137
3137
|
featureOptions.push({ value: "__custom__", label: "\u270F\uFE0F Enter custom feature name..." });
|
|
3138
3138
|
const selected = handleCancel(
|
|
3139
|
-
await
|
|
3139
|
+
await p14.select({
|
|
3140
3140
|
message: "Select target feature:",
|
|
3141
3141
|
options: featureOptions
|
|
3142
3142
|
})
|
|
3143
3143
|
);
|
|
3144
3144
|
if (selected === "__custom__") {
|
|
3145
3145
|
feature = handleCancel(
|
|
3146
|
-
await
|
|
3146
|
+
await p14.text({
|
|
3147
3147
|
message: "Enter feature name:",
|
|
3148
3148
|
validate: (v) => v && v.trim() ? void 0 : "Feature name cannot be empty"
|
|
3149
3149
|
})
|
|
@@ -3153,7 +3153,7 @@ async function runInjectableCommand(classNameArg, flags = {}) {
|
|
|
3153
3153
|
}
|
|
3154
3154
|
} else {
|
|
3155
3155
|
feature = handleCancel(
|
|
3156
|
-
await
|
|
3156
|
+
await p14.text({
|
|
3157
3157
|
message: "Enter target feature name:",
|
|
3158
3158
|
validate: (v) => v && v.trim() ? void 0 : "Feature name cannot be empty"
|
|
3159
3159
|
})
|
|
@@ -3163,7 +3163,7 @@ async function runInjectableCommand(classNameArg, flags = {}) {
|
|
|
3163
3163
|
feature = toCamelCase(feature);
|
|
3164
3164
|
} else if (location === "custom") {
|
|
3165
3165
|
customPath = handleCancel(
|
|
3166
|
-
await
|
|
3166
|
+
await p14.text({
|
|
3167
3167
|
message: "Enter destination directory path:",
|
|
3168
3168
|
placeholder: "e.g. src/services or lib/utils",
|
|
3169
3169
|
validate: (v) => v && v.trim() ? void 0 : "Path cannot be empty"
|
|
@@ -3174,13 +3174,13 @@ async function runInjectableCommand(classNameArg, flags = {}) {
|
|
|
3174
3174
|
let generateInterface2 = false;
|
|
3175
3175
|
if (!flags.yes) {
|
|
3176
3176
|
generateInterface2 = handleCancel(
|
|
3177
|
-
await
|
|
3177
|
+
await p14.confirm({
|
|
3178
3178
|
message: `Generate abstract class interface (I${className}) as runtime DI token?`,
|
|
3179
3179
|
initialValue: false
|
|
3180
3180
|
})
|
|
3181
3181
|
);
|
|
3182
3182
|
}
|
|
3183
|
-
const s =
|
|
3183
|
+
const s = p14.spinner();
|
|
3184
3184
|
s.start(`Generating injectable '${pc14.cyan(className)}'...`);
|
|
3185
3185
|
const options = {
|
|
3186
3186
|
name: className,
|
|
@@ -3195,12 +3195,12 @@ async function runInjectableCommand(classNameArg, flags = {}) {
|
|
|
3195
3195
|
const files = generateInjectable(options);
|
|
3196
3196
|
s.stop("Injectable class generated successfully!");
|
|
3197
3197
|
printGeneratedFiles(files, options.dryRun);
|
|
3198
|
-
|
|
3198
|
+
p14.outro(pc14.green(`Injectable '${className}' created successfully!`));
|
|
3199
3199
|
}
|
|
3200
3200
|
async function runInteractiveMenu(flags = {}) {
|
|
3201
3201
|
printBanner();
|
|
3202
3202
|
const choice = handleCancel(
|
|
3203
|
-
await
|
|
3203
|
+
await p14.select({
|
|
3204
3204
|
message: "What would you like to create in your architecture?",
|
|
3205
3205
|
options: [
|
|
3206
3206
|
{
|
|
@@ -3308,7 +3308,7 @@ async function handleCreate(type, name, flags = {}) {
|
|
|
3308
3308
|
await runInjectableCommand(name, flags);
|
|
3309
3309
|
break;
|
|
3310
3310
|
default:
|
|
3311
|
-
|
|
3311
|
+
p14.log.error(
|
|
3312
3312
|
pc14.red(
|
|
3313
3313
|
`Unknown component type: "${type}". Allowed types: feature, shared, usecase, domain, infrastructure, interface, httpHandler, injectable.`
|
|
3314
3314
|
)
|
|
@@ -3533,7 +3533,7 @@ function installNpmPackages(projectRoot, packages, pm) {
|
|
|
3533
3533
|
installCmd = `npm install ${packages.join(" ")}`;
|
|
3534
3534
|
break;
|
|
3535
3535
|
}
|
|
3536
|
-
|
|
3536
|
+
p14.log.info(`Installing missing dependencies with ${manager}: ${pc14.cyan(packages.join(", "))}`);
|
|
3537
3537
|
execSync(installCmd, {
|
|
3538
3538
|
cwd: projectRoot,
|
|
3539
3539
|
stdio: "inherit"
|
|
@@ -3577,8 +3577,8 @@ function computeDirectoryHash(dirPath, files) {
|
|
|
3577
3577
|
|
|
3578
3578
|
// src/commands/import.ts
|
|
3579
3579
|
var importPrompts = {
|
|
3580
|
-
select:
|
|
3581
|
-
text:
|
|
3580
|
+
select: p14.select,
|
|
3581
|
+
text: p14.text
|
|
3582
3582
|
};
|
|
3583
3583
|
function rewriteImports(content, aliasMap) {
|
|
3584
3584
|
if (aliasMap.size === 0) return content;
|
|
@@ -3607,125 +3607,47 @@ function getExistingModuleDir(projectRoot, modType, modName) {
|
|
|
3607
3607
|
function checkModuleExists(projectRoot, modType, modName) {
|
|
3608
3608
|
return getExistingModuleDir(projectRoot, modType, modName) !== null;
|
|
3609
3609
|
}
|
|
3610
|
-
|
|
3611
|
-
const folder =
|
|
3612
|
-
const
|
|
3613
|
-
|
|
3614
|
-
|
|
3615
|
-
|
|
3616
|
-
|
|
3617
|
-
|
|
3618
|
-
|
|
3619
|
-
|
|
3620
|
-
|
|
3621
|
-
|
|
3622
|
-
|
|
3623
|
-
|
|
3624
|
-
|
|
3625
|
-
|
|
3626
|
-
|
|
3627
|
-
if (!existingDir) {
|
|
3628
|
-
p3.log.info(` \u21B3 Resolving required ${depType} dependency: ${pc14.cyan(depName)}`);
|
|
3629
|
-
await importModuleRecursive(depType, depName, depName);
|
|
3630
|
-
return;
|
|
3631
|
-
}
|
|
3632
|
-
const entry = (depType === "shared" ? index?.shared : index?.features)?.find(
|
|
3633
|
-
(item) => item.name === depName
|
|
3634
|
-
);
|
|
3635
|
-
let remoteIntegrity = entry?.integrity;
|
|
3636
|
-
if (!remoteIntegrity) {
|
|
3637
|
-
try {
|
|
3638
|
-
const depManifest = await fetchModuleManifest(registryBase, depType, depName);
|
|
3639
|
-
remoteIntegrity = depManifest.integrity;
|
|
3640
|
-
} catch {
|
|
3641
|
-
}
|
|
3642
|
-
}
|
|
3643
|
-
const localHash = computeDirectoryHash(existingDir);
|
|
3644
|
-
if (remoteIntegrity && localHash === remoteIntegrity) {
|
|
3645
|
-
p3.log.step(`\u2713 ${depType}/${depName} is up to date (reusing existing)`);
|
|
3646
|
-
importedModules.add(`${depType}:${depName}`);
|
|
3647
|
-
return;
|
|
3648
|
-
}
|
|
3649
|
-
if (flags.overwrite) {
|
|
3650
|
-
p3.log.step(`Overwriting '${depType}/${depName}' with registry version (--overwrite)...`);
|
|
3651
|
-
const baseDir = getModuleBaseDir(projectRoot, depType);
|
|
3652
|
-
const targetDir = path2.join(baseDir, depName);
|
|
3653
|
-
if (!flags.dryRun) {
|
|
3654
|
-
if (existingDir !== targetDir) {
|
|
3655
|
-
fs9.rmSync(existingDir, { recursive: true, force: true });
|
|
3610
|
+
function getAvailableLocalModules(projectRoot, modType) {
|
|
3611
|
+
const folder = modType === "shared" ? "shared" : "features";
|
|
3612
|
+
const dirs = [
|
|
3613
|
+
path2.join(projectRoot, "src", folder),
|
|
3614
|
+
path2.join(projectRoot, folder)
|
|
3615
|
+
];
|
|
3616
|
+
const set = /* @__PURE__ */ new Set();
|
|
3617
|
+
for (const dir of dirs) {
|
|
3618
|
+
if (fs9.existsSync(dir)) {
|
|
3619
|
+
try {
|
|
3620
|
+
const entries = fs9.readdirSync(dir, { withFileTypes: true });
|
|
3621
|
+
for (const e of entries) {
|
|
3622
|
+
if (e.isDirectory() && !e.name.startsWith(".")) {
|
|
3623
|
+
set.add(e.name);
|
|
3624
|
+
}
|
|
3625
|
+
}
|
|
3626
|
+
} catch {
|
|
3656
3627
|
}
|
|
3657
|
-
fs9.rmSync(targetDir, { recursive: true, force: true });
|
|
3658
3628
|
}
|
|
3659
|
-
await importModuleRecursive(depType, depName, depName, { overwrite: true });
|
|
3660
|
-
return;
|
|
3661
|
-
}
|
|
3662
|
-
if (flags.yes) {
|
|
3663
|
-
p3.log.info(`Using existing '${depType}/${depName}'`);
|
|
3664
|
-
importedModules.add(`${depType}:${depName}`);
|
|
3665
|
-
return;
|
|
3666
|
-
}
|
|
3667
|
-
const choice = handleCancel(
|
|
3668
|
-
await importPrompts.select({
|
|
3669
|
-
message: `Local '${depType}/${depName}' differs from the registry version.`,
|
|
3670
|
-
options: [
|
|
3671
|
-
{
|
|
3672
|
-
value: "keep_existing",
|
|
3673
|
-
label: `Keep existing local version (Recommended)`
|
|
3674
|
-
},
|
|
3675
|
-
{
|
|
3676
|
-
value: "rename",
|
|
3677
|
-
label: "Import fresh copy under a new name (alias)"
|
|
3678
|
-
},
|
|
3679
|
-
{
|
|
3680
|
-
value: "overwrite",
|
|
3681
|
-
label: "Overwrite local version with registry version"
|
|
3682
|
-
}
|
|
3683
|
-
]
|
|
3684
|
-
})
|
|
3685
|
-
);
|
|
3686
|
-
if (choice === "keep_existing" || choice === "use_existing") {
|
|
3687
|
-
p3.log.step(`Skipping '${depType}/${depName}' (keeping existing)`);
|
|
3688
|
-
importedModules.add(`${depType}:${depName}`);
|
|
3689
|
-
return;
|
|
3690
3629
|
}
|
|
3691
|
-
|
|
3692
|
-
|
|
3693
|
-
|
|
3694
|
-
|
|
3695
|
-
|
|
3696
|
-
|
|
3697
|
-
|
|
3698
|
-
|
|
3699
|
-
|
|
3700
|
-
|
|
3701
|
-
|
|
3702
|
-
|
|
3703
|
-
|
|
3704
|
-
|
|
3705
|
-
|
|
3630
|
+
return Array.from(set).sort();
|
|
3631
|
+
}
|
|
3632
|
+
function parseMappingFlags(raw) {
|
|
3633
|
+
if (!raw) return {};
|
|
3634
|
+
if (typeof raw === "object" && !Array.isArray(raw)) return raw;
|
|
3635
|
+
const result = {};
|
|
3636
|
+
const entries = Array.isArray(raw) ? raw : [raw];
|
|
3637
|
+
for (const entry of entries) {
|
|
3638
|
+
if (typeof entry === "string") {
|
|
3639
|
+
const idx = entry.indexOf(":");
|
|
3640
|
+
if (idx !== -1) {
|
|
3641
|
+
let key = entry.slice(0, idx).trim();
|
|
3642
|
+
let val = entry.slice(idx + 1).trim();
|
|
3643
|
+
val = val.replace(/^@\/(shared|features)\//, "").replace(/^(src\/)?(shared|features)\//, "").replace(/^\/+|\/+$/g, "").trim();
|
|
3644
|
+
if (key && val) {
|
|
3645
|
+
result[key] = val;
|
|
3706
3646
|
}
|
|
3707
|
-
})
|
|
3708
|
-
).trim();
|
|
3709
|
-
aliasMap.set(`@/${folder}/${depName}/`, `@/${folder}/${newName}/`);
|
|
3710
|
-
const baseDir = getModuleBaseDir(projectRoot, depType);
|
|
3711
|
-
const displayDest = path2.relative(projectRoot, path2.join(baseDir, newName));
|
|
3712
|
-
p3.log.step(`Importing '${depName}' into '${displayDest}'...`);
|
|
3713
|
-
await importModuleRecursive(depType, depName, newName);
|
|
3714
|
-
return;
|
|
3715
|
-
}
|
|
3716
|
-
if (choice === "overwrite") {
|
|
3717
|
-
p3.log.step(`Overwriting '${depType}/${depName}' with registry version...`);
|
|
3718
|
-
const baseDir = getModuleBaseDir(projectRoot, depType);
|
|
3719
|
-
const targetDir = path2.join(baseDir, depName);
|
|
3720
|
-
if (!flags.dryRun) {
|
|
3721
|
-
if (existingDir !== targetDir) {
|
|
3722
|
-
fs9.rmSync(existingDir, { recursive: true, force: true });
|
|
3723
3647
|
}
|
|
3724
|
-
fs9.rmSync(targetDir, { recursive: true, force: true });
|
|
3725
3648
|
}
|
|
3726
|
-
await importModuleRecursive(depType, depName, depName, { overwrite: true });
|
|
3727
|
-
return;
|
|
3728
3649
|
}
|
|
3650
|
+
return result;
|
|
3729
3651
|
}
|
|
3730
3652
|
async function handleImport(typeArg, nameArg, flags = {}) {
|
|
3731
3653
|
const projectRoot = findProjectRoot();
|
|
@@ -3751,11 +3673,11 @@ async function handleImport(typeArg, nameArg, flags = {}) {
|
|
|
3751
3673
|
);
|
|
3752
3674
|
}
|
|
3753
3675
|
if (type !== "shared" && type !== "feature") {
|
|
3754
|
-
|
|
3676
|
+
p14.log.error(pc14.red(`Invalid module type: "${typeArg}". Must be "shared" or "feature".`));
|
|
3755
3677
|
process.exit(1);
|
|
3756
3678
|
}
|
|
3757
3679
|
const registryBase = getRegistryBase(projectRoot, flags.registry);
|
|
3758
|
-
const s =
|
|
3680
|
+
const s = p14.spinner();
|
|
3759
3681
|
s.start(`Connecting to registry at ${pc14.dim(registryBase)}...`);
|
|
3760
3682
|
let index;
|
|
3761
3683
|
try {
|
|
@@ -3763,7 +3685,7 @@ async function handleImport(typeArg, nameArg, flags = {}) {
|
|
|
3763
3685
|
s.stop("Registry index loaded.");
|
|
3764
3686
|
} catch (err) {
|
|
3765
3687
|
s.stop(pc14.red("Failed to load registry index."));
|
|
3766
|
-
|
|
3688
|
+
p14.log.error(pc14.red(err.message || String(err)));
|
|
3767
3689
|
process.exit(1);
|
|
3768
3690
|
}
|
|
3769
3691
|
const availableList = type === "shared" ? index.shared : index.features;
|
|
@@ -3771,7 +3693,7 @@ async function handleImport(typeArg, nameArg, flags = {}) {
|
|
|
3771
3693
|
let name = nameArg?.trim();
|
|
3772
3694
|
if (!name) {
|
|
3773
3695
|
if (availableList.length === 0) {
|
|
3774
|
-
|
|
3696
|
+
p14.log.warn(`No ${type} modules available in the registry.`);
|
|
3775
3697
|
return;
|
|
3776
3698
|
}
|
|
3777
3699
|
name = handleCancel(
|
|
@@ -3787,108 +3709,400 @@ async function handleImport(typeArg, nameArg, flags = {}) {
|
|
|
3787
3709
|
}
|
|
3788
3710
|
if (!candidateNames.includes(name)) {
|
|
3789
3711
|
const closest = findClosestMatch(name, candidateNames);
|
|
3790
|
-
|
|
3712
|
+
p14.log.error(pc14.red(`\u274C Module '${name}' not found in the ${type} registry.`));
|
|
3791
3713
|
if (closest) {
|
|
3792
|
-
|
|
3714
|
+
p14.log.info(pc14.yellow(`Did you mean '${pc14.cyan(closest)}'?`));
|
|
3793
3715
|
}
|
|
3794
3716
|
process.exit(1);
|
|
3795
3717
|
}
|
|
3796
|
-
const
|
|
3797
|
-
|
|
3798
|
-
|
|
3799
|
-
|
|
3800
|
-
const modKey = `${modType}:${targetName}`;
|
|
3801
|
-
if (importedModules.has(modKey)) return;
|
|
3802
|
-
p3.log.step(
|
|
3803
|
-
`Importing ${modType}: ${pc14.cyan(targetName)}${targetName !== registryName ? pc14.dim(` (from ${registryName})`) : ""}...`
|
|
3804
|
-
);
|
|
3718
|
+
const nodes = /* @__PURE__ */ new Map();
|
|
3719
|
+
async function discoverGraph(modType, modName) {
|
|
3720
|
+
const key = `${modType}:${modName}`;
|
|
3721
|
+
if (nodes.has(key)) return;
|
|
3805
3722
|
let manifest;
|
|
3806
3723
|
try {
|
|
3807
|
-
manifest = await fetchModuleManifest(registryBase, modType,
|
|
3724
|
+
manifest = await fetchModuleManifest(registryBase, modType, modName);
|
|
3808
3725
|
} catch (err) {
|
|
3809
|
-
|
|
3726
|
+
p14.log.error(pc14.red(`Failed to fetch manifest for ${modType} '${modName}': ${err.message}`));
|
|
3810
3727
|
process.exit(1);
|
|
3811
3728
|
}
|
|
3812
|
-
|
|
3813
|
-
|
|
3814
|
-
|
|
3815
|
-
|
|
3816
|
-
}
|
|
3817
|
-
const
|
|
3818
|
-
|
|
3819
|
-
await resolveDependency(
|
|
3820
|
-
"shared",
|
|
3821
|
-
dep,
|
|
3822
|
-
aliasMap,
|
|
3823
|
-
projectRoot,
|
|
3824
|
-
flags,
|
|
3825
|
-
importModuleRecursive,
|
|
3826
|
-
importedModules,
|
|
3827
|
-
registryBase,
|
|
3828
|
-
index
|
|
3829
|
-
);
|
|
3729
|
+
nodes.set(key, {
|
|
3730
|
+
type: modType,
|
|
3731
|
+
name: modName,
|
|
3732
|
+
manifest
|
|
3733
|
+
});
|
|
3734
|
+
for (const dep of manifest.dependencies?.shared || []) {
|
|
3735
|
+
await discoverGraph("shared", dep);
|
|
3830
3736
|
}
|
|
3831
|
-
const
|
|
3832
|
-
|
|
3833
|
-
|
|
3834
|
-
|
|
3835
|
-
|
|
3836
|
-
|
|
3837
|
-
|
|
3838
|
-
|
|
3839
|
-
|
|
3840
|
-
|
|
3841
|
-
|
|
3842
|
-
|
|
3737
|
+
for (const dep of manifest.dependencies?.features || []) {
|
|
3738
|
+
await discoverGraph("feature", dep);
|
|
3739
|
+
}
|
|
3740
|
+
}
|
|
3741
|
+
await discoverGraph(type, name);
|
|
3742
|
+
const orderedKeys = [];
|
|
3743
|
+
const visiting = /* @__PURE__ */ new Set();
|
|
3744
|
+
const visited = /* @__PURE__ */ new Set();
|
|
3745
|
+
function buildTopologicalOrder(key) {
|
|
3746
|
+
if (visited.has(key)) return;
|
|
3747
|
+
if (visiting.has(key)) return;
|
|
3748
|
+
visiting.add(key);
|
|
3749
|
+
const node = nodes.get(key);
|
|
3750
|
+
if (node) {
|
|
3751
|
+
for (const dep of node.manifest.dependencies?.shared || []) {
|
|
3752
|
+
buildTopologicalOrder(`shared:${dep}`);
|
|
3753
|
+
}
|
|
3754
|
+
for (const dep of node.manifest.dependencies?.features || []) {
|
|
3755
|
+
buildTopologicalOrder(`feature:${dep}`);
|
|
3756
|
+
}
|
|
3757
|
+
}
|
|
3758
|
+
visiting.delete(key);
|
|
3759
|
+
visited.add(key);
|
|
3760
|
+
orderedKeys.push(key);
|
|
3761
|
+
}
|
|
3762
|
+
const rootKey = `${type}:${name}`;
|
|
3763
|
+
buildTopologicalOrder(rootKey);
|
|
3764
|
+
const resolutions = /* @__PURE__ */ new Map();
|
|
3765
|
+
const globalAliasMap = /* @__PURE__ */ new Map();
|
|
3766
|
+
p14.log.step(`Importing ${type}: ${pc14.cyan(name)}...`);
|
|
3767
|
+
for (const key of orderedKeys) {
|
|
3768
|
+
const node = nodes.get(key);
|
|
3769
|
+
const { type: modType, name: registryName, manifest } = node;
|
|
3770
|
+
const folder = modType === "shared" ? "shared" : "features";
|
|
3771
|
+
if (key === rootKey) {
|
|
3772
|
+
const aliasMap2 = parseMappingFlags(flags.alias);
|
|
3773
|
+
const programmaticAlias2 = aliasMap2[registryName] || aliasMap2[`${modType}/${registryName}`];
|
|
3774
|
+
const targetName = programmaticAlias2 || registryName;
|
|
3775
|
+
if (targetName !== registryName) {
|
|
3776
|
+
globalAliasMap.set(`@/${folder}/${registryName}/`, `@/${folder}/${targetName}/`);
|
|
3777
|
+
globalAliasMap.set(`@/${folder}/${registryName}`, `@/${folder}/${targetName}`);
|
|
3778
|
+
}
|
|
3779
|
+
resolutions.set(key, {
|
|
3780
|
+
type: modType,
|
|
3781
|
+
registryName,
|
|
3782
|
+
targetName,
|
|
3783
|
+
action: flags.overwrite ? "overwrite" : "download",
|
|
3784
|
+
manifest
|
|
3785
|
+
});
|
|
3786
|
+
continue;
|
|
3787
|
+
}
|
|
3788
|
+
const aliasMap = parseMappingFlags(flags.alias);
|
|
3789
|
+
const pointToMap = {
|
|
3790
|
+
...parseMappingFlags(flags.pointTo),
|
|
3791
|
+
...parseMappingFlags(flags["point-to"]),
|
|
3792
|
+
...parseMappingFlags(flags.useExisting),
|
|
3793
|
+
...parseMappingFlags(flags["use-existing"])
|
|
3794
|
+
};
|
|
3795
|
+
const programmaticPointTo = pointToMap[registryName] || pointToMap[`${modType}/${registryName}`];
|
|
3796
|
+
if (programmaticPointTo) {
|
|
3797
|
+
if (!checkModuleExists(projectRoot, modType, programmaticPointTo)) {
|
|
3798
|
+
p14.log.error(
|
|
3799
|
+
pc14.red(
|
|
3800
|
+
`Module '${programmaticPointTo}' specified in --point-to does not exist in ${folder}.`
|
|
3801
|
+
)
|
|
3802
|
+
);
|
|
3803
|
+
process.exit(1);
|
|
3804
|
+
}
|
|
3805
|
+
globalAliasMap.set(`@/${folder}/${registryName}/`, `@/${folder}/${programmaticPointTo}/`);
|
|
3806
|
+
globalAliasMap.set(`@/${folder}/${registryName}`, `@/${folder}/${programmaticPointTo}`);
|
|
3807
|
+
p14.log.step(`Pointing '${modType}/${registryName}' to existing '${folder}/${programmaticPointTo}'`);
|
|
3808
|
+
resolutions.set(key, {
|
|
3809
|
+
type: modType,
|
|
3810
|
+
registryName,
|
|
3811
|
+
targetName: programmaticPointTo,
|
|
3812
|
+
action: "reuse",
|
|
3813
|
+
manifest
|
|
3814
|
+
});
|
|
3815
|
+
continue;
|
|
3816
|
+
}
|
|
3817
|
+
const programmaticAlias = aliasMap[registryName] || aliasMap[`${modType}/${registryName}`];
|
|
3818
|
+
if (programmaticAlias) {
|
|
3819
|
+
globalAliasMap.set(`@/${folder}/${registryName}/`, `@/${folder}/${programmaticAlias}/`);
|
|
3820
|
+
globalAliasMap.set(`@/${folder}/${registryName}`, `@/${folder}/${programmaticAlias}`);
|
|
3821
|
+
const baseDir = getModuleBaseDir(projectRoot, modType);
|
|
3822
|
+
const displayDest = path2.relative(projectRoot, path2.join(baseDir, programmaticAlias));
|
|
3823
|
+
p14.log.step(`Importing '${registryName}' into '${displayDest}'...`);
|
|
3824
|
+
resolutions.set(key, {
|
|
3825
|
+
type: modType,
|
|
3826
|
+
registryName,
|
|
3827
|
+
targetName: programmaticAlias,
|
|
3828
|
+
action: "alias",
|
|
3829
|
+
manifest
|
|
3830
|
+
});
|
|
3831
|
+
continue;
|
|
3832
|
+
}
|
|
3833
|
+
const existingDir = getExistingModuleDir(projectRoot, modType, registryName);
|
|
3834
|
+
if (!existingDir) {
|
|
3835
|
+
p14.log.info(` \u21B3 Resolving required ${modType} dependency: ${pc14.cyan(registryName)}`);
|
|
3836
|
+
resolutions.set(key, {
|
|
3837
|
+
type: modType,
|
|
3838
|
+
registryName,
|
|
3839
|
+
targetName: registryName,
|
|
3840
|
+
action: "download",
|
|
3841
|
+
manifest
|
|
3842
|
+
});
|
|
3843
|
+
continue;
|
|
3844
|
+
}
|
|
3845
|
+
const entry = (modType === "shared" ? index.shared : index.features)?.find(
|
|
3846
|
+
(item) => item.name === registryName
|
|
3847
|
+
);
|
|
3848
|
+
const remoteIntegrity = manifest.integrity || entry?.integrity;
|
|
3849
|
+
const localHash = computeDirectoryHash(existingDir);
|
|
3850
|
+
if (remoteIntegrity && localHash === remoteIntegrity) {
|
|
3851
|
+
p14.log.step(`\u2713 ${modType}/${registryName} is up to date (reusing existing)`);
|
|
3852
|
+
resolutions.set(key, {
|
|
3853
|
+
type: modType,
|
|
3854
|
+
registryName,
|
|
3855
|
+
targetName: registryName,
|
|
3856
|
+
action: "reuse",
|
|
3857
|
+
manifest
|
|
3858
|
+
});
|
|
3859
|
+
continue;
|
|
3860
|
+
}
|
|
3861
|
+
if (flags.overwrite) {
|
|
3862
|
+
p14.log.step(`Overwriting '${modType}/${registryName}' with registry version (--overwrite)...`);
|
|
3863
|
+
resolutions.set(key, {
|
|
3864
|
+
type: modType,
|
|
3865
|
+
registryName,
|
|
3866
|
+
targetName: registryName,
|
|
3867
|
+
action: "overwrite",
|
|
3868
|
+
manifest
|
|
3869
|
+
});
|
|
3870
|
+
continue;
|
|
3871
|
+
}
|
|
3872
|
+
if (flags.yes) {
|
|
3873
|
+
p14.log.info(`Using existing '${modType}/${registryName}'`);
|
|
3874
|
+
resolutions.set(key, {
|
|
3875
|
+
type: modType,
|
|
3876
|
+
registryName,
|
|
3877
|
+
targetName: registryName,
|
|
3878
|
+
action: "reuse",
|
|
3879
|
+
manifest
|
|
3880
|
+
});
|
|
3881
|
+
continue;
|
|
3882
|
+
}
|
|
3883
|
+
const choice = handleCancel(
|
|
3884
|
+
await importPrompts.select({
|
|
3885
|
+
message: `Local '${modType}/${registryName}' differs from the registry version.`,
|
|
3886
|
+
options: [
|
|
3887
|
+
{
|
|
3888
|
+
value: "keep_existing",
|
|
3889
|
+
label: `Keep existing local version (Recommended)`
|
|
3890
|
+
},
|
|
3891
|
+
{
|
|
3892
|
+
value: "point_existing",
|
|
3893
|
+
label: `Point to another existing ${modType} module`
|
|
3894
|
+
},
|
|
3895
|
+
{
|
|
3896
|
+
value: "rename",
|
|
3897
|
+
label: "Import fresh copy under a new name (alias)"
|
|
3898
|
+
},
|
|
3899
|
+
{
|
|
3900
|
+
value: "overwrite",
|
|
3901
|
+
label: "Overwrite local version with registry version"
|
|
3902
|
+
}
|
|
3903
|
+
]
|
|
3904
|
+
})
|
|
3905
|
+
);
|
|
3906
|
+
if (choice === "keep_existing" || choice === "use_existing") {
|
|
3907
|
+
p14.log.step(`Skipping '${modType}/${registryName}' (keeping existing)`);
|
|
3908
|
+
resolutions.set(key, {
|
|
3909
|
+
type: modType,
|
|
3910
|
+
registryName,
|
|
3911
|
+
targetName: registryName,
|
|
3912
|
+
action: "reuse",
|
|
3913
|
+
manifest
|
|
3914
|
+
});
|
|
3915
|
+
continue;
|
|
3916
|
+
}
|
|
3917
|
+
if (choice === "point_existing" || choice === "point_to_existing") {
|
|
3918
|
+
const candidates = getAvailableLocalModules(projectRoot, modType).filter(
|
|
3919
|
+
(m) => m !== registryName
|
|
3843
3920
|
);
|
|
3921
|
+
let chosenName;
|
|
3922
|
+
if (candidates.length > 0) {
|
|
3923
|
+
const selection = handleCancel(
|
|
3924
|
+
await importPrompts.select({
|
|
3925
|
+
message: `Select an existing ${modType} module to point to:`,
|
|
3926
|
+
options: [
|
|
3927
|
+
...candidates.map((m) => ({
|
|
3928
|
+
value: m,
|
|
3929
|
+
label: m
|
|
3930
|
+
})),
|
|
3931
|
+
{
|
|
3932
|
+
value: "__custom__",
|
|
3933
|
+
label: "Enter name manually..."
|
|
3934
|
+
}
|
|
3935
|
+
]
|
|
3936
|
+
})
|
|
3937
|
+
);
|
|
3938
|
+
if (selection === "__custom__") {
|
|
3939
|
+
chosenName = handleCancel(
|
|
3940
|
+
await importPrompts.text({
|
|
3941
|
+
message: `Enter the name of the existing ${modType} module:`,
|
|
3942
|
+
placeholder: `my${registryName}`,
|
|
3943
|
+
validate(val) {
|
|
3944
|
+
const v = val?.trim();
|
|
3945
|
+
if (!v) return "Name cannot be empty";
|
|
3946
|
+
if (v === registryName) {
|
|
3947
|
+
return `Name must be different from '${registryName}' (or select 'Keep existing local version')`;
|
|
3948
|
+
}
|
|
3949
|
+
if (!checkModuleExists(projectRoot, modType, v)) {
|
|
3950
|
+
return `'${v}' does not exist in ${folder}`;
|
|
3951
|
+
}
|
|
3952
|
+
}
|
|
3953
|
+
})
|
|
3954
|
+
).trim();
|
|
3955
|
+
} else {
|
|
3956
|
+
chosenName = selection;
|
|
3957
|
+
}
|
|
3958
|
+
} else {
|
|
3959
|
+
chosenName = handleCancel(
|
|
3960
|
+
await importPrompts.text({
|
|
3961
|
+
message: `Enter the name of the existing ${modType} module:`,
|
|
3962
|
+
placeholder: `my${registryName}`,
|
|
3963
|
+
validate(val) {
|
|
3964
|
+
const v = val?.trim();
|
|
3965
|
+
if (!v) return "Name cannot be empty";
|
|
3966
|
+
if (v === registryName) {
|
|
3967
|
+
return `Name must be different from '${registryName}' (or select 'Keep existing local version')`;
|
|
3968
|
+
}
|
|
3969
|
+
if (!checkModuleExists(projectRoot, modType, v)) {
|
|
3970
|
+
return `'${v}' does not exist in ${folder}`;
|
|
3971
|
+
}
|
|
3972
|
+
}
|
|
3973
|
+
})
|
|
3974
|
+
).trim();
|
|
3975
|
+
}
|
|
3976
|
+
chosenName = chosenName.replace(/^@\/(shared|features)\//, "").replace(/^(src\/)?(shared|features)\//, "").replace(/^\/+|\/+$/g, "").trim();
|
|
3977
|
+
globalAliasMap.set(`@/${folder}/${registryName}/`, `@/${folder}/${chosenName}/`);
|
|
3978
|
+
globalAliasMap.set(`@/${folder}/${registryName}`, `@/${folder}/${chosenName}`);
|
|
3979
|
+
p14.log.step(`Pointing '${modType}/${registryName}' to existing '${folder}/${chosenName}'`);
|
|
3980
|
+
resolutions.set(key, {
|
|
3981
|
+
type: modType,
|
|
3982
|
+
registryName,
|
|
3983
|
+
targetName: chosenName,
|
|
3984
|
+
action: "reuse",
|
|
3985
|
+
manifest
|
|
3986
|
+
});
|
|
3987
|
+
continue;
|
|
3844
3988
|
}
|
|
3845
|
-
|
|
3989
|
+
if (choice === "rename") {
|
|
3990
|
+
const newName = handleCancel(
|
|
3991
|
+
await importPrompts.text({
|
|
3992
|
+
message: "What should we name the new copy?",
|
|
3993
|
+
placeholder: `${registryName}-copy`,
|
|
3994
|
+
validate(val) {
|
|
3995
|
+
const v = val?.trim();
|
|
3996
|
+
if (!v) return "Name cannot be empty";
|
|
3997
|
+
if (v === registryName) return `Name must be different from '${registryName}'`;
|
|
3998
|
+
if (!/^[a-zA-Z0-9_-]+$/.test(v)) {
|
|
3999
|
+
return "Name can only contain alphanumeric characters, dashes, and underscores";
|
|
4000
|
+
}
|
|
4001
|
+
if (checkModuleExists(projectRoot, modType, v)) {
|
|
4002
|
+
return `'${v}' already exists in ${folder}, please choose another name`;
|
|
4003
|
+
}
|
|
4004
|
+
}
|
|
4005
|
+
})
|
|
4006
|
+
).trim();
|
|
4007
|
+
globalAliasMap.set(`@/${folder}/${registryName}/`, `@/${folder}/${newName}/`);
|
|
4008
|
+
globalAliasMap.set(`@/${folder}/${registryName}`, `@/${folder}/${newName}`);
|
|
4009
|
+
const baseDir = getModuleBaseDir(projectRoot, modType);
|
|
4010
|
+
const displayDest = path2.relative(projectRoot, path2.join(baseDir, newName));
|
|
4011
|
+
p14.log.step(`Importing '${registryName}' into '${displayDest}'...`);
|
|
4012
|
+
resolutions.set(key, {
|
|
4013
|
+
type: modType,
|
|
4014
|
+
registryName,
|
|
4015
|
+
targetName: newName,
|
|
4016
|
+
action: "alias",
|
|
4017
|
+
manifest
|
|
4018
|
+
});
|
|
4019
|
+
continue;
|
|
4020
|
+
}
|
|
4021
|
+
if (choice === "overwrite") {
|
|
4022
|
+
p14.log.step(`Overwriting '${modType}/${registryName}' with registry version...`);
|
|
4023
|
+
resolutions.set(key, {
|
|
4024
|
+
type: modType,
|
|
4025
|
+
registryName,
|
|
4026
|
+
targetName: registryName,
|
|
4027
|
+
action: "overwrite",
|
|
4028
|
+
manifest
|
|
4029
|
+
});
|
|
4030
|
+
continue;
|
|
4031
|
+
}
|
|
4032
|
+
}
|
|
4033
|
+
const totalWrittenFiles = [];
|
|
4034
|
+
const requiredNpmPackages = /* @__PURE__ */ new Set();
|
|
4035
|
+
for (const node of nodes.values()) {
|
|
4036
|
+
for (const pkg of node.manifest.dependencies?.npm || []) {
|
|
3846
4037
|
requiredNpmPackages.add(pkg);
|
|
3847
4038
|
}
|
|
3848
|
-
|
|
3849
|
-
|
|
3850
|
-
const
|
|
3851
|
-
|
|
4039
|
+
}
|
|
4040
|
+
for (const key of orderedKeys) {
|
|
4041
|
+
const res = resolutions.get(key);
|
|
4042
|
+
if (res.action === "reuse") {
|
|
4043
|
+
continue;
|
|
4044
|
+
}
|
|
4045
|
+
const folder = res.type === "shared" ? "shared" : "features";
|
|
4046
|
+
const targetDir = path2.join(getModuleBaseDir(projectRoot, res.type), res.targetName);
|
|
4047
|
+
const isOverwrite = Boolean(flags.overwrite || res.action === "overwrite");
|
|
4048
|
+
if (key !== rootKey) {
|
|
4049
|
+
p14.log.step(
|
|
4050
|
+
`Importing ${res.type}: ${pc14.cyan(res.targetName)}${res.targetName !== res.registryName ? pc14.dim(` (from ${res.registryName})`) : ""}...`
|
|
4051
|
+
);
|
|
4052
|
+
}
|
|
4053
|
+
if (res.action === "overwrite" && !flags.dryRun) {
|
|
4054
|
+
const existingDir = getExistingModuleDir(projectRoot, res.type, res.targetName);
|
|
4055
|
+
if (existingDir && existingDir !== targetDir) {
|
|
4056
|
+
fs9.rmSync(existingDir, { recursive: true, force: true });
|
|
4057
|
+
}
|
|
4058
|
+
if (fs9.existsSync(targetDir)) {
|
|
4059
|
+
fs9.rmSync(targetDir, { recursive: true, force: true });
|
|
4060
|
+
}
|
|
4061
|
+
}
|
|
4062
|
+
for (const file of res.manifest.files || []) {
|
|
3852
4063
|
if (file === "registry.json") continue;
|
|
3853
|
-
const remoteFilePath = `${folder}/${registryName}/${file}`;
|
|
4064
|
+
const remoteFilePath = `${folder}/${res.registryName}/${file}`;
|
|
3854
4065
|
const localFilePath = path2.join(targetDir, file);
|
|
3855
4066
|
if (fs9.existsSync(localFilePath) && !isOverwrite) {
|
|
3856
|
-
|
|
4067
|
+
p14.log.warn(
|
|
3857
4068
|
` \u21B3 Skipping existing file: ${pc14.dim(path2.relative(projectRoot, localFilePath))} (use --overwrite to replace)`
|
|
3858
4069
|
);
|
|
3859
4070
|
continue;
|
|
3860
4071
|
}
|
|
3861
4072
|
let content = await fetchRegistryFile(registryBase, remoteFilePath);
|
|
3862
|
-
content = rewriteImports(content,
|
|
4073
|
+
content = rewriteImports(content, globalAliasMap);
|
|
3863
4074
|
if (!flags.dryRun) {
|
|
3864
4075
|
fs9.mkdirSync(path2.dirname(localFilePath), { recursive: true });
|
|
3865
4076
|
fs9.writeFileSync(localFilePath, content, "utf-8");
|
|
3866
4077
|
}
|
|
3867
4078
|
const displayPath = path2.relative(projectRoot, localFilePath);
|
|
3868
4079
|
totalWrittenFiles.push(displayPath);
|
|
3869
|
-
|
|
4080
|
+
p14.log.message(` ${pc14.green("+")} ${displayPath}`);
|
|
3870
4081
|
}
|
|
3871
|
-
importedModules.add(modKey);
|
|
3872
4082
|
}
|
|
3873
|
-
await importModuleRecursive(type, name, name);
|
|
3874
4083
|
const missingNpm = getMissingNpmPackages(projectRoot, Array.from(requiredNpmPackages));
|
|
3875
4084
|
if (missingNpm.length > 0) {
|
|
3876
4085
|
if (flags.skipInstall || flags.dryRun) {
|
|
3877
|
-
|
|
4086
|
+
p14.log.info(`Required npm dependencies to install: ${pc14.cyan(missingNpm.join(", "))}`);
|
|
3878
4087
|
} else {
|
|
3879
4088
|
try {
|
|
3880
4089
|
installNpmPackages(projectRoot, missingNpm);
|
|
3881
4090
|
} catch (err) {
|
|
3882
|
-
|
|
4091
|
+
p14.log.warn(
|
|
4092
|
+
`Could not automatically install packages (${err.message}). Please run: npm install ${missingNpm.join(
|
|
4093
|
+
" "
|
|
4094
|
+
)}`
|
|
4095
|
+
);
|
|
3883
4096
|
}
|
|
3884
4097
|
}
|
|
3885
4098
|
}
|
|
3886
4099
|
if (flags.dryRun) {
|
|
3887
|
-
|
|
4100
|
+
p14.log.info(pc14.yellow("Dry run complete: No files were written to disk."));
|
|
3888
4101
|
} else {
|
|
4102
|
+
const rootRes = resolutions.get(rootKey);
|
|
3889
4103
|
const baseDir = getModuleBaseDir(projectRoot, type);
|
|
3890
|
-
const displayTarget = path2.relative(projectRoot, path2.join(baseDir,
|
|
3891
|
-
|
|
4104
|
+
const displayTarget = path2.relative(projectRoot, path2.join(baseDir, rootRes.targetName));
|
|
4105
|
+
p14.log.success(
|
|
3892
4106
|
pc14.green(
|
|
3893
4107
|
`Successfully imported ${type} '${name}' (${totalWrittenFiles.length} file${totalWrittenFiles.length === 1 ? "" : "s"} placed in ${displayTarget})`
|
|
3894
4108
|
)
|
|
@@ -3899,9 +4113,9 @@ async function handleImport(typeArg, nameArg, flags = {}) {
|
|
|
3899
4113
|
// src/cli.ts
|
|
3900
4114
|
function createCli() {
|
|
3901
4115
|
const cli = cac("mason");
|
|
3902
|
-
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) => {
|
|
4116
|
+
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)").action(async (args, flags) => {
|
|
3903
4117
|
if (args && args.length > 0) {
|
|
3904
|
-
|
|
4118
|
+
p14.log.error(
|
|
3905
4119
|
pc14.red(
|
|
3906
4120
|
`Unknown command: "${args.join(" ")}". Use --help to list available commands.`
|
|
3907
4121
|
)
|
|
@@ -3913,7 +4127,7 @@ function createCli() {
|
|
|
3913
4127
|
const mode = getEffectiveMode(projectRoot, flags);
|
|
3914
4128
|
if (mode === "registry") {
|
|
3915
4129
|
const choice2 = handleCancel(
|
|
3916
|
-
await
|
|
4130
|
+
await p14.select({
|
|
3917
4131
|
message: "\u{1F3DB}\uFE0F Mason (Registry Mode): What would you like to scaffold?",
|
|
3918
4132
|
options: [
|
|
3919
4133
|
{
|
|
@@ -3956,7 +4170,7 @@ function createCli() {
|
|
|
3956
4170
|
return;
|
|
3957
4171
|
}
|
|
3958
4172
|
const choice = handleCancel(
|
|
3959
|
-
await
|
|
4173
|
+
await p14.select({
|
|
3960
4174
|
message: "\u{1F9F1} Mason: What would you like to do?",
|
|
3961
4175
|
options: [
|
|
3962
4176
|
{
|
|
@@ -3994,7 +4208,7 @@ function createCli() {
|
|
|
3994
4208
|
cli.command(
|
|
3995
4209
|
"import [type] [name]",
|
|
3996
4210
|
"Import pre-built shared modules or features from the Solid Stack Registry"
|
|
3997
|
-
).option("-o, --overwrite", "Overwrite existing files").option("-d, --dry-run", "Preview changes without writing to disk").option("-y, --yes", "Accept defaults and skip interactive prompts").option("--registry <url>", "Registry base URL or local directory").option("--skip-install", "Skip automatic package manager dependency installation").example("mason import shared hasher").example("mason import feature authn").example("mason import shared").example("mason import feature").action(async (type, name, flags = {}) => {
|
|
4211
|
+
).option("-o, --overwrite", "Overwrite existing files").option("-d, --dry-run", "Preview changes without writing to disk").option("-y, --yes", "Accept defaults and skip interactive prompts").option("--registry <url>", "Registry base URL or local directory").option("--skip-install", "Skip automatic package manager dependency installation").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)").example("mason import shared hasher").example("mason import feature authn").example("mason import shared").example("mason import feature").action(async (type, name, flags = {}) => {
|
|
3998
4212
|
try {
|
|
3999
4213
|
await handleImport(type, name, flags);
|
|
4000
4214
|
} catch (err) {
|
|
@@ -4024,7 +4238,7 @@ function createCli() {
|
|
|
4024
4238
|
});
|
|
4025
4239
|
}
|
|
4026
4240
|
cli.help();
|
|
4027
|
-
cli.version("1.0.
|
|
4241
|
+
cli.version("1.0.17");
|
|
4028
4242
|
return cli;
|
|
4029
4243
|
}
|
|
4030
4244
|
function handleCliError(err) {
|
|
@@ -4032,7 +4246,7 @@ function handleCliError(err) {
|
|
|
4032
4246
|
process.exit(0);
|
|
4033
4247
|
}
|
|
4034
4248
|
const message = err instanceof Error ? err.message : String(err);
|
|
4035
|
-
|
|
4249
|
+
p14.log.error(pc14.red(`Error: ${message}`));
|
|
4036
4250
|
process.exit(1);
|
|
4037
4251
|
}
|
|
4038
4252
|
async function runCli(argv = process.argv) {
|