@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.cjs
CHANGED
|
@@ -175,7 +175,7 @@ function getEffectiveMode(projectRoot, flags) {
|
|
|
175
175
|
if (flags?.registry) return "registry";
|
|
176
176
|
const config = loadMasonConfig(projectRoot);
|
|
177
177
|
if (config?.mode) return config.mode;
|
|
178
|
-
if (fs9__default.default.existsSync(path2__default.default.join(projectRoot, "index.json")) && (fs9__default.default.existsSync(path2__default.default.join(projectRoot, "features")) || fs9__default.default.existsSync(path2__default.default.join(projectRoot, "shared")))
|
|
178
|
+
if (fs9__default.default.existsSync(path2__default.default.join(projectRoot, "index.json")) && (fs9__default.default.existsSync(path2__default.default.join(projectRoot, "features")) || fs9__default.default.existsSync(path2__default.default.join(projectRoot, "shared")) || fs9__default.default.existsSync(path2__default.default.join(projectRoot, "src/features")) || fs9__default.default.existsSync(path2__default.default.join(projectRoot, "src/shared")))) {
|
|
179
179
|
return "registry";
|
|
180
180
|
}
|
|
181
181
|
return "app";
|
|
@@ -189,6 +189,9 @@ function getConfiguredFeaturesDir(projectRoot, flags) {
|
|
|
189
189
|
}
|
|
190
190
|
const mode = getEffectiveMode(projectRoot, flags);
|
|
191
191
|
if (mode === "registry") {
|
|
192
|
+
if (fs9__default.default.existsSync(path2__default.default.join(projectRoot, "src/features"))) {
|
|
193
|
+
return path2__default.default.join(projectRoot, "src/features");
|
|
194
|
+
}
|
|
192
195
|
return path2__default.default.join(projectRoot, "features");
|
|
193
196
|
}
|
|
194
197
|
if (fs9__default.default.existsSync(path2__default.default.join(projectRoot, "src/features"))) {
|
|
@@ -205,6 +208,9 @@ function getConfiguredSharedDir(projectRoot, flags) {
|
|
|
205
208
|
}
|
|
206
209
|
const mode = getEffectiveMode(projectRoot, flags);
|
|
207
210
|
if (mode === "registry") {
|
|
211
|
+
if (fs9__default.default.existsSync(path2__default.default.join(projectRoot, "src/shared"))) {
|
|
212
|
+
return path2__default.default.join(projectRoot, "src/shared");
|
|
213
|
+
}
|
|
208
214
|
return path2__default.default.join(projectRoot, "shared");
|
|
209
215
|
}
|
|
210
216
|
if (fs9__default.default.existsSync(path2__default.default.join(projectRoot, "src/shared"))) {
|
|
@@ -3432,7 +3438,14 @@ async function fetchRegistryFile(registryBase, relPath) {
|
|
|
3432
3438
|
if (token) {
|
|
3433
3439
|
headers["Authorization"] = `Bearer ${token}`;
|
|
3434
3440
|
}
|
|
3435
|
-
|
|
3441
|
+
let res = await fetch(url, { headers });
|
|
3442
|
+
if (!res.ok && res.status === 404 && !cleanRelPath.startsWith("src/")) {
|
|
3443
|
+
const srcUrl = `${registryBase.replace(/\/+$/, "")}/src/${cleanRelPath}`;
|
|
3444
|
+
const srcRes = await fetch(srcUrl, { headers });
|
|
3445
|
+
if (srcRes.ok) {
|
|
3446
|
+
res = srcRes;
|
|
3447
|
+
}
|
|
3448
|
+
}
|
|
3436
3449
|
if (!res.ok) {
|
|
3437
3450
|
let extraHint = "";
|
|
3438
3451
|
if (res.status === 404) {
|
|
@@ -3452,9 +3465,14 @@ async function fetchRegistryFile(registryBase, relPath) {
|
|
|
3452
3465
|
if (baseDir.startsWith("file://")) {
|
|
3453
3466
|
baseDir = url.fileURLToPath(baseDir);
|
|
3454
3467
|
}
|
|
3455
|
-
|
|
3468
|
+
let filePath = path2__default.default.resolve(baseDir, cleanRelPath);
|
|
3456
3469
|
if (!fs9__default.default.existsSync(filePath)) {
|
|
3457
|
-
|
|
3470
|
+
const inSrcPath = path2__default.default.resolve(baseDir, "src", cleanRelPath);
|
|
3471
|
+
if (fs9__default.default.existsSync(inSrcPath)) {
|
|
3472
|
+
filePath = inSrcPath;
|
|
3473
|
+
} else {
|
|
3474
|
+
throw new Error(`Registry file not found at ${filePath}`);
|
|
3475
|
+
}
|
|
3458
3476
|
}
|
|
3459
3477
|
return fs9__default.default.promises.readFile(filePath, "utf-8");
|
|
3460
3478
|
}
|
|
@@ -3581,7 +3599,7 @@ function getAllFiles(dir, baseDir = dir) {
|
|
|
3581
3599
|
}
|
|
3582
3600
|
files.push(...getAllFiles(fullPath, baseDir));
|
|
3583
3601
|
} else if (entry.isFile()) {
|
|
3584
|
-
if (entry.name === "registry.json" || entry.name.endsWith(".test.ts") || entry.name.endsWith(".spec.ts") || entry.name.startsWith(".")) {
|
|
3602
|
+
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(".")) {
|
|
3585
3603
|
continue;
|
|
3586
3604
|
}
|
|
3587
3605
|
files.push(relPath);
|
|
@@ -3607,8 +3625,15 @@ function computeDirectoryHash(dirPath, files) {
|
|
|
3607
3625
|
// src/commands/import.ts
|
|
3608
3626
|
var importPrompts = {
|
|
3609
3627
|
select: p14__namespace.select,
|
|
3610
|
-
text: p14__namespace.text
|
|
3628
|
+
text: p14__namespace.text,
|
|
3629
|
+
confirm: p14__namespace.confirm
|
|
3611
3630
|
};
|
|
3631
|
+
function isTestFile(filePath) {
|
|
3632
|
+
const normalized = filePath.replace(/\\/g, "/");
|
|
3633
|
+
const parts = normalized.split("/");
|
|
3634
|
+
const fileName = parts[parts.length - 1] || "";
|
|
3635
|
+
return fileName.endsWith(".test.ts") || fileName.endsWith(".test.js") || fileName.endsWith(".spec.ts") || fileName.endsWith(".spec.js") || parts.includes("__tests__");
|
|
3636
|
+
}
|
|
3612
3637
|
function rewriteImports(content, aliasMap) {
|
|
3613
3638
|
if (aliasMap.size === 0) return content;
|
|
3614
3639
|
let rewritten = content;
|
|
@@ -3622,11 +3647,18 @@ function rewriteImports(content, aliasMap) {
|
|
|
3622
3647
|
return rewritten;
|
|
3623
3648
|
}
|
|
3624
3649
|
function getModuleBaseDir(projectRoot, modType) {
|
|
3650
|
+
const mode = getEffectiveMode(projectRoot);
|
|
3651
|
+
if (mode === "registry") {
|
|
3652
|
+
return modType === "shared" ? getConfiguredSharedDir(projectRoot) : getConfiguredFeaturesDir(projectRoot);
|
|
3653
|
+
}
|
|
3625
3654
|
const folder = modType === "shared" ? "shared" : "features";
|
|
3626
3655
|
return path2__default.default.join(projectRoot, "src", folder);
|
|
3627
3656
|
}
|
|
3628
3657
|
function getExistingModuleDir(projectRoot, modType, modName) {
|
|
3629
3658
|
const folder = modType === "shared" ? "shared" : "features";
|
|
3659
|
+
const configuredDir = modType === "shared" ? getConfiguredSharedDir(projectRoot) : getConfiguredFeaturesDir(projectRoot);
|
|
3660
|
+
const inConfigured = path2__default.default.join(configuredDir, modName);
|
|
3661
|
+
if (fs9__default.default.existsSync(inConfigured)) return inConfigured;
|
|
3630
3662
|
const inSrc = path2__default.default.join(projectRoot, "src", folder, modName);
|
|
3631
3663
|
if (fs9__default.default.existsSync(inSrc)) return inSrc;
|
|
3632
3664
|
const inRoot = path2__default.default.join(projectRoot, folder, modName);
|
|
@@ -3638,7 +3670,9 @@ function checkModuleExists(projectRoot, modType, modName) {
|
|
|
3638
3670
|
}
|
|
3639
3671
|
function getAvailableLocalModules(projectRoot, modType) {
|
|
3640
3672
|
const folder = modType === "shared" ? "shared" : "features";
|
|
3673
|
+
const configuredDir = modType === "shared" ? getConfiguredSharedDir(projectRoot) : getConfiguredFeaturesDir(projectRoot);
|
|
3641
3674
|
const dirs = [
|
|
3675
|
+
configuredDir,
|
|
3642
3676
|
path2__default.default.join(projectRoot, "src", folder),
|
|
3643
3677
|
path2__default.default.join(projectRoot, folder)
|
|
3644
3678
|
];
|
|
@@ -4066,6 +4100,22 @@ async function handleImport(typeArg, nameArg, flags = {}) {
|
|
|
4066
4100
|
requiredNpmPackages.add(pkg);
|
|
4067
4101
|
}
|
|
4068
4102
|
}
|
|
4103
|
+
const hasTestFiles = Array.from(nodes.values()).some(
|
|
4104
|
+
(node) => node.manifest.files?.some((file) => isTestFile(file))
|
|
4105
|
+
);
|
|
4106
|
+
let includeTests = true;
|
|
4107
|
+
if (flags.tests !== void 0) {
|
|
4108
|
+
includeTests = Boolean(flags.tests);
|
|
4109
|
+
} else if (flags.yes) {
|
|
4110
|
+
includeTests = true;
|
|
4111
|
+
} else if (hasTestFiles) {
|
|
4112
|
+
includeTests = handleCancel(
|
|
4113
|
+
await importPrompts.confirm({
|
|
4114
|
+
message: "Include test files?",
|
|
4115
|
+
initialValue: true
|
|
4116
|
+
})
|
|
4117
|
+
);
|
|
4118
|
+
}
|
|
4069
4119
|
for (const key of orderedKeys) {
|
|
4070
4120
|
const res = resolutions.get(key);
|
|
4071
4121
|
if (res.action === "reuse") {
|
|
@@ -4090,6 +4140,7 @@ async function handleImport(typeArg, nameArg, flags = {}) {
|
|
|
4090
4140
|
}
|
|
4091
4141
|
for (const file of res.manifest.files || []) {
|
|
4092
4142
|
if (file === "registry.json") continue;
|
|
4143
|
+
if (!includeTests && isTestFile(file)) continue;
|
|
4093
4144
|
const remoteFilePath = `${folder}/${res.registryName}/${file}`;
|
|
4094
4145
|
const localFilePath = path2__default.default.join(targetDir, file);
|
|
4095
4146
|
if (fs9__default.default.existsSync(localFilePath) && !isOverwrite) {
|
|
@@ -4142,7 +4193,7 @@ async function handleImport(typeArg, nameArg, flags = {}) {
|
|
|
4142
4193
|
// src/cli.ts
|
|
4143
4194
|
function createCli() {
|
|
4144
4195
|
const cli = cac.cac("mason");
|
|
4145
|
-
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) => {
|
|
4196
|
+
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) => {
|
|
4146
4197
|
if (args && args.length > 0) {
|
|
4147
4198
|
p14__namespace.log.error(
|
|
4148
4199
|
pc14__default.default.red(
|
|
@@ -4237,7 +4288,7 @@ function createCli() {
|
|
|
4237
4288
|
cli.command(
|
|
4238
4289
|
"import [type] [name]",
|
|
4239
4290
|
"Import pre-built shared modules or features from the Solid Stack Registry"
|
|
4240
|
-
).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 = {}) => {
|
|
4291
|
+
).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 = {}) => {
|
|
4241
4292
|
try {
|
|
4242
4293
|
await handleImport(type, name, flags);
|
|
4243
4294
|
} catch (err) {
|
|
@@ -4267,7 +4318,7 @@ function createCli() {
|
|
|
4267
4318
|
});
|
|
4268
4319
|
}
|
|
4269
4320
|
cli.help();
|
|
4270
|
-
cli.version("1.0.
|
|
4321
|
+
cli.version("1.0.19");
|
|
4271
4322
|
return cli;
|
|
4272
4323
|
}
|
|
4273
4324
|
function handleCliError(err) {
|