@wp-playground/cli 3.1.12 → 3.1.13
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.cjs.map +1 -1
- package/cli.js +33 -3
- package/cli.js.map +1 -1
- package/ensure-jspi.d.ts +16 -0
- package/index.cjs +1 -1
- package/index.js +1 -1
- package/package.json +14 -14
- package/{run-cli-C-eCY5Ux.cjs → run-cli-BZUBWAe5.cjs} +12 -12
- package/{run-cli-C-eCY5Ux.cjs.map → run-cli-BZUBWAe5.cjs.map} +1 -1
- package/{run-cli-2YzKNrNz.js → run-cli-Dka9y1Ev.js} +238 -234
- package/{run-cli-2YzKNrNz.js.map → run-cli-Dka9y1Ev.js.map} +1 -1
- package/sqlite-database-integration.zip +0 -0
- package/worker-thread-v1.cjs +1 -1
- package/worker-thread-v1.js +1 -1
- package/worker-thread-v2.cjs +1 -1
- package/worker-thread-v2.js +1 -1
package/cli.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";const
|
|
1
|
+
"use strict";const i=require("child_process");function t(){return!("Suspending"in WebAssembly||process.env.PLAYGROUND_NO_JSPI_RESPAWN||process.versions.bun||"Deno"in globalThis||process.execArgv.includes("--experimental-wasm-jspi")||parseInt(process.versions.node.split(".")[0],10)<23)}function o(){const r=process.argv.slice(2);Promise.resolve().then(()=>require("./run-cli-BZUBWAe5.cjs")).then(e=>e.runCli).then(({parseOptionsAndRunCLI:e})=>{e(r)})}if(t()){const r=Date.now(),e=i.spawn(process.execPath,["--experimental-wasm-jspi",...process.execArgv,...process.argv.slice(1)],{stdio:"inherit"});for(const s of["SIGINT","SIGTERM"])process.on(s,()=>e.kill(s));e.on("error",()=>{o()}),e.on("close",(s,n)=>{if(s!==0&&!n&&Date.now()-r<1e3){o();return}n?process.kill(process.pid,n):process.exit(s)})}else o();
|
|
2
2
|
//# sourceMappingURL=cli.cjs.map
|
package/cli.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.cjs","sources":["../../../../packages/playground/cli/src/cli.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"cli.cjs","sources":["../../../../packages/playground/cli/src/ensure-jspi.ts","../../../../packages/playground/cli/src/cli.ts"],"sourcesContent":["/**\n * Determines whether the current process should respawn itself with\n * the --experimental-wasm-jspi flag to enable JSPI support.\n *\n * Returns true only when all of these hold:\n * 1. JSPI is not already available in this runtime.\n * 2. We're running on Node.js (not Bun, Deno, or another runtime).\n * 3. The flag hasn't already been passed (avoids infinite loops).\n * 4. The Node.js version is >= 23 (the first version whose V8 has\n * the current JSPI spec with WebAssembly.Suspending).\n *\n * Why not Node 22? It ships V8 12.4 which only exposes the old,\n * since-removed JSPI API (WebAssembly.Suspender). The new API\n * (WebAssembly.Suspending) arrived in V8 12.6 = Node 23.\n */\nexport function shouldRespawnWithJSPI(): boolean {\n\t// JSPI is already usable — nothing to do.\n\tif ('Suspending' in WebAssembly) {\n\t\treturn false;\n\t}\n\n\t// Explicit opt-out. The `unbuilt-asyncify` NX target sets this\n\t// to prevent the respawn on Node versions that support JSPI.\n\tif (process.env['PLAYGROUND_NO_JSPI_RESPAWN']) {\n\t\treturn false;\n\t}\n\n\t// The --experimental-wasm-jspi flag is Node.js-specific. Other\n\t// runtimes (Bun, Deno) set process.versions.node for compat but\n\t// don't support Node's V8 flags.\n\tif (process.versions['bun'] || 'Deno' in globalThis) {\n\t\treturn false;\n\t}\n\n\t// We already tried — the flag didn't help. Don't loop.\n\tif (process.execArgv.includes('--experimental-wasm-jspi')) {\n\t\treturn false;\n\t}\n\n\t// Node 22 and below: V8 is too old for the current JSPI spec.\n\t// The flag exists in Node 22, but it only enables the old API\n\t// (WebAssembly.Suspender) which we don't use.\n\tconst major = parseInt(process.versions.node.split('.')[0], 10);\n\tif (major < 23) {\n\t\treturn false;\n\t}\n\n\treturn true;\n}\n","import { spawn } from 'child_process';\nimport { shouldRespawnWithJSPI } from './ensure-jspi';\n\nfunction runCLI() {\n\tconst args = process.argv.slice(2);\n\t// Dynamic import avoids loading run-cli when we're about to respawn.\n\t// Do not await — top-level await is not supported in all environments.\n\timport('./run-cli').then(({ parseOptionsAndRunCLI }) => {\n\t\tparseOptionsAndRunCLI(args);\n\t});\n}\n\nif (shouldRespawnWithJSPI()) {\n\tconst spawnedAt = Date.now();\n\tconst child = spawn(\n\t\tprocess.execPath,\n\t\t[\n\t\t\t'--experimental-wasm-jspi',\n\t\t\t...process.execArgv,\n\t\t\t...process.argv.slice(1),\n\t\t],\n\t\t{ stdio: 'inherit' }\n\t);\n\n\t// Forward SIGINT/SIGTERM so Ctrl+C and kill work as expected.\n\tfor (const sig of ['SIGINT', 'SIGTERM'] as const) {\n\t\tprocess.on(sig, () => child.kill(sig));\n\t}\n\n\t// If spawn() itself fails (e.g. ENOENT), fall back to running\n\t// without JSPI in this process. We might be inside of a non-Node\n\t// JavaScript runtime that refuses to boot when the `--experimental-wasm-jspi`\n\t// flag is present.\n\tchild.on('error', () => {\n\t\trunCLI();\n\t});\n\n\tchild.on('close', (code, signal) => {\n\t\t// If the child exited almost immediately with an error, the\n\t\t// --experimental-wasm-jspi flag was likely rejected by the\n\t\t// runtime. Fall back to running without JSPI in this process\n\t\t// instead of propagating the failure.\n\t\tif (code !== 0 && !signal && Date.now() - spawnedAt < 1000) {\n\t\t\trunCLI();\n\t\t\treturn;\n\t\t}\n\n\t\t/**\n\t\t * We should always get either a code or a signal as per\n\t\t * https://nodejs.org/api/child_process.html#event-close:\n\t\t *\n\t\t * > If the process exited, code is the final exit code of the\n\t\t * > process, otherwise null. If the process terminated due to\n\t\t * > receipt of a signal, signal is the string name of the signal,\n\t\t * > otherwise null. **One of the two will always be non-null.**\n\t\t */\n\t\tif (signal) {\n\t\t\tprocess.kill(process.pid, signal);\n\t\t} else {\n\t\t\tprocess.exit(code);\n\t\t}\n\t});\n} else {\n\trunCLI();\n}\n"],"names":["shouldRespawnWithJSPI","runCLI","args","n","parseOptionsAndRunCLI","spawnedAt","child","spawn","sig","code","signal"],"mappings":"8CAeO,SAASA,GAAiC,CA4BhD,MA1BI,iBAAgB,aAMhB,QAAQ,IAAI,4BAOZ,QAAQ,SAAS,KAAU,SAAU,YAKrC,QAAQ,SAAS,SAAS,0BAA0B,GAO1C,SAAS,QAAQ,SAAS,KAAK,MAAM,GAAG,EAAE,CAAC,EAAG,EAAE,EAClD,GAKb,CC7CA,SAASC,GAAS,CACjB,MAAMC,EAAO,QAAQ,KAAK,MAAM,CAAC,EAGjC,QAAA,QAAA,EAAA,KAAA,IAAA,QAAO,wBAAW,CAAA,EAAA,KAAAC,GAAAA,EAAA,MAAA,EAAE,KAAK,CAAC,CAAE,sBAAAC,KAA4B,CACvDA,EAAsBF,CAAI,CAC3B,CAAC,CACF,CAEA,GAAIF,IAAyB,CAC5B,MAAMK,EAAY,KAAK,IAAA,EACjBC,EAAQC,EAAAA,MACb,QAAQ,SACR,CACC,2BACA,GAAG,QAAQ,SACX,GAAG,QAAQ,KAAK,MAAM,CAAC,CAAA,EAExB,CAAE,MAAO,SAAA,CAAU,EAIpB,UAAWC,IAAO,CAAC,SAAU,SAAS,EACrC,QAAQ,GAAGA,EAAK,IAAMF,EAAM,KAAKE,CAAG,CAAC,EAOtCF,EAAM,GAAG,QAAS,IAAM,CACvBL,EAAA,CACD,CAAC,EAEDK,EAAM,GAAG,QAAS,CAACG,EAAMC,IAAW,CAKnC,GAAID,IAAS,GAAK,CAACC,GAAU,KAAK,IAAA,EAAQL,EAAY,IAAM,CAC3DJ,EAAA,EACA,MACD,CAWIS,EACH,QAAQ,KAAK,QAAQ,IAAKA,CAAM,EAEhC,QAAQ,KAAKD,CAAI,CAEnB,CAAC,CACF,MACCR,EAAA"}
|
package/cli.js
CHANGED
|
@@ -1,4 +1,34 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { spawn as i } from "child_process";
|
|
2
|
+
function t() {
|
|
3
|
+
return !("Suspending" in WebAssembly || process.env.PLAYGROUND_NO_JSPI_RESPAWN || process.versions.bun || "Deno" in globalThis || process.execArgv.includes("--experimental-wasm-jspi") || parseInt(process.versions.node.split(".")[0], 10) < 23);
|
|
4
|
+
}
|
|
5
|
+
function o() {
|
|
6
|
+
const r = process.argv.slice(2);
|
|
7
|
+
import("./run-cli-Dka9y1Ev.js").then((e) => e.c).then(({ parseOptionsAndRunCLI: e }) => {
|
|
8
|
+
e(r);
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
if (t()) {
|
|
12
|
+
const r = Date.now(), e = i(
|
|
13
|
+
process.execPath,
|
|
14
|
+
[
|
|
15
|
+
"--experimental-wasm-jspi",
|
|
16
|
+
...process.execArgv,
|
|
17
|
+
...process.argv.slice(1)
|
|
18
|
+
],
|
|
19
|
+
{ stdio: "inherit" }
|
|
20
|
+
);
|
|
21
|
+
for (const s of ["SIGINT", "SIGTERM"])
|
|
22
|
+
process.on(s, () => e.kill(s));
|
|
23
|
+
e.on("error", () => {
|
|
24
|
+
o();
|
|
25
|
+
}), e.on("close", (s, n) => {
|
|
26
|
+
if (s !== 0 && !n && Date.now() - r < 1e3) {
|
|
27
|
+
o();
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
n ? process.kill(process.pid, n) : process.exit(s);
|
|
31
|
+
});
|
|
32
|
+
} else
|
|
33
|
+
o();
|
|
4
34
|
//# sourceMappingURL=cli.js.map
|
package/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","sources":["../../../../packages/playground/cli/src/cli.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"cli.js","sources":["../../../../packages/playground/cli/src/ensure-jspi.ts","../../../../packages/playground/cli/src/cli.ts"],"sourcesContent":["/**\n * Determines whether the current process should respawn itself with\n * the --experimental-wasm-jspi flag to enable JSPI support.\n *\n * Returns true only when all of these hold:\n * 1. JSPI is not already available in this runtime.\n * 2. We're running on Node.js (not Bun, Deno, or another runtime).\n * 3. The flag hasn't already been passed (avoids infinite loops).\n * 4. The Node.js version is >= 23 (the first version whose V8 has\n * the current JSPI spec with WebAssembly.Suspending).\n *\n * Why not Node 22? It ships V8 12.4 which only exposes the old,\n * since-removed JSPI API (WebAssembly.Suspender). The new API\n * (WebAssembly.Suspending) arrived in V8 12.6 = Node 23.\n */\nexport function shouldRespawnWithJSPI(): boolean {\n\t// JSPI is already usable — nothing to do.\n\tif ('Suspending' in WebAssembly) {\n\t\treturn false;\n\t}\n\n\t// Explicit opt-out. The `unbuilt-asyncify` NX target sets this\n\t// to prevent the respawn on Node versions that support JSPI.\n\tif (process.env['PLAYGROUND_NO_JSPI_RESPAWN']) {\n\t\treturn false;\n\t}\n\n\t// The --experimental-wasm-jspi flag is Node.js-specific. Other\n\t// runtimes (Bun, Deno) set process.versions.node for compat but\n\t// don't support Node's V8 flags.\n\tif (process.versions['bun'] || 'Deno' in globalThis) {\n\t\treturn false;\n\t}\n\n\t// We already tried — the flag didn't help. Don't loop.\n\tif (process.execArgv.includes('--experimental-wasm-jspi')) {\n\t\treturn false;\n\t}\n\n\t// Node 22 and below: V8 is too old for the current JSPI spec.\n\t// The flag exists in Node 22, but it only enables the old API\n\t// (WebAssembly.Suspender) which we don't use.\n\tconst major = parseInt(process.versions.node.split('.')[0], 10);\n\tif (major < 23) {\n\t\treturn false;\n\t}\n\n\treturn true;\n}\n","import { spawn } from 'child_process';\nimport { shouldRespawnWithJSPI } from './ensure-jspi';\n\nfunction runCLI() {\n\tconst args = process.argv.slice(2);\n\t// Dynamic import avoids loading run-cli when we're about to respawn.\n\t// Do not await — top-level await is not supported in all environments.\n\timport('./run-cli').then(({ parseOptionsAndRunCLI }) => {\n\t\tparseOptionsAndRunCLI(args);\n\t});\n}\n\nif (shouldRespawnWithJSPI()) {\n\tconst spawnedAt = Date.now();\n\tconst child = spawn(\n\t\tprocess.execPath,\n\t\t[\n\t\t\t'--experimental-wasm-jspi',\n\t\t\t...process.execArgv,\n\t\t\t...process.argv.slice(1),\n\t\t],\n\t\t{ stdio: 'inherit' }\n\t);\n\n\t// Forward SIGINT/SIGTERM so Ctrl+C and kill work as expected.\n\tfor (const sig of ['SIGINT', 'SIGTERM'] as const) {\n\t\tprocess.on(sig, () => child.kill(sig));\n\t}\n\n\t// If spawn() itself fails (e.g. ENOENT), fall back to running\n\t// without JSPI in this process. We might be inside of a non-Node\n\t// JavaScript runtime that refuses to boot when the `--experimental-wasm-jspi`\n\t// flag is present.\n\tchild.on('error', () => {\n\t\trunCLI();\n\t});\n\n\tchild.on('close', (code, signal) => {\n\t\t// If the child exited almost immediately with an error, the\n\t\t// --experimental-wasm-jspi flag was likely rejected by the\n\t\t// runtime. Fall back to running without JSPI in this process\n\t\t// instead of propagating the failure.\n\t\tif (code !== 0 && !signal && Date.now() - spawnedAt < 1000) {\n\t\t\trunCLI();\n\t\t\treturn;\n\t\t}\n\n\t\t/**\n\t\t * We should always get either a code or a signal as per\n\t\t * https://nodejs.org/api/child_process.html#event-close:\n\t\t *\n\t\t * > If the process exited, code is the final exit code of the\n\t\t * > process, otherwise null. If the process terminated due to\n\t\t * > receipt of a signal, signal is the string name of the signal,\n\t\t * > otherwise null. **One of the two will always be non-null.**\n\t\t */\n\t\tif (signal) {\n\t\t\tprocess.kill(process.pid, signal);\n\t\t} else {\n\t\t\tprocess.exit(code);\n\t\t}\n\t});\n} else {\n\trunCLI();\n}\n"],"names":["shouldRespawnWithJSPI","runCLI","args","n","parseOptionsAndRunCLI","spawnedAt","child","spawn","sig","code","signal"],"mappings":";AAeO,SAASA,IAAiC;AA4BhD,SA1BI,kBAAgB,eAMhB,QAAQ,IAAI,8BAOZ,QAAQ,SAAS,OAAU,UAAU,cAKrC,QAAQ,SAAS,SAAS,0BAA0B,KAO1C,SAAS,QAAQ,SAAS,KAAK,MAAM,GAAG,EAAE,CAAC,GAAG,EAAE,IAClD;AAKb;AC7CA,SAASC,IAAS;AACjB,QAAMC,IAAO,QAAQ,KAAK,MAAM,CAAC;AAGjC,SAAO,uBAAW,EAAA,KAAA,CAAAC,MAAAA,EAAA,CAAA,EAAE,KAAK,CAAC,EAAE,uBAAAC,QAA4B;AACvD,IAAAA,EAAsBF,CAAI;AAAA,EAC3B,CAAC;AACF;AAEA,IAAIF,KAAyB;AAC5B,QAAMK,IAAY,KAAK,IAAA,GACjBC,IAAQC;AAAA,IACb,QAAQ;AAAA,IACR;AAAA,MACC;AAAA,MACA,GAAG,QAAQ;AAAA,MACX,GAAG,QAAQ,KAAK,MAAM,CAAC;AAAA,IAAA;AAAA,IAExB,EAAE,OAAO,UAAA;AAAA,EAAU;AAIpB,aAAWC,KAAO,CAAC,UAAU,SAAS;AACrC,YAAQ,GAAGA,GAAK,MAAMF,EAAM,KAAKE,CAAG,CAAC;AAOtC,EAAAF,EAAM,GAAG,SAAS,MAAM;AACvB,IAAAL,EAAA;AAAA,EACD,CAAC,GAEDK,EAAM,GAAG,SAAS,CAACG,GAAMC,MAAW;AAKnC,QAAID,MAAS,KAAK,CAACC,KAAU,KAAK,IAAA,IAAQL,IAAY,KAAM;AAC3D,MAAAJ,EAAA;AACA;AAAA,IACD;AAWA,IAAIS,IACH,QAAQ,KAAK,QAAQ,KAAKA,CAAM,IAEhC,QAAQ,KAAKD,CAAI;AAAA,EAEnB,CAAC;AACF;AACC,EAAAR,EAAA;"}
|
package/ensure-jspi.d.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Determines whether the current process should respawn itself with
|
|
3
|
+
* the --experimental-wasm-jspi flag to enable JSPI support.
|
|
4
|
+
*
|
|
5
|
+
* Returns true only when all of these hold:
|
|
6
|
+
* 1. JSPI is not already available in this runtime.
|
|
7
|
+
* 2. We're running on Node.js (not Bun, Deno, or another runtime).
|
|
8
|
+
* 3. The flag hasn't already been passed (avoids infinite loops).
|
|
9
|
+
* 4. The Node.js version is >= 23 (the first version whose V8 has
|
|
10
|
+
* the current JSPI spec with WebAssembly.Suspending).
|
|
11
|
+
*
|
|
12
|
+
* Why not Node 22? It ships V8 12.4 which only exposes the old,
|
|
13
|
+
* since-removed JSPI API (WebAssembly.Suspender). The new API
|
|
14
|
+
* (WebAssembly.Suspending) arrived in V8 12.6 = Node 23.
|
|
15
|
+
*/
|
|
16
|
+
export declare function shouldRespawnWithJSPI(): boolean;
|
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-BZUBWAe5.cjs");exports.LogVerbosity=e.LogVerbosity;exports.internalsKeyForTesting=e.internalsKeyForTesting;exports.mergeDefinedConstants=e.mergeDefinedConstants;exports.parseOptionsAndRunCLI=e.parseOptionsAndRunCLI;exports.runCLI=e.runCLI;exports.spawnWorkerThread=e.spawnWorkerThread;
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|
package/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wp-playground/cli",
|
|
3
|
-
"version": "3.1.
|
|
3
|
+
"version": "3.1.13",
|
|
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": "4523244be9c3e12aef7889bbaca81ca40bcfaef3",
|
|
38
38
|
"dependencies": {
|
|
39
39
|
"@zip.js/zip.js": "2.7.57",
|
|
40
40
|
"ajv": "8.12.0",
|
|
@@ -61,18 +61,18 @@
|
|
|
61
61
|
"ws": "8.18.3",
|
|
62
62
|
"xml2js": "0.6.2",
|
|
63
63
|
"yargs": "17.7.2",
|
|
64
|
-
"@
|
|
65
|
-
"@php-wasm/
|
|
66
|
-
"@php-wasm/
|
|
67
|
-
"@
|
|
68
|
-
"@wp-playground/
|
|
69
|
-
"@wp-playground/wordpress": "3.1.
|
|
70
|
-
"@php-wasm/node": "3.1.
|
|
71
|
-
"@php-wasm/util": "3.1.
|
|
72
|
-
"@php-wasm/cli-util": "3.1.
|
|
73
|
-
"@wp-playground/storage": "3.1.
|
|
74
|
-
"@php-wasm/xdebug-bridge": "3.1.
|
|
75
|
-
"@wp-playground/tools": "3.1.
|
|
64
|
+
"@wp-playground/common": "3.1.13",
|
|
65
|
+
"@php-wasm/logger": "3.1.13",
|
|
66
|
+
"@php-wasm/progress": "3.1.13",
|
|
67
|
+
"@php-wasm/universal": "3.1.13",
|
|
68
|
+
"@wp-playground/blueprints": "3.1.13",
|
|
69
|
+
"@wp-playground/wordpress": "3.1.13",
|
|
70
|
+
"@php-wasm/node": "3.1.13",
|
|
71
|
+
"@php-wasm/util": "3.1.13",
|
|
72
|
+
"@php-wasm/cli-util": "3.1.13",
|
|
73
|
+
"@wp-playground/storage": "3.1.13",
|
|
74
|
+
"@php-wasm/xdebug-bridge": "3.1.13",
|
|
75
|
+
"@wp-playground/tools": "3.1.13"
|
|
76
76
|
},
|
|
77
77
|
"packageManager": "npm@10.9.2",
|
|
78
78
|
"overrides": {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
"use strict";const m=require("@php-wasm/logger"),y=require("@php-wasm/universal"),I=require("@wp-playground/blueprints"),B=require("@wp-playground/common"),c=require("fs"),N=require("worker_threads"),
|
|
1
|
+
"use strict";const m=require("@php-wasm/logger"),y=require("@php-wasm/universal"),I=require("@wp-playground/blueprints"),B=require("@wp-playground/common"),c=require("fs"),N=require("worker_threads"),ve=require("@php-wasm/node"),d=require("path"),pe=require("child_process"),Se=require("util"),me=require("express"),xe=require("stream"),Ee=require("stream/promises"),Te=require("yargs"),_=require("@wp-playground/storage"),se=require("@php-wasm/progress"),$e=require("@wp-playground/wordpress"),k=require("fs-extra"),Ie=require("module"),K=require("os"),ke=require("@php-wasm/xdebug-bridge"),ie=require("tmp-promise"),A=require("@php-wasm/cli-util"),Ce=require("crypto"),W=require("@wp-playground/tools"),ae=require("wasm-feature-detect");var $=typeof document<"u"?document.currentScript:null;function Q(e){const t=[];for(const r of e){const o=r.split(":");if(o.length!==2)throw new Error(`Invalid mount format: ${r}.
|
|
2
2
|
Expected format: /host/path:/vfs/path.
|
|
3
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[s
|
|
4
|
+
Example: --mount-dir C:\\my-plugin /wordpress/wp-content/plugins/my-plugin`);const[n,s]=o;if(!c.existsSync(n))throw new Error(`Host path does not exist: ${n}`);t.push({hostPath:n,vfsPath:s})}return t}function le(e){if(e.length%2!==0)throw new Error("Invalid mount format. Expected: /host/path /vfs/path");const t=[];for(let r=0;r<e.length;r+=2){const o=e[r],n=e[r+1];if(!c.existsSync(o))throw new Error(`Host path does not exist: ${o}`);t.push({hostPath:d.resolve(process.cwd(),o),vfsPath:n})}return t}async function Re(e,t){for(const r of t)await e.mount(r.vfsPath,ve.createNodeFsMountHandler(r.hostPath))}const ue={step:"runPHP",code:{filename:"activate-theme.php",content:`<?php
|
|
5
5
|
$docroot = getenv('DOCROOT') ? getenv('DOCROOT') : '/wordpress';
|
|
6
6
|
require_once "$docroot/wp-load.php";
|
|
7
7
|
$theme = wp_get_theme();
|
|
@@ -12,12 +12,12 @@
|
|
|
12
12
|
switch_theme($themeName);
|
|
13
13
|
}
|
|
14
14
|
}
|
|
15
|
-
`}};function
|
|
15
|
+
`}};function he(e){const t=e.autoMount,r=[...e.mount||[]],o=[...e["mount-before-install"]||[]],n={...e,mount:r,"mount-before-install":o,"additional-blueprint-steps":[...e["additional-blueprint-steps"]||[]]};if(De(t)){const a=`/wordpress/wp-content/plugins/${d.basename(t)}`;r.push({hostPath:t,vfsPath:a,autoMounted:!0}),n["additional-blueprint-steps"].push({step:"activatePlugin",pluginPath:`/wordpress/wp-content/plugins/${d.basename(t)}`})}else if(Be(t)){const s=d.basename(t),a=`/wordpress/wp-content/themes/${s}`;r.push({hostPath:t,vfsPath:a,autoMounted:!0}),n["additional-blueprint-steps"].push(e["experimental-blueprints-v2-runner"]?{step:"activateTheme",themeDirectoryName:s}:{step:"activateTheme",themeFolderName:s})}else if(Ae(t)){const s=c.readdirSync(t);for(const a of s)a!=="index.php"&&r.push({hostPath:`${t}/${a}`,vfsPath:`/wordpress/wp-content/${a}`,autoMounted:!0});n["additional-blueprint-steps"].push(ue)}else Me(t)&&(o.push({hostPath:t,vfsPath:"/wordpress",autoMounted:!0}),n.mode="apply-to-existing-site",n["additional-blueprint-steps"].push(ue),n.wordpressInstallMode||(n.wordpressInstallMode="install-from-existing-files-if-needed"));return n}function Me(e){const t=c.readdirSync(e);return t.includes("wp-admin")&&t.includes("wp-includes")&&t.includes("wp-content")}function Ae(e){const t=c.readdirSync(e);return t.includes("themes")||t.includes("plugins")||t.includes("mu-plugins")||t.includes("uploads")}function Be(e){if(!c.readdirSync(e).includes("style.css"))return!1;const r=c.readFileSync(d.join(e,"style.css"),"utf8");return!!/^(?:[ \t]*<\?php)?[ \t/*#@]*Theme Name:(.*)$/im.exec(r)}function De(e){const t=c.readdirSync(e),r=/^(?:[ \t]*<\?php)?[ \t/*#@]*Plugin Name:(.*)$/im;return!!t.filter(n=>n.endsWith(".php")).find(n=>{const s=c.readFileSync(d.join(e,n),"utf8");return!!r.exec(s)})}function Le(e){if(e.length%2!==0)throw new Error("Invalid constant definition format. Expected pairs of NAME value");const t={};for(let r=0;r<e.length;r+=2){const o=e[r],n=e[r+1];if(!o||!o.trim())throw new Error("Constant name cannot be empty");t[o.trim()]=n}return t}function Ue(e){if(e.length%2!==0)throw new Error("Invalid boolean constant definition format. Expected pairs of NAME value");const t={};for(let r=0;r<e.length;r+=2){const o=e[r],n=e[r+1].trim().toLowerCase();if(!o||!o.trim())throw new Error("Constant name cannot be empty");if(n==="true"||n==="1")t[o.trim()]=!0;else if(n==="false"||n==="0")t[o.trim()]=!1;else throw new Error(`Invalid boolean value for constant "${o}": "${n}". Must be "true", "false", "1", or "0".`)}return t}function _e(e){if(e.length%2!==0)throw new Error("Invalid number constant definition format. Expected pairs of NAME value");const t={};for(let r=0;r<e.length;r+=2){const o=e[r],n=e[r+1].trim();if(!o||!o.trim())throw new Error("Constant name cannot be empty");const s=Number(n);if(isNaN(s))throw new Error(`Invalid number value for constant "${o}": "${n}". Must be a valid number.`);t[o.trim()]=s}return t}function We(e={},t={},r={}){const o={},n=new Set,s=(a,l)=>{for(const u in a){if(n.has(u))throw new Error(`Constant "${u}" is defined multiple times across different --define-${l} flags`);n.add(u),o[u]=a[u]}};return s(e,"string"),s(t,"bool"),s(r,"number"),o}function F(e){return We(e.define,e["define-bool"],e["define-number"])}const He=Se.promisify(pe.exec);function Ne(e){return new Promise(t=>{if(e===0)return t(!1);const r=me().listen(e);r.once("listening",()=>r.close(()=>t(!1))),r.once("error",o=>t(o.code==="EADDRINUSE"))})}async function Fe(e){const t=me(),r=await new Promise((a,l)=>{const u=t.listen(e.port,()=>{const b=u.address();b===null||typeof b=="string"?l(new Error("Server address is not available")):a(u)}).once("error",l)});t.use("/",async(a,l)=>{try{const u={url:a.url,headers:je(a),method:a.method,body:await qe(a)},b=await e.handleRequest(u);await Oe(b,l)}catch(u){m.logger.error(u),l.headersSent||(l.statusCode=500,l.end("Internal Server Error"))}});const n=r.address().port,s=process.env.CODESPACE_NAME;return s&&Ve(n,s),await e.onBind(r,n)}async function Oe(e,t){const[r,o]=await Promise.all([e.headers,e.httpStatusCode]);t.statusCode=o;for(const s in r)t.setHeader(s,r[s]);const n=xe.Readable.fromWeb(e.stdout);try{await Ee.pipeline(n,t)}catch(s){if(s instanceof Error&&"code"in s&&(s.code==="ERR_STREAM_PREMATURE_CLOSE"||s.code==="ERR_STREAM_UNABLE_TO_PIPE"))return;throw s}}const qe=async e=>await new Promise(t=>{const r=[];e.on("data",o=>{r.push(o)}),e.on("end",()=>{t(new Uint8Array(Buffer.concat(r)))})});async function Ve(e,t){m.logger.log(`Publishing port ${e}...`);const r=`gh codespace ports visibility ${e}:public -c ${t}`;for(let o=0;o<10;o++)try{await He(r);return}catch{await new Promise(n=>setTimeout(n,2e3))}}const je=e=>{const t={};if(e.rawHeaders&&e.rawHeaders.length)for(let r=0;r<e.rawHeaders.length;r+=2)t[e.rawHeaders[r].toLowerCase()]=e.rawHeaders[r+1];return t};function Ye(e){return/^latest$|^trunk$|^nightly$|^(?:(\d+)\.(\d+)(?:\.(\d+))?)((?:-beta(?:\d+)?)|(?:-RC(?:\d+)?))?$/.test(e)}async function ze({sourceString:e,blueprintMayReadAdjacentFiles:t}){if(!e)return;if(e.startsWith("http://")||e.startsWith("https://"))return await I.resolveRemoteBlueprint(e);let r=d.resolve(process.cwd(),e);if(!c.existsSync(r))throw new Error(`Blueprint file does not exist: ${r}`);const o=c.statSync(r);if(o.isDirectory()&&(r=d.join(r,"blueprint.json")),!o.isFile()&&o.isSymbolicLink())throw new Error(`Blueprint path is neither a file nor a directory: ${r}`);const n=d.extname(r);switch(n){case".zip":return _.ZipFilesystem.fromArrayBuffer(c.readFileSync(r).buffer);case".json":{const s=c.readFileSync(r,"utf-8");try{JSON.parse(s)}catch{throw new Error(`Blueprint file at ${r} is not a valid JSON file`)}const a=d.dirname(r),l=new _.NodeJsFilesystem(a);return new _.OverlayFilesystem([new _.InMemoryFilesystem({"blueprint.json":s}),{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
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: ${
|
|
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: ${n}. Only .zip and .json files are supported.`)}}class Ge{constructor(t,r){this.args=t,this.siteUrl=r.siteUrl,this.phpVersion=t.php,this.cliOutput=r.cliOutput}getWorkerType(){return"v2"}async bootWordPress(t,r){const o={command:this.args.command,siteUrl:this.siteUrl,blueprint:this.args.blueprint,workerPostInstallMountsPort:r};return await t.bootWordPress(o,r),t}async bootRequestHandler({worker:t,fileLockManagerPort:r,nativeInternalDirPath:o}){const n=y.consumeAPI(t.phpPort);await n.useFileLockManager(r);const s={...this.args,phpVersion:this.phpVersion,siteUrl:this.siteUrl,processId:t.processId,trace:this.args.verbosity==="debug",withIntl:this.args.intl,withRedis:this.args.redis,withMemcached:this.args.memcached,withXdebug:!!this.args.xdebug,nativeInternalDirPath:o,mountsBeforeWpInstall:this.args["mount-before-install"]||[],mountsAfterWpInstall:this.args.mount||[],constants:F(this.args)};return await n.bootWorker(s),n}}const J=d.join(K.homedir(),".wordpress-playground");async function Qe(){const e=typeof __dirname<"u"?__dirname:void 0;let t=d.join(e,"sqlite-database-integration.zip");if(!k.existsSync(t)){const r=Ie.createRequire(typeof document>"u"?require("url").pathToFileURL(__filename).href:$&&$.tagName.toUpperCase()==="SCRIPT"&&$.src||new URL("run-cli-BZUBWAe5.cjs",document.baseURI).href),o=d.dirname(r.resolve("@wp-playground/wordpress-builds/package.json"));t=d.join(o,"src","sqlite-database-integration","sqlite-database-integration-trunk.zip")}return new File([await k.readFile(t)],d.basename(t))}async function Xe(e,t,r){const o=d.join(J,t);return k.existsSync(o)||(k.ensureDirSync(J),await Ze(e,o,r)),fe(o)}async function Ze(e,t,r){const n=(await r.monitorFetch(fetch(e))).body.getReader(),s=`${t}.partial`,a=k.createWriteStream(s);for(;;){const{done:l,value:u}=await n.read();if(u&&a.write(u),l)break}a.close(),a.closed||await new Promise((l,u)=>{a.on("finish",()=>{k.renameSync(s,t),l(null)}),a.on("error",b=>{k.removeSync(s),u(b)})})}function fe(e,t){return new File([k.readFileSync(e)],d.basename(e))}class Je{constructor(t,r){this.args=t,this.siteUrl=r.siteUrl,this.cliOutput=r.cliOutput}getWorkerType(){return"v1"}async bootWordPress(t,r){let o,n,s;const a=new se.EmscriptenDownloadMonitor;if(this.args.wordpressInstallMode==="download-and-install"){let b=!1;a.addEventListener("progress",T=>{if(b)return;const{loaded:p,total:i}=T.detail,h=Math.floor(Math.min(100,100*p/i));b=h===100,this.cliOutput.updateProgress("Downloading WordPress",h)}),o=await $e.resolveWordPressRelease(this.args.wp),s=d.join(J,`prebuilt-wp-content-for-wp-${o.version}.zip`),n=c.existsSync(s)?fe(s):await Xe(o.releaseUrl,`${o.version}.zip`,a),m.logger.debug(`Resolved WordPress release URL: ${o?.releaseUrl}`)}let l;this.args.skipSqliteSetup?(m.logger.debug("Skipping SQLite integration plugin setup..."),l=void 0):(this.cliOutput.updateProgress("Preparing SQLite database"),l=await Qe()),this.cliOutput.updateProgress("Booting WordPress");const u=await I.resolveRuntimeConfiguration(this.getEffectiveBlueprint());return await t.bootWordPress({wpVersion:u.wpVersion,siteUrl:this.siteUrl,wordpressInstallMode:this.args.wordpressInstallMode||"download-and-install",wordPressZip:n&&await n.arrayBuffer(),sqliteIntegrationPluginZip:await l?.arrayBuffer(),constants:F(this.args)},r),s&&!this.args["mount-before-install"]&&!c.existsSync(s)&&(this.cliOutput.updateProgress("Caching WordPress for next boot"),c.writeFileSync(s,await B.zipDirectory(t,"/wordpress"))),t}async bootRequestHandler({worker:t,fileLockManagerPort:r,nativeInternalDirPath:o}){const n=y.consumeAPI(t.phpPort);await n.isConnected();const s=await I.resolveRuntimeConfiguration(this.getEffectiveBlueprint());return await n.useFileLockManager(r),await n.bootRequestHandler({phpVersion:s.phpVersion,siteUrl:this.siteUrl,mountsBeforeWpInstall:this.args["mount-before-install"]||[],mountsAfterWpInstall:this.args.mount||[],processId:t.processId,followSymlinks:this.args.followSymlinks===!0,trace:this.args.experimentalTrace===!0,withIntl:this.args.intl,withRedis:this.args.redis,withMemcached:this.args.memcached,withXdebug:!!this.args.xdebug,nativeInternalDirPath:o,pathAliases:this.args.pathAliases}),await n.isReady(),n}async compileInputBlueprint(t){const r=this.getEffectiveBlueprint(),o=new se.ProgressTracker;let n="",s=!1;return o.addEventListener("progress",a=>{if(s)return;s=a.detail.progress===100;const l=Math.floor(a.detail.progress);n=a.detail.caption||n||"Running Blueprint",this.cliOutput.updateProgress(n.trim(),l)}),await I.compileBlueprintV1(r,{progress:o,additionalSteps:t})}getEffectiveBlueprint(){const t=this.args.blueprint;return I.isBlueprintBundle(t)?t:{login:this.args.login,...t||{},preferredVersions:{php:this.args.php??t?.preferredVersions?.php??B.RecommendedPHPVersion,wp:this.args.wp??t?.preferredVersions?.wp??"latest",...t?.preferredVersions||{}}}}}async function Ke(e,t=!0){const o=`${d.basename(process.argv0)}${e}${process.pid}-`,n=await ie.dir({prefix:o,unsafeCleanup:!0});return t&&ie.setGracefulCleanup(),n}async function et(e,t,r){const n=(await tt(e,t,r)).map(s=>new Promise(a=>{c.rm(s,{recursive:!0},l=>{l?m.logger.warn(`Failed to delete stale Playground temp dir: ${s}`,l):m.logger.info(`Deleted stale Playground temp dir: ${s}`),a()})}));await Promise.all(n)}async function tt(e,t,r){try{const o=c.readdirSync(r).map(s=>d.join(r,s)),n=[];for(const s of o)await rt(e,t,s)&&n.push(s);return n}catch(o){return m.logger.warn(`Failed to find stale Playground temp dirs: ${o}`),[]}}async function rt(e,t,r){if(!c.lstatSync(r).isDirectory())return!1;const n=d.basename(r);if(!n.includes(e))return!1;const s=n.match(new RegExp(`^(.+)${e}(\\d+)-`));if(!s)return!1;const a={executableName:s[1],pid:s[2]};if(ot(a.pid))return!1;const l=Date.now()-t;return c.statSync(r).mtime.getTime()<l}function ot(e,t){try{return process.kill(Number(e),0),!0}catch(r){const o=r,n=o&&typeof o.code=="string"?o.code:void 0;return n==="ESRCH"?!1:n==="EPERM"||n==="EACCES"?(m.logger.debug(`Permission denied while checking if process ${e} exists (code: ${n}).`,r),!0):(m.logger.warn(`Could not determine if process ${e} exists due to unexpected error${n?` (code: ${n})`:""}.`,r),!0)}}function we(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 nt{constructor(t){this.lastProgressLine="",this.progressActive=!1,this.verbosity=t.verbosity,this.writeStream=t.writeStream||process.stdout}get isTTY(){return!!this.writeStream.isTTY}get shouldRender(){return we(this.writeStream)}get isQuiet(){return this.verbosity==="quiet"}bold(t){return this.isTTY?`\x1B[1m${t}\x1B[0m`:t}dim(t){return this.isTTY?`\x1B[2m${t}\x1B[0m`:t}green(t){return this.isTTY?`\x1B[32m${t}\x1B[0m`:t}cyan(t){return this.isTTY?`\x1B[36m${t}\x1B[0m`:t}yellow(t){return this.isTTY?`\x1B[33m${t}\x1B[0m`:t}red(t){return this.isTTY?`\x1B[31m${t}\x1B[0m`:t}printBanner(){if(this.isQuiet)return;const t=this.bold("WordPress Playground CLI");this.writeStream.write(`
|
|
18
18
|
${t}
|
|
19
19
|
|
|
20
|
-
`)}printConfig(t){if(this.isQuiet)return;const r=[];r.push(`${this.dim("PHP")} ${this.cyan(t.phpVersion)} ${this.dim("WordPress")} ${this.cyan(t.wpVersion)}`);const o=[];if(t.intl&&o.push("intl"),t.redis&&o.push("redis"),t.memcached&&o.push("memcached"),t.xdebug&&o.push(this.yellow("xdebug")),o.length>0&&r.push(`${this.dim("Extensions")} ${o.join(", ")}`),t.mounts.length>0)for(const
|
|
20
|
+
`)}printConfig(t){if(this.isQuiet)return;const r=[];r.push(`${this.dim("PHP")} ${this.cyan(t.phpVersion)} ${this.dim("WordPress")} ${this.cyan(t.wpVersion)}`);const o=[];if(t.intl&&o.push("intl"),t.redis&&o.push("redis"),t.memcached&&o.push("memcached"),t.xdebug&&o.push(this.yellow("xdebug")),o.length>0&&r.push(`${this.dim("Extensions")} ${o.join(", ")}`),t.mounts.length>0)for(const n of t.mounts){const s=n.autoMounted?` ${this.dim("(auto-mount)")}`:"";r.push(`${this.dim("Mount")} ${n.hostPath} ${this.dim("→")} ${n.vfsPath}${s}`)}t.blueprint&&r.push(`${this.dim("Blueprint")} ${t.blueprint}`),this.writeStream.write(r.join(`
|
|
21
21
|
`)+`
|
|
22
22
|
|
|
23
23
|
`)}startProgress(t){this.isQuiet||this.shouldRender&&(this.progressActive=!0,this.updateProgress(t))}updateProgress(t,r){if(this.isQuiet||!this.shouldRender)return;this.progressActive||(this.progressActive=!0);let o=`${t}`;r!==void 0&&(o=`${t} ${this.dim(`${r}%`)}`),o!==this.lastProgressLine&&(this.lastProgressLine=o,this.isTTY?(this.writeStream.cursorTo(0),this.writeStream.write(o),this.writeStream.clearLine(1)):this.writeStream.write(`${o}
|
|
@@ -31,8 +31,8 @@ ${this.green("Ready!")} WordPress is running on ${this.bold(t)} ${this.dim(`(${r
|
|
|
31
31
|
`)}printWarning(t){this.isQuiet||this.writeStream.write(`${this.yellow("Warning:")} ${t}
|
|
32
32
|
`)}printPhpMyAdminUrl(t){this.isQuiet||this.writeStream.write(`${this.cyan("phpMyAdmin")} available at ${this.bold(t)}
|
|
33
33
|
|
|
34
|
-
`)}}const
|
|
35
|
-
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},redis:{describe:"Enable Redis (requires JSPI support).",type:"boolean"},memcached:{describe:"Enable Memcached.",type:"boolean"},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:i=>i===""?["vscode","phpstorm"]:[i]},"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},phpmyadmin:{describe:"Install phpMyAdmin for database management. The phpMyAdmin URL will be printed after boot. Optionally specify a custom URL path (default: /phpmyadmin).",type:"string",coerce:i=>i===""?"/phpmyadmin":i}},r={port:{describe:"Port to listen on when serving. Defaults to 9400 when available.",type:"number"},"experimental-multi-worker":{deprecated:"This option is not needed. Multiple workers are always used.",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"},"experimental-devtools":{describe:"Enable experimental browser development tools.",type:"boolean"}},o={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:B.RecommendedPHPVersion,choices:y.SupportedPHPVersions},wp:{describe:"WordPress version to use.",type:"string",default:"latest"},port:{describe:"Port to listen on. Defaults to 9400 when available.",type:"number"},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:
|
|
34
|
+
`)}}const O={Quiet:{name:"quiet",severity:m.LogSeverity.Fatal},Normal:{name:"normal",severity:m.LogSeverity.Info},Debug:{name:"debug",severity:m.LogSeverity.Debug}};async function ye(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:B.RecommendedPHPVersion,choices:y.SupportedPHPVersions},wp:{describe:"WordPress version to use.",type:"string",default:"latest"},define:{describe:'Define PHP string constants (can be used multiple times). Format: NAME value. These constants are set via php.defineConstant() and only exist for the current request. Examples: --define API_KEY secret --define CON=ST "va=lu=e"',type:"string",nargs:2,array:!0,coerce:Le},"define-bool":{describe:'Define PHP boolean constants (can be used multiple times). Format: NAME value. Value must be "true", "false", "1", or "0". Examples: --define-bool WP_DEBUG true --define-bool MY_FEATURE false',type:"string",nargs:2,array:!0,coerce:Ue},"define-number":{describe:"Define PHP number constants (can be used multiple times). Format: NAME value. Examples: --define-number LIMIT 100 --define-number RATE 45.67",type:"string",nargs:2,array:!0,coerce:_e},mount:{describe:"Mount a directory to the PHP runtime (can be used multiple times). Format: /host/path:/vfs/path",type:"array",string:!0,nargs:1,coerce:Q},"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,nargs:1,coerce:Q},"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:le},"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:le},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(O).map(i=>i.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.
|
|
35
|
+
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},redis:{describe:"Enable Redis (requires JSPI support).",type:"boolean"},memcached:{describe:"Enable Memcached.",type:"boolean"},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:i=>i===""?["vscode","phpstorm"]:[i]},"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},phpmyadmin:{describe:"Install phpMyAdmin for database management. The phpMyAdmin URL will be printed after boot. Optionally specify a custom URL path (default: /phpmyadmin).",type:"string",coerce:i=>i===""?"/phpmyadmin":i}},r={port:{describe:"Port to listen on when serving. Defaults to 9400 when available.",type:"number"},"experimental-multi-worker":{deprecated:"This option is not needed. Multiple workers are always used.",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"},"experimental-devtools":{describe:"Enable experimental browser development tools.",type:"boolean"}},o={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:B.RecommendedPHPVersion,choices:y.SupportedPHPVersions},wp:{describe:"WordPress version to use.",type:"string",default:"latest"},port:{describe:"Port to listen on. Defaults to 9400 when available.",type:"number"},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:Q},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},define:t.define,"define-bool":t["define-bool"],"define-number":t["define-number"],phpmyadmin:t.phpmyadmin},n={outfile:{describe:"When building, write to this output file.",type:"string",default:"wordpress.zip"}},s=Te(e).usage("Usage: wp-playground <command> [options]").command("start","Start a local WordPress server with automatic project detection (recommended)",i=>i.usage(`Usage: wp-playground start [options]
|
|
36
36
|
|
|
37
37
|
The easiest way to run WordPress locally. Automatically detects
|
|
38
38
|
if your directory contains a plugin, theme, wp-content, or
|
|
@@ -43,9 +43,9 @@ Examples:
|
|
|
43
43
|
wp-playground start --path=./my-plugin # Start with a specific path
|
|
44
44
|
wp-playground start --wp=6.7 --php=8.3 # Use specific versions
|
|
45
45
|
wp-playground start --skip-browser # Skip opening browser
|
|
46
|
-
wp-playground start --no-auto-mount # Disable auto-detection`).options(o)).command("server","Start a local WordPress server (advanced, low-level)",i=>i.options({...t,...r})).command("run-blueprint","Execute a Blueprint without starting a server",i=>i.options({...t})).command("build-snapshot","Build a ZIP snapshot of a WordPress site based on a Blueprint",i=>i.options({...t,...
|
|
47
|
-
`+i),process.exit(1)),console.error(i),process.exit(1)}).strictOptions().check(async i=>{if(i["skip-wordpress-install"]===!0&&(i["wordpress-install-mode"]="do-not-attempt-installing",i.wordpressInstallMode="do-not-attempt-installing"),i.wp!==void 0&&typeof i.wp=="string"&&!
|
|
48
|
-
`)}}).then(async S=>{o.push(S);const x=await at(l),E=await M.bootRequestHandler({worker:S,fileLockManagerPort:x,nativeInternalDirPath:
|
|
46
|
+
wp-playground start --no-auto-mount # Disable auto-detection`).options(o)).command("server","Start a local WordPress server (advanced, low-level)",i=>i.options({...t,...r})).command("run-blueprint","Execute a Blueprint without starting a server",i=>i.options({...t})).command("build-snapshot","Build a ZIP snapshot of a WordPress site based on a Blueprint",i=>i.options({...t,...n})).command("php","Run a PHP script",i=>i.options({...t})).demandCommand(1,"Please specify a command").strictCommands().conflicts("experimental-unsafe-ide-integration","experimental-devtools").showHelpOnFail(!1).fail((i,h,g)=>{if(h)throw h;i&&i.includes("Please specify a command")&&(g.showHelp(),console.error(`
|
|
47
|
+
`+i),process.exit(1)),console.error(i),process.exit(1)}).strictOptions().check(async i=>{if(i["skip-wordpress-install"]===!0&&(i["wordpress-install-mode"]="do-not-attempt-installing",i.wordpressInstallMode="do-not-attempt-installing"),i.wp!==void 0&&typeof i.wp=="string"&&!Ye(i.wp))try{new URL(i.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 h=i["site-url"];if(typeof h=="string"&&h.trim()!=="")try{new URL(h)}catch{throw new Error(`Invalid site-url "${h}". Please provide a valid URL (e.g., http://localhost:8080 or https://example.com)`)}if(i["auto-mount"]){let g=!1;try{g=c.statSync(i["auto-mount"]).isDirectory()}catch{g=!1}if(!g)throw new Error(`The specified --auto-mount path is not a directory: '${i["auto-mount"]}'.`)}if(i["experimental-blueprints-v2-runner"]===!0)throw new Error("Blueprints v2 are temporarily disabled while we rework their runtime implementation.");if(i.mode!==void 0)throw new Error("The --mode option requires the --experimentalBlueprintsV2Runner flag.");return!0});s.wrap(s.terminalWidth());const a=await s.argv,l=a._[0];["start","run-blueprint","server","build-snapshot","php"].includes(l)||(s.showHelp(),process.exit(1));const u=a.define||{};!("WP_DEBUG"in u)&&!("WP_DEBUG_LOG"in u)&&!("WP_DEBUG_DISPLAY"in u)&&(u.WP_DEBUG="true",u.WP_DEBUG_LOG="true",u.WP_DEBUG_DISPLAY="true");const b={...a,define:u,command:l,mount:[...a.mount||[],...a["mount-dir"]||[]],"mount-before-install":[...a["mount-before-install"]||[],...a["mount-dir-before-install"]||[]]},T=await ee(b);T===void 0&&process.exit(0);const p=(()=>{let i;return async()=>{i===void 0&&(i=T[Symbol.asyncDispose]()),await i,process.exit(0)}})();return process.on("SIGINT",p),process.on("SIGTERM",p),{[Symbol.asyncDispose]:async()=>{process.off("SIGINT",p),process.off("SIGTERM",p),await T[Symbol.asyncDispose]()},[q]:{cliServer:T}}}catch(t){if(console.error(t),!(t instanceof Error))throw t;if(process.argv.includes("--debug"))y.printDebugDetails(t);else{const o=[];let n=t;do o.push(n.message),n=n.cause;while(n instanceof Error);console.error("\x1B[1m"+o.join(" caused by: ")+"\x1B[0m")}process.exit(1)}}function de(e,t){return e.find(r=>r.vfsPath.replace(/\/$/,"")===t.replace(/\/$/,""))}const q=Symbol("playground-cli-testing"),R=e=>process.stdout.isTTY?"\x1B[1m"+e+"\x1B[0m":e,st=e=>process.stdout.isTTY?"\x1B[31m"+e+"\x1B[0m":e,ce=e=>process.stdout.isTTY?`\x1B[2m${e}\x1B[0m`:e,H=e=>process.stdout.isTTY?`\x1B[3m${e}\x1B[0m`:e,X=e=>process.stdout.isTTY?`\x1B[33m${e}\x1B[0m`:e;async function ee(e){let t;const r=e.internalCookieStore?new y.HttpCookieStore:void 0,o=[],n=new Map;if(e.command==="start"&&(e=it(e)),e.autoMount!==void 0&&(e.autoMount===""&&(e={...e,autoMount:process.cwd()}),e=he(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 p=Object.values(O).find(i=>i.name===e.verbosity).severity;m.logger.setSeverityFilterLevel(p)}e.intl||(e.intl=!0),e.redis===void 0&&(e.redis=await ae.jspi()),e.memcached===void 0&&(e.memcached=await ae.jspi()),e.phpmyadmin&&(e.phpmyadmin===!0&&(e.phpmyadmin="/phpmyadmin"),e.pathAliases=[{urlPrefix:e.phpmyadmin,fsPath:W.PHPMYADMIN_INSTALL_PATH}]);const s=new nt({verbosity:e.verbosity||"normal"});e.command==="server"&&(s.printBanner(),s.printConfig({phpVersion:e.php||B.RecommendedPHPVersion,wpVersion:e.wp||"latest",port:e.port??9400,xdebug:!!e.xdebug,intl:!!e.intl,redis:!!e.redis,memcached:!!e.memcached,mounts:[...e.mount||[],...e["mount-before-install"]||[]],blueprint:typeof e.blueprint=="string"?e.blueprint:void 0}));const a=e.command==="server"?e.port??9400:0,l=new y.FileLockManagerInMemory;let u=!1,b=!0;const T=await Fe({port:e.port?e.port:await Ne(a)?0:a,onBind:async(p,i)=>{const h="127.0.0.1",g=`http://${h}:${i}`,V=e["site-url"]||g,j=6,re="-playground-cli-site-",C=await Ke(re);m.logger.debug(`Native temp dir for VFS root: ${C.path}`);const L="WP Playground CLI - Listen for Xdebug",oe=".playground-xdebug-root",Y=d.join(process.cwd(),oe);if(await A.removeTempDirSymlink(Y),e.xdebug){const f={hostPath:d.join(".",d.sep,oe),vfsPath:"/"};if(y.SupportedPHPVersions.indexOf(e.php||B.RecommendedPHPVersion)<=y.SupportedPHPVersions.indexOf("8.5"))await A.createTempDirSymlink(C.path,Y,process.platform),e.xdebug=A.makeXdebugConfig({cwd:process.cwd(),mounts:[f,...e["mount-before-install"]||[],...e.mount||[]],pathSkippings:["/dev/","/home/","/internal/","/request/","/proc/"]}),console.log(R("Xdebug configured successfully")),console.log(X("Playground source root: ")+".playground-xdebug-root"+H(ce(" – you can set breakpoints and preview Playground's VFS structure in there.")));else if(e.experimentalUnsafeIdeIntegration){await A.createTempDirSymlink(C.path,Y,process.platform);try{await A.clearXdebugIDEConfig(L,process.cwd());const w=typeof e.xdebug=="object"?e.xdebug:{},P=await A.addXdebugIDEConfig({name:L,host:h,port:i,ides:e.experimentalUnsafeIdeIntegration,cwd:process.cwd(),mounts:[f,...e["mount-before-install"]||[],...e.mount||[]],ideKey:w.ideKey||"WPPLAYGROUNDCLI"}),S=e.experimentalUnsafeIdeIntegration,x=S.includes("vscode"),E=S.includes("phpstorm"),U=Object.values(P);console.log(""),U.length>0?(console.log(R("Xdebug configured successfully")),console.log(X("Updated IDE config: ")+U.join(" ")),console.log(X("Playground source root: ")+".playground-xdebug-root"+H(ce(" – you can set breakpoints and preview Playground's VFS structure in there.")))):(console.log(R("Xdebug configuration failed.")),console.log("No IDE-specific project settings directory was found in the current working directory.")),console.log(""),x&&P.vscode&&(console.log(R("VS Code / Cursor instructions:")),console.log(" 1. Ensure you have installed an IDE extension for PHP Debugging"),console.log(` (The ${R("PHP Debug")} extension by ${R("Xdebug")} has been a solid option)`),console.log(" 2. Open the Run and Debug panel on the left sidebar"),console.log(` 3. Select "${H(L)}" 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"),E&&console.log("")),E&&P.phpstorm&&(console.log(R("PhpStorm instructions:")),console.log(` 1. Choose "${H(L)}" 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(w){throw new Error("Could not configure Xdebug",{cause:w})}}}const be=d.dirname(C.path),ge=2*24*60*60*1e3;et(re,ge,be);const ne=d.join(C.path,"internal");c.mkdirSync(ne);const Pe=["wordpress","tools","tmp","home"];for(const f of Pe){const v=P=>P.vfsPath===`/${f}`;if(!(e["mount-before-install"]?.some(v)||e.mount?.some(v))){const P=d.join(C.path,f);c.mkdirSync(P),e["mount-before-install"]===void 0&&(e["mount-before-install"]=[]),e["mount-before-install"].unshift({vfsPath:`/${f}`,hostPath:P})}}if(e["mount-before-install"])for(const f of e["mount-before-install"])m.logger.debug(`Mount before WP install: ${f.vfsPath} -> ${f.hostPath}`);if(e.mount)for(const f of e.mount)m.logger.debug(`Mount after WP install: ${f.vfsPath} -> ${f.hostPath}`);let M;e["experimental-blueprints-v2-runner"]?M=new Ge(e,{siteUrl:V,cliOutput:s}):(M=new Je(e,{siteUrl:V,cliOutput:s}),typeof e.blueprint=="string"&&(e.blueprint=await ze({sourceString:e.blueprint,blueprintMayReadAdjacentFiles:e["blueprint-may-read-adjacent-files"]===!0})));let z=!1;const D=async function(){z||(z=!0,await Promise.all(o.map(async v=>{await n.get(v)?.dispose(),await v.worker.terminate()})),p&&await new Promise(v=>{p.close(v),p.closeAllConnections()}),await C.cleanup())};try{const f=[],v=M.getWorkerType();for(let w=0;w<j;w++){const P=te(v,{onExit:S=>{z||S===0&&m.logger.error(`Worker ${w} exited with code ${S}
|
|
48
|
+
`)}}).then(async S=>{o.push(S);const x=await at(l),E=await M.bootRequestHandler({worker:S,fileLockManagerPort:x,nativeInternalDirPath:ne});return n.set(S,E),[S,E]});f.push(P),w===0&&await P}await Promise.all(f),t=y.createObjectPoolProxy(o.map(w=>n.get(w)));{const w=new N.MessageChannel,P=w.port1,S=w.port2;if(await y.exposeAPI({applyPostInstallMountsToAllWorkers:async()=>{await Promise.all(Array.from(n.values()).map(x=>x.mountAfterWordPressInstall(e.mount||[])))}},void 0,P),await M.bootWordPress(t,S),P.close(),u=!0,!e["experimental-blueprints-v2-runner"]){const x=await M.compileInputBlueprint(e["additional-blueprint-steps"]||[]);x&&await I.runBlueprintV1Steps(x,t)}if(e.phpmyadmin&&!await t.fileExists(`${W.PHPMYADMIN_INSTALL_PATH}/index.php`)){const x=await W.getPhpMyAdminInstallSteps(),E=await I.compileBlueprintV1({steps:x});await I.runBlueprintV1Steps(E,t)}if(e.command==="build-snapshot"){await ut(t,e.outfile),s.printStatus(`Exported to ${e.outfile}`),await D();return}else if(e.command==="run-blueprint"){s.finishProgress("Done"),await D();return}else if(e.command==="php"){const x=["/internal/shared/bin/php",...(e._||[]).slice(1)],E=await t.cli(x),[U]=await Promise.all([E.exitCode,E.stdout.pipeTo(new WritableStream({write(G){process.stdout.write(G)}})),E.stderr.pipeTo(new WritableStream({write(G){process.stderr.write(G)}}))]);await D(),process.exit(U)}}if(s.finishProgress(),s.printReady(g,j),e.phpmyadmin){const w=d.join(e.phpmyadmin,W.PHPMYADMIN_ENTRY_PATH);s.printPhpMyAdminUrl(new URL(w,g).toString())}return e.xdebug&&e.experimentalDevtools&&(await ke.startBridge({phpInstance:t,phpRoot:"/wordpress"})).start(),{playground:t,server:p,serverUrl:g,[Symbol.asyncDispose]:D,[q]:{workerThreadCount:j}}}catch(f){if(e.verbosity!=="debug")throw f;let v="";throw await t?.fileExists(m.errorLogPath)&&(v=await t.readFileAsText(m.errorLogPath)),await D(),new Error(v,{cause:f})}},async handleRequest(p){if(!u)return y.StreamedPHPResponse.forHttpCode(502,"WordPress is not ready yet");if(b){b=!1;const h={"Content-Type":["text/plain"],"Content-Length":["0"],Location:[p.url]};return p.headers?.cookie?.includes("playground_auto_login_already_happened")&&(h["Set-Cookie"]=["playground_auto_login_already_happened=1; Max-Age=0; Expires=Thu, 01 Jan 1970 00:00:00 GMT; Path=/"]),y.StreamedPHPResponse.fromPHPResponse(new y.PHPResponse(302,h,new Uint8Array))}r&&(p={...p,headers:{...p.headers,cookie:r.getCookieRequestHeader()}});const i=await t.requestStreamed(p);if(r){const h=await i.headers;r.rememberCookiesFromResponseHeaders(h),delete h["set-cookie"]}return i}}).catch(p=>{s.printError(p.message),process.exit(1)});return T&&e.command==="start"&&!e.skipBrowser&<(T.serverUrl),T}function it(e){let t={...e,command:"server"};e.noAutoMount||(t.autoMount=d.resolve(process.cwd(),t.path??""),t=he(t),delete t.autoMount);const r=de(t["mount-before-install"]||[],"/wordpress")||de(t.mount||[],"/wordpress");if(r)console.log("Site files stored at:",r?.hostPath),e.reset&&(console.log(""),console.log(st("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 o=t.autoMount||process.cwd(),n=Ce.createHash("sha256").update(o).digest("hex"),s=K.homedir(),a=d.join(s,".wordpress-playground/sites",n);console.log("Site files stored at:",a),c.existsSync(a)&&e.reset&&(console.log("Resetting site..."),c.rmdirSync(a,{recursive:!0})),c.mkdirSync(a,{recursive:!0}),t["mount-before-install"]=[...t["mount-before-install"]||[],{vfsPath:"/wordpress",hostPath:a}],t.wordpressInstallMode=c.readdirSync(a).length===0?"download-and-install":"install-from-existing-files-if-needed"}return t}const Z=new y.ProcessIdAllocator;function te(e,{onExit:t}={}){let r;return e==="v1"?r=new N.Worker(new URL("./worker-thread-v1.cjs",typeof document>"u"?require("url").pathToFileURL(__filename).href:$&&$.tagName.toUpperCase()==="SCRIPT"&&$.src||new URL("run-cli-BZUBWAe5.cjs",document.baseURI).href)):r=new N.Worker(new URL("./worker-thread-v2.cjs",typeof document>"u"?require("url").pathToFileURL(__filename).href:$&&$.tagName.toUpperCase()==="SCRIPT"&&$.src||new URL("run-cli-BZUBWAe5.cjs",document.baseURI).href)),new Promise((o,n)=>{const s=Z.claim();r.once("message",function(l){l.command==="worker-script-initialized"&&o({processId:s,worker:r,phpPort:l.phpPort})}),r.once("error",function(l){Z.release(s),console.error(l);const u=new Error(`Worker failed to load worker. ${l.message?`Original error: ${l.message}`:""}`);n(u)});let a=!1;r.once("spawn",()=>{a=!0}),r.once("exit",l=>{Z.release(s),a||n(new Error(`Worker exited before spawning: ${l}`)),t?.(l)})})}async function at(e){const{port1:t,port2:r}=new N.MessageChannel;return await y.exposeSyncAPI(e,t),r}function lt(e){const t=K.platform();let r;switch(t){case"darwin":r=`open "${e}"`;break;case"win32":r=`start "" "${e}"`;break;default:r=`xdg-open "${e}"`;break}pe.exec(r,o=>{o&&m.logger.debug(`Could not open browser: ${o.message}`)})}async function ut(e,t){await e.run({code:`<?php
|
|
49
49
|
$zip = new ZipArchive();
|
|
50
50
|
if(false === $zip->open('/tmp/build.zip', ZipArchive::CREATE | ZipArchive::OVERWRITE)) {
|
|
51
51
|
throw new Exception('Failed to create ZIP');
|
|
@@ -62,5 +62,5 @@ Examples:
|
|
|
62
62
|
}
|
|
63
63
|
$zip->close();
|
|
64
64
|
|
|
65
|
-
`});const r=await e.readFileAsBuffer("/tmp/build.zip");c.writeFileSync(t,r)}exports.LogVerbosity=
|
|
66
|
-
//# sourceMappingURL=run-cli-
|
|
65
|
+
`});const r=await e.readFileAsBuffer("/tmp/build.zip");c.writeFileSync(t,r)}const dt=Object.freeze(Object.defineProperty({__proto__:null,LogVerbosity:O,internalsKeyForTesting:q,mergeDefinedConstants:F,parseOptionsAndRunCLI:ye,runCLI:ee,spawnWorkerThread:te},Symbol.toStringTag,{value:"Module"}));exports.LogVerbosity=O;exports.internalsKeyForTesting=q;exports.mergeDefinedConstants=F;exports.mountResources=Re;exports.parseOptionsAndRunCLI=ye;exports.runCLI=ee;exports.runCli=dt;exports.shouldRenderProgress=we;exports.spawnWorkerThread=te;
|
|
66
|
+
//# sourceMappingURL=run-cli-BZUBWAe5.cjs.map
|