cli:开源Firebase替代方案的命令行工具,支持本地运行、数据库迁移等功能

Supabase CLI. Manage postgres migrations, run Supabase locally, deploy edge functions. Postgres backups. Generating types from your database schema.

Branch229Tags2035
This repository is empty

Supabase CLI

在本地开发,并通过终端部署到 Supabase 平台。

npm Build License Discord


Supabase CLI 让 Supabase 平台在终端触手可及。运行完整本地栈,管理数据库迁移,部署 Edge Functions,生成类型,并自动化项目工作流。

安装

# YOLO
curl -fsSL https://raw.githubusercontent.com/supabase/cli/main/install | bash

# npm
npm install -D supabase                   # or bun/pnpm/yarn add -D supabase
npm install -D supabase@beta              # beta channel

# macOS and Linux
brew install supabase/tap/supabase        # always up to date
brew install supabase                     # official formula, may be delayed
brew install supabase/tap/supabase-beta   # beta channel

# Windows
scoop bucket add supabase https://github.com/supabase/scoop-bucket.git
scoop install supabase
scoop install supabase-beta               # beta channel

# Linux packages
# Download .apk, .deb, .rpm, or .pkg.tar.zst from GitHub Releases.

Linux 软件包可从发布版本获取。社区维护的软件包也可通过 pkgxNixpkgs 获取。

开始本地开发

创建一个 Supabase 工作区,并启动本地服务栈:

supabase init
supabase start
supabase status

本地栈包含 Postgres、Auth、Realtime、Storage、Edge Functions 和 Supabase API。

从模板开始:

supabase bootstrap

关联项目

将本地工作区连接到托管的 Supabase 项目:

supabase login
supabase link

管理您的数据库

创建迁移、比较数据库结构,并将变更应用到本地或已关联的项目:

supabase migration new create_profiles
supabase db diff
supabase db push
supabase db reset

部署 Edge Functions

在同一项目工作区中构建、运行并部署函数:

supabase functions new hello-world
supabase functions serve
supabase functions deploy hello-world

生成类型

从本地数据库或已关联的项目生成 TypeScript 类型:

supabase gen types --local
supabase gen types --linked

参考

在任意命令中使用 --help 以查看参数和示例:

supabase db --help
supabase functions deploy --help

开发

本仓库是一个 pnpm monorepo。正式发布的包位于 apps/cli

pnpm install
pnpm check:all

cd apps/cli

pnpm types:check
pnpm run test:unit && pnpm run test:integration

常用源码入口:

路径 用途
apps/cli TypeScript/Bun CLI 包
apps/cli-go 供 CLI 使用的 Go CLI 源码
packages/stack 本地 Supabase 栈运行时
packages/config 配置模式与生成类型
packages/api 带类型的 Supabase Management API 客户端

全新克隆后,安装供 agent 和开发者检视的参考仓库:

pnpm repos:install

贡献

我们欢迎问题清晰、改动范围小,并且测试与面向用户的行为保持一致的 PR。

请先提交 issue,并等待维护者添加 open-for-contribution 标签后再开始工作——未关联已带标签且开放 issue 的外部 PR 将被自动关闭。完整流程参见 CONTRIBUTING.md

在提交 PR 前,请从仓库根目录运行全仓库质量检查, 然后运行你改动过的每个工作区中相关包的测试。对于每个 改动过的 TypeScript 工作区(或任何声明了该脚本的工作区),也请运行其 pnpm types:check 脚本。例如:

# From the repository root:
pnpm check:all

# From apps/cli (a touched TypeScript workspace):
cd apps/cli
pnpm types:check
pnpm run test:unit && pnpm run test:integration

# Repeat the relevant package tests for every touched workspace; run
# pnpm types:check there too when that workspace declares the script.

PR 标题必须使用 conventional commits,例如:

fix(cli): handle linked projects without cached service versions

许可证

Supabase CLI 软件包采用 MIT 许可证发布。

Introduction

Supabase命令行界面【此简介由AI生成】

Customize your domain
302.41 K524Visit GitHub