@wp-playground/cli 3.1.11 → 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,18 +1,18 @@
1
- import { logger as P, LogSeverity as N, errorLogPath as J } from "@php-wasm/logger";
1
+ import { logger as w, LogSeverity as O, errorLogPath as J } from "@php-wasm/logger";
2
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";
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
7
  import { createNodeFsMountHandler as Ue } from "@php-wasm/node";
8
- import d, { basename as R, join as me } from "path";
8
+ import d, { basename as D, join as me } from "path";
9
9
  import { exec as he } from "child_process";
10
- import { promisify as He } from "util";
10
+ import { promisify as _e } from "util";
11
11
  import fe from "express";
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";
12
+ import { Readable as He } from "stream";
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
16
  import { EmscriptenDownloadMonitor as qe, ProgressTracker as ze } from "@php-wasm/progress";
17
17
  import { resolveWordPressRelease as Ge } from "@wp-playground/wordpress";
18
18
  import $ from "fs-extra";
@@ -20,12 +20,11 @@ import { createRequire as Qe } from "module";
20
20
  import G from "os";
21
21
  import { startBridge as Xe } from "@php-wasm/xdebug-bridge";
22
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";
23
+ import { removeTempDirSymlink as Ke, createTempDirSymlink as oe, makeXdebugConfig as et, clearXdebugIDEConfig as tt, addXdebugIDEConfig as rt } from "@php-wasm/cli-util";
24
+ import { createHash as ot } from "crypto";
25
+ import { PHPMYADMIN_INSTALL_PATH as se, getPhpMyAdminInstallSteps as st, PHPMYADMIN_ENTRY_PATH as it } from "@wp-playground/tools";
27
26
  import { jspi as ie } from "wasm-feature-detect";
28
- function O(e) {
27
+ function F(e) {
29
28
  const t = [];
30
29
  for (const r of e) {
31
30
  const o = r.split(":");
@@ -56,7 +55,7 @@ function ne(e) {
56
55
  }
57
56
  return t;
58
57
  }
59
- async function yr(e, t) {
58
+ async function fr(e, t) {
60
59
  for (const r of t)
61
60
  await e.mount(
62
61
  r.vfsPath,
@@ -91,21 +90,21 @@ function we(e) {
91
90
  ...e["additional-blueprint-steps"] || []
92
91
  ]
93
92
  };
94
- if (dt(t)) {
95
- const n = `/wordpress/wp-content/plugins/${R(t)}`;
93
+ if (ut(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
- pluginPath: `/wordpress/wp-content/plugins/${R(t)}`
101
+ pluginPath: `/wordpress/wp-content/plugins/${D(t)}`
103
102
  });
104
- } else if (ut(t)) {
105
- const i = R(t), n = `/wordpress/wp-content/themes/${i}`;
103
+ } else if (lt(t)) {
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"] ? {
@@ -116,44 +115,44 @@ function we(e) {
116
115
  themeFolderName: i
117
116
  }
118
117
  );
119
- } else if (lt(t)) {
120
- const i = c.readdirSync(t);
121
- for (const n of i)
122
- n !== "index.php" && r.push({
123
- hostPath: `${t}/${n}`,
124
- vfsPath: `/wordpress/wp-content/${n}`,
118
+ } else if (at(t)) {
119
+ const i = p.readdirSync(t);
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
126
  s["additional-blueprint-steps"].push(ae);
128
- } else at(t) && (o.push({
127
+ } else nt(t) && (o.push({
129
128
  hostPath: t,
130
129
  vfsPath: "/wordpress",
131
130
  autoMounted: !0
132
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
- function at(e) {
136
- const t = c.readdirSync(e);
134
+ function nt(e) {
135
+ const t = p.readdirSync(e);
137
136
  return t.includes("wp-admin") && t.includes("wp-includes") && t.includes("wp-content");
138
137
  }
139
- function lt(e) {
140
- const t = c.readdirSync(e);
138
+ function at(e) {
139
+ const t = p.readdirSync(e);
141
140
  return t.includes("themes") || t.includes("plugins") || t.includes("mu-plugins") || t.includes("uploads");
142
141
  }
143
- function ut(e) {
144
- if (!c.readdirSync(e).includes("style.css"))
142
+ function lt(e) {
143
+ if (!p.readdirSync(e).includes("style.css"))
145
144
  return !1;
146
- const r = c.readFileSync(me(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
- function dt(e) {
150
- const t = c.readdirSync(e), r = /^(?:[ \t]*<\?php)?[ \t/*#@]*Plugin Name:(.*)$/im;
148
+ function ut(e) {
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 = c.readFileSync(me(e, s), "utf8");
151
+ const i = p.readFileSync(me(e, s), "utf8");
153
152
  return !!r.exec(i);
154
153
  });
155
154
  }
156
- function pt(e) {
155
+ function dt(e) {
157
156
  if (e.length % 2 !== 0)
158
157
  throw new Error(
159
158
  "Invalid constant definition format. Expected pairs of NAME value"
@@ -188,7 +187,7 @@ function ct(e) {
188
187
  }
189
188
  return t;
190
189
  }
191
- function mt(e) {
190
+ function pt(e) {
192
191
  if (e.length % 2 !== 0)
193
192
  throw new Error(
194
193
  "Invalid number constant definition format. Expected pairs of NAME value"
@@ -207,27 +206,27 @@ function mt(e) {
207
206
  }
208
207
  return t;
209
208
  }
210
- function ht(e = {}, t = {}, r = {}) {
211
- const o = {}, s = /* @__PURE__ */ new Set(), i = (n, l) => {
212
- for (const u in n) {
209
+ function mt(e = {}, t = {}, r = {}) {
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
221
  function ye(e) {
223
- return ht(
222
+ return mt(
224
223
  e.define,
225
224
  e["define-bool"],
226
225
  e["define-number"]
227
226
  );
228
227
  }
229
- const ft = He(he);
230
- function wt(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);
@@ -237,30 +236,30 @@ function wt(e) {
237
236
  );
238
237
  });
239
238
  }
240
- async function yt(e) {
241
- const t = fe(), r = await new Promise((n, l) => {
239
+ async function wt(e) {
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: vt(n),
252
- method: n.method,
253
- body: await gt(n)
254
- }, w = await e.handleRequest(u);
255
- await bt(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;
261
- return i && Pt(s, i), await e.onBind(r, s);
260
+ return i && gt(s, i), await e.onBind(r, s);
262
261
  }
263
- async function bt(e, t) {
262
+ async function yt(e, t) {
264
263
  const [r, o] = await Promise.all([
265
264
  e.headers,
266
265
  e.httpStatusCode
@@ -268,16 +267,16 @@ async function bt(e, t) {
268
267
  t.statusCode = o;
269
268
  for (const i in r)
270
269
  t.setHeader(i, r[i]);
271
- const s = _e.fromWeb(e.stdout);
270
+ const s = He.fromWeb(e.stdout);
272
271
  try {
273
- await Fe(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
  }
279
278
  }
280
- const gt = async (e) => await new Promise((t) => {
279
+ const bt = async (e) => await new Promise((t) => {
281
280
  const r = [];
282
281
  e.on("data", (o) => {
283
282
  r.push(o);
@@ -285,28 +284,28 @@ const gt = async (e) => await new Promise((t) => {
285
284
  t(new Uint8Array(Buffer.concat(r)));
286
285
  });
287
286
  });
288
- async function Pt(e, t) {
289
- P.log(`Publishing port ${e}...`);
287
+ async function gt(e, t) {
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));
297
296
  }
298
297
  }
299
- const vt = (e) => {
298
+ const Pt = (e) => {
300
299
  const t = {};
301
300
  if (e.rawHeaders && e.rawHeaders.length)
302
301
  for (let r = 0; r < e.rawHeaders.length; r += 2)
303
302
  t[e.rawHeaders[r].toLowerCase()] = e.rawHeaders[r + 1];
304
303
  return t;
305
304
  };
306
- function St(e) {
305
+ function vt(e) {
307
306
  return /^latest$|^trunk$|^nightly$|^(?:(\d+)\.(\d+)(?:\.(\d+))?)((?:-beta(?:\d+)?)|(?:-RC(?:\d+)?))?$/.test(e);
308
307
  }
309
- async function xt({
308
+ async function St({
310
309
  sourceString: e,
311
310
  blueprintMayReadAdjacentFiles: t
312
311
  }) {
@@ -315,9 +314,9 @@ async function xt({
315
314
  if (e.startsWith("http://") || e.startsWith("https://"))
316
315
  return await Be(e);
317
316
  let r = d.resolve(process.cwd(), e);
318
- if (!c.existsSync(r))
317
+ if (!p.existsSync(r))
319
318
  throw new Error(`Blueprint file does not exist: ${r}`);
320
- const o = c.statSync(r);
319
+ const o = p.statSync(r);
321
320
  if (o.isDirectory() && (r = d.join(r, "blueprint.json")), !o.isFile() && o.isSymbolicLink())
322
321
  throw new Error(
323
322
  `Blueprint path is neither a file nor a directory: ${r}`
@@ -326,10 +325,10 @@ async function xt({
326
325
  switch (s) {
327
326
  case ".zip":
328
327
  return Ye.fromArrayBuffer(
329
- c.readFileSync(r).buffer
328
+ p.readFileSync(r).buffer
330
329
  );
331
330
  case ".json": {
332
- const i = c.readFileSync(r, "utf-8");
331
+ const i = p.readFileSync(r, "utf-8");
333
332
  try {
334
333
  JSON.parse(i);
335
334
  } catch {
@@ -337,7 +336,7 @@ async function xt({
337
336
  `Blueprint file at ${r} is not a valid JSON file`
338
337
  );
339
338
  }
340
- const n = d.dirname(r), l = new Oe(n);
339
+ const a = d.dirname(r), l = new Fe(a);
341
340
  return new je([
342
341
  new Ve({
343
342
  "blueprint.json": i
@@ -365,7 +364,7 @@ You can allow this Blueprint to read files from the same parent directory by exp
365
364
  );
366
365
  }
367
366
  }
368
- class Et {
367
+ class xt {
369
368
  constructor(t, r) {
370
369
  this.args = t, this.siteUrl = r.siteUrl, this.phpVersion = t.php, this.cliOutput = r.cliOutput;
371
370
  }
@@ -407,7 +406,7 @@ class Et {
407
406
  }
408
407
  }
409
408
  const q = d.join(G.homedir(), ".wordpress-playground");
410
- async function $t() {
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
412
  if (!$.existsSync(t)) {
@@ -423,29 +422,29 @@ async function $t() {
423
422
  }
424
423
  return new File([await $.readFile(t)], d.basename(t));
425
424
  }
426
- async function Tt(e, t, r) {
425
+ async function $t(e, t, r) {
427
426
  const o = d.join(q, t);
428
- return $.existsSync(o) || ($.ensureDirSync(q), await It(e, o, r)), be(o);
427
+ return $.existsSync(o) || ($.ensureDirSync(q), await Tt(e, o, r)), be(o);
429
428
  }
430
- async function It(e, t, r) {
431
- const s = (await r.monitorFetch(fetch(e))).body.getReader(), i = `${t}.partial`, n = $.createWriteStream(i);
429
+ async function Tt(e, t, r) {
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", () => {
436
+ a.close(), a.closed || await new Promise((l, u) => {
437
+ a.on("finish", () => {
439
438
  $.renameSync(i, t), l(null);
440
- }), n.on("error", (w) => {
441
- $.removeSync(i), u(w);
439
+ }), a.on("error", (y) => {
440
+ $.removeSync(i), u(y);
442
441
  });
443
442
  });
444
443
  }
445
444
  function be(e, t) {
446
- return new File([$.readFileSync(e)], R(e));
445
+ return new File([$.readFileSync(e)], D(e));
447
446
  }
448
- class kt {
447
+ class It {
449
448
  constructor(t, r) {
450
449
  this.args = t, this.siteUrl = r.siteUrl, this.cliOutput = r.cliOutput;
451
450
  }
@@ -454,32 +453,32 @@ class kt {
454
453
  }
455
454
  async bootWordPress(t, r) {
456
455
  let o, s, i;
457
- const n = new qe();
456
+ const a = new qe();
458
457
  if (this.args.wordpressInstallMode === "download-and-install") {
459
- let w = !1;
460
- n.addEventListener("progress", (E) => {
461
- if (w)
458
+ let y = !1;
459
+ a.addEventListener("progress", (E) => {
460
+ if (y)
462
461
  return;
463
- const { loaded: p, total: a } = E.detail, m = Math.floor(
464
- Math.min(100, 100 * p / 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
469
  }), o = await Ge(this.args.wp), i = d.join(
471
470
  q,
472
471
  `prebuilt-wp-content-for-wp-${o.version}.zip`
473
- ), s = c.existsSync(i) ? be(i) : await Tt(
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 $t()), this.cliOutput.updateProgress("Booting WordPress");
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");
483
482
  const u = await ee(
484
483
  this.getEffectiveBlueprint()
485
484
  );
@@ -493,11 +492,11 @@ class kt {
493
492
  constants: ye(this.args)
494
493
  },
495
494
  r
496
- ), i && !this.args["mount-before-install"] && !c.existsSync(i) && (this.cliOutput.updateProgress("Caching WordPress for next boot"), c.writeFileSync(
495
+ ), i && !this.args["mount-before-install"] && !p.existsSync(i) && (this.cliOutput.updateProgress("Caching WordPress for next boot"), p.writeFileSync(
497
496
  i,
498
497
  // Comlink proxy is not assignable to UniversalPHP but
499
498
  // proxies all method calls transparently at runtime.
500
- await Re(
499
+ await De(
501
500
  t,
502
501
  "/wordpress"
503
502
  )
@@ -534,20 +533,20 @@ class kt {
534
533
  async compileInputBlueprint(t) {
535
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 pe(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 De(t) ? t : {
549
+ return Re(t) ? t : {
551
550
  login: this.args.login,
552
551
  ...t || {},
553
552
  preferredVersions: {
@@ -558,7 +557,7 @@ class kt {
558
557
  };
559
558
  }
560
559
  }
561
- async function Mt(e, t = !0) {
560
+ async function kt(e, t = !0) {
562
561
  const o = `${d.basename(process.argv0)}${e}${process.pid}-`, s = await Ze({
563
562
  prefix: o,
564
563
  /*
@@ -573,41 +572,41 @@ async function Mt(e, t = !0) {
573
572
  });
574
573
  return t && Je(), s;
575
574
  }
576
- async function Ct(e, t, r) {
577
- const s = (await At(
575
+ async function Mt(e, t, r) {
576
+ const s = (await Ct(
578
577
  e,
579
578
  t,
580
579
  r
581
580
  )).map(
582
- (i) => new Promise((n) => {
583
- c.rm(i, { recursive: !0 }, (l) => {
584
- l ? P.warn(
581
+ (i) => new Promise((a) => {
582
+ p.rm(i, { recursive: !0 }, (l) => {
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
- const o = c.readdirSync(r).map((i) => d.join(r, i)), s = [];
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) {
610
- if (!c.lstatSync(r).isDirectory())
608
+ async function At(e, t, r) {
609
+ if (!p.lstatSync(r).isDirectory())
611
610
  return !1;
612
611
  const s = d.basename(r);
613
612
  if (!s.includes(e))
@@ -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 Dt(n.pid, n.executableName))
623
+ if (Bt(a.pid))
625
624
  return !1;
626
625
  const l = Date.now() - t;
627
- return c.statSync(r).mtime.getTime() < l;
626
+ return p.statSync(r).mtime.getTime() < l;
628
627
  }
629
- async function Dt(e, t) {
630
- const [r] = await new Promise(
631
- (o, s) => {
632
- Ke.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
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 Wt {
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
  }
@@ -811,11 +806,11 @@ ${this.green("Ready!")} WordPress is running on ${this.bold(t)} ${this.dim(`(${r
811
806
  }
812
807
  }
813
808
  const ge = {
814
- Quiet: { name: "quiet", severity: N.Fatal },
815
- Normal: { name: "normal", severity: N.Info },
816
- Debug: { name: "debug", severity: N.Debug }
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 br(e) {
813
+ async function wr(e) {
819
814
  try {
820
815
  const t = {
821
816
  "site-url": {
@@ -838,7 +833,7 @@ async function br(e) {
838
833
  type: "string",
839
834
  nargs: 2,
840
835
  array: !0,
841
- coerce: pt
836
+ coerce: dt
842
837
  },
843
838
  "define-bool": {
844
839
  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 +847,7 @@ async function br(e) {
852
847
  type: "string",
853
848
  nargs: 2,
854
849
  array: !0,
855
- coerce: mt
850
+ coerce: pt
856
851
  },
857
852
  // @TODO: Support read-only mounts, e.g. via WORKERFS, a custom
858
853
  // ReadOnlyNODEFS, or by copying the files into MEMFS
@@ -861,14 +856,14 @@ async function br(e) {
861
856
  type: "array",
862
857
  string: !0,
863
858
  nargs: 1,
864
- coerce: O
859
+ coerce: F
865
860
  },
866
861
  "mount-before-install": {
867
862
  describe: "Mount a directory to the PHP runtime before WordPress installation (can be used multiple times). Format: /host/path:/vfs/path",
868
863
  type: "array",
869
864
  string: !0,
870
865
  nargs: 1,
871
- coerce: O
866
+ coerce: F
872
867
  },
873
868
  "mount-dir": {
874
869
  describe: 'Mount a directory to the PHP runtime (can be used multiple times). Format: "/host/path" "/vfs/path"',
@@ -930,7 +925,7 @@ async function br(e) {
930
925
  describe: "Output logs and progress messages.",
931
926
  type: "string",
932
927
  choices: Object.values(ge).map(
933
- (a) => a.name
928
+ (n) => n.name
934
929
  ),
935
930
  default: "normal"
936
931
  },
@@ -990,7 +985,7 @@ Warning: Following symlinks will expose files outside mounted directories to Pla
990
985
  // supported IDEs and, if needed, will create the relevant
991
986
  // config file for each.
992
987
  choices: ["", "vscode", "phpstorm"],
993
- coerce: (a) => a === "" ? ["vscode", "phpstorm"] : [a]
988
+ coerce: (n) => n === "" ? ["vscode", "phpstorm"] : [n]
994
989
  },
995
990
  "experimental-blueprints-v2-runner": {
996
991
  describe: "Use the experimental Blueprint V2 runner.",
@@ -1009,7 +1004,7 @@ Warning: Following symlinks will expose files outside mounted directories to Pla
1009
1004
  phpmyadmin: {
1010
1005
  describe: "Install phpMyAdmin for database management. The phpMyAdmin URL will be printed after boot. Optionally specify a custom URL path (default: /phpmyadmin).",
1011
1006
  type: "string",
1012
- coerce: (a) => a === "" ? "/phpmyadmin" : a
1007
+ coerce: (n) => n === "" ? "/phpmyadmin" : n
1013
1008
  }
1014
1009
  }, r = {
1015
1010
  port: {
@@ -1080,7 +1075,7 @@ Warning: Following symlinks will expose files outside mounted directories to Pla
1080
1075
  describe: "Mount a directory to the PHP runtime (can be used multiple times). Format: /host/path:/vfs/path. Use this for additional mounts beyond auto-detection.",
1081
1076
  type: "array",
1082
1077
  string: !0,
1083
- coerce: O
1078
+ coerce: F
1084
1079
  },
1085
1080
  reset: {
1086
1081
  describe: "Deletes the stored site directory and starts a new site from scratch.",
@@ -1104,10 +1099,10 @@ Warning: Following symlinks will expose files outside mounted directories to Pla
1104
1099
  type: "string",
1105
1100
  default: "wordpress.zip"
1106
1101
  }
1107
- }, i = Ne(e).usage("Usage: wp-playground <command> [options]").command(
1102
+ }, i = Oe(e).usage("Usage: wp-playground <command> [options]").command(
1108
1103
  "start",
1109
1104
  "Start a local WordPress server with automatic project detection (recommended)",
1110
- (a) => a.usage(
1105
+ (n) => n.usage(
1111
1106
  `Usage: wp-playground start [options]
1112
1107
 
1113
1108
  The easiest way to run WordPress locally. Automatically detects
@@ -1124,43 +1119,43 @@ Examples:
1124
1119
  ).command(
1125
1120
  "server",
1126
1121
  "Start a local WordPress server (advanced, low-level)",
1127
- (a) => a.options({
1122
+ (n) => n.options({
1128
1123
  ...t,
1129
1124
  ...r
1130
1125
  })
1131
1126
  ).command(
1132
1127
  "run-blueprint",
1133
1128
  "Execute a Blueprint without starting a server",
1134
- (a) => a.options({ ...t })
1129
+ (n) => n.options({ ...t })
1135
1130
  ).command(
1136
1131
  "build-snapshot",
1137
1132
  "Build a ZIP snapshot of a WordPress site based on a Blueprint",
1138
- (a) => a.options({
1133
+ (n) => n.options({
1139
1134
  ...t,
1140
1135
  ...s
1141
1136
  })
1142
1137
  ).command(
1143
1138
  "php",
1144
1139
  "Run a PHP script",
1145
- (a) => a.options({ ...t })
1140
+ (n) => n.options({ ...t })
1146
1141
  ).demandCommand(1, "Please specify a command").strictCommands().conflicts(
1147
1142
  "experimental-unsafe-ide-integration",
1148
1143
  "experimental-devtools"
1149
- ).showHelpOnFail(!1).fail((a, m, y) => {
1144
+ ).showHelpOnFail(!1).fail((n, m, b) => {
1150
1145
  if (m)
1151
1146
  throw m;
1152
- a && a.includes("Please specify a command") && (y.showHelp(), console.error(`
1153
- ` + a), process.exit(1)), console.error(a), process.exit(1);
1154
- }).strictOptions().check(async (a) => {
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))
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))
1156
1151
  try {
1157
- new URL(a.wp);
1152
+ new URL(n.wp);
1158
1153
  } catch {
1159
1154
  throw new Error(
1160
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"'
1161
1156
  );
1162
1157
  }
1163
- const m = a["site-url"];
1158
+ const m = n["site-url"];
1164
1159
  if (typeof m == "string" && m.trim() !== "")
1165
1160
  try {
1166
1161
  new URL(m);
@@ -1169,32 +1164,32 @@ Examples:
1169
1164
  `Invalid site-url "${m}". Please provide a valid URL (e.g., http://localhost:8080 or https://example.com)`
1170
1165
  );
1171
1166
  }
1172
- if (a["auto-mount"]) {
1173
- let y = !1;
1167
+ if (n["auto-mount"]) {
1168
+ let b = !1;
1174
1169
  try {
1175
- y = c.statSync(
1176
- a["auto-mount"]
1170
+ b = p.statSync(
1171
+ n["auto-mount"]
1177
1172
  ).isDirectory();
1178
1173
  } catch {
1179
- y = !1;
1174
+ b = !1;
1180
1175
  }
1181
- if (!y)
1176
+ if (!b)
1182
1177
  throw new Error(
1183
- `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"]}'.`
1184
1179
  );
1185
1180
  }
1186
- if (a["experimental-blueprints-v2-runner"] === !0)
1181
+ if (n["experimental-blueprints-v2-runner"] === !0)
1187
1182
  throw new Error(
1188
1183
  "Blueprints v2 are temporarily disabled while we rework their runtime implementation."
1189
1184
  );
1190
- if (a.mode !== void 0)
1185
+ if (n.mode !== void 0)
1191
1186
  throw new Error(
1192
1187
  "The --mode option requires the --experimentalBlueprintsV2Runner flag."
1193
1188
  );
1194
1189
  return !0;
1195
1190
  });
1196
1191
  i.wrap(i.terminalWidth());
1197
- const n = await i.argv, l = n._[0];
1192
+ const a = await i.argv, l = a._[0];
1198
1193
  [
1199
1194
  "start",
1200
1195
  "run-blueprint",
@@ -1202,31 +1197,31 @@ Examples:
1202
1197
  "build-snapshot",
1203
1198
  "php"
1204
1199
  ].includes(l) || (i.showHelp(), process.exit(1));
1205
- const u = n.define || {};
1200
+ const u = a.define || {};
1206
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");
1207
- const w = {
1208
- ...n,
1202
+ const y = {
1203
+ ...a,
1209
1204
  define: u,
1210
1205
  command: l,
1211
1206
  mount: [
1212
- ...n.mount || [],
1213
- ...n["mount-dir"] || []
1207
+ ...a.mount || [],
1208
+ ...a["mount-dir"] || []
1214
1209
  ],
1215
1210
  "mount-before-install": [
1216
- ...n["mount-before-install"] || [],
1217
- ...n["mount-dir-before-install"] || []
1211
+ ...a["mount-before-install"] || [],
1212
+ ...a["mount-dir-before-install"] || []
1218
1213
  ]
1219
- }, E = await Ut(w);
1214
+ }, E = await Lt(y);
1220
1215
  E === void 0 && process.exit(0);
1221
- const p = /* @__PURE__ */ (() => {
1222
- let a;
1216
+ const c = /* @__PURE__ */ (() => {
1217
+ let n;
1223
1218
  return async () => {
1224
- a === void 0 && (a = E[Symbol.asyncDispose]()), await a, process.exit(0);
1219
+ n === void 0 && (n = E[Symbol.asyncDispose]()), await n, process.exit(0);
1225
1220
  };
1226
1221
  })();
1227
- return process.on("SIGINT", p), process.on("SIGTERM", p), {
1222
+ return process.on("SIGINT", c), process.on("SIGTERM", c), {
1228
1223
  [Symbol.asyncDispose]: async () => {
1229
- process.off("SIGINT", p), process.off("SIGTERM", p), await E[Symbol.asyncDispose]();
1224
+ process.off("SIGINT", c), process.off("SIGTERM", c), await E[Symbol.asyncDispose]();
1230
1225
  },
1231
1226
  [Pe]: { cliServer: E }
1232
1227
  };
@@ -1253,15 +1248,15 @@ function le(e, t) {
1253
1248
  (r) => r.vfsPath.replace(/\/$/, "") === t.replace(/\/$/, "")
1254
1249
  );
1255
1250
  }
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) {
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;
1252
+ async function Lt(e) {
1258
1253
  let t;
1259
1254
  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(
1262
- (a) => a.name === e.verbosity
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
1263
1258
  ).severity;
1264
- P.setSeverityFilterLevel(p);
1259
+ w.setSeverityFilterLevel(c);
1265
1260
  }
1266
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) {
1267
1262
  if (e.phpmyadmin === !0 && (e.phpmyadmin = "/phpmyadmin"), e.skipSqliteSetup)
@@ -1275,7 +1270,7 @@ async function Ut(e) {
1275
1270
  }
1276
1271
  ];
1277
1272
  }
1278
- const i = new Wt({
1273
+ const i = new Dt({
1279
1274
  verbosity: e.verbosity || "normal"
1280
1275
  });
1281
1276
  e.command === "server" && (i.printBanner(), i.printConfig({
@@ -1292,15 +1287,15 @@ async function Ut(e) {
1292
1287
  ],
1293
1288
  blueprint: typeof e.blueprint == "string" ? e.blueprint : void 0
1294
1289
  }));
1295
- const n = e.command === "server" ? e.port ?? 9400 : 0, l = new Ie();
1296
- let u = !1, w = !0;
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) {
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) {
1304
1299
  const h = {
1305
1300
  hostPath: d.join(".", d.sep, X),
1306
1301
  vfsPath: "/"
@@ -1310,9 +1305,9 @@ async function Ut(e) {
1310
1305
  ) <= W.indexOf("8.5"))
1311
1306
  await oe(
1312
1307
  T.path,
1313
- H,
1308
+ _,
1314
1309
  process.platform
1315
- ), e.xdebug = tt({
1310
+ ), e.xdebug = et({
1316
1311
  cwd: process.cwd(),
1317
1312
  mounts: [
1318
1313
  h,
@@ -1327,7 +1322,7 @@ async function Ut(e) {
1327
1322
  "/proc/"
1328
1323
  ]
1329
1324
  }), console.log(I("Xdebug configured successfully")), console.log(
1330
- j("Playground source root: ") + ".playground-xdebug-root" + D(
1325
+ j("Playground source root: ") + ".playground-xdebug-root" + R(
1331
1326
  ue(
1332
1327
  " – you can set breakpoints and preview Playground's VFS structure in there."
1333
1328
  )
@@ -1336,18 +1331,18 @@ async function Ut(e) {
1336
1331
  else if (e.experimentalUnsafeIdeIntegration) {
1337
1332
  await oe(
1338
1333
  T.path,
1339
- H,
1334
+ _,
1340
1335
  process.platform
1341
1336
  );
1342
1337
  try {
1343
- await rt(
1338
+ await tt(
1344
1339
  A,
1345
1340
  process.cwd()
1346
1341
  );
1347
- const f = typeof e.xdebug == "object" ? e.xdebug : {}, b = await ot({
1342
+ const f = typeof e.xdebug == "object" ? e.xdebug : {}, g = await rt({
1348
1343
  name: A,
1349
1344
  host: m,
1350
- port: a,
1345
+ port: n,
1351
1346
  ides: e.experimentalUnsafeIdeIntegration,
1352
1347
  cwd: process.cwd(),
1353
1348
  mounts: [
@@ -1356,13 +1351,13 @@ async function Ut(e) {
1356
1351
  ...e.mount || []
1357
1352
  ],
1358
1353
  ideKey: f.ideKey || "WPPLAYGROUNDCLI"
1359
- }), v = e.experimentalUnsafeIdeIntegration, S = v.includes("vscode"), x = v.includes("phpstorm"), B = Object.values(b);
1354
+ }), v = e.experimentalUnsafeIdeIntegration, S = v.includes("vscode"), x = v.includes("phpstorm"), B = Object.values(g);
1360
1355
  console.log(""), B.length > 0 ? (console.log(
1361
1356
  I("Xdebug configured successfully")
1362
1357
  ), console.log(
1363
1358
  j("Updated IDE config: ") + B.join(" ")
1364
1359
  ), console.log(
1365
- j("Playground source root: ") + ".playground-xdebug-root" + D(
1360
+ j("Playground source root: ") + ".playground-xdebug-root" + R(
1366
1361
  ue(
1367
1362
  " – you can set breakpoints and preview Playground's VFS structure in there."
1368
1363
  )
@@ -1371,7 +1366,7 @@ async function Ut(e) {
1371
1366
  I("Xdebug configuration failed.")
1372
1367
  ), console.log(
1373
1368
  "No IDE-specific project settings directory was found in the current working directory."
1374
- )), console.log(""), S && b.vscode && (console.log(
1369
+ )), console.log(""), S && g.vscode && (console.log(
1375
1370
  I("VS Code / Cursor instructions:")
1376
1371
  ), console.log(
1377
1372
  " 1. Ensure you have installed an IDE extension for PHP Debugging"
@@ -1382,15 +1377,15 @@ async function Ut(e) {
1382
1377
  ), console.log(
1383
1378
  " 2. Open the Run and Debug panel on the left sidebar"
1384
1379
  ), console.log(
1385
- ` 3. Select "${D(
1380
+ ` 3. Select "${R(
1386
1381
  A
1387
1382
  )}" from the dropdown`
1388
1383
  ), console.log(' 3. Click "start debugging"'), console.log(
1389
1384
  " 5. Set a breakpoint. For example, in .playground-xdebug-root/wordpress/index.php"
1390
1385
  ), console.log(
1391
1386
  " 6. Visit Playground in your browser to hit the breakpoint"
1392
- ), x && console.log("")), x && b.phpstorm && (console.log(I("PhpStorm instructions:")), console.log(
1393
- ` 1. Choose "${D(
1387
+ ), x && console.log("")), x && g.phpstorm && (console.log(I("PhpStorm instructions:")), console.log(
1388
+ ` 1. Choose "${R(
1394
1389
  A
1395
1390
  )}" debug configuration in the toolbar`
1396
1391
  ), console.log(
@@ -1408,7 +1403,7 @@ async function Ut(e) {
1408
1403
  }
1409
1404
  }
1410
1405
  const ve = d.dirname(T.path), Se = 2 * 24 * 60 * 60 * 1e3;
1411
- Ct(
1406
+ Mt(
1412
1407
  Q,
1413
1408
  Se,
1414
1409
  ve
@@ -1428,55 +1423,55 @@ async function Ut(e) {
1428
1423
  "home"
1429
1424
  ];
1430
1425
  for (const h of xe) {
1431
- const g = (b) => b.vfsPath === `/${h}`;
1432
- if (!(e["mount-before-install"]?.some(g) || e.mount?.some(g))) {
1433
- const b = d.join(
1426
+ const P = (g) => g.vfsPath === `/${h}`;
1427
+ if (!(e["mount-before-install"]?.some(P) || e.mount?.some(P))) {
1428
+ const g = d.join(
1434
1429
  T.path,
1435
1430
  h
1436
1431
  );
1437
- Y(b), e["mount-before-install"] === void 0 && (e["mount-before-install"] = []), e["mount-before-install"].unshift({
1432
+ Y(g), e["mount-before-install"] === void 0 && (e["mount-before-install"] = []), e["mount-before-install"].unshift({
1438
1433
  vfsPath: `/${h}`,
1439
- hostPath: b
1434
+ hostPath: g
1440
1435
  });
1441
1436
  }
1442
1437
  }
1443
1438
  if (e["mount-before-install"])
1444
1439
  for (const h of e["mount-before-install"])
1445
- P.debug(
1440
+ w.debug(
1446
1441
  `Mount before WP install: ${h.vfsPath} -> ${h.hostPath}`
1447
1442
  );
1448
1443
  if (e.mount)
1449
1444
  for (const h of e.mount)
1450
- P.debug(
1445
+ w.debug(
1451
1446
  `Mount after WP install: ${h.vfsPath} -> ${h.hostPath}`
1452
1447
  );
1453
1448
  let k;
1454
- e["experimental-blueprints-v2-runner"] ? k = new Et(e, {
1449
+ e["experimental-blueprints-v2-runner"] ? k = new xt(e, {
1455
1450
  siteUrl: L,
1456
1451
  cliOutput: i
1457
- }) : (k = new kt(e, {
1452
+ }) : (k = new It(e, {
1458
1453
  siteUrl: L,
1459
1454
  cliOutput: i
1460
- }), typeof e.blueprint == "string" && (e.blueprint = await xt({
1455
+ }), typeof e.blueprint == "string" && (e.blueprint = await St({
1461
1456
  sourceString: e.blueprint,
1462
1457
  blueprintMayReadAdjacentFiles: e["blueprint-may-read-adjacent-files"] === !0
1463
1458
  })));
1464
- let _ = !1;
1459
+ let H = !1;
1465
1460
  const M = async function() {
1466
- _ || (_ = !0, await Promise.all(
1467
- o.map(async (g) => {
1468
- await s.get(g)?.dispose(), await g.worker.terminate();
1461
+ H || (H = !0, await Promise.all(
1462
+ o.map(async (P) => {
1463
+ await s.get(P)?.dispose(), await P.worker.terminate();
1469
1464
  })
1470
- ), p && await new Promise((g) => {
1471
- p.close(g), p.closeAllConnections();
1465
+ ), c && await new Promise((P) => {
1466
+ c.close(P), c.closeAllConnections();
1472
1467
  }), await T.cleanup());
1473
1468
  };
1474
1469
  try {
1475
- const h = [], g = k.getWorkerType();
1470
+ const h = [], P = k.getWorkerType();
1476
1471
  for (let f = 0; f < U; f++) {
1477
- const b = _t(g, {
1472
+ const g = _t(P, {
1478
1473
  onExit: (v) => {
1479
- _ || v === 0 && P.error(
1474
+ H || v === 0 && w.error(
1480
1475
  `Worker ${f} exited with code ${v}
1481
1476
  `
1482
1477
  );
@@ -1484,7 +1479,7 @@ async function Ut(e) {
1484
1479
  }).then(
1485
1480
  async (v) => {
1486
1481
  o.push(v);
1487
- const S = await Ft(l), x = await k.bootRequestHandler({
1482
+ const S = await Ht(l), x = await k.bootRequestHandler({
1488
1483
  worker: v,
1489
1484
  fileLockManagerPort: S,
1490
1485
  nativeInternalDirPath: Z
@@ -1495,7 +1490,7 @@ async function Ut(e) {
1495
1490
  ), [v, x];
1496
1491
  }
1497
1492
  );
1498
- h.push(b), f === 0 && await b;
1493
+ h.push(g), f === 0 && await g;
1499
1494
  }
1500
1495
  await Promise.all(h), t = ke(
1501
1496
  o.map(
@@ -1503,7 +1498,7 @@ async function Ut(e) {
1503
1498
  )
1504
1499
  );
1505
1500
  {
1506
- const f = new ce(), b = f.port1, v = f.port2;
1501
+ const f = new pe(), g = f.port1, v = f.port2;
1507
1502
  if (await Me(
1508
1503
  {
1509
1504
  applyPostInstallMountsToAllWorkers: async () => {
@@ -1519,11 +1514,11 @@ async function Ut(e) {
1519
1514
  }
1520
1515
  },
1521
1516
  void 0,
1522
- b
1517
+ g
1523
1518
  ), await k.bootWordPress(
1524
1519
  t,
1525
1520
  v
1526
- ), b.close(), u = !0, !e["experimental-blueprints-v2-runner"]) {
1521
+ ), g.close(), u = !0, !e["experimental-blueprints-v2-runner"]) {
1527
1522
  const S = await k.compileInputBlueprint(
1528
1523
  e["additional-blueprint-steps"] || []
1529
1524
  );
@@ -1535,7 +1530,7 @@ async function Ut(e) {
1535
1530
  if (e.phpmyadmin && !await t.fileExists(
1536
1531
  `${se}/index.php`
1537
1532
  )) {
1538
- const S = await it(), x = await pe({ steps: S });
1533
+ const S = await st(), x = await ce({ steps: S });
1539
1534
  await te(x, t);
1540
1535
  }
1541
1536
  if (e.command === "build-snapshot") {
@@ -1554,15 +1549,15 @@ async function Ut(e) {
1554
1549
  x.exitCode,
1555
1550
  x.stdout.pipeTo(
1556
1551
  new WritableStream({
1557
- write(F) {
1558
- process.stdout.write(F);
1552
+ write(N) {
1553
+ process.stdout.write(N);
1559
1554
  }
1560
1555
  })
1561
1556
  ),
1562
1557
  x.stderr.pipeTo(
1563
1558
  new WritableStream({
1564
- write(F) {
1565
- process.stderr.write(F);
1559
+ write(N) {
1560
+ process.stderr.write(N);
1566
1561
  }
1567
1562
  })
1568
1563
  )
@@ -1570,13 +1565,13 @@ async function Ut(e) {
1570
1565
  await M(), process.exit(B);
1571
1566
  }
1572
1567
  }
1573
- if (i.finishProgress(), i.printReady(y, U), e.phpmyadmin) {
1568
+ if (i.finishProgress(), i.printReady(b, U), e.phpmyadmin) {
1574
1569
  const f = d.join(
1575
1570
  e.phpmyadmin,
1576
- nt
1571
+ it
1577
1572
  );
1578
1573
  i.printPhpMyAdminUrl(
1579
- new URL(f, y).toString()
1574
+ new URL(f, b).toString()
1580
1575
  );
1581
1576
  }
1582
1577
  return e.xdebug && e.experimentalDevtools && (await Xe({
@@ -1584,8 +1579,8 @@ async function Ut(e) {
1584
1579
  phpRoot: "/wordpress"
1585
1580
  })).start(), {
1586
1581
  playground: t,
1587
- server: p,
1588
- serverUrl: y,
1582
+ server: c,
1583
+ serverUrl: b,
1589
1584
  [Symbol.asyncDispose]: M,
1590
1585
  [Pe]: {
1591
1586
  workerThreadCount: U
@@ -1594,24 +1589,24 @@ async function Ut(e) {
1594
1589
  } catch (h) {
1595
1590
  if (e.verbosity !== "debug")
1596
1591
  throw h;
1597
- let g = "";
1598
- throw await t?.fileExists(J) && (g = await t.readFileAsText(J)), await M(), new Error(g, { cause: h });
1592
+ let P = "";
1593
+ throw await t?.fileExists(J) && (P = await t.readFileAsText(J)), await M(), new Error(P, { cause: h });
1599
1594
  }
1600
1595
  },
1601
- async handleRequest(p) {
1596
+ async handleRequest(c) {
1602
1597
  if (!u)
1603
1598
  return K.forHttpCode(
1604
1599
  502,
1605
1600
  "WordPress is not ready yet"
1606
1601
  );
1607
- if (w) {
1608
- w = !1;
1602
+ if (y) {
1603
+ y = !1;
1609
1604
  const m = {
1610
1605
  "Content-Type": ["text/plain"],
1611
1606
  "Content-Length": ["0"],
1612
- Location: [p.url]
1607
+ Location: [c.url]
1613
1608
  };
1614
- return p.headers?.cookie?.includes(
1609
+ return c.headers?.cookie?.includes(
1615
1610
  "playground_auto_login_already_happened"
1616
1611
  ) && (m["Set-Cookie"] = [
1617
1612
  "playground_auto_login_already_happened=1; Max-Age=0; Expires=Thu, 01 Jan 1970 00:00:00 GMT; Path=/"
@@ -1619,10 +1614,10 @@ async function Ut(e) {
1619
1614
  new Ce(302, m, new Uint8Array())
1620
1615
  );
1621
1616
  }
1622
- r && (p = {
1623
- ...p,
1617
+ r && (c = {
1618
+ ...c,
1624
1619
  headers: {
1625
- ...p.headers,
1620
+ ...c.headers,
1626
1621
  // While we have an internal cookie store, we
1627
1622
  // completely replace the incoming request's Cookie
1628
1623
  // header with the cookies from our store. This avoids
@@ -1631,19 +1626,19 @@ async function Ut(e) {
1631
1626
  cookie: r.getCookieRequestHeader()
1632
1627
  }
1633
1628
  });
1634
- const a = await t.requestStreamed(p);
1629
+ const n = await t.requestStreamed(c);
1635
1630
  if (r) {
1636
- const m = await a.headers;
1631
+ const m = await n.headers;
1637
1632
  r.rememberCookiesFromResponseHeaders(m), delete m["set-cookie"];
1638
1633
  }
1639
- return a;
1634
+ return n;
1640
1635
  }
1641
- }).catch((p) => {
1642
- i.printError(p.message), process.exit(1);
1636
+ }).catch((c) => {
1637
+ i.printError(c.message), process.exit(1);
1643
1638
  });
1644
1639
  return E && e.command === "start" && !e.skipBrowser && Nt(E.serverUrl), E;
1645
1640
  }
1646
- function Ht(e) {
1641
+ function Ut(e) {
1647
1642
  let t = { ...e, command: "server" };
1648
1643
  e.noAutoMount || (t.autoMount = d.resolve(process.cwd(), t.path ?? ""), t = we(t), delete t.autoMount);
1649
1644
  const r = le(
@@ -1652,7 +1647,7 @@ function Ht(e) {
1652
1647
  ) || le(t.mount || [], "/wordpress");
1653
1648
  if (r)
1654
1649
  console.log("Site files stored at:", r?.hostPath), e.reset && (console.log(""), console.log(
1655
- Lt(
1650
+ Wt(
1656
1651
  "This site is not managed by Playground CLI and cannot be reset."
1657
1652
  )
1658
1653
  ), console.log(
@@ -1661,15 +1656,15 @@ function Ht(e) {
1661
1656
  "You may still remove the site's directory manually if you wish."
1662
1657
  ), process.exit(1));
1663
1658
  else {
1664
- const o = t.autoMount || process.cwd(), s = st("sha256").update(o).digest("hex"), i = G.homedir(), n = d.join(
1659
+ const o = t.autoMount || process.cwd(), s = ot("sha256").update(o).digest("hex"), i = G.homedir(), a = d.join(
1665
1660
  i,
1666
1661
  ".wordpress-playground/sites",
1667
1662
  s
1668
1663
  );
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"] = [
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"] = [
1670
1665
  ...t["mount-before-install"] || [],
1671
- { vfsPath: "/wordpress", hostPath: n }
1672
- ], t.wordpressInstallMode = Le(n).length === 0 ? (
1666
+ { vfsPath: "/wordpress", hostPath: a }
1667
+ ], t.wordpressInstallMode = Le(a).length === 0 ? (
1673
1668
  // Only download WordPress on the first run when the site directory is still
1674
1669
  // empty.
1675
1670
  "download-and-install"
@@ -1698,16 +1693,16 @@ function _t(e, { onExit: t } = {}) {
1698
1693
  );
1699
1694
  s(u);
1700
1695
  });
1701
- let n = !1;
1696
+ let a = !1;
1702
1697
  r.once("spawn", () => {
1703
- n = !0;
1698
+ a = !0;
1704
1699
  }), r.once("exit", (l) => {
1705
- V.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);
1706
1701
  });
1707
1702
  });
1708
1703
  }
1709
- async function Ft(e) {
1710
- const { port1: t, port2: r } = new ce();
1704
+ async function Ht(e) {
1705
+ const { port1: t, port2: r } = new pe();
1711
1706
  return await Ae(e, t), r;
1712
1707
  }
1713
1708
  function Nt(e) {
@@ -1725,7 +1720,7 @@ function Nt(e) {
1725
1720
  break;
1726
1721
  }
1727
1722
  he(r, (o) => {
1728
- o && P.debug(`Could not open browser: ${o.message}`);
1723
+ o && w.debug(`Could not open browser: ${o.message}`);
1729
1724
  });
1730
1725
  }
1731
1726
  async function Ot(e, t) {
@@ -1750,16 +1745,16 @@ async function Ot(e, t) {
1750
1745
  `
1751
1746
  });
1752
1747
  const r = await e.readFileAsBuffer("/tmp/build.zip");
1753
- c.writeFileSync(t, r);
1748
+ p.writeFileSync(t, r);
1754
1749
  }
1755
1750
  export {
1756
1751
  ge as L,
1757
- yr as a,
1752
+ fr as a,
1758
1753
  Rt as b,
1759
1754
  Pe as i,
1760
1755
  ye as m,
1761
- br as p,
1762
- Ut as r,
1756
+ wr as p,
1757
+ Lt as r,
1763
1758
  _t as s
1764
1759
  };
1765
- //# sourceMappingURL=run-cli-D-hJyCz2.js.map
1760
+ //# sourceMappingURL=run-cli-2YzKNrNz.js.map