@supacloud/cli 0.14.5 → 0.15.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.
Files changed (3) hide show
  1. package/README.md +148 -5
  2. package/dist/index.js +1133 -121
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -36,16 +36,102 @@ grants, extensions, and reference-data changes in migrations; use read-only SQL
36
36
  for ordinary inspection; dry-run remote migrations; and reconcile existing
37
37
  remote drift before touching migration history.
38
38
 
39
- `supacloud-cli` defaults to the current workspace's project context. If you do not pass explicit flags, it tries to auto-link from `.env`:
39
+ ## Environment profiles and production safety
40
+
41
+ Use named environment files to keep test and production configuration separate.
42
+ `--env test` reads `.env.supacloud.test` from the current working directory;
43
+ `--env prod` reads `.env.supacloud.prod` and treats the profile as production.
44
+ For example:
45
+
46
+ ```dotenv
47
+ # .env.supacloud.test
48
+ SUPACLOUD_ENV=test
49
+ SUPACLOUD_API_URL=https://management.test.example.com
50
+ SUPACLOUD_API_TOKEN=<test-management-api-token>
51
+ SUPACLOUD_PROJECT_REF=test-ref
52
+ ```
53
+
54
+ ```dotenv
55
+ # .env.supacloud.prod
56
+ SUPACLOUD_ENV=production
57
+ SUPACLOUD_API_URL=https://management.example.com
58
+ SUPACLOUD_API_TOKEN=<production-management-api-token>
59
+ SUPACLOUD_PROJECT_REF=production-ref
60
+ ```
61
+
62
+ Run commands with the selected profile:
63
+
64
+ ```bash
65
+ supacloud-cli --env test status
66
+ supacloud-cli project get --env test
67
+ supacloud-cli status --env-file ./config/supacloud.staging.env
68
+ ```
69
+
70
+ Global flags may appear before or after the command. Both `--key value` and
71
+ `--key=value` syntax are accepted. `--env` and `--env-file` are mutually
72
+ exclusive. An explicit `--env-file` must declare `SUPACLOUD_ENV`.
73
+
74
+ Environment files contain credentials. The repository root `.gitignore`
75
+ already ignores `.env` and `.env.*`; do not force-add or commit these files.
76
+ Restrict locally created files to the current user:
77
+
78
+ ```bash
79
+ chmod 600 .env.supacloud.test .env.supacloud.prod
80
+ ```
81
+
82
+ CI can provide one complete context through process environment variables
83
+ instead of writing a file:
84
+
85
+ ```bash
86
+ SUPACLOUD_ENV=test \
87
+ SUPACLOUD_API_URL=https://management.test.example.com \
88
+ SUPACLOUD_API_TOKEN="$CI_SUPACLOUD_API_TOKEN" \
89
+ SUPACLOUD_PROJECT_REF=test-ref \
90
+ supacloud-cli status
91
+ ```
92
+
93
+ Project context is resolved from one atomic source: a named profile selected by
94
+ `--env`, an explicit `--env-file`, a complete process environment, or the
95
+ legacy `.env` fallback. Core URL, token, and project-ref values are not filled
96
+ by mixing sources. If `SUPACLOUD_ENV` is set without a complete process context,
97
+ it strictly selects `.env.supacloud.<value>`. For backward compatibility, when
98
+ no selector and no core process variables are present, `supacloud-cli` still
99
+ tries to auto-link from `.env` using:
40
100
 
41
101
  - `SUPABASE_URL` or `SUPACLOUD_API_URL`
42
102
  - `SUPABASE_SERVICE_ROLE_KEY` or `SUPACLOUD_API_TOKEN`
43
103
  - `SUPACLOUD_PROJECT_REF` when the project ref cannot be inferred from a managed `<ref>.api.*` hostname
44
104
 
45
- Both `--key value` and `--key=value` flag syntax are accepted. `--ref` can
46
- override the auto-linked project for an individual command. `status` checks
47
- configuration, Management API connectivity, and authentication; it exits
48
- non-zero when any required check fails.
105
+ The legacy `.env` fallback is unclassified and therefore does not enable the
106
+ production confirmation gate. Production automation must select a `prod` or
107
+ `production` profile, or set `SUPACLOUD_ENV=production` together with a complete
108
+ process context. Use `SUPACLOUD_READ_ONLY=true` when legacy workflows must be
109
+ restricted to inspection only.
110
+
111
+ `SUPACLOUD_READ_ONLY=true` is a safety override that blocks remote writes.
112
+ Production writes require an explicit confirmation equal to the selected
113
+ profile's project ref:
114
+
115
+ ```bash
116
+ supacloud-cli database push_migrations --env prod \
117
+ --ref production-ref --dir supabase/migrations \
118
+ --confirm-production production-ref
119
+ ```
120
+
121
+ Dry runs remain read operations. Production `diagnostics repair` is always
122
+ forbidden, and unclassified actions fail closed in production or read-only
123
+ contexts.
124
+
125
+ For supported command groups, `--ref` overrides the profile's default project
126
+ for one command. A production profile cannot target a different project with
127
+ `--ref`; the requested ref and `--confirm-production` must both exactly match
128
+ the profile's project ref.
129
+
130
+ `status` checks configuration, Management API connectivity, and authentication;
131
+ it exits non-zero when any required check fails. Its output includes
132
+ `environment`, `source` (`kind` and `path`), `apiUrl`, `projectRef`, `readOnly`,
133
+ `production`, and `hasApiToken`. It never prints the API token or service-role
134
+ key.
49
135
 
50
136
  Examples:
51
137
 
@@ -71,6 +157,9 @@ supacloud-cli branch promote --branch_ref preview123 --plan_checksum <sha256>
71
157
  supacloud-cli edge_functions deploy --ref abc123 --slug hello --path ./supabase/functions/hello
72
158
  supacloud-cli edge_functions deploy_bundle --ref abc123 --slug hello --files '{"index.ts":"export default { fetch: () => new Response(\"ok\") }"}'
73
159
  supacloud-cli edge_functions source --ref abc123 --slug hello --output ./hello.ts
160
+ supacloud-cli edge_functions activate --ref abc123 --slug hello --version 3
161
+ supacloud-cli scheduled_functions list --ref abc123
162
+ supacloud-cli secrets upsert --ref abc123 --from-env API_KEY,WEBHOOK_SECRET
74
163
  ```
75
164
 
76
165
  `edge_functions deploy --path` bundles local TypeScript and dependencies with
@@ -82,6 +171,44 @@ Use `source --output <file>` for large Functions so terminal or automation outpu
82
171
  limits cannot truncate the original TS/JS source code. The destination must not
83
172
  already exist.
84
173
 
174
+ `edge_functions activate` restores an existing immutable Function version and
175
+ returns a machine-readable receipt containing the activated version and JWT
176
+ policy. HTTP and malformed-response failures exit non-zero without echoing the
177
+ server response body.
178
+
179
+ Mutation receipts use schema `supacloud.cli.release-control.v1`. An
180
+ `OUTCOME_UNKNOWN` error means the server may have committed the mutation before
181
+ the response was lost or failed validation; read back current state before any
182
+ retry.
183
+
184
+ Scheduled Function lifecycle operations are also project-scoped:
185
+
186
+ ```bash
187
+ supacloud-cli scheduled_functions create --ref abc123 --name nightly \
188
+ --slug cleanup --cron "0 2 * * *" --method POST
189
+ supacloud-cli scheduled_functions update --ref abc123 --schedule_id <id> \
190
+ --cron "0 3 * * *"
191
+ supacloud-cli scheduled_functions delete --ref abc123 --schedule_id <id>
192
+ ```
193
+
194
+ Schedule IDs are canonical UUIDv4 values returned by create/list. Cron values
195
+ use bounded numeric five-field syntax with wildcards, lists, ranges, and steps;
196
+ out-of-range endpoints and steps are rejected before HTTP dispatch.
197
+
198
+ Use `--body_file ./payload.json` for a JSON-object request body. Header values
199
+ must come from environment variables: pass a JSON name mapping such as
200
+ `--header_env '{"x-schedule-token":"SCHEDULE_TOKEN"}'`. Platform-owned
201
+ `authorization`, `apikey`, and `x-project-ref` headers cannot be overridden. Receipts never
202
+ include header values or body content; list and mutation receipts report only
203
+ whether the body is empty and the configured header names.
204
+
205
+ For secret writes, `--from-env` accepts a comma-separated list of environment
206
+ variable names. The CLI reads each non-empty value from its own process
207
+ environment, so command arguments contain names only and values are never
208
+ printed. Names must be unique shell-style identifiers (`[A-Za-z_][A-Za-z0-9_]*`,
209
+ up to 256 characters). Missing or empty values fail before any HTTP request.
210
+ Do not combine `--from-env` with the compatibility `--secrets` input.
211
+
85
212
  Branch promotion is migration-first. `branch promotion_plan` prints pending
86
213
  versions, names, statement counts, and checksums without echoing SQL into terminal
87
214
  logs; review the migration files or the Web Console SQL view before approval.
@@ -174,6 +301,22 @@ USING hnsw (embedding vector_cosine_ops);
174
301
 
175
302
  Transaction boundary: SupaCloud supports transaction blocks inside one SQL request and transactional migrations. It does not expose long-lived HTTP transaction sessions; use a direct Postgres DSN for application-side long transactions.
176
303
 
304
+ Auth configuration commands accept a JSON object from the CLI:
305
+
306
+ ```bash
307
+ supacloud-cli auth update_settings --ref abc123 \
308
+ --config '{"disable_signup":true,"enable_signup":false}'
309
+ supacloud-cli auth update_config --ref abc123 \
310
+ --config '{"third_party_auth":{"enabled":true}}'
311
+ ```
312
+
313
+ Failed Auth mutations exit non-zero and print a JSON object containing the HTTP
314
+ status plus an allowlisted subset of runtime-apply state. If Management API
315
+ returns `503` with `persisted: true`, the desired configuration was saved but
316
+ runtime propagation was incomplete; automation must read the affected settings
317
+ back exactly before deciding whether it is safe to continue. Free-form server
318
+ messages and request configuration are not echoed.
319
+
177
320
  Project commands owned by this CLI:
178
321
 
179
322
  - `project get`