@wp-playground/cli 3.1.9 → 3.1.11

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,31 +1,31 @@
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 P, LogSeverity as N, 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 pe, isBlueprintBundle as De, runBlueprintV1Steps as te } from "@wp-playground/blueprints";
4
+ import { zipDirectory as Re, RecommendedPHPVersion as C } from "@wp-playground/common";
5
+ import c, { existsSync as z, rmdirSync as We, mkdirSync as Y, readdirSync as Le } from "fs";
6
+ import { MessageChannel as ce, Worker as re } from "worker_threads";
7
+ import { createNodeFsMountHandler as Ue } from "@php-wasm/node";
8
+ import d, { basename as R, join as me } from "path";
9
+ import { exec as he } from "child_process";
10
+ import { promisify as He } from "util";
11
11
  import fe from "express";
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";
25
- 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";
28
- function F(e) {
12
+ import { Readable as _e } from "stream";
13
+ import { pipeline as Fe } from "stream/promises";
14
+ import Ne from "yargs";
15
+ import { NodeJsFilesystem as Oe, 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 Ke from "ps-man";
24
+ import { removeTempDirSymlink as et, createTempDirSymlink as oe, makeXdebugConfig as tt, clearXdebugIDEConfig as rt, addXdebugIDEConfig as ot } from "@php-wasm/cli-util";
25
+ import { createHash as st } from "crypto";
26
+ import { PHPMYADMIN_INSTALL_PATH as se, getPhpMyAdminInstallSteps as it, PHPMYADMIN_ENTRY_PATH as nt } from "@wp-playground/tools";
27
+ import { jspi as ie } from "wasm-feature-detect";
28
+ function O(e) {
29
29
  const t = [];
30
30
  for (const r of e) {
31
31
  const o = r.split(":");
@@ -35,19 +35,19 @@ function F(e) {
35
35
  If your path contains a colon, e.g. C:\\myplugin, use the --mount-dir option instead.
36
36
  Example: --mount-dir C:\\my-plugin /wordpress/wp-content/plugins/my-plugin`);
37
37
  const [s, i] = o;
38
- if (!Y(s))
38
+ if (!z(s))
39
39
  throw new Error(`Host path does not exist: ${s}`);
40
40
  t.push({ hostPath: s, vfsPath: i });
41
41
  }
42
42
  return t;
43
43
  }
44
- function ie(e) {
44
+ function ne(e) {
45
45
  if (e.length % 2 !== 0)
46
46
  throw new Error("Invalid mount format. Expected: /host/path /vfs/path");
47
47
  const t = [];
48
48
  for (let r = 0; r < e.length; r += 2) {
49
49
  const o = e[r], s = e[r + 1];
50
- if (!Y(o))
50
+ if (!z(o))
51
51
  throw new Error(`Host path does not exist: ${o}`);
52
52
  t.push({
53
53
  hostPath: d.resolve(process.cwd(), o),
@@ -56,14 +56,14 @@ function ie(e) {
56
56
  }
57
57
  return t;
58
58
  }
59
- async function wr(e, t) {
59
+ async function yr(e, t) {
60
60
  for (const r of t)
61
61
  await e.mount(
62
62
  r.vfsPath,
63
- Le(r.hostPath)
63
+ Ue(r.hostPath)
64
64
  );
65
65
  }
66
- const ne = {
66
+ const ae = {
67
67
  step: "runPHP",
68
68
  code: {
69
69
  filename: "activate-theme.php",
@@ -82,7 +82,7 @@ const ne = {
82
82
  `
83
83
  }
84
84
  };
85
- function he(e) {
85
+ function we(e) {
86
86
  const t = e.autoMount, r = [...e.mount || []], o = [...e["mount-before-install"] || []], s = {
87
87
  ...e,
88
88
  mount: r,
@@ -91,18 +91,18 @@ function he(e) {
91
91
  ...e["additional-blueprint-steps"] || []
92
92
  ]
93
93
  };
94
- if (ut(t)) {
95
- const n = `/wordpress/wp-content/plugins/${D(t)}`;
94
+ if (dt(t)) {
95
+ const n = `/wordpress/wp-content/plugins/${R(t)}`;
96
96
  r.push({
97
97
  hostPath: t,
98
98
  vfsPath: n,
99
99
  autoMounted: !0
100
100
  }), s["additional-blueprint-steps"].push({
101
101
  step: "activatePlugin",
102
- pluginPath: `/wordpress/wp-content/plugins/${D(t)}`
102
+ pluginPath: `/wordpress/wp-content/plugins/${R(t)}`
103
103
  });
104
- } else if (lt(t)) {
105
- const i = D(t), n = `/wordpress/wp-content/themes/${i}`;
104
+ } else if (ut(t)) {
105
+ const i = R(t), n = `/wordpress/wp-content/themes/${i}`;
106
106
  r.push({
107
107
  hostPath: t,
108
108
  vfsPath: n,
@@ -116,44 +116,44 @@ function he(e) {
116
116
  themeFolderName: i
117
117
  }
118
118
  );
119
- } else if (at(t)) {
120
- const i = p.readdirSync(t);
119
+ } else if (lt(t)) {
120
+ const i = c.readdirSync(t);
121
121
  for (const n of i)
122
122
  n !== "index.php" && r.push({
123
123
  hostPath: `${t}/${n}`,
124
124
  vfsPath: `/wordpress/wp-content/${n}`,
125
125
  autoMounted: !0
126
126
  });
127
- s["additional-blueprint-steps"].push(ne);
128
- } else nt(t) && (o.push({
127
+ s["additional-blueprint-steps"].push(ae);
128
+ } else at(t) && (o.push({
129
129
  hostPath: t,
130
130
  vfsPath: "/wordpress",
131
131
  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"));
132
+ }), s.mode = "apply-to-existing-site", s["additional-blueprint-steps"].push(ae), s.wordpressInstallMode || (s.wordpressInstallMode = "install-from-existing-files-if-needed"));
133
133
  return s;
134
134
  }
135
- function nt(e) {
136
- const t = p.readdirSync(e);
135
+ function at(e) {
136
+ const t = c.readdirSync(e);
137
137
  return t.includes("wp-admin") && t.includes("wp-includes") && t.includes("wp-content");
138
138
  }
139
- function at(e) {
140
- const t = p.readdirSync(e);
139
+ function lt(e) {
140
+ const t = c.readdirSync(e);
141
141
  return t.includes("themes") || t.includes("plugins") || t.includes("mu-plugins") || t.includes("uploads");
142
142
  }
143
- function lt(e) {
144
- if (!p.readdirSync(e).includes("style.css"))
143
+ function ut(e) {
144
+ if (!c.readdirSync(e).includes("style.css"))
145
145
  return !1;
146
- const r = p.readFileSync(pe(e, "style.css"), "utf8");
146
+ const r = c.readFileSync(me(e, "style.css"), "utf8");
147
147
  return !!/^(?:[ \t]*<\?php)?[ \t/*#@]*Theme Name:(.*)$/im.exec(r);
148
148
  }
149
- function ut(e) {
150
- const t = p.readdirSync(e), r = /^(?:[ \t]*<\?php)?[ \t/*#@]*Plugin Name:(.*)$/im;
149
+ function dt(e) {
150
+ const t = c.readdirSync(e), r = /^(?:[ \t]*<\?php)?[ \t/*#@]*Plugin Name:(.*)$/im;
151
151
  return !!t.filter((s) => s.endsWith(".php")).find((s) => {
152
- const i = p.readFileSync(pe(e, s), "utf8");
152
+ const i = c.readFileSync(me(e, s), "utf8");
153
153
  return !!r.exec(i);
154
154
  });
155
155
  }
156
- function dt(e) {
156
+ function pt(e) {
157
157
  if (e.length % 2 !== 0)
158
158
  throw new Error(
159
159
  "Invalid constant definition format. Expected pairs of NAME value"
@@ -188,7 +188,7 @@ function ct(e) {
188
188
  }
189
189
  return t;
190
190
  }
191
- function pt(e) {
191
+ function mt(e) {
192
192
  if (e.length % 2 !== 0)
193
193
  throw new Error(
194
194
  "Invalid number constant definition format. Expected pairs of NAME value"
@@ -207,7 +207,7 @@ function pt(e) {
207
207
  }
208
208
  return t;
209
209
  }
210
- function mt(e = {}, t = {}, r = {}) {
210
+ function ht(e = {}, t = {}, r = {}) {
211
211
  const o = {}, s = /* @__PURE__ */ new Set(), i = (n, l) => {
212
212
  for (const u in n) {
213
213
  if (s.has(u))
@@ -219,15 +219,15 @@ function mt(e = {}, t = {}, r = {}) {
219
219
  };
220
220
  return i(e, "string"), i(t, "bool"), i(r, "number"), o;
221
221
  }
222
- function we(e) {
223
- return mt(
222
+ function ye(e) {
223
+ return ht(
224
224
  e.define,
225
225
  e["define-bool"],
226
226
  e["define-number"]
227
227
  );
228
228
  }
229
- const ft = Ue(me);
230
- function ht(e) {
229
+ const ft = He(he);
230
+ function wt(e) {
231
231
  return new Promise((t) => {
232
232
  if (e === 0) return t(!1);
233
233
  const r = fe().listen(e);
@@ -237,7 +237,7 @@ function ht(e) {
237
237
  );
238
238
  });
239
239
  }
240
- async function wt(e) {
240
+ async function yt(e) {
241
241
  const t = fe(), r = await new Promise((n, l) => {
242
242
  const u = t.listen(e.port, () => {
243
243
  const w = u.address();
@@ -248,19 +248,19 @@ async function wt(e) {
248
248
  try {
249
249
  const u = {
250
250
  url: n.url,
251
- headers: Pt(n),
251
+ headers: vt(n),
252
252
  method: n.method,
253
- body: await bt(n)
253
+ body: await gt(n)
254
254
  }, w = await e.handleRequest(u);
255
- await yt(w, l);
255
+ await bt(w, l);
256
256
  } catch (u) {
257
257
  P.error(u), l.headersSent || (l.statusCode = 500, l.end("Internal Server Error"));
258
258
  }
259
259
  });
260
260
  const s = r.address().port, i = process.env.CODESPACE_NAME;
261
- return i && gt(s, i), await e.onBind(r, s);
261
+ return i && Pt(s, i), await e.onBind(r, s);
262
262
  }
263
- async function yt(e, t) {
263
+ async function bt(e, t) {
264
264
  const [r, o] = await Promise.all([
265
265
  e.headers,
266
266
  e.httpStatusCode
@@ -268,16 +268,16 @@ async function yt(e, t) {
268
268
  t.statusCode = o;
269
269
  for (const i in r)
270
270
  t.setHeader(i, r[i]);
271
- const s = He.fromWeb(e.stdout);
271
+ const s = _e.fromWeb(e.stdout);
272
272
  try {
273
- await _e(s, t);
273
+ await Fe(s, t);
274
274
  } catch (i) {
275
275
  if (i instanceof Error && "code" in i && i.code === "ERR_STREAM_PREMATURE_CLOSE")
276
276
  return;
277
277
  throw i;
278
278
  }
279
279
  }
280
- const bt = async (e) => await new Promise((t) => {
280
+ const gt = async (e) => await new Promise((t) => {
281
281
  const r = [];
282
282
  e.on("data", (o) => {
283
283
  r.push(o);
@@ -285,7 +285,7 @@ const bt = async (e) => await new Promise((t) => {
285
285
  t(new Uint8Array(Buffer.concat(r)));
286
286
  });
287
287
  });
288
- async function gt(e, t) {
288
+ async function Pt(e, t) {
289
289
  P.log(`Publishing port ${e}...`);
290
290
  const r = `gh codespace ports visibility ${e}:public -c ${t}`;
291
291
  for (let o = 0; o < 10; o++)
@@ -296,17 +296,17 @@ async function gt(e, t) {
296
296
  await new Promise((s) => setTimeout(s, 2e3));
297
297
  }
298
298
  }
299
- const Pt = (e) => {
299
+ const vt = (e) => {
300
300
  const t = {};
301
301
  if (e.rawHeaders && e.rawHeaders.length)
302
302
  for (let r = 0; r < e.rawHeaders.length; r += 2)
303
303
  t[e.rawHeaders[r].toLowerCase()] = e.rawHeaders[r + 1];
304
304
  return t;
305
305
  };
306
- function vt(e) {
306
+ function St(e) {
307
307
  return /^latest$|^trunk$|^nightly$|^(?:(\d+)\.(\d+)(?:\.(\d+))?)((?:-beta(?:\d+)?)|(?:-RC(?:\d+)?))?$/.test(e);
308
308
  }
309
- async function St({
309
+ async function xt({
310
310
  sourceString: e,
311
311
  blueprintMayReadAdjacentFiles: t
312
312
  }) {
@@ -315,9 +315,9 @@ async function St({
315
315
  if (e.startsWith("http://") || e.startsWith("https://"))
316
316
  return await Be(e);
317
317
  let r = d.resolve(process.cwd(), e);
318
- if (!p.existsSync(r))
318
+ if (!c.existsSync(r))
319
319
  throw new Error(`Blueprint file does not exist: ${r}`);
320
- const o = p.statSync(r);
320
+ const o = c.statSync(r);
321
321
  if (o.isDirectory() && (r = d.join(r, "blueprint.json")), !o.isFile() && o.isSymbolicLink())
322
322
  throw new Error(
323
323
  `Blueprint path is neither a file nor a directory: ${r}`
@@ -325,11 +325,11 @@ async function St({
325
325
  const s = d.extname(r);
326
326
  switch (s) {
327
327
  case ".zip":
328
- return Ve.fromArrayBuffer(
329
- p.readFileSync(r).buffer
328
+ return Ye.fromArrayBuffer(
329
+ c.readFileSync(r).buffer
330
330
  );
331
331
  case ".json": {
332
- const i = p.readFileSync(r, "utf-8");
332
+ const i = c.readFileSync(r, "utf-8");
333
333
  try {
334
334
  JSON.parse(i);
335
335
  } catch {
@@ -337,9 +337,9 @@ async function St({
337
337
  `Blueprint file at ${r} is not a valid JSON file`
338
338
  );
339
339
  }
340
- const n = d.dirname(r), l = new Ne(n);
341
- return new Oe([
342
- new je({
340
+ const n = d.dirname(r), l = new Oe(n);
341
+ return new je([
342
+ new Ve({
343
343
  "blueprint.json": i
344
344
  }),
345
345
  /**
@@ -365,7 +365,7 @@ You can allow this Blueprint to read files from the same parent directory by exp
365
365
  );
366
366
  }
367
367
  }
368
- class xt {
368
+ class Et {
369
369
  constructor(t, r) {
370
370
  this.args = t, this.siteUrl = r.siteUrl, this.phpVersion = t.php, this.cliOutput = r.cliOutput;
371
371
  }
@@ -386,7 +386,7 @@ class xt {
386
386
  fileLockManagerPort: r,
387
387
  nativeInternalDirPath: o
388
388
  }) {
389
- const s = ue(t.phpPort);
389
+ const s = de(t.phpPort);
390
390
  await s.useFileLockManager(r);
391
391
  const i = {
392
392
  ...this.args,
@@ -401,17 +401,17 @@ class xt {
401
401
  nativeInternalDirPath: o,
402
402
  mountsBeforeWpInstall: this.args["mount-before-install"] || [],
403
403
  mountsAfterWpInstall: this.args.mount || [],
404
- constants: we(this.args)
404
+ constants: ye(this.args)
405
405
  };
406
406
  return await s.bootWorker(i), s;
407
407
  }
408
408
  }
409
- const V = d.join(q.homedir(), ".wordpress-playground");
410
- async function Et() {
409
+ const q = d.join(G.homedir(), ".wordpress-playground");
410
+ async function $t() {
411
411
  const e = typeof __dirname < "u" ? __dirname : import.meta.dirname;
412
412
  let t = d.join(e, "sqlite-database-integration.zip");
413
- if (!E.existsSync(t)) {
414
- const r = Ge(import.meta.url), o = d.dirname(
413
+ if (!$.existsSync(t)) {
414
+ const r = Qe(import.meta.url), o = d.dirname(
415
415
  r.resolve("@wp-playground/wordpress-builds/package.json")
416
416
  );
417
417
  t = d.join(
@@ -421,14 +421,14 @@ async function Et() {
421
421
  "sqlite-database-integration-trunk.zip"
422
422
  );
423
423
  }
424
- return new File([await E.readFile(t)], d.basename(t));
425
- }
426
- 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);
424
+ return new File([await $.readFile(t)], d.basename(t));
429
425
  }
430
426
  async function Tt(e, t, r) {
431
- const s = (await r.monitorFetch(fetch(e))).body.getReader(), i = `${t}.partial`, n = E.createWriteStream(i);
427
+ const o = d.join(q, t);
428
+ return $.existsSync(o) || ($.ensureDirSync(q), await It(e, o, r)), be(o);
429
+ }
430
+ async function It(e, t, r) {
431
+ const s = (await r.monitorFetch(fetch(e))).body.getReader(), i = `${t}.partial`, n = $.createWriteStream(i);
432
432
  for (; ; ) {
433
433
  const { done: l, value: u } = await s.read();
434
434
  if (u && n.write(u), l)
@@ -436,16 +436,16 @@ async function Tt(e, t, r) {
436
436
  }
437
437
  n.close(), n.closed || await new Promise((l, u) => {
438
438
  n.on("finish", () => {
439
- E.renameSync(i, t), l(null);
439
+ $.renameSync(i, t), l(null);
440
440
  }), n.on("error", (w) => {
441
- E.removeSync(i), u(w);
441
+ $.removeSync(i), u(w);
442
442
  });
443
443
  });
444
444
  }
445
- function ye(e, t) {
446
- return new File([E.readFileSync(e)], D(e));
445
+ function be(e, t) {
446
+ return new File([$.readFileSync(e)], R(e));
447
447
  }
448
- class It {
448
+ class kt {
449
449
  constructor(t, r) {
450
450
  this.args = t, this.siteUrl = r.siteUrl, this.cliOutput = r.cliOutput;
451
451
  }
@@ -454,23 +454,23 @@ class It {
454
454
  }
455
455
  async bootWordPress(t, r) {
456
456
  let o, s, i;
457
- const n = new Ye();
457
+ const n = new qe();
458
458
  if (this.args.wordpressInstallMode === "download-and-install") {
459
459
  let w = !1;
460
- n.addEventListener("progress", (S) => {
460
+ n.addEventListener("progress", (E) => {
461
461
  if (w)
462
462
  return;
463
- const { loaded: c, total: a } = S.detail, m = Math.floor(
464
- Math.min(100, 100 * c / a)
463
+ const { loaded: p, total: a } = E.detail, m = Math.floor(
464
+ Math.min(100, 100 * p / a)
465
465
  );
466
466
  w = m === 100, this.cliOutput.updateProgress(
467
467
  "Downloading WordPress",
468
468
  m
469
469
  );
470
- }), o = await ze(this.args.wp), i = d.join(
471
- V,
470
+ }), o = await Ge(this.args.wp), i = d.join(
471
+ q,
472
472
  `prebuilt-wp-content-for-wp-${o.version}.zip`
473
- ), s = p.existsSync(i) ? ye(i) : await $t(
473
+ ), s = c.existsSync(i) ? be(i) : await Tt(
474
474
  o.releaseUrl,
475
475
  `${o.version}.zip`,
476
476
  n
@@ -479,8 +479,8 @@ class It {
479
479
  );
480
480
  }
481
481
  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(
482
+ this.args.skipSqliteSetup ? (P.debug("Skipping SQLite integration plugin setup..."), l = void 0) : (this.cliOutput.updateProgress("Preparing SQLite database"), l = await $t()), this.cliOutput.updateProgress("Booting WordPress");
483
+ const u = await ee(
484
484
  this.getEffectiveBlueprint()
485
485
  );
486
486
  return await t.bootWordPress(
@@ -490,14 +490,14 @@ class It {
490
490
  wordpressInstallMode: this.args.wordpressInstallMode || "download-and-install",
491
491
  wordPressZip: s && await s.arrayBuffer(),
492
492
  sqliteIntegrationPluginZip: await l?.arrayBuffer(),
493
- constants: we(this.args)
493
+ constants: ye(this.args)
494
494
  },
495
495
  r
496
- ), i && !this.args["mount-before-install"] && !p.existsSync(i) && (this.cliOutput.updateProgress("Caching WordPress for next boot"), p.writeFileSync(
496
+ ), i && !this.args["mount-before-install"] && !c.existsSync(i) && (this.cliOutput.updateProgress("Caching WordPress for next boot"), c.writeFileSync(
497
497
  i,
498
498
  // Comlink proxy is not assignable to UniversalPHP but
499
499
  // proxies all method calls transparently at runtime.
500
- await De(
500
+ await Re(
501
501
  t,
502
502
  "/wordpress"
503
503
  )
@@ -508,11 +508,11 @@ class It {
508
508
  fileLockManagerPort: r,
509
509
  nativeInternalDirPath: o
510
510
  }) {
511
- const s = ue(
511
+ const s = de(
512
512
  t.phpPort
513
513
  );
514
514
  await s.isConnected();
515
- const i = await K(
515
+ const i = await ee(
516
516
  this.getEffectiveBlueprint()
517
517
  );
518
518
  return await s.useFileLockManager(r), await s.bootRequestHandler({
@@ -532,7 +532,7 @@ class It {
532
532
  }), await s.isReady(), s;
533
533
  }
534
534
  async compileInputBlueprint(t) {
535
- const r = this.getEffectiveBlueprint(), o = new qe();
535
+ const r = this.getEffectiveBlueprint(), o = new ze();
536
536
  let s = "", i = !1;
537
537
  return o.addEventListener("progress", (n) => {
538
538
  if (i)
@@ -540,26 +540,26 @@ class It {
540
540
  i = n.detail.progress === 100;
541
541
  const l = Math.floor(n.detail.progress);
542
542
  s = n.detail.caption || s || "Running Blueprint", this.cliOutput.updateProgress(s.trim(), l);
543
- }), await de(r, {
543
+ }), await pe(r, {
544
544
  progress: o,
545
545
  additionalSteps: t
546
546
  });
547
547
  }
548
548
  getEffectiveBlueprint() {
549
549
  const t = this.args.blueprint;
550
- return Ce(t) ? t : {
550
+ return De(t) ? t : {
551
551
  login: this.args.login,
552
552
  ...t || {},
553
553
  preferredVersions: {
554
- php: this.args.php ?? t?.preferredVersions?.php ?? M,
554
+ php: this.args.php ?? t?.preferredVersions?.php ?? C,
555
555
  wp: this.args.wp ?? t?.preferredVersions?.wp ?? "latest",
556
556
  ...t?.preferredVersions || {}
557
557
  }
558
558
  };
559
559
  }
560
560
  }
561
- async function kt(e, t = !0) {
562
- const o = `${d.basename(process.argv0)}${e}${process.pid}-`, s = await Xe({
561
+ async function Mt(e, t = !0) {
562
+ const o = `${d.basename(process.argv0)}${e}${process.pid}-`, s = await Ze({
563
563
  prefix: o,
564
564
  /*
565
565
  * Allow recursive cleanup on process exit.
@@ -571,16 +571,16 @@ async function kt(e, t = !0) {
571
571
  */
572
572
  unsafeCleanup: !0
573
573
  });
574
- return t && Ze(), s;
574
+ return t && Je(), s;
575
575
  }
576
- async function Mt(e, t, r) {
576
+ async function Ct(e, t, r) {
577
577
  const s = (await At(
578
578
  e,
579
579
  t,
580
580
  r
581
581
  )).map(
582
582
  (i) => new Promise((n) => {
583
- p.rm(i, { recursive: !0 }, (l) => {
583
+ c.rm(i, { recursive: !0 }, (l) => {
584
584
  l ? P.warn(
585
585
  `Failed to delete stale Playground temp dir: ${i}`,
586
586
  l
@@ -594,7 +594,7 @@ async function Mt(e, t, r) {
594
594
  }
595
595
  async function At(e, t, r) {
596
596
  try {
597
- const o = p.readdirSync(r).map((i) => d.join(r, i)), s = [];
597
+ const o = c.readdirSync(r).map((i) => d.join(r, i)), s = [];
598
598
  for (const i of o)
599
599
  await Bt(
600
600
  e,
@@ -607,7 +607,7 @@ async function At(e, t, r) {
607
607
  }
608
608
  }
609
609
  async function Bt(e, t, r) {
610
- if (!p.lstatSync(r).isDirectory())
610
+ if (!c.lstatSync(r).isDirectory())
611
611
  return !1;
612
612
  const s = d.basename(r);
613
613
  if (!s.includes(e))
@@ -621,15 +621,15 @@ async function Bt(e, t, r) {
621
621
  executableName: i[1],
622
622
  pid: i[2]
623
623
  };
624
- if (await Ct(n.pid, n.executableName))
624
+ if (await Dt(n.pid, n.executableName))
625
625
  return !1;
626
626
  const l = Date.now() - t;
627
- return p.statSync(r).mtime.getTime() < l;
627
+ return c.statSync(r).mtime.getTime() < l;
628
628
  }
629
- async function Ct(e, t) {
629
+ async function Dt(e, t) {
630
630
  const [r] = await new Promise(
631
631
  (o, s) => {
632
- Je.list(
632
+ Ke.list(
633
633
  {
634
634
  pid: e,
635
635
  name: t,
@@ -644,10 +644,10 @@ async function Ct(e, t) {
644
644
  );
645
645
  return !!r && r.pid === e && r.command === t;
646
646
  }
647
- function Dt(e) {
647
+ function Rt(e) {
648
648
  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
649
  }
650
- class Rt {
650
+ class Wt {
651
651
  constructor(t) {
652
652
  this.lastProgressLine = "", this.progressActive = !1, this.verbosity = t.verbosity, this.writeStream = t.writeStream || process.stdout;
653
653
  }
@@ -661,7 +661,7 @@ class Rt {
661
661
  * This prevents progress spam in logs - users only see the final outcome.
662
662
  */
663
663
  get shouldRender() {
664
- return Dt(this.writeStream);
664
+ return Rt(this.writeStream);
665
665
  }
666
666
  get isQuiet() {
667
667
  return this.verbosity === "quiet";
@@ -810,12 +810,12 @@ ${this.green("Ready!")} WordPress is running on ${this.bold(t)} ${this.dim(`(${r
810
810
  );
811
811
  }
812
812
  }
813
- const be = {
814
- Quiet: { name: "quiet", severity: _.Fatal },
815
- Normal: { name: "normal", severity: _.Info },
816
- Debug: { name: "debug", severity: _.Debug }
813
+ const ge = {
814
+ Quiet: { name: "quiet", severity: N.Fatal },
815
+ Normal: { name: "normal", severity: N.Info },
816
+ Debug: { name: "debug", severity: N.Debug }
817
817
  };
818
- async function yr(e) {
818
+ async function br(e) {
819
819
  try {
820
820
  const t = {
821
821
  "site-url": {
@@ -825,8 +825,8 @@ async function yr(e) {
825
825
  php: {
826
826
  describe: "PHP version to use.",
827
827
  type: "string",
828
- default: M,
829
- choices: R
828
+ default: C,
829
+ choices: W
830
830
  },
831
831
  wp: {
832
832
  describe: "WordPress version to use.",
@@ -838,7 +838,7 @@ async function yr(e) {
838
838
  type: "string",
839
839
  nargs: 2,
840
840
  array: !0,
841
- coerce: dt
841
+ coerce: pt
842
842
  },
843
843
  "define-bool": {
844
844
  describe: 'Define PHP boolean constants (can be used multiple times). Format: NAME value. Value must be "true", "false", "1", or "0". Examples: --define-bool WP_DEBUG true --define-bool MY_FEATURE false',
@@ -852,7 +852,7 @@ async function yr(e) {
852
852
  type: "string",
853
853
  nargs: 2,
854
854
  array: !0,
855
- coerce: pt
855
+ coerce: mt
856
856
  },
857
857
  // @TODO: Support read-only mounts, e.g. via WORKERFS, a custom
858
858
  // ReadOnlyNODEFS, or by copying the files into MEMFS
@@ -860,27 +860,29 @@ async function yr(e) {
860
860
  describe: "Mount a directory to the PHP runtime (can be used multiple times). Format: /host/path:/vfs/path",
861
861
  type: "array",
862
862
  string: !0,
863
- coerce: F
863
+ nargs: 1,
864
+ coerce: O
864
865
  },
865
866
  "mount-before-install": {
866
867
  describe: "Mount a directory to the PHP runtime before WordPress installation (can be used multiple times). Format: /host/path:/vfs/path",
867
868
  type: "array",
868
869
  string: !0,
869
- coerce: F
870
+ nargs: 1,
871
+ coerce: O
870
872
  },
871
873
  "mount-dir": {
872
874
  describe: 'Mount a directory to the PHP runtime (can be used multiple times). Format: "/host/path" "/vfs/path"',
873
875
  type: "array",
874
876
  nargs: 2,
875
877
  array: !0,
876
- coerce: ie
878
+ coerce: ne
877
879
  },
878
880
  "mount-dir-before-install": {
879
881
  describe: 'Mount a directory before WordPress installation (can be used multiple times). Format: "/host/path" "/vfs/path"',
880
882
  type: "string",
881
883
  nargs: 2,
882
884
  array: !0,
883
- coerce: ie
885
+ coerce: ne
884
886
  },
885
887
  login: {
886
888
  describe: "Should log the user in",
@@ -927,7 +929,7 @@ async function yr(e) {
927
929
  verbosity: {
928
930
  describe: "Output logs and progress messages.",
929
931
  type: "string",
930
- choices: Object.values(be).map(
932
+ choices: Object.values(ge).map(
931
933
  (a) => a.name
932
934
  ),
933
935
  default: "normal"
@@ -1032,8 +1034,8 @@ Warning: Following symlinks will expose files outside mounted directories to Pla
1032
1034
  php: {
1033
1035
  describe: "PHP version to use.",
1034
1036
  type: "string",
1035
- default: M,
1036
- choices: R
1037
+ default: C,
1038
+ choices: W
1037
1039
  },
1038
1040
  wp: {
1039
1041
  describe: "WordPress version to use.",
@@ -1078,7 +1080,7 @@ Warning: Following symlinks will expose files outside mounted directories to Pla
1078
1080
  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.",
1079
1081
  type: "array",
1080
1082
  string: !0,
1081
- coerce: F
1083
+ coerce: O
1082
1084
  },
1083
1085
  reset: {
1084
1086
  describe: "Deletes the stored site directory and starts a new site from scratch.",
@@ -1102,7 +1104,7 @@ Warning: Following symlinks will expose files outside mounted directories to Pla
1102
1104
  type: "string",
1103
1105
  default: "wordpress.zip"
1104
1106
  }
1105
- }, i = Fe(e).usage("Usage: wp-playground <command> [options]").command(
1107
+ }, i = Ne(e).usage("Usage: wp-playground <command> [options]").command(
1106
1108
  "start",
1107
1109
  "Start a local WordPress server with automatic project detection (recommended)",
1108
1110
  (a) => a.usage(
@@ -1137,6 +1139,10 @@ Examples:
1137
1139
  ...t,
1138
1140
  ...s
1139
1141
  })
1142
+ ).command(
1143
+ "php",
1144
+ "Run a PHP script",
1145
+ (a) => a.options({ ...t })
1140
1146
  ).demandCommand(1, "Please specify a command").strictCommands().conflicts(
1141
1147
  "experimental-unsafe-ide-integration",
1142
1148
  "experimental-devtools"
@@ -1146,7 +1152,7 @@ Examples:
1146
1152
  a && a.includes("Please specify a command") && (y.showHelp(), console.error(`
1147
1153
  ` + a), process.exit(1)), console.error(a), process.exit(1);
1148
1154
  }).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))
1155
+ 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" && !St(a.wp))
1150
1156
  try {
1151
1157
  new URL(a.wp);
1152
1158
  } catch {
@@ -1166,7 +1172,7 @@ Examples:
1166
1172
  if (a["auto-mount"]) {
1167
1173
  let y = !1;
1168
1174
  try {
1169
- y = p.statSync(
1175
+ y = c.statSync(
1170
1176
  a["auto-mount"]
1171
1177
  ).isDirectory();
1172
1178
  } catch {
@@ -1189,9 +1195,13 @@ Examples:
1189
1195
  });
1190
1196
  i.wrap(i.terminalWidth());
1191
1197
  const n = await i.argv, l = n._[0];
1192
- ["start", "run-blueprint", "server", "build-snapshot"].includes(
1193
- l
1194
- ) || (i.showHelp(), process.exit(1));
1198
+ [
1199
+ "start",
1200
+ "run-blueprint",
1201
+ "server",
1202
+ "build-snapshot",
1203
+ "php"
1204
+ ].includes(l) || (i.showHelp(), process.exit(1));
1195
1205
  const u = n.define || {};
1196
1206
  !("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
1207
  const w = {
@@ -1206,25 +1216,25 @@ Examples:
1206
1216
  ...n["mount-before-install"] || [],
1207
1217
  ...n["mount-dir-before-install"] || []
1208
1218
  ]
1209
- }, S = await Lt(w);
1210
- S === void 0 && process.exit(0);
1211
- const c = /* @__PURE__ */ (() => {
1219
+ }, E = await Ut(w);
1220
+ E === void 0 && process.exit(0);
1221
+ const p = /* @__PURE__ */ (() => {
1212
1222
  let a;
1213
1223
  return async () => {
1214
- a === void 0 && (a = S[Symbol.asyncDispose]()), await a, process.exit(0);
1224
+ a === void 0 && (a = E[Symbol.asyncDispose]()), await a, process.exit(0);
1215
1225
  };
1216
1226
  })();
1217
- return process.on("SIGINT", c), process.on("SIGTERM", c), {
1227
+ return process.on("SIGINT", p), process.on("SIGTERM", p), {
1218
1228
  [Symbol.asyncDispose]: async () => {
1219
- process.off("SIGINT", c), process.off("SIGTERM", c), await S[Symbol.asyncDispose]();
1229
+ process.off("SIGINT", p), process.off("SIGTERM", p), await E[Symbol.asyncDispose]();
1220
1230
  },
1221
- [ge]: { cliServer: S }
1231
+ [Pe]: { cliServer: E }
1222
1232
  };
1223
1233
  } catch (t) {
1224
1234
  if (console.error(t), !(t instanceof Error))
1225
1235
  throw t;
1226
1236
  if (process.argv.includes("--debug"))
1227
- Ee(t);
1237
+ $e(t);
1228
1238
  else {
1229
1239
  const o = [];
1230
1240
  let s = t;
@@ -1238,22 +1248,22 @@ Examples:
1238
1248
  process.exit(1);
1239
1249
  }
1240
1250
  }
1241
- function ae(e, t) {
1251
+ function le(e, t) {
1242
1252
  return e.find(
1243
1253
  (r) => r.vfsPath.replace(/\/$/, "") === t.replace(/\/$/, "")
1244
1254
  );
1245
1255
  }
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;
1247
- async function Lt(e) {
1256
+ const Pe = Symbol("playground-cli-testing"), I = (e) => process.stdout.isTTY ? "\x1B[1m" + e + "\x1B[0m" : e, Lt = (e) => process.stdout.isTTY ? "\x1B[31m" + e + "\x1B[0m" : e, ue = (e) => process.stdout.isTTY ? `\x1B[2m${e}\x1B[0m` : e, D = (e) => process.stdout.isTTY ? `\x1B[3m${e}\x1B[0m` : e, j = (e) => process.stdout.isTTY ? `\x1B[33m${e}\x1B[0m` : e;
1257
+ async function Ut(e) {
1248
1258
  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(
1259
+ const r = e.internalCookieStore ? new Te() : void 0, o = [], s = /* @__PURE__ */ new Map();
1260
+ if (e.command === "start" && (e = Ht(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) {
1261
+ const p = Object.values(ge).find(
1252
1262
  (a) => a.name === e.verbosity
1253
1263
  ).severity;
1254
- P.setSeverityFilterLevel(c);
1264
+ P.setSeverityFilterLevel(p);
1255
1265
  }
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) {
1266
+ 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
1267
  if (e.phpmyadmin === !0 && (e.phpmyadmin = "/phpmyadmin"), e.skipSqliteSetup)
1258
1268
  throw new Error(
1259
1269
  "--phpmyadmin requires SQLite. Cannot be used with --skip-sqlite-setup."
@@ -1261,15 +1271,15 @@ async function Lt(e) {
1261
1271
  e.pathAliases = [
1262
1272
  {
1263
1273
  urlPrefix: e.phpmyadmin,
1264
- fsPath: oe
1274
+ fsPath: se
1265
1275
  }
1266
1276
  ];
1267
1277
  }
1268
- const i = new Rt({
1278
+ const i = new Wt({
1269
1279
  verbosity: e.verbosity || "normal"
1270
1280
  });
1271
1281
  e.command === "server" && (i.printBanner(), i.printConfig({
1272
- phpVersion: e.php || M,
1282
+ phpVersion: e.php || C,
1273
1283
  wpVersion: e.wp || "latest",
1274
1284
  port: e.port ?? 9400,
1275
1285
  xdebug: !!e.xdebug,
@@ -1282,30 +1292,30 @@ async function Lt(e) {
1282
1292
  ],
1283
1293
  blueprint: typeof e.blueprint == "string" ? e.blueprint : void 0
1284
1294
  }));
1285
- const n = e.command === "server" ? e.port ?? 9400 : 0, l = new Te();
1295
+ const n = e.command === "server" ? e.port ?? 9400 : 0, l = new Ie();
1286
1296
  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),
1297
+ const E = await yt({
1298
+ port: e.port ? e.port : await wt(n) ? 0 : n,
1299
+ onBind: async (p, a) => {
1300
+ const m = "127.0.0.1", y = `http://${m}:${a}`, L = e["site-url"] || y, U = 6, Q = "-playground-cli-site-", T = await Mt(Q);
1301
+ P.debug(`Native temp dir for VFS root: ${T.path}`);
1302
+ const A = "WP Playground CLI - Listen for Xdebug", X = ".playground-xdebug-root", H = d.join(process.cwd(), X);
1303
+ if (await et(H), e.xdebug) {
1304
+ const h = {
1305
+ hostPath: d.join(".", d.sep, X),
1296
1306
  vfsPath: "/"
1297
1307
  };
1298
- if (R.indexOf(
1299
- e.php || M
1300
- ) <= R.indexOf("8.5"))
1301
- await re(
1302
- $.path,
1303
- U,
1308
+ if (W.indexOf(
1309
+ e.php || C
1310
+ ) <= W.indexOf("8.5"))
1311
+ await oe(
1312
+ T.path,
1313
+ H,
1304
1314
  process.platform
1305
- ), e.xdebug = et({
1315
+ ), e.xdebug = tt({
1306
1316
  cwd: process.cwd(),
1307
1317
  mounts: [
1308
- f,
1318
+ h,
1309
1319
  ...e["mount-before-install"] || [],
1310
1320
  ...e.mount || []
1311
1321
  ],
@@ -1317,43 +1327,43 @@ async function Lt(e) {
1317
1327
  "/proc/"
1318
1328
  ]
1319
1329
  }), console.log(I("Xdebug configured successfully")), console.log(
1320
- N("Playground source root: ") + ".playground-xdebug-root" + C(
1321
- le(
1330
+ j("Playground source root: ") + ".playground-xdebug-root" + D(
1331
+ ue(
1322
1332
  " – you can set breakpoints and preview Playground's VFS structure in there."
1323
1333
  )
1324
1334
  )
1325
1335
  );
1326
1336
  else if (e.experimentalUnsafeIdeIntegration) {
1327
- await re(
1328
- $.path,
1329
- U,
1337
+ await oe(
1338
+ T.path,
1339
+ H,
1330
1340
  process.platform
1331
1341
  );
1332
1342
  try {
1333
- await tt(
1343
+ await rt(
1334
1344
  A,
1335
1345
  process.cwd()
1336
1346
  );
1337
- const h = typeof e.xdebug == "object" ? e.xdebug : {}, b = await rt({
1347
+ const f = typeof e.xdebug == "object" ? e.xdebug : {}, b = await ot({
1338
1348
  name: A,
1339
1349
  host: m,
1340
1350
  port: a,
1341
1351
  ides: e.experimentalUnsafeIdeIntegration,
1342
1352
  cwd: process.cwd(),
1343
1353
  mounts: [
1344
- f,
1354
+ h,
1345
1355
  ...e["mount-before-install"] || [],
1346
1356
  ...e.mount || []
1347
1357
  ],
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(
1358
+ ideKey: f.ideKey || "WPPLAYGROUNDCLI"
1359
+ }), v = e.experimentalUnsafeIdeIntegration, S = v.includes("vscode"), x = v.includes("phpstorm"), B = Object.values(b);
1360
+ console.log(""), B.length > 0 ? (console.log(
1351
1361
  I("Xdebug configured successfully")
1352
1362
  ), console.log(
1353
- N("Updated IDE config: ") + X.join(" ")
1363
+ j("Updated IDE config: ") + B.join(" ")
1354
1364
  ), console.log(
1355
- N("Playground source root: ") + ".playground-xdebug-root" + C(
1356
- le(
1365
+ j("Playground source root: ") + ".playground-xdebug-root" + D(
1366
+ ue(
1357
1367
  " – you can set breakpoints and preview Playground's VFS structure in there."
1358
1368
  )
1359
1369
  )
@@ -1361,7 +1371,7 @@ async function Lt(e) {
1361
1371
  I("Xdebug configuration failed.")
1362
1372
  ), console.log(
1363
1373
  "No IDE-specific project settings directory was found in the current working directory."
1364
- )), console.log(""), x && b.vscode && (console.log(
1374
+ )), console.log(""), S && b.vscode && (console.log(
1365
1375
  I("VS Code / Cursor instructions:")
1366
1376
  ), console.log(
1367
1377
  " 1. Ensure you have installed an IDE extension for PHP Debugging"
@@ -1372,15 +1382,15 @@ async function Lt(e) {
1372
1382
  ), console.log(
1373
1383
  " 2. Open the Run and Debug panel on the left sidebar"
1374
1384
  ), console.log(
1375
- ` 3. Select "${C(
1385
+ ` 3. Select "${D(
1376
1386
  A
1377
1387
  )}" from the dropdown`
1378
1388
  ), console.log(' 3. Click "start debugging"'), console.log(
1379
1389
  " 5. Set a breakpoint. For example, in .playground-xdebug-root/wordpress/index.php"
1380
1390
  ), console.log(
1381
1391
  " 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(
1392
+ ), x && console.log("")), x && b.phpstorm && (console.log(I("PhpStorm instructions:")), console.log(
1393
+ ` 1. Choose "${D(
1384
1394
  A
1385
1395
  )}" debug configuration in the toolbar`
1386
1396
  ), console.log(
@@ -1390,22 +1400,22 @@ async function Lt(e) {
1390
1400
  ), console.log(
1391
1401
  " 4. Visit Playground in your browser to hit the breakpoint"
1392
1402
  )), console.log("");
1393
- } catch (h) {
1403
+ } catch (f) {
1394
1404
  throw new Error("Could not configure Xdebug", {
1395
- cause: h
1405
+ cause: f
1396
1406
  });
1397
1407
  }
1398
1408
  }
1399
1409
  }
1400
- const Pe = d.dirname($.path), ve = 2 * 24 * 60 * 60 * 1e3;
1401
- Mt(
1402
- z,
1403
- ve,
1404
- Pe
1410
+ const ve = d.dirname(T.path), Se = 2 * 24 * 60 * 60 * 1e3;
1411
+ Ct(
1412
+ Q,
1413
+ Se,
1414
+ ve
1405
1415
  );
1406
- const Q = d.join($.path, "internal");
1407
- j(Q);
1408
- const Se = [
1416
+ const Z = d.join(T.path, "internal");
1417
+ Y(Z);
1418
+ const xe = [
1409
1419
  "wordpress",
1410
1420
  "tools",
1411
1421
  // Note: These dirs are from Emscripten's "default dirs" list:
@@ -1417,91 +1427,91 @@ async function Lt(e) {
1417
1427
  "tmp",
1418
1428
  "home"
1419
1429
  ];
1420
- for (const f of Se) {
1421
- const g = (b) => b.vfsPath === `/${f}`;
1430
+ for (const h of xe) {
1431
+ const g = (b) => b.vfsPath === `/${h}`;
1422
1432
  if (!(e["mount-before-install"]?.some(g) || e.mount?.some(g))) {
1423
1433
  const b = d.join(
1424
- $.path,
1425
- f
1434
+ T.path,
1435
+ h
1426
1436
  );
1427
- j(b), e["mount-before-install"] === void 0 && (e["mount-before-install"] = []), e["mount-before-install"].unshift({
1428
- vfsPath: `/${f}`,
1437
+ Y(b), e["mount-before-install"] === void 0 && (e["mount-before-install"] = []), e["mount-before-install"].unshift({
1438
+ vfsPath: `/${h}`,
1429
1439
  hostPath: b
1430
1440
  });
1431
1441
  }
1432
1442
  }
1433
1443
  if (e["mount-before-install"])
1434
- for (const f of e["mount-before-install"])
1444
+ for (const h of e["mount-before-install"])
1435
1445
  P.debug(
1436
- `Mount before WP install: ${f.vfsPath} -> ${f.hostPath}`
1446
+ `Mount before WP install: ${h.vfsPath} -> ${h.hostPath}`
1437
1447
  );
1438
1448
  if (e.mount)
1439
- for (const f of e.mount)
1449
+ for (const h of e.mount)
1440
1450
  P.debug(
1441
- `Mount after WP install: ${f.vfsPath} -> ${f.hostPath}`
1451
+ `Mount after WP install: ${h.vfsPath} -> ${h.hostPath}`
1442
1452
  );
1443
1453
  let k;
1444
- e["experimental-blueprints-v2-runner"] ? k = new xt(e, {
1445
- siteUrl: W,
1454
+ e["experimental-blueprints-v2-runner"] ? k = new Et(e, {
1455
+ siteUrl: L,
1446
1456
  cliOutput: i
1447
- }) : (k = new It(e, {
1448
- siteUrl: W,
1457
+ }) : (k = new kt(e, {
1458
+ siteUrl: L,
1449
1459
  cliOutput: i
1450
- }), typeof e.blueprint == "string" && (e.blueprint = await St({
1460
+ }), typeof e.blueprint == "string" && (e.blueprint = await xt({
1451
1461
  sourceString: e.blueprint,
1452
1462
  blueprintMayReadAdjacentFiles: e["blueprint-may-read-adjacent-files"] === !0
1453
1463
  })));
1454
- let H = !1;
1455
- const B = async function() {
1456
- H || (H = !0, await Promise.all(
1464
+ let _ = !1;
1465
+ const M = async function() {
1466
+ _ || (_ = !0, await Promise.all(
1457
1467
  o.map(async (g) => {
1458
1468
  await s.get(g)?.dispose(), await g.worker.terminate();
1459
1469
  })
1460
- ), c && await new Promise((g) => {
1461
- c.close(g), c.closeAllConnections();
1462
- }), await $.cleanup());
1470
+ ), p && await new Promise((g) => {
1471
+ p.close(g), p.closeAllConnections();
1472
+ }), await T.cleanup());
1463
1473
  };
1464
1474
  try {
1465
- const f = [], g = k.getWorkerType();
1466
- for (let h = 0; h < L; h++) {
1467
- const b = Ht(g, {
1475
+ const h = [], g = k.getWorkerType();
1476
+ for (let f = 0; f < U; f++) {
1477
+ const b = _t(g, {
1468
1478
  onExit: (v) => {
1469
- H || v === 0 && P.error(
1470
- `Worker ${h} exited with code ${v}
1479
+ _ || v === 0 && P.error(
1480
+ `Worker ${f} exited with code ${v}
1471
1481
  `
1472
1482
  );
1473
1483
  }
1474
1484
  }).then(
1475
1485
  async (v) => {
1476
1486
  o.push(v);
1477
- const x = await _t(l), T = await k.bootRequestHandler({
1487
+ const S = await Ft(l), x = await k.bootRequestHandler({
1478
1488
  worker: v,
1479
- fileLockManagerPort: x,
1480
- nativeInternalDirPath: Q
1489
+ fileLockManagerPort: S,
1490
+ nativeInternalDirPath: Z
1481
1491
  });
1482
1492
  return s.set(
1483
1493
  v,
1484
- T
1485
- ), [v, T];
1494
+ x
1495
+ ), [v, x];
1486
1496
  }
1487
1497
  );
1488
- f.push(b), h === 0 && await b;
1498
+ h.push(b), f === 0 && await b;
1489
1499
  }
1490
- await Promise.all(f), t = Ie(
1500
+ await Promise.all(h), t = ke(
1491
1501
  o.map(
1492
- (h) => s.get(h)
1502
+ (f) => s.get(f)
1493
1503
  )
1494
1504
  );
1495
1505
  {
1496
- const h = new ce(), b = h.port1, v = h.port2;
1497
- if (await ke(
1506
+ const f = new ce(), b = f.port1, v = f.port2;
1507
+ if (await Me(
1498
1508
  {
1499
1509
  applyPostInstallMountsToAllWorkers: async () => {
1500
1510
  await Promise.all(
1501
1511
  Array.from(
1502
1512
  s.values()
1503
1513
  ).map(
1504
- (x) => x.mountAfterWordPressInstall(
1514
+ (S) => S.mountAfterWordPressInstall(
1505
1515
  e.mount || []
1506
1516
  )
1507
1517
  )
@@ -1514,59 +1524,83 @@ async function Lt(e) {
1514
1524
  t,
1515
1525
  v
1516
1526
  ), b.close(), u = !0, !e["experimental-blueprints-v2-runner"]) {
1517
- const x = await k.compileInputBlueprint(
1527
+ const S = await k.compileInputBlueprint(
1518
1528
  e["additional-blueprint-steps"] || []
1519
1529
  );
1520
- x && await ee(
1521
- x,
1530
+ S && await te(
1531
+ S,
1522
1532
  t
1523
1533
  );
1524
1534
  }
1525
1535
  if (e.phpmyadmin && !await t.fileExists(
1526
- `${oe}/index.php`
1536
+ `${se}/index.php`
1527
1537
  )) {
1528
- const x = await st(), T = await de({ steps: x });
1529
- await ee(T, t);
1538
+ const S = await it(), x = await pe({ steps: S });
1539
+ await te(x, t);
1530
1540
  }
1531
1541
  if (e.command === "build-snapshot") {
1532
- await Nt(t, e.outfile), i.printStatus(`Exported to ${e.outfile}`), await B();
1542
+ await Ot(t, e.outfile), i.printStatus(`Exported to ${e.outfile}`), await M();
1533
1543
  return;
1534
1544
  } else if (e.command === "run-blueprint") {
1535
- i.finishProgress("Done"), await B();
1545
+ i.finishProgress("Done"), await M();
1536
1546
  return;
1547
+ } else if (e.command === "php") {
1548
+ const S = [
1549
+ // @TODO: Import this from somewhere?
1550
+ // Hardcoding it feels fragile.
1551
+ "/internal/shared/bin/php",
1552
+ ...(e._ || []).slice(1)
1553
+ ], x = await t.cli(S), [B] = await Promise.all([
1554
+ x.exitCode,
1555
+ x.stdout.pipeTo(
1556
+ new WritableStream({
1557
+ write(F) {
1558
+ process.stdout.write(F);
1559
+ }
1560
+ })
1561
+ ),
1562
+ x.stderr.pipeTo(
1563
+ new WritableStream({
1564
+ write(F) {
1565
+ process.stderr.write(F);
1566
+ }
1567
+ })
1568
+ )
1569
+ ]);
1570
+ await M(), process.exit(B);
1537
1571
  }
1538
1572
  }
1539
- if (i.finishProgress(), i.printReady(y, L), e.phpmyadmin) {
1540
- const h = d.join(
1573
+ if (i.finishProgress(), i.printReady(y, U), e.phpmyadmin) {
1574
+ const f = d.join(
1541
1575
  e.phpmyadmin,
1542
- it
1576
+ nt
1543
1577
  );
1544
1578
  i.printPhpMyAdminUrl(
1545
- new URL(h, y).toString()
1579
+ new URL(f, y).toString()
1546
1580
  );
1547
1581
  }
1548
- return e.xdebug && e.experimentalDevtools && (await Qe({
1582
+ return e.xdebug && e.experimentalDevtools && (await Xe({
1549
1583
  phpInstance: t,
1550
1584
  phpRoot: "/wordpress"
1551
1585
  })).start(), {
1552
1586
  playground: t,
1553
- server: c,
1587
+ server: p,
1554
1588
  serverUrl: y,
1555
- [Symbol.asyncDispose]: B,
1556
- [ge]: {
1557
- workerThreadCount: L
1589
+ [Symbol.asyncDispose]: M,
1590
+ [Pe]: {
1591
+ workerThreadCount: U
1558
1592
  }
1559
1593
  };
1560
- } catch (f) {
1594
+ } catch (h) {
1561
1595
  if (e.verbosity !== "debug")
1562
- throw f;
1596
+ throw h;
1563
1597
  let g = "";
1564
- throw await t?.fileExists(Z) && (g = await t.readFileAsText(Z)), await B(), new Error(g, { cause: f });
1598
+ throw await t?.fileExists(J) && (g = await t.readFileAsText(J)), await M(), new Error(g, { cause: h });
1565
1599
  }
1566
1600
  },
1567
- async handleRequest(c) {
1601
+ async handleRequest(p) {
1568
1602
  if (!u)
1569
- return J.forHttpCode(
1603
+ return K.forHttpCode(
1570
1604
  502,
1571
1605
  "WordPress is not ready yet"
1572
1606
  );
@@ -1575,20 +1609,20 @@ async function Lt(e) {
1575
1609
  const m = {
1576
1610
  "Content-Type": ["text/plain"],
1577
1611
  "Content-Length": ["0"],
1578
- Location: [c.url]
1612
+ Location: [p.url]
1579
1613
  };
1580
- return c.headers?.cookie?.includes(
1614
+ return p.headers?.cookie?.includes(
1581
1615
  "playground_auto_login_already_happened"
1582
1616
  ) && (m["Set-Cookie"] = [
1583
1617
  "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())
1618
+ ]), K.fromPHPResponse(
1619
+ new Ce(302, m, new Uint8Array())
1586
1620
  );
1587
1621
  }
1588
- r && (c = {
1589
- ...c,
1622
+ r && (p = {
1623
+ ...p,
1590
1624
  headers: {
1591
- ...c.headers,
1625
+ ...p.headers,
1592
1626
  // While we have an internal cookie store, we
1593
1627
  // completely replace the incoming request's Cookie
1594
1628
  // header with the cookies from our store. This avoids
@@ -1597,28 +1631,28 @@ async function Lt(e) {
1597
1631
  cookie: r.getCookieRequestHeader()
1598
1632
  }
1599
1633
  });
1600
- const a = await t.requestStreamed(c);
1634
+ const a = await t.requestStreamed(p);
1601
1635
  if (r) {
1602
1636
  const m = await a.headers;
1603
1637
  r.rememberCookiesFromResponseHeaders(m), delete m["set-cookie"];
1604
1638
  }
1605
1639
  return a;
1606
1640
  }
1607
- }).catch((c) => {
1608
- i.printError(c.message), process.exit(1);
1641
+ }).catch((p) => {
1642
+ i.printError(p.message), process.exit(1);
1609
1643
  });
1610
- return S && e.command === "start" && !e.skipBrowser && Ft(S.serverUrl), S;
1644
+ return E && e.command === "start" && !e.skipBrowser && Nt(E.serverUrl), E;
1611
1645
  }
1612
- function Ut(e) {
1646
+ function Ht(e) {
1613
1647
  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(
1648
+ e.noAutoMount || (t.autoMount = d.resolve(process.cwd(), t.path ?? ""), t = we(t), delete t.autoMount);
1649
+ const r = le(
1616
1650
  t["mount-before-install"] || [],
1617
1651
  "/wordpress"
1618
- ) || ae(t.mount || [], "/wordpress");
1652
+ ) || le(t.mount || [], "/wordpress");
1619
1653
  if (r)
1620
1654
  console.log("Site files stored at:", r?.hostPath), e.reset && (console.log(""), console.log(
1621
- Wt(
1655
+ Lt(
1622
1656
  "This site is not managed by Playground CLI and cannot be reset."
1623
1657
  )
1624
1658
  ), console.log(
@@ -1627,15 +1661,15 @@ function Ut(e) {
1627
1661
  "You may still remove the site's directory manually if you wish."
1628
1662
  ), process.exit(1));
1629
1663
  else {
1630
- const o = t.autoMount || process.cwd(), s = ot("sha256").update(o).digest("hex"), i = q.homedir(), n = d.join(
1664
+ const o = t.autoMount || process.cwd(), s = st("sha256").update(o).digest("hex"), i = G.homedir(), n = d.join(
1631
1665
  i,
1632
1666
  ".wordpress-playground/sites",
1633
1667
  s
1634
1668
  );
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"] = [
1669
+ console.log("Site files stored at:", n), z(n) && e.reset && (console.log("Resetting site..."), We(n, { recursive: !0 })), Y(n, { recursive: !0 }), t["mount-before-install"] = [
1636
1670
  ...t["mount-before-install"] || [],
1637
1671
  { vfsPath: "/wordpress", hostPath: n }
1638
- ], t.wordpressInstallMode = We(n).length === 0 ? (
1672
+ ], t.wordpressInstallMode = Le(n).length === 0 ? (
1639
1673
  // Only download WordPress on the first run when the site directory is still
1640
1674
  // empty.
1641
1675
  "download-and-install"
@@ -1646,11 +1680,11 @@ function Ut(e) {
1646
1680
  }
1647
1681
  return t;
1648
1682
  }
1649
- const O = new xe();
1650
- function Ht(e, { onExit: t } = {}) {
1683
+ const V = new Ee();
1684
+ function _t(e, { onExit: t } = {}) {
1651
1685
  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();
1686
+ 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) => {
1687
+ const i = V.claim();
1654
1688
  r.once("message", function(l) {
1655
1689
  l.command === "worker-script-initialized" && o({
1656
1690
  processId: i,
@@ -1658,7 +1692,7 @@ function Ht(e, { onExit: t } = {}) {
1658
1692
  phpPort: l.phpPort
1659
1693
  });
1660
1694
  }), r.once("error", function(l) {
1661
- O.release(i), console.error(l);
1695
+ V.release(i), console.error(l);
1662
1696
  const u = new Error(
1663
1697
  `Worker failed to load worker. ${l.message ? `Original error: ${l.message}` : ""}`
1664
1698
  );
@@ -1668,16 +1702,16 @@ function Ht(e, { onExit: t } = {}) {
1668
1702
  r.once("spawn", () => {
1669
1703
  n = !0;
1670
1704
  }), r.once("exit", (l) => {
1671
- O.release(i), n || s(new Error(`Worker exited before spawning: ${l}`)), t?.(l);
1705
+ V.release(i), n || s(new Error(`Worker exited before spawning: ${l}`)), t?.(l);
1672
1706
  });
1673
1707
  });
1674
1708
  }
1675
- async function _t(e) {
1709
+ async function Ft(e) {
1676
1710
  const { port1: t, port2: r } = new ce();
1677
1711
  return await Ae(e, t), r;
1678
1712
  }
1679
- function Ft(e) {
1680
- const t = q.platform();
1713
+ function Nt(e) {
1714
+ const t = G.platform();
1681
1715
  let r;
1682
1716
  switch (t) {
1683
1717
  case "darwin":
@@ -1690,11 +1724,11 @@ function Ft(e) {
1690
1724
  r = `xdg-open "${e}"`;
1691
1725
  break;
1692
1726
  }
1693
- me(r, (o) => {
1727
+ he(r, (o) => {
1694
1728
  o && P.debug(`Could not open browser: ${o.message}`);
1695
1729
  });
1696
1730
  }
1697
- async function Nt(e, t) {
1731
+ async function Ot(e, t) {
1698
1732
  await e.run({
1699
1733
  code: `<?php
1700
1734
  $zip = new ZipArchive();
@@ -1716,16 +1750,16 @@ async function Nt(e, t) {
1716
1750
  `
1717
1751
  });
1718
1752
  const r = await e.readFileAsBuffer("/tmp/build.zip");
1719
- p.writeFileSync(t, r);
1753
+ c.writeFileSync(t, r);
1720
1754
  }
1721
1755
  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,
1728
- Lt as r,
1729
- Ht as s
1756
+ ge as L,
1757
+ yr as a,
1758
+ Rt as b,
1759
+ Pe as i,
1760
+ ye as m,
1761
+ br as p,
1762
+ Ut as r,
1763
+ _t as s
1730
1764
  };
1731
- //# sourceMappingURL=run-cli-DEBbpuwb.js.map
1765
+ //# sourceMappingURL=run-cli-D-hJyCz2.js.map