@marktiderman/genesis-cli 1.0.3 → 1.1.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 ADDED
@@ -0,0 +1,62 @@
1
+ # @marktiderman/genesis-cli
2
+
3
+ ```bash
4
+ npx @marktiderman/genesis-cli init <consumer>
5
+ ```
6
+
7
+ Scaffolds a Genesis consumer: a brand package, Tailwind and tokens.
8
+
9
+ ```bash
10
+ npx @marktiderman/genesis-cli studio init
11
+ ```
12
+
13
+ Turns the Data Studio on in an existing Supabase app. It writes three things:
14
+
15
+ - **One migration to review:** the studio's `NOINHERIT` login and the audit trail. It holds no
16
+ password.
17
+ - **The server:** a Next.js route when the app has an `app/` router; otherwise a Supabase Edge
18
+ Function, `supabase/functions/genesis-studio`, with `verify_jwt = false` added to
19
+ `supabase/config.toml` because the function checks tokens itself.
20
+ - **A page:** for Lovable apps, it imports `@/integrations/supabase/client`.
21
+
22
+ It then prints the steps left: install, route the page, set the login's password, set the
23
+ function's secrets, apply the migration. Options: `--host next|supabase-function`, `--route`
24
+ (default `/admin/data`), `--login-role`, `--force`.
25
+
26
+ ```bash
27
+ DATABASE_URL=postgres://… npx @marktiderman/genesis-cli introspect
28
+ ```
29
+
30
+ Writes `resources.genesis.ts`, a checked-in contract for the Data Studio: every table in the
31
+ schemas, with its key, fields (type, database type, nullability, defaults, enum values, links)
32
+ and a row type per table. Review it like code, and pass `contracts` to `createStudioHandler`. It
33
+ wins over discovery for labels, widgets and descriptions; types, keys and permissions still come
34
+ from the live database.
35
+
36
+ | Option | Default | |
37
+ | --- | --- | --- |
38
+ | `--database-env <name>` | `DATABASE_URL` | The variable holding the Postgres URL. It's never read from the command line, so it stays out of shell history. Any role that can read `pg_catalog` works; no table data is read. |
39
+ | `--openapi <file-or-url>` | | Read a PostgREST OpenAPI document instead, e.g. a Supabase project's `https://<ref>.supabase.co/rest/v1/`. |
40
+ | `--apikey-env <name>` | | The variable holding the API key for an `--openapi` URL, sent as `apikey` and as a Bearer token. Like the database URL, it stays off the command line. |
41
+ | `--header "<Name>: <value>"` | | Other headers for an `--openapi` URL, for values that aren't secret. Repeatable. |
42
+ | `-s, --schema <list>` | `public` | Comma-separated schemas. `--openapi` reads one. |
43
+ | `-o, --out <file>` | `resources.genesis.ts` | Where to write. |
44
+ | `--check` | | Write nothing; exit 1 when the file is out of date. Run it in CI to catch drift. |
45
+
46
+ The output is deterministic: a re-run with no schema change writes the same bytes.
47
+
48
+ ## Settings in comments
49
+
50
+ Put labels and widgets next to the schema, in table and column comments:
51
+
52
+ ```sql
53
+ comment on table public.clients is
54
+ 'People in a program. @genesis {"label": "Clients", "labelField": "name"}';
55
+ comment on column public.clients.notes is
56
+ 'Private to the coach. @genesis {"label": "Coach notes", "widget": "textarea"}';
57
+ ```
58
+
59
+ The text before `@genesis` stays the description. Tables take `label`, `labelField` and
60
+ `description`; columns take `label`, `description` and `widget`. Anything else is an error that
61
+ names the table or column. These settings are generator input only: the checked-in file is what
62
+ ships.