@wp-playground/cli 3.1.40 → 3.1.42

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,11 +1,11 @@
1
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";
2
+ import { consumeAPI as he, isLegacyPHPVersion as Q, AllPHPVersions as Te, isPHPNextVersion as Ce, ProcessIdAllocator as Ae, printDebugDetails as De, describeError as z, HttpCookieStore as Re, FileLockManagerInMemory as Le, StreamedPHPResponse as oe, SupportedPHPVersions as V, createObjectPoolProxy as We, exposeAPI as Be, PHPResponse as Ue, exposeSyncAPI as _e } from "@php-wasm/universal";
3
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";
4
+ import { RecommendedPHPVersion as C, zipDirectory as Fe } from "@wp-playground/common";
5
+ import m, { existsSync as X, rmSync as Oe, mkdirSync as G, readdirSync as Ve } from "fs";
6
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";
7
+ import { createNodeFsMountHandler as je } from "@php-wasm/node";
8
+ import u, { basename as _, join as Z } from "path";
9
9
  import { exec as ye } from "child_process";
10
10
  import { promisify as qe } from "util";
11
11
  import ge from "express";
@@ -20,11 +20,11 @@ import { createRequire as rt } from "module";
20
20
  import B from "os";
21
21
  import { startBridge as ot } from "@php-wasm/xdebug-bridge";
22
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";
23
+ import { CLIOutput as st, removeTempDirSymlink as at, createTempDirSymlink as ae, makeXdebugConfig as lt, DEFAULT_PATH_SKIPPINGS as le, clearXdebugIDEConfig as dt, addXdebugIDEConfig as ut } from "@php-wasm/cli-util";
24
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
- import { jspi as de } from "wasm-feature-detect";
27
- function V(e) {
25
+ import { PHPMYADMIN_INSTALL_PATH as de, getPhpMyAdminInstallSteps as ct, PHPMYADMIN_ENTRY_PATH as mt } from "@wp-playground/tools";
26
+ import { jspi as ue } from "wasm-feature-detect";
27
+ function j(e) {
28
28
  const t = [];
29
29
  for (const r of e) {
30
30
  const n = r.split(":");
@@ -49,7 +49,7 @@ function pe(e) {
49
49
  if (!X(n))
50
50
  throw new Error(`Host path does not exist: ${n}`);
51
51
  t.push({
52
- hostPath: d.resolve(process.cwd(), n),
52
+ hostPath: u.resolve(process.cwd(), n),
53
53
  vfsPath: i
54
54
  });
55
55
  }
@@ -59,7 +59,7 @@ async function vr(e, t) {
59
59
  for (const r of t)
60
60
  await e.mount(
61
61
  r.vfsPath,
62
- Ve(r.hostPath)
62
+ je(r.hostPath)
63
63
  );
64
64
  }
65
65
  const ce = {
@@ -210,12 +210,12 @@ function Pt(e) {
210
210
  }
211
211
  function vt(e = {}, t = {}, r = {}) {
212
212
  const n = {}, i = /* @__PURE__ */ new Set(), o = (a, l) => {
213
- for (const u in a) {
214
- if (i.has(u))
213
+ for (const d in a) {
214
+ if (i.has(d))
215
215
  throw new Error(
216
- `Constant "${u}" is defined multiple times across different --define-${l} flags`
216
+ `Constant "${d}" is defined multiple times across different --define-${l} flags`
217
217
  );
218
- i.add(u), n[u] = a[u];
218
+ i.add(d), n[d] = a[d];
219
219
  }
220
220
  };
221
221
  return o(e, "string"), o(t, "bool"), o(r, "number"), n;
@@ -227,8 +227,8 @@ function J(e) {
227
227
  e["define-number"]
228
228
  );
229
229
  }
230
- const St = qe(ye);
231
- function xt(e) {
230
+ const xt = qe(ye);
231
+ function St(e) {
232
232
  return new Promise((t) => {
233
233
  if (e === 0) return t(!1);
234
234
  const r = ge().listen(e);
@@ -240,28 +240,28 @@ function xt(e) {
240
240
  }
241
241
  async function Et(e) {
242
242
  const t = ge(), r = await new Promise((a, l) => {
243
- const u = t.listen(e.port, () => {
244
- const p = u.address();
245
- p === null || typeof p == "string" ? l(new Error("Server address is not available")) : a(u);
243
+ const d = t.listen(e.port, () => {
244
+ const p = d.address();
245
+ p === null || typeof p == "string" ? l(new Error("Server address is not available")) : a(d);
246
246
  }).once("error", l);
247
247
  });
248
248
  t.use("/", async (a, l) => {
249
249
  try {
250
- const u = {
250
+ const d = {
251
251
  url: a.url,
252
252
  headers: Mt(a),
253
253
  method: a.method,
254
- body: await kt(a)
255
- }, p = await e.handleRequest(u);
256
- await $t(p, l);
257
- } catch (u) {
258
- h.error(u), l.headersSent || (l.statusCode = 500, l.end("Internal Server Error"));
254
+ body: await $t(a)
255
+ }, p = await e.handleRequest(d);
256
+ await kt(p, l);
257
+ } catch (d) {
258
+ h.error(d), 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
262
  return o && It(i, o), await e.onBind(r, i);
263
263
  }
264
- async function $t(e, t) {
264
+ async function kt(e, t) {
265
265
  const [r, n] = await Promise.all([
266
266
  e.headers,
267
267
  e.httpStatusCode
@@ -278,7 +278,7 @@ async function $t(e, t) {
278
278
  throw o;
279
279
  }
280
280
  }
281
- const kt = async (e) => await new Promise((t) => {
281
+ const $t = async (e) => await new Promise((t) => {
282
282
  const r = [];
283
283
  e.on("data", (n) => {
284
284
  r.push(n);
@@ -291,7 +291,7 @@ async function It(e, t) {
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 St(r);
294
+ await xt(r);
295
295
  return;
296
296
  } catch {
297
297
  await new Promise((i) => setTimeout(i, 2e3));
@@ -304,10 +304,10 @@ const Mt = (e) => {
304
304
  t[e.rawHeaders[r].toLowerCase()] = e.rawHeaders[r + 1];
305
305
  return t;
306
306
  };
307
- function Ct(e) {
307
+ function Tt(e) {
308
308
  return /^latest$|^beta$|^trunk$|^nightly$|^(?:(\d+)\.(\d+)(?:\.(\d+))?)((?:-beta(?:\d+)?)|(?:-RC(?:\d+)?))?$/.test(e);
309
309
  }
310
- async function Tt({
310
+ async function Ct({
311
311
  sourceString: e,
312
312
  blueprintMayReadAdjacentFiles: t
313
313
  }) {
@@ -315,15 +315,15 @@ async function Tt({
315
315
  return;
316
316
  if (e.startsWith("http://") || e.startsWith("https://"))
317
317
  return await He(e);
318
- let r = d.resolve(process.cwd(), e);
318
+ let r = u.resolve(process.cwd(), e);
319
319
  if (!m.existsSync(r))
320
320
  throw new Error(`Blueprint file does not exist: ${r}`);
321
321
  const n = m.statSync(r);
322
- if (n.isDirectory() && (r = d.join(r, "blueprint.json")), !n.isFile() && n.isSymbolicLink())
322
+ if (n.isDirectory() && (r = u.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}`
325
325
  );
326
- const i = d.extname(r);
326
+ const i = u.extname(r);
327
327
  switch (i) {
328
328
  case ".zip":
329
329
  return Je.fromArrayBuffer(
@@ -338,7 +338,7 @@ async function Tt({
338
338
  `Blueprint file at ${r} is not a valid JSON file`
339
339
  );
340
340
  }
341
- const a = d.dirname(r), l = new Qe(a);
341
+ const a = u.dirname(r), l = new Qe(a);
342
342
  return new Xe([
343
343
  new Ze({
344
344
  "blueprint.json": o
@@ -348,14 +348,14 @@ async function Tt({
348
348
  * unless the user explicitly allowed it.
349
349
  */
350
350
  {
351
- read(u) {
351
+ read(d) {
352
352
  if (!t)
353
353
  throw new Error(
354
- `Error: Blueprint contained tried to read a local file at path "${u}" (via a resource of type "bundled"). Playground restricts access to local resources by default as a security measure.
354
+ `Error: Blueprint contained tried to read a local file at path "${d}" (via a resource of type "bundled"). Playground restricts access to local resources by default as a security measure.
355
355
 
356
356
  You can allow this Blueprint to read files from the same parent directory by explicitly adding the --blueprint-may-read-adjacent-files option to your command.`
357
357
  );
358
- return l.read(u);
358
+ return l.read(d);
359
359
  }
360
360
  }
361
361
  ]);
@@ -418,43 +418,43 @@ class At {
418
418
  return await i.bootWorker(o), i;
419
419
  }
420
420
  }
421
- const G = d.join(B.homedir(), ".wordpress-playground");
421
+ const Y = u.join(B.homedir(), ".wordpress-playground");
422
422
  async function Dt(e = "trunk") {
423
423
  const t = typeof __dirname < "u" ? __dirname : import.meta.dirname;
424
- let r = d.join(t, "sqlite-database-integration.zip");
424
+ let r = u.join(t, "sqlite-database-integration.zip");
425
425
  if (!A.existsSync(r)) {
426
- const n = rt(import.meta.url), i = d.dirname(
426
+ const n = rt(import.meta.url), i = u.dirname(
427
427
  n.resolve("@wp-playground/wordpress-builds/package.json")
428
428
  );
429
- r = d.join(
429
+ r = u.join(
430
430
  i,
431
431
  "src",
432
432
  "sqlite-database-integration",
433
433
  `sqlite-database-integration-${e}.zip`
434
434
  );
435
435
  }
436
- return new File([await A.readFile(r)], d.basename(r));
436
+ return new File([await A.readFile(r)], u.basename(r));
437
437
  }
438
438
  async function Rt(e, t, r) {
439
- const n = d.join(G, t);
440
- return A.existsSync(n) || (A.ensureDirSync(G), await Lt(e, n, r)), Se(n);
439
+ const n = u.join(Y, t);
440
+ return A.existsSync(n) || (A.ensureDirSync(Y), await Lt(e, n, r)), xe(n);
441
441
  }
442
442
  async function Lt(e, t, r) {
443
443
  const i = (await r.monitorFetch(fetch(e))).body.getReader(), o = `${t}.partial`, a = A.createWriteStream(o);
444
444
  for (; ; ) {
445
- const { done: l, value: u } = await i.read();
446
- if (u && a.write(u), l)
445
+ const { done: l, value: d } = await i.read();
446
+ if (d && a.write(d), l)
447
447
  break;
448
448
  }
449
- a.close(), a.closed || await new Promise((l, u) => {
449
+ a.close(), a.closed || await new Promise((l, d) => {
450
450
  a.on("finish", () => {
451
451
  A.renameSync(o, t), l(null);
452
452
  }), a.on("error", (p) => {
453
- A.removeSync(o), u(p);
453
+ A.removeSync(o), d(p);
454
454
  });
455
455
  });
456
456
  }
457
- function Se(e, t) {
457
+ function xe(e, t) {
458
458
  return new File([A.readFileSync(e)], _(e));
459
459
  }
460
460
  class Wt {
@@ -469,20 +469,20 @@ class Wt {
469
469
  const a = new Ke();
470
470
  if (this.args.wordpressInstallMode === "download-and-install") {
471
471
  let p = !1;
472
- a.addEventListener("progress", (C) => {
472
+ a.addEventListener("progress", (T) => {
473
473
  if (p)
474
474
  return;
475
- const { loaded: E, total: f } = C.detail, $ = Math.floor(
475
+ const { loaded: E, total: f } = T.detail, k = Math.floor(
476
476
  Math.min(100, 100 * E / f)
477
477
  );
478
- p = $ === 100, this.cliOutput.updateProgress(
478
+ p = k === 100, this.cliOutput.updateProgress(
479
479
  "Downloading WordPress",
480
- $
480
+ k
481
481
  );
482
- }), n = await tt(this.args.wp), o = d.join(
483
- G,
482
+ }), n = await tt(this.args.wp), o = u.join(
483
+ Y,
484
484
  `prebuilt-wp-content-for-wp-${n.version}.zip`
485
- ), i = m.existsSync(o) ? Se(o) : await Rt(
485
+ ), i = m.existsSync(o) ? xe(o) : await Rt(
486
486
  n.releaseUrl,
487
487
  `${n.version}.zip`,
488
488
  a
@@ -495,17 +495,17 @@ class Wt {
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 p = this.args.php || T, E = Q(p) ? "v3.0.0-rc.3-php52" : "trunk";
498
+ const p = this.args.php || C, E = Q(p) ? "v3.0.0-rc.3-php52" : "trunk";
499
499
  l = await Dt(E);
500
500
  }
501
501
  this.cliOutput.updateProgress("Booting WordPress");
502
- const u = await ne(
502
+ const d = await ne(
503
503
  this.getEffectiveBlueprint()
504
504
  );
505
505
  return await t.bootWordPress(
506
506
  {
507
- phpVersion: u.phpVersion,
508
- wpVersion: u.wpVersion,
507
+ phpVersion: d.phpVersion,
508
+ wpVersion: d.wpVersion,
509
509
  siteUrl: this.siteUrl,
510
510
  wordpressInstallMode: this.args.wordpressInstallMode || "download-and-install",
511
511
  wordPressZip: i && await i.arrayBuffer(),
@@ -568,7 +568,7 @@ class Wt {
568
568
  login: this.args.login,
569
569
  ...t || {},
570
570
  preferredVersions: {
571
- php: this.args.php ?? t?.preferredVersions?.php ?? T,
571
+ php: this.args.php ?? t?.preferredVersions?.php ?? C,
572
572
  wp: this.args.wp ?? t?.preferredVersions?.wp ?? "latest",
573
573
  ...t?.preferredVersions || {}
574
574
  }
@@ -576,7 +576,7 @@ class Wt {
576
576
  }
577
577
  }
578
578
  async function Bt(e, t = !0) {
579
- const n = `${d.basename(process.argv0)}${e}${process.pid}-`, i = await nt({
579
+ const n = `${u.basename(process.argv0)}${e}${process.pid}-`, i = await nt({
580
580
  prefix: n,
581
581
  /*
582
582
  * Allow recursive cleanup on process exit.
@@ -611,7 +611,7 @@ async function Ut(e, t, r) {
611
611
  }
612
612
  async function _t(e, t, r) {
613
613
  try {
614
- const n = m.readdirSync(r).map((o) => d.join(r, o)), i = [];
614
+ const n = m.readdirSync(r).map((o) => u.join(r, o)), i = [];
615
615
  for (const o of n)
616
616
  await Ht(
617
617
  e,
@@ -626,7 +626,7 @@ async function _t(e, t, r) {
626
626
  async function Ht(e, t, r) {
627
627
  if (!m.lstatSync(r).isDirectory())
628
628
  return !1;
629
- const i = d.basename(r);
629
+ const i = u.basename(r);
630
630
  if (!i.includes(e))
631
631
  return !1;
632
632
  const o = i.match(
@@ -792,10 +792,10 @@ 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
- }, me = Ce.filter(
796
- (e) => !Te(e)
795
+ }, me = Te.filter(
796
+ (e) => !Ce(e)
797
797
  );
798
- async function jt(e) {
798
+ async function Vt(e) {
799
799
  try {
800
800
  const t = {
801
801
  "site-url": {
@@ -805,7 +805,7 @@ async function jt(e) {
805
805
  php: {
806
806
  describe: "PHP version to use.",
807
807
  type: "string",
808
- default: T,
808
+ default: C,
809
809
  choices: me
810
810
  },
811
811
  wp: {
@@ -841,14 +841,14 @@ async function jt(e) {
841
841
  type: "array",
842
842
  string: !0,
843
843
  nargs: 1,
844
- coerce: V
844
+ coerce: j
845
845
  },
846
846
  "mount-before-install": {
847
847
  describe: "Mount a directory to the PHP runtime before WordPress installation (can be used multiple times). Format: /host/path:/vfs/path",
848
848
  type: "array",
849
849
  string: !0,
850
850
  nargs: 1,
851
- coerce: V
851
+ coerce: j
852
852
  },
853
853
  "mount-dir": {
854
854
  describe: 'Mount a directory to the PHP runtime (can be used multiple times). Format: "/host/path" "/vfs/path"',
@@ -1036,7 +1036,7 @@ Warning: Following symlinks will expose files outside mounted directories to Pla
1036
1036
  php: {
1037
1037
  describe: "PHP version to use.",
1038
1038
  type: "string",
1039
- default: T,
1039
+ default: C,
1040
1040
  choices: me
1041
1041
  },
1042
1042
  wp: {
@@ -1083,7 +1083,7 @@ Warning: Following symlinks will expose files outside mounted directories to Pla
1083
1083
  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.",
1084
1084
  type: "array",
1085
1085
  string: !0,
1086
- coerce: V
1086
+ coerce: j
1087
1087
  },
1088
1088
  reset: {
1089
1089
  describe: "Deletes the stored site directory and starts a new site from scratch.",
@@ -1159,7 +1159,7 @@ Examples:
1159
1159
  throw new Error(
1160
1160
  "The --phpmyadmin option requires SQLite setup. Remove --skip-sqlite-setup to use phpMyAdmin."
1161
1161
  );
1162
- if (s.wp !== void 0 && typeof s.wp == "string" && !Ct(s.wp))
1162
+ if (s.wp !== void 0 && typeof s.wp == "string" && !Tt(s.wp))
1163
1163
  try {
1164
1164
  new URL(s.wp);
1165
1165
  } catch {
@@ -1178,13 +1178,13 @@ Examples:
1178
1178
  }
1179
1179
  const y = s.autoMount;
1180
1180
  if (s._[0] !== "start" && typeof y == "string" && y) {
1181
- let x = !1;
1181
+ let S = !1;
1182
1182
  try {
1183
- x = m.statSync(y).isDirectory();
1183
+ S = m.statSync(y).isDirectory();
1184
1184
  } catch {
1185
- x = !1;
1185
+ S = !1;
1186
1186
  }
1187
- if (!x)
1187
+ if (!S)
1188
1188
  throw new Error(
1189
1189
  `The specified --auto-mount path is not a directory: '${y}'.`
1190
1190
  );
@@ -1208,13 +1208,13 @@ Examples:
1208
1208
  "build-snapshot",
1209
1209
  "php"
1210
1210
  ].includes(l) || (o.showHelp(), process.exit(1));
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;
1211
+ const d = a.define || {}, p = a["define-bool"] || {}, T = a["define-number"] || {}, E = (s) => s in d || s in p || s in T, f = a.php || C;
1212
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));
1213
- const k = {
1213
+ const $ = {
1214
1214
  ...a,
1215
- define: u,
1215
+ define: d,
1216
1216
  "define-bool": p,
1217
- "define-number": C,
1217
+ "define-number": T,
1218
1218
  command: l,
1219
1219
  mount: [
1220
1220
  ...a.mount || [],
@@ -1224,7 +1224,7 @@ Examples:
1224
1224
  ...a["mount-before-install"] || [],
1225
1225
  ...a["mount-dir-before-install"] || []
1226
1226
  ]
1227
- }, M = await Ee(k);
1227
+ }, M = await Ee($);
1228
1228
  M === void 0 && process.exit(0);
1229
1229
  const D = /* @__PURE__ */ (() => {
1230
1230
  let s;
@@ -1241,55 +1241,15 @@ Examples:
1241
1241
  } catch (t) {
1242
1242
  console.error(t);
1243
1243
  const r = process.argv.includes("--debug");
1244
- if (t instanceof Error)
1245
- if (r)
1246
- De(t);
1247
- else {
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(
1258
- "\x1B[1m" + n.join(" caused by: ") + "\x1B[0m"
1259
- );
1260
- }
1261
- else
1262
- console.error("\x1B[1m" + Y(t) + "\x1B[0m");
1263
- process.exit(1);
1244
+ t instanceof Error ? r ? De(t) : console.error("\x1B[1m" + z(t) + "\x1B[0m") : console.error("\x1B[1m" + z(t) + "\x1B[0m"), process.exit(1);
1264
1245
  }
1265
1246
  }
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
- }
1275
- if (e && typeof e == "object") {
1276
- const t = [], r = e;
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)
1278
- return t.join(" — ");
1279
- try {
1280
- return JSON.stringify(e);
1281
- } catch {
1282
- return String(e);
1283
- }
1284
- }
1285
- return String(e);
1286
- }
1287
1247
  function fe(e, t) {
1288
1248
  return e.find(
1289
1249
  (r) => r.vfsPath.replace(/\/$/, "") === t.replace(/\/$/, "")
1290
1250
  );
1291
1251
  }
1292
- function xe(e) {
1252
+ function Se(e) {
1293
1253
  const t = Math.max(1, B.cpus().length - 1);
1294
1254
  return e === void 0 ? Math.min(6, t) : e === "auto" ? t : e;
1295
1255
  }
@@ -1299,19 +1259,19 @@ async function Ee(e) {
1299
1259
  const r = e.internalCookieStore ? new Re() : void 0, n = [], i = /* @__PURE__ */ new Map(), o = new Ot({
1300
1260
  verbosity: e.verbosity || "normal"
1301
1261
  });
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) {
1262
+ if (e.command === "start" && (e = jt(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
1263
  const f = Object.values(K).find(
1304
- ($) => $.name === e.verbosity
1264
+ (k) => k.name === e.verbosity
1305
1265
  ).severity;
1306
1266
  h.setSeverityFilterLevel(f);
1307
1267
  }
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 = [
1268
+ e.intl || (e.intl = !0), e.redis === void 0 && (e.redis = await ue()), e.memcached === void 0 && (e.memcached = await ue()), Q(e.php || C) && (e.intl = !1, e.redis = !1, e.memcached = !1, e.xdebug = !1), e.phpmyadmin && (e.phpmyadmin === !0 && (e.phpmyadmin = "/phpmyadmin"), e.pathAliases = [
1309
1269
  {
1310
1270
  urlPrefix: e.phpmyadmin,
1311
- fsPath: ue
1271
+ fsPath: de
1312
1272
  }
1313
1273
  ]), e.command === "server" && (o.printBanner(), o.printConfig({
1314
- phpVersion: e.php || T,
1274
+ phpVersion: e.php || C,
1315
1275
  wpVersion: e.wp || "latest",
1316
1276
  port: e.port ?? 9400,
1317
1277
  xdebug: !!e.xdebug,
@@ -1324,16 +1284,16 @@ async function Ee(e) {
1324
1284
  ],
1325
1285
  blueprint: typeof e.blueprint == "string" ? e.blueprint : void 0
1326
1286
  }));
1327
- const l = e.command === "server" ? e.port ?? 9400 : 0, u = new Le();
1328
- let p = !1, C = !0;
1287
+ const l = e.command === "server" ? e.port ?? 9400 : 0, d = new Le();
1288
+ let p = !1, T = !0;
1329
1289
  const E = await Et({
1330
- port: e.port ? e.port : await xt(l) ? 0 : l,
1331
- onBind: async (f, $) => {
1332
- const k = "127.0.0.1", M = `http://${k}:${$}`, D = e["site-url"] || M;
1290
+ port: e.port ? e.port : await St(l) ? 0 : l,
1291
+ onBind: async (f, k) => {
1292
+ const $ = "127.0.0.1", M = `http://${$}:${k}`, D = e["site-url"] || M;
1333
1293
  e["experimental-multi-worker"] !== void 0 && h.warn(
1334
1294
  "--experimental-multi-worker is deprecated and its value is ignored. Use --workers=<n|auto> instead."
1335
1295
  );
1336
- const s = xe(e.workers);
1296
+ const s = Se(e.workers);
1337
1297
  if (s < 6) {
1338
1298
  const c = "Running fewer than 6 workers may increase the likelihood of deadlock due to workers blocking on file locks.";
1339
1299
  e.workers === void 0 ? h.warn(
@@ -1344,13 +1304,13 @@ async function Ee(e) {
1344
1304
  }
1345
1305
  const b = "-playground-cli-site-", y = await Bt(b);
1346
1306
  h.debug(`Native temp dir for VFS root: ${y.path}`);
1347
- const x = "WP Playground CLI - Listen for Xdebug", H = ".playground-xdebug-root", N = d.join(process.cwd(), H);
1307
+ const S = "WP Playground CLI - Listen for Xdebug", H = ".playground-xdebug-root", N = u.join(process.cwd(), H);
1348
1308
  if (await at(N), e.xdebug) {
1349
1309
  const c = {
1350
- hostPath: d.join(".", d.sep, H),
1310
+ hostPath: u.join(".", u.sep, H),
1351
1311
  vfsPath: "/"
1352
- }, w = e.php || T;
1353
- if (j.includes(w) && j.indexOf(w) <= j.indexOf("8.5"))
1312
+ }, w = e.php || C;
1313
+ if (V.includes(w) && V.indexOf(w) <= V.indexOf("8.5"))
1354
1314
  await ae(
1355
1315
  y.path,
1356
1316
  N,
@@ -1379,14 +1339,14 @@ async function Ee(e) {
1379
1339
  process.platform
1380
1340
  );
1381
1341
  try {
1382
- await ut(
1383
- x,
1342
+ await dt(
1343
+ S,
1384
1344
  process.cwd()
1385
1345
  );
1386
- const P = typeof e.xdebug == "object" ? e.xdebug : {}, v = await dt({
1387
- name: x,
1388
- host: k,
1389
- port: $,
1346
+ const P = typeof e.xdebug == "object" ? e.xdebug : {}, v = await ut({
1347
+ name: S,
1348
+ host: $,
1349
+ port: k,
1390
1350
  ides: e.experimentalUnsafeIdeIntegration,
1391
1351
  cwd: process.cwd(),
1392
1352
  mounts: [
@@ -1396,7 +1356,7 @@ async function Ee(e) {
1396
1356
  ],
1397
1357
  pathSkippings: [...le],
1398
1358
  ideKey: P.ideKey || "WPPLAYGROUNDCLI"
1399
- }), S = e.experimentalUnsafeIdeIntegration, I = S.includes("vscode"), U = S.includes("phpstorm"), L = Object.values(v);
1359
+ }), x = e.experimentalUnsafeIdeIntegration, I = x.includes("vscode"), U = x.includes("phpstorm"), L = Object.values(v);
1400
1360
  o.print(""), L.length > 0 ? (o.print(
1401
1361
  o.bold(
1402
1362
  "Xdebug configured successfully"
@@ -1433,7 +1393,7 @@ async function Ee(e) {
1433
1393
  " 2. Open the Run and Debug panel on the left sidebar"
1434
1394
  ), o.print(
1435
1395
  ` 3. Select "${o.italic(
1436
- x
1396
+ S
1437
1397
  )}" from the dropdown`
1438
1398
  ), o.print(' 4. Click "start debugging"'), o.print(
1439
1399
  " 5. Set a breakpoint. For example, in .playground-xdebug-root/wordpress/index.php"
@@ -1443,7 +1403,7 @@ async function Ee(e) {
1443
1403
  o.bold("PhpStorm instructions:")
1444
1404
  ), o.print(
1445
1405
  ` 1. Choose "${o.italic(
1446
- x
1406
+ S
1447
1407
  )}" debug configuration in the toolbar`
1448
1408
  ), o.print(
1449
1409
  " 2. Click the debug button (bug icon)"
@@ -1459,14 +1419,14 @@ async function Ee(e) {
1459
1419
  }
1460
1420
  }
1461
1421
  }
1462
- const ke = d.dirname(y.path), Ie = 2 * 24 * 60 * 60 * 1e3;
1422
+ const $e = u.dirname(y.path), Ie = 2 * 24 * 60 * 60 * 1e3;
1463
1423
  Ut(
1464
1424
  b,
1465
1425
  Ie,
1466
- ke
1426
+ $e
1467
1427
  );
1468
- const te = d.join(y.path, "internal");
1469
- z(te);
1428
+ const te = u.join(y.path, "internal");
1429
+ G(te);
1470
1430
  const Me = [
1471
1431
  "wordpress",
1472
1432
  "tools",
@@ -1482,11 +1442,11 @@ async function Ee(e) {
1482
1442
  for (const c of Me) {
1483
1443
  const w = (P) => P.vfsPath === `/${c}`;
1484
1444
  if (!(e["mount-before-install"]?.some(w) || e.mount?.some(w))) {
1485
- const P = d.join(
1445
+ const P = u.join(
1486
1446
  y.path,
1487
1447
  c
1488
1448
  );
1489
- z(P), e["mount-before-install"] === void 0 && (e["mount-before-install"] = []), e["mount-before-install"].unshift({
1449
+ G(P), e["mount-before-install"] === void 0 && (e["mount-before-install"] = []), e["mount-before-install"].unshift({
1490
1450
  vfsPath: `/${c}`,
1491
1451
  hostPath: P
1492
1452
  });
@@ -1509,7 +1469,7 @@ async function Ee(e) {
1509
1469
  }) : (R = new Wt(e, {
1510
1470
  siteUrl: D,
1511
1471
  cliOutput: o
1512
- }), typeof e.blueprint == "string" && (e.blueprint = await Tt({
1472
+ }), typeof e.blueprint == "string" && (e.blueprint = await Ct({
1513
1473
  sourceString: e.blueprint,
1514
1474
  blueprintMayReadAdjacentFiles: e["blueprint-may-read-adjacent-files"] === !0
1515
1475
  })));
@@ -1526,7 +1486,7 @@ async function Ee(e) {
1526
1486
  try {
1527
1487
  const c = [], w = R.getWorkerType();
1528
1488
  for (let g = 0; g < s; g++) {
1529
- const P = $e(w, {
1489
+ const P = ke(w, {
1530
1490
  onExit: (v) => {
1531
1491
  F || v !== 0 && h.error(
1532
1492
  `Worker ${g} exited with code ${v}
@@ -1536,9 +1496,9 @@ async function Ee(e) {
1536
1496
  }).then(
1537
1497
  async (v) => {
1538
1498
  n.push(v);
1539
- const S = await qt(u), I = await R.bootRequestHandler({
1499
+ const x = await qt(d), I = await R.bootRequestHandler({
1540
1500
  worker: v,
1541
- fileLockManagerPort: S,
1501
+ fileLockManagerPort: x,
1542
1502
  nativeInternalDirPath: te
1543
1503
  });
1544
1504
  return i.set(
@@ -1559,8 +1519,8 @@ async function Ee(e) {
1559
1519
  if (await Be(
1560
1520
  {
1561
1521
  applyPostInstallMountsToAllWorkers: async () => {
1562
- for (const S of i.values())
1563
- await S.mountAfterWordPressInstall(
1522
+ for (const x of i.values())
1523
+ await x.mountAfterWordPressInstall(
1564
1524
  e.mount || []
1565
1525
  );
1566
1526
  }
@@ -1571,18 +1531,18 @@ async function Ee(e) {
1571
1531
  t,
1572
1532
  v
1573
1533
  ), P.close(), p = !0, !e["experimental-blueprints-v2-runner"]) {
1574
- const S = await R.compileInputBlueprint(
1534
+ const x = await R.compileInputBlueprint(
1575
1535
  e["additional-blueprint-steps"] || []
1576
1536
  );
1577
- S && await ie(
1578
- S,
1537
+ x && await ie(
1538
+ x,
1579
1539
  t
1580
1540
  );
1581
1541
  }
1582
1542
  if (e.phpmyadmin && !await t.fileExists(
1583
- `${ue}/index.php`
1543
+ `${de}/index.php`
1584
1544
  )) {
1585
- const S = await ct(), I = await we({ steps: S });
1545
+ const x = await ct(), I = await we({ steps: x });
1586
1546
  await ie(I, t);
1587
1547
  }
1588
1548
  if (e.command === "build-snapshot") {
@@ -1592,12 +1552,12 @@ async function Ee(e) {
1592
1552
  o.finishProgress("Done"), await W();
1593
1553
  return;
1594
1554
  } else if (e.command === "php") {
1595
- const S = [
1555
+ const x = [
1596
1556
  // @TODO: Import this from somewhere?
1597
1557
  // Hardcoding it feels fragile.
1598
1558
  "/internal/shared/bin/php",
1599
1559
  ...(e._ || []).slice(1)
1600
- ], I = await t.cli(S), [U] = await Promise.all([
1560
+ ], I = await t.cli(x), [U] = await Promise.all([
1601
1561
  I.exitCode,
1602
1562
  I.stdout.pipeTo(
1603
1563
  new WritableStream({
@@ -1618,7 +1578,7 @@ async function Ee(e) {
1618
1578
  }
1619
1579
  }
1620
1580
  if (o.finishProgress(), o.printReady(M, s), e.phpmyadmin) {
1621
- const g = d.join(
1581
+ const g = u.join(
1622
1582
  e.phpmyadmin,
1623
1583
  mt
1624
1584
  );
@@ -1652,19 +1612,19 @@ async function Ee(e) {
1652
1612
  502,
1653
1613
  "WordPress is not ready yet"
1654
1614
  );
1655
- if (C) {
1656
- C = !1;
1657
- const k = {
1615
+ if (T) {
1616
+ T = !1;
1617
+ const $ = {
1658
1618
  "Content-Type": ["text/plain"],
1659
1619
  "Content-Length": ["0"],
1660
1620
  Location: [f.url]
1661
1621
  };
1662
1622
  return f.headers?.cookie?.includes(
1663
1623
  "playground_auto_login_already_happened"
1664
- ) && (k["Set-Cookie"] = [
1624
+ ) && ($["Set-Cookie"] = [
1665
1625
  "playground_auto_login_already_happened=1; Max-Age=0; Expires=Thu, 01 Jan 1970 00:00:00 GMT; Path=/"
1666
1626
  ]), oe.fromPHPResponse(
1667
- new Ue(302, k, new Uint8Array())
1627
+ new Ue(302, $, new Uint8Array())
1668
1628
  );
1669
1629
  }
1670
1630
  r && (f = {
@@ -1679,22 +1639,22 @@ async function Ee(e) {
1679
1639
  cookie: r.getCookieRequestHeader()
1680
1640
  }
1681
1641
  });
1682
- const $ = await t.requestStreamed(f);
1642
+ const k = await t.requestStreamed(f);
1683
1643
  if (r) {
1684
- const k = await $.headers;
1685
- r.rememberCookiesFromResponseHeaders(k), delete k["set-cookie"];
1644
+ const $ = await k.headers;
1645
+ r.rememberCookiesFromResponseHeaders($), delete $["set-cookie"];
1686
1646
  }
1687
- return $;
1647
+ return k;
1688
1648
  }
1689
1649
  }).catch((f) => {
1690
- o.printError(Y(f)), process.exit(1);
1650
+ o.printError(z(f)), process.exit(1);
1691
1651
  });
1692
1652
  return E && e.command === "start" && !e.skipBrowser && zt(E.serverUrl), E;
1693
1653
  }
1694
- function Vt(e, t) {
1654
+ function jt(e, t) {
1695
1655
  let r = { ...e, command: "server" };
1696
1656
  const n = e.autoMount !== !1;
1697
- delete r.autoMount, delete r["auto-mount"], n && (r.autoMount = d.resolve(process.cwd(), r.path ?? ""), r = Pe(r), delete r.autoMount);
1657
+ delete r.autoMount, delete r["auto-mount"], n && (r.autoMount = u.resolve(process.cwd(), r.path ?? ""), r = Pe(r), delete r.autoMount);
1698
1658
  const i = fe(
1699
1659
  r["mount-before-install"] || [],
1700
1660
  "/wordpress"
@@ -1712,15 +1672,15 @@ function Vt(e, t) {
1712
1672
  "You may still remove the site's directory manually if you wish."
1713
1673
  ), process.exit(1));
1714
1674
  else {
1715
- const o = r.autoMount || process.cwd(), a = pt("sha256").update(o).digest("hex"), l = B.homedir(), u = d.join(
1675
+ const o = r.autoMount || process.cwd(), a = pt("sha256").update(o).digest("hex"), l = B.homedir(), d = u.join(
1716
1676
  l,
1717
1677
  ".wordpress-playground/sites",
1718
1678
  a
1719
1679
  );
1720
- 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"] = [
1680
+ t.print(`Site files stored at: ${d}`), X(d) && e.reset && (t.print("Resetting site..."), Oe(d, { recursive: !0, force: !0 })), G(d, { recursive: !0 }), r["mount-before-install"] = [
1721
1681
  ...r["mount-before-install"] || [],
1722
- { vfsPath: "/wordpress", hostPath: u }
1723
- ], r.wordpressInstallMode = je(u).length === 0 ? (
1682
+ { vfsPath: "/wordpress", hostPath: d }
1683
+ ], r.wordpressInstallMode = Ve(d).length === 0 ? (
1724
1684
  // Only download WordPress on the first run when the site directory is still
1725
1685
  // empty.
1726
1686
  "download-and-install"
@@ -1732,7 +1692,7 @@ function Vt(e, t) {
1732
1692
  return r;
1733
1693
  }
1734
1694
  const q = new Ae();
1735
- function $e(e, { onExit: t } = {}) {
1695
+ function ke(e, { onExit: t } = {}) {
1736
1696
  let r;
1737
1697
  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) => {
1738
1698
  const o = q.claim();
@@ -1744,8 +1704,8 @@ function $e(e, { onExit: t } = {}) {
1744
1704
  });
1745
1705
  }), r.once("error", function(l) {
1746
1706
  q.release(o), console.error(l);
1747
- const u = l?.message || (l ? String(l) : "unknown error"), p = new Error(
1748
- `Worker failed to load. Original error: ${u}`,
1707
+ const d = l?.message || (l ? String(l) : "unknown error"), p = new Error(
1708
+ `Worker failed to load. Original error: ${d}`,
1749
1709
  { cause: l }
1750
1710
  );
1751
1711
  i(p);
@@ -1804,26 +1764,26 @@ async function Gt(e, t) {
1804
1764
  const r = await e.readFileAsBuffer("/tmp/build.zip");
1805
1765
  m.writeFileSync(t, r);
1806
1766
  }
1807
- const Sr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1767
+ const xr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1808
1768
  __proto__: null,
1809
1769
  LogVerbosity: K,
1810
1770
  internalsKeyForTesting: ee,
1811
1771
  mergeDefinedConstants: J,
1812
- parseOptionsAndRunCLI: jt,
1813
- resolveWorkerCount: xe,
1772
+ parseOptionsAndRunCLI: Vt,
1773
+ resolveWorkerCount: Se,
1814
1774
  runCLI: Ee,
1815
- spawnWorkerThread: $e
1775
+ spawnWorkerThread: ke
1816
1776
  }, Symbol.toStringTag, { value: "Module" }));
1817
1777
  export {
1818
1778
  K as L,
1819
1779
  Ee as a,
1820
1780
  vr as b,
1821
1781
  Ft as c,
1822
- Sr as d,
1782
+ xr as d,
1823
1783
  ee as i,
1824
1784
  J as m,
1825
- jt as p,
1826
- xe as r,
1827
- $e as s
1785
+ Vt as p,
1786
+ Se as r,
1787
+ ke as s
1828
1788
  };
1829
- //# sourceMappingURL=run-cli-B6snvP5v.js.map
1789
+ //# sourceMappingURL=run-cli-Ds7GcDUw.js.map