@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.
@@ -1,30 +1,29 @@
1
- import { logger as P, LogSeverity as _, errorLogPath as Z } from "@php-wasm/logger";
2
- import { consumeAPI as ue, ProcessIdAllocator as xe, SupportedPHPVersions as R, printDebugDetails as Ee, HttpCookieStore as $e, FileLockManagerInMemory as Te, StreamedPHPResponse as J, createObjectPoolProxy as Ie, exposeAPI as ke, PHPResponse as Me, exposeSyncAPI as Ae } from "@php-wasm/universal";
3
- import { resolveRemoteBlueprint as Be, resolveRuntimeConfiguration as K, compileBlueprintV1 as de, isBlueprintBundle as Ce, runBlueprintV1Steps as ee } from "@wp-playground/blueprints";
4
- import { zipDirectory as De, RecommendedPHPVersion as M } from "@wp-playground/common";
5
- import p, { existsSync as Y, rmdirSync as Re, mkdirSync as j, readdirSync as We } from "fs";
6
- import { MessageChannel as ce, Worker as te } from "worker_threads";
7
- import { createNodeFsMountHandler as Le } from "@php-wasm/node";
8
- import d, { basename as D, join as pe } from "path";
9
- import { exec as me } from "child_process";
10
- import { promisify as Ue } from "util";
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 _e } from "stream/promises";
14
- import Fe from "yargs";
15
- import { NodeJsFilesystem as Ne, OverlayFilesystem as Oe, InMemoryFilesystem as je, ZipFilesystem as Ve } from "@wp-playground/storage";
16
- import { EmscriptenDownloadMonitor as Ye, ProgressTracker as qe } from "@php-wasm/progress";
17
- import { resolveWordPressRelease as ze } from "@wp-playground/wordpress";
18
- import E from "fs-extra";
19
- import { createRequire as Ge } from "module";
20
- import q from "os";
21
- import { startBridge as Qe } from "@php-wasm/xdebug-bridge";
22
- import { dir as Xe, setGracefulCleanup as Ze } from "tmp-promise";
23
- import Je from "ps-man";
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 oe, getPhpMyAdminInstallSteps as st, PHPMYADMIN_ENTRY_PATH as it } from "@wp-playground/tools";
27
- import { jspi as se } from "wasm-feature-detect";
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 (!Y(s))
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 ie(e) {
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 (!Y(o))
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 wr(e, t) {
58
+ async function fr(e, t) {
60
59
  for (const r of t)
61
60
  await e.mount(
62
61
  r.vfsPath,
63
- Le(r.hostPath)
62
+ Ue(r.hostPath)
64
63
  );
65
64
  }
66
- const ne = {
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 he(e) {
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 n = `/wordpress/wp-content/plugins/${D(t)}`;
94
+ const a = `/wordpress/wp-content/plugins/${D(t)}`;
96
95
  r.push({
97
96
  hostPath: t,
98
- vfsPath: n,
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), n = `/wordpress/wp-content/themes/${i}`;
104
+ const i = D(t), a = `/wordpress/wp-content/themes/${i}`;
106
105
  r.push({
107
106
  hostPath: t,
108
- vfsPath: n,
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 n of i)
122
- n !== "index.php" && r.push({
123
- hostPath: `${t}/${n}`,
124
- vfsPath: `/wordpress/wp-content/${n}`,
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(ne);
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(ne), s.wordpressInstallMode || (s.wordpressInstallMode = "install-from-existing-files-if-needed"));
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(pe(e, "style.css"), "utf8");
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(pe(e, s), "utf8");
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 = (n, l) => {
212
- for (const u in n) {
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] = n[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 we(e) {
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 ft = Ue(me);
230
- function ht(e) {
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((n, l) => {
240
+ const t = fe(), r = await new Promise((a, l) => {
242
241
  const u = t.listen(e.port, () => {
243
- const w = u.address();
244
- w === null || typeof w == "string" ? l(new Error("Server address is not available")) : n(u);
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 (n, l) => {
246
+ t.use("/", async (a, l) => {
248
247
  try {
249
248
  const u = {
250
- url: n.url,
251
- headers: Pt(n),
252
- method: n.method,
253
- body: await bt(n)
254
- }, w = await e.handleRequest(u);
255
- await yt(w, l);
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
- P.error(u), l.headersSent || (l.statusCode = 500, l.end("Internal Server Error"));
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 _e(s, t);
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
- P.log(`Publishing port ${e}...`);
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 ft(r);
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 Ve.fromArrayBuffer(
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 n = d.dirname(r), l = new Ne(n);
341
- return new Oe([
342
- new je({
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 = ue(t.phpPort);
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: we(this.args)
403
+ constants: ye(this.args)
405
404
  };
406
405
  return await s.bootWorker(i), s;
407
406
  }
408
407
  }
409
- const V = d.join(q.homedir(), ".wordpress-playground");
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 (!E.existsSync(t)) {
414
- const r = Ge(import.meta.url), o = d.dirname(
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 E.readFile(t)], d.basename(t));
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(V, t);
428
- return E.existsSync(o) || (E.ensureDirSync(V), await Tt(e, o, r)), ye(o);
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`, n = E.createWriteStream(i);
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 && n.write(u), l)
433
+ if (u && a.write(u), l)
435
434
  break;
436
435
  }
437
- n.close(), n.closed || await new Promise((l, u) => {
438
- n.on("finish", () => {
439
- E.renameSync(i, t), l(null);
440
- }), n.on("error", (w) => {
441
- E.removeSync(i), u(w);
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 ye(e, t) {
446
- return new File([E.readFileSync(e)], D(e));
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 n = new Ye();
456
+ const a = new qe();
458
457
  if (this.args.wordpressInstallMode === "download-and-install") {
459
- let w = !1;
460
- n.addEventListener("progress", (S) => {
461
- if (w)
458
+ let y = !1;
459
+ a.addEventListener("progress", (E) => {
460
+ if (y)
462
461
  return;
463
- const { loaded: c, total: a } = S.detail, m = Math.floor(
464
- Math.min(100, 100 * c / a)
462
+ const { loaded: c, total: n } = E.detail, m = Math.floor(
463
+ Math.min(100, 100 * c / n)
465
464
  );
466
- w = m === 100, this.cliOutput.updateProgress(
465
+ y = m === 100, this.cliOutput.updateProgress(
467
466
  "Downloading WordPress",
468
467
  m
469
468
  );
470
- }), o = await ze(this.args.wp), i = d.join(
471
- V,
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) ? ye(i) : await $t(
472
+ ), s = p.existsSync(i) ? be(i) : await $t(
474
473
  o.releaseUrl,
475
474
  `${o.version}.zip`,
476
- n
477
- ), P.debug(
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 ? (P.debug("Skipping SQLite integration plugin setup..."), l = void 0) : (this.cliOutput.updateProgress("Preparing SQLite database"), l = await Et()), this.cliOutput.updateProgress("Booting WordPress");
483
- const u = await K(
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: we(this.args)
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 = ue(
510
+ const s = de(
512
511
  t.phpPort
513
512
  );
514
513
  await s.isConnected();
515
- const i = await K(
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 qe();
534
+ const r = this.getEffectiveBlueprint(), o = new ze();
536
535
  let s = "", i = !1;
537
- return o.addEventListener("progress", (n) => {
536
+ return o.addEventListener("progress", (a) => {
538
537
  if (i)
539
538
  return;
540
- i = n.detail.progress === 100;
541
- const l = Math.floor(n.detail.progress);
542
- s = n.detail.caption || s || "Running Blueprint", this.cliOutput.updateProgress(s.trim(), l);
543
- }), await de(r, {
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 Ce(t) ? t : {
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 ?? M,
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 Xe({
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 && Ze(), s;
573
+ return t && Je(), s;
575
574
  }
576
575
  async function Mt(e, t, r) {
577
- const s = (await At(
576
+ const s = (await Ct(
578
577
  e,
579
578
  t,
580
579
  r
581
580
  )).map(
582
- (i) => new Promise((n) => {
581
+ (i) => new Promise((a) => {
583
582
  p.rm(i, { recursive: !0 }, (l) => {
584
- l ? P.warn(
583
+ l ? w.warn(
585
584
  `Failed to delete stale Playground temp dir: ${i}`,
586
585
  l
587
- ) : P.info(
586
+ ) : w.info(
588
587
  `Deleted stale Playground temp dir: ${i}`
589
- ), n();
588
+ ), a();
590
589
  });
591
590
  })
592
591
  );
593
592
  await Promise.all(s);
594
593
  }
595
- async function At(e, t, r) {
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 Bt(
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 P.warn(`Failed to find stale Playground temp dirs: ${o}`), [];
605
+ return w.warn(`Failed to find stale Playground temp dirs: ${o}`), [];
607
606
  }
608
607
  }
609
- async function Bt(e, t, r) {
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 n = {
619
+ const a = {
621
620
  executableName: i[1],
622
621
  pid: i[2]
623
622
  };
624
- if (await Ct(n.pid, n.executableName))
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
- async function Ct(e, t) {
630
- const [r] = await new Promise(
631
- (o, s) => {
632
- Je.list(
633
- {
634
- pid: e,
635
- name: t,
636
- // Remove path from executable name in the results.
637
- clean: !0
638
- },
639
- (i, n) => {
640
- i ? s(i) : o(n);
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 Dt(e) {
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 Rt {
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 Dt(this.writeStream);
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 be = {
814
- Quiet: { name: "quiet", severity: _.Fatal },
815
- Normal: { name: "normal", severity: _.Info },
816
- Debug: { name: "debug", severity: _.Debug }
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 yr(e) {
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: M,
829
- choices: R
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: ie
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: ie
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(be).map(
931
- (a) => a.name
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: (a) => a === "" ? ["vscode", "phpstorm"] : [a]
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: (a) => a === "" ? "/phpmyadmin" : a
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: M,
1036
- choices: R
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 = Fe(e).usage("Usage: wp-playground <command> [options]").command(
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
- (a) => a.usage(
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
- (a) => a.options({
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
- (a) => a.options({ ...t })
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
- (a) => a.options({
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((a, m, y) => {
1144
+ ).showHelpOnFail(!1).fail((n, m, b) => {
1144
1145
  if (m)
1145
1146
  throw m;
1146
- a && a.includes("Please specify a command") && (y.showHelp(), console.error(`
1147
- ` + a), process.exit(1)), console.error(a), process.exit(1);
1148
- }).strictOptions().check(async (a) => {
1149
- 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" && !vt(a.wp))
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(a.wp);
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 = a["site-url"];
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 (a["auto-mount"]) {
1167
- let y = !1;
1167
+ if (n["auto-mount"]) {
1168
+ let b = !1;
1168
1169
  try {
1169
- y = p.statSync(
1170
- a["auto-mount"]
1170
+ b = p.statSync(
1171
+ n["auto-mount"]
1171
1172
  ).isDirectory();
1172
1173
  } catch {
1173
- y = !1;
1174
+ b = !1;
1174
1175
  }
1175
- if (!y)
1176
+ if (!b)
1176
1177
  throw new Error(
1177
- `The specified --auto-mount path is not a directory: '${a["auto-mount"]}'.`
1178
+ `The specified --auto-mount path is not a directory: '${n["auto-mount"]}'.`
1178
1179
  );
1179
1180
  }
1180
- if (a["experimental-blueprints-v2-runner"] === !0)
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 (a.mode !== void 0)
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 n = await i.argv, l = n._[0];
1192
- ["start", "run-blueprint", "server", "build-snapshot"].includes(
1193
- l
1194
- ) || (i.showHelp(), process.exit(1));
1195
- const u = n.define || {};
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 w = {
1198
- ...n,
1202
+ const y = {
1203
+ ...a,
1199
1204
  define: u,
1200
1205
  command: l,
1201
1206
  mount: [
1202
- ...n.mount || [],
1203
- ...n["mount-dir"] || []
1207
+ ...a.mount || [],
1208
+ ...a["mount-dir"] || []
1204
1209
  ],
1205
1210
  "mount-before-install": [
1206
- ...n["mount-before-install"] || [],
1207
- ...n["mount-dir-before-install"] || []
1211
+ ...a["mount-before-install"] || [],
1212
+ ...a["mount-dir-before-install"] || []
1208
1213
  ]
1209
- }, S = await Lt(w);
1210
- S === void 0 && process.exit(0);
1214
+ }, E = await Lt(y);
1215
+ E === void 0 && process.exit(0);
1211
1216
  const c = /* @__PURE__ */ (() => {
1212
- let a;
1217
+ let n;
1213
1218
  return async () => {
1214
- a === void 0 && (a = S[Symbol.asyncDispose]()), await a, process.exit(0);
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 S[Symbol.asyncDispose]();
1224
+ process.off("SIGINT", c), process.off("SIGTERM", c), await E[Symbol.asyncDispose]();
1220
1225
  },
1221
- [ge]: { cliServer: S }
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
- Ee(t);
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 ae(e, t) {
1246
+ function le(e, t) {
1242
1247
  return e.find(
1243
1248
  (r) => r.vfsPath.replace(/\/$/, "") === t.replace(/\/$/, "")
1244
1249
  );
1245
1250
  }
1246
- const ge = 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, le = (e) => process.stdout.isTTY ? `\x1B[2m${e}\x1B[0m` : e, C = (e) => process.stdout.isTTY ? `\x1B[3m${e}\x1B[0m` : e, N = (e) => process.stdout.isTTY ? `\x1B[33m${e}\x1B[0m` : e;
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 $e() : void 0, o = [], s = /* @__PURE__ */ new Map();
1250
- if (e.command === "start" && (e = Ut(e)), e.autoMount !== void 0 && (e.autoMount === "" && (e = { ...e, autoMount: process.cwd() }), e = he(e)), e.wordpressInstallMode === void 0 && (e.wordpressInstallMode = "download-and-install"), e.quiet && (e.verbosity = "quiet", delete e.quiet), e.debug && (e.verbosity = "debug", delete e.debug), e.verbosity) {
1251
- const c = Object.values(be).find(
1252
- (a) => a.name === e.verbosity
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
- P.setSeverityFilterLevel(c);
1259
+ w.setSeverityFilterLevel(c);
1255
1260
  }
1256
- if (e.intl || (e.intl = !0), e.redis === void 0 && (e.redis = await se()), e.memcached === void 0 && (e.memcached = await se()), e.phpmyadmin) {
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: oe
1269
+ fsPath: se
1265
1270
  }
1266
1271
  ];
1267
1272
  }
1268
- const i = new Rt({
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 || M,
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 n = e.command === "server" ? e.port ?? 9400 : 0, l = new Te();
1286
- let u = !1, w = !0;
1287
- const S = await wt({
1288
- port: e.port ? e.port : await ht(n) ? 0 : n,
1289
- onBind: async (c, a) => {
1290
- const m = "127.0.0.1", y = `http://${m}:${a}`, W = e["site-url"] || y, L = 6, z = "-playground-cli-site-", $ = await kt(z);
1291
- P.debug(`Native temp dir for VFS root: ${$.path}`);
1292
- const A = "WP Playground CLI - Listen for Xdebug", G = ".playground-xdebug-root", U = d.join(process.cwd(), G);
1293
- if (await Ke(U), e.xdebug) {
1294
- const f = {
1295
- hostPath: d.join(".", d.sep, G),
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 (R.indexOf(
1299
- e.php || M
1300
- ) <= R.indexOf("8.5"))
1301
- await re(
1302
- $.path,
1303
- U,
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
- f,
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
- N("Playground source root: ") + ".playground-xdebug-root" + C(
1321
- le(
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 re(
1328
- $.path,
1329
- U,
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 h = typeof e.xdebug == "object" ? e.xdebug : {}, b = await rt({
1342
+ const f = typeof e.xdebug == "object" ? e.xdebug : {}, g = await rt({
1338
1343
  name: A,
1339
1344
  host: m,
1340
- port: a,
1345
+ port: n,
1341
1346
  ides: e.experimentalUnsafeIdeIntegration,
1342
1347
  cwd: process.cwd(),
1343
1348
  mounts: [
1344
- f,
1349
+ h,
1345
1350
  ...e["mount-before-install"] || [],
1346
1351
  ...e.mount || []
1347
1352
  ],
1348
- ideKey: h.ideKey || "WPPLAYGROUNDCLI"
1349
- }), v = e.experimentalUnsafeIdeIntegration, x = v.includes("vscode"), T = v.includes("phpstorm"), X = Object.values(b);
1350
- console.log(""), X.length > 0 ? (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
- N("Updated IDE config: ") + X.join(" ")
1358
+ j("Updated IDE config: ") + B.join(" ")
1354
1359
  ), console.log(
1355
- N("Playground source root: ") + ".playground-xdebug-root" + C(
1356
- le(
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(""), x && b.vscode && (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 "${C(
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
- ), T && console.log("")), T && b.phpstorm && (console.log(I("PhpStorm instructions:")), console.log(
1383
- ` 1. Choose "${C(
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 (h) {
1398
+ } catch (f) {
1394
1399
  throw new Error("Could not configure Xdebug", {
1395
- cause: h
1400
+ cause: f
1396
1401
  });
1397
1402
  }
1398
1403
  }
1399
1404
  }
1400
- const Pe = d.dirname($.path), ve = 2 * 24 * 60 * 60 * 1e3;
1405
+ const ve = d.dirname(T.path), Se = 2 * 24 * 60 * 60 * 1e3;
1401
1406
  Mt(
1402
- z,
1403
- ve,
1404
- Pe
1407
+ Q,
1408
+ Se,
1409
+ ve
1405
1410
  );
1406
- const Q = d.join($.path, "internal");
1407
- j(Q);
1408
- const Se = [
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 f of Se) {
1421
- const g = (b) => b.vfsPath === `/${f}`;
1422
- if (!(e["mount-before-install"]?.some(g) || e.mount?.some(g))) {
1423
- const b = d.join(
1424
- $.path,
1425
- f
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
- j(b), e["mount-before-install"] === void 0 && (e["mount-before-install"] = []), e["mount-before-install"].unshift({
1428
- vfsPath: `/${f}`,
1429
- hostPath: b
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 f of e["mount-before-install"])
1435
- P.debug(
1436
- `Mount before WP install: ${f.vfsPath} -> ${f.hostPath}`
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 f of e.mount)
1440
- P.debug(
1441
- `Mount after WP install: ${f.vfsPath} -> ${f.hostPath}`
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: W,
1450
+ siteUrl: L,
1446
1451
  cliOutput: i
1447
1452
  }) : (k = new It(e, {
1448
- siteUrl: W,
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 B = async function() {
1460
+ const M = async function() {
1456
1461
  H || (H = !0, await Promise.all(
1457
- o.map(async (g) => {
1458
- await s.get(g)?.dispose(), await g.worker.terminate();
1462
+ o.map(async (P) => {
1463
+ await s.get(P)?.dispose(), await P.worker.terminate();
1459
1464
  })
1460
- ), c && await new Promise((g) => {
1461
- c.close(g), c.closeAllConnections();
1462
- }), await $.cleanup());
1465
+ ), c && await new Promise((P) => {
1466
+ c.close(P), c.closeAllConnections();
1467
+ }), await T.cleanup());
1463
1468
  };
1464
1469
  try {
1465
- const f = [], g = k.getWorkerType();
1466
- for (let h = 0; h < L; h++) {
1467
- const b = Ht(g, {
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 && P.error(
1470
- `Worker ${h} exited with code ${v}
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 x = await _t(l), T = await k.bootRequestHandler({
1482
+ const S = await Ht(l), x = await k.bootRequestHandler({
1478
1483
  worker: v,
1479
- fileLockManagerPort: x,
1480
- nativeInternalDirPath: Q
1484
+ fileLockManagerPort: S,
1485
+ nativeInternalDirPath: Z
1481
1486
  });
1482
1487
  return s.set(
1483
1488
  v,
1484
- T
1485
- ), [v, T];
1489
+ x
1490
+ ), [v, x];
1486
1491
  }
1487
1492
  );
1488
- f.push(b), h === 0 && await b;
1493
+ h.push(g), f === 0 && await g;
1489
1494
  }
1490
- await Promise.all(f), t = Ie(
1495
+ await Promise.all(h), t = ke(
1491
1496
  o.map(
1492
- (h) => s.get(h)
1497
+ (f) => s.get(f)
1493
1498
  )
1494
1499
  );
1495
1500
  {
1496
- const h = new ce(), b = h.port1, v = h.port2;
1497
- if (await ke(
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
- (x) => x.mountAfterWordPressInstall(
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
- b
1517
+ g
1513
1518
  ), await k.bootWordPress(
1514
1519
  t,
1515
1520
  v
1516
- ), b.close(), u = !0, !e["experimental-blueprints-v2-runner"]) {
1517
- const x = await k.compileInputBlueprint(
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
- x && await ee(
1521
- x,
1525
+ S && await te(
1526
+ S,
1522
1527
  t
1523
1528
  );
1524
1529
  }
1525
1530
  if (e.phpmyadmin && !await t.fileExists(
1526
- `${oe}/index.php`
1531
+ `${se}/index.php`
1527
1532
  )) {
1528
- const x = await st(), T = await de({ steps: x });
1529
- await ee(T, t);
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 Nt(t, e.outfile), i.printStatus(`Exported to ${e.outfile}`), await B();
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 B();
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(y, L), e.phpmyadmin) {
1540
- const h = d.join(
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(h, y).toString()
1574
+ new URL(f, b).toString()
1546
1575
  );
1547
1576
  }
1548
- return e.xdebug && e.experimentalDevtools && (await Qe({
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: y,
1555
- [Symbol.asyncDispose]: B,
1556
- [ge]: {
1557
- workerThreadCount: L
1583
+ serverUrl: b,
1584
+ [Symbol.asyncDispose]: M,
1585
+ [Pe]: {
1586
+ workerThreadCount: U
1558
1587
  }
1559
1588
  };
1560
- } catch (f) {
1589
+ } catch (h) {
1561
1590
  if (e.verbosity !== "debug")
1562
- throw f;
1563
- let g = "";
1564
- throw await t?.fileExists(Z) && (g = await t.readFileAsText(Z)), await B(), new Error(g, { cause: f });
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 J.forHttpCode(
1598
+ return K.forHttpCode(
1570
1599
  502,
1571
1600
  "WordPress is not ready yet"
1572
1601
  );
1573
- if (w) {
1574
- w = !1;
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
- ]), J.fromPHPResponse(
1585
- new Me(302, m, new Uint8Array())
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 a = await t.requestStreamed(c);
1629
+ const n = await t.requestStreamed(c);
1601
1630
  if (r) {
1602
- const m = await a.headers;
1631
+ const m = await n.headers;
1603
1632
  r.rememberCookiesFromResponseHeaders(m), delete m["set-cookie"];
1604
1633
  }
1605
- return a;
1634
+ return n;
1606
1635
  }
1607
1636
  }).catch((c) => {
1608
1637
  i.printError(c.message), process.exit(1);
1609
1638
  });
1610
- return S && e.command === "start" && !e.skipBrowser && Ft(S.serverUrl), S;
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 = he(t), delete t.autoMount);
1615
- const r = ae(
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
- ) || ae(t.mount || [], "/wordpress");
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 = q.homedir(), n = d.join(
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:", n), Y(n) && e.reset && (console.log("Resetting site..."), Re(n, { recursive: !0 })), j(n, { recursive: !0 }), t["mount-before-install"] = [
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: n }
1638
- ], t.wordpressInstallMode = We(n).length === 0 ? (
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 O = new xe();
1650
- function Ht(e, { onExit: t } = {}) {
1678
+ const V = new Ee();
1679
+ function _t(e, { onExit: t } = {}) {
1651
1680
  let r;
1652
- return e === "v1" ? r = new te(new URL("./worker-thread-v1.js", import.meta.url)) : r = new te(new URL("./worker-thread-v2.js", import.meta.url)), new Promise((o, s) => {
1653
- const i = O.claim();
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
- O.release(i), console.error(l);
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 n = !1;
1696
+ let a = !1;
1668
1697
  r.once("spawn", () => {
1669
- n = !0;
1698
+ a = !0;
1670
1699
  }), r.once("exit", (l) => {
1671
- O.release(i), n || s(new Error(`Worker exited before spawning: ${l}`)), t?.(l);
1700
+ V.release(i), a || s(new Error(`Worker exited before spawning: ${l}`)), t?.(l);
1672
1701
  });
1673
1702
  });
1674
1703
  }
1675
- async function _t(e) {
1676
- const { port1: t, port2: r } = new ce();
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 Ft(e) {
1680
- const t = q.platform();
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
- me(r, (o) => {
1694
- o && P.debug(`Could not open browser: ${o.message}`);
1722
+ he(r, (o) => {
1723
+ o && w.debug(`Could not open browser: ${o.message}`);
1695
1724
  });
1696
1725
  }
1697
- async function Nt(e, t) {
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
- be as L,
1723
- wr as a,
1724
- Dt as b,
1725
- ge as i,
1726
- we as m,
1727
- yr as p,
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
- Ht as s
1758
+ _t as s
1730
1759
  };
1731
- //# sourceMappingURL=run-cli-DEBbpuwb.js.map
1760
+ //# sourceMappingURL=run-cli-2YzKNrNz.js.map