CLI Examples
Practical examples of using the DeesseJS CLI
CLI Examples
Practical examples and workflows using the DeesseJS CLI.
Project Setup Examples
Create a New Blog
# Create a new blog project
npx deessejs create my-blog --template blog
# Navigate to project
cd my-blog
# Install dependencies
npm install
# Start development server
npm run devInitialize in Existing Next.js Project
# In your existing Next.js project
npx deessejs init
# The CLI will:
# - Create deesse.config.ts
# - Set up database schema
# - Create admin dashboard structure
# - Generate TypeScript typesCreate E-commerce Site
# Create with e-commerce template
npx deessejs create my-shop --template ecommerce
# Set up environment variables
cp .env.example .env.local
# Push database schema
npx deessejs db:push
# Seed with sample products
npx deessejs db:seed
# Start development
npm run devDatabase Workflows
Set Up Database from Scratch
# 1. Initialize project
npx deessejs create my-app
cd my-app
# 2. Set DATABASE_URL in .env.local
echo "DATABASE_URL=\"postgresql://user:password@localhost:5432/mydb\"" >> .env.local
# 3. Push initial schema
npx deessejs db:push
# 4. (Optional) Seed with data
npx deessejs db:seedCreate and Apply Migration
# 1. Modify your schema in deesse.config.ts
# 2. Create migration
npx deessejs db:migrate --name add_user_roles --create-only
# 3. Review the generated migration file
# 4. Apply the migration
npx deessejs db:migrateReset Database
# WARNING: Deletes all data
npx deessejs db:reset --force
# Reset and reseed
npx deessejs db:reset --seedBrowse Database
# Open Prisma Studio
npx deessejs db:studio
# Opens on http://localhost:5555Collection Management
Create a Posts Collection
# Generate collection
npx deessejs g collection posts
# Or with predefined fields
npx deessejs g collection posts \
--fields title:string,content:text,published:boolean,author:reference:usersThe generated schema:
// deesse.config.ts
collections: [
{
name: 'posts',
fields: [
{ name: 'title', type: 'string', required: true },
{ name: 'content', type: 'richtext', required: true },
{ name: 'published', type: 'boolean', defaultValue: false },
{ name: 'author', type: 'reference', relation: 'users' },
],
},
]Add Field to Existing Collection
// Edit deesse.config.ts
collections: [
{
name: 'posts',
fields: [
// ... existing fields
{ name: 'tags', type: 'array', of: { type: 'string' } },
],
},
]Then push changes:
npx deessejs db:pushPlugin Workflows
Install SEO Plugin
# Add the plugin
npx deessejs plugin:add @deessejs/plugin-seo
# Configure in deesse.config.ts// deesse.config.ts
export const config = defineConfig({
plugins: [
seoPlugin({
enabled: true,
}),
],
})Install Multiple Plugins
# Install all at once
npx deessejs plugin:add @deessejs/plugin-seo
npx deessejs plugin:add @deessejs/plugin-sitemap
npx deessejs plugin:add @deessejs/plugin-rssCreate Custom Plugin
# Generate plugin scaffold
npx deessejs g plugin my-plugin
# Navigate to plugin directory
cd my-plugin
# Build the plugin
npm run build
# Link for local development
npm link
# Use in your project
cd ../my-app
npx deessejs plugin:add link:../my-pluginDevelopment Workflows
Start Development with Hot Reload
# Standard development
npm run dev
# With Turbopack (faster)
npm run dev -- --turbo
# On specific port
npm run dev -- -p 4000Build and Test Production
# Build for production
npm run build
# Test production build locally
npm run start
# Or with custom port
npm run start -- -p 4000Debug Mode
# Enable debug logging
npx deessejs dev --debug
# Or set environment variable
DEBUG=* npm run devDeployment Examples
Prepare for Vercel
# 1. Build the application
npm run build
# 2. Run migrations in production
npx deessejs db:migrate
# 3. Deploy with Vercel CLI
vercel --prodPrepare for Docker
# 1. Build for production
npm run build
# 2. Build Docker image
docker build -t deessejs-app .
# 3. Run container
docker run -p 3000:3000 \
-e DATABASE_URL="your-production-db-url" \
deessejs-appEnvironment Setup for Production
# .env.production
NODE_ENV=production
DATABASE_URL=postgresql://...
NEXT_PUBLIC_APP_URL=https://yourdomain.com
DEESSEJS_TELEMETRY=disabledCommon Workflows
Add New Feature
# 1. Create feature branch
git checkout -b feature/new-collection
# 2. Add collection
npx deessejs g collection products \
--fields name:string,price:number,description:text
# 3. Push schema changes
npx deessejs db:push
# 4. Generate TypeScript types
npx deessejs db:generate
# 5. Test changes
npm run dev
# 6. Commit and push
git add .
git commit -m "Add products collection"
git push origin feature/new-collectionUpdate Schema
# 1. Edit deesse.config.ts
# Add/modify collections and fields
# 2. Create migration
npx deessejs db:migrate --name update_schema
# 3. Review generated migration
# 4. Apply migration
npx deessejs db:migrate
# 5. Regenerate types
npx deessejs db:generateSync with Team
# Pull latest changes
git pull origin main
# Install new dependencies
npm install
# Apply any new migrations
npx deessejs db:migrate
# Regenerate types
npx deessejs db:generate
# Start development
npm run devTroubleshooting Examples
Fix Database Issues
# Reset database (careful!)
npx deessejs db:reset --force
# Or push schema again
npx deessejs db:push --force-reset
# Regenerate client
npx deessejs db:generateClear Cache
# Clear Next.js cache
rm -rf .next
# Clear node modules and reinstall
rm -rf node_modules package-lock.json
npm install
# Clear DeesseJS cache
rm -rf .deessejsFix Build Errors
# 1. Clean build artifacts
npm run clean
# 2. Check for TypeScript errors
npx tsc --noEmit
# 3. Try building again
npm run build
# 4. If still failing, try with debug
npm run build --debugAutomation Examples
CI/CD Pipeline
#!/bin/bash
# deploy.sh
# Install dependencies
npm ci
# Run tests
npm test
# Generate types
npx deessejs db:generate
# Build application
npm run build
# Run migrations
npx deessejs db:migrate
# Deploy
vercel --prodBackup Database
#!/bin/bash
# backup-db.sh
DATE=$(date +%Y%m%d_%H%M%S)
BACKUP_FILE="backup_$DATE.sql"
# Dump database
pg_dump $DATABASE_URL > $BACKUP_FILE
# Upload to S3
aws s3 cp $BACKUP_FILE s3://backups/deessejs/Sync Staging Database
#!/bin/bash
# sync-staging.sh
# Dump production
pg_dump $PROD_DB_URL > prod_dump.sql
# Restore to staging
psql $STAGING_DB_URL < prod_dump.sql
# Run any pending migrations
npx deessejs db:migrateTips and Tricks
Use Aliases
# Add to ~/.bashrc or ~/.zshrc
alias dd='npx deessejs dev'
alias db='npx deessejs db:push'
alias ds='npx deessejs db:studio'
# Usage
dd # Start dev server
db # Push database
ds # Open database studioProject Templates
Create custom templates for your team:
# Create a project with your setup
npx deessejs create my-base
# Customize it
# Add your collections, plugins, etc.
# Use as template for new projects
npx deessejs create new-project --template ./my-baseBatch Operations
# Install multiple plugins at once
for plugin in seo sitemap rss analytics; do
npx deessejs plugin:add @deessejs/plugin-$plugin
doneNext Steps
- Explore CLI Commands
- Learn about CLI Overview
- Return to Documentation Home