https://github.com/builtnorth/wp-cli-builtnorth
https://github.com/builtnorth/wp-cli-builtnorth
Last synced: 11 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/builtnorth/wp-cli-builtnorth
- Owner: builtnorth
- Created: 2025-07-13T15:32:17.000Z (11 months ago)
- Default Branch: main
- Last Pushed: 2025-07-22T01:35:46.000Z (11 months ago)
- Last Synced: 2025-07-22T03:31:37.344Z (11 months ago)
- Language: PHP
- Size: 20.5 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# BuiltNorth WP-CLI Commands
A modular WP-CLI package for BuiltNorth WordPress development workflows.
## Installation
```bash
wp package install builtnorth/wp-cli-builtnorth
```
## Commands
### Setup (Standard)
Standard WordPress project setup:
```bash
wp builtnorth setup --name="My Project" --email="admin@example.com" --password="secure123"
```
This command provides:
- **WordPress installation** with database management
- **Theme handling** - Installs from composer, setup/data/themes, or default WordPress themes
- **Plugin activation** - Activates all available plugins
- **Content import** - Imports from setup/data/content/*.xml
- **Media import** - Imports with automatic logo/icon detection
- **Settings configuration** - Timezone, permalinks, upload settings
- **Page setup** - Configures home and blog pages if found
Options:
- `--name=` - Project name (required)
- `--username=` - WordPress admin username (default: admin)
- `--password=` - WordPress admin password (required)
- `--email=` - WordPress admin email (required)
### Setup BN Project
BuiltNorth-specific project setup with Compass theme:
```bash
wp builtnorth setup-bn-project --name="My Project" --email="admin@example.com" --password="secure123"
```
This enhanced setup includes everything from standard setup plus:
- **Compass theme conversion** - Automatically converts the Compass theme to a project-specific theme
- **Theme customization** - Renames theme to match project name, removes git references
- **Dependency management** - Removes compass from composer.json after conversion
- **NPM workspace integration** - Adds the new theme to npm workspaces and updates build scripts
- **Advanced configuration** - Additional BuiltNorth-specific optimizations
Options:
- `--name=` - Project name (required)
- `--username=` - WordPress admin username (default: admin)
- `--password=` - WordPress admin password (required)
- `--email=` - WordPress admin email (required)
- `--skip-wordpress` - Skip WordPress installation
- `--yes` - Skip confirmation prompts
### Configure
Configure WordPress after installation:
```bash
wp builtnorth configure
```
Options:
- `--skip-content` - Skip content import
- `--skip-media` - Skip media import
- `--url=` - Override site URL for search-replace
- `--yes` - Skip confirmation prompts
### Post Type Switch
Convert posts from one post type to another:
```bash
# Basic conversion
wp builtnorth post-type-switch --from=post --to=article
# Preview changes without making them
wp builtnorth post-type-switch --from=post --to=news --dry-run
# Convert only published posts
wp builtnorth post-type-switch --from=post --to=resource --status=publish
# Convert with taxonomy handling
wp builtnorth post-type-switch --from=post --to=portfolio --include-taxonomies
```
Features:
- **Safe conversion** with validation and confirmation prompts
- **Dry run mode** to preview changes
- **Taxonomy handling** - preserves shared taxonomies, removes unsupported ones
- **Status filtering** - convert only posts with specific status
- **Batch limiting** - test with a limited number of posts first
- **Automatic cleanup** - flushes rewrite rules and clears caches
Options:
- `--from=` - Source post type (required)
- `--to=` - Target post type (required)
- `--status=` - Only convert posts with this status (default: any)
- `--limit=` - Limit number of posts to convert
- `--dry-run` - Preview changes without making them
- `--include-taxonomies` - Handle taxonomy mappings between post types
- `--yes` - Skip confirmation prompt
### Generate
Generate test content for development:
```bash
wp builtnorth generate --count=20 --post-type=post
```
Options:
- `--count=` - Number of posts to generate (default: 10)
- `--post-type=` - Post type to generate (default: post)
- `--taxonomy=` - Taxonomy to assign terms from
- `--terms=` - Comma-separated list of term slugs to create/assign
- `--random-terms` - Randomly assign terms to posts
- `--with-content` - Generate content for posts
## Adding New Commands
1. Create a new command class in `src/Commands/` extending `BaseCommand`
2. Register it in `command.php`
3. Use traits from `src/Traits/` for common functionality
Example:
```php
namespace BuiltNorth\CLI\Commands;
use BuiltNorth\CLI\BaseCommand;
class ExportCommand extends BaseCommand {
protected $command_name = 'export';
protected function get_shortdesc() {
return 'Export site data';
}
public function __invoke($args, $assoc_args) {
// Implementation
}
}
```
## Architecture
- **BaseCommand** - Common functionality for all commands
- **Traits** - Reusable functionality (FileOperations, etc.)
- **Utils** - Helper classes
- **Commands** - Individual command implementations
This modular structure allows easy addition of new commands like import/export, migration tools, and more.