@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/index.js CHANGED
@@ -650,7 +650,7 @@ function getAllFiles(dir, baseDir = dir) {
650
650
  }
651
651
  files.push(...getAllFiles(fullPath, baseDir));
652
652
  } else if (entry.isFile()) {
653
- if (entry.name === "registry.json" || entry.name.endsWith(".test.ts") || entry.name.endsWith(".spec.ts") || entry.name.startsWith(".")) {
653
+ 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(".")) {
654
654
  continue;
655
655
  }
656
656
  files.push(relPath);
@@ -3603,8 +3603,15 @@ async function handleCreate(type, name, flags = {}) {
3603
3603
  }
3604
3604
  var importPrompts = {
3605
3605
  select: p14.select,
3606
- text: p14.text
3606
+ text: p14.text,
3607
+ confirm: p14.confirm
3607
3608
  };
3609
+ function isTestFile(filePath) {
3610
+ const normalized = filePath.replace(/\\/g, "/");
3611
+ const parts = normalized.split("/");
3612
+ const fileName = parts[parts.length - 1] || "";
3613
+ return fileName.endsWith(".test.ts") || fileName.endsWith(".test.js") || fileName.endsWith(".spec.ts") || fileName.endsWith(".spec.js") || parts.includes("__tests__");
3614
+ }
3608
3615
  function rewriteImports(content, aliasMap) {
3609
3616
  if (aliasMap.size === 0) return content;
3610
3617
  let rewritten = content;
@@ -4071,6 +4078,22 @@ async function handleImport(typeArg, nameArg, flags = {}) {
4071
4078
  requiredNpmPackages.add(pkg);
4072
4079
  }
4073
4080
  }
4081
+ const hasTestFiles = Array.from(nodes.values()).some(
4082
+ (node) => node.manifest.files?.some((file) => isTestFile(file))
4083
+ );
4084
+ let includeTests = true;
4085
+ if (flags.tests !== void 0) {
4086
+ includeTests = Boolean(flags.tests);
4087
+ } else if (flags.yes) {
4088
+ includeTests = true;
4089
+ } else if (hasTestFiles) {
4090
+ includeTests = handleCancel(
4091
+ await importPrompts.confirm({
4092
+ message: "Include test files?",
4093
+ initialValue: true
4094
+ })
4095
+ );
4096
+ }
4074
4097
  for (const key of orderedKeys) {
4075
4098
  const res = resolutions.get(key);
4076
4099
  if (res.action === "reuse") {
@@ -4095,6 +4118,7 @@ async function handleImport(typeArg, nameArg, flags = {}) {
4095
4118
  }
4096
4119
  for (const file of res.manifest.files || []) {
4097
4120
  if (file === "registry.json") continue;
4121
+ if (!includeTests && isTestFile(file)) continue;
4098
4122
  const remoteFilePath = `${folder}/${res.registryName}/${file}`;
4099
4123
  const localFilePath = path2.join(targetDir, file);
4100
4124
  if (fs4.existsSync(localFilePath) && !isOverwrite) {
@@ -4147,7 +4171,7 @@ async function handleImport(typeArg, nameArg, flags = {}) {
4147
4171
  // src/cli.ts
4148
4172
  function createCli() {
4149
4173
  const cli = cac("mason");
4150
- 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) => {
4174
+ 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) => {
4151
4175
  if (args && args.length > 0) {
4152
4176
  p14.log.error(
4153
4177
  pc14.red(
@@ -4242,7 +4266,7 @@ function createCli() {
4242
4266
  cli.command(
4243
4267
  "import [type] [name]",
4244
4268
  "Import pre-built shared modules or features from the Solid Stack Registry"
4245
- ).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 = {}) => {
4269
+ ).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 = {}) => {
4246
4270
  try {
4247
4271
  await handleImport(type, name, flags);
4248
4272
  } catch (err) {
@@ -4272,7 +4296,7 @@ function createCli() {
4272
4296
  });
4273
4297
  }
4274
4298
  cli.help();
4275
- cli.version("1.0.18");
4299
+ cli.version("1.0.19");
4276
4300
  return cli;
4277
4301
  }
4278
4302
  function handleCliError(err) {