Repository navigation
feat(blocks): Gutenberg custom block scaffolder (v2.0.0) - #107
Merged
Merged
Conversation
Ship the v2.0.0 "Gutenberg custom block scaffolding" milestone. scripts/scaffold-block.sh generates a self-contained, immediately activatable block plugin under plugins/<name>/ with no build step (WordPress runtime globals + an index.asset.php that declares the package dependencies, mirroring the featured-event reference block). Inputs: block name, --namespace (block.json name <ns>/<name>), and --attributes "name:type[:default]" (string|number|boolean|array|object), wired into block.json, editor controls, save markup and render. --dynamic adds a server-side render.php callback. Outputs: block.json, index.js (edit + save), index.asset.php, editor.css, style.css, render.php (dynamic only), a PHPUnit test stub + bootstrap, phpunit.xml.dist and a README. Also adds: - /scaffold-block slash command and pnpm run scaffold:block - scripts/smoke-block.sh (pnpm run smoke:block): scaffold -> activate -> assert registration -> render on a throwaway page against the Docker stack - docs/blocks/README.md - tests/unit/scaffold-block.bats (13 cases) + .github/workflows/block-validation.yml (bats job + PHP lint/PHPUnit job for both static and dynamic output) Verified: full WP E2E smoke test 8/8; generated PHPUnit stubs green (dynamic 3/10, static 2/7); php -l, node --check and JSON validation clean. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
5 tasks
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.
Summary
Ships the v2.0.0 "Gutenberg custom block scaffolding" milestone: a generator that turns a block name + namespace + attribute spec into a complete, immediately activatable custom block plugin — with no build step required.
scripts/scaffold-block.shemits a self-contained plugin underplugins/<name>/. The generatedindex.jsuses the WordPress runtime globals andindex.asset.phpdeclares the package dependencies, mirroring the existingfeatured-eventreference block.Acceptance criteria
/scaffold-block(orpnpm run scaffold:block) accepts: block name, namespace, supported attributesblock.json, edit + save JS, optional dynamic render callback (--dynamic→render.php+"render"field)tests/bootstrap.php,phpunit.xml.dist)docs/blocks/scripts/smoke-block.sh)Inputs
--namespacename=<namespace>/<block-name>--attributes "name:type[:default]"--dynamic/--staticrender.phpPlus
--title/--description/--category/--icon/--keywords/--text-domain/--php-namespace/--version/--dest/--force/--dry-run.Outputs
Verification (actually run)
flavian/smoke-callout) and rendered on a real page with the correct wrapper class + attribute value, then cleaned up.loadquirk that doesn't affect CI).php -l,node --check, and JSON validation clean.Also included
/scaffold-blockslash command +pnpm run scaffold:block/pnpm run smoke:block.github/workflows/block-validation.yml— bats job + PHP lint/PHPUnit job (static & dynamic)Test plan
🤖 Generated with Claude Code