@wp-playground/cli 2.0.3 → 2.0.4
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/package.json +13 -11
- package/{run-cli-JA8jNok0.js → run-cli-B0BNDNay.js} +96 -89
- package/run-cli-B0BNDNay.js.map +1 -0
- package/run-cli-BSpDmClB.cjs +27 -0
- package/run-cli-BSpDmClB.cjs.map +1 -0
- package/run-cli.d.ts +1 -0
- package/run-cli-BaODvNPu.cjs +0 -27
- package/run-cli-BaODvNPu.cjs.map +0 -1
- package/run-cli-JA8jNok0.js.map +0 -1
package/cli.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";const n=require("./run-cli-
|
|
1
|
+
"use strict";const n=require("./run-cli-BSpDmClB.cjs");n.parseOptionsAndRunCLI();
|
|
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 n=require("./run-cli-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("./run-cli-BSpDmClB.cjs");exports.parseOptionsAndRunCLI=n.parseOptionsAndRunCLI;exports.runCLI=n.runCLI;
|
|
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": "2.0.
|
|
3
|
+
"version": "2.0.4",
|
|
4
4
|
"description": "WordPress Playground CLI",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"module": "./index.js",
|
|
33
33
|
"types": "index.d.ts",
|
|
34
34
|
"bin": "wp-playground.js",
|
|
35
|
-
"gitHead": "
|
|
35
|
+
"gitHead": "8fc1b0f5379a854c9df792c14da17a2ba697e562",
|
|
36
36
|
"dependencies": {
|
|
37
37
|
"@zip.js/zip.js": "2.7.57",
|
|
38
38
|
"ajv": "8.12.0",
|
|
@@ -53,16 +53,18 @@
|
|
|
53
53
|
"simple-get": "4.0.1",
|
|
54
54
|
"wasm-feature-detect": "1.8.0",
|
|
55
55
|
"ws": "8.18.1",
|
|
56
|
+
"xml2js": "0.6.2",
|
|
56
57
|
"yargs": "17.7.2",
|
|
57
|
-
"@php-wasm/logger": "2.0.
|
|
58
|
-
"@php-wasm/progress": "2.0.
|
|
59
|
-
"@php-wasm/universal": "2.0.
|
|
60
|
-
"@wp-playground/blueprints": "2.0.
|
|
61
|
-
"@wp-playground/common": "2.0.
|
|
62
|
-
"@wp-playground/wordpress": "2.0.
|
|
63
|
-
"@php-wasm/node": "2.0.
|
|
64
|
-
"@php-wasm/util": "2.0.
|
|
65
|
-
"@wp-playground/storage": "2.0.
|
|
58
|
+
"@php-wasm/logger": "2.0.4",
|
|
59
|
+
"@php-wasm/progress": "2.0.4",
|
|
60
|
+
"@php-wasm/universal": "2.0.4",
|
|
61
|
+
"@wp-playground/blueprints": "2.0.4",
|
|
62
|
+
"@wp-playground/common": "2.0.4",
|
|
63
|
+
"@wp-playground/wordpress": "2.0.4",
|
|
64
|
+
"@php-wasm/node": "2.0.4",
|
|
65
|
+
"@php-wasm/util": "2.0.4",
|
|
66
|
+
"@wp-playground/storage": "2.0.4",
|
|
67
|
+
"@php-wasm/xdebug-bridge": "2.0.4"
|
|
66
68
|
},
|
|
67
69
|
"overrides": {
|
|
68
70
|
"rollup": "^4.34.6",
|
|
@@ -1,21 +1,22 @@
|
|
|
1
|
-
import { logger as p, errorLogPath as
|
|
2
|
-
import { consumeAPI as L, SupportedPHPVersions as T, printDebugDetails as V, PHPResponse as
|
|
1
|
+
import { logger as p, errorLogPath as I } from "@php-wasm/logger";
|
|
2
|
+
import { consumeAPI as L, SupportedPHPVersions as T, printDebugDetails as V, PHPResponse as B, exposeAPI as q, exposeSyncAPI as j } from "@php-wasm/universal";
|
|
3
3
|
import { resolveRemoteBlueprint as D, isBlueprintBundle as O, compileBlueprint as Z, runBlueprintSteps as _ } from "@wp-playground/blueprints";
|
|
4
4
|
import { zipDirectory as M, RecommendedPHPVersion as $, unzipFile as N } from "@wp-playground/common";
|
|
5
5
|
import w from "fs";
|
|
6
6
|
import { Worker as J, MessageChannel as Y } from "worker_threads";
|
|
7
|
-
import { p as
|
|
7
|
+
import { p as R, a as Q, e as X } from "./mounts-B-Qdcyyt.js";
|
|
8
8
|
import G from "express";
|
|
9
9
|
import { FileLockManagerForNode as K } from "@php-wasm/node";
|
|
10
10
|
import ee, { cpus as te } from "os";
|
|
11
11
|
import { jspi as re } from "wasm-feature-detect";
|
|
12
12
|
import oe from "yargs";
|
|
13
|
-
import
|
|
13
|
+
import b, { basename as se } from "path";
|
|
14
14
|
import { NodeJsFilesystem as ie, OverlayFilesystem as ne, InMemoryFilesystem as ae, ZipFilesystem as le } from "@wp-playground/storage";
|
|
15
15
|
import { EmscriptenDownloadMonitor as pe, ProgressTracker as de } from "@php-wasm/progress";
|
|
16
16
|
import { resolveWordPressRelease as ce } from "@wp-playground/wordpress";
|
|
17
|
-
import
|
|
18
|
-
|
|
17
|
+
import k from "fs-extra";
|
|
18
|
+
import { startBridge as ue } from "@php-wasm/xdebug-bridge";
|
|
19
|
+
async function he(t) {
|
|
19
20
|
const r = G(), e = await new Promise((i, n) => {
|
|
20
21
|
const l = r.listen(t.port, () => {
|
|
21
22
|
const a = l.address();
|
|
@@ -25,9 +26,9 @@ async function ue(t) {
|
|
|
25
26
|
r.use("/", async (i, n) => {
|
|
26
27
|
const l = await t.handleRequest({
|
|
27
28
|
url: i.url,
|
|
28
|
-
headers:
|
|
29
|
+
headers: me(i),
|
|
29
30
|
method: i.method,
|
|
30
|
-
body: await
|
|
31
|
+
body: await fe(i)
|
|
31
32
|
});
|
|
32
33
|
n.statusCode = l.httpStatusCode;
|
|
33
34
|
for (const a in l.headers)
|
|
@@ -37,21 +38,21 @@ async function ue(t) {
|
|
|
37
38
|
const s = e.address().port;
|
|
38
39
|
return await t.onBind(e, s);
|
|
39
40
|
}
|
|
40
|
-
const
|
|
41
|
+
const fe = async (t) => await new Promise((r) => {
|
|
41
42
|
const e = [];
|
|
42
43
|
t.on("data", (o) => {
|
|
43
44
|
e.push(o);
|
|
44
45
|
}), t.on("end", () => {
|
|
45
46
|
r(new Uint8Array(Buffer.concat(e)));
|
|
46
47
|
});
|
|
47
|
-
}),
|
|
48
|
+
}), me = (t) => {
|
|
48
49
|
const r = {};
|
|
49
50
|
if (t.rawHeaders && t.rawHeaders.length)
|
|
50
51
|
for (let e = 0; e < t.rawHeaders.length; e += 2)
|
|
51
52
|
r[t.rawHeaders[e].toLowerCase()] = t.rawHeaders[e + 1];
|
|
52
53
|
return r;
|
|
53
54
|
};
|
|
54
|
-
class
|
|
55
|
+
class we {
|
|
55
56
|
constructor(r) {
|
|
56
57
|
this.workerLoads = [], this.addWorker(r);
|
|
57
58
|
}
|
|
@@ -73,10 +74,10 @@ class me {
|
|
|
73
74
|
});
|
|
74
75
|
}
|
|
75
76
|
}
|
|
76
|
-
function
|
|
77
|
+
function ge(t) {
|
|
77
78
|
return /^latest$|^trunk$|^nightly$|^(?:(\d+)\.(\d+)(?:\.(\d+))?)((?:-beta(?:\d+)?)|(?:-RC(?:\d+)?))?$/.test(t);
|
|
78
79
|
}
|
|
79
|
-
async function
|
|
80
|
+
async function ye({
|
|
80
81
|
sourceString: t,
|
|
81
82
|
blueprintMayReadAdjacentFiles: r
|
|
82
83
|
}) {
|
|
@@ -84,15 +85,15 @@ async function ge({
|
|
|
84
85
|
return;
|
|
85
86
|
if (t.startsWith("http://") || t.startsWith("https://"))
|
|
86
87
|
return await D(t);
|
|
87
|
-
let e =
|
|
88
|
+
let e = b.resolve(process.cwd(), t);
|
|
88
89
|
if (!w.existsSync(e))
|
|
89
90
|
throw new Error(`Blueprint file does not exist: ${e}`);
|
|
90
91
|
const o = w.statSync(e);
|
|
91
|
-
if (o.isDirectory() && (e =
|
|
92
|
+
if (o.isDirectory() && (e = b.join(e, "blueprint.json")), !o.isFile() && o.isSymbolicLink())
|
|
92
93
|
throw new Error(
|
|
93
94
|
`Blueprint path is neither a file nor a directory: ${e}`
|
|
94
95
|
);
|
|
95
|
-
const s =
|
|
96
|
+
const s = b.extname(e);
|
|
96
97
|
switch (s) {
|
|
97
98
|
case ".zip":
|
|
98
99
|
return le.fromArrayBuffer(
|
|
@@ -107,7 +108,7 @@ async function ge({
|
|
|
107
108
|
`Blueprint file at ${e} is not a valid JSON file`
|
|
108
109
|
);
|
|
109
110
|
}
|
|
110
|
-
const n =
|
|
111
|
+
const n = b.dirname(e), l = new ie(n);
|
|
111
112
|
return new ne([
|
|
112
113
|
new ae({
|
|
113
114
|
"blueprint.json": i
|
|
@@ -135,13 +136,13 @@ You can allow this Blueprint to read files from the same parent directory by exp
|
|
|
135
136
|
);
|
|
136
137
|
}
|
|
137
138
|
}
|
|
138
|
-
const
|
|
139
|
-
class
|
|
139
|
+
const be = "" + new URL("worker-thread-v2-Pfv6UYF4.js", import.meta.url).href;
|
|
140
|
+
class Pe {
|
|
140
141
|
constructor(r, e) {
|
|
141
142
|
this.lastProgressMessage = "", this.args = r, this.siteUrl = e.siteUrl, this.processIdSpaceLength = e.processIdSpaceLength, this.phpVersion = r.php;
|
|
142
143
|
}
|
|
143
144
|
getWorkerUrl() {
|
|
144
|
-
return
|
|
145
|
+
return be;
|
|
145
146
|
}
|
|
146
147
|
async bootPrimaryWorker(r, e) {
|
|
147
148
|
const o = L(r);
|
|
@@ -181,8 +182,8 @@ class be {
|
|
|
181
182
|
`));
|
|
182
183
|
}
|
|
183
184
|
}
|
|
184
|
-
const
|
|
185
|
-
async function
|
|
185
|
+
const F = b.join(ee.homedir(), ".wordpress-playground");
|
|
186
|
+
async function ke(t) {
|
|
186
187
|
return await E(
|
|
187
188
|
"https://github.com/WordPress/sqlite-database-integration/archive/refs/heads/develop.zip",
|
|
188
189
|
"sqlite.zip",
|
|
@@ -190,11 +191,11 @@ async function Pe(t) {
|
|
|
190
191
|
);
|
|
191
192
|
}
|
|
192
193
|
async function E(t, r, e) {
|
|
193
|
-
const o =
|
|
194
|
-
return
|
|
194
|
+
const o = b.join(F, r);
|
|
195
|
+
return k.existsSync(o) || (k.ensureDirSync(F), await ve(t, o, e)), A(o);
|
|
195
196
|
}
|
|
196
|
-
async function
|
|
197
|
-
const s = (await e.monitorFetch(fetch(t))).body.getReader(), i = `${r}.partial`, n =
|
|
197
|
+
async function ve(t, r, e) {
|
|
198
|
+
const s = (await e.monitorFetch(fetch(t))).body.getReader(), i = `${r}.partial`, n = k.createWriteStream(i);
|
|
198
199
|
for (; ; ) {
|
|
199
200
|
const { done: l, value: a } = await s.read();
|
|
200
201
|
if (a && n.write(a), l)
|
|
@@ -202,22 +203,22 @@ async function ke(t, r, e) {
|
|
|
202
203
|
}
|
|
203
204
|
n.close(), n.closed || await new Promise((l, a) => {
|
|
204
205
|
n.on("finish", () => {
|
|
205
|
-
|
|
206
|
+
k.renameSync(i, r), l(null);
|
|
206
207
|
}), n.on("error", (c) => {
|
|
207
|
-
|
|
208
|
+
k.removeSync(i), a(c);
|
|
208
209
|
});
|
|
209
210
|
});
|
|
210
211
|
}
|
|
211
212
|
function A(t, r) {
|
|
212
|
-
return new File([
|
|
213
|
+
return new File([k.readFileSync(t)], se(t));
|
|
213
214
|
}
|
|
214
|
-
const
|
|
215
|
-
class
|
|
215
|
+
const We = "" + new URL("worker-thread-v1-BTJIbQLy.js", import.meta.url).href;
|
|
216
|
+
class xe {
|
|
216
217
|
constructor(r, e) {
|
|
217
218
|
this.lastProgressMessage = "", this.args = r, this.siteUrl = e.siteUrl, this.processIdSpaceLength = e.processIdSpaceLength;
|
|
218
219
|
}
|
|
219
220
|
getWorkerUrl() {
|
|
220
|
-
return
|
|
221
|
+
return We;
|
|
221
222
|
}
|
|
222
223
|
async bootPrimaryWorker(r, e) {
|
|
223
224
|
const o = await this.compileInputBlueprint(
|
|
@@ -227,24 +228,24 @@ class We {
|
|
|
227
228
|
let s;
|
|
228
229
|
const i = new pe();
|
|
229
230
|
if (!this.args.skipWordPressSetup) {
|
|
230
|
-
let
|
|
231
|
+
let v = !1;
|
|
231
232
|
i.addEventListener("progress", (h) => {
|
|
232
|
-
if (
|
|
233
|
+
if (v)
|
|
233
234
|
return;
|
|
234
|
-
const { loaded:
|
|
235
|
-
Math.min(100, 100 *
|
|
235
|
+
const { loaded: m, total: W } = h.detail, f = Math.floor(
|
|
236
|
+
Math.min(100, 100 * m / W)
|
|
236
237
|
);
|
|
237
|
-
|
|
238
|
+
v = f === 100, this.args.quiet || this.writeProgressUpdate(
|
|
238
239
|
process.stdout,
|
|
239
|
-
`Downloading WordPress ${
|
|
240
|
-
|
|
240
|
+
`Downloading WordPress ${f}%...`,
|
|
241
|
+
v
|
|
241
242
|
);
|
|
242
243
|
}), s = await ce(this.args.wp), p.log(
|
|
243
244
|
`Resolved WordPress release URL: ${s?.releaseUrl}`
|
|
244
245
|
);
|
|
245
246
|
}
|
|
246
|
-
const n = s &&
|
|
247
|
-
|
|
247
|
+
const n = s && b.join(
|
|
248
|
+
F,
|
|
248
249
|
`prebuilt-wp-content-for-wp-${s.version}.zip`
|
|
249
250
|
), l = s ? w.existsSync(n) ? A(n) : await E(
|
|
250
251
|
s.releaseUrl,
|
|
@@ -252,13 +253,13 @@ class We {
|
|
|
252
253
|
i
|
|
253
254
|
) : void 0;
|
|
254
255
|
p.log("Fetching SQLite integration plugin...");
|
|
255
|
-
const a = this.args.skipSqliteSetup ? void 0 : await
|
|
256
|
+
const a = this.args.skipSqliteSetup ? void 0 : await ke(i), c = this.args.followSymlinks === !0, d = this.args.experimentalTrace === !0, g = this.args["mount-before-install"] || [], P = this.args.mount || [], u = L(r);
|
|
256
257
|
return await u.isConnected(), p.log("Booting WordPress..."), await u.useFileLockManager(e), await u.bootAsPrimaryWorker({
|
|
257
258
|
phpVersion: this.phpVersion,
|
|
258
259
|
wpVersion: o.versions.wp,
|
|
259
260
|
absoluteUrl: this.siteUrl,
|
|
260
261
|
mountsBeforeWpInstall: g,
|
|
261
|
-
mountsAfterWpInstall:
|
|
262
|
+
mountsAfterWpInstall: P,
|
|
262
263
|
wordPressZip: l && await l.arrayBuffer(),
|
|
263
264
|
sqliteIntegrationPluginZip: await a.arrayBuffer(),
|
|
264
265
|
firstProcessId: 0,
|
|
@@ -336,7 +337,7 @@ class We {
|
|
|
336
337
|
`));
|
|
337
338
|
}
|
|
338
339
|
}
|
|
339
|
-
async function
|
|
340
|
+
async function _e() {
|
|
340
341
|
try {
|
|
341
342
|
const t = oe(process.argv.slice(2)).usage("Usage: wp-playground <command> [options]").positional("command", {
|
|
342
343
|
describe: "Command to run",
|
|
@@ -363,12 +364,12 @@ async function Oe() {
|
|
|
363
364
|
describe: "Mount a directory to the PHP runtime (can be used multiple times). Format: /host/path:/vfs/path",
|
|
364
365
|
type: "array",
|
|
365
366
|
string: !0,
|
|
366
|
-
coerce:
|
|
367
|
+
coerce: R
|
|
367
368
|
}).option("mount-before-install", {
|
|
368
369
|
describe: "Mount a directory to the PHP runtime before WordPress installation (can be used multiple times). Format: /host/path:/vfs/path",
|
|
369
370
|
type: "array",
|
|
370
371
|
string: !0,
|
|
371
|
-
coerce:
|
|
372
|
+
coerce: R
|
|
372
373
|
}).option("mount-dir", {
|
|
373
374
|
describe: 'Mount a directory to the PHP runtime (can be used multiple times). Format: "/host/path" "/vfs/path"',
|
|
374
375
|
type: "array",
|
|
@@ -431,6 +432,10 @@ Warning: Following symlinks will expose files outside mounted directories to Pla
|
|
|
431
432
|
describe: "Enable Xdebug.",
|
|
432
433
|
type: "boolean",
|
|
433
434
|
default: !1
|
|
435
|
+
}).option("experimental-devtools", {
|
|
436
|
+
describe: "Enable experimental browser development tools.",
|
|
437
|
+
type: "boolean",
|
|
438
|
+
default: !1
|
|
434
439
|
}).option("experimental-multi-worker", {
|
|
435
440
|
describe: "Enable experimental multi-worker support which requires JSPI and 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.",
|
|
436
441
|
type: "number",
|
|
@@ -442,7 +447,7 @@ Warning: Following symlinks will expose files outside mounted directories to Pla
|
|
|
442
447
|
// Remove the "hidden" flag once Blueprint V2 is fully supported
|
|
443
448
|
hidden: !0
|
|
444
449
|
}).showHelpOnFail(!1).strictOptions().check(async (s) => {
|
|
445
|
-
if (s.wp !== void 0 && !
|
|
450
|
+
if (s.wp !== void 0 && !ge(s.wp))
|
|
446
451
|
try {
|
|
447
452
|
new URL(s.wp);
|
|
448
453
|
} catch {
|
|
@@ -506,102 +511,104 @@ async function Se(t) {
|
|
|
506
511
|
);
|
|
507
512
|
}), i = new K(s);
|
|
508
513
|
let n = !1, l = !0;
|
|
509
|
-
return p.log("Starting a PHP server..."),
|
|
514
|
+
return p.log("Starting a PHP server..."), he({
|
|
510
515
|
port: t.port,
|
|
511
516
|
onBind: async (a, c) => {
|
|
512
|
-
const d = `http://127.0.0.1:${c}`, g = t.experimentalMultiWorker ?? 1,
|
|
517
|
+
const d = `http://127.0.0.1:${c}`, g = t.experimentalMultiWorker ?? 1, P = Math.floor(
|
|
513
518
|
Number.MAX_SAFE_INTEGER / g
|
|
514
519
|
);
|
|
515
520
|
let u;
|
|
516
|
-
t["experimental-blueprints-v2-runner"] ? u = new
|
|
521
|
+
t["experimental-blueprints-v2-runner"] ? u = new Pe(t, {
|
|
517
522
|
siteUrl: d,
|
|
518
|
-
processIdSpaceLength:
|
|
519
|
-
}) : (u = new
|
|
523
|
+
processIdSpaceLength: P
|
|
524
|
+
}) : (u = new xe(t, {
|
|
520
525
|
siteUrl: d,
|
|
521
|
-
processIdSpaceLength:
|
|
522
|
-
}), typeof t.blueprint == "string" && (t.blueprint = await
|
|
526
|
+
processIdSpaceLength: P
|
|
527
|
+
}), typeof t.blueprint == "string" && (t.blueprint = await ye({
|
|
523
528
|
sourceString: t.blueprint,
|
|
524
529
|
blueprintMayReadAdjacentFiles: t["blueprint-may-read-adjacent-files"] === !0
|
|
525
530
|
})));
|
|
526
|
-
const
|
|
531
|
+
const v = Le(
|
|
527
532
|
u.getWorkerUrl(),
|
|
528
533
|
g,
|
|
529
|
-
({ exitCode: h, isMain:
|
|
534
|
+
({ exitCode: h, isMain: m, workerIndex: W }) => {
|
|
530
535
|
h !== 0 && (p.error(
|
|
531
|
-
`Worker ${
|
|
536
|
+
`Worker ${W} exited with code ${h}
|
|
532
537
|
`
|
|
533
|
-
),
|
|
538
|
+
), m && t.exitOnPrimaryWorkerCrash && process.exit(1));
|
|
534
539
|
}
|
|
535
540
|
);
|
|
536
541
|
p.log(`Setting up WordPress ${t.wp}`);
|
|
537
542
|
try {
|
|
538
|
-
const [h, ...
|
|
543
|
+
const [h, ...m] = await v, W = await U(
|
|
539
544
|
i
|
|
540
545
|
);
|
|
541
546
|
if (e = await u.bootPrimaryWorker(
|
|
542
547
|
h.phpPort,
|
|
543
|
-
|
|
548
|
+
W
|
|
544
549
|
), o.push({
|
|
545
550
|
playground: e,
|
|
546
551
|
worker: h.worker
|
|
547
|
-
}), await e.isReady(), n = !0, p.log("Booted!"), r = new
|
|
548
|
-
const
|
|
552
|
+
}), await e.isReady(), n = !0, p.log("Booted!"), r = new we(e), !t["experimental-blueprints-v2-runner"]) {
|
|
553
|
+
const f = await u.compileInputBlueprint(
|
|
549
554
|
t["additional-blueprint-steps"] || []
|
|
550
555
|
);
|
|
551
|
-
|
|
556
|
+
f && (p.log("Running the Blueprint..."), await _(f, e), p.log("Finished running the blueprint"));
|
|
552
557
|
}
|
|
553
|
-
if (t.command === "build-snapshot" ? (await
|
|
558
|
+
if (t.command === "build-snapshot" ? (await Fe(e, t.outfile), p.log(`WordPress exported to ${t.outfile}`), process.exit(0)) : t.command === "run-blueprint" && (p.log("Blueprint executed"), process.exit(0)), t.experimentalMultiWorker && t.experimentalMultiWorker > 1) {
|
|
554
559
|
p.log("Preparing additional workers...");
|
|
555
|
-
const
|
|
560
|
+
const f = await M(
|
|
556
561
|
e,
|
|
557
562
|
"/internal"
|
|
558
|
-
),
|
|
563
|
+
), y = P;
|
|
559
564
|
await Promise.all(
|
|
560
|
-
|
|
561
|
-
const H =
|
|
562
|
-
worker:
|
|
565
|
+
m.map(async (S, C) => {
|
|
566
|
+
const H = y + C * P, z = await U(i), x = await u.bootSecondaryWorker({
|
|
567
|
+
worker: S,
|
|
563
568
|
fileLockManagerPort: z,
|
|
564
569
|
firstProcessId: H
|
|
565
570
|
});
|
|
566
571
|
o.push({
|
|
567
|
-
playground:
|
|
568
|
-
worker:
|
|
569
|
-
}), await
|
|
572
|
+
playground: x,
|
|
573
|
+
worker: S.worker
|
|
574
|
+
}), await x.writeFile(
|
|
570
575
|
"/tmp/internal.zip",
|
|
571
|
-
|
|
576
|
+
f
|
|
572
577
|
), await N(
|
|
573
|
-
|
|
578
|
+
x,
|
|
574
579
|
"/tmp/internal.zip",
|
|
575
580
|
"/internal"
|
|
576
|
-
), await
|
|
581
|
+
), await x.unlink(
|
|
577
582
|
"/tmp/internal.zip"
|
|
578
|
-
), r.addWorker(
|
|
583
|
+
), r.addWorker(x);
|
|
579
584
|
})
|
|
580
585
|
), p.log("Ready!");
|
|
581
586
|
}
|
|
582
|
-
return p.log(`WordPress is running on ${d}`), {
|
|
587
|
+
return p.log(`WordPress is running on ${d}`), t.experimentalDevtools && t.xdebug && (await ue({
|
|
588
|
+
getPHPFile: async (y) => await e.readFileAsText(y)
|
|
589
|
+
})).start(), {
|
|
583
590
|
playground: e,
|
|
584
591
|
server: a,
|
|
585
592
|
[Symbol.asyncDispose]: async function() {
|
|
586
593
|
await Promise.all(
|
|
587
594
|
o.map(
|
|
588
|
-
async ({ playground:
|
|
589
|
-
await
|
|
595
|
+
async ({ playground: y, worker: S }) => {
|
|
596
|
+
await y.dispose(), await S.terminate();
|
|
590
597
|
}
|
|
591
598
|
)
|
|
592
|
-
), await new Promise((
|
|
599
|
+
), await new Promise((y) => a.close(y));
|
|
593
600
|
}
|
|
594
601
|
};
|
|
595
602
|
} catch (h) {
|
|
596
603
|
if (!t.debug)
|
|
597
604
|
throw h;
|
|
598
|
-
let
|
|
599
|
-
throw await e.fileExists(
|
|
605
|
+
let m = "";
|
|
606
|
+
throw await e.fileExists(I) && (m = await e.readFileAsText(I)), new Error(m, { cause: h });
|
|
600
607
|
}
|
|
601
608
|
},
|
|
602
609
|
async handleRequest(a) {
|
|
603
610
|
if (!n)
|
|
604
|
-
return
|
|
611
|
+
return B.forHttpCode(
|
|
605
612
|
502,
|
|
606
613
|
"WordPress is not ready yet"
|
|
607
614
|
);
|
|
@@ -616,13 +623,13 @@ async function Se(t) {
|
|
|
616
623
|
"playground_auto_login_already_happened"
|
|
617
624
|
) && (c["Set-Cookie"] = [
|
|
618
625
|
"playground_auto_login_already_happened=1; Max-Age=0; Expires=Thu, 01 Jan 1970 00:00:00 GMT; Path=/"
|
|
619
|
-
]), new
|
|
626
|
+
]), new B(302, c, new Uint8Array());
|
|
620
627
|
}
|
|
621
628
|
return await r.handleRequest(a);
|
|
622
629
|
}
|
|
623
630
|
});
|
|
624
631
|
}
|
|
625
|
-
function
|
|
632
|
+
function Le(t, r, e) {
|
|
626
633
|
const o = new URL(t, import.meta.url), s = [];
|
|
627
634
|
for (let i = 0; i < r; i++) {
|
|
628
635
|
const n = new J(o), l = (a) => {
|
|
@@ -650,11 +657,11 @@ function xe(t, r, e) {
|
|
|
650
657
|
}
|
|
651
658
|
return Promise.all(s);
|
|
652
659
|
}
|
|
653
|
-
async function
|
|
660
|
+
async function U(t) {
|
|
654
661
|
const { port1: r, port2: e } = new Y();
|
|
655
662
|
return await re() ? q(t, null, r) : await j(t, r), e;
|
|
656
663
|
}
|
|
657
|
-
async function
|
|
664
|
+
async function Fe(t, r) {
|
|
658
665
|
await t.run({
|
|
659
666
|
code: `<?php
|
|
660
667
|
$zip = new ZipArchive();
|
|
@@ -679,7 +686,7 @@ async function Le(t, r) {
|
|
|
679
686
|
w.writeFileSync(r, e);
|
|
680
687
|
}
|
|
681
688
|
export {
|
|
682
|
-
|
|
689
|
+
_e as p,
|
|
683
690
|
Se as r
|
|
684
691
|
};
|
|
685
|
-
//# sourceMappingURL=run-cli-
|
|
692
|
+
//# sourceMappingURL=run-cli-B0BNDNay.js.map
|