@wp-playground/cli 3.1.2 → 3.1.3

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,88 +1,69 @@
1
- import { logger as g, LogSeverity as L, errorLogPath as G } from "@php-wasm/logger";
2
- import { consumeAPI as ne, SupportedPHPVersions as Q, printDebugDetails as be, HttpCookieStore as ge, FileLockManagerInMemory as Pe, StreamedPHPResponse as X, createObjectPoolProxy as ve, exposeAPI as Se, PHPResponse as xe, exposeSyncAPI as Ie } from "@php-wasm/universal";
3
- import { resolveRemoteBlueprint as $e, resolveRuntimeConfiguration as Z, compileBlueprintV1 as ae, isBlueprintBundle as Te, runBlueprintV1Steps as J } from "@wp-playground/blueprints";
4
- import { zipDirectory as Ee, RecommendedPHPVersion as C } from "@wp-playground/common";
5
- import c, { existsSync as O, rmdirSync as ke, mkdirSync as _, readdirSync as Me } from "fs";
6
- import { MessageChannel as le, Worker as K } from "worker_threads";
7
- import { createNodeFsMountHandler as Be } from "@php-wasm/node";
8
- import u, { basename as A, join as de } from "path";
9
- import Ae from "express";
10
- import { Readable as Ce } from "stream";
11
- import { pipeline as De } from "stream/promises";
12
- import j, { cpus as Re } from "os";
13
- import We from "yargs";
14
- import { NodeJsFilesystem as Le, OverlayFilesystem as Ue, InMemoryFilesystem as Fe, ZipFilesystem as He } from "@wp-playground/storage";
15
- import { EmscriptenDownloadMonitor as _e, ProgressTracker as Ne } from "@php-wasm/progress";
16
- import { resolveWordPressRelease as Oe } from "@wp-playground/wordpress";
17
- import I from "fs-extra";
18
- import { createRequire as je } from "module";
19
- import { startBridge as Ve } from "@php-wasm/xdebug-bridge";
20
- import { exec as Ye } from "child_process";
21
- import { dir as qe, setGracefulCleanup as ze } from "tmp-promise";
22
- import Ge from "ps-man";
23
- import { removeTempDirSymlink as Qe, createTempDirSymlink as Xe, clearXdebugIDEConfig as Ze, addXdebugIDEConfig as Je } from "@php-wasm/cli-util";
24
- import { createHash as Ke } from "crypto";
25
- import { PHPMYADMIN_INSTALL_PATH as ee, getPhpMyAdminInstallSteps as et, PHPMYADMIN_ENTRY_PATH as tt } from "@wp-playground/tools";
26
- import { jspi as te } from "wasm-feature-detect";
27
- const rt = 2 ** 31 - 1;
28
- class ot {
29
- constructor(t = 1, r = rt) {
30
- this.claimed = /* @__PURE__ */ new Set(), this.initialId = t, this.maxId = r, this.nextId = t;
31
- }
32
- claim() {
33
- const t = this.maxId - this.initialId + 1;
34
- for (let r = 0; r < t; r++)
35
- if (this.claimed.has(this.nextId))
36
- this.nextId++, this.nextId > this.maxId && (this.nextId = this.initialId);
37
- else
38
- return this.claimed.add(this.nextId), this.nextId;
39
- throw new Error(
40
- `Unable to find free process ID after ${t} tries.`
41
- );
42
- }
43
- release(t) {
44
- return this.claimed.has(t) ? (this.claimed.delete(t), !0) : !1;
45
- }
46
- }
47
- function U(e) {
1
+ import { logger as P, LogSeverity as F, errorLogPath as Z } from "@php-wasm/logger";
2
+ import { consumeAPI as ue, ProcessIdAllocator as xe, SupportedPHPVersions as R, printDebugDetails as $e, HttpCookieStore as Ee, FileLockManagerInMemory as Te, StreamedPHPResponse as J, createObjectPoolProxy as Ie, exposeAPI as ke, PHPResponse as Me, exposeSyncAPI as Be } from "@php-wasm/universal";
3
+ import { resolveRemoteBlueprint as Ae, resolveRuntimeConfiguration as K, compileBlueprintV1 as de, isBlueprintBundle as Ce, runBlueprintV1Steps as ee } from "@wp-playground/blueprints";
4
+ import { zipDirectory as De, RecommendedPHPVersion as M } from "@wp-playground/common";
5
+ import c, { existsSync as Y, rmdirSync as Re, mkdirSync as j, readdirSync as We } from "fs";
6
+ import { MessageChannel as pe, Worker as te } from "worker_threads";
7
+ import { createNodeFsMountHandler as Le } from "@php-wasm/node";
8
+ import d, { basename as D, join as ce } from "path";
9
+ import { exec as me } from "child_process";
10
+ import { promisify as Ue } from "util";
11
+ import fe from "express";
12
+ import { Readable as He } from "stream";
13
+ import { pipeline as Fe } from "stream/promises";
14
+ import Ne from "yargs";
15
+ import { NodeJsFilesystem as Oe, OverlayFilesystem as _e, InMemoryFilesystem as je, ZipFilesystem as Ve } from "@wp-playground/storage";
16
+ import { EmscriptenDownloadMonitor as Ye, ProgressTracker as qe } from "@php-wasm/progress";
17
+ import { resolveWordPressRelease as ze } from "@wp-playground/wordpress";
18
+ import $ from "fs-extra";
19
+ import { createRequire as Ge } from "module";
20
+ import q from "os";
21
+ import { startBridge as Qe } from "@php-wasm/xdebug-bridge";
22
+ import { dir as Xe, setGracefulCleanup as Ze } from "tmp-promise";
23
+ import Je from "ps-man";
24
+ import { removeTempDirSymlink as Ke, createTempDirSymlink as oe, makeXdebugConfig as et, clearXdebugIDEConfig as tt, addXdebugIDEConfig as ot } from "@php-wasm/cli-util";
25
+ import { createHash as rt } from "crypto";
26
+ import { PHPMYADMIN_INSTALL_PATH as re, getPhpMyAdminInstallSteps as st, PHPMYADMIN_ENTRY_PATH as it } from "@wp-playground/tools";
27
+ import { jspi as se } from "wasm-feature-detect";
28
+ function N(e) {
48
29
  const t = [];
49
- for (const r of e) {
50
- const o = r.split(":");
51
- if (o.length !== 2)
52
- throw new Error(`Invalid mount format: ${r}.
30
+ for (const o of e) {
31
+ const r = o.split(":");
32
+ if (r.length !== 2)
33
+ throw new Error(`Invalid mount format: ${o}.
53
34
  Expected format: /host/path:/vfs/path.
54
35
  If your path contains a colon, e.g. C:\\myplugin, use the --mount-dir option instead.
55
36
  Example: --mount-dir C:\\my-plugin /wordpress/wp-content/plugins/my-plugin`);
56
- const [i, s] = o;
57
- if (!O(i))
58
- throw new Error(`Host path does not exist: ${i}`);
59
- t.push({ hostPath: i, vfsPath: s });
37
+ const [s, i] = r;
38
+ if (!Y(s))
39
+ throw new Error(`Host path does not exist: ${s}`);
40
+ t.push({ hostPath: s, vfsPath: i });
60
41
  }
61
42
  return t;
62
43
  }
63
- function re(e) {
44
+ function ie(e) {
64
45
  if (e.length % 2 !== 0)
65
46
  throw new Error("Invalid mount format. Expected: /host/path /vfs/path");
66
47
  const t = [];
67
- for (let r = 0; r < e.length; r += 2) {
68
- const o = e[r], i = e[r + 1];
69
- if (!O(o))
70
- throw new Error(`Host path does not exist: ${o}`);
48
+ for (let o = 0; o < e.length; o += 2) {
49
+ const r = e[o], s = e[o + 1];
50
+ if (!Y(r))
51
+ throw new Error(`Host path does not exist: ${r}`);
71
52
  t.push({
72
- hostPath: u.resolve(process.cwd(), o),
73
- vfsPath: i
53
+ hostPath: d.resolve(process.cwd(), r),
54
+ vfsPath: s
74
55
  });
75
56
  }
76
57
  return t;
77
58
  }
78
- async function cr(e, t) {
79
- for (const r of t)
59
+ async function yo(e, t) {
60
+ for (const o of t)
80
61
  await e.mount(
81
- r.vfsPath,
82
- Be(r.hostPath)
62
+ o.vfsPath,
63
+ Le(o.hostPath)
83
64
  );
84
65
  }
85
- const oe = {
66
+ const ne = {
86
67
  step: "runPHP",
87
68
  code: {
88
69
  filename: "activate-theme.php",
@@ -101,284 +82,307 @@ const oe = {
101
82
  `
102
83
  }
103
84
  };
104
- function ue(e) {
105
- const t = e.autoMount, r = [...e.mount || []], o = [...e["mount-before-install"] || []], i = {
85
+ function he(e) {
86
+ const t = e.autoMount, o = [...e.mount || []], r = [...e["mount-before-install"] || []], s = {
106
87
  ...e,
107
- mount: r,
108
- "mount-before-install": o,
88
+ mount: o,
89
+ "mount-before-install": r,
109
90
  "additional-blueprint-steps": [
110
91
  ...e["additional-blueprint-steps"] || []
111
92
  ]
112
93
  };
113
- if (at(t)) {
114
- const n = `/wordpress/wp-content/plugins/${A(t)}`;
115
- r.push({
94
+ if (ut(t)) {
95
+ const n = `/wordpress/wp-content/plugins/${D(t)}`;
96
+ o.push({
116
97
  hostPath: t,
117
98
  vfsPath: n,
118
99
  autoMounted: !0
119
- }), i["additional-blueprint-steps"].push({
100
+ }), s["additional-blueprint-steps"].push({
120
101
  step: "activatePlugin",
121
- pluginPath: `/wordpress/wp-content/plugins/${A(t)}`
102
+ pluginPath: `/wordpress/wp-content/plugins/${D(t)}`
122
103
  });
123
- } else if (nt(t)) {
124
- const s = A(t), n = `/wordpress/wp-content/themes/${s}`;
125
- r.push({
104
+ } else if (lt(t)) {
105
+ const i = D(t), n = `/wordpress/wp-content/themes/${i}`;
106
+ o.push({
126
107
  hostPath: t,
127
108
  vfsPath: n,
128
109
  autoMounted: !0
129
- }), i["additional-blueprint-steps"].push(
110
+ }), s["additional-blueprint-steps"].push(
130
111
  e["experimental-blueprints-v2-runner"] ? {
131
112
  step: "activateTheme",
132
- themeDirectoryName: s
113
+ themeDirectoryName: i
133
114
  } : {
134
115
  step: "activateTheme",
135
- themeFolderName: s
116
+ themeFolderName: i
136
117
  }
137
118
  );
138
- } else if (st(t)) {
139
- const s = c.readdirSync(t);
140
- for (const n of s)
141
- n !== "index.php" && r.push({
119
+ } else if (at(t)) {
120
+ const i = c.readdirSync(t);
121
+ for (const n of i)
122
+ n !== "index.php" && o.push({
142
123
  hostPath: `${t}/${n}`,
143
124
  vfsPath: `/wordpress/wp-content/${n}`,
144
125
  autoMounted: !0
145
126
  });
146
- i["additional-blueprint-steps"].push(oe);
147
- } else it(t) && (o.push({
127
+ s["additional-blueprint-steps"].push(ne);
128
+ } else nt(t) && (r.push({
148
129
  hostPath: t,
149
130
  vfsPath: "/wordpress",
150
131
  autoMounted: !0
151
- }), i.mode = "apply-to-existing-site", i["additional-blueprint-steps"].push(oe), i.wordpressInstallMode || (i.wordpressInstallMode = "install-from-existing-files-if-needed"));
152
- return i;
132
+ }), s.mode = "apply-to-existing-site", s["additional-blueprint-steps"].push(ne), s.wordpressInstallMode || (s.wordpressInstallMode = "install-from-existing-files-if-needed"));
133
+ return s;
153
134
  }
154
- function it(e) {
135
+ function nt(e) {
155
136
  const t = c.readdirSync(e);
156
137
  return t.includes("wp-admin") && t.includes("wp-includes") && t.includes("wp-content");
157
138
  }
158
- function st(e) {
139
+ function at(e) {
159
140
  const t = c.readdirSync(e);
160
141
  return t.includes("themes") || t.includes("plugins") || t.includes("mu-plugins") || t.includes("uploads");
161
142
  }
162
- function nt(e) {
143
+ function lt(e) {
163
144
  if (!c.readdirSync(e).includes("style.css"))
164
145
  return !1;
165
- const r = c.readFileSync(de(e, "style.css"), "utf8");
166
- return !!/^(?:[ \t]*<\?php)?[ \t/*#@]*Theme Name:(.*)$/im.exec(r);
146
+ const o = c.readFileSync(ce(e, "style.css"), "utf8");
147
+ return !!/^(?:[ \t]*<\?php)?[ \t/*#@]*Theme Name:(.*)$/im.exec(o);
167
148
  }
168
- function at(e) {
169
- const t = c.readdirSync(e), r = /^(?:[ \t]*<\?php)?[ \t/*#@]*Plugin Name:(.*)$/im;
170
- return !!t.filter((i) => i.endsWith(".php")).find((i) => {
171
- const s = c.readFileSync(de(e, i), "utf8");
172
- return !!r.exec(s);
149
+ function ut(e) {
150
+ const t = c.readdirSync(e), o = /^(?:[ \t]*<\?php)?[ \t/*#@]*Plugin Name:(.*)$/im;
151
+ return !!t.filter((s) => s.endsWith(".php")).find((s) => {
152
+ const i = c.readFileSync(ce(e, s), "utf8");
153
+ return !!o.exec(i);
173
154
  });
174
155
  }
175
- function lt(e) {
156
+ function dt(e) {
176
157
  if (e.length % 2 !== 0)
177
158
  throw new Error(
178
159
  "Invalid constant definition format. Expected pairs of NAME value"
179
160
  );
180
161
  const t = {};
181
- for (let r = 0; r < e.length; r += 2) {
182
- const o = e[r], i = e[r + 1];
183
- if (!o || !o.trim())
162
+ for (let o = 0; o < e.length; o += 2) {
163
+ const r = e[o], s = e[o + 1];
164
+ if (!r || !r.trim())
184
165
  throw new Error("Constant name cannot be empty");
185
- t[o.trim()] = i;
166
+ t[r.trim()] = s;
186
167
  }
187
168
  return t;
188
169
  }
189
- function dt(e) {
170
+ function pt(e) {
190
171
  if (e.length % 2 !== 0)
191
172
  throw new Error(
192
173
  "Invalid boolean constant definition format. Expected pairs of NAME value"
193
174
  );
194
175
  const t = {};
195
- for (let r = 0; r < e.length; r += 2) {
196
- const o = e[r], i = e[r + 1].trim().toLowerCase();
197
- if (!o || !o.trim())
176
+ for (let o = 0; o < e.length; o += 2) {
177
+ const r = e[o], s = e[o + 1].trim().toLowerCase();
178
+ if (!r || !r.trim())
198
179
  throw new Error("Constant name cannot be empty");
199
- if (i === "true" || i === "1")
200
- t[o.trim()] = !0;
201
- else if (i === "false" || i === "0")
202
- t[o.trim()] = !1;
180
+ if (s === "true" || s === "1")
181
+ t[r.trim()] = !0;
182
+ else if (s === "false" || s === "0")
183
+ t[r.trim()] = !1;
203
184
  else
204
185
  throw new Error(
205
- `Invalid boolean value for constant "${o}": "${i}". Must be "true", "false", "1", or "0".`
186
+ `Invalid boolean value for constant "${r}": "${s}". Must be "true", "false", "1", or "0".`
206
187
  );
207
188
  }
208
189
  return t;
209
190
  }
210
- function ut(e) {
191
+ function ct(e) {
211
192
  if (e.length % 2 !== 0)
212
193
  throw new Error(
213
194
  "Invalid number constant definition format. Expected pairs of NAME value"
214
195
  );
215
196
  const t = {};
216
- for (let r = 0; r < e.length; r += 2) {
217
- const o = e[r], i = e[r + 1].trim();
218
- if (!o || !o.trim())
197
+ for (let o = 0; o < e.length; o += 2) {
198
+ const r = e[o], s = e[o + 1].trim();
199
+ if (!r || !r.trim())
219
200
  throw new Error("Constant name cannot be empty");
220
- const s = Number(i);
221
- if (isNaN(s))
201
+ const i = Number(s);
202
+ if (isNaN(i))
222
203
  throw new Error(
223
- `Invalid number value for constant "${o}": "${i}". Must be a valid number.`
204
+ `Invalid number value for constant "${r}": "${s}". Must be a valid number.`
224
205
  );
225
- t[o.trim()] = s;
206
+ t[r.trim()] = i;
226
207
  }
227
208
  return t;
228
209
  }
229
- function pt(e = {}, t = {}, r = {}) {
230
- const o = {}, i = /* @__PURE__ */ new Set(), s = (n, l) => {
231
- for (const d in n) {
232
- if (i.has(d))
210
+ function mt(e = {}, t = {}, o = {}) {
211
+ const r = {}, s = /* @__PURE__ */ new Set(), i = (n, l) => {
212
+ for (const u in n) {
213
+ if (s.has(u))
233
214
  throw new Error(
234
- `Constant "${d}" is defined multiple times across different --define-${l} flags`
215
+ `Constant "${u}" is defined multiple times across different --define-${l} flags`
235
216
  );
236
- i.add(d), o[d] = n[d];
217
+ s.add(u), r[u] = n[u];
237
218
  }
238
219
  };
239
- return s(e, "string"), s(t, "bool"), s(r, "number"), o;
220
+ return i(e, "string"), i(t, "bool"), i(o, "number"), r;
240
221
  }
241
- function pe(e) {
242
- return pt(
222
+ function we(e) {
223
+ return mt(
243
224
  e.define,
244
225
  e["define-bool"],
245
226
  e["define-number"]
246
227
  );
247
228
  }
248
- async function ct(e) {
249
- const t = Ae(), r = await new Promise((s, n) => {
250
- const l = t.listen(e.port, () => {
251
- const d = l.address();
252
- d === null || typeof d == "string" ? n(new Error("Server address is not available")) : s(l);
253
- });
229
+ const ft = Ue(me);
230
+ function ht(e) {
231
+ return new Promise((t) => {
232
+ if (e === 0) return t(!1);
233
+ const o = fe().listen(e);
234
+ o.once("listening", () => o.close(() => t(!1))), o.once(
235
+ "error",
236
+ (r) => t(r.code === "EADDRINUSE")
237
+ );
238
+ });
239
+ }
240
+ async function wt(e) {
241
+ const t = fe(), o = await new Promise((n, l) => {
242
+ const u = t.listen(e.port, () => {
243
+ const w = u.address();
244
+ w === null || typeof w == "string" ? l(new Error("Server address is not available")) : n(u);
245
+ }).once("error", l);
254
246
  });
255
- t.use("/", async (s, n) => {
247
+ t.use("/", async (n, l) => {
256
248
  try {
257
- const l = {
258
- url: s.url,
259
- headers: ft(s),
260
- method: s.method,
261
- body: await ht(s)
262
- }, d = await e.handleRequest(l);
263
- await mt(d, n);
264
- } catch (l) {
265
- g.error(l), n.headersSent || (n.statusCode = 500, n.end("Internal Server Error"));
249
+ const u = {
250
+ url: n.url,
251
+ headers: Pt(n),
252
+ method: n.method,
253
+ body: await bt(n)
254
+ }, w = await e.handleRequest(u);
255
+ await yt(w, l);
256
+ } catch (u) {
257
+ P.error(u), l.headersSent || (l.statusCode = 500, l.end("Internal Server Error"));
266
258
  }
267
259
  });
268
- const i = r.address().port;
269
- return await e.onBind(r, i);
260
+ const s = o.address().port, i = process.env.CODESPACE_NAME;
261
+ return i && gt(s, i), await e.onBind(o, s);
270
262
  }
271
- async function mt(e, t) {
272
- const [r, o] = await Promise.all([
263
+ async function yt(e, t) {
264
+ const [o, r] = await Promise.all([
273
265
  e.headers,
274
266
  e.httpStatusCode
275
267
  ]);
276
- t.statusCode = o;
277
- for (const s in r)
278
- t.setHeader(s, r[s]);
279
- const i = Ce.fromWeb(e.stdout);
280
- await De(i, t);
268
+ t.statusCode = r;
269
+ for (const i in o)
270
+ t.setHeader(i, o[i]);
271
+ const s = He.fromWeb(e.stdout);
272
+ await Fe(s, t);
281
273
  }
282
- const ht = async (e) => await new Promise((t) => {
283
- const r = [];
284
- e.on("data", (o) => {
285
- r.push(o);
274
+ const bt = async (e) => await new Promise((t) => {
275
+ const o = [];
276
+ e.on("data", (r) => {
277
+ o.push(r);
286
278
  }), e.on("end", () => {
287
- t(new Uint8Array(Buffer.concat(r)));
279
+ t(new Uint8Array(Buffer.concat(o)));
288
280
  });
289
- }), ft = (e) => {
281
+ });
282
+ async function gt(e, t) {
283
+ P.log(`Publishing port ${e}...`);
284
+ const o = `gh codespace ports visibility ${e}:public -c ${t}`;
285
+ for (let r = 0; r < 10; r++)
286
+ try {
287
+ await ft(o);
288
+ return;
289
+ } catch {
290
+ await new Promise((s) => setTimeout(s, 2e3));
291
+ }
292
+ }
293
+ const Pt = (e) => {
290
294
  const t = {};
291
295
  if (e.rawHeaders && e.rawHeaders.length)
292
- for (let r = 0; r < e.rawHeaders.length; r += 2)
293
- t[e.rawHeaders[r].toLowerCase()] = e.rawHeaders[r + 1];
296
+ for (let o = 0; o < e.rawHeaders.length; o += 2)
297
+ t[e.rawHeaders[o].toLowerCase()] = e.rawHeaders[o + 1];
294
298
  return t;
295
299
  };
296
- function wt(e) {
300
+ function vt(e) {
297
301
  return /^latest$|^trunk$|^nightly$|^(?:(\d+)\.(\d+)(?:\.(\d+))?)((?:-beta(?:\d+)?)|(?:-RC(?:\d+)?))?$/.test(e);
298
302
  }
299
- async function yt({
303
+ async function St({
300
304
  sourceString: e,
301
305
  blueprintMayReadAdjacentFiles: t
302
306
  }) {
303
307
  if (!e)
304
308
  return;
305
309
  if (e.startsWith("http://") || e.startsWith("https://"))
306
- return await $e(e);
307
- let r = u.resolve(process.cwd(), e);
308
- if (!c.existsSync(r))
309
- throw new Error(`Blueprint file does not exist: ${r}`);
310
- const o = c.statSync(r);
311
- if (o.isDirectory() && (r = u.join(r, "blueprint.json")), !o.isFile() && o.isSymbolicLink())
310
+ return await Ae(e);
311
+ let o = d.resolve(process.cwd(), e);
312
+ if (!c.existsSync(o))
313
+ throw new Error(`Blueprint file does not exist: ${o}`);
314
+ const r = c.statSync(o);
315
+ if (r.isDirectory() && (o = d.join(o, "blueprint.json")), !r.isFile() && r.isSymbolicLink())
312
316
  throw new Error(
313
- `Blueprint path is neither a file nor a directory: ${r}`
317
+ `Blueprint path is neither a file nor a directory: ${o}`
314
318
  );
315
- const i = u.extname(r);
316
- switch (i) {
319
+ const s = d.extname(o);
320
+ switch (s) {
317
321
  case ".zip":
318
- return He.fromArrayBuffer(
319
- c.readFileSync(r).buffer
322
+ return Ve.fromArrayBuffer(
323
+ c.readFileSync(o).buffer
320
324
  );
321
325
  case ".json": {
322
- const s = c.readFileSync(r, "utf-8");
326
+ const i = c.readFileSync(o, "utf-8");
323
327
  try {
324
- JSON.parse(s);
328
+ JSON.parse(i);
325
329
  } catch {
326
330
  throw new Error(
327
- `Blueprint file at ${r} is not a valid JSON file`
331
+ `Blueprint file at ${o} is not a valid JSON file`
328
332
  );
329
333
  }
330
- const n = u.dirname(r), l = new Le(n);
331
- return new Ue([
332
- new Fe({
333
- "blueprint.json": s
334
+ const n = d.dirname(o), l = new Oe(n);
335
+ return new _e([
336
+ new je({
337
+ "blueprint.json": i
334
338
  }),
335
339
  /**
336
340
  * Wrap the NodeJS filesystem to prevent access to local files
337
341
  * unless the user explicitly allowed it.
338
342
  */
339
343
  {
340
- read(d) {
344
+ read(u) {
341
345
  if (!t)
342
346
  throw new Error(
343
- `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.
347
+ `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.
344
348
 
345
349
  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.`
346
350
  );
347
- return l.read(d);
351
+ return l.read(u);
348
352
  }
349
353
  }
350
354
  ]);
351
355
  }
352
356
  default:
353
357
  throw new Error(
354
- `Unsupported blueprint file extension: ${i}. Only .zip and .json files are supported.`
358
+ `Unsupported blueprint file extension: ${s}. Only .zip and .json files are supported.`
355
359
  );
356
360
  }
357
361
  }
358
- class bt {
359
- constructor(t, r) {
360
- this.args = t, this.siteUrl = r.siteUrl, this.phpVersion = t.php, this.cliOutput = r.cliOutput;
362
+ class xt {
363
+ constructor(t, o) {
364
+ this.args = t, this.siteUrl = o.siteUrl, this.phpVersion = t.php, this.cliOutput = o.cliOutput;
361
365
  }
362
366
  getWorkerType() {
363
367
  return "v2";
364
368
  }
365
- async bootWordPress(t, r) {
366
- const o = {
369
+ async bootWordPress(t, o) {
370
+ const r = {
367
371
  command: this.args.command,
368
372
  siteUrl: this.siteUrl,
369
373
  blueprint: this.args.blueprint,
370
- workerPostInstallMountsPort: r
374
+ workerPostInstallMountsPort: o
371
375
  };
372
- return await t.bootWordPress(o, r), t;
376
+ return await t.bootWordPress(r, o), t;
373
377
  }
374
378
  async bootRequestHandler({
375
379
  worker: t,
376
- fileLockManagerPort: r,
377
- nativeInternalDirPath: o
380
+ fileLockManagerPort: o,
381
+ nativeInternalDirPath: r
378
382
  }) {
379
- const i = ne(t.phpPort);
380
- await i.useFileLockManager(r);
381
- const s = {
383
+ const s = ue(t.phpPort);
384
+ await s.useFileLockManager(o);
385
+ const i = {
382
386
  ...this.args,
383
387
  phpVersion: this.phpVersion,
384
388
  siteUrl: this.siteUrl,
@@ -388,106 +392,106 @@ class bt {
388
392
  withRedis: this.args.redis,
389
393
  withMemcached: this.args.memcached,
390
394
  withXdebug: !!this.args.xdebug,
391
- nativeInternalDirPath: o,
395
+ nativeInternalDirPath: r,
392
396
  mountsBeforeWpInstall: this.args["mount-before-install"] || [],
393
397
  mountsAfterWpInstall: this.args.mount || [],
394
- constants: pe(this.args)
398
+ constants: we(this.args)
395
399
  };
396
- return await i.bootWorker(s), i;
400
+ return await s.bootWorker(i), s;
397
401
  }
398
402
  }
399
- const N = u.join(j.homedir(), ".wordpress-playground");
400
- async function gt() {
403
+ const V = d.join(q.homedir(), ".wordpress-playground");
404
+ async function $t() {
401
405
  const e = typeof __dirname < "u" ? __dirname : import.meta.dirname;
402
- let t = u.join(e, "sqlite-database-integration.zip");
403
- if (!I.existsSync(t)) {
404
- const r = je(import.meta.url), o = u.dirname(
405
- r.resolve("@wp-playground/wordpress-builds/package.json")
406
+ let t = d.join(e, "sqlite-database-integration.zip");
407
+ if (!$.existsSync(t)) {
408
+ const o = Ge(import.meta.url), r = d.dirname(
409
+ o.resolve("@wp-playground/wordpress-builds/package.json")
406
410
  );
407
- t = u.join(
408
- o,
411
+ t = d.join(
412
+ r,
409
413
  "src",
410
414
  "sqlite-database-integration",
411
415
  "sqlite-database-integration-trunk.zip"
412
416
  );
413
417
  }
414
- return new File([await I.readFile(t)], u.basename(t));
418
+ return new File([await $.readFile(t)], d.basename(t));
415
419
  }
416
- async function Pt(e, t, r) {
417
- const o = u.join(N, t);
418
- return I.existsSync(o) || (I.ensureDirSync(N), await vt(e, o, r)), ce(o);
420
+ async function Et(e, t, o) {
421
+ const r = d.join(V, t);
422
+ return $.existsSync(r) || ($.ensureDirSync(V), await Tt(e, r, o)), ye(r);
419
423
  }
420
- async function vt(e, t, r) {
421
- const i = (await r.monitorFetch(fetch(e))).body.getReader(), s = `${t}.partial`, n = I.createWriteStream(s);
424
+ async function Tt(e, t, o) {
425
+ const s = (await o.monitorFetch(fetch(e))).body.getReader(), i = `${t}.partial`, n = $.createWriteStream(i);
422
426
  for (; ; ) {
423
- const { done: l, value: d } = await i.read();
424
- if (d && n.write(d), l)
427
+ const { done: l, value: u } = await s.read();
428
+ if (u && n.write(u), l)
425
429
  break;
426
430
  }
427
- n.close(), n.closed || await new Promise((l, d) => {
431
+ n.close(), n.closed || await new Promise((l, u) => {
428
432
  n.on("finish", () => {
429
- I.renameSync(s, t), l(null);
430
- }), n.on("error", (x) => {
431
- I.removeSync(s), d(x);
433
+ $.renameSync(i, t), l(null);
434
+ }), n.on("error", (w) => {
435
+ $.removeSync(i), u(w);
432
436
  });
433
437
  });
434
438
  }
435
- function ce(e, t) {
436
- return new File([I.readFileSync(e)], A(e));
439
+ function ye(e, t) {
440
+ return new File([$.readFileSync(e)], D(e));
437
441
  }
438
- class St {
439
- constructor(t, r) {
440
- this.args = t, this.siteUrl = r.siteUrl, this.cliOutput = r.cliOutput;
442
+ class It {
443
+ constructor(t, o) {
444
+ this.args = t, this.siteUrl = o.siteUrl, this.cliOutput = o.cliOutput;
441
445
  }
442
446
  getWorkerType() {
443
447
  return "v1";
444
448
  }
445
- async bootWordPress(t, r) {
446
- let o, i, s;
447
- const n = new _e();
449
+ async bootWordPress(t, o) {
450
+ let r, s, i;
451
+ const n = new Ye();
448
452
  if (this.args.wordpressInstallMode === "download-and-install") {
449
- let x = !1;
453
+ let w = !1;
450
454
  n.addEventListener("progress", (S) => {
451
- if (x)
455
+ if (w)
452
456
  return;
453
457
  const { loaded: p, total: a } = S.detail, m = Math.floor(
454
458
  Math.min(100, 100 * p / a)
455
459
  );
456
- x = m === 100, this.cliOutput.updateProgress(
460
+ w = m === 100, this.cliOutput.updateProgress(
457
461
  "Downloading WordPress",
458
462
  m
459
463
  );
460
- }), o = await Oe(this.args.wp), s = u.join(
461
- N,
462
- `prebuilt-wp-content-for-wp-${o.version}.zip`
463
- ), i = c.existsSync(s) ? ce(s) : await Pt(
464
- o.releaseUrl,
465
- `${o.version}.zip`,
464
+ }), r = await ze(this.args.wp), i = d.join(
465
+ V,
466
+ `prebuilt-wp-content-for-wp-${r.version}.zip`
467
+ ), s = c.existsSync(i) ? ye(i) : await Et(
468
+ r.releaseUrl,
469
+ `${r.version}.zip`,
466
470
  n
467
- ), g.debug(
468
- `Resolved WordPress release URL: ${o?.releaseUrl}`
471
+ ), P.debug(
472
+ `Resolved WordPress release URL: ${r?.releaseUrl}`
469
473
  );
470
474
  }
471
475
  let l;
472
- this.args.skipSqliteSetup ? (g.debug("Skipping SQLite integration plugin setup..."), l = void 0) : (this.cliOutput.updateProgress("Preparing SQLite database"), l = await gt()), this.cliOutput.updateProgress("Booting WordPress");
473
- const d = await Z(
476
+ this.args.skipSqliteSetup ? (P.debug("Skipping SQLite integration plugin setup..."), l = void 0) : (this.cliOutput.updateProgress("Preparing SQLite database"), l = await $t()), this.cliOutput.updateProgress("Booting WordPress");
477
+ const u = await K(
474
478
  this.getEffectiveBlueprint()
475
479
  );
476
480
  return await t.bootWordPress(
477
481
  {
478
- wpVersion: d.wpVersion,
482
+ wpVersion: u.wpVersion,
479
483
  siteUrl: this.siteUrl,
480
484
  wordpressInstallMode: this.args.wordpressInstallMode || "download-and-install",
481
- wordPressZip: i && await i.arrayBuffer(),
485
+ wordPressZip: s && await s.arrayBuffer(),
482
486
  sqliteIntegrationPluginZip: await l?.arrayBuffer(),
483
- constants: pe(this.args)
487
+ constants: we(this.args)
484
488
  },
485
- r
486
- ), s && !this.args["mount-before-install"] && !c.existsSync(s) && (this.cliOutput.updateProgress("Caching WordPress for next boot"), c.writeFileSync(
487
- s,
489
+ o
490
+ ), i && !this.args["mount-before-install"] && !c.existsSync(i) && (this.cliOutput.updateProgress("Caching WordPress for next boot"), c.writeFileSync(
491
+ i,
488
492
  // Comlink proxy is not assignable to UniversalPHP but
489
493
  // proxies all method calls transparently at runtime.
490
- await Ee(
494
+ await De(
491
495
  t,
492
496
  "/wordpress"
493
497
  )
@@ -495,18 +499,18 @@ class St {
495
499
  }
496
500
  async bootRequestHandler({
497
501
  worker: t,
498
- fileLockManagerPort: r,
499
- nativeInternalDirPath: o
502
+ fileLockManagerPort: o,
503
+ nativeInternalDirPath: r
500
504
  }) {
501
- const i = ne(
505
+ const s = ue(
502
506
  t.phpPort
503
507
  );
504
- await i.isConnected();
505
- const s = await Z(
508
+ await s.isConnected();
509
+ const i = await K(
506
510
  this.getEffectiveBlueprint()
507
511
  );
508
- return await i.useFileLockManager(r), await i.bootRequestHandler({
509
- phpVersion: s.phpVersion,
512
+ return await s.useFileLockManager(o), await s.bootRequestHandler({
513
+ phpVersion: i.phpVersion,
510
514
  siteUrl: this.siteUrl,
511
515
  mountsBeforeWpInstall: this.args["mount-before-install"] || [],
512
516
  mountsAfterWpInstall: this.args.mount || [],
@@ -517,40 +521,40 @@ class St {
517
521
  withRedis: this.args.redis,
518
522
  withMemcached: this.args.memcached,
519
523
  withXdebug: !!this.args.xdebug,
520
- nativeInternalDirPath: o,
524
+ nativeInternalDirPath: r,
521
525
  pathAliases: this.args.pathAliases
522
- }), await i.isReady(), i;
526
+ }), await s.isReady(), s;
523
527
  }
524
528
  async compileInputBlueprint(t) {
525
- const r = this.getEffectiveBlueprint(), o = new Ne();
526
- let i = "", s = !1;
527
- return o.addEventListener("progress", (n) => {
528
- if (s)
529
+ const o = this.getEffectiveBlueprint(), r = new qe();
530
+ let s = "", i = !1;
531
+ return r.addEventListener("progress", (n) => {
532
+ if (i)
529
533
  return;
530
- s = n.detail.progress === 100;
534
+ i = n.detail.progress === 100;
531
535
  const l = Math.floor(n.detail.progress);
532
- i = n.detail.caption || i || "Running Blueprint", this.cliOutput.updateProgress(i.trim(), l);
533
- }), await ae(r, {
534
- progress: o,
536
+ s = n.detail.caption || s || "Running Blueprint", this.cliOutput.updateProgress(s.trim(), l);
537
+ }), await de(o, {
538
+ progress: r,
535
539
  additionalSteps: t
536
540
  });
537
541
  }
538
542
  getEffectiveBlueprint() {
539
543
  const t = this.args.blueprint;
540
- return Te(t) ? t : {
544
+ return Ce(t) ? t : {
541
545
  login: this.args.login,
542
546
  ...t || {},
543
547
  preferredVersions: {
544
- php: this.args.php ?? t?.preferredVersions?.php ?? C,
548
+ php: this.args.php ?? t?.preferredVersions?.php ?? M,
545
549
  wp: this.args.wp ?? t?.preferredVersions?.wp ?? "latest",
546
550
  ...t?.preferredVersions || {}
547
551
  }
548
552
  };
549
553
  }
550
554
  }
551
- async function xt(e, t = !0) {
552
- const o = `${u.basename(process.argv0)}${e}${process.pid}-`, i = await qe({
553
- prefix: o,
555
+ async function kt(e, t = !0) {
556
+ const r = `${d.basename(process.argv0)}${e}${process.pid}-`, s = await Xe({
557
+ prefix: r,
554
558
  /*
555
559
  * Allow recursive cleanup on process exit.
556
560
  *
@@ -561,83 +565,83 @@ async function xt(e, t = !0) {
561
565
  */
562
566
  unsafeCleanup: !0
563
567
  });
564
- return t && ze(), i;
568
+ return t && Ze(), s;
565
569
  }
566
- async function It(e, t, r) {
567
- const i = (await $t(
570
+ async function Mt(e, t, o) {
571
+ const s = (await Bt(
568
572
  e,
569
573
  t,
570
- r
574
+ o
571
575
  )).map(
572
- (s) => new Promise((n) => {
573
- c.rm(s, { recursive: !0 }, (l) => {
574
- l ? g.warn(
575
- `Failed to delete stale Playground temp dir: ${s}`,
576
+ (i) => new Promise((n) => {
577
+ c.rm(i, { recursive: !0 }, (l) => {
578
+ l ? P.warn(
579
+ `Failed to delete stale Playground temp dir: ${i}`,
576
580
  l
577
- ) : g.info(
578
- `Deleted stale Playground temp dir: ${s}`
581
+ ) : P.info(
582
+ `Deleted stale Playground temp dir: ${i}`
579
583
  ), n();
580
584
  });
581
585
  })
582
586
  );
583
- await Promise.all(i);
587
+ await Promise.all(s);
584
588
  }
585
- async function $t(e, t, r) {
589
+ async function Bt(e, t, o) {
586
590
  try {
587
- const o = c.readdirSync(r).map((s) => u.join(r, s)), i = [];
588
- for (const s of o)
589
- await Tt(
591
+ const r = c.readdirSync(o).map((i) => d.join(o, i)), s = [];
592
+ for (const i of r)
593
+ await At(
590
594
  e,
591
595
  t,
592
- s
593
- ) && i.push(s);
594
- return i;
595
- } catch (o) {
596
- return g.warn(`Failed to find stale Playground temp dirs: ${o}`), [];
596
+ i
597
+ ) && s.push(i);
598
+ return s;
599
+ } catch (r) {
600
+ return P.warn(`Failed to find stale Playground temp dirs: ${r}`), [];
597
601
  }
598
602
  }
599
- async function Tt(e, t, r) {
600
- if (!c.lstatSync(r).isDirectory())
603
+ async function At(e, t, o) {
604
+ if (!c.lstatSync(o).isDirectory())
601
605
  return !1;
602
- const i = u.basename(r);
603
- if (!i.includes(e))
606
+ const s = d.basename(o);
607
+ if (!s.includes(e))
604
608
  return !1;
605
- const s = i.match(
609
+ const i = s.match(
606
610
  new RegExp(`^(.+)${e}(\\d+)-`)
607
611
  );
608
- if (!s)
612
+ if (!i)
609
613
  return !1;
610
614
  const n = {
611
- executableName: s[1],
612
- pid: s[2]
615
+ executableName: i[1],
616
+ pid: i[2]
613
617
  };
614
- if (await Et(n.pid, n.executableName))
618
+ if (await Ct(n.pid, n.executableName))
615
619
  return !1;
616
620
  const l = Date.now() - t;
617
- return c.statSync(r).mtime.getTime() < l;
621
+ return c.statSync(o).mtime.getTime() < l;
618
622
  }
619
- async function Et(e, t) {
620
- const [r] = await new Promise(
621
- (o, i) => {
622
- Ge.list(
623
+ async function Ct(e, t) {
624
+ const [o] = await new Promise(
625
+ (r, s) => {
626
+ Je.list(
623
627
  {
624
628
  pid: e,
625
629
  name: t,
626
630
  // Remove path from executable name in the results.
627
631
  clean: !0
628
632
  },
629
- (s, n) => {
630
- s ? i(s) : o(n);
633
+ (i, n) => {
634
+ i ? s(i) : r(n);
631
635
  }
632
636
  );
633
637
  }
634
638
  );
635
- return !!r && r.pid === e && r.command === t;
639
+ return !!o && o.pid === e && o.command === t;
636
640
  }
637
- function kt(e) {
641
+ function Dt(e) {
638
642
  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;
639
643
  }
640
- class Mt {
644
+ class Rt {
641
645
  constructor(t) {
642
646
  this.lastProgressLine = "", this.progressActive = !1, this.verbosity = t.verbosity, this.writeStream = t.writeStream || process.stdout;
643
647
  }
@@ -651,7 +655,7 @@ class Mt {
651
655
  * This prevents progress spam in logs - users only see the final outcome.
652
656
  */
653
657
  get shouldRender() {
654
- return kt(this.writeStream);
658
+ return Dt(this.writeStream);
655
659
  }
656
660
  get isQuiet() {
657
661
  return this.verbosity === "quiet";
@@ -698,19 +702,19 @@ ${t}
698
702
  */
699
703
  printConfig(t) {
700
704
  if (this.isQuiet) return;
701
- const r = [];
702
- r.push(
705
+ const o = [];
706
+ o.push(
703
707
  `${this.dim("PHP")} ${this.cyan(t.phpVersion)} ${this.dim("WordPress")} ${this.cyan(t.wpVersion)}`
704
708
  );
705
- const o = [];
706
- if (t.intl && o.push("intl"), t.redis && o.push("redis"), t.memcached && o.push("memcached"), t.xdebug && o.push(this.yellow("xdebug")), o.length > 0 && r.push(`${this.dim("Extensions")} ${o.join(", ")}`), t.mounts.length > 0)
707
- for (const i of t.mounts) {
708
- const s = i.autoMounted ? ` ${this.dim("(auto-mount)")}` : "";
709
- r.push(
710
- `${this.dim("Mount")} ${i.hostPath} ${this.dim("→")} ${i.vfsPath}${s}`
709
+ const r = [];
710
+ if (t.intl && r.push("intl"), t.redis && r.push("redis"), t.memcached && r.push("memcached"), t.xdebug && r.push(this.yellow("xdebug")), r.length > 0 && o.push(`${this.dim("Extensions")} ${r.join(", ")}`), t.mounts.length > 0)
711
+ for (const s of t.mounts) {
712
+ const i = s.autoMounted ? ` ${this.dim("(auto-mount)")}` : "";
713
+ o.push(
714
+ `${this.dim("Mount")} ${s.hostPath} ${this.dim("→")} ${s.vfsPath}${i}`
711
715
  );
712
716
  }
713
- t.blueprint && r.push(`${this.dim("Blueprint")} ${t.blueprint}`), this.writeStream.write(r.join(`
717
+ t.blueprint && o.push(`${this.dim("Blueprint")} ${t.blueprint}`), this.writeStream.write(o.join(`
714
718
  `) + `
715
719
 
716
720
  `);
@@ -731,11 +735,11 @@ ${t}
731
735
  * Identical messages are skipped to prevent flickering. When piped,
732
736
  * this method does nothing (early return via shouldRender check).
733
737
  */
734
- updateProgress(t, r) {
738
+ updateProgress(t, o) {
735
739
  if (this.isQuiet || !this.shouldRender) return;
736
740
  this.progressActive || (this.progressActive = !0);
737
- let o = `${t}`;
738
- r !== void 0 && (o = `${t} ${this.dim(`${r}%`)}`), o !== this.lastProgressLine && (this.lastProgressLine = o, this.isTTY ? (this.writeStream.cursorTo(0), this.writeStream.write(o), this.writeStream.clearLine(1)) : this.writeStream.write(`${o}
741
+ let r = `${t}`;
742
+ o !== void 0 && (r = `${t} ${this.dim(`${o}%`)}`), r !== this.lastProgressLine && (this.lastProgressLine = r, this.isTTY ? (this.writeStream.cursorTo(0), this.writeStream.write(r), this.writeStream.clearLine(1)) : this.writeStream.write(`${r}
739
743
  `));
740
744
  }
741
745
  /**
@@ -775,12 +779,12 @@ ${t}
775
779
  * Note: The exact wording "WordPress is running on" is checked by
776
780
  * CI tests, so changes to this string will break test assertions.
777
781
  */
778
- printReady(t, r) {
782
+ printReady(t, o) {
779
783
  if (this.isQuiet) return;
780
- const o = r === 1 ? "worker" : "workers";
784
+ const r = o === 1 ? "worker" : "workers";
781
785
  this.writeStream.write(
782
786
  `
783
- ${this.green("Ready!")} WordPress is running on ${this.bold(t)} ${this.dim(`(${r} ${o})`)}
787
+ ${this.green("Ready!")} WordPress is running on ${this.bold(t)} ${this.dim(`(${o} ${r})`)}
784
788
 
785
789
  `
786
790
  );
@@ -800,12 +804,12 @@ ${this.green("Ready!")} WordPress is running on ${this.bold(t)} ${this.dim(`(${r
800
804
  );
801
805
  }
802
806
  }
803
- const me = {
804
- Quiet: { name: "quiet", severity: L.Fatal },
805
- Normal: { name: "normal", severity: L.Info },
806
- Debug: { name: "debug", severity: L.Debug }
807
- }, Bt = 10;
808
- async function mr(e) {
807
+ const be = {
808
+ Quiet: { name: "quiet", severity: F.Fatal },
809
+ Normal: { name: "normal", severity: F.Info },
810
+ Debug: { name: "debug", severity: F.Debug }
811
+ };
812
+ async function bo(e) {
809
813
  try {
810
814
  const t = {
811
815
  "site-url": {
@@ -815,8 +819,8 @@ async function mr(e) {
815
819
  php: {
816
820
  describe: "PHP version to use.",
817
821
  type: "string",
818
- default: C,
819
- choices: Q
822
+ default: M,
823
+ choices: R
820
824
  },
821
825
  wp: {
822
826
  describe: "WordPress version to use.",
@@ -828,21 +832,21 @@ async function mr(e) {
828
832
  type: "string",
829
833
  nargs: 2,
830
834
  array: !0,
831
- coerce: lt
835
+ coerce: dt
832
836
  },
833
837
  "define-bool": {
834
838
  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',
835
839
  type: "string",
836
840
  nargs: 2,
837
841
  array: !0,
838
- coerce: dt
842
+ coerce: pt
839
843
  },
840
844
  "define-number": {
841
845
  describe: "Define PHP number constants (can be used multiple times). Format: NAME value. Examples: --define-number LIMIT 100 --define-number RATE 45.67",
842
846
  type: "string",
843
847
  nargs: 2,
844
848
  array: !0,
845
- coerce: ut
849
+ coerce: ct
846
850
  },
847
851
  // @TODO: Support read-only mounts, e.g. via WORKERFS, a custom
848
852
  // ReadOnlyNODEFS, or by copying the files into MEMFS
@@ -850,27 +854,27 @@ async function mr(e) {
850
854
  describe: "Mount a directory to the PHP runtime (can be used multiple times). Format: /host/path:/vfs/path",
851
855
  type: "array",
852
856
  string: !0,
853
- coerce: U
857
+ coerce: N
854
858
  },
855
859
  "mount-before-install": {
856
860
  describe: "Mount a directory to the PHP runtime before WordPress installation (can be used multiple times). Format: /host/path:/vfs/path",
857
861
  type: "array",
858
862
  string: !0,
859
- coerce: U
863
+ coerce: N
860
864
  },
861
865
  "mount-dir": {
862
866
  describe: 'Mount a directory to the PHP runtime (can be used multiple times). Format: "/host/path" "/vfs/path"',
863
867
  type: "array",
864
868
  nargs: 2,
865
869
  array: !0,
866
- coerce: re
870
+ coerce: ie
867
871
  },
868
872
  "mount-dir-before-install": {
869
873
  describe: 'Mount a directory before WordPress installation (can be used multiple times). Format: "/host/path" "/vfs/path"',
870
874
  type: "string",
871
875
  nargs: 2,
872
876
  array: !0,
873
- coerce: re
877
+ coerce: ie
874
878
  },
875
879
  login: {
876
880
  describe: "Should log the user in",
@@ -917,7 +921,7 @@ async function mr(e) {
917
921
  verbosity: {
918
922
  describe: "Output logs and progress messages.",
919
923
  type: "string",
920
- choices: Object.values(me).map(
924
+ choices: Object.values(be).map(
921
925
  (a) => a.name
922
926
  ),
923
927
  default: "normal"
@@ -999,11 +1003,10 @@ Warning: Following symlinks will expose files outside mounted directories to Pla
999
1003
  type: "string",
1000
1004
  coerce: (a) => a === "" ? "/phpmyadmin" : a
1001
1005
  }
1002
- }, r = {
1006
+ }, o = {
1003
1007
  port: {
1004
- describe: "Port to listen on when serving.",
1005
- type: "number",
1006
- default: 9400
1008
+ describe: "Port to listen on when serving. Defaults to 9400 when available.",
1009
+ type: "number"
1007
1010
  },
1008
1011
  "experimental-multi-worker": {
1009
1012
  deprecated: "This option is not needed. Multiple workers are always used.",
@@ -1014,7 +1017,7 @@ Warning: Following symlinks will expose files outside mounted directories to Pla
1014
1017
  describe: "Enable experimental browser development tools.",
1015
1018
  type: "boolean"
1016
1019
  }
1017
- }, o = {
1020
+ }, r = {
1018
1021
  path: {
1019
1022
  describe: "Path to the project directory. Playground will auto-detect if this is a plugin, theme, wp-content, or WordPress directory.",
1020
1023
  type: "string",
@@ -1023,8 +1026,8 @@ Warning: Following symlinks will expose files outside mounted directories to Pla
1023
1026
  php: {
1024
1027
  describe: "PHP version to use.",
1025
1028
  type: "string",
1026
- default: C,
1027
- choices: Q
1029
+ default: M,
1030
+ choices: R
1028
1031
  },
1029
1032
  wp: {
1030
1033
  describe: "WordPress version to use.",
@@ -1032,9 +1035,8 @@ Warning: Following symlinks will expose files outside mounted directories to Pla
1032
1035
  default: "latest"
1033
1036
  },
1034
1037
  port: {
1035
- describe: "Port to listen on.",
1036
- type: "number",
1037
- default: 9400
1038
+ describe: "Port to listen on. Defaults to 9400 when available.",
1039
+ type: "number"
1038
1040
  },
1039
1041
  blueprint: {
1040
1042
  describe: "Path to a Blueprint JSON file to execute on startup.",
@@ -1070,7 +1072,7 @@ Warning: Following symlinks will expose files outside mounted directories to Pla
1070
1072
  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.",
1071
1073
  type: "array",
1072
1074
  string: !0,
1073
- coerce: U
1075
+ coerce: N
1074
1076
  },
1075
1077
  reset: {
1076
1078
  describe: "Deletes the stored site directory and starts a new site from scratch.",
@@ -1088,13 +1090,13 @@ Warning: Following symlinks will expose files outside mounted directories to Pla
1088
1090
  "define-number": t["define-number"],
1089
1091
  // Tools
1090
1092
  phpmyadmin: t.phpmyadmin
1091
- }, i = {
1093
+ }, s = {
1092
1094
  outfile: {
1093
1095
  describe: "When building, write to this output file.",
1094
1096
  type: "string",
1095
1097
  default: "wordpress.zip"
1096
1098
  }
1097
- }, s = We(e).usage("Usage: wp-playground <command> [options]").command(
1099
+ }, i = Ne(e).usage("Usage: wp-playground <command> [options]").command(
1098
1100
  "start",
1099
1101
  "Start a local WordPress server with automatic project detection (recommended)",
1100
1102
  (a) => a.usage(
@@ -1110,13 +1112,13 @@ Examples:
1110
1112
  wp-playground start --wp=6.7 --php=8.3 # Use specific versions
1111
1113
  wp-playground start --skip-browser # Skip opening browser
1112
1114
  wp-playground start --no-auto-mount # Disable auto-detection`
1113
- ).options(o)
1115
+ ).options(r)
1114
1116
  ).command(
1115
1117
  "server",
1116
1118
  "Start a local WordPress server (advanced, low-level)",
1117
1119
  (a) => a.options({
1118
1120
  ...t,
1119
- ...r
1121
+ ...o
1120
1122
  })
1121
1123
  ).command(
1122
1124
  "run-blueprint",
@@ -1127,7 +1129,7 @@ Examples:
1127
1129
  "Build a ZIP snapshot of a WordPress site based on a Blueprint",
1128
1130
  (a) => a.options({
1129
1131
  ...t,
1130
- ...i
1132
+ ...s
1131
1133
  })
1132
1134
  ).demandCommand(1, "Please specify a command").strictCommands().conflicts(
1133
1135
  "experimental-unsafe-ide-integration",
@@ -1138,7 +1140,7 @@ Examples:
1138
1140
  a && a.includes("Please specify a command") && (y.showHelp(), console.error(`
1139
1141
  ` + a), process.exit(1)), console.error(a), process.exit(1);
1140
1142
  }).strictOptions().check(async (a) => {
1141
- if (a["skip-wordpress-install"] === !0 && (a["wordpress-install-mode"] = "do-not-attempt-installing", a.wordpressInstallMode = "do-not-attempt-installing"), a.wp !== void 0 && typeof a.wp == "string" && !wt(a.wp))
1143
+ if (a["skip-wordpress-install"] === !0 && (a["wordpress-install-mode"] = "do-not-attempt-installing", a.wordpressInstallMode = "do-not-attempt-installing"), a.wp !== void 0 && typeof a.wp == "string" && !vt(a.wp))
1142
1144
  try {
1143
1145
  new URL(a.wp);
1144
1146
  } catch {
@@ -1179,16 +1181,16 @@ Examples:
1179
1181
  );
1180
1182
  return !0;
1181
1183
  });
1182
- s.wrap(s.terminalWidth());
1183
- const n = await s.argv, l = n._[0];
1184
+ i.wrap(i.terminalWidth());
1185
+ const n = await i.argv, l = n._[0];
1184
1186
  ["start", "run-blueprint", "server", "build-snapshot"].includes(
1185
1187
  l
1186
- ) || (s.showHelp(), process.exit(1));
1187
- const d = n.define || {};
1188
- !("WP_DEBUG" in d) && !("WP_DEBUG_LOG" in d) && !("WP_DEBUG_DISPLAY" in d) && (d.WP_DEBUG = "true", d.WP_DEBUG_LOG = "true", d.WP_DEBUG_DISPLAY = "true");
1189
- const x = {
1188
+ ) || (i.showHelp(), process.exit(1));
1189
+ const u = n.define || {};
1190
+ !("WP_DEBUG" in u) && !("WP_DEBUG_LOG" in u) && !("WP_DEBUG_DISPLAY" in u) && (u.WP_DEBUG = "true", u.WP_DEBUG_LOG = "true", u.WP_DEBUG_DISPLAY = "true");
1191
+ const w = {
1190
1192
  ...n,
1191
- define: d,
1193
+ define: u,
1192
1194
  command: l,
1193
1195
  mount: [
1194
1196
  ...n.mount || [],
@@ -1198,7 +1200,7 @@ Examples:
1198
1200
  ...n["mount-before-install"] || [],
1199
1201
  ...n["mount-dir-before-install"] || []
1200
1202
  ]
1201
- }, S = await Dt(x);
1203
+ }, S = await Lt(w);
1202
1204
  S === void 0 && process.exit(0);
1203
1205
  const p = /* @__PURE__ */ (() => {
1204
1206
  let a;
@@ -1210,42 +1212,42 @@ Examples:
1210
1212
  [Symbol.asyncDispose]: async () => {
1211
1213
  process.off("SIGINT", p), process.off("SIGTERM", p), await S[Symbol.asyncDispose]();
1212
1214
  },
1213
- [he]: { cliServer: S }
1215
+ [ge]: { cliServer: S }
1214
1216
  };
1215
1217
  } catch (t) {
1216
1218
  if (console.error(t), !(t instanceof Error))
1217
1219
  throw t;
1218
1220
  if (process.argv.includes("--debug"))
1219
- be(t);
1221
+ $e(t);
1220
1222
  else {
1221
- const o = [];
1222
- let i = t;
1223
+ const r = [];
1224
+ let s = t;
1223
1225
  do
1224
- o.push(i.message), i = i.cause;
1225
- while (i instanceof Error);
1226
+ r.push(s.message), s = s.cause;
1227
+ while (s instanceof Error);
1226
1228
  console.error(
1227
- "\x1B[1m" + o.join(" caused by: ") + "\x1B[0m"
1229
+ "\x1B[1m" + r.join(" caused by: ") + "\x1B[0m"
1228
1230
  );
1229
1231
  }
1230
1232
  process.exit(1);
1231
1233
  }
1232
1234
  }
1233
- function ie(e, t) {
1235
+ function ae(e, t) {
1234
1236
  return e.find(
1235
- (r) => r.vfsPath.replace(/\/$/, "") === t.replace(/\/$/, "")
1237
+ (o) => o.vfsPath.replace(/\/$/, "") === t.replace(/\/$/, "")
1236
1238
  );
1237
1239
  }
1238
- const he = Symbol("playground-cli-testing"), k = (e) => process.stdout.isTTY ? "\x1B[1m" + e + "\x1B[0m" : e, At = (e) => process.stdout.isTTY ? "\x1B[31m" + e + "\x1B[0m" : e, Ct = (e) => process.stdout.isTTY ? `\x1B[2m${e}\x1B[0m` : e, F = (e) => process.stdout.isTTY ? `\x1B[3m${e}\x1B[0m` : e, se = (e) => process.stdout.isTTY ? `\x1B[33m${e}\x1B[0m` : e;
1239
- async function Dt(e) {
1240
+ const ge = Symbol("playground-cli-testing"), I = (e) => process.stdout.isTTY ? "\x1B[1m" + e + "\x1B[0m" : e, Wt = (e) => process.stdout.isTTY ? "\x1B[31m" + e + "\x1B[0m" : e, le = (e) => process.stdout.isTTY ? `\x1B[2m${e}\x1B[0m` : e, C = (e) => process.stdout.isTTY ? `\x1B[3m${e}\x1B[0m` : e, O = (e) => process.stdout.isTTY ? `\x1B[33m${e}\x1B[0m` : e;
1241
+ async function Lt(e) {
1240
1242
  let t;
1241
- const r = e.internalCookieStore ? new ge() : void 0, o = [], i = /* @__PURE__ */ new Map();
1242
- if (e.command === "start" && (e = Rt(e)), e.autoMount !== void 0 && (e.autoMount === "" && (e = { ...e, autoMount: process.cwd() }), e = ue(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) {
1243
- const p = Object.values(me).find(
1243
+ const o = e.internalCookieStore ? new Ee() : void 0, r = [], s = /* @__PURE__ */ new Map();
1244
+ if (e.command === "start" && (e = Ut(e)), e.autoMount !== void 0 && (e.autoMount === "" && (e = { ...e, autoMount: process.cwd() }), e = he(e)), e.wordpressInstallMode === void 0 && (e.wordpressInstallMode = "download-and-install"), e.quiet && (e.verbosity = "quiet", delete e.quiet), e.debug && (e.verbosity = "debug", delete e.debug), e.verbosity) {
1245
+ const p = Object.values(be).find(
1244
1246
  (a) => a.name === e.verbosity
1245
1247
  ).severity;
1246
- g.setSeverityFilterLevel(p);
1248
+ P.setSeverityFilterLevel(p);
1247
1249
  }
1248
- if (e.intl || (e.intl = !0), e.redis === void 0 && (e.redis = await te()), e.memcached === void 0 && (e.memcached = await te()), e.phpmyadmin) {
1250
+ if (e.intl || (e.intl = !0), e.redis === void 0 && (e.redis = await se()), e.memcached === void 0 && (e.memcached = await se()), e.phpmyadmin) {
1249
1251
  if (e.phpmyadmin === !0 && (e.phpmyadmin = "/phpmyadmin"), e.skipSqliteSetup)
1250
1252
  throw new Error(
1251
1253
  "--phpmyadmin requires SQLite. Cannot be used with --skip-sqlite-setup."
@@ -1253,17 +1255,17 @@ async function Dt(e) {
1253
1255
  e.pathAliases = [
1254
1256
  {
1255
1257
  urlPrefix: e.phpmyadmin,
1256
- fsPath: ee
1258
+ fsPath: re
1257
1259
  }
1258
1260
  ];
1259
1261
  }
1260
- const s = new Mt({
1262
+ const i = new Rt({
1261
1263
  verbosity: e.verbosity || "normal"
1262
1264
  });
1263
- e.command === "server" && (s.printBanner(), s.printConfig({
1264
- phpVersion: e.php || C,
1265
+ e.command === "server" && (i.printBanner(), i.printConfig({
1266
+ phpVersion: e.php || M,
1265
1267
  wpVersion: e.wp || "latest",
1266
- port: e.port || 9400,
1268
+ port: e.port ?? 9400,
1267
1269
  xdebug: !!e.xdebug,
1268
1270
  intl: !!e.intl,
1269
1271
  redis: !!e.redis,
@@ -1274,92 +1276,130 @@ async function Dt(e) {
1274
1276
  ],
1275
1277
  blueprint: typeof e.blueprint == "string" ? e.blueprint : void 0
1276
1278
  }));
1277
- const n = e.command === "server" ? e.port ?? 9400 : 0, l = new Pe();
1278
- let d = !1, x = !0;
1279
- const S = await ct({
1280
- port: n,
1279
+ const n = e.command === "server" ? e.port ?? 9400 : 0, l = new Te();
1280
+ let u = !1, w = !0;
1281
+ const S = await wt({
1282
+ port: e.port ? e.port : await ht(n) ? 0 : n,
1281
1283
  onBind: async (p, a) => {
1282
- const m = "127.0.0.1", y = `http://${m}:${a}`, D = e["site-url"] || y, R = Math.max(
1283
- Re().length - 1,
1284
- Bt
1285
- ), V = "-playground-cli-site-", T = await xt(V);
1286
- g.debug(`Native temp dir for VFS root: ${T.path}`);
1287
- const M = "WP Playground CLI - Listen for Xdebug", Y = ".playground-xdebug-root", q = u.join(process.cwd(), Y);
1288
- if (await Qe(q), e.xdebug && e.experimentalUnsafeIdeIntegration) {
1289
- await Xe(
1290
- T.path,
1291
- q,
1292
- process.platform
1293
- );
1294
- const h = {
1295
- hostPath: u.join(".", u.sep, Y),
1284
+ const m = "127.0.0.1", y = `http://${m}:${a}`, W = e["site-url"] || y, L = 6, z = "-playground-cli-site-", E = await kt(z);
1285
+ P.debug(`Native temp dir for VFS root: ${E.path}`);
1286
+ const B = "WP Playground CLI - Listen for Xdebug", G = ".playground-xdebug-root", U = d.join(process.cwd(), G);
1287
+ if (await Ke(U), e.xdebug) {
1288
+ const f = {
1289
+ hostPath: d.join(".", d.sep, G),
1296
1290
  vfsPath: "/"
1297
1291
  };
1298
- try {
1299
- await Ze(M, process.cwd());
1300
- const w = typeof e.xdebug == "object" ? e.xdebug : void 0, f = await Je({
1301
- name: M,
1302
- host: m,
1303
- port: a,
1304
- ides: e.experimentalUnsafeIdeIntegration,
1292
+ if (R.indexOf(
1293
+ e.php || M
1294
+ ) <= R.indexOf("8.5"))
1295
+ await oe(
1296
+ E.path,
1297
+ U,
1298
+ process.platform
1299
+ ), e.xdebug = et({
1305
1300
  cwd: process.cwd(),
1306
1301
  mounts: [
1307
- h,
1302
+ f,
1308
1303
  ...e["mount-before-install"] || [],
1309
1304
  ...e.mount || []
1310
1305
  ],
1311
- ideKey: w?.ideKey
1312
- }), b = e.experimentalUnsafeIdeIntegration, P = b.includes("vscode"), v = b.includes("phpstorm"), $ = Object.values(f);
1313
- console.log(""), $.length > 0 ? (console.log(k("Xdebug configured successfully")), console.log(
1314
- se("Updated IDE config: ") + $.join(" ")
1315
- ), console.log(
1316
- se("Playground source root: ") + ".playground-xdebug-root" + F(
1317
- Ct(
1306
+ pathSkippings: [
1307
+ "/dev/",
1308
+ "/home/",
1309
+ "/internal/",
1310
+ "/request/",
1311
+ "/proc/"
1312
+ ]
1313
+ }), console.log(I("Xdebug configured successfully")), console.log(
1314
+ O("Playground source root: ") + ".playground-xdebug-root" + C(
1315
+ le(
1318
1316
  " – you can set breakpoints and preview Playground's VFS structure in there."
1319
1317
  )
1320
1318
  )
1321
- )) : (console.log(k("Xdebug configuration failed.")), console.log(
1322
- "No IDE-specific project settings directory was found in the current working directory."
1323
- )), console.log(""), P && f.vscode && (console.log(k("VS Code / Cursor instructions:")), console.log(
1324
- " 1. Ensure you have installed an IDE extension for PHP Debugging"
1325
- ), console.log(
1326
- ` (The ${k("PHP Debug")} extension by ${k(
1327
- "Xdebug"
1328
- )} has been a solid option)`
1329
- ), console.log(
1330
- " 2. Open the Run and Debug panel on the left sidebar"
1331
- ), console.log(
1332
- ` 3. Select "${F(
1333
- M
1334
- )}" from the dropdown`
1335
- ), console.log(' 3. Click "start debugging"'), console.log(
1336
- " 5. Set a breakpoint. For example, in .playground-xdebug-root/wordpress/index.php"
1337
- ), console.log(
1338
- " 6. Visit Playground in your browser to hit the breakpoint"
1339
- ), v && console.log("")), v && f.phpstorm && (console.log(k("PhpStorm instructions:")), console.log(
1340
- ` 1. Choose "${F(
1341
- M
1342
- )}" debug configuration in the toolbar`
1343
- ), console.log(" 2. Click the debug button (bug icon)`"), console.log(
1344
- " 3. Set a breakpoint. For example, in .playground-xdebug-root/wordpress/index.php"
1345
- ), console.log(
1346
- " 4. Visit Playground in your browser to hit the breakpoint"
1347
- )), console.log("");
1348
- } catch (w) {
1349
- throw new Error("Could not configure Xdebug", {
1350
- cause: w
1351
- });
1319
+ );
1320
+ else if (e.experimentalUnsafeIdeIntegration) {
1321
+ await oe(
1322
+ E.path,
1323
+ U,
1324
+ process.platform
1325
+ );
1326
+ try {
1327
+ await tt(
1328
+ B,
1329
+ process.cwd()
1330
+ );
1331
+ const h = typeof e.xdebug == "object" ? e.xdebug : {}, b = await ot({
1332
+ name: B,
1333
+ host: m,
1334
+ port: a,
1335
+ ides: e.experimentalUnsafeIdeIntegration,
1336
+ cwd: process.cwd(),
1337
+ mounts: [
1338
+ f,
1339
+ ...e["mount-before-install"] || [],
1340
+ ...e.mount || []
1341
+ ],
1342
+ ideKey: h.ideKey || "WPPLAYGROUNDCLI"
1343
+ }), v = e.experimentalUnsafeIdeIntegration, x = v.includes("vscode"), T = v.includes("phpstorm"), X = Object.values(b);
1344
+ console.log(""), X.length > 0 ? (console.log(
1345
+ I("Xdebug configured successfully")
1346
+ ), console.log(
1347
+ O("Updated IDE config: ") + X.join(" ")
1348
+ ), console.log(
1349
+ O("Playground source root: ") + ".playground-xdebug-root" + C(
1350
+ le(
1351
+ " – you can set breakpoints and preview Playground's VFS structure in there."
1352
+ )
1353
+ )
1354
+ )) : (console.log(
1355
+ I("Xdebug configuration failed.")
1356
+ ), console.log(
1357
+ "No IDE-specific project settings directory was found in the current working directory."
1358
+ )), console.log(""), x && b.vscode && (console.log(
1359
+ I("VS Code / Cursor instructions:")
1360
+ ), console.log(
1361
+ " 1. Ensure you have installed an IDE extension for PHP Debugging"
1362
+ ), console.log(
1363
+ ` (The ${I("PHP Debug")} extension by ${I(
1364
+ "Xdebug"
1365
+ )} has been a solid option)`
1366
+ ), console.log(
1367
+ " 2. Open the Run and Debug panel on the left sidebar"
1368
+ ), console.log(
1369
+ ` 3. Select "${C(
1370
+ B
1371
+ )}" from the dropdown`
1372
+ ), console.log(' 3. Click "start debugging"'), console.log(
1373
+ " 5. Set a breakpoint. For example, in .playground-xdebug-root/wordpress/index.php"
1374
+ ), console.log(
1375
+ " 6. Visit Playground in your browser to hit the breakpoint"
1376
+ ), T && console.log("")), T && b.phpstorm && (console.log(I("PhpStorm instructions:")), console.log(
1377
+ ` 1. Choose "${C(
1378
+ B
1379
+ )}" debug configuration in the toolbar`
1380
+ ), console.log(
1381
+ " 2. Click the debug button (bug icon)`"
1382
+ ), console.log(
1383
+ " 3. Set a breakpoint. For example, in .playground-xdebug-root/wordpress/index.php"
1384
+ ), console.log(
1385
+ " 4. Visit Playground in your browser to hit the breakpoint"
1386
+ )), console.log("");
1387
+ } catch (h) {
1388
+ throw new Error("Could not configure Xdebug", {
1389
+ cause: h
1390
+ });
1391
+ }
1352
1392
  }
1353
1393
  }
1354
- const fe = u.dirname(T.path), we = 2 * 24 * 60 * 60 * 1e3;
1355
- It(
1356
- V,
1357
- we,
1358
- fe
1394
+ const Pe = d.dirname(E.path), ve = 2 * 24 * 60 * 60 * 1e3;
1395
+ Mt(
1396
+ z,
1397
+ ve,
1398
+ Pe
1359
1399
  );
1360
- const z = u.join(T.path, "internal");
1361
- _(z);
1362
- const ye = [
1400
+ const Q = d.join(E.path, "internal");
1401
+ j(Q);
1402
+ const Se = [
1363
1403
  "wordpress",
1364
1404
  "tools",
1365
1405
  // Note: These dirs are from Emscripten's "default dirs" list:
@@ -1371,91 +1411,91 @@ async function Dt(e) {
1371
1411
  "tmp",
1372
1412
  "home"
1373
1413
  ];
1374
- for (const h of ye) {
1375
- const w = (b) => b.vfsPath === `/${h}`;
1376
- if (!(e["mount-before-install"]?.some(w) || e.mount?.some(w))) {
1377
- const b = u.join(
1378
- T.path,
1379
- h
1414
+ for (const f of Se) {
1415
+ const g = (b) => b.vfsPath === `/${f}`;
1416
+ if (!(e["mount-before-install"]?.some(g) || e.mount?.some(g))) {
1417
+ const b = d.join(
1418
+ E.path,
1419
+ f
1380
1420
  );
1381
- _(b), e["mount-before-install"] === void 0 && (e["mount-before-install"] = []), e["mount-before-install"].unshift({
1382
- vfsPath: `/${h}`,
1421
+ j(b), e["mount-before-install"] === void 0 && (e["mount-before-install"] = []), e["mount-before-install"].unshift({
1422
+ vfsPath: `/${f}`,
1383
1423
  hostPath: b
1384
1424
  });
1385
1425
  }
1386
1426
  }
1387
1427
  if (e["mount-before-install"])
1388
- for (const h of e["mount-before-install"])
1389
- g.debug(
1390
- `Mount before WP install: ${h.vfsPath} -> ${h.hostPath}`
1428
+ for (const f of e["mount-before-install"])
1429
+ P.debug(
1430
+ `Mount before WP install: ${f.vfsPath} -> ${f.hostPath}`
1391
1431
  );
1392
1432
  if (e.mount)
1393
- for (const h of e.mount)
1394
- g.debug(
1395
- `Mount after WP install: ${h.vfsPath} -> ${h.hostPath}`
1433
+ for (const f of e.mount)
1434
+ P.debug(
1435
+ `Mount after WP install: ${f.vfsPath} -> ${f.hostPath}`
1396
1436
  );
1397
- let E;
1398
- e["experimental-blueprints-v2-runner"] ? E = new bt(e, {
1399
- siteUrl: D,
1400
- cliOutput: s
1401
- }) : (E = new St(e, {
1402
- siteUrl: D,
1403
- cliOutput: s
1404
- }), typeof e.blueprint == "string" && (e.blueprint = await yt({
1437
+ let k;
1438
+ e["experimental-blueprints-v2-runner"] ? k = new xt(e, {
1439
+ siteUrl: W,
1440
+ cliOutput: i
1441
+ }) : (k = new It(e, {
1442
+ siteUrl: W,
1443
+ cliOutput: i
1444
+ }), typeof e.blueprint == "string" && (e.blueprint = await St({
1405
1445
  sourceString: e.blueprint,
1406
1446
  blueprintMayReadAdjacentFiles: e["blueprint-may-read-adjacent-files"] === !0
1407
1447
  })));
1408
- let W = !1;
1409
- const B = async function() {
1410
- W || (W = !0, await Promise.all(
1411
- o.map(async (w) => {
1412
- await i.get(w)?.dispose(), await w.worker.terminate();
1448
+ let H = !1;
1449
+ const A = async function() {
1450
+ H || (H = !0, await Promise.all(
1451
+ r.map(async (g) => {
1452
+ await s.get(g)?.dispose(), await g.worker.terminate();
1413
1453
  })
1414
- ), p && await new Promise((w) => {
1415
- p.close(w), p.closeAllConnections();
1416
- }), await T.cleanup());
1454
+ ), p && await new Promise((g) => {
1455
+ p.close(g), p.closeAllConnections();
1456
+ }), await E.cleanup());
1417
1457
  };
1418
1458
  try {
1419
- const h = [], w = E.getWorkerType();
1420
- for (let f = 0; f < R; f++) {
1421
- const b = Wt(w, {
1422
- onExit: (P) => {
1423
- W || P === 0 && g.error(
1424
- `Worker ${f} exited with code ${P}
1459
+ const f = [], g = k.getWorkerType();
1460
+ for (let h = 0; h < L; h++) {
1461
+ const b = Ht(g, {
1462
+ onExit: (v) => {
1463
+ H || v === 0 && P.error(
1464
+ `Worker ${h} exited with code ${v}
1425
1465
  `
1426
1466
  );
1427
1467
  }
1428
1468
  }).then(
1429
- async (P) => {
1430
- o.push(P);
1431
- const v = await Lt(l), $ = await E.bootRequestHandler({
1432
- worker: P,
1433
- fileLockManagerPort: v,
1434
- nativeInternalDirPath: z
1469
+ async (v) => {
1470
+ r.push(v);
1471
+ const x = await Ft(l), T = await k.bootRequestHandler({
1472
+ worker: v,
1473
+ fileLockManagerPort: x,
1474
+ nativeInternalDirPath: Q
1435
1475
  });
1436
- return i.set(
1437
- P,
1438
- $
1439
- ), [P, $];
1476
+ return s.set(
1477
+ v,
1478
+ T
1479
+ ), [v, T];
1440
1480
  }
1441
1481
  );
1442
- h.push(b), f === 0 && await b;
1482
+ f.push(b), h === 0 && await b;
1443
1483
  }
1444
- await Promise.all(h), t = ve(
1445
- o.map(
1446
- (f) => i.get(f)
1484
+ await Promise.all(f), t = Ie(
1485
+ r.map(
1486
+ (h) => s.get(h)
1447
1487
  )
1448
1488
  );
1449
1489
  {
1450
- const f = new le(), b = f.port1, P = f.port2;
1451
- if (await Se(
1490
+ const h = new pe(), b = h.port1, v = h.port2;
1491
+ if (await ke(
1452
1492
  {
1453
1493
  applyPostInstallMountsToAllWorkers: async () => {
1454
1494
  await Promise.all(
1455
1495
  Array.from(
1456
- i.values()
1496
+ s.values()
1457
1497
  ).map(
1458
- (v) => v.mountAfterWordPressInstall(
1498
+ (x) => x.mountAfterWordPressInstall(
1459
1499
  e.mount || []
1460
1500
  )
1461
1501
  )
@@ -1464,68 +1504,68 @@ async function Dt(e) {
1464
1504
  },
1465
1505
  void 0,
1466
1506
  b
1467
- ), await E.bootWordPress(
1507
+ ), await k.bootWordPress(
1468
1508
  t,
1469
- P
1470
- ), b.close(), d = !0, !e["experimental-blueprints-v2-runner"]) {
1471
- const v = await E.compileInputBlueprint(
1509
+ v
1510
+ ), b.close(), u = !0, !e["experimental-blueprints-v2-runner"]) {
1511
+ const x = await k.compileInputBlueprint(
1472
1512
  e["additional-blueprint-steps"] || []
1473
1513
  );
1474
- v && await J(
1475
- v,
1514
+ x && await ee(
1515
+ x,
1476
1516
  t
1477
1517
  );
1478
1518
  }
1479
1519
  if (e.phpmyadmin && !await t.fileExists(
1480
- `${ee}/index.php`
1520
+ `${re}/index.php`
1481
1521
  )) {
1482
- const v = await et(), $ = await ae({ steps: v });
1483
- await J($, t);
1522
+ const x = await st(), T = await de({ steps: x });
1523
+ await ee(T, t);
1484
1524
  }
1485
1525
  if (e.command === "build-snapshot") {
1486
- await Ft(t, e.outfile), s.printStatus(`Exported to ${e.outfile}`), await B();
1526
+ await Ot(t, e.outfile), i.printStatus(`Exported to ${e.outfile}`), await A();
1487
1527
  return;
1488
1528
  } else if (e.command === "run-blueprint") {
1489
- s.finishProgress("Done"), await B();
1529
+ i.finishProgress("Done"), await A();
1490
1530
  return;
1491
1531
  }
1492
1532
  }
1493
- if (s.finishProgress(), s.printReady(y, R), e.phpmyadmin) {
1494
- const f = u.join(
1533
+ if (i.finishProgress(), i.printReady(y, L), e.phpmyadmin) {
1534
+ const h = d.join(
1495
1535
  e.phpmyadmin,
1496
- tt
1536
+ it
1497
1537
  );
1498
- s.printPhpMyAdminUrl(
1499
- new URL(f, y).toString()
1538
+ i.printPhpMyAdminUrl(
1539
+ new URL(h, y).toString()
1500
1540
  );
1501
1541
  }
1502
- return e.xdebug && e.experimentalDevtools && (await Ve({
1542
+ return e.xdebug && e.experimentalDevtools && (await Qe({
1503
1543
  phpInstance: t,
1504
1544
  phpRoot: "/wordpress"
1505
1545
  })).start(), {
1506
1546
  playground: t,
1507
1547
  server: p,
1508
1548
  serverUrl: y,
1509
- [Symbol.asyncDispose]: B,
1510
- [he]: {
1511
- workerThreadCount: R
1549
+ [Symbol.asyncDispose]: A,
1550
+ [ge]: {
1551
+ workerThreadCount: L
1512
1552
  }
1513
1553
  };
1514
- } catch (h) {
1554
+ } catch (f) {
1515
1555
  if (e.verbosity !== "debug")
1516
- throw h;
1517
- let w = "";
1518
- throw await t?.fileExists(G) && (w = await t.readFileAsText(G)), await B(), new Error(w, { cause: h });
1556
+ throw f;
1557
+ let g = "";
1558
+ throw await t?.fileExists(Z) && (g = await t.readFileAsText(Z)), await A(), new Error(g, { cause: f });
1519
1559
  }
1520
1560
  },
1521
1561
  async handleRequest(p) {
1522
- if (!d)
1523
- return X.forHttpCode(
1562
+ if (!u)
1563
+ return J.forHttpCode(
1524
1564
  502,
1525
1565
  "WordPress is not ready yet"
1526
1566
  );
1527
- if (x) {
1528
- x = !1;
1567
+ if (w) {
1568
+ w = !1;
1529
1569
  const m = {
1530
1570
  "Content-Type": ["text/plain"],
1531
1571
  "Content-Length": ["0"],
@@ -1535,11 +1575,11 @@ async function Dt(e) {
1535
1575
  "playground_auto_login_already_happened"
1536
1576
  ) && (m["Set-Cookie"] = [
1537
1577
  "playground_auto_login_already_happened=1; Max-Age=0; Expires=Thu, 01 Jan 1970 00:00:00 GMT; Path=/"
1538
- ]), X.fromPHPResponse(
1539
- new xe(302, m, new Uint8Array())
1578
+ ]), J.fromPHPResponse(
1579
+ new Me(302, m, new Uint8Array())
1540
1580
  );
1541
1581
  }
1542
- r && (p = {
1582
+ o && (p = {
1543
1583
  ...p,
1544
1584
  headers: {
1545
1585
  ...p.headers,
@@ -1548,29 +1588,31 @@ async function Dt(e) {
1548
1588
  // header with the cookies from our store. This avoids
1549
1589
  // getting into a strange state where both browser and
1550
1590
  // server are managing cookies.
1551
- cookie: r.getCookieRequestHeader()
1591
+ cookie: o.getCookieRequestHeader()
1552
1592
  }
1553
1593
  });
1554
1594
  const a = await t.requestStreamed(p);
1555
- if (r) {
1595
+ if (o) {
1556
1596
  const m = await a.headers;
1557
- r.rememberCookiesFromResponseHeaders(m), delete m["set-cookie"];
1597
+ o.rememberCookiesFromResponseHeaders(m), delete m["set-cookie"];
1558
1598
  }
1559
1599
  return a;
1560
1600
  }
1601
+ }).catch((p) => {
1602
+ i.printError(p.message), process.exit(1);
1561
1603
  });
1562
- return S && e.command === "start" && !e.skipBrowser && Ut(S.serverUrl), S;
1604
+ return S && e.command === "start" && !e.skipBrowser && Nt(S.serverUrl), S;
1563
1605
  }
1564
- function Rt(e) {
1606
+ function Ut(e) {
1565
1607
  let t = { ...e, command: "server" };
1566
- e.noAutoMount || (t.autoMount = u.resolve(process.cwd(), t.path ?? ""), t = ue(t), delete t.autoMount);
1567
- const r = ie(
1608
+ e.noAutoMount || (t.autoMount = d.resolve(process.cwd(), t.path ?? ""), t = he(t), delete t.autoMount);
1609
+ const o = ae(
1568
1610
  t["mount-before-install"] || [],
1569
1611
  "/wordpress"
1570
- ) || ie(t.mount || [], "/wordpress");
1571
- if (r)
1572
- console.log("Site files stored at:", r?.hostPath), e.reset && (console.log(""), console.log(
1573
- At(
1612
+ ) || ae(t.mount || [], "/wordpress");
1613
+ if (o)
1614
+ console.log("Site files stored at:", o?.hostPath), e.reset && (console.log(""), console.log(
1615
+ Wt(
1574
1616
  "This site is not managed by Playground CLI and cannot be reset."
1575
1617
  )
1576
1618
  ), console.log(
@@ -1579,15 +1621,15 @@ function Rt(e) {
1579
1621
  "You may still remove the site's directory manually if you wish."
1580
1622
  ), process.exit(1));
1581
1623
  else {
1582
- const o = t.autoMount || process.cwd(), i = Ke("sha256").update(o).digest("hex"), s = j.homedir(), n = u.join(
1583
- s,
1624
+ const r = t.autoMount || process.cwd(), s = rt("sha256").update(r).digest("hex"), i = q.homedir(), n = d.join(
1625
+ i,
1584
1626
  ".wordpress-playground/sites",
1585
- i
1627
+ s
1586
1628
  );
1587
- console.log("Site files stored at:", n), O(n) && e.reset && (console.log("Resetting site..."), ke(n, { recursive: !0 })), _(n, { recursive: !0 }), t["mount-before-install"] = [
1629
+ console.log("Site files stored at:", n), Y(n) && e.reset && (console.log("Resetting site..."), Re(n, { recursive: !0 })), j(n, { recursive: !0 }), t["mount-before-install"] = [
1588
1630
  ...t["mount-before-install"] || [],
1589
1631
  { vfsPath: "/wordpress", hostPath: n }
1590
- ], t.wordpressInstallMode = Me(n).length === 0 ? (
1632
+ ], t.wordpressInstallMode = We(n).length === 0 ? (
1591
1633
  // Only download WordPress on the first run when the site directory is still
1592
1634
  // empty.
1593
1635
  "download-and-install"
@@ -1598,55 +1640,55 @@ function Rt(e) {
1598
1640
  }
1599
1641
  return t;
1600
1642
  }
1601
- const H = new ot();
1602
- function Wt(e, { onExit: t } = {}) {
1603
- let r;
1604
- return e === "v1" ? r = new K(new URL("./worker-thread-v1.js", import.meta.url)) : r = new K(new URL("./worker-thread-v2.js", import.meta.url)), new Promise((o, i) => {
1605
- const s = H.claim();
1606
- r.once("message", function(l) {
1607
- l.command === "worker-script-initialized" && o({
1608
- processId: s,
1609
- worker: r,
1643
+ const _ = new xe();
1644
+ function Ht(e, { onExit: t } = {}) {
1645
+ let o;
1646
+ return e === "v1" ? o = new te(new URL("./worker-thread-v1.js", import.meta.url)) : o = new te(new URL("./worker-thread-v2.js", import.meta.url)), new Promise((r, s) => {
1647
+ const i = _.claim();
1648
+ o.once("message", function(l) {
1649
+ l.command === "worker-script-initialized" && r({
1650
+ processId: i,
1651
+ worker: o,
1610
1652
  phpPort: l.phpPort
1611
1653
  });
1612
- }), r.once("error", function(l) {
1613
- H.release(s), console.error(l);
1614
- const d = new Error(
1654
+ }), o.once("error", function(l) {
1655
+ _.release(i), console.error(l);
1656
+ const u = new Error(
1615
1657
  `Worker failed to load worker. ${l.message ? `Original error: ${l.message}` : ""}`
1616
1658
  );
1617
- i(d);
1659
+ s(u);
1618
1660
  });
1619
1661
  let n = !1;
1620
- r.once("spawn", () => {
1662
+ o.once("spawn", () => {
1621
1663
  n = !0;
1622
- }), r.once("exit", (l) => {
1623
- H.release(s), n || i(new Error(`Worker exited before spawning: ${l}`)), t?.(l);
1664
+ }), o.once("exit", (l) => {
1665
+ _.release(i), n || s(new Error(`Worker exited before spawning: ${l}`)), t?.(l);
1624
1666
  });
1625
1667
  });
1626
1668
  }
1627
- async function Lt(e) {
1628
- const { port1: t, port2: r } = new le();
1629
- return await Ie(e, t), r;
1669
+ async function Ft(e) {
1670
+ const { port1: t, port2: o } = new pe();
1671
+ return await Be(e, t), o;
1630
1672
  }
1631
- function Ut(e) {
1632
- const t = j.platform();
1633
- let r;
1673
+ function Nt(e) {
1674
+ const t = q.platform();
1675
+ let o;
1634
1676
  switch (t) {
1635
1677
  case "darwin":
1636
- r = `open "${e}"`;
1678
+ o = `open "${e}"`;
1637
1679
  break;
1638
1680
  case "win32":
1639
- r = `start "" "${e}"`;
1681
+ o = `start "" "${e}"`;
1640
1682
  break;
1641
1683
  default:
1642
- r = `xdg-open "${e}"`;
1684
+ o = `xdg-open "${e}"`;
1643
1685
  break;
1644
1686
  }
1645
- Ye(r, (o) => {
1646
- o && g.debug(`Could not open browser: ${o.message}`);
1687
+ me(o, (r) => {
1688
+ r && P.debug(`Could not open browser: ${r.message}`);
1647
1689
  });
1648
1690
  }
1649
- async function Ft(e, t) {
1691
+ async function Ot(e, t) {
1650
1692
  await e.run({
1651
1693
  code: `<?php
1652
1694
  $zip = new ZipArchive();
@@ -1667,17 +1709,17 @@ async function Ft(e, t) {
1667
1709
 
1668
1710
  `
1669
1711
  });
1670
- const r = await e.readFileAsBuffer("/tmp/build.zip");
1671
- c.writeFileSync(t, r);
1712
+ const o = await e.readFileAsBuffer("/tmp/build.zip");
1713
+ c.writeFileSync(t, o);
1672
1714
  }
1673
1715
  export {
1674
- me as L,
1675
- cr as a,
1676
- kt as b,
1677
- he as i,
1678
- pe as m,
1679
- mr as p,
1680
- Dt as r,
1681
- Wt as s
1716
+ be as L,
1717
+ yo as a,
1718
+ Dt as b,
1719
+ ge as i,
1720
+ we as m,
1721
+ bo as p,
1722
+ Lt as r,
1723
+ Ht as s
1682
1724
  };
1683
- //# sourceMappingURL=run-cli-C8e0UxH1.js.map
1725
+ //# sourceMappingURL=run-cli-Cv4FHhj_.js.map