@supacommerce/cli
v0.23.0
Published
CLI for supacommerce — initialise your ecommerce backend with one command
Downloads
1,757
Readme
@supacommerce/cli
The init command for supacommerce. Copies schemas, edge functions, and SQL files into your project.
Usage
npx @supacommerce/cli initOptions:
npx @supacommerce/cli init --dir ./my-project # target a specific directory
npx @supacommerce/cli init --skip-confirmation # skip the confirmation promptWhat it copies
your-project/
├── drizzle.config.example.ts
├── supabase/
│ ├── config.toml
│ ├── rls.sql
│ ├── functions.sql
│ ├── nuke-dbs.sql
│ ├── drop-dbs.sql
│ └── functions/
│ ├── deno.json
│ ├── _shared/
│ │ ├── cors.ts
│ │ └── supabaseAdmin.ts
│ ├── cart-checkout/index.ts
│ ├── order-confirmed/index.ts
│ ├── payment-webhook/index.ts
│ ├── admin-send-invite/index.ts
│ ├── admin-accept-invite/index.ts
│ ├── storage-upload/index.ts
│ └── storage-delete/index.ts
└── src/
└── ecommerce/
└── schema/
├── currencies.ts
├── regions.ts
├── customers.ts
├── catalog.ts
├── inventory.ts
├── pricing.ts
├── promotions.ts
├── tax.ts
├── fulfillment.ts
├── cart.ts
├── orders.ts
├── payments.ts
├── sales_channels.ts
└── admin_users.tsHow it handles your project
- Existing
src/directory — schemas are placed atsrc/ecommerce/schema/without touching your existing code - Files that already exist — shown as
overwritein the preview table with a warning before writing - Non-existent target directory — prompts to create it
- Missing template files — fails fast with a clear error before writing anything
- Failed writes — reports which files failed; successfully written files remain
- Package manager detection — automatically detects pnpm, yarn, bun, or npm and prints the correct install commands
After running init
1. Install dependencies
pnpm add drizzle-orm @supabase/supabase-js @supacommerce/client
pnpm add -D drizzle-kit2. Configure Drizzle
mv drizzle.config.example.ts drizzle.config.tsAdd your database URL to .env:
DATABASE_URL=postgresql://postgres:[password]@[host]:5432/postgres3. Start Supabase locally
supabase start4. Generate and apply migrations
pnpm db:generate
supabase db push5. Apply RLS policies and Postgres functions
Open the Supabase SQL Editor and run:
supabase/rls.sql— Row Level Security policiessupabase/functions.sql— Postgres RPC functions
These are not applied by supabase db push — they must be run manually each time you reset or re-provision.
6. Use the query client
import { createClient as createSupabaseClient } from "@supabase/supabase-js";
import { createClient } from "@supacommerce/client";
const supabase = createSupabaseClient(url, anonKey);
const commerce = createClient(supabase);
const products = await commerce.catalog.listProducts();
const cart = await commerce.cart.getOrCreate();License
MIT
