Skip to content

Auto-install WP-CLI when not detected #1

@juanmaguitar

Description

@juanmaguitar

Summary

Currently, when WP-CLI is not installed, ensureWpCli() shows installation instructions and exits. This proposal adds automatic WP-CLI installation to improve the onboarding experience.

Current Behavior

When WP-CLI is missing, users see:

Error: WP-CLI is not installed or not in PATH.

Install WP-CLI:
  curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
  chmod +x wp-cli.phar
  sudo mv wp-cli.phar /usr/local/bin/wp

Or visit: https://wp-cli.org/#installing

Proposed Behavior

Automatically download and install WP-CLI to a tool-managed location (~/.wordsmith/bin/wp) when not detected.

Implementation Plan

1. Add installWpCli() function

  • Download wp-cli.phar from official source
  • Save to ~/.wordsmith/bin/wp
  • Make executable (chmod +x)
  • No sudo required

2. Update findWpCliPath()

  • Check ~/.wordsmith/bin/wp first
  • Fall back to system PATH lookup

3. Modify ensureWpCli()

  • Prompt user for confirmation before auto-installing
  • Show progress during download
  • Verify installation succeeded

4. (Optional) Add explicit command

  • wordsmith doctor or wordsmith setup for manual installation/verification

Considerations

Aspect Decision
Install location ~/.wordsmith/bin/wp - isolated, no sudo needed
User consent Prompt before installing (not silent)
Platform support macOS/Linux initially, Windows TBD
PHP dependency Check PHP is available before attempting install

Benefits

  • Zero-friction onboarding for new users
  • No manual installation steps required
  • Tool manages its own dependencies
  • Doesn't require elevated privileges

Related Files

  • src/lib/wpcli.ts - Core WP-CLI abstraction layer

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions