@wp-playground/cli 3.1.11 → 3.1.13
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.
- package/cli.cjs +1 -1
- package/cli.cjs.map +1 -1
- package/cli.js +33 -3
- package/cli.js.map +1 -1
- package/ensure-jspi.d.ts +16 -0
- package/index.cjs +1 -1
- package/index.js +1 -1
- package/package.json +14 -15
- package/run-cli-BZUBWAe5.cjs +66 -0
- package/run-cli-BZUBWAe5.cjs.map +1 -0
- package/{run-cli-D-hJyCz2.js → run-cli-Dka9y1Ev.js} +400 -401
- package/run-cli-Dka9y1Ev.js.map +1 -0
- package/sqlite-database-integration.zip +0 -0
- package/worker-thread-v1.cjs +1 -1
- package/worker-thread-v1.js +1 -1
- package/worker-thread-v2.cjs +1 -1
- package/worker-thread-v2.js +1 -1
- package/run-cli-D-hJyCz2.js.map +0 -1
- package/run-cli-DRUR5ErF.cjs +0 -66
- package/run-cli-DRUR5ErF.cjs.map +0 -1
|
@@ -1,31 +1,30 @@
|
|
|
1
|
-
import { logger as
|
|
2
|
-
import { consumeAPI as
|
|
3
|
-
import { resolveRemoteBlueprint as
|
|
4
|
-
import { zipDirectory as
|
|
5
|
-
import
|
|
6
|
-
import { MessageChannel as
|
|
7
|
-
import { createNodeFsMountHandler as
|
|
8
|
-
import d, { basename as
|
|
9
|
-
import { exec as
|
|
10
|
-
import { promisify as
|
|
11
|
-
import
|
|
12
|
-
import { Readable as
|
|
1
|
+
import { logger as w, LogSeverity as O, errorLogPath as te } from "@php-wasm/logger";
|
|
2
|
+
import { consumeAPI as me, ProcessIdAllocator as Te, SupportedPHPVersions as W, printDebugDetails as Ie, HttpCookieStore as ke, FileLockManagerInMemory as Me, StreamedPHPResponse as re, createObjectPoolProxy as Ce, exposeAPI as Ae, PHPResponse as Be, exposeSyncAPI as Re } from "@php-wasm/universal";
|
|
3
|
+
import { resolveRemoteBlueprint as De, resolveRuntimeConfiguration as oe, compileBlueprintV1 as fe, isBlueprintBundle as We, runBlueprintV1Steps as se } from "@wp-playground/blueprints";
|
|
4
|
+
import { zipDirectory as Le, RecommendedPHPVersion as C } from "@wp-playground/common";
|
|
5
|
+
import p, { existsSync as z, rmdirSync as _e, mkdirSync as Y, readdirSync as Ue } from "fs";
|
|
6
|
+
import { MessageChannel as he, Worker as ie } from "worker_threads";
|
|
7
|
+
import { createNodeFsMountHandler as He } from "@php-wasm/node";
|
|
8
|
+
import d, { basename as D, join as we } from "path";
|
|
9
|
+
import { exec as ye } from "child_process";
|
|
10
|
+
import { promisify as Ne } from "util";
|
|
11
|
+
import be from "express";
|
|
12
|
+
import { Readable as Oe } from "stream";
|
|
13
13
|
import { pipeline as Fe } from "stream/promises";
|
|
14
|
-
import
|
|
15
|
-
import { NodeJsFilesystem as
|
|
16
|
-
import { EmscriptenDownloadMonitor as
|
|
17
|
-
import { resolveWordPressRelease as
|
|
14
|
+
import je from "yargs";
|
|
15
|
+
import { NodeJsFilesystem as Ve, OverlayFilesystem as Ye, InMemoryFilesystem as qe, ZipFilesystem as ze } from "@wp-playground/storage";
|
|
16
|
+
import { EmscriptenDownloadMonitor as Ge, ProgressTracker as Qe } from "@php-wasm/progress";
|
|
17
|
+
import { resolveWordPressRelease as Xe } from "@wp-playground/wordpress";
|
|
18
18
|
import $ from "fs-extra";
|
|
19
|
-
import { createRequire as
|
|
19
|
+
import { createRequire as Ze } from "module";
|
|
20
20
|
import G from "os";
|
|
21
|
-
import { startBridge as
|
|
22
|
-
import { dir as
|
|
23
|
-
import
|
|
24
|
-
import {
|
|
25
|
-
import {
|
|
26
|
-
import {
|
|
27
|
-
|
|
28
|
-
function O(e) {
|
|
21
|
+
import { startBridge as Je } from "@php-wasm/xdebug-bridge";
|
|
22
|
+
import { dir as Ke, setGracefulCleanup as et } from "tmp-promise";
|
|
23
|
+
import { removeTempDirSymlink as tt, createTempDirSymlink as ne, makeXdebugConfig as rt, clearXdebugIDEConfig as ot, addXdebugIDEConfig as st } from "@php-wasm/cli-util";
|
|
24
|
+
import { createHash as it } from "crypto";
|
|
25
|
+
import { PHPMYADMIN_INSTALL_PATH as ae, getPhpMyAdminInstallSteps as nt, PHPMYADMIN_ENTRY_PATH as at } from "@wp-playground/tools";
|
|
26
|
+
import { jspi as le } from "wasm-feature-detect";
|
|
27
|
+
function F(e) {
|
|
29
28
|
const t = [];
|
|
30
29
|
for (const r of e) {
|
|
31
30
|
const o = r.split(":");
|
|
@@ -41,7 +40,7 @@ function O(e) {
|
|
|
41
40
|
}
|
|
42
41
|
return t;
|
|
43
42
|
}
|
|
44
|
-
function
|
|
43
|
+
function ue(e) {
|
|
45
44
|
if (e.length % 2 !== 0)
|
|
46
45
|
throw new Error("Invalid mount format. Expected: /host/path /vfs/path");
|
|
47
46
|
const t = [];
|
|
@@ -56,14 +55,14 @@ function ne(e) {
|
|
|
56
55
|
}
|
|
57
56
|
return t;
|
|
58
57
|
}
|
|
59
|
-
async function
|
|
58
|
+
async function wr(e, t) {
|
|
60
59
|
for (const r of t)
|
|
61
60
|
await e.mount(
|
|
62
61
|
r.vfsPath,
|
|
63
|
-
|
|
62
|
+
He(r.hostPath)
|
|
64
63
|
);
|
|
65
64
|
}
|
|
66
|
-
const
|
|
65
|
+
const de = {
|
|
67
66
|
step: "runPHP",
|
|
68
67
|
code: {
|
|
69
68
|
filename: "activate-theme.php",
|
|
@@ -82,7 +81,7 @@ const ae = {
|
|
|
82
81
|
`
|
|
83
82
|
}
|
|
84
83
|
};
|
|
85
|
-
function
|
|
84
|
+
function ge(e) {
|
|
86
85
|
const t = e.autoMount, r = [...e.mount || []], o = [...e["mount-before-install"] || []], s = {
|
|
87
86
|
...e,
|
|
88
87
|
mount: r,
|
|
@@ -91,21 +90,21 @@ function we(e) {
|
|
|
91
90
|
...e["additional-blueprint-steps"] || []
|
|
92
91
|
]
|
|
93
92
|
};
|
|
94
|
-
if (
|
|
95
|
-
const
|
|
93
|
+
if (ct(t)) {
|
|
94
|
+
const a = `/wordpress/wp-content/plugins/${D(t)}`;
|
|
96
95
|
r.push({
|
|
97
96
|
hostPath: t,
|
|
98
|
-
vfsPath:
|
|
97
|
+
vfsPath: a,
|
|
99
98
|
autoMounted: !0
|
|
100
99
|
}), s["additional-blueprint-steps"].push({
|
|
101
100
|
step: "activatePlugin",
|
|
102
|
-
pluginPath: `/wordpress/wp-content/plugins/${
|
|
101
|
+
pluginPath: `/wordpress/wp-content/plugins/${D(t)}`
|
|
103
102
|
});
|
|
104
|
-
} else if (
|
|
105
|
-
const i =
|
|
103
|
+
} else if (dt(t)) {
|
|
104
|
+
const i = D(t), a = `/wordpress/wp-content/themes/${i}`;
|
|
106
105
|
r.push({
|
|
107
106
|
hostPath: t,
|
|
108
|
-
vfsPath:
|
|
107
|
+
vfsPath: a,
|
|
109
108
|
autoMounted: !0
|
|
110
109
|
}), s["additional-blueprint-steps"].push(
|
|
111
110
|
e["experimental-blueprints-v2-runner"] ? {
|
|
@@ -116,40 +115,40 @@ function we(e) {
|
|
|
116
115
|
themeFolderName: i
|
|
117
116
|
}
|
|
118
117
|
);
|
|
119
|
-
} else if (
|
|
120
|
-
const i =
|
|
121
|
-
for (const
|
|
122
|
-
|
|
123
|
-
hostPath: `${t}/${
|
|
124
|
-
vfsPath: `/wordpress/wp-content/${
|
|
118
|
+
} else if (ut(t)) {
|
|
119
|
+
const i = p.readdirSync(t);
|
|
120
|
+
for (const a of i)
|
|
121
|
+
a !== "index.php" && r.push({
|
|
122
|
+
hostPath: `${t}/${a}`,
|
|
123
|
+
vfsPath: `/wordpress/wp-content/${a}`,
|
|
125
124
|
autoMounted: !0
|
|
126
125
|
});
|
|
127
|
-
s["additional-blueprint-steps"].push(
|
|
128
|
-
} else
|
|
126
|
+
s["additional-blueprint-steps"].push(de);
|
|
127
|
+
} else lt(t) && (o.push({
|
|
129
128
|
hostPath: t,
|
|
130
129
|
vfsPath: "/wordpress",
|
|
131
130
|
autoMounted: !0
|
|
132
|
-
}), s.mode = "apply-to-existing-site", s["additional-blueprint-steps"].push(
|
|
131
|
+
}), s.mode = "apply-to-existing-site", s["additional-blueprint-steps"].push(de), s.wordpressInstallMode || (s.wordpressInstallMode = "install-from-existing-files-if-needed"));
|
|
133
132
|
return s;
|
|
134
133
|
}
|
|
135
|
-
function
|
|
136
|
-
const t =
|
|
134
|
+
function lt(e) {
|
|
135
|
+
const t = p.readdirSync(e);
|
|
137
136
|
return t.includes("wp-admin") && t.includes("wp-includes") && t.includes("wp-content");
|
|
138
137
|
}
|
|
139
|
-
function
|
|
140
|
-
const t =
|
|
138
|
+
function ut(e) {
|
|
139
|
+
const t = p.readdirSync(e);
|
|
141
140
|
return t.includes("themes") || t.includes("plugins") || t.includes("mu-plugins") || t.includes("uploads");
|
|
142
141
|
}
|
|
143
|
-
function
|
|
144
|
-
if (!
|
|
142
|
+
function dt(e) {
|
|
143
|
+
if (!p.readdirSync(e).includes("style.css"))
|
|
145
144
|
return !1;
|
|
146
|
-
const r =
|
|
145
|
+
const r = p.readFileSync(we(e, "style.css"), "utf8");
|
|
147
146
|
return !!/^(?:[ \t]*<\?php)?[ \t/*#@]*Theme Name:(.*)$/im.exec(r);
|
|
148
147
|
}
|
|
149
|
-
function
|
|
150
|
-
const t =
|
|
148
|
+
function ct(e) {
|
|
149
|
+
const t = p.readdirSync(e), r = /^(?:[ \t]*<\?php)?[ \t/*#@]*Plugin Name:(.*)$/im;
|
|
151
150
|
return !!t.filter((s) => s.endsWith(".php")).find((s) => {
|
|
152
|
-
const i =
|
|
151
|
+
const i = p.readFileSync(we(e, s), "utf8");
|
|
153
152
|
return !!r.exec(i);
|
|
154
153
|
});
|
|
155
154
|
}
|
|
@@ -167,7 +166,7 @@ function pt(e) {
|
|
|
167
166
|
}
|
|
168
167
|
return t;
|
|
169
168
|
}
|
|
170
|
-
function
|
|
169
|
+
function mt(e) {
|
|
171
170
|
if (e.length % 2 !== 0)
|
|
172
171
|
throw new Error(
|
|
173
172
|
"Invalid boolean constant definition format. Expected pairs of NAME value"
|
|
@@ -188,7 +187,7 @@ function ct(e) {
|
|
|
188
187
|
}
|
|
189
188
|
return t;
|
|
190
189
|
}
|
|
191
|
-
function
|
|
190
|
+
function ft(e) {
|
|
192
191
|
if (e.length % 2 !== 0)
|
|
193
192
|
throw new Error(
|
|
194
193
|
"Invalid number constant definition format. Expected pairs of NAME value"
|
|
@@ -208,59 +207,59 @@ function mt(e) {
|
|
|
208
207
|
return t;
|
|
209
208
|
}
|
|
210
209
|
function ht(e = {}, t = {}, r = {}) {
|
|
211
|
-
const o = {}, s = /* @__PURE__ */ new Set(), i = (
|
|
212
|
-
for (const u in
|
|
210
|
+
const o = {}, s = /* @__PURE__ */ new Set(), i = (a, l) => {
|
|
211
|
+
for (const u in a) {
|
|
213
212
|
if (s.has(u))
|
|
214
213
|
throw new Error(
|
|
215
214
|
`Constant "${u}" is defined multiple times across different --define-${l} flags`
|
|
216
215
|
);
|
|
217
|
-
s.add(u), o[u] =
|
|
216
|
+
s.add(u), o[u] = a[u];
|
|
218
217
|
}
|
|
219
218
|
};
|
|
220
219
|
return i(e, "string"), i(t, "bool"), i(r, "number"), o;
|
|
221
220
|
}
|
|
222
|
-
function
|
|
221
|
+
function Q(e) {
|
|
223
222
|
return ht(
|
|
224
223
|
e.define,
|
|
225
224
|
e["define-bool"],
|
|
226
225
|
e["define-number"]
|
|
227
226
|
);
|
|
228
227
|
}
|
|
229
|
-
const
|
|
230
|
-
function
|
|
228
|
+
const wt = Ne(ye);
|
|
229
|
+
function yt(e) {
|
|
231
230
|
return new Promise((t) => {
|
|
232
231
|
if (e === 0) return t(!1);
|
|
233
|
-
const r =
|
|
232
|
+
const r = be().listen(e);
|
|
234
233
|
r.once("listening", () => r.close(() => t(!1))), r.once(
|
|
235
234
|
"error",
|
|
236
235
|
(o) => t(o.code === "EADDRINUSE")
|
|
237
236
|
);
|
|
238
237
|
});
|
|
239
238
|
}
|
|
240
|
-
async function
|
|
241
|
-
const t =
|
|
239
|
+
async function bt(e) {
|
|
240
|
+
const t = be(), r = await new Promise((a, l) => {
|
|
242
241
|
const u = t.listen(e.port, () => {
|
|
243
|
-
const
|
|
244
|
-
|
|
242
|
+
const y = u.address();
|
|
243
|
+
y === null || typeof y == "string" ? l(new Error("Server address is not available")) : a(u);
|
|
245
244
|
}).once("error", l);
|
|
246
245
|
});
|
|
247
|
-
t.use("/", async (
|
|
246
|
+
t.use("/", async (a, l) => {
|
|
248
247
|
try {
|
|
249
248
|
const u = {
|
|
250
|
-
url:
|
|
251
|
-
headers:
|
|
252
|
-
method:
|
|
253
|
-
body: await
|
|
254
|
-
},
|
|
255
|
-
await
|
|
249
|
+
url: a.url,
|
|
250
|
+
headers: St(a),
|
|
251
|
+
method: a.method,
|
|
252
|
+
body: await Pt(a)
|
|
253
|
+
}, y = await e.handleRequest(u);
|
|
254
|
+
await gt(y, l);
|
|
256
255
|
} catch (u) {
|
|
257
|
-
|
|
256
|
+
w.error(u), l.headersSent || (l.statusCode = 500, l.end("Internal Server Error"));
|
|
258
257
|
}
|
|
259
258
|
});
|
|
260
259
|
const s = r.address().port, i = process.env.CODESPACE_NAME;
|
|
261
|
-
return i &&
|
|
260
|
+
return i && vt(s, i), await e.onBind(r, s);
|
|
262
261
|
}
|
|
263
|
-
async function
|
|
262
|
+
async function gt(e, t) {
|
|
264
263
|
const [r, o] = await Promise.all([
|
|
265
264
|
e.headers,
|
|
266
265
|
e.httpStatusCode
|
|
@@ -268,16 +267,16 @@ async function bt(e, t) {
|
|
|
268
267
|
t.statusCode = o;
|
|
269
268
|
for (const i in r)
|
|
270
269
|
t.setHeader(i, r[i]);
|
|
271
|
-
const s =
|
|
270
|
+
const s = Oe.fromWeb(e.stdout);
|
|
272
271
|
try {
|
|
273
272
|
await Fe(s, t);
|
|
274
273
|
} catch (i) {
|
|
275
|
-
if (i instanceof Error && "code" in i && i.code === "ERR_STREAM_PREMATURE_CLOSE")
|
|
274
|
+
if (i instanceof Error && "code" in i && (i.code === "ERR_STREAM_PREMATURE_CLOSE" || i.code === "ERR_STREAM_UNABLE_TO_PIPE"))
|
|
276
275
|
return;
|
|
277
276
|
throw i;
|
|
278
277
|
}
|
|
279
278
|
}
|
|
280
|
-
const
|
|
279
|
+
const Pt = async (e) => await new Promise((t) => {
|
|
281
280
|
const r = [];
|
|
282
281
|
e.on("data", (o) => {
|
|
283
282
|
r.push(o);
|
|
@@ -285,39 +284,39 @@ const gt = async (e) => await new Promise((t) => {
|
|
|
285
284
|
t(new Uint8Array(Buffer.concat(r)));
|
|
286
285
|
});
|
|
287
286
|
});
|
|
288
|
-
async function
|
|
289
|
-
|
|
287
|
+
async function vt(e, t) {
|
|
288
|
+
w.log(`Publishing port ${e}...`);
|
|
290
289
|
const r = `gh codespace ports visibility ${e}:public -c ${t}`;
|
|
291
290
|
for (let o = 0; o < 10; o++)
|
|
292
291
|
try {
|
|
293
|
-
await
|
|
292
|
+
await wt(r);
|
|
294
293
|
return;
|
|
295
294
|
} catch {
|
|
296
295
|
await new Promise((s) => setTimeout(s, 2e3));
|
|
297
296
|
}
|
|
298
297
|
}
|
|
299
|
-
const
|
|
298
|
+
const St = (e) => {
|
|
300
299
|
const t = {};
|
|
301
300
|
if (e.rawHeaders && e.rawHeaders.length)
|
|
302
301
|
for (let r = 0; r < e.rawHeaders.length; r += 2)
|
|
303
302
|
t[e.rawHeaders[r].toLowerCase()] = e.rawHeaders[r + 1];
|
|
304
303
|
return t;
|
|
305
304
|
};
|
|
306
|
-
function
|
|
305
|
+
function xt(e) {
|
|
307
306
|
return /^latest$|^trunk$|^nightly$|^(?:(\d+)\.(\d+)(?:\.(\d+))?)((?:-beta(?:\d+)?)|(?:-RC(?:\d+)?))?$/.test(e);
|
|
308
307
|
}
|
|
309
|
-
async function
|
|
308
|
+
async function Et({
|
|
310
309
|
sourceString: e,
|
|
311
310
|
blueprintMayReadAdjacentFiles: t
|
|
312
311
|
}) {
|
|
313
312
|
if (!e)
|
|
314
313
|
return;
|
|
315
314
|
if (e.startsWith("http://") || e.startsWith("https://"))
|
|
316
|
-
return await
|
|
315
|
+
return await De(e);
|
|
317
316
|
let r = d.resolve(process.cwd(), e);
|
|
318
|
-
if (!
|
|
317
|
+
if (!p.existsSync(r))
|
|
319
318
|
throw new Error(`Blueprint file does not exist: ${r}`);
|
|
320
|
-
const o =
|
|
319
|
+
const o = p.statSync(r);
|
|
321
320
|
if (o.isDirectory() && (r = d.join(r, "blueprint.json")), !o.isFile() && o.isSymbolicLink())
|
|
322
321
|
throw new Error(
|
|
323
322
|
`Blueprint path is neither a file nor a directory: ${r}`
|
|
@@ -325,11 +324,11 @@ async function xt({
|
|
|
325
324
|
const s = d.extname(r);
|
|
326
325
|
switch (s) {
|
|
327
326
|
case ".zip":
|
|
328
|
-
return
|
|
329
|
-
|
|
327
|
+
return ze.fromArrayBuffer(
|
|
328
|
+
p.readFileSync(r).buffer
|
|
330
329
|
);
|
|
331
330
|
case ".json": {
|
|
332
|
-
const i =
|
|
331
|
+
const i = p.readFileSync(r, "utf-8");
|
|
333
332
|
try {
|
|
334
333
|
JSON.parse(i);
|
|
335
334
|
} catch {
|
|
@@ -337,9 +336,9 @@ async function xt({
|
|
|
337
336
|
`Blueprint file at ${r} is not a valid JSON file`
|
|
338
337
|
);
|
|
339
338
|
}
|
|
340
|
-
const
|
|
341
|
-
return new
|
|
342
|
-
new
|
|
339
|
+
const a = d.dirname(r), l = new Ve(a);
|
|
340
|
+
return new Ye([
|
|
341
|
+
new qe({
|
|
343
342
|
"blueprint.json": i
|
|
344
343
|
}),
|
|
345
344
|
/**
|
|
@@ -365,7 +364,7 @@ You can allow this Blueprint to read files from the same parent directory by exp
|
|
|
365
364
|
);
|
|
366
365
|
}
|
|
367
366
|
}
|
|
368
|
-
class
|
|
367
|
+
class $t {
|
|
369
368
|
constructor(t, r) {
|
|
370
369
|
this.args = t, this.siteUrl = r.siteUrl, this.phpVersion = t.php, this.cliOutput = r.cliOutput;
|
|
371
370
|
}
|
|
@@ -386,7 +385,7 @@ class Et {
|
|
|
386
385
|
fileLockManagerPort: r,
|
|
387
386
|
nativeInternalDirPath: o
|
|
388
387
|
}) {
|
|
389
|
-
const s =
|
|
388
|
+
const s = me(t.phpPort);
|
|
390
389
|
await s.useFileLockManager(r);
|
|
391
390
|
const i = {
|
|
392
391
|
...this.args,
|
|
@@ -401,17 +400,17 @@ class Et {
|
|
|
401
400
|
nativeInternalDirPath: o,
|
|
402
401
|
mountsBeforeWpInstall: this.args["mount-before-install"] || [],
|
|
403
402
|
mountsAfterWpInstall: this.args.mount || [],
|
|
404
|
-
constants:
|
|
403
|
+
constants: Q(this.args)
|
|
405
404
|
};
|
|
406
405
|
return await s.bootWorker(i), s;
|
|
407
406
|
}
|
|
408
407
|
}
|
|
409
408
|
const q = d.join(G.homedir(), ".wordpress-playground");
|
|
410
|
-
async function
|
|
409
|
+
async function Tt() {
|
|
411
410
|
const e = typeof __dirname < "u" ? __dirname : import.meta.dirname;
|
|
412
411
|
let t = d.join(e, "sqlite-database-integration.zip");
|
|
413
412
|
if (!$.existsSync(t)) {
|
|
414
|
-
const r =
|
|
413
|
+
const r = Ze(import.meta.url), o = d.dirname(
|
|
415
414
|
r.resolve("@wp-playground/wordpress-builds/package.json")
|
|
416
415
|
);
|
|
417
416
|
t = d.join(
|
|
@@ -423,29 +422,29 @@ async function $t() {
|
|
|
423
422
|
}
|
|
424
423
|
return new File([await $.readFile(t)], d.basename(t));
|
|
425
424
|
}
|
|
426
|
-
async function
|
|
425
|
+
async function It(e, t, r) {
|
|
427
426
|
const o = d.join(q, t);
|
|
428
|
-
return $.existsSync(o) || ($.ensureDirSync(q), await
|
|
427
|
+
return $.existsSync(o) || ($.ensureDirSync(q), await kt(e, o, r)), Pe(o);
|
|
429
428
|
}
|
|
430
|
-
async function
|
|
431
|
-
const s = (await r.monitorFetch(fetch(e))).body.getReader(), i = `${t}.partial`,
|
|
429
|
+
async function kt(e, t, r) {
|
|
430
|
+
const s = (await r.monitorFetch(fetch(e))).body.getReader(), i = `${t}.partial`, a = $.createWriteStream(i);
|
|
432
431
|
for (; ; ) {
|
|
433
432
|
const { done: l, value: u } = await s.read();
|
|
434
|
-
if (u &&
|
|
433
|
+
if (u && a.write(u), l)
|
|
435
434
|
break;
|
|
436
435
|
}
|
|
437
|
-
|
|
438
|
-
|
|
436
|
+
a.close(), a.closed || await new Promise((l, u) => {
|
|
437
|
+
a.on("finish", () => {
|
|
439
438
|
$.renameSync(i, t), l(null);
|
|
440
|
-
}),
|
|
441
|
-
$.removeSync(i), u(
|
|
439
|
+
}), a.on("error", (y) => {
|
|
440
|
+
$.removeSync(i), u(y);
|
|
442
441
|
});
|
|
443
442
|
});
|
|
444
443
|
}
|
|
445
|
-
function
|
|
446
|
-
return new File([$.readFileSync(e)],
|
|
444
|
+
function Pe(e, t) {
|
|
445
|
+
return new File([$.readFileSync(e)], D(e));
|
|
447
446
|
}
|
|
448
|
-
class
|
|
447
|
+
class Mt {
|
|
449
448
|
constructor(t, r) {
|
|
450
449
|
this.args = t, this.siteUrl = r.siteUrl, this.cliOutput = r.cliOutput;
|
|
451
450
|
}
|
|
@@ -454,33 +453,33 @@ class kt {
|
|
|
454
453
|
}
|
|
455
454
|
async bootWordPress(t, r) {
|
|
456
455
|
let o, s, i;
|
|
457
|
-
const
|
|
456
|
+
const a = new Ge();
|
|
458
457
|
if (this.args.wordpressInstallMode === "download-and-install") {
|
|
459
|
-
let
|
|
460
|
-
|
|
461
|
-
if (
|
|
458
|
+
let y = !1;
|
|
459
|
+
a.addEventListener("progress", (E) => {
|
|
460
|
+
if (y)
|
|
462
461
|
return;
|
|
463
|
-
const { loaded:
|
|
464
|
-
Math.min(100, 100 *
|
|
462
|
+
const { loaded: c, total: n } = E.detail, m = Math.floor(
|
|
463
|
+
Math.min(100, 100 * c / n)
|
|
465
464
|
);
|
|
466
|
-
|
|
465
|
+
y = m === 100, this.cliOutput.updateProgress(
|
|
467
466
|
"Downloading WordPress",
|
|
468
467
|
m
|
|
469
468
|
);
|
|
470
|
-
}), o = await
|
|
469
|
+
}), o = await Xe(this.args.wp), i = d.join(
|
|
471
470
|
q,
|
|
472
471
|
`prebuilt-wp-content-for-wp-${o.version}.zip`
|
|
473
|
-
), s =
|
|
472
|
+
), s = p.existsSync(i) ? Pe(i) : await It(
|
|
474
473
|
o.releaseUrl,
|
|
475
474
|
`${o.version}.zip`,
|
|
476
|
-
|
|
477
|
-
),
|
|
475
|
+
a
|
|
476
|
+
), w.debug(
|
|
478
477
|
`Resolved WordPress release URL: ${o?.releaseUrl}`
|
|
479
478
|
);
|
|
480
479
|
}
|
|
481
480
|
let l;
|
|
482
|
-
this.args.skipSqliteSetup ? (
|
|
483
|
-
const u = await
|
|
481
|
+
this.args.skipSqliteSetup ? (w.debug("Skipping SQLite integration plugin setup..."), l = void 0) : (this.cliOutput.updateProgress("Preparing SQLite database"), l = await Tt()), this.cliOutput.updateProgress("Booting WordPress");
|
|
482
|
+
const u = await oe(
|
|
484
483
|
this.getEffectiveBlueprint()
|
|
485
484
|
);
|
|
486
485
|
return await t.bootWordPress(
|
|
@@ -490,14 +489,14 @@ class kt {
|
|
|
490
489
|
wordpressInstallMode: this.args.wordpressInstallMode || "download-and-install",
|
|
491
490
|
wordPressZip: s && await s.arrayBuffer(),
|
|
492
491
|
sqliteIntegrationPluginZip: await l?.arrayBuffer(),
|
|
493
|
-
constants:
|
|
492
|
+
constants: Q(this.args)
|
|
494
493
|
},
|
|
495
494
|
r
|
|
496
|
-
), i && !this.args["mount-before-install"] && !
|
|
495
|
+
), i && !this.args["mount-before-install"] && !p.existsSync(i) && (this.cliOutput.updateProgress("Caching WordPress for next boot"), p.writeFileSync(
|
|
497
496
|
i,
|
|
498
497
|
// Comlink proxy is not assignable to UniversalPHP but
|
|
499
498
|
// proxies all method calls transparently at runtime.
|
|
500
|
-
await
|
|
499
|
+
await Le(
|
|
501
500
|
t,
|
|
502
501
|
"/wordpress"
|
|
503
502
|
)
|
|
@@ -508,11 +507,11 @@ class kt {
|
|
|
508
507
|
fileLockManagerPort: r,
|
|
509
508
|
nativeInternalDirPath: o
|
|
510
509
|
}) {
|
|
511
|
-
const s =
|
|
510
|
+
const s = me(
|
|
512
511
|
t.phpPort
|
|
513
512
|
);
|
|
514
513
|
await s.isConnected();
|
|
515
|
-
const i = await
|
|
514
|
+
const i = await oe(
|
|
516
515
|
this.getEffectiveBlueprint()
|
|
517
516
|
);
|
|
518
517
|
return await s.useFileLockManager(r), await s.bootRequestHandler({
|
|
@@ -532,22 +531,22 @@ class kt {
|
|
|
532
531
|
}), await s.isReady(), s;
|
|
533
532
|
}
|
|
534
533
|
async compileInputBlueprint(t) {
|
|
535
|
-
const r = this.getEffectiveBlueprint(), o = new
|
|
534
|
+
const r = this.getEffectiveBlueprint(), o = new Qe();
|
|
536
535
|
let s = "", i = !1;
|
|
537
|
-
return o.addEventListener("progress", (
|
|
536
|
+
return o.addEventListener("progress", (a) => {
|
|
538
537
|
if (i)
|
|
539
538
|
return;
|
|
540
|
-
i =
|
|
541
|
-
const l = Math.floor(
|
|
542
|
-
s =
|
|
543
|
-
}), await
|
|
539
|
+
i = a.detail.progress === 100;
|
|
540
|
+
const l = Math.floor(a.detail.progress);
|
|
541
|
+
s = a.detail.caption || s || "Running Blueprint", this.cliOutput.updateProgress(s.trim(), l);
|
|
542
|
+
}), await fe(r, {
|
|
544
543
|
progress: o,
|
|
545
544
|
additionalSteps: t
|
|
546
545
|
});
|
|
547
546
|
}
|
|
548
547
|
getEffectiveBlueprint() {
|
|
549
548
|
const t = this.args.blueprint;
|
|
550
|
-
return
|
|
549
|
+
return We(t) ? t : {
|
|
551
550
|
login: this.args.login,
|
|
552
551
|
...t || {},
|
|
553
552
|
preferredVersions: {
|
|
@@ -558,8 +557,8 @@ class kt {
|
|
|
558
557
|
};
|
|
559
558
|
}
|
|
560
559
|
}
|
|
561
|
-
async function
|
|
562
|
-
const o = `${d.basename(process.argv0)}${e}${process.pid}-`, s = await
|
|
560
|
+
async function Ct(e, t = !0) {
|
|
561
|
+
const o = `${d.basename(process.argv0)}${e}${process.pid}-`, s = await Ke({
|
|
563
562
|
prefix: o,
|
|
564
563
|
/*
|
|
565
564
|
* Allow recursive cleanup on process exit.
|
|
@@ -571,43 +570,43 @@ async function Mt(e, t = !0) {
|
|
|
571
570
|
*/
|
|
572
571
|
unsafeCleanup: !0
|
|
573
572
|
});
|
|
574
|
-
return t &&
|
|
573
|
+
return t && et(), s;
|
|
575
574
|
}
|
|
576
|
-
async function
|
|
577
|
-
const s = (await
|
|
575
|
+
async function At(e, t, r) {
|
|
576
|
+
const s = (await Bt(
|
|
578
577
|
e,
|
|
579
578
|
t,
|
|
580
579
|
r
|
|
581
580
|
)).map(
|
|
582
|
-
(i) => new Promise((
|
|
583
|
-
|
|
584
|
-
l ?
|
|
581
|
+
(i) => new Promise((a) => {
|
|
582
|
+
p.rm(i, { recursive: !0 }, (l) => {
|
|
583
|
+
l ? w.warn(
|
|
585
584
|
`Failed to delete stale Playground temp dir: ${i}`,
|
|
586
585
|
l
|
|
587
|
-
) :
|
|
586
|
+
) : w.info(
|
|
588
587
|
`Deleted stale Playground temp dir: ${i}`
|
|
589
|
-
),
|
|
588
|
+
), a();
|
|
590
589
|
});
|
|
591
590
|
})
|
|
592
591
|
);
|
|
593
592
|
await Promise.all(s);
|
|
594
593
|
}
|
|
595
|
-
async function
|
|
594
|
+
async function Bt(e, t, r) {
|
|
596
595
|
try {
|
|
597
|
-
const o =
|
|
596
|
+
const o = p.readdirSync(r).map((i) => d.join(r, i)), s = [];
|
|
598
597
|
for (const i of o)
|
|
599
|
-
await
|
|
598
|
+
await Rt(
|
|
600
599
|
e,
|
|
601
600
|
t,
|
|
602
601
|
i
|
|
603
602
|
) && s.push(i);
|
|
604
603
|
return s;
|
|
605
604
|
} catch (o) {
|
|
606
|
-
return
|
|
605
|
+
return w.warn(`Failed to find stale Playground temp dirs: ${o}`), [];
|
|
607
606
|
}
|
|
608
607
|
}
|
|
609
|
-
async function
|
|
610
|
-
if (!
|
|
608
|
+
async function Rt(e, t, r) {
|
|
609
|
+
if (!p.lstatSync(r).isDirectory())
|
|
611
610
|
return !1;
|
|
612
611
|
const s = d.basename(r);
|
|
613
612
|
if (!s.includes(e))
|
|
@@ -617,37 +616,33 @@ async function Bt(e, t, r) {
|
|
|
617
616
|
);
|
|
618
617
|
if (!i)
|
|
619
618
|
return !1;
|
|
620
|
-
const
|
|
619
|
+
const a = {
|
|
621
620
|
executableName: i[1],
|
|
622
621
|
pid: i[2]
|
|
623
622
|
};
|
|
624
|
-
if (
|
|
623
|
+
if (Dt(a.pid))
|
|
625
624
|
return !1;
|
|
626
625
|
const l = Date.now() - t;
|
|
627
|
-
return
|
|
626
|
+
return p.statSync(r).mtime.getTime() < l;
|
|
628
627
|
}
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
(
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
);
|
|
643
|
-
}
|
|
644
|
-
);
|
|
645
|
-
return !!r && r.pid === e && r.command === t;
|
|
628
|
+
function Dt(e, t) {
|
|
629
|
+
try {
|
|
630
|
+
return process.kill(Number(e), 0), !0;
|
|
631
|
+
} catch (r) {
|
|
632
|
+
const o = r, s = o && typeof o.code == "string" ? o.code : void 0;
|
|
633
|
+
return s === "ESRCH" ? !1 : s === "EPERM" || s === "EACCES" ? (w.debug(
|
|
634
|
+
`Permission denied while checking if process ${e} exists (code: ${s}).`,
|
|
635
|
+
r
|
|
636
|
+
), !0) : (w.warn(
|
|
637
|
+
`Could not determine if process ${e} exists due to unexpected error${s ? ` (code: ${s})` : ""}.`,
|
|
638
|
+
r
|
|
639
|
+
), !0);
|
|
640
|
+
}
|
|
646
641
|
}
|
|
647
|
-
function
|
|
642
|
+
function Wt(e) {
|
|
648
643
|
return process.env.CI === "true" || process.env.CI === "1" || process.env.GITHUB_ACTIONS === "true" || process.env.GITHUB_ACTIONS === "1" || (process.env.TERM || "").toLowerCase() === "dumb" ? !1 : e ? !!e.isTTY : process.stdout.isTTY;
|
|
649
644
|
}
|
|
650
|
-
class
|
|
645
|
+
class Lt {
|
|
651
646
|
constructor(t) {
|
|
652
647
|
this.lastProgressLine = "", this.progressActive = !1, this.verbosity = t.verbosity, this.writeStream = t.writeStream || process.stdout;
|
|
653
648
|
}
|
|
@@ -661,7 +656,7 @@ class Wt {
|
|
|
661
656
|
* This prevents progress spam in logs - users only see the final outcome.
|
|
662
657
|
*/
|
|
663
658
|
get shouldRender() {
|
|
664
|
-
return
|
|
659
|
+
return Wt(this.writeStream);
|
|
665
660
|
}
|
|
666
661
|
get isQuiet() {
|
|
667
662
|
return this.verbosity === "quiet";
|
|
@@ -810,12 +805,12 @@ ${this.green("Ready!")} WordPress is running on ${this.bold(t)} ${this.dim(`(${r
|
|
|
810
805
|
);
|
|
811
806
|
}
|
|
812
807
|
}
|
|
813
|
-
const
|
|
814
|
-
Quiet: { name: "quiet", severity:
|
|
815
|
-
Normal: { name: "normal", severity:
|
|
816
|
-
Debug: { name: "debug", severity:
|
|
808
|
+
const X = {
|
|
809
|
+
Quiet: { name: "quiet", severity: O.Fatal },
|
|
810
|
+
Normal: { name: "normal", severity: O.Info },
|
|
811
|
+
Debug: { name: "debug", severity: O.Debug }
|
|
817
812
|
};
|
|
818
|
-
async function
|
|
813
|
+
async function _t(e) {
|
|
819
814
|
try {
|
|
820
815
|
const t = {
|
|
821
816
|
"site-url": {
|
|
@@ -845,14 +840,14 @@ async function br(e) {
|
|
|
845
840
|
type: "string",
|
|
846
841
|
nargs: 2,
|
|
847
842
|
array: !0,
|
|
848
|
-
coerce:
|
|
843
|
+
coerce: mt
|
|
849
844
|
},
|
|
850
845
|
"define-number": {
|
|
851
846
|
describe: "Define PHP number constants (can be used multiple times). Format: NAME value. Examples: --define-number LIMIT 100 --define-number RATE 45.67",
|
|
852
847
|
type: "string",
|
|
853
848
|
nargs: 2,
|
|
854
849
|
array: !0,
|
|
855
|
-
coerce:
|
|
850
|
+
coerce: ft
|
|
856
851
|
},
|
|
857
852
|
// @TODO: Support read-only mounts, e.g. via WORKERFS, a custom
|
|
858
853
|
// ReadOnlyNODEFS, or by copying the files into MEMFS
|
|
@@ -861,28 +856,28 @@ async function br(e) {
|
|
|
861
856
|
type: "array",
|
|
862
857
|
string: !0,
|
|
863
858
|
nargs: 1,
|
|
864
|
-
coerce:
|
|
859
|
+
coerce: F
|
|
865
860
|
},
|
|
866
861
|
"mount-before-install": {
|
|
867
862
|
describe: "Mount a directory to the PHP runtime before WordPress installation (can be used multiple times). Format: /host/path:/vfs/path",
|
|
868
863
|
type: "array",
|
|
869
864
|
string: !0,
|
|
870
865
|
nargs: 1,
|
|
871
|
-
coerce:
|
|
866
|
+
coerce: F
|
|
872
867
|
},
|
|
873
868
|
"mount-dir": {
|
|
874
869
|
describe: 'Mount a directory to the PHP runtime (can be used multiple times). Format: "/host/path" "/vfs/path"',
|
|
875
870
|
type: "array",
|
|
876
871
|
nargs: 2,
|
|
877
872
|
array: !0,
|
|
878
|
-
coerce:
|
|
873
|
+
coerce: ue
|
|
879
874
|
},
|
|
880
875
|
"mount-dir-before-install": {
|
|
881
876
|
describe: 'Mount a directory before WordPress installation (can be used multiple times). Format: "/host/path" "/vfs/path"',
|
|
882
877
|
type: "string",
|
|
883
878
|
nargs: 2,
|
|
884
879
|
array: !0,
|
|
885
|
-
coerce:
|
|
880
|
+
coerce: ue
|
|
886
881
|
},
|
|
887
882
|
login: {
|
|
888
883
|
describe: "Should log the user in",
|
|
@@ -929,8 +924,8 @@ async function br(e) {
|
|
|
929
924
|
verbosity: {
|
|
930
925
|
describe: "Output logs and progress messages.",
|
|
931
926
|
type: "string",
|
|
932
|
-
choices: Object.values(
|
|
933
|
-
(
|
|
927
|
+
choices: Object.values(X).map(
|
|
928
|
+
(n) => n.name
|
|
934
929
|
),
|
|
935
930
|
default: "normal"
|
|
936
931
|
},
|
|
@@ -990,7 +985,7 @@ Warning: Following symlinks will expose files outside mounted directories to Pla
|
|
|
990
985
|
// supported IDEs and, if needed, will create the relevant
|
|
991
986
|
// config file for each.
|
|
992
987
|
choices: ["", "vscode", "phpstorm"],
|
|
993
|
-
coerce: (
|
|
988
|
+
coerce: (n) => n === "" ? ["vscode", "phpstorm"] : [n]
|
|
994
989
|
},
|
|
995
990
|
"experimental-blueprints-v2-runner": {
|
|
996
991
|
describe: "Use the experimental Blueprint V2 runner.",
|
|
@@ -1009,7 +1004,7 @@ Warning: Following symlinks will expose files outside mounted directories to Pla
|
|
|
1009
1004
|
phpmyadmin: {
|
|
1010
1005
|
describe: "Install phpMyAdmin for database management. The phpMyAdmin URL will be printed after boot. Optionally specify a custom URL path (default: /phpmyadmin).",
|
|
1011
1006
|
type: "string",
|
|
1012
|
-
coerce: (
|
|
1007
|
+
coerce: (n) => n === "" ? "/phpmyadmin" : n
|
|
1013
1008
|
}
|
|
1014
1009
|
}, r = {
|
|
1015
1010
|
port: {
|
|
@@ -1080,7 +1075,7 @@ Warning: Following symlinks will expose files outside mounted directories to Pla
|
|
|
1080
1075
|
describe: "Mount a directory to the PHP runtime (can be used multiple times). Format: /host/path:/vfs/path. Use this for additional mounts beyond auto-detection.",
|
|
1081
1076
|
type: "array",
|
|
1082
1077
|
string: !0,
|
|
1083
|
-
coerce:
|
|
1078
|
+
coerce: F
|
|
1084
1079
|
},
|
|
1085
1080
|
reset: {
|
|
1086
1081
|
describe: "Deletes the stored site directory and starts a new site from scratch.",
|
|
@@ -1104,10 +1099,10 @@ Warning: Following symlinks will expose files outside mounted directories to Pla
|
|
|
1104
1099
|
type: "string",
|
|
1105
1100
|
default: "wordpress.zip"
|
|
1106
1101
|
}
|
|
1107
|
-
}, i =
|
|
1102
|
+
}, i = je(e).usage("Usage: wp-playground <command> [options]").command(
|
|
1108
1103
|
"start",
|
|
1109
1104
|
"Start a local WordPress server with automatic project detection (recommended)",
|
|
1110
|
-
(
|
|
1105
|
+
(n) => n.usage(
|
|
1111
1106
|
`Usage: wp-playground start [options]
|
|
1112
1107
|
|
|
1113
1108
|
The easiest way to run WordPress locally. Automatically detects
|
|
@@ -1124,43 +1119,43 @@ Examples:
|
|
|
1124
1119
|
).command(
|
|
1125
1120
|
"server",
|
|
1126
1121
|
"Start a local WordPress server (advanced, low-level)",
|
|
1127
|
-
(
|
|
1122
|
+
(n) => n.options({
|
|
1128
1123
|
...t,
|
|
1129
1124
|
...r
|
|
1130
1125
|
})
|
|
1131
1126
|
).command(
|
|
1132
1127
|
"run-blueprint",
|
|
1133
1128
|
"Execute a Blueprint without starting a server",
|
|
1134
|
-
(
|
|
1129
|
+
(n) => n.options({ ...t })
|
|
1135
1130
|
).command(
|
|
1136
1131
|
"build-snapshot",
|
|
1137
1132
|
"Build a ZIP snapshot of a WordPress site based on a Blueprint",
|
|
1138
|
-
(
|
|
1133
|
+
(n) => n.options({
|
|
1139
1134
|
...t,
|
|
1140
1135
|
...s
|
|
1141
1136
|
})
|
|
1142
1137
|
).command(
|
|
1143
1138
|
"php",
|
|
1144
1139
|
"Run a PHP script",
|
|
1145
|
-
(
|
|
1140
|
+
(n) => n.options({ ...t })
|
|
1146
1141
|
).demandCommand(1, "Please specify a command").strictCommands().conflicts(
|
|
1147
1142
|
"experimental-unsafe-ide-integration",
|
|
1148
1143
|
"experimental-devtools"
|
|
1149
|
-
).showHelpOnFail(!1).fail((
|
|
1144
|
+
).showHelpOnFail(!1).fail((n, m, b) => {
|
|
1150
1145
|
if (m)
|
|
1151
1146
|
throw m;
|
|
1152
|
-
|
|
1153
|
-
` +
|
|
1154
|
-
}).strictOptions().check(async (
|
|
1155
|
-
if (
|
|
1147
|
+
n && n.includes("Please specify a command") && (b.showHelp(), console.error(`
|
|
1148
|
+
` + n), process.exit(1)), console.error(n), process.exit(1);
|
|
1149
|
+
}).strictOptions().check(async (n) => {
|
|
1150
|
+
if (n["skip-wordpress-install"] === !0 && (n["wordpress-install-mode"] = "do-not-attempt-installing", n.wordpressInstallMode = "do-not-attempt-installing"), n.wp !== void 0 && typeof n.wp == "string" && !xt(n.wp))
|
|
1156
1151
|
try {
|
|
1157
|
-
new URL(
|
|
1152
|
+
new URL(n.wp);
|
|
1158
1153
|
} catch {
|
|
1159
1154
|
throw new Error(
|
|
1160
1155
|
'Unrecognized WordPress version. Please use "latest", a URL, or a numeric version such as "6.2", "6.0.1", "6.2-beta1", or "6.2-RC1"'
|
|
1161
1156
|
);
|
|
1162
1157
|
}
|
|
1163
|
-
const m =
|
|
1158
|
+
const m = n["site-url"];
|
|
1164
1159
|
if (typeof m == "string" && m.trim() !== "")
|
|
1165
1160
|
try {
|
|
1166
1161
|
new URL(m);
|
|
@@ -1169,32 +1164,32 @@ Examples:
|
|
|
1169
1164
|
`Invalid site-url "${m}". Please provide a valid URL (e.g., http://localhost:8080 or https://example.com)`
|
|
1170
1165
|
);
|
|
1171
1166
|
}
|
|
1172
|
-
if (
|
|
1173
|
-
let
|
|
1167
|
+
if (n["auto-mount"]) {
|
|
1168
|
+
let b = !1;
|
|
1174
1169
|
try {
|
|
1175
|
-
|
|
1176
|
-
|
|
1170
|
+
b = p.statSync(
|
|
1171
|
+
n["auto-mount"]
|
|
1177
1172
|
).isDirectory();
|
|
1178
1173
|
} catch {
|
|
1179
|
-
|
|
1174
|
+
b = !1;
|
|
1180
1175
|
}
|
|
1181
|
-
if (!
|
|
1176
|
+
if (!b)
|
|
1182
1177
|
throw new Error(
|
|
1183
|
-
`The specified --auto-mount path is not a directory: '${
|
|
1178
|
+
`The specified --auto-mount path is not a directory: '${n["auto-mount"]}'.`
|
|
1184
1179
|
);
|
|
1185
1180
|
}
|
|
1186
|
-
if (
|
|
1181
|
+
if (n["experimental-blueprints-v2-runner"] === !0)
|
|
1187
1182
|
throw new Error(
|
|
1188
1183
|
"Blueprints v2 are temporarily disabled while we rework their runtime implementation."
|
|
1189
1184
|
);
|
|
1190
|
-
if (
|
|
1185
|
+
if (n.mode !== void 0)
|
|
1191
1186
|
throw new Error(
|
|
1192
1187
|
"The --mode option requires the --experimentalBlueprintsV2Runner flag."
|
|
1193
1188
|
);
|
|
1194
1189
|
return !0;
|
|
1195
1190
|
});
|
|
1196
1191
|
i.wrap(i.terminalWidth());
|
|
1197
|
-
const
|
|
1192
|
+
const a = await i.argv, l = a._[0];
|
|
1198
1193
|
[
|
|
1199
1194
|
"start",
|
|
1200
1195
|
"run-blueprint",
|
|
@@ -1202,39 +1197,39 @@ Examples:
|
|
|
1202
1197
|
"build-snapshot",
|
|
1203
1198
|
"php"
|
|
1204
1199
|
].includes(l) || (i.showHelp(), process.exit(1));
|
|
1205
|
-
const u =
|
|
1200
|
+
const u = a.define || {};
|
|
1206
1201
|
!("WP_DEBUG" in u) && !("WP_DEBUG_LOG" in u) && !("WP_DEBUG_DISPLAY" in u) && (u.WP_DEBUG = "true", u.WP_DEBUG_LOG = "true", u.WP_DEBUG_DISPLAY = "true");
|
|
1207
|
-
const
|
|
1208
|
-
...
|
|
1202
|
+
const y = {
|
|
1203
|
+
...a,
|
|
1209
1204
|
define: u,
|
|
1210
1205
|
command: l,
|
|
1211
1206
|
mount: [
|
|
1212
|
-
...
|
|
1213
|
-
...
|
|
1207
|
+
...a.mount || [],
|
|
1208
|
+
...a["mount-dir"] || []
|
|
1214
1209
|
],
|
|
1215
1210
|
"mount-before-install": [
|
|
1216
|
-
...
|
|
1217
|
-
...
|
|
1211
|
+
...a["mount-before-install"] || [],
|
|
1212
|
+
...a["mount-dir-before-install"] || []
|
|
1218
1213
|
]
|
|
1219
|
-
}, E = await
|
|
1214
|
+
}, E = await ve(y);
|
|
1220
1215
|
E === void 0 && process.exit(0);
|
|
1221
|
-
const
|
|
1222
|
-
let
|
|
1216
|
+
const c = /* @__PURE__ */ (() => {
|
|
1217
|
+
let n;
|
|
1223
1218
|
return async () => {
|
|
1224
|
-
|
|
1219
|
+
n === void 0 && (n = E[Symbol.asyncDispose]()), await n, process.exit(0);
|
|
1225
1220
|
};
|
|
1226
1221
|
})();
|
|
1227
|
-
return process.on("SIGINT",
|
|
1222
|
+
return process.on("SIGINT", c), process.on("SIGTERM", c), {
|
|
1228
1223
|
[Symbol.asyncDispose]: async () => {
|
|
1229
|
-
process.off("SIGINT",
|
|
1224
|
+
process.off("SIGINT", c), process.off("SIGTERM", c), await E[Symbol.asyncDispose]();
|
|
1230
1225
|
},
|
|
1231
|
-
[
|
|
1226
|
+
[Z]: { cliServer: E }
|
|
1232
1227
|
};
|
|
1233
1228
|
} catch (t) {
|
|
1234
1229
|
if (console.error(t), !(t instanceof Error))
|
|
1235
1230
|
throw t;
|
|
1236
1231
|
if (process.argv.includes("--debug"))
|
|
1237
|
-
|
|
1232
|
+
Ie(t);
|
|
1238
1233
|
else {
|
|
1239
1234
|
const o = [];
|
|
1240
1235
|
let s = t;
|
|
@@ -1248,34 +1243,28 @@ Examples:
|
|
|
1248
1243
|
process.exit(1);
|
|
1249
1244
|
}
|
|
1250
1245
|
}
|
|
1251
|
-
function
|
|
1246
|
+
function ce(e, t) {
|
|
1252
1247
|
return e.find(
|
|
1253
1248
|
(r) => r.vfsPath.replace(/\/$/, "") === t.replace(/\/$/, "")
|
|
1254
1249
|
);
|
|
1255
1250
|
}
|
|
1256
|
-
const
|
|
1257
|
-
async function
|
|
1251
|
+
const Z = Symbol("playground-cli-testing"), I = (e) => process.stdout.isTTY ? "\x1B[1m" + e + "\x1B[0m" : e, Ut = (e) => process.stdout.isTTY ? "\x1B[31m" + e + "\x1B[0m" : e, pe = (e) => process.stdout.isTTY ? `\x1B[2m${e}\x1B[0m` : e, R = (e) => process.stdout.isTTY ? `\x1B[3m${e}\x1B[0m` : e, j = (e) => process.stdout.isTTY ? `\x1B[33m${e}\x1B[0m` : e;
|
|
1252
|
+
async function ve(e) {
|
|
1258
1253
|
let t;
|
|
1259
|
-
const r = e.internalCookieStore ? new
|
|
1260
|
-
if (e.command === "start" && (e = Ht(e)), e.autoMount !== void 0 && (e.autoMount === "" && (e = { ...e, autoMount: process.cwd() }), e =
|
|
1261
|
-
const
|
|
1262
|
-
(
|
|
1254
|
+
const r = e.internalCookieStore ? new ke() : void 0, o = [], s = /* @__PURE__ */ new Map();
|
|
1255
|
+
if (e.command === "start" && (e = Ht(e)), e.autoMount !== void 0 && (e.autoMount === "" && (e = { ...e, autoMount: process.cwd() }), e = ge(e)), e.wordpressInstallMode === void 0 && (e.wordpressInstallMode = "download-and-install"), e.quiet && (e.verbosity = "quiet", delete e.quiet), e.debug && (e.verbosity = "debug", delete e.debug), e.verbosity) {
|
|
1256
|
+
const c = Object.values(X).find(
|
|
1257
|
+
(n) => n.name === e.verbosity
|
|
1263
1258
|
).severity;
|
|
1264
|
-
|
|
1259
|
+
w.setSeverityFilterLevel(c);
|
|
1265
1260
|
}
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
urlPrefix: e.phpmyadmin,
|
|
1274
|
-
fsPath: se
|
|
1275
|
-
}
|
|
1276
|
-
];
|
|
1277
|
-
}
|
|
1278
|
-
const i = new Wt({
|
|
1261
|
+
e.intl || (e.intl = !0), e.redis === void 0 && (e.redis = await le()), e.memcached === void 0 && (e.memcached = await le()), e.phpmyadmin && (e.phpmyadmin === !0 && (e.phpmyadmin = "/phpmyadmin"), e.pathAliases = [
|
|
1262
|
+
{
|
|
1263
|
+
urlPrefix: e.phpmyadmin,
|
|
1264
|
+
fsPath: ae
|
|
1265
|
+
}
|
|
1266
|
+
]);
|
|
1267
|
+
const i = new Lt({
|
|
1279
1268
|
verbosity: e.verbosity || "normal"
|
|
1280
1269
|
});
|
|
1281
1270
|
e.command === "server" && (i.printBanner(), i.printConfig({
|
|
@@ -1292,30 +1281,30 @@ async function Ut(e) {
|
|
|
1292
1281
|
],
|
|
1293
1282
|
blueprint: typeof e.blueprint == "string" ? e.blueprint : void 0
|
|
1294
1283
|
}));
|
|
1295
|
-
const
|
|
1296
|
-
let u = !1,
|
|
1297
|
-
const E = await
|
|
1298
|
-
port: e.port ? e.port : await
|
|
1299
|
-
onBind: async (
|
|
1300
|
-
const m = "127.0.0.1",
|
|
1301
|
-
|
|
1302
|
-
const A = "WP Playground CLI - Listen for Xdebug",
|
|
1303
|
-
if (await
|
|
1304
|
-
const
|
|
1305
|
-
hostPath: d.join(".", d.sep,
|
|
1284
|
+
const a = e.command === "server" ? e.port ?? 9400 : 0, l = new Me();
|
|
1285
|
+
let u = !1, y = !0;
|
|
1286
|
+
const E = await bt({
|
|
1287
|
+
port: e.port ? e.port : await yt(a) ? 0 : a,
|
|
1288
|
+
onBind: async (c, n) => {
|
|
1289
|
+
const m = "127.0.0.1", b = `http://${m}:${n}`, L = e["site-url"] || b, _ = 6, J = "-playground-cli-site-", T = await Ct(J);
|
|
1290
|
+
w.debug(`Native temp dir for VFS root: ${T.path}`);
|
|
1291
|
+
const A = "WP Playground CLI - Listen for Xdebug", K = ".playground-xdebug-root", U = d.join(process.cwd(), K);
|
|
1292
|
+
if (await tt(U), e.xdebug) {
|
|
1293
|
+
const f = {
|
|
1294
|
+
hostPath: d.join(".", d.sep, K),
|
|
1306
1295
|
vfsPath: "/"
|
|
1307
1296
|
};
|
|
1308
1297
|
if (W.indexOf(
|
|
1309
1298
|
e.php || C
|
|
1310
1299
|
) <= W.indexOf("8.5"))
|
|
1311
|
-
await
|
|
1300
|
+
await ne(
|
|
1312
1301
|
T.path,
|
|
1313
|
-
|
|
1302
|
+
U,
|
|
1314
1303
|
process.platform
|
|
1315
|
-
), e.xdebug =
|
|
1304
|
+
), e.xdebug = rt({
|
|
1316
1305
|
cwd: process.cwd(),
|
|
1317
1306
|
mounts: [
|
|
1318
|
-
|
|
1307
|
+
f,
|
|
1319
1308
|
...e["mount-before-install"] || [],
|
|
1320
1309
|
...e.mount || []
|
|
1321
1310
|
],
|
|
@@ -1327,43 +1316,43 @@ async function Ut(e) {
|
|
|
1327
1316
|
"/proc/"
|
|
1328
1317
|
]
|
|
1329
1318
|
}), console.log(I("Xdebug configured successfully")), console.log(
|
|
1330
|
-
j("Playground source root: ") + ".playground-xdebug-root" +
|
|
1331
|
-
|
|
1319
|
+
j("Playground source root: ") + ".playground-xdebug-root" + R(
|
|
1320
|
+
pe(
|
|
1332
1321
|
" – you can set breakpoints and preview Playground's VFS structure in there."
|
|
1333
1322
|
)
|
|
1334
1323
|
)
|
|
1335
1324
|
);
|
|
1336
1325
|
else if (e.experimentalUnsafeIdeIntegration) {
|
|
1337
|
-
await
|
|
1326
|
+
await ne(
|
|
1338
1327
|
T.path,
|
|
1339
|
-
|
|
1328
|
+
U,
|
|
1340
1329
|
process.platform
|
|
1341
1330
|
);
|
|
1342
1331
|
try {
|
|
1343
|
-
await
|
|
1332
|
+
await ot(
|
|
1344
1333
|
A,
|
|
1345
1334
|
process.cwd()
|
|
1346
1335
|
);
|
|
1347
|
-
const
|
|
1336
|
+
const h = typeof e.xdebug == "object" ? e.xdebug : {}, g = await st({
|
|
1348
1337
|
name: A,
|
|
1349
1338
|
host: m,
|
|
1350
|
-
port:
|
|
1339
|
+
port: n,
|
|
1351
1340
|
ides: e.experimentalUnsafeIdeIntegration,
|
|
1352
1341
|
cwd: process.cwd(),
|
|
1353
1342
|
mounts: [
|
|
1354
|
-
|
|
1343
|
+
f,
|
|
1355
1344
|
...e["mount-before-install"] || [],
|
|
1356
1345
|
...e.mount || []
|
|
1357
1346
|
],
|
|
1358
|
-
ideKey:
|
|
1359
|
-
}), v = e.experimentalUnsafeIdeIntegration, S = v.includes("vscode"), x = v.includes("phpstorm"), B = Object.values(
|
|
1347
|
+
ideKey: h.ideKey || "WPPLAYGROUNDCLI"
|
|
1348
|
+
}), v = e.experimentalUnsafeIdeIntegration, S = v.includes("vscode"), x = v.includes("phpstorm"), B = Object.values(g);
|
|
1360
1349
|
console.log(""), B.length > 0 ? (console.log(
|
|
1361
1350
|
I("Xdebug configured successfully")
|
|
1362
1351
|
), console.log(
|
|
1363
1352
|
j("Updated IDE config: ") + B.join(" ")
|
|
1364
1353
|
), console.log(
|
|
1365
|
-
j("Playground source root: ") + ".playground-xdebug-root" +
|
|
1366
|
-
|
|
1354
|
+
j("Playground source root: ") + ".playground-xdebug-root" + R(
|
|
1355
|
+
pe(
|
|
1367
1356
|
" – you can set breakpoints and preview Playground's VFS structure in there."
|
|
1368
1357
|
)
|
|
1369
1358
|
)
|
|
@@ -1371,7 +1360,7 @@ async function Ut(e) {
|
|
|
1371
1360
|
I("Xdebug configuration failed.")
|
|
1372
1361
|
), console.log(
|
|
1373
1362
|
"No IDE-specific project settings directory was found in the current working directory."
|
|
1374
|
-
)), console.log(""), S &&
|
|
1363
|
+
)), console.log(""), S && g.vscode && (console.log(
|
|
1375
1364
|
I("VS Code / Cursor instructions:")
|
|
1376
1365
|
), console.log(
|
|
1377
1366
|
" 1. Ensure you have installed an IDE extension for PHP Debugging"
|
|
@@ -1382,15 +1371,15 @@ async function Ut(e) {
|
|
|
1382
1371
|
), console.log(
|
|
1383
1372
|
" 2. Open the Run and Debug panel on the left sidebar"
|
|
1384
1373
|
), console.log(
|
|
1385
|
-
` 3. Select "${
|
|
1374
|
+
` 3. Select "${R(
|
|
1386
1375
|
A
|
|
1387
1376
|
)}" from the dropdown`
|
|
1388
1377
|
), console.log(' 3. Click "start debugging"'), console.log(
|
|
1389
1378
|
" 5. Set a breakpoint. For example, in .playground-xdebug-root/wordpress/index.php"
|
|
1390
1379
|
), console.log(
|
|
1391
1380
|
" 6. Visit Playground in your browser to hit the breakpoint"
|
|
1392
|
-
), x && console.log("")), x &&
|
|
1393
|
-
` 1. Choose "${
|
|
1381
|
+
), x && console.log("")), x && g.phpstorm && (console.log(I("PhpStorm instructions:")), console.log(
|
|
1382
|
+
` 1. Choose "${R(
|
|
1394
1383
|
A
|
|
1395
1384
|
)}" debug configuration in the toolbar`
|
|
1396
1385
|
), console.log(
|
|
@@ -1400,22 +1389,22 @@ async function Ut(e) {
|
|
|
1400
1389
|
), console.log(
|
|
1401
1390
|
" 4. Visit Playground in your browser to hit the breakpoint"
|
|
1402
1391
|
)), console.log("");
|
|
1403
|
-
} catch (
|
|
1392
|
+
} catch (h) {
|
|
1404
1393
|
throw new Error("Could not configure Xdebug", {
|
|
1405
|
-
cause:
|
|
1394
|
+
cause: h
|
|
1406
1395
|
});
|
|
1407
1396
|
}
|
|
1408
1397
|
}
|
|
1409
1398
|
}
|
|
1410
|
-
const
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1399
|
+
const xe = d.dirname(T.path), Ee = 2 * 24 * 60 * 60 * 1e3;
|
|
1400
|
+
At(
|
|
1401
|
+
J,
|
|
1402
|
+
Ee,
|
|
1403
|
+
xe
|
|
1415
1404
|
);
|
|
1416
|
-
const
|
|
1417
|
-
Y(
|
|
1418
|
-
const
|
|
1405
|
+
const ee = d.join(T.path, "internal");
|
|
1406
|
+
Y(ee);
|
|
1407
|
+
const $e = [
|
|
1419
1408
|
"wordpress",
|
|
1420
1409
|
"tools",
|
|
1421
1410
|
// Note: These dirs are from Emscripten's "default dirs" list:
|
|
@@ -1427,67 +1416,67 @@ async function Ut(e) {
|
|
|
1427
1416
|
"tmp",
|
|
1428
1417
|
"home"
|
|
1429
1418
|
];
|
|
1430
|
-
for (const
|
|
1431
|
-
const
|
|
1432
|
-
if (!(e["mount-before-install"]?.some(
|
|
1433
|
-
const
|
|
1419
|
+
for (const f of $e) {
|
|
1420
|
+
const P = (g) => g.vfsPath === `/${f}`;
|
|
1421
|
+
if (!(e["mount-before-install"]?.some(P) || e.mount?.some(P))) {
|
|
1422
|
+
const g = d.join(
|
|
1434
1423
|
T.path,
|
|
1435
|
-
|
|
1424
|
+
f
|
|
1436
1425
|
);
|
|
1437
|
-
Y(
|
|
1438
|
-
vfsPath: `/${
|
|
1439
|
-
hostPath:
|
|
1426
|
+
Y(g), e["mount-before-install"] === void 0 && (e["mount-before-install"] = []), e["mount-before-install"].unshift({
|
|
1427
|
+
vfsPath: `/${f}`,
|
|
1428
|
+
hostPath: g
|
|
1440
1429
|
});
|
|
1441
1430
|
}
|
|
1442
1431
|
}
|
|
1443
1432
|
if (e["mount-before-install"])
|
|
1444
|
-
for (const
|
|
1445
|
-
|
|
1446
|
-
`Mount before WP install: ${
|
|
1433
|
+
for (const f of e["mount-before-install"])
|
|
1434
|
+
w.debug(
|
|
1435
|
+
`Mount before WP install: ${f.vfsPath} -> ${f.hostPath}`
|
|
1447
1436
|
);
|
|
1448
1437
|
if (e.mount)
|
|
1449
|
-
for (const
|
|
1450
|
-
|
|
1451
|
-
`Mount after WP install: ${
|
|
1438
|
+
for (const f of e.mount)
|
|
1439
|
+
w.debug(
|
|
1440
|
+
`Mount after WP install: ${f.vfsPath} -> ${f.hostPath}`
|
|
1452
1441
|
);
|
|
1453
1442
|
let k;
|
|
1454
|
-
e["experimental-blueprints-v2-runner"] ? k = new
|
|
1443
|
+
e["experimental-blueprints-v2-runner"] ? k = new $t(e, {
|
|
1455
1444
|
siteUrl: L,
|
|
1456
1445
|
cliOutput: i
|
|
1457
|
-
}) : (k = new
|
|
1446
|
+
}) : (k = new Mt(e, {
|
|
1458
1447
|
siteUrl: L,
|
|
1459
1448
|
cliOutput: i
|
|
1460
|
-
}), typeof e.blueprint == "string" && (e.blueprint = await
|
|
1449
|
+
}), typeof e.blueprint == "string" && (e.blueprint = await Et({
|
|
1461
1450
|
sourceString: e.blueprint,
|
|
1462
1451
|
blueprintMayReadAdjacentFiles: e["blueprint-may-read-adjacent-files"] === !0
|
|
1463
1452
|
})));
|
|
1464
|
-
let
|
|
1453
|
+
let H = !1;
|
|
1465
1454
|
const M = async function() {
|
|
1466
|
-
|
|
1467
|
-
o.map(async (
|
|
1468
|
-
await s.get(
|
|
1455
|
+
H || (H = !0, await Promise.all(
|
|
1456
|
+
o.map(async (P) => {
|
|
1457
|
+
await s.get(P)?.dispose(), await P.worker.terminate();
|
|
1469
1458
|
})
|
|
1470
|
-
),
|
|
1471
|
-
|
|
1459
|
+
), c && await new Promise((P) => {
|
|
1460
|
+
c.close(P), c.closeAllConnections();
|
|
1472
1461
|
}), await T.cleanup());
|
|
1473
1462
|
};
|
|
1474
1463
|
try {
|
|
1475
|
-
const
|
|
1476
|
-
for (let
|
|
1477
|
-
const
|
|
1464
|
+
const f = [], P = k.getWorkerType();
|
|
1465
|
+
for (let h = 0; h < _; h++) {
|
|
1466
|
+
const g = Se(P, {
|
|
1478
1467
|
onExit: (v) => {
|
|
1479
|
-
|
|
1480
|
-
`Worker ${
|
|
1468
|
+
H || v === 0 && w.error(
|
|
1469
|
+
`Worker ${h} exited with code ${v}
|
|
1481
1470
|
`
|
|
1482
1471
|
);
|
|
1483
1472
|
}
|
|
1484
1473
|
}).then(
|
|
1485
1474
|
async (v) => {
|
|
1486
1475
|
o.push(v);
|
|
1487
|
-
const S = await
|
|
1476
|
+
const S = await Nt(l), x = await k.bootRequestHandler({
|
|
1488
1477
|
worker: v,
|
|
1489
1478
|
fileLockManagerPort: S,
|
|
1490
|
-
nativeInternalDirPath:
|
|
1479
|
+
nativeInternalDirPath: ee
|
|
1491
1480
|
});
|
|
1492
1481
|
return s.set(
|
|
1493
1482
|
v,
|
|
@@ -1495,16 +1484,16 @@ async function Ut(e) {
|
|
|
1495
1484
|
), [v, x];
|
|
1496
1485
|
}
|
|
1497
1486
|
);
|
|
1498
|
-
|
|
1487
|
+
f.push(g), h === 0 && await g;
|
|
1499
1488
|
}
|
|
1500
|
-
await Promise.all(
|
|
1489
|
+
await Promise.all(f), t = Ce(
|
|
1501
1490
|
o.map(
|
|
1502
|
-
(
|
|
1491
|
+
(h) => s.get(h)
|
|
1503
1492
|
)
|
|
1504
1493
|
);
|
|
1505
1494
|
{
|
|
1506
|
-
const
|
|
1507
|
-
if (await
|
|
1495
|
+
const h = new he(), g = h.port1, v = h.port2;
|
|
1496
|
+
if (await Ae(
|
|
1508
1497
|
{
|
|
1509
1498
|
applyPostInstallMountsToAllWorkers: async () => {
|
|
1510
1499
|
await Promise.all(
|
|
@@ -1519,27 +1508,27 @@ async function Ut(e) {
|
|
|
1519
1508
|
}
|
|
1520
1509
|
},
|
|
1521
1510
|
void 0,
|
|
1522
|
-
|
|
1511
|
+
g
|
|
1523
1512
|
), await k.bootWordPress(
|
|
1524
1513
|
t,
|
|
1525
1514
|
v
|
|
1526
|
-
),
|
|
1515
|
+
), g.close(), u = !0, !e["experimental-blueprints-v2-runner"]) {
|
|
1527
1516
|
const S = await k.compileInputBlueprint(
|
|
1528
1517
|
e["additional-blueprint-steps"] || []
|
|
1529
1518
|
);
|
|
1530
|
-
S && await
|
|
1519
|
+
S && await se(
|
|
1531
1520
|
S,
|
|
1532
1521
|
t
|
|
1533
1522
|
);
|
|
1534
1523
|
}
|
|
1535
1524
|
if (e.phpmyadmin && !await t.fileExists(
|
|
1536
|
-
`${
|
|
1525
|
+
`${ae}/index.php`
|
|
1537
1526
|
)) {
|
|
1538
|
-
const S = await
|
|
1539
|
-
await
|
|
1527
|
+
const S = await nt(), x = await fe({ steps: S });
|
|
1528
|
+
await se(x, t);
|
|
1540
1529
|
}
|
|
1541
1530
|
if (e.command === "build-snapshot") {
|
|
1542
|
-
await
|
|
1531
|
+
await Ft(t, e.outfile), i.printStatus(`Exported to ${e.outfile}`), await M();
|
|
1543
1532
|
return;
|
|
1544
1533
|
} else if (e.command === "run-blueprint") {
|
|
1545
1534
|
i.finishProgress("Done"), await M();
|
|
@@ -1554,15 +1543,15 @@ async function Ut(e) {
|
|
|
1554
1543
|
x.exitCode,
|
|
1555
1544
|
x.stdout.pipeTo(
|
|
1556
1545
|
new WritableStream({
|
|
1557
|
-
write(
|
|
1558
|
-
process.stdout.write(
|
|
1546
|
+
write(N) {
|
|
1547
|
+
process.stdout.write(N);
|
|
1559
1548
|
}
|
|
1560
1549
|
})
|
|
1561
1550
|
),
|
|
1562
1551
|
x.stderr.pipeTo(
|
|
1563
1552
|
new WritableStream({
|
|
1564
|
-
write(
|
|
1565
|
-
process.stderr.write(
|
|
1553
|
+
write(N) {
|
|
1554
|
+
process.stderr.write(N);
|
|
1566
1555
|
}
|
|
1567
1556
|
})
|
|
1568
1557
|
)
|
|
@@ -1570,59 +1559,59 @@ async function Ut(e) {
|
|
|
1570
1559
|
await M(), process.exit(B);
|
|
1571
1560
|
}
|
|
1572
1561
|
}
|
|
1573
|
-
if (i.finishProgress(), i.printReady(
|
|
1574
|
-
const
|
|
1562
|
+
if (i.finishProgress(), i.printReady(b, _), e.phpmyadmin) {
|
|
1563
|
+
const h = d.join(
|
|
1575
1564
|
e.phpmyadmin,
|
|
1576
|
-
|
|
1565
|
+
at
|
|
1577
1566
|
);
|
|
1578
1567
|
i.printPhpMyAdminUrl(
|
|
1579
|
-
new URL(
|
|
1568
|
+
new URL(h, b).toString()
|
|
1580
1569
|
);
|
|
1581
1570
|
}
|
|
1582
|
-
return e.xdebug && e.experimentalDevtools && (await
|
|
1571
|
+
return e.xdebug && e.experimentalDevtools && (await Je({
|
|
1583
1572
|
phpInstance: t,
|
|
1584
1573
|
phpRoot: "/wordpress"
|
|
1585
1574
|
})).start(), {
|
|
1586
1575
|
playground: t,
|
|
1587
|
-
server:
|
|
1588
|
-
serverUrl:
|
|
1576
|
+
server: c,
|
|
1577
|
+
serverUrl: b,
|
|
1589
1578
|
[Symbol.asyncDispose]: M,
|
|
1590
|
-
[
|
|
1591
|
-
workerThreadCount:
|
|
1579
|
+
[Z]: {
|
|
1580
|
+
workerThreadCount: _
|
|
1592
1581
|
}
|
|
1593
1582
|
};
|
|
1594
|
-
} catch (
|
|
1583
|
+
} catch (f) {
|
|
1595
1584
|
if (e.verbosity !== "debug")
|
|
1596
|
-
throw
|
|
1597
|
-
let
|
|
1598
|
-
throw await t?.fileExists(
|
|
1585
|
+
throw f;
|
|
1586
|
+
let P = "";
|
|
1587
|
+
throw await t?.fileExists(te) && (P = await t.readFileAsText(te)), await M(), new Error(P, { cause: f });
|
|
1599
1588
|
}
|
|
1600
1589
|
},
|
|
1601
|
-
async handleRequest(
|
|
1590
|
+
async handleRequest(c) {
|
|
1602
1591
|
if (!u)
|
|
1603
|
-
return
|
|
1592
|
+
return re.forHttpCode(
|
|
1604
1593
|
502,
|
|
1605
1594
|
"WordPress is not ready yet"
|
|
1606
1595
|
);
|
|
1607
|
-
if (
|
|
1608
|
-
|
|
1596
|
+
if (y) {
|
|
1597
|
+
y = !1;
|
|
1609
1598
|
const m = {
|
|
1610
1599
|
"Content-Type": ["text/plain"],
|
|
1611
1600
|
"Content-Length": ["0"],
|
|
1612
|
-
Location: [
|
|
1601
|
+
Location: [c.url]
|
|
1613
1602
|
};
|
|
1614
|
-
return
|
|
1603
|
+
return c.headers?.cookie?.includes(
|
|
1615
1604
|
"playground_auto_login_already_happened"
|
|
1616
1605
|
) && (m["Set-Cookie"] = [
|
|
1617
1606
|
"playground_auto_login_already_happened=1; Max-Age=0; Expires=Thu, 01 Jan 1970 00:00:00 GMT; Path=/"
|
|
1618
|
-
]),
|
|
1619
|
-
new
|
|
1607
|
+
]), re.fromPHPResponse(
|
|
1608
|
+
new Be(302, m, new Uint8Array())
|
|
1620
1609
|
);
|
|
1621
1610
|
}
|
|
1622
|
-
r && (
|
|
1623
|
-
...
|
|
1611
|
+
r && (c = {
|
|
1612
|
+
...c,
|
|
1624
1613
|
headers: {
|
|
1625
|
-
...
|
|
1614
|
+
...c.headers,
|
|
1626
1615
|
// While we have an internal cookie store, we
|
|
1627
1616
|
// completely replace the incoming request's Cookie
|
|
1628
1617
|
// header with the cookies from our store. This avoids
|
|
@@ -1631,28 +1620,28 @@ async function Ut(e) {
|
|
|
1631
1620
|
cookie: r.getCookieRequestHeader()
|
|
1632
1621
|
}
|
|
1633
1622
|
});
|
|
1634
|
-
const
|
|
1623
|
+
const n = await t.requestStreamed(c);
|
|
1635
1624
|
if (r) {
|
|
1636
|
-
const m = await
|
|
1625
|
+
const m = await n.headers;
|
|
1637
1626
|
r.rememberCookiesFromResponseHeaders(m), delete m["set-cookie"];
|
|
1638
1627
|
}
|
|
1639
|
-
return
|
|
1628
|
+
return n;
|
|
1640
1629
|
}
|
|
1641
|
-
}).catch((
|
|
1642
|
-
i.printError(
|
|
1630
|
+
}).catch((c) => {
|
|
1631
|
+
i.printError(c.message), process.exit(1);
|
|
1643
1632
|
});
|
|
1644
|
-
return E && e.command === "start" && !e.skipBrowser &&
|
|
1633
|
+
return E && e.command === "start" && !e.skipBrowser && Ot(E.serverUrl), E;
|
|
1645
1634
|
}
|
|
1646
1635
|
function Ht(e) {
|
|
1647
1636
|
let t = { ...e, command: "server" };
|
|
1648
|
-
e.noAutoMount || (t.autoMount = d.resolve(process.cwd(), t.path ?? ""), t =
|
|
1649
|
-
const r =
|
|
1637
|
+
e.noAutoMount || (t.autoMount = d.resolve(process.cwd(), t.path ?? ""), t = ge(t), delete t.autoMount);
|
|
1638
|
+
const r = ce(
|
|
1650
1639
|
t["mount-before-install"] || [],
|
|
1651
1640
|
"/wordpress"
|
|
1652
|
-
) ||
|
|
1641
|
+
) || ce(t.mount || [], "/wordpress");
|
|
1653
1642
|
if (r)
|
|
1654
1643
|
console.log("Site files stored at:", r?.hostPath), e.reset && (console.log(""), console.log(
|
|
1655
|
-
|
|
1644
|
+
Ut(
|
|
1656
1645
|
"This site is not managed by Playground CLI and cannot be reset."
|
|
1657
1646
|
)
|
|
1658
1647
|
), console.log(
|
|
@@ -1661,15 +1650,15 @@ function Ht(e) {
|
|
|
1661
1650
|
"You may still remove the site's directory manually if you wish."
|
|
1662
1651
|
), process.exit(1));
|
|
1663
1652
|
else {
|
|
1664
|
-
const o = t.autoMount || process.cwd(), s =
|
|
1653
|
+
const o = t.autoMount || process.cwd(), s = it("sha256").update(o).digest("hex"), i = G.homedir(), a = d.join(
|
|
1665
1654
|
i,
|
|
1666
1655
|
".wordpress-playground/sites",
|
|
1667
1656
|
s
|
|
1668
1657
|
);
|
|
1669
|
-
console.log("Site files stored at:",
|
|
1658
|
+
console.log("Site files stored at:", a), z(a) && e.reset && (console.log("Resetting site..."), _e(a, { recursive: !0 })), Y(a, { recursive: !0 }), t["mount-before-install"] = [
|
|
1670
1659
|
...t["mount-before-install"] || [],
|
|
1671
|
-
{ vfsPath: "/wordpress", hostPath:
|
|
1672
|
-
], t.wordpressInstallMode =
|
|
1660
|
+
{ vfsPath: "/wordpress", hostPath: a }
|
|
1661
|
+
], t.wordpressInstallMode = Ue(a).length === 0 ? (
|
|
1673
1662
|
// Only download WordPress on the first run when the site directory is still
|
|
1674
1663
|
// empty.
|
|
1675
1664
|
"download-and-install"
|
|
@@ -1680,10 +1669,10 @@ function Ht(e) {
|
|
|
1680
1669
|
}
|
|
1681
1670
|
return t;
|
|
1682
1671
|
}
|
|
1683
|
-
const V = new
|
|
1684
|
-
function
|
|
1672
|
+
const V = new Te();
|
|
1673
|
+
function Se(e, { onExit: t } = {}) {
|
|
1685
1674
|
let r;
|
|
1686
|
-
return e === "v1" ? r = new
|
|
1675
|
+
return e === "v1" ? r = new ie(new URL("./worker-thread-v1.js", import.meta.url)) : r = new ie(new URL("./worker-thread-v2.js", import.meta.url)), new Promise((o, s) => {
|
|
1687
1676
|
const i = V.claim();
|
|
1688
1677
|
r.once("message", function(l) {
|
|
1689
1678
|
l.command === "worker-script-initialized" && o({
|
|
@@ -1698,19 +1687,19 @@ function _t(e, { onExit: t } = {}) {
|
|
|
1698
1687
|
);
|
|
1699
1688
|
s(u);
|
|
1700
1689
|
});
|
|
1701
|
-
let
|
|
1690
|
+
let a = !1;
|
|
1702
1691
|
r.once("spawn", () => {
|
|
1703
|
-
|
|
1692
|
+
a = !0;
|
|
1704
1693
|
}), r.once("exit", (l) => {
|
|
1705
|
-
V.release(i),
|
|
1694
|
+
V.release(i), a || s(new Error(`Worker exited before spawning: ${l}`)), t?.(l);
|
|
1706
1695
|
});
|
|
1707
1696
|
});
|
|
1708
1697
|
}
|
|
1709
|
-
async function
|
|
1710
|
-
const { port1: t, port2: r } = new
|
|
1711
|
-
return await
|
|
1698
|
+
async function Nt(e) {
|
|
1699
|
+
const { port1: t, port2: r } = new he();
|
|
1700
|
+
return await Re(e, t), r;
|
|
1712
1701
|
}
|
|
1713
|
-
function
|
|
1702
|
+
function Ot(e) {
|
|
1714
1703
|
const t = G.platform();
|
|
1715
1704
|
let r;
|
|
1716
1705
|
switch (t) {
|
|
@@ -1724,11 +1713,11 @@ function Nt(e) {
|
|
|
1724
1713
|
r = `xdg-open "${e}"`;
|
|
1725
1714
|
break;
|
|
1726
1715
|
}
|
|
1727
|
-
|
|
1728
|
-
o &&
|
|
1716
|
+
ye(r, (o) => {
|
|
1717
|
+
o && w.debug(`Could not open browser: ${o.message}`);
|
|
1729
1718
|
});
|
|
1730
1719
|
}
|
|
1731
|
-
async function
|
|
1720
|
+
async function Ft(e, t) {
|
|
1732
1721
|
await e.run({
|
|
1733
1722
|
code: `<?php
|
|
1734
1723
|
$zip = new ZipArchive();
|
|
@@ -1750,16 +1739,26 @@ async function Ot(e, t) {
|
|
|
1750
1739
|
`
|
|
1751
1740
|
});
|
|
1752
1741
|
const r = await e.readFileAsBuffer("/tmp/build.zip");
|
|
1753
|
-
|
|
1742
|
+
p.writeFileSync(t, r);
|
|
1754
1743
|
}
|
|
1744
|
+
const yr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
1745
|
+
__proto__: null,
|
|
1746
|
+
LogVerbosity: X,
|
|
1747
|
+
internalsKeyForTesting: Z,
|
|
1748
|
+
mergeDefinedConstants: Q,
|
|
1749
|
+
parseOptionsAndRunCLI: _t,
|
|
1750
|
+
runCLI: ve,
|
|
1751
|
+
spawnWorkerThread: Se
|
|
1752
|
+
}, Symbol.toStringTag, { value: "Module" }));
|
|
1755
1753
|
export {
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
1754
|
+
X as L,
|
|
1755
|
+
wr as a,
|
|
1756
|
+
Wt as b,
|
|
1757
|
+
yr as c,
|
|
1758
|
+
Z as i,
|
|
1759
|
+
Q as m,
|
|
1760
|
+
_t as p,
|
|
1761
|
+
ve as r,
|
|
1762
|
+
Se as s
|
|
1764
1763
|
};
|
|
1765
|
-
//# sourceMappingURL=run-cli-
|
|
1764
|
+
//# sourceMappingURL=run-cli-Dka9y1Ev.js.map
|