Skip to content

feat(cli): port ssl-enforcement to native TypeScript#5340

Merged
Coly010 merged 1 commit into
developfrom
cli/migrate-ssl-enforcement
May 22, 2026
Merged

feat(cli): port ssl-enforcement to native TypeScript#5340
Coly010 merged 1 commit into
developfrom
cli/migrate-ssl-enforcement

Conversation

@Coly010
Copy link
Copy Markdown
Contributor

@Coly010 Coly010 commented May 22, 2026

Replaces the Phase-0 Go-binary proxies for supabase ssl-enforcement get and supabase ssl-enforcement update with native Effect handlers. Output, error messages, exit codes, and filesystem side effects are byte-identical to the Go CLI.

What changed

  • ssl-enforcement get / update are now native TS — both handlers call the typed Management API client directly, with withCommandInstrumentation + withJsonErrorHandling middleware, and honour all five Go --output {pretty,json,yaml,toml,env} encoders as well as the TS --output-format {text,json,stream-json}.
  • Hoist refactor: three artifacts move from apps/cli/src/legacy/commands/backups/ to a new apps/cli/src/legacy/shared/ directory because they are now reused across command families:
    • legacyManagementApiRuntimeLayer (was legacyBackupsRuntimeLayer)
    • mapLegacyHttpError (was mapLegacyBackupHttpError) — generic over the network/status error class pair
    • Go-compatible encodeGoJson / encodeYaml / encodeToml / encodeEnvencodeGoJson now takes an optional nullForEmptyArrays option so backups can preserve its PITR-only "backups": null shape while ssl-enforcement omits it
  • Backups list/restore call sites are refactored in the same change to use the hoisted shared modules. No behaviour change for backups.

Reviewer-relevant context

  • The update handler validates the mutually-exclusive --enable-db-ssl-enforcement / --disable-db-ssl-enforcement flags at handler entry — Effect CLI has no cobra-equivalent MarkFlagsMutuallyExclusive. Validation error messages are verbatim cobra strings for parity with the Go binary.
  • Effect.ensuring nesting in both handlers mirrors Go's PersistentPostRun: telemetryState.flush wraps the entire body (so it flushes even on ref-resolution failure), while linkedProjectCache.cache(ref) only wraps the post-resolution sub-effect (it requires a resolved ref).
  • The SSL-enforcement SIDE_EFFECTS.md files were previously stubs with wrong API paths (/v1/projects/{ref}/config/ssl-enforcement) and wrong response shapes ({enforced, override_enabled}). Both are rewritten with the correct path (/v1/projects/{ref}/ssl-enforcement) and response ({currentConfig: {database}, appliedSuccessfully}).
  • encodeEnv was hardened to escape \n / \r / \t (Go %q parity). Latent bug — boolean-only ssl-enforcement schema never triggered it, but fixing it now in the shared encoder prevents future ported commands with string fields from injecting newlines into env output that a downstream eval / source would treat as separate KEY=VALUE assignments.
  • docs/go-cli-porting-status.md flips both ssl-enforcement rows from wrapped to ported.

Closes CLI-1297

Replace the Phase-0 Go-binary proxies for `ssl-enforcement get` and
`ssl-enforcement update` with native Effect handlers. Byte-identical
to the Go CLI: text status lines, all five `--output {pretty,json,
yaml,toml,env}` encoders, error message templates, exit codes, and
linked-project + telemetry side effects.

Hoist three artifacts from the backups command family to a new
`src/legacy/shared/` directory because they are now reused across
families: the Management-API runtime layer composition, the
HTTP-error → tagged-error mapper, and the Go-compatible JSON / YAML
/ TOML / env encoders. Refactor the backups list/restore call sites
in the same change.

Refs CLI-1297
@Coly010 Coly010 requested a review from a team as a code owner May 22, 2026 11:19
@Coly010 Coly010 self-assigned this May 22, 2026
@Coly010 Coly010 merged commit c16564a into develop May 22, 2026
12 checks passed
@Coly010 Coly010 deleted the cli/migrate-ssl-enforcement branch May 22, 2026 12:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants