Skip to content

feat(scaffold): delegate theme setup to the shared wp-framework engine#716

Draft
aryanjasala wants to merge 4 commits into
theme-elementary-v2from
feat/scaffold-engine
Draft

feat(scaffold): delegate theme setup to the shared wp-framework engine#716
aryanjasala wants to merge 4 commits into
theme-elementary-v2from
feat/scaffold-engine

Conversation

@aryanjasala

Copy link
Copy Markdown
Member

What this does

Replaces the theme's bespoke ~630-line bin/init.js with a thin wrapper that
hands a per-theme bin/scaffold.config.js to the shared scaffold engine in
rtcamp/wp-framework. Setup behaviour (rename → version → persist → optional
git / Husky / cleanup) now lives in one place the framework owns; this repo only
declares what is theme-specific.

Stacks on the wp-framework scaffold-engine PR.

Changes

  • bin/init.js — 638-line bespoke script → ~50-line wrapper. Resolves the
    engine from vendor/rtcamp/wp-framework/bin/scaffold.js, prints a clear "run
    composer install / npm install" message if it (or @rtcamp/wp-tooling)
    isn't installed, and calls run( config, { root } ).
  • bin/scaffold.config.js (new) — the theme's identity: source placeholder
    (Elementary Theme), token map, the details table, version targets
    (style.css header + package.json), cleanup targets (.github, languages),
    enabled steps (composer / cleanup / git / Husky), and a features: [] array
    (+ a commented Tailwind example) so the theme is manage-mode ready.
  • package.json — add @rtcamp/wp-tooling devDependency; point prepare at
    npm run sync-ai instead of npm run init (drops the footgun where every
    npm install re-ran interactive setup).

Notable fix carried by the new engine + config

The previous init never renamed the PHP namespace (rtCamp\Theme\Elementary)
— neither in source files nor in composer.json's autoload. The new config maps
both the single-backslash (PHP) and double-backslash (JSON) forms, so a scaffolded
theme now gets rtCamp\Theme\<PascalName> consistently across inc/**,
sub-namespaces, and composer.json.

How I verified

Vendored the engine + symlinked @rtcamp/wp-tooling into a throwaway copy, drove
the wrapper with piped answers:

  • Invalid name (9bad) rejected → re-prompt → valid accepted.
  • composer.json autoload rtCamp\\Theme\\My_Test_Theme\\ + inc/Main.php
    namespace rtCamp\Theme\My_Test_Theme; + sub-namespaces all renamed; package
    rtcamp/my-test-theme; version applied to style.css + package.json.
  • .wp-scaffold.json persisted (name / namespace / textDomain / prefixes /
    features); .github + languages cleaned; screenshot.png + bin/ untouched.
  • Second run enters manage mode (--list shows "no optional features";
    --reinit forces a fresh scaffold).

Reviewer notes

  • Requires @rtcamp/wp-tooling in node_modules (devDep, ^0.1.0). It's a
    GitHub-registry package and not published yet — installing it needs an
    @rtcamp:registry=https://npm.pkg.github.com line in .npmrc (not added here)
    and a published version. Tested via a local symlink in the meantime.
  • Onboarding becomes composer install && npm install && npm run init.

Replace the bespoke bin/init.js with a thin wrapper that hands bin/scaffold.config.js to the rtcamp/wp-framework scaffold engine.

The config fixes the previously-unrenamed PHP namespace (rtCamp\Theme\Elementary, in both source files and composer.json) and persists identity to .wp-scaffold.json. Add @rtcamp/wp-tooling as a dev dependency and point prepare at sync-ai (dropping the npm-install auto-trigger of init).
Add featuresDir + an empty features array so the theme supports manage mode, with a commented Tailwind feature example showing the shape. The Tailwind webpack wiring lands with the Tailwind effort.
Declare the placeholder as a full identity (name + explicit namespace/package) plus namespace()/package() templates, replacing the hand-written extraTokens. Lets the shared engine edit any identity field and rename an already-initialized theme from .wp-scaffold.json.
Replace details() with a fields list (key + label) so the review table and the editor stay in sync. Theme shows all eight fields, including CSS Prefix.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors the theme’s scaffolding/onboarding flow by replacing the bespoke bin/init.js implementation with a thin wrapper that delegates all scaffold behavior to the shared rtcamp/wp-framework scaffold engine, with theme-specific behavior defined in a new config file.

Changes:

  • Replaces the large custom init script with a wrapper that loads vendor/rtcamp/wp-framework/bin/scaffold.js and calls the engine’s run() with a per-theme config.
  • Adds bin/scaffold.config.js to define placeholder identity, tokenization inputs, version targets, cleanup targets, and enabled scaffold steps.
  • Updates package.json to add @rtcamp/wp-tooling and switches prepare to npm run sync-ai (avoiding interactive init on install).

Reviewed changes

Copilot reviewed 1 out of 3 changed files in this pull request and generated no comments.

File Description
package.json Adds the scaffold-related dev dependency and adjusts lifecycle scripts to avoid re-running interactive setup on every install.
bin/scaffold.config.js Introduces the theme-specific scaffold configuration consumed by the shared framework scaffold engine.
bin/init.js Replaces bespoke setup logic with a wrapper that locates and invokes the shared scaffold engine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants