nextjs-cms-kit
v0.5.33
Published
A CLI toolkit for managing and maintaining your NextJS CMS application. Provides commands for database setup, schema generation, admin management, and section updates.
Readme
nextjs-cms-kit
A CLI toolkit for managing and maintaining your NextJS CMS application. Provides commands for database setup, schema generation, admin management, and section updates.
Installation
Install globally or use via npx:
# 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 <command>Usage
nextjs-cms-kit [command] [options]Global Options
-d, --dev- Use development environment file (.env.developmentinstead of.env)
Commands
setup
Complete nextjs-cms setup wizard. This is the recommended way to set up a new CMS project.
nextjs-cms-kit setup
nextjs-cms-kit setup --dev # Use development environmentWhat it does:
- Configures database connection
- Generates database schema using Drizzle Kit
- Sets up master admin account
- Updates database tables based on sections
Use this when:
- Setting up a new CMS project
- First-time installation
- After cloning a project
db-config
Initialize or update nextjs-cms database configuration.
nextjs-cms-kit db-config
nextjs-cms-kit db-config --devWhat it does:
- Prompts for database connection details
- Creates or updates
.envfile 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
set-master-admin
Set or update the master admin password.
nextjs-cms-kit set-master-admin
nextjs-cms-kit set-master-admin --devWhat 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
fix-master-admin
Fix master admin privileges for all sections.
nextjs-cms-kit fix-master-admin
nextjs-cms-kit fix-master-admin --devWhat 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
update-sections
Update database tables based on current section definitions and fix master admin privileges.
nextjs-cms-kit update-sections
nextjs-cms-kit update-sections --devWhat it does:
- Scans your sections folder
- Generates/updates database schema to match section definitions
- Adds new fields and tables as needed
- 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
.envfile - Development: Use
--devflag to use.env.developmentfile
Example:
# Uses .env
nextjs-cms-kit setup
# Uses .env.development
nextjs-cms-kit setup --devPrerequisites
Before using the toolkit, ensure you have:
- Database configured - MySQL/MariaDB database server running
- Environment file -
.envor.env.developmentwith database connection details - Sections folder - Your CMS sections defined in the configured sections folder
- Drizzle config -
drizzle.config.tsfile in your project root
Common Workflows
Initial Setup
# 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-adminAfter Adding New Sections
# Update database to match new sections
nextjs-cms-kit update-sectionsAfter Pulling Changes
# Update database schema and permissions
nextjs-cms-kit update-sectionsResetting Admin Access
# Fix admin privileges
nextjs-cms-kit fix-master-admin
# Or reset password
nextjs-cms-kit set-master-adminConfiguration
The toolkit reads configuration from:
- CMS Config:
cms.config.tsin your project root - Environment:
.envor.env.developmentfiles - Drizzle Config:
drizzle.config.tsfor database migrations
Make sure these files are properly configured before running commands.
Troubleshooting
Database Connection Errors
If you see database connection errors:
- Verify database server is running
- Check
.envfile has correct credentials - Run
nextjs-cms-kit db-configto reconfigure
Schema Generation Fails
If schema generation fails:
- Check
drizzle.config.tsis properly configured - Ensure database connection is working
- Verify sections are valid (no syntax errors)
Permission Errors
If you encounter permission errors:
- Run
nextjs-cms-kit fix-master-adminto restore permissions - Verify master admin user exists in database
- Check section definitions are valid
License
MIT License - see LICENSE file for details.
