Skip to content

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

Open
aryanjasala wants to merge 8 commits into
theme-elementary-v2from
feat/scaffold-engine
Open

feat(scaffold): delegate theme setup to the shared wp-framework engine#716
aryanjasala wants to merge 8 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.

@Adi-ty Adi-ty self-assigned this Jun 23, 2026
@Adi-ty Adi-ty requested a review from AnuragVasanwala June 23, 2026 16:10
@Adi-ty Adi-ty marked this pull request as ready for review June 23, 2026 16:11

@aryanjasala aryanjasala left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

LGTM

@AnuragVasanwala AnuragVasanwala left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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>
Adi-ty and others added 2 commits June 24, 2026 12:51
* 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
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.

4 participants