Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions node-packages/wp-tooling/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
- fill `testVersion` from the `Requires PHP` header (PHPCompatibility aborts on the first line of every file without it), `minimum_wp_version` from `Requires at least`, the text domain from `Text Domain`, and the prefixes from the text domain and the PSR-4 namespace;
- accept PSR-4 class file names, and exempt block `render.php` files from the global-variable prefix and text-domain-mismatch checks, since core includes them inside a function and they translate with `block.json`'s text domain;
- lint `tests/`, exempting it from the prefix, VIP file-operation and remote-data, `ini_set` and global-override rules by sniff name. An exclude-pattern on a re-referenced standard such as `WordPress-Docs` has no effect, because its sniffs are already loaded;
- declare `rtcamp/wp-phpcs` as the only dev dependency, with two `composer.json` wiring entries without which `composer require` fails: the `rtCamp/wp-phpcs` VCS repository, so the install works whether or not Packagist serves the package, and `allow-plugins` for the Composer installer that registers the standards.
- declare `rtcamp/wp-phpcs` as the only dev dependency, with one `composer.json` wiring entry without which `composer require` fails: `allow-plugins` for the Composer installer that registers the standards. The package itself resolves from Packagist.

Every PHP file the bundled `wp/*`, `wp-api/*` and `setup/phpunit` scaffolds render (classes, tests and the PHPUnit bootstrap), and the five `utility/*` accessor snippets, passes both.
- `automattic/vipwpcs` as `lint/phpcs/vip`'s dev dependency, with `allow-plugins` wiring for `dealerdirect/phpcodesniffer-composer-installer`, which WPCS and VIPCS depend on: without it a non-interactive `composer require` exits 1 and no standard is registered. The `setup` skill's install command and `docs/examples.md` use the same package.
Expand All @@ -49,7 +49,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
- PHPCS scaffolds exclude intentionally broken AI evaluation fixtures. The standalone server profiler uses short arrays and documents the specific PHPCS exceptions required by WP-CLI evaluation, privileged CLI query data and STDERR diagnostics.
- Feature hooks: `readEnv`/`setEnv` and `readDefine`/`setDefine` treat the key or define name as a literal. They were interpolated into a regular expression, so a name containing `.` or another metacharacter could read or flip a different line.
- `wp-tooling features`: when `npm install` fails after enabling a feature, the retry commands it prints no longer put runtime dependencies under `--save-dev`, and a failed interactive change reads "Failed to enable <id>" rather than "Failed to enabling <id>".
- `lint/eslint`, `lint/stylelint` and `setup/tailwind` asked for `@rtcamp/eslint-config`, `@rtcamp/stylelint-config` and `@rtcamp/tailwind-config` at `^0.1.0` from the npm registry. None of them was on the registry at that version (all three returned 404 when this was fixed), so `npm install` failed, and `features --enable tailwind --record-deps` wrote a spec into package.json that broke the project's next `npm install`. They now use the git specs the skeletons already use (`github:rtCamp/wp-tooling#npm/<package>`).
- `lint/eslint`, `lint/stylelint` and `setup/tailwind` asked for `@rtcamp/eslint-config`, `@rtcamp/stylelint-config` and `@rtcamp/tailwind-config` at `^0.1.0` from the npm registry. None of them was on the registry at that version (all three returned 404 when this was fixed), so `npm install` failed, and `features --enable tailwind --record-deps` wrote a spec into package.json that broke the project's next `npm install`. They now ask for `^1.1.0`, the first release on the registry.
- `lint/phpcs/full` now extends `rtCampWP-Basic` from `rtcamp/wp-phpcs` (and reports it plus `dealerdirect/phpcodesniffer-composer-installer` as dev dependencies) instead of `vendor/rtcamp/wp-framework/phpcs.xml.dist`. The framework export-ignores that file, so every dist install, the Composer default, ended up with a ruleset pointing at a file that was not there. The generated ruleset also sets `testVersion` to `8.2-`, which PHPCompatibilityWP needs.
- `detect-changes --output github` and `coverage-gate --output github` write multi-line outputs under a random per-output heredoc delimiter instead of the fixed `EOF_WP_TOOLING`. The file lists come from the pull request, so a PR adding a file named `EOF_WP_TOOLING` followed by one named `php-count=0` could close the heredoc early and override the real count, skipping the PHP jobs.
- `discover_from: composer.json:autoload.psr-4` now resolves **path** inputs (`base_path`, `*_path`, `*_dir`) from the map entry's directory instead of skipping them, grafted the same way namespaces already were — with a root of `Acme\Blog\` → `inc/`, a `base_path` default of `includes/Services` resolves to `inc/Services`. Previously the namespace was grafted but the directory kept the manifest default, so any project not laid out under `includes/` got a correctly-namespaced class written outside its autoload root, where it never loaded. Affects the 12 bundled scaffolds that declare PSR-4 discovery on `base_path`. Projects already using `includes/`, projects without a `composer.json`, and callers that pass `--base_path` explicitly are unaffected.
Expand Down
2 changes: 1 addition & 1 deletion node-packages/wp-tooling/docs/examples.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ npx wp-tooling add wp/cli --non-interactive --json --cwd . --name=im

**Developer:** yes.

> For `lint/phpcs/full`, `rtcamp/wp-phpcs` is not on Packagist, so I would add its GitHub repository to `repositories` and allow `dealerdirect/phpcodesniffer-composer-installer` under `config.allow-plugins` in `composer.json`.
> For `lint/phpcs/full`, I would allow `dealerdirect/phpcodesniffer-composer-installer` under `config.allow-plugins` in `composer.json`, the Composer plugin that registers the PHPCS standards.
>
> Apply? [yes / skip]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"npm_dev_dependencies": {
"eslint": "^10.0.0",
"@wordpress/eslint-plugin": "^25.1.0",
"@rtcamp/eslint-config": "github:rtCamp/wp-tooling#npm/eslint-config"
"@rtcamp/eslint-config": "^1.1.0"
},
"scripts": {
"npm": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,6 @@
}
],
"wiring": [
{
"target_file": "composer.json",
"anchor": "\"repositories\"",
"snippet_template": "\"repositories\": [\n {\n \"type\": \"vcs\",\n \"url\": \"https://github.com/rtCamp/wp-phpcs.git\",\n \"no-api\": true\n }\n]",
"description": "rtcamp/wp-phpcs is not on Packagist, so Composer only finds it through this repository. Add the entry to the existing repositories array unless the URL is already there, or create the array. Apply before installing the package."
},
{
"target_file": "composer.json",
"anchor": "\"allow-plugins\"",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,6 @@
}
],
"wiring": [
{
"target_file": "composer.json",
"anchor": "\"repositories\"",
"snippet_template": "\"repositories\": [\n {\n \"type\": \"vcs\",\n \"url\": \"https://github.com/rtCamp/wp-phpcs.git\",\n \"no-api\": true\n }\n]",
"description": "rtcamp/wp-phpcs is not on Packagist, so Composer only finds it through this repository. Add the entry to the existing repositories array unless the URL is already there, or create the array. Apply before installing the package."
},
{
"target_file": "composer.json",
"anchor": "\"allow-plugins\"",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"stylelint": "^16.8.2",
"@wordpress/stylelint-config": "^23.37.0",
"stylelint-scss": "^6.4.0",
"@rtcamp/stylelint-config": "github:rtCamp/wp-tooling#npm/stylelint-config"
"@rtcamp/stylelint-config": "^1.1.0"
},
"scripts": {
"npm": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -265,12 +265,7 @@ Create it? [yes / skip PSR-4 / give me the values to use]

### Wiring: composer.json for PHPCS

The `lint/phpcs/*` wiring entries must be in `composer.json` before the developer runs `composer require`, or the install fails:

1. `repositories` (`full` and `core` only) — a `vcs` entry for `https://github.com/rtCamp/wp-phpcs.git`, since `rtcamp/wp-phpcs` is not on Packagist. Append it to an existing array; skip it if that URL is already listed. `vip` needs none: `automattic/vipwpcs` is on Packagist.
2. `config.allow-plugins` (all three) — `dealerdirect/phpcodesniffer-composer-installer: true`, the plugin that registers the standards. Merge it into an existing `config` block.

Show the changes together, ask once, and merge rather than replace existing keys.
All three `lint/phpcs/*` scaffolds need one wiring entry in `composer.json` before the developer runs `composer require`, or the install fails: `config.allow-plugins` with `dealerdirect/phpcodesniffer-composer-installer: true`, the plugin that registers the standards. Merge it into an existing `config` block rather than replacing it, and ask once.

### Wiring: feature scaffolds

Expand Down Expand Up @@ -315,7 +310,7 @@ Developer actions (run these yourself):
npm install --save-dev \
eslint@^10.0.0 \
@wordpress/eslint-plugin@^25.1.0 \
@rtcamp/eslint-config@github:rtCamp/wp-tooling#npm/eslint-config
@rtcamp/eslint-config@^1.1.0

Scripts to add to composer.json:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"gitignore": [ "{{css_dir}}/_tailwind-theme.css" ]
},
"npm_dev_dependencies": {
"@rtcamp/tailwind-config": "github:rtCamp/wp-tooling#npm/tailwind-config",
"@rtcamp/tailwind-config": "^1.1.0",
"tailwindcss": "^4.3.0",
"@tailwindcss/postcss": "^4.3.0"
}
Expand Down
9 changes: 2 additions & 7 deletions node-packages/wp-tooling/skills/setup/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -265,12 +265,7 @@ Create it? [yes / skip PSR-4 / give me the values to use]

### Wiring: composer.json for PHPCS

The `lint/phpcs/*` wiring entries must be in `composer.json` before the developer runs `composer require`, or the install fails:

1. `repositories` (`full` and `core` only) — a `vcs` entry for `https://github.com/rtCamp/wp-phpcs.git`, since `rtcamp/wp-phpcs` is not on Packagist. Append it to an existing array; skip it if that URL is already listed. `vip` needs none: `automattic/vipwpcs` is on Packagist.
2. `config.allow-plugins` (all three) — `dealerdirect/phpcodesniffer-composer-installer: true`, the plugin that registers the standards. Merge it into an existing `config` block.

Show the changes together, ask once, and merge rather than replace existing keys.
All three `lint/phpcs/*` scaffolds need one wiring entry in `composer.json` before the developer runs `composer require`, or the install fails: `config.allow-plugins` with `dealerdirect/phpcodesniffer-composer-installer: true`, the plugin that registers the standards. Merge it into an existing `config` block rather than replacing it, and ask once.

### Wiring: feature scaffolds

Expand Down Expand Up @@ -315,7 +310,7 @@ Developer actions (run these yourself):
npm install --save-dev \
eslint@^10.0.0 \
@wordpress/eslint-plugin@^25.1.0 \
@rtcamp/eslint-config@github:rtCamp/wp-tooling#npm/eslint-config
@rtcamp/eslint-config@^1.1.0

Scripts to add to composer.json:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -949,29 +949,23 @@ describe.each([
});
});

it('wires the repository and plugin permission Composer needs to install it', async () => {
it('wires only the plugin permission Composer needs to install it', async () => {
const result = await registry.execute(
id,
{},
{ dryRun: true, cwd: makeTmpDir() }
);
const [repositories, allowPlugins] = result.ai.wiring;

expect(result.ai.wiring.map((w) => w.targetFile)).toEqual([
'composer.json',
'composer.json',
]);
// Not on Packagist: without this entry the require cannot resolve.
expect(JSON.parse(`{${repositories.snippet}}`).repositories).toEqual([
{
type: 'vcs',
url: 'https://github.com/rtCamp/wp-phpcs.git',
'no-api': true,
// rtcamp/wp-phpcs resolves from Packagist, so no repositories entry.
expect(result.ai.wiring).toHaveLength(1);
expect(result.ai.wiring[0].targetFile).toBe('composer.json');
expect(JSON.parse(`{${result.ai.wiring[0].snippet}}`)).toEqual({
config: {
'allow-plugins': {
'dealerdirect/phpcodesniffer-composer-installer': true,
},
},
]);
expect(
JSON.parse(`{${allowPlugins.snippet}}`).config['allow-plugins']
).toEqual({ 'dealerdirect/phpcodesniffer-composer-installer': true });
});
});

it('falls back to defaults and leaves out the namespace prefix without PSR-4', async () => {
Expand Down
Loading