From 2bbcfc0a32b9112561823f7bbda875c2be9e4f9a Mon Sep 17 00:00:00 2001 From: Lindsay Holmwood Date: Fri, 27 Nov 2026 17:20:41 +1100 Subject: [PATCH 1/2] fix(cli): say the flag wins in eql install and eql repair --database-url help Both commands showed the shared --database-url help, which says a literal databaseUrl in stash.config.ts wins over the flag. Neither loads the config when the flag is given, so the flag wins. Give each its own help text, and add a test that holds every command's --database-url help to the value that command lets win. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01CtEQzxj55RUn35dkbhdwQk --- .changeset/cli-database-url-help.md | 12 ++++ .../cli/__tests__/database-url-help.test.ts | 64 +++++++++++++++++++ .../packages/cli/src/cli/registry.ts | 23 +++++-- skills/stash-cli/SKILL.md | 4 +- 4 files changed, 97 insertions(+), 6 deletions(-) create mode 100644 .changeset/cli-database-url-help.md create mode 100644 languages/typescript/packages/cli/src/cli/__tests__/database-url-help.test.ts diff --git a/.changeset/cli-database-url-help.md b/.changeset/cli-database-url-help.md new file mode 100644 index 0000000000..d6326fecd1 --- /dev/null +++ b/.changeset/cli-database-url-help.md @@ -0,0 +1,12 @@ +--- +"stash": patch +--- + +`stash eql install --help` and `stash eql repair --help` now say that +`--database-url` wins over a literal `databaseUrl` in `stash.config.ts`. That is +what both commands already do: `eql install --database-url` never loads the +config, and `eql repair` never reads it. + +Before, both showed the help text the other database commands share. That text +says the config literal wins. The commands still behave as before. Only the +help changed. diff --git a/languages/typescript/packages/cli/src/cli/__tests__/database-url-help.test.ts b/languages/typescript/packages/cli/src/cli/__tests__/database-url-help.test.ts new file mode 100644 index 0000000000..7350b8aab7 --- /dev/null +++ b/languages/typescript/packages/cli/src/cli/__tests__/database-url-help.test.ts @@ -0,0 +1,64 @@ +/** + * Every command that takes `--database-url` must say, in its help, which value + * wins when stash.config.ts sets a literal `databaseUrl`: the flag or the + * config (#1980). The registry is plain data, so nothing else ties the help to + * what each command does. + * + * `flag` commands never load the config when the flag is given. `config` + * commands load stash.config.ts through `loadStashConfig`, and a literal + * `databaseUrl` there replaces the resolver that reads the flag. + */ + +import { describe, expect, it } from 'vitest' +import { registry } from '@/cli/registry.js' + +type Winner = 'flag' | 'config' + +const WINNER: Record = { + // main.ts passes `scaffoldConfig: 'skip'` with the flag, and + // `resolveInstallContext` then never looks for a config. + 'eql install': 'flag', + // `resolveRepairDatabaseUrl` reads only the flag and DATABASE_URL. + 'eql repair': 'flag', + // `resolveDiagnosticDatabaseUrl` with `flagWins: true`. + 'eql verify': 'flag', + // `resolveDiagnosticDatabaseUrl` with `flagWins: false`. + 'eql preflight': 'config', + 'eql upgrade': 'config', + 'eql status': 'config', + 'eql validate': 'config', + 'db test-connection': 'config', + 'schema build': 'config', +} + +const CONFIG_WINS = + 'a hand-set literal databaseUrl in the config bypasses the resolver and wins over all of these' + +const withFlag = registry + .flatMap((group) => group.commands) + .flatMap((command) => { + const flag = command.flags?.find((f) => f.name === '--database-url') + return flag ? [{ name: command.name, description: flag.description }] : [] + }) + +describe('--database-url help', () => { + it('classifies every command that takes the flag', () => { + expect(withFlag.map((c) => c.name).sort()).toEqual( + Object.keys(WINNER).sort(), + ) + }) + + it.each(withFlag)( + '$name states which value wins', + ({ name, description }) => { + if (WINNER[name] === 'config') { + expect(description).toContain(CONFIG_WINS) + } else { + expect(description).not.toContain(CONFIG_WINS) + expect(description).toMatch( + /bypasses config loading entirely|never reads stash\.config\.ts/, + ) + } + }, + ) +}) diff --git a/languages/typescript/packages/cli/src/cli/registry.ts b/languages/typescript/packages/cli/src/cli/registry.ts index 26e45bdfde..b427579477 100644 --- a/languages/typescript/packages/cli/src/cli/registry.ts +++ b/languages/typescript/packages/cli/src/cli/registry.ts @@ -47,8 +47,11 @@ export interface CommandGroup { } /** - * Shared `--database-url` flag — every db/eql/schema command accepts it, so it's - * declared once and referenced, not copy-pasted. + * Shared `--database-url` flag, for the commands that load stash.config.ts + * through `loadStashConfig`, where a literal `databaseUrl` in the config wins + * over the flag. Commands where the flag wins (`eql install`, `eql repair`, + * `eql verify`) declare their own text. `cli/__tests__/database-url-help.test.ts` + * holds each command to the one that matches what it does. */ const DATABASE_URL_FLAG: Flag = { name: '--database-url', @@ -354,7 +357,13 @@ export const registry: CommandGroup[] = [ description: 'Use Supabase-compatible mode (auto-detected from DATABASE_URL).', }, - DATABASE_URL_FLAG, + { + name: '--database-url', + value: '', + description: + "One-shot, like `eql verify`'s: bypasses config loading entirely, so EQL is installed into the database you name, even when stash.config.ts sets a literal databaseUrl, and no stash.config.ts is scaffolded. Never written to disk. With no flag, install uses the databaseUrl of a stash.config.ts if it finds one, else DATABASE_URL env → supabase status → interactive prompt.", + env: 'DATABASE_URL', + }, ], }, { @@ -507,7 +516,13 @@ export const registry: CommandGroup[] = [ "Drizzle's migration ledger, when drizzle.config.ts overrides `migrations.table` / `migrations.schema`. Defaults to `drizzle.__drizzle_migrations`. Only read with --database-url.", }, DRY_RUN_FLAG, - DATABASE_URL_FLAG, + { + name: '--database-url', + value: '', + description: + 'Database to check applied migrations against, for this run only — never written to disk. Repair never reads stash.config.ts, so this flag wins even when the config sets a literal databaseUrl. With no flag, repair uses DATABASE_URL; with neither, it skips the check and warns. It never runs supabase status or prompts.', + env: 'DATABASE_URL', + }, ], }, { diff --git a/skills/stash-cli/SKILL.md b/skills/stash-cli/SKILL.md index 4ea65c39ca..f36a10ec18 100644 --- a/skills/stash-cli/SKILL.md +++ b/skills/stash-cli/SKILL.md @@ -156,7 +156,7 @@ First hit wins: 4. Interactive prompt — skipped under CI / non-TTY 5. Hard fail, naming the sources it tried -`stash.config.ts` is **not** a separate tier: the scaffolded config calls this same resolver, and the `--database-url` flag still wins. The one exception is a hand-edited config assigning a literal `databaseUrl` string — that bypasses the resolver entirely and beats both flag and env. +`stash.config.ts` is **not** a separate tier: the scaffolded config calls this same resolver, and the `--database-url` flag still wins. The one exception is a hand-edited config assigning a literal `databaseUrl` string — that bypasses the resolver entirely and beats both flag and env. `eql install`, `eql repair`, and `eql verify` are the exceptions to that exception: none of them loads the config when you pass `--database-url`, so the flag wins there. The resolved URL is returned in memory only. It is never written to disk or into `process.env`. @@ -484,7 +484,7 @@ stash eql repair --drizzle --out db/migrations \ | `--drizzle` | Required. Repair a Drizzle migration directory. | | `--out ` | Directory to sweep. Default `drizzle`; set it to match your `drizzle.config.ts`. | | `--dry-run` | Report what would be rewritten without writing anything. | -| `--database-url ` | Check which migrations the database has already applied, and leave those alone. Also read from `DATABASE_URL`. | +| `--database-url ` | Check which migrations the database has already applied, and leave those alone. Also read from `DATABASE_URL`. Repair never reads `stash.config.ts`, so the flag wins even when the config sets a literal `databaseUrl`. | | `--migrations-table <[schema.]table>` | Drizzle's migration ledger, when `drizzle.config.ts` overrides `migrations.table` / `migrations.schema`. Defaults to `drizzle.__drizzle_migrations`. Only read alongside `--database-url`. | What it rewrites, what it refuses, and the schema reconciliation afterwards are identical to the `eql migration --drizzle` sweep above — both call the same rewriter and print the same report. It exits non-zero if any statement is left unrepaired. From ccf866f0f9064ac87e9caabfe5cb36034eb2550b Mon Sep 17 00:00:00 2001 From: Lindsay Holmwood Date: Fri, 27 Nov 2026 17:39:55 +1100 Subject: [PATCH 2/2] fix(cli): tighten the --database-url help after review Spread the shared flag so name, value and env stay defined once. Drop the install/verify cross-references, say that DATABASE_URL alone is not a one-shot, and remove verify's duplicated 'Also settable via DATABASE_URL'. The test now requires a positive flag-wins sentence. The skill no longer says a config literal beats DATABASE_URL in eql repair. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01CtEQzxj55RUn35dkbhdwQk --- .changeset/cli-database-url-help.md | 4 ++++ .../cli/__tests__/database-url-help.test.ts | 8 ++++--- .../packages/cli/src/cli/registry.ts | 23 ++++++++----------- skills/stash-cli/SKILL.md | 2 +- 4 files changed, 19 insertions(+), 18 deletions(-) diff --git a/.changeset/cli-database-url-help.md b/.changeset/cli-database-url-help.md index d6326fecd1..b870c94f72 100644 --- a/.changeset/cli-database-url-help.md +++ b/.changeset/cli-database-url-help.md @@ -10,3 +10,7 @@ config, and `eql repair` never reads it. Before, both showed the help text the other database commands share. That text says the config literal wins. The commands still behave as before. Only the help changed. + +`stash eql verify --help` no longer prints "Also settable via DATABASE_URL" +twice. The `eql install` and `eql verify` help now also says that +`DATABASE_URL` on its own does not skip the config the way the flag does. diff --git a/languages/typescript/packages/cli/src/cli/__tests__/database-url-help.test.ts b/languages/typescript/packages/cli/src/cli/__tests__/database-url-help.test.ts index 7350b8aab7..959e286acb 100644 --- a/languages/typescript/packages/cli/src/cli/__tests__/database-url-help.test.ts +++ b/languages/typescript/packages/cli/src/cli/__tests__/database-url-help.test.ts @@ -24,6 +24,7 @@ const WINNER: Record = { 'eql verify': 'flag', // `resolveDiagnosticDatabaseUrl` with `flagWins: false`. 'eql preflight': 'config', + // These five call `loadStashConfig` directly. 'eql upgrade': 'config', 'eql status': 'config', 'eql validate': 'config', @@ -34,6 +35,9 @@ const WINNER: Record = { const CONFIG_WINS = 'a hand-set literal databaseUrl in the config bypasses the resolver and wins over all of these' +const FLAG_WINS = + 'The flag wins even when stash.config.ts sets a literal databaseUrl.' + const withFlag = registry .flatMap((group) => group.commands) .flatMap((command) => { @@ -55,9 +59,7 @@ describe('--database-url help', () => { expect(description).toContain(CONFIG_WINS) } else { expect(description).not.toContain(CONFIG_WINS) - expect(description).toMatch( - /bypasses config loading entirely|never reads stash\.config\.ts/, - ) + expect(description).toContain(FLAG_WINS) } }, ) diff --git a/languages/typescript/packages/cli/src/cli/registry.ts b/languages/typescript/packages/cli/src/cli/registry.ts index b427579477..7e336dd235 100644 --- a/languages/typescript/packages/cli/src/cli/registry.ts +++ b/languages/typescript/packages/cli/src/cli/registry.ts @@ -50,8 +50,9 @@ export interface CommandGroup { * Shared `--database-url` flag, for the commands that load stash.config.ts * through `loadStashConfig`, where a literal `databaseUrl` in the config wins * over the flag. Commands where the flag wins (`eql install`, `eql repair`, - * `eql verify`) declare their own text. `cli/__tests__/database-url-help.test.ts` - * holds each command to the one that matches what it does. + * `eql verify`) spread it and replace only the description. + * `cli/__tests__/database-url-help.test.ts` holds each command to the text that + * matches what it does. */ const DATABASE_URL_FLAG: Flag = { name: '--database-url', @@ -358,11 +359,9 @@ export const registry: CommandGroup[] = [ 'Use Supabase-compatible mode (auto-detected from DATABASE_URL).', }, { - name: '--database-url', - value: '', + ...DATABASE_URL_FLAG, description: - "One-shot, like `eql verify`'s: bypasses config loading entirely, so EQL is installed into the database you name, even when stash.config.ts sets a literal databaseUrl, and no stash.config.ts is scaffolded. Never written to disk. With no flag, install uses the databaseUrl of a stash.config.ts if it finds one, else DATABASE_URL env → supabase status → interactive prompt.", - env: 'DATABASE_URL', + 'One-shot: bypasses config loading entirely, so EQL is installed into the database you name and no stash.config.ts is scaffolded. The flag wins even when stash.config.ts sets a literal databaseUrl. Never written to disk. DATABASE_URL alone is not a one-shot: with no flag, install uses the databaseUrl of a stash.config.ts if it finds one, else DATABASE_URL env → supabase status → interactive prompt.', }, ], }, @@ -405,11 +404,9 @@ export const registry: CommandGroup[] = [ 'Emit the machine-readable verification report instead of the table.', }, { - name: '--database-url', - value: '', + ...DATABASE_URL_FLAG, description: - "One-shot, like `eql install`'s: bypasses config loading entirely, so the database you name is the database that gets judged. Also settable via DATABASE_URL.", - env: 'DATABASE_URL', + 'One-shot: bypasses config loading entirely, so the database you name is the database that gets judged. The flag wins even when stash.config.ts sets a literal databaseUrl. DATABASE_URL alone is not a one-shot: with no flag, verify uses the databaseUrl of a stash.config.ts if it finds one, else the DATABASE_URL chain.', }, ], }, @@ -517,11 +514,9 @@ export const registry: CommandGroup[] = [ }, DRY_RUN_FLAG, { - name: '--database-url', - value: '', + ...DATABASE_URL_FLAG, description: - 'Database to check applied migrations against, for this run only — never written to disk. Repair never reads stash.config.ts, so this flag wins even when the config sets a literal databaseUrl. With no flag, repair uses DATABASE_URL; with neither, it skips the check and warns. It never runs supabase status or prompts.', - env: 'DATABASE_URL', + 'Database to check applied migrations against, for this run only — never written to disk. Repair never reads stash.config.ts. The flag wins even when stash.config.ts sets a literal databaseUrl. With no flag, repair uses DATABASE_URL, and the config cannot override that either. With neither, it skips the check and warns. It never runs supabase status or prompts.', }, ], }, diff --git a/skills/stash-cli/SKILL.md b/skills/stash-cli/SKILL.md index f36a10ec18..bab835ae51 100644 --- a/skills/stash-cli/SKILL.md +++ b/skills/stash-cli/SKILL.md @@ -156,7 +156,7 @@ First hit wins: 4. Interactive prompt — skipped under CI / non-TTY 5. Hard fail, naming the sources it tried -`stash.config.ts` is **not** a separate tier: the scaffolded config calls this same resolver, and the `--database-url` flag still wins. The one exception is a hand-edited config assigning a literal `databaseUrl` string — that bypasses the resolver entirely and beats both flag and env. `eql install`, `eql repair`, and `eql verify` are the exceptions to that exception: none of them loads the config when you pass `--database-url`, so the flag wins there. +`stash.config.ts` is **not** a separate tier: the scaffolded config calls this same resolver, and the `--database-url` flag still wins. The one exception is a hand-edited config assigning a literal `databaseUrl` string — that bypasses the resolver entirely and beats both flag and env. Three commands work differently. `eql install` and `eql verify` skip the config when you pass `--database-url`, so the flag wins there. `eql repair` never reads the config, so the flag wins, and with no flag `DATABASE_URL` wins. The resolved URL is returned in memory only. It is never written to disk or into `process.env`.