Skip to content

CLI: Fix --login option and "landingPage" Blueprint property #2344

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 12 commits into from
Jul 22, 2025
26 changes: 17 additions & 9 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -237,16 +237,24 @@ jobs:
run: |
source ~/.nvm/nvm.sh;
nvm install 22;
cd $HOST_PATH
RUNNER_TRACKING_ID="" && ( \
nohup node \
--experimental-strip-types \
--experimental-transform-types \
--import ./packages/meta/src/node-es-module-loader/register.mts \
./packages/playground/cli/src/cli.ts server \
--port=$PORT \
--mount="$HOST_PATH:/wordpress/$VERSION" \
--quiet& \
)
nohup python3 -c "import http.server
import socketserver
from urllib.parse import unquote

class PrefixHTTPRequestHandler(http.server.SimpleHTTPRequestHandler):
def do_GET(self):
if self.path.startswith('/${{ env.VERSION }}/'):
self.path = self.path[len('/${{ env.VERSION }}'):]
elif self.path == '/${{ env.VERSION }}':
self.path = '/'
super().do_GET()

with socketserver.TCPServer(('127.0.0.1', ${{ env.PORT }}), PrefixHTTPRequestHandler) as httpd:
httpd.serve_forever()
"&
);
- name: Wait for the package server to be ready
run: |
for i in {1..60}; do
Expand Down
23 changes: 23 additions & 0 deletions packages/playground/cli/src/run-cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,7 @@ export async function runCLI(args: RunCLIArgs): Promise<RunCLIServer> {
const fileLockManager = new FileLockManagerForNode(nativeFlockSync);

let wordPressReady = false;
let isFirstRequest = true;

logger.log('Starting a PHP server...');

Expand Down Expand Up @@ -537,6 +538,28 @@ export async function runCLI(args: RunCLIArgs): Promise<RunCLIServer> {
'WordPress is not ready yet'
);
}
// Clear the playground_auto_login_already_happened cookie on the first request.
// Otherwise the first Playground CLI server started on the machine will set it,
// all the subsequent runs will get the stale cookie, and the auto-login will
// assume they don't have to auto-login again.
if (isFirstRequest) {
isFirstRequest = false;
const headers: Record<string, string[]> = {
'Content-Type': ['text/plain'],
'Content-Length': ['0'],
Location: ['/'],
};
if (
request.headers?.['cookie']?.includes(
'playground_auto_login_already_happened'
)
) {
headers['Set-Cookie'] = [
'playground_auto_login_already_happened=1; Max-Age=0; Expires=Thu, 01 Jan 1970 00:00:00 GMT; Path=/',
];
}
return new PHPResponse(302, headers, new Uint8Array());
}
return await loadBalancer.handleRequest(request);
},
});
Expand Down
2 changes: 1 addition & 1 deletion packages/playground/cli/tests/test-running-unbuilt-cli.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ function test_playground_cli() {
echo "Playground CLI started successfully"
echo "Checking WordPress home page..."

HOME_PAGE_OUTPUT="$(curl -s http://127.0.0.1:9400 || echo 'No output')"
HOME_PAGE_OUTPUT="$(curl -sL http://127.0.0.1:9400 || echo 'No output')"
if [[ $HOME_PAGE_OUTPUT != *"My WordPress Website"* ]]; then
echo "Home page output: $HOME_PAGE_OUTPUT"
echo "Error: Home page did not contain 'My WordPress Website'"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ SupportedPHPVersions.forEach((phpVersion: string) => {
} finally {
await cli[Symbol.asyncDispose]();
}
}, 10000);
}, 22000);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ if (!SupportedPHPVersions.includes(phpVersion)) {
}

describe(`PHP ${phpVersion}`, () => {
it('Should load WordPress', { timeout: 12000 }, async () => {
it('Should load WordPress', { timeout: 22000 }, async () => {
const cli = await runCLI({
command: 'server',
php: phpVersion,
Expand Down
Loading