feat(scaffold): delegate theme setup to the shared wp-framework engine#716
Open
aryanjasala wants to merge 8 commits into
Open
feat(scaffold): delegate theme setup to the shared wp-framework engine#716aryanjasala wants to merge 8 commits into
aryanjasala wants to merge 8 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. |
AnuragVasanwala
left a comment
Member
There was a problem hiding this comment.
LGTM ✅ but let's wait for feature selector to be merged so we can add them to the bin/scaffold.config.js.
* feat: wire the Tailwind theme-token webpack plugin when present Gates GenerateTailwindThemePlugin (from @rtcamp/wp-tooling) on the entry file src/css/frontend/tailwind.css, guard-requiring wp-tooling so the build still works when it is absent. Dormant until the Tailwind feature creates the entry. * feat(scaffold): add Tailwind CSS opt-in feature Toggleable in manage mode: copies the entry CSS + PostCSS config and adds the tailwindcss / @tailwindcss/postcss devDeps; detected via the entry file. The build side lives in webpack.config.js. * docs(tailwind): fix stale default-enablement comments functions.php now defaults ELEMENTARY_THEME_ENABLE_TAILWIND to false (the scaffold feature flips it); the webpack token plugin is still entry-file gated at build time, and the wp-tooling catch only skips that plugin, not Tailwind compilation. * fix(tailwind): consume @rtcamp/tailwind-config and gate enqueue at runtime * feat: toggle HMR (BrowserSync) via ENABLE_HMR (#719) * feat(scaffold): add HMR enable/disable feature HMR (BrowserSync live reload) is now a toggleable feature, gated on a single ENABLE_HMR flag in .env.local that both the build and PHP read: - webpack only starts the BrowserSync server when ENABLE_HMR is not off - Assets.php only enqueues the client under the same flag - the scaffold feature flips ENABLE_HMR in .env.local on enable/disable Default is on, so existing setups are unaffected. browser-sync deps stay installed (they are dev-only), so the toggle is a fast local switch. DISABLE_BS still works for the finer client-only case. Toggle from `npm run init` (manage mode) or by editing .env.local directly. * test(hmr): cover ENABLE_HMR master switch and DISABLE_BS override Mirror the plugin skeleton's AssetsHmrTest so the theme's HMR feature has the same coverage. Exercises the two private env-flag helpers in Assets via a fresh instance per case (each re-reads .env.local): - is_hmr_enabled(): defaults on when ENABLE_HMR is absent, off for 0/false/no/off (case-insensitive), on for 1/true/yes/on - is_browser_sync_disabled(): independent of HMR; off by default, on for truthy DISABLE_BS Backs up and restores any real .env.local so the developer's file is left untouched. * test(hmr): isolate env reads from the real .env.local * feat(scaffold): mark example sets for selective removal (#720) Mark the demo modules (media-text block extension, theme options, author bio), example components and page-creation pattern with grouped wp:example markers so init can drop selected sets while keeping the rest. The three Main.php modules use keyed markers to scope their shared regions. --------- Co-authored-by: Aditya Singh <adityasinghboss1234@gmail.com> --------- Co-authored-by: Aditya Singh <adityasinghboss1234@gmail.com>
* feat: add AI skills, Logger service, and graphify knowledge graph Port the AI-tooling layer from the features-plugin-skeleton, reworded for this theme: init/scaffold/setup skills + Copilot prompts, graphify scripts and committed graph, and an inc/Core/Logger service with Util accessors. * docs: add quick-start and internal-testing guides
Resolve conflicts keeping both sides: - Main.php: Logger (scaffold-engine) + FeatureRegistry/FeaturesSettingsPage (v2); example markers preserved - Util.php: both logger() and FeatureRegistry accessors - Assets.php: v2 handle()/HANDLE_PREFIX + scaffold-engine HMR master switch + lazy tailwind - composer.lock: regenerated against merged composer.json
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.