@wp-playground/cli 3.1.34 → 3.1.36

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,28 +1,28 @@
1
- import { logger as h, LogSeverity as O, errorLogPath as te } from "@php-wasm/logger";
2
- import { consumeAPI as fe, isLegacyPHPVersion as Y, ProcessIdAllocator as Te, AllPHPVersions as re, printDebugDetails as Ce, HttpCookieStore as Ae, FileLockManagerInMemory as De, StreamedPHPResponse as oe, SupportedPHPVersions as j, createObjectPoolProxy as Re, exposeAPI as Le, PHPResponse as We, exposeSyncAPI as Be } from "@php-wasm/universal";
3
- import { resolveRemoteBlueprint as Ue, resolveRuntimeConfiguration as ne, compileBlueprintV1 as he, isBlueprintBundle as _e, runBlueprintV1Steps as ie } from "@wp-playground/blueprints";
4
- import { RecommendedPHPVersion as T, zipDirectory as Ne } from "@wp-playground/common";
5
- import c, { existsSync as Q, rmdirSync as He, mkdirSync as z, readdirSync as Fe } from "fs";
6
- import { MessageChannel as we, Worker as se } from "worker_threads";
7
- import { createNodeFsMountHandler as Oe } from "@php-wasm/node";
8
- import d, { basename as _, join as X } from "path";
9
- import { exec as be } from "child_process";
10
- import { promisify as je } from "util";
11
- import ye from "express";
12
- import { Readable as Ve } from "stream";
13
- import { pipeline as qe } from "stream/promises";
14
- import ze from "yargs";
15
- import { NodeJsFilesystem as Ge, OverlayFilesystem as Ye, InMemoryFilesystem as Qe, ZipFilesystem as Xe } from "@wp-playground/storage";
16
- import { EmscriptenDownloadMonitor as Ze, ProgressTracker as Je } from "@php-wasm/progress";
17
- import { resolveWordPressRelease as Ke } from "@wp-playground/wordpress";
18
- import C from "fs-extra";
19
- import { createRequire as et } from "module";
1
+ import { logger as h, LogSeverity as O, errorLogPath as re } from "@php-wasm/logger";
2
+ import { consumeAPI as he, isLegacyPHPVersion as Q, AllPHPVersions as Ce, isPHPNextVersion as Te, ProcessIdAllocator as Ae, printDebugDetails as De, HttpCookieStore as Re, FileLockManagerInMemory as Le, StreamedPHPResponse as oe, SupportedPHPVersions as j, createObjectPoolProxy as We, exposeAPI as Be, PHPResponse as Ue, exposeSyncAPI as _e } from "@php-wasm/universal";
3
+ import { resolveRemoteBlueprint as He, resolveRuntimeConfiguration as ne, compileBlueprintV1 as we, isBlueprintBundle as Ne, runBlueprintV1Steps as ie } from "@wp-playground/blueprints";
4
+ import { RecommendedPHPVersion as T, zipDirectory as Fe } from "@wp-playground/common";
5
+ import m, { existsSync as X, rmSync as Oe, mkdirSync as z, readdirSync as je } from "fs";
6
+ import { MessageChannel as be, Worker as se } from "worker_threads";
7
+ import { createNodeFsMountHandler as Ve } from "@php-wasm/node";
8
+ import d, { basename as _, join as Z } from "path";
9
+ import { exec as ye } from "child_process";
10
+ import { promisify as qe } from "util";
11
+ import ge from "express";
12
+ import { Readable as ze } from "stream";
13
+ import { pipeline as Ge } from "stream/promises";
14
+ import Ye from "yargs";
15
+ import { NodeJsFilesystem as Qe, OverlayFilesystem as Xe, InMemoryFilesystem as Ze, ZipFilesystem as Je } from "@wp-playground/storage";
16
+ import { EmscriptenDownloadMonitor as Ke, ProgressTracker as et } from "@php-wasm/progress";
17
+ import { resolveWordPressRelease as tt } from "@wp-playground/wordpress";
18
+ import A from "fs-extra";
19
+ import { createRequire as rt } from "module";
20
20
  import B from "os";
21
- import { startBridge as tt } from "@php-wasm/xdebug-bridge";
22
- import { dir as rt, setGracefulCleanup as ot } from "tmp-promise";
23
- import { CLIOutput as nt, removeTempDirSymlink as it, createTempDirSymlink as ae, makeXdebugConfig as st, DEFAULT_PATH_SKIPPINGS as le, clearXdebugIDEConfig as at, addXdebugIDEConfig as lt } from "@php-wasm/cli-util";
24
- import { createHash as ut } from "crypto";
25
- import { PHPMYADMIN_INSTALL_PATH as ue, getPhpMyAdminInstallSteps as dt, PHPMYADMIN_ENTRY_PATH as pt } from "@wp-playground/tools";
21
+ import { startBridge as ot } from "@php-wasm/xdebug-bridge";
22
+ import { dir as nt, setGracefulCleanup as it } from "tmp-promise";
23
+ import { CLIOutput as st, removeTempDirSymlink as at, createTempDirSymlink as ae, makeXdebugConfig as lt, DEFAULT_PATH_SKIPPINGS as le, clearXdebugIDEConfig as ut, addXdebugIDEConfig as dt } from "@php-wasm/cli-util";
24
+ import { createHash as pt } from "crypto";
25
+ import { PHPMYADMIN_INSTALL_PATH as ue, getPhpMyAdminInstallSteps as ct, PHPMYADMIN_ENTRY_PATH as mt } from "@wp-playground/tools";
26
26
  import { jspi as de } from "wasm-feature-detect";
27
27
  function V(e) {
28
28
  const t = [];
@@ -34,7 +34,7 @@ function V(e) {
34
34
  If your path contains a colon, e.g. C:\\myplugin, use the --mount-dir option instead.
35
35
  Example: --mount-dir C:\\my-plugin /wordpress/wp-content/plugins/my-plugin`);
36
36
  const [i, o] = n;
37
- if (!Q(i))
37
+ if (!X(i))
38
38
  throw new Error(`Host path does not exist: ${i}`);
39
39
  t.push({ hostPath: i, vfsPath: o });
40
40
  }
@@ -46,7 +46,7 @@ function pe(e) {
46
46
  const t = [];
47
47
  for (let r = 0; r < e.length; r += 2) {
48
48
  const n = e[r], i = e[r + 1];
49
- if (!Q(n))
49
+ if (!X(n))
50
50
  throw new Error(`Host path does not exist: ${n}`);
51
51
  t.push({
52
52
  hostPath: d.resolve(process.cwd(), n),
@@ -55,11 +55,11 @@ function pe(e) {
55
55
  }
56
56
  return t;
57
57
  }
58
- async function gr(e, t) {
58
+ async function vr(e, t) {
59
59
  for (const r of t)
60
60
  await e.mount(
61
61
  r.vfsPath,
62
- Oe(r.hostPath)
62
+ Ve(r.hostPath)
63
63
  );
64
64
  }
65
65
  const ce = {
@@ -81,7 +81,7 @@ const ce = {
81
81
  `
82
82
  }
83
83
  };
84
- function ge(e) {
84
+ function Pe(e) {
85
85
  if (typeof e.autoMount != "string")
86
86
  return e;
87
87
  const t = e.autoMount, r = [...e.mount || []], n = [...e["mount-before-install"] || []], i = {
@@ -92,7 +92,7 @@ function ge(e) {
92
92
  ...e["additional-blueprint-steps"] || []
93
93
  ]
94
94
  };
95
- if (ht(t)) {
95
+ if (bt(t)) {
96
96
  const a = `/wordpress/wp-content/plugins/${_(t)}`;
97
97
  r.push({
98
98
  hostPath: t,
@@ -102,7 +102,7 @@ function ge(e) {
102
102
  step: "activatePlugin",
103
103
  pluginPath: `/wordpress/wp-content/plugins/${_(t)}`
104
104
  });
105
- } else if (ft(t)) {
105
+ } else if (wt(t)) {
106
106
  const o = _(t), a = `/wordpress/wp-content/themes/${o}`;
107
107
  r.push({
108
108
  hostPath: t,
@@ -117,44 +117,44 @@ function ge(e) {
117
117
  themeFolderName: o
118
118
  }
119
119
  );
120
- } else if (mt(t)) {
121
- const o = c.readdirSync(t);
120
+ } else if (ht(t)) {
121
+ const o = m.readdirSync(t);
122
122
  for (const a of o)
123
123
  a !== "index.php" && r.push({
124
- hostPath: X(t, a),
124
+ hostPath: Z(t, a),
125
125
  vfsPath: `/wordpress/wp-content/${a}`,
126
126
  autoMounted: !0
127
127
  });
128
128
  i["additional-blueprint-steps"].push(ce);
129
- } else ct(t) && (n.push({
129
+ } else ft(t) && (n.push({
130
130
  hostPath: t,
131
131
  vfsPath: "/wordpress",
132
132
  autoMounted: !0
133
133
  }), i.mode = "apply-to-existing-site", i["additional-blueprint-steps"].push(ce), i.wordpressInstallMode || (i.wordpressInstallMode = "install-from-existing-files-if-needed"));
134
134
  return i;
135
135
  }
136
- function ct(e) {
137
- const t = c.readdirSync(e);
136
+ function ft(e) {
137
+ const t = m.readdirSync(e);
138
138
  return t.includes("wp-admin") && t.includes("wp-includes") && t.includes("wp-content");
139
139
  }
140
- function mt(e) {
141
- const t = c.readdirSync(e);
140
+ function ht(e) {
141
+ const t = m.readdirSync(e);
142
142
  return t.includes("themes") || t.includes("plugins") || t.includes("mu-plugins") || t.includes("uploads");
143
143
  }
144
- function ft(e) {
145
- if (!c.readdirSync(e).includes("style.css"))
144
+ function wt(e) {
145
+ if (!m.readdirSync(e).includes("style.css"))
146
146
  return !1;
147
- const r = c.readFileSync(X(e, "style.css"), "utf8");
147
+ const r = m.readFileSync(Z(e, "style.css"), "utf8");
148
148
  return !!/^(?:[ \t]*<\?php)?[ \t/*#@]*Theme Name:(.*)$/im.exec(r);
149
149
  }
150
- function ht(e) {
151
- const t = c.readdirSync(e), r = /^(?:[ \t]*<\?php)?[ \t/*#@]*Plugin Name:(.*)$/im;
150
+ function bt(e) {
151
+ const t = m.readdirSync(e), r = /^(?:[ \t]*<\?php)?[ \t/*#@]*Plugin Name:(.*)$/im;
152
152
  return !!t.filter((i) => i.endsWith(".php")).find((i) => {
153
- const o = c.readFileSync(X(e, i), "utf8");
153
+ const o = m.readFileSync(Z(e, i), "utf8");
154
154
  return !!r.exec(o);
155
155
  });
156
156
  }
157
- function wt(e) {
157
+ function yt(e) {
158
158
  if (e.length % 2 !== 0)
159
159
  throw new Error(
160
160
  "Invalid constant definition format. Expected pairs of NAME value"
@@ -168,7 +168,7 @@ function wt(e) {
168
168
  }
169
169
  return t;
170
170
  }
171
- function bt(e) {
171
+ function gt(e) {
172
172
  if (e.length % 2 !== 0)
173
173
  throw new Error(
174
174
  "Invalid boolean constant definition format. Expected pairs of NAME value"
@@ -189,7 +189,7 @@ function bt(e) {
189
189
  }
190
190
  return t;
191
191
  }
192
- function yt(e) {
192
+ function Pt(e) {
193
193
  if (e.length % 2 !== 0)
194
194
  throw new Error(
195
195
  "Invalid number constant definition format. Expected pairs of NAME value"
@@ -208,7 +208,7 @@ function yt(e) {
208
208
  }
209
209
  return t;
210
210
  }
211
- function gt(e = {}, t = {}, r = {}) {
211
+ function vt(e = {}, t = {}, r = {}) {
212
212
  const n = {}, i = /* @__PURE__ */ new Set(), o = (a, l) => {
213
213
  for (const u in a) {
214
214
  if (i.has(u))
@@ -220,48 +220,48 @@ function gt(e = {}, t = {}, r = {}) {
220
220
  };
221
221
  return o(e, "string"), o(t, "bool"), o(r, "number"), n;
222
222
  }
223
- function Z(e) {
224
- return gt(
223
+ function J(e) {
224
+ return vt(
225
225
  e.define,
226
226
  e["define-bool"],
227
227
  e["define-number"]
228
228
  );
229
229
  }
230
- const Pt = je(be);
231
- function vt(e) {
230
+ const St = qe(ye);
231
+ function xt(e) {
232
232
  return new Promise((t) => {
233
233
  if (e === 0) return t(!1);
234
- const r = ye().listen(e);
234
+ const r = ge().listen(e);
235
235
  r.once("listening", () => r.close(() => t(!1))), r.once(
236
236
  "error",
237
237
  (n) => t(n.code === "EADDRINUSE")
238
238
  );
239
239
  });
240
240
  }
241
- async function St(e) {
242
- const t = ye(), r = await new Promise((a, l) => {
241
+ async function Et(e) {
242
+ const t = ge(), r = await new Promise((a, l) => {
243
243
  const u = t.listen(e.port, () => {
244
- const f = u.address();
245
- f === null || typeof f == "string" ? l(new Error("Server address is not available")) : a(u);
244
+ const p = u.address();
245
+ p === null || typeof p == "string" ? l(new Error("Server address is not available")) : a(u);
246
246
  }).once("error", l);
247
247
  });
248
248
  t.use("/", async (a, l) => {
249
249
  try {
250
250
  const u = {
251
251
  url: a.url,
252
- headers: kt(a),
252
+ headers: Mt(a),
253
253
  method: a.method,
254
- body: await Et(a)
255
- }, f = await e.handleRequest(u);
256
- await xt(f, l);
254
+ body: await kt(a)
255
+ }, p = await e.handleRequest(u);
256
+ await $t(p, l);
257
257
  } catch (u) {
258
258
  h.error(u), l.headersSent || (l.statusCode = 500, l.end("Internal Server Error"));
259
259
  }
260
260
  });
261
261
  const i = r.address().port, o = process.env.CODESPACE_NAME;
262
- return o && $t(i, o), await e.onBind(r, i);
262
+ return o && It(i, o), await e.onBind(r, i);
263
263
  }
264
- async function xt(e, t) {
264
+ async function $t(e, t) {
265
265
  const [r, n] = await Promise.all([
266
266
  e.headers,
267
267
  e.httpStatusCode
@@ -269,16 +269,16 @@ async function xt(e, t) {
269
269
  t.statusCode = n;
270
270
  for (const o in r)
271
271
  t.setHeader(o, r[o]);
272
- const i = Ve.fromWeb(e.stdout);
272
+ const i = ze.fromWeb(e.stdout);
273
273
  try {
274
- await qe(i, t);
274
+ await Ge(i, t);
275
275
  } catch (o) {
276
276
  if (o instanceof Error && "code" in o && (o.code === "ERR_STREAM_PREMATURE_CLOSE" || o.code === "ERR_STREAM_UNABLE_TO_PIPE"))
277
277
  return;
278
278
  throw o;
279
279
  }
280
280
  }
281
- const Et = async (e) => await new Promise((t) => {
281
+ const kt = async (e) => await new Promise((t) => {
282
282
  const r = [];
283
283
  e.on("data", (n) => {
284
284
  r.push(n);
@@ -286,39 +286,39 @@ const Et = async (e) => await new Promise((t) => {
286
286
  t(new Uint8Array(Buffer.concat(r)));
287
287
  });
288
288
  });
289
- async function $t(e, t) {
289
+ async function It(e, t) {
290
290
  h.log(`Publishing port ${e}...`);
291
291
  const r = `gh codespace ports visibility ${e}:public -c ${t}`;
292
292
  for (let n = 0; n < 10; n++)
293
293
  try {
294
- await Pt(r);
294
+ await St(r);
295
295
  return;
296
296
  } catch {
297
297
  await new Promise((i) => setTimeout(i, 2e3));
298
298
  }
299
299
  }
300
- const kt = (e) => {
300
+ const Mt = (e) => {
301
301
  const t = {};
302
302
  if (e.rawHeaders && e.rawHeaders.length)
303
303
  for (let r = 0; r < e.rawHeaders.length; r += 2)
304
304
  t[e.rawHeaders[r].toLowerCase()] = e.rawHeaders[r + 1];
305
305
  return t;
306
306
  };
307
- function It(e) {
307
+ function Ct(e) {
308
308
  return /^latest$|^beta$|^trunk$|^nightly$|^(?:(\d+)\.(\d+)(?:\.(\d+))?)((?:-beta(?:\d+)?)|(?:-RC(?:\d+)?))?$/.test(e);
309
309
  }
310
- async function Mt({
310
+ async function Tt({
311
311
  sourceString: e,
312
312
  blueprintMayReadAdjacentFiles: t
313
313
  }) {
314
314
  if (!e)
315
315
  return;
316
316
  if (e.startsWith("http://") || e.startsWith("https://"))
317
- return await Ue(e);
317
+ return await He(e);
318
318
  let r = d.resolve(process.cwd(), e);
319
- if (!c.existsSync(r))
319
+ if (!m.existsSync(r))
320
320
  throw new Error(`Blueprint file does not exist: ${r}`);
321
- const n = c.statSync(r);
321
+ const n = m.statSync(r);
322
322
  if (n.isDirectory() && (r = d.join(r, "blueprint.json")), !n.isFile() && n.isSymbolicLink())
323
323
  throw new Error(
324
324
  `Blueprint path is neither a file nor a directory: ${r}`
@@ -326,11 +326,11 @@ async function Mt({
326
326
  const i = d.extname(r);
327
327
  switch (i) {
328
328
  case ".zip":
329
- return Xe.fromArrayBuffer(
330
- c.readFileSync(r).buffer
329
+ return Je.fromArrayBuffer(
330
+ m.readFileSync(r).buffer
331
331
  );
332
332
  case ".json": {
333
- const o = c.readFileSync(r, "utf-8");
333
+ const o = m.readFileSync(r, "utf-8");
334
334
  try {
335
335
  JSON.parse(o);
336
336
  } catch {
@@ -338,9 +338,9 @@ async function Mt({
338
338
  `Blueprint file at ${r} is not a valid JSON file`
339
339
  );
340
340
  }
341
- const a = d.dirname(r), l = new Ge(a);
342
- return new Ye([
343
- new Qe({
341
+ const a = d.dirname(r), l = new Qe(a);
342
+ return new Xe([
343
+ new Ze({
344
344
  "blueprint.json": o
345
345
  }),
346
346
  /**
@@ -366,7 +366,7 @@ You can allow this Blueprint to read files from the same parent directory by exp
366
366
  );
367
367
  }
368
368
  }
369
- function Pe(e) {
369
+ function ve(e) {
370
370
  const t = [];
371
371
  e.intl && t.push("intl"), e.redis && t.push("redis"), e.memcached && t.push("memcached"), e.xdebug && t.push(
372
372
  typeof e.xdebug == "object" ? { name: "xdebug", options: e.xdebug } : "xdebug"
@@ -380,7 +380,7 @@ function Pe(e) {
380
380
  });
381
381
  return t;
382
382
  }
383
- class Tt {
383
+ class At {
384
384
  constructor(t, r) {
385
385
  this.args = t, this.siteUrl = r.siteUrl, this.phpVersion = t.php, this.cliOutput = r.cliOutput;
386
386
  }
@@ -401,7 +401,7 @@ class Tt {
401
401
  fileLockManagerPort: r,
402
402
  nativeInternalDirPath: n
403
403
  }) {
404
- const i = fe(t.phpPort);
404
+ const i = he(t.phpPort);
405
405
  await i.useFileLockManager(r);
406
406
  const o = {
407
407
  ...this.args,
@@ -409,21 +409,21 @@ class Tt {
409
409
  siteUrl: this.siteUrl,
410
410
  processId: t.processId,
411
411
  trace: this.args.verbosity === "debug",
412
- extensions: Pe(this.args),
412
+ extensions: ve(this.args),
413
413
  nativeInternalDirPath: n,
414
414
  mountsBeforeWpInstall: this.args["mount-before-install"] || [],
415
415
  mountsAfterWpInstall: this.args.mount || [],
416
- constants: Z(this.args)
416
+ constants: J(this.args)
417
417
  };
418
418
  return await i.bootWorker(o), i;
419
419
  }
420
420
  }
421
421
  const G = d.join(B.homedir(), ".wordpress-playground");
422
- async function Ct(e = "trunk") {
422
+ async function Dt(e = "trunk") {
423
423
  const t = typeof __dirname < "u" ? __dirname : import.meta.dirname;
424
424
  let r = d.join(t, "sqlite-database-integration.zip");
425
- if (!C.existsSync(r)) {
426
- const n = et(import.meta.url), i = d.dirname(
425
+ if (!A.existsSync(r)) {
426
+ const n = rt(import.meta.url), i = d.dirname(
427
427
  n.resolve("@wp-playground/wordpress-builds/package.json")
428
428
  );
429
429
  r = d.join(
@@ -433,14 +433,14 @@ async function Ct(e = "trunk") {
433
433
  `sqlite-database-integration-${e}.zip`
434
434
  );
435
435
  }
436
- return new File([await C.readFile(r)], d.basename(r));
436
+ return new File([await A.readFile(r)], d.basename(r));
437
437
  }
438
- async function At(e, t, r) {
438
+ async function Rt(e, t, r) {
439
439
  const n = d.join(G, t);
440
- return C.existsSync(n) || (C.ensureDirSync(G), await Dt(e, n, r)), ve(n);
440
+ return A.existsSync(n) || (A.ensureDirSync(G), await Lt(e, n, r)), Se(n);
441
441
  }
442
- async function Dt(e, t, r) {
443
- const i = (await r.monitorFetch(fetch(e))).body.getReader(), o = `${t}.partial`, a = C.createWriteStream(o);
442
+ async function Lt(e, t, r) {
443
+ const i = (await r.monitorFetch(fetch(e))).body.getReader(), o = `${t}.partial`, a = A.createWriteStream(o);
444
444
  for (; ; ) {
445
445
  const { done: l, value: u } = await i.read();
446
446
  if (u && a.write(u), l)
@@ -448,16 +448,16 @@ async function Dt(e, t, r) {
448
448
  }
449
449
  a.close(), a.closed || await new Promise((l, u) => {
450
450
  a.on("finish", () => {
451
- C.renameSync(o, t), l(null);
452
- }), a.on("error", (f) => {
453
- C.removeSync(o), u(f);
451
+ A.renameSync(o, t), l(null);
452
+ }), a.on("error", (p) => {
453
+ A.removeSync(o), u(p);
454
454
  });
455
455
  });
456
456
  }
457
- function ve(e, t) {
458
- return new File([C.readFileSync(e)], _(e));
457
+ function Se(e, t) {
458
+ return new File([A.readFileSync(e)], _(e));
459
459
  }
460
- class Rt {
460
+ class Wt {
461
461
  constructor(t, r) {
462
462
  this.args = t, this.siteUrl = r.siteUrl, this.cliOutput = r.cliOutput;
463
463
  }
@@ -466,23 +466,23 @@ class Rt {
466
466
  }
467
467
  async bootWordPress(t, r) {
468
468
  let n, i, o;
469
- const a = new Ze();
469
+ const a = new Ke();
470
470
  if (this.args.wordpressInstallMode === "download-and-install") {
471
- let f = !1;
472
- a.addEventListener("progress", (A) => {
473
- if (f)
471
+ let p = !1;
472
+ a.addEventListener("progress", (C) => {
473
+ if (p)
474
474
  return;
475
- const { loaded: E, total: m } = A.detail, $ = Math.floor(
476
- Math.min(100, 100 * E / m)
475
+ const { loaded: E, total: f } = C.detail, $ = Math.floor(
476
+ Math.min(100, 100 * E / f)
477
477
  );
478
- f = $ === 100, this.cliOutput.updateProgress(
478
+ p = $ === 100, this.cliOutput.updateProgress(
479
479
  "Downloading WordPress",
480
480
  $
481
481
  );
482
- }), n = await Ke(this.args.wp), o = d.join(
482
+ }), n = await tt(this.args.wp), o = d.join(
483
483
  G,
484
484
  `prebuilt-wp-content-for-wp-${n.version}.zip`
485
- ), i = c.existsSync(o) ? ve(o) : await At(
485
+ ), i = m.existsSync(o) ? Se(o) : await Rt(
486
486
  n.releaseUrl,
487
487
  `${n.version}.zip`,
488
488
  a
@@ -495,8 +495,8 @@ class Rt {
495
495
  h.debug("Skipping SQLite integration plugin setup..."), l = void 0;
496
496
  else {
497
497
  this.cliOutput.updateProgress("Preparing SQLite database");
498
- const f = this.args.php || T, E = Y(f) ? "v3.0.0-rc.3-php52" : "trunk";
499
- l = await Ct(E);
498
+ const p = this.args.php || T, E = Q(p) ? "v3.0.0-rc.3-php52" : "trunk";
499
+ l = await Dt(E);
500
500
  }
501
501
  this.cliOutput.updateProgress("Booting WordPress");
502
502
  const u = await ne(
@@ -510,14 +510,14 @@ class Rt {
510
510
  wordpressInstallMode: this.args.wordpressInstallMode || "download-and-install",
511
511
  wordPressZip: i && await i.arrayBuffer(),
512
512
  sqliteIntegrationPluginZip: await l?.arrayBuffer(),
513
- constants: Z(this.args)
513
+ constants: J(this.args)
514
514
  },
515
515
  r
516
- ), o && !this.args["mount-before-install"] && !c.existsSync(o) && (this.cliOutput.updateProgress("Caching WordPress for next boot"), c.writeFileSync(
516
+ ), o && !this.args["mount-before-install"] && !m.existsSync(o) && (this.cliOutput.updateProgress("Caching WordPress for next boot"), m.writeFileSync(
517
517
  o,
518
518
  // Comlink proxy is not assignable to UniversalPHP but
519
519
  // proxies all method calls transparently at runtime.
520
- await Ne(
520
+ await Fe(
521
521
  t,
522
522
  "/wordpress"
523
523
  )
@@ -528,7 +528,7 @@ class Rt {
528
528
  fileLockManagerPort: r,
529
529
  nativeInternalDirPath: n
530
530
  }) {
531
- const i = fe(
531
+ const i = he(
532
532
  t.phpPort
533
533
  );
534
534
  await i.isConnected();
@@ -543,13 +543,13 @@ class Rt {
543
543
  processId: t.processId,
544
544
  followSymlinks: this.args.followSymlinks === !0,
545
545
  trace: this.args.experimentalTrace === !0,
546
- extensions: Pe(this.args),
546
+ extensions: ve(this.args),
547
547
  nativeInternalDirPath: n,
548
548
  pathAliases: this.args.pathAliases
549
549
  }), await i.isReady(), i;
550
550
  }
551
551
  async compileInputBlueprint(t) {
552
- const r = this.getEffectiveBlueprint(), n = new Je();
552
+ const r = this.getEffectiveBlueprint(), n = new et();
553
553
  let i = "", o = !1;
554
554
  return n.addEventListener("progress", (a) => {
555
555
  if (o)
@@ -557,14 +557,14 @@ class Rt {
557
557
  o = a.detail.progress === 100;
558
558
  const l = Math.floor(a.detail.progress);
559
559
  i = a.detail.caption || i || "Running Blueprint", this.cliOutput.updateProgress(i.trim(), l);
560
- }), await he(r, {
560
+ }), await we(r, {
561
561
  progress: n,
562
562
  additionalSteps: t
563
563
  });
564
564
  }
565
565
  getEffectiveBlueprint() {
566
566
  const t = this.args.blueprint;
567
- return _e(t) ? t : {
567
+ return Ne(t) ? t : {
568
568
  login: this.args.login,
569
569
  ...t || {},
570
570
  preferredVersions: {
@@ -575,8 +575,8 @@ class Rt {
575
575
  };
576
576
  }
577
577
  }
578
- async function Lt(e, t = !0) {
579
- const n = `${d.basename(process.argv0)}${e}${process.pid}-`, i = await rt({
578
+ async function Bt(e, t = !0) {
579
+ const n = `${d.basename(process.argv0)}${e}${process.pid}-`, i = await nt({
580
580
  prefix: n,
581
581
  /*
582
582
  * Allow recursive cleanup on process exit.
@@ -588,16 +588,16 @@ async function Lt(e, t = !0) {
588
588
  */
589
589
  unsafeCleanup: !0
590
590
  });
591
- return t && ot(), i;
591
+ return t && it(), i;
592
592
  }
593
- async function Wt(e, t, r) {
594
- const i = (await Bt(
593
+ async function Ut(e, t, r) {
594
+ const i = (await _t(
595
595
  e,
596
596
  t,
597
597
  r
598
598
  )).map(
599
599
  (o) => new Promise((a) => {
600
- c.rm(o, { recursive: !0 }, (l) => {
600
+ m.rm(o, { recursive: !0 }, (l) => {
601
601
  l ? h.warn(
602
602
  `Failed to delete stale Playground temp dir: ${o}`,
603
603
  l
@@ -609,11 +609,11 @@ async function Wt(e, t, r) {
609
609
  );
610
610
  await Promise.all(i);
611
611
  }
612
- async function Bt(e, t, r) {
612
+ async function _t(e, t, r) {
613
613
  try {
614
- const n = c.readdirSync(r).map((o) => d.join(r, o)), i = [];
614
+ const n = m.readdirSync(r).map((o) => d.join(r, o)), i = [];
615
615
  for (const o of n)
616
- await Ut(
616
+ await Ht(
617
617
  e,
618
618
  t,
619
619
  o
@@ -623,8 +623,8 @@ async function Bt(e, t, r) {
623
623
  return h.warn(`Failed to find stale Playground temp dirs: ${n}`), [];
624
624
  }
625
625
  }
626
- async function Ut(e, t, r) {
627
- if (!c.lstatSync(r).isDirectory())
626
+ async function Ht(e, t, r) {
627
+ if (!m.lstatSync(r).isDirectory())
628
628
  return !1;
629
629
  const i = d.basename(r);
630
630
  if (!i.includes(e))
@@ -638,12 +638,12 @@ async function Ut(e, t, r) {
638
638
  executableName: o[1],
639
639
  pid: o[2]
640
640
  };
641
- if (_t(a.pid))
641
+ if (Nt(a.pid))
642
642
  return !1;
643
643
  const l = Date.now() - t;
644
- return c.statSync(r).mtime.getTime() < l;
644
+ return m.statSync(r).mtime.getTime() < l;
645
645
  }
646
- function _t(e, t) {
646
+ function Nt(e, t) {
647
647
  try {
648
648
  return process.kill(Number(e), 0), !0;
649
649
  } catch (r) {
@@ -657,10 +657,10 @@ function _t(e, t) {
657
657
  ), !0);
658
658
  }
659
659
  }
660
- function Nt(e) {
660
+ function Ft(e) {
661
661
  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;
662
662
  }
663
- class Ht extends nt {
663
+ class Ot extends st {
664
664
  constructor() {
665
665
  super(...arguments), this.lastProgressLine = "", this.progressActive = !1;
666
666
  }
@@ -671,7 +671,7 @@ class Ht extends nt {
671
671
  * This prevents progress spam in logs - users only see the final outcome.
672
672
  */
673
673
  get shouldRender() {
674
- return Nt(this.writeStream);
674
+ return Ft(this.writeStream);
675
675
  }
676
676
  printBanner() {
677
677
  if (this.isQuiet) return;
@@ -788,12 +788,14 @@ ${this.green("Ready!")} WordPress is running on ${this.bold(t)} ${this.dim(`(${r
788
788
  );
789
789
  }
790
790
  }
791
- const J = {
791
+ const K = {
792
792
  Quiet: { name: "quiet", severity: O.Fatal },
793
793
  Normal: { name: "normal", severity: O.Info },
794
794
  Debug: { name: "debug", severity: O.Debug }
795
- };
796
- async function Ft(e) {
795
+ }, me = Ce.filter(
796
+ (e) => !Te(e)
797
+ );
798
+ async function jt(e) {
797
799
  try {
798
800
  const t = {
799
801
  "site-url": {
@@ -804,7 +806,7 @@ async function Ft(e) {
804
806
  describe: "PHP version to use.",
805
807
  type: "string",
806
808
  default: T,
807
- choices: re
809
+ choices: me
808
810
  },
809
811
  wp: {
810
812
  describe: "WordPress version to use.",
@@ -816,21 +818,21 @@ async function Ft(e) {
816
818
  type: "string",
817
819
  nargs: 2,
818
820
  array: !0,
819
- coerce: wt
821
+ coerce: yt
820
822
  },
821
823
  "define-bool": {
822
824
  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',
823
825
  type: "string",
824
826
  nargs: 2,
825
827
  array: !0,
826
- coerce: bt
828
+ coerce: gt
827
829
  },
828
830
  "define-number": {
829
831
  describe: "Define PHP number constants (can be used multiple times). Format: NAME value. Examples: --define-number LIMIT 100 --define-number RATE 45.67",
830
832
  type: "string",
831
833
  nargs: 2,
832
834
  array: !0,
833
- coerce: yt
835
+ coerce: Pt
834
836
  },
835
837
  // @TODO: Support read-only mounts, e.g. via WORKERFS, a custom
836
838
  // ReadOnlyNODEFS, or by copying the files into MEMFS
@@ -907,7 +909,7 @@ async function Ft(e) {
907
909
  verbosity: {
908
910
  describe: "Output logs and progress messages.",
909
911
  type: "string",
910
- choices: Object.values(J).map(
912
+ choices: Object.values(K).map(
911
913
  (s) => s.name
912
914
  ),
913
915
  default: "normal"
@@ -1035,7 +1037,7 @@ Warning: Following symlinks will expose files outside mounted directories to Pla
1035
1037
  describe: "PHP version to use.",
1036
1038
  type: "string",
1037
1039
  default: T,
1038
- choices: re
1040
+ choices: me
1039
1041
  },
1040
1042
  wp: {
1041
1043
  describe: "WordPress version to use.",
@@ -1105,7 +1107,7 @@ Warning: Following symlinks will expose files outside mounted directories to Pla
1105
1107
  type: "string",
1106
1108
  default: "wordpress.zip"
1107
1109
  }
1108
- }, o = ze(e).usage("Usage: wp-playground <command> [options]").command(
1110
+ }, o = Ye(e).usage("Usage: wp-playground <command> [options]").command(
1109
1111
  "start",
1110
1112
  "Start a local WordPress server with automatic project detection (recommended)",
1111
1113
  (s) => s.usage(
@@ -1157,7 +1159,7 @@ Examples:
1157
1159
  throw new Error(
1158
1160
  "The --phpmyadmin option requires SQLite setup. Remove --skip-sqlite-setup to use phpMyAdmin."
1159
1161
  );
1160
- if (s.wp !== void 0 && typeof s.wp == "string" && !It(s.wp))
1162
+ if (s.wp !== void 0 && typeof s.wp == "string" && !Ct(s.wp))
1161
1163
  try {
1162
1164
  new URL(s.wp);
1163
1165
  } catch {
@@ -1178,7 +1180,7 @@ Examples:
1178
1180
  if (s._[0] !== "start" && typeof y == "string" && y) {
1179
1181
  let x = !1;
1180
1182
  try {
1181
- x = c.statSync(y).isDirectory();
1183
+ x = m.statSync(y).isDirectory();
1182
1184
  } catch {
1183
1185
  x = !1;
1184
1186
  }
@@ -1206,11 +1208,13 @@ Examples:
1206
1208
  "build-snapshot",
1207
1209
  "php"
1208
1210
  ].includes(l) || (o.showHelp(), process.exit(1));
1209
- const u = a.define || {}, f = a["define-bool"] || {}, A = a["define-number"] || {}, E = (s) => s in u || s in f || s in A, m = a.php || T;
1210
- Y(m) || (E("WP_DEBUG") || (u.WP_DEBUG = "true"), E("WP_DEBUG_LOG") || (u.WP_DEBUG_LOG = "true"), E("WP_DEBUG_DISPLAY") || (u.WP_DEBUG_DISPLAY = "false"));
1211
+ const u = a.define || {}, p = a["define-bool"] || {}, C = a["define-number"] || {}, E = (s) => s in u || s in p || s in C, f = a.php || T;
1212
+ Q(f) || (E("WP_DEBUG") || (p.WP_DEBUG = !0), E("WP_DEBUG_LOG") || (p.WP_DEBUG_LOG = !0), E("WP_DEBUG_DISPLAY") || (p.WP_DEBUG_DISPLAY = !1));
1211
1213
  const k = {
1212
1214
  ...a,
1213
1215
  define: u,
1216
+ "define-bool": p,
1217
+ "define-number": C,
1214
1218
  command: l,
1215
1219
  mount: [
1216
1220
  ...a.mount || [],
@@ -1232,32 +1236,42 @@ Examples:
1232
1236
  [Symbol.asyncDispose]: async () => {
1233
1237
  process.off("SIGINT", D), process.off("SIGTERM", D), await M[Symbol.asyncDispose]();
1234
1238
  },
1235
- [K]: { cliServer: M }
1239
+ [ee]: { cliServer: M }
1236
1240
  };
1237
1241
  } catch (t) {
1238
1242
  console.error(t);
1239
1243
  const r = process.argv.includes("--debug");
1240
1244
  if (t instanceof Error)
1241
1245
  if (r)
1242
- Ce(t);
1246
+ De(t);
1243
1247
  else {
1244
- const n = [];
1245
- let i = t;
1246
- do
1247
- n.push(i.message), i = i.cause;
1248
- while (i instanceof Error);
1249
- console.error(
1248
+ const n = [], i = /* @__PURE__ */ new Set();
1249
+ let o = t;
1250
+ for (let a = 0; o && a < 20; a++) {
1251
+ if (i.has(o)) {
1252
+ n.push("[Circular error cause]"), o = void 0;
1253
+ break;
1254
+ }
1255
+ i.add(o), n.push(Y(o)), o = o.cause instanceof Error ? o.cause : void 0;
1256
+ }
1257
+ o && n.push("[Error cause chain truncated]"), console.error(
1250
1258
  "\x1B[1m" + n.join(" caused by: ") + "\x1B[0m"
1251
1259
  );
1252
1260
  }
1253
1261
  else
1254
- console.error("\x1B[1m" + Se(t) + "\x1B[0m");
1262
+ console.error("\x1B[1m" + Y(t) + "\x1B[0m");
1255
1263
  process.exit(1);
1256
1264
  }
1257
1265
  }
1258
- function Se(e) {
1259
- if (e instanceof Error)
1260
- return e.message;
1266
+ function Y(e) {
1267
+ if (e instanceof Error) {
1268
+ if (e.message)
1269
+ return e.message;
1270
+ const t = [];
1271
+ e.name && e.name !== "Error" && t.push(e.name);
1272
+ const r = e;
1273
+ return r.errno !== void 0 && t.push(`errno: ${r.errno}`), r.code !== void 0 && t.push(`code: ${r.code}`), t.length > 0 ? t.join(" — ") : e.stack || String(e);
1274
+ }
1261
1275
  if (e && typeof e == "object") {
1262
1276
  const t = [], r = e;
1263
1277
  if (r.name && t.push(String(r.name)), r.message && t.push(String(r.message)), r.errno !== void 0 && t.push(`errno: ${r.errno}`), t.length > 0)
@@ -1270,7 +1284,7 @@ function Se(e) {
1270
1284
  }
1271
1285
  return String(e);
1272
1286
  }
1273
- function me(e, t) {
1287
+ function fe(e, t) {
1274
1288
  return e.find(
1275
1289
  (r) => r.vfsPath.replace(/\/$/, "") === t.replace(/\/$/, "")
1276
1290
  );
@@ -1279,19 +1293,19 @@ function xe(e) {
1279
1293
  const t = Math.max(1, B.cpus().length - 1);
1280
1294
  return e === void 0 ? Math.min(6, t) : e === "auto" ? t : e;
1281
1295
  }
1282
- const K = Symbol("playground-cli-testing");
1296
+ const ee = Symbol("playground-cli-testing");
1283
1297
  async function Ee(e) {
1284
1298
  let t;
1285
- const r = e.internalCookieStore ? new Ae() : void 0, n = [], i = /* @__PURE__ */ new Map(), o = new Ht({
1299
+ const r = e.internalCookieStore ? new Re() : void 0, n = [], i = /* @__PURE__ */ new Map(), o = new Ot({
1286
1300
  verbosity: e.verbosity || "normal"
1287
1301
  });
1288
- if (e.command === "start" && (e = Ot(e, o)), e.autoMount !== void 0 && (e.autoMount === "" && (e = { ...e, autoMount: process.cwd() }), e = ge(e)), e.wordpressInstallMode === void 0 && (e.wordpressInstallMode = "download-and-install"), e.quiet && (e.verbosity = "quiet", delete e.quiet), e.debug && (e.verbosity = "debug", delete e.debug), e.verbosity) {
1289
- const m = Object.values(J).find(
1302
+ if (e.command === "start" && (e = Vt(e, o)), e.autoMount !== void 0 && (e.autoMount === "" && (e = { ...e, autoMount: process.cwd() }), e = Pe(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) {
1303
+ const f = Object.values(K).find(
1290
1304
  ($) => $.name === e.verbosity
1291
1305
  ).severity;
1292
- h.setSeverityFilterLevel(m);
1306
+ h.setSeverityFilterLevel(f);
1293
1307
  }
1294
- e.intl || (e.intl = !0), e.redis === void 0 && (e.redis = await de()), e.memcached === void 0 && (e.memcached = await de()), Y(e.php || T) && (e.intl = !1, e.redis = !1, e.memcached = !1, e.xdebug = !1), e.phpmyadmin && (e.phpmyadmin === !0 && (e.phpmyadmin = "/phpmyadmin"), e.pathAliases = [
1308
+ e.intl || (e.intl = !0), e.redis === void 0 && (e.redis = await de()), e.memcached === void 0 && (e.memcached = await de()), Q(e.php || T) && (e.intl = !1, e.redis = !1, e.memcached = !1, e.xdebug = !1), e.phpmyadmin && (e.phpmyadmin === !0 && (e.phpmyadmin = "/phpmyadmin"), e.pathAliases = [
1295
1309
  {
1296
1310
  urlPrefix: e.phpmyadmin,
1297
1311
  fsPath: ue
@@ -1310,41 +1324,41 @@ async function Ee(e) {
1310
1324
  ],
1311
1325
  blueprint: typeof e.blueprint == "string" ? e.blueprint : void 0
1312
1326
  }));
1313
- const l = e.command === "server" ? e.port ?? 9400 : 0, u = new De();
1314
- let f = !1, A = !0;
1315
- const E = await St({
1316
- port: e.port ? e.port : await vt(l) ? 0 : l,
1317
- onBind: async (m, $) => {
1327
+ const l = e.command === "server" ? e.port ?? 9400 : 0, u = new Le();
1328
+ let p = !1, C = !0;
1329
+ const E = await Et({
1330
+ port: e.port ? e.port : await xt(l) ? 0 : l,
1331
+ onBind: async (f, $) => {
1318
1332
  const k = "127.0.0.1", M = `http://${k}:${$}`, D = e["site-url"] || M;
1319
1333
  e["experimental-multi-worker"] !== void 0 && h.warn(
1320
1334
  "--experimental-multi-worker is deprecated and its value is ignored. Use --workers=<n|auto> instead."
1321
1335
  );
1322
1336
  const s = xe(e.workers);
1323
1337
  if (s < 6) {
1324
- const p = "Running fewer than 6 workers may increase the likelihood of deadlock due to workers blocking on file locks.";
1338
+ const c = "Running fewer than 6 workers may increase the likelihood of deadlock due to workers blocking on file locks.";
1325
1339
  e.workers === void 0 ? h.warn(
1326
- `The default worker count has been reduced to ${s} because this machine has only ${B.cpus().length} CPU(s). ` + p
1340
+ `The default worker count has been reduced to ${s} because this machine has only ${B.cpus().length} CPU(s). ` + c
1327
1341
  ) : h.warn(
1328
- `Worker count (${s}) is below the recommended threshold (6). ` + p
1342
+ `Worker count (${s}) is below the recommended threshold (6). ` + c
1329
1343
  );
1330
1344
  }
1331
- const b = "-playground-cli-site-", y = await Lt(b);
1345
+ const b = "-playground-cli-site-", y = await Bt(b);
1332
1346
  h.debug(`Native temp dir for VFS root: ${y.path}`);
1333
- const x = "WP Playground CLI - Listen for Xdebug", N = ".playground-xdebug-root", H = d.join(process.cwd(), N);
1334
- if (await it(H), e.xdebug) {
1335
- const p = {
1336
- hostPath: d.join(".", d.sep, N),
1347
+ const x = "WP Playground CLI - Listen for Xdebug", H = ".playground-xdebug-root", N = d.join(process.cwd(), H);
1348
+ if (await at(N), e.xdebug) {
1349
+ const c = {
1350
+ hostPath: d.join(".", d.sep, H),
1337
1351
  vfsPath: "/"
1338
1352
  }, w = e.php || T;
1339
1353
  if (j.includes(w) && j.indexOf(w) <= j.indexOf("8.5"))
1340
1354
  await ae(
1341
1355
  y.path,
1342
- H,
1356
+ N,
1343
1357
  process.platform
1344
- ), e.xdebug = st({
1358
+ ), e.xdebug = lt({
1345
1359
  cwd: process.cwd(),
1346
1360
  mounts: [
1347
- p,
1361
+ c,
1348
1362
  ...e["mount-before-install"] || [],
1349
1363
  ...e.mount || []
1350
1364
  ],
@@ -1361,22 +1375,22 @@ async function Ee(e) {
1361
1375
  else if (e.experimentalUnsafeIdeIntegration) {
1362
1376
  await ae(
1363
1377
  y.path,
1364
- H,
1378
+ N,
1365
1379
  process.platform
1366
1380
  );
1367
1381
  try {
1368
- await at(
1382
+ await ut(
1369
1383
  x,
1370
1384
  process.cwd()
1371
1385
  );
1372
- const P = typeof e.xdebug == "object" ? e.xdebug : {}, v = await lt({
1386
+ const P = typeof e.xdebug == "object" ? e.xdebug : {}, v = await dt({
1373
1387
  name: x,
1374
1388
  host: k,
1375
1389
  port: $,
1376
1390
  ides: e.experimentalUnsafeIdeIntegration,
1377
1391
  cwd: process.cwd(),
1378
1392
  mounts: [
1379
- p,
1393
+ c,
1380
1394
  ...e["mount-before-install"] || [],
1381
1395
  ...e.mount || []
1382
1396
  ],
@@ -1446,13 +1460,13 @@ async function Ee(e) {
1446
1460
  }
1447
1461
  }
1448
1462
  const ke = d.dirname(y.path), Ie = 2 * 24 * 60 * 60 * 1e3;
1449
- Wt(
1463
+ Ut(
1450
1464
  b,
1451
1465
  Ie,
1452
1466
  ke
1453
1467
  );
1454
- const ee = d.join(y.path, "internal");
1455
- z(ee);
1468
+ const te = d.join(y.path, "internal");
1469
+ z(te);
1456
1470
  const Me = [
1457
1471
  "wordpress",
1458
1472
  "tools",
@@ -1465,37 +1479,37 @@ async function Ee(e) {
1465
1479
  "tmp",
1466
1480
  "home"
1467
1481
  ];
1468
- for (const p of Me) {
1469
- const w = (P) => P.vfsPath === `/${p}`;
1482
+ for (const c of Me) {
1483
+ const w = (P) => P.vfsPath === `/${c}`;
1470
1484
  if (!(e["mount-before-install"]?.some(w) || e.mount?.some(w))) {
1471
1485
  const P = d.join(
1472
1486
  y.path,
1473
- p
1487
+ c
1474
1488
  );
1475
1489
  z(P), e["mount-before-install"] === void 0 && (e["mount-before-install"] = []), e["mount-before-install"].unshift({
1476
- vfsPath: `/${p}`,
1490
+ vfsPath: `/${c}`,
1477
1491
  hostPath: P
1478
1492
  });
1479
1493
  }
1480
1494
  }
1481
1495
  if (e["mount-before-install"])
1482
- for (const p of e["mount-before-install"])
1496
+ for (const c of e["mount-before-install"])
1483
1497
  h.debug(
1484
- `Mount before WP install: ${p.vfsPath} -> ${p.hostPath}`
1498
+ `Mount before WP install: ${c.vfsPath} -> ${c.hostPath}`
1485
1499
  );
1486
1500
  if (e.mount)
1487
- for (const p of e.mount)
1501
+ for (const c of e.mount)
1488
1502
  h.debug(
1489
- `Mount after WP install: ${p.vfsPath} -> ${p.hostPath}`
1503
+ `Mount after WP install: ${c.vfsPath} -> ${c.hostPath}`
1490
1504
  );
1491
1505
  let R;
1492
- e["experimental-blueprints-v2-runner"] ? R = new Tt(e, {
1506
+ e["experimental-blueprints-v2-runner"] ? R = new At(e, {
1493
1507
  siteUrl: D,
1494
1508
  cliOutput: o
1495
- }) : (R = new Rt(e, {
1509
+ }) : (R = new Wt(e, {
1496
1510
  siteUrl: D,
1497
1511
  cliOutput: o
1498
- }), typeof e.blueprint == "string" && (e.blueprint = await Mt({
1512
+ }), typeof e.blueprint == "string" && (e.blueprint = await Tt({
1499
1513
  sourceString: e.blueprint,
1500
1514
  blueprintMayReadAdjacentFiles: e["blueprint-may-read-adjacent-files"] === !0
1501
1515
  })));
@@ -1505,12 +1519,12 @@ async function Ee(e) {
1505
1519
  n.map(async (w) => {
1506
1520
  await i.get(w)?.dispose(), await w.worker.terminate();
1507
1521
  })
1508
- ), m && await new Promise((w) => {
1509
- m.close(w), m.closeAllConnections();
1522
+ ), f && await new Promise((w) => {
1523
+ f.close(w), f.closeAllConnections();
1510
1524
  }), await y.cleanup());
1511
1525
  };
1512
1526
  try {
1513
- const p = [], w = R.getWorkerType();
1527
+ const c = [], w = R.getWorkerType();
1514
1528
  for (let g = 0; g < s; g++) {
1515
1529
  const P = $e(w, {
1516
1530
  onExit: (v) => {
@@ -1522,10 +1536,10 @@ async function Ee(e) {
1522
1536
  }).then(
1523
1537
  async (v) => {
1524
1538
  n.push(v);
1525
- const S = await jt(u), I = await R.bootRequestHandler({
1539
+ const S = await qt(u), I = await R.bootRequestHandler({
1526
1540
  worker: v,
1527
1541
  fileLockManagerPort: S,
1528
- nativeInternalDirPath: ee
1542
+ nativeInternalDirPath: te
1529
1543
  });
1530
1544
  return i.set(
1531
1545
  v,
@@ -1533,16 +1547,16 @@ async function Ee(e) {
1533
1547
  ), [v, I];
1534
1548
  }
1535
1549
  );
1536
- p.push(P), g === 0 && await P;
1550
+ c.push(P), g === 0 && await P;
1537
1551
  }
1538
- await Promise.all(p), t = Re(
1552
+ await Promise.all(c), t = We(
1539
1553
  n.map(
1540
1554
  (g) => i.get(g)
1541
1555
  )
1542
1556
  );
1543
1557
  {
1544
- const g = new we(), P = g.port1, v = g.port2;
1545
- if (await Le(
1558
+ const g = new be(), P = g.port1, v = g.port2;
1559
+ if (await Be(
1546
1560
  {
1547
1561
  applyPostInstallMountsToAllWorkers: async () => {
1548
1562
  for (const S of i.values())
@@ -1556,7 +1570,7 @@ async function Ee(e) {
1556
1570
  ), await R.bootWordPress(
1557
1571
  t,
1558
1572
  v
1559
- ), P.close(), f = !0, !e["experimental-blueprints-v2-runner"]) {
1573
+ ), P.close(), p = !0, !e["experimental-blueprints-v2-runner"]) {
1560
1574
  const S = await R.compileInputBlueprint(
1561
1575
  e["additional-blueprint-steps"] || []
1562
1576
  );
@@ -1568,11 +1582,11 @@ async function Ee(e) {
1568
1582
  if (e.phpmyadmin && !await t.fileExists(
1569
1583
  `${ue}/index.php`
1570
1584
  )) {
1571
- const S = await dt(), I = await he({ steps: S });
1585
+ const S = await ct(), I = await we({ steps: S });
1572
1586
  await ie(I, t);
1573
1587
  }
1574
1588
  if (e.command === "build-snapshot") {
1575
- await qt(t, e.outfile), o.printStatus(`Exported to ${e.outfile}`), await W();
1589
+ await Gt(t, e.outfile), o.printStatus(`Exported to ${e.outfile}`), await W();
1576
1590
  return;
1577
1591
  } else if (e.command === "run-blueprint") {
1578
1592
  o.finishProgress("Done"), await W();
@@ -1606,56 +1620,56 @@ async function Ee(e) {
1606
1620
  if (o.finishProgress(), o.printReady(M, s), e.phpmyadmin) {
1607
1621
  const g = d.join(
1608
1622
  e.phpmyadmin,
1609
- pt
1623
+ mt
1610
1624
  );
1611
1625
  o.printPhpMyAdminUrl(
1612
1626
  new URL(g, M).toString()
1613
1627
  );
1614
1628
  }
1615
- return e.xdebug && e.experimentalDevtools && (await tt({
1629
+ return e.xdebug && e.experimentalDevtools && (await ot({
1616
1630
  phpInstance: t,
1617
1631
  phpRoot: "/wordpress"
1618
1632
  })).start(), {
1619
1633
  playground: t,
1620
- server: m,
1634
+ server: f,
1621
1635
  serverUrl: M,
1622
1636
  [Symbol.asyncDispose]: W,
1623
- [K]: {
1637
+ [ee]: {
1624
1638
  workerThreadCount: s
1625
1639
  }
1626
1640
  };
1627
- } catch (p) {
1641
+ } catch (c) {
1628
1642
  if (e.verbosity !== "debug")
1629
- throw p;
1643
+ throw c;
1630
1644
  let w = "";
1631
- throw await t?.fileExists(te) && (w = await t.readFileAsText(te)), await W(), new Error(w, { cause: p });
1645
+ throw await t?.fileExists(re) && (w = await t.readFileAsText(re)), await W(), new Error(w, { cause: c });
1632
1646
  }
1633
1647
  },
1634
- async handleRequest(m) {
1635
- if (!f)
1648
+ async handleRequest(f) {
1649
+ if (!p)
1636
1650
  return oe.forHttpCode(
1637
1651
  502,
1638
1652
  "WordPress is not ready yet"
1639
1653
  );
1640
- if (A) {
1641
- A = !1;
1654
+ if (C) {
1655
+ C = !1;
1642
1656
  const k = {
1643
1657
  "Content-Type": ["text/plain"],
1644
1658
  "Content-Length": ["0"],
1645
- Location: [m.url]
1659
+ Location: [f.url]
1646
1660
  };
1647
- return m.headers?.cookie?.includes(
1661
+ return f.headers?.cookie?.includes(
1648
1662
  "playground_auto_login_already_happened"
1649
1663
  ) && (k["Set-Cookie"] = [
1650
1664
  "playground_auto_login_already_happened=1; Max-Age=0; Expires=Thu, 01 Jan 1970 00:00:00 GMT; Path=/"
1651
1665
  ]), oe.fromPHPResponse(
1652
- new We(302, k, new Uint8Array())
1666
+ new Ue(302, k, new Uint8Array())
1653
1667
  );
1654
1668
  }
1655
- r && (m = {
1656
- ...m,
1669
+ r && (f = {
1670
+ ...f,
1657
1671
  headers: {
1658
- ...m.headers,
1672
+ ...f.headers,
1659
1673
  // While we have an internal cookie store, we
1660
1674
  // completely replace the incoming request's Cookie
1661
1675
  // header with the cookies from our store. This avoids
@@ -1664,26 +1678,26 @@ async function Ee(e) {
1664
1678
  cookie: r.getCookieRequestHeader()
1665
1679
  }
1666
1680
  });
1667
- const $ = await t.requestStreamed(m);
1681
+ const $ = await t.requestStreamed(f);
1668
1682
  if (r) {
1669
1683
  const k = await $.headers;
1670
1684
  r.rememberCookiesFromResponseHeaders(k), delete k["set-cookie"];
1671
1685
  }
1672
1686
  return $;
1673
1687
  }
1674
- }).catch((m) => {
1675
- o.printError(Se(m)), process.exit(1);
1688
+ }).catch((f) => {
1689
+ o.printError(Y(f)), process.exit(1);
1676
1690
  });
1677
- return E && e.command === "start" && !e.skipBrowser && Vt(E.serverUrl), E;
1691
+ return E && e.command === "start" && !e.skipBrowser && zt(E.serverUrl), E;
1678
1692
  }
1679
- function Ot(e, t) {
1693
+ function Vt(e, t) {
1680
1694
  let r = { ...e, command: "server" };
1681
1695
  const n = e.autoMount !== !1;
1682
- delete r.autoMount, delete r["auto-mount"], n && (r.autoMount = d.resolve(process.cwd(), r.path ?? ""), r = ge(r), delete r.autoMount);
1683
- const i = me(
1696
+ delete r.autoMount, delete r["auto-mount"], n && (r.autoMount = d.resolve(process.cwd(), r.path ?? ""), r = Pe(r), delete r.autoMount);
1697
+ const i = fe(
1684
1698
  r["mount-before-install"] || [],
1685
1699
  "/wordpress"
1686
- ) || me(r.mount || [], "/wordpress");
1700
+ ) || fe(r.mount || [], "/wordpress");
1687
1701
  if (i)
1688
1702
  t.print(
1689
1703
  `Site files stored at: ${i?.hostPath}`
@@ -1697,15 +1711,15 @@ function Ot(e, t) {
1697
1711
  "You may still remove the site's directory manually if you wish."
1698
1712
  ), process.exit(1));
1699
1713
  else {
1700
- const o = r.autoMount || process.cwd(), a = ut("sha256").update(o).digest("hex"), l = B.homedir(), u = d.join(
1714
+ const o = r.autoMount || process.cwd(), a = pt("sha256").update(o).digest("hex"), l = B.homedir(), u = d.join(
1701
1715
  l,
1702
1716
  ".wordpress-playground/sites",
1703
1717
  a
1704
1718
  );
1705
- t.print(`Site files stored at: ${u}`), Q(u) && e.reset && (t.print("Resetting site..."), He(u, { recursive: !0 })), z(u, { recursive: !0 }), r["mount-before-install"] = [
1719
+ t.print(`Site files stored at: ${u}`), X(u) && e.reset && (t.print("Resetting site..."), Oe(u, { recursive: !0, force: !0 })), z(u, { recursive: !0 }), r["mount-before-install"] = [
1706
1720
  ...r["mount-before-install"] || [],
1707
1721
  { vfsPath: "/wordpress", hostPath: u }
1708
- ], r.wordpressInstallMode = Fe(u).length === 0 ? (
1722
+ ], r.wordpressInstallMode = je(u).length === 0 ? (
1709
1723
  // Only download WordPress on the first run when the site directory is still
1710
1724
  // empty.
1711
1725
  "download-and-install"
@@ -1716,7 +1730,7 @@ function Ot(e, t) {
1716
1730
  }
1717
1731
  return r;
1718
1732
  }
1719
- const q = new Te();
1733
+ const q = new Ae();
1720
1734
  function $e(e, { onExit: t } = {}) {
1721
1735
  let r;
1722
1736
  return e === "v1" ? r = new se(new URL("./worker-thread-v1.js", import.meta.url)) : r = new se(new URL("./worker-thread-v2.js", import.meta.url)), new Promise((n, i) => {
@@ -1729,11 +1743,11 @@ function $e(e, { onExit: t } = {}) {
1729
1743
  });
1730
1744
  }), r.once("error", function(l) {
1731
1745
  q.release(o), console.error(l);
1732
- const u = l?.message || (l ? String(l) : "unknown error"), f = new Error(
1746
+ const u = l?.message || (l ? String(l) : "unknown error"), p = new Error(
1733
1747
  `Worker failed to load. Original error: ${u}`,
1734
1748
  { cause: l }
1735
1749
  );
1736
- i(f);
1750
+ i(p);
1737
1751
  });
1738
1752
  let a = !1;
1739
1753
  r.once("spawn", () => {
@@ -1743,11 +1757,11 @@ function $e(e, { onExit: t } = {}) {
1743
1757
  });
1744
1758
  });
1745
1759
  }
1746
- async function jt(e) {
1747
- const { port1: t, port2: r } = new we();
1748
- return await Be(e, t), r;
1760
+ async function qt(e) {
1761
+ const { port1: t, port2: r } = new be();
1762
+ return await _e(e, t), r;
1749
1763
  }
1750
- function Vt(e) {
1764
+ function zt(e) {
1751
1765
  const t = B.platform();
1752
1766
  let r;
1753
1767
  switch (t) {
@@ -1761,11 +1775,11 @@ function Vt(e) {
1761
1775
  r = `xdg-open "${e}"`;
1762
1776
  break;
1763
1777
  }
1764
- be(r, (n) => {
1778
+ ye(r, (n) => {
1765
1779
  n && h.debug(`Could not open browser: ${n.message}`);
1766
1780
  });
1767
1781
  }
1768
- async function qt(e, t) {
1782
+ async function Gt(e, t) {
1769
1783
  await e.run({
1770
1784
  code: `<?php
1771
1785
  $zip = new ZipArchive();
@@ -1787,28 +1801,28 @@ async function qt(e, t) {
1787
1801
  `
1788
1802
  });
1789
1803
  const r = await e.readFileAsBuffer("/tmp/build.zip");
1790
- c.writeFileSync(t, r);
1804
+ m.writeFileSync(t, r);
1791
1805
  }
1792
- const Pr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1806
+ const Sr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1793
1807
  __proto__: null,
1794
- LogVerbosity: J,
1795
- internalsKeyForTesting: K,
1796
- mergeDefinedConstants: Z,
1797
- parseOptionsAndRunCLI: Ft,
1808
+ LogVerbosity: K,
1809
+ internalsKeyForTesting: ee,
1810
+ mergeDefinedConstants: J,
1811
+ parseOptionsAndRunCLI: jt,
1798
1812
  resolveWorkerCount: xe,
1799
1813
  runCLI: Ee,
1800
1814
  spawnWorkerThread: $e
1801
1815
  }, Symbol.toStringTag, { value: "Module" }));
1802
1816
  export {
1803
- J as L,
1817
+ K as L,
1804
1818
  Ee as a,
1805
- gr as b,
1806
- Nt as c,
1807
- Pr as d,
1808
- K as i,
1809
- Z as m,
1810
- Ft as p,
1819
+ vr as b,
1820
+ Ft as c,
1821
+ Sr as d,
1822
+ ee as i,
1823
+ J as m,
1824
+ jt as p,
1811
1825
  xe as r,
1812
1826
  $e as s
1813
1827
  };
1814
- //# sourceMappingURL=run-cli-DxD1h5dy.js.map
1828
+ //# sourceMappingURL=run-cli-B5GdKs2V.js.map