@solid-stack/mason 1.0.16 → 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 +153 -5
- package/dist/bin.cjs.map +1 -1
- package/dist/bin.js +153 -5
- 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 +153 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +153 -5
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/cli.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AASA,wBAAgB,SAAS,
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AASA,wBAAgB,SAAS,sBAqMxB;AAWD,wBAAsB,MAAM,CAAC,IAAI,GAAE,MAAM,EAAiB,GAAG,OAAO,CAAC,IAAI,CAAC,CAGzE"}
|
|
@@ -5,7 +5,9 @@ export interface ImportFlags {
|
|
|
5
5
|
yes?: boolean;
|
|
6
6
|
registry?: string;
|
|
7
7
|
skipInstall?: boolean;
|
|
8
|
-
alias?: Record<string, string
|
|
8
|
+
alias?: Record<string, string> | string | string[];
|
|
9
|
+
pointTo?: Record<string, string> | string | string[];
|
|
10
|
+
useExisting?: Record<string, string> | string | string[];
|
|
9
11
|
[key: string]: any;
|
|
10
12
|
}
|
|
11
13
|
export declare const importPrompts: {
|
|
@@ -29,5 +31,13 @@ export declare function getExistingModuleDir(projectRoot: string, modType: "shar
|
|
|
29
31
|
* Check whether a module already exists in the project (checking both src/<folder>/<name> and <folder>/<name>)
|
|
30
32
|
*/
|
|
31
33
|
export declare function checkModuleExists(projectRoot: string, modType: "shared" | "feature", modName: string): boolean;
|
|
34
|
+
/**
|
|
35
|
+
* List all available local module names for a given type (checking both src/<folder> and <folder>)
|
|
36
|
+
*/
|
|
37
|
+
export declare function getAvailableLocalModules(projectRoot: string, modType: "shared" | "feature"): string[];
|
|
38
|
+
/**
|
|
39
|
+
* Helper to parse mapping flags like { time: "mytime" } or "time:mytime" or ["time:mytime"]
|
|
40
|
+
*/
|
|
41
|
+
export declare function parseMappingFlags(raw: any): Record<string, string>;
|
|
32
42
|
export declare function handleImport(typeArg?: string, nameArg?: string, flags?: ImportFlags): Promise<void>;
|
|
33
43
|
//# sourceMappingURL=import.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"import.d.ts","sourceRoot":"","sources":["../../src/commands/import.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,CAAC,MAAM,gBAAgB,CAAC;AAiBpC,MAAM,WAAW,WAAW;IAC1B,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"import.d.ts","sourceRoot":"","sources":["../../src/commands/import.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,CAAC,MAAM,gBAAgB,CAAC;AAiBpC,MAAM,WAAW,WAAW;IAC1B,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,MAAM,GAAG,MAAM,EAAE,CAAC;IACnD,OAAO,CAAC,EAAE,MAAM,CAAC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uleDir(projectRoot, modType, modName) {
|
|
|
3643
3643
|
function checkModuleExists(projectRoot, modType, modName) {
|
|
3644
3644
|
return getExistingModuleDir(projectRoot, modType, modName) !== null;
|
|
3645
3645
|
}
|
|
3646
|
+
function getAvailableLocalModules(projectRoot, modType) {
|
|
3647
|
+
const folder = modType === "shared" ? "shared" : "features";
|
|
3648
|
+
const dirs = [
|
|
3649
|
+
path2__default.default.join(projectRoot, "src", folder),
|
|
3650
|
+
path2__default.default.join(projectRoot, folder)
|
|
3651
|
+
];
|
|
3652
|
+
const set = /* @__PURE__ */ new Set();
|
|
3653
|
+
for (const dir of dirs) {
|
|
3654
|
+
if (fs4__default.default.existsSync(dir)) {
|
|
3655
|
+
try {
|
|
3656
|
+
const entries = fs4__default.default.readdirSync(dir, { withFileTypes: true });
|
|
3657
|
+
for (const e of entries) {
|
|
3658
|
+
if (e.isDirectory() && !e.name.startsWith(".")) {
|
|
3659
|
+
set.add(e.name);
|
|
3660
|
+
}
|
|
3661
|
+
}
|
|
3662
|
+
} catch {
|
|
3663
|
+
}
|
|
3664
|
+
}
|
|
3665
|
+
}
|
|
3666
|
+
return Array.from(set).sort();
|
|
3667
|
+
}
|
|
3668
|
+
function parseMappingFlags(raw) {
|
|
3669
|
+
if (!raw) return {};
|
|
3670
|
+
if (typeof raw === "object" && !Array.isArray(raw)) return raw;
|
|
3671
|
+
const result = {};
|
|
3672
|
+
const entries = Array.isArray(raw) ? raw : [raw];
|
|
3673
|
+
for (const entry of entries) {
|
|
3674
|
+
if (typeof entry === "string") {
|
|
3675
|
+
const idx = entry.indexOf(":");
|
|
3676
|
+
if (idx !== -1) {
|
|
3677
|
+
let key = entry.slice(0, idx).trim();
|
|
3678
|
+
let val = entry.slice(idx + 1).trim();
|
|
3679
|
+
val = val.replace(/^@\/(shared|features)\//, "").replace(/^(src\/)?(shared|features)\//, "").replace(/^\/+|\/+$/g, "").trim();
|
|
3680
|
+
if (key && val) {
|
|
3681
|
+
result[key] = val;
|
|
3682
|
+
}
|
|
3683
|
+
}
|
|
3684
|
+
}
|
|
3685
|
+
}
|
|
3686
|
+
return result;
|
|
3687
|
+
}
|
|
3646
3688
|
async function handleImport(typeArg, nameArg, flags = {}) {
|
|
3647
3689
|
const projectRoot = findProjectRoot();
|
|
3648
3690
|
let type = typeArg?.trim().toLowerCase();
|
|
@@ -3763,7 +3805,8 @@ async function handleImport(typeArg, nameArg, flags = {}) {
|
|
|
3763
3805
|
const { type: modType, name: registryName, manifest } = node;
|
|
3764
3806
|
const folder = modType === "shared" ? "shared" : "features";
|
|
3765
3807
|
if (key === rootKey) {
|
|
3766
|
-
const
|
|
3808
|
+
const aliasMap2 = parseMappingFlags(flags.alias);
|
|
3809
|
+
const programmaticAlias2 = aliasMap2[registryName] || aliasMap2[`${modType}/${registryName}`];
|
|
3767
3810
|
const targetName = programmaticAlias2 || registryName;
|
|
3768
3811
|
if (targetName !== registryName) {
|
|
3769
3812
|
globalAliasMap.set(`@/${folder}/${registryName}/`, `@/${folder}/${targetName}/`);
|
|
@@ -3778,7 +3821,36 @@ async function handleImport(typeArg, nameArg, flags = {}) {
|
|
|
3778
3821
|
});
|
|
3779
3822
|
continue;
|
|
3780
3823
|
}
|
|
3781
|
-
const
|
|
3824
|
+
const aliasMap = parseMappingFlags(flags.alias);
|
|
3825
|
+
const pointToMap = {
|
|
3826
|
+
...parseMappingFlags(flags.pointTo),
|
|
3827
|
+
...parseMappingFlags(flags["point-to"]),
|
|
3828
|
+
...parseMappingFlags(flags.useExisting),
|
|
3829
|
+
...parseMappingFlags(flags["use-existing"])
|
|
3830
|
+
};
|
|
3831
|
+
const programmaticPointTo = pointToMap[registryName] || pointToMap[`${modType}/${registryName}`];
|
|
3832
|
+
if (programmaticPointTo) {
|
|
3833
|
+
if (!checkModuleExists(projectRoot, modType, programmaticPointTo)) {
|
|
3834
|
+
p14__namespace.log.error(
|
|
3835
|
+
pc14__default.default.red(
|
|
3836
|
+
`Module '${programmaticPointTo}' specified in --point-to does not exist in ${folder}.`
|
|
3837
|
+
)
|
|
3838
|
+
);
|
|
3839
|
+
process.exit(1);
|
|
3840
|
+
}
|
|
3841
|
+
globalAliasMap.set(`@/${folder}/${registryName}/`, `@/${folder}/${programmaticPointTo}/`);
|
|
3842
|
+
globalAliasMap.set(`@/${folder}/${registryName}`, `@/${folder}/${programmaticPointTo}`);
|
|
3843
|
+
p14__namespace.log.step(`Pointing '${modType}/${registryName}' to existing '${folder}/${programmaticPointTo}'`);
|
|
3844
|
+
resolutions.set(key, {
|
|
3845
|
+
type: modType,
|
|
3846
|
+
registryName,
|
|
3847
|
+
targetName: programmaticPointTo,
|
|
3848
|
+
action: "reuse",
|
|
3849
|
+
manifest
|
|
3850
|
+
});
|
|
3851
|
+
continue;
|
|
3852
|
+
}
|
|
3853
|
+
const programmaticAlias = aliasMap[registryName] || aliasMap[`${modType}/${registryName}`];
|
|
3782
3854
|
if (programmaticAlias) {
|
|
3783
3855
|
globalAliasMap.set(`@/${folder}/${registryName}/`, `@/${folder}/${programmaticAlias}/`);
|
|
3784
3856
|
globalAliasMap.set(`@/${folder}/${registryName}`, `@/${folder}/${programmaticAlias}`);
|
|
@@ -3852,6 +3924,10 @@ async function handleImport(typeArg, nameArg, flags = {}) {
|
|
|
3852
3924
|
value: "keep_existing",
|
|
3853
3925
|
label: `Keep existing local version (Recommended)`
|
|
3854
3926
|
},
|
|
3927
|
+
{
|
|
3928
|
+
value: "point_existing",
|
|
3929
|
+
label: `Point to another existing ${modType} module`
|
|
3930
|
+
},
|
|
3855
3931
|
{
|
|
3856
3932
|
value: "rename",
|
|
3857
3933
|
label: "Import fresh copy under a new name (alias)"
|
|
@@ -3874,6 +3950,78 @@ async function handleImport(typeArg, nameArg, flags = {}) {
|
|
|
3874
3950
|
});
|
|
3875
3951
|
continue;
|
|
3876
3952
|
}
|
|
3953
|
+
if (choice === "point_existing" || choice === "point_to_existing") {
|
|
3954
|
+
const candidates = getAvailableLocalModules(projectRoot, modType).filter(
|
|
3955
|
+
(m) => m !== registryName
|
|
3956
|
+
);
|
|
3957
|
+
let chosenName;
|
|
3958
|
+
if (candidates.length > 0) {
|
|
3959
|
+
const selection = handleCancel(
|
|
3960
|
+
await importPrompts.select({
|
|
3961
|
+
message: `Select an existing ${modType} module to point to:`,
|
|
3962
|
+
options: [
|
|
3963
|
+
...candidates.map((m) => ({
|
|
3964
|
+
value: m,
|
|
3965
|
+
label: m
|
|
3966
|
+
})),
|
|
3967
|
+
{
|
|
3968
|
+
value: "__custom__",
|
|
3969
|
+
label: "Enter name manually..."
|
|
3970
|
+
}
|
|
3971
|
+
]
|
|
3972
|
+
})
|
|
3973
|
+
);
|
|
3974
|
+
if (selection === "__custom__") {
|
|
3975
|
+
chosenName = handleCancel(
|
|
3976
|
+
await importPrompts.text({
|
|
3977
|
+
message: `Enter the name of the existing ${modType} module:`,
|
|
3978
|
+
placeholder: `my${registryName}`,
|
|
3979
|
+
validate(val) {
|
|
3980
|
+
const v = val?.trim();
|
|
3981
|
+
if (!v) return "Name cannot be empty";
|
|
3982
|
+
if (v === registryName) {
|
|
3983
|
+
return `Name must be different from '${registryName}' (or select 'Keep existing local version')`;
|
|
3984
|
+
}
|
|
3985
|
+
if (!checkModuleExists(projectRoot, modType, v)) {
|
|
3986
|
+
return `'${v}' does not exist in ${folder}`;
|
|
3987
|
+
}
|
|
3988
|
+
}
|
|
3989
|
+
})
|
|
3990
|
+
).trim();
|
|
3991
|
+
} else {
|
|
3992
|
+
chosenName = selection;
|
|
3993
|
+
}
|
|
3994
|
+
} else {
|
|
3995
|
+
chosenName = handleCancel(
|
|
3996
|
+
await importPrompts.text({
|
|
3997
|
+
message: `Enter the name of the existing ${modType} module:`,
|
|
3998
|
+
placeholder: `my${registryName}`,
|
|
3999
|
+
validate(val) {
|
|
4000
|
+
const v = val?.trim();
|
|
4001
|
+
if (!v) return "Name cannot be empty";
|
|
4002
|
+
if (v === registryName) {
|
|
4003
|
+
return `Name must be different from '${registryName}' (or select 'Keep existing local version')`;
|
|
4004
|
+
}
|
|
4005
|
+
if (!checkModuleExists(projectRoot, modType, v)) {
|
|
4006
|
+
return `'${v}' does not exist in ${folder}`;
|
|
4007
|
+
}
|
|
4008
|
+
}
|
|
4009
|
+
})
|
|
4010
|
+
).trim();
|
|
4011
|
+
}
|
|
4012
|
+
chosenName = chosenName.replace(/^@\/(shared|features)\//, "").replace(/^(src\/)?(shared|features)\//, "").replace(/^\/+|\/+$/g, "").trim();
|
|
4013
|
+
globalAliasMap.set(`@/${folder}/${registryName}/`, `@/${folder}/${chosenName}/`);
|
|
4014
|
+
globalAliasMap.set(`@/${folder}/${registryName}`, `@/${folder}/${chosenName}`);
|
|
4015
|
+
p14__namespace.log.step(`Pointing '${modType}/${registryName}' to existing '${folder}/${chosenName}'`);
|
|
4016
|
+
resolutions.set(key, {
|
|
4017
|
+
type: modType,
|
|
4018
|
+
registryName,
|
|
4019
|
+
targetName: chosenName,
|
|
4020
|
+
action: "reuse",
|
|
4021
|
+
manifest
|
|
4022
|
+
});
|
|
4023
|
+
continue;
|
|
4024
|
+
}
|
|
3877
4025
|
if (choice === "rename") {
|
|
3878
4026
|
const newName = handleCancel(
|
|
3879
4027
|
await importPrompts.text({
|
|
@@ -4001,7 +4149,7 @@ async function handleImport(typeArg, nameArg, flags = {}) {
|
|
|
4001
4149
|
// src/cli.ts
|
|
4002
4150
|
function createCli() {
|
|
4003
4151
|
const cli = cac.cac("mason");
|
|
4004
|
-
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) => {
|
|
4152
|
+
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) => {
|
|
4005
4153
|
if (args && args.length > 0) {
|
|
4006
4154
|
p14__namespace.log.error(
|
|
4007
4155
|
pc14__default.default.red(
|
|
@@ -4096,7 +4244,7 @@ function createCli() {
|
|
|
4096
4244
|
cli.command(
|
|
4097
4245
|
"import [type] [name]",
|
|
4098
4246
|
"Import pre-built shared modules or features from the Solid Stack Registry"
|
|
4099
|
-
).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 = {}) => {
|
|
4247
|
+
).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 = {}) => {
|
|
4100
4248
|
try {
|
|
4101
4249
|
await handleImport(type, name, flags);
|
|
4102
4250
|
} catch (err) {
|
|
@@ -4126,7 +4274,7 @@ function createCli() {
|
|
|
4126
4274
|
});
|
|
4127
4275
|
}
|
|
4128
4276
|
cli.help();
|
|
4129
|
-
cli.version("1.0.
|
|
4277
|
+
cli.version("1.0.17");
|
|
4130
4278
|
return cli;
|
|
4131
4279
|
}
|
|
4132
4280
|
function handleCliError(err) {
|