@wp-playground/cli 3.0.42 → 3.0.44
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 +5 -0
- package/blueprints-v2/blueprints-v2-handler.d.ts +1 -1
- package/blueprints-v2/worker-thread-v2.d.ts +5 -0
- package/cli.cjs +1 -1
- package/cli.js +1 -1
- package/defines.d.ts +53 -0
- package/index.cjs +1 -1
- package/index.js +6 -5
- package/package.json +13 -13
- package/{run-cli-NcKUE5gJ.js → run-cli-DOpShCrT.js} +497 -391
- package/run-cli-DOpShCrT.js.map +1 -0
- package/run-cli-le2xCSBZ.cjs +64 -0
- package/run-cli-le2xCSBZ.cjs.map +1 -0
- package/run-cli.d.ts +16 -1
- 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 +32 -34
- package/worker-thread-v1.js.map +1 -1
- package/worker-thread-v2.cjs +4 -4
- package/worker-thread-v2.cjs.map +1 -1
- package/worker-thread-v2.js +34 -36
- package/worker-thread-v2.js.map +1 -1
- package/run-cli-B8Dv6R-o.cjs +0 -64
- package/run-cli-B8Dv6R-o.cjs.map +0 -1
- package/run-cli-NcKUE5gJ.js.map +0 -1
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
import { logger as
|
|
2
|
-
import { PHPResponse as
|
|
3
|
-
import { resolveRemoteBlueprint as
|
|
4
|
-
import { zipDirectory as
|
|
5
|
-
import
|
|
6
|
-
import { MessageChannel as Be, Worker as
|
|
7
|
-
import { createNodeFsMountHandler as
|
|
8
|
-
import
|
|
1
|
+
import { logger as y, LogSeverity as j, errorLogPath as te } from "@php-wasm/logger";
|
|
2
|
+
import { PHPResponse as z, consumeAPI as U, SupportedPHPVersions as re, printDebugDetails as be, exposeAPI as ve, exposeSyncAPI as Pe } from "@php-wasm/universal";
|
|
3
|
+
import { resolveRemoteBlueprint as Se, resolveRuntimeConfiguration as oe, compileBlueprintV1 as xe, isBlueprintBundle as ke, runBlueprintV1Steps as Ie } from "@wp-playground/blueprints";
|
|
4
|
+
import { zipDirectory as $e, RecommendedPHPVersion as F } from "@wp-playground/common";
|
|
5
|
+
import c, { existsSync as X, rmdirSync as Ee, mkdirSync as G, readdirSync as Te } from "fs";
|
|
6
|
+
import { MessageChannel as Be, Worker as se } from "worker_threads";
|
|
7
|
+
import { createNodeFsMountHandler as Ce, FileLockManagerForNode as Le } from "@php-wasm/node";
|
|
8
|
+
import p, { basename as A, join as de } from "path";
|
|
9
9
|
import We from "express";
|
|
10
|
-
import
|
|
11
|
-
import { jspi as
|
|
10
|
+
import N, { cpus as Me } from "os";
|
|
11
|
+
import { jspi as De } from "wasm-feature-detect";
|
|
12
12
|
import Re from "yargs";
|
|
13
|
-
import { NodeJsFilesystem as
|
|
14
|
-
import { EmscriptenDownloadMonitor as
|
|
15
|
-
import { resolveWordPressRelease as
|
|
13
|
+
import { NodeJsFilesystem as Ae, OverlayFilesystem as Ue, InMemoryFilesystem as Fe, ZipFilesystem as Oe } from "@wp-playground/storage";
|
|
14
|
+
import { EmscriptenDownloadMonitor as Ne, ProgressTracker as _e } from "@php-wasm/progress";
|
|
15
|
+
import { resolveWordPressRelease as He } from "@wp-playground/wordpress";
|
|
16
16
|
import B from "fs-extra";
|
|
17
|
-
import { startBridge as
|
|
17
|
+
import { startBridge as Ve } from "@php-wasm/xdebug-bridge";
|
|
18
18
|
import { exec as je } from "child_process";
|
|
19
|
-
import { dir as
|
|
20
|
-
import
|
|
21
|
-
import { removeTempDirSymlink as
|
|
22
|
-
import { createHash as
|
|
23
|
-
function
|
|
19
|
+
import { dir as qe, setGracefulCleanup as Ye } from "tmp-promise";
|
|
20
|
+
import ze from "ps-man";
|
|
21
|
+
import { removeTempDirSymlink as Ge, createTempDirSymlink as Qe, clearXdebugIDEConfig as Xe, addXdebugIDEConfig as Ze } from "@php-wasm/cli-util";
|
|
22
|
+
import { createHash as Je } from "crypto";
|
|
23
|
+
function q(e) {
|
|
24
24
|
const t = [];
|
|
25
25
|
for (const r of e) {
|
|
26
26
|
const s = r.split(":");
|
|
@@ -29,14 +29,14 @@ function _(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,
|
|
32
|
+
const [o, n] = s;
|
|
33
33
|
if (!X(o))
|
|
34
34
|
throw new Error(`Host path does not exist: ${o}`);
|
|
35
|
-
t.push({ hostPath: o, vfsPath:
|
|
35
|
+
t.push({ hostPath: o, vfsPath: n });
|
|
36
36
|
}
|
|
37
37
|
return t;
|
|
38
38
|
}
|
|
39
|
-
function
|
|
39
|
+
function ne(e) {
|
|
40
40
|
if (e.length % 2 !== 0)
|
|
41
41
|
throw new Error("Invalid mount format. Expected: /host/path /vfs/path");
|
|
42
42
|
const t = [];
|
|
@@ -45,17 +45,17 @@ function se(e) {
|
|
|
45
45
|
if (!X(s))
|
|
46
46
|
throw new Error(`Host path does not exist: ${s}`);
|
|
47
47
|
t.push({
|
|
48
|
-
hostPath:
|
|
48
|
+
hostPath: p.resolve(process.cwd(), s),
|
|
49
49
|
vfsPath: o
|
|
50
50
|
});
|
|
51
51
|
}
|
|
52
52
|
return t;
|
|
53
53
|
}
|
|
54
|
-
async function
|
|
54
|
+
async function rr(e, t) {
|
|
55
55
|
for (const r of t)
|
|
56
56
|
await e.mount(
|
|
57
57
|
r.vfsPath,
|
|
58
|
-
|
|
58
|
+
Ce(r.hostPath)
|
|
59
59
|
);
|
|
60
60
|
}
|
|
61
61
|
const ie = {
|
|
@@ -77,7 +77,7 @@ const ie = {
|
|
|
77
77
|
`
|
|
78
78
|
}
|
|
79
79
|
};
|
|
80
|
-
function
|
|
80
|
+
function ce(e) {
|
|
81
81
|
const t = e.autoMount, r = [...e.mount || []], s = [...e["mount-before-install"] || []], o = {
|
|
82
82
|
...e,
|
|
83
83
|
mount: r,
|
|
@@ -86,110 +86,183 @@ function de(e) {
|
|
|
86
86
|
...e["additional-blueprint-steps"] || []
|
|
87
87
|
]
|
|
88
88
|
};
|
|
89
|
-
if (
|
|
90
|
-
const
|
|
89
|
+
if (rt(t)) {
|
|
90
|
+
const i = `/wordpress/wp-content/plugins/${A(t)}`;
|
|
91
91
|
r.push({
|
|
92
92
|
hostPath: t,
|
|
93
|
-
vfsPath:
|
|
93
|
+
vfsPath: i,
|
|
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
|
-
} else if (
|
|
100
|
-
const
|
|
99
|
+
} else if (tt(t)) {
|
|
100
|
+
const n = A(t), i = `/wordpress/wp-content/themes/${n}`;
|
|
101
101
|
r.push({
|
|
102
102
|
hostPath: t,
|
|
103
|
-
vfsPath:
|
|
103
|
+
vfsPath: i,
|
|
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: n
|
|
109
109
|
} : {
|
|
110
110
|
step: "activateTheme",
|
|
111
|
-
themeFolderName:
|
|
111
|
+
themeFolderName: n
|
|
112
112
|
}
|
|
113
113
|
);
|
|
114
|
-
} else if (
|
|
115
|
-
const
|
|
116
|
-
for (const
|
|
117
|
-
|
|
118
|
-
hostPath: `${t}/${
|
|
119
|
-
vfsPath: `/wordpress/wp-content/${
|
|
114
|
+
} else if (et(t)) {
|
|
115
|
+
const n = c.readdirSync(t);
|
|
116
|
+
for (const i of n)
|
|
117
|
+
i !== "index.php" && r.push({
|
|
118
|
+
hostPath: `${t}/${i}`,
|
|
119
|
+
vfsPath: `/wordpress/wp-content/${i}`,
|
|
120
120
|
autoMounted: !0
|
|
121
121
|
});
|
|
122
122
|
o["additional-blueprint-steps"].push(ie);
|
|
123
|
-
} else
|
|
123
|
+
} else Ke(t) && (s.push({
|
|
124
124
|
hostPath: t,
|
|
125
125
|
vfsPath: "/wordpress",
|
|
126
126
|
autoMounted: !0
|
|
127
127
|
}), o.mode = "apply-to-existing-site", o["additional-blueprint-steps"].push(ie), o.wordpressInstallMode || (o.wordpressInstallMode = "install-from-existing-files-if-needed"));
|
|
128
128
|
return o;
|
|
129
129
|
}
|
|
130
|
-
function
|
|
131
|
-
const t =
|
|
130
|
+
function Ke(e) {
|
|
131
|
+
const t = c.readdirSync(e);
|
|
132
132
|
return t.includes("wp-admin") && t.includes("wp-includes") && t.includes("wp-content");
|
|
133
133
|
}
|
|
134
|
-
function
|
|
135
|
-
const t =
|
|
134
|
+
function et(e) {
|
|
135
|
+
const t = c.readdirSync(e);
|
|
136
136
|
return t.includes("themes") || t.includes("plugins") || t.includes("mu-plugins") || t.includes("uploads");
|
|
137
137
|
}
|
|
138
|
-
function
|
|
139
|
-
if (!
|
|
138
|
+
function tt(e) {
|
|
139
|
+
if (!c.readdirSync(e).includes("style.css"))
|
|
140
140
|
return !1;
|
|
141
|
-
const r =
|
|
141
|
+
const r = c.readFileSync(de(e, "style.css"), "utf8");
|
|
142
142
|
return !!/^(?:[ \t]*<\?php)?[ \t/*#@]*Theme Name:(.*)$/im.exec(r);
|
|
143
143
|
}
|
|
144
|
-
function
|
|
145
|
-
const t =
|
|
144
|
+
function rt(e) {
|
|
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 n = c.readFileSync(de(e, o), "utf8");
|
|
148
|
+
return !!r.exec(n);
|
|
149
149
|
});
|
|
150
150
|
}
|
|
151
|
-
|
|
152
|
-
|
|
151
|
+
function ot(e) {
|
|
152
|
+
if (e.length % 2 !== 0)
|
|
153
|
+
throw new Error(
|
|
154
|
+
"Invalid constant definition format. Expected pairs of NAME value"
|
|
155
|
+
);
|
|
156
|
+
const t = {};
|
|
157
|
+
for (let r = 0; r < e.length; r += 2) {
|
|
158
|
+
const s = e[r], o = e[r + 1];
|
|
159
|
+
if (!s || !s.trim())
|
|
160
|
+
throw new Error("Constant name cannot be empty");
|
|
161
|
+
t[s.trim()] = o;
|
|
162
|
+
}
|
|
163
|
+
return t;
|
|
164
|
+
}
|
|
165
|
+
function st(e) {
|
|
166
|
+
if (e.length % 2 !== 0)
|
|
167
|
+
throw new Error(
|
|
168
|
+
"Invalid boolean constant definition format. Expected pairs of NAME value"
|
|
169
|
+
);
|
|
170
|
+
const t = {};
|
|
171
|
+
for (let r = 0; r < e.length; r += 2) {
|
|
172
|
+
const s = e[r], o = e[r + 1].trim().toLowerCase();
|
|
173
|
+
if (!s || !s.trim())
|
|
174
|
+
throw new Error("Constant name cannot be empty");
|
|
175
|
+
if (o === "true" || o === "1")
|
|
176
|
+
t[s.trim()] = !0;
|
|
177
|
+
else if (o === "false" || o === "0")
|
|
178
|
+
t[s.trim()] = !1;
|
|
179
|
+
else
|
|
180
|
+
throw new Error(
|
|
181
|
+
`Invalid boolean value for constant "${s}": "${o}". Must be "true", "false", "1", or "0".`
|
|
182
|
+
);
|
|
183
|
+
}
|
|
184
|
+
return t;
|
|
185
|
+
}
|
|
186
|
+
function nt(e) {
|
|
187
|
+
if (e.length % 2 !== 0)
|
|
188
|
+
throw new Error(
|
|
189
|
+
"Invalid number constant definition format. Expected pairs of NAME value"
|
|
190
|
+
);
|
|
191
|
+
const t = {};
|
|
192
|
+
for (let r = 0; r < e.length; r += 2) {
|
|
193
|
+
const s = e[r], o = e[r + 1].trim();
|
|
194
|
+
if (!s || !s.trim())
|
|
195
|
+
throw new Error("Constant name cannot be empty");
|
|
196
|
+
const n = Number(o);
|
|
197
|
+
if (isNaN(n))
|
|
198
|
+
throw new Error(
|
|
199
|
+
`Invalid number value for constant "${s}": "${o}". Must be a valid number.`
|
|
200
|
+
);
|
|
201
|
+
t[s.trim()] = n;
|
|
202
|
+
}
|
|
203
|
+
return t;
|
|
204
|
+
}
|
|
205
|
+
function it(e = {}, t = {}, r = {}) {
|
|
206
|
+
const s = {}, o = /* @__PURE__ */ new Set(), n = (i, l) => {
|
|
207
|
+
for (const u in i) {
|
|
208
|
+
if (o.has(u))
|
|
209
|
+
throw new Error(
|
|
210
|
+
`Constant "${u}" is defined multiple times across different --define-${l} flags`
|
|
211
|
+
);
|
|
212
|
+
o.add(u), s[u] = i[u];
|
|
213
|
+
}
|
|
214
|
+
};
|
|
215
|
+
return n(e, "string"), n(t, "bool"), n(r, "number"), s;
|
|
216
|
+
}
|
|
217
|
+
function O(e) {
|
|
218
|
+
return it(
|
|
219
|
+
e.define,
|
|
220
|
+
e["define-bool"],
|
|
221
|
+
e["define-number"]
|
|
222
|
+
);
|
|
223
|
+
}
|
|
224
|
+
async function at(e) {
|
|
225
|
+
const t = We(), r = await new Promise((n, i) => {
|
|
153
226
|
const l = t.listen(e.port, () => {
|
|
154
227
|
const u = l.address();
|
|
155
|
-
u === null || typeof u == "string" ?
|
|
228
|
+
u === null || typeof u == "string" ? i(new Error("Server address is not available")) : n(l);
|
|
156
229
|
});
|
|
157
230
|
});
|
|
158
|
-
t.use("/", async (
|
|
231
|
+
t.use("/", async (n, i) => {
|
|
159
232
|
let l;
|
|
160
233
|
try {
|
|
161
234
|
l = await e.handleRequest({
|
|
162
|
-
url:
|
|
163
|
-
headers:
|
|
164
|
-
method:
|
|
165
|
-
body: await
|
|
235
|
+
url: n.url,
|
|
236
|
+
headers: ut(n),
|
|
237
|
+
method: n.method,
|
|
238
|
+
body: await lt(n)
|
|
166
239
|
});
|
|
167
240
|
} catch (u) {
|
|
168
|
-
|
|
241
|
+
y.error(u), l = z.forHttpCode(500);
|
|
169
242
|
}
|
|
170
|
-
|
|
243
|
+
i.statusCode = l.httpStatusCode;
|
|
171
244
|
for (const u in l.headers)
|
|
172
|
-
|
|
173
|
-
|
|
245
|
+
i.setHeader(u, l.headers[u]);
|
|
246
|
+
i.end(l.bytes);
|
|
174
247
|
});
|
|
175
248
|
const o = r.address().port;
|
|
176
249
|
return await e.onBind(r, o);
|
|
177
250
|
}
|
|
178
|
-
const
|
|
251
|
+
const lt = async (e) => await new Promise((t) => {
|
|
179
252
|
const r = [];
|
|
180
253
|
e.on("data", (s) => {
|
|
181
254
|
r.push(s);
|
|
182
255
|
}), e.on("end", () => {
|
|
183
256
|
t(new Uint8Array(Buffer.concat(r)));
|
|
184
257
|
});
|
|
185
|
-
}),
|
|
258
|
+
}), ut = (e) => {
|
|
186
259
|
const t = {};
|
|
187
260
|
if (e.rawHeaders && e.rawHeaders.length)
|
|
188
261
|
for (let r = 0; r < e.rawHeaders.length; r += 2)
|
|
189
262
|
t[e.rawHeaders[r].toLowerCase()] = e.rawHeaders[r + 1];
|
|
190
263
|
return t;
|
|
191
264
|
};
|
|
192
|
-
class
|
|
265
|
+
class dt {
|
|
193
266
|
constructor(t) {
|
|
194
267
|
this.workerLoads = [], this.addWorker(t);
|
|
195
268
|
}
|
|
@@ -211,8 +284,8 @@ class it {
|
|
|
211
284
|
async handleRequest(t) {
|
|
212
285
|
let r = this.workerLoads[0];
|
|
213
286
|
for (let o = 1; o < this.workerLoads.length; o++) {
|
|
214
|
-
const
|
|
215
|
-
|
|
287
|
+
const n = this.workerLoads[o];
|
|
288
|
+
n.activeRequests.size < r.activeRequests.size && (r = n);
|
|
216
289
|
}
|
|
217
290
|
const s = r.worker.request(t);
|
|
218
291
|
return r.activeRequests.add(s), s.url = t.url, s.finally(() => {
|
|
@@ -220,44 +293,44 @@ class it {
|
|
|
220
293
|
});
|
|
221
294
|
}
|
|
222
295
|
}
|
|
223
|
-
function
|
|
296
|
+
function ct(e) {
|
|
224
297
|
return /^latest$|^trunk$|^nightly$|^(?:(\d+)\.(\d+)(?:\.(\d+))?)((?:-beta(?:\d+)?)|(?:-RC(?:\d+)?))?$/.test(e);
|
|
225
298
|
}
|
|
226
|
-
async function
|
|
299
|
+
async function pt({
|
|
227
300
|
sourceString: e,
|
|
228
301
|
blueprintMayReadAdjacentFiles: t
|
|
229
302
|
}) {
|
|
230
303
|
if (!e)
|
|
231
304
|
return;
|
|
232
305
|
if (e.startsWith("http://") || e.startsWith("https://"))
|
|
233
|
-
return await
|
|
234
|
-
let r =
|
|
235
|
-
if (!
|
|
306
|
+
return await Se(e);
|
|
307
|
+
let r = p.resolve(process.cwd(), e);
|
|
308
|
+
if (!c.existsSync(r))
|
|
236
309
|
throw new Error(`Blueprint file does not exist: ${r}`);
|
|
237
|
-
const s =
|
|
238
|
-
if (s.isDirectory() && (r =
|
|
310
|
+
const s = c.statSync(r);
|
|
311
|
+
if (s.isDirectory() && (r = p.join(r, "blueprint.json")), !s.isFile() && s.isSymbolicLink())
|
|
239
312
|
throw new Error(
|
|
240
313
|
`Blueprint path is neither a file nor a directory: ${r}`
|
|
241
314
|
);
|
|
242
|
-
const o =
|
|
315
|
+
const o = p.extname(r);
|
|
243
316
|
switch (o) {
|
|
244
317
|
case ".zip":
|
|
245
|
-
return
|
|
246
|
-
|
|
318
|
+
return Oe.fromArrayBuffer(
|
|
319
|
+
c.readFileSync(r).buffer
|
|
247
320
|
);
|
|
248
321
|
case ".json": {
|
|
249
|
-
const
|
|
322
|
+
const n = c.readFileSync(r, "utf-8");
|
|
250
323
|
try {
|
|
251
|
-
JSON.parse(
|
|
324
|
+
JSON.parse(n);
|
|
252
325
|
} catch {
|
|
253
326
|
throw new Error(
|
|
254
327
|
`Blueprint file at ${r} is not a valid JSON file`
|
|
255
328
|
);
|
|
256
329
|
}
|
|
257
|
-
const
|
|
258
|
-
return new
|
|
330
|
+
const i = p.dirname(r), l = new Ae(i);
|
|
331
|
+
return new Ue([
|
|
259
332
|
new Fe({
|
|
260
|
-
"blueprint.json":
|
|
333
|
+
"blueprint.json": n
|
|
261
334
|
}),
|
|
262
335
|
/**
|
|
263
336
|
* Wrap the NodeJS filesystem to prevent access to local files
|
|
@@ -282,7 +355,7 @@ You can allow this Blueprint to read files from the same parent directory by exp
|
|
|
282
355
|
);
|
|
283
356
|
}
|
|
284
357
|
}
|
|
285
|
-
class
|
|
358
|
+
class mt {
|
|
286
359
|
constructor(t, r) {
|
|
287
360
|
this.args = t, this.siteUrl = r.siteUrl, this.processIdSpaceLength = r.processIdSpaceLength, this.phpVersion = t.php, this.cliOutput = r.cliOutput;
|
|
288
361
|
}
|
|
@@ -290,9 +363,9 @@ class lt {
|
|
|
290
363
|
return "v2";
|
|
291
364
|
}
|
|
292
365
|
async bootAndSetUpInitialPlayground(t, r, s) {
|
|
293
|
-
const o =
|
|
366
|
+
const o = U(t);
|
|
294
367
|
await o.useFileLockManager(r);
|
|
295
|
-
const
|
|
368
|
+
const n = {
|
|
296
369
|
...this.args,
|
|
297
370
|
phpVersion: this.phpVersion,
|
|
298
371
|
siteUrl: this.siteUrl,
|
|
@@ -309,9 +382,10 @@ class lt {
|
|
|
309
382
|
xdebug: void 0,
|
|
310
383
|
nativeInternalDirPath: s,
|
|
311
384
|
mountsBeforeWpInstall: this.args["mount-before-install"] || [],
|
|
312
|
-
mountsAfterWpInstall: this.args.mount || []
|
|
385
|
+
mountsAfterWpInstall: this.args.mount || [],
|
|
386
|
+
constants: O(this.args)
|
|
313
387
|
};
|
|
314
|
-
return await o.bootAndSetUpInitialWorker(
|
|
388
|
+
return await o.bootAndSetUpInitialWorker(n), o;
|
|
315
389
|
}
|
|
316
390
|
async bootPlayground({
|
|
317
391
|
worker: t,
|
|
@@ -319,9 +393,9 @@ class lt {
|
|
|
319
393
|
firstProcessId: s,
|
|
320
394
|
nativeInternalDirPath: o
|
|
321
395
|
}) {
|
|
322
|
-
const
|
|
323
|
-
await
|
|
324
|
-
const
|
|
396
|
+
const n = U(t.phpPort);
|
|
397
|
+
await n.useFileLockManager(r);
|
|
398
|
+
const i = {
|
|
325
399
|
...this.args,
|
|
326
400
|
phpVersion: this.phpVersion,
|
|
327
401
|
siteUrl: this.siteUrl,
|
|
@@ -332,13 +406,14 @@ class lt {
|
|
|
332
406
|
withXdebug: !!this.args.xdebug,
|
|
333
407
|
nativeInternalDirPath: o,
|
|
334
408
|
mountsBeforeWpInstall: this.args["mount-before-install"] || [],
|
|
335
|
-
mountsAfterWpInstall: this.args.mount || []
|
|
409
|
+
mountsAfterWpInstall: this.args.mount || [],
|
|
410
|
+
constants: O(this.args)
|
|
336
411
|
};
|
|
337
|
-
return await
|
|
412
|
+
return await n.bootWorker(i), n;
|
|
338
413
|
}
|
|
339
414
|
}
|
|
340
|
-
const Q =
|
|
341
|
-
async function
|
|
415
|
+
const Q = p.join(N.homedir(), ".wordpress-playground");
|
|
416
|
+
async function ht(e) {
|
|
342
417
|
return await pe(
|
|
343
418
|
"https://github.com/WordPress/sqlite-database-integration/archive/refs/heads/develop.zip",
|
|
344
419
|
"sqlite.zip",
|
|
@@ -346,28 +421,28 @@ async function ut(e) {
|
|
|
346
421
|
);
|
|
347
422
|
}
|
|
348
423
|
async function pe(e, t, r) {
|
|
349
|
-
const s =
|
|
350
|
-
return B.existsSync(s) || (B.ensureDirSync(Q), await
|
|
424
|
+
const s = p.join(Q, t);
|
|
425
|
+
return B.existsSync(s) || (B.ensureDirSync(Q), await ft(e, s, r)), me(s);
|
|
351
426
|
}
|
|
352
|
-
async function
|
|
353
|
-
const o = (await r.monitorFetch(fetch(e))).body.getReader(),
|
|
427
|
+
async function ft(e, t, r) {
|
|
428
|
+
const o = (await r.monitorFetch(fetch(e))).body.getReader(), n = `${t}.partial`, i = B.createWriteStream(n);
|
|
354
429
|
for (; ; ) {
|
|
355
430
|
const { done: l, value: u } = await o.read();
|
|
356
|
-
if (u &&
|
|
431
|
+
if (u && i.write(u), l)
|
|
357
432
|
break;
|
|
358
433
|
}
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
B.renameSync(
|
|
362
|
-
}),
|
|
363
|
-
B.removeSync(
|
|
434
|
+
i.close(), i.closed || await new Promise((l, u) => {
|
|
435
|
+
i.on("finish", () => {
|
|
436
|
+
B.renameSync(n, t), l(null);
|
|
437
|
+
}), i.on("error", (v) => {
|
|
438
|
+
B.removeSync(n), u(v);
|
|
364
439
|
});
|
|
365
440
|
});
|
|
366
441
|
}
|
|
367
|
-
function
|
|
442
|
+
function me(e, t) {
|
|
368
443
|
return new File([B.readFileSync(e)], A(e));
|
|
369
444
|
}
|
|
370
|
-
class
|
|
445
|
+
class wt {
|
|
371
446
|
constructor(t, r) {
|
|
372
447
|
this.args = t, this.siteUrl = r.siteUrl, this.processIdSpaceLength = r.processIdSpaceLength, this.cliOutput = r.cliOutput;
|
|
373
448
|
}
|
|
@@ -375,51 +450,51 @@ class pt {
|
|
|
375
450
|
return "v1";
|
|
376
451
|
}
|
|
377
452
|
async bootAndSetUpInitialPlayground(t, r, s) {
|
|
378
|
-
let o,
|
|
379
|
-
const l = new
|
|
453
|
+
let o, n, i;
|
|
454
|
+
const l = new Ne();
|
|
380
455
|
if (this.args.wordpressInstallMode === "download-and-install") {
|
|
381
|
-
let
|
|
382
|
-
l.addEventListener("progress", (
|
|
383
|
-
if (
|
|
456
|
+
let k = !1;
|
|
457
|
+
l.addEventListener("progress", (I) => {
|
|
458
|
+
if (k)
|
|
384
459
|
return;
|
|
385
|
-
const { loaded:
|
|
386
|
-
Math.min(100, 100 *
|
|
460
|
+
const { loaded: L, total: Z } = I.detail, W = Math.floor(
|
|
461
|
+
Math.min(100, 100 * L / Z)
|
|
387
462
|
);
|
|
388
|
-
|
|
463
|
+
k = W === 100, this.cliOutput.updateProgress(
|
|
389
464
|
"Downloading WordPress",
|
|
390
|
-
|
|
465
|
+
W
|
|
391
466
|
);
|
|
392
|
-
}), o = await
|
|
467
|
+
}), o = await He(this.args.wp), i = p.join(
|
|
393
468
|
Q,
|
|
394
469
|
`prebuilt-wp-content-for-wp-${o.version}.zip`
|
|
395
|
-
),
|
|
470
|
+
), n = c.existsSync(i) ? me(i) : await pe(
|
|
396
471
|
o.releaseUrl,
|
|
397
472
|
`${o.version}.zip`,
|
|
398
473
|
l
|
|
399
|
-
),
|
|
474
|
+
), y.debug(
|
|
400
475
|
`Resolved WordPress release URL: ${o?.releaseUrl}`
|
|
401
476
|
);
|
|
402
477
|
}
|
|
403
478
|
let u;
|
|
404
|
-
this.args.skipSqliteSetup ? (
|
|
405
|
-
const
|
|
406
|
-
await
|
|
407
|
-
const
|
|
479
|
+
this.args.skipSqliteSetup ? (y.debug("Skipping SQLite integration plugin setup..."), u = void 0) : (this.cliOutput.updateProgress("Preparing SQLite database"), u = await ht(l));
|
|
480
|
+
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
|
+
await g.isConnected(), this.cliOutput.updateProgress("Booting WordPress");
|
|
482
|
+
const h = await oe(
|
|
408
483
|
this.getEffectiveBlueprint()
|
|
409
484
|
);
|
|
410
|
-
return await
|
|
411
|
-
phpVersion:
|
|
412
|
-
wpVersion:
|
|
485
|
+
return await g.useFileLockManager(r), await g.bootAndSetUpInitialWorker({
|
|
486
|
+
phpVersion: h.phpVersion,
|
|
487
|
+
wpVersion: h.wpVersion,
|
|
413
488
|
siteUrl: this.siteUrl,
|
|
414
|
-
mountsBeforeWpInstall:
|
|
415
|
-
mountsAfterWpInstall:
|
|
489
|
+
mountsBeforeWpInstall: w,
|
|
490
|
+
mountsAfterWpInstall: a,
|
|
416
491
|
wordpressInstallMode: this.args.wordpressInstallMode || "download-and-install",
|
|
417
|
-
wordPressZip:
|
|
492
|
+
wordPressZip: n && await n.arrayBuffer(),
|
|
418
493
|
sqliteIntegrationPluginZip: await u?.arrayBuffer(),
|
|
419
494
|
firstProcessId: 0,
|
|
420
495
|
processIdSpaceLength: this.processIdSpaceLength,
|
|
421
|
-
followSymlinks:
|
|
422
|
-
trace:
|
|
496
|
+
followSymlinks: v,
|
|
497
|
+
trace: P,
|
|
423
498
|
internalCookieStore: this.args.internalCookieStore,
|
|
424
499
|
withIntl: this.args.intl,
|
|
425
500
|
// We do not enable Xdebug by default for the initial worker
|
|
@@ -427,11 +502,12 @@ class pt {
|
|
|
427
502
|
// until Playground has fully booted.
|
|
428
503
|
// TODO: Consider supporting Xdebug for the initial worker via a dedicated flag.
|
|
429
504
|
withXdebug: !1,
|
|
430
|
-
nativeInternalDirPath: s
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
505
|
+
nativeInternalDirPath: s,
|
|
506
|
+
constants: O(this.args)
|
|
507
|
+
}), i && !this.args["mount-before-install"] && !c.existsSync(i) && (this.cliOutput.updateProgress("Caching WordPress for next boot"), c.writeFileSync(
|
|
508
|
+
i,
|
|
509
|
+
await $e(g, "/wordpress")
|
|
510
|
+
)), g;
|
|
435
511
|
}
|
|
436
512
|
async bootPlayground({
|
|
437
513
|
worker: t,
|
|
@@ -439,15 +515,15 @@ class pt {
|
|
|
439
515
|
firstProcessId: s,
|
|
440
516
|
nativeInternalDirPath: o
|
|
441
517
|
}) {
|
|
442
|
-
const
|
|
518
|
+
const n = U(
|
|
443
519
|
t.phpPort
|
|
444
520
|
);
|
|
445
|
-
await
|
|
446
|
-
const
|
|
521
|
+
await n.isConnected();
|
|
522
|
+
const i = await oe(
|
|
447
523
|
this.getEffectiveBlueprint()
|
|
448
524
|
);
|
|
449
|
-
return await
|
|
450
|
-
phpVersion:
|
|
525
|
+
return await n.useFileLockManager(r), await n.bootWorker({
|
|
526
|
+
phpVersion: i.phpVersion,
|
|
451
527
|
siteUrl: this.siteUrl,
|
|
452
528
|
mountsBeforeWpInstall: this.args["mount-before-install"] || [],
|
|
453
529
|
mountsAfterWpInstall: this.args.mount || [],
|
|
@@ -460,38 +536,39 @@ class pt {
|
|
|
460
536
|
internalCookieStore: this.args.internalCookieStore,
|
|
461
537
|
withIntl: this.args.intl,
|
|
462
538
|
withXdebug: !!this.args.xdebug,
|
|
463
|
-
nativeInternalDirPath: o
|
|
464
|
-
|
|
539
|
+
nativeInternalDirPath: o,
|
|
540
|
+
constants: O(this.args)
|
|
541
|
+
}), await n.isReady(), n;
|
|
465
542
|
}
|
|
466
543
|
async compileInputBlueprint(t) {
|
|
467
|
-
const r = this.getEffectiveBlueprint(), s = new
|
|
468
|
-
let o = "",
|
|
469
|
-
return s.addEventListener("progress", (
|
|
470
|
-
if (
|
|
544
|
+
const r = this.getEffectiveBlueprint(), s = new _e();
|
|
545
|
+
let o = "", n = !1;
|
|
546
|
+
return s.addEventListener("progress", (i) => {
|
|
547
|
+
if (n)
|
|
471
548
|
return;
|
|
472
|
-
|
|
473
|
-
const l = Math.floor(
|
|
474
|
-
o =
|
|
475
|
-
}), await
|
|
549
|
+
n = i.detail.progress === 100;
|
|
550
|
+
const l = Math.floor(i.detail.progress);
|
|
551
|
+
o = i.detail.caption || o || "Running Blueprint", this.cliOutput.updateProgress(o.trim(), l);
|
|
552
|
+
}), await xe(r, {
|
|
476
553
|
progress: s,
|
|
477
554
|
additionalSteps: t
|
|
478
555
|
});
|
|
479
556
|
}
|
|
480
557
|
getEffectiveBlueprint() {
|
|
481
558
|
const t = this.args.blueprint;
|
|
482
|
-
return
|
|
559
|
+
return ke(t) ? t : {
|
|
483
560
|
login: this.args.login,
|
|
484
561
|
...t || {},
|
|
485
562
|
preferredVersions: {
|
|
486
|
-
php: this.args.php ?? t?.preferredVersions?.php ??
|
|
563
|
+
php: this.args.php ?? t?.preferredVersions?.php ?? F,
|
|
487
564
|
wp: this.args.wp ?? t?.preferredVersions?.wp ?? "latest",
|
|
488
565
|
...t?.preferredVersions || {}
|
|
489
566
|
}
|
|
490
567
|
};
|
|
491
568
|
}
|
|
492
569
|
}
|
|
493
|
-
async function
|
|
494
|
-
const s = `${
|
|
570
|
+
async function gt(e, t = !0) {
|
|
571
|
+
const s = `${p.basename(process.argv0)}${e}${process.pid}-`, o = await qe({
|
|
495
572
|
prefix: s,
|
|
496
573
|
/*
|
|
497
574
|
* Allow recursive cleanup on process exit.
|
|
@@ -503,83 +580,83 @@ async function ct(e, t = !0) {
|
|
|
503
580
|
*/
|
|
504
581
|
unsafeCleanup: !0
|
|
505
582
|
});
|
|
506
|
-
return t &&
|
|
583
|
+
return t && Ye(), o;
|
|
507
584
|
}
|
|
508
|
-
async function
|
|
509
|
-
const o = (await
|
|
585
|
+
async function yt(e, t, r) {
|
|
586
|
+
const o = (await bt(
|
|
510
587
|
e,
|
|
511
588
|
t,
|
|
512
589
|
r
|
|
513
590
|
)).map(
|
|
514
|
-
(
|
|
515
|
-
|
|
516
|
-
l ?
|
|
517
|
-
`Failed to delete stale Playground temp dir: ${
|
|
591
|
+
(n) => new Promise((i) => {
|
|
592
|
+
c.rm(n, { recursive: !0 }, (l) => {
|
|
593
|
+
l ? y.warn(
|
|
594
|
+
`Failed to delete stale Playground temp dir: ${n}`,
|
|
518
595
|
l
|
|
519
|
-
) :
|
|
520
|
-
`Deleted stale Playground temp dir: ${
|
|
521
|
-
),
|
|
596
|
+
) : y.info(
|
|
597
|
+
`Deleted stale Playground temp dir: ${n}`
|
|
598
|
+
), i();
|
|
522
599
|
});
|
|
523
600
|
})
|
|
524
601
|
);
|
|
525
602
|
await Promise.all(o);
|
|
526
603
|
}
|
|
527
|
-
async function
|
|
604
|
+
async function bt(e, t, r) {
|
|
528
605
|
try {
|
|
529
|
-
const s =
|
|
530
|
-
for (const
|
|
531
|
-
await
|
|
606
|
+
const s = c.readdirSync(r).map((n) => p.join(r, n)), o = [];
|
|
607
|
+
for (const n of s)
|
|
608
|
+
await vt(
|
|
532
609
|
e,
|
|
533
610
|
t,
|
|
534
|
-
|
|
535
|
-
) && o.push(
|
|
611
|
+
n
|
|
612
|
+
) && o.push(n);
|
|
536
613
|
return o;
|
|
537
614
|
} catch (s) {
|
|
538
|
-
return
|
|
615
|
+
return y.warn(`Failed to find stale Playground temp dirs: ${s}`), [];
|
|
539
616
|
}
|
|
540
617
|
}
|
|
541
|
-
async function
|
|
542
|
-
if (!
|
|
618
|
+
async function vt(e, t, r) {
|
|
619
|
+
if (!c.lstatSync(r).isDirectory())
|
|
543
620
|
return !1;
|
|
544
|
-
const o =
|
|
621
|
+
const o = p.basename(r);
|
|
545
622
|
if (!o.includes(e))
|
|
546
623
|
return !1;
|
|
547
|
-
const
|
|
624
|
+
const n = o.match(
|
|
548
625
|
new RegExp(`^(.+)${e}(\\d+)-`)
|
|
549
626
|
);
|
|
550
|
-
if (!
|
|
627
|
+
if (!n)
|
|
551
628
|
return !1;
|
|
552
|
-
const
|
|
553
|
-
executableName:
|
|
554
|
-
pid:
|
|
629
|
+
const i = {
|
|
630
|
+
executableName: n[1],
|
|
631
|
+
pid: n[2]
|
|
555
632
|
};
|
|
556
|
-
if (await
|
|
633
|
+
if (await Pt(i.pid, i.executableName))
|
|
557
634
|
return !1;
|
|
558
635
|
const l = Date.now() - t;
|
|
559
|
-
return
|
|
636
|
+
return c.statSync(r).mtime.getTime() < l;
|
|
560
637
|
}
|
|
561
|
-
async function
|
|
638
|
+
async function Pt(e, t) {
|
|
562
639
|
const [r] = await new Promise(
|
|
563
640
|
(s, o) => {
|
|
564
|
-
|
|
641
|
+
ze.list(
|
|
565
642
|
{
|
|
566
643
|
pid: e,
|
|
567
644
|
name: t,
|
|
568
645
|
// Remove path from executable name in the results.
|
|
569
646
|
clean: !0
|
|
570
647
|
},
|
|
571
|
-
(
|
|
572
|
-
|
|
648
|
+
(n, i) => {
|
|
649
|
+
n ? o(n) : s(i);
|
|
573
650
|
}
|
|
574
651
|
);
|
|
575
652
|
}
|
|
576
653
|
);
|
|
577
654
|
return !!r && r.pid === e && r.command === t;
|
|
578
655
|
}
|
|
579
|
-
function
|
|
656
|
+
function St(e) {
|
|
580
657
|
return process.env.CI === "true" || process.env.CI === "1" || process.env.GITHUB_ACTIONS === "true" || process.env.GITHUB_ACTIONS === "1" || (process.env.TERM || "").toLowerCase() === "dumb" ? !1 : e ? !!e.isTTY : process.stdout.isTTY;
|
|
581
658
|
}
|
|
582
|
-
class
|
|
659
|
+
class xt {
|
|
583
660
|
constructor(t) {
|
|
584
661
|
this.lastProgressLine = "", this.progressActive = !1, this.verbosity = t.verbosity, this.writeStream = t.writeStream || process.stdout;
|
|
585
662
|
}
|
|
@@ -593,7 +670,7 @@ class yt {
|
|
|
593
670
|
* This prevents progress spam in logs - users only see the final outcome.
|
|
594
671
|
*/
|
|
595
672
|
get shouldRender() {
|
|
596
|
-
return
|
|
673
|
+
return St(this.writeStream);
|
|
597
674
|
}
|
|
598
675
|
get isQuiet() {
|
|
599
676
|
return this.verbosity === "quiet";
|
|
@@ -647,9 +724,9 @@ ${t}
|
|
|
647
724
|
const s = [];
|
|
648
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)
|
|
649
726
|
for (const o of t.mounts) {
|
|
650
|
-
const
|
|
727
|
+
const n = o.autoMounted ? ` ${this.dim("(auto-mount)")}` : "";
|
|
651
728
|
r.push(
|
|
652
|
-
`${this.dim("Mount")} ${o.hostPath} ${this.dim("→")} ${o.vfsPath}${
|
|
729
|
+
`${this.dim("Mount")} ${o.hostPath} ${this.dim("→")} ${o.vfsPath}${n}`
|
|
653
730
|
);
|
|
654
731
|
}
|
|
655
732
|
t.blueprint && r.push(`${this.dim("Blueprint")} ${t.blueprint}`), this.writeStream.write(r.join(`
|
|
@@ -737,7 +814,7 @@ const he = {
|
|
|
737
814
|
Normal: { name: "normal", severity: j.Info },
|
|
738
815
|
Debug: { name: "debug", severity: j.Debug }
|
|
739
816
|
};
|
|
740
|
-
async function
|
|
817
|
+
async function or(e) {
|
|
741
818
|
try {
|
|
742
819
|
const t = {
|
|
743
820
|
"site-url": {
|
|
@@ -747,41 +824,62 @@ async function Jt(e) {
|
|
|
747
824
|
php: {
|
|
748
825
|
describe: "PHP version to use.",
|
|
749
826
|
type: "string",
|
|
750
|
-
default:
|
|
751
|
-
choices:
|
|
827
|
+
default: F,
|
|
828
|
+
choices: re
|
|
752
829
|
},
|
|
753
830
|
wp: {
|
|
754
831
|
describe: "WordPress version to use.",
|
|
755
832
|
type: "string",
|
|
756
833
|
default: "latest"
|
|
757
834
|
},
|
|
835
|
+
define: {
|
|
836
|
+
describe: 'Define PHP string constants (can be used multiple times). Format: NAME value. These constants are set via php.defineConstant() and only exist for the current request. Examples: --define API_KEY secret --define CON=ST "va=lu=e"',
|
|
837
|
+
type: "string",
|
|
838
|
+
nargs: 2,
|
|
839
|
+
array: !0,
|
|
840
|
+
coerce: ot
|
|
841
|
+
},
|
|
842
|
+
"define-bool": {
|
|
843
|
+
describe: 'Define PHP boolean constants (can be used multiple times). Format: NAME value. Value must be "true", "false", "1", or "0". Examples: --define-bool WP_DEBUG true --define-bool MY_FEATURE false',
|
|
844
|
+
type: "string",
|
|
845
|
+
nargs: 2,
|
|
846
|
+
array: !0,
|
|
847
|
+
coerce: st
|
|
848
|
+
},
|
|
849
|
+
"define-number": {
|
|
850
|
+
describe: "Define PHP number constants (can be used multiple times). Format: NAME value. Examples: --define-number LIMIT 100 --define-number RATE 45.67",
|
|
851
|
+
type: "string",
|
|
852
|
+
nargs: 2,
|
|
853
|
+
array: !0,
|
|
854
|
+
coerce: nt
|
|
855
|
+
},
|
|
758
856
|
// @TODO: Support read-only mounts, e.g. via WORKERFS, a custom
|
|
759
857
|
// ReadOnlyNODEFS, or by copying the files into MEMFS
|
|
760
858
|
mount: {
|
|
761
859
|
describe: "Mount a directory to the PHP runtime (can be used multiple times). Format: /host/path:/vfs/path",
|
|
762
860
|
type: "array",
|
|
763
861
|
string: !0,
|
|
764
|
-
coerce:
|
|
862
|
+
coerce: q
|
|
765
863
|
},
|
|
766
864
|
"mount-before-install": {
|
|
767
865
|
describe: "Mount a directory to the PHP runtime before WordPress installation (can be used multiple times). Format: /host/path:/vfs/path",
|
|
768
866
|
type: "array",
|
|
769
867
|
string: !0,
|
|
770
|
-
coerce:
|
|
868
|
+
coerce: q
|
|
771
869
|
},
|
|
772
870
|
"mount-dir": {
|
|
773
871
|
describe: 'Mount a directory to the PHP runtime (can be used multiple times). Format: "/host/path" "/vfs/path"',
|
|
774
872
|
type: "array",
|
|
775
873
|
nargs: 2,
|
|
776
874
|
array: !0,
|
|
777
|
-
coerce:
|
|
875
|
+
coerce: ne
|
|
778
876
|
},
|
|
779
877
|
"mount-dir-before-install": {
|
|
780
878
|
describe: 'Mount a directory before WordPress installation (can be used multiple times). Format: "/host/path" "/vfs/path"',
|
|
781
879
|
type: "string",
|
|
782
880
|
nargs: 2,
|
|
783
881
|
array: !0,
|
|
784
|
-
coerce:
|
|
882
|
+
coerce: ne
|
|
785
883
|
},
|
|
786
884
|
login: {
|
|
787
885
|
describe: "Should log the user in",
|
|
@@ -904,7 +1002,7 @@ Warning: Following symlinks will expose files outside mounted directories to Pla
|
|
|
904
1002
|
"experimental-multi-worker": {
|
|
905
1003
|
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.",
|
|
906
1004
|
type: "number",
|
|
907
|
-
coerce: (a) => a ??
|
|
1005
|
+
coerce: (a) => a ?? Me().length - 1
|
|
908
1006
|
},
|
|
909
1007
|
"experimental-devtools": {
|
|
910
1008
|
describe: "Enable experimental browser development tools.",
|
|
@@ -919,8 +1017,8 @@ Warning: Following symlinks will expose files outside mounted directories to Pla
|
|
|
919
1017
|
php: {
|
|
920
1018
|
describe: "PHP version to use.",
|
|
921
1019
|
type: "string",
|
|
922
|
-
default:
|
|
923
|
-
choices:
|
|
1020
|
+
default: F,
|
|
1021
|
+
choices: re
|
|
924
1022
|
},
|
|
925
1023
|
wp: {
|
|
926
1024
|
describe: "WordPress version to use.",
|
|
@@ -966,7 +1064,7 @@ Warning: Following symlinks will expose files outside mounted directories to Pla
|
|
|
966
1064
|
describe: "Mount a directory to the PHP runtime (can be used multiple times). Format: /host/path:/vfs/path. Use this for additional mounts beyond auto-detection.",
|
|
967
1065
|
type: "array",
|
|
968
1066
|
string: !0,
|
|
969
|
-
coerce:
|
|
1067
|
+
coerce: q
|
|
970
1068
|
},
|
|
971
1069
|
reset: {
|
|
972
1070
|
describe: "Deletes the stored site directory and starts a new site from scratch.",
|
|
@@ -977,14 +1075,18 @@ Warning: Following symlinks will expose files outside mounted directories to Pla
|
|
|
977
1075
|
describe: "Disable automatic project type detection. Use --mount to manually specify mounts instead.",
|
|
978
1076
|
type: "boolean",
|
|
979
1077
|
default: !1
|
|
980
|
-
}
|
|
1078
|
+
},
|
|
1079
|
+
// Define constants
|
|
1080
|
+
define: t.define,
|
|
1081
|
+
"define-bool": t["define-bool"],
|
|
1082
|
+
"define-number": t["define-number"]
|
|
981
1083
|
}, o = {
|
|
982
1084
|
outfile: {
|
|
983
1085
|
describe: "When building, write to this output file.",
|
|
984
1086
|
type: "string",
|
|
985
1087
|
default: "wordpress.zip"
|
|
986
1088
|
}
|
|
987
|
-
},
|
|
1089
|
+
}, n = Re(e).usage("Usage: wp-playground <command> [options]").command(
|
|
988
1090
|
"start",
|
|
989
1091
|
"Start a local WordPress server with automatic project detection (recommended)",
|
|
990
1092
|
(a) => a.usage(
|
|
@@ -1022,13 +1124,13 @@ Examples:
|
|
|
1022
1124
|
).demandCommand(1, "Please specify a command").strictCommands().conflicts(
|
|
1023
1125
|
"experimental-unsafe-ide-integration",
|
|
1024
1126
|
"experimental-devtools"
|
|
1025
|
-
).showHelpOnFail(!1).fail((a,
|
|
1026
|
-
if (
|
|
1027
|
-
throw
|
|
1028
|
-
a && a.includes("Please specify a command") && (
|
|
1127
|
+
).showHelpOnFail(!1).fail((a, g, h) => {
|
|
1128
|
+
if (g)
|
|
1129
|
+
throw g;
|
|
1130
|
+
a && a.includes("Please specify a command") && (h.showHelp(), console.error(`
|
|
1029
1131
|
` + a), process.exit(1)), console.error(a), process.exit(1);
|
|
1030
1132
|
}).strictOptions().check(async (a) => {
|
|
1031
|
-
if (a["skip-wordpress-install"] === !0 && (a["wordpress-install-mode"] = "do-not-attempt-installing", a.wordpressInstallMode = "do-not-attempt-installing"), a.wp !== void 0 && typeof a.wp == "string" && !
|
|
1133
|
+
if (a["skip-wordpress-install"] === !0 && (a["wordpress-install-mode"] = "do-not-attempt-installing", a.wordpressInstallMode = "do-not-attempt-installing"), a.wp !== void 0 && typeof a.wp == "string" && !ct(a.wp))
|
|
1032
1134
|
try {
|
|
1033
1135
|
new URL(a.wp);
|
|
1034
1136
|
} catch {
|
|
@@ -1036,25 +1138,25 @@ Examples:
|
|
|
1036
1138
|
'Unrecognized WordPress version. Please use "latest", a URL, or a numeric version such as "6.2", "6.0.1", "6.2-beta1", or "6.2-RC1"'
|
|
1037
1139
|
);
|
|
1038
1140
|
}
|
|
1039
|
-
const
|
|
1040
|
-
if (typeof
|
|
1141
|
+
const g = a["site-url"];
|
|
1142
|
+
if (typeof g == "string" && g.trim() !== "")
|
|
1041
1143
|
try {
|
|
1042
|
-
new URL(
|
|
1144
|
+
new URL(g);
|
|
1043
1145
|
} catch {
|
|
1044
1146
|
throw new Error(
|
|
1045
|
-
`Invalid site-url "${
|
|
1147
|
+
`Invalid site-url "${g}". Please provide a valid URL (e.g., http://localhost:8080 or https://example.com)`
|
|
1046
1148
|
);
|
|
1047
1149
|
}
|
|
1048
1150
|
if (a["auto-mount"]) {
|
|
1049
|
-
let
|
|
1151
|
+
let h = !1;
|
|
1050
1152
|
try {
|
|
1051
|
-
|
|
1153
|
+
h = c.statSync(
|
|
1052
1154
|
a["auto-mount"]
|
|
1053
1155
|
).isDirectory();
|
|
1054
1156
|
} catch {
|
|
1055
|
-
|
|
1157
|
+
h = !1;
|
|
1056
1158
|
}
|
|
1057
|
-
if (!
|
|
1159
|
+
if (!h)
|
|
1058
1160
|
throw new Error(
|
|
1059
1161
|
`The specified --auto-mount path is not a directory: '${a["auto-mount"]}'.`
|
|
1060
1162
|
);
|
|
@@ -1085,44 +1187,47 @@ Examples:
|
|
|
1085
1187
|
);
|
|
1086
1188
|
} else
|
|
1087
1189
|
a["wordpress-install-mode"] === "do-not-attempt-installing" ? a.mode = "apply-to-existing-site" : a.mode = "create-new-site";
|
|
1088
|
-
const
|
|
1089
|
-
a.followSymlinks === !0 &&
|
|
1190
|
+
const h = a.allow || [];
|
|
1191
|
+
a.followSymlinks === !0 && h.push("follow-symlinks"), a["blueprint-may-read-adjacent-files"] === !0 && h.push("read-local-fs"), a.allow = h;
|
|
1090
1192
|
} else if (a.mode !== void 0)
|
|
1091
1193
|
throw new Error(
|
|
1092
1194
|
"The --mode option requires the --experimentalBlueprintsV2Runner flag."
|
|
1093
1195
|
);
|
|
1094
1196
|
return !0;
|
|
1095
1197
|
});
|
|
1096
|
-
|
|
1097
|
-
const
|
|
1198
|
+
n.wrap(n.terminalWidth());
|
|
1199
|
+
const i = await n.argv, l = i._[0];
|
|
1098
1200
|
["start", "run-blueprint", "server", "build-snapshot"].includes(
|
|
1099
1201
|
l
|
|
1100
|
-
) || (
|
|
1101
|
-
const u = {
|
|
1102
|
-
|
|
1202
|
+
) || (n.showHelp(), process.exit(1));
|
|
1203
|
+
const u = i.define || {};
|
|
1204
|
+
!("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
|
+
const v = {
|
|
1206
|
+
...i,
|
|
1207
|
+
define: u,
|
|
1103
1208
|
command: l,
|
|
1104
1209
|
mount: [
|
|
1105
|
-
...
|
|
1106
|
-
...
|
|
1210
|
+
...i.mount || [],
|
|
1211
|
+
...i["mount-dir"] || []
|
|
1107
1212
|
],
|
|
1108
1213
|
"mount-before-install": [
|
|
1109
|
-
...
|
|
1110
|
-
...
|
|
1214
|
+
...i["mount-before-install"] || [],
|
|
1215
|
+
...i["mount-dir-before-install"] || []
|
|
1111
1216
|
]
|
|
1112
|
-
},
|
|
1113
|
-
|
|
1114
|
-
const
|
|
1217
|
+
}, P = await Et(v);
|
|
1218
|
+
P === void 0 && process.exit(0);
|
|
1219
|
+
const w = /* @__PURE__ */ (() => {
|
|
1115
1220
|
let a;
|
|
1116
1221
|
return async () => {
|
|
1117
|
-
a !== void 0 && (a =
|
|
1222
|
+
a !== void 0 && (a = P[Symbol.asyncDispose]()), await a, process.exit(0);
|
|
1118
1223
|
};
|
|
1119
1224
|
})();
|
|
1120
|
-
process.on("SIGINT",
|
|
1225
|
+
process.on("SIGINT", w), process.on("SIGTERM", w);
|
|
1121
1226
|
} catch (t) {
|
|
1122
1227
|
if (console.error(t), !(t instanceof Error))
|
|
1123
1228
|
throw t;
|
|
1124
1229
|
if (process.argv.includes("--debug"))
|
|
1125
|
-
|
|
1230
|
+
be(t);
|
|
1126
1231
|
else {
|
|
1127
1232
|
const s = [];
|
|
1128
1233
|
let o = t;
|
|
@@ -1136,27 +1241,27 @@ Examples:
|
|
|
1136
1241
|
process.exit(1);
|
|
1137
1242
|
}
|
|
1138
1243
|
}
|
|
1139
|
-
function
|
|
1244
|
+
function ae(e, t) {
|
|
1140
1245
|
return e.find(
|
|
1141
1246
|
(r) => r.vfsPath.replace(/\/$/, "") === t.replace(/\/$/, "")
|
|
1142
1247
|
);
|
|
1143
1248
|
}
|
|
1144
|
-
const
|
|
1145
|
-
async function
|
|
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, le = (e) => process.stdout.isTTY ? `\x1B[33m${e}\x1B[0m` : e;
|
|
1250
|
+
async function Et(e) {
|
|
1146
1251
|
let t, r;
|
|
1147
1252
|
const s = /* @__PURE__ */ new Map();
|
|
1148
|
-
if (e.command === "start" && (e =
|
|
1149
|
-
const
|
|
1150
|
-
(
|
|
1253
|
+
if (e.command === "start" && (e = Tt(e)), e.autoMount !== void 0 && (e.autoMount === "" && (e = { ...e, autoMount: process.cwd() }), e = ce(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) {
|
|
1254
|
+
const w = Object.values(he).find(
|
|
1255
|
+
(a) => a.name === e.verbosity
|
|
1151
1256
|
).severity;
|
|
1152
|
-
|
|
1257
|
+
y.setSeverityFilterLevel(w);
|
|
1153
1258
|
}
|
|
1154
1259
|
e.intl || (e.intl = !0);
|
|
1155
|
-
const o = new
|
|
1260
|
+
const o = new xt({
|
|
1156
1261
|
verbosity: e.verbosity || "normal"
|
|
1157
1262
|
});
|
|
1158
1263
|
e.command === "server" && (o.printBanner(), o.printConfig({
|
|
1159
|
-
phpVersion: e.php ||
|
|
1264
|
+
phpVersion: e.php || F,
|
|
1160
1265
|
wpVersion: e.wp || "latest",
|
|
1161
1266
|
port: e.port || 9400,
|
|
1162
1267
|
xdebug: !!e.xdebug,
|
|
@@ -1167,42 +1272,42 @@ async function St(e) {
|
|
|
1167
1272
|
],
|
|
1168
1273
|
blueprint: typeof e.blueprint == "string" ? e.blueprint : void 0
|
|
1169
1274
|
}));
|
|
1170
|
-
const
|
|
1275
|
+
const n = e.command === "server" ? e.port ?? 9400 : 0, i = N.platform() === "win32" ? (
|
|
1171
1276
|
// @TODO: Enable fs-ext here when it works with Windows.
|
|
1172
1277
|
void 0
|
|
1173
|
-
) : await import("fs-ext").then((
|
|
1174
|
-
|
|
1278
|
+
) : await import("fs-ext").then((w) => w.flockSync).catch(() => {
|
|
1279
|
+
y.debug(
|
|
1175
1280
|
"The fs-ext package is not installed. Internal file locking will not be integrated with host OS file locking."
|
|
1176
1281
|
);
|
|
1177
|
-
}), l = new Le(
|
|
1178
|
-
let u = !1,
|
|
1179
|
-
const
|
|
1180
|
-
port:
|
|
1181
|
-
onBind: async (
|
|
1182
|
-
const
|
|
1282
|
+
}), l = new Le(i);
|
|
1283
|
+
let u = !1, v = !0;
|
|
1284
|
+
const P = await at({
|
|
1285
|
+
port: n,
|
|
1286
|
+
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, L = e.command === "server" ? (
|
|
1183
1288
|
// Account for the initial worker which is discarded by the server after setup.
|
|
1184
|
-
|
|
1185
|
-
) :
|
|
1186
|
-
|
|
1187
|
-
),
|
|
1188
|
-
|
|
1189
|
-
const M = "WP Playground CLI - Listen for Xdebug",
|
|
1190
|
-
if (await
|
|
1289
|
+
I + 1
|
|
1290
|
+
) : I, W = 2 ** 31 - 1, C = Math.floor(
|
|
1291
|
+
W / L
|
|
1292
|
+
), J = "-playground-cli-site-", $ = await gt(J);
|
|
1293
|
+
y.debug(`Native temp dir for VFS root: ${$.path}`);
|
|
1294
|
+
const M = "WP Playground CLI - Listen for Xdebug", K = ".playground-xdebug-root", ee = p.join(process.cwd(), K);
|
|
1295
|
+
if (await Ge(ee), e.xdebug && e.experimentalUnsafeIdeIntegration) {
|
|
1191
1296
|
await Qe(
|
|
1192
|
-
|
|
1193
|
-
|
|
1297
|
+
$.path,
|
|
1298
|
+
ee,
|
|
1194
1299
|
process.platform
|
|
1195
1300
|
);
|
|
1196
1301
|
const d = {
|
|
1197
|
-
hostPath:
|
|
1302
|
+
hostPath: p.join(".", p.sep, K),
|
|
1198
1303
|
vfsPath: "/"
|
|
1199
1304
|
};
|
|
1200
1305
|
try {
|
|
1201
1306
|
await Xe(M, process.cwd());
|
|
1202
|
-
const
|
|
1307
|
+
const f = typeof e.xdebug == "object" ? e.xdebug : void 0, S = await Ze({
|
|
1203
1308
|
name: M,
|
|
1204
|
-
host:
|
|
1205
|
-
port:
|
|
1309
|
+
host: g,
|
|
1310
|
+
port: a,
|
|
1206
1311
|
ides: e.experimentalUnsafeIdeIntegration,
|
|
1207
1312
|
cwd: process.cwd(),
|
|
1208
1313
|
mounts: [
|
|
@@ -1210,19 +1315,19 @@ async function St(e) {
|
|
|
1210
1315
|
...e["mount-before-install"] || [],
|
|
1211
1316
|
...e.mount || []
|
|
1212
1317
|
],
|
|
1213
|
-
ideKey:
|
|
1214
|
-
}), m = e.experimentalUnsafeIdeIntegration,
|
|
1215
|
-
console.log(""),
|
|
1216
|
-
|
|
1318
|
+
ideKey: f?.ideKey
|
|
1319
|
+
}), m = e.experimentalUnsafeIdeIntegration, b = m.includes("vscode"), x = m.includes("phpstorm"), R = Object.values(S);
|
|
1320
|
+
console.log(""), R.length > 0 ? (console.log(T("Xdebug configured successfully")), console.log(
|
|
1321
|
+
le("Updated IDE config: ") + R.join(" ")
|
|
1217
1322
|
), console.log(
|
|
1218
|
-
|
|
1219
|
-
|
|
1323
|
+
le("Playground source root: ") + ".playground-xdebug-root" + Y(
|
|
1324
|
+
$t(
|
|
1220
1325
|
" – you can set breakpoints and preview Playground's VFS structure in there."
|
|
1221
1326
|
)
|
|
1222
1327
|
)
|
|
1223
1328
|
)) : (console.log(T("Xdebug configuration failed.")), console.log(
|
|
1224
1329
|
"No IDE-specific project settings directory was found in the current working directory."
|
|
1225
|
-
)), console.log(""),
|
|
1330
|
+
)), console.log(""), b && S.vscode && (console.log(T("VS Code / Cursor instructions:")), console.log(
|
|
1226
1331
|
" 1. Ensure you have installed an IDE extension for PHP Debugging"
|
|
1227
1332
|
), console.log(
|
|
1228
1333
|
` (The ${T("PHP Debug")} extension by ${T(
|
|
@@ -1231,15 +1336,15 @@ async function St(e) {
|
|
|
1231
1336
|
), console.log(
|
|
1232
1337
|
" 2. Open the Run and Debug panel on the left sidebar"
|
|
1233
1338
|
), console.log(
|
|
1234
|
-
` 3. Select "${
|
|
1339
|
+
` 3. Select "${Y(
|
|
1235
1340
|
M
|
|
1236
1341
|
)}" from the dropdown`
|
|
1237
1342
|
), console.log(' 3. Click "start debugging"'), console.log(
|
|
1238
1343
|
" 5. Set a breakpoint. For example, in .playground-xdebug-root/wordpress/index.php"
|
|
1239
1344
|
), console.log(
|
|
1240
1345
|
" 6. Visit Playground in your browser to hit the breakpoint"
|
|
1241
|
-
), x && console.log("")), x &&
|
|
1242
|
-
` 1. Choose "${
|
|
1346
|
+
), x && console.log("")), x && S.phpstorm && (console.log(T("PhpStorm instructions:")), console.log(
|
|
1347
|
+
` 1. Choose "${Y(
|
|
1243
1348
|
M
|
|
1244
1349
|
)}" debug configuration in the toolbar`
|
|
1245
1350
|
), console.log(" 2. Click the debug button (bug icon)`"), console.log(
|
|
@@ -1247,21 +1352,21 @@ async function St(e) {
|
|
|
1247
1352
|
), console.log(
|
|
1248
1353
|
" 4. Visit Playground in your browser to hit the breakpoint"
|
|
1249
1354
|
)), console.log("");
|
|
1250
|
-
} catch (
|
|
1355
|
+
} catch (f) {
|
|
1251
1356
|
throw new Error("Could not configure Xdebug", {
|
|
1252
|
-
cause:
|
|
1357
|
+
cause: f
|
|
1253
1358
|
});
|
|
1254
1359
|
}
|
|
1255
1360
|
}
|
|
1256
|
-
const
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1361
|
+
const fe = p.dirname($.path), we = 2 * 24 * 60 * 60 * 1e3;
|
|
1362
|
+
yt(
|
|
1363
|
+
J,
|
|
1364
|
+
we,
|
|
1365
|
+
fe
|
|
1261
1366
|
);
|
|
1262
|
-
const
|
|
1263
|
-
|
|
1264
|
-
const
|
|
1367
|
+
const _ = p.join($.path, "internal");
|
|
1368
|
+
G(_);
|
|
1369
|
+
const ge = [
|
|
1265
1370
|
"wordpress",
|
|
1266
1371
|
// Note: These dirs are from Emscripten's "default dirs" list:
|
|
1267
1372
|
// https://github.com/emscripten-core/emscripten/blob/f431ec220e472e1f8d3db6b52fe23fb377facf30/src/lib/libfs.js#L1400-L1402
|
|
@@ -1272,14 +1377,14 @@ async function St(e) {
|
|
|
1272
1377
|
"tmp",
|
|
1273
1378
|
"home"
|
|
1274
1379
|
];
|
|
1275
|
-
for (const d of
|
|
1276
|
-
const
|
|
1277
|
-
if (!(e["mount-before-install"]?.some(
|
|
1278
|
-
const m =
|
|
1279
|
-
|
|
1380
|
+
for (const d of ge) {
|
|
1381
|
+
const f = (m) => m.vfsPath === `/${d}`;
|
|
1382
|
+
if (!(e["mount-before-install"]?.some(f) || e.mount?.some(f))) {
|
|
1383
|
+
const m = p.join(
|
|
1384
|
+
$.path,
|
|
1280
1385
|
d
|
|
1281
1386
|
);
|
|
1282
|
-
|
|
1387
|
+
G(m), e["mount-before-install"] === void 0 && (e["mount-before-install"] = []), e["mount-before-install"].unshift({
|
|
1283
1388
|
vfsPath: `/${d}`,
|
|
1284
1389
|
hostPath: m
|
|
1285
1390
|
});
|
|
@@ -1287,144 +1392,144 @@ async function St(e) {
|
|
|
1287
1392
|
}
|
|
1288
1393
|
if (e["mount-before-install"])
|
|
1289
1394
|
for (const d of e["mount-before-install"])
|
|
1290
|
-
|
|
1395
|
+
y.debug(
|
|
1291
1396
|
`Mount before WP install: ${d.vfsPath} -> ${d.hostPath}`
|
|
1292
1397
|
);
|
|
1293
1398
|
if (e.mount)
|
|
1294
1399
|
for (const d of e.mount)
|
|
1295
|
-
|
|
1400
|
+
y.debug(
|
|
1296
1401
|
`Mount after WP install: ${d.vfsPath} -> ${d.hostPath}`
|
|
1297
1402
|
);
|
|
1298
|
-
let
|
|
1299
|
-
e["experimental-blueprints-v2-runner"] ?
|
|
1300
|
-
siteUrl:
|
|
1301
|
-
processIdSpaceLength:
|
|
1403
|
+
let E;
|
|
1404
|
+
e["experimental-blueprints-v2-runner"] ? E = new mt(e, {
|
|
1405
|
+
siteUrl: k,
|
|
1406
|
+
processIdSpaceLength: C,
|
|
1302
1407
|
cliOutput: o
|
|
1303
|
-
}) : (
|
|
1304
|
-
siteUrl:
|
|
1305
|
-
processIdSpaceLength:
|
|
1408
|
+
}) : (E = new wt(e, {
|
|
1409
|
+
siteUrl: k,
|
|
1410
|
+
processIdSpaceLength: C,
|
|
1306
1411
|
cliOutput: o
|
|
1307
|
-
}), typeof e.blueprint == "string" && (e.blueprint = await
|
|
1412
|
+
}), typeof e.blueprint == "string" && (e.blueprint = await pt({
|
|
1308
1413
|
sourceString: e.blueprint,
|
|
1309
1414
|
blueprintMayReadAdjacentFiles: e["blueprint-may-read-adjacent-files"] === !0
|
|
1310
1415
|
})));
|
|
1311
|
-
let
|
|
1312
|
-
const
|
|
1313
|
-
|
|
1416
|
+
let H = !1;
|
|
1417
|
+
const D = async function() {
|
|
1418
|
+
H || (H = !0, await Promise.all(
|
|
1314
1419
|
[...s].map(
|
|
1315
|
-
async ([
|
|
1316
|
-
await
|
|
1420
|
+
async ([f, S]) => {
|
|
1421
|
+
await S.dispose(), await f.terminate();
|
|
1317
1422
|
}
|
|
1318
1423
|
)
|
|
1319
|
-
),
|
|
1320
|
-
},
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
({ exitCode: d, workerIndex:
|
|
1324
|
-
|
|
1325
|
-
`Worker ${
|
|
1424
|
+
), w && await new Promise((f) => w.close(f)), await $.cleanup());
|
|
1425
|
+
}, ye = Bt(
|
|
1426
|
+
L,
|
|
1427
|
+
E.getWorkerType(),
|
|
1428
|
+
({ exitCode: d, workerIndex: f }) => {
|
|
1429
|
+
H || d === 0 && y.error(
|
|
1430
|
+
`Worker ${f} exited with code ${d}
|
|
1326
1431
|
`
|
|
1327
1432
|
);
|
|
1328
1433
|
}
|
|
1329
1434
|
);
|
|
1330
1435
|
o.startProgress("Starting...");
|
|
1331
1436
|
try {
|
|
1332
|
-
const d = await
|
|
1437
|
+
const d = await ye, f = await ue(l);
|
|
1333
1438
|
{
|
|
1334
|
-
const m = d.shift(),
|
|
1439
|
+
const m = d.shift(), b = await E.bootAndSetUpInitialPlayground(
|
|
1335
1440
|
m.phpPort,
|
|
1336
|
-
|
|
1337
|
-
|
|
1441
|
+
f,
|
|
1442
|
+
_
|
|
1338
1443
|
);
|
|
1339
1444
|
if (s.set(
|
|
1340
1445
|
m.worker,
|
|
1341
|
-
|
|
1342
|
-
), await
|
|
1343
|
-
const x = await
|
|
1446
|
+
b
|
|
1447
|
+
), await b.isReady(), u = !0, t = new dt(b), !e["experimental-blueprints-v2-runner"]) {
|
|
1448
|
+
const x = await E.compileInputBlueprint(
|
|
1344
1449
|
e["additional-blueprint-steps"] || []
|
|
1345
1450
|
);
|
|
1346
|
-
x && await
|
|
1451
|
+
x && await Ie(
|
|
1347
1452
|
x,
|
|
1348
|
-
|
|
1453
|
+
b
|
|
1349
1454
|
);
|
|
1350
1455
|
}
|
|
1351
1456
|
if (e.command === "build-snapshot") {
|
|
1352
|
-
await
|
|
1457
|
+
await Wt(r, e.outfile), o.printStatus(`Exported to ${e.outfile}`), await D();
|
|
1353
1458
|
return;
|
|
1354
1459
|
} else if (e.command === "run-blueprint") {
|
|
1355
|
-
o.finishProgress("Done"), await
|
|
1460
|
+
o.finishProgress("Done"), await D();
|
|
1356
1461
|
return;
|
|
1357
1462
|
}
|
|
1358
|
-
await t.removeWorker(
|
|
1463
|
+
await t.removeWorker(b), await b.dispose(), await m.worker.terminate(), s.delete(m.worker);
|
|
1359
1464
|
}
|
|
1360
|
-
const
|
|
1465
|
+
const S = C;
|
|
1361
1466
|
return [r] = await Promise.all(
|
|
1362
|
-
d.map(async (m,
|
|
1363
|
-
const x =
|
|
1467
|
+
d.map(async (m, b) => {
|
|
1468
|
+
const x = S + b * C, R = await ue(l), V = await E.bootPlayground({
|
|
1364
1469
|
worker: m,
|
|
1365
|
-
fileLockManagerPort:
|
|
1470
|
+
fileLockManagerPort: R,
|
|
1366
1471
|
firstProcessId: x,
|
|
1367
|
-
nativeInternalDirPath:
|
|
1472
|
+
nativeInternalDirPath: _
|
|
1368
1473
|
});
|
|
1369
1474
|
return s.set(
|
|
1370
1475
|
m.worker,
|
|
1371
|
-
|
|
1372
|
-
), t.addWorker(
|
|
1476
|
+
V
|
|
1477
|
+
), t.addWorker(V), V;
|
|
1373
1478
|
})
|
|
1374
|
-
), o.finishProgress(), o.printReady(
|
|
1479
|
+
), o.finishProgress(), o.printReady(h, I), e.xdebug && e.experimentalDevtools && (await Ve({
|
|
1375
1480
|
phpInstance: r,
|
|
1376
1481
|
phpRoot: "/wordpress"
|
|
1377
1482
|
})).start(), {
|
|
1378
1483
|
playground: r,
|
|
1379
|
-
server:
|
|
1380
|
-
serverUrl:
|
|
1381
|
-
[Symbol.asyncDispose]:
|
|
1382
|
-
[
|
|
1383
|
-
workerThreadCount:
|
|
1384
|
-
getWorkerNumberFromProcessId: (m) => Math.floor(m /
|
|
1484
|
+
server: w,
|
|
1485
|
+
serverUrl: h,
|
|
1486
|
+
[Symbol.asyncDispose]: D,
|
|
1487
|
+
[kt]: {
|
|
1488
|
+
workerThreadCount: I,
|
|
1489
|
+
getWorkerNumberFromProcessId: (m) => Math.floor(m / C)
|
|
1385
1490
|
}
|
|
1386
1491
|
};
|
|
1387
1492
|
} catch (d) {
|
|
1388
1493
|
if (e.verbosity !== "debug")
|
|
1389
1494
|
throw d;
|
|
1390
|
-
let
|
|
1391
|
-
throw await r?.fileExists(
|
|
1495
|
+
let f = "";
|
|
1496
|
+
throw await r?.fileExists(te) && (f = await r.readFileAsText(te)), await D(), new Error(f, { cause: d });
|
|
1392
1497
|
}
|
|
1393
1498
|
},
|
|
1394
|
-
async handleRequest(
|
|
1499
|
+
async handleRequest(w) {
|
|
1395
1500
|
if (!u)
|
|
1396
|
-
return
|
|
1501
|
+
return z.forHttpCode(
|
|
1397
1502
|
502,
|
|
1398
1503
|
"WordPress is not ready yet"
|
|
1399
1504
|
);
|
|
1400
|
-
if (
|
|
1401
|
-
|
|
1402
|
-
const
|
|
1505
|
+
if (v) {
|
|
1506
|
+
v = !1;
|
|
1507
|
+
const a = {
|
|
1403
1508
|
"Content-Type": ["text/plain"],
|
|
1404
1509
|
"Content-Length": ["0"],
|
|
1405
|
-
Location: [
|
|
1510
|
+
Location: [w.url]
|
|
1406
1511
|
};
|
|
1407
|
-
return
|
|
1512
|
+
return w.headers?.cookie?.includes(
|
|
1408
1513
|
"playground_auto_login_already_happened"
|
|
1409
|
-
) && (
|
|
1514
|
+
) && (a["Set-Cookie"] = [
|
|
1410
1515
|
"playground_auto_login_already_happened=1; Max-Age=0; Expires=Thu, 01 Jan 1970 00:00:00 GMT; Path=/"
|
|
1411
|
-
]), new
|
|
1516
|
+
]), new z(302, a, new Uint8Array());
|
|
1412
1517
|
}
|
|
1413
|
-
return await t.handleRequest(
|
|
1518
|
+
return await t.handleRequest(w);
|
|
1414
1519
|
}
|
|
1415
1520
|
});
|
|
1416
|
-
return
|
|
1521
|
+
return P && e.command === "start" && !e.skipBrowser && Lt(P.serverUrl), P;
|
|
1417
1522
|
}
|
|
1418
|
-
function
|
|
1523
|
+
function Tt(e) {
|
|
1419
1524
|
let t = { ...e, command: "server" };
|
|
1420
|
-
e.noAutoMount || (t.autoMount =
|
|
1421
|
-
const r =
|
|
1525
|
+
e.noAutoMount || (t.autoMount = p.resolve(process.cwd(), t.path ?? ""), t = ce(t), delete t.autoMount);
|
|
1526
|
+
const r = ae(
|
|
1422
1527
|
t["mount-before-install"] || [],
|
|
1423
1528
|
"/wordpress"
|
|
1424
|
-
) ||
|
|
1529
|
+
) || ae(t.mount || [], "/wordpress");
|
|
1425
1530
|
if (r)
|
|
1426
1531
|
console.log("Site files stored at:", r?.hostPath), e.reset && (console.log(""), console.log(
|
|
1427
|
-
|
|
1532
|
+
It(
|
|
1428
1533
|
"This site is not managed by Playground CLI and cannot be reset."
|
|
1429
1534
|
)
|
|
1430
1535
|
), console.log(
|
|
@@ -1433,15 +1538,15 @@ function xt(e) {
|
|
|
1433
1538
|
"You may still remove the site's directory manually if you wish."
|
|
1434
1539
|
), process.exit(1));
|
|
1435
1540
|
else {
|
|
1436
|
-
const s = t.autoMount || process.cwd(), o =
|
|
1437
|
-
|
|
1541
|
+
const s = t.autoMount || process.cwd(), o = Je("sha256").update(s).digest("hex"), n = N.homedir(), i = p.join(
|
|
1542
|
+
n,
|
|
1438
1543
|
".wordpress-playground/sites",
|
|
1439
1544
|
o
|
|
1440
1545
|
);
|
|
1441
|
-
console.log("Site files stored at:",
|
|
1546
|
+
console.log("Site files stored at:", i), X(i) && e.reset && (console.log("Resetting site..."), Ee(i, { recursive: !0 })), G(i, { recursive: !0 }), t["mount-before-install"] = [
|
|
1442
1547
|
...t["mount-before-install"] || [],
|
|
1443
|
-
{ vfsPath: "/wordpress", hostPath:
|
|
1444
|
-
], t.wordpressInstallMode = Te(
|
|
1548
|
+
{ vfsPath: "/wordpress", hostPath: i }
|
|
1549
|
+
], t.wordpressInstallMode = Te(i).length === 0 ? (
|
|
1445
1550
|
// Only download WordPress on the first run when the site directory is still
|
|
1446
1551
|
// empty.
|
|
1447
1552
|
"download-and-install"
|
|
@@ -1452,45 +1557,45 @@ function xt(e) {
|
|
|
1452
1557
|
}
|
|
1453
1558
|
return t;
|
|
1454
1559
|
}
|
|
1455
|
-
async function
|
|
1560
|
+
async function Bt(e, t, r) {
|
|
1456
1561
|
const s = [];
|
|
1457
1562
|
for (let o = 0; o < e; o++) {
|
|
1458
|
-
const
|
|
1563
|
+
const i = Ct(t, { onExit: (l) => {
|
|
1459
1564
|
r({
|
|
1460
1565
|
exitCode: l,
|
|
1461
1566
|
workerIndex: o
|
|
1462
1567
|
});
|
|
1463
1568
|
} });
|
|
1464
|
-
s.push(
|
|
1569
|
+
s.push(i);
|
|
1465
1570
|
}
|
|
1466
1571
|
return Promise.all(s);
|
|
1467
1572
|
}
|
|
1468
|
-
function
|
|
1573
|
+
function Ct(e, { onExit: t } = {}) {
|
|
1469
1574
|
let r;
|
|
1470
|
-
return e === "v1" ? r = new
|
|
1471
|
-
r.once("message", function(
|
|
1472
|
-
|
|
1473
|
-
}), r.once("error", function(
|
|
1474
|
-
console.error(
|
|
1575
|
+
return e === "v1" ? r = new se(new URL("./worker-thread-v1.js", import.meta.url)) : r = new se(new URL("./worker-thread-v2.js", import.meta.url)), new Promise((s, o) => {
|
|
1576
|
+
r.once("message", function(i) {
|
|
1577
|
+
i.command === "worker-script-initialized" && s({ worker: r, phpPort: i.phpPort });
|
|
1578
|
+
}), r.once("error", function(i) {
|
|
1579
|
+
console.error(i);
|
|
1475
1580
|
const l = new Error(
|
|
1476
|
-
`Worker failed to load worker. ${
|
|
1581
|
+
`Worker failed to load worker. ${i.message ? `Original error: ${i.message}` : ""}`
|
|
1477
1582
|
);
|
|
1478
1583
|
o(l);
|
|
1479
1584
|
});
|
|
1480
|
-
let
|
|
1585
|
+
let n = !1;
|
|
1481
1586
|
r.once("spawn", () => {
|
|
1482
|
-
|
|
1483
|
-
}), r.once("exit", (
|
|
1484
|
-
|
|
1587
|
+
n = !0;
|
|
1588
|
+
}), r.once("exit", (i) => {
|
|
1589
|
+
n || o(new Error(`Worker exited before spawning: ${i}`)), t?.(i);
|
|
1485
1590
|
});
|
|
1486
1591
|
});
|
|
1487
1592
|
}
|
|
1488
|
-
async function
|
|
1593
|
+
async function ue(e) {
|
|
1489
1594
|
const { port1: t, port2: r } = new Be();
|
|
1490
|
-
return await
|
|
1595
|
+
return await De() ? ve(e, null, t) : await Pe(e, t), r;
|
|
1491
1596
|
}
|
|
1492
|
-
function
|
|
1493
|
-
const t =
|
|
1597
|
+
function Lt(e) {
|
|
1598
|
+
const t = N.platform();
|
|
1494
1599
|
let r;
|
|
1495
1600
|
switch (t) {
|
|
1496
1601
|
case "darwin":
|
|
@@ -1504,10 +1609,10 @@ function $t(e) {
|
|
|
1504
1609
|
break;
|
|
1505
1610
|
}
|
|
1506
1611
|
je(r, (s) => {
|
|
1507
|
-
s &&
|
|
1612
|
+
s && y.debug(`Could not open browser: ${s.message}`);
|
|
1508
1613
|
});
|
|
1509
1614
|
}
|
|
1510
|
-
async function
|
|
1615
|
+
async function Wt(e, t) {
|
|
1511
1616
|
await e.run({
|
|
1512
1617
|
code: `<?php
|
|
1513
1618
|
$zip = new ZipArchive();
|
|
@@ -1529,15 +1634,16 @@ async function Tt(e, t) {
|
|
|
1529
1634
|
`
|
|
1530
1635
|
});
|
|
1531
1636
|
const r = await e.readFileAsBuffer("/tmp/build.zip");
|
|
1532
|
-
|
|
1637
|
+
c.writeFileSync(t, r);
|
|
1533
1638
|
}
|
|
1534
1639
|
export {
|
|
1535
1640
|
he as L,
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1641
|
+
rr as a,
|
|
1642
|
+
St as b,
|
|
1643
|
+
kt as i,
|
|
1644
|
+
O as m,
|
|
1645
|
+
or as p,
|
|
1646
|
+
Et as r,
|
|
1647
|
+
Ct as s
|
|
1542
1648
|
};
|
|
1543
|
-
//# sourceMappingURL=run-cli-
|
|
1649
|
+
//# sourceMappingURL=run-cli-DOpShCrT.js.map
|