@wp-playground/cli 2.0.11 → 2.0.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,42 +1,42 @@
1
- import { logger as p, errorLogPath as R } from "@php-wasm/logger";
2
- import { consumeAPI as L, SupportedPHPVersions as q, printDebugDetails as j, PHPResponse as U, exposeAPI as D, exposeSyncAPI as O } from "@php-wasm/universal";
1
+ import { logger as p, errorLogPath as B } from "@php-wasm/logger";
2
+ import { consumeAPI as L, SupportedPHPVersions as q, printDebugDetails as j, PHPResponse as R, exposeAPI as D, exposeSyncAPI as O } from "@php-wasm/universal";
3
3
  import { resolveRemoteBlueprint as Z, isBlueprintBundle as _, compileBlueprint as N, runBlueprintSteps as J } from "@wp-playground/blueprints";
4
4
  import { zipDirectory as E, RecommendedPHPVersion as A, unzipFile as Y } from "@wp-playground/common";
5
- import y from "fs";
5
+ import m from "fs";
6
6
  import { Worker as Q, MessageChannel as X } from "worker_threads";
7
- import { p as M, a as G, e as K } from "./mounts-ClzM-OKS.js";
7
+ import { p as U, a as G, e as K } from "./mounts-D25idKz8.js";
8
8
  import ee from "express";
9
9
  import { FileLockManagerForNode as te } from "@php-wasm/node";
10
10
  import re, { cpus as oe } from "os";
11
- import { jspi as se } from "wasm-feature-detect";
12
- import ie from "yargs";
13
- import m, { basename as ne } from "path";
11
+ import { jspi as ie } from "wasm-feature-detect";
12
+ import se from "yargs";
13
+ import w, { basename as ne } from "path";
14
14
  import { NodeJsFilesystem as ae, OverlayFilesystem as le, InMemoryFilesystem as pe, ZipFilesystem as de } from "@wp-playground/storage";
15
15
  import { EmscriptenDownloadMonitor as ce, ProgressTracker as ue } from "@php-wasm/progress";
16
16
  import { resolveWordPressRelease as he } from "@wp-playground/wordpress";
17
17
  import k from "fs-extra";
18
18
  import { startBridge as fe } from "@php-wasm/xdebug-bridge";
19
19
  async function me(t) {
20
- const r = ee(), e = await new Promise((i, n) => {
20
+ const r = ee(), e = await new Promise((s, n) => {
21
21
  const l = r.listen(t.port, () => {
22
22
  const a = l.address();
23
- a === null || typeof a == "string" ? n(new Error("Server address is not available")) : i(l);
23
+ a === null || typeof a == "string" ? n(new Error("Server address is not available")) : s(l);
24
24
  });
25
25
  });
26
- r.use("/", async (i, n) => {
26
+ r.use("/", async (s, n) => {
27
27
  const l = await t.handleRequest({
28
- url: i.url,
29
- headers: ge(i),
30
- method: i.method,
31
- body: await we(i)
28
+ url: s.url,
29
+ headers: ge(s),
30
+ method: s.method,
31
+ body: await we(s)
32
32
  });
33
33
  n.statusCode = l.httpStatusCode;
34
34
  for (const a in l.headers)
35
35
  n.setHeader(a, l.headers[a]);
36
36
  n.end(l.bytes);
37
37
  });
38
- const s = e.address().port;
39
- return await t.onBind(e, s);
38
+ const i = e.address().port;
39
+ return await t.onBind(e, i);
40
40
  }
41
41
  const we = async (t) => await new Promise((r) => {
42
42
  const e = [];
@@ -64,9 +64,9 @@ class ye {
64
64
  }
65
65
  async handleRequest(r) {
66
66
  let e = this.workerLoads[0];
67
- for (let s = 1; s < this.workerLoads.length; s++) {
68
- const i = this.workerLoads[s];
69
- i.activeRequests.size < e.activeRequests.size && (e = i);
67
+ for (let i = 1; i < this.workerLoads.length; i++) {
68
+ const s = this.workerLoads[i];
69
+ s.activeRequests.size < e.activeRequests.size && (e = s);
70
70
  }
71
71
  const o = e.worker.request(r);
72
72
  return e.activeRequests.add(o), o.url = r.url, o.finally(() => {
@@ -85,33 +85,33 @@ async function Pe({
85
85
  return;
86
86
  if (t.startsWith("http://") || t.startsWith("https://"))
87
87
  return await Z(t);
88
- let e = m.resolve(process.cwd(), t);
89
- if (!y.existsSync(e))
88
+ let e = w.resolve(process.cwd(), t);
89
+ if (!m.existsSync(e))
90
90
  throw new Error(`Blueprint file does not exist: ${e}`);
91
- const o = y.statSync(e);
92
- if (o.isDirectory() && (e = m.join(e, "blueprint.json")), !o.isFile() && o.isSymbolicLink())
91
+ const o = m.statSync(e);
92
+ if (o.isDirectory() && (e = w.join(e, "blueprint.json")), !o.isFile() && o.isSymbolicLink())
93
93
  throw new Error(
94
94
  `Blueprint path is neither a file nor a directory: ${e}`
95
95
  );
96
- const s = m.extname(e);
97
- switch (s) {
96
+ const i = w.extname(e);
97
+ switch (i) {
98
98
  case ".zip":
99
99
  return de.fromArrayBuffer(
100
- y.readFileSync(e).buffer
100
+ m.readFileSync(e).buffer
101
101
  );
102
102
  case ".json": {
103
- const i = y.readFileSync(e, "utf-8");
103
+ const s = m.readFileSync(e, "utf-8");
104
104
  try {
105
- JSON.parse(i);
105
+ JSON.parse(s);
106
106
  } catch {
107
107
  throw new Error(
108
108
  `Blueprint file at ${e} is not a valid JSON file`
109
109
  );
110
110
  }
111
- const n = m.dirname(e), l = new ae(n);
111
+ const n = w.dirname(e), l = new ae(n);
112
112
  return new le([
113
113
  new pe({
114
- "blueprint.json": i
114
+ "blueprint.json": s
115
115
  }),
116
116
  /**
117
117
  * Wrap the NodeJS filesystem to prevent access to local files
@@ -132,7 +132,7 @@ You can allow this Blueprint to read files from the same parent directory by exp
132
132
  }
133
133
  default:
134
134
  throw new Error(
135
- `Unsupported blueprint file extension: ${s}. Only .zip and .json files are supported.`
135
+ `Unsupported blueprint file extension: ${i}. Only .zip and .json files are supported.`
136
136
  );
137
137
  }
138
138
  }
@@ -142,7 +142,7 @@ class ke {
142
142
  this.lastProgressMessage = "", this.args = r, this.siteUrl = e.siteUrl, this.processIdSpaceLength = e.processIdSpaceLength, this.phpVersion = r.php;
143
143
  }
144
144
  getWorkerUrl() {
145
- return process.env.VITEST && I.startsWith("/src/") ? m.join(
145
+ return process.env.VITEST && I.startsWith("/src/") ? w.join(
146
146
  import.meta.dirname,
147
147
  "..",
148
148
  "..",
@@ -152,7 +152,7 @@ class ke {
152
152
  async bootPrimaryWorker(r, e) {
153
153
  const o = L(r);
154
154
  await o.useFileLockManager(e);
155
- const s = {
155
+ const i = {
156
156
  ...this.args,
157
157
  php: this.phpVersion,
158
158
  siteUrl: this.siteUrl,
@@ -161,16 +161,16 @@ class ke {
161
161
  trace: this.args.debug || !1,
162
162
  blueprint: this.args.blueprint
163
163
  };
164
- return await o.bootAsPrimaryWorker(s), o;
164
+ return await o.bootAsPrimaryWorker(i), o;
165
165
  }
166
166
  async bootSecondaryWorker({
167
167
  worker: r,
168
168
  fileLockManagerPort: e,
169
169
  firstProcessId: o
170
170
  }) {
171
- const s = L(r.phpPort);
172
- await s.useFileLockManager(e);
173
- const i = {
171
+ const i = L(r.phpPort);
172
+ await i.useFileLockManager(e);
173
+ const s = {
174
174
  ...this.args,
175
175
  php: this.phpVersion,
176
176
  siteUrl: this.siteUrl,
@@ -179,7 +179,7 @@ class ke {
179
179
  trace: this.args.debug || !1,
180
180
  blueprint: this.args.blueprint
181
181
  };
182
- return await s.bootAsSecondaryWorker(i), s;
182
+ return await i.bootAsSecondaryWorker(s), i;
183
183
  }
184
184
  writeProgressUpdate(r, e, o) {
185
185
  e !== this.lastProgressMessage && (this.lastProgressMessage = e, r.isTTY ? (r.cursorTo(0), r.write(e), r.clearLine(1), o && r.write(`
@@ -187,7 +187,7 @@ class ke {
187
187
  `));
188
188
  }
189
189
  }
190
- const B = m.join(re.homedir(), ".wordpress-playground");
190
+ const M = w.join(re.homedir(), ".wordpress-playground");
191
191
  async function ve(t) {
192
192
  return await C(
193
193
  "https://github.com/WordPress/sqlite-database-integration/archive/refs/heads/develop.zip",
@@ -196,21 +196,21 @@ async function ve(t) {
196
196
  );
197
197
  }
198
198
  async function C(t, r, e) {
199
- const o = m.join(B, r);
200
- return k.existsSync(o) || (k.ensureDirSync(B), await We(t, o, e)), T(o);
199
+ const o = w.join(M, r);
200
+ return k.existsSync(o) || (k.ensureDirSync(M), await We(t, o, e)), T(o);
201
201
  }
202
202
  async function We(t, r, e) {
203
- const s = (await e.monitorFetch(fetch(t))).body.getReader(), i = `${r}.partial`, n = k.createWriteStream(i);
203
+ const i = (await e.monitorFetch(fetch(t))).body.getReader(), s = `${r}.partial`, n = k.createWriteStream(s);
204
204
  for (; ; ) {
205
- const { done: l, value: a } = await s.read();
205
+ const { done: l, value: a } = await i.read();
206
206
  if (a && n.write(a), l)
207
207
  break;
208
208
  }
209
209
  n.close(), n.closed || await new Promise((l, a) => {
210
210
  n.on("finish", () => {
211
- k.renameSync(i, r), l(null);
211
+ k.renameSync(s, r), l(null);
212
212
  }), n.on("error", (c) => {
213
- k.removeSync(i), a(c);
213
+ k.removeSync(s), a(c);
214
214
  });
215
215
  });
216
216
  }
@@ -218,12 +218,12 @@ function T(t, r) {
218
218
  return new File([k.readFileSync(t)], ne(t));
219
219
  }
220
220
  const F = "" + new URL("worker-thread-v1-BTJIbQLy.js", import.meta.url).href;
221
- class xe {
221
+ class Se {
222
222
  constructor(r, e) {
223
223
  this.lastProgressMessage = "", this.args = r, this.siteUrl = e.siteUrl, this.processIdSpaceLength = e.processIdSpaceLength;
224
224
  }
225
225
  getWorkerUrl() {
226
- return process.env.VITEST && F.startsWith("/src/") ? m.join(
226
+ return process.env.VITEST && F.startsWith("/src/") ? w.join(
227
227
  import.meta.dirname,
228
228
  "..",
229
229
  "..",
@@ -235,40 +235,40 @@ class xe {
235
235
  this.args["additional-blueprint-steps"] || []
236
236
  );
237
237
  this.phpVersion = o.versions.php;
238
- let s;
239
- const i = new ce();
238
+ let i;
239
+ const s = new ce();
240
240
  if (!this.args.skipWordPressSetup) {
241
241
  let v = !1;
242
- i.addEventListener("progress", (h) => {
242
+ s.addEventListener("progress", (h) => {
243
243
  if (v)
244
244
  return;
245
- const { loaded: g, total: W } = h.detail, f = Math.floor(
246
- Math.min(100, 100 * g / W)
245
+ const { loaded: y, total: W } = h.detail, f = Math.floor(
246
+ Math.min(100, 100 * y / W)
247
247
  );
248
248
  v = f === 100, this.args.quiet || this.writeProgressUpdate(
249
249
  process.stdout,
250
250
  `Downloading WordPress ${f}%...`,
251
251
  v
252
252
  );
253
- }), s = await he(this.args.wp), p.log(
254
- `Resolved WordPress release URL: ${s?.releaseUrl}`
253
+ }), i = await he(this.args.wp), p.log(
254
+ `Resolved WordPress release URL: ${i?.releaseUrl}`
255
255
  );
256
256
  }
257
- const n = s && m.join(
258
- B,
259
- `prebuilt-wp-content-for-wp-${s.version}.zip`
260
- ), l = s ? y.existsSync(n) ? T(n) : await C(
261
- s.releaseUrl,
262
- `${s.version}.zip`,
263
- i
257
+ const n = i && w.join(
258
+ M,
259
+ `prebuilt-wp-content-for-wp-${i.version}.zip`
260
+ ), l = i ? m.existsSync(n) ? T(n) : await C(
261
+ i.releaseUrl,
262
+ `${i.version}.zip`,
263
+ s
264
264
  ) : void 0;
265
265
  p.log("Fetching SQLite integration plugin...");
266
- const a = this.args.skipSqliteSetup ? void 0 : await ve(i), c = this.args.followSymlinks === !0, d = this.args.experimentalTrace === !0, w = this.args["mount-before-install"] || [], P = this.args.mount || [], u = L(r);
266
+ const a = this.args.skipSqliteSetup ? void 0 : await ve(s), c = this.args.followSymlinks === !0, d = this.args.experimentalTrace === !0, g = this.args["mount-before-install"] || [], P = this.args.mount || [], u = L(r);
267
267
  return await u.isConnected(), p.log("Booting WordPress..."), await u.useFileLockManager(e), await u.bootAsPrimaryWorker({
268
268
  phpVersion: this.phpVersion,
269
269
  wpVersion: o.versions.wp,
270
270
  absoluteUrl: this.siteUrl,
271
- mountsBeforeWpInstall: w,
271
+ mountsBeforeWpInstall: g,
272
272
  mountsAfterWpInstall: P,
273
273
  wordPressZip: l && await l.arrayBuffer(),
274
274
  sqliteIntegrationPluginZip: await a?.arrayBuffer(),
@@ -278,7 +278,7 @@ class xe {
278
278
  trace: d,
279
279
  internalCookieStore: this.args.internalCookieStore,
280
280
  withXdebug: this.args.xdebug
281
- }), s && !this.args["mount-before-install"] && !y.existsSync(n) && (p.log("Caching preinstalled WordPress for the next boot..."), y.writeFileSync(
281
+ }), i && !this.args["mount-before-install"] && !m.existsSync(n) && (p.log("Caching preinstalled WordPress for the next boot..."), m.writeFileSync(
282
282
  n,
283
283
  await E(u, "/wordpress")
284
284
  ), p.log("Cached!")), u;
@@ -288,10 +288,10 @@ class xe {
288
288
  fileLockManagerPort: e,
289
289
  firstProcessId: o
290
290
  }) {
291
- const s = L(
291
+ const i = L(
292
292
  r.phpPort
293
293
  );
294
- return await s.isConnected(), await s.useFileLockManager(e), await s.bootAsSecondaryWorker({
294
+ return await i.isConnected(), await i.useFileLockManager(e), await i.bootAsSecondaryWorker({
295
295
  phpVersion: this.phpVersion,
296
296
  absoluteUrl: this.siteUrl,
297
297
  mountsBeforeWpInstall: this.args["mount-before-install"] || [],
@@ -311,10 +311,10 @@ class xe {
311
311
  // will have a separate cookie store.
312
312
  internalCookieStore: this.args.internalCookieStore,
313
313
  withXdebug: this.args.xdebug
314
- }), await s.isReady(), s;
314
+ }), await i.isReady(), i;
315
315
  }
316
316
  async compileInputBlueprint(r) {
317
- const e = this.args, o = e.blueprint, s = _(o) ? o : {
317
+ const e = this.args, o = e.blueprint, i = _(o) ? o : {
318
318
  login: e.login,
319
319
  ...o || {},
320
320
  preferredVersions: {
@@ -322,9 +322,9 @@ class xe {
322
322
  wp: e.wp ?? o?.preferredVersions?.wp ?? "latest",
323
323
  ...o?.preferredVersions || {}
324
324
  }
325
- }, i = new ue();
325
+ }, s = new ue();
326
326
  let n = "", l = !1;
327
- return i.addEventListener("progress", (a) => {
327
+ return s.addEventListener("progress", (a) => {
328
328
  if (l)
329
329
  return;
330
330
  l = a.detail.progress === 100;
@@ -336,8 +336,8 @@ class xe {
336
336
  d,
337
337
  l
338
338
  );
339
- }), await N(s, {
340
- progress: i,
339
+ }), await N(i, {
340
+ progress: s,
341
341
  additionalSteps: r
342
342
  });
343
343
  }
@@ -349,7 +349,7 @@ class xe {
349
349
  }
350
350
  async function _e() {
351
351
  try {
352
- const t = ie(process.argv.slice(2)).usage("Usage: wp-playground <command> [options]").positional("command", {
352
+ const t = se(process.argv.slice(2)).usage("Usage: wp-playground <command> [options]").positional("command", {
353
353
  describe: "Command to run",
354
354
  choices: ["server", "run-blueprint", "build-snapshot"],
355
355
  demandOption: !0
@@ -374,12 +374,12 @@ async function _e() {
374
374
  describe: "Mount a directory to the PHP runtime (can be used multiple times). Format: /host/path:/vfs/path",
375
375
  type: "array",
376
376
  string: !0,
377
- coerce: M
377
+ coerce: U
378
378
  }).option("mount-before-install", {
379
379
  describe: "Mount a directory to the PHP runtime before WordPress installation (can be used multiple times). Format: /host/path:/vfs/path",
380
380
  type: "array",
381
381
  string: !0,
382
- coerce: M
382
+ coerce: U
383
383
  }).option("mount-dir", {
384
384
  describe: 'Mount a directory to the PHP runtime (can be used multiple times). Format: "/host/path" "/vfs/path"',
385
385
  type: "array",
@@ -420,9 +420,8 @@ async function _e() {
420
420
  type: "boolean",
421
421
  default: !1
422
422
  }).option("auto-mount", {
423
- describe: "Automatically mount the current working directory. You can mount a WordPress directory, a plugin directory, a theme directory, a wp-content directory, or any directory containing PHP and HTML files.",
424
- type: "boolean",
425
- default: !1
423
+ describe: "Automatically mount the specified directory. If no path is provided, mount the current working directory. You can mount a WordPress directory, a plugin directory, a theme directory, a wp-content directory, or any directory containing PHP and HTML files.",
424
+ type: "string"
426
425
  }).option("follow-symlinks", {
427
426
  describe: `Allow Playground to follow symlinks by automatically mounting symlinked directories and files encountered in mounted directories.
428
427
  Warning: Following symlinks will expose files outside mounted directories to Playground and could be a security risk.`,
@@ -449,33 +448,45 @@ Warning: Following symlinks will expose files outside mounted directories to Pla
449
448
  }).option("experimental-multi-worker", {
450
449
  describe: "Enable experimental multi-worker support which requires JSPI and a /wordpress directory backed by a real filesystem. Pass a positive number to specify the number of workers to use. Otherwise, default to the number of CPUs minus 1.",
451
450
  type: "number",
452
- coerce: (s) => s ?? oe().length - 1
451
+ coerce: (i) => i ?? oe().length - 1
453
452
  }).option("experimental-blueprints-v2-runner", {
454
453
  describe: "Use the experimental Blueprint V2 runner.",
455
454
  type: "boolean",
456
455
  default: !1,
457
456
  // Remove the "hidden" flag once Blueprint V2 is fully supported
458
457
  hidden: !0
459
- }).showHelpOnFail(!1).strictOptions().check(async (s) => {
460
- if (s.wp !== void 0 && !be(s.wp))
458
+ }).showHelpOnFail(!1).strictOptions().check(async (i) => {
459
+ if (i.wp !== void 0 && !be(i.wp))
461
460
  try {
462
- new URL(s.wp);
461
+ new URL(i.wp);
463
462
  } catch {
464
463
  throw new Error(
465
464
  '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"'
466
465
  );
467
466
  }
468
- if (s["experimental-multi-worker"] !== void 0) {
469
- if (s["experimental-multi-worker"] <= 1)
467
+ if (i["auto-mount"]) {
468
+ let s = !1;
469
+ try {
470
+ s = m.statSync(i["auto-mount"]).isDirectory();
471
+ } catch {
472
+ s = !1;
473
+ }
474
+ if (!s)
475
+ throw new Error(
476
+ `The specified --auto-mount path is not a directory: '${i["auto-mount"]}'.`
477
+ );
478
+ }
479
+ if (i["experimental-multi-worker"] !== void 0) {
480
+ if (i["experimental-multi-worker"] <= 1)
470
481
  throw new Error(
471
- "The --experimentalMultiWorker flag must be a positive integer greater than 1."
482
+ "The --experimental-multi-worker flag must be a positive integer greater than 1."
472
483
  );
473
- const i = (n) => n.vfsPath === "/wordpress";
474
- if (!s.mount?.some(i) && !s["mount-before-install"]?.some(
475
- i
484
+ const s = (n) => n.vfsPath === "/wordpress";
485
+ if (!i.mount?.some(s) && !i["mount-before-install"]?.some(
486
+ s
476
487
  ))
477
488
  throw new Error(
478
- "Please mount a real filesystem directory as the /wordpress directory before using the --experimentalMultiWorker flag. For example: --mount-dir-before-install ./empty-dir /wordpress"
489
+ "Please mount a real filesystem directory as the /wordpress directory before using the --experimental-multi-worker flag. For example: --mount-dir-before-install ./empty-dir /wordpress"
479
490
  );
480
491
  }
481
492
  return !0;
@@ -492,7 +503,7 @@ Warning: Following symlinks will expose files outside mounted directories to Pla
492
503
  ...r["mount-dir-before-install"] || []
493
504
  ]
494
505
  };
495
- await Se(o);
506
+ await xe(o);
496
507
  } catch (t) {
497
508
  if (!(t instanceof Error))
498
509
  throw t;
@@ -511,27 +522,27 @@ Warning: Following symlinks will expose files outside mounted directories to Pla
511
522
  process.exit(1);
512
523
  }
513
524
  }
514
- async function Se(t) {
525
+ async function xe(t) {
515
526
  let r, e;
516
527
  const o = [];
517
- t.autoMount && (t = K(t)), t.quiet && (p.handlers = []);
518
- const s = await import("fs-ext").then((a) => a.flockSync).catch(() => {
528
+ t.autoMount !== void 0 && (t.autoMount === "" && (t = { ...t, autoMount: process.cwd() }), t = K(t)), t.quiet && (p.handlers = []);
529
+ const i = await import("fs-ext").then((a) => a.flockSync).catch(() => {
519
530
  p.warn(
520
531
  "The fs-ext package is not installed. Internal file locking will not be integrated with host OS file locking."
521
532
  );
522
- }), i = new te(s);
533
+ }), s = new te(i);
523
534
  let n = !1, l = !0;
524
535
  return p.log("Starting a PHP server..."), me({
525
536
  port: t.port,
526
537
  onBind: async (a, c) => {
527
- const d = `http://127.0.0.1:${c}`, w = t.experimentalMultiWorker ?? 1, P = Math.floor(
528
- Number.MAX_SAFE_INTEGER / w
538
+ const d = `http://127.0.0.1:${c}`, g = t.experimentalMultiWorker ?? 1, P = Math.floor(
539
+ Number.MAX_SAFE_INTEGER / g
529
540
  );
530
541
  let u;
531
542
  t["experimental-blueprints-v2-runner"] ? u = new ke(t, {
532
543
  siteUrl: d,
533
544
  processIdSpaceLength: P
534
- }) : (u = new xe(t, {
545
+ }) : (u = new Se(t, {
535
546
  siteUrl: d,
536
547
  processIdSpaceLength: P
537
548
  }), typeof t.blueprint == "string" && (t.blueprint = await Pe({
@@ -540,18 +551,18 @@ async function Se(t) {
540
551
  })));
541
552
  const v = Le(
542
553
  u.getWorkerUrl(),
543
- w,
544
- ({ exitCode: h, isMain: g, workerIndex: W }) => {
554
+ g,
555
+ ({ exitCode: h, isMain: y, workerIndex: W }) => {
545
556
  h !== 0 && (p.error(
546
557
  `Worker ${W} exited with code ${h}
547
558
  `
548
- ), g && t.exitOnPrimaryWorkerCrash && process.exit(1));
559
+ ), y && t.exitOnPrimaryWorkerCrash && process.exit(1));
549
560
  }
550
561
  );
551
562
  p.log(`Setting up WordPress ${t.wp}`);
552
563
  try {
553
- const [h, ...g] = await v, W = await $(
554
- i
564
+ const [h, ...y] = await v, W = await $(
565
+ s
555
566
  );
556
567
  if (e = await u.bootPrimaryWorker(
557
568
  h.phpPort,
@@ -572,25 +583,25 @@ async function Se(t) {
572
583
  "/internal"
573
584
  ), b = P;
574
585
  await Promise.all(
575
- g.map(async (S, H) => {
576
- const z = b + H * P, V = await $(i), x = await u.bootSecondaryWorker({
577
- worker: S,
586
+ y.map(async (x, H) => {
587
+ const z = b + H * P, V = await $(s), S = await u.bootSecondaryWorker({
588
+ worker: x,
578
589
  fileLockManagerPort: V,
579
590
  firstProcessId: z
580
591
  });
581
592
  o.push({
582
- playground: x,
583
- worker: S.worker
584
- }), await x.writeFile(
593
+ playground: S,
594
+ worker: x.worker
595
+ }), await S.writeFile(
585
596
  "/tmp/internal.zip",
586
597
  f
587
598
  ), await Y(
588
- x,
599
+ S,
589
600
  "/tmp/internal.zip",
590
601
  "/internal"
591
- ), await x.unlink(
602
+ ), await S.unlink(
592
603
  "/tmp/internal.zip"
593
- ), r.addWorker(x);
604
+ ), r.addWorker(S);
594
605
  })
595
606
  ), p.log("Ready!");
596
607
  }
@@ -602,24 +613,24 @@ async function Se(t) {
602
613
  [Symbol.asyncDispose]: async function() {
603
614
  await Promise.all(
604
615
  o.map(
605
- async ({ playground: b, worker: S }) => {
606
- await b.dispose(), await S.terminate();
616
+ async ({ playground: b, worker: x }) => {
617
+ await b.dispose(), await x.terminate();
607
618
  }
608
619
  )
609
620
  ), await new Promise((b) => a.close(b));
610
621
  },
611
- workerThreadCount: w
622
+ workerThreadCount: g
612
623
  };
613
624
  } catch (h) {
614
625
  if (!t.debug)
615
626
  throw h;
616
- let g = "";
617
- throw await e?.fileExists(R) && (g = await e.readFileAsText(R)), new Error(g, { cause: h });
627
+ let y = "";
628
+ throw await e?.fileExists(B) && (y = await e.readFileAsText(B)), new Error(y, { cause: h });
618
629
  }
619
630
  },
620
631
  async handleRequest(a) {
621
632
  if (!n)
622
- return U.forHttpCode(
633
+ return R.forHttpCode(
623
634
  502,
624
635
  "WordPress is not ready yet"
625
636
  );
@@ -634,43 +645,43 @@ async function Se(t) {
634
645
  "playground_auto_login_already_happened"
635
646
  ) && (c["Set-Cookie"] = [
636
647
  "playground_auto_login_already_happened=1; Max-Age=0; Expires=Thu, 01 Jan 1970 00:00:00 GMT; Path=/"
637
- ]), new U(302, c, new Uint8Array());
648
+ ]), new R(302, c, new Uint8Array());
638
649
  }
639
650
  return await r.handleRequest(a);
640
651
  }
641
652
  });
642
653
  }
643
654
  function Le(t, r, e) {
644
- const o = new URL(t, import.meta.url), s = [];
645
- for (let i = 0; i < r; i++) {
655
+ const o = new URL(t, import.meta.url), i = [];
656
+ for (let s = 0; s < r; s++) {
646
657
  const n = new Q(o), l = (a) => {
647
658
  e({
648
659
  exitCode: a,
649
- isMain: i === 0,
650
- workerIndex: i
660
+ isMain: s === 0,
661
+ workerIndex: s
651
662
  });
652
663
  };
653
- s.push(
664
+ i.push(
654
665
  new Promise(
655
666
  (a, c) => {
656
667
  n.once("message", function(d) {
657
668
  d.command === "worker-script-initialized" && a({ worker: n, phpPort: d.phpPort });
658
669
  }), n.once("error", function(d) {
659
670
  console.error(d);
660
- const w = new Error(
671
+ const g = new Error(
661
672
  `Worker failed to load at ${o}. ${d.message ? `Original error: ${d.message}` : ""}`
662
673
  );
663
- w.filename = o, c(w);
674
+ g.filename = o, c(g);
664
675
  }), n.once("exit", l);
665
676
  }
666
677
  )
667
678
  );
668
679
  }
669
- return Promise.all(s);
680
+ return Promise.all(i);
670
681
  }
671
682
  async function $(t) {
672
683
  const { port1: r, port2: e } = new X();
673
- return await se() ? D(t, null, r) : await O(t, r), e;
684
+ return await ie() ? D(t, null, r) : await O(t, r), e;
674
685
  }
675
686
  async function Ie(t, r) {
676
687
  await t.run({
@@ -694,10 +705,10 @@ async function Ie(t, r) {
694
705
  `
695
706
  });
696
707
  const e = await t.readFileAsBuffer("/tmp/build.zip");
697
- y.writeFileSync(r, e);
708
+ m.writeFileSync(r, e);
698
709
  }
699
710
  export {
700
711
  _e as p,
701
- Se as r
712
+ xe as r
702
713
  };
703
- //# sourceMappingURL=run-cli-FboNWUuJ.js.map
714
+ //# sourceMappingURL=run-cli-Bq7rmNGR.js.map