@solid-stack/mason 1.0.18 → 1.0.21

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 CHANGED
@@ -3599,7 +3599,7 @@ function getAllFiles(dir, baseDir = dir) {
3599
3599
  }
3600
3600
  files.push(...getAllFiles(fullPath, baseDir));
3601
3601
  } else if (entry.isFile()) {
3602
- 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(".")) {
3603
3603
  continue;
3604
3604
  }
3605
3605
  files.push(relPath);
@@ -3625,8 +3625,15 @@ function computeDirectoryHash(dirPath, files) {
3625
3625
  // src/commands/import.ts
3626
3626
  var importPrompts = {
3627
3627
  select: p14__namespace.select,
3628
- text: p14__namespace.text
3628
+ text: p14__namespace.text,
3629
+ confirm: p14__namespace.confirm
3629
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
+ }
3630
3637
  function rewriteImports(content, aliasMap) {
3631
3638
  if (aliasMap.size === 0) return content;
3632
3639
  let rewritten = content;
@@ -4093,6 +4100,22 @@ async function handleImport(typeArg, nameArg, flags = {}) {
4093
4100
  requiredNpmPackages.add(pkg);
4094
4101
  }
4095
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
+ }
4096
4119
  for (const key of orderedKeys) {
4097
4120
  const res = resolutions.get(key);
4098
4121
  if (res.action === "reuse") {
@@ -4117,6 +4140,7 @@ async function handleImport(typeArg, nameArg, flags = {}) {
4117
4140
  }
4118
4141
  for (const file of res.manifest.files || []) {
4119
4142
  if (file === "registry.json") continue;
4143
+ if (!includeTests && isTestFile(file)) continue;
4120
4144
  const remoteFilePath = `${folder}/${res.registryName}/${file}`;
4121
4145
  const localFilePath = path2__default.default.join(targetDir, file);
4122
4146
  if (fs9__default.default.existsSync(localFilePath) && !isOverwrite) {
@@ -4169,7 +4193,7 @@ async function handleImport(typeArg, nameArg, flags = {}) {
4169
4193
  // src/cli.ts
4170
4194
  function createCli() {
4171
4195
  const cli = cac.cac("mason");
4172
- 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) => {
4173
4197
  if (args && args.length > 0) {
4174
4198
  p14__namespace.log.error(
4175
4199
  pc14__default.default.red(
@@ -4264,7 +4288,7 @@ function createCli() {
4264
4288
  cli.command(
4265
4289
  "import [type] [name]",
4266
4290
  "Import pre-built shared modules or features from the Solid Stack Registry"
4267
- ).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 = {}) => {
4268
4292
  try {
4269
4293
  await handleImport(type, name, flags);
4270
4294
  } catch (err) {
@@ -4294,7 +4318,7 @@ function createCli() {
4294
4318
  });
4295
4319
  }
4296
4320
  cli.help();
4297
- cli.version("1.0.18");
4321
+ cli.version("1.0.19");
4298
4322
  return cli;
4299
4323
  }
4300
4324
  function handleCliError(err) {