@motherbase/cli 0.2.4 → 0.2.6

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 (63) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +131 -18
  3. package/bin/motherbase.js +10 -10
  4. package/package.json +35 -26
  5. package/src/api.js +233 -229
  6. package/src/commands/_util.js +106 -50
  7. package/src/commands/backups.js +16 -0
  8. package/src/commands/branches.js +113 -0
  9. package/src/commands/completion.js +90 -0
  10. package/src/commands/config.js +47 -47
  11. package/src/commands/cron.js +65 -65
  12. package/src/commands/db-catalog.js +326 -0
  13. package/src/commands/db.js +103 -92
  14. package/src/commands/domains.js +124 -0
  15. package/src/commands/functions.js +63 -33
  16. package/src/commands/gen.js +63 -17
  17. package/src/commands/import.js +55 -35
  18. package/src/commands/index.js +85 -64
  19. package/src/commands/inspect.js +178 -41
  20. package/src/commands/link.js +35 -35
  21. package/src/commands/local.js +23 -2
  22. package/src/commands/login.js +39 -39
  23. package/src/commands/logout.js +16 -16
  24. package/src/commands/mcp.js +27 -9
  25. package/src/commands/migrate.js +207 -0
  26. package/src/commands/migration.js +108 -33
  27. package/src/commands/network.js +83 -0
  28. package/src/commands/orgs.js +40 -0
  29. package/src/commands/postgres-config.js +113 -0
  30. package/src/commands/projects.js +130 -125
  31. package/src/commands/queues.js +133 -0
  32. package/src/commands/realtime.js +35 -35
  33. package/src/commands/rls.js +176 -176
  34. package/src/commands/secrets.js +66 -45
  35. package/src/commands/signing.js +130 -0
  36. package/src/commands/snippets.js +44 -0
  37. package/src/commands/status.js +42 -42
  38. package/src/commands/storage.js +261 -113
  39. package/src/commands/test.js +9 -0
  40. package/src/commands/unlink.js +15 -15
  41. package/src/commands/users.js +142 -113
  42. package/src/commands/vault.js +82 -0
  43. package/src/commands/webhooks.js +62 -62
  44. package/src/commands/whoami.js +20 -20
  45. package/src/commands/wrappers.js +150 -0
  46. package/src/config.js +98 -98
  47. package/src/context.js +106 -102
  48. package/src/docs.js +68 -0
  49. package/src/edge-templates.js +194 -0
  50. package/src/format.js +92 -0
  51. package/src/inspect/csv.js +22 -0
  52. package/src/inspect/queries.js +562 -0
  53. package/src/main.js +224 -160
  54. package/src/mcp/platform-tools.js +233 -0
  55. package/src/mcp/protocol.js +4 -1
  56. package/src/mcp/storage-tools.js +93 -0
  57. package/src/mcp/tools.js +318 -6
  58. package/src/migration/commands.js +375 -0
  59. package/src/migration/files.js +245 -0
  60. package/src/prompt.js +91 -91
  61. package/src/storage/remote.js +62 -0
  62. package/src/ui.js +111 -111
  63. package/src/commands/migrations.js +0 -85
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Motherbase contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  A Supabase-CLI-like operator CLI for **Motherbase**. It drives both the
4
4
  **Platform Console** (account + multi-project lifecycle) and a **linked project's
5
- admin API** through the Console proxy — or a single project API directly.
5
+ admin API** through the Console proxy, or a single project API directly.
6
6
 
7
7
  Zero runtime dependencies. Node ≥ 18 (uses built-in `fetch`, `readline`, `fs`,
8
8
  `child_process` only).
@@ -18,17 +18,17 @@ motherbase functions deploy --name hello --route hello --file ./hello.js
18
18
 
19
19
  ## Connection model
20
20
 
21
- 1. **Console / account** — `motherbase login [--url <consoleUrl>]` performs a real
21
+ 1. **Console / account**, `motherbase login [--url <consoleUrl>]` performs a real
22
22
  Console login (`POST /api/platform/login`) and stores the session token.
23
- 2. **Linked project** — `motherbase link [project]` records which project this
23
+ 2. **Linked project**, `motherbase link [project]` records which project this
24
24
  directory targets. All resource commands then route through the Console proxy
25
25
  (`/api/projects/:id/admin/*`).
26
- 3. **Direct mode (CI / single stack)** — set `MOTHERBASE_URL` +
26
+ 3. **Direct mode (CI / single stack)**. Set `MOTHERBASE_URL` +
27
27
  `MOTHERBASE_ADMIN_TOKEN` to talk straight to one project's `/api/admin/*`.
28
28
 
29
29
  ### Configuration files
30
30
 
31
- **Global credentials** — `~/.motherbase/config.json` (contains tokens, written `0o600`):
31
+ **Global credentials**: `~/.motherbase/config.json` (contains tokens, written `0o600`):
32
32
 
33
33
  ```json
34
34
  {
@@ -39,7 +39,7 @@ motherbase functions deploy --name hello --route hello --file ./hello.js
39
39
  }
40
40
  ```
41
41
 
42
- **Project link** — `./.motherbase/config.json` (versionable, non-secret):
42
+ **Project link**: `./.motherbase/config.json` (versionable, non-secret):
43
43
 
44
44
  ```json
45
45
  { "consoleUrl": "https://console.example.com", "projectId": "my-app", "projectName": "my-app" }
@@ -54,7 +54,7 @@ motherbase functions deploy --name hello --route hello --file ./hello.js
54
54
  | console URL | `--url/-u` | `MOTHERBASE_CONSOLE_URL` | link / global `current` |
55
55
  | token | `--token` | `MOTHERBASE_TOKEN` | global console entry |
56
56
  | project | `--project/-p` | `MOTHERBASE_PROJECT` | link |
57
- | direct API | — | `MOTHERBASE_URL` + `MOTHERBASE_ADMIN_TOKEN` | — |
57
+ | direct API | (| `MOTHERBASE_URL` + `MOTHERBASE_ADMIN_TOKEN` |) |
58
58
 
59
59
  ### Auth headers
60
60
 
@@ -65,29 +65,80 @@ request. Console requests hit `/api/platform/*`; admin requests hit the proxy at
65
65
 
66
66
  ## Commands
67
67
 
68
- Global flags: `--json`, `--yes/-y`, `--project/-p <id>`, `--url/-u <consoleUrl>`,
69
- `--token <t>`, `-h/--help`, `-v/--version`.
68
+ Global flags: `-o/--output pretty|json|yaml|env` (`--json` is `-o json`),
69
+ `--yes/-y`, `--project/-p/--project-ref <id>`, `--url/-u <consoleUrl>`,
70
+ `--token <t>`, `--workdir <dir>`, `--debug` (one stderr line per HTTP request),
71
+ `-h/--help`, `-v/--version`.
72
+
73
+ Commands follow the Supabase CLI's names. Where Motherbase already had its own
74
+ name, both work: `projects api-keys` / `keys list`, `backups list|restore` /
75
+ `db backups|restore`, `functions download` / `functions pull`, `db lint` /
76
+ `rls lint`, `gen types --lang <l>` / `gen types <l>`.
70
77
 
71
78
  - **Connection**: `login`, `logout`, `whoami`, `link`, `unlink`, `status`
72
- - **Projects (Console)**: `projects list|create|start|stop|restart|update|rebuild|delete|logs|info|limits`
79
+ - **Orgs & projects (Console)**: `orgs list|create`, `projects list|create|start|stop|restart|update|rebuild|delete|logs|info|limits|api-keys`
80
+ - **Branches (Console)**: `branches create <name> [--with-data] [--git-branch <ref>]`, `branches list|get|update|delete|pause|unpause|reset|merge|rebase|switch <name>`
81
+ - **Domains (Console)**: `domains create --custom-hostname <host>`, `domains get|reverify|activate|delete`, `vanity-subdomains get|check-availability|activate --desired-subdomain <name>|delete`
82
+ - **Database access**: `network-restrictions get|update --db-allow-cidr <cidr> ...`, `ssl-enforcement get|update --enable-db-ssl-enforcement|--disable-db-ssl-enforcement`
73
83
  - **Local self-host** (docker compose): `init`, `start`, `stop`, `deploy`, `logs`
74
- - **Database**: `db tables|sql|dump|restore|backups`
75
- - **Migrations**: `migrations list|diff|get|create|apply|rollback`, `migration new`
84
+ - **Database**: `db push|pull|diff|reset|dump|seed`, `db tables|sql|backup|restore|backups|lint`, `backups list|restore`, `test db`
85
+ - **Database objects**: `db indexes list|create|drop`, `db types list|create|add-value|rename-value|drop`, `db roles list|create|alter|drop`, `db column-privileges list|grant|revoke`, `db publications list|create|alter|drop`
86
+ - **Postgres config**: `postgres-config get [--all]`, `postgres-config update --config k=v [--scope database|role|system] [--replace-existing-overrides]`, `postgres-config delete --config k1,k2`
87
+ - **Migrations**: `migration new|list|up|down|repair|squash|fetch|diff|get|create|apply|rollback` (`migrations` is an alias)
76
88
  - **Import**: `import --from-supabase <conn> [--preview] [--no-data] [--no-auth]`
77
89
  - **RLS**: `rls list|enable|disable`, `rls policy create|delete`
78
- - **Users**: `users list|get|create|update|delete|reset-password|promote|demote|revoke-sessions`
79
- - **Storage**: `storage buckets list|create|delete`, `storage ls|cp|rm`
80
- - **Functions**: `functions list|get|new|deploy|delete|invoke|logs`
81
- - **Secrets**: `secrets list|set|unset`
90
+ - **Users**: `users list|get|create|update|delete|reset-password|promote|demote|revoke-sessions|audit`
91
+ - **Storage**: `storage buckets list|create|delete`, `storage ls|cp|mv|rm [-r]` on `ss:///bucket/key` paths
92
+ - **Functions**: `functions list|get|new|deploy|pull|download|serve|delete|invoke|logs`
93
+ - **Secrets**: `secrets list|unset`, `secrets set NAME=VALUE ... [--env-file .env]`
82
94
  - **Realtime**: `realtime config|channels`
83
95
  - **Webhooks**: `webhooks list|create|delete|test`
84
96
  - **Cron**: `cron list|create|delete|toggle`
97
+ - **Queues**: `queues list|enable|expose|create|drop|send|read|archive|purge`
98
+ - **Vault**: `vault list|enable|create|update|reveal|delete`
99
+ - **Wrappers**: `wrappers list|enable|create-server|drop-server|credentials|import|create-table|drop-table`
85
100
  - **Config**: `config list|get|set`
86
- - **Inspect**: `inspect logs|stats|performance|requests|advisor|shield`
87
- - **Codegen**: `gen types typescript [--schema public] [--local] [--output <file>] [--check]`
101
+ - **Inspect**: `inspect db <query>`, `inspect report`, `inspect logs|stats|performance|index-advisor|requests|advisor|shield`
102
+ - **Codegen**: `gen types [--lang typescript|zod] [--schema public] [--local] [--output <file>] [--check]`
103
+ - **AI agents**: `mcp [--write]`
104
+ - **Keys**: `gen signing-key [--algorithm ES256|RS256|EdDSA] [--append]`, `gen bearer-jwt --sub <user> [--role] [--valid-for 1h]`, `gen keys [-o env]`
105
+ - **Shell**: `completion bash|zsh|fish` (e.g. `source <(motherbase completion bash)`)
88
106
 
89
107
  Run `motherbase <group> -h` for per-group usage.
90
108
 
109
+ ## Migrations and seeds
110
+
111
+ Local files, laid out like a Supabase project's `supabase/` directory:
112
+
113
+ ```
114
+ motherbase/
115
+ migrations/<version>_<name>.sql `migration new <name>` stamps the version (UTC)
116
+ seed.sql or db.seed.sql_paths in motherbase/config.json
117
+ tests/*.sql pgTAP, for `motherbase test db`
118
+ ```
119
+
120
+ A migration file may end with a `-- @down` line followed by the SQL that undoes
121
+ it; `migration down` needs one. The linked project keeps the history, keyed on
122
+ `version`, and the Studio Migrations page shows the same rows (origin `cli`,
123
+ `studio` or `git`).
124
+
125
+ ```bash
126
+ motherbase migration list # LOCAL | REMOTE side by side
127
+ motherbase db push --dry-run # then without, add --include-seed for the seeds
128
+ motherbase db pull # remote changes -> a new file, recorded as applied
129
+ motherbase db diff -f add_index # the same diff, written as a new migration
130
+ motherbase migration repair 20260101120000 --status reverted
131
+ motherbase db reset --confirm # backup, empty app schemas, replay migrations + seed
132
+ motherbase db dump -f schema.sql --schema-only
133
+ ```
134
+
135
+ Each pushed file runs in its own transaction; a push stops at the first file
136
+ that fails, and nothing of that file is recorded. `db diff` replays the local
137
+ migrations into a throwaway database on the same server and compares tables,
138
+ columns and indexes: review what it writes. With no local migration yet, `db
139
+ pull` writes the remote schema itself, from `pg_dump`. `db dump` used to take a
140
+ server-side backup; that is `db backup` now.
141
+
91
142
  ## Type generation
92
143
 
93
144
  Generate TypeScript definitions for the live schema, in the shape supabase-js
@@ -111,6 +162,68 @@ when the committed file differs from a fresh generation:
111
162
  motherbase gen types typescript --check --output database.types.ts
112
163
  ```
113
164
 
165
+ ## Storage paths
166
+
167
+ Objects are addressed as the Supabase CLI does, `ss:///<bucket>/<key>`, and
168
+ `-r` applies a command to everything under a prefix:
169
+
170
+ ```bash
171
+ motherbase storage ls # buckets
172
+ motherbase storage ls ss:///media/img # one level; -r for every key
173
+ motherbase storage cp ./logo.png ss:///media/img/ # upload (overwrites)
174
+ motherbase storage cp -r ./site ss:///web/v2 # upload a directory tree
175
+ motherbase storage cp -r ss:///web/v2 ./site-backup # download a prefix
176
+ motherbase storage mv -r ss:///web/v2 ss:///web/live # move within a bucket
177
+ motherbase storage rm -r ss:///web/old
178
+ ```
179
+
180
+ Bulk commands send one request per object and stop at the first failure,
181
+ saying how many had already gone through. `mv` and in-bucket `cp` work within
182
+ one bucket. The older forms still work: `cp ./a.png bucket:` uploads with a
183
+ generated key, `cp <fileId> ./a.png` downloads and `rm <fileId>` deletes by id.
184
+
185
+ ## Database inspection
186
+
187
+ `inspect db` runs the Supabase CLI's diagnostic queries against the linked
188
+ project, on its read-only SQL endpoint:
189
+
190
+ ```bash
191
+ motherbase inspect db outliers # slowest queries by total time
192
+ motherbase inspect db table-stats -o json
193
+ motherbase inspect report --output-dir reports # one CSV per query in reports/<YYYY-MM-DD>/
194
+ ```
195
+
196
+ The queries are `bloat`, `blocking`, `calls`, `db-stats`, `index-stats`,
197
+ `locks`, `long-running-queries`, `outliers`, `replication-slots`, `role-stats`,
198
+ `table-stats`, `traffic-profile` and `vacuum-stats`. The names Supabase has
199
+ deprecated (`cache-hit`, `index-usage`, `table-sizes`, `unused-indexes`, …)
200
+ still work and run the query that replaced them. `calls` and `outliers` read
201
+ `pg_stat_statements`: it is preloaded by the Motherbase Postgres image but has
202
+ to be created once per database (Studio > Database > Extensions, or
203
+ `motherbase db sql -e "create extension pg_stat_statements"`); `inspect report`
204
+ skips those two files until it is.
205
+
206
+ ## MCP server
207
+
208
+ `motherbase mcp` serves this project to an AI agent over stdio:
209
+
210
+ ```json
211
+ { "mcpServers": { "motherbase": { "command": "npx", "args": ["@motherbase/cli", "mcp"] } } }
212
+ ```
213
+
214
+ It exposes what the session can reach. With a linked project (or direct mode):
215
+ `list_tables`, `describe_table`, `list_policies`, `simulate_rls`,
216
+ `get_advisors`, `get_logs`, `generate_types`, `execute_sql` (read-only),
217
+ `get_project_url`, `get_publishable_keys`, `list_extensions`,
218
+ `list_migrations`, `list_edge_functions`, `get_edge_function`,
219
+ `list_storage_buckets` and `get_storage_config`. With a console login:
220
+ `list_organizations`, `get_organization`, `list_projects` and `get_project`.
221
+
222
+ Everything that changes something needs `--write`: `apply_migration`,
223
+ `execute_sql_write`, `deploy_edge_function`, `create_project`,
224
+ `pause_project` and `restore_project`. The names and arguments follow
225
+ Supabase's MCP server.
226
+
114
227
  ## Supabase migration
115
228
 
116
229
  Preview a Supabase import without writing to Motherbase:
package/bin/motherbase.js CHANGED
@@ -1,11 +1,11 @@
1
1
  #!/usr/bin/env node
2
- 'use strict';
3
-
4
- const { main } = require('../src/main');
5
-
6
- main(process.argv.slice(2))
7
- .then(code => { process.exitCode = code || 0; })
8
- .catch(err => {
9
- process.stderr.write((err && err.message ? err.message : String(err)) + '\n');
10
- process.exitCode = 1;
11
- });
2
+ 'use strict';
3
+
4
+ const { main } = require('../src/main');
5
+
6
+ main(process.argv.slice(2))
7
+ .then(code => { process.exitCode = code || 0; })
8
+ .catch(err => {
9
+ process.stderr.write((err && err.message ? err.message : String(err)) + '\n');
10
+ process.exitCode = 1;
11
+ });
package/package.json CHANGED
@@ -1,26 +1,35 @@
1
- {
2
- "name": "@motherbase/cli",
3
- "version": "0.2.4",
4
- "description": "Motherbase operator CLI — drives the Platform Console and linked projects.",
5
- "type": "commonjs",
6
- "bin": {
7
- "motherbase": "./bin/motherbase.js"
8
- },
9
- "engines": {
10
- "node": ">=18"
11
- },
12
- "scripts": {
13
- "test": "node --test",
14
- "lint": "eslint ."
15
- },
16
- "files": [
17
- "bin",
18
- "src",
19
- "README.md"
20
- ],
21
- "publishConfig": {
22
- "access": "public"
23
- },
24
- "license": "MIT",
25
- "dependencies": {}
26
- }
1
+ {
2
+ "name": "@motherbase/cli",
3
+ "version": "0.2.6",
4
+ "description": "Motherbase operator CLI: drives the Platform Console and linked projects.",
5
+ "type": "commonjs",
6
+ "bin": {
7
+ "motherbase": "./bin/motherbase.js"
8
+ },
9
+ "engines": {
10
+ "node": ">=18"
11
+ },
12
+ "scripts": {
13
+ "test": "node --test",
14
+ "docs:cli": "node scripts/generate-cli-docs.js",
15
+ "lint": "eslint ."
16
+ },
17
+ "files": [
18
+ "bin",
19
+ "src",
20
+ "README.md"
21
+ ],
22
+ "publishConfig": {
23
+ "access": "public"
24
+ },
25
+ "license": "MIT",
26
+ "repository": {
27
+ "type": "git",
28
+ "url": "git+https://github.com/JulienGuinot/Boilerplate-backend.git",
29
+ "directory": "packages/cli"
30
+ },
31
+ "homepage": "https://github.com/JulienGuinot/Boilerplate-backend#readme",
32
+ "bugs": {
33
+ "url": "https://github.com/JulienGuinot/Boilerplate-backend/issues"
34
+ }
35
+ }