When developing features that require changes to WordPress Playground packages (@wp-playground/* or @php-wasm/*), you can test Studio's CLI with locally built Playground packages.
Note: The desktop app does not directly use PHP-WASM packages - only the CLI does. These instructions are for testing CLI functionality.
Clone the WordPress Playground repository alongside the Studio repository:
Code/
├── studio/
└── wordpress-playground/
Important: Make sure to initialize git submodules:
cd /path/to/wordpress-playground
git submodule update --init --recursivecd /path/to/wordpress-playground
npm install
npm run buildReplace the existing Playground dependencies in apps/cli/package.json with local file references:
{
"dependencies": {
"@php-wasm/universal": "file:../../wordpress-playground/dist/packages/php-wasm/universal",
"@wp-playground/blueprints": "file:../../wordpress-playground/dist/packages/playground/blueprints",
"@wp-playground/cli": "file:../../wordpress-playground/dist/packages/playground/cli",
"@wp-playground/common": "file:../../wordpress-playground/dist/packages/playground/common",
"@wp-playground/storage": "file:../../wordpress-playground/dist/packages/playground/storage"
}
}Playground's built packages import other packages from node_modules. By default, these point to source directories, but we need them to point to the built dist/ packages.
Run this from the wordpress-playground root:
cd /path/to/wordpress-playground
for pkg in node-polyfills logger util progress fs-journal stream-compression scopes universal node web web-service-worker cli xdebug-bridge; do
if [ -d "dist/packages/php-wasm/$pkg" ]; then
rm -rf "node_modules/@php-wasm/$pkg" && ln -s "../../dist/packages/php-wasm/$pkg" "node_modules/@php-wasm/$pkg"
fi
done
for pkg in cli blueprints wordpress common storage client remote components wordpress-builds; do
if [ -d "dist/packages/playground/$pkg" ]; then
rm -rf "node_modules/@wp-playground/$pkg" && ln -s "../../dist/packages/playground/$pkg" "node_modules/@wp-playground/$pkg"
fi
donecd /path/to/studio
rm -rf apps/cli/node_modules
npm --prefix apps/cli install
npm installnpm run cli:build
node apps/cli/dist/cli/main.mjs site create --name test-siteIf you want to test the full desktop app with CLI changes:
npm startAfter making changes to Playground:
-
Rebuild the changed package(s):
cd /path/to/wordpress-playground npx nx build playground-cli # or other package name
-
Rebuild the CLI:
cd /path/to/studio npm run cli:build -
If testing with the desktop app, restart
npm start
To go back to using the published npm packages:
- Restore
apps/cli/package.json:git checkout apps/cli/package.json
- Reinstall CLI dependencies:
rm -rf apps/cli/node_modules npm --prefix apps/cli install
- In the Playground repo, restore the original
node_modulessymlinks:cd /path/to/wordpress-playground npm install