@wp-playground/cli 3.0.39 → 3.0.41
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cli.cjs +1 -1
- package/cli.js +1 -1
- package/index.cjs +1 -1
- package/index.js +1 -1
- package/mounts.d.ts +1 -1
- package/package.json +13 -13
- package/run-cli-DJNPNQa1.cjs +53 -0
- package/run-cli-DJNPNQa1.cjs.map +1 -0
- package/{run-cli-pLJHMn5d.js → run-cli-vem_UKTF.js} +516 -363
- package/run-cli-vem_UKTF.js.map +1 -0
- package/run-cli.d.ts +8 -1
- package/sqlite-database-integration-develop.zip +0 -0
- package/worker-thread-v1.cjs +1 -1
- package/worker-thread-v1.js +1 -1
- package/worker-thread-v2.cjs +5 -5
- package/worker-thread-v2.cjs.map +1 -1
- package/worker-thread-v2.js +7 -7
- package/worker-thread-v2.js.map +1 -1
- package/run-cli-D8BNUM1f.cjs +0 -42
- package/run-cli-D8BNUM1f.cjs.map +0 -1
- package/run-cli-pLJHMn5d.js.map +0 -1
package/cli.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";const s=require("./run-cli-
|
|
1
|
+
"use strict";const s=require("./run-cli-DJNPNQa1.cjs"),r=process.argv.slice(2);s.parseOptionsAndRunCLI(r);
|
|
2
2
|
//# sourceMappingURL=cli.cjs.map
|
package/cli.js
CHANGED
package/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./run-cli-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./run-cli-DJNPNQa1.cjs");exports.LogVerbosity=e.LogVerbosity;exports.internalsKeyForTesting=e.internalsKeyForTesting;exports.parseOptionsAndRunCLI=e.parseOptionsAndRunCLI;exports.runCLI=e.runCLI;exports.spawnWorkerThread=e.spawnWorkerThread;
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|
package/index.js
CHANGED
package/mounts.d.ts
CHANGED
|
@@ -41,4 +41,4 @@ export declare function expandAutoMounts(args: RunCLIArgs): RunCLIArgs;
|
|
|
41
41
|
export declare function containsFullWordPressInstallation(path: string): boolean;
|
|
42
42
|
export declare function containsWpContentDirectories(path: string): boolean;
|
|
43
43
|
export declare function isThemeDirectory(path: string): boolean;
|
|
44
|
-
export declare function
|
|
44
|
+
export declare function isPluginDirectory(path: string): boolean;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wp-playground/cli",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.41",
|
|
4
4
|
"description": "WordPress Playground CLI",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"bin": {
|
|
35
35
|
"wp-playground-cli": "wp-playground.js"
|
|
36
36
|
},
|
|
37
|
-
"gitHead": "
|
|
37
|
+
"gitHead": "638b025343c1cfee4f1b1732c0e05d286e67e136",
|
|
38
38
|
"dependencies": {
|
|
39
39
|
"@zip.js/zip.js": "2.7.57",
|
|
40
40
|
"ajv": "8.12.0",
|
|
@@ -62,17 +62,17 @@
|
|
|
62
62
|
"ws": "8.18.3",
|
|
63
63
|
"xml2js": "0.6.2",
|
|
64
64
|
"yargs": "17.7.2",
|
|
65
|
-
"@php-wasm/logger": "3.0.
|
|
66
|
-
"@php-wasm/progress": "3.0.
|
|
67
|
-
"@php-wasm/universal": "3.0.
|
|
68
|
-
"@wp-playground/blueprints": "3.0.
|
|
69
|
-
"@wp-playground/common": "3.0.
|
|
70
|
-
"@wp-playground/wordpress": "3.0.
|
|
71
|
-
"@php-wasm/node": "3.0.
|
|
72
|
-
"@php-wasm/util": "3.0.
|
|
73
|
-
"@php-wasm/cli-util": "3.0.
|
|
74
|
-
"@wp-playground/storage": "3.0.
|
|
75
|
-
"@php-wasm/xdebug-bridge": "3.0.
|
|
65
|
+
"@php-wasm/logger": "3.0.41",
|
|
66
|
+
"@php-wasm/progress": "3.0.41",
|
|
67
|
+
"@php-wasm/universal": "3.0.41",
|
|
68
|
+
"@wp-playground/blueprints": "3.0.41",
|
|
69
|
+
"@wp-playground/common": "3.0.41",
|
|
70
|
+
"@wp-playground/wordpress": "3.0.41",
|
|
71
|
+
"@php-wasm/node": "3.0.41",
|
|
72
|
+
"@php-wasm/util": "3.0.41",
|
|
73
|
+
"@php-wasm/cli-util": "3.0.41",
|
|
74
|
+
"@wp-playground/storage": "3.0.41",
|
|
75
|
+
"@php-wasm/xdebug-bridge": "3.0.41"
|
|
76
76
|
},
|
|
77
77
|
"packageManager": "npm@10.9.2",
|
|
78
78
|
"overrides": {
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";var Pe=Object.create;var te=Object.defineProperty;var ve=Object.getOwnPropertyDescriptor;var ke=Object.getOwnPropertyNames;var xe=Object.getPrototypeOf,Se=Object.prototype.hasOwnProperty;var Ie=(e,t,o,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of ke(t))!Se.call(e,r)&&r!==o&&te(e,r,{get:()=>t[r],enumerable:!(s=ve(t,r))||s.enumerable});return e};var Te=(e,t,o)=>(o=e!=null?Pe(xe(e)):{},Ie(t||!e||!e.__esModule?te(o,"default",{value:e,enumerable:!0}):o,e));const d=require("@php-wasm/logger"),b=require("@php-wasm/universal"),L=require("@wp-playground/blueprints"),H=require("@wp-playground/common"),c=require("fs"),Y=require("worker_threads"),de=require("@php-wasm/node"),p=require("path"),$e=require("express"),B=require("os"),Ce=require("wasm-feature-detect"),Re=require("yargs"),A=require("@wp-playground/storage"),oe=require("@php-wasm/progress"),Ee=require("@wp-playground/wordpress"),W=require("fs-extra"),Le=require("@php-wasm/xdebug-bridge"),We=require("child_process"),re=require("tmp-promise"),Be=require("ps-man"),q=require("@php-wasm/cli-util"),Me=require("crypto");var R=typeof document<"u"?document.currentScript:null;function z(e){const t=[];for(const o of e){const s=o.split(":");if(s.length!==2)throw new Error(`Invalid mount format: ${o}.
|
|
2
|
+
Expected format: /host/path:/vfs/path.
|
|
3
|
+
If your path contains a colon, e.g. C:\\myplugin, use the --mount-dir option instead.
|
|
4
|
+
Example: --mount-dir C:\\my-plugin /wordpress/wp-content/plugins/my-plugin`);const[r,n]=s;if(!c.existsSync(r))throw new Error(`Host path does not exist: ${r}`);t.push({hostPath:r,vfsPath:n})}return t}function se(e){if(e.length%2!==0)throw new Error("Invalid mount format. Expected: /host/path /vfs/path");const t=[];for(let o=0;o<e.length;o+=2){const s=e[o],r=e[o+1];if(!c.existsSync(s))throw new Error(`Host path does not exist: ${s}`);t.push({hostPath:p.resolve(process.cwd(),s),vfsPath:r})}return t}async function Ue(e,t){for(const o of t)await e.mount(o.vfsPath,de.createNodeFsMountHandler(o.hostPath))}const ne={step:"runPHP",code:{filename:"activate-theme.php",content:`<?php
|
|
5
|
+
$docroot = getenv('DOCROOT') ? getenv('DOCROOT') : '/wordpress';
|
|
6
|
+
require_once "$docroot/wp-load.php";
|
|
7
|
+
$theme = wp_get_theme();
|
|
8
|
+
if (!$theme->exists()) {
|
|
9
|
+
$themes = wp_get_themes();
|
|
10
|
+
if (count($themes) > 0) {
|
|
11
|
+
$themeName = array_keys($themes)[0];
|
|
12
|
+
switch_theme($themeName);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
`}};function ce(e){const t=e.autoMount,o=[...e.mount||[]],s=[...e["mount-before-install"]||[]],r={...e,mount:o,"mount-before-install":s,"additional-blueprint-steps":[...e["additional-blueprint-steps"]||[]]};if(qe(t)){const n=p.basename(t);o.push({hostPath:t,vfsPath:`/wordpress/wp-content/plugins/${n}`}),r["additional-blueprint-steps"].push({step:"activatePlugin",pluginPath:`/wordpress/wp-content/plugins/${p.basename(t)}`})}else if(Ae(t)){const n=p.basename(t);o.push({hostPath:t,vfsPath:`/wordpress/wp-content/themes/${n}`}),r["additional-blueprint-steps"].push(e["experimental-blueprints-v2-runner"]?{step:"activateTheme",themeDirectoryName:n}:{step:"activateTheme",themeFolderName:n})}else if(Fe(t)){const n=c.readdirSync(t);for(const i of n)i!=="index.php"&&o.push({hostPath:`${t}/${i}`,vfsPath:`/wordpress/wp-content/${i}`});r["additional-blueprint-steps"].push(ne)}else De(t)&&(s.push({hostPath:t,vfsPath:"/wordpress"}),r.mode="apply-to-existing-site",r["additional-blueprint-steps"].push(ne),r.wordpressInstallMode||(r.wordpressInstallMode="install-from-existing-files-if-needed"));return r}function De(e){const t=c.readdirSync(e);return t.includes("wp-admin")&&t.includes("wp-includes")&&t.includes("wp-content")}function Fe(e){const t=c.readdirSync(e);return t.includes("themes")||t.includes("plugins")||t.includes("mu-plugins")||t.includes("uploads")}function Ae(e){if(!c.readdirSync(e).includes("style.css"))return!1;const o=c.readFileSync(p.join(e,"style.css"),"utf8");return!!/^(?:[ \t]*<\?php)?[ \t/*#@]*Theme Name:(.*)$/im.exec(o)}function qe(e){const t=c.readdirSync(e),o=/^(?:[ \t]*<\?php)?[ \t/*#@]*Plugin Name:(.*)$/im;return!!t.filter(r=>r.endsWith(".php")).find(r=>{const n=c.readFileSync(p.join(e,r),"utf8");return!!o.exec(n)})}async function He(e){const t=$e(),o=await new Promise((n,i)=>{const l=t.listen(e.port,()=>{const u=l.address();u===null||typeof u=="string"?i(new Error("Server address is not available")):n(l)})});t.use("/",async(n,i)=>{let l;try{l=await e.handleRequest({url:n.url,headers:_e(n),method:n.method,body:await Ve(n)})}catch(u){d.logger.error(u),l=b.PHPResponse.forHttpCode(500)}i.statusCode=l.httpStatusCode;for(const u in l.headers)i.setHeader(u,l.headers[u]);i.end(l.bytes)});const r=o.address().port;return await e.onBind(o,r)}const Ve=async e=>await new Promise(t=>{const o=[];e.on("data",s=>{o.push(s)}),e.on("end",()=>{t(new Uint8Array(Buffer.concat(o)))})}),_e=e=>{const t={};if(e.rawHeaders&&e.rawHeaders.length)for(let o=0;o<e.rawHeaders.length;o+=2)t[e.rawHeaders[o].toLowerCase()]=e.rawHeaders[o+1];return t};class Ne{constructor(t){this.workerLoads=[],this.addWorker(t)}addWorker(t){this.workerLoads.push({worker:t,activeRequests:new Set})}async removeWorker(t){const o=this.workerLoads.findIndex(r=>r.worker===t);if(o===-1)return;const[s]=this.workerLoads.splice(o,1);await Promise.allSettled(s.activeRequests)}async handleRequest(t){let o=this.workerLoads[0];for(let r=1;r<this.workerLoads.length;r++){const n=this.workerLoads[r];n.activeRequests.size<o.activeRequests.size&&(o=n)}const s=o.worker.request(t);return o.activeRequests.add(s),s.url=t.url,s.finally(()=>{o.activeRequests.delete(s)})}}function Oe(e){return/^latest$|^trunk$|^nightly$|^(?:(\d+)\.(\d+)(?:\.(\d+))?)((?:-beta(?:\d+)?)|(?:-RC(?:\d+)?))?$/.test(e)}async function je({sourceString:e,blueprintMayReadAdjacentFiles:t}){if(!e)return;if(e.startsWith("http://")||e.startsWith("https://"))return await L.resolveRemoteBlueprint(e);let o=p.resolve(process.cwd(),e);if(!c.existsSync(o))throw new Error(`Blueprint file does not exist: ${o}`);const s=c.statSync(o);if(s.isDirectory()&&(o=p.join(o,"blueprint.json")),!s.isFile()&&s.isSymbolicLink())throw new Error(`Blueprint path is neither a file nor a directory: ${o}`);const r=p.extname(o);switch(r){case".zip":return A.ZipFilesystem.fromArrayBuffer(c.readFileSync(o).buffer);case".json":{const n=c.readFileSync(o,"utf-8");try{JSON.parse(n)}catch{throw new Error(`Blueprint file at ${o} is not a valid JSON file`)}const i=p.dirname(o),l=new A.NodeJsFilesystem(i);return new A.OverlayFilesystem([new A.InMemoryFilesystem({"blueprint.json":n}),{read(u){if(!t)throw new Error(`Error: Blueprint contained tried to read a local file at path "${u}" (via a resource of type "bundled"). Playground restricts access to local resources by default as a security measure.
|
|
16
|
+
|
|
17
|
+
You can allow this Blueprint to read files from the same parent directory by explicitly adding the --blueprint-may-read-adjacent-files option to your command.`);return l.read(u)}}])}default:throw new Error(`Unsupported blueprint file extension: ${r}. Only .zip and .json files are supported.`)}}function G(e){return process.env.CI==="true"||process.env.CI==="1"||process.env.GITHUB_ACTIONS==="true"||process.env.GITHUB_ACTIONS==="1"||(process.env.TERM||"").toLowerCase()==="dumb"?!1:e?!!e.isTTY:process.stdout.isTTY}class ze{constructor(t,o){this.lastProgressMessage="",this.args=t,this.siteUrl=o.siteUrl,this.processIdSpaceLength=o.processIdSpaceLength,this.phpVersion=t.php}getWorkerType(){return"v2"}async bootAndSetUpInitialPlayground(t,o,s){const r=b.consumeAPI(t);await r.useFileLockManager(o);const n={...this.args,phpVersion:this.phpVersion,siteUrl:this.siteUrl,firstProcessId:1,processIdSpaceLength:this.processIdSpaceLength,trace:this.args.verbosity==="debug",blueprint:this.args.blueprint,withIntl:this.args.intl,withXdebug:!1,xdebug:void 0,nativeInternalDirPath:s,mountsBeforeWpInstall:this.args["mount-before-install"]||[],mountsAfterWpInstall:this.args.mount||[]};return await r.bootAndSetUpInitialWorker(n),r}async bootPlayground({worker:t,fileLockManagerPort:o,firstProcessId:s,nativeInternalDirPath:r}){const n=b.consumeAPI(t.phpPort);await n.useFileLockManager(o);const i={...this.args,phpVersion:this.phpVersion,siteUrl:this.siteUrl,firstProcessId:s,processIdSpaceLength:this.processIdSpaceLength,trace:this.args.verbosity==="debug",withIntl:this.args.intl,withXdebug:!!this.args.xdebug,nativeInternalDirPath:r,mountsBeforeWpInstall:this.args["mount-before-install"]||[],mountsAfterWpInstall:this.args.mount||[]};return await n.bootWorker(i),n}writeProgressUpdate(t,o,s){G(t)&&o!==this.lastProgressMessage&&(this.lastProgressMessage=o,t.isTTY?(t.cursorTo(0),t.write(o),t.clearLine(1),s&&t.write(`
|
|
18
|
+
`)):t.write(`${o}
|
|
19
|
+
`))}}const Z=p.join(B.homedir(),".wordpress-playground");async function Xe(e){return await ue("https://github.com/WordPress/sqlite-database-integration/archive/refs/heads/develop.zip","sqlite.zip",e)}async function ue(e,t,o){const s=p.join(Z,t);return W.existsSync(s)||(W.ensureDirSync(Z),await Ye(e,s,o)),pe(s)}async function Ye(e,t,o){const r=(await o.monitorFetch(fetch(e))).body.getReader(),n=`${t}.partial`,i=W.createWriteStream(n);for(;;){const{done:l,value:u}=await r.read();if(u&&i.write(u),l)break}i.close(),i.closed||await new Promise((l,u)=>{i.on("finish",()=>{W.renameSync(n,t),l(null)}),i.on("error",P=>{W.removeSync(n),u(P)})})}function pe(e,t){return new File([W.readFileSync(e)],p.basename(e))}class Ze{constructor(t,o){this.lastProgressMessage="",this.args=t,this.siteUrl=o.siteUrl,this.processIdSpaceLength=o.processIdSpaceLength}getWorkerType(){return"v1"}async bootAndSetUpInitialPlayground(t,o,s){let r,n,i;const l=new oe.EmscriptenDownloadMonitor;if(this.args.wordpressInstallMode==="download-and-install"){let k=!1;l.addEventListener("progress",M=>{if(k)return;const{loaded:J,total:_}=M.detail,x=Math.floor(Math.min(100,100*J/_));k=x===100,this.writeProgressUpdate(process.stdout,`Downloading WordPress ${x}%...`,k)}),r=await Ee.resolveWordPressRelease(this.args.wp),i=p.join(Z,`prebuilt-wp-content-for-wp-${r.version}.zip`),n=c.existsSync(i)?pe(i):await ue(r.releaseUrl,`${r.version}.zip`,l),d.logger.log(`Resolved WordPress release URL: ${r?.releaseUrl}`)}let u;this.args.skipSqliteSetup?(d.logger.log("Skipping SQLite integration plugin setup..."),u=void 0):(d.logger.log("Fetching SQLite integration plugin..."),u=await Xe(l));const P=this.args.followSymlinks===!0,w=this.args.experimentalTrace===!0,a=this.args["mount-before-install"]||[],y=this.args.mount||[],h=b.consumeAPI(t);await h.isConnected(),d.logger.log("Booting WordPress...");const T=await L.resolveRuntimeConfiguration(this.getEffectiveBlueprint());return await h.useFileLockManager(o),await h.bootAndSetUpInitialWorker({phpVersion:T.phpVersion,wpVersion:T.wpVersion,siteUrl:this.siteUrl,mountsBeforeWpInstall:a,mountsAfterWpInstall:y,wordpressInstallMode:this.args.wordpressInstallMode||"download-and-install",wordPressZip:n&&await n.arrayBuffer(),sqliteIntegrationPluginZip:await u?.arrayBuffer(),firstProcessId:0,processIdSpaceLength:this.processIdSpaceLength,followSymlinks:P,trace:w,internalCookieStore:this.args.internalCookieStore,withIntl:this.args.intl,withXdebug:!1,nativeInternalDirPath:s}),i&&!this.args["mount-before-install"]&&!c.existsSync(i)&&(d.logger.log("Caching preinstalled WordPress for the next boot..."),c.writeFileSync(i,await H.zipDirectory(h,"/wordpress")),d.logger.log("Cached!")),h}async bootPlayground({worker:t,fileLockManagerPort:o,firstProcessId:s,nativeInternalDirPath:r}){const n=b.consumeAPI(t.phpPort);await n.isConnected();const i=await L.resolveRuntimeConfiguration(this.getEffectiveBlueprint());return await n.useFileLockManager(o),await n.bootWorker({phpVersion:i.phpVersion,siteUrl:this.siteUrl,mountsBeforeWpInstall:this.args["mount-before-install"]||[],mountsAfterWpInstall:this.args.mount||[],firstProcessId:s,processIdSpaceLength:this.processIdSpaceLength,followSymlinks:this.args.followSymlinks===!0,trace:this.args.experimentalTrace===!0,internalCookieStore:this.args.internalCookieStore,withIntl:this.args.intl,withXdebug:!!this.args.xdebug,nativeInternalDirPath:r}),await n.isReady(),n}async compileInputBlueprint(t){const o=this.getEffectiveBlueprint(),s=new oe.ProgressTracker;let r="",n=!1;return s.addEventListener("progress",i=>{if(n)return;n=i.detail.progress===100;const l=Math.floor(i.detail.progress);r=i.detail.caption||r||"Running the Blueprint";const u=`${r.trim()} – ${l}%`;this.writeProgressUpdate(process.stdout,u,n)}),await L.compileBlueprintV1(o,{progress:s,additionalSteps:t})}getEffectiveBlueprint(){const t=this.args.blueprint;return L.isBlueprintBundle(t)?t:{login:this.args.login,...t||{},preferredVersions:{php:this.args.php??t?.preferredVersions?.php??H.RecommendedPHPVersion,wp:this.args.wp??t?.preferredVersions?.wp??"latest",...t?.preferredVersions||{}}}}writeProgressUpdate(t,o,s){this.args.verbosity!==V.Quiet.name&&G(t)&&o!==this.lastProgressMessage&&(this.lastProgressMessage=o,t.isTTY?(t.cursorTo(0),t.write(o),t.clearLine(1),s&&t.write(`
|
|
20
|
+
`)):t.write(`${o}
|
|
21
|
+
`))}}async function Ge(e,t=!0){const s=`${p.basename(process.argv0)}${e}${process.pid}-`,r=await re.dir({prefix:s,unsafeCleanup:!0});return t&&re.setGracefulCleanup(),r}async function Je(e,t,o){const r=(await Ke(e,t,o)).map(n=>new Promise(i=>{c.rm(n,{recursive:!0},l=>{l?d.logger.warn(`Failed to delete stale Playground temp dir: ${n}`,l):d.logger.info(`Deleted stale Playground temp dir: ${n}`),i()})}));await Promise.all(r)}async function Ke(e,t,o){try{const s=c.readdirSync(o).map(n=>p.join(o,n)),r=[];for(const n of s)await Qe(e,t,n)&&r.push(n);return r}catch(s){return d.logger.warn(`Failed to find stale Playground temp dirs: ${s}`),[]}}async function Qe(e,t,o){if(!c.lstatSync(o).isDirectory())return!1;const r=p.basename(o);if(!r.includes(e))return!1;const n=r.match(new RegExp(`^(.+)${e}(\\d+)-`));if(!n)return!1;const i={executableName:n[1],pid:n[2]};if(await et(i.pid,i.executableName))return!1;const l=Date.now()-t;return c.statSync(o).mtime.getTime()<l}async function et(e,t){const[o]=await new Promise((s,r)=>{Be.list({pid:e,name:t,clean:!0},(n,i)=>{n?r(n):s(i)})});return!!o&&o.pid===e&&o.command===t}const V={Quiet:{name:"quiet",severity:d.LogSeverity.Fatal},Normal:{name:"normal",severity:d.LogSeverity.Info},Debug:{name:"debug",severity:d.LogSeverity.Debug}};async function tt(e){try{const t={"site-url":{describe:"Site URL to use for WordPress. Defaults to http://127.0.0.1:{port}",type:"string"},php:{describe:"PHP version to use.",type:"string",default:H.RecommendedPHPVersion,choices:b.SupportedPHPVersions},wp:{describe:"WordPress version to use.",type:"string",default:"latest"},mount:{describe:"Mount a directory to the PHP runtime (can be used multiple times). Format: /host/path:/vfs/path",type:"array",string:!0,coerce:z},"mount-before-install":{describe:"Mount a directory to the PHP runtime before WordPress installation (can be used multiple times). Format: /host/path:/vfs/path",type:"array",string:!0,coerce:z},"mount-dir":{describe:'Mount a directory to the PHP runtime (can be used multiple times). Format: "/host/path" "/vfs/path"',type:"array",nargs:2,array:!0,coerce:se},"mount-dir-before-install":{describe:'Mount a directory before WordPress installation (can be used multiple times). Format: "/host/path" "/vfs/path"',type:"string",nargs:2,array:!0,coerce:se},login:{describe:"Should log the user in",type:"boolean",default:!1},blueprint:{describe:"Blueprint to execute.",type:"string"},"blueprint-may-read-adjacent-files":{describe:'Consent flag: Allow "bundled" resources in a local blueprint to read files in the same directory as the blueprint file.',type:"boolean",default:!1},"wordpress-install-mode":{describe:"Control how Playground prepares WordPress before booting.",type:"string",default:"download-and-install",choices:["download-and-install","install-from-existing-files","install-from-existing-files-if-needed","do-not-attempt-installing"]},"skip-wordpress-install":{describe:"[Deprecated] Use --wordpress-install-mode instead.",type:"boolean",hidden:!0},"skip-sqlite-setup":{describe:"Skip the SQLite integration plugin setup to allow the WordPress site to use MySQL.",type:"boolean",default:!1},quiet:{describe:"Do not output logs and progress messages.",type:"boolean",default:!1,hidden:!0},verbosity:{describe:"Output logs and progress messages.",type:"string",choices:Object.values(V).map(a=>a.name),default:"normal"},debug:{describe:"Print PHP error log content if an error occurs during Playground boot.",type:"boolean",default:!1,hidden:!0},"auto-mount":{describe:"Automatically mount the specified directory. If no path is provided, mount the current working directory. You can mount a WordPress directory, a plugin directory, a theme directory, a wp-content directory, or any directory containing PHP and HTML files.",type:"string"},"follow-symlinks":{describe:`Allow Playground to follow symlinks by automatically mounting symlinked directories and files encountered in mounted directories.
|
|
22
|
+
Warning: Following symlinks will expose files outside mounted directories to Playground and could be a security risk.`,type:"boolean",default:!1},"experimental-trace":{describe:"Print detailed messages about system behavior to the console. Useful for troubleshooting.",type:"boolean",default:!1,hidden:!0},"internal-cookie-store":{describe:"Enable internal cookie handling. When enabled, Playground will manage cookies internally using an HttpCookieStore that persists cookies across requests. When disabled, cookies are handled externally (e.g., by a browser in Node.js environments).",type:"boolean",default:!1},intl:{describe:"Enable Intl.",type:"boolean",default:!0},xdebug:{describe:"Enable Xdebug.",type:"boolean",default:!1},"experimental-unsafe-ide-integration":{describe:"Enable experimental IDE development tools. This option edits IDE config files to set Xdebug path mappings and web server details. CAUTION: If there are bugs, this feature may break your IDE config files. Please consider backing up your IDE configs before using this feature.",type:"string",choices:["","vscode","phpstorm"],coerce:a=>a===""?["vscode","phpstorm"]:[a]},"experimental-blueprints-v2-runner":{describe:"Use the experimental Blueprint V2 runner.",type:"boolean",default:!1,hidden:!0},mode:{describe:"Blueprints v2 runner mode to use. This option is required when using the --experimental-blueprints-v2-runner flag with a blueprint.",type:"string",choices:["create-new-site","apply-to-existing-site"],hidden:!0}},o={port:{describe:"Port to listen on when serving.",type:"number",default:9400},"experimental-multi-worker":{describe:"Enable experimental multi-worker support which requires a /wordpress directory backed by a real filesystem. Pass a positive number to specify the number of workers to use. Otherwise, default to the number of CPUs minus 1.",type:"number",coerce:a=>a??B.cpus().length-1},"experimental-devtools":{describe:"Enable experimental browser development tools.",type:"boolean"}},s={path:{describe:"Path to the project directory. Playground will auto-detect if this is a plugin, theme, wp-content, or WordPress directory.",type:"string",default:process.cwd()},php:{describe:"PHP version to use.",type:"string",default:H.RecommendedPHPVersion,choices:b.SupportedPHPVersions},wp:{describe:"WordPress version to use.",type:"string",default:"latest"},port:{describe:"Port to listen on.",type:"number",default:9400},blueprint:{describe:"Path to a Blueprint JSON file to execute on startup.",type:"string"},login:{describe:"Auto-login as the admin user.",type:"boolean",default:!0},xdebug:{describe:"Enable Xdebug for debugging.",type:"boolean",default:!1},"experimental-unsafe-ide-integration":t["experimental-unsafe-ide-integration"],"skip-browser":{describe:"Do not open the site in your default browser on startup.",type:"boolean",default:!1},quiet:{describe:"Suppress non-essential output.",type:"boolean",default:!1},"site-url":{describe:"Override the site URL. By default, derived from the port (http://127.0.0.1:<port>).",type:"string"},mount:{describe:"Mount a directory to the PHP runtime (can be used multiple times). Format: /host/path:/vfs/path. Use this for additional mounts beyond auto-detection.",type:"array",string:!0,coerce:z},reset:{describe:"Deletes the stored site directory and starts a new site from scratch.",type:"boolean",default:!1},"no-auto-mount":{describe:"Disable automatic project type detection. Use --mount to manually specify mounts instead.",type:"boolean",default:!1}},r={outfile:{describe:"When building, write to this output file.",type:"string",default:"wordpress.zip"}},n=Re(e).usage("Usage: wp-playground <command> [options]").command("start","Start a local WordPress server with automatic project detection (recommended)",a=>a.usage(`Usage: wp-playground start [options]
|
|
23
|
+
|
|
24
|
+
The easiest way to run WordPress locally. Automatically detects
|
|
25
|
+
if your directory contains a plugin, theme, wp-content, or
|
|
26
|
+
WordPress installation and configures everything for you.
|
|
27
|
+
|
|
28
|
+
Examples:
|
|
29
|
+
wp-playground start # Start in current directory
|
|
30
|
+
wp-playground start --path=./my-plugin # Start with a specific path
|
|
31
|
+
wp-playground start --wp=6.7 --php=8.3 # Use specific versions
|
|
32
|
+
wp-playground start --skip-browser # Skip opening browser
|
|
33
|
+
wp-playground start --no-auto-mount # Disable auto-detection`).options(s)).command("server","Start a local WordPress server (advanced, low-level)",a=>a.options({...t,...o})).command("run-blueprint","Execute a Blueprint without starting a server",a=>a.options({...t})).command("build-snapshot","Build a ZIP snapshot of a WordPress site based on a Blueprint",a=>a.options({...t,...r})).demandCommand(1,"Please specify a command").strictCommands().conflicts("experimental-unsafe-ide-integration","experimental-devtools").showHelpOnFail(!1).fail((a,y,h)=>{if(y)throw y;a&&a.includes("Please specify a command")&&(h.showHelp(),console.error(`
|
|
34
|
+
`+a),process.exit(1)),console.error(a),process.exit(1)}).strictOptions().check(async a=>{if(a["skip-wordpress-install"]===!0&&(a["wordpress-install-mode"]="do-not-attempt-installing",a.wordpressInstallMode="do-not-attempt-installing"),a.wp!==void 0&&typeof a.wp=="string"&&!Oe(a.wp))try{new URL(a.wp)}catch{throw new Error('Unrecognized WordPress version. Please use "latest", a URL, or a numeric version such as "6.2", "6.0.1", "6.2-beta1", or "6.2-RC1"')}const y=a["site-url"];if(typeof y=="string"&&y.trim()!=="")try{new URL(y)}catch{throw new Error(`Invalid site-url "${y}". Please provide a valid URL (e.g., http://localhost:8080 or https://example.com)`)}if(a["auto-mount"]){let h=!1;try{h=c.statSync(a["auto-mount"]).isDirectory()}catch{h=!1}if(!h)throw new Error(`The specified --auto-mount path is not a directory: '${a["auto-mount"]}'.`)}if(a["experimental-multi-worker"]!==void 0){if(a._[0]!=="server")throw new Error("The --experimental-multi-worker flag is only supported when running the server command.");if(a["experimental-multi-worker"]!==void 0&&typeof a["experimental-multi-worker"]=="number"&&a["experimental-multi-worker"]<=1)throw new Error("The --experimental-multi-worker flag must be a positive integer greater than 1.")}if(a["experimental-blueprints-v2-runner"]===!0){if(a.mode!==void 0){if(a["wordpress-install-mode"]!==void 0)throw new Error("The --wordpress-install-mode option cannot be used with the --mode option. Use one or the other.");if("skip-sqlite-setup"in a)throw new Error("The --skipSqliteSetup option is not supported in Blueprint V2 mode.");if(a["auto-mount"]!==void 0)throw new Error("The --mode option cannot be used with --auto-mount because --auto-mount automatically sets the mode.")}else a["wordpress-install-mode"]==="do-not-attempt-installing"?a.mode="apply-to-existing-site":a.mode="create-new-site";const h=a.allow||[];a.followSymlinks===!0&&h.push("follow-symlinks"),a["blueprint-may-read-adjacent-files"]===!0&&h.push("read-local-fs"),a.allow=h}else if(a.mode!==void 0)throw new Error("The --mode option requires the --experimentalBlueprintsV2Runner flag.");return!0});n.wrap(n.terminalWidth());const i=await n.argv,l=i._[0];["start","run-blueprint","server","build-snapshot"].includes(l)||(n.showHelp(),process.exit(1));const u={...i,command:l,mount:[...i.mount||[],...i["mount-dir"]||[]],"mount-before-install":[...i["mount-before-install"]||[],...i["mount-dir-before-install"]||[]]},P=await he(u);P===void 0&&process.exit(0);const w=(()=>{let a;return async()=>{a!==void 0&&(a=P[Symbol.asyncDispose]()),await a,process.exit(0)}})();process.on("SIGINT",w),process.on("SIGTERM",w)}catch(t){if(console.error(t),!(t instanceof Error))throw t;if(process.argv.includes("--debug"))b.printDebugDetails(t);else{const s=[];let r=t;do s.push(r.message),r=r.cause;while(r instanceof Error);console.error("\x1B[1m"+s.join(" caused by: ")+"\x1B[0m")}process.exit(1)}}function ie(e,t){return e.find(o=>o.vfsPath.replace(/\/$/,"")===t.replace(/\/$/,""))}const fe=Symbol("playground-cli-testing"),E=e=>process.stdout.isTTY?"\x1B[1m"+e+"\x1B[0m":e,ot=e=>process.stdout.isTTY?"\x1B[31m"+e+"\x1B[0m":e,rt=e=>process.stdout.isTTY?`\x1B[2m${e}\x1B[0m`:e,X=e=>process.stdout.isTTY?`\x1B[3m${e}\x1B[0m`:e,ae=e=>process.stdout.isTTY?`\x1B[33m${e}\x1B[0m`:e;async function he(e){let t,o;const s=new Map;if(e.command==="start"&&(e=st(e)),e.autoMount!==void 0&&(e.autoMount===""&&(e={...e,autoMount:process.cwd()}),e=ce(e)),e.wordpressInstallMode===void 0&&(e.wordpressInstallMode="download-and-install"),e.quiet&&(e.verbosity="quiet",delete e.quiet),e.debug&&(e.verbosity="debug",delete e.debug),e.verbosity){const w=Object.values(V).find(a=>a.name===e.verbosity).severity;d.logger.setSeverityFilterLevel(w)}e.intl||(e.intl=!0);const r=e.command==="server"?e.port??9400:0,n=B.platform()==="win32"?void 0:await import("fs-ext").then(w=>w.flockSync).catch(()=>{d.logger.warn("The fs-ext package is not installed. Internal file locking will not be integrated with host OS file locking.")}),i=new de.FileLockManagerForNode(n);let l=!1,u=!0;d.logger.log("Starting a PHP server...");const P=await He({port:r,onBind:async(w,a)=>{const y="127.0.0.1",h=`http://${y}:${a}`,T=e["site-url"]||h,k=e.command==="server"?e.experimentalMultiWorker??1:1,M=e.command==="server"?k+1:k,_=2**31-1,x=Math.floor(_/M),K="-playground-cli-site-",$=await Ge(K);d.logger.debug(`Native temp dir for VFS root: ${$.path}`);const U="WP Playground CLI - Listen for Xdebug",Q=".playground-xdebug-root",ee=p.join(process.cwd(),Q);if(await q.removeTempDirSymlink(ee),e.xdebug&&e.experimentalUnsafeIdeIntegration){await q.createTempDirSymlink($.path,ee,process.platform);const f={hostPath:p.join(".",p.sep,Q),vfsPath:"/"};try{await q.clearXdebugIDEConfig(U,process.cwd());const g=typeof e.xdebug=="object"?e.xdebug:void 0,S=await q.addXdebugIDEConfig({name:U,host:y,port:a,ides:e.experimentalUnsafeIdeIntegration,cwd:process.cwd(),mounts:[f,...e["mount-before-install"]||[],...e.mount||[]],ideKey:g?.ideKey}),m=e.experimentalUnsafeIdeIntegration,v=m.includes("vscode"),I=m.includes("phpstorm"),F=Object.values(S);console.log(""),F.length>0?(console.log(E("Xdebug configured successfully")),console.log(ae("Updated IDE config: ")+F.join(" ")),console.log(ae("Playground source root: ")+".playground-xdebug-root"+X(rt(" – you can set breakpoints and preview Playground's VFS structure in there.")))):(console.log(E("Xdebug configuration failed.")),console.log("No IDE-specific project settings directory was found in the current working directory.")),console.log(""),v&&S.vscode&&(console.log(E("VS Code / Cursor instructions:")),console.log(" 1. Ensure you have installed an IDE extension for PHP Debugging"),console.log(` (The ${E("PHP Debug")} extension by ${E("Xdebug")} has been a solid option)`),console.log(" 2. Open the Run and Debug panel on the left sidebar"),console.log(` 3. Select "${X(U)}" from the dropdown`),console.log(' 3. Click "start debugging"'),console.log(" 5. Set a breakpoint. For example, in .playground-xdebug-root/wordpress/index.php"),console.log(" 6. Visit Playground in your browser to hit the breakpoint"),I&&console.log("")),I&&S.phpstorm&&(console.log(E("PhpStorm instructions:")),console.log(` 1. Choose "${X(U)}" debug configuration in the toolbar`),console.log(" 2. Click the debug button (bug icon)`"),console.log(" 3. Set a breakpoint. For example, in .playground-xdebug-root/wordpress/index.php"),console.log(" 4. Visit Playground in your browser to hit the breakpoint")),console.log("")}catch(g){throw new Error("Could not configure Xdebug",{cause:g})}}const ge=p.dirname($.path),we=2*24*60*60*1e3;Je(K,we,ge);const N=p.join($.path,"internal");c.mkdirSync(N);const ye=["wordpress","tmp","home"];for(const f of ye){const g=m=>m.vfsPath===`/${f}`;if(!(e["mount-before-install"]?.some(g)||e.mount?.some(g))){const m=p.join($.path,f);c.mkdirSync(m),e["mount-before-install"]===void 0&&(e["mount-before-install"]=[]),e["mount-before-install"].unshift({vfsPath:`/${f}`,hostPath:m})}}if(e["mount-before-install"])for(const f of e["mount-before-install"])d.logger.debug(`Mount before WP install: ${f.vfsPath} -> ${f.hostPath}`);if(e.mount)for(const f of e.mount)d.logger.debug(`Mount after WP install: ${f.vfsPath} -> ${f.hostPath}`);let C;e["experimental-blueprints-v2-runner"]?C=new ze(e,{siteUrl:T,processIdSpaceLength:x}):(C=new Ze(e,{siteUrl:T,processIdSpaceLength:x}),typeof e.blueprint=="string"&&(e.blueprint=await je({sourceString:e.blueprint,blueprintMayReadAdjacentFiles:e["blueprint-may-read-adjacent-files"]===!0})));let O=!1;const D=async function(){O||(O=!0,await Promise.all([...s].map(async([g,S])=>{await S.dispose(),await g.terminate()})),w&&await new Promise(g=>w.close(g)),await $.cleanup())},be=nt(M,C.getWorkerType(),({exitCode:f,workerIndex:g})=>{O||f===0&&d.logger.error(`Worker ${g} exited with code ${f}
|
|
35
|
+
`)});d.logger.log("Starting up workers");try{const f=await be,g=await le(i);{const m=f.shift(),v=await C.bootAndSetUpInitialPlayground(m.phpPort,g,N);if(s.set(m.worker,v),await v.isReady(),l=!0,d.logger.log("Booted!"),t=new Ne(v),!e["experimental-blueprints-v2-runner"]){const I=await C.compileInputBlueprint(e["additional-blueprint-steps"]||[]);I&&(d.logger.log("Running the Blueprint..."),await L.runBlueprintV1Steps(I,v),d.logger.log("Finished running the blueprint"))}if(e.command==="build-snapshot"){await at(o,e.outfile),d.logger.log(`WordPress exported to ${e.outfile}`),await D();return}else if(e.command==="run-blueprint"){d.logger.log("Blueprint executed"),await D();return}await t.removeWorker(v),await v.dispose(),await m.worker.terminate(),s.delete(m.worker)}d.logger.log("Preparing workers...");const S=x;return[o]=await Promise.all(f.map(async(m,v)=>{const I=S+v*x,F=await le(i),j=await C.bootPlayground({worker:m,fileLockManagerPort:F,firstProcessId:I,nativeInternalDirPath:N});return s.set(m.worker,j),t.addWorker(j),j})),d.logger.log(`WordPress is running on ${h} with ${k} worker(s)`),e.xdebug&&e.experimentalDevtools&&(await Le.startBridge({phpInstance:o,phpRoot:"/wordpress"})).start(),{playground:o,server:w,serverUrl:h,[Symbol.asyncDispose]:D,[fe]:{workerThreadCount:k,getWorkerNumberFromProcessId:m=>Math.floor(m/x)}}}catch(f){if(e.verbosity!=="debug")throw f;let g="";throw await o?.fileExists(d.errorLogPath)&&(g=await o.readFileAsText(d.errorLogPath)),await D(),new Error(g,{cause:f})}},async handleRequest(w){if(!l)return b.PHPResponse.forHttpCode(502,"WordPress is not ready yet");if(u){u=!1;const a={"Content-Type":["text/plain"],"Content-Length":["0"],Location:[w.url]};return w.headers?.cookie?.includes("playground_auto_login_already_happened")&&(a["Set-Cookie"]=["playground_auto_login_already_happened=1; Max-Age=0; Expires=Thu, 01 Jan 1970 00:00:00 GMT; Path=/"]),new b.PHPResponse(302,a,new Uint8Array)}return await t.handleRequest(w)}});return P&&e.command==="start"&&!e.skipBrowser&&it(P.serverUrl),P}function st(e){let t={...e,command:"server"};e.noAutoMount||(t.autoMount=p.resolve(process.cwd(),t.path??""),t=ce(t),delete t.autoMount);const o=ie(t["mount-before-install"]||[],"/wordpress")||ie(t.mount||[],"/wordpress");if(o)console.log("Site files stored at:",o?.hostPath),e.reset&&(console.log(""),console.log(ot("This site is not managed by Playground CLI and cannot be reset.")),console.log("(It's not stored in the ~/.wordpress-playground/sites/<site-id> directory.)"),console.log(""),console.log("You may still remove the site's directory manually if you wish."),process.exit(1));else{const s=t.autoMount||process.cwd(),r=Me.createHash("sha256").update(s).digest("hex"),n=B.homedir(),i=p.join(n,".wordpress-playground/sites",r);console.log("Site files stored at:",i),c.existsSync(i)&&e.reset&&(console.log("Resetting site..."),c.rmdirSync(i,{recursive:!0})),c.mkdirSync(i,{recursive:!0}),t["mount-before-install"]=[...t["mount-before-install"]||[],{vfsPath:"/wordpress",hostPath:i}],t.wordpressInstallMode=c.readdirSync(i).length===0?"download-and-install":"install-from-existing-files-if-needed"}return t}async function nt(e,t,o){const s=[];for(let r=0;r<e;r++){const i=me(t,{onExit:l=>{o({exitCode:l,workerIndex:r})}});s.push(i)}return Promise.all(s)}function me(e,{onExit:t}={}){let o;return e==="v1"?o=new Y.Worker(new URL("./worker-thread-v1.cjs",typeof document>"u"?require("url").pathToFileURL(__filename).href:R&&R.tagName.toUpperCase()==="SCRIPT"&&R.src||new URL("run-cli-DJNPNQa1.cjs",document.baseURI).href)):o=new Y.Worker(new URL("./worker-thread-v2.cjs",typeof document>"u"?require("url").pathToFileURL(__filename).href:R&&R.tagName.toUpperCase()==="SCRIPT"&&R.src||new URL("run-cli-DJNPNQa1.cjs",document.baseURI).href)),new Promise((s,r)=>{o.once("message",function(i){i.command==="worker-script-initialized"&&s({worker:o,phpPort:i.phpPort})}),o.once("error",function(i){console.error(i);const l=new Error(`Worker failed to load worker. ${i.message?`Original error: ${i.message}`:""}`);r(l)});let n=!1;o.once("spawn",()=>{n=!0}),o.once("exit",i=>{n||r(new Error(`Worker exited before spawning: ${i}`)),t?.(i)})})}async function le(e){const{port1:t,port2:o}=new Y.MessageChannel;return await Ce.jspi()?b.exposeAPI(e,null,t):await b.exposeSyncAPI(e,t),o}function it(e){const t=B.platform();let o;switch(t){case"darwin":o=`open "${e}"`;break;case"win32":o=`start "" "${e}"`;break;default:o=`xdg-open "${e}"`;break}We.exec(o,s=>{s&&d.logger.debug(`Could not open browser: ${s.message}`)})}async function at(e,t){await e.run({code:`<?php
|
|
36
|
+
$zip = new ZipArchive();
|
|
37
|
+
if(false === $zip->open('/tmp/build.zip', ZipArchive::CREATE | ZipArchive::OVERWRITE)) {
|
|
38
|
+
throw new Exception('Failed to create ZIP');
|
|
39
|
+
}
|
|
40
|
+
$files = new RecursiveIteratorIterator(
|
|
41
|
+
new RecursiveDirectoryIterator('/wordpress')
|
|
42
|
+
);
|
|
43
|
+
foreach ($files as $file) {
|
|
44
|
+
echo $file . PHP_EOL;
|
|
45
|
+
if (!$file->isFile()) {
|
|
46
|
+
continue;
|
|
47
|
+
}
|
|
48
|
+
$zip->addFile($file->getPathname(), $file->getPathname());
|
|
49
|
+
}
|
|
50
|
+
$zip->close();
|
|
51
|
+
|
|
52
|
+
`});const o=await e.readFileAsBuffer("/tmp/build.zip");c.writeFileSync(t,o)}exports.LogVerbosity=V;exports.internalsKeyForTesting=fe;exports.mountResources=Ue;exports.parseOptionsAndRunCLI=tt;exports.runCLI=he;exports.shouldRenderProgress=G;exports.spawnWorkerThread=me;
|
|
53
|
+
//# sourceMappingURL=run-cli-DJNPNQa1.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run-cli-DJNPNQa1.cjs","sources":["../../../../packages/playground/cli/src/mounts.ts","../../../../packages/playground/cli/src/start-server.ts","../../../../packages/playground/cli/src/load-balancer.ts","../../../../packages/playground/cli/src/is-valid-wordpress-slug.ts","../../../../packages/playground/cli/src/resolve-blueprint.ts","../../../../packages/playground/cli/src/utils/progress.ts","../../../../packages/playground/cli/src/blueprints-v2/blueprints-v2-handler.ts","../../../../packages/playground/cli/src/blueprints-v1/download.ts","../../../../packages/playground/cli/src/blueprints-v1/blueprints-v1-handler.ts","../../../../packages/playground/cli/src/temp-dir.ts","../../../../packages/playground/cli/src/run-cli.ts"],"sourcesContent":["import { createNodeFsMountHandler } from '@php-wasm/node';\nimport type { PHP } from '@php-wasm/universal';\nimport fs, { existsSync } from 'fs';\nimport path, { basename, join } from 'path';\nimport type { RunCLIArgs } from './run-cli';\nimport type { Mount } from '@php-wasm/cli-util';\n\n/**\n * Parse an array of mount argument strings where the host path and VFS path\n * are separated by a colon.\n *\n * Example:\n * parseMountWithDelimiterArguments( [ '/host/path:/vfs/path', '/host/path:/vfs/path' ] )\n * // returns:\n * [\n * { hostPath: '/host/path', vfsPath: '/vfs/path' },\n * { hostPath: '/host/path', vfsPath: '/vfs/path' }\n * ]\n *\n * @param mounts - An array of mount argument strings separated by a colon.\n * @returns An array of Mount objects.\n */\nexport function parseMountWithDelimiterArguments(mounts: string[]): Mount[] {\n\tconst parsedMounts = [];\n\tfor (const mount of mounts) {\n\t\tconst mountParts = mount.split(':');\n\t\tif (mountParts.length !== 2) {\n\t\t\tthrow new Error(`Invalid mount format: ${mount}.\n\t\t\t\tExpected format: /host/path:/vfs/path.\n\t\t\t\tIf your path contains a colon, e.g. C:\\\\myplugin, use the --mount-dir option instead.\n\t\t\t\tExample: --mount-dir C:\\\\my-plugin /wordpress/wp-content/plugins/my-plugin`);\n\t\t}\n\t\tconst [hostPath, vfsPath] = mountParts;\n\t\tif (!existsSync(hostPath)) {\n\t\t\tthrow new Error(`Host path does not exist: ${hostPath}`);\n\t\t}\n\t\tparsedMounts.push({ hostPath, vfsPath });\n\t}\n\treturn parsedMounts;\n}\n\n/**\n * Parse an array of mount argument strings where each odd array element is a host path\n * and each even element is the VFS path.\n * e.g. [ '/host/path', '/vfs/path', '/host/path2', '/vfs/path2' ]\n *\n * The result will be an array of Mount objects for each host path the\n * following element is it's VFS path.\n * e.g. [\n * { hostPath: '/host/path', vfsPath: '/vfs/path' },\n * { hostPath: '/host/path2', vfsPath: '/vfs/path2' }\n * ]\n *\n * @param mounts - An array of paths\n * @returns An array of Mount objects.\n */\nexport function parseMountDirArguments(mounts: string[]): Mount[] {\n\tif (mounts.length % 2 !== 0) {\n\t\tthrow new Error('Invalid mount format. Expected: /host/path /vfs/path');\n\t}\n\n\tconst parsedMounts = [];\n\tfor (let i = 0; i < mounts.length; i += 2) {\n\t\tconst source = mounts[i];\n\t\tconst vfsPath = mounts[i + 1];\n\t\tif (!existsSync(source)) {\n\t\t\tthrow new Error(`Host path does not exist: ${source}`);\n\t\t}\n\t\tparsedMounts.push({\n\t\t\thostPath: path.resolve(process.cwd(), source),\n\t\t\tvfsPath,\n\t\t});\n\t}\n\treturn parsedMounts;\n}\n\nexport async function mountResources(php: PHP, mounts: Mount[]) {\n\tfor (const mount of mounts) {\n\t\tawait php.mount(\n\t\t\tmount.vfsPath,\n\t\t\tcreateNodeFsMountHandler(mount.hostPath)\n\t\t);\n\t}\n}\n\nconst ACTIVATE_FIRST_THEME_STEP = {\n\tstep: 'runPHP',\n\tcode: {\n\t\tfilename: 'activate-theme.php',\n\t\t// @TODO: Remove DOCROOT check after moving totally to Blueprints v2.\n\t\tcontent: `<?php\n\t\t\t$docroot = getenv('DOCROOT') ? getenv('DOCROOT') : '/wordpress';\n\t\t\trequire_once \"$docroot/wp-load.php\";\n\t\t\t$theme = wp_get_theme();\n\t\t\tif (!$theme->exists()) {\n\t\t\t\t$themes = wp_get_themes();\n\t\t\t\tif (count($themes) > 0) {\n\t\t\t\t\t$themeName = array_keys($themes)[0];\n\t\t\t\t\tswitch_theme($themeName);\n\t\t\t\t}\n\t\t\t}\n\t\t`,\n\t},\n};\n\n/**\n * Auto-mounts resolution logic:\n */\nexport function expandAutoMounts(args: RunCLIArgs): RunCLIArgs {\n\tconst path = args.autoMount!;\n\n\tconst mount = [...(args.mount || [])];\n\tconst mountBeforeInstall = [...(args['mount-before-install'] || [])];\n\n\tconst newArgs = {\n\t\t...args,\n\t\tmount,\n\t\t'mount-before-install': mountBeforeInstall,\n\t\t'additional-blueprint-steps': [\n\t\t\t...((args as any)['additional-blueprint-steps'] || []),\n\t\t],\n\t};\n\n\tif (isPluginDirectory(path)) {\n\t\tconst pluginName = basename(path);\n\t\tmount.push({\n\t\t\thostPath: path,\n\t\t\tvfsPath: `/wordpress/wp-content/plugins/${pluginName}`,\n\t\t});\n\t\tnewArgs['additional-blueprint-steps'].push({\n\t\t\tstep: 'activatePlugin',\n\t\t\tpluginPath: `/wordpress/wp-content/plugins/${basename(path)}`,\n\t\t});\n\t} else if (isThemeDirectory(path)) {\n\t\tconst themeName = basename(path);\n\t\tmount.push({\n\t\t\thostPath: path,\n\t\t\tvfsPath: `/wordpress/wp-content/themes/${themeName}`,\n\t\t});\n\t\tnewArgs['additional-blueprint-steps'].push(\n\t\t\targs['experimental-blueprints-v2-runner']\n\t\t\t\t? {\n\t\t\t\t\t\tstep: 'activateTheme',\n\t\t\t\t\t\tthemeDirectoryName: themeName,\n\t\t\t\t\t}\n\t\t\t\t: {\n\t\t\t\t\t\tstep: 'activateTheme',\n\t\t\t\t\t\tthemeFolderName: themeName,\n\t\t\t\t\t}\n\t\t);\n\t} else if (containsWpContentDirectories(path)) {\n\t\t/**\n\t\t * Mount each wp-content file and directory individually.\n\t\t */\n\t\tconst files = fs.readdirSync(path);\n\t\tfor (const file of files) {\n\t\t\t/**\n\t\t\t * WordPress already ships with the wp-content/index.php file\n\t\t\t * and Playground does not support overriding existing VFS files\n\t\t\t * with mounts.\n\t\t\t */\n\t\t\tif (file === 'index.php') {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tmount.push({\n\t\t\t\thostPath: `${path}/${file}`,\n\t\t\t\tvfsPath: `/wordpress/wp-content/${file}`,\n\t\t\t});\n\t\t}\n\t\tnewArgs['additional-blueprint-steps'].push(ACTIVATE_FIRST_THEME_STEP);\n\t} else if (containsFullWordPressInstallation(path)) {\n\t\tmountBeforeInstall.push({ hostPath: path, vfsPath: '/wordpress' });\n\t\t// @TODO: If overriding another mode, throw an error or print a warning.\n\t\tnewArgs.mode = 'apply-to-existing-site';\n\t\tnewArgs['additional-blueprint-steps'].push(ACTIVATE_FIRST_THEME_STEP);\n\t\tif (!newArgs.wordpressInstallMode) {\n\t\t\tnewArgs.wordpressInstallMode =\n\t\t\t\t'install-from-existing-files-if-needed';\n\t\t}\n\t}\n\n\treturn newArgs as RunCLIArgs;\n}\n\nexport function containsFullWordPressInstallation(path: string): boolean {\n\tconst files = fs.readdirSync(path);\n\treturn (\n\t\tfiles.includes('wp-admin') &&\n\t\tfiles.includes('wp-includes') &&\n\t\tfiles.includes('wp-content')\n\t);\n}\n\nexport function containsWpContentDirectories(path: string): boolean {\n\tconst files = fs.readdirSync(path);\n\treturn (\n\t\tfiles.includes('themes') ||\n\t\tfiles.includes('plugins') ||\n\t\tfiles.includes('mu-plugins') ||\n\t\tfiles.includes('uploads')\n\t);\n}\n\nexport function isThemeDirectory(path: string): boolean {\n\tconst files = fs.readdirSync(path);\n\tif (!files.includes('style.css')) {\n\t\treturn false;\n\t}\n\tconst styleCssContent = fs.readFileSync(join(path, 'style.css'), 'utf8');\n\tconst themeNameRegex = /^(?:[ \\t]*<\\?php)?[ \\t/*#@]*Theme Name:(.*)$/im;\n\treturn !!themeNameRegex.exec(styleCssContent);\n}\n\nexport function isPluginDirectory(path: string): boolean {\n\tconst files = fs.readdirSync(path);\n\tconst pluginNameRegex = /^(?:[ \\t]*<\\?php)?[ \\t/*#@]*Plugin Name:(.*)$/im;\n\tconst pluginNameMatch = files\n\t\t.filter((file) => file.endsWith('.php'))\n\t\t.find((file) => {\n\t\t\tconst fileContent = fs.readFileSync(join(path, file), 'utf8');\n\t\t\treturn !!pluginNameRegex.exec(fileContent);\n\t\t});\n\treturn !!pluginNameMatch;\n}\n","import { type PHPRequest, PHPResponse } from '@php-wasm/universal';\nimport type { Request } from 'express';\nimport express from 'express';\nimport type { IncomingMessage, Server, ServerResponse } from 'http';\nimport type { AddressInfo } from 'net';\nimport type { RunCLIServer } from './run-cli';\nimport { logger } from '@php-wasm/logger';\n\nexport interface ServerOptions {\n\tport: number;\n\tonBind: (server: Server, port: number) => Promise<RunCLIServer | void>;\n\thandleRequest: (request: PHPRequest) => Promise<PHPResponse>;\n}\n\nexport async function startServer(\n\toptions: ServerOptions\n): Promise<RunCLIServer | void> {\n\tconst app = express();\n\n\tconst server = await new Promise<\n\t\tServer<typeof IncomingMessage, typeof ServerResponse>\n\t>((resolve, reject) => {\n\t\tconst server = app.listen(options.port, () => {\n\t\t\tconst address = server.address();\n\t\t\tif (address === null || typeof address === 'string') {\n\t\t\t\treject(new Error('Server address is not available'));\n\t\t\t} else {\n\t\t\t\tresolve(server);\n\t\t\t}\n\t\t});\n\t});\n\n\tapp.use('/', async (req, res) => {\n\t\tlet phpResponse: PHPResponse;\n\t\ttry {\n\t\t\tphpResponse = await options.handleRequest({\n\t\t\t\turl: req.url,\n\t\t\t\theaders: parseHeaders(req),\n\t\t\t\tmethod: req.method as any,\n\t\t\t\tbody: await bufferRequestBody(req),\n\t\t\t});\n\t\t} catch (error) {\n\t\t\tlogger.error(error);\n\t\t\tphpResponse = PHPResponse.forHttpCode(500);\n\t\t}\n\n\t\tres.statusCode = phpResponse.httpStatusCode;\n\t\tfor (const key in phpResponse.headers) {\n\t\t\tres.setHeader(key, phpResponse.headers[key]);\n\t\t}\n\t\tres.end(phpResponse.bytes);\n\t});\n\n\tconst address = server.address();\n\tconst port = (address! as AddressInfo).port;\n\treturn await options.onBind(server, port);\n}\n\nconst bufferRequestBody = async (req: Request): Promise<Uint8Array> =>\n\tawait new Promise((resolve) => {\n\t\tconst body: Uint8Array[] = [];\n\t\treq.on('data', (chunk) => {\n\t\t\tbody.push(chunk);\n\t\t});\n\t\treq.on('end', () => {\n\t\t\tresolve(new Uint8Array(Buffer.concat(body)));\n\t\t});\n\t});\n\nconst parseHeaders = (req: Request): Record<string, string> => {\n\tconst requestHeaders: Record<string, string> = {};\n\tif (req.rawHeaders && req.rawHeaders.length) {\n\t\tfor (let i = 0; i < req.rawHeaders.length; i += 2) {\n\t\t\trequestHeaders[req.rawHeaders[i].toLowerCase()] =\n\t\t\t\treq.rawHeaders[i + 1];\n\t\t}\n\t}\n\treturn requestHeaders;\n};\n","import type { PHPRequest, PHPResponse, RemoteAPI } from '@php-wasm/universal';\nimport type { PlaygroundCliBlueprintV1Worker as PlaygroundCliWorkerV1 } from './blueprints-v1/worker-thread-v1';\nimport type { PlaygroundCliBlueprintV2Worker as PlaygroundCliWorkerV2 } from './blueprints-v2/worker-thread-v2';\n\ntype PlaygroundCliWorker = PlaygroundCliWorkerV1 | PlaygroundCliWorkerV2;\n\n// TODO: Let's merge worker management into PHPProcessManager\n// when we can have multiple workers in both CLI and web.\n// ¡ATTENTION!:Please don't expand upon this as an independent abstraction.\n\n// TODO: Could we just spawn a worker using the factory function to PHPProcessManager?\ntype WorkerLoad = {\n\tworker: RemoteAPI<PlaygroundCliWorker>;\n\tactiveRequests: Set<Promise<PHPResponse>>;\n};\nexport class LoadBalancer {\n\tworkerLoads: WorkerLoad[] = [];\n\n\tconstructor(\n\t\t// NOTE: We require a worker to start so that a load balancer\n\t\t// may not exist without being able to service requests.\n\t\t// Playground CLI initialization, as of 2025-06-11, requires that\n\t\t// an initial worker is booted alone and initialized via Blueprint\n\t\t// before additional workers are created based on the initialized worker.\n\t\tinitialWorker: RemoteAPI<PlaygroundCliWorker>\n\t) {\n\t\tthis.addWorker(initialWorker);\n\t}\n\n\taddWorker(worker: RemoteAPI<PlaygroundCliWorker>) {\n\t\tthis.workerLoads.push({\n\t\t\tworker,\n\t\t\tactiveRequests: new Set(),\n\t\t});\n\t}\n\tasync removeWorker(worker: RemoteAPI<PlaygroundCliWorker>) {\n\t\tconst workerIndex = this.workerLoads.findIndex(\n\t\t\t(workerLoad) => workerLoad.worker === worker\n\t\t);\n\t\tif (workerIndex === -1) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst [removedWorker] = this.workerLoads.splice(workerIndex, 1);\n\n\t\t// A worker can only be considered fully removed once all\n\t\t// its active requests have settled.\n\t\tawait Promise.allSettled(removedWorker.activeRequests);\n\t}\n\n\tasync handleRequest(request: PHPRequest) {\n\t\tlet smallestWorkerLoad = this.workerLoads[0];\n\n\t\t// TODO: Is there any way for us to track CPU load so we could avoid\n\t\t// picking a worker that is under heavy load despite few requests?\n\t\t// Possibly this: https://nodejs.org/api/worker_threads.html#workerperformance\n\t\t// Though we probably don't need to worry about it.\n\t\tfor (let i = 1; i < this.workerLoads.length; i++) {\n\t\t\tconst workerLoad = this.workerLoads[i];\n\t\t\tif (\n\t\t\t\tworkerLoad.activeRequests.size <\n\t\t\t\tsmallestWorkerLoad.activeRequests.size\n\t\t\t) {\n\t\t\t\tsmallestWorkerLoad = workerLoad;\n\t\t\t}\n\t\t}\n\n\t\t// TODO: Add trace facility to Playground CLI to observe internals like request routing.\n\n\t\tconst promiseForResponse = smallestWorkerLoad.worker.request(request);\n\t\tsmallestWorkerLoad.activeRequests.add(promiseForResponse);\n\n\t\t// Add URL to promise for use while debugging\n\t\t(promiseForResponse as any).url = request.url;\n\n\t\treturn promiseForResponse.finally(() => {\n\t\t\tsmallestWorkerLoad.activeRequests.delete(promiseForResponse);\n\t\t});\n\t}\n}\n","/**\n * Checks if the given version string is a valid WordPress version.\n *\n * The Regex is based on the releases on https://wordpress.org/download/releases/#betas\n * The version string can be one of the following formats:\n * - \"latest\"\n * - \"trunk\"\n * - \"trunk\" (legacy alias: \"nightly\")\n * - \"x.y\" (x and y are integers) e.g. \"6.2\"\n * - \"x.y.z\" (x, y and z are integers) e.g. \"6.2.1\"\n * - \"x.y.z-betaN\" (N is an integer) e.g. \"6.2.1-beta1\"\n * - \"x.y.z-RCN\" (N is an integer) e.g. \"6.2-RC1\"\n *\n * @param version The version string to check.\n * @returns A boolean value indicating whether the version string is a valid WordPress version.\n */\nexport function isValidWordPressSlug(version: string): boolean {\n\tconst versionPattern =\n\t\t/^latest$|^trunk$|^nightly$|^(?:(\\d+)\\.(\\d+)(?:\\.(\\d+))?)((?:-beta(?:\\d+)?)|(?:-RC(?:\\d+)?))?$/;\n\treturn versionPattern.test(version);\n}\n","import fs from 'fs';\nimport path from 'path';\nimport {\n\tZipFilesystem,\n\tNodeJsFilesystem,\n\tOverlayFilesystem,\n\tInMemoryFilesystem,\n} from '@wp-playground/storage';\nimport { resolveRemoteBlueprint } from '@wp-playground/blueprints';\n\ntype ResolveBlueprintOptions = {\n\tsourceString: string | undefined;\n\tblueprintMayReadAdjacentFiles: boolean;\n};\n\n/**\n * Resolves a blueprint from a URL or a local path.\n *\n * @TODO: Extract the common Blueprint resolution logic between CLI and\n * the website into a single, isomorphic resolveBlueprint() function.\n * Still retain the CLI-specific bits in the CLI package.\n *\n * @param sourceString - The source string to resolve the blueprint from.\n * @param blueprintMayReadAdjacentFiles - Whether the blueprint may read adjacent files.\n * @returns The resolved blueprint.\n */\nexport async function resolveBlueprint({\n\tsourceString,\n\tblueprintMayReadAdjacentFiles,\n}: ResolveBlueprintOptions) {\n\tif (!sourceString) {\n\t\treturn undefined;\n\t}\n\n\tif (\n\t\tsourceString.startsWith('http://') ||\n\t\tsourceString.startsWith('https://')\n\t) {\n\t\treturn await resolveRemoteBlueprint(sourceString);\n\t}\n\n\t// If the sourceString does not refer to a remote blueprint, try to\n\t// resolve it from a local filesystem.\n\n\tlet blueprintPath = path.resolve(process.cwd(), sourceString);\n\tif (!fs.existsSync(blueprintPath)) {\n\t\tthrow new Error(`Blueprint file does not exist: ${blueprintPath}`);\n\t}\n\n\tconst stat = fs.statSync(blueprintPath);\n\tif (stat.isDirectory()) {\n\t\tblueprintPath = path.join(blueprintPath, 'blueprint.json');\n\t}\n\n\tif (!stat.isFile() && stat.isSymbolicLink()) {\n\t\tthrow new Error(\n\t\t\t`Blueprint path is neither a file nor a directory: ${blueprintPath}`\n\t\t);\n\t}\n\n\tconst extension = path.extname(blueprintPath);\n\tswitch (extension) {\n\t\tcase '.zip':\n\t\t\treturn ZipFilesystem.fromArrayBuffer(\n\t\t\t\tfs.readFileSync(blueprintPath).buffer as ArrayBuffer\n\t\t\t);\n\t\tcase '.json': {\n\t\t\tconst blueprintText = fs.readFileSync(blueprintPath, 'utf-8');\n\t\t\ttry {\n\t\t\t\tJSON.parse(blueprintText);\n\t\t\t} catch {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Blueprint file at ${blueprintPath} is not a valid JSON file`\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tconst contextPath = path.dirname(blueprintPath);\n\t\t\tconst nodeJsFilesystem = new NodeJsFilesystem(contextPath);\n\t\t\treturn new OverlayFilesystem([\n\t\t\t\tnew InMemoryFilesystem({\n\t\t\t\t\t'blueprint.json': blueprintText,\n\t\t\t\t}),\n\t\t\t\t/**\n\t\t\t\t * Wrap the NodeJS filesystem to prevent access to local files\n\t\t\t\t * unless the user explicitly allowed it.\n\t\t\t\t */\n\t\t\t\t{\n\t\t\t\t\tread(path) {\n\t\t\t\t\t\tif (!blueprintMayReadAdjacentFiles) {\n\t\t\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\t\t`Error: Blueprint contained tried to read a local file at path \"${path}\" (via a resource of type \"bundled\"). ` +\n\t\t\t\t\t\t\t\t\t`Playground restricts access to local resources by default as a security measure. \\n\\n` +\n\t\t\t\t\t\t\t\t\t`You can allow this Blueprint to read files from the same parent directory by explicitly adding the ` +\n\t\t\t\t\t\t\t\t\t`--blueprint-may-read-adjacent-files option to your command.`\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn nodeJsFilesystem.read(path);\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t]);\n\t\t}\n\t\tdefault:\n\t\t\tthrow new Error(\n\t\t\t\t`Unsupported blueprint file extension: ${extension}. Only .zip and .json files are supported.`\n\t\t\t);\n\t}\n}\n","export function shouldRenderProgress(\n\twriteStream?: { isTTY?: boolean } | null\n): boolean {\n\tif (process.env['CI'] === 'true' || process.env['CI'] === '1') {\n\t\treturn false;\n\t}\n\tif (\n\t\tprocess.env['GITHUB_ACTIONS'] === 'true' ||\n\t\tprocess.env['GITHUB_ACTIONS'] === '1'\n\t) {\n\t\treturn false;\n\t}\n\tif ((process.env['TERM'] || '').toLowerCase() === 'dumb') {\n\t\treturn false;\n\t}\n\tif (writeStream) {\n\t\treturn Boolean(writeStream.isTTY);\n\t}\n\treturn process.stdout.isTTY;\n}\n","import type { RemoteAPI, SupportedPHPVersion } from '@php-wasm/universal';\nimport { consumeAPI } from '@php-wasm/universal';\nimport type {\n\tPlaygroundCliBlueprintV2Worker,\n\tSecondaryWorkerBootArgs,\n} from './worker-thread-v2';\nimport type { MessagePort as NodeMessagePort } from 'worker_threads';\nimport type { RunCLIArgs, SpawnedWorker, WorkerType } from '../run-cli';\nimport { shouldRenderProgress } from '../utils/progress';\n\n/**\n * Boots Playground CLI workers using Blueprint version 2.\n *\n * Progress tracking, downloads, steps, and all other features are\n * implemented in PHP and orchestrated by the worker thread.\n */\nexport class BlueprintsV2Handler {\n\tprivate phpVersion: SupportedPHPVersion;\n\tprivate lastProgressMessage = '';\n\n\tprivate siteUrl: string;\n\tprivate processIdSpaceLength: number;\n\tprivate args: RunCLIArgs;\n\n\tconstructor(\n\t\targs: RunCLIArgs,\n\t\toptions: {\n\t\t\tsiteUrl: string;\n\t\t\tprocessIdSpaceLength: number;\n\t\t}\n\t) {\n\t\tthis.args = args;\n\t\tthis.siteUrl = options.siteUrl;\n\t\tthis.processIdSpaceLength = options.processIdSpaceLength;\n\t\tthis.phpVersion = args.php as SupportedPHPVersion;\n\t}\n\n\tgetWorkerType(): WorkerType {\n\t\treturn 'v2';\n\t}\n\n\tasync bootAndSetUpInitialPlayground(\n\t\tphpPort: NodeMessagePort,\n\t\tfileLockManagerPort: NodeMessagePort,\n\t\tnativeInternalDirPath: string\n\t) {\n\t\tconst playground: RemoteAPI<PlaygroundCliBlueprintV2Worker> =\n\t\t\tconsumeAPI(phpPort);\n\n\t\tawait playground.useFileLockManager(fileLockManagerPort);\n\n\t\tconst workerBootArgs = {\n\t\t\t...this.args,\n\t\t\tphpVersion: this.phpVersion,\n\t\t\tsiteUrl: this.siteUrl,\n\t\t\tfirstProcessId: 1,\n\t\t\tprocessIdSpaceLength: this.processIdSpaceLength,\n\t\t\ttrace: this.args.verbosity === 'debug',\n\t\t\tblueprint: this.args.blueprint!,\n\t\t\twithIntl: this.args.intl,\n\t\t\t// We do not enable Xdebug by default for the initial worker\n\t\t\t// because we do not imagine users expect to hit breakpoints\n\t\t\t// until Playground has fully booted.\n\t\t\t// TODO: Consider supporting Xdebug for the initial worker via a dedicated flag.\n\t\t\twithXdebug: false,\n\t\t\txdebug: undefined,\n\t\t\tnativeInternalDirPath,\n\t\t\tmountsBeforeWpInstall: this.args['mount-before-install'] || [],\n\t\t\tmountsAfterWpInstall: this.args.mount || [],\n\t\t};\n\n\t\tawait playground.bootAndSetUpInitialWorker(workerBootArgs);\n\t\treturn playground;\n\t}\n\n\tasync bootPlayground({\n\t\tworker,\n\t\tfileLockManagerPort,\n\t\tfirstProcessId,\n\t\tnativeInternalDirPath,\n\t}: {\n\t\tworker: SpawnedWorker;\n\t\tfileLockManagerPort: NodeMessagePort;\n\t\tfirstProcessId: number;\n\t\tnativeInternalDirPath: string;\n\t}) {\n\t\tconst playground: RemoteAPI<PlaygroundCliBlueprintV2Worker> =\n\t\t\tconsumeAPI(worker.phpPort);\n\n\t\tawait playground.useFileLockManager(fileLockManagerPort);\n\n\t\tconst workerBootArgs: SecondaryWorkerBootArgs = {\n\t\t\t...this.args,\n\t\t\tphpVersion: this.phpVersion,\n\t\t\tsiteUrl: this.siteUrl,\n\t\t\tfirstProcessId,\n\t\t\tprocessIdSpaceLength: this.processIdSpaceLength,\n\t\t\ttrace: this.args.verbosity === 'debug',\n\t\t\twithIntl: this.args.intl,\n\t\t\twithXdebug: !!this.args.xdebug,\n\t\t\tnativeInternalDirPath,\n\t\t\tmountsBeforeWpInstall: this.args['mount-before-install'] || [],\n\t\t\tmountsAfterWpInstall: this.args.mount || [],\n\t\t};\n\n\t\tawait playground.bootWorker(workerBootArgs);\n\n\t\treturn playground;\n\t}\n\n\twriteProgressUpdate(\n\t\twriteStream: NodeJS.WriteStream,\n\t\tmessage: string,\n\t\tfinalUpdate: boolean\n\t) {\n\t\tif (!shouldRenderProgress(writeStream)) {\n\t\t\treturn;\n\t\t}\n\t\tif (message === this.lastProgressMessage) {\n\t\t\t// Avoid repeating the same message\n\t\t\treturn;\n\t\t}\n\t\tthis.lastProgressMessage = message;\n\n\t\tif (writeStream.isTTY) {\n\t\t\t// Overwrite previous progress updates in-place for a quieter UX.\n\t\t\twriteStream.cursorTo(0);\n\t\t\twriteStream.write(message);\n\t\t\twriteStream.clearLine(1);\n\n\t\t\tif (finalUpdate) {\n\t\t\t\twriteStream.write('\\n');\n\t\t\t}\n\t\t} else {\n\t\t\t// Fall back to writing one line per progress update\n\t\t\twriteStream.write(`${message}\\n`);\n\t\t}\n\t}\n}\n","import type { EmscriptenDownloadMonitor } from '@php-wasm/progress';\nimport fs from 'fs-extra';\nimport os from 'os';\nimport path, { basename } from 'path';\n\nexport const CACHE_FOLDER = path.join(os.homedir(), '.wordpress-playground');\n\nexport async function fetchSqliteIntegration(\n\tmonitor: EmscriptenDownloadMonitor\n) {\n\tconst sqliteZip = await cachedDownload(\n\t\t'https://github.com/WordPress/sqlite-database-integration/archive/refs/heads/develop.zip',\n\t\t'sqlite.zip',\n\t\tmonitor\n\t);\n\treturn sqliteZip;\n}\n\n// @TODO: Support HTTP cache, invalidate the local file if the remote file has\n// changed\nexport async function cachedDownload(\n\tremoteUrl: string,\n\tcacheKey: string,\n\tmonitor: EmscriptenDownloadMonitor\n) {\n\tconst artifactPath = path.join(CACHE_FOLDER, cacheKey);\n\tif (!fs.existsSync(artifactPath)) {\n\t\tfs.ensureDirSync(CACHE_FOLDER);\n\t\tawait downloadTo(remoteUrl, artifactPath, monitor);\n\t}\n\treturn readAsFile(artifactPath);\n}\n\nasync function downloadTo(\n\tremoteUrl: string,\n\tlocalPath: string,\n\tmonitor: EmscriptenDownloadMonitor\n) {\n\tconst response = await monitor.monitorFetch(fetch(remoteUrl));\n\tconst reader = response.body!.getReader();\n\tconst tmpPath = `${localPath}.partial`;\n\tconst writer = fs.createWriteStream(tmpPath);\n\twhile (true) {\n\t\tconst { done, value } = await reader.read();\n\t\tif (value) {\n\t\t\twriter.write(value);\n\t\t}\n\t\tif (done) {\n\t\t\tbreak;\n\t\t}\n\t}\n\twriter.close();\n\tif (!writer.closed) {\n\t\tawait new Promise((resolve, reject) => {\n\t\t\twriter.on('finish', () => {\n\t\t\t\tfs.renameSync(tmpPath, localPath);\n\t\t\t\tresolve(null);\n\t\t\t});\n\t\t\twriter.on('error', (err: any) => {\n\t\t\t\tfs.removeSync(tmpPath);\n\t\t\t\treject(err);\n\t\t\t});\n\t\t});\n\t}\n}\n\nexport function readAsFile(path: string, fileName?: string): File {\n\treturn new File([fs.readFileSync(path)], fileName ?? basename(path));\n}\n","import { logger } from '@php-wasm/logger';\nimport { EmscriptenDownloadMonitor, ProgressTracker } from '@php-wasm/progress';\nimport { consumeAPI } from '@php-wasm/universal';\nimport type { BlueprintV1Declaration } from '@wp-playground/blueprints';\nimport {\n\tcompileBlueprintV1,\n\tisBlueprintBundle,\n\tresolveRuntimeConfiguration,\n} from '@wp-playground/blueprints';\nimport { RecommendedPHPVersion, zipDirectory } from '@wp-playground/common';\nimport fs from 'fs';\nimport path from 'path';\nimport { resolveWordPressRelease } from '@wp-playground/wordpress';\nimport {\n\tCACHE_FOLDER,\n\tcachedDownload,\n\tfetchSqliteIntegration,\n\treadAsFile,\n} from './download';\nimport type { PlaygroundCliBlueprintV1Worker } from './worker-thread-v1';\nimport type { MessagePort as NodeMessagePort } from 'worker_threads';\nimport {\n\tLogVerbosity,\n\ttype RunCLIArgs,\n\ttype SpawnedWorker,\n\ttype WorkerType,\n} from '../run-cli';\nimport { shouldRenderProgress } from '../utils/progress';\n\n/**\n * Boots Playground CLI workers using Blueprint version 1.\n *\n * Progress tracking, downloads, steps, and all other features are\n * implemented in TypeScript and orchestrated by this class.\n */\nexport class BlueprintsV1Handler {\n\tprivate lastProgressMessage = '';\n\n\tprivate siteUrl: string;\n\tprivate processIdSpaceLength: number;\n\tprivate args: RunCLIArgs;\n\n\tconstructor(\n\t\targs: RunCLIArgs,\n\t\toptions: {\n\t\t\tsiteUrl: string;\n\t\t\tprocessIdSpaceLength: number;\n\t\t}\n\t) {\n\t\tthis.args = args;\n\t\tthis.siteUrl = options.siteUrl;\n\t\tthis.processIdSpaceLength = options.processIdSpaceLength;\n\t}\n\n\tgetWorkerType(): WorkerType {\n\t\treturn 'v1';\n\t}\n\n\tasync bootAndSetUpInitialPlayground(\n\t\tphpPort: NodeMessagePort,\n\t\tfileLockManagerPort: NodeMessagePort,\n\t\tnativeInternalDirPath: string\n\t) {\n\t\tlet wpDetails: any = undefined;\n\t\tlet wordPressZip: any = undefined;\n\t\tlet preinstalledWpContentPath: string | undefined = undefined;\n\t\t// @TODO: Rename to FetchProgressMonitor. There's nothing Emscripten\n\t\t// about that class anymore.\n\t\tconst monitor = new EmscriptenDownloadMonitor();\n\t\tif (this.args.wordpressInstallMode === 'download-and-install') {\n\t\t\tlet progressReached100 = false;\n\t\t\tmonitor.addEventListener('progress', ((\n\t\t\t\te: CustomEvent<ProgressEvent & { finished: boolean }>\n\t\t\t) => {\n\t\t\t\tif (progressReached100) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// @TODO Every progress bar will want percentages. The\n\t\t\t\t// download monitor should just provide that.\n\t\t\t\tconst { loaded, total } = e.detail;\n\t\t\t\t// Use floor() so we don't report 100% until truly there.\n\t\t\t\tconst percentProgress = Math.floor(\n\t\t\t\t\tMath.min(100, (100 * loaded) / total)\n\t\t\t\t);\n\t\t\t\tprogressReached100 = percentProgress === 100;\n\n\t\t\t\tthis.writeProgressUpdate(\n\t\t\t\t\tprocess.stdout,\n\t\t\t\t\t`Downloading WordPress ${percentProgress}%...`,\n\t\t\t\t\tprogressReached100\n\t\t\t\t);\n\t\t\t}) as any);\n\n\t\t\twpDetails = await resolveWordPressRelease(this.args.wp);\n\t\t\tpreinstalledWpContentPath = path.join(\n\t\t\t\tCACHE_FOLDER,\n\t\t\t\t`prebuilt-wp-content-for-wp-${wpDetails.version}.zip`\n\t\t\t);\n\t\t\twordPressZip = fs.existsSync(preinstalledWpContentPath)\n\t\t\t\t? readAsFile(preinstalledWpContentPath)\n\t\t\t\t: await cachedDownload(\n\t\t\t\t\t\twpDetails.releaseUrl,\n\t\t\t\t\t\t`${wpDetails.version}.zip`,\n\t\t\t\t\t\tmonitor\n\t\t\t\t\t);\n\t\t\tlogger.log(\n\t\t\t\t`Resolved WordPress release URL: ${wpDetails?.releaseUrl}`\n\t\t\t);\n\t\t}\n\n\t\tlet sqliteIntegrationPluginZip;\n\t\tif (this.args.skipSqliteSetup) {\n\t\t\tlogger.log(`Skipping SQLite integration plugin setup...`);\n\t\t\tsqliteIntegrationPluginZip = undefined;\n\t\t} else {\n\t\t\tlogger.log(`Fetching SQLite integration plugin...`);\n\t\t\tsqliteIntegrationPluginZip = await fetchSqliteIntegration(monitor);\n\t\t}\n\n\t\tconst followSymlinks = this.args.followSymlinks === true;\n\t\tconst trace = this.args.experimentalTrace === true;\n\n\t\tconst mountsBeforeWpInstall = this.args['mount-before-install'] || [];\n\t\tconst mountsAfterWpInstall = this.args.mount || [];\n\n\t\tconst playground = consumeAPI<PlaygroundCliBlueprintV1Worker>(phpPort);\n\n\t\t// Comlink communication proxy\n\t\tawait playground.isConnected();\n\n\t\tlogger.log(`Booting WordPress...`);\n\n\t\tconst runtimeConfiguration = await resolveRuntimeConfiguration(\n\t\t\tthis.getEffectiveBlueprint()\n\t\t);\n\n\t\tawait playground.useFileLockManager(fileLockManagerPort);\n\t\tawait playground.bootAndSetUpInitialWorker({\n\t\t\tphpVersion: runtimeConfiguration.phpVersion,\n\t\t\twpVersion: runtimeConfiguration.wpVersion,\n\t\t\tsiteUrl: this.siteUrl,\n\t\t\tmountsBeforeWpInstall,\n\t\t\tmountsAfterWpInstall,\n\t\t\twordpressInstallMode:\n\t\t\t\tthis.args.wordpressInstallMode || 'download-and-install',\n\t\t\twordPressZip: wordPressZip && (await wordPressZip!.arrayBuffer()),\n\t\t\tsqliteIntegrationPluginZip:\n\t\t\t\tawait sqliteIntegrationPluginZip?.arrayBuffer(),\n\t\t\tfirstProcessId: 0,\n\t\t\tprocessIdSpaceLength: this.processIdSpaceLength,\n\t\t\tfollowSymlinks,\n\t\t\ttrace,\n\t\t\tinternalCookieStore: this.args.internalCookieStore,\n\t\t\twithIntl: this.args.intl,\n\t\t\t// We do not enable Xdebug by default for the initial worker\n\t\t\t// because we do not imagine users expect to hit breakpoints\n\t\t\t// until Playground has fully booted.\n\t\t\t// TODO: Consider supporting Xdebug for the initial worker via a dedicated flag.\n\t\t\twithXdebug: false,\n\t\t\tnativeInternalDirPath,\n\t\t});\n\n\t\tif (\n\t\t\tpreinstalledWpContentPath &&\n\t\t\t!this.args['mount-before-install'] &&\n\t\t\t!fs.existsSync(preinstalledWpContentPath)\n\t\t) {\n\t\t\tlogger.log(`Caching preinstalled WordPress for the next boot...`);\n\t\t\tfs.writeFileSync(\n\t\t\t\tpreinstalledWpContentPath,\n\t\t\t\t(await zipDirectory(playground, '/wordpress'))!\n\t\t\t);\n\t\t\tlogger.log(`Cached!`);\n\t\t}\n\n\t\treturn playground;\n\t}\n\n\tasync bootPlayground({\n\t\tworker,\n\t\tfileLockManagerPort,\n\t\tfirstProcessId,\n\t\tnativeInternalDirPath,\n\t}: {\n\t\tworker: SpawnedWorker;\n\t\tfileLockManagerPort: NodeMessagePort;\n\t\tfirstProcessId: number;\n\t\tnativeInternalDirPath: string;\n\t}) {\n\t\tconst playground = consumeAPI<PlaygroundCliBlueprintV1Worker>(\n\t\t\tworker.phpPort\n\t\t);\n\n\t\tawait playground.isConnected();\n\t\tconst runtimeConfiguration = await resolveRuntimeConfiguration(\n\t\t\tthis.getEffectiveBlueprint()\n\t\t);\n\t\tawait playground.useFileLockManager(fileLockManagerPort);\n\t\tawait playground.bootWorker({\n\t\t\tphpVersion: runtimeConfiguration.phpVersion,\n\t\t\tsiteUrl: this.siteUrl,\n\t\t\tmountsBeforeWpInstall: this.args['mount-before-install'] || [],\n\t\t\tmountsAfterWpInstall: this.args['mount'] || [],\n\t\t\tfirstProcessId,\n\t\t\tprocessIdSpaceLength: this.processIdSpaceLength,\n\t\t\tfollowSymlinks: this.args.followSymlinks === true,\n\t\t\ttrace: this.args.experimentalTrace === true,\n\t\t\t// @TODO: Move this to the request handler or else every worker\n\t\t\t// will have a separate cookie store.\n\t\t\tinternalCookieStore: this.args.internalCookieStore,\n\t\t\twithIntl: this.args.intl,\n\t\t\twithXdebug: !!this.args.xdebug,\n\t\t\tnativeInternalDirPath,\n\t\t});\n\t\tawait playground.isReady();\n\t\treturn playground;\n\t}\n\n\tasync compileInputBlueprint(additionalBlueprintSteps: any[]) {\n\t\tconst blueprint = this.getEffectiveBlueprint();\n\n\t\tconst tracker = new ProgressTracker();\n\t\tlet lastCaption = '';\n\t\tlet progressReached100 = false;\n\t\ttracker.addEventListener('progress', (e: any) => {\n\t\t\tif (progressReached100) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tprogressReached100 = e.detail.progress === 100;\n\n\t\t\t// Use floor() so we don't report 100% until truly there.\n\t\t\tconst progressInteger = Math.floor(e.detail.progress);\n\t\t\tlastCaption =\n\t\t\t\te.detail.caption || lastCaption || 'Running the Blueprint';\n\t\t\tconst message = `${lastCaption.trim()} – ${progressInteger}%`;\n\t\t\tthis.writeProgressUpdate(\n\t\t\t\tprocess.stdout,\n\t\t\t\tmessage,\n\t\t\t\tprogressReached100\n\t\t\t);\n\t\t});\n\t\treturn await compileBlueprintV1(blueprint as BlueprintV1Declaration, {\n\t\t\tprogress: tracker,\n\t\t\tadditionalSteps: additionalBlueprintSteps,\n\t\t});\n\t}\n\n\tprivate getEffectiveBlueprint() {\n\t\tconst resolvedBlueprint = this.args.blueprint as BlueprintV1Declaration;\n\t\t/**\n\t\t * @TODO This looks similar to the resolveBlueprint() call in the website package:\n\t\t * \t https://github.com/WordPress/wordpress-playground/blob/ce586059e5885d185376184fdd2f52335cca32b0/packages/playground/website/src/main.tsx#L41\n\t\t *\n\t\t * \t\t Also the Blueprint Builder tool does something similar.\n\t\t * Perhaps all these cases could be handled by the same function?\n\t\t */\n\t\treturn isBlueprintBundle(resolvedBlueprint)\n\t\t\t? resolvedBlueprint\n\t\t\t: {\n\t\t\t\t\tlogin: this.args.login,\n\t\t\t\t\t...(resolvedBlueprint || {}),\n\t\t\t\t\tpreferredVersions: {\n\t\t\t\t\t\tphp:\n\t\t\t\t\t\t\tthis.args.php ??\n\t\t\t\t\t\t\tresolvedBlueprint?.preferredVersions?.php ??\n\t\t\t\t\t\t\tRecommendedPHPVersion,\n\t\t\t\t\t\twp:\n\t\t\t\t\t\t\tthis.args.wp ??\n\t\t\t\t\t\t\tresolvedBlueprint?.preferredVersions?.wp ??\n\t\t\t\t\t\t\t'latest',\n\t\t\t\t\t\t...(resolvedBlueprint?.preferredVersions || {}),\n\t\t\t\t\t},\n\t\t\t\t};\n\t}\n\n\twriteProgressUpdate(\n\t\twriteStream: NodeJS.WriteStream,\n\t\tmessage: string,\n\t\tfinalUpdate: boolean\n\t) {\n\t\tif (this.args.verbosity === LogVerbosity.Quiet.name) {\n\t\t\treturn;\n\t\t}\n\t\tif (!shouldRenderProgress(writeStream)) {\n\t\t\treturn;\n\t\t}\n\t\tif (message === this.lastProgressMessage) {\n\t\t\t// Avoid repeating the same message\n\t\t\treturn;\n\t\t}\n\t\tthis.lastProgressMessage = message;\n\n\t\tif (writeStream.isTTY) {\n\t\t\t// Overwrite previous progress updates in-place for a quieter UX.\n\t\t\twriteStream.cursorTo(0);\n\t\t\twriteStream.write(message);\n\t\t\twriteStream.clearLine(1);\n\n\t\t\tif (finalUpdate) {\n\t\t\t\twriteStream.write('\\n');\n\t\t\t}\n\t\t} else {\n\t\t\t// Fall back to writing one line per progress update\n\t\t\twriteStream.write(`${message}\\n`);\n\t\t}\n\t}\n}\n","import fs from 'fs';\nimport path from 'path';\nimport { logger } from '@php-wasm/logger';\nimport {\n\tdir as tmpDir,\n\tsetGracefulCleanup as tmpSetGracefulCleanup,\n} from 'tmp-promise';\n// NOTE: We use ps-man rather than more popular packages because there\n// is no native build required to install the package.\n// @ts-ignore -- There are no types for this package.\nimport ps from 'ps-man';\n\n/**\n * Create a temp dir for the Playground CLI.\n *\n * The temp dir is created in the system temp dir and is named\n * based on the Playground CLI binary name and the process ID.\n *\n * @param substrToIdentifyTempDirs The substring to identify the temp dir.\n * @param autoCleanup Whether to skip cleanup on process exit. Primarily used for unit testing.\n * @returns The path to the temp dir.\n */\nexport async function createPlaygroundCliTempDir(\n\tsubstrToIdentifyTempDirs: string,\n\t// Allow controlling auto-cleanup for test purposes.\n\tautoCleanup = true\n) {\n\tconst nodeBinaryName = path.basename(process.argv0);\n\n\t// We place the binary name before the playground-related fragment\n\t// so we can use the position of the fragment to parse the binary name.\n\t// Otherwise, we would have to parse the binary name from the full path.\n\tconst tempDirPrefix = `${nodeBinaryName}${substrToIdentifyTempDirs}${process.pid}-`;\n\n\tconst nativeDir = await tmpDir({\n\t\tprefix: tempDirPrefix,\n\t\t/*\n\t\t * Allow recursive cleanup on process exit.\n\t\t *\n\t\t * NOTE: I worried about whether this cleanup would follow symlinks\n\t\t * and delete target files instead of unlinking the symlink,\n\t\t * but this feature uses rimraf under the hood which respects symlinks:\n\t\t * https://github.com/raszi/node-tmp/blob/3d2fe387f3f91b13830b9182faa02c3231ea8258/lib/tmp.js#L318\n\t\t */\n\t\tunsafeCleanup: true,\n\t});\n\n\tif (autoCleanup) {\n\t\t// Request graceful cleanup on process exit.\n\t\ttmpSetGracefulCleanup();\n\t}\n\n\treturn nativeDir;\n}\n\n/**\n * Cleanup stale Playground temp dirs.\n *\n * A temp dir is considered stale if it is older than the specified age\n * and the associated process no longer exists.\n *\n * @param substrToIdentifyTempDirs The substring to identify the temp dir.\n * @param staleAgeInMillis The age in milliseconds after which a temp dir is considered stale.\n * @param tempRootDir The root directory of the temp dirs.\n */\nexport async function cleanupStalePlaygroundTempDirs(\n\tsubstrToIdentifyTempDirs: string,\n\tstaleAgeInMillis: number,\n\ttempRootDir: string\n) {\n\tconst stalePlaygroundTempDirs = await findStalePlaygroundTempDirs(\n\t\tsubstrToIdentifyTempDirs,\n\t\tstaleAgeInMillis,\n\t\ttempRootDir\n\t);\n\tconst promisesToRemove = stalePlaygroundTempDirs.map(\n\t\t(stalePlaygroundTempDir) =>\n\t\t\tnew Promise<void>((resolve) => {\n\t\t\t\t// TODO: Non-blocking: Consider how to avoid conflicts with another CLI doing cleanup.\n\t\t\t\tfs.rm(stalePlaygroundTempDir, { recursive: true }, (err) => {\n\t\t\t\t\tif (err) {\n\t\t\t\t\t\tlogger.warn(\n\t\t\t\t\t\t\t`Failed to delete stale Playground temp dir: ${stalePlaygroundTempDir}`,\n\t\t\t\t\t\t\terr\n\t\t\t\t\t\t);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tlogger.info(\n\t\t\t\t\t\t\t`Deleted stale Playground temp dir: ${stalePlaygroundTempDir}`\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\tresolve();\n\t\t\t\t});\n\t\t\t})\n\t);\n\tawait Promise.all(promisesToRemove);\n}\n\nasync function findStalePlaygroundTempDirs(\n\tsubstrToIdentifyTempDirs: string,\n\tstaleAgeInMillis: number,\n\ttempRootDir: string\n) {\n\ttry {\n\t\tconst tempPaths = fs\n\t\t\t.readdirSync(tempRootDir)\n\t\t\t.map((dirName) => path.join(tempRootDir, dirName));\n\n\t\tconst stalePlaygroundTempDirs = [];\n\t\tfor (const tempPath of tempPaths) {\n\t\t\tconst appearsToBeStale = await appearsToBeStalePlaygroundTempDir(\n\t\t\t\tsubstrToIdentifyTempDirs,\n\t\t\t\tstaleAgeInMillis,\n\t\t\t\ttempPath\n\t\t\t);\n\t\t\tif (appearsToBeStale) {\n\t\t\t\tstalePlaygroundTempDirs.push(tempPath);\n\t\t\t}\n\t\t}\n\t\treturn stalePlaygroundTempDirs;\n\t} catch (e) {\n\t\tlogger.warn(`Failed to find stale Playground temp dirs: ${e}`);\n\t\t// Failing to find stale temp dirs should not prevent the CLI from starting.\n\t\treturn [];\n\t}\n}\n\nasync function appearsToBeStalePlaygroundTempDir(\n\tsubstrToIdentifyTempDirs: string,\n\tstaleAgeInMillis: number,\n\tabsolutePath: string\n) {\n\tconst lstat = fs.lstatSync(absolutePath);\n\tif (!lstat.isDirectory()) {\n\t\t// A non-directory cannot be a Playground temp dir.\n\t\treturn false;\n\t}\n\n\tconst dirName = path.basename(absolutePath);\n\tif (!dirName.includes(substrToIdentifyTempDirs)) {\n\t\t// This doesn't look like one of our temp dirs.\n\t\treturn false;\n\t}\n\n\tconst match = dirName.match(\n\t\tnew RegExp(`^(.+)${substrToIdentifyTempDirs}(\\\\d+)-`)\n\t);\n\tif (!match) {\n\t\t// We cannot parse the temp dir name,\n\t\t// so there is nothing more to try.\n\t\treturn false;\n\t}\n\n\tconst info = {\n\t\tabsolutePath,\n\t\texecutableName: match[1],\n\t\tpid: match[2],\n\t};\n\n\tif (await doesProcessExist(info.pid, info.executableName)) {\n\t\t// It looks like the temp dir's process is still running.\n\t\treturn false;\n\t}\n\n\tconst STALE_DATE = Date.now() - staleAgeInMillis;\n\tconst dirStat = fs.statSync(absolutePath);\n\tif (dirStat.mtime.getTime() < STALE_DATE) {\n\t\treturn true;\n\t}\n\n\treturn false;\n}\n\nasync function doesProcessExist(pid: string, executableName: string) {\n\t// Define this type because there are no types for ps.list()\n\ttype ProcessInfo = {\n\t\tpid: string;\n\t\tcommand: string;\n\t};\n\t// Look for an existing process with the same PID and executable name.\n\tconst [existingProcess] = await new Promise<ProcessInfo[]>(\n\t\t(resolve, reject) => {\n\t\t\tps.list(\n\t\t\t\t{\n\t\t\t\t\tpid,\n\t\t\t\t\tname: executableName,\n\t\t\t\t\t// Remove path from executable name in the results.\n\t\t\t\t\tclean: true,\n\t\t\t\t},\n\t\t\t\t(err: any, processes: ProcessInfo[]) => {\n\t\t\t\t\tif (err) {\n\t\t\t\t\t\treject(err);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tresolve(processes);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t);\n\t\t}\n\t);\n\treturn (\n\t\t!!existingProcess &&\n\t\texistingProcess.pid === pid &&\n\t\texistingProcess.command === executableName\n\t);\n}\n","import { errorLogPath, logger, LogSeverity } from '@php-wasm/logger';\nimport type {\n\tPHPRequest,\n\tRemoteAPI,\n\tSupportedPHPVersion,\n\tUniversalPHP,\n} from '@php-wasm/universal';\nimport {\n\tPHPResponse,\n\texposeAPI,\n\texposeSyncAPI,\n\tprintDebugDetails,\n} from '@php-wasm/universal';\nimport type {\n\tBlueprintBundle,\n\tBlueprintV1Declaration,\n\tBlueprintV2Declaration,\n} from '@wp-playground/blueprints';\nimport { runBlueprintV1Steps } from '@wp-playground/blueprints';\nimport { RecommendedPHPVersion } from '@wp-playground/common';\nimport fs, { existsSync, mkdirSync, readdirSync, rmdirSync } from 'fs';\nimport type { Server } from 'http';\nimport { MessageChannel as NodeMessageChannel, Worker } from 'worker_threads';\n// @ts-ignore\nimport {\n\texpandAutoMounts,\n\tparseMountDirArguments,\n\tparseMountWithDelimiterArguments,\n} from './mounts';\nimport { startServer } from './start-server';\nimport type { PlaygroundCliBlueprintV1Worker } from './blueprints-v1/worker-thread-v1';\nimport type { PlaygroundCliBlueprintV2Worker } from './blueprints-v2/worker-thread-v2';\nimport { FileLockManagerForNode } from '@php-wasm/node';\nimport { LoadBalancer } from './load-balancer';\n/* eslint-disable no-console */\nimport { SupportedPHPVersions } from '@php-wasm/universal';\nimport { cpus } from 'os';\nimport { jspi } from 'wasm-feature-detect';\nimport type { MessagePort as NodeMessagePort } from 'worker_threads';\nimport yargs, { type Argv, type Options as YargsOptions } from 'yargs';\nimport { isValidWordPressSlug } from './is-valid-wordpress-slug';\nimport { resolveBlueprint } from './resolve-blueprint';\nimport { BlueprintsV2Handler } from './blueprints-v2/blueprints-v2-handler';\nimport { BlueprintsV1Handler } from './blueprints-v1/blueprints-v1-handler';\nimport { startBridge } from '@php-wasm/xdebug-bridge';\nimport path from 'path';\nimport os from 'os';\nimport { exec } from 'child_process';\nimport {\n\tcleanupStalePlaygroundTempDirs,\n\tcreatePlaygroundCliTempDir,\n} from './temp-dir';\nimport { type WordPressInstallMode } from '@wp-playground/wordpress';\nimport {\n\ttype Mount,\n\taddXdebugIDEConfig,\n\tclearXdebugIDEConfig,\n\tcreateTempDirSymlink,\n\tremoveTempDirSymlink,\n} from '@php-wasm/cli-util';\nimport { createHash } from 'crypto';\n\n// Inlined worker URLs for static analysis by downstream bundlers\n// These are replaced at build time by the Vite plugin in vite.config.ts\ndeclare const __WORKER_V1_URL__: string;\ndeclare const __WORKER_V2_URL__: string;\n\nexport const LogVerbosity = {\n\tQuiet: { name: 'quiet', severity: LogSeverity.Fatal },\n\tNormal: { name: 'normal', severity: LogSeverity.Info },\n\tDebug: { name: 'debug', severity: LogSeverity.Debug },\n} as const;\n\ntype LogVerbosity = (typeof LogVerbosity)[keyof typeof LogVerbosity]['name'];\n\nexport type WorkerType = 'v1' | 'v2';\n\n/**\n * Parse the CLI args and run the appropriate command.\n *\n * @param argsToParse string[] The CLI args to parse.\n */\nexport async function parseOptionsAndRunCLI(argsToParse: string[]) {\n\ttry {\n\t\t/**\n\t\t * @TODO This looks similar to Query API args https://wordpress.github.io/wordpress-playground/developers/apis/query-api/\n\t\t * Perhaps the two could be handled by the same code?\n\t\t */\n\t\tconst sharedOptions: Record<string, YargsOptions> = {\n\t\t\t'site-url': {\n\t\t\t\tdescribe:\n\t\t\t\t\t'Site URL to use for WordPress. Defaults to http://127.0.0.1:{port}',\n\t\t\t\ttype: 'string',\n\t\t\t},\n\t\t\tphp: {\n\t\t\t\tdescribe: 'PHP version to use.',\n\t\t\t\ttype: 'string',\n\t\t\t\tdefault: RecommendedPHPVersion,\n\t\t\t\tchoices: SupportedPHPVersions,\n\t\t\t},\n\t\t\twp: {\n\t\t\t\tdescribe: 'WordPress version to use.',\n\t\t\t\ttype: 'string',\n\t\t\t\tdefault: 'latest',\n\t\t\t},\n\t\t\t// @TODO: Support read-only mounts, e.g. via WORKERFS, a custom\n\t\t\t// ReadOnlyNODEFS, or by copying the files into MEMFS\n\t\t\tmount: {\n\t\t\t\tdescribe:\n\t\t\t\t\t'Mount a directory to the PHP runtime (can be used multiple times). Format: /host/path:/vfs/path',\n\t\t\t\ttype: 'array',\n\t\t\t\tstring: true,\n\t\t\t\tcoerce: parseMountWithDelimiterArguments,\n\t\t\t},\n\t\t\t'mount-before-install': {\n\t\t\t\tdescribe:\n\t\t\t\t\t'Mount a directory to the PHP runtime before WordPress installation (can be used multiple times). Format: /host/path:/vfs/path',\n\t\t\t\ttype: 'array',\n\t\t\t\tstring: true,\n\t\t\t\tcoerce: parseMountWithDelimiterArguments,\n\t\t\t},\n\t\t\t'mount-dir': {\n\t\t\t\tdescribe:\n\t\t\t\t\t'Mount a directory to the PHP runtime (can be used multiple times). Format: \"/host/path\" \"/vfs/path\"',\n\t\t\t\ttype: 'array',\n\t\t\t\tnargs: 2,\n\t\t\t\tarray: true,\n\t\t\t\tcoerce: parseMountDirArguments,\n\t\t\t},\n\t\t\t'mount-dir-before-install': {\n\t\t\t\tdescribe:\n\t\t\t\t\t'Mount a directory before WordPress installation (can be used multiple times). Format: \"/host/path\" \"/vfs/path\"',\n\t\t\t\ttype: 'string',\n\t\t\t\tnargs: 2,\n\t\t\t\tarray: true,\n\t\t\t\tcoerce: parseMountDirArguments,\n\t\t\t},\n\t\t\tlogin: {\n\t\t\t\tdescribe: 'Should log the user in',\n\t\t\t\ttype: 'boolean',\n\t\t\t\tdefault: false,\n\t\t\t},\n\t\t\tblueprint: {\n\t\t\t\tdescribe: 'Blueprint to execute.',\n\t\t\t\ttype: 'string',\n\t\t\t},\n\t\t\t'blueprint-may-read-adjacent-files': {\n\t\t\t\tdescribe:\n\t\t\t\t\t'Consent flag: Allow \"bundled\" resources in a local blueprint to read files in the same directory as the blueprint file.',\n\t\t\t\ttype: 'boolean',\n\t\t\t\tdefault: false,\n\t\t\t},\n\t\t\t'wordpress-install-mode': {\n\t\t\t\tdescribe:\n\t\t\t\t\t'Control how Playground prepares WordPress before booting.',\n\t\t\t\ttype: 'string',\n\t\t\t\tdefault: 'download-and-install',\n\t\t\t\tchoices: [\n\t\t\t\t\t'download-and-install',\n\t\t\t\t\t'install-from-existing-files',\n\t\t\t\t\t'install-from-existing-files-if-needed',\n\t\t\t\t\t'do-not-attempt-installing',\n\t\t\t\t] as const,\n\t\t\t},\n\t\t\t'skip-wordpress-install': {\n\t\t\t\tdescribe: '[Deprecated] Use --wordpress-install-mode instead.',\n\t\t\t\ttype: 'boolean',\n\t\t\t\thidden: true,\n\t\t\t},\n\t\t\t'skip-sqlite-setup': {\n\t\t\t\tdescribe:\n\t\t\t\t\t'Skip the SQLite integration plugin setup to allow the WordPress site to use MySQL.',\n\t\t\t\ttype: 'boolean',\n\t\t\t\tdefault: false,\n\t\t\t},\n\t\t\t// Hidden - Deprecated in favor of verbosity\n\t\t\tquiet: {\n\t\t\t\tdescribe: 'Do not output logs and progress messages.',\n\t\t\t\ttype: 'boolean',\n\t\t\t\tdefault: false,\n\t\t\t\thidden: true,\n\t\t\t},\n\t\t\tverbosity: {\n\t\t\t\tdescribe: 'Output logs and progress messages.',\n\t\t\t\ttype: 'string',\n\t\t\t\tchoices: Object.values(LogVerbosity).map(\n\t\t\t\t\t(verbosity) => verbosity.name\n\t\t\t\t),\n\t\t\t\tdefault: 'normal',\n\t\t\t},\n\t\t\tdebug: {\n\t\t\t\tdescribe:\n\t\t\t\t\t'Print PHP error log content if an error occurs during Playground boot.',\n\t\t\t\ttype: 'boolean',\n\t\t\t\tdefault: false,\n\t\t\t\t// Hide this deprecated option. Use verbosity=debug instead.\n\t\t\t\thidden: true,\n\t\t\t},\n\t\t\t'auto-mount': {\n\t\t\t\tdescribe: `Automatically mount the specified directory. If no path is provided, mount the current working directory. You can mount a WordPress directory, a plugin directory, a theme directory, a wp-content directory, or any directory containing PHP and HTML files.`,\n\t\t\t\ttype: 'string',\n\t\t\t},\n\t\t\t'follow-symlinks': {\n\t\t\t\tdescribe:\n\t\t\t\t\t'Allow Playground to follow symlinks by automatically mounting symlinked directories and files encountered in mounted directories. \\nWarning: Following symlinks will expose files outside mounted directories to Playground and could be a security risk.',\n\t\t\t\ttype: 'boolean',\n\t\t\t\tdefault: false,\n\t\t\t},\n\t\t\t'experimental-trace': {\n\t\t\t\tdescribe:\n\t\t\t\t\t'Print detailed messages about system behavior to the console. Useful for troubleshooting.',\n\t\t\t\ttype: 'boolean',\n\t\t\t\tdefault: false,\n\t\t\t\t// Hide this option because we want to replace with a more general log-level flag.\n\t\t\t\thidden: true,\n\t\t\t},\n\t\t\t'internal-cookie-store': {\n\t\t\t\tdescribe:\n\t\t\t\t\t'Enable internal cookie handling. When enabled, Playground will manage cookies internally using ' +\n\t\t\t\t\t'an HttpCookieStore that persists cookies across requests. When disabled, cookies are handled ' +\n\t\t\t\t\t'externally (e.g., by a browser in Node.js environments).',\n\t\t\t\ttype: 'boolean',\n\t\t\t\tdefault: false,\n\t\t\t},\n\t\t\tintl: {\n\t\t\t\tdescribe: 'Enable Intl.',\n\t\t\t\ttype: 'boolean',\n\t\t\t\tdefault: true,\n\t\t\t},\n\t\t\txdebug: {\n\t\t\t\tdescribe: 'Enable Xdebug.',\n\t\t\t\ttype: 'boolean',\n\t\t\t\tdefault: false,\n\t\t\t},\n\t\t\t'experimental-unsafe-ide-integration': {\n\t\t\t\tdescribe:\n\t\t\t\t\t'Enable experimental IDE development tools. This option edits IDE config files ' +\n\t\t\t\t\t'to set Xdebug path mappings and web server details. CAUTION: If there are bugs, ' +\n\t\t\t\t\t'this feature may break your IDE config files. Please consider backing up your IDE configs ' +\n\t\t\t\t\t'before using this feature.',\n\t\t\t\ttype: 'string',\n\t\t\t\t// The empty value means the option is enabled for all\n\t\t\t\t// supported IDEs and, if needed, will create the relevant\n\t\t\t\t// config file for each.\n\t\t\t\tchoices: ['', 'vscode', 'phpstorm'],\n\t\t\t\tcoerce: (value?: string) =>\n\t\t\t\t\tvalue === '' ? ['vscode', 'phpstorm'] : [value],\n\t\t\t},\n\t\t\t'experimental-blueprints-v2-runner': {\n\t\t\t\tdescribe: 'Use the experimental Blueprint V2 runner.',\n\t\t\t\ttype: 'boolean',\n\t\t\t\tdefault: false,\n\t\t\t\t// Remove the \"hidden\" flag once Blueprint V2 is fully supported\n\t\t\t\thidden: true,\n\t\t\t},\n\t\t\tmode: {\n\t\t\t\tdescribe:\n\t\t\t\t\t'Blueprints v2 runner mode to use. This option is required when using the --experimental-blueprints-v2-runner flag with a blueprint.',\n\t\t\t\ttype: 'string',\n\t\t\t\tchoices: ['create-new-site', 'apply-to-existing-site'],\n\t\t\t\t// Remove the \"hidden\" flag once Blueprint V2 is fully supported\n\t\t\t\thidden: true,\n\t\t\t},\n\t\t};\n\n\t\tconst serverOnlyOptions: Record<string, YargsOptions> = {\n\t\t\tport: {\n\t\t\t\tdescribe: 'Port to listen on when serving.',\n\t\t\t\ttype: 'number',\n\t\t\t\tdefault: 9400,\n\t\t\t},\n\t\t\t'experimental-multi-worker': {\n\t\t\t\tdescribe:\n\t\t\t\t\t'Enable experimental multi-worker support which requires ' +\n\t\t\t\t\t'a /wordpress directory backed by a real filesystem. ' +\n\t\t\t\t\t'Pass a positive number to specify the number of workers to use. ' +\n\t\t\t\t\t'Otherwise, default to the number of CPUs minus 1.',\n\t\t\t\ttype: 'number',\n\t\t\t\tcoerce: (value?: number) => value ?? cpus().length - 1,\n\t\t\t},\n\t\t\t'experimental-devtools': {\n\t\t\t\tdescribe: 'Enable experimental browser development tools.',\n\t\t\t\ttype: 'boolean',\n\t\t\t},\n\t\t};\n\n\t\t/**\n\t\t * Options for the high-level `start` command.\n\t\t * This command provides a simplified, opinionated interface for common use cases,\n\t\t * similar to wp-now. It auto-detects project type and uses sensible defaults.\n\t\t */\n\t\tconst startCommandOptions: Record<string, YargsOptions> = {\n\t\t\tpath: {\n\t\t\t\tdescribe:\n\t\t\t\t\t'Path to the project directory. Playground will auto-detect if this is a plugin, theme, wp-content, or WordPress directory.',\n\t\t\t\ttype: 'string',\n\t\t\t\tdefault: process.cwd(),\n\t\t\t},\n\t\t\tphp: {\n\t\t\t\tdescribe: 'PHP version to use.',\n\t\t\t\ttype: 'string',\n\t\t\t\tdefault: RecommendedPHPVersion,\n\t\t\t\tchoices: SupportedPHPVersions,\n\t\t\t},\n\t\t\twp: {\n\t\t\t\tdescribe: 'WordPress version to use.',\n\t\t\t\ttype: 'string',\n\t\t\t\tdefault: 'latest',\n\t\t\t},\n\t\t\tport: {\n\t\t\t\tdescribe: 'Port to listen on.',\n\t\t\t\ttype: 'number',\n\t\t\t\tdefault: 9400,\n\t\t\t},\n\t\t\tblueprint: {\n\t\t\t\tdescribe:\n\t\t\t\t\t'Path to a Blueprint JSON file to execute on startup.',\n\t\t\t\ttype: 'string',\n\t\t\t},\n\t\t\tlogin: {\n\t\t\t\tdescribe: 'Auto-login as the admin user.',\n\t\t\t\ttype: 'boolean',\n\t\t\t\tdefault: true,\n\t\t\t},\n\t\t\txdebug: {\n\t\t\t\tdescribe: 'Enable Xdebug for debugging.',\n\t\t\t\ttype: 'boolean',\n\t\t\t\tdefault: false,\n\t\t\t},\n\t\t\t'experimental-unsafe-ide-integration':\n\t\t\t\tsharedOptions['experimental-unsafe-ide-integration'],\n\t\t\t'skip-browser': {\n\t\t\t\tdescribe:\n\t\t\t\t\t'Do not open the site in your default browser on startup.',\n\t\t\t\ttype: 'boolean',\n\t\t\t\tdefault: false,\n\t\t\t},\n\t\t\tquiet: {\n\t\t\t\tdescribe: 'Suppress non-essential output.',\n\t\t\t\ttype: 'boolean',\n\t\t\t\tdefault: false,\n\t\t\t},\n\t\t\t// Advanced options for power users who need more control\n\t\t\t'site-url': {\n\t\t\t\tdescribe:\n\t\t\t\t\t'Override the site URL. By default, derived from the port (http://127.0.0.1:<port>).',\n\t\t\t\ttype: 'string',\n\t\t\t},\n\t\t\tmount: {\n\t\t\t\tdescribe:\n\t\t\t\t\t'Mount a directory to the PHP runtime (can be used multiple times). Format: /host/path:/vfs/path. Use this for additional mounts beyond auto-detection.',\n\t\t\t\ttype: 'array',\n\t\t\t\tstring: true,\n\t\t\t\tcoerce: parseMountWithDelimiterArguments,\n\t\t\t},\n\t\t\treset: {\n\t\t\t\tdescribe:\n\t\t\t\t\t'Deletes the stored site directory and starts a new site from scratch.',\n\t\t\t\ttype: 'boolean',\n\t\t\t\tdefault: false,\n\t\t\t},\n\t\t\t'no-auto-mount': {\n\t\t\t\tdescribe:\n\t\t\t\t\t'Disable automatic project type detection. Use --mount to manually specify mounts instead.',\n\t\t\t\ttype: 'boolean',\n\t\t\t\tdefault: false,\n\t\t\t},\n\t\t};\n\n\t\tconst buildSnapshotOnlyOptions: Record<string, YargsOptions> = {\n\t\t\toutfile: {\n\t\t\t\tdescribe: 'When building, write to this output file.',\n\t\t\t\ttype: 'string',\n\t\t\t\tdefault: 'wordpress.zip',\n\t\t\t},\n\t\t};\n\n\t\tconst yargsObject = yargs(argsToParse)\n\t\t\t.usage('Usage: wp-playground <command> [options]')\n\t\t\t.command(\n\t\t\t\t'start',\n\t\t\t\t'Start a local WordPress server with automatic project detection (recommended)',\n\t\t\t\t(yargsInstance: Argv) =>\n\t\t\t\t\tyargsInstance\n\t\t\t\t\t\t.usage(\n\t\t\t\t\t\t\t'Usage: wp-playground start [options]\\n\\n' +\n\t\t\t\t\t\t\t\t'The easiest way to run WordPress locally. Automatically detects\\n' +\n\t\t\t\t\t\t\t\t'if your directory contains a plugin, theme, wp-content, or\\n' +\n\t\t\t\t\t\t\t\t'WordPress installation and configures everything for you.\\n\\n' +\n\t\t\t\t\t\t\t\t'Examples:\\n' +\n\t\t\t\t\t\t\t\t' wp-playground start # Start in current directory\\n' +\n\t\t\t\t\t\t\t\t' wp-playground start --path=./my-plugin # Start with a specific path\\n' +\n\t\t\t\t\t\t\t\t' wp-playground start --wp=6.7 --php=8.3 # Use specific versions\\n' +\n\t\t\t\t\t\t\t\t' wp-playground start --skip-browser # Skip opening browser\\n' +\n\t\t\t\t\t\t\t\t' wp-playground start --no-auto-mount # Disable auto-detection'\n\t\t\t\t\t\t)\n\t\t\t\t\t\t.options(startCommandOptions)\n\t\t\t)\n\t\t\t.command(\n\t\t\t\t'server',\n\t\t\t\t'Start a local WordPress server (advanced, low-level)',\n\t\t\t\t(yargsInstance: Argv) =>\n\t\t\t\t\tyargsInstance.options({\n\t\t\t\t\t\t...sharedOptions,\n\t\t\t\t\t\t...serverOnlyOptions,\n\t\t\t\t\t})\n\t\t\t)\n\t\t\t.command(\n\t\t\t\t'run-blueprint',\n\t\t\t\t'Execute a Blueprint without starting a server',\n\t\t\t\t(yargsInstance: Argv) =>\n\t\t\t\t\tyargsInstance.options({ ...sharedOptions })\n\t\t\t)\n\t\t\t.command(\n\t\t\t\t'build-snapshot',\n\t\t\t\t'Build a ZIP snapshot of a WordPress site based on a Blueprint',\n\t\t\t\t(yargsInstance: Argv) =>\n\t\t\t\t\tyargsInstance.options({\n\t\t\t\t\t\t...sharedOptions,\n\t\t\t\t\t\t...buildSnapshotOnlyOptions,\n\t\t\t\t\t})\n\t\t\t)\n\t\t\t.demandCommand(1, 'Please specify a command')\n\t\t\t.strictCommands()\n\t\t\t.conflicts(\n\t\t\t\t'experimental-unsafe-ide-integration',\n\t\t\t\t'experimental-devtools'\n\t\t\t)\n\t\t\t.showHelpOnFail(false)\n\t\t\t.fail((msg, err, yargsInstance) => {\n\t\t\t\tif (err) {\n\t\t\t\t\tthrow err;\n\t\t\t\t}\n\t\t\t\tif (msg && msg.includes('Please specify a command')) {\n\t\t\t\t\tyargsInstance.showHelp();\n\t\t\t\t\tconsole.error('\\n' + msg);\n\t\t\t\t\tprocess.exit(1);\n\t\t\t\t}\n\t\t\t\tconsole.error(msg);\n\t\t\t\tprocess.exit(1);\n\t\t\t})\n\t\t\t.strictOptions()\n\t\t\t.check(async (args) => {\n\t\t\t\tif (args['skip-wordpress-install'] === true) {\n\t\t\t\t\targs['wordpress-install-mode'] =\n\t\t\t\t\t\t'do-not-attempt-installing';\n\t\t\t\t\targs['wordpressInstallMode'] = 'do-not-attempt-installing';\n\t\t\t\t}\n\n\t\t\t\tif (\n\t\t\t\t\targs['wp'] !== undefined &&\n\t\t\t\t\ttypeof args['wp'] === 'string' &&\n\t\t\t\t\t!isValidWordPressSlug(args['wp'])\n\t\t\t\t) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\t// Check if is valid URL\n\t\t\t\t\t\tnew URL(args['wp']);\n\t\t\t\t\t} catch {\n\t\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\t'Unrecognized WordPress version. Please use \"latest\", a URL, or a numeric version such as \"6.2\", \"6.0.1\", \"6.2-beta1\", or \"6.2-RC1\"'\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tconst siteUrlArg = args['site-url'];\n\t\t\t\tif (\n\t\t\t\t\ttypeof siteUrlArg === 'string' &&\n\t\t\t\t\tsiteUrlArg.trim() !== ''\n\t\t\t\t) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tnew URL(siteUrlArg);\n\t\t\t\t\t} catch {\n\t\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\t`Invalid site-url \"${siteUrlArg}\". Please provide a valid URL (e.g., http://localhost:8080 or https://example.com)`\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (args['auto-mount']) {\n\t\t\t\t\tlet autoMountIsDir = false;\n\t\t\t\t\ttry {\n\t\t\t\t\t\tconst autoMountStats = fs.statSync(\n\t\t\t\t\t\t\targs['auto-mount'] as string\n\t\t\t\t\t\t);\n\t\t\t\t\t\tautoMountIsDir = autoMountStats.isDirectory();\n\t\t\t\t\t} catch {\n\t\t\t\t\t\tautoMountIsDir = false;\n\t\t\t\t\t}\n\n\t\t\t\t\tif (!autoMountIsDir) {\n\t\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\t`The specified --auto-mount path is not a directory: '${args['auto-mount']}'.`\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (args['experimental-multi-worker'] !== undefined) {\n\t\t\t\t\tconst cliCommand = args._[0] as string;\n\t\t\t\t\tif (cliCommand !== 'server') {\n\t\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\t'The --experimental-multi-worker flag is only supported when running the server command.'\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\tif (\n\t\t\t\t\t\targs['experimental-multi-worker'] !== undefined &&\n\t\t\t\t\t\ttypeof args['experimental-multi-worker'] === 'number' &&\n\t\t\t\t\t\targs['experimental-multi-worker'] <= 1\n\t\t\t\t\t) {\n\t\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\t'The --experimental-multi-worker flag must be a positive integer greater than 1.'\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (args['experimental-blueprints-v2-runner'] === true) {\n\t\t\t\t\tif (args['mode'] !== undefined) {\n\t\t\t\t\t\tif (args['wordpress-install-mode'] !== undefined) {\n\t\t\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\t\t'The --wordpress-install-mode option cannot be used with the --mode option. Use one or the other.'\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif ('skip-sqlite-setup' in args) {\n\t\t\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\t\t'The --skipSqliteSetup option is not supported in Blueprint V2 mode.'\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (args['auto-mount'] !== undefined) {\n\t\t\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\t\t'The --mode option cannot be used with --auto-mount because --auto-mount automatically sets the mode.'\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// Support the legacy v1 runner options\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\targs['wordpress-install-mode'] ===\n\t\t\t\t\t\t\t'do-not-attempt-installing'\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\targs['mode'] = 'apply-to-existing-site';\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\targs['mode'] = 'create-new-site';\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\t// Support the legacy v1 runner options\n\t\t\t\t\tconst allow = (args['allow'] as string[]) || [];\n\n\t\t\t\t\tif (args['followSymlinks'] === true) {\n\t\t\t\t\t\tallow.push('follow-symlinks');\n\t\t\t\t\t}\n\n\t\t\t\t\tif (args['blueprint-may-read-adjacent-files'] === true) {\n\t\t\t\t\t\tallow.push('read-local-fs');\n\t\t\t\t\t}\n\n\t\t\t\t\targs['allow'] = allow;\n\t\t\t\t} else {\n\t\t\t\t\tif (args['mode'] !== undefined) {\n\t\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\t'The --mode option requires the --experimentalBlueprintsV2Runner flag.'\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\treturn true;\n\t\t\t});\n\n\t\tyargsObject.wrap(yargsObject.terminalWidth());\n\t\tconst args = await yargsObject.argv;\n\n\t\tconst command = args._[0] as string;\n\n\t\tif (\n\t\t\t!['start', 'run-blueprint', 'server', 'build-snapshot'].includes(\n\t\t\t\tcommand\n\t\t\t)\n\t\t) {\n\t\t\tyargsObject.showHelp();\n\t\t\tprocess.exit(1);\n\t\t}\n\n\t\tconst cliArgs = {\n\t\t\t...args,\n\t\t\tcommand,\n\t\t\tmount: [\n\t\t\t\t...((args['mount'] as Mount[]) || []),\n\t\t\t\t...((args['mount-dir'] as Mount[]) || []),\n\t\t\t],\n\t\t\t'mount-before-install': [\n\t\t\t\t...((args['mount-before-install'] as Mount[]) || []),\n\t\t\t\t...((args['mount-dir-before-install'] as Mount[]) || []),\n\t\t\t],\n\t\t} as RunCLIArgs;\n\n\t\tconst cliServer = await runCLI(cliArgs);\n\t\tif (cliServer === undefined) {\n\t\t\t// No server was started, so we are done with our work.\n\t\t\tprocess.exit(0);\n\t\t}\n\n\t\tconst cleanUpCliAndExit = (() => {\n\t\t\t// Remember we are already cleaning up to preclude the possibility\n\t\t\t// of multiple, conflicting cleanup attempts.\n\t\t\tlet promiseToCleanup: Promise<void>;\n\n\t\t\treturn async () => {\n\t\t\t\tif (promiseToCleanup !== undefined) {\n\t\t\t\t\tpromiseToCleanup = cliServer[Symbol.asyncDispose]();\n\t\t\t\t}\n\t\t\t\tawait promiseToCleanup;\n\t\t\t\tprocess.exit(0);\n\t\t\t};\n\t\t})();\n\n\t\t// Playground CLI server must be killed to exit. From the terminal,\n\t\t// this may occur via Ctrl+C which sends SIGINT. Let's handle both\n\t\t// SIGINT and SIGTERM (the default kill signal) to make sure we\n\t\t// clean up after ourselves even if this process is being killed.\n\t\t// NOTE: Windows does not support SIGTERM, but Node.js provides some emulation.\n\t\tprocess.on('SIGINT', cleanUpCliAndExit);\n\t\tprocess.on('SIGTERM', cleanUpCliAndExit);\n\t} catch (e) {\n\t\tconsole.error(e);\n\t\tif (!(e instanceof Error)) {\n\t\t\tthrow e;\n\t\t}\n\t\tconst debug = process.argv.includes('--debug');\n\t\tif (debug) {\n\t\t\tprintDebugDetails(e);\n\t\t} else {\n\t\t\tconst messageChain = [];\n\t\t\tlet currentError = e;\n\t\t\tdo {\n\t\t\t\tmessageChain.push(currentError.message);\n\t\t\t\tcurrentError = currentError.cause as Error;\n\t\t\t} while (currentError instanceof Error);\n\t\t\tconsole.error(\n\t\t\t\t'\\x1b[1m' + messageChain.join(' caused by: ') + '\\x1b[0m'\n\t\t\t);\n\t\t}\n\t\tprocess.exit(1);\n\t}\n}\n\nfunction getMountForVfsPath(\n\tmounts: Mount[],\n\tvfsPath: string\n): Mount | undefined {\n\treturn mounts.find(\n\t\t(mount) =>\n\t\t\tmount.vfsPath.replace(/\\/$/, '') === vfsPath.replace(/\\/$/, '')\n\t);\n}\n\nexport interface RunCLIArgs {\n\tblueprint?:\n\t\t| BlueprintV1Declaration\n\t\t| BlueprintV2Declaration\n\t\t| BlueprintBundle;\n\tcommand: 'start' | 'server' | 'run-blueprint' | 'build-snapshot';\n\tdebug?: boolean;\n\tlogin?: boolean;\n\tmount?: Mount[];\n\t'mount-before-install'?: Mount[];\n\toutfile?: string;\n\tphp?: SupportedPHPVersion;\n\tport?: number;\n\t'site-url'?: string;\n\tquiet?: boolean;\n\tverbosity?: LogVerbosity;\n\twp?: string;\n\tautoMount?: string;\n\texperimentalMultiWorker?: number;\n\texperimentalTrace?: boolean;\n\tinternalCookieStore?: boolean;\n\t'additional-blueprint-steps'?: any[];\n\tintl?: boolean;\n\txdebug?: boolean | { ideKey?: string };\n\texperimentalUnsafeIdeIntegration?: string[];\n\texperimentalDevtools?: boolean;\n\t'experimental-blueprints-v2-runner'?: boolean;\n\twordpressInstallMode?: WordPressInstallMode;\n\n\t// --------- Blueprint V1 args -----------\n\tskipSqliteSetup?: boolean;\n\tfollowSymlinks?: boolean;\n\t'blueprint-may-read-adjacent-files'?: boolean;\n\n\t// --------- Blueprint V2 args -----------\n\tmode?: 'mount-only' | 'create-new-site' | 'apply-to-existing-site';\n\n\t// --------- Blueprint V2 args (not available via CLI yet) -----------\n\t'db-engine'?: 'sqlite' | 'mysql';\n\t'db-host'?: string;\n\t'db-user'?: string;\n\t'db-pass'?: string;\n\t'db-name'?: string;\n\t'db-path'?: string;\n\t'truncate-new-site-directory'?: boolean;\n\tallow?: string;\n\n\t// --------- Start command args -----------\n\tpath?: string;\n\tskipBrowser?: boolean;\n\tnoAutoMount?: boolean;\n\treset?: boolean;\n}\n\ntype PlaygroundCliWorker =\n\t| PlaygroundCliBlueprintV1Worker\n\t| PlaygroundCliBlueprintV2Worker;\n\nexport const internalsKeyForTesting = Symbol('playground-cli-testing');\n\nexport interface RunCLIServer extends AsyncDisposable {\n\tplayground: RemoteAPI<PlaygroundCliWorker>;\n\tserver: Server;\n\tserverUrl: string;\n\n\t[Symbol.asyncDispose](): Promise<void>;\n\n\t// Provide some details and helpers for automated testing.\n\t[internalsKeyForTesting]: {\n\t\tworkerThreadCount: number;\n\t\tgetWorkerNumberFromProcessId(processId: number): number;\n\t};\n}\n\nconst bold = (text: string) =>\n\tprocess.stdout.isTTY ? '\\x1b[1m' + text + '\\x1b[0m' : text;\n\nconst red = (text: string) =>\n\tprocess.stdout.isTTY ? '\\x1b[31m' + text + '\\x1b[0m' : text;\n\nconst dim = (text: string) =>\n\tprocess.stdout.isTTY ? `\\x1b[2m${text}\\x1b[0m` : text;\n\nconst italic = (text: string) =>\n\tprocess.stdout.isTTY ? `\\x1b[3m${text}\\x1b[0m` : text;\n\nconst highlight = (text: string) =>\n\tprocess.stdout.isTTY ? `\\x1b[33m${text}\\x1b[0m` : text;\n\n// These overloads are declared for convenience so runCLI() can return\n// different things depending on the CLI command without forcing the\n// callers (mostly automated tests) to check return values.\nexport async function runCLI(\n\targs: RunCLIArgs & { command: 'build-snapshot' | 'run-blueprint' }\n): Promise<void>;\nexport async function runCLI(\n\targs: RunCLIArgs & { command: 'start' }\n): Promise<RunCLIServer>;\nexport async function runCLI(\n\targs: RunCLIArgs & { command: 'server' }\n): Promise<RunCLIServer>;\nexport async function runCLI(args: RunCLIArgs): Promise<RunCLIServer | void>;\nexport async function runCLI(args: RunCLIArgs): Promise<RunCLIServer | void> {\n\tlet loadBalancer: LoadBalancer;\n\tlet playground: RemoteAPI<PlaygroundCliWorker>;\n\n\tconst playgroundsToCleanUp: Map<\n\t\tWorker,\n\t\tRemoteAPI<PlaygroundCliWorker>\n\t> = new Map();\n\n\tif (args.command === 'start') {\n\t\targs = expandStartCommandArgs(args);\n\t}\n\n\tif (args.autoMount !== undefined) {\n\t\tif (args.autoMount === '') {\n\t\t\t// No auto-mount path was provided, so use the current working directory.\n\t\t\t// Note: We default here instead of in the yargs declaration because\n\t\t\t// it allows us to test the default as part of the runCLI() unit tests.\n\t\t\targs = { ...args, autoMount: process.cwd() };\n\t\t}\n\t\targs = expandAutoMounts(args);\n\t}\n\n\tif (args.wordpressInstallMode === undefined) {\n\t\targs.wordpressInstallMode = 'download-and-install';\n\t}\n\n\t// Keeping the '--quiet' option to preserve backward compatibility\n\tif (args.quiet) {\n\t\targs.verbosity = 'quiet';\n\t\tdelete args['quiet'];\n\t}\n\t// Keeping the '--debug' option to preserve backward compatibility\n\tif (args.debug) {\n\t\targs.verbosity = 'debug';\n\t\tdelete args['debug'];\n\t}\n\n\tif (args.verbosity) {\n\t\tconst severity = Object.values(LogVerbosity).find(\n\t\t\t(v) => v.name === args.verbosity\n\t\t)!.severity;\n\t\tlogger.setSeverityFilterLevel(severity);\n\t}\n\n\t// Enables Intl dynamic extension by default\n\tif (!args.intl) {\n\t\targs.intl = true;\n\t}\n\n\tconst selectedPort =\n\t\targs.command === 'server' ? ((args['port'] as number) ?? 9400) : 0;\n\n\t// Declare file lock manager outside scope of startServer\n\t// so we can look at it when debugging request handling.\n\tconst nativeFlockSync =\n\t\tos.platform() === 'win32'\n\t\t\t? // @TODO: Enable fs-ext here when it works with Windows.\n\t\t\t\tundefined\n\t\t\t: await import('fs-ext')\n\t\t\t\t\t.then((m) => m.flockSync)\n\t\t\t\t\t.catch(() => {\n\t\t\t\t\t\tlogger.warn(\n\t\t\t\t\t\t\t'The fs-ext package is not installed. ' +\n\t\t\t\t\t\t\t\t'Internal file locking will not be integrated with ' +\n\t\t\t\t\t\t\t\t'host OS file locking.'\n\t\t\t\t\t\t);\n\t\t\t\t\t\treturn undefined;\n\t\t\t\t\t});\n\tconst fileLockManager = new FileLockManagerForNode(nativeFlockSync);\n\n\tlet wordPressReady = false;\n\tlet isFirstRequest = true;\n\n\tlogger.log('Starting a PHP server...');\n\n\tconst server = await startServer({\n\t\tport: selectedPort,\n\t\tonBind: async (server: Server, port: number) => {\n\t\t\tconst host = '127.0.0.1';\n\t\t\tconst serverUrl = `http://${host}:${port}`;\n\t\t\tconst siteUrl = args['site-url'] || serverUrl;\n\n\t\t\tconst targetWorkerCount =\n\t\t\t\targs.command === 'server'\n\t\t\t\t\t? (args.experimentalMultiWorker ?? 1)\n\t\t\t\t\t: 1;\n\t\t\tconst totalWorkersToSpawn =\n\t\t\t\targs.command === 'server'\n\t\t\t\t\t? // Account for the initial worker which is discarded by the server after setup.\n\t\t\t\t\t\ttargetWorkerCount + 1\n\t\t\t\t\t: targetWorkerCount;\n\n\t\t\t// Process IDs appear to be defined as `int` in Emscripten:\n\t\t\t// https://github.com/emscripten-core/emscripten/blob/95d2bf9c5c27b88ab7de6eba2d8e61ea1af977ac/system/lib/libc/musl/arch/emscripten/bits/alltypes.h#L290\n\t\t\t// and those are typically 32 bits wide in both 32-bit and 64-bit systems.\n\t\t\t// Apparently, this is a signed type, so we cannot use the leftmost bit.\n\t\t\tconst maxValueForSigned32BitInteger = 2 ** (32 - 1) - 1;\n\t\t\tconst maxProcessIdValue = maxValueForSigned32BitInteger;\n\t\t\tconst processIdSpaceLength = Math.floor(\n\t\t\t\tmaxProcessIdValue / totalWorkersToSpawn\n\t\t\t);\n\n\t\t\t/*\n\t\t\t * Use a real temp dir as a target for the following Playground paths\n\t\t\t * so that multiple worker threads can share the same files.\n\t\t\t * - /internal\n\t\t\t * - /tmp\n\t\t\t * - /wordpress\n\t\t\t *\n\t\t\t * Sharing the same files leads to faster boot times and uses less memory\n\t\t\t * because we don't have to create or maintain multiple copies of the same files.\n\t\t\t */\n\t\t\tconst tempDirNameDelimiter = '-playground-cli-site-';\n\t\t\tconst nativeDir =\n\t\t\t\tawait createPlaygroundCliTempDir(tempDirNameDelimiter);\n\t\t\tlogger.debug(`Native temp dir for VFS root: ${nativeDir.path}`);\n\n\t\t\tconst IDEConfigName = 'WP Playground CLI - Listen for Xdebug';\n\n\t\t\t// Always clean up any existing Playground files symlink in the project root.\n\t\t\tconst symlinkName = '.playground-xdebug-root';\n\t\t\tconst symlinkPath = path.join(process.cwd(), symlinkName);\n\n\t\t\tawait removeTempDirSymlink(symlinkPath);\n\n\t\t\t// Then, if xdebug, and experimental IDE are enabled,\n\t\t\t// recreate the symlink pointing to the temporary\n\t\t\t// directory and add the new IDE config.\n\t\t\tif (args.xdebug && args.experimentalUnsafeIdeIntegration) {\n\t\t\t\tawait createTempDirSymlink(\n\t\t\t\t\tnativeDir.path,\n\t\t\t\t\tsymlinkPath,\n\t\t\t\t\tprocess.platform\n\t\t\t\t);\n\n\t\t\t\tconst symlinkMount: Mount = {\n\t\t\t\t\thostPath: path.join('.', path.sep, symlinkName),\n\t\t\t\t\tvfsPath: '/',\n\t\t\t\t};\n\n\t\t\t\ttry {\n\t\t\t\t\t// NOTE: Both the 'clear' and 'add' operations can throw errors.\n\t\t\t\t\tawait clearXdebugIDEConfig(IDEConfigName, process.cwd());\n\n\t\t\t\t\tconst xdebugOptions =\n\t\t\t\t\t\ttypeof args.xdebug === 'object'\n\t\t\t\t\t\t\t? args.xdebug\n\t\t\t\t\t\t\t: undefined;\n\t\t\t\t\tconst modifiedConfig = await addXdebugIDEConfig({\n\t\t\t\t\t\tname: IDEConfigName,\n\t\t\t\t\t\thost: host,\n\t\t\t\t\t\tport: port,\n\t\t\t\t\t\tides: args.experimentalUnsafeIdeIntegration!,\n\t\t\t\t\t\tcwd: process.cwd(),\n\t\t\t\t\t\tmounts: [\n\t\t\t\t\t\t\tsymlinkMount,\n\t\t\t\t\t\t\t...(args['mount-before-install'] || []),\n\t\t\t\t\t\t\t...(args.mount || []),\n\t\t\t\t\t\t],\n\t\t\t\t\t\tideKey: xdebugOptions?.ideKey,\n\t\t\t\t\t});\n\n\t\t\t\t\t// Display IDE-specific instructions\n\t\t\t\t\tconst ides = args.experimentalUnsafeIdeIntegration;\n\t\t\t\t\tconst hasVSCode = ides.includes('vscode');\n\t\t\t\t\tconst hasPhpStorm = ides.includes('phpstorm');\n\t\t\t\t\tconst configFiles = Object.values(modifiedConfig);\n\n\t\t\t\t\tconsole.log('');\n\n\t\t\t\t\tif (configFiles.length > 0) {\n\t\t\t\t\t\tconsole.log(bold(`Xdebug configured successfully`));\n\t\t\t\t\t\tconsole.log(\n\t\t\t\t\t\t\thighlight(`Updated IDE config: `) +\n\t\t\t\t\t\t\t\tconfigFiles.join(' ')\n\t\t\t\t\t\t);\n\t\t\t\t\t\tconsole.log(\n\t\t\t\t\t\t\thighlight('Playground source root: ') +\n\t\t\t\t\t\t\t\t`.playground-xdebug-root` +\n\t\t\t\t\t\t\t\titalic(\n\t\t\t\t\t\t\t\t\tdim(\n\t\t\t\t\t\t\t\t\t\t` – you can set breakpoints and preview Playground's VFS structure in there.`\n\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tconsole.log(bold(`Xdebug configuration failed.`));\n\t\t\t\t\t\tconsole.log(\n\t\t\t\t\t\t\t'No IDE-specific project settings directory was found in the current working directory.'\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\n\t\t\t\t\tconsole.log('');\n\n\t\t\t\t\tif (hasVSCode && modifiedConfig['vscode']) {\n\t\t\t\t\t\tconsole.log(bold('VS Code / Cursor instructions:'));\n\t\t\t\t\t\tconsole.log(\n\t\t\t\t\t\t\t' 1. Ensure you have installed an IDE extension for PHP Debugging'\n\t\t\t\t\t\t);\n\t\t\t\t\t\tconsole.log(\n\t\t\t\t\t\t\t` (The ${bold('PHP Debug')} extension by ${bold(\n\t\t\t\t\t\t\t\t'Xdebug'\n\t\t\t\t\t\t\t)} has been a solid option)`\n\t\t\t\t\t\t);\n\t\t\t\t\t\tconsole.log(\n\t\t\t\t\t\t\t' 2. Open the Run and Debug panel on the left sidebar'\n\t\t\t\t\t\t);\n\t\t\t\t\t\tconsole.log(\n\t\t\t\t\t\t\t` 3. Select \"${italic(\n\t\t\t\t\t\t\t\tIDEConfigName\n\t\t\t\t\t\t\t)}\" from the dropdown`\n\t\t\t\t\t\t);\n\t\t\t\t\t\tconsole.log(' 3. Click \"start debugging\"');\n\t\t\t\t\t\tconsole.log(\n\t\t\t\t\t\t\t' 5. Set a breakpoint. For example, in .playground-xdebug-root/wordpress/index.php'\n\t\t\t\t\t\t);\n\t\t\t\t\t\tconsole.log(\n\t\t\t\t\t\t\t' 6. Visit Playground in your browser to hit the breakpoint'\n\t\t\t\t\t\t);\n\t\t\t\t\t\tif (hasPhpStorm) {\n\t\t\t\t\t\t\tconsole.log('');\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tif (hasPhpStorm && modifiedConfig['phpstorm']) {\n\t\t\t\t\t\tconsole.log(bold('PhpStorm instructions:'));\n\t\t\t\t\t\tconsole.log(\n\t\t\t\t\t\t\t` 1. Choose \"${italic(\n\t\t\t\t\t\t\t\tIDEConfigName\n\t\t\t\t\t\t\t)}\" debug configuration in the toolbar`\n\t\t\t\t\t\t);\n\t\t\t\t\t\tconsole.log(' 2. Click the debug button (bug icon)`');\n\t\t\t\t\t\tconsole.log(\n\t\t\t\t\t\t\t' 3. Set a breakpoint. For example, in .playground-xdebug-root/wordpress/index.php'\n\t\t\t\t\t\t);\n\t\t\t\t\t\tconsole.log(\n\t\t\t\t\t\t\t' 4. Visit Playground in your browser to hit the breakpoint'\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\n\t\t\t\t\tconsole.log('');\n\t\t\t\t} catch (error) {\n\t\t\t\t\tthrow new Error('Could not configure Xdebug', {\n\t\t\t\t\t\tcause: error,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// We do not know the system temp dir,\n\t\t\t// but we can try to infer from the location of the current temp dir.\n\t\t\tconst tempDirRoot = path.dirname(nativeDir.path);\n\n\t\t\tconst twoDaysInMillis = 2 * 24 * 60 * 60 * 1000;\n\t\t\tconst tempDirStaleAgeInMillis = twoDaysInMillis;\n\n\t\t\t// NOTE: This is an async operation, but we do not care to block on it.\n\t\t\t// Let's let the cleanup happen as the main thread has time.\n\t\t\tcleanupStalePlaygroundTempDirs(\n\t\t\t\ttempDirNameDelimiter,\n\t\t\t\ttempDirStaleAgeInMillis,\n\t\t\t\ttempDirRoot\n\t\t\t);\n\n\t\t\t// NOTE: We do not add mount declarations for /internal here\n\t\t\t// because it will be mounted as part of php-wasm init.\n\t\t\tconst nativeInternalDirPath = path.join(nativeDir.path, 'internal');\n\t\t\tmkdirSync(nativeInternalDirPath);\n\n\t\t\tconst userProvidableNativeSubdirs = [\n\t\t\t\t'wordpress',\n\t\t\t\t// Note: These dirs are from Emscripten's \"default dirs\" list:\n\t\t\t\t// https://github.com/emscripten-core/emscripten/blob/f431ec220e472e1f8d3db6b52fe23fb377facf30/src/lib/libfs.js#L1400-L1402\n\t\t\t\t//\n\t\t\t\t// Any Playground process with multiple workers may assume\n\t\t\t\t// these are part of a shared filesystem, so let's recognize\n\t\t\t\t// them explicitly here.\n\t\t\t\t'tmp',\n\t\t\t\t'home',\n\t\t\t];\n\n\t\t\tfor (const subdirName of userProvidableNativeSubdirs) {\n\t\t\t\tconst isMountingSubdirName = (mount: Mount) =>\n\t\t\t\t\tmount.vfsPath === `/${subdirName}`;\n\t\t\t\tconst thisSubdirHasAMount =\n\t\t\t\t\targs['mount-before-install']?.some(isMountingSubdirName) ||\n\t\t\t\t\targs['mount']?.some(isMountingSubdirName);\n\t\t\t\tif (!thisSubdirHasAMount) {\n\t\t\t\t\t// The user hasn't requested mounting a different native dir for this path,\n\t\t\t\t\t// so let's create a mount from within our native temp dir.\n\t\t\t\t\tconst nativeSubdirPath = path.join(\n\t\t\t\t\t\tnativeDir.path,\n\t\t\t\t\t\tsubdirName\n\t\t\t\t\t);\n\t\t\t\t\tmkdirSync(nativeSubdirPath);\n\n\t\t\t\t\tif (args['mount-before-install'] === undefined) {\n\t\t\t\t\t\targs['mount-before-install'] = [];\n\t\t\t\t\t}\n\n\t\t\t\t\t// Make the real mount first so any further subdirs are mounted into it.\n\t\t\t\t\targs['mount-before-install'].unshift({\n\t\t\t\t\t\tvfsPath: `/${subdirName}`,\n\t\t\t\t\t\thostPath: nativeSubdirPath,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (args['mount-before-install']) {\n\t\t\t\tfor (const mount of args['mount-before-install']) {\n\t\t\t\t\tlogger.debug(\n\t\t\t\t\t\t`Mount before WP install: ${mount.vfsPath} -> ${mount.hostPath}`\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (args['mount']) {\n\t\t\t\tfor (const mount of args['mount']) {\n\t\t\t\t\tlogger.debug(\n\t\t\t\t\t\t`Mount after WP install: ${mount.vfsPath} -> ${mount.hostPath}`\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tlet handler: BlueprintsV1Handler | BlueprintsV2Handler;\n\t\t\tif (args['experimental-blueprints-v2-runner']) {\n\t\t\t\thandler = new BlueprintsV2Handler(args, {\n\t\t\t\t\tsiteUrl,\n\t\t\t\t\tprocessIdSpaceLength,\n\t\t\t\t});\n\t\t\t} else {\n\t\t\t\thandler = new BlueprintsV1Handler(args, {\n\t\t\t\t\tsiteUrl,\n\t\t\t\t\tprocessIdSpaceLength,\n\t\t\t\t});\n\n\t\t\t\tif (typeof args.blueprint === 'string') {\n\t\t\t\t\targs.blueprint = await resolveBlueprint({\n\t\t\t\t\t\tsourceString: args.blueprint,\n\t\t\t\t\t\tblueprintMayReadAdjacentFiles:\n\t\t\t\t\t\t\targs['blueprint-may-read-adjacent-files'] === true,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Remember whether we are already disposing so we can avoid:\n\t\t\t// - we can avoid multiple, conflicting dispose attempts\n\t\t\t// - logging that a worker exited while the CLI itself is exiting\n\t\t\tlet disposing = false;\n\t\t\tconst disposeCLI = async function disposeCLI() {\n\t\t\t\tif (disposing) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tdisposing = true;\n\t\t\t\tawait Promise.all(\n\t\t\t\t\t[...playgroundsToCleanUp].map(\n\t\t\t\t\t\tasync ([worker, playground]) => {\n\t\t\t\t\t\t\tawait playground.dispose();\n\t\t\t\t\t\t\tawait worker.terminate();\n\t\t\t\t\t\t}\n\t\t\t\t\t)\n\t\t\t\t);\n\t\t\t\tif (server) {\n\t\t\t\t\tawait new Promise((resolve) => server.close(resolve));\n\t\t\t\t}\n\t\t\t\tawait nativeDir.cleanup();\n\t\t\t};\n\n\t\t\t// Kick off worker threads now to save time later.\n\t\t\t// There is no need to wait for other async processes to complete.\n\t\t\tconst promisedWorkers = spawnWorkerThreads(\n\t\t\t\ttotalWorkersToSpawn,\n\t\t\t\thandler.getWorkerType(),\n\t\t\t\t({ exitCode, workerIndex }) => {\n\t\t\t\t\t// We are already disposing, so worker exit is expected\n\t\t\t\t\t// and does not need to be logged.\n\t\t\t\t\tif (disposing) {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\tif (exitCode !== 0) {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\tlogger.error(\n\t\t\t\t\t\t`Worker ${workerIndex} exited with code ${exitCode}\\n`\n\t\t\t\t\t);\n\t\t\t\t\t// @TODO: Should we respawn the worker if it exited with an error and the CLI is not shutting down?\n\t\t\t\t}\n\t\t\t);\n\n\t\t\tlogger.log(`Starting up workers`);\n\n\t\t\ttry {\n\t\t\t\tconst workers = await promisedWorkers;\n\n\t\t\t\tconst fileLockManagerPort =\n\t\t\t\t\tawait exposeFileLockManager(fileLockManager);\n\n\t\t\t\t// NOTE: Using a free-standing block to isolate initial boot vars\n\t\t\t\t// while keeping the logic inline.\n\t\t\t\t{\n\t\t\t\t\t// Boot the primary worker using the handler\n\t\t\t\t\tconst initialWorker = workers.shift()!;\n\t\t\t\t\tconst initialPlayground =\n\t\t\t\t\t\tawait handler.bootAndSetUpInitialPlayground(\n\t\t\t\t\t\t\tinitialWorker.phpPort,\n\t\t\t\t\t\t\tfileLockManagerPort,\n\t\t\t\t\t\t\tnativeInternalDirPath\n\t\t\t\t\t\t);\n\t\t\t\t\tplaygroundsToCleanUp.set(\n\t\t\t\t\t\tinitialWorker.worker,\n\t\t\t\t\t\tinitialPlayground\n\t\t\t\t\t);\n\n\t\t\t\t\tawait initialPlayground.isReady();\n\t\t\t\t\twordPressReady = true;\n\t\t\t\t\tlogger.log(`Booted!`);\n\n\t\t\t\t\tloadBalancer = new LoadBalancer(initialPlayground);\n\n\t\t\t\t\tif (!args['experimental-blueprints-v2-runner']) {\n\t\t\t\t\t\tconst compiledBlueprint = await (\n\t\t\t\t\t\t\thandler as BlueprintsV1Handler\n\t\t\t\t\t\t).compileInputBlueprint(\n\t\t\t\t\t\t\targs['additional-blueprint-steps'] || []\n\t\t\t\t\t\t);\n\n\t\t\t\t\t\tif (compiledBlueprint) {\n\t\t\t\t\t\t\tlogger.log(`Running the Blueprint...`);\n\t\t\t\t\t\t\tawait runBlueprintV1Steps(\n\t\t\t\t\t\t\t\tcompiledBlueprint,\n\t\t\t\t\t\t\t\tinitialPlayground as UniversalPHP\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tlogger.log(`Finished running the blueprint`);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tif (args.command === 'build-snapshot') {\n\t\t\t\t\t\tawait zipSite(playground, args.outfile as string);\n\t\t\t\t\t\tlogger.log(`WordPress exported to ${args.outfile}`);\n\t\t\t\t\t\tawait disposeCLI();\n\t\t\t\t\t\treturn;\n\t\t\t\t\t} else if (args.command === 'run-blueprint') {\n\t\t\t\t\t\tlogger.log(`Blueprint executed`);\n\t\t\t\t\t\tawait disposeCLI();\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\t// We discard the initial Playground worker because it can\n\t\t\t\t\t// be configured differently than post-boot workers.\n\t\t\t\t\t// For example, we do not enable Xdebug by default for the initial worker.\n\t\t\t\t\tawait loadBalancer.removeWorker(initialPlayground);\n\t\t\t\t\tawait initialPlayground.dispose();\n\t\t\t\t\tawait initialWorker.worker.terminate();\n\t\t\t\t\tplaygroundsToCleanUp.delete(initialWorker.worker);\n\t\t\t\t}\n\n\t\t\t\tlogger.log(`Preparing workers...`);\n\n\t\t\t\t// Boot additional workers using the handler\n\t\t\t\tconst initialWorkerProcessIdSpace = processIdSpaceLength;\n\t\t\t\t// Just take the first Playground instance to be returned to the caller.\n\t\t\t\t[playground] = await Promise.all(\n\t\t\t\t\tworkers.map(async (worker, index) => {\n\t\t\t\t\t\tconst firstProcessId =\n\t\t\t\t\t\t\tinitialWorkerProcessIdSpace +\n\t\t\t\t\t\t\tindex * processIdSpaceLength;\n\n\t\t\t\t\t\tconst fileLockManagerPort =\n\t\t\t\t\t\t\tawait exposeFileLockManager(fileLockManager);\n\n\t\t\t\t\t\tconst additionalPlayground =\n\t\t\t\t\t\t\tawait handler.bootPlayground({\n\t\t\t\t\t\t\t\tworker,\n\t\t\t\t\t\t\t\tfileLockManagerPort,\n\t\t\t\t\t\t\t\tfirstProcessId,\n\t\t\t\t\t\t\t\tnativeInternalDirPath,\n\t\t\t\t\t\t\t});\n\n\t\t\t\t\t\tplaygroundsToCleanUp.set(\n\t\t\t\t\t\t\tworker.worker,\n\t\t\t\t\t\t\tadditionalPlayground\n\t\t\t\t\t\t);\n\t\t\t\t\t\tloadBalancer.addWorker(additionalPlayground);\n\n\t\t\t\t\t\treturn additionalPlayground;\n\t\t\t\t\t})\n\t\t\t\t);\n\n\t\t\t\tlogger.log(\n\t\t\t\t\t`WordPress is running on ${serverUrl} with ${targetWorkerCount} worker(s)`\n\t\t\t\t);\n\n\t\t\t\tif (args.xdebug && args.experimentalDevtools) {\n\t\t\t\t\tconst bridge = await startBridge({\n\t\t\t\t\t\tphpInstance: playground,\n\t\t\t\t\t\tphpRoot: '/wordpress',\n\t\t\t\t\t});\n\n\t\t\t\t\tbridge.start();\n\t\t\t\t}\n\n\t\t\t\treturn {\n\t\t\t\t\tplayground,\n\t\t\t\t\tserver,\n\t\t\t\t\tserverUrl,\n\t\t\t\t\t[Symbol.asyncDispose]: disposeCLI,\n\t\t\t\t\t[internalsKeyForTesting]: {\n\t\t\t\t\t\tworkerThreadCount: targetWorkerCount,\n\t\t\t\t\t\tgetWorkerNumberFromProcessId: (processId: number) => {\n\t\t\t\t\t\t\treturn Math.floor(processId / processIdSpaceLength);\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t\t} catch (error) {\n\t\t\t\tif (args.verbosity !== 'debug') {\n\t\t\t\t\tthrow error;\n\t\t\t\t}\n\t\t\t\tlet phpLogs = '';\n\t\t\t\tif (await playground?.fileExists(errorLogPath)) {\n\t\t\t\t\tphpLogs = await playground.readFileAsText(errorLogPath);\n\t\t\t\t}\n\t\t\t\tawait disposeCLI();\n\t\t\t\tthrow new Error(phpLogs, { cause: error });\n\t\t\t}\n\t\t},\n\t\tasync handleRequest(request: PHPRequest) {\n\t\t\tif (!wordPressReady) {\n\t\t\t\treturn PHPResponse.forHttpCode(\n\t\t\t\t\t502,\n\t\t\t\t\t'WordPress is not ready yet'\n\t\t\t\t);\n\t\t\t}\n\t\t\t// Clear the playground_auto_login_already_happened cookie on the first request.\n\t\t\t// Otherwise the first Playground CLI server started on the machine will set it,\n\t\t\t// all the subsequent runs will get the stale cookie, and the auto-login will\n\t\t\t// assume they don't have to auto-login again.\n\t\t\tif (isFirstRequest) {\n\t\t\t\tisFirstRequest = false;\n\t\t\t\tconst headers: Record<string, string[]> = {\n\t\t\t\t\t'Content-Type': ['text/plain'],\n\t\t\t\t\t'Content-Length': ['0'],\n\t\t\t\t\tLocation: [request.url],\n\t\t\t\t};\n\t\t\t\tif (\n\t\t\t\t\trequest.headers?.['cookie']?.includes(\n\t\t\t\t\t\t'playground_auto_login_already_happened'\n\t\t\t\t\t)\n\t\t\t\t) {\n\t\t\t\t\theaders['Set-Cookie'] = [\n\t\t\t\t\t\t'playground_auto_login_already_happened=1; Max-Age=0; Expires=Thu, 01 Jan 1970 00:00:00 GMT; Path=/',\n\t\t\t\t\t];\n\t\t\t\t}\n\t\t\t\treturn new PHPResponse(302, headers, new Uint8Array());\n\t\t\t}\n\t\t\treturn await loadBalancer.handleRequest(request);\n\t\t},\n\t});\n\n\tif (server && args.command === 'start' && !args.skipBrowser) {\n\t\topenInBrowser(server.serverUrl);\n\t}\n\treturn server;\n}\n\n/**\n * Transforms CLI args for the `start` command into the `server` command arguments.\n *\n * (Yes, the `start` command is just a convenience wrapper to provide useful defaults\n * for the `server` command.)\n */\nfunction expandStartCommandArgs(\n\targs: RunCLIArgs & { reset?: boolean }\n): RunCLIArgs {\n\tlet newArgs = { ...args, command: 'server' };\n\n\t/**\n\t * Enable auto-mount unless explicitly disabled\n\t */\n\tif (!args.noAutoMount) {\n\t\tnewArgs.autoMount = path.resolve(process.cwd(), newArgs['path'] ?? '');\n\t\tnewArgs = expandAutoMounts(newArgs as RunCLIArgs);\n\t\t// Delete the autoMount argument to avoid double expansion later on.\n\t\tdelete newArgs.autoMount;\n\t}\n\n\tconst existingSiteRootMount =\n\t\tgetMountForVfsPath(\n\t\t\tnewArgs['mount-before-install'] || [],\n\t\t\t'/wordpress'\n\t\t) || getMountForVfsPath(newArgs.mount || [], '/wordpress');\n\n\t/**\n\t * Persist the site into a ~/.wordpress-playground/sites/<site-id> directory,\n\t * but only if we don't have an explicit mount for the /wordpress VFS path.\n\t *\n\t * Why the limitation?\n\t *\n\t * Because we can only do one of the two:\n\t *\n\t * 1. Mount host path /my/wordpress/site directory at /wordpress VFS path\n\t * 2. Mount host path ~/.wordpress-playground/sites/<site-id> directory at /wordpress VFS path\n\t *\n\t * When either the user or expandAutoMounts() already provided a mount for the /wordpress VFS path,\n\t * it means a WordPress installation is already present in that directory. In this case, that's our\n\t * persistent store.\n\t */\n\tif (!existingSiteRootMount) {\n\t\t/**\n\t\t * Persist the sites by default by mounting a real, stable directory\n\t\t * as the site root.\n\t\t */\n\t\tconst currentSitePath = newArgs['autoMount'] || process.cwd();\n\t\tconst currentSiteHash = createHash('sha256')\n\t\t\t.update(currentSitePath as string)\n\t\t\t.digest('hex');\n\n\t\tconst homeDir = os.homedir();\n\t\tconst hostPath = path.join(\n\t\t\thomeDir,\n\t\t\t'.wordpress-playground/sites',\n\t\t\tcurrentSiteHash\n\t\t);\n\t\tconsole.log('Site files stored at:', hostPath);\n\n\t\tif (existsSync(hostPath) && (args['reset'] as boolean)) {\n\t\t\tconsole.log('Resetting site...');\n\t\t\trmdirSync(hostPath, { recursive: true });\n\t\t}\n\t\tmkdirSync(hostPath, { recursive: true });\n\t\tnewArgs['mount-before-install'] = [\n\t\t\t...((newArgs['mount-before-install'] || []) as Mount[]),\n\t\t\t{ vfsPath: '/wordpress', hostPath },\n\t\t];\n\n\t\tnewArgs.wordpressInstallMode =\n\t\t\treaddirSync(hostPath).length === 0\n\t\t\t\t? // Only download WordPress on the first run when the site directory is still\n\t\t\t\t\t// empty.\n\t\t\t\t\t'download-and-install'\n\t\t\t\t: // After that, reuse the WordPress installation from the initial run.\n\t\t\t\t\t'install-from-existing-files-if-needed';\n\t} else {\n\t\tconsole.log('Site files stored at:', existingSiteRootMount?.hostPath);\n\t\tif (args['reset']) {\n\t\t\tconsole.log(``);\n\t\t\tconsole.log(\n\t\t\t\tred(\n\t\t\t\t\t`This site is not managed by Playground CLI and cannot be reset.`\n\t\t\t\t)\n\t\t\t);\n\t\t\tconsole.log(\n\t\t\t\t`(It's not stored in the ~/.wordpress-playground/sites/<site-id> directory.)`\n\t\t\t);\n\t\t\tconsole.log(``);\n\t\t\tconsole.log(\n\t\t\t\t`You may still remove the site's directory manually if you wish.`\n\t\t\t);\n\t\t\tprocess.exit(1);\n\t\t}\n\t}\n\n\treturn newArgs as RunCLIArgs;\n}\n\nexport type SpawnedWorker = {\n\tworker: Worker;\n\tphpPort: NodeMessagePort;\n};\n\nasync function spawnWorkerThreads(\n\tcount: number,\n\tworkerType: WorkerType,\n\tonWorkerExit: (options: { exitCode: number; workerIndex: number }) => void\n): Promise<SpawnedWorker[]> {\n\tconst promises = [];\n\tfor (let i = 0; i < count; i++) {\n\t\tconst onExit: (code: number) => void = (code: number) => {\n\t\t\tonWorkerExit({\n\t\t\t\texitCode: code,\n\t\t\t\tworkerIndex: i,\n\t\t\t});\n\t\t};\n\t\tconst worker = spawnWorkerThread(workerType, { onExit });\n\t\tpromises.push(worker);\n\t}\n\treturn Promise.all(promises);\n}\n\n/**\n * A statically analyzable function that spawns a worker thread of a given type.\n *\n * **Important:** This function builds to code that has the worker URL hardcoded\n * inline, e.g. `new Worker(new URL('./worker-thread-v1.js', import.meta.url))`.\n * This allows the downstream consumers to statically analyze the code, recognize\n * it uses workers, create new entrypoints, and rewrite the new Worker() calls.\n *\n * @param workerType\n * @returns\n */\nexport function spawnWorkerThread(\n\tworkerType: 'v1' | 'v2',\n\t{ onExit }: { onExit?: (code: number) => void } = {}\n) {\n\t/**\n\t * When running the CLI from source via `node cli.ts`, the Vite-provided\n\t * __WORKER_V1_URL__ and __WORKER_V2_URL__ are undefined. Let's set them to\n\t * the correct paths.\n\t */\n\tif (typeof __WORKER_V1_URL__ === 'undefined') {\n\t\t// @ts-expect-error\n\t\tglobalThis['__WORKER_V1_URL__'] = './blueprints-v1/worker-thread-v1.ts';\n\t}\n\tif (typeof __WORKER_V2_URL__ === 'undefined') {\n\t\t// @ts-expect-error\n\t\tglobalThis['__WORKER_V2_URL__'] = './blueprints-v2/worker-thread-v2.ts';\n\t}\n\tlet worker: Worker;\n\tif (workerType === 'v1') {\n\t\tworker = new Worker(new URL(__WORKER_V1_URL__, import.meta.url));\n\t} else {\n\t\tworker = new Worker(new URL(__WORKER_V2_URL__, import.meta.url));\n\t}\n\n\treturn new Promise<SpawnedWorker>((resolve, reject) => {\n\t\tworker.once('message', function (message: any) {\n\t\t\t// Let the worker confirm it has initialized.\n\t\t\t// We could use the 'online' event to detect start of JS execution,\n\t\t\t// but that would miss initialization errors.\n\t\t\tif (message.command === 'worker-script-initialized') {\n\t\t\t\tresolve({ worker, phpPort: message.phpPort });\n\t\t\t}\n\t\t});\n\t\tworker.once('error', function (e: Error) {\n\t\t\tconsole.error(e);\n\t\t\tconst error = new Error(\n\t\t\t\t`Worker failed to load worker. ${\n\t\t\t\t\te.message ? `Original error: ${e.message}` : ''\n\t\t\t\t}`\n\t\t\t);\n\t\t\treject(error);\n\t\t});\n\t\tlet spawned = false;\n\t\tworker.once('spawn', () => {\n\t\t\tspawned = true;\n\t\t});\n\t\tworker.once('exit', (code) => {\n\t\t\tif (!spawned) {\n\t\t\t\treject(new Error(`Worker exited before spawning: ${code}`));\n\t\t\t}\n\t\t\tonExit?.(code);\n\t\t});\n\t});\n}\n\n/**\n * Expose the file lock manager API on a MessagePort and return it.\n *\n * @see comlink-sync.ts\n * @see phpwasm-emscripten-library-file-locking-for-node.js\n */\nasync function exposeFileLockManager(fileLockManager: FileLockManagerForNode) {\n\tconst { port1, port2 } = new NodeMessageChannel();\n\tif (await jspi()) {\n\t\t/**\n\t\t * When JSPI is available, the worker thread expects an asynchronous API.\n\t\t *\n\t\t * @see worker-thread.ts\n\t\t * @see comlink-sync.ts\n\t\t * @see phpwasm-emscripten-library-file-locking-for-node.js\n\t\t */\n\t\texposeAPI(fileLockManager, null, port1);\n\t} else {\n\t\t/**\n\t\t * When JSPI is not available, the worker thread expects a synchronous API.\n\t\t *\n\t\t * @see worker-thread.ts\n\t\t * @see comlink-sync.ts\n\t\t * @see phpwasm-emscripten-library-file-locking-for-node.js\n\t\t */\n\t\tawait exposeSyncAPI(fileLockManager, port1);\n\t}\n\treturn port2;\n}\n\n/**\n * Open a URL in the user's default browser.\n * Works cross-platform: macOS, Windows, and Linux.\n */\nfunction openInBrowser(url: string): void {\n\tconst platform = os.platform();\n\tlet command: string;\n\n\tswitch (platform) {\n\t\tcase 'darwin':\n\t\t\tcommand = `open \"${url}\"`;\n\t\t\tbreak;\n\t\tcase 'win32':\n\t\t\tcommand = `start \"\" \"${url}\"`;\n\t\t\tbreak;\n\t\tdefault:\n\t\t\t// Linux and other Unix-like systems\n\t\t\tcommand = `xdg-open \"${url}\"`;\n\t\t\tbreak;\n\t}\n\n\texec(command, (error) => {\n\t\tif (error) {\n\t\t\t// Don't fail the CLI if browser opening fails, just log a debug message\n\t\t\tlogger.debug(`Could not open browser: ${error.message}`);\n\t\t}\n\t});\n}\n\nasync function zipSite(\n\tplayground: RemoteAPI<PlaygroundCliWorker>,\n\toutfile: string\n) {\n\tawait playground.run({\n\t\tcode: `<?php\n\t\t$zip = new ZipArchive();\n\t\tif(false === $zip->open('/tmp/build.zip', ZipArchive::CREATE | ZipArchive::OVERWRITE)) {\n\t\t\tthrow new Exception('Failed to create ZIP');\n\t\t}\n\t\t$files = new RecursiveIteratorIterator(\n\t\t\tnew RecursiveDirectoryIterator('/wordpress')\n\t\t);\n\t\tforeach ($files as $file) {\n\t\t\techo $file . PHP_EOL;\n\t\t\tif (!$file->isFile()) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\t$zip->addFile($file->getPathname(), $file->getPathname());\n\t\t}\n\t\t$zip->close();\n\n\t`,\n\t});\n\tconst zip = await playground.readFileAsBuffer('/tmp/build.zip');\n\tfs.writeFileSync(outfile, zip);\n}\n"],"names":["parseMountWithDelimiterArguments","mounts","parsedMounts","mount","mountParts","hostPath","vfsPath","existsSync","parseMountDirArguments","i","source","path","mountResources","php","createNodeFsMountHandler","ACTIVATE_FIRST_THEME_STEP","expandAutoMounts","args","mountBeforeInstall","newArgs","isPluginDirectory","pluginName","basename","isThemeDirectory","themeName","containsWpContentDirectories","files","fs","file","containsFullWordPressInstallation","styleCssContent","join","pluginNameRegex","fileContent","startServer","options","app","express","server","resolve","reject","address","req","res","phpResponse","parseHeaders","bufferRequestBody","error","logger","PHPResponse","key","port","body","chunk","requestHeaders","LoadBalancer","initialWorker","worker","workerIndex","workerLoad","removedWorker","request","smallestWorkerLoad","promiseForResponse","isValidWordPressSlug","version","resolveBlueprint","sourceString","blueprintMayReadAdjacentFiles","resolveRemoteBlueprint","blueprintPath","stat","extension","ZipFilesystem","blueprintText","contextPath","nodeJsFilesystem","NodeJsFilesystem","OverlayFilesystem","InMemoryFilesystem","shouldRenderProgress","writeStream","BlueprintsV2Handler","phpPort","fileLockManagerPort","nativeInternalDirPath","playground","consumeAPI","workerBootArgs","firstProcessId","message","finalUpdate","CACHE_FOLDER","os","fetchSqliteIntegration","monitor","cachedDownload","remoteUrl","cacheKey","artifactPath","downloadTo","readAsFile","localPath","reader","tmpPath","writer","done","value","err","fileName","BlueprintsV1Handler","wpDetails","wordPressZip","preinstalledWpContentPath","EmscriptenDownloadMonitor","progressReached100","e","loaded","total","percentProgress","resolveWordPressRelease","sqliteIntegrationPluginZip","followSymlinks","trace","mountsBeforeWpInstall","mountsAfterWpInstall","runtimeConfiguration","resolveRuntimeConfiguration","zipDirectory","additionalBlueprintSteps","blueprint","tracker","ProgressTracker","lastCaption","progressInteger","compileBlueprintV1","resolvedBlueprint","isBlueprintBundle","RecommendedPHPVersion","LogVerbosity","createPlaygroundCliTempDir","substrToIdentifyTempDirs","autoCleanup","tempDirPrefix","nativeDir","tmpDir","tmpSetGracefulCleanup","cleanupStalePlaygroundTempDirs","staleAgeInMillis","tempRootDir","promisesToRemove","findStalePlaygroundTempDirs","stalePlaygroundTempDir","tempPaths","dirName","stalePlaygroundTempDirs","tempPath","appearsToBeStalePlaygroundTempDir","absolutePath","match","info","doesProcessExist","STALE_DATE","pid","executableName","existingProcess","ps","processes","LogSeverity","parseOptionsAndRunCLI","argsToParse","sharedOptions","SupportedPHPVersions","verbosity","serverOnlyOptions","cpus","startCommandOptions","buildSnapshotOnlyOptions","yargsObject","yargs","yargsInstance","msg","siteUrlArg","autoMountIsDir","allow","command","cliArgs","cliServer","runCLI","cleanUpCliAndExit","promiseToCleanup","printDebugDetails","messageChain","currentError","getMountForVfsPath","internalsKeyForTesting","bold","text","red","dim","italic","highlight","loadBalancer","playgroundsToCleanUp","expandStartCommandArgs","severity","v","selectedPort","nativeFlockSync","m","fileLockManager","FileLockManagerForNode","wordPressReady","isFirstRequest","host","serverUrl","siteUrl","targetWorkerCount","totalWorkersToSpawn","maxProcessIdValue","processIdSpaceLength","tempDirNameDelimiter","IDEConfigName","symlinkName","symlinkPath","removeTempDirSymlink","createTempDirSymlink","symlinkMount","clearXdebugIDEConfig","xdebugOptions","modifiedConfig","addXdebugIDEConfig","ides","hasVSCode","hasPhpStorm","configFiles","tempDirRoot","tempDirStaleAgeInMillis","mkdirSync","userProvidableNativeSubdirs","subdirName","isMountingSubdirName","nativeSubdirPath","handler","disposing","disposeCLI","promisedWorkers","spawnWorkerThreads","exitCode","workers","exposeFileLockManager","initialPlayground","compiledBlueprint","runBlueprintV1Steps","zipSite","initialWorkerProcessIdSpace","index","additionalPlayground","startBridge","processId","phpLogs","errorLogPath","headers","openInBrowser","existingSiteRootMount","currentSitePath","currentSiteHash","createHash","homeDir","rmdirSync","readdirSync","count","workerType","onWorkerExit","promises","spawnWorkerThread","code","onExit","Worker","_documentCurrentScript","spawned","port1","port2","NodeMessageChannel","jspi","exposeAPI","exposeSyncAPI","url","platform","exec","outfile","zip"],"mappings":"4oCAsBO,SAASA,EAAiCC,EAA2B,CAC3E,MAAMC,EAAe,CAAA,EACrB,UAAWC,KAASF,EAAQ,CAC3B,MAAMG,EAAaD,EAAM,MAAM,GAAG,EAClC,GAAIC,EAAW,SAAW,EACzB,MAAM,IAAI,MAAM,yBAAyBD,CAAK;AAAA;AAAA;AAAA,+EAG8B,EAE7E,KAAM,CAACE,EAAUC,CAAO,EAAIF,EAC5B,GAAI,CAACG,EAAAA,WAAWF,CAAQ,EACvB,MAAM,IAAI,MAAM,6BAA6BA,CAAQ,EAAE,EAExDH,EAAa,KAAK,CAAE,SAAAG,EAAU,QAAAC,CAAA,CAAS,CACxC,CACA,OAAOJ,CACR,CAiBO,SAASM,GAAuBP,EAA2B,CACjE,GAAIA,EAAO,OAAS,IAAM,EACzB,MAAM,IAAI,MAAM,sDAAsD,EAGvE,MAAMC,EAAe,CAAA,EACrB,QAASO,EAAI,EAAGA,EAAIR,EAAO,OAAQQ,GAAK,EAAG,CAC1C,MAAMC,EAAST,EAAOQ,CAAC,EACjBH,EAAUL,EAAOQ,EAAI,CAAC,EAC5B,GAAI,CAACF,EAAAA,WAAWG,CAAM,EACrB,MAAM,IAAI,MAAM,6BAA6BA,CAAM,EAAE,EAEtDR,EAAa,KAAK,CACjB,SAAUS,EAAK,QAAQ,QAAQ,IAAA,EAAOD,CAAM,EAC5C,QAAAJ,CAAA,CACA,CACF,CACA,OAAOJ,CACR,CAEA,eAAsBU,GAAeC,EAAUZ,EAAiB,CAC/D,UAAWE,KAASF,EACnB,MAAMY,EAAI,MACTV,EAAM,QACNW,GAAAA,yBAAyBX,EAAM,QAAQ,CAAA,CAG1C,CAEA,MAAMY,GAA4B,CACjC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