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