Skip to content

Issue-544: Fix the configure script's search and replace - #547

Draft
mogmarsh wants to merge 1 commit into
feature/issue-544/tests-for-configure-php-regressionsfrom
feature/issue-544/fix-configure-php-replacements
Draft

mogmarsh wants to merge 1 commit into
feature/issue-544/tests-for-configure-php-regressionsfrom
feature/issue-544/fix-configure-php-replacements

Conversation

@mogmarsh

@mogmarsh mogmarsh commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

Stacked on #546 — the base branch is feature/issue-544/tests-for-configure-php-regressions, so review that one first (or read the diff against it).

The tests in #546 documented five defects in configure.php. This fixes them and turns those characterization assertions into assertions of the intended behavior.

The fixes

Replacing alleyinteractive everywhere rewrote every reference to Alley's other packages. For any vendor other than Alley, a scaffolded plugin got a composer.json that cannot install (test-vendor/composer-wordpress-autoloader, test-vendor/wp-type-extensions, test-vendor/alley-coding-standards), workflows pointing at uses: test-vendor/action-test-php@develop, and rewritten links to Alley's docs. The map now replaces alleyinteractive/create-wordpress-plugin — this skeleton's own repository — ahead of the slug rule, so everything else survives. composer install --dry-run in a configured copy now resolves cleanly. The one spot that legitimately wanted the vendor on its own (the composer.json keyword) uses a new vendor_slug placeholder.

The bare Create_WordPress_Plugin token was never replaced, only the fully-qualified namespace, so it survived in scaffold/config.json's "namespace", src/features/README.md, the README usage example and CLAUDE.md. It now maps to the last segment of the namespace, using the str_after() helper that was already in the file but unused. The two spots that actually meant the text domain became create-wordpress-plugin, the README example was missing its namespace root, and CLAUDE.md now points at the replacement map instead of restating tokens that the map then rewrites. The JSON-escaped namespace rule also lost its trailing-\\ requirement so it matches both the …\\Tests\\ and …\\ forms.

.scaffolder was excluded from the search and replace entirely, so npm run scaffold in a configured plugin generated features in Alley\WP\Create_WordPress_Plugin\Features. It is included now. The generated test template also referenced Create_WordPress_Plugin\Tests\TestCase, a namespace root that never existed — broken in the skeleton too — now Alley\WP\Create_WordPress_Plugin\Tests\TestCase.

The parent-project rollup could not remove the Composer loader. Confirming Composer ran remove_composer_wrapper_comments(), which strips the /* Start|End Composer Loader */ markers that remove_composer_require() later matches on, so the rollup left the loader in place while printing that it had removed it. The comments are now stripped once at the end of the run, after every prompt that can remove the loader outright, and the function returns early when the markers are already gone.

remove_phpstan() left scripts.lint as a JSON object ({"0": "@phpcs", "2": "@rector"}) because array_filter preserves keys.

Two more while in there:

  • The PHPCS global prefix came from the vendor's display name, so .phpcs.xml ended up with <element value="Test Vendor" /> — not a usable prefix. It now uses a vendor_prefix token (test_vendor).
  • remove_configure_test() re-encoded composer.json, which would have reindented every scaffolded plugin's composer.json from two spaces to four. It now drops its two lines textually, falling back to a rewrite only if that would leave invalid JSON.

Tests

test_documents_the_placeholders_that_are_left_behind is gone, replaced by three tests of the real behavior: test_keeps_references_to_third_party_packages, test_replaces_the_skeletons_own_repository and test_replaces_the_placeholders_in_the_scaffolder_templates. Create_WordPress_Plugin, vendor_slug and vendor_prefix joined the placeholder scan, .scaffolder/ came off the untouched list, the rollup test asserts the loader is gone, and the PHPStan test asserts scripts.lint === ['@phpcs', '@rector'].

21 tests / 285 assertions pass, composer lint is clean, and the Mantle suite still passes. Each of the five fixes was mutated back to its broken form one at a time to confirm the suite catches it.

🤖 Generated with Claude Code

@mogmarsh
mogmarsh force-pushed the feature/issue-544/fix-configure-php-replacements branch from c8d3f2d to 6ee89d7 Compare September 9, 2026 21:16
@mogmarsh
mogmarsh force-pushed the feature/issue-544/tests-for-configure-php-regressions branch from d82ba1b to 41dbfe8 Compare September 9, 2026 21:31
@mogmarsh
mogmarsh force-pushed the feature/issue-544/fix-configure-php-replacements branch from 6ee89d7 to 1bc2192 Compare September 9, 2026 21:32
@mogmarsh
mogmarsh force-pushed the feature/issue-544/tests-for-configure-php-regressions branch from 41dbfe8 to 914359f Compare September 9, 2026 21:34
The tests added in the previous commit documented five defects in
configure.php. This fixes them and turns those characterization
assertions into assertions of the intended behavior.

- Replacing `alleyinteractive` everywhere rewrote every reference to
  Alley's other packages when the vendor was someone else, producing a
  composer.json that cannot install (`test-vendor/wp-type-extensions`)
  and workflows that reference actions that do not exist. Replace
  `alleyinteractive/create-wordpress-plugin` — this skeleton's own
  repository — instead, and add a `vendor_slug` placeholder for the one
  remaining spot that wants the vendor on its own.
- The bare `Create_WordPress_Plugin` token was only replaced as part of
  the full namespace, so it survived in `scaffold/config.json`, the
  feature docs and the README. Replace it with the last segment of the
  namespace, and fix the two places that meant the text domain instead.
- The `.scaffolder` templates were excluded from the search and replace
  entirely, so scaffolded features landed in the skeleton's namespace.
  Include them, and give the generated test the namespace root it was
  missing.
- The parent project rollup could not remove the Composer loader,
  because confirming Composer had already stripped the comments that
  mark it. Strip those comments at the end of the run instead.
- `remove_phpstan()` left `scripts.lint` as a JSON object with a gap in
  its keys rather than a list.

Also use the vendor prefix, not the vendor's display name, for the
PHPCS global prefix, and remove the `test:configure` script without
reformatting the rest of composer.json.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@mogmarsh
mogmarsh force-pushed the feature/issue-544/fix-configure-php-replacements branch from 1bc2192 to 5539961 Compare September 9, 2026 21:34
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.

1 participant