@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/bin.js
CHANGED
|
@@ -146,7 +146,7 @@ function getEffectiveMode(projectRoot, flags) {
|
|
|
146
146
|
if (flags?.registry) return "registry";
|
|
147
147
|
const config = loadMasonConfig(projectRoot);
|
|
148
148
|
if (config?.mode) return config.mode;
|
|
149
|
-
if (fs9.existsSync(path2.join(projectRoot, "index.json")) && (fs9.existsSync(path2.join(projectRoot, "features")) || fs9.existsSync(path2.join(projectRoot, "shared")))
|
|
149
|
+
if (fs9.existsSync(path2.join(projectRoot, "index.json")) && (fs9.existsSync(path2.join(projectRoot, "features")) || fs9.existsSync(path2.join(projectRoot, "shared")) || fs9.existsSync(path2.join(projectRoot, "src/features")) || fs9.existsSync(path2.join(projectRoot, "src/shared")))) {
|
|
150
150
|
return "registry";
|
|
151
151
|
}
|
|
152
152
|
return "app";
|
|
@@ -160,6 +160,9 @@ function getConfiguredFeaturesDir(projectRoot, flags) {
|
|
|
160
160
|
}
|
|
161
161
|
const mode = getEffectiveMode(projectRoot, flags);
|
|
162
162
|
if (mode === "registry") {
|
|
163
|
+
if (fs9.existsSync(path2.join(projectRoot, "src/features"))) {
|
|
164
|
+
return path2.join(projectRoot, "src/features");
|
|
165
|
+
}
|
|
163
166
|
return path2.join(projectRoot, "features");
|
|
164
167
|
}
|
|
165
168
|
if (fs9.existsSync(path2.join(projectRoot, "src/features"))) {
|
|
@@ -176,6 +179,9 @@ function getConfiguredSharedDir(projectRoot, flags) {
|
|
|
176
179
|
}
|
|
177
180
|
const mode = getEffectiveMode(projectRoot, flags);
|
|
178
181
|
if (mode === "registry") {
|
|
182
|
+
if (fs9.existsSync(path2.join(projectRoot, "src/shared"))) {
|
|
183
|
+
return path2.join(projectRoot, "src/shared");
|
|
184
|
+
}
|
|
179
185
|
return path2.join(projectRoot, "shared");
|
|
180
186
|
}
|
|
181
187
|
if (fs9.existsSync(path2.join(projectRoot, "src/shared"))) {
|
|
@@ -3403,7 +3409,14 @@ async function fetchRegistryFile(registryBase, relPath) {
|
|
|
3403
3409
|
if (token) {
|
|
3404
3410
|
headers["Authorization"] = `Bearer ${token}`;
|
|
3405
3411
|
}
|
|
3406
|
-
|
|
3412
|
+
let res = await fetch(url, { headers });
|
|
3413
|
+
if (!res.ok && res.status === 404 && !cleanRelPath.startsWith("src/")) {
|
|
3414
|
+
const srcUrl = `${registryBase.replace(/\/+$/, "")}/src/${cleanRelPath}`;
|
|
3415
|
+
const srcRes = await fetch(srcUrl, { headers });
|
|
3416
|
+
if (srcRes.ok) {
|
|
3417
|
+
res = srcRes;
|
|
3418
|
+
}
|
|
3419
|
+
}
|
|
3407
3420
|
if (!res.ok) {
|
|
3408
3421
|
let extraHint = "";
|
|
3409
3422
|
if (res.status === 404) {
|
|
@@ -3423,9 +3436,14 @@ async function fetchRegistryFile(registryBase, relPath) {
|
|
|
3423
3436
|
if (baseDir.startsWith("file://")) {
|
|
3424
3437
|
baseDir = fileURLToPath(baseDir);
|
|
3425
3438
|
}
|
|
3426
|
-
|
|
3439
|
+
let filePath = path2.resolve(baseDir, cleanRelPath);
|
|
3427
3440
|
if (!fs9.existsSync(filePath)) {
|
|
3428
|
-
|
|
3441
|
+
const inSrcPath = path2.resolve(baseDir, "src", cleanRelPath);
|
|
3442
|
+
if (fs9.existsSync(inSrcPath)) {
|
|
3443
|
+
filePath = inSrcPath;
|
|
3444
|
+
} else {
|
|
3445
|
+
throw new Error(`Registry file not found at ${filePath}`);
|
|
3446
|
+
}
|
|
3429
3447
|
}
|
|
3430
3448
|
return fs9.promises.readFile(filePath, "utf-8");
|
|
3431
3449
|
}
|
|
@@ -3552,7 +3570,7 @@ function getAllFiles(dir, baseDir = dir) {
|
|
|
3552
3570
|
}
|
|
3553
3571
|
files.push(...getAllFiles(fullPath, baseDir));
|
|
3554
3572
|
} else if (entry.isFile()) {
|
|
3555
|
-
if (entry.name === "registry.json" || entry.name.endsWith(".test.ts") || entry.name.endsWith(".spec.ts") || entry.name.startsWith(".")) {
|
|
3573
|
+
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(".")) {
|
|
3556
3574
|
continue;
|
|
3557
3575
|
}
|
|
3558
3576
|
files.push(relPath);
|
|
@@ -3578,8 +3596,15 @@ function computeDirectoryHash(dirPath, files) {
|
|
|
3578
3596
|
// src/commands/import.ts
|
|
3579
3597
|
var importPrompts = {
|
|
3580
3598
|
select: p14.select,
|
|
3581
|
-
text: p14.text
|
|
3599
|
+
text: p14.text,
|
|
3600
|
+
confirm: p14.confirm
|
|
3582
3601
|
};
|
|
3602
|
+
function isTestFile(filePath) {
|
|
3603
|
+
const normalized = filePath.replace(/\\/g, "/");
|
|
3604
|
+
const parts = normalized.split("/");
|
|
3605
|
+
const fileName = parts[parts.length - 1] || "";
|
|
3606
|
+
return fileName.endsWith(".test.ts") || fileName.endsWith(".test.js") || fileName.endsWith(".spec.ts") || fileName.endsWith(".spec.js") || parts.includes("__tests__");
|
|
3607
|
+
}
|
|
3583
3608
|
function rewriteImports(content, aliasMap) {
|
|
3584
3609
|
if (aliasMap.size === 0) return content;
|
|
3585
3610
|
let rewritten = content;
|
|
@@ -3593,11 +3618,18 @@ function rewriteImports(content, aliasMap) {
|
|
|
3593
3618
|
return rewritten;
|
|
3594
3619
|
}
|
|
3595
3620
|
function getModuleBaseDir(projectRoot, modType) {
|
|
3621
|
+
const mode = getEffectiveMode(projectRoot);
|
|
3622
|
+
if (mode === "registry") {
|
|
3623
|
+
return modType === "shared" ? getConfiguredSharedDir(projectRoot) : getConfiguredFeaturesDir(projectRoot);
|
|
3624
|
+
}
|
|
3596
3625
|
const folder = modType === "shared" ? "shared" : "features";
|
|
3597
3626
|
return path2.join(projectRoot, "src", folder);
|
|
3598
3627
|
}
|
|
3599
3628
|
function getExistingModuleDir(projectRoot, modType, modName) {
|
|
3600
3629
|
const folder = modType === "shared" ? "shared" : "features";
|
|
3630
|
+
const configuredDir = modType === "shared" ? getConfiguredSharedDir(projectRoot) : getConfiguredFeaturesDir(projectRoot);
|
|
3631
|
+
const inConfigured = path2.join(configuredDir, modName);
|
|
3632
|
+
if (fs9.existsSync(inConfigured)) return inConfigured;
|
|
3601
3633
|
const inSrc = path2.join(projectRoot, "src", folder, modName);
|
|
3602
3634
|
if (fs9.existsSync(inSrc)) return inSrc;
|
|
3603
3635
|
const inRoot = path2.join(projectRoot, folder, modName);
|
|
@@ -3609,7 +3641,9 @@ function checkModuleExists(projectRoot, modType, modName) {
|
|
|
3609
3641
|
}
|
|
3610
3642
|
function getAvailableLocalModules(projectRoot, modType) {
|
|
3611
3643
|
const folder = modType === "shared" ? "shared" : "features";
|
|
3644
|
+
const configuredDir = modType === "shared" ? getConfiguredSharedDir(projectRoot) : getConfiguredFeaturesDir(projectRoot);
|
|
3612
3645
|
const dirs = [
|
|
3646
|
+
configuredDir,
|
|
3613
3647
|
path2.join(projectRoot, "src", folder),
|
|
3614
3648
|
path2.join(projectRoot, folder)
|
|
3615
3649
|
];
|
|
@@ -4037,6 +4071,22 @@ async function handleImport(typeArg, nameArg, flags = {}) {
|
|
|
4037
4071
|
requiredNpmPackages.add(pkg);
|
|
4038
4072
|
}
|
|
4039
4073
|
}
|
|
4074
|
+
const hasTestFiles = Array.from(nodes.values()).some(
|
|
4075
|
+
(node) => node.manifest.files?.some((file) => isTestFile(file))
|
|
4076
|
+
);
|
|
4077
|
+
let includeTests = true;
|
|
4078
|
+
if (flags.tests !== void 0) {
|
|
4079
|
+
includeTests = Boolean(flags.tests);
|
|
4080
|
+
} else if (flags.yes) {
|
|
4081
|
+
includeTests = true;
|
|
4082
|
+
} else if (hasTestFiles) {
|
|
4083
|
+
includeTests = handleCancel(
|
|
4084
|
+
await importPrompts.confirm({
|
|
4085
|
+
message: "Include test files?",
|
|
4086
|
+
initialValue: true
|
|
4087
|
+
})
|
|
4088
|
+
);
|
|
4089
|
+
}
|
|
4040
4090
|
for (const key of orderedKeys) {
|
|
4041
4091
|
const res = resolutions.get(key);
|
|
4042
4092
|
if (res.action === "reuse") {
|
|
@@ -4061,6 +4111,7 @@ async function handleImport(typeArg, nameArg, flags = {}) {
|
|
|
4061
4111
|
}
|
|
4062
4112
|
for (const file of res.manifest.files || []) {
|
|
4063
4113
|
if (file === "registry.json") continue;
|
|
4114
|
+
if (!includeTests && isTestFile(file)) continue;
|
|
4064
4115
|
const remoteFilePath = `${folder}/${res.registryName}/${file}`;
|
|
4065
4116
|
const localFilePath = path2.join(targetDir, file);
|
|
4066
4117
|
if (fs9.existsSync(localFilePath) && !isOverwrite) {
|
|
@@ -4113,7 +4164,7 @@ async function handleImport(typeArg, nameArg, flags = {}) {
|
|
|
4113
4164
|
// src/cli.ts
|
|
4114
4165
|
function createCli() {
|
|
4115
4166
|
const cli = cac("mason");
|
|
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) => {
|
|
4167
|
+
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) => {
|
|
4117
4168
|
if (args && args.length > 0) {
|
|
4118
4169
|
p14.log.error(
|
|
4119
4170
|
pc14.red(
|
|
@@ -4208,7 +4259,7 @@ function createCli() {
|
|
|
4208
4259
|
cli.command(
|
|
4209
4260
|
"import [type] [name]",
|
|
4210
4261
|
"Import pre-built shared modules or features from the Solid Stack Registry"
|
|
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 = {}) => {
|
|
4262
|
+
).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 = {}) => {
|
|
4212
4263
|
try {
|
|
4213
4264
|
await handleImport(type, name, flags);
|
|
4214
4265
|
} catch (err) {
|
|
@@ -4238,7 +4289,7 @@ function createCli() {
|
|
|
4238
4289
|
});
|
|
4239
4290
|
}
|
|
4240
4291
|
cli.help();
|
|
4241
|
-
cli.version("1.0.
|
|
4292
|
+
cli.version("1.0.19");
|
|
4242
4293
|
return cli;
|
|
4243
4294
|
}
|
|
4244
4295
|
function handleCliError(err) {
|