@solid-stack/mason 1.0.17 → 1.0.18

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/index.js CHANGED
@@ -147,7 +147,7 @@ function getEffectiveMode(projectRoot, flags) {
147
147
  if (flags?.registry) return "registry";
148
148
  const config = loadMasonConfig(projectRoot);
149
149
  if (config?.mode) return config.mode;
150
- if (fs4.existsSync(path2.join(projectRoot, "index.json")) && (fs4.existsSync(path2.join(projectRoot, "features")) || fs4.existsSync(path2.join(projectRoot, "shared"))) && !fs4.existsSync(path2.join(projectRoot, "src"))) {
150
+ if (fs4.existsSync(path2.join(projectRoot, "index.json")) && (fs4.existsSync(path2.join(projectRoot, "features")) || fs4.existsSync(path2.join(projectRoot, "shared")) || fs4.existsSync(path2.join(projectRoot, "src/features")) || fs4.existsSync(path2.join(projectRoot, "src/shared")))) {
151
151
  return "registry";
152
152
  }
153
153
  return "app";
@@ -161,6 +161,9 @@ function getConfiguredFeaturesDir(projectRoot, flags) {
161
161
  }
162
162
  const mode = getEffectiveMode(projectRoot, flags);
163
163
  if (mode === "registry") {
164
+ if (fs4.existsSync(path2.join(projectRoot, "src/features"))) {
165
+ return path2.join(projectRoot, "src/features");
166
+ }
164
167
  return path2.join(projectRoot, "features");
165
168
  }
166
169
  if (fs4.existsSync(path2.join(projectRoot, "src/features"))) {
@@ -177,6 +180,9 @@ function getConfiguredSharedDir(projectRoot, flags) {
177
180
  }
178
181
  const mode = getEffectiveMode(projectRoot, flags);
179
182
  if (mode === "registry") {
183
+ if (fs4.existsSync(path2.join(projectRoot, "src/shared"))) {
184
+ return path2.join(projectRoot, "src/shared");
185
+ }
180
186
  return path2.join(projectRoot, "shared");
181
187
  }
182
188
  if (fs4.existsSync(path2.join(projectRoot, "src/shared"))) {
@@ -483,7 +489,14 @@ async function fetchRegistryFile(registryBase, relPath) {
483
489
  if (token) {
484
490
  headers["Authorization"] = `Bearer ${token}`;
485
491
  }
486
- const res = await fetch(url, { headers });
492
+ let res = await fetch(url, { headers });
493
+ if (!res.ok && res.status === 404 && !cleanRelPath.startsWith("src/")) {
494
+ const srcUrl = `${registryBase.replace(/\/+$/, "")}/src/${cleanRelPath}`;
495
+ const srcRes = await fetch(srcUrl, { headers });
496
+ if (srcRes.ok) {
497
+ res = srcRes;
498
+ }
499
+ }
487
500
  if (!res.ok) {
488
501
  let extraHint = "";
489
502
  if (res.status === 404) {
@@ -503,9 +516,14 @@ async function fetchRegistryFile(registryBase, relPath) {
503
516
  if (baseDir.startsWith("file://")) {
504
517
  baseDir = fileURLToPath(baseDir);
505
518
  }
506
- const filePath = path2.resolve(baseDir, cleanRelPath);
519
+ let filePath = path2.resolve(baseDir, cleanRelPath);
507
520
  if (!fs4.existsSync(filePath)) {
508
- throw new Error(`Registry file not found at ${filePath}`);
521
+ const inSrcPath = path2.resolve(baseDir, "src", cleanRelPath);
522
+ if (fs4.existsSync(inSrcPath)) {
523
+ filePath = inSrcPath;
524
+ } else {
525
+ throw new Error(`Registry file not found at ${filePath}`);
526
+ }
509
527
  }
510
528
  return fs4.promises.readFile(filePath, "utf-8");
511
529
  }
@@ -3600,11 +3618,18 @@ function rewriteImports(content, aliasMap) {
3600
3618
  return rewritten;
3601
3619
  }
3602
3620
  function getModuleBaseDir(projectRoot, modType) {
3621
+ const mode = getEffectiveMode(projectRoot);
3622
+ if (mode === "registry") {
3623
+ return modType === "shared" ? getConfiguredSharedDir(projectRoot) : getConfiguredFeaturesDir(projectRoot);
3624
+ }
3603
3625
  const folder = modType === "shared" ? "shared" : "features";
3604
3626
  return path2.join(projectRoot, "src", folder);
3605
3627
  }
3606
3628
  function getExistingModuleDir(projectRoot, modType, modName) {
3607
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 (fs4.existsSync(inConfigured)) return inConfigured;
3608
3633
  const inSrc = path2.join(projectRoot, "src", folder, modName);
3609
3634
  if (fs4.existsSync(inSrc)) return inSrc;
3610
3635
  const inRoot = path2.join(projectRoot, folder, modName);
@@ -3616,7 +3641,9 @@ function checkModuleExists(projectRoot, modType, modName) {
3616
3641
  }
3617
3642
  function getAvailableLocalModules(projectRoot, modType) {
3618
3643
  const folder = modType === "shared" ? "shared" : "features";
3644
+ const configuredDir = modType === "shared" ? getConfiguredSharedDir(projectRoot) : getConfiguredFeaturesDir(projectRoot);
3619
3645
  const dirs = [
3646
+ configuredDir,
3620
3647
  path2.join(projectRoot, "src", folder),
3621
3648
  path2.join(projectRoot, folder)
3622
3649
  ];
@@ -4245,7 +4272,7 @@ function createCli() {
4245
4272
  });
4246
4273
  }
4247
4274
  cli.help();
4248
- cli.version("1.0.17");
4275
+ cli.version("1.0.18");
4249
4276
  return cli;
4250
4277
  }
4251
4278
  function handleCliError(err) {