@marktiderman/genesis-cli 1.12.0 → 1.13.0

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/doctor.js CHANGED
@@ -843,7 +843,9 @@ ${globs.join("\n")}`;
843
843
  for (const dir of [...dirs].sort()) {
844
844
  const manifest = path14.join(dir, "package.json");
845
845
  if (!existsSync(manifest)) continue;
846
- if (!inside(real2, realpathSync(dir))) continue;
846
+ if (!inside(real2, realpathSync(dir))) {
847
+ throw new LocalPackagesError(`${path14.relative(appRoot, dir) || dir} is outside the repository; localPackages may only list folders inside it`);
848
+ }
847
849
  let pkg;
848
850
  try {
849
851
  pkg = JSON.parse(readFileSync(manifest, "utf8"));
@@ -1564,7 +1566,7 @@ function namedImportsFrom(code, pkg) {
1564
1566
  // src/doctor/native.ts
1565
1567
  var SCRIPT_EXTS3 = /* @__PURE__ */ new Set([".ts", ".tsx", ".js", ".jsx", ".mts", ".cts", ".mjs", ".cjs"]);
1566
1568
  var JSX_EXTS3 = /* @__PURE__ */ new Set([".tsx", ".jsx"]);
1567
- var LAYOUT_NAME = /(?:Page|Screen|ScreenContainer)$/;
1569
+ var LAYOUT_NAME = /(?:Page|Screen|ScreenContainer)$|^NativeResourceView$/;
1568
1570
  var NON_SCREEN_ROUTE = /(?:^|\/)(?:_layout|\+html|\+native-intent|\+middleware)\.[jt]sx?$|\+api\.[jt]sx?$/;
1569
1571
  var PART_HEADER = /(?:Section|List|Card|Dialog|Table|Group|Column|Row|Cell|Accordion|Sheet|Drawer|Modal|Popover|Menu|Panel|Form)Header$/;
1570
1572
  var HIDES_HEADER = /\bheaderShown\s*(?::|=\s*\{)\s*false\b/;
@@ -2361,7 +2363,7 @@ var SOURCE = /\.(?:[cm]?[jt]sx?)$/;
2361
2363
  var SKIP_DIRS2 = /* @__PURE__ */ new Set(["node_modules", "dist", "build", "coverage", ".turbo"]);
2362
2364
  var BUILTINS = new Set(builtinModules.flatMap((m) => [m, `node:${m}`]));
2363
2365
  var IMPORT = /(?:\bfrom\s*|\bimport\s*\(\s*|\bimport\s+|\brequire\s*\(\s*)["']([^"']+)["']/g;
2364
- var TYPE_ONLY = /\b(?:import|export)\s+type\b[^;"'`]*?\bfrom\s*["'][^"']+["']/g;
2366
+ var TYPE_ONLY = /\b(?:import|export)\s+type\s+(?:\{[^}]*\}|\*\s+as\s+[\w$]+|\*|[\w$]+)\s*from\s*["'][^"']+["']/g;
2365
2367
  function sourceFiles(dir, rel = "") {
2366
2368
  const out = [];
2367
2369
  for (const entry of readdirSync(path14.join(dir, rel)).sort()) {
@@ -2500,7 +2502,7 @@ function checkExports(ctx, pkg, json) {
2500
2502
  };
2501
2503
  walk(json.exports);
2502
2504
  for (const t of targets) {
2503
- if (!t.startsWith("./") || t.includes("*") || /^\.\/(dist|build)\//.test(t)) continue;
2505
+ if (!t.startsWith("./") || t.includes("*") || !/\.(?:[cm]?tsx?|json)$/.test(t) || /\.d\.[cm]?ts$/.test(t)) continue;
2504
2506
  if (!existsSync(path14.join(pkg.dir, t))) {
2505
2507
  ctx.report({ rule: "package-export-missing", file: `${pkg.rel}/package.json`, subject: t, message: `${pkg.name} exports ${t}, which doesn't exist` });
2506
2508
  }
@@ -2531,10 +2533,13 @@ function checkRegistered(ctx, pkg) {
2531
2533
  } catch {
2532
2534
  return;
2533
2535
  }
2536
+ const top = git(ctx.root, ["rev-parse", "--show-toplevel"])?.trim();
2537
+ const forms = /* @__PURE__ */ new Set([pkg.rel]);
2538
+ if (top) forms.add(path14.relative(top, realpathSync(pkg.dir)).split(path14.sep).join("/"));
2534
2539
  const covered = (doc.features ?? []).some(
2535
2540
  (f) => (f.links?.code ?? []).some((c) => {
2536
2541
  const norm = c.replace(/^\.\//, "").replace(/\/+$/, "");
2537
- return norm === pkg.rel || norm.startsWith(`${pkg.rel}/`) || pkg.rel.startsWith(`${norm}/`);
2542
+ return [...forms].some((rel) => norm === rel || norm.startsWith(`${rel}/`) || rel.startsWith(`${norm}/`));
2538
2543
  })
2539
2544
  );
2540
2545
  if (!covered) {
@@ -2558,8 +2563,12 @@ function mergeBaseOf(root, base) {
2558
2563
  return sha ? { sha } : { reason: `HEAD has no merge base with ${base} (fetch with depth 0)` };
2559
2564
  }
2560
2565
  function checkChanges(ctx, pkg, json, base, mergeBase) {
2561
- const diff = git(ctx.root, ["diff", "--relative", "--name-status", "-M", mergeBase, "--", pkg.rel]) ?? "";
2562
- const untracked = (git(ctx.root, ["ls-files", "--others", "--exclude-standard", "--", pkg.rel]) ?? "").split("\n").filter(Boolean);
2566
+ const top = git(ctx.root, ["rev-parse", "--show-toplevel"])?.trim();
2567
+ if (!top) return;
2568
+ const appRelative = (fromTop) => path14.relative(realpathSync(ctx.root), path14.join(top, fromTop)).split(path14.sep).join("/");
2569
+ const inRepo = path14.relative(top, realpathSync(pkg.dir)).split(path14.sep).join("/");
2570
+ 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");
2571
+ const untracked = (git(top, ["ls-files", "--others", "--exclude-standard", "--", inRepo]) ?? "").split("\n").filter(Boolean).map(appRelative);
2563
2572
  const changed = [...diff.split("\n").filter(Boolean).map((row) => row.split(" ").at(-1)), ...untracked].filter(
2564
2573
  (f) => !/(^|\/)(CHANGELOG\.md|node_modules\/)/.test(f)
2565
2574
  );
@@ -2580,7 +2589,6 @@ function checkChanges(ctx, pkg, json, base, mergeBase) {
2580
2589
  const now = typeof json.version === "string" ? parseVersion(json.version) : null;
2581
2590
  const was = typeof versionBefore === "string" ? parseVersion(versionBefore) : null;
2582
2591
  const bumped = before === null || now !== null && was !== null && compareVersions(now, was) > 0;
2583
- const top = git(ctx.root, ["rev-parse", "--show-toplevel"])?.trim();
2584
2592
  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) => path14.join(top, f)) : [];
2585
2593
  const naming = changesets.filter((p) => existsSync(p) && changesetNames(readFileSync(p, "utf8")).has(json.name));
2586
2594
  const named = naming.length > 0;
@@ -2598,6 +2606,9 @@ function checkChanges(ctx, pkg, json, base, mergeBase) {
2598
2606
  const registry = (git(ctx.root, ["diff", "--relative", "--name-only", mergeBase, "--", "features.ts", "src/features.ts"]) ?? "").trim();
2599
2607
  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` });
2600
2608
  }
2609
+ if (bumped && !named && before !== null) {
2610
+ 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` });
2611
+ }
2601
2612
  if (!bumped && !named) {
2602
2613
  ctx.report({
2603
2614
  rule: "package-unversioned-change",
@@ -3394,8 +3405,9 @@ var CONTAINER = /(?:Card|CardContent|Dialog|DialogContent|Sheet|SheetContent|Dra
3394
3405
  var SWITCHER = /<(TabsList|SubNavTabs)(?=[\s>/])/g;
3395
3406
  var SHELL = /<AppShell(?=[\s>/])/;
3396
3407
  var GENESIS_PACKAGE2 = /^@marktiderman\/genesis(?:-[\w-]+)?(?:\/|$)/;
3397
- var PAGE_LAYOUT = /^(?!Breadcrumb)[A-Z]\w*(?:Page|PageShell)$/;
3398
- var PACKAGE_SCREEN = /^(?!Breadcrumb)[A-Z]\w*(?:Page|PageShell|Screen|Workspace)$/;
3408
+ var PAGE_LAYOUT = /^(?:(?!Breadcrumb)[A-Z]\w*(?:Page|PageShell)|ResourceView)$/;
3409
+ var EMBEDDED_RESOURCE_VIEW = /<ResourceView\b[^>]*?\blayout\s*=\s*(?:(["'`]) {8}\1|\{\s*(["'`]) {8}\2\s*\})[^>]*>/g;
3410
+ var PACKAGE_SCREEN = /^(?:(?!Breadcrumb)[A-Z]\w*(?:Page|PageShell|Screen|Workspace)|ResourceView)$/;
3399
3411
  var isNative = (ctx) => ctx.config.packs?.includes("native") ?? false;
3400
3412
  var rendersRe = (names) => {
3401
3413
  const list = [...names];
@@ -3509,7 +3521,7 @@ function checkPageLayouts(ctx) {
3509
3521
  const rendersLayout = (code) => {
3510
3522
  const names = new Set(layouts);
3511
3523
  for (const n of namedImportsFrom(code, GENESIS_PACKAGE2)) if (PACKAGE_SCREEN.test(n)) names.add(n);
3512
- return rendersRe(names)?.test(code) ?? false;
3524
+ return rendersRe(names)?.test(code.replace(EMBEDDED_RESOURCE_VIEW, "")) ?? false;
3513
3525
  };
3514
3526
  const cache2 = /* @__PURE__ */ new Map();
3515
3527
  const provides = (r) => {