@wp-playground/cli 2.0.4 → 2.0.7
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/{mounts-B-Qdcyyt.js → mounts-ClzM-OKS.js} +9 -7
- package/mounts-ClzM-OKS.js.map +1 -0
- package/{mounts-D7bhhGq3.cjs → mounts-qNNxXLf_.cjs} +4 -3
- package/mounts-qNNxXLf_.cjs.map +1 -0
- package/package.json +15 -13
- package/{run-cli-B0BNDNay.js → run-cli-CNQwmbae.js} +126 -116
- package/run-cli-CNQwmbae.js.map +1 -0
- package/run-cli-M1t6BUJ6.cjs +27 -0
- package/run-cli-M1t6BUJ6.cjs.map +1 -0
- package/worker-thread-v1-BTJIbQLy.js.map +1 -1
- package/worker-thread-v1.cjs +1 -1
- package/worker-thread-v1.js +1 -1
- package/mounts-B-Qdcyyt.js.map +0 -1
- package/mounts-D7bhhGq3.cjs.map +0 -1
- package/run-cli-B0BNDNay.js.map +0 -1
- package/run-cli-BSpDmClB.cjs +0 -27
- package/run-cli-BSpDmClB.cjs.map +0 -1
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
import { logger as p, errorLogPath as
|
|
2
|
-
import { consumeAPI as L, SupportedPHPVersions as
|
|
3
|
-
import { resolveRemoteBlueprint as
|
|
4
|
-
import { zipDirectory as
|
|
5
|
-
import
|
|
6
|
-
import { Worker as
|
|
7
|
-
import { p as
|
|
8
|
-
import
|
|
9
|
-
import { FileLockManagerForNode as
|
|
10
|
-
import
|
|
11
|
-
import { jspi as
|
|
12
|
-
import
|
|
13
|
-
import
|
|
14
|
-
import { NodeJsFilesystem as
|
|
15
|
-
import { EmscriptenDownloadMonitor as
|
|
16
|
-
import { resolveWordPressRelease as
|
|
1
|
+
import { logger as p, errorLogPath as R } from "@php-wasm/logger";
|
|
2
|
+
import { consumeAPI as L, SupportedPHPVersions as q, printDebugDetails as j, PHPResponse as U, exposeAPI as D, exposeSyncAPI as O } from "@php-wasm/universal";
|
|
3
|
+
import { resolveRemoteBlueprint as Z, isBlueprintBundle as _, compileBlueprint as N, runBlueprintSteps as J } from "@wp-playground/blueprints";
|
|
4
|
+
import { zipDirectory as E, RecommendedPHPVersion as A, unzipFile as Y } from "@wp-playground/common";
|
|
5
|
+
import g from "fs";
|
|
6
|
+
import { Worker as Q, MessageChannel as X } from "worker_threads";
|
|
7
|
+
import { p as M, a as G, e as K } from "./mounts-ClzM-OKS.js";
|
|
8
|
+
import ee from "express";
|
|
9
|
+
import { FileLockManagerForNode as te } from "@php-wasm/node";
|
|
10
|
+
import re, { cpus as oe } from "os";
|
|
11
|
+
import { jspi as se } from "wasm-feature-detect";
|
|
12
|
+
import ie from "yargs";
|
|
13
|
+
import m, { basename as ne } from "path";
|
|
14
|
+
import { NodeJsFilesystem as ae, OverlayFilesystem as le, InMemoryFilesystem as pe, ZipFilesystem as de } from "@wp-playground/storage";
|
|
15
|
+
import { EmscriptenDownloadMonitor as ce, ProgressTracker as ue } from "@php-wasm/progress";
|
|
16
|
+
import { resolveWordPressRelease as he } from "@wp-playground/wordpress";
|
|
17
17
|
import k from "fs-extra";
|
|
18
|
-
import { startBridge as
|
|
19
|
-
async function
|
|
20
|
-
const r =
|
|
18
|
+
import { startBridge as fe } from "@php-wasm/xdebug-bridge";
|
|
19
|
+
async function me(t) {
|
|
20
|
+
const r = ee(), e = await new Promise((i, n) => {
|
|
21
21
|
const l = r.listen(t.port, () => {
|
|
22
22
|
const a = l.address();
|
|
23
23
|
a === null || typeof a == "string" ? n(new Error("Server address is not available")) : i(l);
|
|
@@ -26,9 +26,9 @@ async function he(t) {
|
|
|
26
26
|
r.use("/", async (i, n) => {
|
|
27
27
|
const l = await t.handleRequest({
|
|
28
28
|
url: i.url,
|
|
29
|
-
headers:
|
|
29
|
+
headers: ge(i),
|
|
30
30
|
method: i.method,
|
|
31
|
-
body: await
|
|
31
|
+
body: await we(i)
|
|
32
32
|
});
|
|
33
33
|
n.statusCode = l.httpStatusCode;
|
|
34
34
|
for (const a in l.headers)
|
|
@@ -38,21 +38,21 @@ async function he(t) {
|
|
|
38
38
|
const s = e.address().port;
|
|
39
39
|
return await t.onBind(e, s);
|
|
40
40
|
}
|
|
41
|
-
const
|
|
41
|
+
const we = async (t) => await new Promise((r) => {
|
|
42
42
|
const e = [];
|
|
43
43
|
t.on("data", (o) => {
|
|
44
44
|
e.push(o);
|
|
45
45
|
}), t.on("end", () => {
|
|
46
46
|
r(new Uint8Array(Buffer.concat(e)));
|
|
47
47
|
});
|
|
48
|
-
}),
|
|
48
|
+
}), ge = (t) => {
|
|
49
49
|
const r = {};
|
|
50
50
|
if (t.rawHeaders && t.rawHeaders.length)
|
|
51
51
|
for (let e = 0; e < t.rawHeaders.length; e += 2)
|
|
52
52
|
r[t.rawHeaders[e].toLowerCase()] = t.rawHeaders[e + 1];
|
|
53
53
|
return r;
|
|
54
54
|
};
|
|
55
|
-
class
|
|
55
|
+
class ye {
|
|
56
56
|
constructor(r) {
|
|
57
57
|
this.workerLoads = [], this.addWorker(r);
|
|
58
58
|
}
|
|
@@ -74,33 +74,33 @@ class we {
|
|
|
74
74
|
});
|
|
75
75
|
}
|
|
76
76
|
}
|
|
77
|
-
function
|
|
77
|
+
function be(t) {
|
|
78
78
|
return /^latest$|^trunk$|^nightly$|^(?:(\d+)\.(\d+)(?:\.(\d+))?)((?:-beta(?:\d+)?)|(?:-RC(?:\d+)?))?$/.test(t);
|
|
79
79
|
}
|
|
80
|
-
async function
|
|
80
|
+
async function Pe({
|
|
81
81
|
sourceString: t,
|
|
82
82
|
blueprintMayReadAdjacentFiles: r
|
|
83
83
|
}) {
|
|
84
84
|
if (!t)
|
|
85
85
|
return;
|
|
86
86
|
if (t.startsWith("http://") || t.startsWith("https://"))
|
|
87
|
-
return await
|
|
88
|
-
let e =
|
|
89
|
-
if (!
|
|
87
|
+
return await Z(t);
|
|
88
|
+
let e = m.resolve(process.cwd(), t);
|
|
89
|
+
if (!g.existsSync(e))
|
|
90
90
|
throw new Error(`Blueprint file does not exist: ${e}`);
|
|
91
|
-
const o =
|
|
92
|
-
if (o.isDirectory() && (e =
|
|
91
|
+
const o = g.statSync(e);
|
|
92
|
+
if (o.isDirectory() && (e = m.join(e, "blueprint.json")), !o.isFile() && o.isSymbolicLink())
|
|
93
93
|
throw new Error(
|
|
94
94
|
`Blueprint path is neither a file nor a directory: ${e}`
|
|
95
95
|
);
|
|
96
|
-
const s =
|
|
96
|
+
const s = m.extname(e);
|
|
97
97
|
switch (s) {
|
|
98
98
|
case ".zip":
|
|
99
|
-
return
|
|
100
|
-
|
|
99
|
+
return de.fromArrayBuffer(
|
|
100
|
+
g.readFileSync(e).buffer
|
|
101
101
|
);
|
|
102
102
|
case ".json": {
|
|
103
|
-
const i =
|
|
103
|
+
const i = g.readFileSync(e, "utf-8");
|
|
104
104
|
try {
|
|
105
105
|
JSON.parse(i);
|
|
106
106
|
} catch {
|
|
@@ -108,9 +108,9 @@ async function ye({
|
|
|
108
108
|
`Blueprint file at ${e} is not a valid JSON file`
|
|
109
109
|
);
|
|
110
110
|
}
|
|
111
|
-
const n =
|
|
112
|
-
return new
|
|
113
|
-
new
|
|
111
|
+
const n = m.dirname(e), l = new ae(n);
|
|
112
|
+
return new le([
|
|
113
|
+
new pe({
|
|
114
114
|
"blueprint.json": i
|
|
115
115
|
}),
|
|
116
116
|
/**
|
|
@@ -136,13 +136,18 @@ You can allow this Blueprint to read files from the same parent directory by exp
|
|
|
136
136
|
);
|
|
137
137
|
}
|
|
138
138
|
}
|
|
139
|
-
const
|
|
140
|
-
class
|
|
139
|
+
const I = "" + new URL("worker-thread-v2-Pfv6UYF4.js", import.meta.url).href;
|
|
140
|
+
class ke {
|
|
141
141
|
constructor(r, e) {
|
|
142
142
|
this.lastProgressMessage = "", this.args = r, this.siteUrl = e.siteUrl, this.processIdSpaceLength = e.processIdSpaceLength, this.phpVersion = r.php;
|
|
143
143
|
}
|
|
144
144
|
getWorkerUrl() {
|
|
145
|
-
return
|
|
145
|
+
return process.env.VITEST && I.startsWith("/src/") ? m.join(
|
|
146
|
+
import.meta.dirname,
|
|
147
|
+
"..",
|
|
148
|
+
"..",
|
|
149
|
+
I
|
|
150
|
+
) : I;
|
|
146
151
|
}
|
|
147
152
|
async bootPrimaryWorker(r, e) {
|
|
148
153
|
const o = L(r);
|
|
@@ -182,19 +187,19 @@ class Pe {
|
|
|
182
187
|
`));
|
|
183
188
|
}
|
|
184
189
|
}
|
|
185
|
-
const
|
|
186
|
-
async function
|
|
187
|
-
return await
|
|
190
|
+
const B = m.join(re.homedir(), ".wordpress-playground");
|
|
191
|
+
async function ve(t) {
|
|
192
|
+
return await C(
|
|
188
193
|
"https://github.com/WordPress/sqlite-database-integration/archive/refs/heads/develop.zip",
|
|
189
194
|
"sqlite.zip",
|
|
190
195
|
t
|
|
191
196
|
);
|
|
192
197
|
}
|
|
193
|
-
async function
|
|
194
|
-
const o =
|
|
195
|
-
return k.existsSync(o) || (k.ensureDirSync(
|
|
198
|
+
async function C(t, r, e) {
|
|
199
|
+
const o = m.join(B, r);
|
|
200
|
+
return k.existsSync(o) || (k.ensureDirSync(B), await We(t, o, e)), T(o);
|
|
196
201
|
}
|
|
197
|
-
async function
|
|
202
|
+
async function We(t, r, e) {
|
|
198
203
|
const s = (await e.monitorFetch(fetch(t))).body.getReader(), i = `${r}.partial`, n = k.createWriteStream(i);
|
|
199
204
|
for (; ; ) {
|
|
200
205
|
const { done: l, value: a } = await s.read();
|
|
@@ -209,16 +214,21 @@ async function ve(t, r, e) {
|
|
|
209
214
|
});
|
|
210
215
|
});
|
|
211
216
|
}
|
|
212
|
-
function
|
|
213
|
-
return new File([k.readFileSync(t)],
|
|
217
|
+
function T(t, r) {
|
|
218
|
+
return new File([k.readFileSync(t)], ne(t));
|
|
214
219
|
}
|
|
215
|
-
const
|
|
220
|
+
const F = "" + new URL("worker-thread-v1-BTJIbQLy.js", import.meta.url).href;
|
|
216
221
|
class xe {
|
|
217
222
|
constructor(r, e) {
|
|
218
223
|
this.lastProgressMessage = "", this.args = r, this.siteUrl = e.siteUrl, this.processIdSpaceLength = e.processIdSpaceLength;
|
|
219
224
|
}
|
|
220
225
|
getWorkerUrl() {
|
|
221
|
-
return
|
|
226
|
+
return process.env.VITEST && F.startsWith("/src/") ? m.join(
|
|
227
|
+
import.meta.dirname,
|
|
228
|
+
"..",
|
|
229
|
+
"..",
|
|
230
|
+
F
|
|
231
|
+
) : F;
|
|
222
232
|
}
|
|
223
233
|
async bootPrimaryWorker(r, e) {
|
|
224
234
|
const o = await this.compileInputBlueprint(
|
|
@@ -226,51 +236,51 @@ class xe {
|
|
|
226
236
|
);
|
|
227
237
|
this.phpVersion = o.versions.php;
|
|
228
238
|
let s;
|
|
229
|
-
const i = new
|
|
239
|
+
const i = new ce();
|
|
230
240
|
if (!this.args.skipWordPressSetup) {
|
|
231
241
|
let v = !1;
|
|
232
242
|
i.addEventListener("progress", (h) => {
|
|
233
243
|
if (v)
|
|
234
244
|
return;
|
|
235
|
-
const { loaded:
|
|
236
|
-
Math.min(100, 100 *
|
|
245
|
+
const { loaded: w, total: W } = h.detail, f = Math.floor(
|
|
246
|
+
Math.min(100, 100 * w / W)
|
|
237
247
|
);
|
|
238
248
|
v = f === 100, this.args.quiet || this.writeProgressUpdate(
|
|
239
249
|
process.stdout,
|
|
240
250
|
`Downloading WordPress ${f}%...`,
|
|
241
251
|
v
|
|
242
252
|
);
|
|
243
|
-
}), s = await
|
|
253
|
+
}), s = await he(this.args.wp), p.log(
|
|
244
254
|
`Resolved WordPress release URL: ${s?.releaseUrl}`
|
|
245
255
|
);
|
|
246
256
|
}
|
|
247
|
-
const n = s &&
|
|
248
|
-
|
|
257
|
+
const n = s && m.join(
|
|
258
|
+
B,
|
|
249
259
|
`prebuilt-wp-content-for-wp-${s.version}.zip`
|
|
250
|
-
), l = s ?
|
|
260
|
+
), l = s ? g.existsSync(n) ? T(n) : await C(
|
|
251
261
|
s.releaseUrl,
|
|
252
262
|
`${s.version}.zip`,
|
|
253
263
|
i
|
|
254
264
|
) : void 0;
|
|
255
265
|
p.log("Fetching SQLite integration plugin...");
|
|
256
|
-
const a = this.args.skipSqliteSetup ? void 0 : await
|
|
266
|
+
const a = this.args.skipSqliteSetup ? void 0 : await ve(i), c = this.args.followSymlinks === !0, d = this.args.experimentalTrace === !0, y = this.args["mount-before-install"] || [], P = this.args.mount || [], u = L(r);
|
|
257
267
|
return await u.isConnected(), p.log("Booting WordPress..."), await u.useFileLockManager(e), await u.bootAsPrimaryWorker({
|
|
258
268
|
phpVersion: this.phpVersion,
|
|
259
269
|
wpVersion: o.versions.wp,
|
|
260
270
|
absoluteUrl: this.siteUrl,
|
|
261
|
-
mountsBeforeWpInstall:
|
|
271
|
+
mountsBeforeWpInstall: y,
|
|
262
272
|
mountsAfterWpInstall: P,
|
|
263
273
|
wordPressZip: l && await l.arrayBuffer(),
|
|
264
|
-
sqliteIntegrationPluginZip: await a
|
|
274
|
+
sqliteIntegrationPluginZip: await a?.arrayBuffer(),
|
|
265
275
|
firstProcessId: 0,
|
|
266
276
|
processIdSpaceLength: this.processIdSpaceLength,
|
|
267
277
|
followSymlinks: c,
|
|
268
278
|
trace: d,
|
|
269
279
|
internalCookieStore: this.args.internalCookieStore,
|
|
270
280
|
withXdebug: this.args.xdebug
|
|
271
|
-
}), s && !this.args["mount-before-install"] && !
|
|
281
|
+
}), s && !this.args["mount-before-install"] && !g.existsSync(n) && (p.log("Caching preinstalled WordPress for the next boot..."), g.writeFileSync(
|
|
272
282
|
n,
|
|
273
|
-
await
|
|
283
|
+
await E(u, "/wordpress")
|
|
274
284
|
), p.log("Cached!")), u;
|
|
275
285
|
}
|
|
276
286
|
async bootSecondaryWorker({
|
|
@@ -304,15 +314,15 @@ class xe {
|
|
|
304
314
|
}), await s.isReady(), s;
|
|
305
315
|
}
|
|
306
316
|
async compileInputBlueprint(r) {
|
|
307
|
-
const e = this.args, o = e.blueprint, s =
|
|
317
|
+
const e = this.args, o = e.blueprint, s = _(o) ? o : {
|
|
308
318
|
login: e.login,
|
|
309
319
|
...o || {},
|
|
310
320
|
preferredVersions: {
|
|
311
|
-
php: e.php ?? o?.preferredVersions?.php ??
|
|
321
|
+
php: e.php ?? o?.preferredVersions?.php ?? A,
|
|
312
322
|
wp: e.wp ?? o?.preferredVersions?.wp ?? "latest",
|
|
313
323
|
...o?.preferredVersions || {}
|
|
314
324
|
}
|
|
315
|
-
}, i = new
|
|
325
|
+
}, i = new ue();
|
|
316
326
|
let n = "", l = !1;
|
|
317
327
|
return i.addEventListener("progress", (a) => {
|
|
318
328
|
if (l)
|
|
@@ -326,7 +336,7 @@ class xe {
|
|
|
326
336
|
d,
|
|
327
337
|
l
|
|
328
338
|
);
|
|
329
|
-
}), await
|
|
339
|
+
}), await N(s, {
|
|
330
340
|
progress: i,
|
|
331
341
|
additionalSteps: r
|
|
332
342
|
});
|
|
@@ -339,7 +349,7 @@ class xe {
|
|
|
339
349
|
}
|
|
340
350
|
async function _e() {
|
|
341
351
|
try {
|
|
342
|
-
const t =
|
|
352
|
+
const t = ie(process.argv.slice(2)).usage("Usage: wp-playground <command> [options]").positional("command", {
|
|
343
353
|
describe: "Command to run",
|
|
344
354
|
choices: ["server", "run-blueprint", "build-snapshot"],
|
|
345
355
|
demandOption: !0
|
|
@@ -354,8 +364,8 @@ async function _e() {
|
|
|
354
364
|
}).option("php", {
|
|
355
365
|
describe: "PHP version to use.",
|
|
356
366
|
type: "string",
|
|
357
|
-
default:
|
|
358
|
-
choices:
|
|
367
|
+
default: A,
|
|
368
|
+
choices: q
|
|
359
369
|
}).option("wp", {
|
|
360
370
|
describe: "WordPress version to use.",
|
|
361
371
|
type: "string",
|
|
@@ -364,12 +374,12 @@ async function _e() {
|
|
|
364
374
|
describe: "Mount a directory to the PHP runtime (can be used multiple times). Format: /host/path:/vfs/path",
|
|
365
375
|
type: "array",
|
|
366
376
|
string: !0,
|
|
367
|
-
coerce:
|
|
377
|
+
coerce: M
|
|
368
378
|
}).option("mount-before-install", {
|
|
369
379
|
describe: "Mount a directory to the PHP runtime before WordPress installation (can be used multiple times). Format: /host/path:/vfs/path",
|
|
370
380
|
type: "array",
|
|
371
381
|
string: !0,
|
|
372
|
-
coerce:
|
|
382
|
+
coerce: M
|
|
373
383
|
}).option("mount-dir", {
|
|
374
384
|
describe: 'Mount a directory to the PHP runtime (can be used multiple times). Format: "/host/path" "/vfs/path"',
|
|
375
385
|
type: "array",
|
|
@@ -381,7 +391,7 @@ async function _e() {
|
|
|
381
391
|
type: "string",
|
|
382
392
|
nargs: 2,
|
|
383
393
|
array: !0,
|
|
384
|
-
coerce:
|
|
394
|
+
coerce: G
|
|
385
395
|
}).option("login", {
|
|
386
396
|
describe: "Should log the user in",
|
|
387
397
|
type: "boolean",
|
|
@@ -439,7 +449,7 @@ Warning: Following symlinks will expose files outside mounted directories to Pla
|
|
|
439
449
|
}).option("experimental-multi-worker", {
|
|
440
450
|
describe: "Enable experimental multi-worker support which requires JSPI and 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.",
|
|
441
451
|
type: "number",
|
|
442
|
-
coerce: (s) => s ??
|
|
452
|
+
coerce: (s) => s ?? oe().length - 1
|
|
443
453
|
}).option("experimental-blueprints-v2-runner", {
|
|
444
454
|
describe: "Use the experimental Blueprint V2 runner.",
|
|
445
455
|
type: "boolean",
|
|
@@ -447,7 +457,7 @@ Warning: Following symlinks will expose files outside mounted directories to Pla
|
|
|
447
457
|
// Remove the "hidden" flag once Blueprint V2 is fully supported
|
|
448
458
|
hidden: !0
|
|
449
459
|
}).showHelpOnFail(!1).strictOptions().check(async (s) => {
|
|
450
|
-
if (s.wp !== void 0 && !
|
|
460
|
+
if (s.wp !== void 0 && !be(s.wp))
|
|
451
461
|
try {
|
|
452
462
|
new URL(s.wp);
|
|
453
463
|
} catch {
|
|
@@ -487,7 +497,7 @@ Warning: Following symlinks will expose files outside mounted directories to Pla
|
|
|
487
497
|
if (!(t instanceof Error))
|
|
488
498
|
throw t;
|
|
489
499
|
if (process.argv.includes("--debug"))
|
|
490
|
-
|
|
500
|
+
j(t);
|
|
491
501
|
else {
|
|
492
502
|
const e = [];
|
|
493
503
|
let o = t;
|
|
@@ -504,43 +514,43 @@ Warning: Following symlinks will expose files outside mounted directories to Pla
|
|
|
504
514
|
async function Se(t) {
|
|
505
515
|
let r, e;
|
|
506
516
|
const o = [];
|
|
507
|
-
t.autoMount && (t =
|
|
517
|
+
t.autoMount && (t = K(t)), t.quiet && (p.handlers = []);
|
|
508
518
|
const s = await import("fs-ext").then((a) => a.flockSync).catch(() => {
|
|
509
519
|
p.warn(
|
|
510
520
|
"The fs-ext package is not installed. Internal file locking will not be integrated with host OS file locking."
|
|
511
521
|
);
|
|
512
|
-
}), i = new
|
|
522
|
+
}), i = new te(s);
|
|
513
523
|
let n = !1, l = !0;
|
|
514
|
-
return p.log("Starting a PHP server..."),
|
|
524
|
+
return p.log("Starting a PHP server..."), me({
|
|
515
525
|
port: t.port,
|
|
516
526
|
onBind: async (a, c) => {
|
|
517
|
-
const d = `http://127.0.0.1:${c}`,
|
|
518
|
-
Number.MAX_SAFE_INTEGER /
|
|
527
|
+
const d = `http://127.0.0.1:${c}`, y = t.experimentalMultiWorker ?? 1, P = Math.floor(
|
|
528
|
+
Number.MAX_SAFE_INTEGER / y
|
|
519
529
|
);
|
|
520
530
|
let u;
|
|
521
|
-
t["experimental-blueprints-v2-runner"] ? u = new
|
|
531
|
+
t["experimental-blueprints-v2-runner"] ? u = new ke(t, {
|
|
522
532
|
siteUrl: d,
|
|
523
533
|
processIdSpaceLength: P
|
|
524
534
|
}) : (u = new xe(t, {
|
|
525
535
|
siteUrl: d,
|
|
526
536
|
processIdSpaceLength: P
|
|
527
|
-
}), typeof t.blueprint == "string" && (t.blueprint = await
|
|
537
|
+
}), typeof t.blueprint == "string" && (t.blueprint = await Pe({
|
|
528
538
|
sourceString: t.blueprint,
|
|
529
539
|
blueprintMayReadAdjacentFiles: t["blueprint-may-read-adjacent-files"] === !0
|
|
530
540
|
})));
|
|
531
541
|
const v = Le(
|
|
532
542
|
u.getWorkerUrl(),
|
|
533
|
-
|
|
534
|
-
({ exitCode: h, isMain:
|
|
543
|
+
y,
|
|
544
|
+
({ exitCode: h, isMain: w, workerIndex: W }) => {
|
|
535
545
|
h !== 0 && (p.error(
|
|
536
546
|
`Worker ${W} exited with code ${h}
|
|
537
547
|
`
|
|
538
|
-
),
|
|
548
|
+
), w && t.exitOnPrimaryWorkerCrash && process.exit(1));
|
|
539
549
|
}
|
|
540
550
|
);
|
|
541
551
|
p.log(`Setting up WordPress ${t.wp}`);
|
|
542
552
|
try {
|
|
543
|
-
const [h, ...
|
|
553
|
+
const [h, ...w] = await v, W = await $(
|
|
544
554
|
i
|
|
545
555
|
);
|
|
546
556
|
if (e = await u.bootPrimaryWorker(
|
|
@@ -549,24 +559,24 @@ async function Se(t) {
|
|
|
549
559
|
), o.push({
|
|
550
560
|
playground: e,
|
|
551
561
|
worker: h.worker
|
|
552
|
-
}), await e.isReady(), n = !0, p.log("Booted!"), r = new
|
|
562
|
+
}), await e.isReady(), n = !0, p.log("Booted!"), r = new ye(e), !t["experimental-blueprints-v2-runner"]) {
|
|
553
563
|
const f = await u.compileInputBlueprint(
|
|
554
564
|
t["additional-blueprint-steps"] || []
|
|
555
565
|
);
|
|
556
|
-
f && (p.log("Running the Blueprint..."), await
|
|
566
|
+
f && (p.log("Running the Blueprint..."), await J(f, e), p.log("Finished running the blueprint"));
|
|
557
567
|
}
|
|
558
|
-
if (t.command === "build-snapshot" ? (await
|
|
568
|
+
if (t.command === "build-snapshot" ? (await Ie(e, t.outfile), p.log(`WordPress exported to ${t.outfile}`), process.exit(0)) : t.command === "run-blueprint" && (p.log("Blueprint executed"), process.exit(0)), t.experimentalMultiWorker && t.experimentalMultiWorker > 1) {
|
|
559
569
|
p.log("Preparing additional workers...");
|
|
560
|
-
const f = await
|
|
570
|
+
const f = await E(
|
|
561
571
|
e,
|
|
562
572
|
"/internal"
|
|
563
|
-
),
|
|
573
|
+
), b = P;
|
|
564
574
|
await Promise.all(
|
|
565
|
-
|
|
566
|
-
const
|
|
575
|
+
w.map(async (S, H) => {
|
|
576
|
+
const z = b + H * P, V = await $(i), x = await u.bootSecondaryWorker({
|
|
567
577
|
worker: S,
|
|
568
|
-
fileLockManagerPort:
|
|
569
|
-
firstProcessId:
|
|
578
|
+
fileLockManagerPort: V,
|
|
579
|
+
firstProcessId: z
|
|
570
580
|
});
|
|
571
581
|
o.push({
|
|
572
582
|
playground: x,
|
|
@@ -574,7 +584,7 @@ async function Se(t) {
|
|
|
574
584
|
}), await x.writeFile(
|
|
575
585
|
"/tmp/internal.zip",
|
|
576
586
|
f
|
|
577
|
-
), await
|
|
587
|
+
), await Y(
|
|
578
588
|
x,
|
|
579
589
|
"/tmp/internal.zip",
|
|
580
590
|
"/internal"
|
|
@@ -584,31 +594,31 @@ async function Se(t) {
|
|
|
584
594
|
})
|
|
585
595
|
), p.log("Ready!");
|
|
586
596
|
}
|
|
587
|
-
return p.log(`WordPress is running on ${d}`), t.experimentalDevtools && t.xdebug && (await
|
|
588
|
-
getPHPFile: async (
|
|
597
|
+
return p.log(`WordPress is running on ${d}`), t.experimentalDevtools && t.xdebug && (await fe({
|
|
598
|
+
getPHPFile: async (b) => await e.readFileAsText(b)
|
|
589
599
|
})).start(), {
|
|
590
600
|
playground: e,
|
|
591
601
|
server: a,
|
|
592
602
|
[Symbol.asyncDispose]: async function() {
|
|
593
603
|
await Promise.all(
|
|
594
604
|
o.map(
|
|
595
|
-
async ({ playground:
|
|
596
|
-
await
|
|
605
|
+
async ({ playground: b, worker: S }) => {
|
|
606
|
+
await b.dispose(), await S.terminate();
|
|
597
607
|
}
|
|
598
608
|
)
|
|
599
|
-
), await new Promise((
|
|
609
|
+
), await new Promise((b) => a.close(b));
|
|
600
610
|
}
|
|
601
611
|
};
|
|
602
612
|
} catch (h) {
|
|
603
613
|
if (!t.debug)
|
|
604
614
|
throw h;
|
|
605
|
-
let
|
|
606
|
-
throw await e
|
|
615
|
+
let w = "";
|
|
616
|
+
throw await e?.fileExists(R) && (w = await e.readFileAsText(R)), new Error(w, { cause: h });
|
|
607
617
|
}
|
|
608
618
|
},
|
|
609
619
|
async handleRequest(a) {
|
|
610
620
|
if (!n)
|
|
611
|
-
return
|
|
621
|
+
return U.forHttpCode(
|
|
612
622
|
502,
|
|
613
623
|
"WordPress is not ready yet"
|
|
614
624
|
);
|
|
@@ -623,7 +633,7 @@ async function Se(t) {
|
|
|
623
633
|
"playground_auto_login_already_happened"
|
|
624
634
|
) && (c["Set-Cookie"] = [
|
|
625
635
|
"playground_auto_login_already_happened=1; Max-Age=0; Expires=Thu, 01 Jan 1970 00:00:00 GMT; Path=/"
|
|
626
|
-
]), new
|
|
636
|
+
]), new U(302, c, new Uint8Array());
|
|
627
637
|
}
|
|
628
638
|
return await r.handleRequest(a);
|
|
629
639
|
}
|
|
@@ -632,7 +642,7 @@ async function Se(t) {
|
|
|
632
642
|
function Le(t, r, e) {
|
|
633
643
|
const o = new URL(t, import.meta.url), s = [];
|
|
634
644
|
for (let i = 0; i < r; i++) {
|
|
635
|
-
const n = new
|
|
645
|
+
const n = new Q(o), l = (a) => {
|
|
636
646
|
e({
|
|
637
647
|
exitCode: a,
|
|
638
648
|
isMain: i === 0,
|
|
@@ -646,10 +656,10 @@ function Le(t, r, e) {
|
|
|
646
656
|
d.command === "worker-script-initialized" && a({ worker: n, phpPort: d.phpPort });
|
|
647
657
|
}), n.once("error", function(d) {
|
|
648
658
|
console.error(d);
|
|
649
|
-
const
|
|
659
|
+
const y = new Error(
|
|
650
660
|
`Worker failed to load at ${o}. ${d.message ? `Original error: ${d.message}` : ""}`
|
|
651
661
|
);
|
|
652
|
-
|
|
662
|
+
y.filename = o, c(y);
|
|
653
663
|
}), n.once("exit", l);
|
|
654
664
|
}
|
|
655
665
|
)
|
|
@@ -657,11 +667,11 @@ function Le(t, r, e) {
|
|
|
657
667
|
}
|
|
658
668
|
return Promise.all(s);
|
|
659
669
|
}
|
|
660
|
-
async function
|
|
661
|
-
const { port1: r, port2: e } = new
|
|
662
|
-
return await
|
|
670
|
+
async function $(t) {
|
|
671
|
+
const { port1: r, port2: e } = new X();
|
|
672
|
+
return await se() ? D(t, null, r) : await O(t, r), e;
|
|
663
673
|
}
|
|
664
|
-
async function
|
|
674
|
+
async function Ie(t, r) {
|
|
665
675
|
await t.run({
|
|
666
676
|
code: `<?php
|
|
667
677
|
$zip = new ZipArchive();
|
|
@@ -683,10 +693,10 @@ async function Fe(t, r) {
|
|
|
683
693
|
`
|
|
684
694
|
});
|
|
685
695
|
const e = await t.readFileAsBuffer("/tmp/build.zip");
|
|
686
|
-
|
|
696
|
+
g.writeFileSync(r, e);
|
|
687
697
|
}
|
|
688
698
|
export {
|
|
689
699
|
_e as p,
|
|
690
700
|
Se as r
|
|
691
701
|
};
|
|
692
|
-
//# sourceMappingURL=run-cli-
|
|
702
|
+
//# sourceMappingURL=run-cli-CNQwmbae.js.map
|