feat(scaffold): delegate theme setup to the shared wp-framework engine#716
Draft
aryanjasala wants to merge 4 commits into
Draft
feat(scaffold): delegate theme setup to the shared wp-framework engine#716aryanjasala wants to merge 4 commits into
aryanjasala wants to merge 4 commits into
Conversation
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.
There was a problem hiding this comment.
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.jsand calls the engine’srun()with a per-theme config. - Adds
bin/scaffold.config.jsto define placeholder identity, tokenization inputs, version targets, cleanup targets, and enabled scaffold steps. - Updates
package.jsonto add@rtcamp/wp-toolingand switchespreparetonpm 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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this does
Replaces the theme's bespoke ~630-line
bin/init.jswith a thin wrapper thathands a per-theme
bin/scaffold.config.jsto the shared scaffold engine inrtcamp/wp-framework. Setup behaviour (rename → version → persist → optionalgit / 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 theengine from
vendor/rtcamp/wp-framework/bin/scaffold.js, prints a clear "runcomposer 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.cssheader +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-toolingdevDependency; pointprepareatnpm run sync-aiinstead ofnpm run init(drops the footgun where everynpm installre-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 mapsboth the single-backslash (PHP) and double-backslash (JSON) forms, so a scaffolded
theme now gets
rtCamp\Theme\<PascalName>consistently acrossinc/**,sub-namespaces, and
composer.json.How I verified
Vendored the engine + symlinked
@rtcamp/wp-toolinginto a throwaway copy, drovethe wrapper with piped answers:
9bad) rejected → re-prompt → valid accepted.composer.jsonautoloadrtCamp\\Theme\\My_Test_Theme\\+inc/Main.phpnamespace rtCamp\Theme\My_Test_Theme;+ sub-namespaces all renamed; packagertcamp/my-test-theme; version applied tostyle.css+package.json..wp-scaffold.jsonpersisted (name / namespace / textDomain / prefixes /features);
.github+languagescleaned;screenshot.png+bin/untouched.--listshows "no optional features";--reinitforces a fresh scaffold).Reviewer notes
@rtcamp/wp-toolinginnode_modules(devDep,^0.1.0). It's aGitHub-registry package and not published yet — installing it needs an
@rtcamp:registry=https://npm.pkg.github.comline in.npmrc(not added here)and a published version. Tested via a local symlink in the meantime.
composer install && npm install && npm run init.