Skip to content
Open
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 docs/design-docs/playground-cli-workflow.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ graph TB
RunCLI --> SetupMode{Setup Mode?}

SetupMode --> |Yes| RunBlueprint["Command run-blueprint<br/>Installs WP if needed<br/>Runs blueprint steps<br/>Process exits on completion"]
SetupMode --> |No| StartServer["Command server<br/>skipWordPressSetup true<br/>Keeps process running"]
SetupMode --> |No| StartServer["Command server<br/>wordpressInstallMode: install-from-existing-files-if-needed<br/>Keeps process running"]

RunBlueprint --> MountDirs["Mount Directories<br/>wordpress to site path<br/>internal studio mu-plugins<br/>internal shared mu-plugins"]

Expand Down Expand Up @@ -102,7 +102,7 @@ graph TB

StartProcess --> ForkChild["Fork utility process<br/>playground-server-process-child ts"]

ForkChild --> RunServer["runCLI with server command<br/>skipWordPressSetup true<br/>port assigned port<br/>mount paths"]
ForkChild --> RunServer["runCLI with server command<br/>wordpressInstallMode: install-from-existing-files-if-needed<br/>port assigned port<br/>mount paths"]

RunServer --> WaitReady[Wait for ready message]

Expand Down
377 changes: 179 additions & 198 deletions package-lock.json

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,9 @@
"@formatjs/intl-locale": "^3.4.5",
"@formatjs/intl-localematcher": "^0.5.4",
"@inquirer/prompts": "^7.10.1",
"@php-wasm/node": "^3.0.19",
"@php-wasm/scopes": "^3.0.19",
"@php-wasm/universal": "^3.0.19",
"@php-wasm/node": "^3.0.21",
"@php-wasm/scopes": "^3.0.21",
"@php-wasm/universal": "^3.0.21",
"@reduxjs/toolkit": "^2.7.0",
"@rive-app/react-canvas": "^4.12.0",
"@sentry/electron": "^6.5.0",
Expand All @@ -132,9 +132,9 @@
"@wordpress/dataviews": "^10.2.0",
"@wordpress/i18n": "^6.1.0",
"@wordpress/icons": "^11.1.0",
"@wp-playground/blueprints": "^3.0.19",
"@wp-playground/cli": "^3.0.19",
"@wp-playground/wordpress": "^3.0.14",
"@wp-playground/blueprints": "^3.0.21",
"@wp-playground/cli": "^3.0.21",
"@wp-playground/wordpress": "^3.0.21",
"archiver": "^6.0.1",
"atomically": "^2.0.3",
"cli-table3": "^0.6.5",
Expand Down
25 changes: 0 additions & 25 deletions patches/@wp-playground+wordpress+3.0.19.patch

This file was deleted.

25 changes: 25 additions & 0 deletions patches/@wp-playground+wordpress+3.0.21.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
diff --git a/node_modules/@wp-playground/wordpress/index.cjs b/node_modules/@wp-playground/wordpress/index.cjs
index 8c1f5c9..d2d29d5 100644
--- a/node_modules/@wp-playground/wordpress/index.cjs
+++ b/node_modules/@wp-playground/wordpress/index.cjs
@@ -352,7 +352,7 @@ function skip_whitespace($tokens) {
ob_clean();
echo false === $return_value ? '0' : '1';
ob_end_flush();
- `})).text!=="1")throw new Error("Failed to rewrite constants in wp-config.php.")}async function w(e,n){const t=a.joinPaths(n,"wp-config.php"),i={DB_NAME:"wordpress"};!e.fileExists(t)&&e.fileExists(a.joinPaths(n,"wp-config-sample.php"))&&await e.writeFile(t,await e.readFileAsBuffer(a.joinPaths(n,"wp-config-sample.php"))),await g(e,t,i,"skip")}async function L(e){const n=await m(e);return await $(n,e),n}async function $(e,n){var l,s;const t=await e.getPrimaryPhp();if((l=n.hooks)!=null&&l.beforeWordPressFiles&&await n.hooks.beforeWordPressFiles(t),n.wordPressZip&&await S(t,await n.wordPressZip),n.constants)for(const d in n.constants)t.defineConstant(d,n.constants[d]);n.dataSqlPath&&(t.defineConstant("DB_DIR",a.dirname(n.dataSqlPath)),t.defineConstant("DB_FILE",a.basename(n.dataSqlPath))),t.defineConstant("WP_HOME",n.siteUrl),t.defineConstant("WP_SITEURL",n.siteUrl),await w(t,e.documentRoot),(s=n.hooks)!=null&&s.beforeDatabaseSetup&&await n.hooks.beforeDatabaseSetup(t);let i=!1;n.sqliteIntegrationPluginZip&&(i=!0,await R(t,await n.sqliteIntegrationPluginZip));const r=n.wordpressInstallMode??"download-and-install",o=!!n.dataSqlPath;if(["download-and-install","install-from-existing-files"].includes(r)){await c(e,{usesSqlite:i,hasCustomDatabasePath:o});try{await _(t)}catch(d){throw o||await p(e),d}o||await p(e)}else if(r==="install-from-existing-files-if-needed"){if(await c(e,{usesSqlite:i,hasCustomDatabasePath:o}),!await b(t))try{await _(t)}catch(d){throw o||await p(e),d}o||await p(e)}return e}async function c(e,{usesSqlite:n,hasCustomDatabasePath:t}){const i=await e.getPrimaryPhp();if(i.isFile("/internal/shared/preload/0-sqlite.php"))return;const r=a.joinPaths(e.documentRoot,"wp-content/mu-plugins/sqlite-database-integration");if(!i.isDir(r)&&!n&&!t)throw new Error("Error connecting to the MySQL database.")}async function p(e){const n=await e.getPrimaryPhp();if(await I(n))return;if(n.isFile("/internal/shared/preload/0-sqlite.php"))throw new Error("Error connecting to the SQLite database.");const i=a.joinPaths(e.documentRoot,"wp-content/mu-plugins/sqlite-database-integration");throw n.isDir(i)?new Error("Error connecting to the SQLite database."):new Error("Error connecting to the MySQL database.")}async function m(e){const n=e.spawnHandler??u.sandboxedSpawnHandlerFactory;async function t(r,o){const l=await e.createPhpRuntime(o),s=new u.PHP(l);return e.sapiName&&s.setSapiName(e.sapiName),r&&(s.requestHandler=r),e.phpIniEntries&&u.setPhpIniEntries(s,e.phpIniEntries),s.defineConstant("WP_SQLITE_AST_DRIVER",!0),o&&!s.isFile("/internal/.boot-files-written")&&(await E(s),await u.writeFiles(s,"/",e.createFiles||{}),await T(s,a.joinPaths(new URL(e.siteUrl).pathname,"phpinfo.php")),await u.writeFiles(s,"/internal",{".boot-files-written":""})),n&&await s.setSpawnHandler(n(r.processManager)),s.enableRuntimeRotation({recreateRuntime:e.createPhpRuntime,maxRequests:400}),e.onPHPInstanceCreated&&await e.onPHPInstanceCreated(s,{isPrimary:o}),s}const i=new u.PHPRequestHandler({phpFactory:async({isPrimary:r})=>t(i,r),documentRoot:e.documentRoot||"/wordpress",absoluteUrl:e.siteUrl,rewriteRules:k,getFileNotFoundAction:e.getFileNotFoundAction??y,cookieStore:e.cookieStore});return i}async function b(e){return(await e.run({code:`<?php
+ `})).text!=="1")throw new Error("Failed to rewrite constants in wp-config.php.")}async function w(e,n){const t=a.joinPaths(n,"wp-config.php"),i={};!e.fileExists(t)&&e.fileExists(a.joinPaths(n,"wp-config-sample.php"))&&await e.writeFile(t,await e.readFileAsBuffer(a.joinPaths(n,"wp-config-sample.php"))),await g(e,t,i,"skip")}async function L(e){const n=await m(e);return await $(n,e),n}async function $(e,n){var l,s;const t=await e.getPrimaryPhp();if((l=n.hooks)!=null&&l.beforeWordPressFiles&&await n.hooks.beforeWordPressFiles(t),n.wordPressZip&&await S(t,await n.wordPressZip),n.constants)for(const d in n.constants)t.defineConstant(d,n.constants[d]);n.dataSqlPath&&(t.defineConstant("DB_DIR",a.dirname(n.dataSqlPath)),t.defineConstant("DB_FILE",a.basename(n.dataSqlPath))),t.defineConstant("WP_HOME",n.siteUrl),t.defineConstant("WP_SITEURL",n.siteUrl),await w(t,e.documentRoot),(s=n.hooks)!=null&&s.beforeDatabaseSetup&&await n.hooks.beforeDatabaseSetup(t);let i=!1;n.sqliteIntegrationPluginZip&&(i=!0,await R(t,await n.sqliteIntegrationPluginZip));const r=n.wordpressInstallMode??"download-and-install",o=!!n.dataSqlPath;if(["download-and-install","install-from-existing-files"].includes(r)){await c(e,{usesSqlite:i,hasCustomDatabasePath:o});try{await _(t)}catch(d){throw o||await p(e),d}o||await p(e)}else if(r==="install-from-existing-files-if-needed"){if(await c(e,{usesSqlite:i,hasCustomDatabasePath:o}),!await b(t))try{await _(t)}catch(d){throw o||await p(e),d}o||await p(e)}return e}async function c(e,{usesSqlite:n,hasCustomDatabasePath:t}){const i=await e.getPrimaryPhp();if(i.isFile("/internal/shared/preload/0-sqlite.php"))return;const r=a.joinPaths(e.documentRoot,"wp-content/mu-plugins/sqlite-database-integration");if(!i.isDir(r)&&!n&&!t)throw new Error("Error connecting to the MySQL database.")}async function p(e){const n=await e.getPrimaryPhp();if(await I(n))return;if(n.isFile("/internal/shared/preload/0-sqlite.php"))throw new Error("Error connecting to the SQLite database.");const i=a.joinPaths(e.documentRoot,"wp-content/mu-plugins/sqlite-database-integration");throw n.isDir(i)?new Error("Error connecting to the SQLite database."):new Error("Error connecting to the MySQL database.")}async function m(e){const n=e.spawnHandler??u.sandboxedSpawnHandlerFactory;async function t(r,o){const l=await e.createPhpRuntime(o),s=new u.PHP(l);return e.sapiName&&s.setSapiName(e.sapiName),r&&(s.requestHandler=r),e.phpIniEntries&&u.setPhpIniEntries(s,e.phpIniEntries),s.defineConstant("WP_SQLITE_AST_DRIVER",!0),o&&!s.isFile("/internal/.boot-files-written")&&(await E(s),await u.writeFiles(s,"/",e.createFiles||{}),await T(s,a.joinPaths(new URL(e.siteUrl).pathname,"phpinfo.php")),await u.writeFiles(s,"/internal",{".boot-files-written":""})),n&&await s.setSpawnHandler(n(r.processManager)),s.enableRuntimeRotation({recreateRuntime:e.createPhpRuntime,maxRequests:400}),e.onPHPInstanceCreated&&await e.onPHPInstanceCreated(s,{isPrimary:o}),s}const i=new u.PHPRequestHandler({phpFactory:async({isPrimary:r})=>t(i,r),documentRoot:e.documentRoot||"/wordpress",absoluteUrl:e.siteUrl,rewriteRules:k,getFileNotFoundAction:e.getFileNotFoundAction??y,cookieStore:e.cookieStore});return i}async function b(e){return(await e.run({code:`<?php
ob_start();
$wp_load = getenv('DOCUMENT_ROOT') . '/wp-load.php';
if (!file_exists($wp_load)) {
diff --git a/node_modules/@wp-playground/wordpress/index.js b/node_modules/@wp-playground/wordpress/index.js
index e880c7a..52f19ea 100644
--- a/node_modules/@wp-playground/wordpress/index.js
+++ b/node_modules/@wp-playground/wordpress/index.js
@@ -366,7 +366,6 @@ async function x(e, n, t, i = "rewrite") {
}
async function L(e, n) {
const t = s(n, "wp-config.php"), i = {
- DB_NAME: "wordpress"
};
!e.fileExists(t) && e.fileExists(s(n, "wp-config-sample.php")) && await e.writeFile(
t,
2 changes: 1 addition & 1 deletion src/lib/sentry-sanitizer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ export function sanitizeRunCLIArgs( args: RunCLIArgs ): Record< string, unknown
port: args.port,
debug: args.debug,
verbosity: args.verbosity,
skipWordPressSetup: args.skipWordPressSetup,
wordpressInstallMode: args.wordpressInstallMode,
skipSqliteSetup: args.skipSqliteSetup,
followSymlinks: args.followSymlinks,
internalCookieStore: args.internalCookieStore,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import nodePath from 'path';
import { SupportedPHPVersions } from '@php-wasm/universal';
import { Blueprint, StepDefinition } from '@wp-playground/blueprints';
import { RecommendedPHPVersion } from '@wp-playground/common';
import { WordPressInstallMode } from '@wp-playground/wordpress';
import { recursiveCopyDirectory, pathExists, isWordPressDirectory } from 'common/lib/fs-utils';
import { DEFAULT_LOCALE } from 'common/lib/locale';
import { isOnline } from 'common/lib/network-utils';
Expand All @@ -23,7 +24,7 @@ export interface PlaygroundCliOptions {
phpVersion: string;
documentRoot: string;
autoMount: boolean;
skipWordpressSetup: boolean;
wordpressInstallMode: WordPressInstallMode;
blueprint?: Blueprint;
}

Expand Down Expand Up @@ -70,7 +71,9 @@ export class PlaygroundCliProvider implements WordPressProvider {
phpVersion,
documentRoot: options.path,
autoMount: true,
skipWordpressSetup: hasWordPress,
wordpressInstallMode: hasWordPress
? 'install-from-existing-files-if-needed'
: 'download-and-install',
blueprint: options.blueprint,
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ async function startServer(
'mount-before-install': mounts,
'site-url': serverOptions.absoluteUrl,
blueprint: options.blueprint || {},
skipWordPressSetup: options.skipWordpressSetup,
wordpressInstallMode: options.wordpressInstallMode,
};

if ( options.phpVersion ) {
Expand Down
Loading