@wp-playground/cli 3.1.18 → 3.1.20
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.js +1 -1
- package/index.cjs +1 -1
- package/index.js +1 -1
- package/package.json +17 -16
- package/{run-cli-DZBuTllO.cjs → run-cli-B6Dm34vQ.cjs} +8 -8
- package/run-cli-B6Dm34vQ.cjs.map +1 -0
- package/{run-cli-CrCfo8mJ.js → run-cli-B9kBDU12.js} +219 -224
- package/run-cli-B9kBDU12.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-CrCfo8mJ.js.map +0 -1
- package/run-cli-DZBuTllO.cjs.map +0 -1
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
import { logger as y, LogSeverity as F, errorLogPath as
|
|
2
|
-
import { consumeAPI as
|
|
3
|
-
import { resolveRemoteBlueprint as
|
|
4
|
-
import { zipDirectory as
|
|
5
|
-
import p, { existsSync as G, rmdirSync as
|
|
6
|
-
import { MessageChannel as
|
|
7
|
-
import { createNodeFsMountHandler as
|
|
8
|
-
import d, { basename as _, join 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
|
|
1
|
+
import { logger as y, LogSeverity as F, errorLogPath as re } from "@php-wasm/logger";
|
|
2
|
+
import { consumeAPI as he, ProcessIdAllocator as ke, SupportedPHPVersions as U, printDebugDetails as Me, HttpCookieStore as Ce, FileLockManagerInMemory as Ae, StreamedPHPResponse as oe, createObjectPoolProxy as Be, exposeAPI as De, PHPResponse as Re, exposeSyncAPI as We } from "@php-wasm/universal";
|
|
3
|
+
import { resolveRemoteBlueprint as Le, resolveRuntimeConfiguration as se, compileBlueprintV1 as we, isBlueprintBundle as _e, runBlueprintV1Steps as ie } from "@wp-playground/blueprints";
|
|
4
|
+
import { zipDirectory as Ue, RecommendedPHPVersion as D } from "@wp-playground/common";
|
|
5
|
+
import p, { existsSync as G, rmdirSync as He, mkdirSync as q, readdirSync as Ne } from "fs";
|
|
6
|
+
import { MessageChannel as ye, Worker as ne } from "worker_threads";
|
|
7
|
+
import { createNodeFsMountHandler as Oe } from "@php-wasm/node";
|
|
8
|
+
import d, { basename as _, join as Q } from "path";
|
|
9
|
+
import { exec as be } from "child_process";
|
|
10
|
+
import { promisify as Fe } from "util";
|
|
11
|
+
import ge from "express";
|
|
12
|
+
import { Readable as je } from "stream";
|
|
13
|
+
import { pipeline as Ve } from "stream/promises";
|
|
14
|
+
import Ye from "yargs";
|
|
15
|
+
import { NodeJsFilesystem as qe, OverlayFilesystem as ze, InMemoryFilesystem as Ge, ZipFilesystem as Qe } from "@wp-playground/storage";
|
|
16
|
+
import { EmscriptenDownloadMonitor as Xe, ProgressTracker as Ze } from "@php-wasm/progress";
|
|
17
|
+
import { resolveWordPressRelease as Je } from "@wp-playground/wordpress";
|
|
18
18
|
import k from "fs-extra";
|
|
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
|
|
19
|
+
import { createRequire as Ke } from "module";
|
|
20
|
+
import X from "os";
|
|
21
|
+
import { startBridge as et } from "@php-wasm/xdebug-bridge";
|
|
22
|
+
import { dir as tt, setGracefulCleanup as rt } from "tmp-promise";
|
|
23
|
+
import { removeTempDirSymlink as ot, createTempDirSymlink as ae, makeXdebugConfig as st, DEFAULT_PATH_SKIPPINGS as le, clearXdebugIDEConfig as it, addXdebugIDEConfig as nt } from "@php-wasm/cli-util";
|
|
24
|
+
import { createHash as at } from "crypto";
|
|
25
|
+
import { PHPMYADMIN_INSTALL_PATH as ue, getPhpMyAdminInstallSteps as lt, PHPMYADMIN_ENTRY_PATH as ut } from "@wp-playground/tools";
|
|
26
|
+
import { jspi as de } from "wasm-feature-detect";
|
|
27
27
|
function j(e) {
|
|
28
28
|
const t = [];
|
|
29
29
|
for (const r of e) {
|
|
@@ -40,7 +40,7 @@ function j(e) {
|
|
|
40
40
|
}
|
|
41
41
|
return t;
|
|
42
42
|
}
|
|
43
|
-
function
|
|
43
|
+
function ce(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 = [];
|
|
@@ -55,14 +55,14 @@ function ue(e) {
|
|
|
55
55
|
}
|
|
56
56
|
return t;
|
|
57
57
|
}
|
|
58
|
-
async function
|
|
58
|
+
async function br(e, t) {
|
|
59
59
|
for (const r of t)
|
|
60
60
|
await e.mount(
|
|
61
61
|
r.vfsPath,
|
|
62
|
-
|
|
62
|
+
Oe(r.hostPath)
|
|
63
63
|
);
|
|
64
64
|
}
|
|
65
|
-
const
|
|
65
|
+
const pe = {
|
|
66
66
|
step: "runPHP",
|
|
67
67
|
code: {
|
|
68
68
|
filename: "activate-theme.php",
|
|
@@ -81,7 +81,7 @@ const de = {
|
|
|
81
81
|
`
|
|
82
82
|
}
|
|
83
83
|
};
|
|
84
|
-
function
|
|
84
|
+
function Pe(e) {
|
|
85
85
|
const t = e.autoMount, r = [...e.mount || []], o = [...e["mount-before-install"] || []], s = {
|
|
86
86
|
...e,
|
|
87
87
|
mount: r,
|
|
@@ -90,7 +90,7 @@ function ge(e) {
|
|
|
90
90
|
...e["additional-blueprint-steps"] || []
|
|
91
91
|
]
|
|
92
92
|
};
|
|
93
|
-
if (
|
|
93
|
+
if (mt(t)) {
|
|
94
94
|
const n = `/wordpress/wp-content/plugins/${_(t)}`;
|
|
95
95
|
r.push({
|
|
96
96
|
hostPath: t,
|
|
@@ -100,7 +100,7 @@ function ge(e) {
|
|
|
100
100
|
step: "activatePlugin",
|
|
101
101
|
pluginPath: `/wordpress/wp-content/plugins/${_(t)}`
|
|
102
102
|
});
|
|
103
|
-
} else if (
|
|
103
|
+
} else if (pt(t)) {
|
|
104
104
|
const i = _(t), n = `/wordpress/wp-content/themes/${i}`;
|
|
105
105
|
r.push({
|
|
106
106
|
hostPath: t,
|
|
@@ -115,44 +115,44 @@ function ge(e) {
|
|
|
115
115
|
themeFolderName: i
|
|
116
116
|
}
|
|
117
117
|
);
|
|
118
|
-
} else if (
|
|
118
|
+
} else if (ct(t)) {
|
|
119
119
|
const i = p.readdirSync(t);
|
|
120
120
|
for (const n of i)
|
|
121
121
|
n !== "index.php" && r.push({
|
|
122
|
-
hostPath:
|
|
122
|
+
hostPath: Q(t, n),
|
|
123
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(pe);
|
|
127
|
+
} else dt(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(pe), s.wordpressInstallMode || (s.wordpressInstallMode = "install-from-existing-files-if-needed"));
|
|
132
132
|
return s;
|
|
133
133
|
}
|
|
134
|
-
function
|
|
134
|
+
function dt(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 ct(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 pt(e) {
|
|
143
143
|
if (!p.readdirSync(e).includes("style.css"))
|
|
144
144
|
return !1;
|
|
145
|
-
const r = p.readFileSync(
|
|
145
|
+
const r = p.readFileSync(Q(e, "style.css"), "utf8");
|
|
146
146
|
return !!/^(?:[ \t]*<\?php)?[ \t/*#@]*Theme Name:(.*)$/im.exec(r);
|
|
147
147
|
}
|
|
148
|
-
function
|
|
148
|
+
function mt(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(Q(e, s), "utf8");
|
|
152
152
|
return !!r.exec(i);
|
|
153
153
|
});
|
|
154
154
|
}
|
|
155
|
-
function
|
|
155
|
+
function ft(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 mt(e) {
|
|
|
166
166
|
}
|
|
167
167
|
return t;
|
|
168
168
|
}
|
|
169
|
-
function
|
|
169
|
+
function ht(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 ft(e) {
|
|
|
187
187
|
}
|
|
188
188
|
return t;
|
|
189
189
|
}
|
|
190
|
-
function
|
|
190
|
+
function wt(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,7 +206,7 @@ function ht(e) {
|
|
|
206
206
|
}
|
|
207
207
|
return t;
|
|
208
208
|
}
|
|
209
|
-
function
|
|
209
|
+
function yt(e = {}, t = {}, r = {}) {
|
|
210
210
|
const o = {}, s = /* @__PURE__ */ new Set(), i = (n, l) => {
|
|
211
211
|
for (const u in n) {
|
|
212
212
|
if (s.has(u))
|
|
@@ -218,26 +218,26 @@ function wt(e = {}, t = {}, r = {}) {
|
|
|
218
218
|
};
|
|
219
219
|
return i(e, "string"), i(t, "bool"), i(r, "number"), o;
|
|
220
220
|
}
|
|
221
|
-
function
|
|
222
|
-
return
|
|
221
|
+
function Z(e) {
|
|
222
|
+
return yt(
|
|
223
223
|
e.define,
|
|
224
224
|
e["define-bool"],
|
|
225
225
|
e["define-number"]
|
|
226
226
|
);
|
|
227
227
|
}
|
|
228
|
-
const
|
|
229
|
-
function
|
|
228
|
+
const bt = Fe(be);
|
|
229
|
+
function gt(e) {
|
|
230
230
|
return new Promise((t) => {
|
|
231
231
|
if (e === 0) return t(!1);
|
|
232
|
-
const r =
|
|
232
|
+
const r = ge().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 Pt(e) {
|
|
240
|
+
const t = ge(), r = await new Promise((n, l) => {
|
|
241
241
|
const u = t.listen(e.port, () => {
|
|
242
242
|
const h = u.address();
|
|
243
243
|
h === null || typeof h == "string" ? l(new Error("Server address is not available")) : n(u);
|
|
@@ -247,19 +247,19 @@ async function gt(e) {
|
|
|
247
247
|
try {
|
|
248
248
|
const u = {
|
|
249
249
|
url: n.url,
|
|
250
|
-
headers:
|
|
250
|
+
headers: Et(n),
|
|
251
251
|
method: n.method,
|
|
252
|
-
body: await
|
|
252
|
+
body: await St(n)
|
|
253
253
|
}, h = await e.handleRequest(u);
|
|
254
|
-
await
|
|
254
|
+
await vt(h, l);
|
|
255
255
|
} catch (u) {
|
|
256
256
|
y.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 && xt(s, i), await e.onBind(r, s);
|
|
261
261
|
}
|
|
262
|
-
async function
|
|
262
|
+
async function vt(e, t) {
|
|
263
263
|
const [r, o] = await Promise.all([
|
|
264
264
|
e.headers,
|
|
265
265
|
e.httpStatusCode
|
|
@@ -267,16 +267,16 @@ async function Pt(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 = je.fromWeb(e.stdout);
|
|
271
271
|
try {
|
|
272
|
-
await
|
|
272
|
+
await Ve(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 St = 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 vt = async (e) => await new Promise((t) => {
|
|
|
284
284
|
t(new Uint8Array(Buffer.concat(r)));
|
|
285
285
|
});
|
|
286
286
|
});
|
|
287
|
-
async function
|
|
287
|
+
async function xt(e, t) {
|
|
288
288
|
y.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 bt(r);
|
|
293
293
|
return;
|
|
294
294
|
} catch {
|
|
295
295
|
await new Promise((s) => setTimeout(s, 2e3));
|
|
296
296
|
}
|
|
297
297
|
}
|
|
298
|
-
const
|
|
298
|
+
const Et = (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 $t(e) {
|
|
306
306
|
return /^latest$|^beta$|^trunk$|^nightly$|^(?:(\d+)\.(\d+)(?:\.(\d+))?)((?:-beta(?:\d+)?)|(?:-RC(?:\d+)?))?$/.test(e);
|
|
307
307
|
}
|
|
308
|
-
async function
|
|
308
|
+
async function Tt({
|
|
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 Le(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 $t({
|
|
|
324
324
|
const s = d.extname(r);
|
|
325
325
|
switch (s) {
|
|
326
326
|
case ".zip":
|
|
327
|
-
return
|
|
327
|
+
return Qe.fromArrayBuffer(
|
|
328
328
|
p.readFileSync(r).buffer
|
|
329
329
|
);
|
|
330
330
|
case ".json": {
|
|
@@ -336,9 +336,9 @@ async function $t({
|
|
|
336
336
|
`Blueprint file at ${r} is not a valid JSON file`
|
|
337
337
|
);
|
|
338
338
|
}
|
|
339
|
-
const n = d.dirname(r), l = new
|
|
340
|
-
return new
|
|
341
|
-
new
|
|
339
|
+
const n = d.dirname(r), l = new qe(n);
|
|
340
|
+
return new ze([
|
|
341
|
+
new Ge({
|
|
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 It {
|
|
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 Tt {
|
|
|
385
385
|
fileLockManagerPort: r,
|
|
386
386
|
nativeInternalDirPath: o
|
|
387
387
|
}) {
|
|
388
|
-
const s =
|
|
388
|
+
const s = he(t.phpPort);
|
|
389
389
|
await s.useFileLockManager(r);
|
|
390
390
|
const i = {
|
|
391
391
|
...this.args,
|
|
@@ -400,17 +400,17 @@ class Tt {
|
|
|
400
400
|
nativeInternalDirPath: o,
|
|
401
401
|
mountsBeforeWpInstall: this.args["mount-before-install"] || [],
|
|
402
402
|
mountsAfterWpInstall: this.args.mount || [],
|
|
403
|
-
constants:
|
|
403
|
+
constants: Z(this.args)
|
|
404
404
|
};
|
|
405
405
|
return await s.bootWorker(i), s;
|
|
406
406
|
}
|
|
407
407
|
}
|
|
408
|
-
const z = d.join(
|
|
409
|
-
async function
|
|
408
|
+
const z = d.join(X.homedir(), ".wordpress-playground");
|
|
409
|
+
async function kt() {
|
|
410
410
|
const e = typeof __dirname < "u" ? __dirname : import.meta.dirname;
|
|
411
411
|
let t = d.join(e, "sqlite-database-integration.zip");
|
|
412
412
|
if (!k.existsSync(t)) {
|
|
413
|
-
const r =
|
|
413
|
+
const r = Ke(import.meta.url), o = d.dirname(
|
|
414
414
|
r.resolve("@wp-playground/wordpress-builds/package.json")
|
|
415
415
|
);
|
|
416
416
|
t = d.join(
|
|
@@ -422,11 +422,11 @@ async function It() {
|
|
|
422
422
|
}
|
|
423
423
|
return new File([await k.readFile(t)], d.basename(t));
|
|
424
424
|
}
|
|
425
|
-
async function
|
|
425
|
+
async function Mt(e, t, r) {
|
|
426
426
|
const o = d.join(z, t);
|
|
427
|
-
return k.existsSync(o) || (k.ensureDirSync(z), await
|
|
427
|
+
return k.existsSync(o) || (k.ensureDirSync(z), await Ct(e, o, r)), ve(o);
|
|
428
428
|
}
|
|
429
|
-
async function
|
|
429
|
+
async function Ct(e, t, r) {
|
|
430
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();
|
|
@@ -441,10 +441,10 @@ async function Mt(e, t, r) {
|
|
|
441
441
|
});
|
|
442
442
|
});
|
|
443
443
|
}
|
|
444
|
-
function
|
|
444
|
+
function ve(e, t) {
|
|
445
445
|
return new File([k.readFileSync(e)], _(e));
|
|
446
446
|
}
|
|
447
|
-
class
|
|
447
|
+
class At {
|
|
448
448
|
constructor(t, r) {
|
|
449
449
|
this.args = t, this.siteUrl = r.siteUrl, this.cliOutput = r.cliOutput;
|
|
450
450
|
}
|
|
@@ -453,7 +453,7 @@ class Ct {
|
|
|
453
453
|
}
|
|
454
454
|
async bootWordPress(t, r) {
|
|
455
455
|
let o, s, i;
|
|
456
|
-
const n = new
|
|
456
|
+
const n = new Xe();
|
|
457
457
|
if (this.args.wordpressInstallMode === "download-and-install") {
|
|
458
458
|
let h = !1;
|
|
459
459
|
n.addEventListener("progress", (M) => {
|
|
@@ -466,10 +466,10 @@ class Ct {
|
|
|
466
466
|
"Downloading WordPress",
|
|
467
467
|
w
|
|
468
468
|
);
|
|
469
|
-
}), o = await
|
|
469
|
+
}), o = await Je(this.args.wp), i = d.join(
|
|
470
470
|
z,
|
|
471
471
|
`prebuilt-wp-content-for-wp-${o.version}.zip`
|
|
472
|
-
), s = p.existsSync(i) ?
|
|
472
|
+
), s = p.existsSync(i) ? ve(i) : await Mt(
|
|
473
473
|
o.releaseUrl,
|
|
474
474
|
`${o.version}.zip`,
|
|
475
475
|
n
|
|
@@ -478,8 +478,8 @@ class Ct {
|
|
|
478
478
|
);
|
|
479
479
|
}
|
|
480
480
|
let l;
|
|
481
|
-
this.args.skipSqliteSetup ? (y.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 ? (y.debug("Skipping SQLite integration plugin setup..."), l = void 0) : (this.cliOutput.updateProgress("Preparing SQLite database"), l = await kt()), this.cliOutput.updateProgress("Booting WordPress");
|
|
482
|
+
const u = await se(
|
|
483
483
|
this.getEffectiveBlueprint()
|
|
484
484
|
);
|
|
485
485
|
return await t.bootWordPress(
|
|
@@ -489,14 +489,14 @@ class Ct {
|
|
|
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: Z(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 Ue(
|
|
500
500
|
t,
|
|
501
501
|
"/wordpress"
|
|
502
502
|
)
|
|
@@ -507,11 +507,11 @@ class Ct {
|
|
|
507
507
|
fileLockManagerPort: r,
|
|
508
508
|
nativeInternalDirPath: o
|
|
509
509
|
}) {
|
|
510
|
-
const s =
|
|
510
|
+
const s = he(
|
|
511
511
|
t.phpPort
|
|
512
512
|
);
|
|
513
513
|
await s.isConnected();
|
|
514
|
-
const i = await
|
|
514
|
+
const i = await se(
|
|
515
515
|
this.getEffectiveBlueprint()
|
|
516
516
|
);
|
|
517
517
|
return await s.useFileLockManager(r), await s.bootRequestHandler({
|
|
@@ -531,7 +531,7 @@ class Ct {
|
|
|
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 Ze();
|
|
535
535
|
let s = "", i = !1;
|
|
536
536
|
return o.addEventListener("progress", (n) => {
|
|
537
537
|
if (i)
|
|
@@ -539,14 +539,14 @@ class Ct {
|
|
|
539
539
|
i = n.detail.progress === 100;
|
|
540
540
|
const l = Math.floor(n.detail.progress);
|
|
541
541
|
s = n.detail.caption || s || "Running Blueprint", this.cliOutput.updateProgress(s.trim(), l);
|
|
542
|
-
}), await
|
|
542
|
+
}), await we(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 _e(t) ? t : {
|
|
550
550
|
login: this.args.login,
|
|
551
551
|
...t || {},
|
|
552
552
|
preferredVersions: {
|
|
@@ -558,7 +558,7 @@ class Ct {
|
|
|
558
558
|
}
|
|
559
559
|
}
|
|
560
560
|
async function Bt(e, t = !0) {
|
|
561
|
-
const o = `${d.basename(process.argv0)}${e}${process.pid}-`, s = await
|
|
561
|
+
const o = `${d.basename(process.argv0)}${e}${process.pid}-`, s = await tt({
|
|
562
562
|
prefix: o,
|
|
563
563
|
/*
|
|
564
564
|
* Allow recursive cleanup on process exit.
|
|
@@ -570,10 +570,10 @@ async function Bt(e, t = !0) {
|
|
|
570
570
|
*/
|
|
571
571
|
unsafeCleanup: !0
|
|
572
572
|
});
|
|
573
|
-
return t &&
|
|
573
|
+
return t && rt(), s;
|
|
574
574
|
}
|
|
575
|
-
async function
|
|
576
|
-
const s = (await
|
|
575
|
+
async function Dt(e, t, r) {
|
|
576
|
+
const s = (await Rt(
|
|
577
577
|
e,
|
|
578
578
|
t,
|
|
579
579
|
r
|
|
@@ -591,11 +591,11 @@ async function At(e, t, r) {
|
|
|
591
591
|
);
|
|
592
592
|
await Promise.all(s);
|
|
593
593
|
}
|
|
594
|
-
async function
|
|
594
|
+
async function Rt(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 Wt(
|
|
599
599
|
e,
|
|
600
600
|
t,
|
|
601
601
|
i
|
|
@@ -605,7 +605,7 @@ async function Dt(e, t, r) {
|
|
|
605
605
|
return y.warn(`Failed to find stale Playground temp dirs: ${o}`), [];
|
|
606
606
|
}
|
|
607
607
|
}
|
|
608
|
-
async function
|
|
608
|
+
async function Wt(e, t, r) {
|
|
609
609
|
if (!p.lstatSync(r).isDirectory())
|
|
610
610
|
return !1;
|
|
611
611
|
const s = d.basename(r);
|
|
@@ -620,12 +620,12 @@ async function Rt(e, t, r) {
|
|
|
620
620
|
executableName: i[1],
|
|
621
621
|
pid: i[2]
|
|
622
622
|
};
|
|
623
|
-
if (
|
|
623
|
+
if (Lt(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 Lt(e, t) {
|
|
629
629
|
try {
|
|
630
630
|
return process.kill(Number(e), 0), !0;
|
|
631
631
|
} catch (r) {
|
|
@@ -639,10 +639,10 @@ function Wt(e, t) {
|
|
|
639
639
|
), !0);
|
|
640
640
|
}
|
|
641
641
|
}
|
|
642
|
-
function
|
|
642
|
+
function _t(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 Ut {
|
|
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 _t {
|
|
|
656
656
|
* This prevents progress spam in logs - users only see the final outcome.
|
|
657
657
|
*/
|
|
658
658
|
get shouldRender() {
|
|
659
|
-
return
|
|
659
|
+
return _t(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
|
|
808
|
+
const J = {
|
|
809
809
|
Quiet: { name: "quiet", severity: F.Fatal },
|
|
810
810
|
Normal: { name: "normal", severity: F.Info },
|
|
811
811
|
Debug: { name: "debug", severity: F.Debug }
|
|
812
812
|
};
|
|
813
|
-
async function
|
|
813
|
+
async function Ht(e) {
|
|
814
814
|
try {
|
|
815
815
|
const t = {
|
|
816
816
|
"site-url": {
|
|
@@ -833,21 +833,21 @@ async function Ut(e) {
|
|
|
833
833
|
type: "string",
|
|
834
834
|
nargs: 2,
|
|
835
835
|
array: !0,
|
|
836
|
-
coerce:
|
|
836
|
+
coerce: ft
|
|
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: ht
|
|
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: wt
|
|
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
|
|
@@ -870,14 +870,14 @@ async function Ut(e) {
|
|
|
870
870
|
type: "array",
|
|
871
871
|
nargs: 2,
|
|
872
872
|
array: !0,
|
|
873
|
-
coerce:
|
|
873
|
+
coerce: ce
|
|
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: ce
|
|
881
881
|
},
|
|
882
882
|
login: {
|
|
883
883
|
describe: "Should log the user in",
|
|
@@ -924,7 +924,7 @@ async function Ut(e) {
|
|
|
924
924
|
verbosity: {
|
|
925
925
|
describe: "Output logs and progress messages.",
|
|
926
926
|
type: "string",
|
|
927
|
-
choices: Object.values(
|
|
927
|
+
choices: Object.values(J).map(
|
|
928
928
|
(a) => a.name
|
|
929
929
|
),
|
|
930
930
|
default: "normal"
|
|
@@ -1099,7 +1099,7 @@ 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 = Ye(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(
|
|
@@ -1147,7 +1147,7 @@ Examples:
|
|
|
1147
1147
|
a && a.includes("Please specify a command") && (P.showHelp(), console.error(`
|
|
1148
1148
|
` + a), process.exit(1)), console.error(a), process.exit(1);
|
|
1149
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" &&
|
|
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" && !$t(a.wp))
|
|
1151
1151
|
try {
|
|
1152
1152
|
new URL(a.wp);
|
|
1153
1153
|
} catch {
|
|
@@ -1211,7 +1211,7 @@ Examples:
|
|
|
1211
1211
|
...n["mount-before-install"] || [],
|
|
1212
1212
|
...n["mount-dir-before-install"] || []
|
|
1213
1213
|
]
|
|
1214
|
-
}, w = await
|
|
1214
|
+
}, w = await xe(x);
|
|
1215
1215
|
w === void 0 && process.exit(0);
|
|
1216
1216
|
const T = /* @__PURE__ */ (() => {
|
|
1217
1217
|
let a;
|
|
@@ -1223,14 +1223,14 @@ Examples:
|
|
|
1223
1223
|
[Symbol.asyncDispose]: async () => {
|
|
1224
1224
|
process.off("SIGINT", T), process.off("SIGTERM", T), await w[Symbol.asyncDispose]();
|
|
1225
1225
|
},
|
|
1226
|
-
[
|
|
1226
|
+
[K]: { cliServer: w }
|
|
1227
1227
|
};
|
|
1228
1228
|
} catch (t) {
|
|
1229
1229
|
console.error(t);
|
|
1230
1230
|
const r = process.argv.includes("--debug");
|
|
1231
1231
|
if (t instanceof Error)
|
|
1232
1232
|
if (r)
|
|
1233
|
-
|
|
1233
|
+
Me(t);
|
|
1234
1234
|
else {
|
|
1235
1235
|
const o = [];
|
|
1236
1236
|
let s = t;
|
|
@@ -1242,11 +1242,11 @@ Examples:
|
|
|
1242
1242
|
);
|
|
1243
1243
|
}
|
|
1244
1244
|
else
|
|
1245
|
-
console.error("\x1B[1m" +
|
|
1245
|
+
console.error("\x1B[1m" + Se(t) + "\x1B[0m");
|
|
1246
1246
|
process.exit(1);
|
|
1247
1247
|
}
|
|
1248
1248
|
}
|
|
1249
|
-
function
|
|
1249
|
+
function Se(e) {
|
|
1250
1250
|
if (e instanceof Error)
|
|
1251
1251
|
return e.message;
|
|
1252
1252
|
if (e && typeof e == "object") {
|
|
@@ -1261,28 +1261,28 @@ function ve(e) {
|
|
|
1261
1261
|
}
|
|
1262
1262
|
return String(e);
|
|
1263
1263
|
}
|
|
1264
|
-
function
|
|
1264
|
+
function me(e, t) {
|
|
1265
1265
|
return e.find(
|
|
1266
1266
|
(r) => r.vfsPath.replace(/\/$/, "") === t.replace(/\/$/, "")
|
|
1267
1267
|
);
|
|
1268
1268
|
}
|
|
1269
|
-
const
|
|
1270
|
-
async function
|
|
1269
|
+
const K = Symbol("playground-cli-testing"), C = (e) => process.stdout.isTTY ? "\x1B[1m" + e + "\x1B[0m" : e, Nt = (e) => process.stdout.isTTY ? "\x1B[31m" + e + "\x1B[0m" : e, fe = (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;
|
|
1270
|
+
async function xe(e) {
|
|
1271
1271
|
let t;
|
|
1272
|
-
const r = e.internalCookieStore ? new
|
|
1273
|
-
if (e.command === "start" && (e =
|
|
1274
|
-
const c = Object.values(
|
|
1272
|
+
const r = e.internalCookieStore ? new Ce() : void 0, o = [], s = /* @__PURE__ */ new Map();
|
|
1273
|
+
if (e.command === "start" && (e = Ot(e)), e.autoMount !== void 0 && (e.autoMount === "" && (e = { ...e, autoMount: process.cwd() }), e = Pe(e)), e.wordpressInstallMode === void 0 && (e.wordpressInstallMode = "download-and-install"), e.quiet && (e.verbosity = "quiet", delete e.quiet), e.debug && (e.verbosity = "debug", delete e.debug), e.verbosity) {
|
|
1274
|
+
const c = Object.values(J).find(
|
|
1275
1275
|
(x) => x.name === e.verbosity
|
|
1276
1276
|
).severity;
|
|
1277
1277
|
y.setSeverityFilterLevel(c);
|
|
1278
1278
|
}
|
|
1279
|
-
e.intl || (e.intl = !0), e.redis === void 0 && (e.redis = await
|
|
1279
|
+
e.intl || (e.intl = !0), e.redis === void 0 && (e.redis = await de()), e.memcached === void 0 && (e.memcached = await de()), e.phpmyadmin && (e.phpmyadmin === !0 && (e.phpmyadmin = "/phpmyadmin"), e.pathAliases = [
|
|
1280
1280
|
{
|
|
1281
1281
|
urlPrefix: e.phpmyadmin,
|
|
1282
|
-
fsPath:
|
|
1282
|
+
fsPath: ue
|
|
1283
1283
|
}
|
|
1284
1284
|
]);
|
|
1285
|
-
const i = new
|
|
1285
|
+
const i = new Ut({
|
|
1286
1286
|
verbosity: e.verbosity || "normal"
|
|
1287
1287
|
});
|
|
1288
1288
|
e.command === "server" && (i.printBanner(), i.printConfig({
|
|
@@ -1299,59 +1299,53 @@ async function Se(e) {
|
|
|
1299
1299
|
],
|
|
1300
1300
|
blueprint: typeof e.blueprint == "string" ? e.blueprint : void 0
|
|
1301
1301
|
}));
|
|
1302
|
-
const n = e.command === "server" ? e.port ?? 9400 : 0, l = new
|
|
1302
|
+
const n = e.command === "server" ? e.port ?? 9400 : 0, l = new Ae();
|
|
1303
1303
|
let u = !1, h = !0;
|
|
1304
|
-
const M = await
|
|
1305
|
-
port: e.port ? e.port : await
|
|
1304
|
+
const M = await Pt({
|
|
1305
|
+
port: e.port ? e.port : await gt(n) ? 0 : n,
|
|
1306
1306
|
onBind: async (c, x) => {
|
|
1307
1307
|
const w = "127.0.0.1", T = `http://${w}:${x}`, a = e["site-url"] || T, E = 6, P = "-playground-cli-site-", I = await Bt(P);
|
|
1308
1308
|
y.debug(`Native temp dir for VFS root: ${I.path}`);
|
|
1309
|
-
const R = "WP Playground CLI - Listen for Xdebug",
|
|
1310
|
-
if (await
|
|
1309
|
+
const R = "WP Playground CLI - Listen for Xdebug", ee = ".playground-xdebug-root", H = d.join(process.cwd(), ee);
|
|
1310
|
+
if (await ot(H), e.xdebug) {
|
|
1311
1311
|
const m = {
|
|
1312
|
-
hostPath: d.join(".", d.sep,
|
|
1312
|
+
hostPath: d.join(".", d.sep, ee),
|
|
1313
1313
|
vfsPath: "/"
|
|
1314
1314
|
};
|
|
1315
1315
|
if (U.indexOf(
|
|
1316
1316
|
e.php || D
|
|
1317
1317
|
) <= U.indexOf("8.5"))
|
|
1318
|
-
await
|
|
1318
|
+
await ae(
|
|
1319
1319
|
I.path,
|
|
1320
1320
|
H,
|
|
1321
1321
|
process.platform
|
|
1322
|
-
), e.xdebug =
|
|
1322
|
+
), e.xdebug = st({
|
|
1323
1323
|
cwd: process.cwd(),
|
|
1324
1324
|
mounts: [
|
|
1325
1325
|
m,
|
|
1326
1326
|
...e["mount-before-install"] || [],
|
|
1327
1327
|
...e.mount || []
|
|
1328
1328
|
],
|
|
1329
|
-
pathSkippings: [
|
|
1330
|
-
"/dev/",
|
|
1331
|
-
"/home/",
|
|
1332
|
-
"/internal/",
|
|
1333
|
-
"/request/",
|
|
1334
|
-
"/proc/"
|
|
1335
|
-
]
|
|
1329
|
+
pathSkippings: [...le]
|
|
1336
1330
|
}), console.log(C("Xdebug configured successfully")), console.log(
|
|
1337
1331
|
V("Playground source root: ") + ".playground-xdebug-root" + L(
|
|
1338
|
-
|
|
1332
|
+
fe(
|
|
1339
1333
|
" – you can set breakpoints and preview Playground's VFS structure in there."
|
|
1340
1334
|
)
|
|
1341
1335
|
)
|
|
1342
1336
|
);
|
|
1343
1337
|
else if (e.experimentalUnsafeIdeIntegration) {
|
|
1344
|
-
await
|
|
1338
|
+
await ae(
|
|
1345
1339
|
I.path,
|
|
1346
1340
|
H,
|
|
1347
1341
|
process.platform
|
|
1348
1342
|
);
|
|
1349
1343
|
try {
|
|
1350
|
-
await
|
|
1344
|
+
await it(
|
|
1351
1345
|
R,
|
|
1352
1346
|
process.cwd()
|
|
1353
1347
|
);
|
|
1354
|
-
const f = typeof e.xdebug == "object" ? e.xdebug : {}, b = await
|
|
1348
|
+
const f = typeof e.xdebug == "object" ? e.xdebug : {}, b = await nt({
|
|
1355
1349
|
name: R,
|
|
1356
1350
|
host: w,
|
|
1357
1351
|
port: x,
|
|
@@ -1362,6 +1356,7 @@ async function Se(e) {
|
|
|
1362
1356
|
...e["mount-before-install"] || [],
|
|
1363
1357
|
...e.mount || []
|
|
1364
1358
|
],
|
|
1359
|
+
pathSkippings: [...le],
|
|
1365
1360
|
ideKey: f.ideKey || "WPPLAYGROUNDCLI"
|
|
1366
1361
|
}), v = e.experimentalUnsafeIdeIntegration, S = v.includes("vscode"), $ = v.includes("phpstorm"), W = Object.values(b);
|
|
1367
1362
|
console.log(""), W.length > 0 ? (console.log(
|
|
@@ -1370,7 +1365,7 @@ async function Se(e) {
|
|
|
1370
1365
|
V("Updated IDE config: ") + W.join(" ")
|
|
1371
1366
|
), console.log(
|
|
1372
1367
|
V("Playground source root: ") + ".playground-xdebug-root" + L(
|
|
1373
|
-
|
|
1368
|
+
fe(
|
|
1374
1369
|
" – you can set breakpoints and preview Playground's VFS structure in there."
|
|
1375
1370
|
)
|
|
1376
1371
|
)
|
|
@@ -1414,15 +1409,15 @@ async function Se(e) {
|
|
|
1414
1409
|
}
|
|
1415
1410
|
}
|
|
1416
1411
|
}
|
|
1417
|
-
const
|
|
1418
|
-
|
|
1412
|
+
const $e = d.dirname(I.path), Te = 2 * 24 * 60 * 60 * 1e3;
|
|
1413
|
+
Dt(
|
|
1419
1414
|
P,
|
|
1420
|
-
|
|
1421
|
-
|
|
1415
|
+
Te,
|
|
1416
|
+
$e
|
|
1422
1417
|
);
|
|
1423
|
-
const
|
|
1424
|
-
q(
|
|
1425
|
-
const
|
|
1418
|
+
const te = d.join(I.path, "internal");
|
|
1419
|
+
q(te);
|
|
1420
|
+
const Ie = [
|
|
1426
1421
|
"wordpress",
|
|
1427
1422
|
"tools",
|
|
1428
1423
|
// Note: These dirs are from Emscripten's "default dirs" list:
|
|
@@ -1434,7 +1429,7 @@ async function Se(e) {
|
|
|
1434
1429
|
"tmp",
|
|
1435
1430
|
"home"
|
|
1436
1431
|
];
|
|
1437
|
-
for (const m of
|
|
1432
|
+
for (const m of Ie) {
|
|
1438
1433
|
const g = (b) => b.vfsPath === `/${m}`;
|
|
1439
1434
|
if (!(e["mount-before-install"]?.some(g) || e.mount?.some(g))) {
|
|
1440
1435
|
const b = d.join(
|
|
@@ -1457,19 +1452,19 @@ async function Se(e) {
|
|
|
1457
1452
|
y.debug(
|
|
1458
1453
|
`Mount after WP install: ${m.vfsPath} -> ${m.hostPath}`
|
|
1459
1454
|
);
|
|
1460
|
-
let
|
|
1461
|
-
e["experimental-blueprints-v2-runner"] ?
|
|
1455
|
+
let A;
|
|
1456
|
+
e["experimental-blueprints-v2-runner"] ? A = new It(e, {
|
|
1462
1457
|
siteUrl: a,
|
|
1463
1458
|
cliOutput: i
|
|
1464
|
-
}) : (
|
|
1459
|
+
}) : (A = new At(e, {
|
|
1465
1460
|
siteUrl: a,
|
|
1466
1461
|
cliOutput: i
|
|
1467
|
-
}), typeof e.blueprint == "string" && (e.blueprint = await
|
|
1462
|
+
}), typeof e.blueprint == "string" && (e.blueprint = await Tt({
|
|
1468
1463
|
sourceString: e.blueprint,
|
|
1469
1464
|
blueprintMayReadAdjacentFiles: e["blueprint-may-read-adjacent-files"] === !0
|
|
1470
1465
|
})));
|
|
1471
1466
|
let N = !1;
|
|
1472
|
-
const
|
|
1467
|
+
const B = async function() {
|
|
1473
1468
|
N || (N = !0, await Promise.all(
|
|
1474
1469
|
o.map(async (g) => {
|
|
1475
1470
|
await s.get(g)?.dispose(), await g.worker.terminate();
|
|
@@ -1479,9 +1474,9 @@ async function Se(e) {
|
|
|
1479
1474
|
}), await I.cleanup());
|
|
1480
1475
|
};
|
|
1481
1476
|
try {
|
|
1482
|
-
const m = [], g =
|
|
1477
|
+
const m = [], g = A.getWorkerType();
|
|
1483
1478
|
for (let f = 0; f < E; f++) {
|
|
1484
|
-
const b =
|
|
1479
|
+
const b = Ee(g, {
|
|
1485
1480
|
onExit: (v) => {
|
|
1486
1481
|
N || v !== 0 && y.error(
|
|
1487
1482
|
`Worker ${f} exited with code ${v}
|
|
@@ -1491,10 +1486,10 @@ async function Se(e) {
|
|
|
1491
1486
|
}).then(
|
|
1492
1487
|
async (v) => {
|
|
1493
1488
|
o.push(v);
|
|
1494
|
-
const S = await
|
|
1489
|
+
const S = await Ft(l), $ = await A.bootRequestHandler({
|
|
1495
1490
|
worker: v,
|
|
1496
1491
|
fileLockManagerPort: S,
|
|
1497
|
-
nativeInternalDirPath:
|
|
1492
|
+
nativeInternalDirPath: te
|
|
1498
1493
|
});
|
|
1499
1494
|
return s.set(
|
|
1500
1495
|
v,
|
|
@@ -1510,8 +1505,8 @@ async function Se(e) {
|
|
|
1510
1505
|
)
|
|
1511
1506
|
);
|
|
1512
1507
|
{
|
|
1513
|
-
const f = new
|
|
1514
|
-
if (await
|
|
1508
|
+
const f = new ye(), b = f.port1, v = f.port2;
|
|
1509
|
+
if (await De(
|
|
1515
1510
|
{
|
|
1516
1511
|
applyPostInstallMountsToAllWorkers: async () => {
|
|
1517
1512
|
for (const S of s.values())
|
|
@@ -1522,29 +1517,29 @@ async function Se(e) {
|
|
|
1522
1517
|
},
|
|
1523
1518
|
void 0,
|
|
1524
1519
|
b
|
|
1525
|
-
), await
|
|
1520
|
+
), await A.bootWordPress(
|
|
1526
1521
|
t,
|
|
1527
1522
|
v
|
|
1528
1523
|
), b.close(), u = !0, !e["experimental-blueprints-v2-runner"]) {
|
|
1529
|
-
const S = await
|
|
1524
|
+
const S = await A.compileInputBlueprint(
|
|
1530
1525
|
e["additional-blueprint-steps"] || []
|
|
1531
1526
|
);
|
|
1532
|
-
S && await
|
|
1527
|
+
S && await ie(
|
|
1533
1528
|
S,
|
|
1534
1529
|
t
|
|
1535
1530
|
);
|
|
1536
1531
|
}
|
|
1537
1532
|
if (e.phpmyadmin && !await t.fileExists(
|
|
1538
|
-
`${
|
|
1533
|
+
`${ue}/index.php`
|
|
1539
1534
|
)) {
|
|
1540
|
-
const S = await
|
|
1541
|
-
await
|
|
1535
|
+
const S = await lt(), $ = await we({ steps: S });
|
|
1536
|
+
await ie($, t);
|
|
1542
1537
|
}
|
|
1543
1538
|
if (e.command === "build-snapshot") {
|
|
1544
|
-
await
|
|
1539
|
+
await Vt(t, e.outfile), i.printStatus(`Exported to ${e.outfile}`), await B();
|
|
1545
1540
|
return;
|
|
1546
1541
|
} else if (e.command === "run-blueprint") {
|
|
1547
|
-
i.finishProgress("Done"), await
|
|
1542
|
+
i.finishProgress("Done"), await B();
|
|
1548
1543
|
return;
|
|
1549
1544
|
} else if (e.command === "php") {
|
|
1550
1545
|
const S = [
|
|
@@ -1569,27 +1564,27 @@ async function Se(e) {
|
|
|
1569
1564
|
})
|
|
1570
1565
|
)
|
|
1571
1566
|
]);
|
|
1572
|
-
await
|
|
1567
|
+
await B(), process.exit(W);
|
|
1573
1568
|
}
|
|
1574
1569
|
}
|
|
1575
1570
|
if (i.finishProgress(), i.printReady(T, E), e.phpmyadmin) {
|
|
1576
1571
|
const f = d.join(
|
|
1577
1572
|
e.phpmyadmin,
|
|
1578
|
-
|
|
1573
|
+
ut
|
|
1579
1574
|
);
|
|
1580
1575
|
i.printPhpMyAdminUrl(
|
|
1581
1576
|
new URL(f, T).toString()
|
|
1582
1577
|
);
|
|
1583
1578
|
}
|
|
1584
|
-
return e.xdebug && e.experimentalDevtools && (await
|
|
1579
|
+
return e.xdebug && e.experimentalDevtools && (await et({
|
|
1585
1580
|
phpInstance: t,
|
|
1586
1581
|
phpRoot: "/wordpress"
|
|
1587
1582
|
})).start(), {
|
|
1588
1583
|
playground: t,
|
|
1589
1584
|
server: c,
|
|
1590
1585
|
serverUrl: T,
|
|
1591
|
-
[Symbol.asyncDispose]:
|
|
1592
|
-
[
|
|
1586
|
+
[Symbol.asyncDispose]: B,
|
|
1587
|
+
[K]: {
|
|
1593
1588
|
workerThreadCount: E
|
|
1594
1589
|
}
|
|
1595
1590
|
};
|
|
@@ -1597,12 +1592,12 @@ async function Se(e) {
|
|
|
1597
1592
|
if (e.verbosity !== "debug")
|
|
1598
1593
|
throw m;
|
|
1599
1594
|
let g = "";
|
|
1600
|
-
throw await t?.fileExists(
|
|
1595
|
+
throw await t?.fileExists(re) && (g = await t.readFileAsText(re)), await B(), new Error(g, { cause: m });
|
|
1601
1596
|
}
|
|
1602
1597
|
},
|
|
1603
1598
|
async handleRequest(c) {
|
|
1604
1599
|
if (!u)
|
|
1605
|
-
return
|
|
1600
|
+
return oe.forHttpCode(
|
|
1606
1601
|
502,
|
|
1607
1602
|
"WordPress is not ready yet"
|
|
1608
1603
|
);
|
|
@@ -1617,8 +1612,8 @@ async function Se(e) {
|
|
|
1617
1612
|
"playground_auto_login_already_happened"
|
|
1618
1613
|
) && (w["Set-Cookie"] = [
|
|
1619
1614
|
"playground_auto_login_already_happened=1; Max-Age=0; Expires=Thu, 01 Jan 1970 00:00:00 GMT; Path=/"
|
|
1620
|
-
]),
|
|
1621
|
-
new
|
|
1615
|
+
]), oe.fromPHPResponse(
|
|
1616
|
+
new Re(302, w, new Uint8Array())
|
|
1622
1617
|
);
|
|
1623
1618
|
}
|
|
1624
1619
|
r && (c = {
|
|
@@ -1641,20 +1636,20 @@ async function Se(e) {
|
|
|
1641
1636
|
return x;
|
|
1642
1637
|
}
|
|
1643
1638
|
}).catch((c) => {
|
|
1644
|
-
i.printError(
|
|
1639
|
+
i.printError(Se(c)), process.exit(1);
|
|
1645
1640
|
});
|
|
1646
|
-
return M && e.command === "start" && !e.skipBrowser &&
|
|
1641
|
+
return M && e.command === "start" && !e.skipBrowser && jt(M.serverUrl), M;
|
|
1647
1642
|
}
|
|
1648
|
-
function
|
|
1643
|
+
function Ot(e) {
|
|
1649
1644
|
let t = { ...e, command: "server" };
|
|
1650
|
-
e.noAutoMount || (t.autoMount = d.resolve(process.cwd(), t.path ?? ""), t =
|
|
1651
|
-
const r =
|
|
1645
|
+
e.noAutoMount || (t.autoMount = d.resolve(process.cwd(), t.path ?? ""), t = Pe(t), delete t.autoMount);
|
|
1646
|
+
const r = me(
|
|
1652
1647
|
t["mount-before-install"] || [],
|
|
1653
1648
|
"/wordpress"
|
|
1654
|
-
) ||
|
|
1649
|
+
) || me(t.mount || [], "/wordpress");
|
|
1655
1650
|
if (r)
|
|
1656
1651
|
console.log("Site files stored at:", r?.hostPath), e.reset && (console.log(""), console.log(
|
|
1657
|
-
|
|
1652
|
+
Nt(
|
|
1658
1653
|
"This site is not managed by Playground CLI and cannot be reset."
|
|
1659
1654
|
)
|
|
1660
1655
|
), console.log(
|
|
@@ -1663,15 +1658,15 @@ function Nt(e) {
|
|
|
1663
1658
|
"You may still remove the site's directory manually if you wish."
|
|
1664
1659
|
), process.exit(1));
|
|
1665
1660
|
else {
|
|
1666
|
-
const o = t.autoMount || process.cwd(), s =
|
|
1661
|
+
const o = t.autoMount || process.cwd(), s = at("sha256").update(o).digest("hex"), i = X.homedir(), n = d.join(
|
|
1667
1662
|
i,
|
|
1668
1663
|
".wordpress-playground/sites",
|
|
1669
1664
|
s
|
|
1670
1665
|
);
|
|
1671
|
-
console.log("Site files stored at:", n), G(n) && e.reset && (console.log("Resetting site..."),
|
|
1666
|
+
console.log("Site files stored at:", n), G(n) && e.reset && (console.log("Resetting site..."), He(n, { recursive: !0 })), q(n, { recursive: !0 }), t["mount-before-install"] = [
|
|
1672
1667
|
...t["mount-before-install"] || [],
|
|
1673
1668
|
{ vfsPath: "/wordpress", hostPath: n }
|
|
1674
|
-
], t.wordpressInstallMode =
|
|
1669
|
+
], t.wordpressInstallMode = Ne(n).length === 0 ? (
|
|
1675
1670
|
// Only download WordPress on the first run when the site directory is still
|
|
1676
1671
|
// empty.
|
|
1677
1672
|
"download-and-install"
|
|
@@ -1682,10 +1677,10 @@ function Nt(e) {
|
|
|
1682
1677
|
}
|
|
1683
1678
|
return t;
|
|
1684
1679
|
}
|
|
1685
|
-
const Y = new
|
|
1686
|
-
function
|
|
1680
|
+
const Y = new ke();
|
|
1681
|
+
function Ee(e, { onExit: t } = {}) {
|
|
1687
1682
|
let r;
|
|
1688
|
-
return e === "v1" ? r = new
|
|
1683
|
+
return e === "v1" ? r = new ne(new URL("./worker-thread-v1.js", import.meta.url)) : r = new ne(new URL("./worker-thread-v2.js", import.meta.url)), new Promise((o, s) => {
|
|
1689
1684
|
const i = Y.claim();
|
|
1690
1685
|
r.once("message", function(l) {
|
|
1691
1686
|
l.command === "worker-script-initialized" && o({
|
|
@@ -1709,12 +1704,12 @@ function xe(e, { onExit: t } = {}) {
|
|
|
1709
1704
|
});
|
|
1710
1705
|
});
|
|
1711
1706
|
}
|
|
1712
|
-
async function
|
|
1713
|
-
const { port1: t, port2: r } = new
|
|
1714
|
-
return await
|
|
1707
|
+
async function Ft(e) {
|
|
1708
|
+
const { port1: t, port2: r } = new ye();
|
|
1709
|
+
return await We(e, t), r;
|
|
1715
1710
|
}
|
|
1716
|
-
function
|
|
1717
|
-
const t =
|
|
1711
|
+
function jt(e) {
|
|
1712
|
+
const t = X.platform();
|
|
1718
1713
|
let r;
|
|
1719
1714
|
switch (t) {
|
|
1720
1715
|
case "darwin":
|
|
@@ -1727,11 +1722,11 @@ function Ft(e) {
|
|
|
1727
1722
|
r = `xdg-open "${e}"`;
|
|
1728
1723
|
break;
|
|
1729
1724
|
}
|
|
1730
|
-
|
|
1725
|
+
be(r, (o) => {
|
|
1731
1726
|
o && y.debug(`Could not open browser: ${o.message}`);
|
|
1732
1727
|
});
|
|
1733
1728
|
}
|
|
1734
|
-
async function
|
|
1729
|
+
async function Vt(e, t) {
|
|
1735
1730
|
await e.run({
|
|
1736
1731
|
code: `<?php
|
|
1737
1732
|
$zip = new ZipArchive();
|
|
@@ -1755,24 +1750,24 @@ async function jt(e, t) {
|
|
|
1755
1750
|
const r = await e.readFileAsBuffer("/tmp/build.zip");
|
|
1756
1751
|
p.writeFileSync(t, r);
|
|
1757
1752
|
}
|
|
1758
|
-
const
|
|
1753
|
+
const gr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
1759
1754
|
__proto__: null,
|
|
1760
|
-
LogVerbosity:
|
|
1761
|
-
internalsKeyForTesting:
|
|
1762
|
-
mergeDefinedConstants:
|
|
1763
|
-
parseOptionsAndRunCLI:
|
|
1764
|
-
runCLI:
|
|
1765
|
-
spawnWorkerThread:
|
|
1755
|
+
LogVerbosity: J,
|
|
1756
|
+
internalsKeyForTesting: K,
|
|
1757
|
+
mergeDefinedConstants: Z,
|
|
1758
|
+
parseOptionsAndRunCLI: Ht,
|
|
1759
|
+
runCLI: xe,
|
|
1760
|
+
spawnWorkerThread: Ee
|
|
1766
1761
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
1767
1762
|
export {
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1763
|
+
J as L,
|
|
1764
|
+
br as a,
|
|
1765
|
+
_t as b,
|
|
1766
|
+
gr as c,
|
|
1767
|
+
K as i,
|
|
1768
|
+
Z as m,
|
|
1769
|
+
Ht as p,
|
|
1770
|
+
xe as r,
|
|
1771
|
+
Ee as s
|
|
1777
1772
|
};
|
|
1778
|
-
//# sourceMappingURL=run-cli-
|
|
1773
|
+
//# sourceMappingURL=run-cli-B9kBDU12.js.map
|