@wp-playground/cli 3.1.16 → 3.1.17
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/is-valid-wordpress-slug.d.ts +1 -0
- package/package.json +14 -14
- package/{run-cli-CaJWk9j8.js → run-cli-CrCfo8mJ.js} +229 -215
- package/run-cli-CrCfo8mJ.js.map +1 -0
- package/{run-cli-BpNO572W.cjs → run-cli-DZBuTllO.cjs} +10 -10
- package/run-cli-DZBuTllO.cjs.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-BpNO572W.cjs.map +0 -1
- package/run-cli-CaJWk9j8.js.map +0 -1
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
import { logger as
|
|
2
|
-
import { consumeAPI as me, ProcessIdAllocator as
|
|
3
|
-
import { resolveRemoteBlueprint as
|
|
4
|
-
import { zipDirectory as
|
|
5
|
-
import p, { existsSync as G, rmdirSync as
|
|
1
|
+
import { logger as y, LogSeverity as F, errorLogPath as te } from "@php-wasm/logger";
|
|
2
|
+
import { consumeAPI as me, ProcessIdAllocator as Ie, SupportedPHPVersions as U, printDebugDetails as ke, HttpCookieStore as Me, FileLockManagerInMemory as Ce, StreamedPHPResponse as re, createObjectPoolProxy as Be, exposeAPI as Ae, PHPResponse as De, exposeSyncAPI as Re } from "@php-wasm/universal";
|
|
3
|
+
import { resolveRemoteBlueprint as We, resolveRuntimeConfiguration as oe, compileBlueprintV1 as fe, isBlueprintBundle as Le, runBlueprintV1Steps as se } from "@wp-playground/blueprints";
|
|
4
|
+
import { zipDirectory as _e, RecommendedPHPVersion as D } from "@wp-playground/common";
|
|
5
|
+
import p, { existsSync as G, rmdirSync as Ue, mkdirSync as q, readdirSync as He } from "fs";
|
|
6
6
|
import { MessageChannel as he, Worker as ie } from "worker_threads";
|
|
7
|
-
import { createNodeFsMountHandler as
|
|
7
|
+
import { createNodeFsMountHandler as Ne } from "@php-wasm/node";
|
|
8
8
|
import d, { basename as _, join as we } from "path";
|
|
9
9
|
import { exec as ye } from "child_process";
|
|
10
|
-
import { promisify as
|
|
10
|
+
import { promisify as Oe } from "util";
|
|
11
11
|
import be from "express";
|
|
12
|
-
import { Readable as
|
|
13
|
-
import { pipeline as
|
|
14
|
-
import
|
|
15
|
-
import { NodeJsFilesystem as
|
|
16
|
-
import { EmscriptenDownloadMonitor as
|
|
17
|
-
import { resolveWordPressRelease as
|
|
12
|
+
import { Readable as Fe } from "stream";
|
|
13
|
+
import { pipeline as je } from "stream/promises";
|
|
14
|
+
import Ve from "yargs";
|
|
15
|
+
import { NodeJsFilesystem as Ye, OverlayFilesystem as qe, InMemoryFilesystem as ze, ZipFilesystem as Ge } from "@wp-playground/storage";
|
|
16
|
+
import { EmscriptenDownloadMonitor as Qe, ProgressTracker as Xe } from "@php-wasm/progress";
|
|
17
|
+
import { resolveWordPressRelease as Ze } from "@wp-playground/wordpress";
|
|
18
18
|
import k from "fs-extra";
|
|
19
|
-
import { createRequire as
|
|
19
|
+
import { createRequire as Je } from "module";
|
|
20
20
|
import Q from "os";
|
|
21
|
-
import { startBridge as
|
|
22
|
-
import { dir as
|
|
23
|
-
import { removeTempDirSymlink as
|
|
24
|
-
import { createHash as
|
|
25
|
-
import { PHPMYADMIN_INSTALL_PATH as ae, getPhpMyAdminInstallSteps as
|
|
21
|
+
import { startBridge as Ke } from "@php-wasm/xdebug-bridge";
|
|
22
|
+
import { dir as et, setGracefulCleanup as tt } from "tmp-promise";
|
|
23
|
+
import { removeTempDirSymlink as rt, createTempDirSymlink as ne, makeXdebugConfig as ot, clearXdebugIDEConfig as st, addXdebugIDEConfig as it } from "@php-wasm/cli-util";
|
|
24
|
+
import { createHash as nt } from "crypto";
|
|
25
|
+
import { PHPMYADMIN_INSTALL_PATH as ae, getPhpMyAdminInstallSteps as at, PHPMYADMIN_ENTRY_PATH as lt } from "@wp-playground/tools";
|
|
26
26
|
import { jspi as le } from "wasm-feature-detect";
|
|
27
27
|
function j(e) {
|
|
28
28
|
const t = [];
|
|
@@ -55,11 +55,11 @@ function ue(e) {
|
|
|
55
55
|
}
|
|
56
56
|
return t;
|
|
57
57
|
}
|
|
58
|
-
async function
|
|
58
|
+
async function yr(e, t) {
|
|
59
59
|
for (const r of t)
|
|
60
60
|
await e.mount(
|
|
61
61
|
r.vfsPath,
|
|
62
|
-
|
|
62
|
+
Ne(r.hostPath)
|
|
63
63
|
);
|
|
64
64
|
}
|
|
65
65
|
const de = {
|
|
@@ -90,7 +90,7 @@ function ge(e) {
|
|
|
90
90
|
...e["additional-blueprint-steps"] || []
|
|
91
91
|
]
|
|
92
92
|
};
|
|
93
|
-
if (
|
|
93
|
+
if (pt(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 (ct(t)) {
|
|
104
104
|
const i = _(t), n = `/wordpress/wp-content/themes/${i}`;
|
|
105
105
|
r.push({
|
|
106
106
|
hostPath: t,
|
|
@@ -115,7 +115,7 @@ function ge(e) {
|
|
|
115
115
|
themeFolderName: i
|
|
116
116
|
}
|
|
117
117
|
);
|
|
118
|
-
} else if (
|
|
118
|
+
} else if (dt(t)) {
|
|
119
119
|
const i = p.readdirSync(t);
|
|
120
120
|
for (const n of i)
|
|
121
121
|
n !== "index.php" && r.push({
|
|
@@ -124,35 +124,35 @@ function ge(e) {
|
|
|
124
124
|
autoMounted: !0
|
|
125
125
|
});
|
|
126
126
|
s["additional-blueprint-steps"].push(de);
|
|
127
|
-
} else
|
|
127
|
+
} else ut(t) && (o.push({
|
|
128
128
|
hostPath: t,
|
|
129
129
|
vfsPath: "/wordpress",
|
|
130
130
|
autoMounted: !0
|
|
131
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 ut(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 dt(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 ct(e) {
|
|
143
143
|
if (!p.readdirSync(e).includes("style.css"))
|
|
144
144
|
return !1;
|
|
145
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 pt(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
151
|
const i = p.readFileSync(we(e, s), "utf8");
|
|
152
152
|
return !!r.exec(i);
|
|
153
153
|
});
|
|
154
154
|
}
|
|
155
|
-
function
|
|
155
|
+
function mt(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 pt(e) {
|
|
|
166
166
|
}
|
|
167
167
|
return t;
|
|
168
168
|
}
|
|
169
|
-
function
|
|
169
|
+
function ft(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 mt(e) {
|
|
|
187
187
|
}
|
|
188
188
|
return t;
|
|
189
189
|
}
|
|
190
|
-
function
|
|
190
|
+
function ht(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 ft(e) {
|
|
|
206
206
|
}
|
|
207
207
|
return t;
|
|
208
208
|
}
|
|
209
|
-
function
|
|
209
|
+
function wt(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))
|
|
@@ -219,14 +219,14 @@ function ht(e = {}, t = {}, r = {}) {
|
|
|
219
219
|
return i(e, "string"), i(t, "bool"), i(r, "number"), o;
|
|
220
220
|
}
|
|
221
221
|
function X(e) {
|
|
222
|
-
return
|
|
222
|
+
return wt(
|
|
223
223
|
e.define,
|
|
224
224
|
e["define-bool"],
|
|
225
225
|
e["define-number"]
|
|
226
226
|
);
|
|
227
227
|
}
|
|
228
|
-
const
|
|
229
|
-
function
|
|
228
|
+
const yt = Oe(ye);
|
|
229
|
+
function bt(e) {
|
|
230
230
|
return new Promise((t) => {
|
|
231
231
|
if (e === 0) return t(!1);
|
|
232
232
|
const r = be().listen(e);
|
|
@@ -236,30 +236,30 @@ function yt(e) {
|
|
|
236
236
|
);
|
|
237
237
|
});
|
|
238
238
|
}
|
|
239
|
-
async function
|
|
239
|
+
async function gt(e) {
|
|
240
240
|
const t = be(), r = await new Promise((n, l) => {
|
|
241
241
|
const u = t.listen(e.port, () => {
|
|
242
|
-
const
|
|
243
|
-
|
|
242
|
+
const h = u.address();
|
|
243
|
+
h === null || typeof h == "string" ? l(new Error("Server address is not available")) : n(u);
|
|
244
244
|
}).once("error", l);
|
|
245
245
|
});
|
|
246
246
|
t.use("/", async (n, l) => {
|
|
247
247
|
try {
|
|
248
248
|
const u = {
|
|
249
249
|
url: n.url,
|
|
250
|
-
headers:
|
|
250
|
+
headers: xt(n),
|
|
251
251
|
method: n.method,
|
|
252
|
-
body: await
|
|
253
|
-
},
|
|
254
|
-
await
|
|
252
|
+
body: await vt(n)
|
|
253
|
+
}, h = await e.handleRequest(u);
|
|
254
|
+
await Pt(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 && St(s, i), await e.onBind(r, s);
|
|
261
261
|
}
|
|
262
|
-
async function
|
|
262
|
+
async function Pt(e, t) {
|
|
263
263
|
const [r, o] = await Promise.all([
|
|
264
264
|
e.headers,
|
|
265
265
|
e.httpStatusCode
|
|
@@ -267,16 +267,16 @@ async function gt(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 = Fe.fromWeb(e.stdout);
|
|
271
271
|
try {
|
|
272
|
-
await
|
|
272
|
+
await je(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 vt = 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 Pt = async (e) => await new Promise((t) => {
|
|
|
284
284
|
t(new Uint8Array(Buffer.concat(r)));
|
|
285
285
|
});
|
|
286
286
|
});
|
|
287
|
-
async function
|
|
288
|
-
|
|
287
|
+
async function St(e, t) {
|
|
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 yt(r);
|
|
293
293
|
return;
|
|
294
294
|
} catch {
|
|
295
295
|
await new Promise((s) => setTimeout(s, 2e3));
|
|
296
296
|
}
|
|
297
297
|
}
|
|
298
|
-
const
|
|
298
|
+
const xt = (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
|
|
306
|
-
return /^latest$|^trunk$|^nightly$|^(?:(\d+)\.(\d+)(?:\.(\d+))?)((?:-beta(?:\d+)?)|(?:-RC(?:\d+)?))?$/.test(e);
|
|
305
|
+
function Et(e) {
|
|
306
|
+
return /^latest$|^beta$|^trunk$|^nightly$|^(?:(\d+)\.(\d+)(?:\.(\d+))?)((?:-beta(?:\d+)?)|(?:-RC(?:\d+)?))?$/.test(e);
|
|
307
307
|
}
|
|
308
|
-
async function
|
|
308
|
+
async function $t({
|
|
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 We(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 Et({
|
|
|
324
324
|
const s = d.extname(r);
|
|
325
325
|
switch (s) {
|
|
326
326
|
case ".zip":
|
|
327
|
-
return
|
|
327
|
+
return Ge.fromArrayBuffer(
|
|
328
328
|
p.readFileSync(r).buffer
|
|
329
329
|
);
|
|
330
330
|
case ".json": {
|
|
@@ -336,9 +336,9 @@ async function Et({
|
|
|
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 Ye(n);
|
|
340
|
+
return new qe([
|
|
341
|
+
new ze({
|
|
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 Tt {
|
|
368
368
|
constructor(t, r) {
|
|
369
369
|
this.args = t, this.siteUrl = r.siteUrl, this.phpVersion = t.php, this.cliOutput = r.cliOutput;
|
|
370
370
|
}
|
|
@@ -406,11 +406,11 @@ class $t {
|
|
|
406
406
|
}
|
|
407
407
|
}
|
|
408
408
|
const z = d.join(Q.homedir(), ".wordpress-playground");
|
|
409
|
-
async function
|
|
409
|
+
async function It() {
|
|
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 = Je(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 Tt() {
|
|
|
422
422
|
}
|
|
423
423
|
return new File([await k.readFile(t)], d.basename(t));
|
|
424
424
|
}
|
|
425
|
-
async function
|
|
425
|
+
async function kt(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 Mt(e, o, r)), Pe(o);
|
|
428
428
|
}
|
|
429
|
-
async function
|
|
429
|
+
async function Mt(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();
|
|
@@ -436,15 +436,15 @@ async function kt(e, t, r) {
|
|
|
436
436
|
n.close(), n.closed || await new Promise((l, u) => {
|
|
437
437
|
n.on("finish", () => {
|
|
438
438
|
k.renameSync(i, t), l(null);
|
|
439
|
-
}), n.on("error", (
|
|
440
|
-
k.removeSync(i), u(
|
|
439
|
+
}), n.on("error", (h) => {
|
|
440
|
+
k.removeSync(i), u(h);
|
|
441
441
|
});
|
|
442
442
|
});
|
|
443
443
|
}
|
|
444
444
|
function Pe(e, t) {
|
|
445
445
|
return new File([k.readFileSync(e)], _(e));
|
|
446
446
|
}
|
|
447
|
-
class
|
|
447
|
+
class Ct {
|
|
448
448
|
constructor(t, r) {
|
|
449
449
|
this.args = t, this.siteUrl = r.siteUrl, this.cliOutput = r.cliOutput;
|
|
450
450
|
}
|
|
@@ -453,32 +453,32 @@ class Mt {
|
|
|
453
453
|
}
|
|
454
454
|
async bootWordPress(t, r) {
|
|
455
455
|
let o, s, i;
|
|
456
|
-
const n = new
|
|
456
|
+
const n = new Qe();
|
|
457
457
|
if (this.args.wordpressInstallMode === "download-and-install") {
|
|
458
|
-
let
|
|
458
|
+
let h = !1;
|
|
459
459
|
n.addEventListener("progress", (M) => {
|
|
460
|
-
if (
|
|
460
|
+
if (h)
|
|
461
461
|
return;
|
|
462
|
-
const { loaded: c, total: x } = M.detail,
|
|
462
|
+
const { loaded: c, total: x } = M.detail, w = Math.floor(
|
|
463
463
|
Math.min(100, 100 * c / x)
|
|
464
464
|
);
|
|
465
|
-
|
|
465
|
+
h = w === 100, this.cliOutput.updateProgress(
|
|
466
466
|
"Downloading WordPress",
|
|
467
|
-
|
|
467
|
+
w
|
|
468
468
|
);
|
|
469
|
-
}), o = await
|
|
469
|
+
}), o = await Ze(this.args.wp), i = d.join(
|
|
470
470
|
z,
|
|
471
471
|
`prebuilt-wp-content-for-wp-${o.version}.zip`
|
|
472
|
-
), s = p.existsSync(i) ? Pe(i) : await
|
|
472
|
+
), s = p.existsSync(i) ? Pe(i) : await kt(
|
|
473
473
|
o.releaseUrl,
|
|
474
474
|
`${o.version}.zip`,
|
|
475
475
|
n
|
|
476
|
-
),
|
|
476
|
+
), y.debug(
|
|
477
477
|
`Resolved WordPress release URL: ${o?.releaseUrl}`
|
|
478
478
|
);
|
|
479
479
|
}
|
|
480
480
|
let l;
|
|
481
|
-
this.args.skipSqliteSetup ? (
|
|
481
|
+
this.args.skipSqliteSetup ? (y.debug("Skipping SQLite integration plugin setup..."), l = void 0) : (this.cliOutput.updateProgress("Preparing SQLite database"), l = await It()), this.cliOutput.updateProgress("Booting WordPress");
|
|
482
482
|
const u = await oe(
|
|
483
483
|
this.getEffectiveBlueprint()
|
|
484
484
|
);
|
|
@@ -496,7 +496,7 @@ class Mt {
|
|
|
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 _e(
|
|
500
500
|
t,
|
|
501
501
|
"/wordpress"
|
|
502
502
|
)
|
|
@@ -531,7 +531,7 @@ class Mt {
|
|
|
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 Xe();
|
|
535
535
|
let s = "", i = !1;
|
|
536
536
|
return o.addEventListener("progress", (n) => {
|
|
537
537
|
if (i)
|
|
@@ -546,7 +546,7 @@ class Mt {
|
|
|
546
546
|
}
|
|
547
547
|
getEffectiveBlueprint() {
|
|
548
548
|
const t = this.args.blueprint;
|
|
549
|
-
return
|
|
549
|
+
return Le(t) ? t : {
|
|
550
550
|
login: this.args.login,
|
|
551
551
|
...t || {},
|
|
552
552
|
preferredVersions: {
|
|
@@ -557,8 +557,8 @@ class Mt {
|
|
|
557
557
|
};
|
|
558
558
|
}
|
|
559
559
|
}
|
|
560
|
-
async function
|
|
561
|
-
const o = `${d.basename(process.argv0)}${e}${process.pid}-`, s = await
|
|
560
|
+
async function Bt(e, t = !0) {
|
|
561
|
+
const o = `${d.basename(process.argv0)}${e}${process.pid}-`, s = await et({
|
|
562
562
|
prefix: o,
|
|
563
563
|
/*
|
|
564
564
|
* Allow recursive cleanup on process exit.
|
|
@@ -570,20 +570,20 @@ async function Ct(e, t = !0) {
|
|
|
570
570
|
*/
|
|
571
571
|
unsafeCleanup: !0
|
|
572
572
|
});
|
|
573
|
-
return t &&
|
|
573
|
+
return t && tt(), s;
|
|
574
574
|
}
|
|
575
575
|
async function At(e, t, r) {
|
|
576
|
-
const s = (await
|
|
576
|
+
const s = (await Dt(
|
|
577
577
|
e,
|
|
578
578
|
t,
|
|
579
579
|
r
|
|
580
580
|
)).map(
|
|
581
581
|
(i) => new Promise((n) => {
|
|
582
582
|
p.rm(i, { recursive: !0 }, (l) => {
|
|
583
|
-
l ?
|
|
583
|
+
l ? y.warn(
|
|
584
584
|
`Failed to delete stale Playground temp dir: ${i}`,
|
|
585
585
|
l
|
|
586
|
-
) :
|
|
586
|
+
) : y.info(
|
|
587
587
|
`Deleted stale Playground temp dir: ${i}`
|
|
588
588
|
), n();
|
|
589
589
|
});
|
|
@@ -591,21 +591,21 @@ async function At(e, t, r) {
|
|
|
591
591
|
);
|
|
592
592
|
await Promise.all(s);
|
|
593
593
|
}
|
|
594
|
-
async function
|
|
594
|
+
async function Dt(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 Rt(
|
|
599
599
|
e,
|
|
600
600
|
t,
|
|
601
601
|
i
|
|
602
602
|
) && s.push(i);
|
|
603
603
|
return s;
|
|
604
604
|
} catch (o) {
|
|
605
|
-
return
|
|
605
|
+
return y.warn(`Failed to find stale Playground temp dirs: ${o}`), [];
|
|
606
606
|
}
|
|
607
607
|
}
|
|
608
|
-
async function
|
|
608
|
+
async function Rt(e, t, r) {
|
|
609
609
|
if (!p.lstatSync(r).isDirectory())
|
|
610
610
|
return !1;
|
|
611
611
|
const s = d.basename(r);
|
|
@@ -620,29 +620,29 @@ async function Dt(e, t, r) {
|
|
|
620
620
|
executableName: i[1],
|
|
621
621
|
pid: i[2]
|
|
622
622
|
};
|
|
623
|
-
if (
|
|
623
|
+
if (Wt(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 Wt(e, t) {
|
|
629
629
|
try {
|
|
630
630
|
return process.kill(Number(e), 0), !0;
|
|
631
631
|
} catch (r) {
|
|
632
632
|
const o = r, s = o && typeof o.code == "string" ? o.code : void 0;
|
|
633
|
-
return s === "ESRCH" ? !1 : s === "EPERM" || s === "EACCES" ? (
|
|
633
|
+
return s === "ESRCH" ? !1 : s === "EPERM" || s === "EACCES" ? (y.debug(
|
|
634
634
|
`Permission denied while checking if process ${e} exists (code: ${s}).`,
|
|
635
635
|
r
|
|
636
|
-
), !0) : (
|
|
636
|
+
), !0) : (y.warn(
|
|
637
637
|
`Could not determine if process ${e} exists due to unexpected error${s ? ` (code: ${s})` : ""}.`,
|
|
638
638
|
r
|
|
639
639
|
), !0);
|
|
640
640
|
}
|
|
641
641
|
}
|
|
642
|
-
function
|
|
642
|
+
function Lt(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 _t {
|
|
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 Lt {
|
|
|
656
656
|
* This prevents progress spam in logs - users only see the final outcome.
|
|
657
657
|
*/
|
|
658
658
|
get shouldRender() {
|
|
659
|
-
return
|
|
659
|
+
return Lt(this.writeStream);
|
|
660
660
|
}
|
|
661
661
|
get isQuiet() {
|
|
662
662
|
return this.verbosity === "quiet";
|
|
@@ -810,7 +810,7 @@ const Z = {
|
|
|
810
810
|
Normal: { name: "normal", severity: F.Info },
|
|
811
811
|
Debug: { name: "debug", severity: F.Debug }
|
|
812
812
|
};
|
|
813
|
-
async function
|
|
813
|
+
async function Ut(e) {
|
|
814
814
|
try {
|
|
815
815
|
const t = {
|
|
816
816
|
"site-url": {
|
|
@@ -833,21 +833,21 @@ async function _t(e) {
|
|
|
833
833
|
type: "string",
|
|
834
834
|
nargs: 2,
|
|
835
835
|
array: !0,
|
|
836
|
-
coerce:
|
|
836
|
+
coerce: mt
|
|
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: ft
|
|
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: ht
|
|
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
|
|
@@ -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 = Ve(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,12 +1147,12 @@ 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" && !Et(a.wp))
|
|
1151
1151
|
try {
|
|
1152
1152
|
new URL(a.wp);
|
|
1153
1153
|
} catch {
|
|
1154
1154
|
throw new Error(
|
|
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"'
|
|
1155
|
+
'Unrecognized WordPress version. Please use "latest", "beta", "trunk", "nightly", a URL, or a numeric version such as "6.2", "6.0.1", "6.2-beta1", or "6.2-RC1" (see --help for details).'
|
|
1156
1156
|
);
|
|
1157
1157
|
}
|
|
1158
1158
|
const E = a["site-url"];
|
|
@@ -1197,7 +1197,7 @@ Examples:
|
|
|
1197
1197
|
"build-snapshot",
|
|
1198
1198
|
"php"
|
|
1199
1199
|
].includes(l) || (i.showHelp(), process.exit(1));
|
|
1200
|
-
const u = n.define || {},
|
|
1200
|
+
const u = n.define || {}, h = n["define-bool"] || {}, M = n["define-number"] || {}, c = (a) => a in u || a in h || a in M;
|
|
1201
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
1202
|
const x = {
|
|
1203
1203
|
...n,
|
|
@@ -1211,52 +1211,70 @@ Examples:
|
|
|
1211
1211
|
...n["mount-before-install"] || [],
|
|
1212
1212
|
...n["mount-dir-before-install"] || []
|
|
1213
1213
|
]
|
|
1214
|
-
},
|
|
1215
|
-
|
|
1214
|
+
}, w = await Se(x);
|
|
1215
|
+
w === void 0 && process.exit(0);
|
|
1216
1216
|
const T = /* @__PURE__ */ (() => {
|
|
1217
1217
|
let a;
|
|
1218
1218
|
return async () => {
|
|
1219
|
-
a === void 0 && (a =
|
|
1219
|
+
a === void 0 && (a = w[Symbol.asyncDispose]()), await a, process.exit(0);
|
|
1220
1220
|
};
|
|
1221
1221
|
})();
|
|
1222
1222
|
return process.on("SIGINT", T), process.on("SIGTERM", T), {
|
|
1223
1223
|
[Symbol.asyncDispose]: async () => {
|
|
1224
|
-
process.off("SIGINT", T), process.off("SIGTERM", T), await
|
|
1224
|
+
process.off("SIGINT", T), process.off("SIGTERM", T), await w[Symbol.asyncDispose]();
|
|
1225
1225
|
},
|
|
1226
|
-
[J]: { cliServer:
|
|
1226
|
+
[J]: { cliServer: w }
|
|
1227
1227
|
};
|
|
1228
1228
|
} catch (t) {
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
if (
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1229
|
+
console.error(t);
|
|
1230
|
+
const r = process.argv.includes("--debug");
|
|
1231
|
+
if (t instanceof Error)
|
|
1232
|
+
if (r)
|
|
1233
|
+
ke(t);
|
|
1234
|
+
else {
|
|
1235
|
+
const o = [];
|
|
1236
|
+
let s = t;
|
|
1237
|
+
do
|
|
1238
|
+
o.push(s.message), s = s.cause;
|
|
1239
|
+
while (s instanceof Error);
|
|
1240
|
+
console.error(
|
|
1241
|
+
"\x1B[1m" + o.join(" caused by: ") + "\x1B[0m"
|
|
1242
|
+
);
|
|
1243
|
+
}
|
|
1244
|
+
else
|
|
1245
|
+
console.error("\x1B[1m" + ve(t) + "\x1B[0m");
|
|
1243
1246
|
process.exit(1);
|
|
1244
1247
|
}
|
|
1245
1248
|
}
|
|
1249
|
+
function ve(e) {
|
|
1250
|
+
if (e instanceof Error)
|
|
1251
|
+
return e.message;
|
|
1252
|
+
if (e && typeof e == "object") {
|
|
1253
|
+
const t = [], r = e;
|
|
1254
|
+
if (r.name && t.push(String(r.name)), r.message && t.push(String(r.message)), r.errno !== void 0 && t.push(`errno: ${r.errno}`), t.length > 0)
|
|
1255
|
+
return t.join(" — ");
|
|
1256
|
+
try {
|
|
1257
|
+
return JSON.stringify(e);
|
|
1258
|
+
} catch {
|
|
1259
|
+
return String(e);
|
|
1260
|
+
}
|
|
1261
|
+
}
|
|
1262
|
+
return String(e);
|
|
1263
|
+
}
|
|
1246
1264
|
function ce(e, t) {
|
|
1247
1265
|
return e.find(
|
|
1248
1266
|
(r) => r.vfsPath.replace(/\/$/, "") === t.replace(/\/$/, "")
|
|
1249
1267
|
);
|
|
1250
1268
|
}
|
|
1251
|
-
const J = Symbol("playground-cli-testing"), C = (e) => process.stdout.isTTY ? "\x1B[1m" + e + "\x1B[0m" : e,
|
|
1252
|
-
async function
|
|
1269
|
+
const J = Symbol("playground-cli-testing"), C = (e) => process.stdout.isTTY ? "\x1B[1m" + e + "\x1B[0m" : e, Ht = (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;
|
|
1270
|
+
async function Se(e) {
|
|
1253
1271
|
let t;
|
|
1254
|
-
const r = e.internalCookieStore ? new
|
|
1255
|
-
if (e.command === "start" && (e =
|
|
1272
|
+
const r = e.internalCookieStore ? new Me() : void 0, o = [], s = /* @__PURE__ */ new Map();
|
|
1273
|
+
if (e.command === "start" && (e = Nt(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
1274
|
const c = Object.values(Z).find(
|
|
1257
1275
|
(x) => x.name === e.verbosity
|
|
1258
1276
|
).severity;
|
|
1259
|
-
|
|
1277
|
+
y.setSeverityFilterLevel(c);
|
|
1260
1278
|
}
|
|
1261
1279
|
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
1280
|
{
|
|
@@ -1264,7 +1282,7 @@ async function ve(e) {
|
|
|
1264
1282
|
fsPath: ae
|
|
1265
1283
|
}
|
|
1266
1284
|
]);
|
|
1267
|
-
const i = new
|
|
1285
|
+
const i = new _t({
|
|
1268
1286
|
verbosity: e.verbosity || "normal"
|
|
1269
1287
|
});
|
|
1270
1288
|
e.command === "server" && (i.printBanner(), i.printConfig({
|
|
@@ -1281,15 +1299,15 @@ async function ve(e) {
|
|
|
1281
1299
|
],
|
|
1282
1300
|
blueprint: typeof e.blueprint == "string" ? e.blueprint : void 0
|
|
1283
1301
|
}));
|
|
1284
|
-
const n = e.command === "server" ? e.port ?? 9400 : 0, l = new
|
|
1285
|
-
let u = !1,
|
|
1286
|
-
const M = await
|
|
1287
|
-
port: e.port ? e.port : await
|
|
1302
|
+
const n = e.command === "server" ? e.port ?? 9400 : 0, l = new Ce();
|
|
1303
|
+
let u = !1, h = !0;
|
|
1304
|
+
const M = await gt({
|
|
1305
|
+
port: e.port ? e.port : await bt(n) ? 0 : n,
|
|
1288
1306
|
onBind: async (c, x) => {
|
|
1289
|
-
const
|
|
1290
|
-
|
|
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
|
+
y.debug(`Native temp dir for VFS root: ${I.path}`);
|
|
1291
1309
|
const R = "WP Playground CLI - Listen for Xdebug", K = ".playground-xdebug-root", H = d.join(process.cwd(), K);
|
|
1292
|
-
if (await
|
|
1310
|
+
if (await rt(H), e.xdebug) {
|
|
1293
1311
|
const m = {
|
|
1294
1312
|
hostPath: d.join(".", d.sep, K),
|
|
1295
1313
|
vfsPath: "/"
|
|
@@ -1301,7 +1319,7 @@ async function ve(e) {
|
|
|
1301
1319
|
I.path,
|
|
1302
1320
|
H,
|
|
1303
1321
|
process.platform
|
|
1304
|
-
), e.xdebug =
|
|
1322
|
+
), e.xdebug = ot({
|
|
1305
1323
|
cwd: process.cwd(),
|
|
1306
1324
|
mounts: [
|
|
1307
1325
|
m,
|
|
@@ -1329,13 +1347,13 @@ async function ve(e) {
|
|
|
1329
1347
|
process.platform
|
|
1330
1348
|
);
|
|
1331
1349
|
try {
|
|
1332
|
-
await
|
|
1350
|
+
await st(
|
|
1333
1351
|
R,
|
|
1334
1352
|
process.cwd()
|
|
1335
1353
|
);
|
|
1336
|
-
const f = typeof e.xdebug == "object" ? e.xdebug : {}, b = await
|
|
1354
|
+
const f = typeof e.xdebug == "object" ? e.xdebug : {}, b = await it({
|
|
1337
1355
|
name: R,
|
|
1338
|
-
host:
|
|
1356
|
+
host: w,
|
|
1339
1357
|
port: x,
|
|
1340
1358
|
ides: e.experimentalUnsafeIdeIntegration,
|
|
1341
1359
|
cwd: process.cwd(),
|
|
@@ -1396,15 +1414,15 @@ async function ve(e) {
|
|
|
1396
1414
|
}
|
|
1397
1415
|
}
|
|
1398
1416
|
}
|
|
1399
|
-
const
|
|
1417
|
+
const Ee = d.dirname(I.path), $e = 2 * 24 * 60 * 60 * 1e3;
|
|
1400
1418
|
At(
|
|
1401
1419
|
P,
|
|
1402
|
-
|
|
1403
|
-
|
|
1420
|
+
$e,
|
|
1421
|
+
Ee
|
|
1404
1422
|
);
|
|
1405
1423
|
const ee = d.join(I.path, "internal");
|
|
1406
1424
|
q(ee);
|
|
1407
|
-
const
|
|
1425
|
+
const Te = [
|
|
1408
1426
|
"wordpress",
|
|
1409
1427
|
"tools",
|
|
1410
1428
|
// Note: These dirs are from Emscripten's "default dirs" list:
|
|
@@ -1416,7 +1434,7 @@ async function ve(e) {
|
|
|
1416
1434
|
"tmp",
|
|
1417
1435
|
"home"
|
|
1418
1436
|
];
|
|
1419
|
-
for (const m of
|
|
1437
|
+
for (const m of Te) {
|
|
1420
1438
|
const g = (b) => b.vfsPath === `/${m}`;
|
|
1421
1439
|
if (!(e["mount-before-install"]?.some(g) || e.mount?.some(g))) {
|
|
1422
1440
|
const b = d.join(
|
|
@@ -1431,27 +1449,27 @@ async function ve(e) {
|
|
|
1431
1449
|
}
|
|
1432
1450
|
if (e["mount-before-install"])
|
|
1433
1451
|
for (const m of e["mount-before-install"])
|
|
1434
|
-
|
|
1452
|
+
y.debug(
|
|
1435
1453
|
`Mount before WP install: ${m.vfsPath} -> ${m.hostPath}`
|
|
1436
1454
|
);
|
|
1437
1455
|
if (e.mount)
|
|
1438
1456
|
for (const m of e.mount)
|
|
1439
|
-
|
|
1457
|
+
y.debug(
|
|
1440
1458
|
`Mount after WP install: ${m.vfsPath} -> ${m.hostPath}`
|
|
1441
1459
|
);
|
|
1442
|
-
let
|
|
1443
|
-
e["experimental-blueprints-v2-runner"] ?
|
|
1460
|
+
let B;
|
|
1461
|
+
e["experimental-blueprints-v2-runner"] ? B = new Tt(e, {
|
|
1444
1462
|
siteUrl: a,
|
|
1445
1463
|
cliOutput: i
|
|
1446
|
-
}) : (
|
|
1464
|
+
}) : (B = new Ct(e, {
|
|
1447
1465
|
siteUrl: a,
|
|
1448
1466
|
cliOutput: i
|
|
1449
|
-
}), typeof e.blueprint == "string" && (e.blueprint = await
|
|
1467
|
+
}), typeof e.blueprint == "string" && (e.blueprint = await $t({
|
|
1450
1468
|
sourceString: e.blueprint,
|
|
1451
1469
|
blueprintMayReadAdjacentFiles: e["blueprint-may-read-adjacent-files"] === !0
|
|
1452
1470
|
})));
|
|
1453
1471
|
let N = !1;
|
|
1454
|
-
const
|
|
1472
|
+
const A = async function() {
|
|
1455
1473
|
N || (N = !0, await Promise.all(
|
|
1456
1474
|
o.map(async (g) => {
|
|
1457
1475
|
await s.get(g)?.dispose(), await g.worker.terminate();
|
|
@@ -1461,11 +1479,11 @@ async function ve(e) {
|
|
|
1461
1479
|
}), await I.cleanup());
|
|
1462
1480
|
};
|
|
1463
1481
|
try {
|
|
1464
|
-
const m = [], g =
|
|
1482
|
+
const m = [], g = B.getWorkerType();
|
|
1465
1483
|
for (let f = 0; f < E; f++) {
|
|
1466
|
-
const b =
|
|
1484
|
+
const b = xe(g, {
|
|
1467
1485
|
onExit: (v) => {
|
|
1468
|
-
N || v
|
|
1486
|
+
N || v !== 0 && y.error(
|
|
1469
1487
|
`Worker ${f} exited with code ${v}
|
|
1470
1488
|
`
|
|
1471
1489
|
);
|
|
@@ -1473,7 +1491,7 @@ async function ve(e) {
|
|
|
1473
1491
|
}).then(
|
|
1474
1492
|
async (v) => {
|
|
1475
1493
|
o.push(v);
|
|
1476
|
-
const S = await
|
|
1494
|
+
const S = await Ot(l), $ = await B.bootRequestHandler({
|
|
1477
1495
|
worker: v,
|
|
1478
1496
|
fileLockManagerPort: S,
|
|
1479
1497
|
nativeInternalDirPath: ee
|
|
@@ -1486,7 +1504,7 @@ async function ve(e) {
|
|
|
1486
1504
|
);
|
|
1487
1505
|
m.push(b), f === 0 && await b;
|
|
1488
1506
|
}
|
|
1489
|
-
await Promise.all(m), t =
|
|
1507
|
+
await Promise.all(m), t = Be(
|
|
1490
1508
|
o.map(
|
|
1491
1509
|
(f) => s.get(f)
|
|
1492
1510
|
)
|
|
@@ -1496,24 +1514,19 @@ async function ve(e) {
|
|
|
1496
1514
|
if (await Ae(
|
|
1497
1515
|
{
|
|
1498
1516
|
applyPostInstallMountsToAllWorkers: async () => {
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
)
|
|
1503
|
-
(S) => S.mountAfterWordPressInstall(
|
|
1504
|
-
e.mount || []
|
|
1505
|
-
)
|
|
1506
|
-
)
|
|
1507
|
-
);
|
|
1517
|
+
for (const S of s.values())
|
|
1518
|
+
await S.mountAfterWordPressInstall(
|
|
1519
|
+
e.mount || []
|
|
1520
|
+
);
|
|
1508
1521
|
}
|
|
1509
1522
|
},
|
|
1510
1523
|
void 0,
|
|
1511
1524
|
b
|
|
1512
|
-
), await
|
|
1525
|
+
), await B.bootWordPress(
|
|
1513
1526
|
t,
|
|
1514
1527
|
v
|
|
1515
1528
|
), b.close(), u = !0, !e["experimental-blueprints-v2-runner"]) {
|
|
1516
|
-
const S = await
|
|
1529
|
+
const S = await B.compileInputBlueprint(
|
|
1517
1530
|
e["additional-blueprint-steps"] || []
|
|
1518
1531
|
);
|
|
1519
1532
|
S && await se(
|
|
@@ -1524,14 +1537,14 @@ async function ve(e) {
|
|
|
1524
1537
|
if (e.phpmyadmin && !await t.fileExists(
|
|
1525
1538
|
`${ae}/index.php`
|
|
1526
1539
|
)) {
|
|
1527
|
-
const S = await
|
|
1540
|
+
const S = await at(), $ = await fe({ steps: S });
|
|
1528
1541
|
await se($, t);
|
|
1529
1542
|
}
|
|
1530
1543
|
if (e.command === "build-snapshot") {
|
|
1531
|
-
await
|
|
1544
|
+
await jt(t, e.outfile), i.printStatus(`Exported to ${e.outfile}`), await A();
|
|
1532
1545
|
return;
|
|
1533
1546
|
} else if (e.command === "run-blueprint") {
|
|
1534
|
-
i.finishProgress("Done"), await
|
|
1547
|
+
i.finishProgress("Done"), await A();
|
|
1535
1548
|
return;
|
|
1536
1549
|
} else if (e.command === "php") {
|
|
1537
1550
|
const S = [
|
|
@@ -1556,26 +1569,26 @@ async function ve(e) {
|
|
|
1556
1569
|
})
|
|
1557
1570
|
)
|
|
1558
1571
|
]);
|
|
1559
|
-
await
|
|
1572
|
+
await A(), process.exit(W);
|
|
1560
1573
|
}
|
|
1561
1574
|
}
|
|
1562
1575
|
if (i.finishProgress(), i.printReady(T, E), e.phpmyadmin) {
|
|
1563
1576
|
const f = d.join(
|
|
1564
1577
|
e.phpmyadmin,
|
|
1565
|
-
|
|
1578
|
+
lt
|
|
1566
1579
|
);
|
|
1567
1580
|
i.printPhpMyAdminUrl(
|
|
1568
1581
|
new URL(f, T).toString()
|
|
1569
1582
|
);
|
|
1570
1583
|
}
|
|
1571
|
-
return e.xdebug && e.experimentalDevtools && (await
|
|
1584
|
+
return e.xdebug && e.experimentalDevtools && (await Ke({
|
|
1572
1585
|
phpInstance: t,
|
|
1573
1586
|
phpRoot: "/wordpress"
|
|
1574
1587
|
})).start(), {
|
|
1575
1588
|
playground: t,
|
|
1576
1589
|
server: c,
|
|
1577
1590
|
serverUrl: T,
|
|
1578
|
-
[Symbol.asyncDispose]:
|
|
1591
|
+
[Symbol.asyncDispose]: A,
|
|
1579
1592
|
[J]: {
|
|
1580
1593
|
workerThreadCount: E
|
|
1581
1594
|
}
|
|
@@ -1584,7 +1597,7 @@ async function ve(e) {
|
|
|
1584
1597
|
if (e.verbosity !== "debug")
|
|
1585
1598
|
throw m;
|
|
1586
1599
|
let g = "";
|
|
1587
|
-
throw await t?.fileExists(te) && (g = await t.readFileAsText(te)), await
|
|
1600
|
+
throw await t?.fileExists(te) && (g = await t.readFileAsText(te)), await A(), new Error(g, { cause: m });
|
|
1588
1601
|
}
|
|
1589
1602
|
},
|
|
1590
1603
|
async handleRequest(c) {
|
|
@@ -1593,19 +1606,19 @@ async function ve(e) {
|
|
|
1593
1606
|
502,
|
|
1594
1607
|
"WordPress is not ready yet"
|
|
1595
1608
|
);
|
|
1596
|
-
if (
|
|
1597
|
-
|
|
1598
|
-
const
|
|
1609
|
+
if (h) {
|
|
1610
|
+
h = !1;
|
|
1611
|
+
const w = {
|
|
1599
1612
|
"Content-Type": ["text/plain"],
|
|
1600
1613
|
"Content-Length": ["0"],
|
|
1601
1614
|
Location: [c.url]
|
|
1602
1615
|
};
|
|
1603
1616
|
return c.headers?.cookie?.includes(
|
|
1604
1617
|
"playground_auto_login_already_happened"
|
|
1605
|
-
) && (
|
|
1618
|
+
) && (w["Set-Cookie"] = [
|
|
1606
1619
|
"playground_auto_login_already_happened=1; Max-Age=0; Expires=Thu, 01 Jan 1970 00:00:00 GMT; Path=/"
|
|
1607
1620
|
]), re.fromPHPResponse(
|
|
1608
|
-
new
|
|
1621
|
+
new De(302, w, new Uint8Array())
|
|
1609
1622
|
);
|
|
1610
1623
|
}
|
|
1611
1624
|
r && (c = {
|
|
@@ -1622,17 +1635,17 @@ async function ve(e) {
|
|
|
1622
1635
|
});
|
|
1623
1636
|
const x = await t.requestStreamed(c);
|
|
1624
1637
|
if (r) {
|
|
1625
|
-
const
|
|
1626
|
-
r.rememberCookiesFromResponseHeaders(
|
|
1638
|
+
const w = await x.headers;
|
|
1639
|
+
r.rememberCookiesFromResponseHeaders(w), delete w["set-cookie"];
|
|
1627
1640
|
}
|
|
1628
1641
|
return x;
|
|
1629
1642
|
}
|
|
1630
1643
|
}).catch((c) => {
|
|
1631
|
-
i.printError(c
|
|
1644
|
+
i.printError(ve(c)), process.exit(1);
|
|
1632
1645
|
});
|
|
1633
|
-
return M && e.command === "start" && !e.skipBrowser &&
|
|
1646
|
+
return M && e.command === "start" && !e.skipBrowser && Ft(M.serverUrl), M;
|
|
1634
1647
|
}
|
|
1635
|
-
function
|
|
1648
|
+
function Nt(e) {
|
|
1636
1649
|
let t = { ...e, command: "server" };
|
|
1637
1650
|
e.noAutoMount || (t.autoMount = d.resolve(process.cwd(), t.path ?? ""), t = ge(t), delete t.autoMount);
|
|
1638
1651
|
const r = ce(
|
|
@@ -1641,7 +1654,7 @@ function Ht(e) {
|
|
|
1641
1654
|
) || ce(t.mount || [], "/wordpress");
|
|
1642
1655
|
if (r)
|
|
1643
1656
|
console.log("Site files stored at:", r?.hostPath), e.reset && (console.log(""), console.log(
|
|
1644
|
-
|
|
1657
|
+
Ht(
|
|
1645
1658
|
"This site is not managed by Playground CLI and cannot be reset."
|
|
1646
1659
|
)
|
|
1647
1660
|
), console.log(
|
|
@@ -1650,15 +1663,15 @@ function Ht(e) {
|
|
|
1650
1663
|
"You may still remove the site's directory manually if you wish."
|
|
1651
1664
|
), process.exit(1));
|
|
1652
1665
|
else {
|
|
1653
|
-
const o = t.autoMount || process.cwd(), s =
|
|
1666
|
+
const o = t.autoMount || process.cwd(), s = nt("sha256").update(o).digest("hex"), i = Q.homedir(), n = d.join(
|
|
1654
1667
|
i,
|
|
1655
1668
|
".wordpress-playground/sites",
|
|
1656
1669
|
s
|
|
1657
1670
|
);
|
|
1658
|
-
console.log("Site files stored at:", n), G(n) && e.reset && (console.log("Resetting site..."),
|
|
1671
|
+
console.log("Site files stored at:", n), G(n) && e.reset && (console.log("Resetting site..."), Ue(n, { recursive: !0 })), q(n, { recursive: !0 }), t["mount-before-install"] = [
|
|
1659
1672
|
...t["mount-before-install"] || [],
|
|
1660
1673
|
{ vfsPath: "/wordpress", hostPath: n }
|
|
1661
|
-
], t.wordpressInstallMode =
|
|
1674
|
+
], t.wordpressInstallMode = He(n).length === 0 ? (
|
|
1662
1675
|
// Only download WordPress on the first run when the site directory is still
|
|
1663
1676
|
// empty.
|
|
1664
1677
|
"download-and-install"
|
|
@@ -1669,8 +1682,8 @@ function Ht(e) {
|
|
|
1669
1682
|
}
|
|
1670
1683
|
return t;
|
|
1671
1684
|
}
|
|
1672
|
-
const Y = new
|
|
1673
|
-
function
|
|
1685
|
+
const Y = new Ie();
|
|
1686
|
+
function xe(e, { onExit: t } = {}) {
|
|
1674
1687
|
let r;
|
|
1675
1688
|
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
1689
|
const i = Y.claim();
|
|
@@ -1682,10 +1695,11 @@ function Se(e, { onExit: t } = {}) {
|
|
|
1682
1695
|
});
|
|
1683
1696
|
}), r.once("error", function(l) {
|
|
1684
1697
|
Y.release(i), console.error(l);
|
|
1685
|
-
const u = new Error(
|
|
1686
|
-
`Worker failed to load
|
|
1698
|
+
const u = l?.message || (l ? String(l) : "unknown error"), h = new Error(
|
|
1699
|
+
`Worker failed to load. Original error: ${u}`,
|
|
1700
|
+
{ cause: l }
|
|
1687
1701
|
);
|
|
1688
|
-
s(
|
|
1702
|
+
s(h);
|
|
1689
1703
|
});
|
|
1690
1704
|
let n = !1;
|
|
1691
1705
|
r.once("spawn", () => {
|
|
@@ -1695,11 +1709,11 @@ function Se(e, { onExit: t } = {}) {
|
|
|
1695
1709
|
});
|
|
1696
1710
|
});
|
|
1697
1711
|
}
|
|
1698
|
-
async function
|
|
1712
|
+
async function Ot(e) {
|
|
1699
1713
|
const { port1: t, port2: r } = new he();
|
|
1700
|
-
return await
|
|
1714
|
+
return await Re(e, t), r;
|
|
1701
1715
|
}
|
|
1702
|
-
function
|
|
1716
|
+
function Ft(e) {
|
|
1703
1717
|
const t = Q.platform();
|
|
1704
1718
|
let r;
|
|
1705
1719
|
switch (t) {
|
|
@@ -1714,10 +1728,10 @@ function Ot(e) {
|
|
|
1714
1728
|
break;
|
|
1715
1729
|
}
|
|
1716
1730
|
ye(r, (o) => {
|
|
1717
|
-
o &&
|
|
1731
|
+
o && y.debug(`Could not open browser: ${o.message}`);
|
|
1718
1732
|
});
|
|
1719
1733
|
}
|
|
1720
|
-
async function
|
|
1734
|
+
async function jt(e, t) {
|
|
1721
1735
|
await e.run({
|
|
1722
1736
|
code: `<?php
|
|
1723
1737
|
$zip = new ZipArchive();
|
|
@@ -1741,24 +1755,24 @@ async function Ft(e, t) {
|
|
|
1741
1755
|
const r = await e.readFileAsBuffer("/tmp/build.zip");
|
|
1742
1756
|
p.writeFileSync(t, r);
|
|
1743
1757
|
}
|
|
1744
|
-
const
|
|
1758
|
+
const br = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
1745
1759
|
__proto__: null,
|
|
1746
1760
|
LogVerbosity: Z,
|
|
1747
1761
|
internalsKeyForTesting: J,
|
|
1748
1762
|
mergeDefinedConstants: X,
|
|
1749
|
-
parseOptionsAndRunCLI:
|
|
1750
|
-
runCLI:
|
|
1751
|
-
spawnWorkerThread:
|
|
1763
|
+
parseOptionsAndRunCLI: Ut,
|
|
1764
|
+
runCLI: Se,
|
|
1765
|
+
spawnWorkerThread: xe
|
|
1752
1766
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
1753
1767
|
export {
|
|
1754
1768
|
Z as L,
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1769
|
+
yr as a,
|
|
1770
|
+
Lt as b,
|
|
1771
|
+
br as c,
|
|
1758
1772
|
J as i,
|
|
1759
1773
|
X as m,
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1774
|
+
Ut as p,
|
|
1775
|
+
Se as r,
|
|
1776
|
+
xe as s
|
|
1763
1777
|
};
|
|
1764
|
-
//# sourceMappingURL=run-cli-
|
|
1778
|
+
//# sourceMappingURL=run-cli-CrCfo8mJ.js.map
|