WordPress / WordPress/create-block-theme

[Tracking] WP-CLI support: phased implementation

Open
#828 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement wp-cli
Dominant language
JavaScript
Stars
417
Forks
66
PR merge metrics
No merged PRs in 30d

Description

Tracking issue for adding WP-CLI support to Create Block Theme, originally requested in #688.

Background

Issue #688 proposes WP-CLI commands so developers can persist Editor changes to disk from the terminal — useful for git workflows and automation. @bacoords prototyped a wp cbt save command on a separate branch (https://github.com/bacoords/create-block-theme/tree/add/cli-export-command) but did not open a PR; the prototype acknowledges duplicated logic from the REST API.

This tracking issue proposes a four-PR sequence that ships the CLI as a thin layer over a properly extracted service layer, so REST and CLI share a single implementation.

Approach

For each of save and export:

  1. Refactor first — extract the REST handler's orchestration into a service class (CBT_Theme_Save, CBT_Theme_Export) under includes/create-theme/. REST endpoint becomes a thin wrapper. Add PHPUnit coverage. No behavior change at the wire boundary.
  2. Add the CLI command — register on the same service. Kebab-case flags, wp_is_block_theme() guard, ## EXAMPLES, i18n.

Doing the refactor first means the test coverage we need anyway lands in a small, reviewable PR before any new surface area is added.

Variation, clone, child-theme, blank-theme, and reset commands are deliberately out of scope for v1 and can be added in follow-ups once the pattern is established.

Sub-issues

  • #829 — Extract CBT_Theme_Save service from rest_save_theme
  • #830 — Add wp cbt save CLI command
  • #831 — Extract CBT_Theme_Export service from rest_export_theme
  • #832 — Add wp cbt export CLI command

Out of scope (potential follow-ups)

  • Variation / clone / blank / child theme creation as CLI commands
  • Behat feature tests (the plugin has no Behat infrastructure today)
  • Promoting silent filesystem failures to WP_Error (separate concern from the refactor)

References

Open to discussion on scope, sequencing, and naming before any PRs are opened.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with sub-issue #829 and the REST handlers named in this tracking issue, rest_save_theme and rest_export_theme, under includes/create-theme/. Review the proposed sequence and PHPUnit coverage requirements; the tracking work is done when the relevant service extraction or CLI sub-issue is completed without taking the listed out-of-scope commands into v1.

Written by the indexing model from the issue text.

Assessment

Tech stack
php, wordpress
Domain
backend-api-design, cli
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.