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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
4 changes: 4 additions & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
engine-strict=true

# Supply-chain cooldown: never install an npm package version published less
# than this many days ago (npm >= 11.10). Deliberate updates bump the pins.
min-release-age=30
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
24.12.0
24.18.0
37 changes: 37 additions & 0 deletions bin/register-bsuwordpresscs.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php
/**
* Register the BSUWordPressCS standard with PHP_CodeSniffer.
*
* The dealerdirect composer installer regenerates CodeSniffer.conf on every
* composer install/update and only registers composer-installed standards, so
* the consumer-side BSUWordPressCS path is dropped each time. This composer
* post-install/post-update hook re-appends it, so consuming repos can resolve
* the BSUWordPressCS standard by name.
*
* The path is relative to the phpcs directory (vendor/squizlabs/php_codesniffer),
* reaching @bsu/BSUWordPressCS installed as a sibling in the consumer's
* node_modules/@bsu/.
*/

$phpcs = __DIR__ . '/../vendor/bin/phpcs';
$bsu_path = '../../../../BSUWordPressCS';

if ( ! is_file( $phpcs ) ) {
return;
}

/* Read the installed_paths phpcs currently knows about. */
$show = (string) shell_exec( escapeshellarg( PHP_BINARY ) . ' ' . escapeshellarg( $phpcs ) . ' --config-show 2>/dev/null' );
preg_match( '/installed_paths:\s*(.*)/', $show, $match );
$paths = array_values( array_filter( array_map( 'trim', explode( ',', $match[1] ?? '' ) ) ) );

/* Nothing to do if it is already registered. */
if ( in_array( $bsu_path, $paths, true ) ) {
echo "BSUWordPressCS already registered in phpcs installed_paths.\n";
return;
}

/* Append it and write the config back through phpcs itself. */
$paths[] = $bsu_path;
shell_exec( escapeshellarg( PHP_BINARY ) . ' ' . escapeshellarg( $phpcs ) . ' --config-set installed_paths ' . escapeshellarg( implode( ',', $paths ) ) . ' 2>/dev/null' );
echo "Registered BSUWordPressCS in phpcs installed_paths.\n";
17 changes: 11 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,21 @@
{
"require-dev": {
"wp-coding-standards/wpcs": "3.2.0",
"phpcsstandards/php_codesniffer": "^4.0",
"phpstan/phpstan": "^2.0",
"phpstan/extension-installer": "^1.4",
"szepeviktor/phpstan-wordpress": "^2.0",
"php-stubs/acf-pro-stubs": "^6.0"
"squizlabs/php_codesniffer": "3.13.5",
"wp-coding-standards/wpcs": "3.3.0",
"phpstan/phpstan": "2.2.2",
"phpstan/extension-installer": "1.4.3",
"szepeviktor/phpstan-wordpress": "2.0.3",
"php-stubs/acf-pro-stubs": "6.8.2",
"phpunit/phpunit": "12.5.29"
},
"config": {
"allow-plugins": {
"dealerdirect/phpcodesniffer-composer-installer": true,
"phpstan/extension-installer": true
}
},
"scripts": {
"post-install-cmd": "@php bin/register-bsuwordpresscs.php",
"post-update-cmd": "@php bin/register-bsuwordpresscs.php"
}
}
Loading