@solid-stack/mason 1.0.17 → 1.0.20
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 +60 -9
- package/dist/bin.cjs.map +1 -1
- package/dist/bin.js +60 -9
- package/dist/bin.js.map +1 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/commands/import.d.ts +8 -2
- package/dist/commands/import.d.ts.map +1 -1
- package/dist/index.cjs +60 -9
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +60 -9
- package/dist/index.js.map +1 -1
- package/dist/utils/config.d.ts.map +1 -1
- package/dist/utils/integrity.d.ts.map +1 -1
- package/dist/utils/registry.d.ts.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,sBAuMxB;AAWD,wBAAsB,MAAM,CAAC,IAAI,GAAE,MAAM,EAAiB,GAAG,OAAO,CAAC,IAAI,CAAC,CAGzE"}
|
|
@@ -8,12 +8,18 @@ export interface ImportFlags {
|
|
|
8
8
|
alias?: Record<string, string> | string | string[];
|
|
9
9
|
pointTo?: Record<string, string> | string | string[];
|
|
10
10
|
useExisting?: Record<string, string> | string | string[];
|
|
11
|
+
tests?: boolean;
|
|
11
12
|
[key: string]: any;
|
|
12
13
|
}
|
|
13
14
|
export declare const importPrompts: {
|
|
14
15
|
select: <Value>(opts: p.SelectOptions<Value>) => Promise<Value | typeof p.CANCEL_SYMBOL>;
|
|
15
16
|
text: (opts: p.TextOptions) => Promise<string | typeof p.CANCEL_SYMBOL>;
|
|
17
|
+
confirm: (opts: p.ConfirmOptions) => Promise<boolean | typeof p.CANCEL_SYMBOL>;
|
|
16
18
|
};
|
|
19
|
+
/**
|
|
20
|
+
* Checks whether a given relative file path is a test file.
|
|
21
|
+
*/
|
|
22
|
+
export declare function isTestFile(filePath: string): boolean;
|
|
17
23
|
/**
|
|
18
24
|
* Rewrite import strings across file content based on an alias mapping.
|
|
19
25
|
* E.g. "@/shared/hasher/" -> "@/shared/auth-hasher/"
|
|
@@ -24,7 +30,7 @@ export declare function rewriteImports(content: string, aliasMap: Map<string, st
|
|
|
24
30
|
*/
|
|
25
31
|
export declare function getModuleBaseDir(projectRoot: string, modType: "shared" | "feature"): string;
|
|
26
32
|
/**
|
|
27
|
-
* Resolves the existing directory path for a module in the project, checking
|
|
33
|
+
* Resolves the existing directory path for a module in the project, checking configured dirs, src/<folder>/<name>, and <folder>/<name>.
|
|
28
34
|
*/
|
|
29
35
|
export declare function getExistingModuleDir(projectRoot: string, modType: "shared" | "feature", modName: string): string | null;
|
|
30
36
|
/**
|
|
@@ -32,7 +38,7 @@ export declare function getExistingModuleDir(projectRoot: string, modType: "shar
|
|
|
32
38
|
*/
|
|
33
39
|
export declare function checkModuleExists(projectRoot: string, modType: "shared" | "feature", modName: string): boolean;
|
|
34
40
|
/**
|
|
35
|
-
* List all available local module names for a given type (checking
|
|
41
|
+
* List all available local module names for a given type (checking configured dir, src/<folder>, and <folder>)
|
|
36
42
|
*/
|
|
37
43
|
export declare function getAvailableLocalModules(projectRoot: string, modType: "shared" | "feature"): string[];
|
|
38
44
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"import.d.ts","sourceRoot":"","sources":["../../src/commands/import.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,CAAC,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"import.d.ts","sourceRoot":"","sources":["../../src/commands/import.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,CAAC,MAAM,gBAAgB,CAAC;AAkBpC,MAAM,WAAW,WAAW;IAC1B,SAAS,CAAC,EAAE,OAAO,CAAC;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,CACtC,WAAW,EAAE,MAAM,EACnB,OAAO,EAAE,QAAQ,GAAG,SAAS,GAC5B,MAAM,EAAE,CAwBV;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,GAAG,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAuBlE;AAgBD,wBAAsB,YAAY,CAChC,OAAO,CAAC,EAAE,MAAM,EAChB,OAAO,CAAC,EAAE,MAAM,EAChB,KAAK,GAAE,WAAgB,GACtB,OAAO,CAAC,IAAI,CAAC,CA8jBf"}
|
package/dist/index.cjs
CHANGED
|
@@ -176,7 +176,7 @@ function getEffectiveMode(projectRoot, flags) {
|
|
|
176
176
|
if (flags?.registry) return "registry";
|
|
177
177
|
const config = loadMasonConfig(projectRoot);
|
|
178
178
|
if (config?.mode) return config.mode;
|
|
179
|
-
if (fs4__default.default.existsSync(path2__default.default.join(projectRoot, "index.json")) && (fs4__default.default.existsSync(path2__default.default.join(projectRoot, "features")) || fs4__default.default.existsSync(path2__default.default.join(projectRoot, "shared")))
|
|
179
|
+
if (fs4__default.default.existsSync(path2__default.default.join(projectRoot, "index.json")) && (fs4__default.default.existsSync(path2__default.default.join(projectRoot, "features")) || fs4__default.default.existsSync(path2__default.default.join(projectRoot, "shared")) || fs4__default.default.existsSync(path2__default.default.join(projectRoot, "src/features")) || fs4__default.default.existsSync(path2__default.default.join(projectRoot, "src/shared")))) {
|
|
180
180
|
return "registry";
|
|
181
181
|
}
|
|
182
182
|
return "app";
|
|
@@ -190,6 +190,9 @@ function getConfiguredFeaturesDir(projectRoot, flags) {
|
|
|
190
190
|
}
|
|
191
191
|
const mode = getEffectiveMode(projectRoot, flags);
|
|
192
192
|
if (mode === "registry") {
|
|
193
|
+
if (fs4__default.default.existsSync(path2__default.default.join(projectRoot, "src/features"))) {
|
|
194
|
+
return path2__default.default.join(projectRoot, "src/features");
|
|
195
|
+
}
|
|
193
196
|
return path2__default.default.join(projectRoot, "features");
|
|
194
197
|
}
|
|
195
198
|
if (fs4__default.default.existsSync(path2__default.default.join(projectRoot, "src/features"))) {
|
|
@@ -206,6 +209,9 @@ function getConfiguredSharedDir(projectRoot, flags) {
|
|
|
206
209
|
}
|
|
207
210
|
const mode = getEffectiveMode(projectRoot, flags);
|
|
208
211
|
if (mode === "registry") {
|
|
212
|
+
if (fs4__default.default.existsSync(path2__default.default.join(projectRoot, "src/shared"))) {
|
|
213
|
+
return path2__default.default.join(projectRoot, "src/shared");
|
|
214
|
+
}
|
|
209
215
|
return path2__default.default.join(projectRoot, "shared");
|
|
210
216
|
}
|
|
211
217
|
if (fs4__default.default.existsSync(path2__default.default.join(projectRoot, "src/shared"))) {
|
|
@@ -512,7 +518,14 @@ async function fetchRegistryFile(registryBase, relPath) {
|
|
|
512
518
|
if (token) {
|
|
513
519
|
headers["Authorization"] = `Bearer ${token}`;
|
|
514
520
|
}
|
|
515
|
-
|
|
521
|
+
let res = await fetch(url, { headers });
|
|
522
|
+
if (!res.ok && res.status === 404 && !cleanRelPath.startsWith("src/")) {
|
|
523
|
+
const srcUrl = `${registryBase.replace(/\/+$/, "")}/src/${cleanRelPath}`;
|
|
524
|
+
const srcRes = await fetch(srcUrl, { headers });
|
|
525
|
+
if (srcRes.ok) {
|
|
526
|
+
res = srcRes;
|
|
527
|
+
}
|
|
528
|
+
}
|
|
516
529
|
if (!res.ok) {
|
|
517
530
|
let extraHint = "";
|
|
518
531
|
if (res.status === 404) {
|
|
@@ -532,9 +545,14 @@ async function fetchRegistryFile(registryBase, relPath) {
|
|
|
532
545
|
if (baseDir.startsWith("file://")) {
|
|
533
546
|
baseDir = url.fileURLToPath(baseDir);
|
|
534
547
|
}
|
|
535
|
-
|
|
548
|
+
let filePath = path2__default.default.resolve(baseDir, cleanRelPath);
|
|
536
549
|
if (!fs4__default.default.existsSync(filePath)) {
|
|
537
|
-
|
|
550
|
+
const inSrcPath = path2__default.default.resolve(baseDir, "src", cleanRelPath);
|
|
551
|
+
if (fs4__default.default.existsSync(inSrcPath)) {
|
|
552
|
+
filePath = inSrcPath;
|
|
553
|
+
} else {
|
|
554
|
+
throw new Error(`Registry file not found at ${filePath}`);
|
|
555
|
+
}
|
|
538
556
|
}
|
|
539
557
|
return fs4__default.default.promises.readFile(filePath, "utf-8");
|
|
540
558
|
}
|
|
@@ -661,7 +679,7 @@ function getAllFiles(dir, baseDir = dir) {
|
|
|
661
679
|
}
|
|
662
680
|
files.push(...getAllFiles(fullPath, baseDir));
|
|
663
681
|
} else if (entry.isFile()) {
|
|
664
|
-
if (entry.name === "registry.json" || entry.name.endsWith(".test.ts") || entry.name.endsWith(".spec.ts") || entry.name.startsWith(".")) {
|
|
682
|
+
if (entry.name === "registry.json" || entry.name.endsWith(".test.ts") || entry.name.endsWith(".spec.ts") || entry.name.endsWith(".test.js") || entry.name.endsWith(".spec.js") || entry.name.startsWith(".")) {
|
|
665
683
|
continue;
|
|
666
684
|
}
|
|
667
685
|
files.push(relPath);
|
|
@@ -3614,8 +3632,15 @@ async function handleCreate(type, name, flags = {}) {
|
|
|
3614
3632
|
}
|
|
3615
3633
|
var importPrompts = {
|
|
3616
3634
|
select: p14__namespace.select,
|
|
3617
|
-
text: p14__namespace.text
|
|
3635
|
+
text: p14__namespace.text,
|
|
3636
|
+
confirm: p14__namespace.confirm
|
|
3618
3637
|
};
|
|
3638
|
+
function isTestFile(filePath) {
|
|
3639
|
+
const normalized = filePath.replace(/\\/g, "/");
|
|
3640
|
+
const parts = normalized.split("/");
|
|
3641
|
+
const fileName = parts[parts.length - 1] || "";
|
|
3642
|
+
return fileName.endsWith(".test.ts") || fileName.endsWith(".test.js") || fileName.endsWith(".spec.ts") || fileName.endsWith(".spec.js") || parts.includes("__tests__");
|
|
3643
|
+
}
|
|
3619
3644
|
function rewriteImports(content, aliasMap) {
|
|
3620
3645
|
if (aliasMap.size === 0) return content;
|
|
3621
3646
|
let rewritten = content;
|
|
@@ -3629,11 +3654,18 @@ function rewriteImports(content, aliasMap) {
|
|
|
3629
3654
|
return rewritten;
|
|
3630
3655
|
}
|
|
3631
3656
|
function getModuleBaseDir(projectRoot, modType) {
|
|
3657
|
+
const mode = getEffectiveMode(projectRoot);
|
|
3658
|
+
if (mode === "registry") {
|
|
3659
|
+
return modType === "shared" ? getConfiguredSharedDir(projectRoot) : getConfiguredFeaturesDir(projectRoot);
|
|
3660
|
+
}
|
|
3632
3661
|
const folder = modType === "shared" ? "shared" : "features";
|
|
3633
3662
|
return path2__default.default.join(projectRoot, "src", folder);
|
|
3634
3663
|
}
|
|
3635
3664
|
function getExistingModuleDir(projectRoot, modType, modName) {
|
|
3636
3665
|
const folder = modType === "shared" ? "shared" : "features";
|
|
3666
|
+
const configuredDir = modType === "shared" ? getConfiguredSharedDir(projectRoot) : getConfiguredFeaturesDir(projectRoot);
|
|
3667
|
+
const inConfigured = path2__default.default.join(configuredDir, modName);
|
|
3668
|
+
if (fs4__default.default.existsSync(inConfigured)) return inConfigured;
|
|
3637
3669
|
const inSrc = path2__default.default.join(projectRoot, "src", folder, modName);
|
|
3638
3670
|
if (fs4__default.default.existsSync(inSrc)) return inSrc;
|
|
3639
3671
|
const inRoot = path2__default.default.join(projectRoot, folder, modName);
|
|
@@ -3645,7 +3677,9 @@ function checkModuleExists(projectRoot, modType, modName) {
|
|
|
3645
3677
|
}
|
|
3646
3678
|
function getAvailableLocalModules(projectRoot, modType) {
|
|
3647
3679
|
const folder = modType === "shared" ? "shared" : "features";
|
|
3680
|
+
const configuredDir = modType === "shared" ? getConfiguredSharedDir(projectRoot) : getConfiguredFeaturesDir(projectRoot);
|
|
3648
3681
|
const dirs = [
|
|
3682
|
+
configuredDir,
|
|
3649
3683
|
path2__default.default.join(projectRoot, "src", folder),
|
|
3650
3684
|
path2__default.default.join(projectRoot, folder)
|
|
3651
3685
|
];
|
|
@@ -4073,6 +4107,22 @@ async function handleImport(typeArg, nameArg, flags = {}) {
|
|
|
4073
4107
|
requiredNpmPackages.add(pkg);
|
|
4074
4108
|
}
|
|
4075
4109
|
}
|
|
4110
|
+
const hasTestFiles = Array.from(nodes.values()).some(
|
|
4111
|
+
(node) => node.manifest.files?.some((file) => isTestFile(file))
|
|
4112
|
+
);
|
|
4113
|
+
let includeTests = true;
|
|
4114
|
+
if (flags.tests !== void 0) {
|
|
4115
|
+
includeTests = Boolean(flags.tests);
|
|
4116
|
+
} else if (flags.yes) {
|
|
4117
|
+
includeTests = true;
|
|
4118
|
+
} else if (hasTestFiles) {
|
|
4119
|
+
includeTests = handleCancel(
|
|
4120
|
+
await importPrompts.confirm({
|
|
4121
|
+
message: "Include test files?",
|
|
4122
|
+
initialValue: true
|
|
4123
|
+
})
|
|
4124
|
+
);
|
|
4125
|
+
}
|
|
4076
4126
|
for (const key of orderedKeys) {
|
|
4077
4127
|
const res = resolutions.get(key);
|
|
4078
4128
|
if (res.action === "reuse") {
|
|
@@ -4097,6 +4147,7 @@ async function handleImport(typeArg, nameArg, flags = {}) {
|
|
|
4097
4147
|
}
|
|
4098
4148
|
for (const file of res.manifest.files || []) {
|
|
4099
4149
|
if (file === "registry.json") continue;
|
|
4150
|
+
if (!includeTests && isTestFile(file)) continue;
|
|
4100
4151
|
const remoteFilePath = `${folder}/${res.registryName}/${file}`;
|
|
4101
4152
|
const localFilePath = path2__default.default.join(targetDir, file);
|
|
4102
4153
|
if (fs4__default.default.existsSync(localFilePath) && !isOverwrite) {
|
|
@@ -4149,7 +4200,7 @@ async function handleImport(typeArg, nameArg, flags = {}) {
|
|
|
4149
4200
|
// src/cli.ts
|
|
4150
4201
|
function createCli() {
|
|
4151
4202
|
const cli = cac.cac("mason");
|
|
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) => {
|
|
4203
|
+
cli.command("[...args]", "Interactive scaffolding and import wizard").option("-d, --dry-run", "Preview changes without writing to disk").option("-o, --overwrite", "Overwrite existing files").option("-y, --yes", "Accept defaults and skip interactive prompts").option("--registry", "Run in registry mode").option("--point-to <mapping>", "Point a dependency to an existing local module (e.g. --point-to time:mytime)").option("--alias <mapping>", "Import a dependency fresh under an alias name (e.g. --alias time:time-mason)").option("--tests", "Include test files (use --no-tests to exclude)").action(async (args, flags) => {
|
|
4153
4204
|
if (args && args.length > 0) {
|
|
4154
4205
|
p14__namespace.log.error(
|
|
4155
4206
|
pc14__default.default.red(
|
|
@@ -4244,7 +4295,7 @@ function createCli() {
|
|
|
4244
4295
|
cli.command(
|
|
4245
4296
|
"import [type] [name]",
|
|
4246
4297
|
"Import pre-built shared modules or features from the Solid Stack Registry"
|
|
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 = {}) => {
|
|
4298
|
+
).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)").option("--tests", "Include test files (use --no-tests to exclude)").example("mason import shared hasher").example("mason import feature authn").example("mason import shared").example("mason import feature").action(async (type, name, flags = {}) => {
|
|
4248
4299
|
try {
|
|
4249
4300
|
await handleImport(type, name, flags);
|
|
4250
4301
|
} catch (err) {
|
|
@@ -4274,7 +4325,7 @@ function createCli() {
|
|
|
4274
4325
|
});
|
|
4275
4326
|
}
|
|
4276
4327
|
cli.help();
|
|
4277
|
-
cli.version("1.0.
|
|
4328
|
+
cli.version("1.0.19");
|
|
4278
4329
|
return cli;
|
|
4279
4330
|
}
|
|
4280
4331
|
function handleCliError(err) {
|