@motherbase/cli
v0.2.4
Published
Motherbase operator CLI — drives the Platform Console and linked projects.
Readme
Motherbase CLI
A Supabase-CLI-like operator CLI for Motherbase. It drives both the Platform Console (account + multi-project lifecycle) and a linked project's admin API through the Console proxy — or a single project API directly.
Zero runtime dependencies. Node ≥ 18 (uses built-in fetch, readline, fs,
child_process only).
node bin/motherbase.js --help # auto-generated help
npm link # or: npm i -g @motherbase/cli
motherbase login --url https://console.example.com
motherbase link # pick a project → writes ./.motherbase/config.json
motherbase db tables
motherbase functions deploy --name hello --route hello --file ./hello.jsConnection model
- Console / account —
motherbase login [--url <consoleUrl>]performs a real Console login (POST /api/platform/login) and stores the session token. - Linked project —
motherbase link [project]records which project this directory targets. All resource commands then route through the Console proxy (/api/projects/:id/admin/*). - Direct mode (CI / single stack) — set
MOTHERBASE_URL+MOTHERBASE_ADMIN_TOKENto talk straight to one project's/api/admin/*.
Configuration files
Global credentials — ~/.motherbase/config.json (contains tokens, written 0o600):
{
"consoles": {
"https://console.example.com": { "token": "…", "email": "[email protected]" }
},
"current": "https://console.example.com"
}Project link — ./.motherbase/config.json (versionable, non-secret):
{ "consoleUrl": "https://console.example.com", "projectId": "my-app", "projectName": "my-app" }Resolution precedence
flags > env > config, per value:
| Value | Flag | Env | Config |
| ----------- | ----------------- | ------------------------- | ------ |
| console URL | --url/-u | MOTHERBASE_CONSOLE_URL | link / global current |
| token | --token | MOTHERBASE_TOKEN | global console entry |
| project | --project/-p | MOTHERBASE_PROJECT | link |
| direct API | — | MOTHERBASE_URL + MOTHERBASE_ADMIN_TOKEN | — |
Auth headers
The console session token is sent as Authorization: Bearer <token> on every
request. Console requests hit /api/platform/*; admin requests hit the proxy at
/api/projects/:id/admin/* (which validates the session, then injects its own
X-Platform-Token to the project). In direct mode the admin token is the Bearer.
Commands
Global flags: --json, --yes/-y, --project/-p <id>, --url/-u <consoleUrl>,
--token <t>, -h/--help, -v/--version.
- Connection:
login,logout,whoami,link,unlink,status - Projects (Console):
projects list|create|start|stop|restart|update|rebuild|delete|logs|info|limits - Local self-host (docker compose):
init,start,stop,deploy,logs - Database:
db tables|sql|dump|restore|backups - Migrations:
migrations list|diff|get|create|apply|rollback,migration new - Import:
import --from-supabase <conn> [--preview] [--no-data] [--no-auth] - RLS:
rls list|enable|disable,rls policy create|delete - Users:
users list|get|create|update|delete|reset-password|promote|demote|revoke-sessions - Storage:
storage buckets list|create|delete,storage ls|cp|rm - Functions:
functions list|get|new|deploy|delete|invoke|logs - Secrets:
secrets list|set|unset - Realtime:
realtime config|channels - Webhooks:
webhooks list|create|delete|test - Cron:
cron list|create|delete|toggle - Config:
config list|get|set - Inspect:
inspect logs|stats|performance|requests|advisor|shield - Codegen:
gen types typescript [--schema public] [--local] [--output <file>] [--check]
Run motherbase <group> -h for per-group usage.
Type generation
Generate TypeScript definitions for the live schema, in the shape supabase-js
emits, so createClient<Database>(url, key) types every row, rejects unknown
columns and types .rpc() calls:
motherbase gen types typescript > database.types.ts
motherbase gen types typescript --schema shop --output src/shop.types.tsWith no --output the file goes to stdout and nothing else does, so the
redirect above produces a compiling file. --local skips the Console proxy and
talks to a project API on this machine (MOTHERBASE_URL, default
http://localhost:5001, with MOTHERBASE_ADMIN_TOKEN).
Gate CI on schema drift with --check, which never writes and exits non-zero
when the committed file differs from a fresh generation:
motherbase gen types typescript --check --output database.types.tsSupabase migration
Preview a Supabase import without writing to Motherbase:
motherbase import --from-supabase "$SUPABASE_DB_URL" --preview --jsonRun the import:
motherbase import --from-supabase "$SUPABASE_DB_URL" --yesThe importer moves the portable parts of a Supabase project: public schema, table data, RLS policies, and email/password users from auth.users. Storage objects are not copied. Use --no-data or --no-auth for partial imports.
Tests
npm test # node --test, mocked fetch, no network/DB