wp-lemon
v1.2.1
Published
A CLI tool to help you with common tasks when setting up a new WordPress project using the wp-lemon-stack
Downloads
676
Maintainers
Readme
wp-lemon CLI
A powerful command-line tool designed to streamline the setup and management of WordPress sites built with the wp-lemon WordPress theme by Studio Lemon. This CLI helps you scaffold new sites, create and manage blocks, and simplify your WordPress development workflow.
Developed by Studio Lemon for developers working with the wp-lemon stack.
📋 Table of Contents
✨ Features
- 🚀 Quick Site Setup - Scaffold a new wp-lemon WordPress site in minutes
- 🧩 Block Management - Create, reuse, and update WordPress blocks effortlessly
- 🔄 Site Ejection - Convert a wp-lemon site to a standard WordPress installation
- 🎨 Interactive CLI - User-friendly prompts guide you through setup processes
Use with npx:
npx wp-lemon <command>Install from source:
git clone [email protected]:Studio-Lemon/wp-lemon-create.git
cd wp-lemon-create
npm install
npm link🔧 Requirements
- Node.js v16.0.0 or higher
- npm (comes with Node.js)
- PHP (8.2 or higher)
- Composer (for PHP dependency management)
- wp CLI (for WordPress command line management)
- wp dotenv package (for managing environment variables)
Check your Node.js version:
node --version📚 Commands
Site Commands
wp-lemon site create
Creates a new wp-lemon WordPress site with scaffolded theme structure and dependencies.
Usage:
npx wp-lemon site createWhat it does:
- Initializes a new WordPress project
- Sets up the wp-lemon theme structure
- Installs required PHP dependencies via Composer
- Configures block directories
- Creates initial configuration files
Interactive prompts:
- Project name
- Project slug (auto-generated from name)
- Theme configuration options
Example:
$ npx wp-lemon site create
# Follow the prompts to configure your new sitewp-lemon site update
Updates an existing wp-lemon site with the latest theme files and dependencies.
Usage:
npx wp-lemon site updateNote: This feature is currently in development. Check back soon for updates!
wp-lemon site eject
Converts a wp-lemon managed site to a standard WordPress installation, removing wp-lemon specific tooling and configurations.
Usage:
npx wp-lemon site ejectWhat it does:
- Removes wp-lemon CLI dependencies
- Converts wp-lemon specific configurations to standard WordPress configs
- Maintains all your content and customizations
- Generates a backup of your configuration
⚠️ Warning: This action is irreversible. Make sure you have a backup before ejecting!
Block Commands
wp-lemon block create
Scaffolds a new WordPress block in the current site with all necessary files and configuration.
Usage:
npx wp-lemon block createWhat it does:
- Creates a new block directory with proper structure
- Generates PHP block files (PHP registration and rendering)
- Creates JavaScript/TypeScript component files
- Sets up block metadata (
block.json) - Configures block styles and editor styles
- Registers the block with WordPress
Interactive prompts:
- Block name (e.g., "Hero Section")
- Block slug (auto-generated, can be customized)
- Block category (common, formatting, layout, widgets, embed)
- Additional block options (supports, alignments, etc.)
Generated files:
blocks/
├── block-slug/
│ ├── block.json
│ ├── block-slug.php
│ ├── block-slug.twig
│ ├── acf-block-slug.css
│ └── index.jsonExample:
$ npx wp-lemon block create
# Follow the prompts to configure your new blockwp-lemon block reuse
Reuses a block from a different wp-lemon site by copying it into the current site.
Usage:
npx wp-lemon block reuseWhat it does:
- Allows you to copy/paste a path to a block from another wp-lemon site
- Copies block files to your current site
- Registers the block with your site configuration
- Able to rename the block if needed
Interactive prompts:
- Input path to source block
- Confirm block configuration for new site
Example:
$ npx wp-lemon block reuse
# Select a block from another project to copy into this oneBlocks Commands
wp-lemon blocks update
Updates all blocks in your site to the latest versions and standards.
Usage:
npx wp-lemon blocks updateWhat it does:
- Scans all blocks in your site
- Updates block metadata and registration
- Migrates blocks to latest WordPress block standards
- Updates block styles and scripts
- Validates block configurations
Note: This feature is currently in development. Check back soon for updates!
Help & Version
wp-lemon help
Displays comprehensive help information about all available commands.
Usage:
npx wp-lemon helpor
npx wp-lemon --help
npx wp-lemon -hwp-lemon --version
Displays the current version of the wp-lemon CLI tool.
Usage:
npx wp-lemon --version
npx wp-lemon -v🤝 Contributing
We welcome contributions from the wp-lemon community! Here's how you can help improve wp-lemon-create:
Getting Started
Fork the repository on GitHub
git clone [email protected]:YOUR_USERNAME/wp-lemon-create.git cd wp-lemon-createInstall dependencies
npm installCreate a feature branch
git checkout -b feature/your-feature-name
Development Workflow
Running Tests
npm testThis runs the CLI test suite and validates all commands.
Testing Commands Locally
Link the package locally for testing:
npm linkThen test commands as if they were globally installed:
npx wp-lemon site create
npx wp-lemon block createTo unlink:
npm unlinkCode Structure
wp-lemon-create/
├── index.js # Main CLI entry point
├── lib/
│ ├── banner.js # CLI banner display
│ ├── actions/
│ │ ├── help.js # Help command handler
│ │ ├── site/
│ │ │ ├── site-create.js # Site creation logic
│ │ │ ├── site-eject.js # Site ejection logic
│ │ │ └── create-vanilla.js # Vanilla site setup
│ │ └── block/
│ │ ├── block-create.js # Block scaffolding
│ │ └── block-reuse.js # Block reuse logic
│ └── helpers/
│ └── test-block-version.js # Version utilities
├── test/
│ └── cli.test.js # Test suite
└── package.json # Dependencies & scriptsCommon Tasks
Adding a New Command
Create action file in appropriate directory:
// lib/actions/your-feature/your-command.js const yourCommand = () => { // Implementation }; module.exports = { yourCommand };Import in
index.js:const { yourCommand } = require('./lib/actions/your-feature/your-command');Register command:
const yourCommand = program.command('your-feature'); yourCommand .command('your-command') .description('Description of your command') .action(() => { showBanner('Your Command'); yourCommand(); });
Adding a Helper Function
Create in
lib/helpers/:// lib/helpers/your-helper.js const yourHelper = (param) => { // Implementation }; module.exports = { yourHelper };Import where needed and add tests
📄 License
This project is licensed under the MIT License - see the LICENSE file for details.
🆘 Support
Getting Help
- 📖 Read the documentation
- 🐛 Report bugs
- 💡 Suggest features
- 📧 Contact: [email protected]
🔗 Related Resources
Made with ❤️ by Studio Lemon
