@marktiderman/genesis-cli 1.17.1 → 1.17.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
@@ -631,6 +631,7 @@ keep `raw-color`).
631
631
  | `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. |
632
632
  | `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. |
633
633
  | `store-readiness` | warn | Static checks of `app.json`, `app.config.json` and (as text, best-effort) `app.config.{ts,js,mjs,cjs}`. **Usage strings**: Expo applies an installed module's config plugin even when it isn't listed, with a generic default string (`Allow $(PRODUCT_NAME) to access your camera`), and App Review rejects generic purpose strings; so a module without its own sentence (`ios.infoPlist.<Key>` or the plugin option) is flagged, and `false` (Expo's opt-out) counts as set. Covered: `expo-camera`, `expo-image-picker` (photos; camera only "if the app takes photos"), `expo-media-library`, `expo-location`, `expo-av` / `expo-audio` (microphone "if the app records audio"), `expo-contacts`, `expo-local-authentication` (Face ID). **Sign in with Apple**: third-party sign-in (`@react-native-google-signin/google-signin`, `react-native-fbsdk-next`, or a Supabase `signInWithOAuth` / `signInWithIdToken` with a non-Apple provider) without Apple sign-in (`expo-apple-authentication`, or Supabase's `apple` provider). Guideline 4.8 accepts any equivalent privacy-focused login, so this is a warning to `allow` with the reason when another option qualifies; `expo-auth-session` alone doesn't trigger it (it serves non-login OAuth too). Also the export-compliance flag (`ios.config.usesNonExemptEncryption` or `ITSAppUsesNonExemptEncryption`), `ios.privacyManifests`, and a missing Expo config. Those two count as set when the [Expo config plugin](#expo-config-plugin) (`@marktiderman/genesis-cli` in `plugins`) will set them: export compliance unless `exportCompliance: false`, the privacy manifest unless `privacyManifest: false` and only when a dependency needs one. |
634
+ | `eas-placeholder` | warn | A `REPLACE_WITH_…` placeholder from the EAS templates still in `eas.json` or `.eas/workflows/*.yml` (YAML comment lines aren't read): the store ids in `eas.json` `submit.production`, or `REPLACE_WITH_APP_FOLDER` in `pr-preview.yml`'s `paths`, which otherwise matches nothing, so code changes never start a preview. `genesis init --template native` fills the app folder in (`src`). |
634
635
 
635
636
  **`supabase`**, for `supabase/migrations/*.sql` (`supabase.migrations`). The SQL is read
636
637
  statement by statement with comments removed and string (`'…'`, `E'…'`) and dollar-quoted
@@ -638,7 +639,7 @@ bodies blanked, so text inside a function body never matches; the one exception
638
639
 
639
640
  | Rule | Level | What it flags |
640
641
  | --- | --- | --- |
641
- | `migration-grants` | error / warn | In new migrations: `grant … on all functions in schema …` and `alter default privileges … grant … on functions` to `anon` or `public` (error) or `authenticated` (warn: it re-grants functions revoked from signed-in users); other roles (`service_role`, `postgres`) are fine. A function outside `exposedSchemas` granted to `anon` or `public` by name, and `grant usage on schema <unexposed> to anon/public` (error). Revokes, `revoke grant option for`, argument types and `granted by` are read correctly. Grant by name so an earlier revoke survives. |
642
+ | `migration-grants` | error / warn | In new migrations: `grant … on all functions in schema …` and `alter default privileges … grant … on functions` to `anon` or `public` (error) or `authenticated` (warn: it re-grants functions revoked from signed-in users); other roles (`service_role`, `postgres`) are fine. A function outside `exposedSchemas` granted to `anon` or `public` by name, and `grant usage on schema <unexposed> to anon/public` (error). A grant built as a string for `execute` in a body (`execute format('grant … to anon', f)` in a loop) to `anon`, `public` or a computed role (warn: what it grants can't be read). Revokes, `revoke grant option for`, argument types and `granted by` are read correctly. Grant by name so an earlier revoke survives. |
642
643
  | `migration-rls` | error | A table in an exposed schema whose row level security is off once every migration has run: never enabled, or disabled later. Renames (`alter table … rename to`, `set schema`) and drops are followed. RLS enabled by dynamic SQL (a `do $$ … execute format('alter table %I enable row level security', t) … $$` loop) can't be traced, so such a block counts as enabling it for every table created before it. |
643
644
  | `migration-definer-search-path` | error | A `security definer` function or procedure without `set search_path`. Functions are keyed by name and argument types, so overloads are separate; `alter function … security definer` makes one definer, `alter function … set search_path` fixes it, and renames, replaces and drops are followed. |
644
645
  | `migration-edited` | error | A `.sql` migration that already exists at the merge base with `supabase.base` (default `origin/main`) was modified, deleted or renamed. Applied migrations are never edited; add a new one. Skipped outside a git repo; a **warn** when the base ref isn't available. |
package/dist/cli.js CHANGED
@@ -238,32 +238,32 @@ function inside(parent, child) {
238
238
  const rel = path28.relative(parent, child);
239
239
  return rel === "" || !rel.startsWith("..") && !path28.isAbsolute(rel);
240
240
  }
241
- function readPackageFile(packageDir3, rel) {
241
+ function readPackageFile(packageDir2, rel) {
242
242
  const safe = safeRelative(rel);
243
243
  if (!safe) throw new Error(`"${rel}" is not a plain path inside the package`);
244
- const root = realpathSync(packageDir3);
244
+ const root = realpathSync(packageDir2);
245
245
  const file = path28.join(root, ...safe.split("/"));
246
246
  if (!existsSync(file)) return null;
247
247
  const real2 = realpathSync(file);
248
- if (!inside(root, real2)) throw new Error(`${rel} in ${packageDir3} points outside the package`);
248
+ if (!inside(root, real2)) throw new Error(`${rel} in ${packageDir2} points outside the package`);
249
249
  if (!statSync(real2).isFile()) return null;
250
250
  return readFileSync(real2, "utf8");
251
251
  }
252
- function readPackageDir(packageDir3, rel, skipped = []) {
252
+ function readPackageDir(packageDir2, rel, skipped = []) {
253
253
  const safe = safeRelative(rel);
254
254
  if (!safe) throw new Error(`"${rel}" is not a plain path inside the package`);
255
- const root = realpathSync(packageDir3);
255
+ const root = realpathSync(packageDir2);
256
256
  const dir = path28.join(root, ...safe.split("/"));
257
257
  if (!existsSync(dir)) return null;
258
258
  const real2 = realpathSync(dir);
259
- if (!inside(root, real2) || !statSync(real2).isDirectory()) throw new Error(`${rel} in ${packageDir3} is not a folder inside the package`);
259
+ if (!inside(root, real2) || !statSync(real2).isDirectory()) throw new Error(`${rel} in ${packageDir2} is not a folder inside the package`);
260
260
  const out = [];
261
261
  for (const entry of readdirSync(real2, { withFileTypes: true }).sort((a, b) => a.name.localeCompare(b.name))) {
262
262
  if (!/^[A-Za-z0-9][A-Za-z0-9._-]*$/.test(entry.name) || entry.isDirectory()) {
263
263
  skipped.push(`${safe}/${entry.name}`);
264
264
  continue;
265
265
  }
266
- const content = readPackageFile(packageDir3, `${safe}/${entry.name}`);
266
+ const content = readPackageFile(packageDir2, `${safe}/${entry.name}`);
267
267
  if (content !== null && entry.isFile()) out.push({ name: entry.name, content });
268
268
  }
269
269
  return out;
@@ -2062,6 +2062,7 @@ var init_templates = __esm({
2062
2062
  // src/blocks/init-native.ts
2063
2063
  var init_native_exports = {};
2064
2064
  __export(init_native_exports, {
2065
+ APP_FOLDER_PLACEHOLDER: () => APP_FOLDER_PLACEHOLDER,
2065
2066
  appPnpmSettings: () => appPnpmSettings,
2066
2067
  initNative: () => initNative,
2067
2068
  runInitNative: () => runInitNative,
@@ -2123,7 +2124,13 @@ function initNative(options) {
2123
2124
  const source = starterDir();
2124
2125
  const read2 = (rel) => readFileSync(path28.join(source, rel), "utf8");
2125
2126
  const was = starterIdentity(read2("starter.config.ts"));
2126
- const substitutions = { [was.bundleId]: bundleId, [was.slug]: slug, [was.scheme]: scheme, [was.name]: display };
2127
+ const substitutions = {
2128
+ [was.bundleId]: bundleId,
2129
+ [was.slug]: slug,
2130
+ [was.scheme]: scheme,
2131
+ [was.name]: display,
2132
+ [APP_FOLDER_PLACEHOLDER]: "src"
2133
+ };
2127
2134
  const files = /* @__PURE__ */ new Map();
2128
2135
  for (const rel of walk(source, STARTER_EXCLUDE)) {
2129
2136
  const to = rel.replace(new RegExp(`(^|/)${PACKED_GITIGNORE}$`), "$1.gitignore");
@@ -2206,7 +2213,7 @@ function initNative(options) {
2206
2213
  async function runInitNative(options) {
2207
2214
  return initNative({ ...options, blocks: catalogBlocks() });
2208
2215
  }
2209
- var SLUG, BUNDLE, SCHEME, METRO;
2216
+ var APP_FOLDER_PLACEHOLDER, SLUG, BUNDLE, SCHEME, METRO;
2210
2217
  var init_init_native = __esm({
2211
2218
  "src/blocks/init-native.ts"() {
2212
2219
  init_discover();
@@ -2216,6 +2223,7 @@ var init_init_native = __esm({
2216
2223
  init_pm();
2217
2224
  init_templates();
2218
2225
  init_walk();
2226
+ APP_FOLDER_PLACEHOLDER = "REPLACE_WITH_APP_FOLDER";
2219
2227
  SLUG = /^[a-z][a-z0-9-]{1,40}$/;
2220
2228
  BUNDLE = /^[a-zA-Z][a-zA-Z0-9]*(\.[a-zA-Z][a-zA-Z0-9]*)+$/;
2221
2229
  SCHEME = /^[a-z][a-z0-9+.-]*$/;
@@ -2665,14 +2673,14 @@ function inherit(own, source) {
2665
2673
  }
2666
2674
  function resolveViews(relations) {
2667
2675
  const done = /* @__PURE__ */ new Set();
2668
- const resolve26 = (relation, depth) => {
2676
+ const resolve25 = (relation, depth) => {
2669
2677
  if (done.has(relation.oid) || !relation.origins || depth > MAX_VIEW_DEPTH) return;
2670
2678
  done.add(relation.oid);
2671
2679
  const sources = new Set([...relation.origins.values()].map((o) => o.relation));
2672
2680
  if (sources.size !== 1) return;
2673
2681
  const source = relations.get([...sources][0]);
2674
2682
  if (!source) return;
2675
- resolve26(source, depth + 1);
2683
+ resolve25(source, depth + 1);
2676
2684
  const viewAttnumOf = /* @__PURE__ */ new Map();
2677
2685
  for (const [attnum, origin] of relation.origins) {
2678
2686
  const own = relation.columns.get(attnum);
@@ -2695,7 +2703,7 @@ function resolveViews(relations) {
2695
2703
  };
2696
2704
  if (Object.keys(inherited).length) relation.table.settings = { ...inherited, ...relation.table.settings };
2697
2705
  };
2698
- for (const relation of relations.values()) resolve26(relation, 0);
2706
+ for (const relation of relations.values()) resolve25(relation, 0);
2699
2707
  }
2700
2708
  async function introspectPostgres(sql, schemas, options = {}) {
2701
2709
  const relations = /* @__PURE__ */ new Map();
@@ -3420,6 +3428,7 @@ var init_rules = __esm({
3420
3428
  "native-custom-header",
3421
3429
  "native-screen-layout",
3422
3430
  "store-readiness",
3431
+ "eas-placeholder",
3423
3432
  // supabase pack
3424
3433
  "migration-grants",
3425
3434
  "migration-rls",
@@ -3659,6 +3668,31 @@ function checkNativePack(ctx) {
3659
3668
  checkCustomHeaders(ctx, pkg);
3660
3669
  checkScreenLayouts(ctx, pkg);
3661
3670
  checkStoreReadiness(ctx);
3671
+ checkEasPlaceholders(ctx);
3672
+ }
3673
+ function checkEasPlaceholders(ctx) {
3674
+ const files = [];
3675
+ if (existsSync(path28.join(ctx.root, "eas.json"))) files.push("eas.json");
3676
+ const workflows = path28.join(ctx.root, ".eas", "workflows");
3677
+ if (existsSync(workflows)) {
3678
+ for (const name of readdirSync(workflows).sort()) if (/\.ya?ml$/.test(name)) files.push(`.eas/workflows/${name}`);
3679
+ }
3680
+ for (const file of files) {
3681
+ const lines = readFileSync(path28.join(ctx.root, file), "utf8").split("\n");
3682
+ lines.forEach((text, i) => {
3683
+ if (!file.endsWith(".json") && /^\s*#/.test(text)) return;
3684
+ for (const m of text.matchAll(EAS_PLACEHOLDER)) {
3685
+ ctx.report({
3686
+ rule: "eas-placeholder",
3687
+ level: "warn",
3688
+ file,
3689
+ line: i + 1,
3690
+ subject: m[0],
3691
+ message: m[0] === "REPLACE_WITH_APP_FOLDER" ? "still names REPLACE_WITH_APP_FOLDER, so only config changes start a preview; replace it with the app's code folder (src, or apps/<name> in a monorepo)" : `still has the template placeholder ${m[0]}; replace it before the job that reads it runs (see docs/NATIVE-RELEASE.md in the Genesis repository)`
3692
+ });
3693
+ }
3694
+ });
3695
+ }
3662
3696
  }
3663
3697
  function checkRawPrimitives(ctx, pkg) {
3664
3698
  const overlays = markedOverlays(ctx);
@@ -3937,7 +3971,7 @@ function checkStoreReadiness(ctx) {
3937
3971
  });
3938
3972
  }
3939
3973
  }
3940
- 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;
3974
+ var SCRIPT_EXTS3, JSX_EXTS3, LAYOUT_NAME, NON_SCREEN_ROUTE, PART_HEADER, HIDES_HEADER, EAS_PLACEHOLDER, 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;
3941
3975
  var init_native = __esm({
3942
3976
  "src/doctor/native.ts"() {
3943
3977
  init_native_primitives();
@@ -3953,6 +3987,7 @@ var init_native = __esm({
3953
3987
  NON_SCREEN_ROUTE = /(?:^|\/)(?:_layout|\+html|\+native-intent|\+middleware)\.[jt]sx?$|\+api\.[jt]sx?$/;
3954
3988
  PART_HEADER = /(?:Section|List|Card|Dialog|Table|Group|Column|Row|Cell|Accordion|Sheet|Drawer|Modal|Popover|Menu|Panel|Form)Header$/;
3955
3989
  HIDES_HEADER = /\bheaderShown\s*(?::|=\s*\{)\s*false\b/;
3990
+ EAS_PLACEHOLDER = /\bREPLACE_WITH_[A-Z0-9_]+/g;
3956
3991
  RN = String.raw`["']react-native["']`;
3957
3992
  LOADING_ROUTE_COMPANIONS = /* @__PURE__ */ new Set(["NativeLoadingState", "Stack.Screen", "Fragment", "React.Fragment"]);
3958
3993
  PERMISSIONS = [
@@ -4585,7 +4620,7 @@ function toRegExp2(source, flags = "") {
4585
4620
  if (source.startsWith("(?i)")) return new RegExp(source.slice(4), flags + "i");
4586
4621
  return new RegExp(source, flags);
4587
4622
  }
4588
- function validateDeclaration(raw, packageName3, packageDir3, ignored) {
4623
+ function validateDeclaration(raw, packageName3, packageDir2, ignored) {
4589
4624
  const fail = (msg) => {
4590
4625
  throw new PackageDeclarationError(`${packageName3}: genesis.doctor ${msg}`);
4591
4626
  };
@@ -4605,9 +4640,9 @@ function validateDeclaration(raw, packageName3, packageDir3, ignored) {
4605
4640
  }
4606
4641
  });
4607
4642
  if (typeof raw === "string") {
4608
- if (!packageDir3) fail(`points at ${raw}, but the package folder is unknown`);
4609
- const file = path28.resolve(packageDir3, raw);
4610
- if (!inside(packageDir3, file)) fail(`points outside the package (${raw})`);
4643
+ if (!packageDir2) fail(`points at ${raw}, but the package folder is unknown`);
4644
+ const file = path28.resolve(packageDir2, raw);
4645
+ if (!inside(packageDir2, file)) fail(`points outside the package (${raw})`);
4611
4646
  if (!existsSync(file)) fail(`points at ${raw}, which doesn't exist (is it in package.json "files"?)`);
4612
4647
  let parsed;
4613
4648
  try {
@@ -4615,7 +4650,7 @@ function validateDeclaration(raw, packageName3, packageDir3, ignored) {
4615
4650
  } catch (err) {
4616
4651
  return fail(`file ${raw} is not valid JSON: ${err.message}`);
4617
4652
  }
4618
- return validateDeclaration(parsed, packageName3, packageDir3, ignored);
4653
+ return validateDeclaration(parsed, packageName3, packageDir2, ignored);
4619
4654
  }
4620
4655
  if (raw === false) fail(`is false; say why with { "enforce": false, "reason": "\u2026" }`);
4621
4656
  if (!isObject3(raw)) fail(`must be an object (or a path to a JSON file in the package)`);
@@ -4653,10 +4688,10 @@ function validateDeclaration(raw, packageName3, packageDir3, ignored) {
4653
4688
  });
4654
4689
  let plugin;
4655
4690
  if (typeof c.plugin === "string") {
4656
- if (!packageDir3) plugin = c.plugin;
4691
+ if (!packageDir2) plugin = c.plugin;
4657
4692
  else {
4658
- plugin = path28.resolve(packageDir3, c.plugin);
4659
- if (!inside(packageDir3, plugin)) fail(`plugin points outside the package (${c.plugin})`);
4693
+ plugin = path28.resolve(packageDir2, c.plugin);
4694
+ if (!inside(packageDir2, plugin)) fail(`plugin points outside the package (${c.plugin})`);
4660
4695
  }
4661
4696
  }
4662
4697
  return {
@@ -5529,6 +5564,23 @@ function checkTestingKit(ctx, migrations) {
5529
5564
  function granteesOf(s) {
5530
5565
  return s.replace(/\s+granted by .*$/, "").replace(/\s+with grant option$/, "").split(/\s*,\s*/).map((r) => r.replace(/^group\s+/, "").trim()).filter(Boolean);
5531
5566
  }
5567
+ function dynamicGrants(body) {
5568
+ const out = [];
5569
+ const code = body.replace(/\/\*[\s\S]*?\*\/|--[^\n]*/g, "").replace(/(?<![\w."'$])raise\s+(?:(?:debug|log|info|notice|warning|exception|sqlstate|using)\b|')[^;]*;/g, ";");
5570
+ const strings2 = /(?<![\w$])e'((?:[^'\\]|\\[\s\S]|'')*)(?:'|$)|'((?:[^']|'')*)(?:'|$)|\$(\w*)\$([\s\S]*?)(?:\$\3\$|$)/g;
5571
+ for (const m of code.matchAll(strings2)) {
5572
+ for (const stmt of (m[1] ?? m[2] ?? m[4] ?? "").split(";")) {
5573
+ if (!/^\s*(?:grant|alter default privileges\b.*?\bgrant)\b/.test(stmt)) continue;
5574
+ const to = /\bto(?:\s+|$)([\s\S]*)$/.exec(stmt);
5575
+ if (!to) continue;
5576
+ const roles = to[1].replace(/\s+(?:with grant option|granted by)\b[\s\S]*$/, "").trim();
5577
+ const open = /\b(anon|public)\b/.exec(roles);
5578
+ if (open) out.push(open[1]);
5579
+ else if (!roles || roles.includes("%")) out.push(null);
5580
+ }
5581
+ }
5582
+ return out;
5583
+ }
5532
5584
  function checkGrants(ctx, migrations, exposed) {
5533
5585
  const fix = "grant by name (grant execute on function schema.fn(args) to role) so an earlier revoke survives";
5534
5586
  const open = (roles) => roles.filter((r) => r === "anon" || r === "public");
@@ -5539,7 +5591,19 @@ function checkGrants(ctx, migrations, exposed) {
5539
5591
  return null;
5540
5592
  };
5541
5593
  for (const { file, statements } of migrations) {
5542
- for (const { sql, line } of statements) {
5594
+ for (const { sql, line, bodies } of statements) {
5595
+ const dynamic = bodies.flatMap(dynamicGrants);
5596
+ if (dynamic.length) {
5597
+ const named = [...new Set(dynamic.filter((r) => r !== null))];
5598
+ ctx.report({
5599
+ rule: "migration-grants",
5600
+ level: "warn",
5601
+ file,
5602
+ line,
5603
+ subject: "dynamic grant",
5604
+ message: named.length ? `builds a grant to ${named.join(" and ")} in dynamic SQL (execute), so the doctor can't check what it grants; name each object and role in a static grant, or make sure every target is in an exposed schema` : "builds a grant to a computed role in dynamic SQL (execute), so the doctor can't check it isn't anon or public; name the role in the grant"
5605
+ });
5606
+ }
5543
5607
  const all = /^grant\b.*\bon all (?:functions|routines|procedures) in schema .+? to (.+)$/.exec(sql);
5544
5608
  if (all) {
5545
5609
  const hit = blanket(granteesOf(all[1]));
@@ -6632,23 +6696,42 @@ var init_api_usage = __esm({
6632
6696
  };
6633
6697
  }
6634
6698
  });
6699
+ function specifierParts(spec) {
6700
+ return spec.trim().replace(/^type\s+/, "").split(/\s+as\s+/).map((part) => part.trim());
6701
+ }
6702
+ function tagOf(comment) {
6703
+ const doc = comment.replace(/^[ \t]*\*?[ \t]*/gm, "");
6704
+ const deprecated = /^@deprecated\b[ \t]*([\s\S]*?)(?=^@|(?![\s\S]))/m.exec(doc);
6705
+ const stability = /^@stability\s+(Experimental|Beta|Stable|Deprecated)\b/im.exec(doc)?.[1]?.toLowerCase();
6706
+ const note = deprecated?.[1].replace(/\s+/g, " ").trim();
6707
+ if (deprecated) return { stability: "deprecated", ...note ? { note } : {} };
6708
+ return stability ? { stability } : void 0;
6709
+ }
6635
6710
  function stabilityTagsIn(dts) {
6636
6711
  const tags = /* @__PURE__ */ new Map();
6637
6712
  for (const m of dts.matchAll(DECLARATION)) {
6638
- const doc = m[1].replace(/^[ \t]*\*?[ \t]*/gm, "");
6639
- const deprecated = /^@deprecated\b[ \t]*([\s\S]*?)(?=^@|(?![\s\S]))/m.exec(doc);
6640
- const stability = /^@stability\s+(Experimental|Beta|Stable|Deprecated)\b/im.exec(doc)?.[1]?.toLowerCase();
6641
- const note = deprecated?.[1].replace(/\s+/g, " ").trim();
6642
- if (deprecated) tags.set(m[2], { stability: "deprecated", ...note ? { note } : {} });
6643
- else if (stability) tags.set(m[2], { stability });
6713
+ const tag = tagOf(m[1]);
6714
+ if (tag) tags.set(m[2], tag);
6644
6715
  }
6716
+ for (const [name, tag] of taggedReexports(dts)) tags.set(name, tag);
6645
6717
  return tags;
6646
6718
  }
6647
- function genesisNamedImports(code) {
6719
+ function* taggedReexports(dts) {
6720
+ for (const m of dts.matchAll(REEXPORT)) {
6721
+ const tag = tagOf(m[1]);
6722
+ if (!tag) continue;
6723
+ for (const spec of m[2].split(",")) {
6724
+ const name = specifierParts(spec).pop();
6725
+ if (name) yield [name, tag];
6726
+ }
6727
+ }
6728
+ }
6729
+ function genesisNamedImports(source) {
6648
6730
  const out = [];
6731
+ const code = stripForImports(source) ?? source;
6649
6732
  const re = /import\s+(?:type\s+)?(?:[\w$]+\s*,\s*)?\{([^}]*)\}\s*from\s*["']((@marktiderman\/genesis[\w-]*)(?:\/[^"']*)?)["']/g;
6650
6733
  for (const m of code.matchAll(re)) {
6651
- const names = m[1].split(",").map((n) => n.trim().replace(/^type\s+/, "").split(/\s+as\s+/)[0].trim()).filter(Boolean);
6734
+ const names = m[1].split(",").map((n) => specifierParts(n)[0]).filter(Boolean);
6652
6735
  out.push({ pkg: m[3], specifier: m[2], names, line: code.slice(0, m.index).split("\n").length });
6653
6736
  }
6654
6737
  return out;
@@ -6661,13 +6744,6 @@ function declarationFiles(dir, out = []) {
6661
6744
  }
6662
6745
  return out;
6663
6746
  }
6664
- function packageDir2(root, pkg) {
6665
- for (let dir = path28.resolve(root); ; dir = path28.dirname(dir)) {
6666
- const candidate = path28.join(dir, "node_modules", ...pkg.split("/"));
6667
- if (existsSync(path28.join(candidate, "package.json"))) return candidate;
6668
- if (path28.dirname(dir) === dir) return null;
6669
- }
6670
- }
6671
6747
  function readPackageTags(dir) {
6672
6748
  const pkg = JSON.parse(readFileSync(path28.join(dir, "package.json"), "utf8"));
6673
6749
  const tags = { dir, byFile: /* @__PURE__ */ new Map(), declaredIn: /* @__PURE__ */ new Map(), exports: typeof pkg.exports === "object" && pkg.exports ? pkg.exports : {} };
@@ -6676,11 +6752,12 @@ function readPackageTags(dir) {
6676
6752
  for (const file of declarationFiles(dist)) {
6677
6753
  const text = readFileSync(file, "utf8");
6678
6754
  tags.byFile.set(file, stabilityTagsIn(text));
6755
+ const names = /* @__PURE__ */ new Set();
6679
6756
  for (const m of text.matchAll(/^(?:export\s+)?(?:declare\s+)?(?:abstract\s+)?(?:function|const|let|class|interface|type|enum|namespace)\s+([A-Za-z_$][\w$]*)/gm)) {
6680
- const files = tags.declaredIn.get(m[1]) ?? [];
6681
- if (!files.includes(file)) files.push(file);
6682
- tags.declaredIn.set(m[1], files);
6757
+ names.add(m[1]);
6683
6758
  }
6759
+ for (const [name] of taggedReexports(text)) names.add(name);
6760
+ for (const name of names) tags.declaredIn.set(name, [...tags.declaredIn.get(name) ?? [], file]);
6684
6761
  }
6685
6762
  return tags;
6686
6763
  }
@@ -6700,7 +6777,7 @@ function checkStabilityImports(ctx) {
6700
6777
  const cache2 = /* @__PURE__ */ new Map();
6701
6778
  const tagsOf = (pkg) => {
6702
6779
  if (!cache2.has(pkg)) {
6703
- const dir = packageDir2(ctx.root, pkg);
6780
+ const dir = findPackageDir(ctx.root, pkg);
6704
6781
  cache2.set(pkg, dir ? readPackageTags(dir) : null);
6705
6782
  }
6706
6783
  return cache2.get(pkg);
@@ -6722,11 +6799,14 @@ function checkStabilityImports(ctx) {
6722
6799
  }
6723
6800
  }
6724
6801
  }
6725
- var SCRIPT_EXTS6, DECLARATION;
6802
+ var SCRIPT_EXTS6, DECLARATION, REEXPORT;
6726
6803
  var init_stability = __esm({
6727
6804
  "src/doctor/stability.ts"() {
6805
+ init_genesis();
6806
+ init_trail();
6728
6807
  SCRIPT_EXTS6 = /* @__PURE__ */ new Set([".ts", ".tsx", ".js", ".jsx", ".mts", ".cts", ".mjs", ".cjs"]);
6729
6808
  DECLARATION = /\/\*\*((?:(?!\*\/)[\s\S])*)\*\/\s*\n(?:export\s+)?(?:declare\s+)?(?:abstract\s+)?(?:function|const|let|class|interface|type|enum|namespace)\s+([A-Za-z_$][\w$]*)/g;
6809
+ REEXPORT = /\/\*\*((?:(?!\*\/)[\s\S])*)\*\/\s*\nexport\s+(?:type\s+)?\{([^}]*)\}/g;
6730
6810
  }
6731
6811
  });
6732
6812
  function git3(root, args) {
@@ -9743,7 +9823,7 @@ studio.command("init").description("Turn the Data Studio on in this app: a serve
9743
9823
  const packageJson = JSON.parse(await fs.readFile(path28.join(root, "package.json"), "utf-8").catch(() => "{}"));
9744
9824
  const existsSync36 = (await import('fs')).existsSync;
9745
9825
  const readSync = (await import('fs')).readFileSync;
9746
- const readdirSync17 = (await import('fs')).readdirSync;
9826
+ const readdirSync18 = (await import('fs')).readdirSync;
9747
9827
  if (opts.host && !["next", "tanstack-start", "supabase-function"].includes(opts.host)) {
9748
9828
  throw new Error("--host must be next, tanstack-start or supabase-function.");
9749
9829
  }
@@ -9756,7 +9836,7 @@ studio.command("init").description("Turn the Data Studio on in this app: a serve
9756
9836
  listDeep: (p) => {
9757
9837
  const out = [];
9758
9838
  const walk2 = (rel) => {
9759
- for (const entry of readdirSync17(path28.join(root, rel), { withFileTypes: true })) {
9839
+ for (const entry of readdirSync18(path28.join(root, rel), { withFileTypes: true })) {
9760
9840
  const child = `${rel}/${entry.name}`;
9761
9841
  if (entry.isDirectory()) walk2(child);
9762
9842
  else out.push(child);
@@ -9770,7 +9850,7 @@ studio.command("init").description("Turn the Data Studio on in this app: a serve
9770
9850
  },
9771
9851
  list: (p) => {
9772
9852
  try {
9773
- return readdirSync17(path28.join(root, p));
9853
+ return readdirSync18(path28.join(root, p));
9774
9854
  } catch {
9775
9855
  return [];
9776
9856
  }