@wp-playground/cli 3.1.10 → 3.1.12
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 +14 -15
- package/{run-cli-DEBbpuwb.js → run-cli-2YzKNrNz.js} +382 -353
- package/run-cli-2YzKNrNz.js.map +1 -0
- package/run-cli-C-eCY5Ux.cjs +66 -0
- package/run-cli-C-eCY5Ux.cjs.map +1 -0
- package/run-cli.d.ts +7 -2
- 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/run-cli-DEBbpuwb.js.map +0 -1
- package/run-cli-EWuKythm.cjs +0 -66
- package/run-cli-EWuKythm.cjs.map +0 -1
|
@@ -1,30 +1,29 @@
|
|
|
1
|
-
import { logger as
|
|
2
|
-
import { consumeAPI as
|
|
3
|
-
import { resolveRemoteBlueprint as Be, resolveRuntimeConfiguration as
|
|
4
|
-
import { zipDirectory as De, RecommendedPHPVersion as
|
|
5
|
-
import p, { existsSync as
|
|
6
|
-
import { MessageChannel as
|
|
7
|
-
import { createNodeFsMountHandler as
|
|
8
|
-
import d, { basename as D, join as
|
|
9
|
-
import { exec as
|
|
10
|
-
import { promisify as
|
|
1
|
+
import { logger as w, LogSeverity as O, errorLogPath as J } from "@php-wasm/logger";
|
|
2
|
+
import { consumeAPI as de, ProcessIdAllocator as Ee, SupportedPHPVersions as W, printDebugDetails as $e, HttpCookieStore as Te, FileLockManagerInMemory as Ie, StreamedPHPResponse as K, createObjectPoolProxy as ke, exposeAPI as Me, PHPResponse as Ce, exposeSyncAPI as Ae } from "@php-wasm/universal";
|
|
3
|
+
import { resolveRemoteBlueprint as Be, resolveRuntimeConfiguration as ee, compileBlueprintV1 as ce, isBlueprintBundle as Re, runBlueprintV1Steps as te } from "@wp-playground/blueprints";
|
|
4
|
+
import { zipDirectory as De, RecommendedPHPVersion as C } from "@wp-playground/common";
|
|
5
|
+
import p, { existsSync as z, rmdirSync as We, mkdirSync as Y, readdirSync as Le } from "fs";
|
|
6
|
+
import { MessageChannel as pe, Worker as re } from "worker_threads";
|
|
7
|
+
import { createNodeFsMountHandler as Ue } from "@php-wasm/node";
|
|
8
|
+
import d, { basename as D, join as me } from "path";
|
|
9
|
+
import { exec as he } from "child_process";
|
|
10
|
+
import { promisify as _e } from "util";
|
|
11
11
|
import fe from "express";
|
|
12
12
|
import { Readable as He } from "stream";
|
|
13
|
-
import { pipeline as
|
|
14
|
-
import
|
|
15
|
-
import { NodeJsFilesystem as
|
|
16
|
-
import { EmscriptenDownloadMonitor as
|
|
17
|
-
import { resolveWordPressRelease as
|
|
18
|
-
import
|
|
19
|
-
import { createRequire as
|
|
20
|
-
import
|
|
21
|
-
import { startBridge as
|
|
22
|
-
import { dir as
|
|
23
|
-
import
|
|
24
|
-
import { removeTempDirSymlink as Ke, createTempDirSymlink as re, makeXdebugConfig as et, clearXdebugIDEConfig as tt, addXdebugIDEConfig as rt } from "@php-wasm/cli-util";
|
|
13
|
+
import { pipeline as Ne } from "stream/promises";
|
|
14
|
+
import Oe from "yargs";
|
|
15
|
+
import { NodeJsFilesystem as Fe, OverlayFilesystem as je, InMemoryFilesystem as Ve, ZipFilesystem as Ye } from "@wp-playground/storage";
|
|
16
|
+
import { EmscriptenDownloadMonitor as qe, ProgressTracker as ze } from "@php-wasm/progress";
|
|
17
|
+
import { resolveWordPressRelease as Ge } from "@wp-playground/wordpress";
|
|
18
|
+
import $ from "fs-extra";
|
|
19
|
+
import { createRequire as Qe } from "module";
|
|
20
|
+
import G from "os";
|
|
21
|
+
import { startBridge as Xe } from "@php-wasm/xdebug-bridge";
|
|
22
|
+
import { dir as Ze, setGracefulCleanup as Je } from "tmp-promise";
|
|
23
|
+
import { removeTempDirSymlink as Ke, createTempDirSymlink as oe, makeXdebugConfig as et, clearXdebugIDEConfig as tt, addXdebugIDEConfig as rt } from "@php-wasm/cli-util";
|
|
25
24
|
import { createHash as ot } from "crypto";
|
|
26
|
-
import { PHPMYADMIN_INSTALL_PATH as
|
|
27
|
-
import { jspi as
|
|
25
|
+
import { PHPMYADMIN_INSTALL_PATH as se, getPhpMyAdminInstallSteps as st, PHPMYADMIN_ENTRY_PATH as it } from "@wp-playground/tools";
|
|
26
|
+
import { jspi as ie } from "wasm-feature-detect";
|
|
28
27
|
function F(e) {
|
|
29
28
|
const t = [];
|
|
30
29
|
for (const r of e) {
|
|
@@ -35,19 +34,19 @@ function F(e) {
|
|
|
35
34
|
If your path contains a colon, e.g. C:\\myplugin, use the --mount-dir option instead.
|
|
36
35
|
Example: --mount-dir C:\\my-plugin /wordpress/wp-content/plugins/my-plugin`);
|
|
37
36
|
const [s, i] = o;
|
|
38
|
-
if (!
|
|
37
|
+
if (!z(s))
|
|
39
38
|
throw new Error(`Host path does not exist: ${s}`);
|
|
40
39
|
t.push({ hostPath: s, vfsPath: i });
|
|
41
40
|
}
|
|
42
41
|
return t;
|
|
43
42
|
}
|
|
44
|
-
function
|
|
43
|
+
function ne(e) {
|
|
45
44
|
if (e.length % 2 !== 0)
|
|
46
45
|
throw new Error("Invalid mount format. Expected: /host/path /vfs/path");
|
|
47
46
|
const t = [];
|
|
48
47
|
for (let r = 0; r < e.length; r += 2) {
|
|
49
48
|
const o = e[r], s = e[r + 1];
|
|
50
|
-
if (!
|
|
49
|
+
if (!z(o))
|
|
51
50
|
throw new Error(`Host path does not exist: ${o}`);
|
|
52
51
|
t.push({
|
|
53
52
|
hostPath: d.resolve(process.cwd(), o),
|
|
@@ -56,14 +55,14 @@ function ie(e) {
|
|
|
56
55
|
}
|
|
57
56
|
return t;
|
|
58
57
|
}
|
|
59
|
-
async function
|
|
58
|
+
async function fr(e, t) {
|
|
60
59
|
for (const r of t)
|
|
61
60
|
await e.mount(
|
|
62
61
|
r.vfsPath,
|
|
63
|
-
|
|
62
|
+
Ue(r.hostPath)
|
|
64
63
|
);
|
|
65
64
|
}
|
|
66
|
-
const
|
|
65
|
+
const ae = {
|
|
67
66
|
step: "runPHP",
|
|
68
67
|
code: {
|
|
69
68
|
filename: "activate-theme.php",
|
|
@@ -82,7 +81,7 @@ const ne = {
|
|
|
82
81
|
`
|
|
83
82
|
}
|
|
84
83
|
};
|
|
85
|
-
function
|
|
84
|
+
function we(e) {
|
|
86
85
|
const t = e.autoMount, r = [...e.mount || []], o = [...e["mount-before-install"] || []], s = {
|
|
87
86
|
...e,
|
|
88
87
|
mount: r,
|
|
@@ -92,20 +91,20 @@ function he(e) {
|
|
|
92
91
|
]
|
|
93
92
|
};
|
|
94
93
|
if (ut(t)) {
|
|
95
|
-
const
|
|
94
|
+
const a = `/wordpress/wp-content/plugins/${D(t)}`;
|
|
96
95
|
r.push({
|
|
97
96
|
hostPath: t,
|
|
98
|
-
vfsPath:
|
|
97
|
+
vfsPath: a,
|
|
99
98
|
autoMounted: !0
|
|
100
99
|
}), s["additional-blueprint-steps"].push({
|
|
101
100
|
step: "activatePlugin",
|
|
102
101
|
pluginPath: `/wordpress/wp-content/plugins/${D(t)}`
|
|
103
102
|
});
|
|
104
103
|
} else if (lt(t)) {
|
|
105
|
-
const i = D(t),
|
|
104
|
+
const i = D(t), a = `/wordpress/wp-content/themes/${i}`;
|
|
106
105
|
r.push({
|
|
107
106
|
hostPath: t,
|
|
108
|
-
vfsPath:
|
|
107
|
+
vfsPath: a,
|
|
109
108
|
autoMounted: !0
|
|
110
109
|
}), s["additional-blueprint-steps"].push(
|
|
111
110
|
e["experimental-blueprints-v2-runner"] ? {
|
|
@@ -118,18 +117,18 @@ function he(e) {
|
|
|
118
117
|
);
|
|
119
118
|
} else if (at(t)) {
|
|
120
119
|
const i = p.readdirSync(t);
|
|
121
|
-
for (const
|
|
122
|
-
|
|
123
|
-
hostPath: `${t}/${
|
|
124
|
-
vfsPath: `/wordpress/wp-content/${
|
|
120
|
+
for (const a of i)
|
|
121
|
+
a !== "index.php" && r.push({
|
|
122
|
+
hostPath: `${t}/${a}`,
|
|
123
|
+
vfsPath: `/wordpress/wp-content/${a}`,
|
|
125
124
|
autoMounted: !0
|
|
126
125
|
});
|
|
127
|
-
s["additional-blueprint-steps"].push(
|
|
126
|
+
s["additional-blueprint-steps"].push(ae);
|
|
128
127
|
} else nt(t) && (o.push({
|
|
129
128
|
hostPath: t,
|
|
130
129
|
vfsPath: "/wordpress",
|
|
131
130
|
autoMounted: !0
|
|
132
|
-
}), s.mode = "apply-to-existing-site", s["additional-blueprint-steps"].push(
|
|
131
|
+
}), s.mode = "apply-to-existing-site", s["additional-blueprint-steps"].push(ae), s.wordpressInstallMode || (s.wordpressInstallMode = "install-from-existing-files-if-needed"));
|
|
133
132
|
return s;
|
|
134
133
|
}
|
|
135
134
|
function nt(e) {
|
|
@@ -143,13 +142,13 @@ function at(e) {
|
|
|
143
142
|
function lt(e) {
|
|
144
143
|
if (!p.readdirSync(e).includes("style.css"))
|
|
145
144
|
return !1;
|
|
146
|
-
const r = p.readFileSync(
|
|
145
|
+
const r = p.readFileSync(me(e, "style.css"), "utf8");
|
|
147
146
|
return !!/^(?:[ \t]*<\?php)?[ \t/*#@]*Theme Name:(.*)$/im.exec(r);
|
|
148
147
|
}
|
|
149
148
|
function ut(e) {
|
|
150
149
|
const t = p.readdirSync(e), r = /^(?:[ \t]*<\?php)?[ \t/*#@]*Plugin Name:(.*)$/im;
|
|
151
150
|
return !!t.filter((s) => s.endsWith(".php")).find((s) => {
|
|
152
|
-
const i = p.readFileSync(
|
|
151
|
+
const i = p.readFileSync(me(e, s), "utf8");
|
|
153
152
|
return !!r.exec(i);
|
|
154
153
|
});
|
|
155
154
|
}
|
|
@@ -208,26 +207,26 @@ function pt(e) {
|
|
|
208
207
|
return t;
|
|
209
208
|
}
|
|
210
209
|
function mt(e = {}, t = {}, r = {}) {
|
|
211
|
-
const o = {}, s = /* @__PURE__ */ new Set(), i = (
|
|
212
|
-
for (const u in
|
|
210
|
+
const o = {}, s = /* @__PURE__ */ new Set(), i = (a, l) => {
|
|
211
|
+
for (const u in a) {
|
|
213
212
|
if (s.has(u))
|
|
214
213
|
throw new Error(
|
|
215
214
|
`Constant "${u}" is defined multiple times across different --define-${l} flags`
|
|
216
215
|
);
|
|
217
|
-
s.add(u), o[u] =
|
|
216
|
+
s.add(u), o[u] = a[u];
|
|
218
217
|
}
|
|
219
218
|
};
|
|
220
219
|
return i(e, "string"), i(t, "bool"), i(r, "number"), o;
|
|
221
220
|
}
|
|
222
|
-
function
|
|
221
|
+
function ye(e) {
|
|
223
222
|
return mt(
|
|
224
223
|
e.define,
|
|
225
224
|
e["define-bool"],
|
|
226
225
|
e["define-number"]
|
|
227
226
|
);
|
|
228
227
|
}
|
|
229
|
-
const
|
|
230
|
-
function
|
|
228
|
+
const ht = _e(he);
|
|
229
|
+
function ft(e) {
|
|
231
230
|
return new Promise((t) => {
|
|
232
231
|
if (e === 0) return t(!1);
|
|
233
232
|
const r = fe().listen(e);
|
|
@@ -238,23 +237,23 @@ function ht(e) {
|
|
|
238
237
|
});
|
|
239
238
|
}
|
|
240
239
|
async function wt(e) {
|
|
241
|
-
const t = fe(), r = await new Promise((
|
|
240
|
+
const t = fe(), r = await new Promise((a, l) => {
|
|
242
241
|
const u = t.listen(e.port, () => {
|
|
243
|
-
const
|
|
244
|
-
|
|
242
|
+
const y = u.address();
|
|
243
|
+
y === null || typeof y == "string" ? l(new Error("Server address is not available")) : a(u);
|
|
245
244
|
}).once("error", l);
|
|
246
245
|
});
|
|
247
|
-
t.use("/", async (
|
|
246
|
+
t.use("/", async (a, l) => {
|
|
248
247
|
try {
|
|
249
248
|
const u = {
|
|
250
|
-
url:
|
|
251
|
-
headers: Pt(
|
|
252
|
-
method:
|
|
253
|
-
body: await bt(
|
|
254
|
-
},
|
|
255
|
-
await yt(
|
|
249
|
+
url: a.url,
|
|
250
|
+
headers: Pt(a),
|
|
251
|
+
method: a.method,
|
|
252
|
+
body: await bt(a)
|
|
253
|
+
}, y = await e.handleRequest(u);
|
|
254
|
+
await yt(y, l);
|
|
256
255
|
} catch (u) {
|
|
257
|
-
|
|
256
|
+
w.error(u), l.headersSent || (l.statusCode = 500, l.end("Internal Server Error"));
|
|
258
257
|
}
|
|
259
258
|
});
|
|
260
259
|
const s = r.address().port, i = process.env.CODESPACE_NAME;
|
|
@@ -270,9 +269,9 @@ async function yt(e, t) {
|
|
|
270
269
|
t.setHeader(i, r[i]);
|
|
271
270
|
const s = He.fromWeb(e.stdout);
|
|
272
271
|
try {
|
|
273
|
-
await
|
|
272
|
+
await Ne(s, t);
|
|
274
273
|
} catch (i) {
|
|
275
|
-
if (i instanceof Error && "code" in i && i.code === "ERR_STREAM_PREMATURE_CLOSE")
|
|
274
|
+
if (i instanceof Error && "code" in i && (i.code === "ERR_STREAM_PREMATURE_CLOSE" || i.code === "ERR_STREAM_UNABLE_TO_PIPE"))
|
|
276
275
|
return;
|
|
277
276
|
throw i;
|
|
278
277
|
}
|
|
@@ -286,11 +285,11 @@ const bt = async (e) => await new Promise((t) => {
|
|
|
286
285
|
});
|
|
287
286
|
});
|
|
288
287
|
async function gt(e, t) {
|
|
289
|
-
|
|
288
|
+
w.log(`Publishing port ${e}...`);
|
|
290
289
|
const r = `gh codespace ports visibility ${e}:public -c ${t}`;
|
|
291
290
|
for (let o = 0; o < 10; o++)
|
|
292
291
|
try {
|
|
293
|
-
await
|
|
292
|
+
await ht(r);
|
|
294
293
|
return;
|
|
295
294
|
} catch {
|
|
296
295
|
await new Promise((s) => setTimeout(s, 2e3));
|
|
@@ -325,7 +324,7 @@ async function St({
|
|
|
325
324
|
const s = d.extname(r);
|
|
326
325
|
switch (s) {
|
|
327
326
|
case ".zip":
|
|
328
|
-
return
|
|
327
|
+
return Ye.fromArrayBuffer(
|
|
329
328
|
p.readFileSync(r).buffer
|
|
330
329
|
);
|
|
331
330
|
case ".json": {
|
|
@@ -337,9 +336,9 @@ async function St({
|
|
|
337
336
|
`Blueprint file at ${r} is not a valid JSON file`
|
|
338
337
|
);
|
|
339
338
|
}
|
|
340
|
-
const
|
|
341
|
-
return new
|
|
342
|
-
new
|
|
339
|
+
const a = d.dirname(r), l = new Fe(a);
|
|
340
|
+
return new je([
|
|
341
|
+
new Ve({
|
|
343
342
|
"blueprint.json": i
|
|
344
343
|
}),
|
|
345
344
|
/**
|
|
@@ -386,7 +385,7 @@ class xt {
|
|
|
386
385
|
fileLockManagerPort: r,
|
|
387
386
|
nativeInternalDirPath: o
|
|
388
387
|
}) {
|
|
389
|
-
const s =
|
|
388
|
+
const s = de(t.phpPort);
|
|
390
389
|
await s.useFileLockManager(r);
|
|
391
390
|
const i = {
|
|
392
391
|
...this.args,
|
|
@@ -401,17 +400,17 @@ class xt {
|
|
|
401
400
|
nativeInternalDirPath: o,
|
|
402
401
|
mountsBeforeWpInstall: this.args["mount-before-install"] || [],
|
|
403
402
|
mountsAfterWpInstall: this.args.mount || [],
|
|
404
|
-
constants:
|
|
403
|
+
constants: ye(this.args)
|
|
405
404
|
};
|
|
406
405
|
return await s.bootWorker(i), s;
|
|
407
406
|
}
|
|
408
407
|
}
|
|
409
|
-
const
|
|
408
|
+
const q = d.join(G.homedir(), ".wordpress-playground");
|
|
410
409
|
async function Et() {
|
|
411
410
|
const e = typeof __dirname < "u" ? __dirname : import.meta.dirname;
|
|
412
411
|
let t = d.join(e, "sqlite-database-integration.zip");
|
|
413
|
-
if (
|
|
414
|
-
const r =
|
|
412
|
+
if (!$.existsSync(t)) {
|
|
413
|
+
const r = Qe(import.meta.url), o = d.dirname(
|
|
415
414
|
r.resolve("@wp-playground/wordpress-builds/package.json")
|
|
416
415
|
);
|
|
417
416
|
t = d.join(
|
|
@@ -421,29 +420,29 @@ async function Et() {
|
|
|
421
420
|
"sqlite-database-integration-trunk.zip"
|
|
422
421
|
);
|
|
423
422
|
}
|
|
424
|
-
return new File([await
|
|
423
|
+
return new File([await $.readFile(t)], d.basename(t));
|
|
425
424
|
}
|
|
426
425
|
async function $t(e, t, r) {
|
|
427
|
-
const o = d.join(
|
|
428
|
-
return
|
|
426
|
+
const o = d.join(q, t);
|
|
427
|
+
return $.existsSync(o) || ($.ensureDirSync(q), await Tt(e, o, r)), be(o);
|
|
429
428
|
}
|
|
430
429
|
async function Tt(e, t, r) {
|
|
431
|
-
const s = (await r.monitorFetch(fetch(e))).body.getReader(), i = `${t}.partial`,
|
|
430
|
+
const s = (await r.monitorFetch(fetch(e))).body.getReader(), i = `${t}.partial`, a = $.createWriteStream(i);
|
|
432
431
|
for (; ; ) {
|
|
433
432
|
const { done: l, value: u } = await s.read();
|
|
434
|
-
if (u &&
|
|
433
|
+
if (u && a.write(u), l)
|
|
435
434
|
break;
|
|
436
435
|
}
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
}),
|
|
441
|
-
|
|
436
|
+
a.close(), a.closed || await new Promise((l, u) => {
|
|
437
|
+
a.on("finish", () => {
|
|
438
|
+
$.renameSync(i, t), l(null);
|
|
439
|
+
}), a.on("error", (y) => {
|
|
440
|
+
$.removeSync(i), u(y);
|
|
442
441
|
});
|
|
443
442
|
});
|
|
444
443
|
}
|
|
445
|
-
function
|
|
446
|
-
return new File([
|
|
444
|
+
function be(e, t) {
|
|
445
|
+
return new File([$.readFileSync(e)], D(e));
|
|
447
446
|
}
|
|
448
447
|
class It {
|
|
449
448
|
constructor(t, r) {
|
|
@@ -454,33 +453,33 @@ class It {
|
|
|
454
453
|
}
|
|
455
454
|
async bootWordPress(t, r) {
|
|
456
455
|
let o, s, i;
|
|
457
|
-
const
|
|
456
|
+
const a = new qe();
|
|
458
457
|
if (this.args.wordpressInstallMode === "download-and-install") {
|
|
459
|
-
let
|
|
460
|
-
|
|
461
|
-
if (
|
|
458
|
+
let y = !1;
|
|
459
|
+
a.addEventListener("progress", (E) => {
|
|
460
|
+
if (y)
|
|
462
461
|
return;
|
|
463
|
-
const { loaded: c, total:
|
|
464
|
-
Math.min(100, 100 * c /
|
|
462
|
+
const { loaded: c, total: n } = E.detail, m = Math.floor(
|
|
463
|
+
Math.min(100, 100 * c / n)
|
|
465
464
|
);
|
|
466
|
-
|
|
465
|
+
y = m === 100, this.cliOutput.updateProgress(
|
|
467
466
|
"Downloading WordPress",
|
|
468
467
|
m
|
|
469
468
|
);
|
|
470
|
-
}), o = await
|
|
471
|
-
|
|
469
|
+
}), o = await Ge(this.args.wp), i = d.join(
|
|
470
|
+
q,
|
|
472
471
|
`prebuilt-wp-content-for-wp-${o.version}.zip`
|
|
473
|
-
), s = p.existsSync(i) ?
|
|
472
|
+
), s = p.existsSync(i) ? be(i) : await $t(
|
|
474
473
|
o.releaseUrl,
|
|
475
474
|
`${o.version}.zip`,
|
|
476
|
-
|
|
477
|
-
),
|
|
475
|
+
a
|
|
476
|
+
), w.debug(
|
|
478
477
|
`Resolved WordPress release URL: ${o?.releaseUrl}`
|
|
479
478
|
);
|
|
480
479
|
}
|
|
481
480
|
let l;
|
|
482
|
-
this.args.skipSqliteSetup ? (
|
|
483
|
-
const u = await
|
|
481
|
+
this.args.skipSqliteSetup ? (w.debug("Skipping SQLite integration plugin setup..."), l = void 0) : (this.cliOutput.updateProgress("Preparing SQLite database"), l = await Et()), this.cliOutput.updateProgress("Booting WordPress");
|
|
482
|
+
const u = await ee(
|
|
484
483
|
this.getEffectiveBlueprint()
|
|
485
484
|
);
|
|
486
485
|
return await t.bootWordPress(
|
|
@@ -490,7 +489,7 @@ class It {
|
|
|
490
489
|
wordpressInstallMode: this.args.wordpressInstallMode || "download-and-install",
|
|
491
490
|
wordPressZip: s && await s.arrayBuffer(),
|
|
492
491
|
sqliteIntegrationPluginZip: await l?.arrayBuffer(),
|
|
493
|
-
constants:
|
|
492
|
+
constants: ye(this.args)
|
|
494
493
|
},
|
|
495
494
|
r
|
|
496
495
|
), i && !this.args["mount-before-install"] && !p.existsSync(i) && (this.cliOutput.updateProgress("Caching WordPress for next boot"), p.writeFileSync(
|
|
@@ -508,11 +507,11 @@ class It {
|
|
|
508
507
|
fileLockManagerPort: r,
|
|
509
508
|
nativeInternalDirPath: o
|
|
510
509
|
}) {
|
|
511
|
-
const s =
|
|
510
|
+
const s = de(
|
|
512
511
|
t.phpPort
|
|
513
512
|
);
|
|
514
513
|
await s.isConnected();
|
|
515
|
-
const i = await
|
|
514
|
+
const i = await ee(
|
|
516
515
|
this.getEffectiveBlueprint()
|
|
517
516
|
);
|
|
518
517
|
return await s.useFileLockManager(r), await s.bootRequestHandler({
|
|
@@ -532,26 +531,26 @@ class It {
|
|
|
532
531
|
}), await s.isReady(), s;
|
|
533
532
|
}
|
|
534
533
|
async compileInputBlueprint(t) {
|
|
535
|
-
const r = this.getEffectiveBlueprint(), o = new
|
|
534
|
+
const r = this.getEffectiveBlueprint(), o = new ze();
|
|
536
535
|
let s = "", i = !1;
|
|
537
|
-
return o.addEventListener("progress", (
|
|
536
|
+
return o.addEventListener("progress", (a) => {
|
|
538
537
|
if (i)
|
|
539
538
|
return;
|
|
540
|
-
i =
|
|
541
|
-
const l = Math.floor(
|
|
542
|
-
s =
|
|
543
|
-
}), await
|
|
539
|
+
i = a.detail.progress === 100;
|
|
540
|
+
const l = Math.floor(a.detail.progress);
|
|
541
|
+
s = a.detail.caption || s || "Running Blueprint", this.cliOutput.updateProgress(s.trim(), l);
|
|
542
|
+
}), await ce(r, {
|
|
544
543
|
progress: o,
|
|
545
544
|
additionalSteps: t
|
|
546
545
|
});
|
|
547
546
|
}
|
|
548
547
|
getEffectiveBlueprint() {
|
|
549
548
|
const t = this.args.blueprint;
|
|
550
|
-
return
|
|
549
|
+
return Re(t) ? t : {
|
|
551
550
|
login: this.args.login,
|
|
552
551
|
...t || {},
|
|
553
552
|
preferredVersions: {
|
|
554
|
-
php: this.args.php ?? t?.preferredVersions?.php ??
|
|
553
|
+
php: this.args.php ?? t?.preferredVersions?.php ?? C,
|
|
555
554
|
wp: this.args.wp ?? t?.preferredVersions?.wp ?? "latest",
|
|
556
555
|
...t?.preferredVersions || {}
|
|
557
556
|
}
|
|
@@ -559,7 +558,7 @@ class It {
|
|
|
559
558
|
}
|
|
560
559
|
}
|
|
561
560
|
async function kt(e, t = !0) {
|
|
562
|
-
const o = `${d.basename(process.argv0)}${e}${process.pid}-`, s = await
|
|
561
|
+
const o = `${d.basename(process.argv0)}${e}${process.pid}-`, s = await Ze({
|
|
563
562
|
prefix: o,
|
|
564
563
|
/*
|
|
565
564
|
* Allow recursive cleanup on process exit.
|
|
@@ -571,42 +570,42 @@ async function kt(e, t = !0) {
|
|
|
571
570
|
*/
|
|
572
571
|
unsafeCleanup: !0
|
|
573
572
|
});
|
|
574
|
-
return t &&
|
|
573
|
+
return t && Je(), s;
|
|
575
574
|
}
|
|
576
575
|
async function Mt(e, t, r) {
|
|
577
|
-
const s = (await
|
|
576
|
+
const s = (await Ct(
|
|
578
577
|
e,
|
|
579
578
|
t,
|
|
580
579
|
r
|
|
581
580
|
)).map(
|
|
582
|
-
(i) => new Promise((
|
|
581
|
+
(i) => new Promise((a) => {
|
|
583
582
|
p.rm(i, { recursive: !0 }, (l) => {
|
|
584
|
-
l ?
|
|
583
|
+
l ? w.warn(
|
|
585
584
|
`Failed to delete stale Playground temp dir: ${i}`,
|
|
586
585
|
l
|
|
587
|
-
) :
|
|
586
|
+
) : w.info(
|
|
588
587
|
`Deleted stale Playground temp dir: ${i}`
|
|
589
|
-
),
|
|
588
|
+
), a();
|
|
590
589
|
});
|
|
591
590
|
})
|
|
592
591
|
);
|
|
593
592
|
await Promise.all(s);
|
|
594
593
|
}
|
|
595
|
-
async function
|
|
594
|
+
async function Ct(e, t, r) {
|
|
596
595
|
try {
|
|
597
596
|
const o = p.readdirSync(r).map((i) => d.join(r, i)), s = [];
|
|
598
597
|
for (const i of o)
|
|
599
|
-
await
|
|
598
|
+
await At(
|
|
600
599
|
e,
|
|
601
600
|
t,
|
|
602
601
|
i
|
|
603
602
|
) && s.push(i);
|
|
604
603
|
return s;
|
|
605
604
|
} catch (o) {
|
|
606
|
-
return
|
|
605
|
+
return w.warn(`Failed to find stale Playground temp dirs: ${o}`), [];
|
|
607
606
|
}
|
|
608
607
|
}
|
|
609
|
-
async function
|
|
608
|
+
async function At(e, t, r) {
|
|
610
609
|
if (!p.lstatSync(r).isDirectory())
|
|
611
610
|
return !1;
|
|
612
611
|
const s = d.basename(r);
|
|
@@ -617,37 +616,33 @@ async function Bt(e, t, r) {
|
|
|
617
616
|
);
|
|
618
617
|
if (!i)
|
|
619
618
|
return !1;
|
|
620
|
-
const
|
|
619
|
+
const a = {
|
|
621
620
|
executableName: i[1],
|
|
622
621
|
pid: i[2]
|
|
623
622
|
};
|
|
624
|
-
if (
|
|
623
|
+
if (Bt(a.pid))
|
|
625
624
|
return !1;
|
|
626
625
|
const l = Date.now() - t;
|
|
627
626
|
return p.statSync(r).mtime.getTime() < l;
|
|
628
627
|
}
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
(
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
);
|
|
643
|
-
}
|
|
644
|
-
);
|
|
645
|
-
return !!r && r.pid === e && r.command === t;
|
|
628
|
+
function Bt(e, t) {
|
|
629
|
+
try {
|
|
630
|
+
return process.kill(Number(e), 0), !0;
|
|
631
|
+
} catch (r) {
|
|
632
|
+
const o = r, s = o && typeof o.code == "string" ? o.code : void 0;
|
|
633
|
+
return s === "ESRCH" ? !1 : s === "EPERM" || s === "EACCES" ? (w.debug(
|
|
634
|
+
`Permission denied while checking if process ${e} exists (code: ${s}).`,
|
|
635
|
+
r
|
|
636
|
+
), !0) : (w.warn(
|
|
637
|
+
`Could not determine if process ${e} exists due to unexpected error${s ? ` (code: ${s})` : ""}.`,
|
|
638
|
+
r
|
|
639
|
+
), !0);
|
|
640
|
+
}
|
|
646
641
|
}
|
|
647
|
-
function
|
|
642
|
+
function Rt(e) {
|
|
648
643
|
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;
|
|
649
644
|
}
|
|
650
|
-
class
|
|
645
|
+
class Dt {
|
|
651
646
|
constructor(t) {
|
|
652
647
|
this.lastProgressLine = "", this.progressActive = !1, this.verbosity = t.verbosity, this.writeStream = t.writeStream || process.stdout;
|
|
653
648
|
}
|
|
@@ -661,7 +656,7 @@ class Rt {
|
|
|
661
656
|
* This prevents progress spam in logs - users only see the final outcome.
|
|
662
657
|
*/
|
|
663
658
|
get shouldRender() {
|
|
664
|
-
return
|
|
659
|
+
return Rt(this.writeStream);
|
|
665
660
|
}
|
|
666
661
|
get isQuiet() {
|
|
667
662
|
return this.verbosity === "quiet";
|
|
@@ -810,12 +805,12 @@ ${this.green("Ready!")} WordPress is running on ${this.bold(t)} ${this.dim(`(${r
|
|
|
810
805
|
);
|
|
811
806
|
}
|
|
812
807
|
}
|
|
813
|
-
const
|
|
814
|
-
Quiet: { name: "quiet", severity:
|
|
815
|
-
Normal: { name: "normal", severity:
|
|
816
|
-
Debug: { name: "debug", severity:
|
|
808
|
+
const ge = {
|
|
809
|
+
Quiet: { name: "quiet", severity: O.Fatal },
|
|
810
|
+
Normal: { name: "normal", severity: O.Info },
|
|
811
|
+
Debug: { name: "debug", severity: O.Debug }
|
|
817
812
|
};
|
|
818
|
-
async function
|
|
813
|
+
async function wr(e) {
|
|
819
814
|
try {
|
|
820
815
|
const t = {
|
|
821
816
|
"site-url": {
|
|
@@ -825,8 +820,8 @@ async function yr(e) {
|
|
|
825
820
|
php: {
|
|
826
821
|
describe: "PHP version to use.",
|
|
827
822
|
type: "string",
|
|
828
|
-
default:
|
|
829
|
-
choices:
|
|
823
|
+
default: C,
|
|
824
|
+
choices: W
|
|
830
825
|
},
|
|
831
826
|
wp: {
|
|
832
827
|
describe: "WordPress version to use.",
|
|
@@ -860,12 +855,14 @@ async function yr(e) {
|
|
|
860
855
|
describe: "Mount a directory to the PHP runtime (can be used multiple times). Format: /host/path:/vfs/path",
|
|
861
856
|
type: "array",
|
|
862
857
|
string: !0,
|
|
858
|
+
nargs: 1,
|
|
863
859
|
coerce: F
|
|
864
860
|
},
|
|
865
861
|
"mount-before-install": {
|
|
866
862
|
describe: "Mount a directory to the PHP runtime before WordPress installation (can be used multiple times). Format: /host/path:/vfs/path",
|
|
867
863
|
type: "array",
|
|
868
864
|
string: !0,
|
|
865
|
+
nargs: 1,
|
|
869
866
|
coerce: F
|
|
870
867
|
},
|
|
871
868
|
"mount-dir": {
|
|
@@ -873,14 +870,14 @@ async function yr(e) {
|
|
|
873
870
|
type: "array",
|
|
874
871
|
nargs: 2,
|
|
875
872
|
array: !0,
|
|
876
|
-
coerce:
|
|
873
|
+
coerce: ne
|
|
877
874
|
},
|
|
878
875
|
"mount-dir-before-install": {
|
|
879
876
|
describe: 'Mount a directory before WordPress installation (can be used multiple times). Format: "/host/path" "/vfs/path"',
|
|
880
877
|
type: "string",
|
|
881
878
|
nargs: 2,
|
|
882
879
|
array: !0,
|
|
883
|
-
coerce:
|
|
880
|
+
coerce: ne
|
|
884
881
|
},
|
|
885
882
|
login: {
|
|
886
883
|
describe: "Should log the user in",
|
|
@@ -927,8 +924,8 @@ async function yr(e) {
|
|
|
927
924
|
verbosity: {
|
|
928
925
|
describe: "Output logs and progress messages.",
|
|
929
926
|
type: "string",
|
|
930
|
-
choices: Object.values(
|
|
931
|
-
(
|
|
927
|
+
choices: Object.values(ge).map(
|
|
928
|
+
(n) => n.name
|
|
932
929
|
),
|
|
933
930
|
default: "normal"
|
|
934
931
|
},
|
|
@@ -988,7 +985,7 @@ Warning: Following symlinks will expose files outside mounted directories to Pla
|
|
|
988
985
|
// supported IDEs and, if needed, will create the relevant
|
|
989
986
|
// config file for each.
|
|
990
987
|
choices: ["", "vscode", "phpstorm"],
|
|
991
|
-
coerce: (
|
|
988
|
+
coerce: (n) => n === "" ? ["vscode", "phpstorm"] : [n]
|
|
992
989
|
},
|
|
993
990
|
"experimental-blueprints-v2-runner": {
|
|
994
991
|
describe: "Use the experimental Blueprint V2 runner.",
|
|
@@ -1007,7 +1004,7 @@ Warning: Following symlinks will expose files outside mounted directories to Pla
|
|
|
1007
1004
|
phpmyadmin: {
|
|
1008
1005
|
describe: "Install phpMyAdmin for database management. The phpMyAdmin URL will be printed after boot. Optionally specify a custom URL path (default: /phpmyadmin).",
|
|
1009
1006
|
type: "string",
|
|
1010
|
-
coerce: (
|
|
1007
|
+
coerce: (n) => n === "" ? "/phpmyadmin" : n
|
|
1011
1008
|
}
|
|
1012
1009
|
}, r = {
|
|
1013
1010
|
port: {
|
|
@@ -1032,8 +1029,8 @@ Warning: Following symlinks will expose files outside mounted directories to Pla
|
|
|
1032
1029
|
php: {
|
|
1033
1030
|
describe: "PHP version to use.",
|
|
1034
1031
|
type: "string",
|
|
1035
|
-
default:
|
|
1036
|
-
choices:
|
|
1032
|
+
default: C,
|
|
1033
|
+
choices: W
|
|
1037
1034
|
},
|
|
1038
1035
|
wp: {
|
|
1039
1036
|
describe: "WordPress version to use.",
|
|
@@ -1102,10 +1099,10 @@ Warning: Following symlinks will expose files outside mounted directories to Pla
|
|
|
1102
1099
|
type: "string",
|
|
1103
1100
|
default: "wordpress.zip"
|
|
1104
1101
|
}
|
|
1105
|
-
}, i =
|
|
1102
|
+
}, i = Oe(e).usage("Usage: wp-playground <command> [options]").command(
|
|
1106
1103
|
"start",
|
|
1107
1104
|
"Start a local WordPress server with automatic project detection (recommended)",
|
|
1108
|
-
(
|
|
1105
|
+
(n) => n.usage(
|
|
1109
1106
|
`Usage: wp-playground start [options]
|
|
1110
1107
|
|
|
1111
1108
|
The easiest way to run WordPress locally. Automatically detects
|
|
@@ -1122,39 +1119,43 @@ Examples:
|
|
|
1122
1119
|
).command(
|
|
1123
1120
|
"server",
|
|
1124
1121
|
"Start a local WordPress server (advanced, low-level)",
|
|
1125
|
-
(
|
|
1122
|
+
(n) => n.options({
|
|
1126
1123
|
...t,
|
|
1127
1124
|
...r
|
|
1128
1125
|
})
|
|
1129
1126
|
).command(
|
|
1130
1127
|
"run-blueprint",
|
|
1131
1128
|
"Execute a Blueprint without starting a server",
|
|
1132
|
-
(
|
|
1129
|
+
(n) => n.options({ ...t })
|
|
1133
1130
|
).command(
|
|
1134
1131
|
"build-snapshot",
|
|
1135
1132
|
"Build a ZIP snapshot of a WordPress site based on a Blueprint",
|
|
1136
|
-
(
|
|
1133
|
+
(n) => n.options({
|
|
1137
1134
|
...t,
|
|
1138
1135
|
...s
|
|
1139
1136
|
})
|
|
1137
|
+
).command(
|
|
1138
|
+
"php",
|
|
1139
|
+
"Run a PHP script",
|
|
1140
|
+
(n) => n.options({ ...t })
|
|
1140
1141
|
).demandCommand(1, "Please specify a command").strictCommands().conflicts(
|
|
1141
1142
|
"experimental-unsafe-ide-integration",
|
|
1142
1143
|
"experimental-devtools"
|
|
1143
|
-
).showHelpOnFail(!1).fail((
|
|
1144
|
+
).showHelpOnFail(!1).fail((n, m, b) => {
|
|
1144
1145
|
if (m)
|
|
1145
1146
|
throw m;
|
|
1146
|
-
|
|
1147
|
-
` +
|
|
1148
|
-
}).strictOptions().check(async (
|
|
1149
|
-
if (
|
|
1147
|
+
n && n.includes("Please specify a command") && (b.showHelp(), console.error(`
|
|
1148
|
+
` + n), process.exit(1)), console.error(n), process.exit(1);
|
|
1149
|
+
}).strictOptions().check(async (n) => {
|
|
1150
|
+
if (n["skip-wordpress-install"] === !0 && (n["wordpress-install-mode"] = "do-not-attempt-installing", n.wordpressInstallMode = "do-not-attempt-installing"), n.wp !== void 0 && typeof n.wp == "string" && !vt(n.wp))
|
|
1150
1151
|
try {
|
|
1151
|
-
new URL(
|
|
1152
|
+
new URL(n.wp);
|
|
1152
1153
|
} catch {
|
|
1153
1154
|
throw new Error(
|
|
1154
1155
|
'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"'
|
|
1155
1156
|
);
|
|
1156
1157
|
}
|
|
1157
|
-
const m =
|
|
1158
|
+
const m = n["site-url"];
|
|
1158
1159
|
if (typeof m == "string" && m.trim() !== "")
|
|
1159
1160
|
try {
|
|
1160
1161
|
new URL(m);
|
|
@@ -1163,68 +1164,72 @@ Examples:
|
|
|
1163
1164
|
`Invalid site-url "${m}". Please provide a valid URL (e.g., http://localhost:8080 or https://example.com)`
|
|
1164
1165
|
);
|
|
1165
1166
|
}
|
|
1166
|
-
if (
|
|
1167
|
-
let
|
|
1167
|
+
if (n["auto-mount"]) {
|
|
1168
|
+
let b = !1;
|
|
1168
1169
|
try {
|
|
1169
|
-
|
|
1170
|
-
|
|
1170
|
+
b = p.statSync(
|
|
1171
|
+
n["auto-mount"]
|
|
1171
1172
|
).isDirectory();
|
|
1172
1173
|
} catch {
|
|
1173
|
-
|
|
1174
|
+
b = !1;
|
|
1174
1175
|
}
|
|
1175
|
-
if (!
|
|
1176
|
+
if (!b)
|
|
1176
1177
|
throw new Error(
|
|
1177
|
-
`The specified --auto-mount path is not a directory: '${
|
|
1178
|
+
`The specified --auto-mount path is not a directory: '${n["auto-mount"]}'.`
|
|
1178
1179
|
);
|
|
1179
1180
|
}
|
|
1180
|
-
if (
|
|
1181
|
+
if (n["experimental-blueprints-v2-runner"] === !0)
|
|
1181
1182
|
throw new Error(
|
|
1182
1183
|
"Blueprints v2 are temporarily disabled while we rework their runtime implementation."
|
|
1183
1184
|
);
|
|
1184
|
-
if (
|
|
1185
|
+
if (n.mode !== void 0)
|
|
1185
1186
|
throw new Error(
|
|
1186
1187
|
"The --mode option requires the --experimentalBlueprintsV2Runner flag."
|
|
1187
1188
|
);
|
|
1188
1189
|
return !0;
|
|
1189
1190
|
});
|
|
1190
1191
|
i.wrap(i.terminalWidth());
|
|
1191
|
-
const
|
|
1192
|
-
[
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1192
|
+
const a = await i.argv, l = a._[0];
|
|
1193
|
+
[
|
|
1194
|
+
"start",
|
|
1195
|
+
"run-blueprint",
|
|
1196
|
+
"server",
|
|
1197
|
+
"build-snapshot",
|
|
1198
|
+
"php"
|
|
1199
|
+
].includes(l) || (i.showHelp(), process.exit(1));
|
|
1200
|
+
const u = a.define || {};
|
|
1196
1201
|
!("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");
|
|
1197
|
-
const
|
|
1198
|
-
...
|
|
1202
|
+
const y = {
|
|
1203
|
+
...a,
|
|
1199
1204
|
define: u,
|
|
1200
1205
|
command: l,
|
|
1201
1206
|
mount: [
|
|
1202
|
-
...
|
|
1203
|
-
...
|
|
1207
|
+
...a.mount || [],
|
|
1208
|
+
...a["mount-dir"] || []
|
|
1204
1209
|
],
|
|
1205
1210
|
"mount-before-install": [
|
|
1206
|
-
...
|
|
1207
|
-
...
|
|
1211
|
+
...a["mount-before-install"] || [],
|
|
1212
|
+
...a["mount-dir-before-install"] || []
|
|
1208
1213
|
]
|
|
1209
|
-
},
|
|
1210
|
-
|
|
1214
|
+
}, E = await Lt(y);
|
|
1215
|
+
E === void 0 && process.exit(0);
|
|
1211
1216
|
const c = /* @__PURE__ */ (() => {
|
|
1212
|
-
let
|
|
1217
|
+
let n;
|
|
1213
1218
|
return async () => {
|
|
1214
|
-
|
|
1219
|
+
n === void 0 && (n = E[Symbol.asyncDispose]()), await n, process.exit(0);
|
|
1215
1220
|
};
|
|
1216
1221
|
})();
|
|
1217
1222
|
return process.on("SIGINT", c), process.on("SIGTERM", c), {
|
|
1218
1223
|
[Symbol.asyncDispose]: async () => {
|
|
1219
|
-
process.off("SIGINT", c), process.off("SIGTERM", c), await
|
|
1224
|
+
process.off("SIGINT", c), process.off("SIGTERM", c), await E[Symbol.asyncDispose]();
|
|
1220
1225
|
},
|
|
1221
|
-
[
|
|
1226
|
+
[Pe]: { cliServer: E }
|
|
1222
1227
|
};
|
|
1223
1228
|
} catch (t) {
|
|
1224
1229
|
if (console.error(t), !(t instanceof Error))
|
|
1225
1230
|
throw t;
|
|
1226
1231
|
if (process.argv.includes("--debug"))
|
|
1227
|
-
|
|
1232
|
+
$e(t);
|
|
1228
1233
|
else {
|
|
1229
1234
|
const o = [];
|
|
1230
1235
|
let s = t;
|
|
@@ -1238,22 +1243,22 @@ Examples:
|
|
|
1238
1243
|
process.exit(1);
|
|
1239
1244
|
}
|
|
1240
1245
|
}
|
|
1241
|
-
function
|
|
1246
|
+
function le(e, t) {
|
|
1242
1247
|
return e.find(
|
|
1243
1248
|
(r) => r.vfsPath.replace(/\/$/, "") === t.replace(/\/$/, "")
|
|
1244
1249
|
);
|
|
1245
1250
|
}
|
|
1246
|
-
const
|
|
1251
|
+
const Pe = Symbol("playground-cli-testing"), I = (e) => process.stdout.isTTY ? "\x1B[1m" + e + "\x1B[0m" : e, Wt = (e) => process.stdout.isTTY ? "\x1B[31m" + e + "\x1B[0m" : e, ue = (e) => process.stdout.isTTY ? `\x1B[2m${e}\x1B[0m` : e, R = (e) => process.stdout.isTTY ? `\x1B[3m${e}\x1B[0m` : e, j = (e) => process.stdout.isTTY ? `\x1B[33m${e}\x1B[0m` : e;
|
|
1247
1252
|
async function Lt(e) {
|
|
1248
1253
|
let t;
|
|
1249
|
-
const r = e.internalCookieStore ? new
|
|
1250
|
-
if (e.command === "start" && (e = Ut(e)), e.autoMount !== void 0 && (e.autoMount === "" && (e = { ...e, autoMount: process.cwd() }), e =
|
|
1251
|
-
const c = Object.values(
|
|
1252
|
-
(
|
|
1254
|
+
const r = e.internalCookieStore ? new Te() : void 0, o = [], s = /* @__PURE__ */ new Map();
|
|
1255
|
+
if (e.command === "start" && (e = Ut(e)), e.autoMount !== void 0 && (e.autoMount === "" && (e = { ...e, autoMount: process.cwd() }), e = we(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) {
|
|
1256
|
+
const c = Object.values(ge).find(
|
|
1257
|
+
(n) => n.name === e.verbosity
|
|
1253
1258
|
).severity;
|
|
1254
|
-
|
|
1259
|
+
w.setSeverityFilterLevel(c);
|
|
1255
1260
|
}
|
|
1256
|
-
if (e.intl || (e.intl = !0), e.redis === void 0 && (e.redis = await
|
|
1261
|
+
if (e.intl || (e.intl = !0), e.redis === void 0 && (e.redis = await ie()), e.memcached === void 0 && (e.memcached = await ie()), e.phpmyadmin) {
|
|
1257
1262
|
if (e.phpmyadmin === !0 && (e.phpmyadmin = "/phpmyadmin"), e.skipSqliteSetup)
|
|
1258
1263
|
throw new Error(
|
|
1259
1264
|
"--phpmyadmin requires SQLite. Cannot be used with --skip-sqlite-setup."
|
|
@@ -1261,15 +1266,15 @@ async function Lt(e) {
|
|
|
1261
1266
|
e.pathAliases = [
|
|
1262
1267
|
{
|
|
1263
1268
|
urlPrefix: e.phpmyadmin,
|
|
1264
|
-
fsPath:
|
|
1269
|
+
fsPath: se
|
|
1265
1270
|
}
|
|
1266
1271
|
];
|
|
1267
1272
|
}
|
|
1268
|
-
const i = new
|
|
1273
|
+
const i = new Dt({
|
|
1269
1274
|
verbosity: e.verbosity || "normal"
|
|
1270
1275
|
});
|
|
1271
1276
|
e.command === "server" && (i.printBanner(), i.printConfig({
|
|
1272
|
-
phpVersion: e.php ||
|
|
1277
|
+
phpVersion: e.php || C,
|
|
1273
1278
|
wpVersion: e.wp || "latest",
|
|
1274
1279
|
port: e.port ?? 9400,
|
|
1275
1280
|
xdebug: !!e.xdebug,
|
|
@@ -1282,30 +1287,30 @@ async function Lt(e) {
|
|
|
1282
1287
|
],
|
|
1283
1288
|
blueprint: typeof e.blueprint == "string" ? e.blueprint : void 0
|
|
1284
1289
|
}));
|
|
1285
|
-
const
|
|
1286
|
-
let u = !1,
|
|
1287
|
-
const
|
|
1288
|
-
port: e.port ? e.port : await
|
|
1289
|
-
onBind: async (c,
|
|
1290
|
-
const m = "127.0.0.1",
|
|
1291
|
-
|
|
1292
|
-
const A = "WP Playground CLI - Listen for Xdebug",
|
|
1293
|
-
if (await Ke(
|
|
1294
|
-
const
|
|
1295
|
-
hostPath: d.join(".", d.sep,
|
|
1290
|
+
const a = e.command === "server" ? e.port ?? 9400 : 0, l = new Ie();
|
|
1291
|
+
let u = !1, y = !0;
|
|
1292
|
+
const E = await wt({
|
|
1293
|
+
port: e.port ? e.port : await ft(a) ? 0 : a,
|
|
1294
|
+
onBind: async (c, n) => {
|
|
1295
|
+
const m = "127.0.0.1", b = `http://${m}:${n}`, L = e["site-url"] || b, U = 6, Q = "-playground-cli-site-", T = await kt(Q);
|
|
1296
|
+
w.debug(`Native temp dir for VFS root: ${T.path}`);
|
|
1297
|
+
const A = "WP Playground CLI - Listen for Xdebug", X = ".playground-xdebug-root", _ = d.join(process.cwd(), X);
|
|
1298
|
+
if (await Ke(_), e.xdebug) {
|
|
1299
|
+
const h = {
|
|
1300
|
+
hostPath: d.join(".", d.sep, X),
|
|
1296
1301
|
vfsPath: "/"
|
|
1297
1302
|
};
|
|
1298
|
-
if (
|
|
1299
|
-
e.php ||
|
|
1300
|
-
) <=
|
|
1301
|
-
await
|
|
1302
|
-
|
|
1303
|
-
|
|
1303
|
+
if (W.indexOf(
|
|
1304
|
+
e.php || C
|
|
1305
|
+
) <= W.indexOf("8.5"))
|
|
1306
|
+
await oe(
|
|
1307
|
+
T.path,
|
|
1308
|
+
_,
|
|
1304
1309
|
process.platform
|
|
1305
1310
|
), e.xdebug = et({
|
|
1306
1311
|
cwd: process.cwd(),
|
|
1307
1312
|
mounts: [
|
|
1308
|
-
|
|
1313
|
+
h,
|
|
1309
1314
|
...e["mount-before-install"] || [],
|
|
1310
1315
|
...e.mount || []
|
|
1311
1316
|
],
|
|
@@ -1317,16 +1322,16 @@ async function Lt(e) {
|
|
|
1317
1322
|
"/proc/"
|
|
1318
1323
|
]
|
|
1319
1324
|
}), console.log(I("Xdebug configured successfully")), console.log(
|
|
1320
|
-
|
|
1321
|
-
|
|
1325
|
+
j("Playground source root: ") + ".playground-xdebug-root" + R(
|
|
1326
|
+
ue(
|
|
1322
1327
|
" – you can set breakpoints and preview Playground's VFS structure in there."
|
|
1323
1328
|
)
|
|
1324
1329
|
)
|
|
1325
1330
|
);
|
|
1326
1331
|
else if (e.experimentalUnsafeIdeIntegration) {
|
|
1327
|
-
await
|
|
1328
|
-
|
|
1329
|
-
|
|
1332
|
+
await oe(
|
|
1333
|
+
T.path,
|
|
1334
|
+
_,
|
|
1330
1335
|
process.platform
|
|
1331
1336
|
);
|
|
1332
1337
|
try {
|
|
@@ -1334,26 +1339,26 @@ async function Lt(e) {
|
|
|
1334
1339
|
A,
|
|
1335
1340
|
process.cwd()
|
|
1336
1341
|
);
|
|
1337
|
-
const
|
|
1342
|
+
const f = typeof e.xdebug == "object" ? e.xdebug : {}, g = await rt({
|
|
1338
1343
|
name: A,
|
|
1339
1344
|
host: m,
|
|
1340
|
-
port:
|
|
1345
|
+
port: n,
|
|
1341
1346
|
ides: e.experimentalUnsafeIdeIntegration,
|
|
1342
1347
|
cwd: process.cwd(),
|
|
1343
1348
|
mounts: [
|
|
1344
|
-
|
|
1349
|
+
h,
|
|
1345
1350
|
...e["mount-before-install"] || [],
|
|
1346
1351
|
...e.mount || []
|
|
1347
1352
|
],
|
|
1348
|
-
ideKey:
|
|
1349
|
-
}), v = e.experimentalUnsafeIdeIntegration,
|
|
1350
|
-
console.log(""),
|
|
1353
|
+
ideKey: f.ideKey || "WPPLAYGROUNDCLI"
|
|
1354
|
+
}), v = e.experimentalUnsafeIdeIntegration, S = v.includes("vscode"), x = v.includes("phpstorm"), B = Object.values(g);
|
|
1355
|
+
console.log(""), B.length > 0 ? (console.log(
|
|
1351
1356
|
I("Xdebug configured successfully")
|
|
1352
1357
|
), console.log(
|
|
1353
|
-
|
|
1358
|
+
j("Updated IDE config: ") + B.join(" ")
|
|
1354
1359
|
), console.log(
|
|
1355
|
-
|
|
1356
|
-
|
|
1360
|
+
j("Playground source root: ") + ".playground-xdebug-root" + R(
|
|
1361
|
+
ue(
|
|
1357
1362
|
" – you can set breakpoints and preview Playground's VFS structure in there."
|
|
1358
1363
|
)
|
|
1359
1364
|
)
|
|
@@ -1361,7 +1366,7 @@ async function Lt(e) {
|
|
|
1361
1366
|
I("Xdebug configuration failed.")
|
|
1362
1367
|
), console.log(
|
|
1363
1368
|
"No IDE-specific project settings directory was found in the current working directory."
|
|
1364
|
-
)), console.log(""),
|
|
1369
|
+
)), console.log(""), S && g.vscode && (console.log(
|
|
1365
1370
|
I("VS Code / Cursor instructions:")
|
|
1366
1371
|
), console.log(
|
|
1367
1372
|
" 1. Ensure you have installed an IDE extension for PHP Debugging"
|
|
@@ -1372,15 +1377,15 @@ async function Lt(e) {
|
|
|
1372
1377
|
), console.log(
|
|
1373
1378
|
" 2. Open the Run and Debug panel on the left sidebar"
|
|
1374
1379
|
), console.log(
|
|
1375
|
-
` 3. Select "${
|
|
1380
|
+
` 3. Select "${R(
|
|
1376
1381
|
A
|
|
1377
1382
|
)}" from the dropdown`
|
|
1378
1383
|
), console.log(' 3. Click "start debugging"'), console.log(
|
|
1379
1384
|
" 5. Set a breakpoint. For example, in .playground-xdebug-root/wordpress/index.php"
|
|
1380
1385
|
), console.log(
|
|
1381
1386
|
" 6. Visit Playground in your browser to hit the breakpoint"
|
|
1382
|
-
),
|
|
1383
|
-
` 1. Choose "${
|
|
1387
|
+
), x && console.log("")), x && g.phpstorm && (console.log(I("PhpStorm instructions:")), console.log(
|
|
1388
|
+
` 1. Choose "${R(
|
|
1384
1389
|
A
|
|
1385
1390
|
)}" debug configuration in the toolbar`
|
|
1386
1391
|
), console.log(
|
|
@@ -1390,22 +1395,22 @@ async function Lt(e) {
|
|
|
1390
1395
|
), console.log(
|
|
1391
1396
|
" 4. Visit Playground in your browser to hit the breakpoint"
|
|
1392
1397
|
)), console.log("");
|
|
1393
|
-
} catch (
|
|
1398
|
+
} catch (f) {
|
|
1394
1399
|
throw new Error("Could not configure Xdebug", {
|
|
1395
|
-
cause:
|
|
1400
|
+
cause: f
|
|
1396
1401
|
});
|
|
1397
1402
|
}
|
|
1398
1403
|
}
|
|
1399
1404
|
}
|
|
1400
|
-
const
|
|
1405
|
+
const ve = d.dirname(T.path), Se = 2 * 24 * 60 * 60 * 1e3;
|
|
1401
1406
|
Mt(
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1407
|
+
Q,
|
|
1408
|
+
Se,
|
|
1409
|
+
ve
|
|
1405
1410
|
);
|
|
1406
|
-
const
|
|
1407
|
-
|
|
1408
|
-
const
|
|
1411
|
+
const Z = d.join(T.path, "internal");
|
|
1412
|
+
Y(Z);
|
|
1413
|
+
const xe = [
|
|
1409
1414
|
"wordpress",
|
|
1410
1415
|
"tools",
|
|
1411
1416
|
// Note: These dirs are from Emscripten's "default dirs" list:
|
|
@@ -1417,91 +1422,91 @@ async function Lt(e) {
|
|
|
1417
1422
|
"tmp",
|
|
1418
1423
|
"home"
|
|
1419
1424
|
];
|
|
1420
|
-
for (const
|
|
1421
|
-
const
|
|
1422
|
-
if (!(e["mount-before-install"]?.some(
|
|
1423
|
-
const
|
|
1424
|
-
|
|
1425
|
-
|
|
1425
|
+
for (const h of xe) {
|
|
1426
|
+
const P = (g) => g.vfsPath === `/${h}`;
|
|
1427
|
+
if (!(e["mount-before-install"]?.some(P) || e.mount?.some(P))) {
|
|
1428
|
+
const g = d.join(
|
|
1429
|
+
T.path,
|
|
1430
|
+
h
|
|
1426
1431
|
);
|
|
1427
|
-
|
|
1428
|
-
vfsPath: `/${
|
|
1429
|
-
hostPath:
|
|
1432
|
+
Y(g), e["mount-before-install"] === void 0 && (e["mount-before-install"] = []), e["mount-before-install"].unshift({
|
|
1433
|
+
vfsPath: `/${h}`,
|
|
1434
|
+
hostPath: g
|
|
1430
1435
|
});
|
|
1431
1436
|
}
|
|
1432
1437
|
}
|
|
1433
1438
|
if (e["mount-before-install"])
|
|
1434
|
-
for (const
|
|
1435
|
-
|
|
1436
|
-
`Mount before WP install: ${
|
|
1439
|
+
for (const h of e["mount-before-install"])
|
|
1440
|
+
w.debug(
|
|
1441
|
+
`Mount before WP install: ${h.vfsPath} -> ${h.hostPath}`
|
|
1437
1442
|
);
|
|
1438
1443
|
if (e.mount)
|
|
1439
|
-
for (const
|
|
1440
|
-
|
|
1441
|
-
`Mount after WP install: ${
|
|
1444
|
+
for (const h of e.mount)
|
|
1445
|
+
w.debug(
|
|
1446
|
+
`Mount after WP install: ${h.vfsPath} -> ${h.hostPath}`
|
|
1442
1447
|
);
|
|
1443
1448
|
let k;
|
|
1444
1449
|
e["experimental-blueprints-v2-runner"] ? k = new xt(e, {
|
|
1445
|
-
siteUrl:
|
|
1450
|
+
siteUrl: L,
|
|
1446
1451
|
cliOutput: i
|
|
1447
1452
|
}) : (k = new It(e, {
|
|
1448
|
-
siteUrl:
|
|
1453
|
+
siteUrl: L,
|
|
1449
1454
|
cliOutput: i
|
|
1450
1455
|
}), typeof e.blueprint == "string" && (e.blueprint = await St({
|
|
1451
1456
|
sourceString: e.blueprint,
|
|
1452
1457
|
blueprintMayReadAdjacentFiles: e["blueprint-may-read-adjacent-files"] === !0
|
|
1453
1458
|
})));
|
|
1454
1459
|
let H = !1;
|
|
1455
|
-
const
|
|
1460
|
+
const M = async function() {
|
|
1456
1461
|
H || (H = !0, await Promise.all(
|
|
1457
|
-
o.map(async (
|
|
1458
|
-
await s.get(
|
|
1462
|
+
o.map(async (P) => {
|
|
1463
|
+
await s.get(P)?.dispose(), await P.worker.terminate();
|
|
1459
1464
|
})
|
|
1460
|
-
), c && await new Promise((
|
|
1461
|
-
c.close(
|
|
1462
|
-
}), await
|
|
1465
|
+
), c && await new Promise((P) => {
|
|
1466
|
+
c.close(P), c.closeAllConnections();
|
|
1467
|
+
}), await T.cleanup());
|
|
1463
1468
|
};
|
|
1464
1469
|
try {
|
|
1465
|
-
const
|
|
1466
|
-
for (let
|
|
1467
|
-
const
|
|
1470
|
+
const h = [], P = k.getWorkerType();
|
|
1471
|
+
for (let f = 0; f < U; f++) {
|
|
1472
|
+
const g = _t(P, {
|
|
1468
1473
|
onExit: (v) => {
|
|
1469
|
-
H || v === 0 &&
|
|
1470
|
-
`Worker ${
|
|
1474
|
+
H || v === 0 && w.error(
|
|
1475
|
+
`Worker ${f} exited with code ${v}
|
|
1471
1476
|
`
|
|
1472
1477
|
);
|
|
1473
1478
|
}
|
|
1474
1479
|
}).then(
|
|
1475
1480
|
async (v) => {
|
|
1476
1481
|
o.push(v);
|
|
1477
|
-
const
|
|
1482
|
+
const S = await Ht(l), x = await k.bootRequestHandler({
|
|
1478
1483
|
worker: v,
|
|
1479
|
-
fileLockManagerPort:
|
|
1480
|
-
nativeInternalDirPath:
|
|
1484
|
+
fileLockManagerPort: S,
|
|
1485
|
+
nativeInternalDirPath: Z
|
|
1481
1486
|
});
|
|
1482
1487
|
return s.set(
|
|
1483
1488
|
v,
|
|
1484
|
-
|
|
1485
|
-
), [v,
|
|
1489
|
+
x
|
|
1490
|
+
), [v, x];
|
|
1486
1491
|
}
|
|
1487
1492
|
);
|
|
1488
|
-
|
|
1493
|
+
h.push(g), f === 0 && await g;
|
|
1489
1494
|
}
|
|
1490
|
-
await Promise.all(
|
|
1495
|
+
await Promise.all(h), t = ke(
|
|
1491
1496
|
o.map(
|
|
1492
|
-
(
|
|
1497
|
+
(f) => s.get(f)
|
|
1493
1498
|
)
|
|
1494
1499
|
);
|
|
1495
1500
|
{
|
|
1496
|
-
const
|
|
1497
|
-
if (await
|
|
1501
|
+
const f = new pe(), g = f.port1, v = f.port2;
|
|
1502
|
+
if (await Me(
|
|
1498
1503
|
{
|
|
1499
1504
|
applyPostInstallMountsToAllWorkers: async () => {
|
|
1500
1505
|
await Promise.all(
|
|
1501
1506
|
Array.from(
|
|
1502
1507
|
s.values()
|
|
1503
1508
|
).map(
|
|
1504
|
-
(
|
|
1509
|
+
(S) => S.mountAfterWordPressInstall(
|
|
1505
1510
|
e.mount || []
|
|
1506
1511
|
)
|
|
1507
1512
|
)
|
|
@@ -1509,69 +1514,93 @@ async function Lt(e) {
|
|
|
1509
1514
|
}
|
|
1510
1515
|
},
|
|
1511
1516
|
void 0,
|
|
1512
|
-
|
|
1517
|
+
g
|
|
1513
1518
|
), await k.bootWordPress(
|
|
1514
1519
|
t,
|
|
1515
1520
|
v
|
|
1516
|
-
),
|
|
1517
|
-
const
|
|
1521
|
+
), g.close(), u = !0, !e["experimental-blueprints-v2-runner"]) {
|
|
1522
|
+
const S = await k.compileInputBlueprint(
|
|
1518
1523
|
e["additional-blueprint-steps"] || []
|
|
1519
1524
|
);
|
|
1520
|
-
|
|
1521
|
-
|
|
1525
|
+
S && await te(
|
|
1526
|
+
S,
|
|
1522
1527
|
t
|
|
1523
1528
|
);
|
|
1524
1529
|
}
|
|
1525
1530
|
if (e.phpmyadmin && !await t.fileExists(
|
|
1526
|
-
`${
|
|
1531
|
+
`${se}/index.php`
|
|
1527
1532
|
)) {
|
|
1528
|
-
const
|
|
1529
|
-
await
|
|
1533
|
+
const S = await st(), x = await ce({ steps: S });
|
|
1534
|
+
await te(x, t);
|
|
1530
1535
|
}
|
|
1531
1536
|
if (e.command === "build-snapshot") {
|
|
1532
|
-
await
|
|
1537
|
+
await Ot(t, e.outfile), i.printStatus(`Exported to ${e.outfile}`), await M();
|
|
1533
1538
|
return;
|
|
1534
1539
|
} else if (e.command === "run-blueprint") {
|
|
1535
|
-
i.finishProgress("Done"), await
|
|
1540
|
+
i.finishProgress("Done"), await M();
|
|
1536
1541
|
return;
|
|
1542
|
+
} else if (e.command === "php") {
|
|
1543
|
+
const S = [
|
|
1544
|
+
// @TODO: Import this from somewhere?
|
|
1545
|
+
// Hardcoding it feels fragile.
|
|
1546
|
+
"/internal/shared/bin/php",
|
|
1547
|
+
...(e._ || []).slice(1)
|
|
1548
|
+
], x = await t.cli(S), [B] = await Promise.all([
|
|
1549
|
+
x.exitCode,
|
|
1550
|
+
x.stdout.pipeTo(
|
|
1551
|
+
new WritableStream({
|
|
1552
|
+
write(N) {
|
|
1553
|
+
process.stdout.write(N);
|
|
1554
|
+
}
|
|
1555
|
+
})
|
|
1556
|
+
),
|
|
1557
|
+
x.stderr.pipeTo(
|
|
1558
|
+
new WritableStream({
|
|
1559
|
+
write(N) {
|
|
1560
|
+
process.stderr.write(N);
|
|
1561
|
+
}
|
|
1562
|
+
})
|
|
1563
|
+
)
|
|
1564
|
+
]);
|
|
1565
|
+
await M(), process.exit(B);
|
|
1537
1566
|
}
|
|
1538
1567
|
}
|
|
1539
|
-
if (i.finishProgress(), i.printReady(
|
|
1540
|
-
const
|
|
1568
|
+
if (i.finishProgress(), i.printReady(b, U), e.phpmyadmin) {
|
|
1569
|
+
const f = d.join(
|
|
1541
1570
|
e.phpmyadmin,
|
|
1542
1571
|
it
|
|
1543
1572
|
);
|
|
1544
1573
|
i.printPhpMyAdminUrl(
|
|
1545
|
-
new URL(
|
|
1574
|
+
new URL(f, b).toString()
|
|
1546
1575
|
);
|
|
1547
1576
|
}
|
|
1548
|
-
return e.xdebug && e.experimentalDevtools && (await
|
|
1577
|
+
return e.xdebug && e.experimentalDevtools && (await Xe({
|
|
1549
1578
|
phpInstance: t,
|
|
1550
1579
|
phpRoot: "/wordpress"
|
|
1551
1580
|
})).start(), {
|
|
1552
1581
|
playground: t,
|
|
1553
1582
|
server: c,
|
|
1554
|
-
serverUrl:
|
|
1555
|
-
[Symbol.asyncDispose]:
|
|
1556
|
-
[
|
|
1557
|
-
workerThreadCount:
|
|
1583
|
+
serverUrl: b,
|
|
1584
|
+
[Symbol.asyncDispose]: M,
|
|
1585
|
+
[Pe]: {
|
|
1586
|
+
workerThreadCount: U
|
|
1558
1587
|
}
|
|
1559
1588
|
};
|
|
1560
|
-
} catch (
|
|
1589
|
+
} catch (h) {
|
|
1561
1590
|
if (e.verbosity !== "debug")
|
|
1562
|
-
throw
|
|
1563
|
-
let
|
|
1564
|
-
throw await t?.fileExists(
|
|
1591
|
+
throw h;
|
|
1592
|
+
let P = "";
|
|
1593
|
+
throw await t?.fileExists(J) && (P = await t.readFileAsText(J)), await M(), new Error(P, { cause: h });
|
|
1565
1594
|
}
|
|
1566
1595
|
},
|
|
1567
1596
|
async handleRequest(c) {
|
|
1568
1597
|
if (!u)
|
|
1569
|
-
return
|
|
1598
|
+
return K.forHttpCode(
|
|
1570
1599
|
502,
|
|
1571
1600
|
"WordPress is not ready yet"
|
|
1572
1601
|
);
|
|
1573
|
-
if (
|
|
1574
|
-
|
|
1602
|
+
if (y) {
|
|
1603
|
+
y = !1;
|
|
1575
1604
|
const m = {
|
|
1576
1605
|
"Content-Type": ["text/plain"],
|
|
1577
1606
|
"Content-Length": ["0"],
|
|
@@ -1581,8 +1610,8 @@ async function Lt(e) {
|
|
|
1581
1610
|
"playground_auto_login_already_happened"
|
|
1582
1611
|
) && (m["Set-Cookie"] = [
|
|
1583
1612
|
"playground_auto_login_already_happened=1; Max-Age=0; Expires=Thu, 01 Jan 1970 00:00:00 GMT; Path=/"
|
|
1584
|
-
]),
|
|
1585
|
-
new
|
|
1613
|
+
]), K.fromPHPResponse(
|
|
1614
|
+
new Ce(302, m, new Uint8Array())
|
|
1586
1615
|
);
|
|
1587
1616
|
}
|
|
1588
1617
|
r && (c = {
|
|
@@ -1597,25 +1626,25 @@ async function Lt(e) {
|
|
|
1597
1626
|
cookie: r.getCookieRequestHeader()
|
|
1598
1627
|
}
|
|
1599
1628
|
});
|
|
1600
|
-
const
|
|
1629
|
+
const n = await t.requestStreamed(c);
|
|
1601
1630
|
if (r) {
|
|
1602
|
-
const m = await
|
|
1631
|
+
const m = await n.headers;
|
|
1603
1632
|
r.rememberCookiesFromResponseHeaders(m), delete m["set-cookie"];
|
|
1604
1633
|
}
|
|
1605
|
-
return
|
|
1634
|
+
return n;
|
|
1606
1635
|
}
|
|
1607
1636
|
}).catch((c) => {
|
|
1608
1637
|
i.printError(c.message), process.exit(1);
|
|
1609
1638
|
});
|
|
1610
|
-
return
|
|
1639
|
+
return E && e.command === "start" && !e.skipBrowser && Nt(E.serverUrl), E;
|
|
1611
1640
|
}
|
|
1612
1641
|
function Ut(e) {
|
|
1613
1642
|
let t = { ...e, command: "server" };
|
|
1614
|
-
e.noAutoMount || (t.autoMount = d.resolve(process.cwd(), t.path ?? ""), t =
|
|
1615
|
-
const r =
|
|
1643
|
+
e.noAutoMount || (t.autoMount = d.resolve(process.cwd(), t.path ?? ""), t = we(t), delete t.autoMount);
|
|
1644
|
+
const r = le(
|
|
1616
1645
|
t["mount-before-install"] || [],
|
|
1617
1646
|
"/wordpress"
|
|
1618
|
-
) ||
|
|
1647
|
+
) || le(t.mount || [], "/wordpress");
|
|
1619
1648
|
if (r)
|
|
1620
1649
|
console.log("Site files stored at:", r?.hostPath), e.reset && (console.log(""), console.log(
|
|
1621
1650
|
Wt(
|
|
@@ -1627,15 +1656,15 @@ function Ut(e) {
|
|
|
1627
1656
|
"You may still remove the site's directory manually if you wish."
|
|
1628
1657
|
), process.exit(1));
|
|
1629
1658
|
else {
|
|
1630
|
-
const o = t.autoMount || process.cwd(), s = ot("sha256").update(o).digest("hex"), i =
|
|
1659
|
+
const o = t.autoMount || process.cwd(), s = ot("sha256").update(o).digest("hex"), i = G.homedir(), a = d.join(
|
|
1631
1660
|
i,
|
|
1632
1661
|
".wordpress-playground/sites",
|
|
1633
1662
|
s
|
|
1634
1663
|
);
|
|
1635
|
-
console.log("Site files stored at:",
|
|
1664
|
+
console.log("Site files stored at:", a), z(a) && e.reset && (console.log("Resetting site..."), We(a, { recursive: !0 })), Y(a, { recursive: !0 }), t["mount-before-install"] = [
|
|
1636
1665
|
...t["mount-before-install"] || [],
|
|
1637
|
-
{ vfsPath: "/wordpress", hostPath:
|
|
1638
|
-
], t.wordpressInstallMode =
|
|
1666
|
+
{ vfsPath: "/wordpress", hostPath: a }
|
|
1667
|
+
], t.wordpressInstallMode = Le(a).length === 0 ? (
|
|
1639
1668
|
// Only download WordPress on the first run when the site directory is still
|
|
1640
1669
|
// empty.
|
|
1641
1670
|
"download-and-install"
|
|
@@ -1646,11 +1675,11 @@ function Ut(e) {
|
|
|
1646
1675
|
}
|
|
1647
1676
|
return t;
|
|
1648
1677
|
}
|
|
1649
|
-
const
|
|
1650
|
-
function
|
|
1678
|
+
const V = new Ee();
|
|
1679
|
+
function _t(e, { onExit: t } = {}) {
|
|
1651
1680
|
let r;
|
|
1652
|
-
return e === "v1" ? r = new
|
|
1653
|
-
const i =
|
|
1681
|
+
return e === "v1" ? r = new re(new URL("./worker-thread-v1.js", import.meta.url)) : r = new re(new URL("./worker-thread-v2.js", import.meta.url)), new Promise((o, s) => {
|
|
1682
|
+
const i = V.claim();
|
|
1654
1683
|
r.once("message", function(l) {
|
|
1655
1684
|
l.command === "worker-script-initialized" && o({
|
|
1656
1685
|
processId: i,
|
|
@@ -1658,26 +1687,26 @@ function Ht(e, { onExit: t } = {}) {
|
|
|
1658
1687
|
phpPort: l.phpPort
|
|
1659
1688
|
});
|
|
1660
1689
|
}), r.once("error", function(l) {
|
|
1661
|
-
|
|
1690
|
+
V.release(i), console.error(l);
|
|
1662
1691
|
const u = new Error(
|
|
1663
1692
|
`Worker failed to load worker. ${l.message ? `Original error: ${l.message}` : ""}`
|
|
1664
1693
|
);
|
|
1665
1694
|
s(u);
|
|
1666
1695
|
});
|
|
1667
|
-
let
|
|
1696
|
+
let a = !1;
|
|
1668
1697
|
r.once("spawn", () => {
|
|
1669
|
-
|
|
1698
|
+
a = !0;
|
|
1670
1699
|
}), r.once("exit", (l) => {
|
|
1671
|
-
|
|
1700
|
+
V.release(i), a || s(new Error(`Worker exited before spawning: ${l}`)), t?.(l);
|
|
1672
1701
|
});
|
|
1673
1702
|
});
|
|
1674
1703
|
}
|
|
1675
|
-
async function
|
|
1676
|
-
const { port1: t, port2: r } = new
|
|
1704
|
+
async function Ht(e) {
|
|
1705
|
+
const { port1: t, port2: r } = new pe();
|
|
1677
1706
|
return await Ae(e, t), r;
|
|
1678
1707
|
}
|
|
1679
|
-
function
|
|
1680
|
-
const t =
|
|
1708
|
+
function Nt(e) {
|
|
1709
|
+
const t = G.platform();
|
|
1681
1710
|
let r;
|
|
1682
1711
|
switch (t) {
|
|
1683
1712
|
case "darwin":
|
|
@@ -1690,11 +1719,11 @@ function Ft(e) {
|
|
|
1690
1719
|
r = `xdg-open "${e}"`;
|
|
1691
1720
|
break;
|
|
1692
1721
|
}
|
|
1693
|
-
|
|
1694
|
-
o &&
|
|
1722
|
+
he(r, (o) => {
|
|
1723
|
+
o && w.debug(`Could not open browser: ${o.message}`);
|
|
1695
1724
|
});
|
|
1696
1725
|
}
|
|
1697
|
-
async function
|
|
1726
|
+
async function Ot(e, t) {
|
|
1698
1727
|
await e.run({
|
|
1699
1728
|
code: `<?php
|
|
1700
1729
|
$zip = new ZipArchive();
|
|
@@ -1719,13 +1748,13 @@ async function Nt(e, t) {
|
|
|
1719
1748
|
p.writeFileSync(t, r);
|
|
1720
1749
|
}
|
|
1721
1750
|
export {
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1751
|
+
ge as L,
|
|
1752
|
+
fr as a,
|
|
1753
|
+
Rt as b,
|
|
1754
|
+
Pe as i,
|
|
1755
|
+
ye as m,
|
|
1756
|
+
wr as p,
|
|
1728
1757
|
Lt as r,
|
|
1729
|
-
|
|
1758
|
+
_t as s
|
|
1730
1759
|
};
|
|
1731
|
-
//# sourceMappingURL=run-cli-
|
|
1760
|
+
//# sourceMappingURL=run-cli-2YzKNrNz.js.map
|