@wp-playground/cli 3.0.8 → 3.0.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cli.cjs +1 -1
- package/cli.js +1 -1
- package/index.cjs +1 -1
- package/index.js +1 -1
- package/package.json +17 -14
- package/{run-cli-DdsLZ1X6.cjs → run-cli-Bb8U_jz3.cjs} +8 -8
- package/run-cli-Bb8U_jz3.cjs.map +1 -0
- package/{run-cli-Md2TQOSk.js → run-cli-C0WqHEVM.js} +178 -159
- package/run-cli-C0WqHEVM.js.map +1 -0
- package/run-cli.d.ts +1 -0
- package/start-server.d.ts +1 -1
- package/run-cli-DdsLZ1X6.cjs.map +0 -1
- package/run-cli-Md2TQOSk.js.map +0 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { logger as p, LogSeverity as
|
|
2
|
-
import { consumeAPI as R, SupportedPHPVersions as X, printDebugDetails as Y,
|
|
1
|
+
import { logger as p, LogSeverity as I, errorLogPath as A } from "@php-wasm/logger";
|
|
2
|
+
import { PHPResponse as E, consumeAPI as R, SupportedPHPVersions as X, printDebugDetails as Y, exposeAPI as G, exposeSyncAPI as K } from "@php-wasm/universal";
|
|
3
3
|
import { resolveRemoteBlueprint as ee, resolveRuntimeConfiguration as te, compileBlueprintV1 as re, isBlueprintBundle as oe, runBlueprintV1Steps as ie } from "@wp-playground/blueprints";
|
|
4
4
|
import { zipDirectory as se, RecommendedPHPVersion as _ } from "@wp-playground/common";
|
|
5
|
-
import
|
|
5
|
+
import c, { mkdirSync as D } from "fs";
|
|
6
6
|
import { Worker as H, MessageChannel as ne } from "worker_threads";
|
|
7
7
|
import { p as V, a as ae, e as le } from "./mounts-D1_eXSTw.js";
|
|
8
8
|
import pe from "express";
|
|
@@ -10,9 +10,9 @@ import { FileLockManagerForNode as ue } from "@php-wasm/node";
|
|
|
10
10
|
import q, { cpus as de } from "os";
|
|
11
11
|
import { jspi as ce } from "wasm-feature-detect";
|
|
12
12
|
import fe from "yargs";
|
|
13
|
-
import
|
|
14
|
-
import { NodeJsFilesystem as me, OverlayFilesystem as we, InMemoryFilesystem as ye, ZipFilesystem as
|
|
15
|
-
import { EmscriptenDownloadMonitor as
|
|
13
|
+
import f, { basename as he } from "path";
|
|
14
|
+
import { NodeJsFilesystem as me, OverlayFilesystem as we, InMemoryFilesystem as ye, ZipFilesystem as be } from "@wp-playground/storage";
|
|
15
|
+
import { EmscriptenDownloadMonitor as ge, ProgressTracker as Pe } from "@php-wasm/progress";
|
|
16
16
|
import { resolveWordPressRelease as ve } from "@wp-playground/wordpress";
|
|
17
17
|
import S from "fs-extra";
|
|
18
18
|
import { startBridge as ke } from "@php-wasm/xdebug-bridge";
|
|
@@ -20,22 +20,27 @@ import { dir as Se, setGracefulCleanup as xe } from "tmp-promise";
|
|
|
20
20
|
import We from "ps-man";
|
|
21
21
|
async function Le(e) {
|
|
22
22
|
const r = pe(), t = await new Promise((i, n) => {
|
|
23
|
-
const
|
|
24
|
-
const
|
|
25
|
-
|
|
23
|
+
const l = r.listen(e.port, () => {
|
|
24
|
+
const a = l.address();
|
|
25
|
+
a === null || typeof a == "string" ? n(new Error("Server address is not available")) : i(l);
|
|
26
26
|
});
|
|
27
27
|
});
|
|
28
28
|
r.use("/", async (i, n) => {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
29
|
+
let l;
|
|
30
|
+
try {
|
|
31
|
+
l = await e.handleRequest({
|
|
32
|
+
url: i.url,
|
|
33
|
+
headers: $e(i),
|
|
34
|
+
method: i.method,
|
|
35
|
+
body: await Re(i)
|
|
36
|
+
});
|
|
37
|
+
} catch (a) {
|
|
38
|
+
p.error(a), l = E.forHttpCode(500);
|
|
39
|
+
}
|
|
40
|
+
n.statusCode = l.httpStatusCode;
|
|
41
|
+
for (const a in l.headers)
|
|
42
|
+
n.setHeader(a, l.headers[a]);
|
|
43
|
+
n.end(l.bytes);
|
|
39
44
|
});
|
|
40
45
|
const o = t.address().port;
|
|
41
46
|
return await e.onBind(t, o);
|
|
@@ -47,14 +52,14 @@ const Re = async (e) => await new Promise((r) => {
|
|
|
47
52
|
}), e.on("end", () => {
|
|
48
53
|
r(new Uint8Array(Buffer.concat(t)));
|
|
49
54
|
});
|
|
50
|
-
}),
|
|
55
|
+
}), $e = (e) => {
|
|
51
56
|
const r = {};
|
|
52
57
|
if (e.rawHeaders && e.rawHeaders.length)
|
|
53
58
|
for (let t = 0; t < e.rawHeaders.length; t += 2)
|
|
54
59
|
r[e.rawHeaders[t].toLowerCase()] = e.rawHeaders[t + 1];
|
|
55
60
|
return r;
|
|
56
61
|
};
|
|
57
|
-
class
|
|
62
|
+
class Be {
|
|
58
63
|
constructor(r) {
|
|
59
64
|
this.workerLoads = [], this.addWorker(r);
|
|
60
65
|
}
|
|
@@ -79,7 +84,7 @@ class Ie {
|
|
|
79
84
|
function Me(e) {
|
|
80
85
|
return /^latest$|^trunk$|^nightly$|^(?:(\d+)\.(\d+)(?:\.(\d+))?)((?:-beta(?:\d+)?)|(?:-RC(?:\d+)?))?$/.test(e);
|
|
81
86
|
}
|
|
82
|
-
async function
|
|
87
|
+
async function Ie({
|
|
83
88
|
sourceString: e,
|
|
84
89
|
blueprintMayReadAdjacentFiles: r
|
|
85
90
|
}) {
|
|
@@ -87,22 +92,22 @@ async function Ee({
|
|
|
87
92
|
return;
|
|
88
93
|
if (e.startsWith("http://") || e.startsWith("https://"))
|
|
89
94
|
return await ee(e);
|
|
90
|
-
let t =
|
|
91
|
-
if (!
|
|
95
|
+
let t = f.resolve(process.cwd(), e);
|
|
96
|
+
if (!c.existsSync(t))
|
|
92
97
|
throw new Error(`Blueprint file does not exist: ${t}`);
|
|
93
|
-
const s =
|
|
94
|
-
if (s.isDirectory() && (t =
|
|
98
|
+
const s = c.statSync(t);
|
|
99
|
+
if (s.isDirectory() && (t = f.join(t, "blueprint.json")), !s.isFile() && s.isSymbolicLink())
|
|
95
100
|
throw new Error(
|
|
96
101
|
`Blueprint path is neither a file nor a directory: ${t}`
|
|
97
102
|
);
|
|
98
|
-
const o =
|
|
103
|
+
const o = f.extname(t);
|
|
99
104
|
switch (o) {
|
|
100
105
|
case ".zip":
|
|
101
|
-
return
|
|
102
|
-
|
|
106
|
+
return be.fromArrayBuffer(
|
|
107
|
+
c.readFileSync(t).buffer
|
|
103
108
|
);
|
|
104
109
|
case ".json": {
|
|
105
|
-
const i =
|
|
110
|
+
const i = c.readFileSync(t, "utf-8");
|
|
106
111
|
try {
|
|
107
112
|
JSON.parse(i);
|
|
108
113
|
} catch {
|
|
@@ -110,7 +115,7 @@ async function Ee({
|
|
|
110
115
|
`Blueprint file at ${t} is not a valid JSON file`
|
|
111
116
|
);
|
|
112
117
|
}
|
|
113
|
-
const n =
|
|
118
|
+
const n = f.dirname(t), l = new me(n);
|
|
114
119
|
return new we([
|
|
115
120
|
new ye({
|
|
116
121
|
"blueprint.json": i
|
|
@@ -120,14 +125,14 @@ async function Ee({
|
|
|
120
125
|
* unless the user explicitly allowed it.
|
|
121
126
|
*/
|
|
122
127
|
{
|
|
123
|
-
read(
|
|
128
|
+
read(a) {
|
|
124
129
|
if (!r)
|
|
125
130
|
throw new Error(
|
|
126
|
-
`Error: Blueprint contained tried to read a local file at path "${
|
|
131
|
+
`Error: Blueprint contained tried to read a local file at path "${a}" (via a resource of type "bundled"). Playground restricts access to local resources by default as a security measure.
|
|
127
132
|
|
|
128
133
|
You can allow this Blueprint to read files from the same parent directory by explicitly adding the --blueprint-may-read-adjacent-files option to your command.`
|
|
129
134
|
);
|
|
130
|
-
return
|
|
135
|
+
return l.read(a);
|
|
131
136
|
}
|
|
132
137
|
}
|
|
133
138
|
]);
|
|
@@ -138,7 +143,7 @@ You can allow this Blueprint to read files from the same parent directory by exp
|
|
|
138
143
|
);
|
|
139
144
|
}
|
|
140
145
|
}
|
|
141
|
-
class
|
|
146
|
+
class Ee {
|
|
142
147
|
constructor(r, t) {
|
|
143
148
|
this.lastProgressMessage = "", this.args = r, this.siteUrl = t.siteUrl, this.processIdSpaceLength = t.processIdSpaceLength, this.phpVersion = r.php;
|
|
144
149
|
}
|
|
@@ -187,7 +192,7 @@ class $e {
|
|
|
187
192
|
`));
|
|
188
193
|
}
|
|
189
194
|
}
|
|
190
|
-
const
|
|
195
|
+
const T = f.join(q.homedir(), ".wordpress-playground");
|
|
191
196
|
async function Te(e) {
|
|
192
197
|
return await z(
|
|
193
198
|
"https://github.com/WordPress/sqlite-database-integration/archive/refs/heads/develop.zip",
|
|
@@ -196,28 +201,28 @@ async function Te(e) {
|
|
|
196
201
|
);
|
|
197
202
|
}
|
|
198
203
|
async function z(e, r, t) {
|
|
199
|
-
const s =
|
|
200
|
-
return S.existsSync(s) || (S.ensureDirSync(
|
|
204
|
+
const s = f.join(T, r);
|
|
205
|
+
return S.existsSync(s) || (S.ensureDirSync(T), await Fe(e, s, t)), O(s);
|
|
201
206
|
}
|
|
202
207
|
async function Fe(e, r, t) {
|
|
203
208
|
const o = (await t.monitorFetch(fetch(e))).body.getReader(), i = `${r}.partial`, n = S.createWriteStream(i);
|
|
204
209
|
for (; ; ) {
|
|
205
|
-
const { done:
|
|
206
|
-
if (
|
|
210
|
+
const { done: l, value: a } = await o.read();
|
|
211
|
+
if (a && n.write(a), l)
|
|
207
212
|
break;
|
|
208
213
|
}
|
|
209
|
-
n.close(), n.closed || await new Promise((
|
|
214
|
+
n.close(), n.closed || await new Promise((l, a) => {
|
|
210
215
|
n.on("finish", () => {
|
|
211
|
-
S.renameSync(i, r),
|
|
212
|
-
}), n.on("error", (
|
|
213
|
-
S.removeSync(i),
|
|
216
|
+
S.renameSync(i, r), l(null);
|
|
217
|
+
}), n.on("error", (d) => {
|
|
218
|
+
S.removeSync(i), a(d);
|
|
214
219
|
});
|
|
215
220
|
});
|
|
216
221
|
}
|
|
217
222
|
function O(e, r) {
|
|
218
223
|
return new File([S.readFileSync(e)], he(e));
|
|
219
224
|
}
|
|
220
|
-
class
|
|
225
|
+
class Ce {
|
|
221
226
|
constructor(r, t) {
|
|
222
227
|
this.lastProgressMessage = "", this.args = r, this.siteUrl = t.siteUrl, this.processIdSpaceLength = t.processIdSpaceLength;
|
|
223
228
|
}
|
|
@@ -226,34 +231,34 @@ class Ae {
|
|
|
226
231
|
}
|
|
227
232
|
async bootPrimaryWorker(r, t, s) {
|
|
228
233
|
let o;
|
|
229
|
-
const i = new
|
|
234
|
+
const i = new ge();
|
|
230
235
|
if (!this.args.skipWordPressSetup) {
|
|
231
|
-
let
|
|
232
|
-
i.addEventListener("progress", (
|
|
233
|
-
if (
|
|
236
|
+
let y = !1;
|
|
237
|
+
i.addEventListener("progress", ($) => {
|
|
238
|
+
if (y)
|
|
234
239
|
return;
|
|
235
|
-
const { loaded:
|
|
236
|
-
Math.min(100, 100 *
|
|
240
|
+
const { loaded: C, total: B } = $.detail, P = Math.floor(
|
|
241
|
+
Math.min(100, 100 * C / B)
|
|
237
242
|
);
|
|
238
|
-
|
|
243
|
+
y = P === 100, this.writeProgressUpdate(
|
|
239
244
|
process.stdout,
|
|
240
|
-
`Downloading WordPress ${
|
|
241
|
-
|
|
245
|
+
`Downloading WordPress ${P}%...`,
|
|
246
|
+
y
|
|
242
247
|
);
|
|
243
248
|
}), o = await ve(this.args.wp), p.log(
|
|
244
249
|
`Resolved WordPress release URL: ${o?.releaseUrl}`
|
|
245
250
|
);
|
|
246
251
|
}
|
|
247
|
-
const n = o &&
|
|
248
|
-
|
|
252
|
+
const n = o && f.join(
|
|
253
|
+
T,
|
|
249
254
|
`prebuilt-wp-content-for-wp-${o.version}.zip`
|
|
250
|
-
),
|
|
255
|
+
), l = o ? c.existsSync(n) ? O(n) : await z(
|
|
251
256
|
o.releaseUrl,
|
|
252
257
|
`${o.version}.zip`,
|
|
253
258
|
i
|
|
254
259
|
) : void 0;
|
|
255
260
|
p.log("Fetching SQLite integration plugin...");
|
|
256
|
-
const
|
|
261
|
+
const a = this.args.skipSqliteSetup ? void 0 : await Te(i), d = this.args.followSymlinks === !0, b = this.args.experimentalTrace === !0, W = this.args["mount-before-install"] || [], g = this.args.mount || [], m = R(r);
|
|
257
262
|
await m.isConnected(), p.log("Booting WordPress...");
|
|
258
263
|
const x = await te(
|
|
259
264
|
this.getEffectiveBlueprint()
|
|
@@ -263,17 +268,17 @@ class Ae {
|
|
|
263
268
|
wpVersion: x.wpVersion,
|
|
264
269
|
siteUrl: this.siteUrl,
|
|
265
270
|
mountsBeforeWpInstall: W,
|
|
266
|
-
mountsAfterWpInstall:
|
|
267
|
-
wordPressZip:
|
|
268
|
-
sqliteIntegrationPluginZip: await
|
|
271
|
+
mountsAfterWpInstall: g,
|
|
272
|
+
wordPressZip: l && await l.arrayBuffer(),
|
|
273
|
+
sqliteIntegrationPluginZip: await a?.arrayBuffer(),
|
|
269
274
|
firstProcessId: 0,
|
|
270
275
|
processIdSpaceLength: this.processIdSpaceLength,
|
|
271
|
-
followSymlinks:
|
|
276
|
+
followSymlinks: d,
|
|
272
277
|
trace: b,
|
|
273
278
|
internalCookieStore: this.args.internalCookieStore,
|
|
274
279
|
withXdebug: this.args.xdebug,
|
|
275
280
|
nativeInternalDirPath: s
|
|
276
|
-
}), o && !this.args["mount-before-install"] && !
|
|
281
|
+
}), o && !this.args["mount-before-install"] && !c.existsSync(n) && (p.log("Caching preinstalled WordPress for the next boot..."), c.writeFileSync(
|
|
277
282
|
n,
|
|
278
283
|
await se(m, "/wordpress")
|
|
279
284
|
), p.log("Cached!")), m;
|
|
@@ -310,12 +315,12 @@ class Ae {
|
|
|
310
315
|
if (i)
|
|
311
316
|
return;
|
|
312
317
|
i = n.detail.progress === 100;
|
|
313
|
-
const
|
|
318
|
+
const l = Math.floor(n.detail.progress);
|
|
314
319
|
o = n.detail.caption || o || "Running the Blueprint";
|
|
315
|
-
const
|
|
320
|
+
const a = `${o.trim()} – ${l}%`;
|
|
316
321
|
this.writeProgressUpdate(
|
|
317
322
|
process.stdout,
|
|
318
|
-
|
|
323
|
+
a,
|
|
319
324
|
i
|
|
320
325
|
);
|
|
321
326
|
}), await re(t, {
|
|
@@ -336,13 +341,13 @@ class Ae {
|
|
|
336
341
|
};
|
|
337
342
|
}
|
|
338
343
|
writeProgressUpdate(r, t, s) {
|
|
339
|
-
this.args.verbosity !==
|
|
344
|
+
this.args.verbosity !== F.Quiet.name && t !== this.lastProgressMessage && (this.lastProgressMessage = t, r.isTTY ? (r.cursorTo(0), r.write(t), r.clearLine(1), s && r.write(`
|
|
340
345
|
`)) : r.write(`${t}
|
|
341
346
|
`));
|
|
342
347
|
}
|
|
343
348
|
}
|
|
344
349
|
async function Ue(e, r = !0) {
|
|
345
|
-
const s = `${
|
|
350
|
+
const s = `${f.basename(process.argv0)}${e}${process.pid}-`, o = (await Se({
|
|
346
351
|
prefix: s,
|
|
347
352
|
/*
|
|
348
353
|
* Allow recursive cleanup on process exit.
|
|
@@ -356,17 +361,17 @@ async function Ue(e, r = !0) {
|
|
|
356
361
|
})).path;
|
|
357
362
|
return r && xe(), o;
|
|
358
363
|
}
|
|
359
|
-
async function
|
|
364
|
+
async function Ae(e, r, t) {
|
|
360
365
|
const o = (await De(
|
|
361
366
|
e,
|
|
362
367
|
r,
|
|
363
368
|
t
|
|
364
369
|
)).map(
|
|
365
370
|
(i) => new Promise((n) => {
|
|
366
|
-
|
|
367
|
-
|
|
371
|
+
c.rm(i, { recursive: !0 }, (l) => {
|
|
372
|
+
l ? p.warn(
|
|
368
373
|
`Failed to delete stale Playground temp dir: ${i}`,
|
|
369
|
-
|
|
374
|
+
l
|
|
370
375
|
) : p.info(
|
|
371
376
|
`Deleted stale Playground temp dir: ${i}`
|
|
372
377
|
), n();
|
|
@@ -377,7 +382,7 @@ async function Ce(e, r, t) {
|
|
|
377
382
|
}
|
|
378
383
|
async function De(e, r, t) {
|
|
379
384
|
try {
|
|
380
|
-
const s =
|
|
385
|
+
const s = c.readdirSync(t).map((i) => f.join(t, i)), o = [];
|
|
381
386
|
for (const i of s)
|
|
382
387
|
await He(
|
|
383
388
|
e,
|
|
@@ -390,9 +395,9 @@ async function De(e, r, t) {
|
|
|
390
395
|
}
|
|
391
396
|
}
|
|
392
397
|
async function He(e, r, t) {
|
|
393
|
-
if (!
|
|
398
|
+
if (!c.lstatSync(t).isDirectory())
|
|
394
399
|
return !1;
|
|
395
|
-
const o =
|
|
400
|
+
const o = f.basename(t);
|
|
396
401
|
if (!o.includes(e))
|
|
397
402
|
return !1;
|
|
398
403
|
const i = o.match(
|
|
@@ -406,8 +411,8 @@ async function He(e, r, t) {
|
|
|
406
411
|
};
|
|
407
412
|
if (await Ve(n.pid, n.executableName))
|
|
408
413
|
return !1;
|
|
409
|
-
const
|
|
410
|
-
return
|
|
414
|
+
const l = Date.now() - r;
|
|
415
|
+
return c.statSync(t).mtime.getTime() < l;
|
|
411
416
|
}
|
|
412
417
|
async function Ve(e, r) {
|
|
413
418
|
const [t] = await new Promise(
|
|
@@ -427,10 +432,10 @@ async function Ve(e, r) {
|
|
|
427
432
|
);
|
|
428
433
|
return !!t && t.pid === e && t.command === r;
|
|
429
434
|
}
|
|
430
|
-
const
|
|
431
|
-
Quiet: { name: "quiet", severity:
|
|
432
|
-
Normal: { name: "normal", severity:
|
|
433
|
-
Debug: { name: "debug", severity:
|
|
435
|
+
const F = {
|
|
436
|
+
Quiet: { name: "quiet", severity: I.Fatal },
|
|
437
|
+
Normal: { name: "normal", severity: I.Info },
|
|
438
|
+
Debug: { name: "debug", severity: I.Debug }
|
|
434
439
|
};
|
|
435
440
|
async function dt() {
|
|
436
441
|
try {
|
|
@@ -507,7 +512,7 @@ async function dt() {
|
|
|
507
512
|
}).option("verbosity", {
|
|
508
513
|
describe: "Output logs and progress messages.",
|
|
509
514
|
type: "string",
|
|
510
|
-
choices: Object.values(
|
|
515
|
+
choices: Object.values(F).map(
|
|
511
516
|
(o) => o.name
|
|
512
517
|
),
|
|
513
518
|
default: "normal"
|
|
@@ -577,7 +582,7 @@ Warning: Following symlinks will expose files outside mounted directories to Pla
|
|
|
577
582
|
if (o["auto-mount"]) {
|
|
578
583
|
let i = !1;
|
|
579
584
|
try {
|
|
580
|
-
i =
|
|
585
|
+
i = c.statSync(o["auto-mount"]).isDirectory();
|
|
581
586
|
} catch {
|
|
582
587
|
i = !1;
|
|
583
588
|
}
|
|
@@ -649,35 +654,37 @@ async function je(e) {
|
|
|
649
654
|
let r, t;
|
|
650
655
|
const s = [];
|
|
651
656
|
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) {
|
|
652
|
-
const
|
|
653
|
-
(
|
|
657
|
+
const a = Object.values(F).find(
|
|
658
|
+
(d) => d.name === e.verbosity
|
|
654
659
|
).severity;
|
|
655
|
-
p.setSeverityFilterLevel(
|
|
660
|
+
p.setSeverityFilterLevel(a);
|
|
656
661
|
}
|
|
657
662
|
const o = q.platform() === "win32" ? (
|
|
658
663
|
// @TODO: Enable fs-ext here when it works with Windows.
|
|
659
664
|
void 0
|
|
660
|
-
) : await import("fs-ext").then((
|
|
665
|
+
) : await import("fs-ext").then((a) => a.flockSync).catch(() => {
|
|
661
666
|
p.warn(
|
|
662
667
|
"The fs-ext package is not installed. Internal file locking will not be integrated with host OS file locking."
|
|
663
668
|
);
|
|
664
669
|
}), i = new ue(o);
|
|
665
|
-
let n = !1,
|
|
670
|
+
let n = !1, l = !0;
|
|
666
671
|
return p.log("Starting a PHP server..."), Le({
|
|
667
672
|
port: e.port,
|
|
668
|
-
onBind: async (
|
|
669
|
-
const b = `http://127.0.0.1:${
|
|
670
|
-
Number.MAX_SAFE_INTEGER /
|
|
671
|
-
), x = "-playground-cli-site-",
|
|
673
|
+
onBind: async (a, d) => {
|
|
674
|
+
const b = `http://127.0.0.1:${d}`, W = e["site-url"] || b, g = e.experimentalMultiWorker ?? 1, m = Math.floor(
|
|
675
|
+
Number.MAX_SAFE_INTEGER / g
|
|
676
|
+
), x = "-playground-cli-site-", y = await Ue(
|
|
672
677
|
x
|
|
673
|
-
)
|
|
674
|
-
|
|
678
|
+
);
|
|
679
|
+
p.debug(`Native temp dir for VFS root: ${y}`);
|
|
680
|
+
const $ = f.dirname(y), B = 2 * 24 * 60 * 60 * 1e3;
|
|
681
|
+
Ae(
|
|
675
682
|
x,
|
|
676
|
-
|
|
677
|
-
|
|
683
|
+
B,
|
|
684
|
+
$
|
|
678
685
|
);
|
|
679
|
-
const
|
|
680
|
-
D(
|
|
686
|
+
const P = f.join(y, "internal");
|
|
687
|
+
D(P);
|
|
681
688
|
const N = [
|
|
682
689
|
"wordpress",
|
|
683
690
|
// Note: These dirs are from Emscripten's "default dirs" list:
|
|
@@ -689,54 +696,64 @@ async function je(e) {
|
|
|
689
696
|
"tmp",
|
|
690
697
|
"home"
|
|
691
698
|
];
|
|
692
|
-
for (const
|
|
693
|
-
const w = (h) => h.vfsPath === `/${
|
|
699
|
+
for (const u of N) {
|
|
700
|
+
const w = (h) => h.vfsPath === `/${u}`;
|
|
694
701
|
if (!(e["mount-before-install"]?.some(w) || e.mount?.some(w))) {
|
|
695
|
-
const h =
|
|
696
|
-
|
|
697
|
-
|
|
702
|
+
const h = f.join(
|
|
703
|
+
y,
|
|
704
|
+
u
|
|
698
705
|
);
|
|
699
706
|
D(h), e["mount-before-install"] === void 0 && (e["mount-before-install"] = []), e["mount-before-install"].unshift({
|
|
700
|
-
vfsPath: `/${
|
|
707
|
+
vfsPath: `/${u}`,
|
|
701
708
|
hostPath: h
|
|
702
709
|
});
|
|
703
710
|
}
|
|
704
711
|
}
|
|
705
|
-
|
|
706
|
-
|
|
712
|
+
if (e["mount-before-install"])
|
|
713
|
+
for (const u of e["mount-before-install"])
|
|
714
|
+
p.debug(
|
|
715
|
+
`Mount before WP install: ${u.vfsPath} -> ${u.hostPath}`
|
|
716
|
+
);
|
|
717
|
+
if (e.mount)
|
|
718
|
+
for (const u of e.mount)
|
|
719
|
+
p.debug(
|
|
720
|
+
`Mount after WP install: ${u.vfsPath} -> ${u.hostPath}`
|
|
721
|
+
);
|
|
722
|
+
let v;
|
|
723
|
+
e["experimental-blueprints-v2-runner"] ? v = new Ee(e, {
|
|
707
724
|
siteUrl: W,
|
|
708
725
|
processIdSpaceLength: m
|
|
709
|
-
}) : (
|
|
726
|
+
}) : (v = new Ce(e, {
|
|
710
727
|
siteUrl: W,
|
|
711
728
|
processIdSpaceLength: m
|
|
712
|
-
}), typeof e.blueprint == "string" && (e.blueprint = await
|
|
729
|
+
}), typeof e.blueprint == "string" && (e.blueprint = await Ie({
|
|
713
730
|
sourceString: e.blueprint,
|
|
714
731
|
blueprintMayReadAdjacentFiles: e["blueprint-may-read-adjacent-files"] === !0
|
|
715
732
|
})));
|
|
716
733
|
const Z = _e(
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
({ exitCode:
|
|
720
|
-
|
|
721
|
-
`Worker ${L} exited with code ${
|
|
734
|
+
g,
|
|
735
|
+
v.getWorkerType(),
|
|
736
|
+
({ exitCode: u, isMain: w, workerIndex: L }) => {
|
|
737
|
+
u !== 0 && (p.error(
|
|
738
|
+
`Worker ${L} exited with code ${u}
|
|
722
739
|
`
|
|
723
740
|
), w && e.exitOnPrimaryWorkerCrash && process.exit(1));
|
|
724
741
|
}
|
|
725
742
|
);
|
|
726
743
|
p.log(`Setting up WordPress ${e.wp}`);
|
|
727
744
|
try {
|
|
728
|
-
const [
|
|
745
|
+
const [u, ...w] = await Z, L = await j(
|
|
729
746
|
i
|
|
730
747
|
);
|
|
731
|
-
if (t = await
|
|
732
|
-
|
|
748
|
+
if (t = await v.bootPrimaryWorker(
|
|
749
|
+
u.phpPort,
|
|
733
750
|
L,
|
|
734
|
-
|
|
751
|
+
P
|
|
735
752
|
), s.push({
|
|
736
753
|
playground: t,
|
|
737
|
-
worker:
|
|
738
|
-
}), await t.isReady(), n = !0, p.log("Booted!"), r = new
|
|
739
|
-
const h = await
|
|
754
|
+
worker: u.worker
|
|
755
|
+
}), await t.isReady(), n = !0, p.log("Booted!"), r = new Be(t), !e["experimental-blueprints-v2-runner"]) {
|
|
756
|
+
const h = await v.compileInputBlueprint(
|
|
740
757
|
e["additional-blueprint-steps"] || []
|
|
741
758
|
);
|
|
742
759
|
h && (p.log("Running the Blueprint..."), await ie(
|
|
@@ -748,89 +765,91 @@ async function je(e) {
|
|
|
748
765
|
p.log("Preparing additional workers...");
|
|
749
766
|
const h = m;
|
|
750
767
|
await Promise.all(
|
|
751
|
-
w.map(async (
|
|
752
|
-
const J = h + M * m, Q = await j(i),
|
|
753
|
-
worker:
|
|
768
|
+
w.map(async (k, M) => {
|
|
769
|
+
const J = h + M * m, Q = await j(i), U = await v.bootSecondaryWorker({
|
|
770
|
+
worker: k,
|
|
754
771
|
fileLockManagerPort: Q,
|
|
755
772
|
firstProcessId: J,
|
|
756
|
-
nativeInternalDirPath:
|
|
773
|
+
nativeInternalDirPath: P
|
|
757
774
|
});
|
|
758
775
|
s.push({
|
|
759
|
-
playground:
|
|
760
|
-
worker:
|
|
761
|
-
}), r.addWorker(
|
|
776
|
+
playground: U,
|
|
777
|
+
worker: k.worker
|
|
778
|
+
}), r.addWorker(U);
|
|
762
779
|
})
|
|
763
780
|
);
|
|
764
781
|
}
|
|
765
782
|
return p.log(
|
|
766
|
-
`WordPress is running on ${b} with ${
|
|
783
|
+
`WordPress is running on ${b} with ${g} worker(s)`
|
|
767
784
|
), e.experimentalDevtools && e.xdebug && (await ke({
|
|
768
|
-
|
|
785
|
+
phpInstance: t,
|
|
786
|
+
phpRoot: "/wordpress"
|
|
769
787
|
})).start(), {
|
|
770
788
|
playground: t,
|
|
771
|
-
server:
|
|
789
|
+
server: a,
|
|
790
|
+
serverUrl: b,
|
|
772
791
|
[Symbol.asyncDispose]: async function() {
|
|
773
792
|
await Promise.all(
|
|
774
793
|
s.map(
|
|
775
|
-
async ({ playground:
|
|
776
|
-
await
|
|
794
|
+
async ({ playground: k, worker: M }) => {
|
|
795
|
+
await k.dispose(), await M.terminate();
|
|
777
796
|
}
|
|
778
797
|
)
|
|
779
|
-
), await new Promise((
|
|
798
|
+
), await new Promise((k) => a.close(k));
|
|
780
799
|
},
|
|
781
|
-
workerThreadCount:
|
|
800
|
+
workerThreadCount: g
|
|
782
801
|
};
|
|
783
|
-
} catch (
|
|
802
|
+
} catch (u) {
|
|
784
803
|
if (!e.debug)
|
|
785
|
-
throw
|
|
804
|
+
throw u;
|
|
786
805
|
let w = "";
|
|
787
|
-
throw await t?.fileExists(
|
|
806
|
+
throw await t?.fileExists(A) && (w = await t.readFileAsText(A)), new Error(w, { cause: u });
|
|
788
807
|
}
|
|
789
808
|
},
|
|
790
|
-
async handleRequest(
|
|
809
|
+
async handleRequest(a) {
|
|
791
810
|
if (!n)
|
|
792
|
-
return
|
|
811
|
+
return E.forHttpCode(
|
|
793
812
|
502,
|
|
794
813
|
"WordPress is not ready yet"
|
|
795
814
|
);
|
|
796
|
-
if (
|
|
797
|
-
|
|
798
|
-
const
|
|
815
|
+
if (l) {
|
|
816
|
+
l = !1;
|
|
817
|
+
const d = {
|
|
799
818
|
"Content-Type": ["text/plain"],
|
|
800
819
|
"Content-Length": ["0"],
|
|
801
|
-
Location: [
|
|
820
|
+
Location: [a.url]
|
|
802
821
|
};
|
|
803
|
-
return
|
|
822
|
+
return a.headers?.cookie?.includes(
|
|
804
823
|
"playground_auto_login_already_happened"
|
|
805
|
-
) && (
|
|
824
|
+
) && (d["Set-Cookie"] = [
|
|
806
825
|
"playground_auto_login_already_happened=1; Max-Age=0; Expires=Thu, 01 Jan 1970 00:00:00 GMT; Path=/"
|
|
807
|
-
]), new
|
|
826
|
+
]), new E(302, d, new Uint8Array());
|
|
808
827
|
}
|
|
809
|
-
return await r.handleRequest(
|
|
828
|
+
return await r.handleRequest(a);
|
|
810
829
|
}
|
|
811
830
|
});
|
|
812
831
|
}
|
|
813
832
|
async function _e(e, r, t) {
|
|
814
833
|
const s = [];
|
|
815
834
|
for (let o = 0; o < e; o++) {
|
|
816
|
-
const i = await qe(r), n = (
|
|
835
|
+
const i = await qe(r), n = (l) => {
|
|
817
836
|
t({
|
|
818
|
-
exitCode:
|
|
837
|
+
exitCode: l,
|
|
819
838
|
isMain: o === 0,
|
|
820
839
|
workerIndex: o
|
|
821
840
|
});
|
|
822
841
|
};
|
|
823
842
|
s.push(
|
|
824
843
|
new Promise(
|
|
825
|
-
(
|
|
826
|
-
i.once("message", function(
|
|
827
|
-
|
|
828
|
-
}), i.once("error", function(
|
|
829
|
-
console.error(
|
|
844
|
+
(l, a) => {
|
|
845
|
+
i.once("message", function(d) {
|
|
846
|
+
d.command === "worker-script-initialized" && l({ worker: i, phpPort: d.phpPort });
|
|
847
|
+
}), i.once("error", function(d) {
|
|
848
|
+
console.error(d);
|
|
830
849
|
const b = new Error(
|
|
831
|
-
`Worker failed to load worker. ${
|
|
850
|
+
`Worker failed to load worker. ${d.message ? `Original error: ${d.message}` : ""}`
|
|
832
851
|
);
|
|
833
|
-
|
|
852
|
+
a(b);
|
|
834
853
|
}), i.once("exit", n);
|
|
835
854
|
}
|
|
836
855
|
)
|
|
@@ -867,11 +886,11 @@ async function ze(e, r) {
|
|
|
867
886
|
`
|
|
868
887
|
});
|
|
869
888
|
const t = await e.readFileAsBuffer("/tmp/build.zip");
|
|
870
|
-
|
|
889
|
+
c.writeFileSync(r, t);
|
|
871
890
|
}
|
|
872
891
|
export {
|
|
873
|
-
|
|
892
|
+
F as L,
|
|
874
893
|
dt as p,
|
|
875
894
|
je as r
|
|
876
895
|
};
|
|
877
|
-
//# sourceMappingURL=run-cli-
|
|
896
|
+
//# sourceMappingURL=run-cli-C0WqHEVM.js.map
|