A CLI toolkit for managing and maintaining your NextJS CMS application. Provides commands for database setup, schema generation, admin management, and section updates.
npm install nextjs-cms-kitbash
Global installation
npm install -g nextjs-cms-kit
or
pnpm add -g nextjs-cms-kit
or
yarn global add nextjs-cms-kit
or
bun add -g nextjs-cms-kit
Or use via npx (no installation needed)
npx nextjs-cms-kit
`
Usage
`bash
nextjs-cms-kit [command] [options]
`
$3
- -d, --dev - Use development environment file (.env.development instead of .env)
Commands
$3
Complete nextjs-cms setup wizard. This is the recommended way to set up a new CMS project.
`bash
nextjs-cms-kit setup
nextjs-cms-kit setup --dev # Use development environment
`
What it does:
1. Configures database connection
2. Generates database schema using Drizzle Kit
3. Sets up master admin account
4. Updates database tables based on sections
Use this when:
- Setting up a new CMS project
- First-time installation
- After cloning a project
$3
Initialize or update nextjs-cms database configuration.
`bash
nextjs-cms-kit db-config
nextjs-cms-kit db-config --dev
`
What it does:
- Prompts for database connection details
- Creates or updates .env file with database configuration
- Validates database connection
Use this when:
- Setting up database connection for the first time
- Changing database credentials
- Moving to a different database server
$3
Set or update the master admin password.
`bash
nextjs-cms-kit set-master-admin
nextjs-cms-kit set-master-admin --dev
`
What it does:
- Prompts for new master admin password
- Updates the master admin user in the database
- Ensures master admin has proper privileges
Use this when:
- First-time admin setup
- Resetting forgotten admin password
- Changing admin password
$3
Fix master admin privileges for all sections.
`bash
nextjs-cms-kit fix-master-admin
nextjs-cms-kit fix-master-admin --dev
`
What it does:
- Ensures master admin has full access to all sections
- Updates section permissions in the database
- Fixes any permission inconsistencies
Use this when:
- Master admin lost access to sections
- After restoring from backup
- After section structure changes
$3
Update database tables based on current section definitions and fix master admin privileges.
`bash
nextjs-cms-kit update-sections
nextjs-cms-kit update-sections --dev
`
What it does:
1. Scans your sections folder
2. Generates/updates database schema to match section definitions
3. Adds new fields and tables as needed
4. Updates master admin privileges
Use this when:
- After adding new sections
- After modifying section fields
- After pulling changes that include section updates
- When database schema is out of sync with sections
Environment Files
The toolkit supports different environment files:
- Production (default): Uses .env file
- Development: Use --dev flag to use .env.development file
Example:
`bash
Uses .env
nextjs-cms-kit setup
Uses .env.development
nextjs-cms-kit setup --dev
`
Prerequisites
Before using the toolkit, ensure you have:
1. Database configured - MySQL/MariaDB database server running
2. Environment file - .env or .env.development with database connection details
3. Sections folder - Your CMS sections defined in the configured sections folder
4. Drizzle config - drizzle.config.ts file in your project root
Common Workflows
$3
`bash
1. Configure database
nextjs-cms-kit db-config
2. Complete setup
nextjs-cms-kit setup
3. Set master admin password
nextjs-cms-kit set-master-admin
`
$3
`bash
Update database to match new sections
nextjs-cms-kit update-sections
`
$3
`bash
Update database schema and permissions
nextjs-cms-kit update-sections
`
$3
`bash
Fix admin privileges
nextjs-cms-kit fix-master-admin
Or reset password
nextjs-cms-kit set-master-admin
`
Configuration
The toolkit reads configuration from:
- CMS Config: cms.config.ts in your project root
- Environment: .env or .env.development files
- Drizzle Config: drizzle.config.ts for database migrations
Make sure these files are properly configured before running commands.
Troubleshooting
$3
If you see database connection errors:
1. Verify database server is running
2. Check .env file has correct credentials
3. Run nextjs-cms-kit db-config to reconfigure
$3
If schema generation fails:
1. Check drizzle.config.ts is properly configured
2. Ensure database connection is working
3. Verify sections are valid (no syntax errors)
$3
If you encounter permission errors:
1. Run nextjs-cms-kit fix-master-admin` to restore permissions