@marktiderman/genesis-cli 1.5.0 → 1.6.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/README.md CHANGED
@@ -211,6 +211,69 @@ before building something.
211
211
  Scanned by default: `src/**/*.{ts,tsx,js,jsx,mts,cts,css}`, skipping tests, `__fixtures__`,
212
212
  `__mocks__`, `*.d.ts` and `*.gen.*`. Comments are ignored by every rule.
213
213
 
214
+ ### Rule packs
215
+
216
+ Two packs are opt-in, so a web app is unaffected until it lists them. Turn them on explicitly
217
+ (they are not auto-detected, so adding `expo` or a `supabase/` folder never changes a build's
218
+ result on its own):
219
+
220
+ ```json
221
+ {
222
+ "doctor": {
223
+ "packs": ["native", "supabase"],
224
+ "native": { "routerRoot": "app" },
225
+ "supabase": { "migrations": "supabase/migrations", "base": "origin/main", "exposedSchemas": ["public"], "since": "20260101000000" }
226
+ }
227
+ }
228
+ ```
229
+
230
+ Pack rule ids are built-in ids, so `rules` and `allow` work on them as on any other rule.
231
+ Folder settings (`routerRoot`, `migrations`) are app-relative: `./app/` is read as `app`, and
232
+ an absolute path or one leaving the app is a config error. `exposedSchemas` compares lowercased.
233
+
234
+ **`native`**, for Expo apps on `@marktiderman/genesis-ui-native`. With the pack on, the core
235
+ rules read the native package (unless `uiPackage` says otherwise) and the default scan is
236
+ `app`, `src` and `components`. The screen layouts are every component the installed native
237
+ package exports whose name ends in `Page`, `Screen` or `ScreenContainer` (`ScreenContainer`,
238
+ `SettingsPage`, `SettingsSubPage`, `NotificationsPage`, `AuthScreen`, `NativeResourcePage`, …),
239
+ so a new layout is recognized when Genesis ships it.
240
+
241
+ With the native pack on, every hex or `rgb()` literal in a script file is reported as
242
+ `native-literal-color` instead of `raw-color`, web files in a mixed repo included. Existing
243
+ `rules` and `allow` entries for `raw-color` that cover script files need the new id (CSS files
244
+ keep `raw-color`).
245
+
246
+ | Rule | Level | What it flags |
247
+ | --- | --- | --- |
248
+ | `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. |
249
+ | `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(...)`. |
250
+ | `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. |
251
+ | `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. |
252
+ | `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. |
253
+
254
+ **`supabase`**, for `supabase/migrations/*.sql` (`supabase.migrations`). The SQL is read
255
+ statement by statement with comments removed and string (`'…'`, `E'…'`) and dollar-quoted
256
+ bodies blanked, so text inside a function body never matches; the one exception is below.
257
+
258
+ | Rule | Level | What it flags |
259
+ | --- | --- | --- |
260
+ | `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. |
261
+ | `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. |
262
+ | `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. |
263
+ | `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. |
264
+
265
+ **Which migrations are new.** In a git repo with the base ref, a migration is new when it was
266
+ added, modified or is untracked since the merge base. `since` (a file name or timestamp prefix)
267
+ also trusts every file that sorts before it. Without git or the base ref (a shallow CI clone, a
268
+ Vercel build), `migration-grants` is skipped with a warning unless `since` is set, so applied
269
+ migrations never fail a build. In CI, check out with full history and fetch the base:
270
+
271
+ ```yaml
272
+ - uses: actions/checkout@v4
273
+ with: { fetch-depth: 0 }
274
+ - run: git fetch origin main
275
+ ```
276
+
214
277
  ### Config
215
278
 
216
279
  `genesis.config.json` (or `"genesis": { "doctor": { … } }` in package.json):
@@ -237,10 +300,13 @@ Scanned by default: `src/**/*.{ts,tsx,js,jsx,mts,cts,css}`, skipping tests, `__f
237
300
 
238
301
  | Key | Default | |
239
302
  | --- | --- | --- |
240
- | `src` | `["src"]` | Folders (or files) to scan. |
303
+ | `packs` | | Opt-in rule packs: `"native"`, `"supabase"`. See [Rule packs](#rule-packs). |
304
+ | `native` | | `{ routerRoot }` for the native pack. |
305
+ | `supabase` | | `{ migrations, base, exposedSchemas, since }` for the supabase pack. |
306
+ | `src` | `["src"]` (`["app", "src", "components"]` with the native pack) | Folders (or files) to scan. |
241
307
  | `extensions` | `.ts .tsx .js .jsx .mts .cts .css` | |
242
308
  | `ignore` | | Globs to skip, added to the defaults. `*` stays in a folder, `**` crosses folders, a trailing `/` means the whole folder. |
243
- | `uiPackage` | `@marktiderman/genesis-ui` | |
309
+ | `uiPackage` | `@marktiderman/genesis-ui` (`@marktiderman/genesis-ui-native` with the native pack) | |
244
310
  | `themeCss` | the design system's `dist/themes/*.css` + genesis-ui's styles | One stylesheet or a list: package paths (`@marktiderman/genesis-design-system/dist/themes/genesis.css`) or app paths. |
245
311
  | `tokenFiles` | every scanned `.css` | Globs of app files whose `--x:` declarations count as defined tokens. Files outside `src` work too. |
246
312
  | `ignoreTokenPrefixes` | `["--tw-", "--radix-"]` | |