@wp-playground/cli 3.1.13 → 3.1.14
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 -14
- package/run-cli-BpNO572W.cjs +66 -0
- package/run-cli-BpNO572W.cjs.map +1 -0
- package/{run-cli-Dka9y1Ev.js → run-cli-CaJWk9j8.js} +269 -269
- package/run-cli-CaJWk9j8.js.map +1 -0
- 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-BZUBWAe5.cjs +0 -66
- package/run-cli-BZUBWAe5.cjs.map +0 -1
- package/run-cli-Dka9y1Ev.js.map +0 -1
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { logger as w, LogSeverity as
|
|
2
|
-
import { consumeAPI as me, ProcessIdAllocator as Te, SupportedPHPVersions as
|
|
3
|
-
import { resolveRemoteBlueprint as
|
|
4
|
-
import { zipDirectory as Le, RecommendedPHPVersion as
|
|
5
|
-
import p, { existsSync as
|
|
1
|
+
import { logger as w, LogSeverity as F, errorLogPath as te } from "@php-wasm/logger";
|
|
2
|
+
import { consumeAPI as me, ProcessIdAllocator as Te, SupportedPHPVersions as U, printDebugDetails as Ie, HttpCookieStore as ke, FileLockManagerInMemory as Me, StreamedPHPResponse as re, createObjectPoolProxy as Ce, exposeAPI as Ae, PHPResponse as Be, exposeSyncAPI as De } from "@php-wasm/universal";
|
|
3
|
+
import { resolveRemoteBlueprint as Re, resolveRuntimeConfiguration as oe, compileBlueprintV1 as fe, isBlueprintBundle as We, runBlueprintV1Steps as se } from "@wp-playground/blueprints";
|
|
4
|
+
import { zipDirectory as Le, RecommendedPHPVersion as D } from "@wp-playground/common";
|
|
5
|
+
import p, { existsSync as G, rmdirSync as _e, mkdirSync as q, readdirSync as Ue } from "fs";
|
|
6
6
|
import { MessageChannel as he, Worker as ie } from "worker_threads";
|
|
7
7
|
import { createNodeFsMountHandler as He } from "@php-wasm/node";
|
|
8
|
-
import d, { basename as
|
|
8
|
+
import d, { basename as _, join as we } from "path";
|
|
9
9
|
import { exec as ye } from "child_process";
|
|
10
10
|
import { promisify as Ne } from "util";
|
|
11
11
|
import be from "express";
|
|
@@ -15,16 +15,16 @@ import je from "yargs";
|
|
|
15
15
|
import { NodeJsFilesystem as Ve, OverlayFilesystem as Ye, InMemoryFilesystem as qe, ZipFilesystem as ze } from "@wp-playground/storage";
|
|
16
16
|
import { EmscriptenDownloadMonitor as Ge, ProgressTracker as Qe } from "@php-wasm/progress";
|
|
17
17
|
import { resolveWordPressRelease as Xe } from "@wp-playground/wordpress";
|
|
18
|
-
import
|
|
18
|
+
import k from "fs-extra";
|
|
19
19
|
import { createRequire as Ze } from "module";
|
|
20
|
-
import
|
|
20
|
+
import Q from "os";
|
|
21
21
|
import { startBridge as Je } from "@php-wasm/xdebug-bridge";
|
|
22
22
|
import { dir as Ke, setGracefulCleanup as et } from "tmp-promise";
|
|
23
23
|
import { removeTempDirSymlink as tt, createTempDirSymlink as ne, makeXdebugConfig as rt, clearXdebugIDEConfig as ot, addXdebugIDEConfig as st } from "@php-wasm/cli-util";
|
|
24
24
|
import { createHash as it } from "crypto";
|
|
25
25
|
import { PHPMYADMIN_INSTALL_PATH as ae, getPhpMyAdminInstallSteps as nt, PHPMYADMIN_ENTRY_PATH as at } from "@wp-playground/tools";
|
|
26
26
|
import { jspi as le } from "wasm-feature-detect";
|
|
27
|
-
function
|
|
27
|
+
function j(e) {
|
|
28
28
|
const t = [];
|
|
29
29
|
for (const r of e) {
|
|
30
30
|
const o = r.split(":");
|
|
@@ -34,7 +34,7 @@ function F(e) {
|
|
|
34
34
|
If your path contains a colon, e.g. C:\\myplugin, use the --mount-dir option instead.
|
|
35
35
|
Example: --mount-dir C:\\my-plugin /wordpress/wp-content/plugins/my-plugin`);
|
|
36
36
|
const [s, i] = o;
|
|
37
|
-
if (!
|
|
37
|
+
if (!G(s))
|
|
38
38
|
throw new Error(`Host path does not exist: ${s}`);
|
|
39
39
|
t.push({ hostPath: s, vfsPath: i });
|
|
40
40
|
}
|
|
@@ -46,7 +46,7 @@ function ue(e) {
|
|
|
46
46
|
const t = [];
|
|
47
47
|
for (let r = 0; r < e.length; r += 2) {
|
|
48
48
|
const o = e[r], s = e[r + 1];
|
|
49
|
-
if (!
|
|
49
|
+
if (!G(o))
|
|
50
50
|
throw new Error(`Host path does not exist: ${o}`);
|
|
51
51
|
t.push({
|
|
52
52
|
hostPath: d.resolve(process.cwd(), o),
|
|
@@ -91,20 +91,20 @@ function ge(e) {
|
|
|
91
91
|
]
|
|
92
92
|
};
|
|
93
93
|
if (ct(t)) {
|
|
94
|
-
const
|
|
94
|
+
const n = `/wordpress/wp-content/plugins/${_(t)}`;
|
|
95
95
|
r.push({
|
|
96
96
|
hostPath: t,
|
|
97
|
-
vfsPath:
|
|
97
|
+
vfsPath: n,
|
|
98
98
|
autoMounted: !0
|
|
99
99
|
}), s["additional-blueprint-steps"].push({
|
|
100
100
|
step: "activatePlugin",
|
|
101
|
-
pluginPath: `/wordpress/wp-content/plugins/${
|
|
101
|
+
pluginPath: `/wordpress/wp-content/plugins/${_(t)}`
|
|
102
102
|
});
|
|
103
103
|
} else if (dt(t)) {
|
|
104
|
-
const i =
|
|
104
|
+
const i = _(t), n = `/wordpress/wp-content/themes/${i}`;
|
|
105
105
|
r.push({
|
|
106
106
|
hostPath: t,
|
|
107
|
-
vfsPath:
|
|
107
|
+
vfsPath: n,
|
|
108
108
|
autoMounted: !0
|
|
109
109
|
}), s["additional-blueprint-steps"].push(
|
|
110
110
|
e["experimental-blueprints-v2-runner"] ? {
|
|
@@ -117,10 +117,10 @@ function ge(e) {
|
|
|
117
117
|
);
|
|
118
118
|
} else if (ut(t)) {
|
|
119
119
|
const i = p.readdirSync(t);
|
|
120
|
-
for (const
|
|
121
|
-
|
|
122
|
-
hostPath: `${t}/${
|
|
123
|
-
vfsPath: `/wordpress/wp-content/${
|
|
120
|
+
for (const n of i)
|
|
121
|
+
n !== "index.php" && r.push({
|
|
122
|
+
hostPath: `${t}/${n}`,
|
|
123
|
+
vfsPath: `/wordpress/wp-content/${n}`,
|
|
124
124
|
autoMounted: !0
|
|
125
125
|
});
|
|
126
126
|
s["additional-blueprint-steps"].push(de);
|
|
@@ -207,18 +207,18 @@ function ft(e) {
|
|
|
207
207
|
return t;
|
|
208
208
|
}
|
|
209
209
|
function ht(e = {}, t = {}, r = {}) {
|
|
210
|
-
const o = {}, s = /* @__PURE__ */ new Set(), i = (
|
|
211
|
-
for (const u in
|
|
210
|
+
const o = {}, s = /* @__PURE__ */ new Set(), i = (n, l) => {
|
|
211
|
+
for (const u in n) {
|
|
212
212
|
if (s.has(u))
|
|
213
213
|
throw new Error(
|
|
214
214
|
`Constant "${u}" is defined multiple times across different --define-${l} flags`
|
|
215
215
|
);
|
|
216
|
-
s.add(u), o[u] =
|
|
216
|
+
s.add(u), o[u] = n[u];
|
|
217
217
|
}
|
|
218
218
|
};
|
|
219
219
|
return i(e, "string"), i(t, "bool"), i(r, "number"), o;
|
|
220
220
|
}
|
|
221
|
-
function
|
|
221
|
+
function X(e) {
|
|
222
222
|
return ht(
|
|
223
223
|
e.define,
|
|
224
224
|
e["define-bool"],
|
|
@@ -237,19 +237,19 @@ function yt(e) {
|
|
|
237
237
|
});
|
|
238
238
|
}
|
|
239
239
|
async function bt(e) {
|
|
240
|
-
const t = be(), r = await new Promise((
|
|
240
|
+
const t = be(), r = await new Promise((n, l) => {
|
|
241
241
|
const u = t.listen(e.port, () => {
|
|
242
242
|
const y = u.address();
|
|
243
|
-
y === null || typeof y == "string" ? l(new Error("Server address is not available")) :
|
|
243
|
+
y === null || typeof y == "string" ? l(new Error("Server address is not available")) : n(u);
|
|
244
244
|
}).once("error", l);
|
|
245
245
|
});
|
|
246
|
-
t.use("/", async (
|
|
246
|
+
t.use("/", async (n, l) => {
|
|
247
247
|
try {
|
|
248
248
|
const u = {
|
|
249
|
-
url:
|
|
250
|
-
headers: St(
|
|
251
|
-
method:
|
|
252
|
-
body: await Pt(
|
|
249
|
+
url: n.url,
|
|
250
|
+
headers: St(n),
|
|
251
|
+
method: n.method,
|
|
252
|
+
body: await Pt(n)
|
|
253
253
|
}, y = await e.handleRequest(u);
|
|
254
254
|
await gt(y, l);
|
|
255
255
|
} catch (u) {
|
|
@@ -312,7 +312,7 @@ async function Et({
|
|
|
312
312
|
if (!e)
|
|
313
313
|
return;
|
|
314
314
|
if (e.startsWith("http://") || e.startsWith("https://"))
|
|
315
|
-
return await
|
|
315
|
+
return await Re(e);
|
|
316
316
|
let r = d.resolve(process.cwd(), e);
|
|
317
317
|
if (!p.existsSync(r))
|
|
318
318
|
throw new Error(`Blueprint file does not exist: ${r}`);
|
|
@@ -336,7 +336,7 @@ async function Et({
|
|
|
336
336
|
`Blueprint file at ${r} is not a valid JSON file`
|
|
337
337
|
);
|
|
338
338
|
}
|
|
339
|
-
const
|
|
339
|
+
const n = d.dirname(r), l = new Ve(n);
|
|
340
340
|
return new Ye([
|
|
341
341
|
new qe({
|
|
342
342
|
"blueprint.json": i
|
|
@@ -400,16 +400,16 @@ class $t {
|
|
|
400
400
|
nativeInternalDirPath: o,
|
|
401
401
|
mountsBeforeWpInstall: this.args["mount-before-install"] || [],
|
|
402
402
|
mountsAfterWpInstall: this.args.mount || [],
|
|
403
|
-
constants:
|
|
403
|
+
constants: X(this.args)
|
|
404
404
|
};
|
|
405
405
|
return await s.bootWorker(i), s;
|
|
406
406
|
}
|
|
407
407
|
}
|
|
408
|
-
const
|
|
408
|
+
const z = d.join(Q.homedir(), ".wordpress-playground");
|
|
409
409
|
async function Tt() {
|
|
410
410
|
const e = typeof __dirname < "u" ? __dirname : import.meta.dirname;
|
|
411
411
|
let t = d.join(e, "sqlite-database-integration.zip");
|
|
412
|
-
if (
|
|
412
|
+
if (!k.existsSync(t)) {
|
|
413
413
|
const r = Ze(import.meta.url), o = d.dirname(
|
|
414
414
|
r.resolve("@wp-playground/wordpress-builds/package.json")
|
|
415
415
|
);
|
|
@@ -420,29 +420,29 @@ async function Tt() {
|
|
|
420
420
|
"sqlite-database-integration-trunk.zip"
|
|
421
421
|
);
|
|
422
422
|
}
|
|
423
|
-
return new File([await
|
|
423
|
+
return new File([await k.readFile(t)], d.basename(t));
|
|
424
424
|
}
|
|
425
425
|
async function It(e, t, r) {
|
|
426
|
-
const o = d.join(
|
|
427
|
-
return
|
|
426
|
+
const o = d.join(z, t);
|
|
427
|
+
return k.existsSync(o) || (k.ensureDirSync(z), await kt(e, o, r)), Pe(o);
|
|
428
428
|
}
|
|
429
429
|
async function kt(e, t, r) {
|
|
430
|
-
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`, n = k.createWriteStream(i);
|
|
431
431
|
for (; ; ) {
|
|
432
432
|
const { done: l, value: u } = await s.read();
|
|
433
|
-
if (u &&
|
|
433
|
+
if (u && n.write(u), l)
|
|
434
434
|
break;
|
|
435
435
|
}
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
}),
|
|
440
|
-
|
|
436
|
+
n.close(), n.closed || await new Promise((l, u) => {
|
|
437
|
+
n.on("finish", () => {
|
|
438
|
+
k.renameSync(i, t), l(null);
|
|
439
|
+
}), n.on("error", (y) => {
|
|
440
|
+
k.removeSync(i), u(y);
|
|
441
441
|
});
|
|
442
442
|
});
|
|
443
443
|
}
|
|
444
444
|
function Pe(e, t) {
|
|
445
|
-
return new File([
|
|
445
|
+
return new File([k.readFileSync(e)], _(e));
|
|
446
446
|
}
|
|
447
447
|
class Mt {
|
|
448
448
|
constructor(t, r) {
|
|
@@ -453,26 +453,26 @@ class Mt {
|
|
|
453
453
|
}
|
|
454
454
|
async bootWordPress(t, r) {
|
|
455
455
|
let o, s, i;
|
|
456
|
-
const
|
|
456
|
+
const n = new Ge();
|
|
457
457
|
if (this.args.wordpressInstallMode === "download-and-install") {
|
|
458
458
|
let y = !1;
|
|
459
|
-
|
|
459
|
+
n.addEventListener("progress", (M) => {
|
|
460
460
|
if (y)
|
|
461
461
|
return;
|
|
462
|
-
const { loaded: c, total:
|
|
463
|
-
Math.min(100, 100 * c /
|
|
462
|
+
const { loaded: c, total: x } = M.detail, h = Math.floor(
|
|
463
|
+
Math.min(100, 100 * c / x)
|
|
464
464
|
);
|
|
465
|
-
y =
|
|
465
|
+
y = h === 100, this.cliOutput.updateProgress(
|
|
466
466
|
"Downloading WordPress",
|
|
467
|
-
|
|
467
|
+
h
|
|
468
468
|
);
|
|
469
469
|
}), o = await Xe(this.args.wp), i = d.join(
|
|
470
|
-
|
|
470
|
+
z,
|
|
471
471
|
`prebuilt-wp-content-for-wp-${o.version}.zip`
|
|
472
472
|
), s = p.existsSync(i) ? Pe(i) : await It(
|
|
473
473
|
o.releaseUrl,
|
|
474
474
|
`${o.version}.zip`,
|
|
475
|
-
|
|
475
|
+
n
|
|
476
476
|
), w.debug(
|
|
477
477
|
`Resolved WordPress release URL: ${o?.releaseUrl}`
|
|
478
478
|
);
|
|
@@ -489,7 +489,7 @@ class Mt {
|
|
|
489
489
|
wordpressInstallMode: this.args.wordpressInstallMode || "download-and-install",
|
|
490
490
|
wordPressZip: s && await s.arrayBuffer(),
|
|
491
491
|
sqliteIntegrationPluginZip: await l?.arrayBuffer(),
|
|
492
|
-
constants:
|
|
492
|
+
constants: X(this.args)
|
|
493
493
|
},
|
|
494
494
|
r
|
|
495
495
|
), i && !this.args["mount-before-install"] && !p.existsSync(i) && (this.cliOutput.updateProgress("Caching WordPress for next boot"), p.writeFileSync(
|
|
@@ -533,12 +533,12 @@ class Mt {
|
|
|
533
533
|
async compileInputBlueprint(t) {
|
|
534
534
|
const r = this.getEffectiveBlueprint(), o = new Qe();
|
|
535
535
|
let s = "", i = !1;
|
|
536
|
-
return o.addEventListener("progress", (
|
|
536
|
+
return o.addEventListener("progress", (n) => {
|
|
537
537
|
if (i)
|
|
538
538
|
return;
|
|
539
|
-
i =
|
|
540
|
-
const l = Math.floor(
|
|
541
|
-
s =
|
|
539
|
+
i = n.detail.progress === 100;
|
|
540
|
+
const l = Math.floor(n.detail.progress);
|
|
541
|
+
s = n.detail.caption || s || "Running Blueprint", this.cliOutput.updateProgress(s.trim(), l);
|
|
542
542
|
}), await fe(r, {
|
|
543
543
|
progress: o,
|
|
544
544
|
additionalSteps: t
|
|
@@ -550,7 +550,7 @@ class Mt {
|
|
|
550
550
|
login: this.args.login,
|
|
551
551
|
...t || {},
|
|
552
552
|
preferredVersions: {
|
|
553
|
-
php: this.args.php ?? t?.preferredVersions?.php ??
|
|
553
|
+
php: this.args.php ?? t?.preferredVersions?.php ?? D,
|
|
554
554
|
wp: this.args.wp ?? t?.preferredVersions?.wp ?? "latest",
|
|
555
555
|
...t?.preferredVersions || {}
|
|
556
556
|
}
|
|
@@ -578,14 +578,14 @@ async function At(e, t, r) {
|
|
|
578
578
|
t,
|
|
579
579
|
r
|
|
580
580
|
)).map(
|
|
581
|
-
(i) => new Promise((
|
|
581
|
+
(i) => new Promise((n) => {
|
|
582
582
|
p.rm(i, { recursive: !0 }, (l) => {
|
|
583
583
|
l ? w.warn(
|
|
584
584
|
`Failed to delete stale Playground temp dir: ${i}`,
|
|
585
585
|
l
|
|
586
586
|
) : w.info(
|
|
587
587
|
`Deleted stale Playground temp dir: ${i}`
|
|
588
|
-
),
|
|
588
|
+
), n();
|
|
589
589
|
});
|
|
590
590
|
})
|
|
591
591
|
);
|
|
@@ -595,7 +595,7 @@ async function Bt(e, t, r) {
|
|
|
595
595
|
try {
|
|
596
596
|
const o = p.readdirSync(r).map((i) => d.join(r, i)), s = [];
|
|
597
597
|
for (const i of o)
|
|
598
|
-
await
|
|
598
|
+
await Dt(
|
|
599
599
|
e,
|
|
600
600
|
t,
|
|
601
601
|
i
|
|
@@ -605,7 +605,7 @@ async function Bt(e, t, r) {
|
|
|
605
605
|
return w.warn(`Failed to find stale Playground temp dirs: ${o}`), [];
|
|
606
606
|
}
|
|
607
607
|
}
|
|
608
|
-
async function
|
|
608
|
+
async function Dt(e, t, r) {
|
|
609
609
|
if (!p.lstatSync(r).isDirectory())
|
|
610
610
|
return !1;
|
|
611
611
|
const s = d.basename(r);
|
|
@@ -616,16 +616,16 @@ async function Rt(e, t, r) {
|
|
|
616
616
|
);
|
|
617
617
|
if (!i)
|
|
618
618
|
return !1;
|
|
619
|
-
const
|
|
619
|
+
const n = {
|
|
620
620
|
executableName: i[1],
|
|
621
621
|
pid: i[2]
|
|
622
622
|
};
|
|
623
|
-
if (
|
|
623
|
+
if (Rt(n.pid))
|
|
624
624
|
return !1;
|
|
625
625
|
const l = Date.now() - t;
|
|
626
626
|
return p.statSync(r).mtime.getTime() < l;
|
|
627
627
|
}
|
|
628
|
-
function
|
|
628
|
+
function Rt(e, t) {
|
|
629
629
|
try {
|
|
630
630
|
return process.kill(Number(e), 0), !0;
|
|
631
631
|
} catch (r) {
|
|
@@ -805,10 +805,10 @@ ${this.green("Ready!")} WordPress is running on ${this.bold(t)} ${this.dim(`(${r
|
|
|
805
805
|
);
|
|
806
806
|
}
|
|
807
807
|
}
|
|
808
|
-
const
|
|
809
|
-
Quiet: { name: "quiet", severity:
|
|
810
|
-
Normal: { name: "normal", severity:
|
|
811
|
-
Debug: { name: "debug", severity:
|
|
808
|
+
const Z = {
|
|
809
|
+
Quiet: { name: "quiet", severity: F.Fatal },
|
|
810
|
+
Normal: { name: "normal", severity: F.Info },
|
|
811
|
+
Debug: { name: "debug", severity: F.Debug }
|
|
812
812
|
};
|
|
813
813
|
async function _t(e) {
|
|
814
814
|
try {
|
|
@@ -820,8 +820,8 @@ async function _t(e) {
|
|
|
820
820
|
php: {
|
|
821
821
|
describe: "PHP version to use.",
|
|
822
822
|
type: "string",
|
|
823
|
-
default:
|
|
824
|
-
choices:
|
|
823
|
+
default: D,
|
|
824
|
+
choices: U
|
|
825
825
|
},
|
|
826
826
|
wp: {
|
|
827
827
|
describe: "WordPress version to use.",
|
|
@@ -856,14 +856,14 @@ async function _t(e) {
|
|
|
856
856
|
type: "array",
|
|
857
857
|
string: !0,
|
|
858
858
|
nargs: 1,
|
|
859
|
-
coerce:
|
|
859
|
+
coerce: j
|
|
860
860
|
},
|
|
861
861
|
"mount-before-install": {
|
|
862
862
|
describe: "Mount a directory to the PHP runtime before WordPress installation (can be used multiple times). Format: /host/path:/vfs/path",
|
|
863
863
|
type: "array",
|
|
864
864
|
string: !0,
|
|
865
865
|
nargs: 1,
|
|
866
|
-
coerce:
|
|
866
|
+
coerce: j
|
|
867
867
|
},
|
|
868
868
|
"mount-dir": {
|
|
869
869
|
describe: 'Mount a directory to the PHP runtime (can be used multiple times). Format: "/host/path" "/vfs/path"',
|
|
@@ -924,8 +924,8 @@ async function _t(e) {
|
|
|
924
924
|
verbosity: {
|
|
925
925
|
describe: "Output logs and progress messages.",
|
|
926
926
|
type: "string",
|
|
927
|
-
choices: Object.values(
|
|
928
|
-
(
|
|
927
|
+
choices: Object.values(Z).map(
|
|
928
|
+
(a) => a.name
|
|
929
929
|
),
|
|
930
930
|
default: "normal"
|
|
931
931
|
},
|
|
@@ -985,7 +985,7 @@ Warning: Following symlinks will expose files outside mounted directories to Pla
|
|
|
985
985
|
// supported IDEs and, if needed, will create the relevant
|
|
986
986
|
// config file for each.
|
|
987
987
|
choices: ["", "vscode", "phpstorm"],
|
|
988
|
-
coerce: (
|
|
988
|
+
coerce: (a) => a === "" ? ["vscode", "phpstorm"] : [a]
|
|
989
989
|
},
|
|
990
990
|
"experimental-blueprints-v2-runner": {
|
|
991
991
|
describe: "Use the experimental Blueprint V2 runner.",
|
|
@@ -1004,7 +1004,7 @@ Warning: Following symlinks will expose files outside mounted directories to Pla
|
|
|
1004
1004
|
phpmyadmin: {
|
|
1005
1005
|
describe: "Install phpMyAdmin for database management. The phpMyAdmin URL will be printed after boot. Optionally specify a custom URL path (default: /phpmyadmin).",
|
|
1006
1006
|
type: "string",
|
|
1007
|
-
coerce: (
|
|
1007
|
+
coerce: (a) => a === "" ? "/phpmyadmin" : a
|
|
1008
1008
|
}
|
|
1009
1009
|
}, r = {
|
|
1010
1010
|
port: {
|
|
@@ -1029,8 +1029,8 @@ Warning: Following symlinks will expose files outside mounted directories to Pla
|
|
|
1029
1029
|
php: {
|
|
1030
1030
|
describe: "PHP version to use.",
|
|
1031
1031
|
type: "string",
|
|
1032
|
-
default:
|
|
1033
|
-
choices:
|
|
1032
|
+
default: D,
|
|
1033
|
+
choices: U
|
|
1034
1034
|
},
|
|
1035
1035
|
wp: {
|
|
1036
1036
|
describe: "WordPress version to use.",
|
|
@@ -1075,7 +1075,7 @@ Warning: Following symlinks will expose files outside mounted directories to Pla
|
|
|
1075
1075
|
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.",
|
|
1076
1076
|
type: "array",
|
|
1077
1077
|
string: !0,
|
|
1078
|
-
coerce:
|
|
1078
|
+
coerce: j
|
|
1079
1079
|
},
|
|
1080
1080
|
reset: {
|
|
1081
1081
|
describe: "Deletes the stored site directory and starts a new site from scratch.",
|
|
@@ -1102,7 +1102,7 @@ Warning: Following symlinks will expose files outside mounted directories to Pla
|
|
|
1102
1102
|
}, i = je(e).usage("Usage: wp-playground <command> [options]").command(
|
|
1103
1103
|
"start",
|
|
1104
1104
|
"Start a local WordPress server with automatic project detection (recommended)",
|
|
1105
|
-
(
|
|
1105
|
+
(a) => a.usage(
|
|
1106
1106
|
`Usage: wp-playground start [options]
|
|
1107
1107
|
|
|
1108
1108
|
The easiest way to run WordPress locally. Automatically detects
|
|
@@ -1119,77 +1119,77 @@ Examples:
|
|
|
1119
1119
|
).command(
|
|
1120
1120
|
"server",
|
|
1121
1121
|
"Start a local WordPress server (advanced, low-level)",
|
|
1122
|
-
(
|
|
1122
|
+
(a) => a.options({
|
|
1123
1123
|
...t,
|
|
1124
1124
|
...r
|
|
1125
1125
|
})
|
|
1126
1126
|
).command(
|
|
1127
1127
|
"run-blueprint",
|
|
1128
1128
|
"Execute a Blueprint without starting a server",
|
|
1129
|
-
(
|
|
1129
|
+
(a) => a.options({ ...t })
|
|
1130
1130
|
).command(
|
|
1131
1131
|
"build-snapshot",
|
|
1132
1132
|
"Build a ZIP snapshot of a WordPress site based on a Blueprint",
|
|
1133
|
-
(
|
|
1133
|
+
(a) => a.options({
|
|
1134
1134
|
...t,
|
|
1135
1135
|
...s
|
|
1136
1136
|
})
|
|
1137
1137
|
).command(
|
|
1138
1138
|
"php",
|
|
1139
1139
|
"Run a PHP script",
|
|
1140
|
-
(
|
|
1140
|
+
(a) => a.options({ ...t })
|
|
1141
1141
|
).demandCommand(1, "Please specify a command").strictCommands().conflicts(
|
|
1142
1142
|
"experimental-unsafe-ide-integration",
|
|
1143
1143
|
"experimental-devtools"
|
|
1144
|
-
).showHelpOnFail(!1).fail((
|
|
1145
|
-
if (
|
|
1146
|
-
throw
|
|
1147
|
-
|
|
1148
|
-
` +
|
|
1149
|
-
}).strictOptions().check(async (
|
|
1150
|
-
if (
|
|
1144
|
+
).showHelpOnFail(!1).fail((a, E, P) => {
|
|
1145
|
+
if (E)
|
|
1146
|
+
throw E;
|
|
1147
|
+
a && a.includes("Please specify a command") && (P.showHelp(), console.error(`
|
|
1148
|
+
` + a), process.exit(1)), console.error(a), process.exit(1);
|
|
1149
|
+
}).strictOptions().check(async (a) => {
|
|
1150
|
+
if (a["skip-wordpress-install"] === !0 && (a["wordpress-install-mode"] = "do-not-attempt-installing", a.wordpressInstallMode = "do-not-attempt-installing"), a.wp !== void 0 && typeof a.wp == "string" && !xt(a.wp))
|
|
1151
1151
|
try {
|
|
1152
|
-
new URL(
|
|
1152
|
+
new URL(a.wp);
|
|
1153
1153
|
} catch {
|
|
1154
1154
|
throw new Error(
|
|
1155
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"'
|
|
1156
1156
|
);
|
|
1157
1157
|
}
|
|
1158
|
-
const
|
|
1159
|
-
if (typeof
|
|
1158
|
+
const E = a["site-url"];
|
|
1159
|
+
if (typeof E == "string" && E.trim() !== "")
|
|
1160
1160
|
try {
|
|
1161
|
-
new URL(
|
|
1161
|
+
new URL(E);
|
|
1162
1162
|
} catch {
|
|
1163
1163
|
throw new Error(
|
|
1164
|
-
`Invalid site-url "${
|
|
1164
|
+
`Invalid site-url "${E}". Please provide a valid URL (e.g., http://localhost:8080 or https://example.com)`
|
|
1165
1165
|
);
|
|
1166
1166
|
}
|
|
1167
|
-
if (
|
|
1168
|
-
let
|
|
1167
|
+
if (a["auto-mount"]) {
|
|
1168
|
+
let P = !1;
|
|
1169
1169
|
try {
|
|
1170
|
-
|
|
1171
|
-
|
|
1170
|
+
P = p.statSync(
|
|
1171
|
+
a["auto-mount"]
|
|
1172
1172
|
).isDirectory();
|
|
1173
1173
|
} catch {
|
|
1174
|
-
|
|
1174
|
+
P = !1;
|
|
1175
1175
|
}
|
|
1176
|
-
if (!
|
|
1176
|
+
if (!P)
|
|
1177
1177
|
throw new Error(
|
|
1178
|
-
`The specified --auto-mount path is not a directory: '${
|
|
1178
|
+
`The specified --auto-mount path is not a directory: '${a["auto-mount"]}'.`
|
|
1179
1179
|
);
|
|
1180
1180
|
}
|
|
1181
|
-
if (
|
|
1181
|
+
if (a["experimental-blueprints-v2-runner"] === !0)
|
|
1182
1182
|
throw new Error(
|
|
1183
1183
|
"Blueprints v2 are temporarily disabled while we rework their runtime implementation."
|
|
1184
1184
|
);
|
|
1185
|
-
if (
|
|
1185
|
+
if (a.mode !== void 0)
|
|
1186
1186
|
throw new Error(
|
|
1187
1187
|
"The --mode option requires the --experimentalBlueprintsV2Runner flag."
|
|
1188
1188
|
);
|
|
1189
1189
|
return !0;
|
|
1190
1190
|
});
|
|
1191
1191
|
i.wrap(i.terminalWidth());
|
|
1192
|
-
const
|
|
1192
|
+
const n = await i.argv, l = n._[0];
|
|
1193
1193
|
[
|
|
1194
1194
|
"start",
|
|
1195
1195
|
"run-blueprint",
|
|
@@ -1197,33 +1197,33 @@ Examples:
|
|
|
1197
1197
|
"build-snapshot",
|
|
1198
1198
|
"php"
|
|
1199
1199
|
].includes(l) || (i.showHelp(), process.exit(1));
|
|
1200
|
-
const u =
|
|
1201
|
-
|
|
1202
|
-
const
|
|
1203
|
-
...
|
|
1200
|
+
const u = n.define || {}, y = n["define-bool"] || {}, M = n["define-number"] || {}, c = (a) => a in u || a in y || a in M;
|
|
1201
|
+
c("WP_DEBUG") || (u.WP_DEBUG = "true"), c("WP_DEBUG_LOG") || (u.WP_DEBUG_LOG = "true"), c("WP_DEBUG_DISPLAY") || (u.WP_DEBUG_DISPLAY = "false");
|
|
1202
|
+
const x = {
|
|
1203
|
+
...n,
|
|
1204
1204
|
define: u,
|
|
1205
1205
|
command: l,
|
|
1206
1206
|
mount: [
|
|
1207
|
-
...
|
|
1208
|
-
...
|
|
1207
|
+
...n.mount || [],
|
|
1208
|
+
...n["mount-dir"] || []
|
|
1209
1209
|
],
|
|
1210
1210
|
"mount-before-install": [
|
|
1211
|
-
...
|
|
1212
|
-
...
|
|
1211
|
+
...n["mount-before-install"] || [],
|
|
1212
|
+
...n["mount-dir-before-install"] || []
|
|
1213
1213
|
]
|
|
1214
|
-
},
|
|
1215
|
-
|
|
1216
|
-
const
|
|
1217
|
-
let
|
|
1214
|
+
}, h = await ve(x);
|
|
1215
|
+
h === void 0 && process.exit(0);
|
|
1216
|
+
const T = /* @__PURE__ */ (() => {
|
|
1217
|
+
let a;
|
|
1218
1218
|
return async () => {
|
|
1219
|
-
|
|
1219
|
+
a === void 0 && (a = h[Symbol.asyncDispose]()), await a, process.exit(0);
|
|
1220
1220
|
};
|
|
1221
1221
|
})();
|
|
1222
|
-
return process.on("SIGINT",
|
|
1222
|
+
return process.on("SIGINT", T), process.on("SIGTERM", T), {
|
|
1223
1223
|
[Symbol.asyncDispose]: async () => {
|
|
1224
|
-
process.off("SIGINT",
|
|
1224
|
+
process.off("SIGINT", T), process.off("SIGTERM", T), await h[Symbol.asyncDispose]();
|
|
1225
1225
|
},
|
|
1226
|
-
[
|
|
1226
|
+
[J]: { cliServer: h }
|
|
1227
1227
|
};
|
|
1228
1228
|
} catch (t) {
|
|
1229
1229
|
if (console.error(t), !(t instanceof Error))
|
|
@@ -1248,13 +1248,13 @@ function ce(e, t) {
|
|
|
1248
1248
|
(r) => r.vfsPath.replace(/\/$/, "") === t.replace(/\/$/, "")
|
|
1249
1249
|
);
|
|
1250
1250
|
}
|
|
1251
|
-
const
|
|
1251
|
+
const J = Symbol("playground-cli-testing"), C = (e) => process.stdout.isTTY ? "\x1B[1m" + e + "\x1B[0m" : e, Ut = (e) => process.stdout.isTTY ? "\x1B[31m" + e + "\x1B[0m" : e, pe = (e) => process.stdout.isTTY ? `\x1B[2m${e}\x1B[0m` : e, L = (e) => process.stdout.isTTY ? `\x1B[3m${e}\x1B[0m` : e, V = (e) => process.stdout.isTTY ? `\x1B[33m${e}\x1B[0m` : e;
|
|
1252
1252
|
async function ve(e) {
|
|
1253
1253
|
let t;
|
|
1254
1254
|
const r = e.internalCookieStore ? new ke() : void 0, o = [], s = /* @__PURE__ */ new Map();
|
|
1255
1255
|
if (e.command === "start" && (e = Ht(e)), e.autoMount !== void 0 && (e.autoMount === "" && (e = { ...e, autoMount: process.cwd() }), e = ge(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(
|
|
1257
|
-
(
|
|
1256
|
+
const c = Object.values(Z).find(
|
|
1257
|
+
(x) => x.name === e.verbosity
|
|
1258
1258
|
).severity;
|
|
1259
1259
|
w.setSeverityFilterLevel(c);
|
|
1260
1260
|
}
|
|
@@ -1268,7 +1268,7 @@ async function ve(e) {
|
|
|
1268
1268
|
verbosity: e.verbosity || "normal"
|
|
1269
1269
|
});
|
|
1270
1270
|
e.command === "server" && (i.printBanner(), i.printConfig({
|
|
1271
|
-
phpVersion: e.php ||
|
|
1271
|
+
phpVersion: e.php || D,
|
|
1272
1272
|
wpVersion: e.wp || "latest",
|
|
1273
1273
|
port: e.port ?? 9400,
|
|
1274
1274
|
xdebug: !!e.xdebug,
|
|
@@ -1281,30 +1281,30 @@ async function ve(e) {
|
|
|
1281
1281
|
],
|
|
1282
1282
|
blueprint: typeof e.blueprint == "string" ? e.blueprint : void 0
|
|
1283
1283
|
}));
|
|
1284
|
-
const
|
|
1284
|
+
const n = e.command === "server" ? e.port ?? 9400 : 0, l = new Me();
|
|
1285
1285
|
let u = !1, y = !0;
|
|
1286
|
-
const
|
|
1287
|
-
port: e.port ? e.port : await yt(
|
|
1288
|
-
onBind: async (c,
|
|
1289
|
-
const
|
|
1290
|
-
w.debug(`Native temp dir for VFS root: ${
|
|
1291
|
-
const
|
|
1292
|
-
if (await tt(
|
|
1293
|
-
const
|
|
1286
|
+
const M = await bt({
|
|
1287
|
+
port: e.port ? e.port : await yt(n) ? 0 : n,
|
|
1288
|
+
onBind: async (c, x) => {
|
|
1289
|
+
const h = "127.0.0.1", T = `http://${h}:${x}`, a = e["site-url"] || T, E = 6, P = "-playground-cli-site-", I = await Ct(P);
|
|
1290
|
+
w.debug(`Native temp dir for VFS root: ${I.path}`);
|
|
1291
|
+
const R = "WP Playground CLI - Listen for Xdebug", K = ".playground-xdebug-root", H = d.join(process.cwd(), K);
|
|
1292
|
+
if (await tt(H), e.xdebug) {
|
|
1293
|
+
const m = {
|
|
1294
1294
|
hostPath: d.join(".", d.sep, K),
|
|
1295
1295
|
vfsPath: "/"
|
|
1296
1296
|
};
|
|
1297
|
-
if (
|
|
1298
|
-
e.php ||
|
|
1299
|
-
) <=
|
|
1297
|
+
if (U.indexOf(
|
|
1298
|
+
e.php || D
|
|
1299
|
+
) <= U.indexOf("8.5"))
|
|
1300
1300
|
await ne(
|
|
1301
|
-
|
|
1302
|
-
|
|
1301
|
+
I.path,
|
|
1302
|
+
H,
|
|
1303
1303
|
process.platform
|
|
1304
1304
|
), e.xdebug = rt({
|
|
1305
1305
|
cwd: process.cwd(),
|
|
1306
1306
|
mounts: [
|
|
1307
|
-
|
|
1307
|
+
m,
|
|
1308
1308
|
...e["mount-before-install"] || [],
|
|
1309
1309
|
...e.mount || []
|
|
1310
1310
|
],
|
|
@@ -1315,8 +1315,8 @@ async function ve(e) {
|
|
|
1315
1315
|
"/request/",
|
|
1316
1316
|
"/proc/"
|
|
1317
1317
|
]
|
|
1318
|
-
}), console.log(
|
|
1319
|
-
|
|
1318
|
+
}), console.log(C("Xdebug configured successfully")), console.log(
|
|
1319
|
+
V("Playground source root: ") + ".playground-xdebug-root" + L(
|
|
1320
1320
|
pe(
|
|
1321
1321
|
" – you can set breakpoints and preview Playground's VFS structure in there."
|
|
1322
1322
|
)
|
|
@@ -1324,63 +1324,63 @@ async function ve(e) {
|
|
|
1324
1324
|
);
|
|
1325
1325
|
else if (e.experimentalUnsafeIdeIntegration) {
|
|
1326
1326
|
await ne(
|
|
1327
|
-
|
|
1328
|
-
|
|
1327
|
+
I.path,
|
|
1328
|
+
H,
|
|
1329
1329
|
process.platform
|
|
1330
1330
|
);
|
|
1331
1331
|
try {
|
|
1332
1332
|
await ot(
|
|
1333
|
-
|
|
1333
|
+
R,
|
|
1334
1334
|
process.cwd()
|
|
1335
1335
|
);
|
|
1336
|
-
const
|
|
1337
|
-
name:
|
|
1338
|
-
host:
|
|
1339
|
-
port:
|
|
1336
|
+
const f = typeof e.xdebug == "object" ? e.xdebug : {}, b = await st({
|
|
1337
|
+
name: R,
|
|
1338
|
+
host: h,
|
|
1339
|
+
port: x,
|
|
1340
1340
|
ides: e.experimentalUnsafeIdeIntegration,
|
|
1341
1341
|
cwd: process.cwd(),
|
|
1342
1342
|
mounts: [
|
|
1343
|
-
|
|
1343
|
+
m,
|
|
1344
1344
|
...e["mount-before-install"] || [],
|
|
1345
1345
|
...e.mount || []
|
|
1346
1346
|
],
|
|
1347
|
-
ideKey:
|
|
1348
|
-
}), v = e.experimentalUnsafeIdeIntegration, S = v.includes("vscode"),
|
|
1349
|
-
console.log(""),
|
|
1350
|
-
|
|
1347
|
+
ideKey: f.ideKey || "WPPLAYGROUNDCLI"
|
|
1348
|
+
}), v = e.experimentalUnsafeIdeIntegration, S = v.includes("vscode"), $ = v.includes("phpstorm"), W = Object.values(b);
|
|
1349
|
+
console.log(""), W.length > 0 ? (console.log(
|
|
1350
|
+
C("Xdebug configured successfully")
|
|
1351
1351
|
), console.log(
|
|
1352
|
-
|
|
1352
|
+
V("Updated IDE config: ") + W.join(" ")
|
|
1353
1353
|
), console.log(
|
|
1354
|
-
|
|
1354
|
+
V("Playground source root: ") + ".playground-xdebug-root" + L(
|
|
1355
1355
|
pe(
|
|
1356
1356
|
" – you can set breakpoints and preview Playground's VFS structure in there."
|
|
1357
1357
|
)
|
|
1358
1358
|
)
|
|
1359
1359
|
)) : (console.log(
|
|
1360
|
-
|
|
1360
|
+
C("Xdebug configuration failed.")
|
|
1361
1361
|
), console.log(
|
|
1362
1362
|
"No IDE-specific project settings directory was found in the current working directory."
|
|
1363
|
-
)), console.log(""), S &&
|
|
1364
|
-
|
|
1363
|
+
)), console.log(""), S && b.vscode && (console.log(
|
|
1364
|
+
C("VS Code / Cursor instructions:")
|
|
1365
1365
|
), console.log(
|
|
1366
1366
|
" 1. Ensure you have installed an IDE extension for PHP Debugging"
|
|
1367
1367
|
), console.log(
|
|
1368
|
-
` (The ${
|
|
1368
|
+
` (The ${C("PHP Debug")} extension by ${C(
|
|
1369
1369
|
"Xdebug"
|
|
1370
1370
|
)} has been a solid option)`
|
|
1371
1371
|
), console.log(
|
|
1372
1372
|
" 2. Open the Run and Debug panel on the left sidebar"
|
|
1373
1373
|
), console.log(
|
|
1374
|
-
` 3. Select "${
|
|
1375
|
-
|
|
1374
|
+
` 3. Select "${L(
|
|
1375
|
+
R
|
|
1376
1376
|
)}" from the dropdown`
|
|
1377
1377
|
), console.log(' 3. Click "start debugging"'), console.log(
|
|
1378
1378
|
" 5. Set a breakpoint. For example, in .playground-xdebug-root/wordpress/index.php"
|
|
1379
1379
|
), console.log(
|
|
1380
1380
|
" 6. Visit Playground in your browser to hit the breakpoint"
|
|
1381
|
-
),
|
|
1382
|
-
` 1. Choose "${
|
|
1383
|
-
|
|
1381
|
+
), $ && console.log("")), $ && b.phpstorm && (console.log(C("PhpStorm instructions:")), console.log(
|
|
1382
|
+
` 1. Choose "${L(
|
|
1383
|
+
R
|
|
1384
1384
|
)}" debug configuration in the toolbar`
|
|
1385
1385
|
), console.log(
|
|
1386
1386
|
" 2. Click the debug button (bug icon)`"
|
|
@@ -1389,21 +1389,21 @@ async function ve(e) {
|
|
|
1389
1389
|
), console.log(
|
|
1390
1390
|
" 4. Visit Playground in your browser to hit the breakpoint"
|
|
1391
1391
|
)), console.log("");
|
|
1392
|
-
} catch (
|
|
1392
|
+
} catch (f) {
|
|
1393
1393
|
throw new Error("Could not configure Xdebug", {
|
|
1394
|
-
cause:
|
|
1394
|
+
cause: f
|
|
1395
1395
|
});
|
|
1396
1396
|
}
|
|
1397
1397
|
}
|
|
1398
1398
|
}
|
|
1399
|
-
const xe = d.dirname(
|
|
1399
|
+
const xe = d.dirname(I.path), Ee = 2 * 24 * 60 * 60 * 1e3;
|
|
1400
1400
|
At(
|
|
1401
|
-
|
|
1401
|
+
P,
|
|
1402
1402
|
Ee,
|
|
1403
1403
|
xe
|
|
1404
1404
|
);
|
|
1405
|
-
const ee = d.join(
|
|
1406
|
-
|
|
1405
|
+
const ee = d.join(I.path, "internal");
|
|
1406
|
+
q(ee);
|
|
1407
1407
|
const $e = [
|
|
1408
1408
|
"wordpress",
|
|
1409
1409
|
"tools",
|
|
@@ -1416,83 +1416,83 @@ async function ve(e) {
|
|
|
1416
1416
|
"tmp",
|
|
1417
1417
|
"home"
|
|
1418
1418
|
];
|
|
1419
|
-
for (const
|
|
1420
|
-
const
|
|
1421
|
-
if (!(e["mount-before-install"]?.some(
|
|
1422
|
-
const
|
|
1423
|
-
|
|
1424
|
-
|
|
1419
|
+
for (const m of $e) {
|
|
1420
|
+
const g = (b) => b.vfsPath === `/${m}`;
|
|
1421
|
+
if (!(e["mount-before-install"]?.some(g) || e.mount?.some(g))) {
|
|
1422
|
+
const b = d.join(
|
|
1423
|
+
I.path,
|
|
1424
|
+
m
|
|
1425
1425
|
);
|
|
1426
|
-
|
|
1427
|
-
vfsPath: `/${
|
|
1428
|
-
hostPath:
|
|
1426
|
+
q(b), e["mount-before-install"] === void 0 && (e["mount-before-install"] = []), e["mount-before-install"].unshift({
|
|
1427
|
+
vfsPath: `/${m}`,
|
|
1428
|
+
hostPath: b
|
|
1429
1429
|
});
|
|
1430
1430
|
}
|
|
1431
1431
|
}
|
|
1432
1432
|
if (e["mount-before-install"])
|
|
1433
|
-
for (const
|
|
1433
|
+
for (const m of e["mount-before-install"])
|
|
1434
1434
|
w.debug(
|
|
1435
|
-
`Mount before WP install: ${
|
|
1435
|
+
`Mount before WP install: ${m.vfsPath} -> ${m.hostPath}`
|
|
1436
1436
|
);
|
|
1437
1437
|
if (e.mount)
|
|
1438
|
-
for (const
|
|
1438
|
+
for (const m of e.mount)
|
|
1439
1439
|
w.debug(
|
|
1440
|
-
`Mount after WP install: ${
|
|
1440
|
+
`Mount after WP install: ${m.vfsPath} -> ${m.hostPath}`
|
|
1441
1441
|
);
|
|
1442
|
-
let
|
|
1443
|
-
e["experimental-blueprints-v2-runner"] ?
|
|
1444
|
-
siteUrl:
|
|
1442
|
+
let A;
|
|
1443
|
+
e["experimental-blueprints-v2-runner"] ? A = new $t(e, {
|
|
1444
|
+
siteUrl: a,
|
|
1445
1445
|
cliOutput: i
|
|
1446
|
-
}) : (
|
|
1447
|
-
siteUrl:
|
|
1446
|
+
}) : (A = new Mt(e, {
|
|
1447
|
+
siteUrl: a,
|
|
1448
1448
|
cliOutput: i
|
|
1449
1449
|
}), typeof e.blueprint == "string" && (e.blueprint = await Et({
|
|
1450
1450
|
sourceString: e.blueprint,
|
|
1451
1451
|
blueprintMayReadAdjacentFiles: e["blueprint-may-read-adjacent-files"] === !0
|
|
1452
1452
|
})));
|
|
1453
|
-
let
|
|
1454
|
-
const
|
|
1455
|
-
|
|
1456
|
-
o.map(async (
|
|
1457
|
-
await s.get(
|
|
1453
|
+
let N = !1;
|
|
1454
|
+
const B = async function() {
|
|
1455
|
+
N || (N = !0, await Promise.all(
|
|
1456
|
+
o.map(async (g) => {
|
|
1457
|
+
await s.get(g)?.dispose(), await g.worker.terminate();
|
|
1458
1458
|
})
|
|
1459
|
-
), c && await new Promise((
|
|
1460
|
-
c.close(
|
|
1461
|
-
}), await
|
|
1459
|
+
), c && await new Promise((g) => {
|
|
1460
|
+
c.close(g), c.closeAllConnections();
|
|
1461
|
+
}), await I.cleanup());
|
|
1462
1462
|
};
|
|
1463
1463
|
try {
|
|
1464
|
-
const
|
|
1465
|
-
for (let
|
|
1466
|
-
const
|
|
1464
|
+
const m = [], g = A.getWorkerType();
|
|
1465
|
+
for (let f = 0; f < E; f++) {
|
|
1466
|
+
const b = Se(g, {
|
|
1467
1467
|
onExit: (v) => {
|
|
1468
|
-
|
|
1469
|
-
`Worker ${
|
|
1468
|
+
N || v === 0 && w.error(
|
|
1469
|
+
`Worker ${f} exited with code ${v}
|
|
1470
1470
|
`
|
|
1471
1471
|
);
|
|
1472
1472
|
}
|
|
1473
1473
|
}).then(
|
|
1474
1474
|
async (v) => {
|
|
1475
1475
|
o.push(v);
|
|
1476
|
-
const S = await Nt(l),
|
|
1476
|
+
const S = await Nt(l), $ = await A.bootRequestHandler({
|
|
1477
1477
|
worker: v,
|
|
1478
1478
|
fileLockManagerPort: S,
|
|
1479
1479
|
nativeInternalDirPath: ee
|
|
1480
1480
|
});
|
|
1481
1481
|
return s.set(
|
|
1482
1482
|
v,
|
|
1483
|
-
|
|
1484
|
-
), [v,
|
|
1483
|
+
$
|
|
1484
|
+
), [v, $];
|
|
1485
1485
|
}
|
|
1486
1486
|
);
|
|
1487
|
-
|
|
1487
|
+
m.push(b), f === 0 && await b;
|
|
1488
1488
|
}
|
|
1489
|
-
await Promise.all(
|
|
1489
|
+
await Promise.all(m), t = Ce(
|
|
1490
1490
|
o.map(
|
|
1491
|
-
(
|
|
1491
|
+
(f) => s.get(f)
|
|
1492
1492
|
)
|
|
1493
1493
|
);
|
|
1494
1494
|
{
|
|
1495
|
-
const
|
|
1495
|
+
const f = new he(), b = f.port1, v = f.port2;
|
|
1496
1496
|
if (await Ae(
|
|
1497
1497
|
{
|
|
1498
1498
|
applyPostInstallMountsToAllWorkers: async () => {
|
|
@@ -1508,12 +1508,12 @@ async function ve(e) {
|
|
|
1508
1508
|
}
|
|
1509
1509
|
},
|
|
1510
1510
|
void 0,
|
|
1511
|
-
|
|
1512
|
-
), await
|
|
1511
|
+
b
|
|
1512
|
+
), await A.bootWordPress(
|
|
1513
1513
|
t,
|
|
1514
1514
|
v
|
|
1515
|
-
),
|
|
1516
|
-
const S = await
|
|
1515
|
+
), b.close(), u = !0, !e["experimental-blueprints-v2-runner"]) {
|
|
1516
|
+
const S = await A.compileInputBlueprint(
|
|
1517
1517
|
e["additional-blueprint-steps"] || []
|
|
1518
1518
|
);
|
|
1519
1519
|
S && await se(
|
|
@@ -1524,14 +1524,14 @@ async function ve(e) {
|
|
|
1524
1524
|
if (e.phpmyadmin && !await t.fileExists(
|
|
1525
1525
|
`${ae}/index.php`
|
|
1526
1526
|
)) {
|
|
1527
|
-
const S = await nt(),
|
|
1528
|
-
await se(
|
|
1527
|
+
const S = await nt(), $ = await fe({ steps: S });
|
|
1528
|
+
await se($, t);
|
|
1529
1529
|
}
|
|
1530
1530
|
if (e.command === "build-snapshot") {
|
|
1531
|
-
await Ft(t, e.outfile), i.printStatus(`Exported to ${e.outfile}`), await
|
|
1531
|
+
await Ft(t, e.outfile), i.printStatus(`Exported to ${e.outfile}`), await B();
|
|
1532
1532
|
return;
|
|
1533
1533
|
} else if (e.command === "run-blueprint") {
|
|
1534
|
-
i.finishProgress("Done"), await
|
|
1534
|
+
i.finishProgress("Done"), await B();
|
|
1535
1535
|
return;
|
|
1536
1536
|
} else if (e.command === "php") {
|
|
1537
1537
|
const S = [
|
|
@@ -1539,33 +1539,33 @@ async function ve(e) {
|
|
|
1539
1539
|
// Hardcoding it feels fragile.
|
|
1540
1540
|
"/internal/shared/bin/php",
|
|
1541
1541
|
...(e._ || []).slice(1)
|
|
1542
|
-
],
|
|
1543
|
-
|
|
1544
|
-
|
|
1542
|
+
], $ = await t.cli(S), [W] = await Promise.all([
|
|
1543
|
+
$.exitCode,
|
|
1544
|
+
$.stdout.pipeTo(
|
|
1545
1545
|
new WritableStream({
|
|
1546
|
-
write(
|
|
1547
|
-
process.stdout.write(
|
|
1546
|
+
write(O) {
|
|
1547
|
+
process.stdout.write(O);
|
|
1548
1548
|
}
|
|
1549
1549
|
})
|
|
1550
1550
|
),
|
|
1551
|
-
|
|
1551
|
+
$.stderr.pipeTo(
|
|
1552
1552
|
new WritableStream({
|
|
1553
|
-
write(
|
|
1554
|
-
process.stderr.write(
|
|
1553
|
+
write(O) {
|
|
1554
|
+
process.stderr.write(O);
|
|
1555
1555
|
}
|
|
1556
1556
|
})
|
|
1557
1557
|
)
|
|
1558
1558
|
]);
|
|
1559
|
-
await
|
|
1559
|
+
await B(), process.exit(W);
|
|
1560
1560
|
}
|
|
1561
1561
|
}
|
|
1562
|
-
if (i.finishProgress(), i.printReady(
|
|
1563
|
-
const
|
|
1562
|
+
if (i.finishProgress(), i.printReady(T, E), e.phpmyadmin) {
|
|
1563
|
+
const f = d.join(
|
|
1564
1564
|
e.phpmyadmin,
|
|
1565
1565
|
at
|
|
1566
1566
|
);
|
|
1567
1567
|
i.printPhpMyAdminUrl(
|
|
1568
|
-
new URL(
|
|
1568
|
+
new URL(f, T).toString()
|
|
1569
1569
|
);
|
|
1570
1570
|
}
|
|
1571
1571
|
return e.xdebug && e.experimentalDevtools && (await Je({
|
|
@@ -1574,17 +1574,17 @@ async function ve(e) {
|
|
|
1574
1574
|
})).start(), {
|
|
1575
1575
|
playground: t,
|
|
1576
1576
|
server: c,
|
|
1577
|
-
serverUrl:
|
|
1578
|
-
[Symbol.asyncDispose]:
|
|
1579
|
-
[
|
|
1580
|
-
workerThreadCount:
|
|
1577
|
+
serverUrl: T,
|
|
1578
|
+
[Symbol.asyncDispose]: B,
|
|
1579
|
+
[J]: {
|
|
1580
|
+
workerThreadCount: E
|
|
1581
1581
|
}
|
|
1582
1582
|
};
|
|
1583
|
-
} catch (
|
|
1583
|
+
} catch (m) {
|
|
1584
1584
|
if (e.verbosity !== "debug")
|
|
1585
|
-
throw
|
|
1586
|
-
let
|
|
1587
|
-
throw await t?.fileExists(te) && (
|
|
1585
|
+
throw m;
|
|
1586
|
+
let g = "";
|
|
1587
|
+
throw await t?.fileExists(te) && (g = await t.readFileAsText(te)), await B(), new Error(g, { cause: m });
|
|
1588
1588
|
}
|
|
1589
1589
|
},
|
|
1590
1590
|
async handleRequest(c) {
|
|
@@ -1595,17 +1595,17 @@ async function ve(e) {
|
|
|
1595
1595
|
);
|
|
1596
1596
|
if (y) {
|
|
1597
1597
|
y = !1;
|
|
1598
|
-
const
|
|
1598
|
+
const h = {
|
|
1599
1599
|
"Content-Type": ["text/plain"],
|
|
1600
1600
|
"Content-Length": ["0"],
|
|
1601
1601
|
Location: [c.url]
|
|
1602
1602
|
};
|
|
1603
1603
|
return c.headers?.cookie?.includes(
|
|
1604
1604
|
"playground_auto_login_already_happened"
|
|
1605
|
-
) && (
|
|
1605
|
+
) && (h["Set-Cookie"] = [
|
|
1606
1606
|
"playground_auto_login_already_happened=1; Max-Age=0; Expires=Thu, 01 Jan 1970 00:00:00 GMT; Path=/"
|
|
1607
1607
|
]), re.fromPHPResponse(
|
|
1608
|
-
new Be(302,
|
|
1608
|
+
new Be(302, h, new Uint8Array())
|
|
1609
1609
|
);
|
|
1610
1610
|
}
|
|
1611
1611
|
r && (c = {
|
|
@@ -1620,17 +1620,17 @@ async function ve(e) {
|
|
|
1620
1620
|
cookie: r.getCookieRequestHeader()
|
|
1621
1621
|
}
|
|
1622
1622
|
});
|
|
1623
|
-
const
|
|
1623
|
+
const x = await t.requestStreamed(c);
|
|
1624
1624
|
if (r) {
|
|
1625
|
-
const
|
|
1626
|
-
r.rememberCookiesFromResponseHeaders(
|
|
1625
|
+
const h = await x.headers;
|
|
1626
|
+
r.rememberCookiesFromResponseHeaders(h), delete h["set-cookie"];
|
|
1627
1627
|
}
|
|
1628
|
-
return
|
|
1628
|
+
return x;
|
|
1629
1629
|
}
|
|
1630
1630
|
}).catch((c) => {
|
|
1631
1631
|
i.printError(c.message), process.exit(1);
|
|
1632
1632
|
});
|
|
1633
|
-
return
|
|
1633
|
+
return M && e.command === "start" && !e.skipBrowser && Ot(M.serverUrl), M;
|
|
1634
1634
|
}
|
|
1635
1635
|
function Ht(e) {
|
|
1636
1636
|
let t = { ...e, command: "server" };
|
|
@@ -1650,15 +1650,15 @@ function Ht(e) {
|
|
|
1650
1650
|
"You may still remove the site's directory manually if you wish."
|
|
1651
1651
|
), process.exit(1));
|
|
1652
1652
|
else {
|
|
1653
|
-
const o = t.autoMount || process.cwd(), s = it("sha256").update(o).digest("hex"), i =
|
|
1653
|
+
const o = t.autoMount || process.cwd(), s = it("sha256").update(o).digest("hex"), i = Q.homedir(), n = d.join(
|
|
1654
1654
|
i,
|
|
1655
1655
|
".wordpress-playground/sites",
|
|
1656
1656
|
s
|
|
1657
1657
|
);
|
|
1658
|
-
console.log("Site files stored at:",
|
|
1658
|
+
console.log("Site files stored at:", n), G(n) && e.reset && (console.log("Resetting site..."), _e(n, { recursive: !0 })), q(n, { recursive: !0 }), t["mount-before-install"] = [
|
|
1659
1659
|
...t["mount-before-install"] || [],
|
|
1660
|
-
{ vfsPath: "/wordpress", hostPath:
|
|
1661
|
-
], t.wordpressInstallMode = Ue(
|
|
1660
|
+
{ vfsPath: "/wordpress", hostPath: n }
|
|
1661
|
+
], t.wordpressInstallMode = Ue(n).length === 0 ? (
|
|
1662
1662
|
// Only download WordPress on the first run when the site directory is still
|
|
1663
1663
|
// empty.
|
|
1664
1664
|
"download-and-install"
|
|
@@ -1669,11 +1669,11 @@ function Ht(e) {
|
|
|
1669
1669
|
}
|
|
1670
1670
|
return t;
|
|
1671
1671
|
}
|
|
1672
|
-
const
|
|
1672
|
+
const Y = new Te();
|
|
1673
1673
|
function Se(e, { onExit: t } = {}) {
|
|
1674
1674
|
let r;
|
|
1675
1675
|
return e === "v1" ? r = new ie(new URL("./worker-thread-v1.js", import.meta.url)) : r = new ie(new URL("./worker-thread-v2.js", import.meta.url)), new Promise((o, s) => {
|
|
1676
|
-
const i =
|
|
1676
|
+
const i = Y.claim();
|
|
1677
1677
|
r.once("message", function(l) {
|
|
1678
1678
|
l.command === "worker-script-initialized" && o({
|
|
1679
1679
|
processId: i,
|
|
@@ -1681,26 +1681,26 @@ function Se(e, { onExit: t } = {}) {
|
|
|
1681
1681
|
phpPort: l.phpPort
|
|
1682
1682
|
});
|
|
1683
1683
|
}), r.once("error", function(l) {
|
|
1684
|
-
|
|
1684
|
+
Y.release(i), console.error(l);
|
|
1685
1685
|
const u = new Error(
|
|
1686
1686
|
`Worker failed to load worker. ${l.message ? `Original error: ${l.message}` : ""}`
|
|
1687
1687
|
);
|
|
1688
1688
|
s(u);
|
|
1689
1689
|
});
|
|
1690
|
-
let
|
|
1690
|
+
let n = !1;
|
|
1691
1691
|
r.once("spawn", () => {
|
|
1692
|
-
|
|
1692
|
+
n = !0;
|
|
1693
1693
|
}), r.once("exit", (l) => {
|
|
1694
|
-
|
|
1694
|
+
Y.release(i), n || s(new Error(`Worker exited before spawning: ${l}`)), t?.(l);
|
|
1695
1695
|
});
|
|
1696
1696
|
});
|
|
1697
1697
|
}
|
|
1698
1698
|
async function Nt(e) {
|
|
1699
1699
|
const { port1: t, port2: r } = new he();
|
|
1700
|
-
return await
|
|
1700
|
+
return await De(e, t), r;
|
|
1701
1701
|
}
|
|
1702
1702
|
function Ot(e) {
|
|
1703
|
-
const t =
|
|
1703
|
+
const t = Q.platform();
|
|
1704
1704
|
let r;
|
|
1705
1705
|
switch (t) {
|
|
1706
1706
|
case "darwin":
|
|
@@ -1743,22 +1743,22 @@ async function Ft(e, t) {
|
|
|
1743
1743
|
}
|
|
1744
1744
|
const yr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
1745
1745
|
__proto__: null,
|
|
1746
|
-
LogVerbosity:
|
|
1747
|
-
internalsKeyForTesting:
|
|
1748
|
-
mergeDefinedConstants:
|
|
1746
|
+
LogVerbosity: Z,
|
|
1747
|
+
internalsKeyForTesting: J,
|
|
1748
|
+
mergeDefinedConstants: X,
|
|
1749
1749
|
parseOptionsAndRunCLI: _t,
|
|
1750
1750
|
runCLI: ve,
|
|
1751
1751
|
spawnWorkerThread: Se
|
|
1752
1752
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
1753
1753
|
export {
|
|
1754
|
-
|
|
1754
|
+
Z as L,
|
|
1755
1755
|
wr as a,
|
|
1756
1756
|
Wt as b,
|
|
1757
1757
|
yr as c,
|
|
1758
|
-
|
|
1759
|
-
|
|
1758
|
+
J as i,
|
|
1759
|
+
X as m,
|
|
1760
1760
|
_t as p,
|
|
1761
1761
|
ve as r,
|
|
1762
1762
|
Se as s
|
|
1763
1763
|
};
|
|
1764
|
-
//# sourceMappingURL=run-cli-
|
|
1764
|
+
//# sourceMappingURL=run-cli-CaJWk9j8.js.map
|