@marktiderman/genesis-cli 1.11.0 → 1.11.2

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/README.md CHANGED
@@ -358,7 +358,7 @@ Exit codes: `0` pass, `1` findings, `2` the doctor couldn't run (bad config, Gen
358
358
  | `raw-color` | error | Hex and `rgb()/hsl()` literals in code and CSS, via the same lexer as the repo's `check:token-usage` (comments, issue refs and `hsl(var(--x))` are fine). A brand file that defines token values needs an `allow` entry. |
359
359
  | `undefined-token` | error | `var(--x)` where the theme doesn't define `--x`. Tokens declared in the app's CSS (or only `tokenFiles`) and inline style custom properties count as defined; `--tw-*` and `--radix-*` are ignored. |
360
360
  | `shadowed-export` | error | An exported value named like a Genesis export (`export function Button`). Reuse or extend it. |
361
- | `duplicate-genesis-package` | warn | More than one copy of a `@marktiderman/genesis-*` package that the app can load, with each copy's path, version and the ranges that asked for it. Found by resolving dependencies the way Node does, from each package's real folder, so npm/yarn/bun hoisted and nested trees, pnpm's `.pnpm` store (in the app, or at the workspace root above a sub-app) and bun's isolated `.bun` store all count; a store entry nothing resolves to is ignored. Two copies are two module instances: a `DataProvider` from one is invisible to hooks from the other. A copy reached only through dev tooling (the app's `devDependencies`, or anything under `@marktiderman/genesis-cli`, wherever it's listed) is `[dev only]`: every path to it from the app runs through declared tooling (test runners, `@types/*`, linters and formatters, compilers and bundlers, Storybook, release tools, or the CLI). Other devDependencies count as runtime: a bundler ships what the app imports from them. When exactly one copy is reached from a declared runtime dependency and every other copy is dev-only, the finding is `info` (it can't split the app's contexts). Anything else warns, a copy reached through an undeclared hoisted package included. An app with no runtime dependencies at all (a bundled SPA listing everything in `devDependencies`) has its devDependencies taken as runtime. |
361
+ | `duplicate-genesis-package` | warn | More than one copy of a `@marktiderman/genesis-*` package that the app can load, with each copy's path, version and the ranges that asked for it. Found by resolving the app's dependency graph the way Node does, from each package's real folder (starting from the app's own `package.json`), so npm/yarn/bun hoisted and nested trees, pnpm's `.pnpm` store (in the app, or at the workspace root above a sub-app) and bun's isolated `.bun` store all count; a store entry nothing resolves to is ignored. Two copies are two module instances: a `DataProvider` from one is invisible to hooks from the other. A copy reached only through dev tooling (the app's `devDependencies`, or anything under `@marktiderman/genesis-cli`, wherever it's listed) is `[dev only]`: every path to it from the app runs through declared tooling (test runners, `@types/*`, linters and formatters, compilers and bundlers, Storybook, release tools, or the CLI). Other devDependencies count as runtime: a bundler ships what the app imports from them. When exactly one copy is reached from a declared runtime dependency and every other copy is dev-only, the finding is `info` (it can't split the app's contexts). Anything else warns, a copy reached through an undeclared hoisted package included. An app with no runtime dependencies at all (a bundled SPA listing everything in `devDependencies`) has its devDependencies taken as runtime. A copy that only walking up the folders finds is left out: in an app with its own install inside another app's folder (a lockfile of its own, like `apps/mobile`), a peer dependency the app doesn't declare or install is unmet rather than met by the parent's copy, and the parent's CLI isn't followed unless the app declares it. A regular dependency that resolves up to the parent still counts. |
362
362
  | `peer-range-mismatch` | warn | An installed Genesis package's `peerDependencies` range on another Genesis package that the copy it resolves (looked up from its own folder, as Node does) doesn't satisfy: the package, the range and the installed version. Missing peers and non-semver ranges (`workspace:*`) are skipped. Ranges are read with npm's grammar (`^ ~ x - ||`, prereleases only when the range names one). A mismatch inside a dev-only copy (the CLI's own tree) is `info`. |
363
363
  | `hand-rolled-sub-nav` | warn | A route under the layout that renders `AppShell` that switches its sections with its own page-level `<TabsList>` or `<SubNavTabs>`, when the installed Genesis has `useAppShellSubNav`. Tabs inside a card, dialog, sheet, popover, accordion, panel, table or another tab's content are fine, as are pages that call the hook. Use `useAppShellSubNav(items, { mode: "tabs" })`, `AppShellPageHeader` and `AppShellSubNavEnd` from `@marktiderman/genesis-ui/layout` ([sub-navigation](../ui/SKILL.md)). |
364
364
  | `local-genesis-copy` | warn | An app component definition named like a component of `uiPackage` or of `componentPackages` (forms-studio's `ResourceHeader`, `SettingsSection`, `ResourceSettingsPage`, `HeadlineNumbers`, `SummaryCard`, `ShareDialog`, …): "Genesis already has X". A definition renders JSX, isn't in a file that imports the Genesis one, and is exported or lives outside the routes folder; a route's own non-exported functions and anything passed as `component` / `errorComponent` / `pendingComponent` / `notFoundComponent` (TanStack's `FormError`) are not copies. An exported genesis-ui value is `shadowed-export` instead; `const X = lazy(() => import("@marktiderman/genesis-…"))` is fine. |
@@ -448,7 +448,7 @@ keep `raw-color`).
448
448
 
449
449
  | Rule | Level | What it flags |
450
450
  | --- | --- | --- |
451
- | `native-raw-primitive` | error | A React Native primitive Genesis wraps, used from `react-native` (`Modal`, `ActivityIndicator`; the list in the repo's `scripts/lib/native-primitives.mjs`, shared with `check:forbidden-imports`): named and aliased imports (multi-line too), `import * as RN` then `RN.Modal`, `require("react-native").Modal`, destructured `require`, and `export { Modal } from "react-native"`. Type-only imports are fine. The message names the replacements the installed package exports. |
451
+ | `native-raw-primitive` | error | A React Native primitive Genesis wraps, used from `react-native` (`Modal`, `ActivityIndicator`, which points to `NativeLoadingState`; the list in the repo's `scripts/lib/native-primitives.mjs`, shared with `check:forbidden-imports`): named and aliased imports (multi-line too), `import * as RN` then `RN.Modal`, `require("react-native").Modal`, destructured `require`, and `export { Modal } from "react-native"`. Type-only imports are fine. The message names the replacements the installed package exports. |
452
452
  | `native-literal-color` | error | Hex and `rgb()/hsl()` literals in native code (the same lexer as `raw-color`, which it replaces for script files). Use a theme role (`useThemeRoles()`), a token className or `PlatformColor(...)`. |
453
453
  | `native-custom-header` | warn | A file that sets `headerShown: false` and draws its own header (a `<…Header>` of the app's own, or `style={styles.header}`); a screen that draws one when the `_layout` beside it hides the navigator's; a hand-built tab bar (`tabBar={…}` in a file with `<Tabs>`, or a `<…TabBar>` of the app's own). Section headers (`SectionHeader`, `ListHeader`, `CardHeader`, …) and Genesis components don't count. Only the `_layout` in the screen's own folder is followed, not ancestors. |
454
454
  | `native-screen-layout` | warn | A route screen under the router root (`native.routerRoot`, default `src/app`, else `app`) that renders no Genesis screen layout, directly or through one local import (`./`, `../`, `@/`, `~/`). `_layout`, `+html`, `+native-intent`, `+middleware`, `+api` files, re-export-only routes and `<Redirect>` routes are skipped. Also a warning when the router root is missing, or when `src` leaves it unscanned. |
package/dist/cli.js CHANGED
@@ -2525,7 +2525,7 @@ var init_native_primitives = __esm({
2525
2525
  "../../scripts/lib/native-primitives.mjs"() {
2526
2526
  NATIVE_WRAPPED_PRIMITIVES = Object.freeze({
2527
2527
  Modal: Object.freeze(["NativeDialog", "NativeSheet", "NativeDrawer"]),
2528
- ActivityIndicator: Object.freeze(["NativeSkeleton", "NativeProgress"])
2528
+ ActivityIndicator: Object.freeze(["NativeLoadingState", "NativeSkeleton", "NativeProgress"])
2529
2529
  });
2530
2530
  }
2531
2531
  });
@@ -2799,6 +2799,12 @@ function checkCustomHeaders(ctx, pkg) {
2799
2799
  });
2800
2800
  }
2801
2801
  }
2802
+ function isLoadingOnlyRoute(code) {
2803
+ const loading = [...code.matchAll(/<NativeLoadingState\b([^>]*)>/g)];
2804
+ if (loading.length === 0 || loading.some((m) => /\bfullScreen\s*=\s*\{\s*false\s*\}/.test(m[1] ?? ""))) return false;
2805
+ const tags = [...code.matchAll(/<([A-Z][\w.]*)/g)].map((m) => m[1] ?? "");
2806
+ return tags.every((t) => LOADING_ROUTE_COMPANIONS.has(t));
2807
+ }
2802
2808
  function routerRoot(ctx) {
2803
2809
  if (ctx.config.native?.routerRoot) return ctx.config.native.routerRoot.replace(/\/+$/, "");
2804
2810
  return existsSync(path32.join(ctx.root, "src", "app")) ? "src/app" : "app";
@@ -2821,12 +2827,13 @@ function checkScreenLayouts(ctx, pkg) {
2821
2827
  });
2822
2828
  return;
2823
2829
  }
2824
- const renders2 = new RegExp(`<(?:${layouts.join("|")}|Redirect)\\b`);
2830
+ const renders2 = new RegExp(`<(?:${[...layouts, "Redirect"].join("|")})\\b`);
2831
+ const loadingOnly = pkg.values.has("NativeLoadingState") ? isLoadingOnlyRoute : () => false;
2825
2832
  const byPath = new Map(ctx.files.map((f) => [f.absolutePath, f]));
2826
2833
  for (const file of routes) {
2827
2834
  if (!JSX_EXTS3.has(file.ext) || NON_SCREEN_ROUTE.test(file.path)) continue;
2828
2835
  if (!/\bexport\s+default\b/.test(file.code) || !/<[A-Za-z]/.test(file.code)) continue;
2829
- if (renders2.test(file.code)) continue;
2836
+ if (renders2.test(file.code) || loadingOnly(file.code)) continue;
2830
2837
  const viaImport = localImports(ctx.root, file).some((abs) => {
2831
2838
  const target = byPath.get(abs) ?? readSource(abs);
2832
2839
  return target !== null && renders2.test(target.code);
@@ -2964,7 +2971,7 @@ function checkStoreReadiness(ctx) {
2964
2971
  });
2965
2972
  }
2966
2973
  }
2967
- var SCRIPT_EXTS3, JSX_EXTS3, LAYOUT_NAME, NON_SCREEN_ROUTE, PART_HEADER, HIDES_HEADER, RN, PERMISSIONS, SOCIAL_SIGN_IN, WEAK_SOCIAL_SIGN_IN, APPLE_SIGN_IN, EXPO_CONFIGS, SUPABASE_SIGN_IN, GENESIS_PLUGIN, GENESIS_PLUGIN_TEXT, GENESIS_PLUGIN_IMPORT;
2974
+ var SCRIPT_EXTS3, JSX_EXTS3, LAYOUT_NAME, NON_SCREEN_ROUTE, PART_HEADER, HIDES_HEADER, RN, LOADING_ROUTE_COMPANIONS, PERMISSIONS, SOCIAL_SIGN_IN, WEAK_SOCIAL_SIGN_IN, APPLE_SIGN_IN, EXPO_CONFIGS, SUPABASE_SIGN_IN, GENESIS_PLUGIN, GENESIS_PLUGIN_TEXT, GENESIS_PLUGIN_IMPORT;
2968
2975
  var init_native = __esm({
2969
2976
  "src/doctor/native.ts"() {
2970
2977
  init_native_primitives();
@@ -2980,6 +2987,7 @@ var init_native = __esm({
2980
2987
  PART_HEADER = /(?:Section|List|Card|Dialog|Table|Group|Column|Row|Cell|Accordion|Sheet|Drawer|Modal|Popover|Menu|Panel|Form)Header$/;
2981
2988
  HIDES_HEADER = /\bheaderShown\s*(?::|=\s*\{)\s*false\b/;
2982
2989
  RN = String.raw`["']react-native["']`;
2990
+ LOADING_ROUTE_COMPANIONS = /* @__PURE__ */ new Set(["NativeLoadingState", "Stack.Screen", "Fragment", "React.Fragment"]);
2983
2991
  PERMISSIONS = [
2984
2992
  { module: "expo-camera", key: "NSCameraUsageDescription", option: "cameraPermission" },
2985
2993
  { module: "expo-image-picker", key: "NSPhotoLibraryUsageDescription", option: "photosPermission" },
@@ -3582,6 +3590,10 @@ var init_semver = __esm({
3582
3590
  ver = (major, minor, patch, pre = []) => ({ major, minor, patch, pre });
3583
3591
  }
3584
3592
  });
3593
+ function nodeModulesOf(dir) {
3594
+ const parent = path32.dirname(dir);
3595
+ return path32.basename(parent).startsWith("@") ? path32.dirname(parent) : parent;
3596
+ }
3585
3597
  function packagesIn(nodeModules) {
3586
3598
  if (!existsSync(nodeModules)) return [];
3587
3599
  const out = [];
@@ -3630,18 +3642,33 @@ function genesisInstalls(root) {
3630
3642
  for (const r of roots) visit(r.dir, r.by, r.range);
3631
3643
  while (queue.length) {
3632
3644
  const { real: from, manifest, label } = queue.shift();
3633
- const deps = { ...manifest.peerDependencies, ...manifest.optionalDependencies, ...manifest.dependencies };
3645
+ const deps = { ...manifest.optionalDependencies, ...manifest.dependencies };
3634
3646
  for (const [name, range] of Object.entries(deps)) {
3635
3647
  const dir = findPackageDir(from, name);
3636
3648
  if (dir) visit(dir, label, range);
3637
3649
  }
3650
+ for (const [name, range] of Object.entries(manifest.peerDependencies ?? {})) {
3651
+ if (name in deps) continue;
3652
+ const dir = peerOf(from, name);
3653
+ if (dir) visit(dir, label, range);
3654
+ }
3638
3655
  }
3639
3656
  };
3657
+ const peerOf = (from, name) => {
3658
+ const dir = findPackageDir(from, name);
3659
+ if (!dir) return null;
3660
+ if (!ownInstall || name in declared) return dir;
3661
+ const realDir = real(dir);
3662
+ if (realDir.startsWith(realRoot + path32.sep)) return dir;
3663
+ return nodeModulesOf(realDir) === nodeModulesOf(from) ? dir : null;
3664
+ };
3640
3665
  const rootsOf = (deps, by) => Object.entries(deps).flatMap(([name, range]) => {
3641
3666
  const dir = findPackageDir(root, name);
3642
3667
  return dir ? [{ dir, by, ...range ? { range } : {} }] : [];
3643
3668
  });
3644
3669
  const app = readManifest(root);
3670
+ const ownInstall = LOCKFILES.some((f) => existsSync(path32.join(root, f)));
3671
+ const declared = { ...app?.devDependencies, ...app?.peerDependencies, ...app?.optionalDependencies, ...app?.dependencies };
3645
3672
  const declaredDev = Object.entries(app?.devDependencies ?? {});
3646
3673
  const runtimeDeps = {
3647
3674
  ...Object.fromEntries(declaredDev.filter(([n]) => !NON_SHIPPING.test(n))),
@@ -3660,7 +3687,7 @@ function genesisInstalls(root) {
3660
3687
  }).map((dir) => ({ dir, by: "hoisted, not a direct dependency" }))
3661
3688
  );
3662
3689
  const devRoots = { ...devDeps };
3663
- for (const tool of DEV_TOOLS) if (!(tool in devRoots)) devRoots[tool] = runtimeDeps[tool];
3690
+ for (const tool of DEV_TOOLS) if (!(tool in devRoots) && tool in runtimeDeps) devRoots[tool] = runtimeDeps[tool];
3664
3691
  walk2("dev", rootsOf(devRoots, "the app (dev)"));
3665
3692
  for (const [key2, copy] of copies) {
3666
3693
  const kinds = via.get(key2);
@@ -3720,7 +3747,7 @@ function checkPeerRanges(ctx) {
3720
3747
  }
3721
3748
  }
3722
3749
  }
3723
- var GENESIS, DEV_TOOLS, NON_SHIPPING, readManifest, real;
3750
+ var GENESIS, DEV_TOOLS, NON_SHIPPING, readManifest, real, LOCKFILES;
3724
3751
  var init_installs = __esm({
3725
3752
  "src/doctor/installs.ts"() {
3726
3753
  init_genesis();
@@ -3742,6 +3769,7 @@ var init_installs = __esm({
3742
3769
  return p;
3743
3770
  }
3744
3771
  };
3772
+ LOCKFILES = ["bun.lock", "bun.lockb", "package-lock.json", "npm-shrinkwrap.json", "yarn.lock", "pnpm-lock.yaml"];
3745
3773
  }
3746
3774
  });
3747
3775
  function stripForImports(code) {