@wp-playground/cli 3.0.44 → 3.0.46
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/worker-thread-v1.d.ts +4 -0
- package/blueprints-v2/worker-thread-v2.d.ts +3 -1
- package/cli-output.d.ts +2 -0
- package/cli.cjs +1 -1
- package/cli.js +1 -1
- package/index.cjs +1 -1
- package/index.js +1 -1
- package/package.json +14 -14
- package/{run-cli-DOpShCrT.js → run-cli-BK0MGgcU.js} +230 -210
- package/run-cli-BK0MGgcU.js.map +1 -0
- package/{run-cli-le2xCSBZ.cjs → run-cli-BUDz-Yr3.cjs} +11 -11
- package/run-cli-BUDz-Yr3.cjs.map +1 -0
- package/run-cli.d.ts +2 -0
- package/sqlite-database-integration-develop.zip +0 -0
- package/worker-thread-v1.cjs +2 -2
- package/worker-thread-v1.cjs.map +1 -1
- package/worker-thread-v1.js +11 -9
- package/worker-thread-v1.js.map +1 -1
- package/worker-thread-v2.cjs +6 -6
- package/worker-thread-v2.cjs.map +1 -1
- package/worker-thread-v2.js +89 -85
- package/worker-thread-v2.js.map +1 -1
- package/run-cli-DOpShCrT.js.map +0 -1
- package/run-cli-le2xCSBZ.cjs.map +0 -1
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { logger as y, LogSeverity as j, errorLogPath as
|
|
2
|
-
import { PHPResponse as z, consumeAPI as U, SupportedPHPVersions as
|
|
3
|
-
import { resolveRemoteBlueprint as
|
|
4
|
-
import { zipDirectory as
|
|
5
|
-
import c, { existsSync as
|
|
6
|
-
import { MessageChannel as
|
|
1
|
+
import { logger as y, LogSeverity as j, errorLogPath as re } from "@php-wasm/logger";
|
|
2
|
+
import { PHPResponse as z, consumeAPI as U, SupportedPHPVersions as oe, printDebugDetails as ve, exposeAPI as Pe, exposeSyncAPI as Se } from "@php-wasm/universal";
|
|
3
|
+
import { resolveRemoteBlueprint as xe, resolveRuntimeConfiguration as se, compileBlueprintV1 as ke, isBlueprintBundle as Ie, runBlueprintV1Steps as $e } from "@wp-playground/blueprints";
|
|
4
|
+
import { zipDirectory as Ee, RecommendedPHPVersion as F } from "@wp-playground/common";
|
|
5
|
+
import c, { existsSync as Z, rmdirSync as Te, mkdirSync as G, readdirSync as Be } from "fs";
|
|
6
|
+
import { MessageChannel as Me, Worker as ie } from "worker_threads";
|
|
7
7
|
import { createNodeFsMountHandler as Ce, FileLockManagerForNode as Le } from "@php-wasm/node";
|
|
8
|
-
import p, { basename as A, join as
|
|
8
|
+
import p, { basename as A, join as ce } from "path";
|
|
9
9
|
import We from "express";
|
|
10
|
-
import N, { cpus as
|
|
11
|
-
import { jspi as
|
|
10
|
+
import N, { cpus as De } from "os";
|
|
11
|
+
import { jspi as Q } from "wasm-feature-detect";
|
|
12
12
|
import Re from "yargs";
|
|
13
13
|
import { NodeJsFilesystem as Ae, OverlayFilesystem as Ue, InMemoryFilesystem as Fe, ZipFilesystem as Oe } from "@wp-playground/storage";
|
|
14
14
|
import { EmscriptenDownloadMonitor as Ne, ProgressTracker as _e } from "@php-wasm/progress";
|
|
@@ -29,10 +29,10 @@ function q(e) {
|
|
|
29
29
|
Expected format: /host/path:/vfs/path.
|
|
30
30
|
If your path contains a colon, e.g. C:\\myplugin, use the --mount-dir option instead.
|
|
31
31
|
Example: --mount-dir C:\\my-plugin /wordpress/wp-content/plugins/my-plugin`);
|
|
32
|
-
const [o,
|
|
33
|
-
if (!
|
|
32
|
+
const [o, i] = s;
|
|
33
|
+
if (!Z(o))
|
|
34
34
|
throw new Error(`Host path does not exist: ${o}`);
|
|
35
|
-
t.push({ hostPath: o, vfsPath:
|
|
35
|
+
t.push({ hostPath: o, vfsPath: i });
|
|
36
36
|
}
|
|
37
37
|
return t;
|
|
38
38
|
}
|
|
@@ -42,7 +42,7 @@ function ne(e) {
|
|
|
42
42
|
const t = [];
|
|
43
43
|
for (let r = 0; r < e.length; r += 2) {
|
|
44
44
|
const s = e[r], o = e[r + 1];
|
|
45
|
-
if (!
|
|
45
|
+
if (!Z(s))
|
|
46
46
|
throw new Error(`Host path does not exist: ${s}`);
|
|
47
47
|
t.push({
|
|
48
48
|
hostPath: p.resolve(process.cwd(), s),
|
|
@@ -58,7 +58,7 @@ async function rr(e, t) {
|
|
|
58
58
|
Ce(r.hostPath)
|
|
59
59
|
);
|
|
60
60
|
}
|
|
61
|
-
const
|
|
61
|
+
const ae = {
|
|
62
62
|
step: "runPHP",
|
|
63
63
|
code: {
|
|
64
64
|
filename: "activate-theme.php",
|
|
@@ -77,7 +77,7 @@ const ie = {
|
|
|
77
77
|
`
|
|
78
78
|
}
|
|
79
79
|
};
|
|
80
|
-
function
|
|
80
|
+
function pe(e) {
|
|
81
81
|
const t = e.autoMount, r = [...e.mount || []], s = [...e["mount-before-install"] || []], o = {
|
|
82
82
|
...e,
|
|
83
83
|
mount: r,
|
|
@@ -87,44 +87,44 @@ function ce(e) {
|
|
|
87
87
|
]
|
|
88
88
|
};
|
|
89
89
|
if (rt(t)) {
|
|
90
|
-
const
|
|
90
|
+
const n = `/wordpress/wp-content/plugins/${A(t)}`;
|
|
91
91
|
r.push({
|
|
92
92
|
hostPath: t,
|
|
93
|
-
vfsPath:
|
|
93
|
+
vfsPath: n,
|
|
94
94
|
autoMounted: !0
|
|
95
95
|
}), o["additional-blueprint-steps"].push({
|
|
96
96
|
step: "activatePlugin",
|
|
97
97
|
pluginPath: `/wordpress/wp-content/plugins/${A(t)}`
|
|
98
98
|
});
|
|
99
99
|
} else if (tt(t)) {
|
|
100
|
-
const
|
|
100
|
+
const i = A(t), n = `/wordpress/wp-content/themes/${i}`;
|
|
101
101
|
r.push({
|
|
102
102
|
hostPath: t,
|
|
103
|
-
vfsPath:
|
|
103
|
+
vfsPath: n,
|
|
104
104
|
autoMounted: !0
|
|
105
105
|
}), o["additional-blueprint-steps"].push(
|
|
106
106
|
e["experimental-blueprints-v2-runner"] ? {
|
|
107
107
|
step: "activateTheme",
|
|
108
|
-
themeDirectoryName:
|
|
108
|
+
themeDirectoryName: i
|
|
109
109
|
} : {
|
|
110
110
|
step: "activateTheme",
|
|
111
|
-
themeFolderName:
|
|
111
|
+
themeFolderName: i
|
|
112
112
|
}
|
|
113
113
|
);
|
|
114
114
|
} else if (et(t)) {
|
|
115
|
-
const
|
|
116
|
-
for (const
|
|
117
|
-
|
|
118
|
-
hostPath: `${t}/${
|
|
119
|
-
vfsPath: `/wordpress/wp-content/${
|
|
115
|
+
const i = c.readdirSync(t);
|
|
116
|
+
for (const n of i)
|
|
117
|
+
n !== "index.php" && r.push({
|
|
118
|
+
hostPath: `${t}/${n}`,
|
|
119
|
+
vfsPath: `/wordpress/wp-content/${n}`,
|
|
120
120
|
autoMounted: !0
|
|
121
121
|
});
|
|
122
|
-
o["additional-blueprint-steps"].push(
|
|
122
|
+
o["additional-blueprint-steps"].push(ae);
|
|
123
123
|
} else Ke(t) && (s.push({
|
|
124
124
|
hostPath: t,
|
|
125
125
|
vfsPath: "/wordpress",
|
|
126
126
|
autoMounted: !0
|
|
127
|
-
}), o.mode = "apply-to-existing-site", o["additional-blueprint-steps"].push(
|
|
127
|
+
}), o.mode = "apply-to-existing-site", o["additional-blueprint-steps"].push(ae), o.wordpressInstallMode || (o.wordpressInstallMode = "install-from-existing-files-if-needed"));
|
|
128
128
|
return o;
|
|
129
129
|
}
|
|
130
130
|
function Ke(e) {
|
|
@@ -138,14 +138,14 @@ function et(e) {
|
|
|
138
138
|
function tt(e) {
|
|
139
139
|
if (!c.readdirSync(e).includes("style.css"))
|
|
140
140
|
return !1;
|
|
141
|
-
const r = c.readFileSync(
|
|
141
|
+
const r = c.readFileSync(ce(e, "style.css"), "utf8");
|
|
142
142
|
return !!/^(?:[ \t]*<\?php)?[ \t/*#@]*Theme Name:(.*)$/im.exec(r);
|
|
143
143
|
}
|
|
144
144
|
function rt(e) {
|
|
145
145
|
const t = c.readdirSync(e), r = /^(?:[ \t]*<\?php)?[ \t/*#@]*Plugin Name:(.*)$/im;
|
|
146
146
|
return !!t.filter((o) => o.endsWith(".php")).find((o) => {
|
|
147
|
-
const
|
|
148
|
-
return !!r.exec(
|
|
147
|
+
const i = c.readFileSync(ce(e, o), "utf8");
|
|
148
|
+
return !!r.exec(i);
|
|
149
149
|
});
|
|
150
150
|
}
|
|
151
151
|
function ot(e) {
|
|
@@ -183,7 +183,7 @@ function st(e) {
|
|
|
183
183
|
}
|
|
184
184
|
return t;
|
|
185
185
|
}
|
|
186
|
-
function
|
|
186
|
+
function it(e) {
|
|
187
187
|
if (e.length % 2 !== 0)
|
|
188
188
|
throw new Error(
|
|
189
189
|
"Invalid number constant definition format. Expected pairs of NAME value"
|
|
@@ -193,57 +193,57 @@ function nt(e) {
|
|
|
193
193
|
const s = e[r], o = e[r + 1].trim();
|
|
194
194
|
if (!s || !s.trim())
|
|
195
195
|
throw new Error("Constant name cannot be empty");
|
|
196
|
-
const
|
|
197
|
-
if (isNaN(
|
|
196
|
+
const i = Number(o);
|
|
197
|
+
if (isNaN(i))
|
|
198
198
|
throw new Error(
|
|
199
199
|
`Invalid number value for constant "${s}": "${o}". Must be a valid number.`
|
|
200
200
|
);
|
|
201
|
-
t[s.trim()] =
|
|
201
|
+
t[s.trim()] = i;
|
|
202
202
|
}
|
|
203
203
|
return t;
|
|
204
204
|
}
|
|
205
|
-
function
|
|
206
|
-
const s = {}, o = /* @__PURE__ */ new Set(),
|
|
207
|
-
for (const u in
|
|
205
|
+
function nt(e = {}, t = {}, r = {}) {
|
|
206
|
+
const s = {}, o = /* @__PURE__ */ new Set(), i = (n, l) => {
|
|
207
|
+
for (const u in n) {
|
|
208
208
|
if (o.has(u))
|
|
209
209
|
throw new Error(
|
|
210
210
|
`Constant "${u}" is defined multiple times across different --define-${l} flags`
|
|
211
211
|
);
|
|
212
|
-
o.add(u), s[u] =
|
|
212
|
+
o.add(u), s[u] = n[u];
|
|
213
213
|
}
|
|
214
214
|
};
|
|
215
|
-
return
|
|
215
|
+
return i(e, "string"), i(t, "bool"), i(r, "number"), s;
|
|
216
216
|
}
|
|
217
217
|
function O(e) {
|
|
218
|
-
return
|
|
218
|
+
return nt(
|
|
219
219
|
e.define,
|
|
220
220
|
e["define-bool"],
|
|
221
221
|
e["define-number"]
|
|
222
222
|
);
|
|
223
223
|
}
|
|
224
224
|
async function at(e) {
|
|
225
|
-
const t = We(), r = await new Promise((
|
|
225
|
+
const t = We(), r = await new Promise((i, n) => {
|
|
226
226
|
const l = t.listen(e.port, () => {
|
|
227
227
|
const u = l.address();
|
|
228
|
-
u === null || typeof u == "string" ?
|
|
228
|
+
u === null || typeof u == "string" ? n(new Error("Server address is not available")) : i(l);
|
|
229
229
|
});
|
|
230
230
|
});
|
|
231
|
-
t.use("/", async (
|
|
231
|
+
t.use("/", async (i, n) => {
|
|
232
232
|
let l;
|
|
233
233
|
try {
|
|
234
234
|
l = await e.handleRequest({
|
|
235
|
-
url:
|
|
236
|
-
headers: ut(
|
|
237
|
-
method:
|
|
238
|
-
body: await lt(
|
|
235
|
+
url: i.url,
|
|
236
|
+
headers: ut(i),
|
|
237
|
+
method: i.method,
|
|
238
|
+
body: await lt(i)
|
|
239
239
|
});
|
|
240
240
|
} catch (u) {
|
|
241
241
|
y.error(u), l = z.forHttpCode(500);
|
|
242
242
|
}
|
|
243
|
-
|
|
243
|
+
n.statusCode = l.httpStatusCode;
|
|
244
244
|
for (const u in l.headers)
|
|
245
|
-
|
|
246
|
-
|
|
245
|
+
n.setHeader(u, l.headers[u]);
|
|
246
|
+
n.end(l.bytes);
|
|
247
247
|
});
|
|
248
248
|
const o = r.address().port;
|
|
249
249
|
return await e.onBind(r, o);
|
|
@@ -284,8 +284,8 @@ class dt {
|
|
|
284
284
|
async handleRequest(t) {
|
|
285
285
|
let r = this.workerLoads[0];
|
|
286
286
|
for (let o = 1; o < this.workerLoads.length; o++) {
|
|
287
|
-
const
|
|
288
|
-
|
|
287
|
+
const i = this.workerLoads[o];
|
|
288
|
+
i.activeRequests.size < r.activeRequests.size && (r = i);
|
|
289
289
|
}
|
|
290
290
|
const s = r.worker.request(t);
|
|
291
291
|
return r.activeRequests.add(s), s.url = t.url, s.finally(() => {
|
|
@@ -303,7 +303,7 @@ async function pt({
|
|
|
303
303
|
if (!e)
|
|
304
304
|
return;
|
|
305
305
|
if (e.startsWith("http://") || e.startsWith("https://"))
|
|
306
|
-
return await
|
|
306
|
+
return await xe(e);
|
|
307
307
|
let r = p.resolve(process.cwd(), e);
|
|
308
308
|
if (!c.existsSync(r))
|
|
309
309
|
throw new Error(`Blueprint file does not exist: ${r}`);
|
|
@@ -319,18 +319,18 @@ async function pt({
|
|
|
319
319
|
c.readFileSync(r).buffer
|
|
320
320
|
);
|
|
321
321
|
case ".json": {
|
|
322
|
-
const
|
|
322
|
+
const i = c.readFileSync(r, "utf-8");
|
|
323
323
|
try {
|
|
324
|
-
JSON.parse(
|
|
324
|
+
JSON.parse(i);
|
|
325
325
|
} catch {
|
|
326
326
|
throw new Error(
|
|
327
327
|
`Blueprint file at ${r} is not a valid JSON file`
|
|
328
328
|
);
|
|
329
329
|
}
|
|
330
|
-
const
|
|
330
|
+
const n = p.dirname(r), l = new Ae(n);
|
|
331
331
|
return new Ue([
|
|
332
332
|
new Fe({
|
|
333
|
-
"blueprint.json":
|
|
333
|
+
"blueprint.json": i
|
|
334
334
|
}),
|
|
335
335
|
/**
|
|
336
336
|
* Wrap the NodeJS filesystem to prevent access to local files
|
|
@@ -365,7 +365,7 @@ class mt {
|
|
|
365
365
|
async bootAndSetUpInitialPlayground(t, r, s) {
|
|
366
366
|
const o = U(t);
|
|
367
367
|
await o.useFileLockManager(r);
|
|
368
|
-
const
|
|
368
|
+
const i = {
|
|
369
369
|
...this.args,
|
|
370
370
|
phpVersion: this.phpVersion,
|
|
371
371
|
siteUrl: this.siteUrl,
|
|
@@ -374,6 +374,8 @@ class mt {
|
|
|
374
374
|
trace: this.args.verbosity === "debug",
|
|
375
375
|
blueprint: this.args.blueprint,
|
|
376
376
|
withIntl: this.args.intl,
|
|
377
|
+
withRedis: this.args.redis,
|
|
378
|
+
withMemcached: this.args.memcached,
|
|
377
379
|
// We do not enable Xdebug by default for the initial worker
|
|
378
380
|
// because we do not imagine users expect to hit breakpoints
|
|
379
381
|
// until Playground has fully booted.
|
|
@@ -385,7 +387,7 @@ class mt {
|
|
|
385
387
|
mountsAfterWpInstall: this.args.mount || [],
|
|
386
388
|
constants: O(this.args)
|
|
387
389
|
};
|
|
388
|
-
return await o.bootAndSetUpInitialWorker(
|
|
390
|
+
return await o.bootAndSetUpInitialWorker(i), o;
|
|
389
391
|
}
|
|
390
392
|
async bootPlayground({
|
|
391
393
|
worker: t,
|
|
@@ -393,9 +395,9 @@ class mt {
|
|
|
393
395
|
firstProcessId: s,
|
|
394
396
|
nativeInternalDirPath: o
|
|
395
397
|
}) {
|
|
396
|
-
const
|
|
397
|
-
await
|
|
398
|
-
const
|
|
398
|
+
const i = U(t.phpPort);
|
|
399
|
+
await i.useFileLockManager(r);
|
|
400
|
+
const n = {
|
|
399
401
|
...this.args,
|
|
400
402
|
phpVersion: this.phpVersion,
|
|
401
403
|
siteUrl: this.siteUrl,
|
|
@@ -403,43 +405,45 @@ class mt {
|
|
|
403
405
|
processIdSpaceLength: this.processIdSpaceLength,
|
|
404
406
|
trace: this.args.verbosity === "debug",
|
|
405
407
|
withIntl: this.args.intl,
|
|
408
|
+
withRedis: this.args.redis,
|
|
409
|
+
withMemcached: this.args.memcached,
|
|
406
410
|
withXdebug: !!this.args.xdebug,
|
|
407
411
|
nativeInternalDirPath: o,
|
|
408
412
|
mountsBeforeWpInstall: this.args["mount-before-install"] || [],
|
|
409
413
|
mountsAfterWpInstall: this.args.mount || [],
|
|
410
414
|
constants: O(this.args)
|
|
411
415
|
};
|
|
412
|
-
return await
|
|
416
|
+
return await i.bootWorker(n), i;
|
|
413
417
|
}
|
|
414
418
|
}
|
|
415
|
-
const
|
|
419
|
+
const X = p.join(N.homedir(), ".wordpress-playground");
|
|
416
420
|
async function ht(e) {
|
|
417
|
-
return await
|
|
421
|
+
return await me(
|
|
418
422
|
"https://github.com/WordPress/sqlite-database-integration/archive/refs/heads/develop.zip",
|
|
419
423
|
"sqlite.zip",
|
|
420
424
|
e
|
|
421
425
|
);
|
|
422
426
|
}
|
|
423
|
-
async function
|
|
424
|
-
const s = p.join(
|
|
425
|
-
return B.existsSync(s) || (B.ensureDirSync(
|
|
427
|
+
async function me(e, t, r) {
|
|
428
|
+
const s = p.join(X, t);
|
|
429
|
+
return B.existsSync(s) || (B.ensureDirSync(X), await ft(e, s, r)), he(s);
|
|
426
430
|
}
|
|
427
431
|
async function ft(e, t, r) {
|
|
428
|
-
const o = (await r.monitorFetch(fetch(e))).body.getReader(),
|
|
432
|
+
const o = (await r.monitorFetch(fetch(e))).body.getReader(), i = `${t}.partial`, n = B.createWriteStream(i);
|
|
429
433
|
for (; ; ) {
|
|
430
434
|
const { done: l, value: u } = await o.read();
|
|
431
|
-
if (u &&
|
|
435
|
+
if (u && n.write(u), l)
|
|
432
436
|
break;
|
|
433
437
|
}
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
B.renameSync(
|
|
437
|
-
}),
|
|
438
|
-
B.removeSync(
|
|
438
|
+
n.close(), n.closed || await new Promise((l, u) => {
|
|
439
|
+
n.on("finish", () => {
|
|
440
|
+
B.renameSync(i, t), l(null);
|
|
441
|
+
}), n.on("error", (v) => {
|
|
442
|
+
B.removeSync(i), u(v);
|
|
439
443
|
});
|
|
440
444
|
});
|
|
441
445
|
}
|
|
442
|
-
function
|
|
446
|
+
function he(e, t) {
|
|
443
447
|
return new File([B.readFileSync(e)], A(e));
|
|
444
448
|
}
|
|
445
449
|
class wt {
|
|
@@ -450,24 +454,24 @@ class wt {
|
|
|
450
454
|
return "v1";
|
|
451
455
|
}
|
|
452
456
|
async bootAndSetUpInitialPlayground(t, r, s) {
|
|
453
|
-
let o,
|
|
457
|
+
let o, i, n;
|
|
454
458
|
const l = new Ne();
|
|
455
459
|
if (this.args.wordpressInstallMode === "download-and-install") {
|
|
456
460
|
let k = !1;
|
|
457
461
|
l.addEventListener("progress", (I) => {
|
|
458
462
|
if (k)
|
|
459
463
|
return;
|
|
460
|
-
const { loaded:
|
|
461
|
-
Math.min(100, 100 *
|
|
464
|
+
const { loaded: C, total: J } = I.detail, L = Math.floor(
|
|
465
|
+
Math.min(100, 100 * C / J)
|
|
462
466
|
);
|
|
463
|
-
k =
|
|
467
|
+
k = L === 100, this.cliOutput.updateProgress(
|
|
464
468
|
"Downloading WordPress",
|
|
465
|
-
|
|
469
|
+
L
|
|
466
470
|
);
|
|
467
|
-
}), o = await He(this.args.wp),
|
|
468
|
-
|
|
471
|
+
}), o = await He(this.args.wp), n = p.join(
|
|
472
|
+
X,
|
|
469
473
|
`prebuilt-wp-content-for-wp-${o.version}.zip`
|
|
470
|
-
),
|
|
474
|
+
), i = c.existsSync(n) ? he(n) : await me(
|
|
471
475
|
o.releaseUrl,
|
|
472
476
|
`${o.version}.zip`,
|
|
473
477
|
l
|
|
@@ -479,7 +483,7 @@ class wt {
|
|
|
479
483
|
this.args.skipSqliteSetup ? (y.debug("Skipping SQLite integration plugin setup..."), u = void 0) : (this.cliOutput.updateProgress("Preparing SQLite database"), u = await ht(l));
|
|
480
484
|
const v = this.args.followSymlinks === !0, P = this.args.experimentalTrace === !0, w = this.args["mount-before-install"] || [], a = this.args.mount || [], g = U(t);
|
|
481
485
|
await g.isConnected(), this.cliOutput.updateProgress("Booting WordPress");
|
|
482
|
-
const h = await
|
|
486
|
+
const h = await se(
|
|
483
487
|
this.getEffectiveBlueprint()
|
|
484
488
|
);
|
|
485
489
|
return await g.useFileLockManager(r), await g.bootAndSetUpInitialWorker({
|
|
@@ -489,7 +493,7 @@ class wt {
|
|
|
489
493
|
mountsBeforeWpInstall: w,
|
|
490
494
|
mountsAfterWpInstall: a,
|
|
491
495
|
wordpressInstallMode: this.args.wordpressInstallMode || "download-and-install",
|
|
492
|
-
wordPressZip:
|
|
496
|
+
wordPressZip: i && await i.arrayBuffer(),
|
|
493
497
|
sqliteIntegrationPluginZip: await u?.arrayBuffer(),
|
|
494
498
|
firstProcessId: 0,
|
|
495
499
|
processIdSpaceLength: this.processIdSpaceLength,
|
|
@@ -497,6 +501,8 @@ class wt {
|
|
|
497
501
|
trace: P,
|
|
498
502
|
internalCookieStore: this.args.internalCookieStore,
|
|
499
503
|
withIntl: this.args.intl,
|
|
504
|
+
withRedis: this.args.redis,
|
|
505
|
+
withMemcached: this.args.memcached,
|
|
500
506
|
// We do not enable Xdebug by default for the initial worker
|
|
501
507
|
// because we do not imagine users expect to hit breakpoints
|
|
502
508
|
// until Playground has fully booted.
|
|
@@ -504,9 +510,9 @@ class wt {
|
|
|
504
510
|
withXdebug: !1,
|
|
505
511
|
nativeInternalDirPath: s,
|
|
506
512
|
constants: O(this.args)
|
|
507
|
-
}),
|
|
508
|
-
|
|
509
|
-
await
|
|
513
|
+
}), n && !this.args["mount-before-install"] && !c.existsSync(n) && (this.cliOutput.updateProgress("Caching WordPress for next boot"), c.writeFileSync(
|
|
514
|
+
n,
|
|
515
|
+
await Ee(g, "/wordpress")
|
|
510
516
|
)), g;
|
|
511
517
|
}
|
|
512
518
|
async bootPlayground({
|
|
@@ -515,15 +521,15 @@ class wt {
|
|
|
515
521
|
firstProcessId: s,
|
|
516
522
|
nativeInternalDirPath: o
|
|
517
523
|
}) {
|
|
518
|
-
const
|
|
524
|
+
const i = U(
|
|
519
525
|
t.phpPort
|
|
520
526
|
);
|
|
521
|
-
await
|
|
522
|
-
const
|
|
527
|
+
await i.isConnected();
|
|
528
|
+
const n = await se(
|
|
523
529
|
this.getEffectiveBlueprint()
|
|
524
530
|
);
|
|
525
|
-
return await
|
|
526
|
-
phpVersion:
|
|
531
|
+
return await i.useFileLockManager(r), await i.bootWorker({
|
|
532
|
+
phpVersion: n.phpVersion,
|
|
527
533
|
siteUrl: this.siteUrl,
|
|
528
534
|
mountsBeforeWpInstall: this.args["mount-before-install"] || [],
|
|
529
535
|
mountsAfterWpInstall: this.args.mount || [],
|
|
@@ -535,28 +541,30 @@ class wt {
|
|
|
535
541
|
// will have a separate cookie store.
|
|
536
542
|
internalCookieStore: this.args.internalCookieStore,
|
|
537
543
|
withIntl: this.args.intl,
|
|
544
|
+
withRedis: this.args.redis,
|
|
545
|
+
withMemcached: this.args.memcached,
|
|
538
546
|
withXdebug: !!this.args.xdebug,
|
|
539
547
|
nativeInternalDirPath: o,
|
|
540
548
|
constants: O(this.args)
|
|
541
|
-
}), await
|
|
549
|
+
}), await i.isReady(), i;
|
|
542
550
|
}
|
|
543
551
|
async compileInputBlueprint(t) {
|
|
544
552
|
const r = this.getEffectiveBlueprint(), s = new _e();
|
|
545
|
-
let o = "",
|
|
546
|
-
return s.addEventListener("progress", (
|
|
547
|
-
if (
|
|
553
|
+
let o = "", i = !1;
|
|
554
|
+
return s.addEventListener("progress", (n) => {
|
|
555
|
+
if (i)
|
|
548
556
|
return;
|
|
549
|
-
|
|
550
|
-
const l = Math.floor(
|
|
551
|
-
o =
|
|
552
|
-
}), await
|
|
557
|
+
i = n.detail.progress === 100;
|
|
558
|
+
const l = Math.floor(n.detail.progress);
|
|
559
|
+
o = n.detail.caption || o || "Running Blueprint", this.cliOutput.updateProgress(o.trim(), l);
|
|
560
|
+
}), await ke(r, {
|
|
553
561
|
progress: s,
|
|
554
562
|
additionalSteps: t
|
|
555
563
|
});
|
|
556
564
|
}
|
|
557
565
|
getEffectiveBlueprint() {
|
|
558
566
|
const t = this.args.blueprint;
|
|
559
|
-
return
|
|
567
|
+
return Ie(t) ? t : {
|
|
560
568
|
login: this.args.login,
|
|
561
569
|
...t || {},
|
|
562
570
|
preferredVersions: {
|
|
@@ -588,14 +596,14 @@ async function yt(e, t, r) {
|
|
|
588
596
|
t,
|
|
589
597
|
r
|
|
590
598
|
)).map(
|
|
591
|
-
(
|
|
592
|
-
c.rm(
|
|
599
|
+
(i) => new Promise((n) => {
|
|
600
|
+
c.rm(i, { recursive: !0 }, (l) => {
|
|
593
601
|
l ? y.warn(
|
|
594
|
-
`Failed to delete stale Playground temp dir: ${
|
|
602
|
+
`Failed to delete stale Playground temp dir: ${i}`,
|
|
595
603
|
l
|
|
596
604
|
) : y.info(
|
|
597
|
-
`Deleted stale Playground temp dir: ${
|
|
598
|
-
),
|
|
605
|
+
`Deleted stale Playground temp dir: ${i}`
|
|
606
|
+
), n();
|
|
599
607
|
});
|
|
600
608
|
})
|
|
601
609
|
);
|
|
@@ -603,13 +611,13 @@ async function yt(e, t, r) {
|
|
|
603
611
|
}
|
|
604
612
|
async function bt(e, t, r) {
|
|
605
613
|
try {
|
|
606
|
-
const s = c.readdirSync(r).map((
|
|
607
|
-
for (const
|
|
614
|
+
const s = c.readdirSync(r).map((i) => p.join(r, i)), o = [];
|
|
615
|
+
for (const i of s)
|
|
608
616
|
await vt(
|
|
609
617
|
e,
|
|
610
618
|
t,
|
|
611
|
-
|
|
612
|
-
) && o.push(
|
|
619
|
+
i
|
|
620
|
+
) && o.push(i);
|
|
613
621
|
return o;
|
|
614
622
|
} catch (s) {
|
|
615
623
|
return y.warn(`Failed to find stale Playground temp dirs: ${s}`), [];
|
|
@@ -621,16 +629,16 @@ async function vt(e, t, r) {
|
|
|
621
629
|
const o = p.basename(r);
|
|
622
630
|
if (!o.includes(e))
|
|
623
631
|
return !1;
|
|
624
|
-
const
|
|
632
|
+
const i = o.match(
|
|
625
633
|
new RegExp(`^(.+)${e}(\\d+)-`)
|
|
626
634
|
);
|
|
627
|
-
if (!
|
|
635
|
+
if (!i)
|
|
628
636
|
return !1;
|
|
629
|
-
const
|
|
630
|
-
executableName:
|
|
631
|
-
pid:
|
|
637
|
+
const n = {
|
|
638
|
+
executableName: i[1],
|
|
639
|
+
pid: i[2]
|
|
632
640
|
};
|
|
633
|
-
if (await Pt(
|
|
641
|
+
if (await Pt(n.pid, n.executableName))
|
|
634
642
|
return !1;
|
|
635
643
|
const l = Date.now() - t;
|
|
636
644
|
return c.statSync(r).mtime.getTime() < l;
|
|
@@ -645,8 +653,8 @@ async function Pt(e, t) {
|
|
|
645
653
|
// Remove path from executable name in the results.
|
|
646
654
|
clean: !0
|
|
647
655
|
},
|
|
648
|
-
(
|
|
649
|
-
|
|
656
|
+
(i, n) => {
|
|
657
|
+
i ? o(i) : s(n);
|
|
650
658
|
}
|
|
651
659
|
);
|
|
652
660
|
}
|
|
@@ -722,11 +730,11 @@ ${t}
|
|
|
722
730
|
`${this.dim("PHP")} ${this.cyan(t.phpVersion)} ${this.dim("WordPress")} ${this.cyan(t.wpVersion)}`
|
|
723
731
|
);
|
|
724
732
|
const s = [];
|
|
725
|
-
if (t.intl && s.push("intl"), t.xdebug && s.push(this.yellow("xdebug")), s.length > 0 && r.push(`${this.dim("Extensions")} ${s.join(", ")}`), t.mounts.length > 0)
|
|
733
|
+
if (t.intl && s.push("intl"), t.redis && s.push("redis"), t.memcached && s.push("memcached"), t.xdebug && s.push(this.yellow("xdebug")), s.length > 0 && r.push(`${this.dim("Extensions")} ${s.join(", ")}`), t.mounts.length > 0)
|
|
726
734
|
for (const o of t.mounts) {
|
|
727
|
-
const
|
|
735
|
+
const i = o.autoMounted ? ` ${this.dim("(auto-mount)")}` : "";
|
|
728
736
|
r.push(
|
|
729
|
-
`${this.dim("Mount")} ${o.hostPath} ${this.dim("→")} ${o.vfsPath}${
|
|
737
|
+
`${this.dim("Mount")} ${o.hostPath} ${this.dim("→")} ${o.vfsPath}${i}`
|
|
730
738
|
);
|
|
731
739
|
}
|
|
732
740
|
t.blueprint && r.push(`${this.dim("Blueprint")} ${t.blueprint}`), this.writeStream.write(r.join(`
|
|
@@ -809,7 +817,7 @@ ${this.green("Ready!")} WordPress is running on ${this.bold(t)} ${this.dim(`(${r
|
|
|
809
817
|
`);
|
|
810
818
|
}
|
|
811
819
|
}
|
|
812
|
-
const
|
|
820
|
+
const fe = {
|
|
813
821
|
Quiet: { name: "quiet", severity: j.Fatal },
|
|
814
822
|
Normal: { name: "normal", severity: j.Info },
|
|
815
823
|
Debug: { name: "debug", severity: j.Debug }
|
|
@@ -825,7 +833,7 @@ async function or(e) {
|
|
|
825
833
|
describe: "PHP version to use.",
|
|
826
834
|
type: "string",
|
|
827
835
|
default: F,
|
|
828
|
-
choices:
|
|
836
|
+
choices: oe
|
|
829
837
|
},
|
|
830
838
|
wp: {
|
|
831
839
|
describe: "WordPress version to use.",
|
|
@@ -851,7 +859,7 @@ async function or(e) {
|
|
|
851
859
|
type: "string",
|
|
852
860
|
nargs: 2,
|
|
853
861
|
array: !0,
|
|
854
|
-
coerce:
|
|
862
|
+
coerce: it
|
|
855
863
|
},
|
|
856
864
|
// @TODO: Support read-only mounts, e.g. via WORKERFS, a custom
|
|
857
865
|
// ReadOnlyNODEFS, or by copying the files into MEMFS
|
|
@@ -926,7 +934,7 @@ async function or(e) {
|
|
|
926
934
|
verbosity: {
|
|
927
935
|
describe: "Output logs and progress messages.",
|
|
928
936
|
type: "string",
|
|
929
|
-
choices: Object.values(
|
|
937
|
+
choices: Object.values(fe).map(
|
|
930
938
|
(a) => a.name
|
|
931
939
|
),
|
|
932
940
|
default: "normal"
|
|
@@ -965,6 +973,16 @@ Warning: Following symlinks will expose files outside mounted directories to Pla
|
|
|
965
973
|
type: "boolean",
|
|
966
974
|
default: !0
|
|
967
975
|
},
|
|
976
|
+
redis: {
|
|
977
|
+
describe: "Enable Redis (requires JSPI support).",
|
|
978
|
+
type: "boolean"
|
|
979
|
+
// No default - will be determined at runtime based on JSPI availability
|
|
980
|
+
},
|
|
981
|
+
memcached: {
|
|
982
|
+
describe: "Enable Memcached.",
|
|
983
|
+
type: "boolean"
|
|
984
|
+
// No default - will be determined at runtime based on JSPI availability
|
|
985
|
+
},
|
|
968
986
|
xdebug: {
|
|
969
987
|
describe: "Enable Xdebug.",
|
|
970
988
|
type: "boolean",
|
|
@@ -1002,7 +1020,7 @@ Warning: Following symlinks will expose files outside mounted directories to Pla
|
|
|
1002
1020
|
"experimental-multi-worker": {
|
|
1003
1021
|
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.",
|
|
1004
1022
|
type: "number",
|
|
1005
|
-
coerce: (a) => a ??
|
|
1023
|
+
coerce: (a) => a ?? De().length - 1
|
|
1006
1024
|
},
|
|
1007
1025
|
"experimental-devtools": {
|
|
1008
1026
|
describe: "Enable experimental browser development tools.",
|
|
@@ -1018,7 +1036,7 @@ Warning: Following symlinks will expose files outside mounted directories to Pla
|
|
|
1018
1036
|
describe: "PHP version to use.",
|
|
1019
1037
|
type: "string",
|
|
1020
1038
|
default: F,
|
|
1021
|
-
choices:
|
|
1039
|
+
choices: oe
|
|
1022
1040
|
},
|
|
1023
1041
|
wp: {
|
|
1024
1042
|
describe: "WordPress version to use.",
|
|
@@ -1086,7 +1104,7 @@ Warning: Following symlinks will expose files outside mounted directories to Pla
|
|
|
1086
1104
|
type: "string",
|
|
1087
1105
|
default: "wordpress.zip"
|
|
1088
1106
|
}
|
|
1089
|
-
},
|
|
1107
|
+
}, i = Re(e).usage("Usage: wp-playground <command> [options]").command(
|
|
1090
1108
|
"start",
|
|
1091
1109
|
"Start a local WordPress server with automatic project detection (recommended)",
|
|
1092
1110
|
(a) => a.usage(
|
|
@@ -1195,24 +1213,24 @@ Examples:
|
|
|
1195
1213
|
);
|
|
1196
1214
|
return !0;
|
|
1197
1215
|
});
|
|
1198
|
-
|
|
1199
|
-
const
|
|
1216
|
+
i.wrap(i.terminalWidth());
|
|
1217
|
+
const n = await i.argv, l = n._[0];
|
|
1200
1218
|
["start", "run-blueprint", "server", "build-snapshot"].includes(
|
|
1201
1219
|
l
|
|
1202
|
-
) || (
|
|
1203
|
-
const u =
|
|
1220
|
+
) || (i.showHelp(), process.exit(1));
|
|
1221
|
+
const u = n.define || {};
|
|
1204
1222
|
!("WP_DEBUG" in u) && !("WP_DEBUG_LOG" in u) && !("WP_DEBUG_DISPLAY" in u) && (u.WP_DEBUG = "true", u.WP_DEBUG_LOG = "true", u.WP_DEBUG_DISPLAY = "true");
|
|
1205
1223
|
const v = {
|
|
1206
|
-
...
|
|
1224
|
+
...n,
|
|
1207
1225
|
define: u,
|
|
1208
1226
|
command: l,
|
|
1209
1227
|
mount: [
|
|
1210
|
-
...
|
|
1211
|
-
...
|
|
1228
|
+
...n.mount || [],
|
|
1229
|
+
...n["mount-dir"] || []
|
|
1212
1230
|
],
|
|
1213
1231
|
"mount-before-install": [
|
|
1214
|
-
...
|
|
1215
|
-
...
|
|
1232
|
+
...n["mount-before-install"] || [],
|
|
1233
|
+
...n["mount-dir-before-install"] || []
|
|
1216
1234
|
]
|
|
1217
1235
|
}, P = await Et(v);
|
|
1218
1236
|
P === void 0 && process.exit(0);
|
|
@@ -1227,7 +1245,7 @@ Examples:
|
|
|
1227
1245
|
if (console.error(t), !(t instanceof Error))
|
|
1228
1246
|
throw t;
|
|
1229
1247
|
if (process.argv.includes("--debug"))
|
|
1230
|
-
|
|
1248
|
+
ve(t);
|
|
1231
1249
|
else {
|
|
1232
1250
|
const s = [];
|
|
1233
1251
|
let o = t;
|
|
@@ -1241,22 +1259,22 @@ Examples:
|
|
|
1241
1259
|
process.exit(1);
|
|
1242
1260
|
}
|
|
1243
1261
|
}
|
|
1244
|
-
function
|
|
1262
|
+
function le(e, t) {
|
|
1245
1263
|
return e.find(
|
|
1246
1264
|
(r) => r.vfsPath.replace(/\/$/, "") === t.replace(/\/$/, "")
|
|
1247
1265
|
);
|
|
1248
1266
|
}
|
|
1249
|
-
const kt = Symbol("playground-cli-testing"), T = (e) => process.stdout.isTTY ? "\x1B[1m" + e + "\x1B[0m" : e, It = (e) => process.stdout.isTTY ? "\x1B[31m" + e + "\x1B[0m" : e, $t = (e) => process.stdout.isTTY ? `\x1B[2m${e}\x1B[0m` : e, Y = (e) => process.stdout.isTTY ? `\x1B[3m${e}\x1B[0m` : e,
|
|
1267
|
+
const kt = Symbol("playground-cli-testing"), T = (e) => process.stdout.isTTY ? "\x1B[1m" + e + "\x1B[0m" : e, It = (e) => process.stdout.isTTY ? "\x1B[31m" + e + "\x1B[0m" : e, $t = (e) => process.stdout.isTTY ? `\x1B[2m${e}\x1B[0m` : e, Y = (e) => process.stdout.isTTY ? `\x1B[3m${e}\x1B[0m` : e, ue = (e) => process.stdout.isTTY ? `\x1B[33m${e}\x1B[0m` : e;
|
|
1250
1268
|
async function Et(e) {
|
|
1251
1269
|
let t, r;
|
|
1252
1270
|
const s = /* @__PURE__ */ new Map();
|
|
1253
|
-
if (e.command === "start" && (e = Tt(e)), e.autoMount !== void 0 && (e.autoMount === "" && (e = { ...e, autoMount: process.cwd() }), e =
|
|
1254
|
-
const w = Object.values(
|
|
1271
|
+
if (e.command === "start" && (e = Tt(e)), e.autoMount !== void 0 && (e.autoMount === "" && (e = { ...e, autoMount: process.cwd() }), e = pe(e)), e.wordpressInstallMode === void 0 && (e.wordpressInstallMode = "download-and-install"), e.quiet && (e.verbosity = "quiet", delete e.quiet), e.debug && (e.verbosity = "debug", delete e.debug), e.verbosity) {
|
|
1272
|
+
const w = Object.values(fe).find(
|
|
1255
1273
|
(a) => a.name === e.verbosity
|
|
1256
1274
|
).severity;
|
|
1257
1275
|
y.setSeverityFilterLevel(w);
|
|
1258
1276
|
}
|
|
1259
|
-
e.intl || (e.intl = !0);
|
|
1277
|
+
e.intl || (e.intl = !0), e.redis === void 0 && (e.redis = await Q()), e.memcached === void 0 && (e.memcached = await Q());
|
|
1260
1278
|
const o = new xt({
|
|
1261
1279
|
verbosity: e.verbosity || "normal"
|
|
1262
1280
|
});
|
|
@@ -1266,46 +1284,48 @@ async function Et(e) {
|
|
|
1266
1284
|
port: e.port || 9400,
|
|
1267
1285
|
xdebug: !!e.xdebug,
|
|
1268
1286
|
intl: !!e.intl,
|
|
1287
|
+
redis: !!e.redis,
|
|
1288
|
+
memcached: !!e.memcached,
|
|
1269
1289
|
mounts: [
|
|
1270
1290
|
...e.mount || [],
|
|
1271
1291
|
...e["mount-before-install"] || []
|
|
1272
1292
|
],
|
|
1273
1293
|
blueprint: typeof e.blueprint == "string" ? e.blueprint : void 0
|
|
1274
1294
|
}));
|
|
1275
|
-
const
|
|
1295
|
+
const i = e.command === "server" ? e.port ?? 9400 : 0, n = N.platform() === "win32" ? (
|
|
1276
1296
|
// @TODO: Enable fs-ext here when it works with Windows.
|
|
1277
1297
|
void 0
|
|
1278
1298
|
) : await import("fs-ext").then((w) => w.flockSync).catch(() => {
|
|
1279
1299
|
y.debug(
|
|
1280
1300
|
"The fs-ext package is not installed. Internal file locking will not be integrated with host OS file locking."
|
|
1281
1301
|
);
|
|
1282
|
-
}), l = new Le(
|
|
1302
|
+
}), l = new Le(n);
|
|
1283
1303
|
let u = !1, v = !0;
|
|
1284
1304
|
const P = await at({
|
|
1285
|
-
port:
|
|
1305
|
+
port: i,
|
|
1286
1306
|
onBind: async (w, a) => {
|
|
1287
|
-
const g = "127.0.0.1", h = `http://${g}:${a}`, k = e["site-url"] || h, I = e.command === "server" ? e.experimentalMultiWorker ?? 1 : 1,
|
|
1307
|
+
const g = "127.0.0.1", h = `http://${g}:${a}`, k = e["site-url"] || h, I = e.command === "server" ? e.experimentalMultiWorker ?? 1 : 1, C = e.command === "server" ? (
|
|
1288
1308
|
// Account for the initial worker which is discarded by the server after setup.
|
|
1289
1309
|
I + 1
|
|
1290
|
-
) : I,
|
|
1291
|
-
|
|
1292
|
-
),
|
|
1310
|
+
) : I, L = 2 ** 31 - 1, M = Math.floor(
|
|
1311
|
+
L / C
|
|
1312
|
+
), K = "-playground-cli-site-", $ = await gt(K);
|
|
1293
1313
|
y.debug(`Native temp dir for VFS root: ${$.path}`);
|
|
1294
|
-
const
|
|
1295
|
-
if (await Ge(
|
|
1314
|
+
const W = "WP Playground CLI - Listen for Xdebug", ee = ".playground-xdebug-root", te = p.join(process.cwd(), ee);
|
|
1315
|
+
if (await Ge(te), e.xdebug && e.experimentalUnsafeIdeIntegration) {
|
|
1296
1316
|
await Qe(
|
|
1297
1317
|
$.path,
|
|
1298
|
-
|
|
1318
|
+
te,
|
|
1299
1319
|
process.platform
|
|
1300
1320
|
);
|
|
1301
1321
|
const d = {
|
|
1302
|
-
hostPath: p.join(".", p.sep,
|
|
1322
|
+
hostPath: p.join(".", p.sep, ee),
|
|
1303
1323
|
vfsPath: "/"
|
|
1304
1324
|
};
|
|
1305
1325
|
try {
|
|
1306
|
-
await Xe(
|
|
1326
|
+
await Xe(W, process.cwd());
|
|
1307
1327
|
const f = typeof e.xdebug == "object" ? e.xdebug : void 0, S = await Ze({
|
|
1308
|
-
name:
|
|
1328
|
+
name: W,
|
|
1309
1329
|
host: g,
|
|
1310
1330
|
port: a,
|
|
1311
1331
|
ides: e.experimentalUnsafeIdeIntegration,
|
|
@@ -1318,9 +1338,9 @@ async function Et(e) {
|
|
|
1318
1338
|
ideKey: f?.ideKey
|
|
1319
1339
|
}), m = e.experimentalUnsafeIdeIntegration, b = m.includes("vscode"), x = m.includes("phpstorm"), R = Object.values(S);
|
|
1320
1340
|
console.log(""), R.length > 0 ? (console.log(T("Xdebug configured successfully")), console.log(
|
|
1321
|
-
|
|
1341
|
+
ue("Updated IDE config: ") + R.join(" ")
|
|
1322
1342
|
), console.log(
|
|
1323
|
-
|
|
1343
|
+
ue("Playground source root: ") + ".playground-xdebug-root" + Y(
|
|
1324
1344
|
$t(
|
|
1325
1345
|
" – you can set breakpoints and preview Playground's VFS structure in there."
|
|
1326
1346
|
)
|
|
@@ -1337,7 +1357,7 @@ async function Et(e) {
|
|
|
1337
1357
|
" 2. Open the Run and Debug panel on the left sidebar"
|
|
1338
1358
|
), console.log(
|
|
1339
1359
|
` 3. Select "${Y(
|
|
1340
|
-
|
|
1360
|
+
W
|
|
1341
1361
|
)}" from the dropdown`
|
|
1342
1362
|
), console.log(' 3. Click "start debugging"'), console.log(
|
|
1343
1363
|
" 5. Set a breakpoint. For example, in .playground-xdebug-root/wordpress/index.php"
|
|
@@ -1345,7 +1365,7 @@ async function Et(e) {
|
|
|
1345
1365
|
" 6. Visit Playground in your browser to hit the breakpoint"
|
|
1346
1366
|
), x && console.log("")), x && S.phpstorm && (console.log(T("PhpStorm instructions:")), console.log(
|
|
1347
1367
|
` 1. Choose "${Y(
|
|
1348
|
-
|
|
1368
|
+
W
|
|
1349
1369
|
)}" debug configuration in the toolbar`
|
|
1350
1370
|
), console.log(" 2. Click the debug button (bug icon)`"), console.log(
|
|
1351
1371
|
" 3. Set a breakpoint. For example, in .playground-xdebug-root/wordpress/index.php"
|
|
@@ -1358,15 +1378,15 @@ async function Et(e) {
|
|
|
1358
1378
|
});
|
|
1359
1379
|
}
|
|
1360
1380
|
}
|
|
1361
|
-
const
|
|
1381
|
+
const we = p.dirname($.path), ge = 2 * 24 * 60 * 60 * 1e3;
|
|
1362
1382
|
yt(
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1383
|
+
K,
|
|
1384
|
+
ge,
|
|
1385
|
+
we
|
|
1366
1386
|
);
|
|
1367
1387
|
const _ = p.join($.path, "internal");
|
|
1368
1388
|
G(_);
|
|
1369
|
-
const
|
|
1389
|
+
const ye = [
|
|
1370
1390
|
"wordpress",
|
|
1371
1391
|
// Note: These dirs are from Emscripten's "default dirs" list:
|
|
1372
1392
|
// https://github.com/emscripten-core/emscripten/blob/f431ec220e472e1f8d3db6b52fe23fb377facf30/src/lib/libfs.js#L1400-L1402
|
|
@@ -1377,7 +1397,7 @@ async function Et(e) {
|
|
|
1377
1397
|
"tmp",
|
|
1378
1398
|
"home"
|
|
1379
1399
|
];
|
|
1380
|
-
for (const d of
|
|
1400
|
+
for (const d of ye) {
|
|
1381
1401
|
const f = (m) => m.vfsPath === `/${d}`;
|
|
1382
1402
|
if (!(e["mount-before-install"]?.some(f) || e.mount?.some(f))) {
|
|
1383
1403
|
const m = p.join(
|
|
@@ -1403,11 +1423,11 @@ async function Et(e) {
|
|
|
1403
1423
|
let E;
|
|
1404
1424
|
e["experimental-blueprints-v2-runner"] ? E = new mt(e, {
|
|
1405
1425
|
siteUrl: k,
|
|
1406
|
-
processIdSpaceLength:
|
|
1426
|
+
processIdSpaceLength: M,
|
|
1407
1427
|
cliOutput: o
|
|
1408
1428
|
}) : (E = new wt(e, {
|
|
1409
1429
|
siteUrl: k,
|
|
1410
|
-
processIdSpaceLength:
|
|
1430
|
+
processIdSpaceLength: M,
|
|
1411
1431
|
cliOutput: o
|
|
1412
1432
|
}), typeof e.blueprint == "string" && (e.blueprint = await pt({
|
|
1413
1433
|
sourceString: e.blueprint,
|
|
@@ -1422,8 +1442,8 @@ async function Et(e) {
|
|
|
1422
1442
|
}
|
|
1423
1443
|
)
|
|
1424
1444
|
), w && await new Promise((f) => w.close(f)), await $.cleanup());
|
|
1425
|
-
},
|
|
1426
|
-
|
|
1445
|
+
}, be = Bt(
|
|
1446
|
+
C,
|
|
1427
1447
|
E.getWorkerType(),
|
|
1428
1448
|
({ exitCode: d, workerIndex: f }) => {
|
|
1429
1449
|
H || d === 0 && y.error(
|
|
@@ -1434,7 +1454,7 @@ async function Et(e) {
|
|
|
1434
1454
|
);
|
|
1435
1455
|
o.startProgress("Starting...");
|
|
1436
1456
|
try {
|
|
1437
|
-
const d = await
|
|
1457
|
+
const d = await be, f = await de(l);
|
|
1438
1458
|
{
|
|
1439
1459
|
const m = d.shift(), b = await E.bootAndSetUpInitialPlayground(
|
|
1440
1460
|
m.phpPort,
|
|
@@ -1448,13 +1468,13 @@ async function Et(e) {
|
|
|
1448
1468
|
const x = await E.compileInputBlueprint(
|
|
1449
1469
|
e["additional-blueprint-steps"] || []
|
|
1450
1470
|
);
|
|
1451
|
-
x && await
|
|
1471
|
+
x && await $e(
|
|
1452
1472
|
x,
|
|
1453
1473
|
b
|
|
1454
1474
|
);
|
|
1455
1475
|
}
|
|
1456
1476
|
if (e.command === "build-snapshot") {
|
|
1457
|
-
await
|
|
1477
|
+
await Lt(r, e.outfile), o.printStatus(`Exported to ${e.outfile}`), await D();
|
|
1458
1478
|
return;
|
|
1459
1479
|
} else if (e.command === "run-blueprint") {
|
|
1460
1480
|
o.finishProgress("Done"), await D();
|
|
@@ -1462,10 +1482,10 @@ async function Et(e) {
|
|
|
1462
1482
|
}
|
|
1463
1483
|
await t.removeWorker(b), await b.dispose(), await m.worker.terminate(), s.delete(m.worker);
|
|
1464
1484
|
}
|
|
1465
|
-
const S =
|
|
1485
|
+
const S = M;
|
|
1466
1486
|
return [r] = await Promise.all(
|
|
1467
1487
|
d.map(async (m, b) => {
|
|
1468
|
-
const x = S + b *
|
|
1488
|
+
const x = S + b * M, R = await de(l), V = await E.bootPlayground({
|
|
1469
1489
|
worker: m,
|
|
1470
1490
|
fileLockManagerPort: R,
|
|
1471
1491
|
firstProcessId: x,
|
|
@@ -1486,14 +1506,14 @@ async function Et(e) {
|
|
|
1486
1506
|
[Symbol.asyncDispose]: D,
|
|
1487
1507
|
[kt]: {
|
|
1488
1508
|
workerThreadCount: I,
|
|
1489
|
-
getWorkerNumberFromProcessId: (m) => Math.floor(m /
|
|
1509
|
+
getWorkerNumberFromProcessId: (m) => Math.floor(m / M)
|
|
1490
1510
|
}
|
|
1491
1511
|
};
|
|
1492
1512
|
} catch (d) {
|
|
1493
1513
|
if (e.verbosity !== "debug")
|
|
1494
1514
|
throw d;
|
|
1495
1515
|
let f = "";
|
|
1496
|
-
throw await r?.fileExists(
|
|
1516
|
+
throw await r?.fileExists(re) && (f = await r.readFileAsText(re)), await D(), new Error(f, { cause: d });
|
|
1497
1517
|
}
|
|
1498
1518
|
},
|
|
1499
1519
|
async handleRequest(w) {
|
|
@@ -1518,15 +1538,15 @@ async function Et(e) {
|
|
|
1518
1538
|
return await t.handleRequest(w);
|
|
1519
1539
|
}
|
|
1520
1540
|
});
|
|
1521
|
-
return P && e.command === "start" && !e.skipBrowser &&
|
|
1541
|
+
return P && e.command === "start" && !e.skipBrowser && Ct(P.serverUrl), P;
|
|
1522
1542
|
}
|
|
1523
1543
|
function Tt(e) {
|
|
1524
1544
|
let t = { ...e, command: "server" };
|
|
1525
|
-
e.noAutoMount || (t.autoMount = p.resolve(process.cwd(), t.path ?? ""), t =
|
|
1526
|
-
const r =
|
|
1545
|
+
e.noAutoMount || (t.autoMount = p.resolve(process.cwd(), t.path ?? ""), t = pe(t), delete t.autoMount);
|
|
1546
|
+
const r = le(
|
|
1527
1547
|
t["mount-before-install"] || [],
|
|
1528
1548
|
"/wordpress"
|
|
1529
|
-
) ||
|
|
1549
|
+
) || le(t.mount || [], "/wordpress");
|
|
1530
1550
|
if (r)
|
|
1531
1551
|
console.log("Site files stored at:", r?.hostPath), e.reset && (console.log(""), console.log(
|
|
1532
1552
|
It(
|
|
@@ -1538,15 +1558,15 @@ function Tt(e) {
|
|
|
1538
1558
|
"You may still remove the site's directory manually if you wish."
|
|
1539
1559
|
), process.exit(1));
|
|
1540
1560
|
else {
|
|
1541
|
-
const s = t.autoMount || process.cwd(), o = Je("sha256").update(s).digest("hex"),
|
|
1542
|
-
|
|
1561
|
+
const s = t.autoMount || process.cwd(), o = Je("sha256").update(s).digest("hex"), i = N.homedir(), n = p.join(
|
|
1562
|
+
i,
|
|
1543
1563
|
".wordpress-playground/sites",
|
|
1544
1564
|
o
|
|
1545
1565
|
);
|
|
1546
|
-
console.log("Site files stored at:",
|
|
1566
|
+
console.log("Site files stored at:", n), Z(n) && e.reset && (console.log("Resetting site..."), Te(n, { recursive: !0 })), G(n, { recursive: !0 }), t["mount-before-install"] = [
|
|
1547
1567
|
...t["mount-before-install"] || [],
|
|
1548
|
-
{ vfsPath: "/wordpress", hostPath:
|
|
1549
|
-
], t.wordpressInstallMode =
|
|
1568
|
+
{ vfsPath: "/wordpress", hostPath: n }
|
|
1569
|
+
], t.wordpressInstallMode = Be(n).length === 0 ? (
|
|
1550
1570
|
// Only download WordPress on the first run when the site directory is still
|
|
1551
1571
|
// empty.
|
|
1552
1572
|
"download-and-install"
|
|
@@ -1560,41 +1580,41 @@ function Tt(e) {
|
|
|
1560
1580
|
async function Bt(e, t, r) {
|
|
1561
1581
|
const s = [];
|
|
1562
1582
|
for (let o = 0; o < e; o++) {
|
|
1563
|
-
const
|
|
1583
|
+
const n = Mt(t, { onExit: (l) => {
|
|
1564
1584
|
r({
|
|
1565
1585
|
exitCode: l,
|
|
1566
1586
|
workerIndex: o
|
|
1567
1587
|
});
|
|
1568
1588
|
} });
|
|
1569
|
-
s.push(
|
|
1589
|
+
s.push(n);
|
|
1570
1590
|
}
|
|
1571
1591
|
return Promise.all(s);
|
|
1572
1592
|
}
|
|
1573
|
-
function
|
|
1593
|
+
function Mt(e, { onExit: t } = {}) {
|
|
1574
1594
|
let r;
|
|
1575
|
-
return e === "v1" ? r = new
|
|
1576
|
-
r.once("message", function(
|
|
1577
|
-
|
|
1578
|
-
}), r.once("error", function(
|
|
1579
|
-
console.error(
|
|
1595
|
+
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((s, o) => {
|
|
1596
|
+
r.once("message", function(n) {
|
|
1597
|
+
n.command === "worker-script-initialized" && s({ worker: r, phpPort: n.phpPort });
|
|
1598
|
+
}), r.once("error", function(n) {
|
|
1599
|
+
console.error(n);
|
|
1580
1600
|
const l = new Error(
|
|
1581
|
-
`Worker failed to load worker. ${
|
|
1601
|
+
`Worker failed to load worker. ${n.message ? `Original error: ${n.message}` : ""}`
|
|
1582
1602
|
);
|
|
1583
1603
|
o(l);
|
|
1584
1604
|
});
|
|
1585
|
-
let
|
|
1605
|
+
let i = !1;
|
|
1586
1606
|
r.once("spawn", () => {
|
|
1587
|
-
|
|
1588
|
-
}), r.once("exit", (
|
|
1589
|
-
|
|
1607
|
+
i = !0;
|
|
1608
|
+
}), r.once("exit", (n) => {
|
|
1609
|
+
i || o(new Error(`Worker exited before spawning: ${n}`)), t?.(n);
|
|
1590
1610
|
});
|
|
1591
1611
|
});
|
|
1592
1612
|
}
|
|
1593
|
-
async function
|
|
1594
|
-
const { port1: t, port2: r } = new
|
|
1595
|
-
return await
|
|
1613
|
+
async function de(e) {
|
|
1614
|
+
const { port1: t, port2: r } = new Me();
|
|
1615
|
+
return await Q() ? Pe(e, null, t) : await Se(e, t), r;
|
|
1596
1616
|
}
|
|
1597
|
-
function
|
|
1617
|
+
function Ct(e) {
|
|
1598
1618
|
const t = N.platform();
|
|
1599
1619
|
let r;
|
|
1600
1620
|
switch (t) {
|
|
@@ -1612,7 +1632,7 @@ function Lt(e) {
|
|
|
1612
1632
|
s && y.debug(`Could not open browser: ${s.message}`);
|
|
1613
1633
|
});
|
|
1614
1634
|
}
|
|
1615
|
-
async function
|
|
1635
|
+
async function Lt(e, t) {
|
|
1616
1636
|
await e.run({
|
|
1617
1637
|
code: `<?php
|
|
1618
1638
|
$zip = new ZipArchive();
|
|
@@ -1637,13 +1657,13 @@ async function Wt(e, t) {
|
|
|
1637
1657
|
c.writeFileSync(t, r);
|
|
1638
1658
|
}
|
|
1639
1659
|
export {
|
|
1640
|
-
|
|
1660
|
+
fe as L,
|
|
1641
1661
|
rr as a,
|
|
1642
1662
|
St as b,
|
|
1643
1663
|
kt as i,
|
|
1644
1664
|
O as m,
|
|
1645
1665
|
or as p,
|
|
1646
1666
|
Et as r,
|
|
1647
|
-
|
|
1667
|
+
Mt as s
|
|
1648
1668
|
};
|
|
1649
|
-
//# sourceMappingURL=run-cli-
|
|
1669
|
+
//# sourceMappingURL=run-cli-BK0MGgcU.js.map
|