page.tsx276 lines · main
| 1 | import { PmTabs } from '../../components/pm-tabs'; |
| 2 | import { DocsShell } from '../../components/shell'; |
| 3 | import { pmDlx, pmExec, pmInstall } from '../../lib/pm'; |
| 4 | |
| 5 | export const metadata = { |
| 6 | title: 'cli', |
| 7 | }; |
| 8 | |
| 9 | const INSTALL = pmInstall('@briven/cli', { dev: true }); |
| 10 | const ONE_SHOT = pmDlx('briven'); |
| 11 | const SETUP = pmExec( |
| 12 | 'briven setup', |
| 13 | 'briven setup --name my-app', |
| 14 | 'briven setup my-app', |
| 15 | 'briven setup --name my-app --template todo-app --region eu-west', |
| 16 | ); |
| 17 | const INIT = pmExec('briven init'); |
| 18 | const CONNECT = pmExec( |
| 19 | 'briven connect', |
| 20 | 'briven connect p_xxx', |
| 21 | 'briven connect --project p_xxx', |
| 22 | 'briven connect status', |
| 23 | 'briven connect logout', |
| 24 | 'briven connect --force', |
| 25 | ); |
| 26 | const LOGIN = pmExec('briven login --project p_xxx --key brk_xxx'); |
| 27 | const WHOAMI = pmExec('briven whoami'); |
| 28 | const LINK = pmExec('briven link --project p_xxx'); |
| 29 | const DEPLOY = pmExec( |
| 30 | 'briven deploy', |
| 31 | 'briven deploy --dry-run', |
| 32 | 'briven deploy --confirm-destructive', |
| 33 | ); |
| 34 | const INVOKE = pmExec( |
| 35 | 'briven invoke poolStats', |
| 36 | 'briven invoke createNote --body \'{"body":"hello"}\'', |
| 37 | 'briven invoke getNotes --raw', |
| 38 | ); |
| 39 | const ENV = pmExec('briven env list', 'briven env put STRIPE_KEY sk_...', 'briven env rm STRIPE_KEY'); |
| 40 | const DB = pmExec('briven db shell'); |
| 41 | const DEV = pmExec('briven dev'); |
| 42 | const LOGS = pmExec('briven logs', 'briven logs --follow'); |
| 43 | const LOGOUT = pmExec('briven logout', 'briven logout --project p_xxx'); |
| 44 | const PROJECTS = pmExec( |
| 45 | 'briven projects list', |
| 46 | 'briven projects list --remote', |
| 47 | 'briven projects create --name my-app', |
| 48 | 'briven projects use p_xxx', |
| 49 | 'briven projects use p_xxx --link', |
| 50 | 'briven projects unlink p_xxx', |
| 51 | 'briven projects set-default p_xxx', |
| 52 | ); |
| 53 | const EXPORT = pmExec( |
| 54 | 'briven export', |
| 55 | 'briven export --out backup.json', |
| 56 | 'briven export --with-data', |
| 57 | ); |
| 58 | const IMPORT = pmExec( |
| 59 | 'briven import backup.json', |
| 60 | 'briven import backup.json --restore-data', |
| 61 | ); |
| 62 | const DOCTOR = pmExec('briven doctor', 'briven doctor --origin https://api.example.com'); |
| 63 | |
| 64 | export default function CliPage() { |
| 65 | return ( |
| 66 | <DocsShell> |
| 67 | <h1 className="font-mono text-2xl tracking-tight">cli</h1> |
| 68 | <p className="mt-2 font-mono text-sm text-[var(--color-text-muted)]"> |
| 69 | <code>@briven/cli</code> — install as a dev dependency, or run one-off via each PM's |
| 70 | remote-exec shim. |
| 71 | </p> |
| 72 | |
| 73 | <Section title="install"> |
| 74 | <PmTabs commands={INSTALL} /> |
| 75 | <p>…or skip the install and invoke directly:</p> |
| 76 | <PmTabs commands={ONE_SHOT} /> |
| 77 | </Section> |
| 78 | |
| 79 | <Section title="setup · new project"> |
| 80 | <p> |
| 81 | Create a <em>new</em> cloud project only: browser sign-in, scaffold folder, mint CLI + S3 |
| 82 | keys. To attach an <em>existing</em> project use <code>briven connect</code> (section |
| 83 | below). Full walkthrough on the{' '} |
| 84 | <a className="underline" href="/connect"> |
| 85 | connect |
| 86 | </a>{' '} |
| 87 | page. Bare <code>briven</code> with no linked project also starts setup. |
| 88 | </p> |
| 89 | <PmTabs commands={SETUP} /> |
| 90 | </Section> |
| 91 | |
| 92 | <Section title="init"> |
| 93 | <p> |
| 94 | Scaffold local files only (<code>briven.json</code>, schema, example function) — no cloud. |
| 95 | Prefer <code>briven setup</code> when you want the full connect + project flow. |
| 96 | </p> |
| 97 | <PmTabs commands={INIT} /> |
| 98 | <p> |
| 99 | Pass <code>--name</code> to override the directory name. Pass <code>--force</code> to |
| 100 | overwrite an existing <code>briven.json</code>. |
| 101 | </p> |
| 102 | </Section> |
| 103 | |
| 104 | <Section title="connect"> |
| 105 | <p> |
| 106 | Sign this machine into the <em>platform</em> only (browser OAuth) without scaffolding. |
| 107 | Usually you want <code>briven setup</code> instead. |
| 108 | </p> |
| 109 | <PmTabs commands={CONNECT} /> |
| 110 | <p> |
| 111 | Stores a user session in <code>~/.config/briven/credentials.json</code>.{' '} |
| 112 | <code>connect logout</code> clears only that session; project <code>brk_…</code> keys stay |
| 113 | until <code>briven logout</code>. |
| 114 | </p> |
| 115 | </Section> |
| 116 | |
| 117 | <Section title="login (manual key)"> |
| 118 | <p> |
| 119 | Store a dashboard-issued API key for a project — the manual alternative to{' '} |
| 120 | <code>briven projects use</code> after <code>connect</code>. |
| 121 | </p> |
| 122 | <PmTabs commands={LOGIN} /> |
| 123 | <p> |
| 124 | Credentials land at <code>~/.config/briven/credentials.json</code> with mode 0600. Get a |
| 125 | key from the dashboard under <em>api keys</em>. |
| 126 | </p> |
| 127 | </Section> |
| 128 | |
| 129 | <Section title="whoami"> |
| 130 | <p>Verify the stored key is still valid and which project it belongs to.</p> |
| 131 | <PmTabs commands={WHOAMI} /> |
| 132 | </Section> |
| 133 | |
| 134 | <Section title="link"> |
| 135 | <p> |
| 136 | Associate the current directory with an existing briven project — writes the project id |
| 137 | into <code>briven.json</code> so subsequent commands don't need <code>--project</code>. |
| 138 | </p> |
| 139 | <PmTabs commands={LINK} /> |
| 140 | </Section> |
| 141 | |
| 142 | <Section title="deploy"> |
| 143 | <p> |
| 144 | Loads <code>briven/schema.ts</code>, compares it to the currently deployed schema, and |
| 145 | creates a new deployment. Destructive changes (drop table, drop column) are refused unless{' '} |
| 146 | <code>--confirm-destructive</code> is passed. |
| 147 | </p> |
| 148 | <PmTabs commands={DEPLOY} /> |
| 149 | </Section> |
| 150 | |
| 151 | <Section title="invoke"> |
| 152 | <p> |
| 153 | Call a deployed function and print the response. Reads the project id from{' '} |
| 154 | <code>briven.json</code>; pass <code>--body</code> for an inline JSON body or{' '} |
| 155 | <code>--body-file path</code> to read from disk. <code>--raw</code> prints just the |
| 156 | unwrapped function value, jq-pipeable. |
| 157 | </p> |
| 158 | <PmTabs commands={INVOKE} /> |
| 159 | </Section> |
| 160 | |
| 161 | <Section title="env"> |
| 162 | <p> |
| 163 | Manage per-project environment variables. Values are encrypted at rest with the platform |
| 164 | key and only decrypted into the function runtime at cold start; <code>env list</code>{' '} |
| 165 | surfaces metadata only. |
| 166 | </p> |
| 167 | <PmTabs commands={ENV} /> |
| 168 | </Section> |
| 169 | |
| 170 | <Section title="db"> |
| 171 | <p> |
| 172 | Open a psql shell against the project's data-plane schema. Issues a short-lived dsn |
| 173 | via the api — the cli never sees the long-lived superuser credentials. Admin-tier; rate |
| 174 | limited. |
| 175 | </p> |
| 176 | <PmTabs commands={DB} /> |
| 177 | </Section> |
| 178 | |
| 179 | <Section title="dev"> |
| 180 | <p> |
| 181 | Watch <code>briven/schema.ts</code> + <code>briven/functions/*</code> and push on |
| 182 | change. Drives the inner-loop dev experience — same effect as running{' '} |
| 183 | <code>briven deploy</code> after every save. |
| 184 | </p> |
| 185 | <PmTabs commands={DEV} /> |
| 186 | </Section> |
| 187 | |
| 188 | <Section title="logs"> |
| 189 | <p> |
| 190 | Stream function-invocation logs for the linked project. Shows the structured envelope |
| 191 | per invocation: <code>requestId</code>, <code>functionName</code>, <code>durationMs</code>, |
| 192 | status, and any logs the function wrote via <code>ctx.log</code>. |
| 193 | </p> |
| 194 | <PmTabs commands={LOGS} /> |
| 195 | </Section> |
| 196 | |
| 197 | <Section title="logout"> |
| 198 | <PmTabs commands={LOGOUT} /> |
| 199 | </Section> |
| 200 | |
| 201 | <Section title="projects"> |
| 202 | <p> |
| 203 | Full project lifecycle from the shell. Local commands read{' '} |
| 204 | <code>~/.config/briven/credentials.json</code>; remote / create / use need{' '} |
| 205 | <code>briven connect</code> first. |
| 206 | </p> |
| 207 | <PmTabs commands={PROJECTS} /> |
| 208 | <ul className="list-disc pl-5"> |
| 209 | <li> |
| 210 | <code>list</code> — keys on this machine; <code>list --remote</code> — account projects |
| 211 | </li> |
| 212 | <li> |
| 213 | <code>create --name …</code> — create on the platform, mint a CLI key, set default |
| 214 | </li> |
| 215 | <li> |
| 216 | <code>use <id></code> — mint/store key for an existing project;{' '} |
| 217 | <code>--link</code> writes <code>projectId</code> into <code>briven.json</code> |
| 218 | </li> |
| 219 | <li> |
| 220 | <code>unlink</code> — drop the local key only; <code>set-default</code> — pick which |
| 221 | project other commands fall back to |
| 222 | </li> |
| 223 | </ul> |
| 224 | </Section> |
| 225 | |
| 226 | <Section title="export / import"> |
| 227 | <p> |
| 228 | Move a project's schema + functions (and optionally its data) between |
| 229 | projects or to disk. <code>--with-data</code> shells out to{' '} |
| 230 | <code>pg_dump --format=custom --compress=6</code> against a short-lived dsn;{' '} |
| 231 | <code>--restore-data</code> on the import side looks for the sibling data dump |
| 232 | and pipes it into <code>pg_restore</code>. No new cli deps, but assumes{' '} |
| 233 | <code>pg_dump</code> + <code>pg_restore</code> on your PATH. |
| 234 | </p> |
| 235 | <PmTabs commands={EXPORT} /> |
| 236 | <PmTabs commands={IMPORT} /> |
| 237 | </Section> |
| 238 | |
| 239 | <Section title="doctor"> |
| 240 | <p> |
| 241 | End-to-end health check against the linked api. Prints pass/fail for: api |
| 242 | reachable, session valid, project reachable, runtime ready, an example function |
| 243 | invoke (if any). Useful first-line triage when something feels off. |
| 244 | </p> |
| 245 | <PmTabs commands={DOCTOR} /> |
| 246 | </Section> |
| 247 | |
| 248 | <Section title="environment"> |
| 249 | <ul className="list-disc pl-5"> |
| 250 | <li> |
| 251 | <code>BRIVEN_API_ORIGIN</code> — override the control-plane origin for a self-hosted |
| 252 | deployment. Default: <code>https://api.briven.tech</code>. |
| 253 | </li> |
| 254 | <li> |
| 255 | <code>BRIVEN_DASHBOARD_ORIGIN</code> — where browser OAuth opens ( |
| 256 | <code>briven connect</code>). Default: <code>https://app.briven.tech</code>. |
| 257 | </li> |
| 258 | <li> |
| 259 | <code>XDG_CONFIG_HOME</code> — where credentials are stored, following the XDG spec. |
| 260 | </li> |
| 261 | </ul> |
| 262 | </Section> |
| 263 | </DocsShell> |
| 264 | ); |
| 265 | } |
| 266 | |
| 267 | function Section({ title, children }: { title: string; children: React.ReactNode }) { |
| 268 | return ( |
| 269 | <section className="mt-10"> |
| 270 | <h2 className="font-mono text-lg">{title}</h2> |
| 271 | <div className="mt-2 space-y-3 font-mono text-sm text-[var(--color-text-muted)]"> |
| 272 | {children} |
| 273 | </div> |
| 274 | </section> |
| 275 | ); |
| 276 | } |