@marktiderman/genesis-cli 1.8.0 → 1.10.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.
@@ -1,7 +1,8 @@
1
1
  /**
2
2
  * Public types for `genesis doctor` and its rule plugins.
3
3
  */
4
- type Level = "error" | "warn";
4
+ /** `info` is reported but never fails a run, `--strict` included. */
5
+ type Level = "error" | "warn" | "info";
5
6
  /** A rule's configured level: a level, or `"off"` to drop its findings. */
6
7
  type RuleSetting = Level | "off";
7
8
  /** One problem the doctor found. */
@@ -113,7 +114,7 @@ interface DoctorConfig {
113
114
  forbiddenImports?: Record<string, string>;
114
115
  /** Folders that must not exist (local design-system primitives). Default `["src/components/ui"]`. */
115
116
  localPrimitiveDirs?: string[];
116
- /** Per-rule level overrides, e.g. `{ "raw-color": "warn", "palette-color": "off" }`. */
117
+ /** Per-rule level overrides, e.g. `{ "raw-color": "warn", "palette-color": "off" }`. `info` never fails a run. */
117
118
  rules?: Record<string, RuleSetting>;
118
119
  /** Justified exceptions. */
119
120
  allow?: AllowEntry[];
@@ -123,6 +124,18 @@ interface DoctorConfig {
123
124
  rulesDoc?: string;
124
125
  /** Rule modules, resolved relative to the config file. */
125
126
  plugins?: PluginSpec[];
127
+ /**
128
+ * The web app's file-based routes folder, read by the structure rules
129
+ * (`hand-rolled-sub-nav`, `resource-workspace`, `page-layout`). Default: the
130
+ * first of `src/routes`, `src/app`, `app`, `src/pages`, `pages` that exists.
131
+ */
132
+ routesDir?: string;
133
+ /**
134
+ * Genesis packages besides `uiPackage` whose exported components an app
135
+ * should reuse, not copy (`local-genesis-copy`). Default
136
+ * `["@marktiderman/genesis-forms-studio"]`; packages not installed are skipped.
137
+ */
138
+ componentPackages?: string[];
126
139
  /** Commands `--build` runs, in order. Default: the app's `typecheck` then `build` scripts. */
127
140
  build?: string[];
128
141
  }
@@ -142,6 +155,15 @@ interface GenesisFacts {
142
155
  rawTags: ReadonlyMap<string, string>;
143
156
  /** Tailwind palette color names (red, slate, …). */
144
157
  palette: readonly string[];
158
+ /** The installed `componentPackages` (forms-studio by default) and the components each exports. */
159
+ companions: ReadonlyArray<CompanionPackage>;
160
+ }
161
+ /** A Genesis component package read alongside the main one. */
162
+ interface CompanionPackage {
163
+ package: string;
164
+ version: string;
165
+ /** Exported components, sorted. */
166
+ components: readonly string[];
145
167
  }
146
168
  /** One scanned file. */
147
169
  interface SourceFile {
@@ -180,6 +202,8 @@ interface DoctorResult {
180
202
  ruleCount: number;
181
203
  errors: number;
182
204
  warnings: number;
205
+ /** Findings at `info`: shown, never failing. */
206
+ infos: number;
183
207
  }
184
208
 
185
209
  /** A genesis.config.json that can't be read or has a block of the wrong shape. */
@@ -266,4 +290,4 @@ declare function validateLinks(raw: unknown, source?: string): GenesisLinks;
266
290
  /** Check the shape, so a typo fails loudly instead of silently disabling a check. */
267
291
  declare function validateConfig(raw: unknown, source?: string): DoctorConfig;
268
292
 
269
- export { type AllowEntry as A, type DoctorConfig as D, type Finding as F, type GenesisDataUse as G, type Level as L, type NativePackConfig as N, PRIVACY_DATA_TYPES as P, type RuleSetting as R, type SourceFile as S, type GenesisPrivacy as a, type GenesisLinks as b, GenesisConfigError as c, PRIVACY_PURPOSES as d, validatePrivacy as e, DoctorConfigError as f, type DoctorContext as g, type DoctorPlugin as h, type DoctorResult as i, type GenesisConfigFile as j, type GenesisFacts as k, type PatternRule as l, type DoctorPack as m, type FindingInput as n, type PluginSpec as o, privacyDataType as p, type SupabasePackConfig as q, readGenesisConfig as r, loadConfig as s, validateConfig as t, validateLinks as v };
293
+ export { type AllowEntry as A, type CompanionPackage as C, type DoctorConfig as D, type Finding as F, type GenesisDataUse as G, type Level as L, type NativePackConfig as N, PRIVACY_DATA_TYPES as P, type RuleSetting as R, type SourceFile as S, type GenesisPrivacy as a, type GenesisLinks as b, GenesisConfigError as c, PRIVACY_PURPOSES as d, validatePrivacy as e, DoctorConfigError as f, type DoctorContext as g, type DoctorPlugin as h, type DoctorResult as i, type GenesisConfigFile as j, type GenesisFacts as k, type PatternRule as l, type DoctorPack as m, type FindingInput as n, type PluginSpec as o, privacyDataType as p, type SupabasePackConfig as q, readGenesisConfig as r, loadConfig as s, validateConfig as t, validateLinks as v };
package/dist/doctor.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { D as DoctorConfig, k as GenesisFacts, l as PatternRule, h as DoctorPlugin, i as DoctorResult, F as Finding } from './config-CrZbM3jD.js';
2
- export { A as AllowEntry, f as DoctorConfigError, g as DoctorContext, m as DoctorPack, n as FindingInput, c as GenesisConfigError, j as GenesisConfigFile, b as GenesisLinks, L as Level, N as NativePackConfig, o as PluginSpec, R as RuleSetting, S as SourceFile, q as SupabasePackConfig, s as loadConfig, r as readGenesisConfig, t as validateConfig, v as validateLinks } from './config-CrZbM3jD.js';
1
+ import { D as DoctorConfig, k as GenesisFacts, l as PatternRule, h as DoctorPlugin, S as SourceFile, g as DoctorContext, i as DoctorResult, F as Finding } from './config-QC_Ewwwp.js';
2
+ export { A as AllowEntry, C as CompanionPackage, f as DoctorConfigError, m as DoctorPack, n as FindingInput, c as GenesisConfigError, j as GenesisConfigFile, b as GenesisLinks, L as Level, N as NativePackConfig, o as PluginSpec, R as RuleSetting, q as SupabasePackConfig, s as loadConfig, r as readGenesisConfig, t as validateConfig, v as validateLinks } from './config-QC_Ewwwp.js';
3
3
 
4
4
  /** The installed folder of `name`, looking in node_modules from `from` upward (works with hoisting and pnpm). */
5
5
  declare function findPackageDir(from: string, name: string): string | null;
@@ -26,7 +26,7 @@ declare function parseRulesMarkdown(markdown: string): PatternRule[];
26
26
  declare function defineDoctorPlugin(plugin: DoctorPlugin): DoctorPlugin;
27
27
 
28
28
  /** Ids of the built-in rules, for `rules` overrides and `allow` entries. */
29
- declare const BUILTIN_RULES: readonly ["local-primitives", "starter-leftover", "forbidden-import", "raw-tag", "palette-color", "arbitrary-color", "raw-color", "undefined-token", "shadowed-export", "version-skew", "native-raw-primitive", "native-literal-color", "native-custom-header", "native-screen-layout", "store-readiness", "migration-grants", "migration-rls", "migration-definer-search-path", "migration-edited"];
29
+ declare const BUILTIN_RULES: readonly ["local-primitives", "starter-leftover", "forbidden-import", "raw-tag", "palette-color", "arbitrary-color", "raw-color", "undefined-token", "shadowed-export", "version-skew", "duplicate-genesis-package", "peer-range-mismatch", "hand-rolled-sub-nav", "local-genesis-copy", "resource-workspace", "page-layout", "iso-date-slice", "native-raw-primitive", "native-literal-color", "native-custom-header", "native-screen-layout", "store-readiness", "migration-grants", "migration-rls", "migration-definer-search-path", "migration-edited", "migration-testing-kit"];
30
30
 
31
31
  /**
32
32
  * Minimal globs for config: `*` matches within a folder, `**` across folders,
@@ -56,6 +56,87 @@ interface ReleaseManifest {
56
56
  /** The installed umbrella's manifest, or null when there's no umbrella or no manifest. */
57
57
  declare function readReleaseManifest(root: string): ReleaseManifest | null;
58
58
 
59
+ /** One physical copy of a Genesis package, and who asked for it. */
60
+ interface GenesisInstall {
61
+ name: string;
62
+ version: string;
63
+ /** Folder relative to the app root, POSIX separators. */
64
+ dir: string;
65
+ /** The folder's real absolute path. */
66
+ absolutePath: string;
67
+ /** `the app` or `<package>@<version>`, with the range it declared. */
68
+ requiredBy: Array<{
69
+ by: string;
70
+ range?: string;
71
+ }>;
72
+ /**
73
+ * Reached only through dev tooling: every path to it from the app runs through
74
+ * a declared devDependency, or the Genesis CLI's own tree. Such a copy runs in
75
+ * scripts and builds, not in the app.
76
+ */
77
+ devOnly: boolean;
78
+ /** Reached from a declared runtime dependency of the app: it ships. */
79
+ runtime: boolean;
80
+ }
81
+ /**
82
+ * Every installed copy of every Genesis package the app can load, by name.
83
+ *
84
+ * Follows resolution, not folder layout: from each top-level package in the
85
+ * app's `node_modules` (and the app's own dependencies), each dependency is
86
+ * resolved the way Node does, from the real folder of the package asking. That
87
+ * covers npm/yarn/bun hoisted and nested trees, pnpm's `.pnpm` store (in the
88
+ * app or at a workspace root above a sub-app) and bun's isolated `.bun` store,
89
+ * where a package's dependencies are its siblings in the store entry. Copies
90
+ * nothing resolves to are left out: they never load.
91
+ *
92
+ * Each copy records which roots reach it: the app's declared runtime
93
+ * dependencies (`runtime`), hoisted packages nobody declared (they could be
94
+ * anyone's), and the dev roots (declared devDependencies, and the Genesis CLI
95
+ * wherever it's listed). Only a copy reached from dev roots alone is `devOnly`.
96
+ * An app with no runtime dependencies at all (everything in devDependencies, as
97
+ * a bundled SPA may list them) has its devDependencies taken as runtime.
98
+ */
99
+ declare function genesisInstalls(root: string): Map<string, GenesisInstall[]>;
100
+
101
+ /**
102
+ * Whether `version` satisfies `range`; null when either isn't semver (the caller
103
+ * can't judge it). A prerelease satisfies a set only if one of its comparators
104
+ * names the same major.minor.patch with a prerelease.
105
+ */
106
+ declare function satisfies(version: string, range: string): boolean | null;
107
+
108
+ interface RouteFile {
109
+ /** The file holding the route's component: the `.lazy` file when there is one. */
110
+ file: SourceFile;
111
+ /** Every file of the route (`posts.tsx` and `posts.lazy.tsx`). */
112
+ files: SourceFile[];
113
+ /** Path segments (`$param`, `[param]` and pathless `_layout` segments included), without the index/route stem. */
114
+ segments: string[];
115
+ /** Where it sits in the route tree: the segments, plus Next's `(group)` / `@slot` folders. Layouts wrap what's below them here. */
116
+ tree: string[];
117
+ /** The folder's own page: `index.tsx`, `page.tsx`, `my.index.tsx`. */
118
+ index: boolean;
119
+ /** Wraps child routes: a layout file (`route.tsx`, `layout.tsx`, `__root`), a pathless `_layout` route, or one rendering `<Outlet>` (itself or in a component it imports). */
120
+ layout: boolean;
121
+ /**
122
+ * A page of its own: not a pure layout. `__root`, Next's `layout` and a
123
+ * pathless `_layout` route are pure; a route with an `<Outlet>` is a page
124
+ * only when it renders content of its own beside it (text, a heading, a
125
+ * list or table), so a wrapper `<div><Outlet /></div>` isn't.
126
+ */
127
+ page: boolean;
128
+ /** A page whose own last segment is a param (`$courseId`, `[id]`): a detail page. */
129
+ detail: boolean;
130
+ /** Renders nothing but a redirect (or no component at all). */
131
+ redirectOnly: boolean;
132
+ /** The layout routes around it, nearest first. */
133
+ parents: RouteFile[];
134
+ }
135
+ /** The routes folder (`routesDir`, else the first candidate that exists), or null. */
136
+ declare function routesDir(ctx: Pick<DoctorContext, "root" | "config">): string | null;
137
+ /** Every scanned JSX route file under the routes folder, with its layouts. Empty without one. */
138
+ declare function webRoutes(ctx: Pick<DoctorContext, "root" | "config" | "files">): RouteFile[];
139
+
59
140
  interface RunDoctorOptions {
60
141
  /** The app root. Default `process.cwd()`. */
61
142
  root?: string;
@@ -73,6 +154,12 @@ interface RunDoctorOptions {
73
154
  genesis?: GenesisFacts;
74
155
  }
75
156
  declare function runDoctor(options?: RunDoctorOptions): Promise<DoctorResult>;
157
+ /**
158
+ * The built-in checks, in the order they run. A new built-in rule is a check
159
+ * here plus its ids in BUILTIN_RULES (rules.ts); a pack's checks run only when
160
+ * `packs` lists it.
161
+ */
162
+ declare function builtinChecks(config: DoctorConfig): DoctorPlugin[];
76
163
  /** The human-readable report. */
77
164
  declare function formatReport(result: DoctorResult): string;
78
165
  /** The `--json` report: plain data, sets turned into sorted lists. */
@@ -81,6 +168,7 @@ declare function toJson(result: DoctorResult): {
81
168
  genesis: string;
82
169
  errors: number;
83
170
  warnings: number;
171
+ infos: number;
84
172
  findings: Finding[];
85
173
  unused: string[];
86
174
  };
@@ -93,6 +181,9 @@ declare function genesisSummary(g: GenesisFacts): {
93
181
  [k: string]: string;
94
182
  };
95
183
  palette: readonly string[];
184
+ companions: {
185
+ [k: string]: readonly string[];
186
+ };
96
187
  };
97
188
 
98
- export { BUILTIN_RULES, DoctorConfig, DoctorPlugin, DoctorResult, Finding, GenesisFacts, PatternRule, type ReleaseManifest, type RunDoctorOptions, defineDoctorPlugin, findPackageDir, formatReport, genesisSummary, globToRegExp, loadGenesis, nativeLayouts, parseExportNames, parseRulesMarkdown, readPackageExports, readReleaseManifest, runDoctor, sqlStatements, toJson };
189
+ export { BUILTIN_RULES, DoctorConfig, DoctorContext, DoctorPlugin, DoctorResult, Finding, GenesisFacts, type GenesisInstall, PatternRule, type ReleaseManifest, type RouteFile, type RunDoctorOptions, SourceFile, builtinChecks, defineDoctorPlugin, findPackageDir, formatReport, genesisInstalls, genesisSummary, globToRegExp, loadGenesis, nativeLayouts, parseExportNames, parseRulesMarkdown, readPackageExports, readReleaseManifest, routesDir, runDoctor, satisfies, sqlStatements, toJson, webRoutes };