@wp-playground/cli 3.0.1 → 3.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/blueprints-v1/blueprints-v1-handler.d.ts +1 -0
- package/blueprints-v2/worker-thread-v2.d.ts +3 -2
- package/cli.cjs +1 -1
- package/cli.js +1 -1
- package/index.cjs +1 -1
- package/index.js +1 -1
- package/package.json +12 -12
- package/{run-cli-B2OOyNez.cjs → run-cli-DdsLZ1X6.cjs} +8 -8
- package/run-cli-DdsLZ1X6.cjs.map +1 -0
- package/{run-cli-8MDZfFdj.js → run-cli-Md2TQOSk.js} +168 -164
- package/run-cli-Md2TQOSk.js.map +1 -0
- package/run-cli.d.ts +2 -2
- package/worker-thread-v1.cjs +2 -2
- package/worker-thread-v1.cjs.map +1 -1
- package/worker-thread-v1.js +36 -36
- package/worker-thread-v1.js.map +1 -1
- package/worker-thread-v2.cjs +2 -2
- package/worker-thread-v2.cjs.map +1 -1
- package/worker-thread-v2.js +13 -13
- package/worker-thread-v2.js.map +1 -1
- package/run-cli-8MDZfFdj.js.map +0 -1
- package/run-cli-B2OOyNez.cjs.map +0 -1
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
import { logger as p, LogSeverity as
|
|
2
|
-
import { consumeAPI as R, SupportedPHPVersions as X, printDebugDetails as Y, PHPResponse as
|
|
3
|
-
import { resolveRemoteBlueprint as ee,
|
|
4
|
-
import { zipDirectory as
|
|
5
|
-
import d, { mkdirSync as
|
|
6
|
-
import { Worker as H, MessageChannel as
|
|
7
|
-
import { p as V, a as
|
|
8
|
-
import
|
|
9
|
-
import { FileLockManagerForNode as
|
|
10
|
-
import q, { cpus as
|
|
11
|
-
import { jspi as
|
|
12
|
-
import
|
|
13
|
-
import c, { basename as
|
|
14
|
-
import { NodeJsFilesystem as
|
|
15
|
-
import { EmscriptenDownloadMonitor as be, ProgressTracker as
|
|
16
|
-
import { resolveWordPressRelease as
|
|
17
|
-
import
|
|
1
|
+
import { logger as p, LogSeverity as E, errorLogPath as U } from "@php-wasm/logger";
|
|
2
|
+
import { consumeAPI as R, SupportedPHPVersions as X, printDebugDetails as Y, PHPResponse as C, exposeAPI as G, exposeSyncAPI as K } from "@php-wasm/universal";
|
|
3
|
+
import { resolveRemoteBlueprint as ee, resolveRuntimeConfiguration as te, compileBlueprintV1 as re, isBlueprintBundle as oe, runBlueprintV1Steps as ie } from "@wp-playground/blueprints";
|
|
4
|
+
import { zipDirectory as se, RecommendedPHPVersion as _ } from "@wp-playground/common";
|
|
5
|
+
import d, { mkdirSync as D } from "fs";
|
|
6
|
+
import { Worker as H, MessageChannel as ne } from "worker_threads";
|
|
7
|
+
import { p as V, a as ae, e as le } from "./mounts-D1_eXSTw.js";
|
|
8
|
+
import pe from "express";
|
|
9
|
+
import { FileLockManagerForNode as ue } from "@php-wasm/node";
|
|
10
|
+
import q, { cpus as de } from "os";
|
|
11
|
+
import { jspi as ce } from "wasm-feature-detect";
|
|
12
|
+
import fe from "yargs";
|
|
13
|
+
import c, { basename as he } from "path";
|
|
14
|
+
import { NodeJsFilesystem as me, OverlayFilesystem as we, InMemoryFilesystem as ye, ZipFilesystem as ge } from "@wp-playground/storage";
|
|
15
|
+
import { EmscriptenDownloadMonitor as be, ProgressTracker as Pe } from "@php-wasm/progress";
|
|
16
|
+
import { resolveWordPressRelease as ve } from "@wp-playground/wordpress";
|
|
17
|
+
import S from "fs-extra";
|
|
18
18
|
import { startBridge as ke } from "@php-wasm/xdebug-bridge";
|
|
19
|
-
import { dir as
|
|
20
|
-
import
|
|
21
|
-
async function
|
|
22
|
-
const r =
|
|
19
|
+
import { dir as Se, setGracefulCleanup as xe } from "tmp-promise";
|
|
20
|
+
import We from "ps-man";
|
|
21
|
+
async function Le(e) {
|
|
22
|
+
const r = pe(), t = await new Promise((i, n) => {
|
|
23
23
|
const a = r.listen(e.port, () => {
|
|
24
24
|
const l = a.address();
|
|
25
25
|
l === null || typeof l == "string" ? n(new Error("Server address is not available")) : i(a);
|
|
@@ -28,9 +28,9 @@ async function We(e) {
|
|
|
28
28
|
r.use("/", async (i, n) => {
|
|
29
29
|
const a = await e.handleRequest({
|
|
30
30
|
url: i.url,
|
|
31
|
-
headers:
|
|
31
|
+
headers: Be(i),
|
|
32
32
|
method: i.method,
|
|
33
|
-
body: await
|
|
33
|
+
body: await Re(i)
|
|
34
34
|
});
|
|
35
35
|
n.statusCode = a.httpStatusCode;
|
|
36
36
|
for (const l in a.headers)
|
|
@@ -40,21 +40,21 @@ async function We(e) {
|
|
|
40
40
|
const o = t.address().port;
|
|
41
41
|
return await e.onBind(t, o);
|
|
42
42
|
}
|
|
43
|
-
const
|
|
43
|
+
const Re = async (e) => await new Promise((r) => {
|
|
44
44
|
const t = [];
|
|
45
45
|
e.on("data", (s) => {
|
|
46
46
|
t.push(s);
|
|
47
47
|
}), e.on("end", () => {
|
|
48
48
|
r(new Uint8Array(Buffer.concat(t)));
|
|
49
49
|
});
|
|
50
|
-
}),
|
|
50
|
+
}), Be = (e) => {
|
|
51
51
|
const r = {};
|
|
52
52
|
if (e.rawHeaders && e.rawHeaders.length)
|
|
53
53
|
for (let t = 0; t < e.rawHeaders.length; t += 2)
|
|
54
54
|
r[e.rawHeaders[t].toLowerCase()] = e.rawHeaders[t + 1];
|
|
55
55
|
return r;
|
|
56
56
|
};
|
|
57
|
-
class
|
|
57
|
+
class Ie {
|
|
58
58
|
constructor(r) {
|
|
59
59
|
this.workerLoads = [], this.addWorker(r);
|
|
60
60
|
}
|
|
@@ -76,10 +76,10 @@ class Be {
|
|
|
76
76
|
});
|
|
77
77
|
}
|
|
78
78
|
}
|
|
79
|
-
function
|
|
79
|
+
function Me(e) {
|
|
80
80
|
return /^latest$|^trunk$|^nightly$|^(?:(\d+)\.(\d+)(?:\.(\d+))?)((?:-beta(?:\d+)?)|(?:-RC(?:\d+)?))?$/.test(e);
|
|
81
81
|
}
|
|
82
|
-
async function
|
|
82
|
+
async function Ee({
|
|
83
83
|
sourceString: e,
|
|
84
84
|
blueprintMayReadAdjacentFiles: r
|
|
85
85
|
}) {
|
|
@@ -98,7 +98,7 @@ async function Me({
|
|
|
98
98
|
const o = c.extname(t);
|
|
99
99
|
switch (o) {
|
|
100
100
|
case ".zip":
|
|
101
|
-
return
|
|
101
|
+
return ge.fromArrayBuffer(
|
|
102
102
|
d.readFileSync(t).buffer
|
|
103
103
|
);
|
|
104
104
|
case ".json": {
|
|
@@ -110,9 +110,9 @@ async function Me({
|
|
|
110
110
|
`Blueprint file at ${t} is not a valid JSON file`
|
|
111
111
|
);
|
|
112
112
|
}
|
|
113
|
-
const n = c.dirname(t), a = new
|
|
114
|
-
return new
|
|
115
|
-
new
|
|
113
|
+
const n = c.dirname(t), a = new me(n);
|
|
114
|
+
return new we([
|
|
115
|
+
new ye({
|
|
116
116
|
"blueprint.json": i
|
|
117
117
|
}),
|
|
118
118
|
/**
|
|
@@ -187,8 +187,8 @@ class $e {
|
|
|
187
187
|
`));
|
|
188
188
|
}
|
|
189
189
|
}
|
|
190
|
-
const
|
|
191
|
-
async function
|
|
190
|
+
const $ = c.join(q.homedir(), ".wordpress-playground");
|
|
191
|
+
async function Te(e) {
|
|
192
192
|
return await z(
|
|
193
193
|
"https://github.com/WordPress/sqlite-database-integration/archive/refs/heads/develop.zip",
|
|
194
194
|
"sqlite.zip",
|
|
@@ -196,11 +196,11 @@ async function Ee(e) {
|
|
|
196
196
|
);
|
|
197
197
|
}
|
|
198
198
|
async function z(e, r, t) {
|
|
199
|
-
const s = c.join(
|
|
200
|
-
return
|
|
199
|
+
const s = c.join($, r);
|
|
200
|
+
return S.existsSync(s) || (S.ensureDirSync($), await Fe(e, s, t)), O(s);
|
|
201
201
|
}
|
|
202
|
-
async function
|
|
203
|
-
const o = (await t.monitorFetch(fetch(e))).body.getReader(), i = `${r}.partial`, n =
|
|
202
|
+
async function Fe(e, r, t) {
|
|
203
|
+
const o = (await t.monitorFetch(fetch(e))).body.getReader(), i = `${r}.partial`, n = S.createWriteStream(i);
|
|
204
204
|
for (; ; ) {
|
|
205
205
|
const { done: a, value: l } = await o.read();
|
|
206
206
|
if (l && n.write(l), a)
|
|
@@ -208,16 +208,16 @@ async function Te(e, r, t) {
|
|
|
208
208
|
}
|
|
209
209
|
n.close(), n.closed || await new Promise((a, l) => {
|
|
210
210
|
n.on("finish", () => {
|
|
211
|
-
|
|
211
|
+
S.renameSync(i, r), a(null);
|
|
212
212
|
}), n.on("error", (u) => {
|
|
213
|
-
|
|
213
|
+
S.removeSync(i), l(u);
|
|
214
214
|
});
|
|
215
215
|
});
|
|
216
216
|
}
|
|
217
217
|
function O(e, r) {
|
|
218
|
-
return new File([
|
|
218
|
+
return new File([S.readFileSync(e)], he(e));
|
|
219
219
|
}
|
|
220
|
-
class
|
|
220
|
+
class Ae {
|
|
221
221
|
constructor(r, t) {
|
|
222
222
|
this.lastProgressMessage = "", this.args = r, this.siteUrl = t.siteUrl, this.processIdSpaceLength = t.processIdSpaceLength;
|
|
223
223
|
}
|
|
@@ -225,15 +225,11 @@ class Fe {
|
|
|
225
225
|
return "v1";
|
|
226
226
|
}
|
|
227
227
|
async bootPrimaryWorker(r, t, s) {
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
);
|
|
231
|
-
this.phpVersion = o.versions.php;
|
|
232
|
-
let i;
|
|
233
|
-
const n = new be();
|
|
228
|
+
let o;
|
|
229
|
+
const i = new be();
|
|
234
230
|
if (!this.args.skipWordPressSetup) {
|
|
235
231
|
let g = !1;
|
|
236
|
-
|
|
232
|
+
i.addEventListener("progress", (B) => {
|
|
237
233
|
if (g)
|
|
238
234
|
return;
|
|
239
235
|
const { loaded: F, total: I } = B.detail, v = Math.floor(
|
|
@@ -244,39 +240,43 @@ class Fe {
|
|
|
244
240
|
`Downloading WordPress ${v}%...`,
|
|
245
241
|
g
|
|
246
242
|
);
|
|
247
|
-
}),
|
|
248
|
-
`Resolved WordPress release URL: ${
|
|
243
|
+
}), o = await ve(this.args.wp), p.log(
|
|
244
|
+
`Resolved WordPress release URL: ${o?.releaseUrl}`
|
|
249
245
|
);
|
|
250
246
|
}
|
|
251
|
-
const
|
|
252
|
-
|
|
253
|
-
`prebuilt-wp-content-for-wp-${
|
|
254
|
-
),
|
|
255
|
-
|
|
256
|
-
`${
|
|
257
|
-
|
|
247
|
+
const n = o && c.join(
|
|
248
|
+
$,
|
|
249
|
+
`prebuilt-wp-content-for-wp-${o.version}.zip`
|
|
250
|
+
), a = o ? d.existsSync(n) ? O(n) : await z(
|
|
251
|
+
o.releaseUrl,
|
|
252
|
+
`${o.version}.zip`,
|
|
253
|
+
i
|
|
258
254
|
) : void 0;
|
|
259
255
|
p.log("Fetching SQLite integration plugin...");
|
|
260
|
-
const
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
256
|
+
const l = this.args.skipSqliteSetup ? void 0 : await Te(i), u = this.args.followSymlinks === !0, b = this.args.experimentalTrace === !0, W = this.args["mount-before-install"] || [], P = this.args.mount || [], m = R(r);
|
|
257
|
+
await m.isConnected(), p.log("Booting WordPress...");
|
|
258
|
+
const x = await te(
|
|
259
|
+
this.getEffectiveBlueprint()
|
|
260
|
+
);
|
|
261
|
+
return await m.useFileLockManager(t), await m.bootAsPrimaryWorker({
|
|
262
|
+
phpVersion: x.phpVersion,
|
|
263
|
+
wpVersion: x.wpVersion,
|
|
264
264
|
siteUrl: this.siteUrl,
|
|
265
|
-
mountsBeforeWpInstall:
|
|
266
|
-
mountsAfterWpInstall:
|
|
267
|
-
wordPressZip:
|
|
268
|
-
sqliteIntegrationPluginZip: await
|
|
265
|
+
mountsBeforeWpInstall: W,
|
|
266
|
+
mountsAfterWpInstall: P,
|
|
267
|
+
wordPressZip: a && await a.arrayBuffer(),
|
|
268
|
+
sqliteIntegrationPluginZip: await l?.arrayBuffer(),
|
|
269
269
|
firstProcessId: 0,
|
|
270
270
|
processIdSpaceLength: this.processIdSpaceLength,
|
|
271
|
-
followSymlinks:
|
|
272
|
-
trace:
|
|
271
|
+
followSymlinks: u,
|
|
272
|
+
trace: b,
|
|
273
273
|
internalCookieStore: this.args.internalCookieStore,
|
|
274
274
|
withXdebug: this.args.xdebug,
|
|
275
275
|
nativeInternalDirPath: s
|
|
276
|
-
}),
|
|
277
|
-
|
|
278
|
-
await
|
|
279
|
-
), p.log("Cached!")),
|
|
276
|
+
}), o && !this.args["mount-before-install"] && !d.existsSync(n) && (p.log("Caching preinstalled WordPress for the next boot..."), d.writeFileSync(
|
|
277
|
+
n,
|
|
278
|
+
await se(m, "/wordpress")
|
|
279
|
+
), p.log("Cached!")), m;
|
|
280
280
|
}
|
|
281
281
|
async bootSecondaryWorker({
|
|
282
282
|
worker: r,
|
|
@@ -304,41 +304,45 @@ class Fe {
|
|
|
304
304
|
}), await i.isReady(), i;
|
|
305
305
|
}
|
|
306
306
|
async compileInputBlueprint(r) {
|
|
307
|
-
const t = this.
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
php: t.php ?? s?.preferredVersions?.php ?? _,
|
|
312
|
-
wp: t.wp ?? s?.preferredVersions?.wp ?? "latest",
|
|
313
|
-
...s?.preferredVersions || {}
|
|
314
|
-
}
|
|
315
|
-
}, i = new ge();
|
|
316
|
-
let n = "", a = !1;
|
|
317
|
-
return i.addEventListener("progress", (l) => {
|
|
318
|
-
if (a)
|
|
307
|
+
const t = this.getEffectiveBlueprint(), s = new Pe();
|
|
308
|
+
let o = "", i = !1;
|
|
309
|
+
return s.addEventListener("progress", (n) => {
|
|
310
|
+
if (i)
|
|
319
311
|
return;
|
|
320
|
-
|
|
321
|
-
const
|
|
322
|
-
|
|
323
|
-
const
|
|
312
|
+
i = n.detail.progress === 100;
|
|
313
|
+
const a = Math.floor(n.detail.progress);
|
|
314
|
+
o = n.detail.caption || o || "Running the Blueprint";
|
|
315
|
+
const l = `${o.trim()} – ${a}%`;
|
|
324
316
|
this.writeProgressUpdate(
|
|
325
317
|
process.stdout,
|
|
326
|
-
|
|
327
|
-
|
|
318
|
+
l,
|
|
319
|
+
i
|
|
328
320
|
);
|
|
329
|
-
}), await re(
|
|
330
|
-
progress:
|
|
321
|
+
}), await re(t, {
|
|
322
|
+
progress: s,
|
|
331
323
|
additionalSteps: r
|
|
332
324
|
});
|
|
333
325
|
}
|
|
326
|
+
getEffectiveBlueprint() {
|
|
327
|
+
const r = this.args.blueprint;
|
|
328
|
+
return oe(r) ? r : {
|
|
329
|
+
login: this.args.login,
|
|
330
|
+
...r || {},
|
|
331
|
+
preferredVersions: {
|
|
332
|
+
php: this.args.php ?? r?.preferredVersions?.php ?? _,
|
|
333
|
+
wp: this.args.wp ?? r?.preferredVersions?.wp ?? "latest",
|
|
334
|
+
...r?.preferredVersions || {}
|
|
335
|
+
}
|
|
336
|
+
};
|
|
337
|
+
}
|
|
334
338
|
writeProgressUpdate(r, t, s) {
|
|
335
339
|
this.args.verbosity !== T.Quiet.name && t !== this.lastProgressMessage && (this.lastProgressMessage = t, r.isTTY ? (r.cursorTo(0), r.write(t), r.clearLine(1), s && r.write(`
|
|
336
340
|
`)) : r.write(`${t}
|
|
337
341
|
`));
|
|
338
342
|
}
|
|
339
343
|
}
|
|
340
|
-
async function
|
|
341
|
-
const s = `${c.basename(process.argv0)}${e}${process.pid}-`, o = (await
|
|
344
|
+
async function Ue(e, r = !0) {
|
|
345
|
+
const s = `${c.basename(process.argv0)}${e}${process.pid}-`, o = (await Se({
|
|
342
346
|
prefix: s,
|
|
343
347
|
/*
|
|
344
348
|
* Allow recursive cleanup on process exit.
|
|
@@ -350,9 +354,9 @@ async function Ae(e, r = !0) {
|
|
|
350
354
|
*/
|
|
351
355
|
unsafeCleanup: !0
|
|
352
356
|
})).path;
|
|
353
|
-
return r &&
|
|
357
|
+
return r && xe(), o;
|
|
354
358
|
}
|
|
355
|
-
async function
|
|
359
|
+
async function Ce(e, r, t) {
|
|
356
360
|
const o = (await De(
|
|
357
361
|
e,
|
|
358
362
|
r,
|
|
@@ -375,7 +379,7 @@ async function De(e, r, t) {
|
|
|
375
379
|
try {
|
|
376
380
|
const s = d.readdirSync(t).map((i) => c.join(t, i)), o = [];
|
|
377
381
|
for (const i of s)
|
|
378
|
-
await
|
|
382
|
+
await He(
|
|
379
383
|
e,
|
|
380
384
|
r,
|
|
381
385
|
i
|
|
@@ -385,7 +389,7 @@ async function De(e, r, t) {
|
|
|
385
389
|
return p.warn(`Failed to find stale Playground temp dirs: ${s}`), [];
|
|
386
390
|
}
|
|
387
391
|
}
|
|
388
|
-
async function
|
|
392
|
+
async function He(e, r, t) {
|
|
389
393
|
if (!d.lstatSync(t).isDirectory())
|
|
390
394
|
return !1;
|
|
391
395
|
const o = c.basename(t);
|
|
@@ -400,15 +404,15 @@ async function Ce(e, r, t) {
|
|
|
400
404
|
executableName: i[1],
|
|
401
405
|
pid: i[2]
|
|
402
406
|
};
|
|
403
|
-
if (await
|
|
407
|
+
if (await Ve(n.pid, n.executableName))
|
|
404
408
|
return !1;
|
|
405
409
|
const a = Date.now() - r;
|
|
406
410
|
return d.statSync(t).mtime.getTime() < a;
|
|
407
411
|
}
|
|
408
|
-
async function
|
|
412
|
+
async function Ve(e, r) {
|
|
409
413
|
const [t] = await new Promise(
|
|
410
414
|
(s, o) => {
|
|
411
|
-
|
|
415
|
+
We.list(
|
|
412
416
|
{
|
|
413
417
|
pid: e,
|
|
414
418
|
name: r,
|
|
@@ -424,13 +428,13 @@ async function He(e, r) {
|
|
|
424
428
|
return !!t && t.pid === e && t.command === r;
|
|
425
429
|
}
|
|
426
430
|
const T = {
|
|
427
|
-
Quiet: { name: "quiet", severity:
|
|
428
|
-
Normal: { name: "normal", severity:
|
|
429
|
-
Debug: { name: "debug", severity:
|
|
431
|
+
Quiet: { name: "quiet", severity: E.Fatal },
|
|
432
|
+
Normal: { name: "normal", severity: E.Info },
|
|
433
|
+
Debug: { name: "debug", severity: E.Debug }
|
|
430
434
|
};
|
|
431
|
-
async function
|
|
435
|
+
async function dt() {
|
|
432
436
|
try {
|
|
433
|
-
const e =
|
|
437
|
+
const e = fe(process.argv.slice(2)).usage("Usage: wp-playground <command> [options]").positional("command", {
|
|
434
438
|
describe: "Command to run",
|
|
435
439
|
choices: ["server", "run-blueprint", "build-snapshot"],
|
|
436
440
|
demandOption: !0
|
|
@@ -475,7 +479,7 @@ async function ut() {
|
|
|
475
479
|
type: "string",
|
|
476
480
|
nargs: 2,
|
|
477
481
|
array: !0,
|
|
478
|
-
coerce:
|
|
482
|
+
coerce: ae
|
|
479
483
|
}).option("login", {
|
|
480
484
|
describe: "Should log the user in",
|
|
481
485
|
type: "boolean",
|
|
@@ -540,7 +544,7 @@ Warning: Following symlinks will expose files outside mounted directories to Pla
|
|
|
540
544
|
}).option("experimental-multi-worker", {
|
|
541
545
|
describe: "Enable experimental multi-worker support which requires a /wordpress directory backed by a real filesystem. Pass a positive number to specify the number of workers to use. Otherwise, default to the number of CPUs minus 1.",
|
|
542
546
|
type: "number",
|
|
543
|
-
coerce: (o) => o ??
|
|
547
|
+
coerce: (o) => o ?? de().length - 1
|
|
544
548
|
}).option("experimental-blueprints-v2-runner", {
|
|
545
549
|
describe: "Use the experimental Blueprint V2 runner.",
|
|
546
550
|
type: "boolean",
|
|
@@ -554,7 +558,7 @@ Warning: Following symlinks will expose files outside mounted directories to Pla
|
|
|
554
558
|
// Remove the "hidden" flag once Blueprint V2 is fully supported
|
|
555
559
|
hidden: !0
|
|
556
560
|
}).showHelpOnFail(!1).strictOptions().check(async (o) => {
|
|
557
|
-
if ((o["skip-wordpress-setup"] || o.skipWordpressSetup) && (o.skipWordPressSetup = !0), o.wp !== void 0 && !
|
|
561
|
+
if ((o["skip-wordpress-setup"] || o.skipWordpressSetup) && (o.skipWordPressSetup = !0), o.wp !== void 0 && !Me(o.wp))
|
|
558
562
|
try {
|
|
559
563
|
new URL(o.wp);
|
|
560
564
|
} catch {
|
|
@@ -622,7 +626,7 @@ Warning: Following symlinks will expose files outside mounted directories to Pla
|
|
|
622
626
|
...r["mount-dir-before-install"] || []
|
|
623
627
|
]
|
|
624
628
|
};
|
|
625
|
-
await
|
|
629
|
+
await je(s);
|
|
626
630
|
} catch (e) {
|
|
627
631
|
if (!(e instanceof Error))
|
|
628
632
|
throw e;
|
|
@@ -641,10 +645,10 @@ Warning: Following symlinks will expose files outside mounted directories to Pla
|
|
|
641
645
|
process.exit(1);
|
|
642
646
|
}
|
|
643
647
|
}
|
|
644
|
-
async function
|
|
648
|
+
async function je(e) {
|
|
645
649
|
let r, t;
|
|
646
650
|
const s = [];
|
|
647
|
-
if (e.autoMount !== void 0 && (e.autoMount === "" && (e = { ...e, autoMount: process.cwd() }), e =
|
|
651
|
+
if (e.autoMount !== void 0 && (e.autoMount === "" && (e = { ...e, autoMount: process.cwd() }), e = le(e)), e.quiet && (e.verbosity = "quiet", delete e.quiet), e.debug ? e.verbosity = "debug" : e.verbosity === "debug" && (e.debug = !0), e.verbosity) {
|
|
648
652
|
const l = Object.values(T).find(
|
|
649
653
|
(u) => u.name === e.verbosity
|
|
650
654
|
).severity;
|
|
@@ -657,23 +661,23 @@ async function Ve(e) {
|
|
|
657
661
|
p.warn(
|
|
658
662
|
"The fs-ext package is not installed. Internal file locking will not be integrated with host OS file locking."
|
|
659
663
|
);
|
|
660
|
-
}), i = new
|
|
664
|
+
}), i = new ue(o);
|
|
661
665
|
let n = !1, a = !0;
|
|
662
|
-
return p.log("Starting a PHP server..."),
|
|
666
|
+
return p.log("Starting a PHP server..."), Le({
|
|
663
667
|
port: e.port,
|
|
664
668
|
onBind: async (l, u) => {
|
|
665
|
-
const
|
|
669
|
+
const b = `http://127.0.0.1:${u}`, W = e["site-url"] || b, P = e.experimentalMultiWorker ?? 1, m = Math.floor(
|
|
666
670
|
Number.MAX_SAFE_INTEGER / P
|
|
667
|
-
),
|
|
668
|
-
|
|
671
|
+
), x = "-playground-cli-site-", g = await Ue(
|
|
672
|
+
x
|
|
669
673
|
), B = c.dirname(g), I = 2 * 24 * 60 * 60 * 1e3;
|
|
670
|
-
|
|
671
|
-
|
|
674
|
+
Ce(
|
|
675
|
+
x,
|
|
672
676
|
I,
|
|
673
677
|
B
|
|
674
678
|
);
|
|
675
679
|
const v = c.join(g, "internal");
|
|
676
|
-
|
|
680
|
+
D(v);
|
|
677
681
|
const N = [
|
|
678
682
|
"wordpress",
|
|
679
683
|
// Note: These dirs are from Emscripten's "default dirs" list:
|
|
@@ -686,106 +690,106 @@ async function Ve(e) {
|
|
|
686
690
|
"home"
|
|
687
691
|
];
|
|
688
692
|
for (const f of N) {
|
|
689
|
-
const
|
|
690
|
-
if (!(e["mount-before-install"]?.some(
|
|
693
|
+
const w = (h) => h.vfsPath === `/${f}`;
|
|
694
|
+
if (!(e["mount-before-install"]?.some(w) || e.mount?.some(w))) {
|
|
691
695
|
const h = c.join(
|
|
692
696
|
g,
|
|
693
697
|
f
|
|
694
698
|
);
|
|
695
|
-
|
|
699
|
+
D(h), e["mount-before-install"] === void 0 && (e["mount-before-install"] = []), e["mount-before-install"].unshift({
|
|
696
700
|
vfsPath: `/${f}`,
|
|
697
701
|
hostPath: h
|
|
698
702
|
});
|
|
699
703
|
}
|
|
700
704
|
}
|
|
701
|
-
let
|
|
702
|
-
e["experimental-blueprints-v2-runner"] ?
|
|
705
|
+
let k;
|
|
706
|
+
e["experimental-blueprints-v2-runner"] ? k = new $e(e, {
|
|
703
707
|
siteUrl: W,
|
|
704
|
-
processIdSpaceLength:
|
|
705
|
-
}) : (
|
|
708
|
+
processIdSpaceLength: m
|
|
709
|
+
}) : (k = new Ae(e, {
|
|
706
710
|
siteUrl: W,
|
|
707
|
-
processIdSpaceLength:
|
|
708
|
-
}), typeof e.blueprint == "string" && (e.blueprint = await
|
|
711
|
+
processIdSpaceLength: m
|
|
712
|
+
}), typeof e.blueprint == "string" && (e.blueprint = await Ee({
|
|
709
713
|
sourceString: e.blueprint,
|
|
710
714
|
blueprintMayReadAdjacentFiles: e["blueprint-may-read-adjacent-files"] === !0
|
|
711
715
|
})));
|
|
712
|
-
const Z =
|
|
716
|
+
const Z = _e(
|
|
713
717
|
P,
|
|
714
|
-
|
|
715
|
-
({ exitCode: f, isMain:
|
|
718
|
+
k.getWorkerType(),
|
|
719
|
+
({ exitCode: f, isMain: w, workerIndex: L }) => {
|
|
716
720
|
f !== 0 && (p.error(
|
|
717
721
|
`Worker ${L} exited with code ${f}
|
|
718
722
|
`
|
|
719
|
-
),
|
|
723
|
+
), w && e.exitOnPrimaryWorkerCrash && process.exit(1));
|
|
720
724
|
}
|
|
721
725
|
);
|
|
722
726
|
p.log(`Setting up WordPress ${e.wp}`);
|
|
723
727
|
try {
|
|
724
|
-
const [f, ...
|
|
728
|
+
const [f, ...w] = await Z, L = await j(
|
|
725
729
|
i
|
|
726
730
|
);
|
|
727
|
-
if (t = await
|
|
731
|
+
if (t = await k.bootPrimaryWorker(
|
|
728
732
|
f.phpPort,
|
|
729
733
|
L,
|
|
730
734
|
v
|
|
731
735
|
), s.push({
|
|
732
736
|
playground: t,
|
|
733
737
|
worker: f.worker
|
|
734
|
-
}), await t.isReady(), n = !0, p.log("Booted!"), r = new
|
|
735
|
-
const h = await
|
|
738
|
+
}), await t.isReady(), n = !0, p.log("Booted!"), r = new Ie(t), !e["experimental-blueprints-v2-runner"]) {
|
|
739
|
+
const h = await k.compileInputBlueprint(
|
|
736
740
|
e["additional-blueprint-steps"] || []
|
|
737
741
|
);
|
|
738
|
-
h && (p.log("Running the Blueprint..."), await
|
|
742
|
+
h && (p.log("Running the Blueprint..."), await ie(
|
|
739
743
|
h,
|
|
740
744
|
t
|
|
741
745
|
), p.log("Finished running the blueprint"));
|
|
742
746
|
}
|
|
743
|
-
if (e.command === "build-snapshot" ? (await
|
|
747
|
+
if (e.command === "build-snapshot" ? (await ze(t, e.outfile), p.log(`WordPress exported to ${e.outfile}`), process.exit(0)) : e.command === "run-blueprint" && (p.log("Blueprint executed"), process.exit(0)), e.experimentalMultiWorker && e.experimentalMultiWorker > 1) {
|
|
744
748
|
p.log("Preparing additional workers...");
|
|
745
|
-
const h =
|
|
749
|
+
const h = m;
|
|
746
750
|
await Promise.all(
|
|
747
|
-
|
|
748
|
-
const J = h + M *
|
|
749
|
-
worker:
|
|
751
|
+
w.map(async (y, M) => {
|
|
752
|
+
const J = h + M * m, Q = await j(i), A = await k.bootSecondaryWorker({
|
|
753
|
+
worker: y,
|
|
750
754
|
fileLockManagerPort: Q,
|
|
751
755
|
firstProcessId: J,
|
|
752
756
|
nativeInternalDirPath: v
|
|
753
757
|
});
|
|
754
758
|
s.push({
|
|
755
759
|
playground: A,
|
|
756
|
-
worker:
|
|
760
|
+
worker: y.worker
|
|
757
761
|
}), r.addWorker(A);
|
|
758
762
|
})
|
|
759
763
|
);
|
|
760
764
|
}
|
|
761
765
|
return p.log(
|
|
762
|
-
`WordPress is running on ${
|
|
766
|
+
`WordPress is running on ${b} with ${P} worker(s)`
|
|
763
767
|
), e.experimentalDevtools && e.xdebug && (await ke({
|
|
764
|
-
getPHPFile: async (
|
|
768
|
+
getPHPFile: async (y) => await t.readFileAsText(y)
|
|
765
769
|
})).start(), {
|
|
766
770
|
playground: t,
|
|
767
771
|
server: l,
|
|
768
772
|
[Symbol.asyncDispose]: async function() {
|
|
769
773
|
await Promise.all(
|
|
770
774
|
s.map(
|
|
771
|
-
async ({ playground:
|
|
772
|
-
await
|
|
775
|
+
async ({ playground: y, worker: M }) => {
|
|
776
|
+
await y.dispose(), await M.terminate();
|
|
773
777
|
}
|
|
774
778
|
)
|
|
775
|
-
), await new Promise((
|
|
779
|
+
), await new Promise((y) => l.close(y));
|
|
776
780
|
},
|
|
777
781
|
workerThreadCount: P
|
|
778
782
|
};
|
|
779
783
|
} catch (f) {
|
|
780
784
|
if (!e.debug)
|
|
781
785
|
throw f;
|
|
782
|
-
let
|
|
783
|
-
throw await t?.fileExists(U) && (
|
|
786
|
+
let w = "";
|
|
787
|
+
throw await t?.fileExists(U) && (w = await t.readFileAsText(U)), new Error(w, { cause: f });
|
|
784
788
|
}
|
|
785
789
|
},
|
|
786
790
|
async handleRequest(l) {
|
|
787
791
|
if (!n)
|
|
788
|
-
return
|
|
792
|
+
return C.forHttpCode(
|
|
789
793
|
502,
|
|
790
794
|
"WordPress is not ready yet"
|
|
791
795
|
);
|
|
@@ -800,16 +804,16 @@ async function Ve(e) {
|
|
|
800
804
|
"playground_auto_login_already_happened"
|
|
801
805
|
) && (u["Set-Cookie"] = [
|
|
802
806
|
"playground_auto_login_already_happened=1; Max-Age=0; Expires=Thu, 01 Jan 1970 00:00:00 GMT; Path=/"
|
|
803
|
-
]), new
|
|
807
|
+
]), new C(302, u, new Uint8Array());
|
|
804
808
|
}
|
|
805
809
|
return await r.handleRequest(l);
|
|
806
810
|
}
|
|
807
811
|
});
|
|
808
812
|
}
|
|
809
|
-
async function
|
|
813
|
+
async function _e(e, r, t) {
|
|
810
814
|
const s = [];
|
|
811
815
|
for (let o = 0; o < e; o++) {
|
|
812
|
-
const i = await
|
|
816
|
+
const i = await qe(r), n = (a) => {
|
|
813
817
|
t({
|
|
814
818
|
exitCode: a,
|
|
815
819
|
isMain: o === 0,
|
|
@@ -823,10 +827,10 @@ async function je(e, r, t) {
|
|
|
823
827
|
u.command === "worker-script-initialized" && a({ worker: i, phpPort: u.phpPort });
|
|
824
828
|
}), i.once("error", function(u) {
|
|
825
829
|
console.error(u);
|
|
826
|
-
const
|
|
830
|
+
const b = new Error(
|
|
827
831
|
`Worker failed to load worker. ${u.message ? `Original error: ${u.message}` : ""}`
|
|
828
832
|
);
|
|
829
|
-
l(
|
|
833
|
+
l(b);
|
|
830
834
|
}), i.once("exit", n);
|
|
831
835
|
}
|
|
832
836
|
)
|
|
@@ -834,14 +838,14 @@ async function je(e, r, t) {
|
|
|
834
838
|
}
|
|
835
839
|
return Promise.all(s);
|
|
836
840
|
}
|
|
837
|
-
async function
|
|
841
|
+
async function qe(e) {
|
|
838
842
|
return e === "v1" ? new H(new URL("./worker-thread-v1.js", import.meta.url)) : new H(new URL("./worker-thread-v2.js", import.meta.url));
|
|
839
843
|
}
|
|
840
844
|
async function j(e) {
|
|
841
|
-
const { port1: r, port2: t } = new
|
|
842
|
-
return await
|
|
845
|
+
const { port1: r, port2: t } = new ne();
|
|
846
|
+
return await ce() ? G(e, null, r) : await K(e, r), t;
|
|
843
847
|
}
|
|
844
|
-
async function
|
|
848
|
+
async function ze(e, r) {
|
|
845
849
|
await e.run({
|
|
846
850
|
code: `<?php
|
|
847
851
|
$zip = new ZipArchive();
|
|
@@ -867,7 +871,7 @@ async function qe(e, r) {
|
|
|
867
871
|
}
|
|
868
872
|
export {
|
|
869
873
|
T as L,
|
|
870
|
-
|
|
871
|
-
|
|
874
|
+
dt as p,
|
|
875
|
+
je as r
|
|
872
876
|
};
|
|
873
|
-
//# sourceMappingURL=run-cli-
|
|
877
|
+
//# sourceMappingURL=run-cli-Md2TQOSk.js.map
|