Skip to content

Proposal for a npx @wp-playground/cli start new command #2498

@zaerl

Description

@zaerl

Add an interactive start command that simplifies the low-level interface of the new CLI.

npx @wp-playground/cli start opens a 6-item menu on the terminal

  1. serve-wp
    • Ask for the folder where the site is saved. Default to ./ if it seems like a site
    • Ask for the PHP version; the default is the latest version
    • Alias of @wp-playground/cli server --mount-before-install=__CHOSEN_FOLDER__:/wordpress --skip-wordpress-setup --skip-sqlite-setup --php=__PHP_VERSION__
    • wp-now alias of npx @wp-now/wp-now start --path=__CHOSEN_FOLDER__ --skip-browser
  2. plugin
    • Ask for the folder where the plugin is saved. Default to ./ if it seems like a plugin
    • Alias of @wp-playground/cli server --mount-before-install=__FOLDER__:/wordpress/wp-content/plugins
    • wp-now alias of npx @wp-now/wp-now start --path=__CHOSEN_FOLDER__ --skip-browser
  3. theme
    • Ask for the folder where the plugin is saved. Default to ./ if it seems like a theme
    • Alias of @wp-playground/cli server --mount-before-install=__FOLDER__:/wordpress/wp-content/themes
    • wp-now alias of npx @wp-now/wp-now start --path=__CHOSEN_FOLDER__ --skip-browser
  4. blueprint
    • Ask for the blueprint file name
    • Alias for @wp-playground/cli run-blueprint --blueprint=__FILENAME__
    • wp-now alias of npx @wp-now/wp-now start --blueprint=__FILENAME__
  5. create-site
    • Ask for the folder where the site is saved
    • Ask for WordPress version, the default is the latest version
    • Ask for the PHP version; the default is the latest version
    • Alias of @wp-playground/cli server --mount-before-install=__CHOSEN_FOLDER__:/wordpress --wp=__WP_VERSION__ --php=__PHP_VERSION__
  6. build-snapshot
    • Ask for the blueprint file name
    • Alias for @wp-playground/cli build-snapshot --blueprint=__CHOSEN_FILENAME__

This way, if the user is always pressing Enter on the keyboard, it will serve the current folder as a site. This is what happens when you run npx @wp-now/wp-now start inside a WordPress folder.

Additional proposals

  1. If the CLI is run in a terminal with TERM_DEV="dumb" environment variable, it's an alias of @wp-playground/cli server __ARGS__
  2. We can potentially select 1, 2, or 3 if the resolution logic of expandAutoMounts returns site, plugin, and others. However, it may appear as a bug.
  3. We can set create and init as aliases
  4. The CLI can ask for additional advanced properties like "Want to specify other advanced options? [yN]" or similar to let the user pass what it has not passed already by arguments in the initial call.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions