Reference
@rippledb/cli
CLI tools for RippleDB - schema codegen and utilities
@rippledb/cli
CLI tools for RippleDB, including schema codegen from external sources like Drizzle.
Installation
pnpm add -D @rippledb/clinpm install -D @rippledb/cliyarn add -D @rippledb/cliCommands
rippledb generate
Generates RippleDB schemas from configured sources (currently Drizzle).
npx rippledb generate
npx rippledb generate --config custom.config.ts| Option | Description | Default |
|---|---|---|
-c, --config <path> | Path to config file | ripple.config.ts |
Configuration
Create a ripple.config.ts file in your project root:
import { defineConfig } from "@rippledb/cli/config";
export default defineConfig({
codegen: {
drizzle: {
entities: "./src/db/ripple-entities.ts",
output: "./src/shared/schema.ts",
},
},
});The CLI validates this config at runtime using a small valibot schema, so typos or missing keys throw a helpful error before generation starts.
Configuration Options
codegen.drizzle
Generate RippleDB schema from Drizzle tables.
| Option | Type | Description |
|---|---|---|
entities | string | Path to file exporting Drizzle tables |
output | string | Output path for generated schema |
Drizzle Codegen
Setup
- Create an entities file that exports the Drizzle tables you want in RippleDB:
// src/db/ripple-entities.ts
export { todos, users } from "./schema";
// Only export tables you want as RippleDB entities- Configure the CLI in
ripple.config.ts:
import { defineConfig } from "@rippledb/cli/config";
export default defineConfig({
codegen: {
drizzle: {
entities: "./src/db/ripple-entities.ts",
output: "./src/shared/schema.ts",
},
},
});- Run the generator:
npx rippledb generateGenerated Output
The CLI generates a RippleDB schema file:
// AUTO-GENERATED by @rippledb/cli vx.x.x - DO NOT EDIT
// Source: ./src/db/ripple-entities.ts
import { defineSchema, s, type InferSchema } from "@rippledb/core";
export const schema = defineSchema({
todos: {
id: s.string(),
title: s.string(),
done: s.boolean(),
createdAt: s.string().optional(),
},
users: {
id: s.string(),
name: s.string(),
email: s.string(),
},
});
export type Schema = InferSchema<typeof schema>;Type Mapping
| Drizzle Type | RippleDB Type |
|---|---|
text, varchar, char, uuid | s.string() |
integer, smallint, bigint, real, float, decimal | s.number() |
boolean | s.boolean() |
| Nullable columns | .optional() |
Unknown Drizzle types default to s.string() with a console warning.
Workflow Integration
Package.json Script
Add a generate script to your package.json:
{
"scripts": {
"generate": "rippledb generate",
"postinstall": "rippledb generate"
}
}Pre-commit Hook
Generate schema before commits to keep it in sync:
# .husky/pre-commit
npx rippledb generate
git add src/shared/schema.tsCI/CD
Run generation in your CI pipeline:
# .github/workflows/ci.yml
- name: Generate RippleDB schema
run: npx rippledb generateWhy Use Codegen?
When using Drizzle as your database layer:
- Drizzle is the source of truth - migrations, schema changes happen in Drizzle
- No duplication - RippleDB schema is derived, not manually maintained
- Type safety flows through - Drizzle types → RippleDB types → Frontend types
- Frontend stays clean - No
drizzle-ormdependency in your frontend bundle
┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐
│ Drizzle Schema │ ──► │ rippledb gen │ ──► │ RippleDB Schema │
│ (DB source) │ │ │ │ (Frontend-safe) │
└─────────────────┘ └─────────────────┘ └─────────────────┘
│
▼
Migrations