@wp-playground/cli 3.1.1 → 3.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cli.cjs +1 -1
- package/cli.js +1 -1
- package/index.cjs +1 -1
- package/index.js +1 -1
- package/package.json +14 -14
- package/{run-cli-FHDubnX7.js → run-cli-C8e0UxH1.js} +393 -380
- package/run-cli-C8e0UxH1.js.map +1 -0
- package/{run-cli-D-GS-Yv7.cjs → run-cli-DoRePwjp.cjs} +11 -11
- package/run-cli-DoRePwjp.cjs.map +1 -0
- package/start-server.d.ts +5 -2
- package/worker-thread-v1.cjs +1 -1
- package/worker-thread-v1.js +1 -1
- package/worker-thread-v2.cjs +1 -1
- package/worker-thread-v2.js +1 -1
- package/run-cli-D-GS-Yv7.cjs.map +0 -1
- package/run-cli-FHDubnX7.js.map +0 -1
|
@@ -1,30 +1,32 @@
|
|
|
1
|
-
import { logger as g, LogSeverity as L, errorLogPath as
|
|
2
|
-
import {
|
|
3
|
-
import { resolveRemoteBlueprint as
|
|
4
|
-
import { zipDirectory as
|
|
5
|
-
import c, { existsSync as
|
|
1
|
+
import { logger as g, LogSeverity as L, errorLogPath as G } from "@php-wasm/logger";
|
|
2
|
+
import { consumeAPI as ne, SupportedPHPVersions as Q, printDebugDetails as be, HttpCookieStore as ge, FileLockManagerInMemory as Pe, StreamedPHPResponse as X, createObjectPoolProxy as ve, exposeAPI as Se, PHPResponse as xe, exposeSyncAPI as Ie } from "@php-wasm/universal";
|
|
3
|
+
import { resolveRemoteBlueprint as $e, resolveRuntimeConfiguration as Z, compileBlueprintV1 as ae, isBlueprintBundle as Te, runBlueprintV1Steps as J } from "@wp-playground/blueprints";
|
|
4
|
+
import { zipDirectory as Ee, RecommendedPHPVersion as C } from "@wp-playground/common";
|
|
5
|
+
import c, { existsSync as O, rmdirSync as ke, mkdirSync as _, readdirSync as Me } from "fs";
|
|
6
6
|
import { MessageChannel as le, Worker as K } from "worker_threads";
|
|
7
|
-
import { createNodeFsMountHandler as
|
|
7
|
+
import { createNodeFsMountHandler as Be } from "@php-wasm/node";
|
|
8
8
|
import u, { basename as A, join as de } from "path";
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
import {
|
|
13
|
-
import
|
|
14
|
-
import {
|
|
9
|
+
import Ae from "express";
|
|
10
|
+
import { Readable as Ce } from "stream";
|
|
11
|
+
import { pipeline as De } from "stream/promises";
|
|
12
|
+
import j, { cpus as Re } from "os";
|
|
13
|
+
import We from "yargs";
|
|
14
|
+
import { NodeJsFilesystem as Le, OverlayFilesystem as Ue, InMemoryFilesystem as Fe, ZipFilesystem as He } from "@wp-playground/storage";
|
|
15
|
+
import { EmscriptenDownloadMonitor as _e, ProgressTracker as Ne } from "@php-wasm/progress";
|
|
16
|
+
import { resolveWordPressRelease as Oe } from "@wp-playground/wordpress";
|
|
15
17
|
import I from "fs-extra";
|
|
16
|
-
import { createRequire as
|
|
17
|
-
import { startBridge as
|
|
18
|
-
import { exec as
|
|
19
|
-
import { dir as
|
|
20
|
-
import
|
|
21
|
-
import { removeTempDirSymlink as
|
|
22
|
-
import { createHash as
|
|
23
|
-
import { PHPMYADMIN_INSTALL_PATH as ee, getPhpMyAdminInstallSteps as
|
|
18
|
+
import { createRequire as je } from "module";
|
|
19
|
+
import { startBridge as Ve } from "@php-wasm/xdebug-bridge";
|
|
20
|
+
import { exec as Ye } from "child_process";
|
|
21
|
+
import { dir as qe, setGracefulCleanup as ze } from "tmp-promise";
|
|
22
|
+
import Ge from "ps-man";
|
|
23
|
+
import { removeTempDirSymlink as Qe, createTempDirSymlink as Xe, clearXdebugIDEConfig as Ze, addXdebugIDEConfig as Je } from "@php-wasm/cli-util";
|
|
24
|
+
import { createHash as Ke } from "crypto";
|
|
25
|
+
import { PHPMYADMIN_INSTALL_PATH as ee, getPhpMyAdminInstallSteps as et, PHPMYADMIN_ENTRY_PATH as tt } from "@wp-playground/tools";
|
|
24
26
|
import { jspi as te } from "wasm-feature-detect";
|
|
25
|
-
const
|
|
26
|
-
class
|
|
27
|
-
constructor(t = 1, r =
|
|
27
|
+
const rt = 2 ** 31 - 1;
|
|
28
|
+
class ot {
|
|
29
|
+
constructor(t = 1, r = rt) {
|
|
28
30
|
this.claimed = /* @__PURE__ */ new Set(), this.initialId = t, this.maxId = r, this.nextId = t;
|
|
29
31
|
}
|
|
30
32
|
claim() {
|
|
@@ -51,10 +53,10 @@ function U(e) {
|
|
|
51
53
|
Expected format: /host/path:/vfs/path.
|
|
52
54
|
If your path contains a colon, e.g. C:\\myplugin, use the --mount-dir option instead.
|
|
53
55
|
Example: --mount-dir C:\\my-plugin /wordpress/wp-content/plugins/my-plugin`);
|
|
54
|
-
const [
|
|
55
|
-
if (!
|
|
56
|
-
throw new Error(`Host path does not exist: ${
|
|
57
|
-
t.push({ hostPath:
|
|
56
|
+
const [i, s] = o;
|
|
57
|
+
if (!O(i))
|
|
58
|
+
throw new Error(`Host path does not exist: ${i}`);
|
|
59
|
+
t.push({ hostPath: i, vfsPath: s });
|
|
58
60
|
}
|
|
59
61
|
return t;
|
|
60
62
|
}
|
|
@@ -63,21 +65,21 @@ function re(e) {
|
|
|
63
65
|
throw new Error("Invalid mount format. Expected: /host/path /vfs/path");
|
|
64
66
|
const t = [];
|
|
65
67
|
for (let r = 0; r < e.length; r += 2) {
|
|
66
|
-
const o = e[r],
|
|
67
|
-
if (!
|
|
68
|
+
const o = e[r], i = e[r + 1];
|
|
69
|
+
if (!O(o))
|
|
68
70
|
throw new Error(`Host path does not exist: ${o}`);
|
|
69
71
|
t.push({
|
|
70
72
|
hostPath: u.resolve(process.cwd(), o),
|
|
71
|
-
vfsPath:
|
|
73
|
+
vfsPath: i
|
|
72
74
|
});
|
|
73
75
|
}
|
|
74
76
|
return t;
|
|
75
77
|
}
|
|
76
|
-
async function
|
|
78
|
+
async function cr(e, t) {
|
|
77
79
|
for (const r of t)
|
|
78
80
|
await e.mount(
|
|
79
81
|
r.vfsPath,
|
|
80
|
-
|
|
82
|
+
Be(r.hostPath)
|
|
81
83
|
);
|
|
82
84
|
}
|
|
83
85
|
const oe = {
|
|
@@ -100,7 +102,7 @@ const oe = {
|
|
|
100
102
|
}
|
|
101
103
|
};
|
|
102
104
|
function ue(e) {
|
|
103
|
-
const t = e.autoMount, r = [...e.mount || []], o = [...e["mount-before-install"] || []],
|
|
105
|
+
const t = e.autoMount, r = [...e.mount || []], o = [...e["mount-before-install"] || []], i = {
|
|
104
106
|
...e,
|
|
105
107
|
mount: r,
|
|
106
108
|
"mount-before-install": o,
|
|
@@ -108,193 +110,200 @@ function ue(e) {
|
|
|
108
110
|
...e["additional-blueprint-steps"] || []
|
|
109
111
|
]
|
|
110
112
|
};
|
|
111
|
-
if (
|
|
112
|
-
const
|
|
113
|
+
if (at(t)) {
|
|
114
|
+
const n = `/wordpress/wp-content/plugins/${A(t)}`;
|
|
113
115
|
r.push({
|
|
114
116
|
hostPath: t,
|
|
115
|
-
vfsPath:
|
|
117
|
+
vfsPath: n,
|
|
116
118
|
autoMounted: !0
|
|
117
|
-
}),
|
|
119
|
+
}), i["additional-blueprint-steps"].push({
|
|
118
120
|
step: "activatePlugin",
|
|
119
121
|
pluginPath: `/wordpress/wp-content/plugins/${A(t)}`
|
|
120
122
|
});
|
|
121
|
-
} else if (
|
|
122
|
-
const
|
|
123
|
+
} else if (nt(t)) {
|
|
124
|
+
const s = A(t), n = `/wordpress/wp-content/themes/${s}`;
|
|
123
125
|
r.push({
|
|
124
126
|
hostPath: t,
|
|
125
|
-
vfsPath:
|
|
127
|
+
vfsPath: n,
|
|
126
128
|
autoMounted: !0
|
|
127
|
-
}),
|
|
129
|
+
}), i["additional-blueprint-steps"].push(
|
|
128
130
|
e["experimental-blueprints-v2-runner"] ? {
|
|
129
131
|
step: "activateTheme",
|
|
130
|
-
themeDirectoryName:
|
|
132
|
+
themeDirectoryName: s
|
|
131
133
|
} : {
|
|
132
134
|
step: "activateTheme",
|
|
133
|
-
themeFolderName:
|
|
135
|
+
themeFolderName: s
|
|
134
136
|
}
|
|
135
137
|
);
|
|
136
|
-
} else if (
|
|
137
|
-
const
|
|
138
|
-
for (const
|
|
139
|
-
|
|
140
|
-
hostPath: `${t}/${
|
|
141
|
-
vfsPath: `/wordpress/wp-content/${
|
|
138
|
+
} else if (st(t)) {
|
|
139
|
+
const s = c.readdirSync(t);
|
|
140
|
+
for (const n of s)
|
|
141
|
+
n !== "index.php" && r.push({
|
|
142
|
+
hostPath: `${t}/${n}`,
|
|
143
|
+
vfsPath: `/wordpress/wp-content/${n}`,
|
|
142
144
|
autoMounted: !0
|
|
143
145
|
});
|
|
144
|
-
|
|
145
|
-
} else
|
|
146
|
+
i["additional-blueprint-steps"].push(oe);
|
|
147
|
+
} else it(t) && (o.push({
|
|
146
148
|
hostPath: t,
|
|
147
149
|
vfsPath: "/wordpress",
|
|
148
150
|
autoMounted: !0
|
|
149
|
-
}),
|
|
150
|
-
return
|
|
151
|
+
}), i.mode = "apply-to-existing-site", i["additional-blueprint-steps"].push(oe), i.wordpressInstallMode || (i.wordpressInstallMode = "install-from-existing-files-if-needed"));
|
|
152
|
+
return i;
|
|
151
153
|
}
|
|
152
|
-
function
|
|
154
|
+
function it(e) {
|
|
153
155
|
const t = c.readdirSync(e);
|
|
154
156
|
return t.includes("wp-admin") && t.includes("wp-includes") && t.includes("wp-content");
|
|
155
157
|
}
|
|
156
|
-
function
|
|
158
|
+
function st(e) {
|
|
157
159
|
const t = c.readdirSync(e);
|
|
158
160
|
return t.includes("themes") || t.includes("plugins") || t.includes("mu-plugins") || t.includes("uploads");
|
|
159
161
|
}
|
|
160
|
-
function
|
|
162
|
+
function nt(e) {
|
|
161
163
|
if (!c.readdirSync(e).includes("style.css"))
|
|
162
164
|
return !1;
|
|
163
165
|
const r = c.readFileSync(de(e, "style.css"), "utf8");
|
|
164
166
|
return !!/^(?:[ \t]*<\?php)?[ \t/*#@]*Theme Name:(.*)$/im.exec(r);
|
|
165
167
|
}
|
|
166
|
-
function
|
|
168
|
+
function at(e) {
|
|
167
169
|
const t = c.readdirSync(e), r = /^(?:[ \t]*<\?php)?[ \t/*#@]*Plugin Name:(.*)$/im;
|
|
168
|
-
return !!t.filter((
|
|
169
|
-
const
|
|
170
|
-
return !!r.exec(
|
|
170
|
+
return !!t.filter((i) => i.endsWith(".php")).find((i) => {
|
|
171
|
+
const s = c.readFileSync(de(e, i), "utf8");
|
|
172
|
+
return !!r.exec(s);
|
|
171
173
|
});
|
|
172
174
|
}
|
|
173
|
-
function
|
|
175
|
+
function lt(e) {
|
|
174
176
|
if (e.length % 2 !== 0)
|
|
175
177
|
throw new Error(
|
|
176
178
|
"Invalid constant definition format. Expected pairs of NAME value"
|
|
177
179
|
);
|
|
178
180
|
const t = {};
|
|
179
181
|
for (let r = 0; r < e.length; r += 2) {
|
|
180
|
-
const o = e[r],
|
|
182
|
+
const o = e[r], i = e[r + 1];
|
|
181
183
|
if (!o || !o.trim())
|
|
182
184
|
throw new Error("Constant name cannot be empty");
|
|
183
|
-
t[o.trim()] =
|
|
185
|
+
t[o.trim()] = i;
|
|
184
186
|
}
|
|
185
187
|
return t;
|
|
186
188
|
}
|
|
187
|
-
function
|
|
189
|
+
function dt(e) {
|
|
188
190
|
if (e.length % 2 !== 0)
|
|
189
191
|
throw new Error(
|
|
190
192
|
"Invalid boolean constant definition format. Expected pairs of NAME value"
|
|
191
193
|
);
|
|
192
194
|
const t = {};
|
|
193
195
|
for (let r = 0; r < e.length; r += 2) {
|
|
194
|
-
const o = e[r],
|
|
196
|
+
const o = e[r], i = e[r + 1].trim().toLowerCase();
|
|
195
197
|
if (!o || !o.trim())
|
|
196
198
|
throw new Error("Constant name cannot be empty");
|
|
197
|
-
if (
|
|
199
|
+
if (i === "true" || i === "1")
|
|
198
200
|
t[o.trim()] = !0;
|
|
199
|
-
else if (
|
|
201
|
+
else if (i === "false" || i === "0")
|
|
200
202
|
t[o.trim()] = !1;
|
|
201
203
|
else
|
|
202
204
|
throw new Error(
|
|
203
|
-
`Invalid boolean value for constant "${o}": "${
|
|
205
|
+
`Invalid boolean value for constant "${o}": "${i}". Must be "true", "false", "1", or "0".`
|
|
204
206
|
);
|
|
205
207
|
}
|
|
206
208
|
return t;
|
|
207
209
|
}
|
|
208
|
-
function
|
|
210
|
+
function ut(e) {
|
|
209
211
|
if (e.length % 2 !== 0)
|
|
210
212
|
throw new Error(
|
|
211
213
|
"Invalid number constant definition format. Expected pairs of NAME value"
|
|
212
214
|
);
|
|
213
215
|
const t = {};
|
|
214
216
|
for (let r = 0; r < e.length; r += 2) {
|
|
215
|
-
const o = e[r],
|
|
217
|
+
const o = e[r], i = e[r + 1].trim();
|
|
216
218
|
if (!o || !o.trim())
|
|
217
219
|
throw new Error("Constant name cannot be empty");
|
|
218
|
-
const
|
|
219
|
-
if (isNaN(
|
|
220
|
+
const s = Number(i);
|
|
221
|
+
if (isNaN(s))
|
|
220
222
|
throw new Error(
|
|
221
|
-
`Invalid number value for constant "${o}": "${
|
|
223
|
+
`Invalid number value for constant "${o}": "${i}". Must be a valid number.`
|
|
222
224
|
);
|
|
223
|
-
t[o.trim()] =
|
|
225
|
+
t[o.trim()] = s;
|
|
224
226
|
}
|
|
225
227
|
return t;
|
|
226
228
|
}
|
|
227
|
-
function
|
|
228
|
-
const o = {},
|
|
229
|
-
for (const d in
|
|
230
|
-
if (
|
|
229
|
+
function pt(e = {}, t = {}, r = {}) {
|
|
230
|
+
const o = {}, i = /* @__PURE__ */ new Set(), s = (n, l) => {
|
|
231
|
+
for (const d in n) {
|
|
232
|
+
if (i.has(d))
|
|
231
233
|
throw new Error(
|
|
232
234
|
`Constant "${d}" is defined multiple times across different --define-${l} flags`
|
|
233
235
|
);
|
|
234
|
-
|
|
236
|
+
i.add(d), o[d] = n[d];
|
|
235
237
|
}
|
|
236
238
|
};
|
|
237
|
-
return
|
|
239
|
+
return s(e, "string"), s(t, "bool"), s(r, "number"), o;
|
|
238
240
|
}
|
|
239
241
|
function pe(e) {
|
|
240
|
-
return
|
|
242
|
+
return pt(
|
|
241
243
|
e.define,
|
|
242
244
|
e["define-bool"],
|
|
243
245
|
e["define-number"]
|
|
244
246
|
);
|
|
245
247
|
}
|
|
246
|
-
async function
|
|
247
|
-
const t =
|
|
248
|
+
async function ct(e) {
|
|
249
|
+
const t = Ae(), r = await new Promise((s, n) => {
|
|
248
250
|
const l = t.listen(e.port, () => {
|
|
249
251
|
const d = l.address();
|
|
250
|
-
d === null || typeof d == "string" ?
|
|
252
|
+
d === null || typeof d == "string" ? n(new Error("Server address is not available")) : s(l);
|
|
251
253
|
});
|
|
252
254
|
});
|
|
253
|
-
t.use("/", async (
|
|
254
|
-
let l;
|
|
255
|
+
t.use("/", async (s, n) => {
|
|
255
256
|
try {
|
|
256
|
-
l =
|
|
257
|
-
url:
|
|
258
|
-
headers:
|
|
259
|
-
method:
|
|
260
|
-
body: await
|
|
261
|
-
});
|
|
262
|
-
|
|
263
|
-
|
|
257
|
+
const l = {
|
|
258
|
+
url: s.url,
|
|
259
|
+
headers: ft(s),
|
|
260
|
+
method: s.method,
|
|
261
|
+
body: await ht(s)
|
|
262
|
+
}, d = await e.handleRequest(l);
|
|
263
|
+
await mt(d, n);
|
|
264
|
+
} catch (l) {
|
|
265
|
+
g.error(l), n.headersSent || (n.statusCode = 500, n.end("Internal Server Error"));
|
|
264
266
|
}
|
|
265
|
-
a.statusCode = l.httpStatusCode;
|
|
266
|
-
for (const d in l.headers)
|
|
267
|
-
a.setHeader(d, l.headers[d]);
|
|
268
|
-
a.end(l.bytes);
|
|
269
267
|
});
|
|
270
|
-
const
|
|
271
|
-
return await e.onBind(r,
|
|
268
|
+
const i = r.address().port;
|
|
269
|
+
return await e.onBind(r, i);
|
|
270
|
+
}
|
|
271
|
+
async function mt(e, t) {
|
|
272
|
+
const [r, o] = await Promise.all([
|
|
273
|
+
e.headers,
|
|
274
|
+
e.httpStatusCode
|
|
275
|
+
]);
|
|
276
|
+
t.statusCode = o;
|
|
277
|
+
for (const s in r)
|
|
278
|
+
t.setHeader(s, r[s]);
|
|
279
|
+
const i = Ce.fromWeb(e.stdout);
|
|
280
|
+
await De(i, t);
|
|
272
281
|
}
|
|
273
|
-
const
|
|
282
|
+
const ht = async (e) => await new Promise((t) => {
|
|
274
283
|
const r = [];
|
|
275
284
|
e.on("data", (o) => {
|
|
276
285
|
r.push(o);
|
|
277
286
|
}), e.on("end", () => {
|
|
278
287
|
t(new Uint8Array(Buffer.concat(r)));
|
|
279
288
|
});
|
|
280
|
-
}),
|
|
289
|
+
}), ft = (e) => {
|
|
281
290
|
const t = {};
|
|
282
291
|
if (e.rawHeaders && e.rawHeaders.length)
|
|
283
292
|
for (let r = 0; r < e.rawHeaders.length; r += 2)
|
|
284
293
|
t[e.rawHeaders[r].toLowerCase()] = e.rawHeaders[r + 1];
|
|
285
294
|
return t;
|
|
286
295
|
};
|
|
287
|
-
function
|
|
296
|
+
function wt(e) {
|
|
288
297
|
return /^latest$|^trunk$|^nightly$|^(?:(\d+)\.(\d+)(?:\.(\d+))?)((?:-beta(?:\d+)?)|(?:-RC(?:\d+)?))?$/.test(e);
|
|
289
298
|
}
|
|
290
|
-
async function
|
|
299
|
+
async function yt({
|
|
291
300
|
sourceString: e,
|
|
292
301
|
blueprintMayReadAdjacentFiles: t
|
|
293
302
|
}) {
|
|
294
303
|
if (!e)
|
|
295
304
|
return;
|
|
296
305
|
if (e.startsWith("http://") || e.startsWith("https://"))
|
|
297
|
-
return await
|
|
306
|
+
return await $e(e);
|
|
298
307
|
let r = u.resolve(process.cwd(), e);
|
|
299
308
|
if (!c.existsSync(r))
|
|
300
309
|
throw new Error(`Blueprint file does not exist: ${r}`);
|
|
@@ -303,25 +312,25 @@ async function mt({
|
|
|
303
312
|
throw new Error(
|
|
304
313
|
`Blueprint path is neither a file nor a directory: ${r}`
|
|
305
314
|
);
|
|
306
|
-
const
|
|
307
|
-
switch (
|
|
315
|
+
const i = u.extname(r);
|
|
316
|
+
switch (i) {
|
|
308
317
|
case ".zip":
|
|
309
|
-
return
|
|
318
|
+
return He.fromArrayBuffer(
|
|
310
319
|
c.readFileSync(r).buffer
|
|
311
320
|
);
|
|
312
321
|
case ".json": {
|
|
313
|
-
const
|
|
322
|
+
const s = c.readFileSync(r, "utf-8");
|
|
314
323
|
try {
|
|
315
|
-
JSON.parse(
|
|
324
|
+
JSON.parse(s);
|
|
316
325
|
} catch {
|
|
317
326
|
throw new Error(
|
|
318
327
|
`Blueprint file at ${r} is not a valid JSON file`
|
|
319
328
|
);
|
|
320
329
|
}
|
|
321
|
-
const
|
|
322
|
-
return new
|
|
323
|
-
new
|
|
324
|
-
"blueprint.json":
|
|
330
|
+
const n = u.dirname(r), l = new Le(n);
|
|
331
|
+
return new Ue([
|
|
332
|
+
new Fe({
|
|
333
|
+
"blueprint.json": s
|
|
325
334
|
}),
|
|
326
335
|
/**
|
|
327
336
|
* Wrap the NodeJS filesystem to prevent access to local files
|
|
@@ -342,11 +351,11 @@ You can allow this Blueprint to read files from the same parent directory by exp
|
|
|
342
351
|
}
|
|
343
352
|
default:
|
|
344
353
|
throw new Error(
|
|
345
|
-
`Unsupported blueprint file extension: ${
|
|
354
|
+
`Unsupported blueprint file extension: ${i}. Only .zip and .json files are supported.`
|
|
346
355
|
);
|
|
347
356
|
}
|
|
348
357
|
}
|
|
349
|
-
class
|
|
358
|
+
class bt {
|
|
350
359
|
constructor(t, r) {
|
|
351
360
|
this.args = t, this.siteUrl = r.siteUrl, this.phpVersion = t.php, this.cliOutput = r.cliOutput;
|
|
352
361
|
}
|
|
@@ -367,9 +376,9 @@ class ht {
|
|
|
367
376
|
fileLockManagerPort: r,
|
|
368
377
|
nativeInternalDirPath: o
|
|
369
378
|
}) {
|
|
370
|
-
const
|
|
371
|
-
await
|
|
372
|
-
const
|
|
379
|
+
const i = ne(t.phpPort);
|
|
380
|
+
await i.useFileLockManager(r);
|
|
381
|
+
const s = {
|
|
373
382
|
...this.args,
|
|
374
383
|
phpVersion: this.phpVersion,
|
|
375
384
|
siteUrl: this.siteUrl,
|
|
@@ -384,15 +393,15 @@ class ht {
|
|
|
384
393
|
mountsAfterWpInstall: this.args.mount || [],
|
|
385
394
|
constants: pe(this.args)
|
|
386
395
|
};
|
|
387
|
-
return await
|
|
396
|
+
return await i.bootWorker(s), i;
|
|
388
397
|
}
|
|
389
398
|
}
|
|
390
|
-
const
|
|
391
|
-
async function
|
|
399
|
+
const N = u.join(j.homedir(), ".wordpress-playground");
|
|
400
|
+
async function gt() {
|
|
392
401
|
const e = typeof __dirname < "u" ? __dirname : import.meta.dirname;
|
|
393
402
|
let t = u.join(e, "sqlite-database-integration.zip");
|
|
394
403
|
if (!I.existsSync(t)) {
|
|
395
|
-
const r =
|
|
404
|
+
const r = je(import.meta.url), o = u.dirname(
|
|
396
405
|
r.resolve("@wp-playground/wordpress-builds/package.json")
|
|
397
406
|
);
|
|
398
407
|
t = u.join(
|
|
@@ -404,29 +413,29 @@ async function ft() {
|
|
|
404
413
|
}
|
|
405
414
|
return new File([await I.readFile(t)], u.basename(t));
|
|
406
415
|
}
|
|
407
|
-
async function
|
|
408
|
-
const o = u.join(
|
|
409
|
-
return I.existsSync(o) || (I.ensureDirSync(
|
|
416
|
+
async function Pt(e, t, r) {
|
|
417
|
+
const o = u.join(N, t);
|
|
418
|
+
return I.existsSync(o) || (I.ensureDirSync(N), await vt(e, o, r)), ce(o);
|
|
410
419
|
}
|
|
411
|
-
async function
|
|
412
|
-
const
|
|
420
|
+
async function vt(e, t, r) {
|
|
421
|
+
const i = (await r.monitorFetch(fetch(e))).body.getReader(), s = `${t}.partial`, n = I.createWriteStream(s);
|
|
413
422
|
for (; ; ) {
|
|
414
|
-
const { done: l, value: d } = await
|
|
415
|
-
if (d &&
|
|
423
|
+
const { done: l, value: d } = await i.read();
|
|
424
|
+
if (d && n.write(d), l)
|
|
416
425
|
break;
|
|
417
426
|
}
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
I.renameSync(
|
|
421
|
-
}),
|
|
422
|
-
I.removeSync(
|
|
427
|
+
n.close(), n.closed || await new Promise((l, d) => {
|
|
428
|
+
n.on("finish", () => {
|
|
429
|
+
I.renameSync(s, t), l(null);
|
|
430
|
+
}), n.on("error", (x) => {
|
|
431
|
+
I.removeSync(s), d(x);
|
|
423
432
|
});
|
|
424
433
|
});
|
|
425
434
|
}
|
|
426
435
|
function ce(e, t) {
|
|
427
436
|
return new File([I.readFileSync(e)], A(e));
|
|
428
437
|
}
|
|
429
|
-
class
|
|
438
|
+
class St {
|
|
430
439
|
constructor(t, r) {
|
|
431
440
|
this.args = t, this.siteUrl = r.siteUrl, this.cliOutput = r.cliOutput;
|
|
432
441
|
}
|
|
@@ -434,33 +443,33 @@ class bt {
|
|
|
434
443
|
return "v1";
|
|
435
444
|
}
|
|
436
445
|
async bootWordPress(t, r) {
|
|
437
|
-
let o,
|
|
438
|
-
const
|
|
446
|
+
let o, i, s;
|
|
447
|
+
const n = new _e();
|
|
439
448
|
if (this.args.wordpressInstallMode === "download-and-install") {
|
|
440
|
-
let
|
|
441
|
-
|
|
442
|
-
if (
|
|
449
|
+
let x = !1;
|
|
450
|
+
n.addEventListener("progress", (S) => {
|
|
451
|
+
if (x)
|
|
443
452
|
return;
|
|
444
|
-
const { loaded: p, total:
|
|
445
|
-
Math.min(100, 100 * p /
|
|
453
|
+
const { loaded: p, total: a } = S.detail, m = Math.floor(
|
|
454
|
+
Math.min(100, 100 * p / a)
|
|
446
455
|
);
|
|
447
|
-
|
|
456
|
+
x = m === 100, this.cliOutput.updateProgress(
|
|
448
457
|
"Downloading WordPress",
|
|
449
|
-
|
|
458
|
+
m
|
|
450
459
|
);
|
|
451
|
-
}), o = await
|
|
452
|
-
|
|
460
|
+
}), o = await Oe(this.args.wp), s = u.join(
|
|
461
|
+
N,
|
|
453
462
|
`prebuilt-wp-content-for-wp-${o.version}.zip`
|
|
454
|
-
),
|
|
463
|
+
), i = c.existsSync(s) ? ce(s) : await Pt(
|
|
455
464
|
o.releaseUrl,
|
|
456
465
|
`${o.version}.zip`,
|
|
457
|
-
|
|
466
|
+
n
|
|
458
467
|
), g.debug(
|
|
459
468
|
`Resolved WordPress release URL: ${o?.releaseUrl}`
|
|
460
469
|
);
|
|
461
470
|
}
|
|
462
471
|
let l;
|
|
463
|
-
this.args.skipSqliteSetup ? (g.debug("Skipping SQLite integration plugin setup..."), l = void 0) : (this.cliOutput.updateProgress("Preparing SQLite database"), l = await
|
|
472
|
+
this.args.skipSqliteSetup ? (g.debug("Skipping SQLite integration plugin setup..."), l = void 0) : (this.cliOutput.updateProgress("Preparing SQLite database"), l = await gt()), this.cliOutput.updateProgress("Booting WordPress");
|
|
464
473
|
const d = await Z(
|
|
465
474
|
this.getEffectiveBlueprint()
|
|
466
475
|
);
|
|
@@ -469,16 +478,16 @@ class bt {
|
|
|
469
478
|
wpVersion: d.wpVersion,
|
|
470
479
|
siteUrl: this.siteUrl,
|
|
471
480
|
wordpressInstallMode: this.args.wordpressInstallMode || "download-and-install",
|
|
472
|
-
wordPressZip:
|
|
481
|
+
wordPressZip: i && await i.arrayBuffer(),
|
|
473
482
|
sqliteIntegrationPluginZip: await l?.arrayBuffer(),
|
|
474
483
|
constants: pe(this.args)
|
|
475
484
|
},
|
|
476
485
|
r
|
|
477
|
-
),
|
|
478
|
-
|
|
486
|
+
), s && !this.args["mount-before-install"] && !c.existsSync(s) && (this.cliOutput.updateProgress("Caching WordPress for next boot"), c.writeFileSync(
|
|
487
|
+
s,
|
|
479
488
|
// Comlink proxy is not assignable to UniversalPHP but
|
|
480
489
|
// proxies all method calls transparently at runtime.
|
|
481
|
-
await
|
|
490
|
+
await Ee(
|
|
482
491
|
t,
|
|
483
492
|
"/wordpress"
|
|
484
493
|
)
|
|
@@ -489,15 +498,15 @@ class bt {
|
|
|
489
498
|
fileLockManagerPort: r,
|
|
490
499
|
nativeInternalDirPath: o
|
|
491
500
|
}) {
|
|
492
|
-
const
|
|
501
|
+
const i = ne(
|
|
493
502
|
t.phpPort
|
|
494
503
|
);
|
|
495
|
-
await
|
|
496
|
-
const
|
|
504
|
+
await i.isConnected();
|
|
505
|
+
const s = await Z(
|
|
497
506
|
this.getEffectiveBlueprint()
|
|
498
507
|
);
|
|
499
|
-
return await
|
|
500
|
-
phpVersion:
|
|
508
|
+
return await i.useFileLockManager(r), await i.bootRequestHandler({
|
|
509
|
+
phpVersion: s.phpVersion,
|
|
501
510
|
siteUrl: this.siteUrl,
|
|
502
511
|
mountsBeforeWpInstall: this.args["mount-before-install"] || [],
|
|
503
512
|
mountsAfterWpInstall: this.args.mount || [],
|
|
@@ -510,17 +519,17 @@ class bt {
|
|
|
510
519
|
withXdebug: !!this.args.xdebug,
|
|
511
520
|
nativeInternalDirPath: o,
|
|
512
521
|
pathAliases: this.args.pathAliases
|
|
513
|
-
}), await
|
|
522
|
+
}), await i.isReady(), i;
|
|
514
523
|
}
|
|
515
524
|
async compileInputBlueprint(t) {
|
|
516
|
-
const r = this.getEffectiveBlueprint(), o = new
|
|
517
|
-
let
|
|
518
|
-
return o.addEventListener("progress", (
|
|
519
|
-
if (
|
|
525
|
+
const r = this.getEffectiveBlueprint(), o = new Ne();
|
|
526
|
+
let i = "", s = !1;
|
|
527
|
+
return o.addEventListener("progress", (n) => {
|
|
528
|
+
if (s)
|
|
520
529
|
return;
|
|
521
|
-
|
|
522
|
-
const l = Math.floor(
|
|
523
|
-
|
|
530
|
+
s = n.detail.progress === 100;
|
|
531
|
+
const l = Math.floor(n.detail.progress);
|
|
532
|
+
i = n.detail.caption || i || "Running Blueprint", this.cliOutput.updateProgress(i.trim(), l);
|
|
524
533
|
}), await ae(r, {
|
|
525
534
|
progress: o,
|
|
526
535
|
additionalSteps: t
|
|
@@ -528,7 +537,7 @@ class bt {
|
|
|
528
537
|
}
|
|
529
538
|
getEffectiveBlueprint() {
|
|
530
539
|
const t = this.args.blueprint;
|
|
531
|
-
return
|
|
540
|
+
return Te(t) ? t : {
|
|
532
541
|
login: this.args.login,
|
|
533
542
|
...t || {},
|
|
534
543
|
preferredVersions: {
|
|
@@ -539,8 +548,8 @@ class bt {
|
|
|
539
548
|
};
|
|
540
549
|
}
|
|
541
550
|
}
|
|
542
|
-
async function
|
|
543
|
-
const o = `${u.basename(process.argv0)}${e}${process.pid}-`,
|
|
551
|
+
async function xt(e, t = !0) {
|
|
552
|
+
const o = `${u.basename(process.argv0)}${e}${process.pid}-`, i = await qe({
|
|
544
553
|
prefix: o,
|
|
545
554
|
/*
|
|
546
555
|
* Allow recursive cleanup on process exit.
|
|
@@ -552,83 +561,83 @@ async function gt(e, t = !0) {
|
|
|
552
561
|
*/
|
|
553
562
|
unsafeCleanup: !0
|
|
554
563
|
});
|
|
555
|
-
return t &&
|
|
564
|
+
return t && ze(), i;
|
|
556
565
|
}
|
|
557
|
-
async function
|
|
558
|
-
const
|
|
566
|
+
async function It(e, t, r) {
|
|
567
|
+
const i = (await $t(
|
|
559
568
|
e,
|
|
560
569
|
t,
|
|
561
570
|
r
|
|
562
571
|
)).map(
|
|
563
|
-
(
|
|
564
|
-
c.rm(
|
|
572
|
+
(s) => new Promise((n) => {
|
|
573
|
+
c.rm(s, { recursive: !0 }, (l) => {
|
|
565
574
|
l ? g.warn(
|
|
566
|
-
`Failed to delete stale Playground temp dir: ${
|
|
575
|
+
`Failed to delete stale Playground temp dir: ${s}`,
|
|
567
576
|
l
|
|
568
577
|
) : g.info(
|
|
569
|
-
`Deleted stale Playground temp dir: ${
|
|
570
|
-
),
|
|
578
|
+
`Deleted stale Playground temp dir: ${s}`
|
|
579
|
+
), n();
|
|
571
580
|
});
|
|
572
581
|
})
|
|
573
582
|
);
|
|
574
|
-
await Promise.all(
|
|
583
|
+
await Promise.all(i);
|
|
575
584
|
}
|
|
576
|
-
async function
|
|
585
|
+
async function $t(e, t, r) {
|
|
577
586
|
try {
|
|
578
|
-
const o = c.readdirSync(r).map((
|
|
579
|
-
for (const
|
|
580
|
-
await
|
|
587
|
+
const o = c.readdirSync(r).map((s) => u.join(r, s)), i = [];
|
|
588
|
+
for (const s of o)
|
|
589
|
+
await Tt(
|
|
581
590
|
e,
|
|
582
591
|
t,
|
|
583
|
-
|
|
584
|
-
) &&
|
|
585
|
-
return
|
|
592
|
+
s
|
|
593
|
+
) && i.push(s);
|
|
594
|
+
return i;
|
|
586
595
|
} catch (o) {
|
|
587
596
|
return g.warn(`Failed to find stale Playground temp dirs: ${o}`), [];
|
|
588
597
|
}
|
|
589
598
|
}
|
|
590
|
-
async function
|
|
599
|
+
async function Tt(e, t, r) {
|
|
591
600
|
if (!c.lstatSync(r).isDirectory())
|
|
592
601
|
return !1;
|
|
593
|
-
const
|
|
594
|
-
if (!
|
|
602
|
+
const i = u.basename(r);
|
|
603
|
+
if (!i.includes(e))
|
|
595
604
|
return !1;
|
|
596
|
-
const
|
|
605
|
+
const s = i.match(
|
|
597
606
|
new RegExp(`^(.+)${e}(\\d+)-`)
|
|
598
607
|
);
|
|
599
|
-
if (!
|
|
608
|
+
if (!s)
|
|
600
609
|
return !1;
|
|
601
|
-
const
|
|
602
|
-
executableName:
|
|
603
|
-
pid:
|
|
610
|
+
const n = {
|
|
611
|
+
executableName: s[1],
|
|
612
|
+
pid: s[2]
|
|
604
613
|
};
|
|
605
|
-
if (await
|
|
614
|
+
if (await Et(n.pid, n.executableName))
|
|
606
615
|
return !1;
|
|
607
616
|
const l = Date.now() - t;
|
|
608
617
|
return c.statSync(r).mtime.getTime() < l;
|
|
609
618
|
}
|
|
610
|
-
async function
|
|
619
|
+
async function Et(e, t) {
|
|
611
620
|
const [r] = await new Promise(
|
|
612
|
-
(o,
|
|
613
|
-
|
|
621
|
+
(o, i) => {
|
|
622
|
+
Ge.list(
|
|
614
623
|
{
|
|
615
624
|
pid: e,
|
|
616
625
|
name: t,
|
|
617
626
|
// Remove path from executable name in the results.
|
|
618
627
|
clean: !0
|
|
619
628
|
},
|
|
620
|
-
(
|
|
621
|
-
|
|
629
|
+
(s, n) => {
|
|
630
|
+
s ? i(s) : o(n);
|
|
622
631
|
}
|
|
623
632
|
);
|
|
624
633
|
}
|
|
625
634
|
);
|
|
626
635
|
return !!r && r.pid === e && r.command === t;
|
|
627
636
|
}
|
|
628
|
-
function
|
|
637
|
+
function kt(e) {
|
|
629
638
|
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;
|
|
630
639
|
}
|
|
631
|
-
class
|
|
640
|
+
class Mt {
|
|
632
641
|
constructor(t) {
|
|
633
642
|
this.lastProgressLine = "", this.progressActive = !1, this.verbosity = t.verbosity, this.writeStream = t.writeStream || process.stdout;
|
|
634
643
|
}
|
|
@@ -642,7 +651,7 @@ class $t {
|
|
|
642
651
|
* This prevents progress spam in logs - users only see the final outcome.
|
|
643
652
|
*/
|
|
644
653
|
get shouldRender() {
|
|
645
|
-
return
|
|
654
|
+
return kt(this.writeStream);
|
|
646
655
|
}
|
|
647
656
|
get isQuiet() {
|
|
648
657
|
return this.verbosity === "quiet";
|
|
@@ -695,10 +704,10 @@ ${t}
|
|
|
695
704
|
);
|
|
696
705
|
const o = [];
|
|
697
706
|
if (t.intl && o.push("intl"), t.redis && o.push("redis"), t.memcached && o.push("memcached"), t.xdebug && o.push(this.yellow("xdebug")), o.length > 0 && r.push(`${this.dim("Extensions")} ${o.join(", ")}`), t.mounts.length > 0)
|
|
698
|
-
for (const
|
|
699
|
-
const
|
|
707
|
+
for (const i of t.mounts) {
|
|
708
|
+
const s = i.autoMounted ? ` ${this.dim("(auto-mount)")}` : "";
|
|
700
709
|
r.push(
|
|
701
|
-
`${this.dim("Mount")} ${
|
|
710
|
+
`${this.dim("Mount")} ${i.hostPath} ${this.dim("→")} ${i.vfsPath}${s}`
|
|
702
711
|
);
|
|
703
712
|
}
|
|
704
713
|
t.blueprint && r.push(`${this.dim("Blueprint")} ${t.blueprint}`), this.writeStream.write(r.join(`
|
|
@@ -795,8 +804,8 @@ const me = {
|
|
|
795
804
|
Quiet: { name: "quiet", severity: L.Fatal },
|
|
796
805
|
Normal: { name: "normal", severity: L.Info },
|
|
797
806
|
Debug: { name: "debug", severity: L.Debug }
|
|
798
|
-
},
|
|
799
|
-
async function
|
|
807
|
+
}, Bt = 10;
|
|
808
|
+
async function mr(e) {
|
|
800
809
|
try {
|
|
801
810
|
const t = {
|
|
802
811
|
"site-url": {
|
|
@@ -807,7 +816,7 @@ async function ar(e) {
|
|
|
807
816
|
describe: "PHP version to use.",
|
|
808
817
|
type: "string",
|
|
809
818
|
default: C,
|
|
810
|
-
choices:
|
|
819
|
+
choices: Q
|
|
811
820
|
},
|
|
812
821
|
wp: {
|
|
813
822
|
describe: "WordPress version to use.",
|
|
@@ -819,21 +828,21 @@ async function ar(e) {
|
|
|
819
828
|
type: "string",
|
|
820
829
|
nargs: 2,
|
|
821
830
|
array: !0,
|
|
822
|
-
coerce:
|
|
831
|
+
coerce: lt
|
|
823
832
|
},
|
|
824
833
|
"define-bool": {
|
|
825
834
|
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',
|
|
826
835
|
type: "string",
|
|
827
836
|
nargs: 2,
|
|
828
837
|
array: !0,
|
|
829
|
-
coerce:
|
|
838
|
+
coerce: dt
|
|
830
839
|
},
|
|
831
840
|
"define-number": {
|
|
832
841
|
describe: "Define PHP number constants (can be used multiple times). Format: NAME value. Examples: --define-number LIMIT 100 --define-number RATE 45.67",
|
|
833
842
|
type: "string",
|
|
834
843
|
nargs: 2,
|
|
835
844
|
array: !0,
|
|
836
|
-
coerce:
|
|
845
|
+
coerce: ut
|
|
837
846
|
},
|
|
838
847
|
// @TODO: Support read-only mounts, e.g. via WORKERFS, a custom
|
|
839
848
|
// ReadOnlyNODEFS, or by copying the files into MEMFS
|
|
@@ -909,7 +918,7 @@ async function ar(e) {
|
|
|
909
918
|
describe: "Output logs and progress messages.",
|
|
910
919
|
type: "string",
|
|
911
920
|
choices: Object.values(me).map(
|
|
912
|
-
(
|
|
921
|
+
(a) => a.name
|
|
913
922
|
),
|
|
914
923
|
default: "normal"
|
|
915
924
|
},
|
|
@@ -969,7 +978,7 @@ Warning: Following symlinks will expose files outside mounted directories to Pla
|
|
|
969
978
|
// supported IDEs and, if needed, will create the relevant
|
|
970
979
|
// config file for each.
|
|
971
980
|
choices: ["", "vscode", "phpstorm"],
|
|
972
|
-
coerce: (
|
|
981
|
+
coerce: (a) => a === "" ? ["vscode", "phpstorm"] : [a]
|
|
973
982
|
},
|
|
974
983
|
"experimental-blueprints-v2-runner": {
|
|
975
984
|
describe: "Use the experimental Blueprint V2 runner.",
|
|
@@ -988,7 +997,7 @@ Warning: Following symlinks will expose files outside mounted directories to Pla
|
|
|
988
997
|
phpmyadmin: {
|
|
989
998
|
describe: "Install phpMyAdmin for database management. The phpMyAdmin URL will be printed after boot. Optionally specify a custom URL path (default: /phpmyadmin).",
|
|
990
999
|
type: "string",
|
|
991
|
-
coerce: (
|
|
1000
|
+
coerce: (a) => a === "" ? "/phpmyadmin" : a
|
|
992
1001
|
}
|
|
993
1002
|
}, r = {
|
|
994
1003
|
port: {
|
|
@@ -1015,7 +1024,7 @@ Warning: Following symlinks will expose files outside mounted directories to Pla
|
|
|
1015
1024
|
describe: "PHP version to use.",
|
|
1016
1025
|
type: "string",
|
|
1017
1026
|
default: C,
|
|
1018
|
-
choices:
|
|
1027
|
+
choices: Q
|
|
1019
1028
|
},
|
|
1020
1029
|
wp: {
|
|
1021
1030
|
describe: "WordPress version to use.",
|
|
@@ -1079,16 +1088,16 @@ Warning: Following symlinks will expose files outside mounted directories to Pla
|
|
|
1079
1088
|
"define-number": t["define-number"],
|
|
1080
1089
|
// Tools
|
|
1081
1090
|
phpmyadmin: t.phpmyadmin
|
|
1082
|
-
},
|
|
1091
|
+
}, i = {
|
|
1083
1092
|
outfile: {
|
|
1084
1093
|
describe: "When building, write to this output file.",
|
|
1085
1094
|
type: "string",
|
|
1086
1095
|
default: "wordpress.zip"
|
|
1087
1096
|
}
|
|
1088
|
-
},
|
|
1097
|
+
}, s = We(e).usage("Usage: wp-playground <command> [options]").command(
|
|
1089
1098
|
"start",
|
|
1090
1099
|
"Start a local WordPress server with automatic project detection (recommended)",
|
|
1091
|
-
(
|
|
1100
|
+
(a) => a.usage(
|
|
1092
1101
|
`Usage: wp-playground start [options]
|
|
1093
1102
|
|
|
1094
1103
|
The easiest way to run WordPress locally. Automatically detects
|
|
@@ -1105,103 +1114,103 @@ Examples:
|
|
|
1105
1114
|
).command(
|
|
1106
1115
|
"server",
|
|
1107
1116
|
"Start a local WordPress server (advanced, low-level)",
|
|
1108
|
-
(
|
|
1117
|
+
(a) => a.options({
|
|
1109
1118
|
...t,
|
|
1110
1119
|
...r
|
|
1111
1120
|
})
|
|
1112
1121
|
).command(
|
|
1113
1122
|
"run-blueprint",
|
|
1114
1123
|
"Execute a Blueprint without starting a server",
|
|
1115
|
-
(
|
|
1124
|
+
(a) => a.options({ ...t })
|
|
1116
1125
|
).command(
|
|
1117
1126
|
"build-snapshot",
|
|
1118
1127
|
"Build a ZIP snapshot of a WordPress site based on a Blueprint",
|
|
1119
|
-
(
|
|
1128
|
+
(a) => a.options({
|
|
1120
1129
|
...t,
|
|
1121
|
-
...
|
|
1130
|
+
...i
|
|
1122
1131
|
})
|
|
1123
1132
|
).demandCommand(1, "Please specify a command").strictCommands().conflicts(
|
|
1124
1133
|
"experimental-unsafe-ide-integration",
|
|
1125
1134
|
"experimental-devtools"
|
|
1126
|
-
).showHelpOnFail(!1).fail((
|
|
1127
|
-
if (
|
|
1128
|
-
throw
|
|
1129
|
-
|
|
1130
|
-
` +
|
|
1131
|
-
}).strictOptions().check(async (
|
|
1132
|
-
if (
|
|
1135
|
+
).showHelpOnFail(!1).fail((a, m, y) => {
|
|
1136
|
+
if (m)
|
|
1137
|
+
throw m;
|
|
1138
|
+
a && a.includes("Please specify a command") && (y.showHelp(), console.error(`
|
|
1139
|
+
` + a), process.exit(1)), console.error(a), process.exit(1);
|
|
1140
|
+
}).strictOptions().check(async (a) => {
|
|
1141
|
+
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" && !wt(a.wp))
|
|
1133
1142
|
try {
|
|
1134
|
-
new URL(
|
|
1143
|
+
new URL(a.wp);
|
|
1135
1144
|
} catch {
|
|
1136
1145
|
throw new Error(
|
|
1137
1146
|
'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"'
|
|
1138
1147
|
);
|
|
1139
1148
|
}
|
|
1140
|
-
const
|
|
1141
|
-
if (typeof
|
|
1149
|
+
const m = a["site-url"];
|
|
1150
|
+
if (typeof m == "string" && m.trim() !== "")
|
|
1142
1151
|
try {
|
|
1143
|
-
new URL(
|
|
1152
|
+
new URL(m);
|
|
1144
1153
|
} catch {
|
|
1145
1154
|
throw new Error(
|
|
1146
|
-
`Invalid site-url "${
|
|
1155
|
+
`Invalid site-url "${m}". Please provide a valid URL (e.g., http://localhost:8080 or https://example.com)`
|
|
1147
1156
|
);
|
|
1148
1157
|
}
|
|
1149
|
-
if (
|
|
1158
|
+
if (a["auto-mount"]) {
|
|
1150
1159
|
let y = !1;
|
|
1151
1160
|
try {
|
|
1152
1161
|
y = c.statSync(
|
|
1153
|
-
|
|
1162
|
+
a["auto-mount"]
|
|
1154
1163
|
).isDirectory();
|
|
1155
1164
|
} catch {
|
|
1156
1165
|
y = !1;
|
|
1157
1166
|
}
|
|
1158
1167
|
if (!y)
|
|
1159
1168
|
throw new Error(
|
|
1160
|
-
`The specified --auto-mount path is not a directory: '${
|
|
1169
|
+
`The specified --auto-mount path is not a directory: '${a["auto-mount"]}'.`
|
|
1161
1170
|
);
|
|
1162
1171
|
}
|
|
1163
|
-
if (
|
|
1172
|
+
if (a["experimental-blueprints-v2-runner"] === !0)
|
|
1164
1173
|
throw new Error(
|
|
1165
1174
|
"Blueprints v2 are temporarily disabled while we rework their runtime implementation."
|
|
1166
1175
|
);
|
|
1167
|
-
if (
|
|
1176
|
+
if (a.mode !== void 0)
|
|
1168
1177
|
throw new Error(
|
|
1169
1178
|
"The --mode option requires the --experimentalBlueprintsV2Runner flag."
|
|
1170
1179
|
);
|
|
1171
1180
|
return !0;
|
|
1172
1181
|
});
|
|
1173
|
-
|
|
1174
|
-
const
|
|
1182
|
+
s.wrap(s.terminalWidth());
|
|
1183
|
+
const n = await s.argv, l = n._[0];
|
|
1175
1184
|
["start", "run-blueprint", "server", "build-snapshot"].includes(
|
|
1176
1185
|
l
|
|
1177
|
-
) || (
|
|
1178
|
-
const d =
|
|
1186
|
+
) || (s.showHelp(), process.exit(1));
|
|
1187
|
+
const d = n.define || {};
|
|
1179
1188
|
!("WP_DEBUG" in d) && !("WP_DEBUG_LOG" in d) && !("WP_DEBUG_DISPLAY" in d) && (d.WP_DEBUG = "true", d.WP_DEBUG_LOG = "true", d.WP_DEBUG_DISPLAY = "true");
|
|
1180
|
-
const
|
|
1181
|
-
...
|
|
1189
|
+
const x = {
|
|
1190
|
+
...n,
|
|
1182
1191
|
define: d,
|
|
1183
1192
|
command: l,
|
|
1184
1193
|
mount: [
|
|
1185
|
-
...
|
|
1186
|
-
...
|
|
1194
|
+
...n.mount || [],
|
|
1195
|
+
...n["mount-dir"] || []
|
|
1187
1196
|
],
|
|
1188
1197
|
"mount-before-install": [
|
|
1189
|
-
...
|
|
1190
|
-
...
|
|
1198
|
+
...n["mount-before-install"] || [],
|
|
1199
|
+
...n["mount-dir-before-install"] || []
|
|
1191
1200
|
]
|
|
1192
|
-
},
|
|
1193
|
-
|
|
1201
|
+
}, S = await Dt(x);
|
|
1202
|
+
S === void 0 && process.exit(0);
|
|
1194
1203
|
const p = /* @__PURE__ */ (() => {
|
|
1195
|
-
let
|
|
1204
|
+
let a;
|
|
1196
1205
|
return async () => {
|
|
1197
|
-
|
|
1206
|
+
a === void 0 && (a = S[Symbol.asyncDispose]()), await a, process.exit(0);
|
|
1198
1207
|
};
|
|
1199
1208
|
})();
|
|
1200
1209
|
return process.on("SIGINT", p), process.on("SIGTERM", p), {
|
|
1201
1210
|
[Symbol.asyncDispose]: async () => {
|
|
1202
|
-
process.off("SIGINT", p), process.off("SIGTERM", p), await
|
|
1211
|
+
process.off("SIGINT", p), process.off("SIGTERM", p), await S[Symbol.asyncDispose]();
|
|
1203
1212
|
},
|
|
1204
|
-
[he]: { cliServer:
|
|
1213
|
+
[he]: { cliServer: S }
|
|
1205
1214
|
};
|
|
1206
1215
|
} catch (t) {
|
|
1207
1216
|
if (console.error(t), !(t instanceof Error))
|
|
@@ -1210,10 +1219,10 @@ Examples:
|
|
|
1210
1219
|
be(t);
|
|
1211
1220
|
else {
|
|
1212
1221
|
const o = [];
|
|
1213
|
-
let
|
|
1222
|
+
let i = t;
|
|
1214
1223
|
do
|
|
1215
|
-
o.push(
|
|
1216
|
-
while (
|
|
1224
|
+
o.push(i.message), i = i.cause;
|
|
1225
|
+
while (i instanceof Error);
|
|
1217
1226
|
console.error(
|
|
1218
1227
|
"\x1B[1m" + o.join(" caused by: ") + "\x1B[0m"
|
|
1219
1228
|
);
|
|
@@ -1221,18 +1230,18 @@ Examples:
|
|
|
1221
1230
|
process.exit(1);
|
|
1222
1231
|
}
|
|
1223
1232
|
}
|
|
1224
|
-
function
|
|
1233
|
+
function ie(e, t) {
|
|
1225
1234
|
return e.find(
|
|
1226
1235
|
(r) => r.vfsPath.replace(/\/$/, "") === t.replace(/\/$/, "")
|
|
1227
1236
|
);
|
|
1228
1237
|
}
|
|
1229
|
-
const he = Symbol("playground-cli-testing"), k = (e) => process.stdout.isTTY ? "\x1B[1m" + e + "\x1B[0m" : e,
|
|
1230
|
-
async function
|
|
1238
|
+
const he = Symbol("playground-cli-testing"), k = (e) => process.stdout.isTTY ? "\x1B[1m" + e + "\x1B[0m" : e, At = (e) => process.stdout.isTTY ? "\x1B[31m" + e + "\x1B[0m" : e, Ct = (e) => process.stdout.isTTY ? `\x1B[2m${e}\x1B[0m` : e, F = (e) => process.stdout.isTTY ? `\x1B[3m${e}\x1B[0m` : e, se = (e) => process.stdout.isTTY ? `\x1B[33m${e}\x1B[0m` : e;
|
|
1239
|
+
async function Dt(e) {
|
|
1231
1240
|
let t;
|
|
1232
|
-
const r = e.internalCookieStore ? new ge() : void 0, o = [],
|
|
1233
|
-
if (e.command === "start" && (e =
|
|
1241
|
+
const r = e.internalCookieStore ? new ge() : void 0, o = [], i = /* @__PURE__ */ new Map();
|
|
1242
|
+
if (e.command === "start" && (e = Rt(e)), e.autoMount !== void 0 && (e.autoMount === "" && (e = { ...e, autoMount: process.cwd() }), e = ue(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) {
|
|
1234
1243
|
const p = Object.values(me).find(
|
|
1235
|
-
(
|
|
1244
|
+
(a) => a.name === e.verbosity
|
|
1236
1245
|
).severity;
|
|
1237
1246
|
g.setSeverityFilterLevel(p);
|
|
1238
1247
|
}
|
|
@@ -1248,10 +1257,10 @@ async function Mt(e) {
|
|
|
1248
1257
|
}
|
|
1249
1258
|
];
|
|
1250
1259
|
}
|
|
1251
|
-
const
|
|
1260
|
+
const s = new Mt({
|
|
1252
1261
|
verbosity: e.verbosity || "normal"
|
|
1253
1262
|
});
|
|
1254
|
-
e.command === "server" && (
|
|
1263
|
+
e.command === "server" && (s.printBanner(), s.printConfig({
|
|
1255
1264
|
phpVersion: e.php || C,
|
|
1256
1265
|
wpVersion: e.wp || "latest",
|
|
1257
1266
|
port: e.port || 9400,
|
|
@@ -1265,53 +1274,53 @@ async function Mt(e) {
|
|
|
1265
1274
|
],
|
|
1266
1275
|
blueprint: typeof e.blueprint == "string" ? e.blueprint : void 0
|
|
1267
1276
|
}));
|
|
1268
|
-
const
|
|
1269
|
-
let d = !1,
|
|
1270
|
-
const
|
|
1271
|
-
port:
|
|
1272
|
-
onBind: async (p,
|
|
1273
|
-
const
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
),
|
|
1277
|
+
const n = e.command === "server" ? e.port ?? 9400 : 0, l = new Pe();
|
|
1278
|
+
let d = !1, x = !0;
|
|
1279
|
+
const S = await ct({
|
|
1280
|
+
port: n,
|
|
1281
|
+
onBind: async (p, a) => {
|
|
1282
|
+
const m = "127.0.0.1", y = `http://${m}:${a}`, D = e["site-url"] || y, R = Math.max(
|
|
1283
|
+
Re().length - 1,
|
|
1284
|
+
Bt
|
|
1285
|
+
), V = "-playground-cli-site-", T = await xt(V);
|
|
1277
1286
|
g.debug(`Native temp dir for VFS root: ${T.path}`);
|
|
1278
|
-
const M = "WP Playground CLI - Listen for Xdebug",
|
|
1279
|
-
if (await
|
|
1280
|
-
await
|
|
1287
|
+
const M = "WP Playground CLI - Listen for Xdebug", Y = ".playground-xdebug-root", q = u.join(process.cwd(), Y);
|
|
1288
|
+
if (await Qe(q), e.xdebug && e.experimentalUnsafeIdeIntegration) {
|
|
1289
|
+
await Xe(
|
|
1281
1290
|
T.path,
|
|
1282
|
-
|
|
1291
|
+
q,
|
|
1283
1292
|
process.platform
|
|
1284
1293
|
);
|
|
1285
|
-
const
|
|
1286
|
-
hostPath: u.join(".", u.sep,
|
|
1294
|
+
const h = {
|
|
1295
|
+
hostPath: u.join(".", u.sep, Y),
|
|
1287
1296
|
vfsPath: "/"
|
|
1288
1297
|
};
|
|
1289
1298
|
try {
|
|
1290
|
-
await
|
|
1291
|
-
const w = typeof e.xdebug == "object" ? e.xdebug : void 0,
|
|
1299
|
+
await Ze(M, process.cwd());
|
|
1300
|
+
const w = typeof e.xdebug == "object" ? e.xdebug : void 0, f = await Je({
|
|
1292
1301
|
name: M,
|
|
1293
|
-
host:
|
|
1294
|
-
port:
|
|
1302
|
+
host: m,
|
|
1303
|
+
port: a,
|
|
1295
1304
|
ides: e.experimentalUnsafeIdeIntegration,
|
|
1296
1305
|
cwd: process.cwd(),
|
|
1297
1306
|
mounts: [
|
|
1298
|
-
|
|
1307
|
+
h,
|
|
1299
1308
|
...e["mount-before-install"] || [],
|
|
1300
1309
|
...e.mount || []
|
|
1301
1310
|
],
|
|
1302
1311
|
ideKey: w?.ideKey
|
|
1303
|
-
}), b = e.experimentalUnsafeIdeIntegration, P = b.includes("vscode"), v = b.includes("phpstorm"), $ = Object.values(
|
|
1312
|
+
}), b = e.experimentalUnsafeIdeIntegration, P = b.includes("vscode"), v = b.includes("phpstorm"), $ = Object.values(f);
|
|
1304
1313
|
console.log(""), $.length > 0 ? (console.log(k("Xdebug configured successfully")), console.log(
|
|
1305
|
-
|
|
1314
|
+
se("Updated IDE config: ") + $.join(" ")
|
|
1306
1315
|
), console.log(
|
|
1307
|
-
|
|
1308
|
-
|
|
1316
|
+
se("Playground source root: ") + ".playground-xdebug-root" + F(
|
|
1317
|
+
Ct(
|
|
1309
1318
|
" – you can set breakpoints and preview Playground's VFS structure in there."
|
|
1310
1319
|
)
|
|
1311
1320
|
)
|
|
1312
1321
|
)) : (console.log(k("Xdebug configuration failed.")), console.log(
|
|
1313
1322
|
"No IDE-specific project settings directory was found in the current working directory."
|
|
1314
|
-
)), console.log(""), P &&
|
|
1323
|
+
)), console.log(""), P && f.vscode && (console.log(k("VS Code / Cursor instructions:")), console.log(
|
|
1315
1324
|
" 1. Ensure you have installed an IDE extension for PHP Debugging"
|
|
1316
1325
|
), console.log(
|
|
1317
1326
|
` (The ${k("PHP Debug")} extension by ${k(
|
|
@@ -1327,7 +1336,7 @@ async function Mt(e) {
|
|
|
1327
1336
|
" 5. Set a breakpoint. For example, in .playground-xdebug-root/wordpress/index.php"
|
|
1328
1337
|
), console.log(
|
|
1329
1338
|
" 6. Visit Playground in your browser to hit the breakpoint"
|
|
1330
|
-
), v && console.log("")), v &&
|
|
1339
|
+
), v && console.log("")), v && f.phpstorm && (console.log(k("PhpStorm instructions:")), console.log(
|
|
1331
1340
|
` 1. Choose "${F(
|
|
1332
1341
|
M
|
|
1333
1342
|
)}" debug configuration in the toolbar`
|
|
@@ -1343,13 +1352,13 @@ async function Mt(e) {
|
|
|
1343
1352
|
}
|
|
1344
1353
|
}
|
|
1345
1354
|
const fe = u.dirname(T.path), we = 2 * 24 * 60 * 60 * 1e3;
|
|
1346
|
-
|
|
1347
|
-
|
|
1355
|
+
It(
|
|
1356
|
+
V,
|
|
1348
1357
|
we,
|
|
1349
1358
|
fe
|
|
1350
1359
|
);
|
|
1351
|
-
const
|
|
1352
|
-
|
|
1360
|
+
const z = u.join(T.path, "internal");
|
|
1361
|
+
_(z);
|
|
1353
1362
|
const ye = [
|
|
1354
1363
|
"wordpress",
|
|
1355
1364
|
"tools",
|
|
@@ -1362,37 +1371,37 @@ async function Mt(e) {
|
|
|
1362
1371
|
"tmp",
|
|
1363
1372
|
"home"
|
|
1364
1373
|
];
|
|
1365
|
-
for (const
|
|
1366
|
-
const w = (b) => b.vfsPath === `/${
|
|
1374
|
+
for (const h of ye) {
|
|
1375
|
+
const w = (b) => b.vfsPath === `/${h}`;
|
|
1367
1376
|
if (!(e["mount-before-install"]?.some(w) || e.mount?.some(w))) {
|
|
1368
1377
|
const b = u.join(
|
|
1369
1378
|
T.path,
|
|
1370
|
-
|
|
1379
|
+
h
|
|
1371
1380
|
);
|
|
1372
|
-
|
|
1373
|
-
vfsPath: `/${
|
|
1381
|
+
_(b), e["mount-before-install"] === void 0 && (e["mount-before-install"] = []), e["mount-before-install"].unshift({
|
|
1382
|
+
vfsPath: `/${h}`,
|
|
1374
1383
|
hostPath: b
|
|
1375
1384
|
});
|
|
1376
1385
|
}
|
|
1377
1386
|
}
|
|
1378
1387
|
if (e["mount-before-install"])
|
|
1379
|
-
for (const
|
|
1388
|
+
for (const h of e["mount-before-install"])
|
|
1380
1389
|
g.debug(
|
|
1381
|
-
`Mount before WP install: ${
|
|
1390
|
+
`Mount before WP install: ${h.vfsPath} -> ${h.hostPath}`
|
|
1382
1391
|
);
|
|
1383
1392
|
if (e.mount)
|
|
1384
|
-
for (const
|
|
1393
|
+
for (const h of e.mount)
|
|
1385
1394
|
g.debug(
|
|
1386
|
-
`Mount after WP install: ${
|
|
1395
|
+
`Mount after WP install: ${h.vfsPath} -> ${h.hostPath}`
|
|
1387
1396
|
);
|
|
1388
1397
|
let E;
|
|
1389
|
-
e["experimental-blueprints-v2-runner"] ? E = new
|
|
1398
|
+
e["experimental-blueprints-v2-runner"] ? E = new bt(e, {
|
|
1390
1399
|
siteUrl: D,
|
|
1391
|
-
cliOutput:
|
|
1392
|
-
}) : (E = new
|
|
1400
|
+
cliOutput: s
|
|
1401
|
+
}) : (E = new St(e, {
|
|
1393
1402
|
siteUrl: D,
|
|
1394
|
-
cliOutput:
|
|
1395
|
-
}), typeof e.blueprint == "string" && (e.blueprint = await
|
|
1403
|
+
cliOutput: s
|
|
1404
|
+
}), typeof e.blueprint == "string" && (e.blueprint = await yt({
|
|
1396
1405
|
sourceString: e.blueprint,
|
|
1397
1406
|
blueprintMayReadAdjacentFiles: e["blueprint-may-read-adjacent-files"] === !0
|
|
1398
1407
|
})));
|
|
@@ -1400,51 +1409,51 @@ async function Mt(e) {
|
|
|
1400
1409
|
const B = async function() {
|
|
1401
1410
|
W || (W = !0, await Promise.all(
|
|
1402
1411
|
o.map(async (w) => {
|
|
1403
|
-
await
|
|
1412
|
+
await i.get(w)?.dispose(), await w.worker.terminate();
|
|
1404
1413
|
})
|
|
1405
1414
|
), p && await new Promise((w) => {
|
|
1406
1415
|
p.close(w), p.closeAllConnections();
|
|
1407
1416
|
}), await T.cleanup());
|
|
1408
1417
|
};
|
|
1409
1418
|
try {
|
|
1410
|
-
const
|
|
1411
|
-
for (let
|
|
1412
|
-
const b =
|
|
1419
|
+
const h = [], w = E.getWorkerType();
|
|
1420
|
+
for (let f = 0; f < R; f++) {
|
|
1421
|
+
const b = Wt(w, {
|
|
1413
1422
|
onExit: (P) => {
|
|
1414
1423
|
W || P === 0 && g.error(
|
|
1415
|
-
`Worker ${
|
|
1424
|
+
`Worker ${f} exited with code ${P}
|
|
1416
1425
|
`
|
|
1417
1426
|
);
|
|
1418
1427
|
}
|
|
1419
1428
|
}).then(
|
|
1420
1429
|
async (P) => {
|
|
1421
1430
|
o.push(P);
|
|
1422
|
-
const v = await
|
|
1431
|
+
const v = await Lt(l), $ = await E.bootRequestHandler({
|
|
1423
1432
|
worker: P,
|
|
1424
1433
|
fileLockManagerPort: v,
|
|
1425
|
-
nativeInternalDirPath:
|
|
1434
|
+
nativeInternalDirPath: z
|
|
1426
1435
|
});
|
|
1427
|
-
return
|
|
1436
|
+
return i.set(
|
|
1428
1437
|
P,
|
|
1429
1438
|
$
|
|
1430
1439
|
), [P, $];
|
|
1431
1440
|
}
|
|
1432
1441
|
);
|
|
1433
|
-
|
|
1442
|
+
h.push(b), f === 0 && await b;
|
|
1434
1443
|
}
|
|
1435
|
-
await Promise.all(
|
|
1444
|
+
await Promise.all(h), t = ve(
|
|
1436
1445
|
o.map(
|
|
1437
|
-
(
|
|
1446
|
+
(f) => i.get(f)
|
|
1438
1447
|
)
|
|
1439
1448
|
);
|
|
1440
1449
|
{
|
|
1441
|
-
const
|
|
1442
|
-
if (await
|
|
1450
|
+
const f = new le(), b = f.port1, P = f.port2;
|
|
1451
|
+
if (await Se(
|
|
1443
1452
|
{
|
|
1444
1453
|
applyPostInstallMountsToAllWorkers: async () => {
|
|
1445
1454
|
await Promise.all(
|
|
1446
1455
|
Array.from(
|
|
1447
|
-
|
|
1456
|
+
i.values()
|
|
1448
1457
|
).map(
|
|
1449
1458
|
(v) => v.mountAfterWordPressInstall(
|
|
1450
1459
|
e.mount || []
|
|
@@ -1470,27 +1479,27 @@ async function Mt(e) {
|
|
|
1470
1479
|
if (e.phpmyadmin && !await t.fileExists(
|
|
1471
1480
|
`${ee}/index.php`
|
|
1472
1481
|
)) {
|
|
1473
|
-
const v = await
|
|
1482
|
+
const v = await et(), $ = await ae({ steps: v });
|
|
1474
1483
|
await J($, t);
|
|
1475
1484
|
}
|
|
1476
1485
|
if (e.command === "build-snapshot") {
|
|
1477
|
-
await
|
|
1486
|
+
await Ft(t, e.outfile), s.printStatus(`Exported to ${e.outfile}`), await B();
|
|
1478
1487
|
return;
|
|
1479
1488
|
} else if (e.command === "run-blueprint") {
|
|
1480
|
-
|
|
1489
|
+
s.finishProgress("Done"), await B();
|
|
1481
1490
|
return;
|
|
1482
1491
|
}
|
|
1483
1492
|
}
|
|
1484
|
-
if (
|
|
1485
|
-
const
|
|
1493
|
+
if (s.finishProgress(), s.printReady(y, R), e.phpmyadmin) {
|
|
1494
|
+
const f = u.join(
|
|
1486
1495
|
e.phpmyadmin,
|
|
1487
|
-
|
|
1496
|
+
tt
|
|
1488
1497
|
);
|
|
1489
|
-
|
|
1490
|
-
new URL(
|
|
1498
|
+
s.printPhpMyAdminUrl(
|
|
1499
|
+
new URL(f, y).toString()
|
|
1491
1500
|
);
|
|
1492
1501
|
}
|
|
1493
|
-
return e.xdebug && e.experimentalDevtools && (await
|
|
1502
|
+
return e.xdebug && e.experimentalDevtools && (await Ve({
|
|
1494
1503
|
phpInstance: t,
|
|
1495
1504
|
phpRoot: "/wordpress"
|
|
1496
1505
|
})).start(), {
|
|
@@ -1502,31 +1511,33 @@ async function Mt(e) {
|
|
|
1502
1511
|
workerThreadCount: R
|
|
1503
1512
|
}
|
|
1504
1513
|
};
|
|
1505
|
-
} catch (
|
|
1514
|
+
} catch (h) {
|
|
1506
1515
|
if (e.verbosity !== "debug")
|
|
1507
|
-
throw
|
|
1516
|
+
throw h;
|
|
1508
1517
|
let w = "";
|
|
1509
|
-
throw await t?.fileExists(
|
|
1518
|
+
throw await t?.fileExists(G) && (w = await t.readFileAsText(G)), await B(), new Error(w, { cause: h });
|
|
1510
1519
|
}
|
|
1511
1520
|
},
|
|
1512
1521
|
async handleRequest(p) {
|
|
1513
1522
|
if (!d)
|
|
1514
|
-
return
|
|
1523
|
+
return X.forHttpCode(
|
|
1515
1524
|
502,
|
|
1516
1525
|
"WordPress is not ready yet"
|
|
1517
1526
|
);
|
|
1518
|
-
if (
|
|
1519
|
-
|
|
1520
|
-
const
|
|
1527
|
+
if (x) {
|
|
1528
|
+
x = !1;
|
|
1529
|
+
const m = {
|
|
1521
1530
|
"Content-Type": ["text/plain"],
|
|
1522
1531
|
"Content-Length": ["0"],
|
|
1523
1532
|
Location: [p.url]
|
|
1524
1533
|
};
|
|
1525
1534
|
return p.headers?.cookie?.includes(
|
|
1526
1535
|
"playground_auto_login_already_happened"
|
|
1527
|
-
) && (
|
|
1536
|
+
) && (m["Set-Cookie"] = [
|
|
1528
1537
|
"playground_auto_login_already_happened=1; Max-Age=0; Expires=Thu, 01 Jan 1970 00:00:00 GMT; Path=/"
|
|
1529
|
-
]),
|
|
1538
|
+
]), X.fromPHPResponse(
|
|
1539
|
+
new xe(302, m, new Uint8Array())
|
|
1540
|
+
);
|
|
1530
1541
|
}
|
|
1531
1542
|
r && (p = {
|
|
1532
1543
|
...p,
|
|
@@ -1540,24 +1551,26 @@ async function Mt(e) {
|
|
|
1540
1551
|
cookie: r.getCookieRequestHeader()
|
|
1541
1552
|
}
|
|
1542
1553
|
});
|
|
1543
|
-
const
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1554
|
+
const a = await t.requestStreamed(p);
|
|
1555
|
+
if (r) {
|
|
1556
|
+
const m = await a.headers;
|
|
1557
|
+
r.rememberCookiesFromResponseHeaders(m), delete m["set-cookie"];
|
|
1558
|
+
}
|
|
1559
|
+
return a;
|
|
1547
1560
|
}
|
|
1548
1561
|
});
|
|
1549
|
-
return
|
|
1562
|
+
return S && e.command === "start" && !e.skipBrowser && Ut(S.serverUrl), S;
|
|
1550
1563
|
}
|
|
1551
|
-
function
|
|
1564
|
+
function Rt(e) {
|
|
1552
1565
|
let t = { ...e, command: "server" };
|
|
1553
1566
|
e.noAutoMount || (t.autoMount = u.resolve(process.cwd(), t.path ?? ""), t = ue(t), delete t.autoMount);
|
|
1554
|
-
const r =
|
|
1567
|
+
const r = ie(
|
|
1555
1568
|
t["mount-before-install"] || [],
|
|
1556
1569
|
"/wordpress"
|
|
1557
|
-
) ||
|
|
1570
|
+
) || ie(t.mount || [], "/wordpress");
|
|
1558
1571
|
if (r)
|
|
1559
1572
|
console.log("Site files stored at:", r?.hostPath), e.reset && (console.log(""), console.log(
|
|
1560
|
-
|
|
1573
|
+
At(
|
|
1561
1574
|
"This site is not managed by Playground CLI and cannot be reset."
|
|
1562
1575
|
)
|
|
1563
1576
|
), console.log(
|
|
@@ -1566,15 +1579,15 @@ function Bt(e) {
|
|
|
1566
1579
|
"You may still remove the site's directory manually if you wish."
|
|
1567
1580
|
), process.exit(1));
|
|
1568
1581
|
else {
|
|
1569
|
-
const o = t.autoMount || process.cwd(),
|
|
1570
|
-
|
|
1582
|
+
const o = t.autoMount || process.cwd(), i = Ke("sha256").update(o).digest("hex"), s = j.homedir(), n = u.join(
|
|
1583
|
+
s,
|
|
1571
1584
|
".wordpress-playground/sites",
|
|
1572
|
-
|
|
1585
|
+
i
|
|
1573
1586
|
);
|
|
1574
|
-
console.log("Site files stored at:",
|
|
1587
|
+
console.log("Site files stored at:", n), O(n) && e.reset && (console.log("Resetting site..."), ke(n, { recursive: !0 })), _(n, { recursive: !0 }), t["mount-before-install"] = [
|
|
1575
1588
|
...t["mount-before-install"] || [],
|
|
1576
|
-
{ vfsPath: "/wordpress", hostPath:
|
|
1577
|
-
], t.wordpressInstallMode =
|
|
1589
|
+
{ vfsPath: "/wordpress", hostPath: n }
|
|
1590
|
+
], t.wordpressInstallMode = Me(n).length === 0 ? (
|
|
1578
1591
|
// Only download WordPress on the first run when the site directory is still
|
|
1579
1592
|
// empty.
|
|
1580
1593
|
"download-and-install"
|
|
@@ -1585,38 +1598,38 @@ function Bt(e) {
|
|
|
1585
1598
|
}
|
|
1586
1599
|
return t;
|
|
1587
1600
|
}
|
|
1588
|
-
const
|
|
1589
|
-
function
|
|
1601
|
+
const H = new ot();
|
|
1602
|
+
function Wt(e, { onExit: t } = {}) {
|
|
1590
1603
|
let r;
|
|
1591
|
-
return e === "v1" ? r = new K(new URL("./worker-thread-v1.js", import.meta.url)) : r = new K(new URL("./worker-thread-v2.js", import.meta.url)), new Promise((o,
|
|
1592
|
-
const
|
|
1604
|
+
return e === "v1" ? r = new K(new URL("./worker-thread-v1.js", import.meta.url)) : r = new K(new URL("./worker-thread-v2.js", import.meta.url)), new Promise((o, i) => {
|
|
1605
|
+
const s = H.claim();
|
|
1593
1606
|
r.once("message", function(l) {
|
|
1594
1607
|
l.command === "worker-script-initialized" && o({
|
|
1595
|
-
processId:
|
|
1608
|
+
processId: s,
|
|
1596
1609
|
worker: r,
|
|
1597
1610
|
phpPort: l.phpPort
|
|
1598
1611
|
});
|
|
1599
1612
|
}), r.once("error", function(l) {
|
|
1600
|
-
|
|
1613
|
+
H.release(s), console.error(l);
|
|
1601
1614
|
const d = new Error(
|
|
1602
1615
|
`Worker failed to load worker. ${l.message ? `Original error: ${l.message}` : ""}`
|
|
1603
1616
|
);
|
|
1604
|
-
|
|
1617
|
+
i(d);
|
|
1605
1618
|
});
|
|
1606
|
-
let
|
|
1619
|
+
let n = !1;
|
|
1607
1620
|
r.once("spawn", () => {
|
|
1608
|
-
|
|
1621
|
+
n = !0;
|
|
1609
1622
|
}), r.once("exit", (l) => {
|
|
1610
|
-
|
|
1623
|
+
H.release(s), n || i(new Error(`Worker exited before spawning: ${l}`)), t?.(l);
|
|
1611
1624
|
});
|
|
1612
1625
|
});
|
|
1613
1626
|
}
|
|
1614
|
-
async function
|
|
1627
|
+
async function Lt(e) {
|
|
1615
1628
|
const { port1: t, port2: r } = new le();
|
|
1616
|
-
return await
|
|
1629
|
+
return await Ie(e, t), r;
|
|
1617
1630
|
}
|
|
1618
|
-
function
|
|
1619
|
-
const t =
|
|
1631
|
+
function Ut(e) {
|
|
1632
|
+
const t = j.platform();
|
|
1620
1633
|
let r;
|
|
1621
1634
|
switch (t) {
|
|
1622
1635
|
case "darwin":
|
|
@@ -1629,11 +1642,11 @@ function Dt(e) {
|
|
|
1629
1642
|
r = `xdg-open "${e}"`;
|
|
1630
1643
|
break;
|
|
1631
1644
|
}
|
|
1632
|
-
|
|
1645
|
+
Ye(r, (o) => {
|
|
1633
1646
|
o && g.debug(`Could not open browser: ${o.message}`);
|
|
1634
1647
|
});
|
|
1635
1648
|
}
|
|
1636
|
-
async function
|
|
1649
|
+
async function Ft(e, t) {
|
|
1637
1650
|
await e.run({
|
|
1638
1651
|
code: `<?php
|
|
1639
1652
|
$zip = new ZipArchive();
|
|
@@ -1659,12 +1672,12 @@ async function Rt(e, t) {
|
|
|
1659
1672
|
}
|
|
1660
1673
|
export {
|
|
1661
1674
|
me as L,
|
|
1662
|
-
|
|
1663
|
-
|
|
1675
|
+
cr as a,
|
|
1676
|
+
kt as b,
|
|
1664
1677
|
he as i,
|
|
1665
1678
|
pe as m,
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1679
|
+
mr as p,
|
|
1680
|
+
Dt as r,
|
|
1681
|
+
Wt as s
|
|
1669
1682
|
};
|
|
1670
|
-
//# sourceMappingURL=run-cli-
|
|
1683
|
+
//# sourceMappingURL=run-cli-C8e0UxH1.js.map
|