dev について
devは、WordPress ActivityPubプラグインの開発ワークフローをまとめたスキルです。環境管理、テスト、コードチェック、ビルドのコマンドに加え、デバッグ、カバレッジ、コミット前の手順を開発者向けに説明します。
主な機能
- 01WordPress環境の起動と停止
- 02PHPおよびE2Eテストのコマンド
- 03PHP、JavaScript、CSSのチェック
- 04アセットのビルドと開発時の監視
- 05カバレッジとデバッグの参照情報
- 06自動プリコミットフックの説明
活用シーン
- 01ローカルのWordPress開発環境を起動
- 02個別テストまたは全テストを実行
- 03コードをチェックしてアセットをビルド
- 04失敗したテストを調べてコミットを準備
インストール
コマンドをコピーしてターミナルで実行します。
npx skills add https:/ / github.com/ automattic/ wordpress-activitypub --skill devインストール後、Claude Code で/devを入力して読み込まれたか確認します。
詳細
ActivityPub 開発サイクル
WordPress ActivityPub プラグインでよく使う開発ワークフローのクイックリファレンスです。
クイックリファレンス
環境管理
npm run env-start # Start WordPress at http://localhost:8888.
npm run env-stop # Stop WordPress environment.
テストコマンド
npm run env-test # Run all PHP tests.
npm run env-test -- --filter=pattern # Run tests matching pattern.
npm run env-test -- path/to/test.php # Run specific test file.
npm run env-test -- --group=name # Run tests with @group annotation.
npm run test:e2e # Run Playwright E2E tests.
npm run test:e2e:debug # Debug E2E tests.
コード品質
composer lint # Check PHP coding standards.
composer lint:fix # Auto-fix PHP issues.
npm run lint:js # Check JavaScript.
npm run lint:css # Check CSS styles.
npm run format # Format all code (wp-scripts).
アセットのビルド
npm run build # Build for production (formatted and minified).
npm run dev # Start development watch mode.
コードカバレッジ
npm run env-start -- --xdebug=coverage # Start with coverage support.
npm run env-test -- --coverage-text # Generate text coverage report.
npm run env-test -- --coverage-html ./coverage # Generate HTML report.
詳細ドキュメント
詳しいセットアップ手順については、docs/development-environment.md を参照してください。
包括的なテストガイドについては、tests/README.md を参照してください。
Lint 設定と標準については、docs/code-linting.md を参照してください。
コミット前フック
このリポジトリでは、自動コミット前フック(.githooks/pre-commit)を使用しており、git commit の実行時に自動で動作します。
- PHP のインポートを並べ替え - use 文を自動的に整理します。
- 未使用のインポートを確認 - 未使用の use 文を防ぎます。
- テストパターンを検証 -
remove_all_filters('pre_http_request')をブロックします。 - PHPCS の自動修正を実行 - コーディング標準を自動的に適用します。
- JavaScript をフォーマット - wp-scripts のフォーマッターを実行します。
重要: フックはステージ済みのファイルを自動的に変更します。コミット前に必ず変更内容を確認してください。フックによって変更が加えられた場合は、再度ステージしてコミットする必要があります。
セットアップ: フックは npm run prepare によってインストールされます(npm install の後に自動で実行されます)。
よく使う開発ワークフロー
初期セットアップ
git clone [email protected]:Automattic/wordpress-activitypub.git
cd wordpress-activitypub
npm install # Also runs 'npm run prepare' to install hooks.
composer install
npm run env-start # WordPress at http://localhost:8888.
変更を加えるワークフロー
# 1. Make code changes.
# 2. Run relevant tests.
npm run env-test -- --filter=FeatureName
# 3. Check code quality (optional - pre-commit hook does this).
composer lint
npm run lint:js
# 4. Commit (pre-commit hook runs automatically).
git add .
git commit -m "Description"
# Hook may modify files - review and stage again if needed.
管理画面アプリが、ビルド時に wp.* グローバルへ外部化される @wordpress/* パッケージからインポートする場合は、node_modules ではなく、プラグインの最低 WordPress バージョンに同梱されているもの(wp-includes/js/dist/<package>.js、またはブラウザーでの typeof wp.<package>.<name>)にそのエクスポートがあるか確認してください。新しい npm バージョンでは、同梱されているグローバルには存在しない名前がエクスポートされることがあります。
PR 作成前
# Run full test suite.
npm run env-test
# Build assets.
npm run build
# Final lint check.
composer lint
npm run lint:js
テスト失敗時のデバッグ
# Run with verbose output.
npm run env-test -- --verbose --filter=test_name
# Run single test file to isolate issue.
npm run env-test -- tests/phpunit/tests/path/to/test.php
# Check test groups.
npm run env-test -- --list-groups
npm run env-test -- --group=specific_group
クリーンな環境
npm run env-stop
npm run env-start
# wp-env automatically sets up WordPress with debug mode and test users.
主要ファイル
package.json- npm スクリプトと依存関係。composer.json- PHP の依存関係と Lint スクリプト。.wp-env.json- wp-env の設定。phpcs.xml- PHP コーディング標準(カスタム WordPress ルール)。.githooks/pre-commit- コミット前の自動処理。