@marktiderman/genesis-cli 1.12.0 → 1.12.1

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/cli.js CHANGED
@@ -390,7 +390,9 @@ ${globs.join("\n")}`;
390
390
  for (const dir of [...dirs].sort()) {
391
391
  const manifest = path23.join(dir, "package.json");
392
392
  if (!existsSync(manifest)) continue;
393
- if (!inside(real2, realpathSync(dir))) continue;
393
+ if (!inside(real2, realpathSync(dir))) {
394
+ throw new LocalPackagesError(`${path23.relative(appRoot, dir) || dir} is outside the repository; localPackages may only list folders inside it`);
395
+ }
394
396
  let pkg;
395
397
  try {
396
398
  pkg = JSON.parse(readFileSync(manifest, "utf8"));
@@ -3757,7 +3759,7 @@ function checkExports(ctx, pkg, json) {
3757
3759
  };
3758
3760
  walk2(json.exports);
3759
3761
  for (const t of targets) {
3760
- if (!t.startsWith("./") || t.includes("*") || /^\.\/(dist|build)\//.test(t)) continue;
3762
+ if (!t.startsWith("./") || t.includes("*") || !/\.(?:[cm]?tsx?|json)$/.test(t) || /\.d\.[cm]?ts$/.test(t)) continue;
3761
3763
  if (!existsSync(path23.join(pkg.dir, t))) {
3762
3764
  ctx.report({ rule: "package-export-missing", file: `${pkg.rel}/package.json`, subject: t, message: `${pkg.name} exports ${t}, which doesn't exist` });
3763
3765
  }
@@ -3788,10 +3790,13 @@ function checkRegistered(ctx, pkg) {
3788
3790
  } catch {
3789
3791
  return;
3790
3792
  }
3793
+ const top = git(ctx.root, ["rev-parse", "--show-toplevel"])?.trim();
3794
+ const forms = /* @__PURE__ */ new Set([pkg.rel]);
3795
+ if (top) forms.add(path23.relative(top, realpathSync(pkg.dir)).split(path23.sep).join("/"));
3791
3796
  const covered = (doc.features ?? []).some(
3792
3797
  (f) => (f.links?.code ?? []).some((c) => {
3793
3798
  const norm = c.replace(/^\.\//, "").replace(/\/+$/, "");
3794
- return norm === pkg.rel || norm.startsWith(`${pkg.rel}/`) || pkg.rel.startsWith(`${norm}/`);
3799
+ return [...forms].some((rel) => norm === rel || norm.startsWith(`${rel}/`) || rel.startsWith(`${norm}/`));
3795
3800
  })
3796
3801
  );
3797
3802
  if (!covered) {
@@ -3815,8 +3820,12 @@ function mergeBaseOf(root, base) {
3815
3820
  return sha ? { sha } : { reason: `HEAD has no merge base with ${base} (fetch with depth 0)` };
3816
3821
  }
3817
3822
  function checkChanges(ctx, pkg, json, base, mergeBase) {
3818
- const diff = git(ctx.root, ["diff", "--relative", "--name-status", "-M", mergeBase, "--", pkg.rel]) ?? "";
3819
- const untracked = (git(ctx.root, ["ls-files", "--others", "--exclude-standard", "--", pkg.rel]) ?? "").split("\n").filter(Boolean);
3823
+ const top = git(ctx.root, ["rev-parse", "--show-toplevel"])?.trim();
3824
+ if (!top) return;
3825
+ const appRelative = (fromTop) => path23.relative(realpathSync(ctx.root), path23.join(top, fromTop)).split(path23.sep).join("/");
3826
+ const inRepo = path23.relative(top, realpathSync(pkg.dir)).split(path23.sep).join("/");
3827
+ const diff = (git(top, ["diff", "--name-status", "-M", mergeBase, "--", inRepo]) ?? "").split("\n").filter(Boolean).map((row) => row.split(" ").map((cell, i) => i === 0 ? cell : appRelative(cell)).join(" ")).join("\n");
3828
+ const untracked = (git(top, ["ls-files", "--others", "--exclude-standard", "--", inRepo]) ?? "").split("\n").filter(Boolean).map(appRelative);
3820
3829
  const changed = [...diff.split("\n").filter(Boolean).map((row) => row.split(" ").at(-1)), ...untracked].filter(
3821
3830
  (f) => !/(^|\/)(CHANGELOG\.md|node_modules\/)/.test(f)
3822
3831
  );
@@ -3837,7 +3846,6 @@ function checkChanges(ctx, pkg, json, base, mergeBase) {
3837
3846
  const now = typeof json.version === "string" ? parseVersion(json.version) : null;
3838
3847
  const was = typeof versionBefore === "string" ? parseVersion(versionBefore) : null;
3839
3848
  const bumped = before === null || now !== null && was !== null && compareVersions(now, was) > 0;
3840
- const top = git(ctx.root, ["rev-parse", "--show-toplevel"])?.trim();
3841
3849
  const changesets = top ? (git(top, ["diff", "--name-only", "--diff-filter=A", mergeBase, "--", ".changeset"]) ?? "").split("\n").concat((git(top, ["ls-files", "--others", "--exclude-standard", "--", ".changeset"]) ?? "").split("\n")).filter((f) => f.endsWith(".md")).map((f) => path23.join(top, f)) : [];
3842
3850
  const naming = changesets.filter((p) => existsSync(p) && changesetNames(readFileSync(p, "utf8")).has(json.name));
3843
3851
  const named = naming.length > 0;
@@ -3855,6 +3863,9 @@ function checkChanges(ctx, pkg, json, base, mergeBase) {
3855
3863
  const registry = (git(ctx.root, ["diff", "--relative", "--name-only", mergeBase, "--", "features.ts", "src/features.ts"]) ?? "").trim();
3856
3864
  if (!registry) ctx.report({ rule: "package-unversioned-change", level: "warn", file: `${pkg.rel}/package.json`, message: `${pkg.name}'s blocks or exports changed but features.ts didn't; update the features they belong to` });
3857
3865
  }
3866
+ if (bumped && !named && before !== null) {
3867
+ ctx.report({ rule: "package-unversioned-change", level: "warn", file: `${pkg.rel}/package.json`, message: `${pkg.name}'s version went up without a changeset; add one with a "Features:" line so the change is recorded` });
3868
+ }
3858
3869
  if (!bumped && !named) {
3859
3870
  ctx.report({
3860
3871
  rule: "package-unversioned-change",
@@ -3900,7 +3911,7 @@ var init_packages = __esm({
3900
3911
  SKIP_DIRS2 = /* @__PURE__ */ new Set(["node_modules", "dist", "build", "coverage", ".turbo"]);
3901
3912
  BUILTINS = new Set(builtinModules.flatMap((m) => [m, `node:${m}`]));
3902
3913
  IMPORT = /(?:\bfrom\s*|\bimport\s*\(\s*|\bimport\s+|\brequire\s*\(\s*)["']([^"']+)["']/g;
3903
- TYPE_ONLY = /\b(?:import|export)\s+type\b[^;"'`]*?\bfrom\s*["'][^"']+["']/g;
3914
+ TYPE_ONLY = /\b(?:import|export)\s+type\s+(?:\{[^}]*\}|\*\s+as\s+[\w$]+|\*|[\w$]+)\s*from\s*["'][^"']+["']/g;
3904
3915
  }
3905
3916
  });
3906
3917
  function sqlStatements(text) {