@marktiderman/genesis-cli 1.19.0 → 1.21.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 +98 -1
- package/dist/cli.js +682 -74
- package/dist/cli.js.map +1 -1
- package/dist/doctor.d.ts +1 -1
- package/dist/doctor.js +270 -8
- package/dist/doctor.js.map +1 -1
- package/dist/eslint.cjs +99 -0
- package/dist/eslint.cjs.map +1 -0
- package/dist/eslint.d.cts +68 -0
- package/dist/eslint.d.ts +68 -0
- package/dist/eslint.js +72 -0
- package/dist/eslint.js.map +1 -0
- package/dist/genesis-catalog.json +86 -14
- package/dist/index.js +278 -16
- package/dist/index.js.map +1 -1
- package/dist/starter/README.md +17 -5
- package/dist/starter/__tests__/components/setup.ts +11 -0
- package/dist/starter/__tests__/starter.test.ts +19 -0
- package/dist/starter/eslint.config.js +8 -1
- package/dist/starter/nativewind-env.d.ts +1 -0
- package/dist/starter/package.json +5 -3
- package/dist/starter/src/lib/app.ts +13 -5
- package/dist/starter/src/lib/define-starter.ts +1 -1
- package/dist/starter/src/lib/devtools-overlay.ts +3 -4
- package/dist/starter/src/lib/native-modules.ts +5 -1
- package/dist/starter/src/lib/offline.ts +14 -0
- package/dist/starter/supabase/migrations/20261024000750_support_default_tenant.sql +18 -0
- package/dist/starter/supabase/migrations/20261024000800_genesis_support_tickets.sql +800 -0
- package/dist/starter/supabase/migrations/20261025000070_starter_tenancy.sql +26 -0
- package/dist/starter/supabase/migrations/20261025000080_genesis_chat_tenants.sql +716 -0
- package/dist/starter/supabase/tests/database/chat_people.test.sql +1 -1
- package/dist/starter/supabase/tests/database/genesis_chat.test.sql +10 -2
- package/dist/starter/supabase/tests/database/genesis_chat_coaching.test.sql +8 -0
- package/dist/starter/supabase/tests/database/genesis_chat_search_threads.test.sql +8 -0
- package/dist/starter/supabase/tests/database/genesis_chat_tenants.test.sql +259 -0
- package/dist/starter/supabase/tests/database/genesis_support.test.sql +15 -3
- package/dist/starter/supabase/tests/database/genesis_support_findings.test.sql +10 -0
- package/dist/starter/supabase/tests/database/genesis_support_tickets.test.sql +327 -0
- package/dist/starter/supabase/tests/database/starter_tenancy.test.sql +19 -0
- package/dist/vite.js +270 -8
- package/dist/vite.js.map +1 -1
- package/package.json +18 -4
package/README.md
CHANGED
|
@@ -437,6 +437,34 @@ steps point at the notifications runner (`genesis-notifications`), which sends i
|
|
|
437
437
|
0001 after 0005 works too (it adopts the tables); then stop calling `genesis-push-send`, as
|
|
438
438
|
notifications' steps say.
|
|
439
439
|
|
|
440
|
+
A migration that calls a hook the app defines (a function Genesis never ships) names it in
|
|
441
|
+
`needs`, with what to add:
|
|
442
|
+
|
|
443
|
+
```json
|
|
444
|
+
{
|
|
445
|
+
"file": "migrations/0004_genesis_chat_tenants.sql",
|
|
446
|
+
"needs": [{ "function": "private.genesis_viewer_people", "how": "add the tenancy hook before it (genesis-supabase 0016's header)" }]
|
|
447
|
+
}
|
|
448
|
+
```
|
|
449
|
+
|
|
450
|
+
When `genesis add`, `migrate` or `upgrade` would copy it into an app where no migration defines that
|
|
451
|
+
function (by `create [or replace] function`, in the app's migrations or one copied before it in
|
|
452
|
+
the same run, outside SQL comments), its row says `needs <function> first: <how>` and the
|
|
453
|
+
command warns, before `supabase db push` fails on it.
|
|
454
|
+
|
|
455
|
+
A migration another block's migration reads names that one in `runsBefore`:
|
|
456
|
+
|
|
457
|
+
```json
|
|
458
|
+
{
|
|
459
|
+
"file": "migrations/0006_genesis_support_chat_tenants.sql",
|
|
460
|
+
"runsBefore": [{ "package": "@marktiderman/genesis-chat", "file": "migrations/0004_genesis_chat_tenants.sql" }]
|
|
461
|
+
}
|
|
462
|
+
```
|
|
463
|
+
|
|
464
|
+
When both are new in the same `genesis add`, `migrate` or `upgrade` run, it is copied first (with
|
|
465
|
+
its own package's earlier migrations, which keep their order), so it gets the earlier timestamp.
|
|
466
|
+
When the other is already in the app, nothing moves: the migration has to handle that case itself.
|
|
467
|
+
|
|
440
468
|
In an app whose database files live elsewhere ([A phone app beside a web app](#a-phone-app-beside-a-web-app)),
|
|
441
469
|
migrate plans nothing and says where to run it.
|
|
442
470
|
|
|
@@ -473,6 +501,7 @@ doesn't fit, is a warning.
|
|
|
473
501
|
| Codemod | Runs when | Changes |
|
|
474
502
|
| --- | --- | --- |
|
|
475
503
|
| `genesis-core-2-scope-names` | genesis-core crosses 2.0.0 | Genesis API usage only, never an app's own names that match (a view field means one inside `defineView(…)` or an object typed `ViewDefinition`/`ViewField`; the prop means an attribute of `<NativeResourceView>` or a key of an object typed `NativeResourceViewProps`; each with the name imported from Genesis): a view field's `timeZone: "practice"` → `"scope"`, NativeResourceView's `practiceTimeZone` (attribute or object key) → `scopeTimeZone`, `resolveZone("practice", …)` → `"scope"`, and DisplayTimeZones' `practice` (a `{ viewer, practice }` object's key, `.practice` on a value from `useDisplayTimeZones()` or typed `DisplayTimeZones`) → `scope`. `scope={{ practiceId }}` needs nothing (it is the app's own key in ResourceScope's open slot); when a file reads `scope.practiceId` and nothing declares it, the codemod prints the one-line `ResourceScope` augmentation that types it. The doctor's `removed-scope-name` rule finds what it would rewrite. |
|
|
504
|
+
| `genesis-cli-eslint-config` | genesis-cli crosses 1.20.0 | An ESLint flat config (`eslint.config.{js,mjs,cjs,ts,mts,cts}`) that doesn't load [`@marktiderman/genesis-cli/eslint`](#lint-rules) yet: adds the import (`require` or `import`, as the file is written) and spreads `genesis("native")` (an app with `expo` or `react-native`) or `genesis("web")` last into the array it exports, or into the array or arguments of the `defineConfig(…)` / `tseslint.config(…)` call it exports. A native app gets `eslint-plugin-testing-library` in its devDependencies when it's missing. A config that already loads the export is left alone; one it can't edit safely (built in a variable or a function, or exported twice) is left as it is, and it prints the two lines to add. A config that still inlines the starter's RNTL rules gets the spread and a note to delete the old block. Started from an older CLI, the upgrade doesn't have this codemod (see "Upgrading the CLI itself" below); the doctor's `genesis-eslint-config` then reports the app, and `genesis codemod genesis-cli-eslint-config` runs it. |
|
|
476
505
|
3. Reinstalls. With pnpm, a release younger than the app's `minimumReleaseAge` is installed in
|
|
477
506
|
loose mode and pnpm pins it in `minimumReleaseAgeExclude`, in the pnpm-workspace.yaml pnpm reads
|
|
478
507
|
(the nearest one at or above the app, but never above the repository's top level, else beside
|
|
@@ -496,6 +525,15 @@ doesn't fit, is a warning.
|
|
|
496
525
|
and yarn are skipped), so a Genesis package isn't left installed at two versions
|
|
497
526
|
(`duplicate-genesis-package`), and commits pnpm-workspace.yaml with `--pr`.
|
|
498
527
|
|
|
528
|
+
With Bun, which has no dedupe, it edits `bun.lock` before the install instead: a nested copy
|
|
529
|
+
of a Genesis package (`<parent>/@marktiderman/genesis-…` in `packages`) at another version
|
|
530
|
+
than the root's goes when the root's version satisfies the parent's range, since Bun keeps it
|
|
531
|
+
across installs otherwise; and an overlay the upgrade deleted leaves `workspaces` (in
|
|
532
|
+
`bun.lock` and the root `package.json`), or `bun install` stops with "Workspace dependency not
|
|
533
|
+
found". If the install leaves a nested copy behind, it's dropped and the install runs once
|
|
534
|
+
more. The summary lists what went, and says to run `bun install` when the upgrade didn't. The
|
|
535
|
+
binary `bun.lockb` isn't edited.
|
|
536
|
+
|
|
499
537
|
With `minimumReleaseAge` set in the app, pnpm runs in strict mode instead: the install fails
|
|
500
538
|
with `ERR_PNPM_NO_MATURE_MATCHING_VERSION` before any tidy, and the upgrade stops and names the
|
|
501
539
|
versions pnpm refused. It never loosens that setting for you: add those versions to
|
|
@@ -518,6 +556,23 @@ doesn't fit, is a warning.
|
|
|
518
556
|
(found up to the repository's root), never `.genesis-next` files. `--dry-run` changes nothing,
|
|
519
557
|
and shows the refresh against the packages installed now.
|
|
520
558
|
|
|
559
|
+
`--version <v>` is upgrade's own option: `genesis upgrade --version 2.30.0` upgrades to 2.30.0
|
|
560
|
+
(the CLI's own version is `genesis --version`, before any command). Since genesis-cli 1.18.0;
|
|
561
|
+
1.17.3 printed its own version instead.
|
|
562
|
+
|
|
563
|
+
**Upgrading the CLI itself.** The upgrade runs in the CLI that started it. It moves the app's
|
|
564
|
+
`@marktiderman/genesis-cli` dependency with the rest, but it doesn't restart in the new CLI: the
|
|
565
|
+
codemods, the owned-file refresh and the doctor of this run are the installed CLI's, so a
|
|
566
|
+
codemod the new release added doesn't run. To upgrade with the release's own CLI, start it
|
|
567
|
+
through npx:
|
|
568
|
+
|
|
569
|
+
```bash
|
|
570
|
+
npx @marktiderman/genesis-cli@latest upgrade --version <v>
|
|
571
|
+
```
|
|
572
|
+
|
|
573
|
+
The next `genesis upgrade` (and `genesis doctor`) in the app then runs the new CLI from its
|
|
574
|
+
dependencies.
|
|
575
|
+
|
|
521
576
|
`genesis.lock.json` is checked like a manifest, since anyone with commit access can edit it: each
|
|
522
577
|
entry may only write where its kind of source goes (a template to `eas.json`, `.eas/`, `.maestro/`
|
|
523
578
|
or `.github/workflows/`, a function file to `supabase/functions/<name>/`, a pgTAP test to
|
|
@@ -525,6 +580,47 @@ or `.github/workflows/`, a function file to `supabase/functions/<name>/`, a pgTA
|
|
|
525
580
|
substitutions may only replace the starter's own names. A pgTAP test waits while its block has
|
|
526
581
|
new migrations to copy.
|
|
527
582
|
|
|
583
|
+
## Lint rules
|
|
584
|
+
|
|
585
|
+
Genesis's lint rules for apps ship with the CLI, as ESLint flat-config pieces from
|
|
586
|
+
`@marktiderman/genesis-cli/eslint` (for `require` and `import`). An app spreads them into its
|
|
587
|
+
`eslint.config.js` once, and every CLI release it installs brings new and changed rules, with no
|
|
588
|
+
edit to the config. They ship from the CLI rather than a package of their own because every
|
|
589
|
+
Genesis app, web or native, already has `@marktiderman/genesis-cli` in its devDependencies (the
|
|
590
|
+
[genesis-upgrade workflow](../../docs/APP-CI.md) needs it), so nothing new is installed.
|
|
591
|
+
|
|
592
|
+
```js
|
|
593
|
+
// eslint.config.js (CommonJS, as Expo writes it)
|
|
594
|
+
const { defineConfig } = require("eslint/config");
|
|
595
|
+
const expoConfig = require("eslint-config-expo/flat");
|
|
596
|
+
const { genesis } = require("@marktiderman/genesis-cli/eslint");
|
|
597
|
+
|
|
598
|
+
module.exports = defineConfig([expoConfig, ...genesis("native")]);
|
|
599
|
+
```
|
|
600
|
+
|
|
601
|
+
In an ES module config: `import { genesis } from "@marktiderman/genesis-cli/eslint"`.
|
|
602
|
+
|
|
603
|
+
| Export | What it is |
|
|
604
|
+
| --- | --- |
|
|
605
|
+
| `genesis(platform, options?)` | Every Genesis piece for `"native"` or `"web"`. Spread this one, so pieces a release adds arrive too. `"native"` is `testing`; `"web"` is empty for now (Testing Library for React keeps `render` and `fireEvent` synchronous, so the RNTL await rules don't apply), and is there so web rules arrive when Genesis has some. |
|
|
606
|
+
| `testing(options?)` | React Native Testing Library 14's await rules, for test files (`TEST_FILES`: `**/__tests__/**` and `*.test.*`). RNTL 14 made `render`, `renderHook`, `fireEvent`, `act`, `rerender` and `unmount` async; left unawaited, a test reads the screen before React updated it. It turns on testing-library's `await-async-events` with `eventModule: ["fireEvent", "userEvent"]`, and a `no-restricted-syntax` rule for what the plugin has no rule for: `render`, `renderHook`, expo-router's `renderRouter`, the starter's `renderApp` and `act`; `rerender` and `unmount` as methods and destructured; and a chained `userEvent.setup().press(…)`. Each is flagged as a statement, a declaration or an assignment whose promise is dropped. |
|
|
607
|
+
| `rntlAwaitSelectors(options?)` | Those `no-restricted-syntax` entries, for an app that sets its own `no-restricted-syntax` on test files: a later setting of a rule replaces an earlier one, so spread these into yours. |
|
|
608
|
+
|
|
609
|
+
Options: `renders` (the app's own helpers that wrap `render`, checked like it:
|
|
610
|
+
`genesis("native", { renders: ["renderWithStore"] })`), `testFiles` (other test globs) and
|
|
611
|
+
`testingLibrary` (the plugin, when the config loads it itself).
|
|
612
|
+
|
|
613
|
+
`testing` needs `eslint-plugin-testing-library` (7 or later) in the app's devDependencies, an
|
|
614
|
+
optional peer dependency of the CLI. A flat config's plugins are objects, not names ESLint looks
|
|
615
|
+
up, so the piece loads the plugin itself when it's built (never on import): from the app (the
|
|
616
|
+
working directory, so it's the copy the app's own config would load), then from the CLI. When
|
|
617
|
+
it's missing, the config fails to load with a message saying to install it.
|
|
618
|
+
|
|
619
|
+
`genesis upgrade` adds the pieces to an app made before they shipped: the
|
|
620
|
+
`genesis-cli-eslint-config` codemod (see [genesis upgrade](#genesis-upgrade)) runs when the app's
|
|
621
|
+
CLI moves to 1.20.0. The doctor's `genesis-eslint-config` rule reports a native app still without
|
|
622
|
+
them, with the fix.
|
|
623
|
+
|
|
528
624
|
## Expo config plugin
|
|
529
625
|
|
|
530
626
|
`withGenesis()` keeps an Expo app's `app.config.ts` to a name, ids and plugins:
|
|
@@ -695,7 +791,8 @@ Exit codes: `0` pass, `1` findings, `2` the doctor couldn't run (bad config, Gen
|
|
|
695
791
|
| `package-rule-override` | warn | `rules` changes a package rule's level without a reason; move it to `packageRules` with one. |
|
|
696
792
|
| `agent-guide-stale` | warn | The agent guide `genesis agents` wrote (`.claude/skills/genesis/SKILL.md` and the `genesis-primitives` block in AGENTS.md) doesn't match the installed packages, one of the two is missing, or the block's markers are broken (one missing, repeated or out of order; `genesis agents` then writes nothing). An app with neither isn't checked. Line endings don't count. |
|
|
697
793
|
| `database-elsewhere` | warn | An app whose `genesis.config.json` `supabase` setting puts its database files in another app (`{ "app": "../app" }`) or nowhere (`false`): **warn** when the named app has no `supabase/` folder, and when this app still has one (`add`, `migrate` and `upgrade` never plan it, so it's a second, unused copy). The supabase pack doesn't run in such an app. |
|
|
698
|
-
| `
|
|
794
|
+
| `genesis-eslint-config` | warn | A native app (with `expo` or `react-native`, or the `native` pack) whose ESLint flat config doesn't load [`@marktiderman/genesis-cli/eslint`](#lint-rules), so `genesis upgrade` can't bring Genesis's lint rules; or loads it without `eslint-plugin-testing-library` in package.json, so the config can't load. The message gives the fix: `genesis codemod genesis-cli-eslint-config`, or the two lines to add. Web apps (Genesis has no web lint rules yet) and apps without a flat config aren't checked. Ratcheted by default: under `--base`, an unchanged config reports it as `info`. |
|
|
795
|
+
| `lock-files` | warn / info | `genesis.lock.json` against the files on disk. **warn**: a file the lock owns is missing; `genesis upgrade` never brings a deleted owned file back, so a lock naming files that aren't there passes every upgrade silently. A file you deleted on purpose gets `"deleted": true` in its lock entry: the warning stops and upgrade still leaves it deleted. **info**: a locked file whose checksum differs from the lock's (an app edit, which upgrade three-way merges the next version into, or one waiting on its `.genesis-next`); a file marked deleted that is back; a locked block whose `starter.config.ts` switch is off (upgrade and migrate leave it out, and its files aren't checked); files under `supabase/` the lock still lists in an app whose database lives elsewhere (upgrade leaves them alone, so delete the entries). Also `bun.lock` (at or above the app, with or without `genesis.lock.json`), **warn**: a nested copy of a Genesis package at another version than the root's, when the root's version satisfies the range of the package it's nested under. Bun keeps it across installs, so the app runs two copies; the finding names the entry to delete, then reinstall (`genesis upgrade` does both). |
|
|
699
796
|
| `ratchet-skipped` | warn / error | `--base` was given, but git couldn't compare (not a repository, or the ref isn't fetched). A warning when only the ratchet was skipped (every rule ran at its full level); an error when the config file holds `allow`, `rules` or `packageRules`, which then went uncompared. In CI, check out with `fetch-depth: 0`. |
|
|
700
797
|
| `allow-grew` | error | Under `--base`: an `allow` entry (its rule, file and match) that the doctor settings at the merge base didn't have. The list only shrinks. Rewording a `reason` is fine. The base's settings are found as the doctor finds them (genesis.config.json's `doctor`, else package.json's `genesis.doctor`), so moving them between the two compares as usual; when the base had none (adopting the doctor), nothing is compared. |
|
|
701
798
|
| `rules-weakened` | error | Under `--base`, comparing the app's settings with the base's only (never with a rule's own level, which a package upgrade may change): a rule the base's `rules` or `packageRules` set that this branch sets lower, a rule newly set to `off`, or an `exclude` glob a `packageRules` entry gained. A new entry at any other level isn't compared, so pinning a rule its package raised is fine; an entry renamed with its rule counts as new. `files` isn't compared. Not compared when the base had no doctor settings. |
|