@marktiderman/genesis-cli 1.17.1 → 1.17.3

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.
@@ -9,16 +9,30 @@
9
9
  # The `account` flows sign in, so they are left out (`exclude_tags: account`) until the
10
10
  # development EAS environment has MAESTRO_TEST_EMAIL and MAESTRO_TEST_PASSWORD (a test account on
11
11
  # the development Supabase project) as secret variables; then delete that line. Maestro reads
12
- # MAESTRO_* variables from the environment. This runs the pull request's code with that
12
+ # MAESTRO_* variables from the environment. This runs the branch's code with that
13
13
  # environment's variables: keep nothing there that production depends on.
14
14
  #
15
+ # It runs only when started by hand: Maestro jobs need a paid EAS plan, and each run is a
16
+ # simulator build or repack. Start it from git, always with --ref (without it, eas workflow:run
17
+ # uploads your working directory as it is):
18
+ #
19
+ # eas workflow:run e2e.yml --ref <branch>
20
+ #
21
+ # Once the plan includes Maestro, run it on pull requests too by adding, under `on:`, a
22
+ # pull_request trigger narrowed the way pr-preview.yml narrows it (into main, the app's paths):
23
+ #
24
+ # pull_request:
25
+ # branches: [main]
26
+ # paths: ["REPLACE_WITH_APP_FOLDER/**", "app.json", "app.config.*", "eas.json", "package.json", "pnpm-lock.yaml", ".maestro/**"]
27
+ #
28
+ # (the first path is the app's code folder, as in pr-preview.yml; list your package manager's
29
+ # lockfile.)
30
+ #
15
31
  # Genesis template (templates/eas/workflows/e2e.yml). Edit the copy in your app; see
16
32
  # docs/NATIVE-RELEASE.md in the Genesis repository.
17
33
  name: E2E
18
34
 
19
35
  on:
20
- pull_request:
21
- types: [opened, reopened, synchronize]
22
36
  workflow_dispatch: {}
23
37
 
24
38
  jobs:
@@ -6,6 +6,27 @@
6
6
  # 3. Publish the pull request's JavaScript as an update to the channel `pr-<number>`.
7
7
  # 4. Comment on the pull request: the build's install link and QR code, and the update.
8
8
  #
9
+ # When it runs (each run is up to two EAS builds or repacks, so the default is narrow):
10
+ # - A pull request into main that changes the app: its code folder or the config a build reads. A
11
+ # docs-only pull request, or one into another branch, starts nothing.
12
+ # The first path is the app's code folder. `genesis init --template native` fills in `src` (the
13
+ # starter keeps its code there); in a copy made by hand, replace the placeholder: `src`, or
14
+ # `apps/<name>` in a monorepo. An app with code in other top-level folders (`app/`,
15
+ # `components/`) lists each. Until it's replaced only the config files start a run, and
16
+ # `genesis doctor` warns about it (rule eas-placeholder).
17
+ # - Any pull request labeled `Preview` (create the label in GitHub), whatever it changes. A pull
18
+ # request that also matches the paths can start two runs (one per trigger); `concurrency` keeps
19
+ # one per branch, cancelling the older, and does the same when a new push supersedes a run.
20
+ # To widen it, add branches or paths; to run on every pull request, delete `branches` and `paths`.
21
+ #
22
+ # iOS is off until you turn it on. An iOS preview is an internal (ad hoc) build, which installs
23
+ # only on devices registered before it was built (`eas device:create`); with none registered,
24
+ # every iOS job fails. Register a device, then add the plain variable PREVIEW_IOS=true to the
25
+ # preview EAS environment. Android runs from the start. The gate reads PREVIEW_IOS through the
26
+ # `env` context of jobs that name the preview environment, as EAS's syntax describes; see
27
+ # docs/NATIVE-RELEASE.md, "Build cost", for what is verified. The fingerprint job hashes both
28
+ # platforms in one job and isn't gated.
29
+ #
9
30
  # Nothing here can reach production: the preview profile and EAS environment, internal
10
31
  # distribution, a pr-<number> channel, and no submit job. It does build the pull request's code
11
32
  # with the preview environment's variables, so keep nothing there that production depends on.
@@ -18,6 +39,26 @@ name: PR preview
18
39
  on:
19
40
  pull_request:
20
41
  types: [opened, reopened, synchronize]
42
+ branches: [main]
43
+ paths:
44
+ - "REPLACE_WITH_APP_FOLDER/**"
45
+ - "app.json"
46
+ - "app.config.*"
47
+ - "eas.json"
48
+ - "package.json"
49
+ - "pnpm-lock.yaml"
50
+ - "yarn.lock"
51
+ - "package-lock.json"
52
+ - "bun.lock"
53
+ - "bun.lockb"
54
+ pull_request_labeled:
55
+ labels: [Preview]
56
+
57
+ # One run per branch: a newer run (a push, or the Preview label on a pull request that also
58
+ # matched the paths) cancels the one in progress.
59
+ concurrency:
60
+ group: ${{ workflow.filename }}-${{ github.ref }}
61
+ cancel_in_progress: true
21
62
 
22
63
  jobs:
23
64
  fingerprint:
@@ -31,7 +72,9 @@ jobs:
31
72
  get_ios_build:
32
73
  name: Find a preview iOS build with this fingerprint
33
74
  needs: [fingerprint]
75
+ if: ${{ env.PREVIEW_IOS == 'true' }}
34
76
  type: get-build
77
+ environment: preview
35
78
  params:
36
79
  platform: ios
37
80
  profile: preview
@@ -51,7 +94,7 @@ jobs:
51
94
  repack_ios:
52
95
  name: Repack iOS with this JavaScript
53
96
  needs: [get_ios_build]
54
- if: ${{ needs.get_ios_build.outputs.build_id }}
97
+ if: ${{ env.PREVIEW_IOS == 'true' && needs.get_ios_build.outputs.build_id }}
55
98
  type: repack
56
99
  environment: preview
57
100
  env:
@@ -77,7 +120,7 @@ jobs:
77
120
  build_ios:
78
121
  name: Build iOS (native code changed)
79
122
  needs: [get_ios_build]
80
- if: ${{ !needs.get_ios_build.outputs.build_id }}
123
+ if: ${{ env.PREVIEW_IOS == 'true' && !needs.get_ios_build.outputs.build_id }}
81
124
  type: build
82
125
  environment: preview
83
126
  params:
@@ -1,7 +1,8 @@
1
1
  # Maestro flows
2
2
 
3
3
  Smoke flows for the starter, run against the development variant on a simulator or emulator.
4
- `.eas/workflows/e2e.yml` runs them on EAS for each pull request.
4
+ `.eas/workflows/e2e.yml` runs them on EAS when started by hand (`eas workflow:run e2e.yml --ref <branch>`);
5
+ it can run on pull requests once the EAS plan includes Maestro (see its header).
5
6
 
6
7
  | Flow | Tags | What it checks |
7
8
  | --- | --- | --- |
@@ -216,8 +216,8 @@ flows; [docs/NATIVE-RELEASE.md](../../docs/NATIVE-RELEASE.md) has the setup and
216
216
 
217
217
  | Workflow | When | What |
218
218
  | --- | --- | --- |
219
- | `pr-preview.yml` | each pull request | Repack a preview build with the same fingerprint (or build one), publish an update to `pr-<number>`, comment the install link and QR code. |
220
- | `e2e.yml` | each pull request | The Maestro flows on an iOS simulator build. |
219
+ | `pr-preview.yml` | a pull request into `main` that changes the app, or one labeled `Preview` | Repack a preview build with the same fingerprint (or build one), publish an update to `pr-<number>`, comment the install link and QR code. iOS once `PREVIEW_IOS=true`. |
220
+ | `e2e.yml` | by hand (Maestro needs a paid EAS plan) | The Maestro flows on an iOS simulator build. |
221
221
  | `deploy-production.yml` | a pushed `v*.*.*` tag | A store build where native code changed, else an update to `production` at 10%; both after a person approves. |
222
222
  | `rollout.yml` | by hand | Promote the staged update after a failed-launch check, or roll it back. |
223
223
 
@@ -225,7 +225,8 @@ Profiles: `development`, `preview` and `production` build the `APP_VARIANT` of t
225
225
  the channel of the same name; `e2e` is a development build for the simulator. Store ids in
226
226
  `eas.json` are `REPLACE_WITH_…` placeholders. These files are copies of
227
227
  [`templates/eas/`](../../templates/eas) and [`templates/maestro/`](../../templates/maestro); a test
228
- fails if they drift.
228
+ fails if they drift. What each workflow builds by default, and how to widen it:
229
+ [Build cost](../../docs/NATIVE-RELEASE.md#build-cost).
229
230
 
230
231
  ## Not covered yet
231
232
 
@@ -9,16 +9,30 @@
9
9
  # The `account` flows sign in, so they are left out (`exclude_tags: account`) until the
10
10
  # development EAS environment has MAESTRO_TEST_EMAIL and MAESTRO_TEST_PASSWORD (a test account on
11
11
  # the development Supabase project) as secret variables; then delete that line. Maestro reads
12
- # MAESTRO_* variables from the environment. This runs the pull request's code with that
12
+ # MAESTRO_* variables from the environment. This runs the branch's code with that
13
13
  # environment's variables: keep nothing there that production depends on.
14
14
  #
15
+ # It runs only when started by hand: Maestro jobs need a paid EAS plan, and each run is a
16
+ # simulator build or repack. Start it from git, always with --ref (without it, eas workflow:run
17
+ # uploads your working directory as it is):
18
+ #
19
+ # eas workflow:run e2e.yml --ref <branch>
20
+ #
21
+ # Once the plan includes Maestro, run it on pull requests too by adding, under `on:`, a
22
+ # pull_request trigger narrowed the way pr-preview.yml narrows it (into main, the app's paths):
23
+ #
24
+ # pull_request:
25
+ # branches: [main]
26
+ # paths: ["REPLACE_WITH_APP_FOLDER/**", "app.json", "app.config.*", "eas.json", "package.json", "pnpm-lock.yaml", ".maestro/**"]
27
+ #
28
+ # (the first path is the app's code folder, as in pr-preview.yml; list your package manager's
29
+ # lockfile.)
30
+ #
15
31
  # Genesis template (templates/eas/workflows/e2e.yml). Edit the copy in your app; see
16
32
  # docs/NATIVE-RELEASE.md in the Genesis repository.
17
33
  name: E2E
18
34
 
19
35
  on:
20
- pull_request:
21
- types: [opened, reopened, synchronize]
22
36
  workflow_dispatch: {}
23
37
 
24
38
  jobs:
@@ -6,6 +6,27 @@
6
6
  # 3. Publish the pull request's JavaScript as an update to the channel `pr-<number>`.
7
7
  # 4. Comment on the pull request: the build's install link and QR code, and the update.
8
8
  #
9
+ # When it runs (each run is up to two EAS builds or repacks, so the default is narrow):
10
+ # - A pull request into main that changes the app: its code folder or the config a build reads. A
11
+ # docs-only pull request, or one into another branch, starts nothing.
12
+ # The first path is the app's code folder. `genesis init --template native` fills in `src` (the
13
+ # starter keeps its code there); in a copy made by hand, replace the placeholder: `src`, or
14
+ # `apps/<name>` in a monorepo. An app with code in other top-level folders (`app/`,
15
+ # `components/`) lists each. Until it's replaced only the config files start a run, and
16
+ # `genesis doctor` warns about it (rule eas-placeholder).
17
+ # - Any pull request labeled `Preview` (create the label in GitHub), whatever it changes. A pull
18
+ # request that also matches the paths can start two runs (one per trigger); `concurrency` keeps
19
+ # one per branch, cancelling the older, and does the same when a new push supersedes a run.
20
+ # To widen it, add branches or paths; to run on every pull request, delete `branches` and `paths`.
21
+ #
22
+ # iOS is off until you turn it on. An iOS preview is an internal (ad hoc) build, which installs
23
+ # only on devices registered before it was built (`eas device:create`); with none registered,
24
+ # every iOS job fails. Register a device, then add the plain variable PREVIEW_IOS=true to the
25
+ # preview EAS environment. Android runs from the start. The gate reads PREVIEW_IOS through the
26
+ # `env` context of jobs that name the preview environment, as EAS's syntax describes; see
27
+ # docs/NATIVE-RELEASE.md, "Build cost", for what is verified. The fingerprint job hashes both
28
+ # platforms in one job and isn't gated.
29
+ #
9
30
  # Nothing here can reach production: the preview profile and EAS environment, internal
10
31
  # distribution, a pr-<number> channel, and no submit job. It does build the pull request's code
11
32
  # with the preview environment's variables, so keep nothing there that production depends on.
@@ -18,6 +39,26 @@ name: PR preview
18
39
  on:
19
40
  pull_request:
20
41
  types: [opened, reopened, synchronize]
42
+ branches: [main]
43
+ paths:
44
+ - "REPLACE_WITH_APP_FOLDER/**"
45
+ - "app.json"
46
+ - "app.config.*"
47
+ - "eas.json"
48
+ - "package.json"
49
+ - "pnpm-lock.yaml"
50
+ - "yarn.lock"
51
+ - "package-lock.json"
52
+ - "bun.lock"
53
+ - "bun.lockb"
54
+ pull_request_labeled:
55
+ labels: [Preview]
56
+
57
+ # One run per branch: a newer run (a push, or the Preview label on a pull request that also
58
+ # matched the paths) cancels the one in progress.
59
+ concurrency:
60
+ group: ${{ workflow.filename }}-${{ github.ref }}
61
+ cancel_in_progress: true
21
62
 
22
63
  jobs:
23
64
  fingerprint:
@@ -31,7 +72,9 @@ jobs:
31
72
  get_ios_build:
32
73
  name: Find a preview iOS build with this fingerprint
33
74
  needs: [fingerprint]
75
+ if: ${{ env.PREVIEW_IOS == 'true' }}
34
76
  type: get-build
77
+ environment: preview
35
78
  params:
36
79
  platform: ios
37
80
  profile: preview
@@ -51,7 +94,7 @@ jobs:
51
94
  repack_ios:
52
95
  name: Repack iOS with this JavaScript
53
96
  needs: [get_ios_build]
54
- if: ${{ needs.get_ios_build.outputs.build_id }}
97
+ if: ${{ env.PREVIEW_IOS == 'true' && needs.get_ios_build.outputs.build_id }}
55
98
  type: repack
56
99
  environment: preview
57
100
  env:
@@ -77,7 +120,7 @@ jobs:
77
120
  build_ios:
78
121
  name: Build iOS (native code changed)
79
122
  needs: [get_ios_build]
80
- if: ${{ !needs.get_ios_build.outputs.build_id }}
123
+ if: ${{ env.PREVIEW_IOS == 'true' && !needs.get_ios_build.outputs.build_id }}
81
124
  type: build
82
125
  environment: preview
83
126
  params:
package/dist/vite.js CHANGED
@@ -454,14 +454,14 @@ function inherit(own, source) {
454
454
  }
455
455
  function resolveViews(relations) {
456
456
  const done = /* @__PURE__ */ new Set();
457
- const resolve17 = (relation, depth) => {
457
+ const resolve16 = (relation, depth) => {
458
458
  if (done.has(relation.oid) || !relation.origins || depth > MAX_VIEW_DEPTH) return;
459
459
  done.add(relation.oid);
460
460
  const sources = new Set([...relation.origins.values()].map((o) => o.relation));
461
461
  if (sources.size !== 1) return;
462
462
  const source = relations.get([...sources][0]);
463
463
  if (!source) return;
464
- resolve17(source, depth + 1);
464
+ resolve16(source, depth + 1);
465
465
  const viewAttnumOf = /* @__PURE__ */ new Map();
466
466
  for (const [attnum, origin] of relation.origins) {
467
467
  const own = relation.columns.get(attnum);
@@ -484,7 +484,7 @@ function resolveViews(relations) {
484
484
  };
485
485
  if (Object.keys(inherited).length) relation.table.settings = { ...inherited, ...relation.table.settings };
486
486
  };
487
- for (const relation of relations.values()) resolve17(relation, 0);
487
+ for (const relation of relations.values()) resolve16(relation, 0);
488
488
  }
489
489
  async function introspectPostgres(sql, schemas, options = {}) {
490
490
  const relations = /* @__PURE__ */ new Map();
@@ -2188,6 +2188,7 @@ var BUILTIN_RULES = [
2188
2188
  "native-custom-header",
2189
2189
  "native-screen-layout",
2190
2190
  "store-readiness",
2191
+ "eas-placeholder",
2191
2192
  // supabase pack
2192
2193
  "migration-grants",
2193
2194
  "migration-rls",
@@ -2564,6 +2565,32 @@ function checkNativePack(ctx) {
2564
2565
  checkCustomHeaders(ctx, pkg);
2565
2566
  checkScreenLayouts(ctx, pkg);
2566
2567
  checkStoreReadiness(ctx);
2568
+ checkEasPlaceholders(ctx);
2569
+ }
2570
+ var EAS_PLACEHOLDER = /\bREPLACE_WITH_[A-Z0-9_]+/g;
2571
+ function checkEasPlaceholders(ctx) {
2572
+ const files = [];
2573
+ if (existsSync(path19.join(ctx.root, "eas.json"))) files.push("eas.json");
2574
+ const workflows = path19.join(ctx.root, ".eas", "workflows");
2575
+ if (existsSync(workflows)) {
2576
+ for (const name of readdirSync(workflows).sort()) if (/\.ya?ml$/.test(name)) files.push(`.eas/workflows/${name}`);
2577
+ }
2578
+ for (const file of files) {
2579
+ const lines = readFileSync(path19.join(ctx.root, file), "utf8").split("\n");
2580
+ lines.forEach((text, i) => {
2581
+ if (!file.endsWith(".json") && /^\s*#/.test(text)) return;
2582
+ for (const m of text.matchAll(EAS_PLACEHOLDER)) {
2583
+ ctx.report({
2584
+ rule: "eas-placeholder",
2585
+ level: "warn",
2586
+ file,
2587
+ line: i + 1,
2588
+ subject: m[0],
2589
+ 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)`
2590
+ });
2591
+ }
2592
+ });
2593
+ }
2567
2594
  }
2568
2595
  var RN = String.raw`["']react-native["']`;
2569
2596
  function checkRawPrimitives(ctx, pkg) {
@@ -3490,7 +3517,7 @@ function toRegExp2(source, flags = "") {
3490
3517
  if (source.startsWith("(?i)")) return new RegExp(source.slice(4), flags + "i");
3491
3518
  return new RegExp(source, flags);
3492
3519
  }
3493
- function validateDeclaration(raw, packageName3, packageDir2, ignored) {
3520
+ function validateDeclaration(raw, packageName3, packageDir, ignored) {
3494
3521
  const fail = (msg) => {
3495
3522
  throw new PackageDeclarationError(`${packageName3}: genesis.doctor ${msg}`);
3496
3523
  };
@@ -3510,9 +3537,9 @@ function validateDeclaration(raw, packageName3, packageDir2, ignored) {
3510
3537
  }
3511
3538
  });
3512
3539
  if (typeof raw === "string") {
3513
- if (!packageDir2) fail(`points at ${raw}, but the package folder is unknown`);
3514
- const file = path19.resolve(packageDir2, raw);
3515
- if (!inside(packageDir2, file)) fail(`points outside the package (${raw})`);
3540
+ if (!packageDir) fail(`points at ${raw}, but the package folder is unknown`);
3541
+ const file = path19.resolve(packageDir, raw);
3542
+ if (!inside(packageDir, file)) fail(`points outside the package (${raw})`);
3516
3543
  if (!existsSync(file)) fail(`points at ${raw}, which doesn't exist (is it in package.json "files"?)`);
3517
3544
  let parsed;
3518
3545
  try {
@@ -3520,7 +3547,7 @@ function validateDeclaration(raw, packageName3, packageDir2, ignored) {
3520
3547
  } catch (err) {
3521
3548
  return fail(`file ${raw} is not valid JSON: ${err.message}`);
3522
3549
  }
3523
- return validateDeclaration(parsed, packageName3, packageDir2, ignored);
3550
+ return validateDeclaration(parsed, packageName3, packageDir, ignored);
3524
3551
  }
3525
3552
  if (raw === false) fail(`is false; say why with { "enforce": false, "reason": "\u2026" }`);
3526
3553
  if (!isObject3(raw)) fail(`must be an object (or a path to a JSON file in the package)`);
@@ -3558,10 +3585,10 @@ function validateDeclaration(raw, packageName3, packageDir2, ignored) {
3558
3585
  });
3559
3586
  let plugin;
3560
3587
  if (typeof c.plugin === "string") {
3561
- if (!packageDir2) plugin = c.plugin;
3588
+ if (!packageDir) plugin = c.plugin;
3562
3589
  else {
3563
- plugin = path19.resolve(packageDir2, c.plugin);
3564
- if (!inside(packageDir2, plugin)) fail(`plugin points outside the package (${c.plugin})`);
3590
+ plugin = path19.resolve(packageDir, c.plugin);
3591
+ if (!inside(packageDir, plugin)) fail(`plugin points outside the package (${c.plugin})`);
3565
3592
  }
3566
3593
  }
3567
3594
  return {
@@ -4407,6 +4434,23 @@ function checkTestingKit(ctx, migrations) {
4407
4434
  function granteesOf(s) {
4408
4435
  return s.replace(/\s+granted by .*$/, "").replace(/\s+with grant option$/, "").split(/\s*,\s*/).map((r) => r.replace(/^group\s+/, "").trim()).filter(Boolean);
4409
4436
  }
4437
+ function dynamicGrants(body) {
4438
+ const out = [];
4439
+ const code = body.replace(/\/\*[\s\S]*?\*\/|--[^\n]*/g, "").replace(/(?<![\w."'$])raise\s+(?:(?:debug|log|info|notice|warning|exception|sqlstate|using)\b|')[^;]*;/g, ";");
4440
+ const strings2 = /(?<![\w$])e'((?:[^'\\]|\\[\s\S]|'')*)(?:'|$)|'((?:[^']|'')*)(?:'|$)|\$(\w*)\$([\s\S]*?)(?:\$\3\$|$)/g;
4441
+ for (const m of code.matchAll(strings2)) {
4442
+ for (const stmt of (m[1] ?? m[2] ?? m[4] ?? "").split(";")) {
4443
+ if (!/^\s*(?:grant|alter default privileges\b.*?\bgrant)\b/.test(stmt)) continue;
4444
+ const to = /\bto(?:\s+|$)([\s\S]*)$/.exec(stmt);
4445
+ if (!to) continue;
4446
+ const roles = to[1].replace(/\s+(?:with grant option|granted by)\b[\s\S]*$/, "").trim();
4447
+ const open = /\b(anon|public)\b/.exec(roles);
4448
+ if (open) out.push(open[1]);
4449
+ else if (!roles || roles.includes("%")) out.push(null);
4450
+ }
4451
+ }
4452
+ return out;
4453
+ }
4410
4454
  function checkGrants(ctx, migrations, exposed) {
4411
4455
  const fix = "grant by name (grant execute on function schema.fn(args) to role) so an earlier revoke survives";
4412
4456
  const open = (roles) => roles.filter((r) => r === "anon" || r === "public");
@@ -4417,7 +4461,19 @@ function checkGrants(ctx, migrations, exposed) {
4417
4461
  return null;
4418
4462
  };
4419
4463
  for (const { file, statements } of migrations) {
4420
- for (const { sql, line } of statements) {
4464
+ for (const { sql, line, bodies } of statements) {
4465
+ const dynamic = bodies.flatMap(dynamicGrants);
4466
+ if (dynamic.length) {
4467
+ const named = [...new Set(dynamic.filter((r) => r !== null))];
4468
+ ctx.report({
4469
+ rule: "migration-grants",
4470
+ level: "warn",
4471
+ file,
4472
+ line,
4473
+ subject: "dynamic grant",
4474
+ 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"
4475
+ });
4476
+ }
4421
4477
  const all = /^grant\b.*\bon all (?:functions|routines|procedures) in schema .+? to (.+)$/.exec(sql);
4422
4478
  if (all) {
4423
4479
  const hit = blanket(granteesOf(all[1]));
@@ -5355,23 +5411,43 @@ function checkRemovedScopeNames(ctx) {
5355
5411
  }
5356
5412
  var SCRIPT_EXTS6 = /* @__PURE__ */ new Set([".ts", ".tsx", ".js", ".jsx", ".mts", ".cts", ".mjs", ".cjs"]);
5357
5413
  var 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;
5414
+ var REEXPORT = /\/\*\*((?:(?!\*\/)[\s\S])*)\*\/\s*\nexport\s+(?:type\s+)?\{([^}]*)\}/g;
5415
+ function specifierParts(spec) {
5416
+ return spec.trim().replace(/^type\s+/, "").split(/\s+as\s+/).map((part) => part.trim());
5417
+ }
5418
+ function tagOf(comment) {
5419
+ const doc = comment.replace(/^[ \t]*\*?[ \t]*/gm, "");
5420
+ const deprecated = /^@deprecated\b[ \t]*([\s\S]*?)(?=^@|(?![\s\S]))/m.exec(doc);
5421
+ const stability = /^@stability\s+(Experimental|Beta|Stable|Deprecated)\b/im.exec(doc)?.[1]?.toLowerCase();
5422
+ const note = deprecated?.[1].replace(/\s+/g, " ").trim();
5423
+ if (deprecated) return { stability: "deprecated", ...note ? { note } : {} };
5424
+ return stability ? { stability } : void 0;
5425
+ }
5358
5426
  function stabilityTagsIn(dts) {
5359
5427
  const tags = /* @__PURE__ */ new Map();
5360
5428
  for (const m of dts.matchAll(DECLARATION)) {
5361
- const doc = m[1].replace(/^[ \t]*\*?[ \t]*/gm, "");
5362
- const deprecated = /^@deprecated\b[ \t]*([\s\S]*?)(?=^@|(?![\s\S]))/m.exec(doc);
5363
- const stability = /^@stability\s+(Experimental|Beta|Stable|Deprecated)\b/im.exec(doc)?.[1]?.toLowerCase();
5364
- const note = deprecated?.[1].replace(/\s+/g, " ").trim();
5365
- if (deprecated) tags.set(m[2], { stability: "deprecated", ...note ? { note } : {} });
5366
- else if (stability) tags.set(m[2], { stability });
5429
+ const tag = tagOf(m[1]);
5430
+ if (tag) tags.set(m[2], tag);
5367
5431
  }
5432
+ for (const [name, tag] of taggedReexports(dts)) tags.set(name, tag);
5368
5433
  return tags;
5369
5434
  }
5370
- function genesisNamedImports(code) {
5435
+ function* taggedReexports(dts) {
5436
+ for (const m of dts.matchAll(REEXPORT)) {
5437
+ const tag = tagOf(m[1]);
5438
+ if (!tag) continue;
5439
+ for (const spec of m[2].split(",")) {
5440
+ const name = specifierParts(spec).pop();
5441
+ if (name) yield [name, tag];
5442
+ }
5443
+ }
5444
+ }
5445
+ function genesisNamedImports(source) {
5371
5446
  const out = [];
5447
+ const code = stripForImports(source) ?? source;
5372
5448
  const re = /import\s+(?:type\s+)?(?:[\w$]+\s*,\s*)?\{([^}]*)\}\s*from\s*["']((@marktiderman\/genesis[\w-]*)(?:\/[^"']*)?)["']/g;
5373
5449
  for (const m of code.matchAll(re)) {
5374
- const names = m[1].split(",").map((n) => n.trim().replace(/^type\s+/, "").split(/\s+as\s+/)[0].trim()).filter(Boolean);
5450
+ const names = m[1].split(",").map((n) => specifierParts(n)[0]).filter(Boolean);
5375
5451
  out.push({ pkg: m[3], specifier: m[2], names, line: code.slice(0, m.index).split("\n").length });
5376
5452
  }
5377
5453
  return out;
@@ -5384,13 +5460,6 @@ function declarationFiles(dir, out = []) {
5384
5460
  }
5385
5461
  return out;
5386
5462
  }
5387
- function packageDir(root, pkg) {
5388
- for (let dir = path19.resolve(root); ; dir = path19.dirname(dir)) {
5389
- const candidate = path19.join(dir, "node_modules", ...pkg.split("/"));
5390
- if (existsSync(path19.join(candidate, "package.json"))) return candidate;
5391
- if (path19.dirname(dir) === dir) return null;
5392
- }
5393
- }
5394
5463
  function readPackageTags(dir) {
5395
5464
  const pkg = JSON.parse(readFileSync(path19.join(dir, "package.json"), "utf8"));
5396
5465
  const tags = { dir, byFile: /* @__PURE__ */ new Map(), declaredIn: /* @__PURE__ */ new Map(), exports: typeof pkg.exports === "object" && pkg.exports ? pkg.exports : {} };
@@ -5399,11 +5468,12 @@ function readPackageTags(dir) {
5399
5468
  for (const file of declarationFiles(dist)) {
5400
5469
  const text = readFileSync(file, "utf8");
5401
5470
  tags.byFile.set(file, stabilityTagsIn(text));
5471
+ const names = /* @__PURE__ */ new Set();
5402
5472
  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)) {
5403
- const files = tags.declaredIn.get(m[1]) ?? [];
5404
- if (!files.includes(file)) files.push(file);
5405
- tags.declaredIn.set(m[1], files);
5473
+ names.add(m[1]);
5406
5474
  }
5475
+ for (const [name] of taggedReexports(text)) names.add(name);
5476
+ for (const name of names) tags.declaredIn.set(name, [...tags.declaredIn.get(name) ?? [], file]);
5407
5477
  }
5408
5478
  return tags;
5409
5479
  }
@@ -5423,7 +5493,7 @@ function checkStabilityImports(ctx) {
5423
5493
  const cache2 = /* @__PURE__ */ new Map();
5424
5494
  const tagsOf = (pkg) => {
5425
5495
  if (!cache2.has(pkg)) {
5426
- const dir = packageDir(ctx.root, pkg);
5496
+ const dir = findPackageDir(ctx.root, pkg);
5427
5497
  cache2.set(pkg, dir ? readPackageTags(dir) : null);
5428
5498
  }
5429
5499
  return cache2.get(pkg);