@wp-playground/cli 3.1.20 → 3.1.22
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/README.md +2 -1
- package/blueprints-v1/download.d.ts +1 -1
- package/blueprints-v1/worker-thread-v1.d.ts +5 -6
- package/blueprints-v2/worker-thread-v2.d.ts +3 -5
- package/cli-output.d.ts +8 -33
- package/cli.cjs +1 -1
- package/cli.js +1 -1
- package/index.cjs +1 -1
- package/index.js +4 -3
- package/package.json +15 -14
- package/php-extensions.d.ts +21 -0
- package/{run-cli-B9kBDU12.js → run-cli-CC9V0J3D.js} +665 -639
- package/run-cli-CC9V0J3D.js.map +1 -0
- package/run-cli-b6r6MAhq.cjs +65 -0
- package/run-cli-b6r6MAhq.cjs.map +1 -0
- package/run-cli.d.ts +19 -4
- package/sqlite-database-integration.zip +0 -0
- package/worker-thread-v1.cjs +2 -2
- package/worker-thread-v1.cjs.map +1 -1
- package/worker-thread-v1.js +62 -62
- package/worker-thread-v1.js.map +1 -1
- package/worker-thread-v2.cjs +8 -8
- package/worker-thread-v2.cjs.map +1 -1
- package/worker-thread-v2.js +99 -105
- package/worker-thread-v2.js.map +1 -1
- package/run-cli-B6Dm34vQ.cjs +0 -66
- package/run-cli-B6Dm34vQ.cjs.map +0 -1
- package/run-cli-B9kBDU12.js.map +0 -1
|
@@ -1,68 +1,68 @@
|
|
|
1
|
-
import { logger as
|
|
2
|
-
import { consumeAPI as
|
|
3
|
-
import { resolveRemoteBlueprint as
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
6
|
-
import { MessageChannel as
|
|
1
|
+
import { logger as h, LogSeverity as O, errorLogPath as te } from "@php-wasm/logger";
|
|
2
|
+
import { consumeAPI as fe, isLegacyPHPVersion as Y, ProcessIdAllocator as Te, AllPHPVersions as re, printDebugDetails as Ce, HttpCookieStore as Ae, FileLockManagerInMemory as De, StreamedPHPResponse as oe, SupportedPHPVersions as j, createObjectPoolProxy as Re, exposeAPI as Le, PHPResponse as We, exposeSyncAPI as Be } from "@php-wasm/universal";
|
|
3
|
+
import { resolveRemoteBlueprint as Ue, resolveRuntimeConfiguration as ne, compileBlueprintV1 as he, isBlueprintBundle as _e, runBlueprintV1Steps as ie } from "@wp-playground/blueprints";
|
|
4
|
+
import { RecommendedPHPVersion as T, zipDirectory as Ne } from "@wp-playground/common";
|
|
5
|
+
import c, { existsSync as Q, rmdirSync as He, mkdirSync as z, readdirSync as Fe } from "fs";
|
|
6
|
+
import { MessageChannel as we, Worker as se } from "worker_threads";
|
|
7
7
|
import { createNodeFsMountHandler as Oe } from "@php-wasm/node";
|
|
8
|
-
import d, { basename as _, join as
|
|
8
|
+
import d, { basename as _, join as X } from "path";
|
|
9
9
|
import { exec as be } from "child_process";
|
|
10
|
-
import { promisify as
|
|
11
|
-
import
|
|
12
|
-
import { Readable as
|
|
13
|
-
import { pipeline as
|
|
14
|
-
import
|
|
15
|
-
import { NodeJsFilesystem as
|
|
16
|
-
import { EmscriptenDownloadMonitor as
|
|
17
|
-
import { resolveWordPressRelease as
|
|
18
|
-
import
|
|
19
|
-
import { createRequire as
|
|
20
|
-
import
|
|
21
|
-
import { startBridge as
|
|
22
|
-
import { dir as
|
|
23
|
-
import { removeTempDirSymlink as
|
|
24
|
-
import { createHash as
|
|
25
|
-
import { PHPMYADMIN_INSTALL_PATH as ue, getPhpMyAdminInstallSteps as
|
|
10
|
+
import { promisify as je } from "util";
|
|
11
|
+
import ye from "express";
|
|
12
|
+
import { Readable as Ve } from "stream";
|
|
13
|
+
import { pipeline as qe } from "stream/promises";
|
|
14
|
+
import ze from "yargs";
|
|
15
|
+
import { NodeJsFilesystem as Ge, OverlayFilesystem as Ye, InMemoryFilesystem as Qe, ZipFilesystem as Xe } from "@wp-playground/storage";
|
|
16
|
+
import { EmscriptenDownloadMonitor as Ze, ProgressTracker as Je } from "@php-wasm/progress";
|
|
17
|
+
import { resolveWordPressRelease as Ke } from "@wp-playground/wordpress";
|
|
18
|
+
import C from "fs-extra";
|
|
19
|
+
import { createRequire as et } from "module";
|
|
20
|
+
import B from "os";
|
|
21
|
+
import { startBridge as tt } from "@php-wasm/xdebug-bridge";
|
|
22
|
+
import { dir as rt, setGracefulCleanup as ot } from "tmp-promise";
|
|
23
|
+
import { CLIOutput as nt, removeTempDirSymlink as it, createTempDirSymlink as ae, makeXdebugConfig as st, DEFAULT_PATH_SKIPPINGS as le, clearXdebugIDEConfig as at, addXdebugIDEConfig as lt } from "@php-wasm/cli-util";
|
|
24
|
+
import { createHash as ut } from "crypto";
|
|
25
|
+
import { PHPMYADMIN_INSTALL_PATH as ue, getPhpMyAdminInstallSteps as dt, PHPMYADMIN_ENTRY_PATH as pt } from "@wp-playground/tools";
|
|
26
26
|
import { jspi as de } from "wasm-feature-detect";
|
|
27
|
-
function
|
|
27
|
+
function V(e) {
|
|
28
28
|
const t = [];
|
|
29
29
|
for (const r of e) {
|
|
30
|
-
const
|
|
31
|
-
if (
|
|
30
|
+
const n = r.split(":");
|
|
31
|
+
if (n.length !== 2)
|
|
32
32
|
throw new Error(`Invalid mount format: ${r}.
|
|
33
33
|
Expected format: /host/path:/vfs/path.
|
|
34
34
|
If your path contains a colon, e.g. C:\\myplugin, use the --mount-dir option instead.
|
|
35
35
|
Example: --mount-dir C:\\my-plugin /wordpress/wp-content/plugins/my-plugin`);
|
|
36
|
-
const [
|
|
37
|
-
if (!
|
|
38
|
-
throw new Error(`Host path does not exist: ${
|
|
39
|
-
t.push({ hostPath:
|
|
36
|
+
const [i, o] = n;
|
|
37
|
+
if (!Q(i))
|
|
38
|
+
throw new Error(`Host path does not exist: ${i}`);
|
|
39
|
+
t.push({ hostPath: i, vfsPath: o });
|
|
40
40
|
}
|
|
41
41
|
return t;
|
|
42
42
|
}
|
|
43
|
-
function
|
|
43
|
+
function pe(e) {
|
|
44
44
|
if (e.length % 2 !== 0)
|
|
45
45
|
throw new Error("Invalid mount format. Expected: /host/path /vfs/path");
|
|
46
46
|
const t = [];
|
|
47
47
|
for (let r = 0; r < e.length; r += 2) {
|
|
48
|
-
const
|
|
49
|
-
if (!
|
|
50
|
-
throw new Error(`Host path does not exist: ${
|
|
48
|
+
const n = e[r], i = e[r + 1];
|
|
49
|
+
if (!Q(n))
|
|
50
|
+
throw new Error(`Host path does not exist: ${n}`);
|
|
51
51
|
t.push({
|
|
52
|
-
hostPath: d.resolve(process.cwd(),
|
|
53
|
-
vfsPath:
|
|
52
|
+
hostPath: d.resolve(process.cwd(), n),
|
|
53
|
+
vfsPath: i
|
|
54
54
|
});
|
|
55
55
|
}
|
|
56
56
|
return t;
|
|
57
57
|
}
|
|
58
|
-
async function
|
|
58
|
+
async function gr(e, t) {
|
|
59
59
|
for (const r of t)
|
|
60
60
|
await e.mount(
|
|
61
61
|
r.vfsPath,
|
|
62
62
|
Oe(r.hostPath)
|
|
63
63
|
);
|
|
64
64
|
}
|
|
65
|
-
const
|
|
65
|
+
const ce = {
|
|
66
66
|
step: "runPHP",
|
|
67
67
|
code: {
|
|
68
68
|
filename: "activate-theme.php",
|
|
@@ -81,265 +81,267 @@ const pe = {
|
|
|
81
81
|
`
|
|
82
82
|
}
|
|
83
83
|
};
|
|
84
|
-
function
|
|
85
|
-
|
|
84
|
+
function ge(e) {
|
|
85
|
+
if (typeof e.autoMount != "string")
|
|
86
|
+
return e;
|
|
87
|
+
const t = e.autoMount, r = [...e.mount || []], n = [...e["mount-before-install"] || []], i = {
|
|
86
88
|
...e,
|
|
87
89
|
mount: r,
|
|
88
|
-
"mount-before-install":
|
|
90
|
+
"mount-before-install": n,
|
|
89
91
|
"additional-blueprint-steps": [
|
|
90
92
|
...e["additional-blueprint-steps"] || []
|
|
91
93
|
]
|
|
92
94
|
};
|
|
93
|
-
if (
|
|
94
|
-
const
|
|
95
|
+
if (ht(t)) {
|
|
96
|
+
const a = `/wordpress/wp-content/plugins/${_(t)}`;
|
|
95
97
|
r.push({
|
|
96
98
|
hostPath: t,
|
|
97
|
-
vfsPath:
|
|
99
|
+
vfsPath: a,
|
|
98
100
|
autoMounted: !0
|
|
99
|
-
}),
|
|
101
|
+
}), i["additional-blueprint-steps"].push({
|
|
100
102
|
step: "activatePlugin",
|
|
101
103
|
pluginPath: `/wordpress/wp-content/plugins/${_(t)}`
|
|
102
104
|
});
|
|
103
|
-
} else if (
|
|
104
|
-
const
|
|
105
|
+
} else if (ft(t)) {
|
|
106
|
+
const o = _(t), a = `/wordpress/wp-content/themes/${o}`;
|
|
105
107
|
r.push({
|
|
106
108
|
hostPath: t,
|
|
107
|
-
vfsPath:
|
|
109
|
+
vfsPath: a,
|
|
108
110
|
autoMounted: !0
|
|
109
|
-
}),
|
|
111
|
+
}), i["additional-blueprint-steps"].push(
|
|
110
112
|
e["experimental-blueprints-v2-runner"] ? {
|
|
111
113
|
step: "activateTheme",
|
|
112
|
-
themeDirectoryName:
|
|
114
|
+
themeDirectoryName: o
|
|
113
115
|
} : {
|
|
114
116
|
step: "activateTheme",
|
|
115
|
-
themeFolderName:
|
|
117
|
+
themeFolderName: o
|
|
116
118
|
}
|
|
117
119
|
);
|
|
118
|
-
} else if (
|
|
119
|
-
const
|
|
120
|
-
for (const
|
|
121
|
-
|
|
122
|
-
hostPath:
|
|
123
|
-
vfsPath: `/wordpress/wp-content/${
|
|
120
|
+
} else if (mt(t)) {
|
|
121
|
+
const o = c.readdirSync(t);
|
|
122
|
+
for (const a of o)
|
|
123
|
+
a !== "index.php" && r.push({
|
|
124
|
+
hostPath: X(t, a),
|
|
125
|
+
vfsPath: `/wordpress/wp-content/${a}`,
|
|
124
126
|
autoMounted: !0
|
|
125
127
|
});
|
|
126
|
-
|
|
127
|
-
} else
|
|
128
|
+
i["additional-blueprint-steps"].push(ce);
|
|
129
|
+
} else ct(t) && (n.push({
|
|
128
130
|
hostPath: t,
|
|
129
131
|
vfsPath: "/wordpress",
|
|
130
132
|
autoMounted: !0
|
|
131
|
-
}),
|
|
132
|
-
return
|
|
133
|
+
}), i.mode = "apply-to-existing-site", i["additional-blueprint-steps"].push(ce), i.wordpressInstallMode || (i.wordpressInstallMode = "install-from-existing-files-if-needed"));
|
|
134
|
+
return i;
|
|
133
135
|
}
|
|
134
|
-
function
|
|
135
|
-
const t =
|
|
136
|
+
function ct(e) {
|
|
137
|
+
const t = c.readdirSync(e);
|
|
136
138
|
return t.includes("wp-admin") && t.includes("wp-includes") && t.includes("wp-content");
|
|
137
139
|
}
|
|
138
|
-
function
|
|
139
|
-
const t =
|
|
140
|
+
function mt(e) {
|
|
141
|
+
const t = c.readdirSync(e);
|
|
140
142
|
return t.includes("themes") || t.includes("plugins") || t.includes("mu-plugins") || t.includes("uploads");
|
|
141
143
|
}
|
|
142
|
-
function
|
|
143
|
-
if (!
|
|
144
|
+
function ft(e) {
|
|
145
|
+
if (!c.readdirSync(e).includes("style.css"))
|
|
144
146
|
return !1;
|
|
145
|
-
const r =
|
|
147
|
+
const r = c.readFileSync(X(e, "style.css"), "utf8");
|
|
146
148
|
return !!/^(?:[ \t]*<\?php)?[ \t/*#@]*Theme Name:(.*)$/im.exec(r);
|
|
147
149
|
}
|
|
148
|
-
function
|
|
149
|
-
const t =
|
|
150
|
-
return !!t.filter((
|
|
151
|
-
const
|
|
152
|
-
return !!r.exec(
|
|
150
|
+
function ht(e) {
|
|
151
|
+
const t = c.readdirSync(e), r = /^(?:[ \t]*<\?php)?[ \t/*#@]*Plugin Name:(.*)$/im;
|
|
152
|
+
return !!t.filter((i) => i.endsWith(".php")).find((i) => {
|
|
153
|
+
const o = c.readFileSync(X(e, i), "utf8");
|
|
154
|
+
return !!r.exec(o);
|
|
153
155
|
});
|
|
154
156
|
}
|
|
155
|
-
function
|
|
157
|
+
function wt(e) {
|
|
156
158
|
if (e.length % 2 !== 0)
|
|
157
159
|
throw new Error(
|
|
158
160
|
"Invalid constant definition format. Expected pairs of NAME value"
|
|
159
161
|
);
|
|
160
162
|
const t = {};
|
|
161
163
|
for (let r = 0; r < e.length; r += 2) {
|
|
162
|
-
const
|
|
163
|
-
if (!
|
|
164
|
+
const n = e[r], i = e[r + 1];
|
|
165
|
+
if (!n || !n.trim())
|
|
164
166
|
throw new Error("Constant name cannot be empty");
|
|
165
|
-
t[
|
|
167
|
+
t[n.trim()] = i;
|
|
166
168
|
}
|
|
167
169
|
return t;
|
|
168
170
|
}
|
|
169
|
-
function
|
|
171
|
+
function bt(e) {
|
|
170
172
|
if (e.length % 2 !== 0)
|
|
171
173
|
throw new Error(
|
|
172
174
|
"Invalid boolean constant definition format. Expected pairs of NAME value"
|
|
173
175
|
);
|
|
174
176
|
const t = {};
|
|
175
177
|
for (let r = 0; r < e.length; r += 2) {
|
|
176
|
-
const
|
|
177
|
-
if (!
|
|
178
|
+
const n = e[r], i = e[r + 1].trim().toLowerCase();
|
|
179
|
+
if (!n || !n.trim())
|
|
178
180
|
throw new Error("Constant name cannot be empty");
|
|
179
|
-
if (
|
|
180
|
-
t[
|
|
181
|
-
else if (
|
|
182
|
-
t[
|
|
181
|
+
if (i === "true" || i === "1")
|
|
182
|
+
t[n.trim()] = !0;
|
|
183
|
+
else if (i === "false" || i === "0")
|
|
184
|
+
t[n.trim()] = !1;
|
|
183
185
|
else
|
|
184
186
|
throw new Error(
|
|
185
|
-
`Invalid boolean value for constant "${
|
|
187
|
+
`Invalid boolean value for constant "${n}": "${i}". Must be "true", "false", "1", or "0".`
|
|
186
188
|
);
|
|
187
189
|
}
|
|
188
190
|
return t;
|
|
189
191
|
}
|
|
190
|
-
function
|
|
192
|
+
function yt(e) {
|
|
191
193
|
if (e.length % 2 !== 0)
|
|
192
194
|
throw new Error(
|
|
193
195
|
"Invalid number constant definition format. Expected pairs of NAME value"
|
|
194
196
|
);
|
|
195
197
|
const t = {};
|
|
196
198
|
for (let r = 0; r < e.length; r += 2) {
|
|
197
|
-
const
|
|
198
|
-
if (!
|
|
199
|
+
const n = e[r], i = e[r + 1].trim();
|
|
200
|
+
if (!n || !n.trim())
|
|
199
201
|
throw new Error("Constant name cannot be empty");
|
|
200
|
-
const
|
|
201
|
-
if (isNaN(
|
|
202
|
+
const o = Number(i);
|
|
203
|
+
if (isNaN(o))
|
|
202
204
|
throw new Error(
|
|
203
|
-
`Invalid number value for constant "${
|
|
205
|
+
`Invalid number value for constant "${n}": "${i}". Must be a valid number.`
|
|
204
206
|
);
|
|
205
|
-
t[
|
|
207
|
+
t[n.trim()] = o;
|
|
206
208
|
}
|
|
207
209
|
return t;
|
|
208
210
|
}
|
|
209
|
-
function
|
|
210
|
-
const
|
|
211
|
-
for (const u in
|
|
212
|
-
if (
|
|
211
|
+
function gt(e = {}, t = {}, r = {}) {
|
|
212
|
+
const n = {}, i = /* @__PURE__ */ new Set(), o = (a, l) => {
|
|
213
|
+
for (const u in a) {
|
|
214
|
+
if (i.has(u))
|
|
213
215
|
throw new Error(
|
|
214
216
|
`Constant "${u}" is defined multiple times across different --define-${l} flags`
|
|
215
217
|
);
|
|
216
|
-
|
|
218
|
+
i.add(u), n[u] = a[u];
|
|
217
219
|
}
|
|
218
220
|
};
|
|
219
|
-
return
|
|
221
|
+
return o(e, "string"), o(t, "bool"), o(r, "number"), n;
|
|
220
222
|
}
|
|
221
223
|
function Z(e) {
|
|
222
|
-
return
|
|
224
|
+
return gt(
|
|
223
225
|
e.define,
|
|
224
226
|
e["define-bool"],
|
|
225
227
|
e["define-number"]
|
|
226
228
|
);
|
|
227
229
|
}
|
|
228
|
-
const
|
|
229
|
-
function
|
|
230
|
+
const Pt = je(be);
|
|
231
|
+
function vt(e) {
|
|
230
232
|
return new Promise((t) => {
|
|
231
233
|
if (e === 0) return t(!1);
|
|
232
|
-
const r =
|
|
234
|
+
const r = ye().listen(e);
|
|
233
235
|
r.once("listening", () => r.close(() => t(!1))), r.once(
|
|
234
236
|
"error",
|
|
235
|
-
(
|
|
237
|
+
(n) => t(n.code === "EADDRINUSE")
|
|
236
238
|
);
|
|
237
239
|
});
|
|
238
240
|
}
|
|
239
|
-
async function
|
|
240
|
-
const t =
|
|
241
|
+
async function St(e) {
|
|
242
|
+
const t = ye(), r = await new Promise((a, l) => {
|
|
241
243
|
const u = t.listen(e.port, () => {
|
|
242
|
-
const
|
|
243
|
-
|
|
244
|
+
const f = u.address();
|
|
245
|
+
f === null || typeof f == "string" ? l(new Error("Server address is not available")) : a(u);
|
|
244
246
|
}).once("error", l);
|
|
245
247
|
});
|
|
246
|
-
t.use("/", async (
|
|
248
|
+
t.use("/", async (a, l) => {
|
|
247
249
|
try {
|
|
248
250
|
const u = {
|
|
249
|
-
url:
|
|
250
|
-
headers:
|
|
251
|
-
method:
|
|
252
|
-
body: await
|
|
253
|
-
},
|
|
254
|
-
await
|
|
251
|
+
url: a.url,
|
|
252
|
+
headers: kt(a),
|
|
253
|
+
method: a.method,
|
|
254
|
+
body: await Et(a)
|
|
255
|
+
}, f = await e.handleRequest(u);
|
|
256
|
+
await xt(f, l);
|
|
255
257
|
} catch (u) {
|
|
256
|
-
|
|
258
|
+
h.error(u), l.headersSent || (l.statusCode = 500, l.end("Internal Server Error"));
|
|
257
259
|
}
|
|
258
260
|
});
|
|
259
|
-
const
|
|
260
|
-
return
|
|
261
|
+
const i = r.address().port, o = process.env.CODESPACE_NAME;
|
|
262
|
+
return o && $t(i, o), await e.onBind(r, i);
|
|
261
263
|
}
|
|
262
|
-
async function
|
|
263
|
-
const [r,
|
|
264
|
+
async function xt(e, t) {
|
|
265
|
+
const [r, n] = await Promise.all([
|
|
264
266
|
e.headers,
|
|
265
267
|
e.httpStatusCode
|
|
266
268
|
]);
|
|
267
|
-
t.statusCode =
|
|
268
|
-
for (const
|
|
269
|
-
t.setHeader(
|
|
270
|
-
const
|
|
269
|
+
t.statusCode = n;
|
|
270
|
+
for (const o in r)
|
|
271
|
+
t.setHeader(o, r[o]);
|
|
272
|
+
const i = Ve.fromWeb(e.stdout);
|
|
271
273
|
try {
|
|
272
|
-
await
|
|
273
|
-
} catch (
|
|
274
|
-
if (
|
|
274
|
+
await qe(i, t);
|
|
275
|
+
} catch (o) {
|
|
276
|
+
if (o instanceof Error && "code" in o && (o.code === "ERR_STREAM_PREMATURE_CLOSE" || o.code === "ERR_STREAM_UNABLE_TO_PIPE"))
|
|
275
277
|
return;
|
|
276
|
-
throw
|
|
278
|
+
throw o;
|
|
277
279
|
}
|
|
278
280
|
}
|
|
279
|
-
const
|
|
281
|
+
const Et = async (e) => await new Promise((t) => {
|
|
280
282
|
const r = [];
|
|
281
|
-
e.on("data", (
|
|
282
|
-
r.push(
|
|
283
|
+
e.on("data", (n) => {
|
|
284
|
+
r.push(n);
|
|
283
285
|
}), e.on("end", () => {
|
|
284
286
|
t(new Uint8Array(Buffer.concat(r)));
|
|
285
287
|
});
|
|
286
288
|
});
|
|
287
|
-
async function
|
|
288
|
-
|
|
289
|
+
async function $t(e, t) {
|
|
290
|
+
h.log(`Publishing port ${e}...`);
|
|
289
291
|
const r = `gh codespace ports visibility ${e}:public -c ${t}`;
|
|
290
|
-
for (let
|
|
292
|
+
for (let n = 0; n < 10; n++)
|
|
291
293
|
try {
|
|
292
|
-
await
|
|
294
|
+
await Pt(r);
|
|
293
295
|
return;
|
|
294
296
|
} catch {
|
|
295
|
-
await new Promise((
|
|
297
|
+
await new Promise((i) => setTimeout(i, 2e3));
|
|
296
298
|
}
|
|
297
299
|
}
|
|
298
|
-
const
|
|
300
|
+
const kt = (e) => {
|
|
299
301
|
const t = {};
|
|
300
302
|
if (e.rawHeaders && e.rawHeaders.length)
|
|
301
303
|
for (let r = 0; r < e.rawHeaders.length; r += 2)
|
|
302
304
|
t[e.rawHeaders[r].toLowerCase()] = e.rawHeaders[r + 1];
|
|
303
305
|
return t;
|
|
304
306
|
};
|
|
305
|
-
function
|
|
307
|
+
function It(e) {
|
|
306
308
|
return /^latest$|^beta$|^trunk$|^nightly$|^(?:(\d+)\.(\d+)(?:\.(\d+))?)((?:-beta(?:\d+)?)|(?:-RC(?:\d+)?))?$/.test(e);
|
|
307
309
|
}
|
|
308
|
-
async function
|
|
310
|
+
async function Mt({
|
|
309
311
|
sourceString: e,
|
|
310
312
|
blueprintMayReadAdjacentFiles: t
|
|
311
313
|
}) {
|
|
312
314
|
if (!e)
|
|
313
315
|
return;
|
|
314
316
|
if (e.startsWith("http://") || e.startsWith("https://"))
|
|
315
|
-
return await
|
|
317
|
+
return await Ue(e);
|
|
316
318
|
let r = d.resolve(process.cwd(), e);
|
|
317
|
-
if (!
|
|
319
|
+
if (!c.existsSync(r))
|
|
318
320
|
throw new Error(`Blueprint file does not exist: ${r}`);
|
|
319
|
-
const
|
|
320
|
-
if (
|
|
321
|
+
const n = c.statSync(r);
|
|
322
|
+
if (n.isDirectory() && (r = d.join(r, "blueprint.json")), !n.isFile() && n.isSymbolicLink())
|
|
321
323
|
throw new Error(
|
|
322
324
|
`Blueprint path is neither a file nor a directory: ${r}`
|
|
323
325
|
);
|
|
324
|
-
const
|
|
325
|
-
switch (
|
|
326
|
+
const i = d.extname(r);
|
|
327
|
+
switch (i) {
|
|
326
328
|
case ".zip":
|
|
327
|
-
return
|
|
328
|
-
|
|
329
|
+
return Xe.fromArrayBuffer(
|
|
330
|
+
c.readFileSync(r).buffer
|
|
329
331
|
);
|
|
330
332
|
case ".json": {
|
|
331
|
-
const
|
|
333
|
+
const o = c.readFileSync(r, "utf-8");
|
|
332
334
|
try {
|
|
333
|
-
JSON.parse(
|
|
335
|
+
JSON.parse(o);
|
|
334
336
|
} catch {
|
|
335
337
|
throw new Error(
|
|
336
338
|
`Blueprint file at ${r} is not a valid JSON file`
|
|
337
339
|
);
|
|
338
340
|
}
|
|
339
|
-
const
|
|
340
|
-
return new
|
|
341
|
-
new
|
|
342
|
-
"blueprint.json":
|
|
341
|
+
const a = d.dirname(r), l = new Ge(a);
|
|
342
|
+
return new Ye([
|
|
343
|
+
new Qe({
|
|
344
|
+
"blueprint.json": o
|
|
343
345
|
}),
|
|
344
346
|
/**
|
|
345
347
|
* Wrap the NodeJS filesystem to prevent access to local files
|
|
@@ -360,11 +362,17 @@ You can allow this Blueprint to read files from the same parent directory by exp
|
|
|
360
362
|
}
|
|
361
363
|
default:
|
|
362
364
|
throw new Error(
|
|
363
|
-
`Unsupported blueprint file extension: ${
|
|
365
|
+
`Unsupported blueprint file extension: ${i}. Only .zip and .json files are supported.`
|
|
364
366
|
);
|
|
365
367
|
}
|
|
366
368
|
}
|
|
367
|
-
|
|
369
|
+
function Pe(e) {
|
|
370
|
+
const t = [];
|
|
371
|
+
return e.intl && t.push("intl"), e.redis && t.push("redis"), e.memcached && t.push("memcached"), e.xdebug && t.push(
|
|
372
|
+
typeof e.xdebug == "object" ? { name: "xdebug", options: e.xdebug } : "xdebug"
|
|
373
|
+
), t;
|
|
374
|
+
}
|
|
375
|
+
class Tt {
|
|
368
376
|
constructor(t, r) {
|
|
369
377
|
this.args = t, this.siteUrl = r.siteUrl, this.phpVersion = t.php, this.cliOutput = r.cliOutput;
|
|
370
378
|
}
|
|
@@ -372,79 +380,76 @@ class It {
|
|
|
372
380
|
return "v2";
|
|
373
381
|
}
|
|
374
382
|
async bootWordPress(t, r) {
|
|
375
|
-
const
|
|
383
|
+
const n = {
|
|
376
384
|
command: this.args.command,
|
|
377
385
|
siteUrl: this.siteUrl,
|
|
378
386
|
blueprint: this.args.blueprint,
|
|
379
387
|
workerPostInstallMountsPort: r
|
|
380
388
|
};
|
|
381
|
-
return await t.bootWordPress(
|
|
389
|
+
return await t.bootWordPress(n, r), t;
|
|
382
390
|
}
|
|
383
391
|
async bootRequestHandler({
|
|
384
392
|
worker: t,
|
|
385
393
|
fileLockManagerPort: r,
|
|
386
|
-
nativeInternalDirPath:
|
|
394
|
+
nativeInternalDirPath: n
|
|
387
395
|
}) {
|
|
388
|
-
const
|
|
389
|
-
await
|
|
390
|
-
const
|
|
396
|
+
const i = fe(t.phpPort);
|
|
397
|
+
await i.useFileLockManager(r);
|
|
398
|
+
const o = {
|
|
391
399
|
...this.args,
|
|
392
400
|
phpVersion: this.phpVersion,
|
|
393
401
|
siteUrl: this.siteUrl,
|
|
394
402
|
processId: t.processId,
|
|
395
403
|
trace: this.args.verbosity === "debug",
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
withMemcached: this.args.memcached,
|
|
399
|
-
withXdebug: !!this.args.xdebug,
|
|
400
|
-
nativeInternalDirPath: o,
|
|
404
|
+
extensions: Pe(this.args),
|
|
405
|
+
nativeInternalDirPath: n,
|
|
401
406
|
mountsBeforeWpInstall: this.args["mount-before-install"] || [],
|
|
402
407
|
mountsAfterWpInstall: this.args.mount || [],
|
|
403
408
|
constants: Z(this.args)
|
|
404
409
|
};
|
|
405
|
-
return await
|
|
410
|
+
return await i.bootWorker(o), i;
|
|
406
411
|
}
|
|
407
412
|
}
|
|
408
|
-
const
|
|
409
|
-
async function
|
|
410
|
-
const
|
|
411
|
-
let
|
|
412
|
-
if (!
|
|
413
|
-
const
|
|
414
|
-
|
|
413
|
+
const G = d.join(B.homedir(), ".wordpress-playground");
|
|
414
|
+
async function Ct(e = "trunk") {
|
|
415
|
+
const t = typeof __dirname < "u" ? __dirname : import.meta.dirname;
|
|
416
|
+
let r = d.join(t, "sqlite-database-integration.zip");
|
|
417
|
+
if (!C.existsSync(r)) {
|
|
418
|
+
const n = et(import.meta.url), i = d.dirname(
|
|
419
|
+
n.resolve("@wp-playground/wordpress-builds/package.json")
|
|
415
420
|
);
|
|
416
|
-
|
|
417
|
-
|
|
421
|
+
r = d.join(
|
|
422
|
+
i,
|
|
418
423
|
"src",
|
|
419
424
|
"sqlite-database-integration",
|
|
420
|
-
|
|
425
|
+
`sqlite-database-integration-${e}.zip`
|
|
421
426
|
);
|
|
422
427
|
}
|
|
423
|
-
return new File([await
|
|
428
|
+
return new File([await C.readFile(r)], d.basename(r));
|
|
424
429
|
}
|
|
425
|
-
async function
|
|
426
|
-
const
|
|
427
|
-
return
|
|
430
|
+
async function At(e, t, r) {
|
|
431
|
+
const n = d.join(G, t);
|
|
432
|
+
return C.existsSync(n) || (C.ensureDirSync(G), await Dt(e, n, r)), ve(n);
|
|
428
433
|
}
|
|
429
|
-
async function
|
|
430
|
-
const
|
|
434
|
+
async function Dt(e, t, r) {
|
|
435
|
+
const i = (await r.monitorFetch(fetch(e))).body.getReader(), o = `${t}.partial`, a = C.createWriteStream(o);
|
|
431
436
|
for (; ; ) {
|
|
432
|
-
const { done: l, value: u } = await
|
|
433
|
-
if (u &&
|
|
437
|
+
const { done: l, value: u } = await i.read();
|
|
438
|
+
if (u && a.write(u), l)
|
|
434
439
|
break;
|
|
435
440
|
}
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
}),
|
|
440
|
-
|
|
441
|
+
a.close(), a.closed || await new Promise((l, u) => {
|
|
442
|
+
a.on("finish", () => {
|
|
443
|
+
C.renameSync(o, t), l(null);
|
|
444
|
+
}), a.on("error", (f) => {
|
|
445
|
+
C.removeSync(o), u(f);
|
|
441
446
|
});
|
|
442
447
|
});
|
|
443
448
|
}
|
|
444
449
|
function ve(e, t) {
|
|
445
|
-
return new File([
|
|
450
|
+
return new File([C.readFileSync(e)], _(e));
|
|
446
451
|
}
|
|
447
|
-
class
|
|
452
|
+
class Rt {
|
|
448
453
|
constructor(t, r) {
|
|
449
454
|
this.args = t, this.siteUrl = r.siteUrl, this.cliOutput = r.cliOutput;
|
|
450
455
|
}
|
|
@@ -452,51 +457,59 @@ class At {
|
|
|
452
457
|
return "v1";
|
|
453
458
|
}
|
|
454
459
|
async bootWordPress(t, r) {
|
|
455
|
-
let
|
|
456
|
-
const
|
|
460
|
+
let n, i, o;
|
|
461
|
+
const a = new Ze();
|
|
457
462
|
if (this.args.wordpressInstallMode === "download-and-install") {
|
|
458
|
-
let
|
|
459
|
-
|
|
460
|
-
if (
|
|
463
|
+
let f = !1;
|
|
464
|
+
a.addEventListener("progress", (A) => {
|
|
465
|
+
if (f)
|
|
461
466
|
return;
|
|
462
|
-
const { loaded:
|
|
463
|
-
Math.min(100, 100 *
|
|
467
|
+
const { loaded: E, total: m } = A.detail, $ = Math.floor(
|
|
468
|
+
Math.min(100, 100 * E / m)
|
|
464
469
|
);
|
|
465
|
-
|
|
470
|
+
f = $ === 100, this.cliOutput.updateProgress(
|
|
466
471
|
"Downloading WordPress",
|
|
467
|
-
|
|
472
|
+
$
|
|
468
473
|
);
|
|
469
|
-
}),
|
|
470
|
-
|
|
471
|
-
`prebuilt-wp-content-for-wp-${
|
|
472
|
-
),
|
|
473
|
-
|
|
474
|
-
`${
|
|
475
|
-
|
|
476
|
-
),
|
|
477
|
-
`Resolved WordPress release URL: ${
|
|
474
|
+
}), n = await Ke(this.args.wp), o = d.join(
|
|
475
|
+
G,
|
|
476
|
+
`prebuilt-wp-content-for-wp-${n.version}.zip`
|
|
477
|
+
), i = c.existsSync(o) ? ve(o) : await At(
|
|
478
|
+
n.releaseUrl,
|
|
479
|
+
`${n.version}.zip`,
|
|
480
|
+
a
|
|
481
|
+
), h.debug(
|
|
482
|
+
`Resolved WordPress release URL: ${n?.releaseUrl}`
|
|
478
483
|
);
|
|
479
484
|
}
|
|
480
485
|
let l;
|
|
481
|
-
this.args.skipSqliteSetup
|
|
482
|
-
|
|
486
|
+
if (this.args.skipSqliteSetup)
|
|
487
|
+
h.debug("Skipping SQLite integration plugin setup..."), l = void 0;
|
|
488
|
+
else {
|
|
489
|
+
this.cliOutput.updateProgress("Preparing SQLite database");
|
|
490
|
+
const f = this.args.php || T, E = Y(f) ? "v3.0.0-rc.3-php52" : "trunk";
|
|
491
|
+
l = await Ct(E);
|
|
492
|
+
}
|
|
493
|
+
this.cliOutput.updateProgress("Booting WordPress");
|
|
494
|
+
const u = await ne(
|
|
483
495
|
this.getEffectiveBlueprint()
|
|
484
496
|
);
|
|
485
497
|
return await t.bootWordPress(
|
|
486
498
|
{
|
|
499
|
+
phpVersion: u.phpVersion,
|
|
487
500
|
wpVersion: u.wpVersion,
|
|
488
501
|
siteUrl: this.siteUrl,
|
|
489
502
|
wordpressInstallMode: this.args.wordpressInstallMode || "download-and-install",
|
|
490
|
-
wordPressZip:
|
|
503
|
+
wordPressZip: i && await i.arrayBuffer(),
|
|
491
504
|
sqliteIntegrationPluginZip: await l?.arrayBuffer(),
|
|
492
505
|
constants: Z(this.args)
|
|
493
506
|
},
|
|
494
507
|
r
|
|
495
|
-
),
|
|
496
|
-
|
|
508
|
+
), o && !this.args["mount-before-install"] && !c.existsSync(o) && (this.cliOutput.updateProgress("Caching WordPress for next boot"), c.writeFileSync(
|
|
509
|
+
o,
|
|
497
510
|
// Comlink proxy is not assignable to UniversalPHP but
|
|
498
511
|
// proxies all method calls transparently at runtime.
|
|
499
|
-
await
|
|
512
|
+
await Ne(
|
|
500
513
|
t,
|
|
501
514
|
"/wordpress"
|
|
502
515
|
)
|
|
@@ -505,42 +518,39 @@ class At {
|
|
|
505
518
|
async bootRequestHandler({
|
|
506
519
|
worker: t,
|
|
507
520
|
fileLockManagerPort: r,
|
|
508
|
-
nativeInternalDirPath:
|
|
521
|
+
nativeInternalDirPath: n
|
|
509
522
|
}) {
|
|
510
|
-
const
|
|
523
|
+
const i = fe(
|
|
511
524
|
t.phpPort
|
|
512
525
|
);
|
|
513
|
-
await
|
|
514
|
-
const
|
|
526
|
+
await i.isConnected();
|
|
527
|
+
const o = await ne(
|
|
515
528
|
this.getEffectiveBlueprint()
|
|
516
529
|
);
|
|
517
|
-
return await
|
|
518
|
-
phpVersion:
|
|
530
|
+
return await i.useFileLockManager(r), await i.bootRequestHandler({
|
|
531
|
+
phpVersion: o.phpVersion,
|
|
519
532
|
siteUrl: this.siteUrl,
|
|
520
533
|
mountsBeforeWpInstall: this.args["mount-before-install"] || [],
|
|
521
534
|
mountsAfterWpInstall: this.args.mount || [],
|
|
522
535
|
processId: t.processId,
|
|
523
536
|
followSymlinks: this.args.followSymlinks === !0,
|
|
524
537
|
trace: this.args.experimentalTrace === !0,
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
withMemcached: this.args.memcached,
|
|
528
|
-
withXdebug: !!this.args.xdebug,
|
|
529
|
-
nativeInternalDirPath: o,
|
|
538
|
+
extensions: Pe(this.args),
|
|
539
|
+
nativeInternalDirPath: n,
|
|
530
540
|
pathAliases: this.args.pathAliases
|
|
531
|
-
}), await
|
|
541
|
+
}), await i.isReady(), i;
|
|
532
542
|
}
|
|
533
543
|
async compileInputBlueprint(t) {
|
|
534
|
-
const r = this.getEffectiveBlueprint(),
|
|
535
|
-
let
|
|
536
|
-
return
|
|
537
|
-
if (
|
|
544
|
+
const r = this.getEffectiveBlueprint(), n = new Je();
|
|
545
|
+
let i = "", o = !1;
|
|
546
|
+
return n.addEventListener("progress", (a) => {
|
|
547
|
+
if (o)
|
|
538
548
|
return;
|
|
539
|
-
|
|
540
|
-
const l = Math.floor(
|
|
541
|
-
|
|
542
|
-
}), await
|
|
543
|
-
progress:
|
|
549
|
+
o = a.detail.progress === 100;
|
|
550
|
+
const l = Math.floor(a.detail.progress);
|
|
551
|
+
i = a.detail.caption || i || "Running Blueprint", this.cliOutput.updateProgress(i.trim(), l);
|
|
552
|
+
}), await he(r, {
|
|
553
|
+
progress: n,
|
|
544
554
|
additionalSteps: t
|
|
545
555
|
});
|
|
546
556
|
}
|
|
@@ -550,16 +560,16 @@ class At {
|
|
|
550
560
|
login: this.args.login,
|
|
551
561
|
...t || {},
|
|
552
562
|
preferredVersions: {
|
|
553
|
-
php: this.args.php ?? t?.preferredVersions?.php ??
|
|
563
|
+
php: this.args.php ?? t?.preferredVersions?.php ?? T,
|
|
554
564
|
wp: this.args.wp ?? t?.preferredVersions?.wp ?? "latest",
|
|
555
565
|
...t?.preferredVersions || {}
|
|
556
566
|
}
|
|
557
567
|
};
|
|
558
568
|
}
|
|
559
569
|
}
|
|
560
|
-
async function
|
|
561
|
-
const
|
|
562
|
-
prefix:
|
|
570
|
+
async function Lt(e, t = !0) {
|
|
571
|
+
const n = `${d.basename(process.argv0)}${e}${process.pid}-`, i = await rt({
|
|
572
|
+
prefix: n,
|
|
563
573
|
/*
|
|
564
574
|
* Allow recursive cleanup on process exit.
|
|
565
575
|
*
|
|
@@ -570,84 +580,81 @@ async function Bt(e, t = !0) {
|
|
|
570
580
|
*/
|
|
571
581
|
unsafeCleanup: !0
|
|
572
582
|
});
|
|
573
|
-
return t &&
|
|
583
|
+
return t && ot(), i;
|
|
574
584
|
}
|
|
575
|
-
async function
|
|
576
|
-
const
|
|
585
|
+
async function Wt(e, t, r) {
|
|
586
|
+
const i = (await Bt(
|
|
577
587
|
e,
|
|
578
588
|
t,
|
|
579
589
|
r
|
|
580
590
|
)).map(
|
|
581
|
-
(
|
|
582
|
-
|
|
583
|
-
l ?
|
|
584
|
-
`Failed to delete stale Playground temp dir: ${
|
|
591
|
+
(o) => new Promise((a) => {
|
|
592
|
+
c.rm(o, { recursive: !0 }, (l) => {
|
|
593
|
+
l ? h.warn(
|
|
594
|
+
`Failed to delete stale Playground temp dir: ${o}`,
|
|
585
595
|
l
|
|
586
|
-
) :
|
|
587
|
-
`Deleted stale Playground temp dir: ${
|
|
588
|
-
),
|
|
596
|
+
) : h.info(
|
|
597
|
+
`Deleted stale Playground temp dir: ${o}`
|
|
598
|
+
), a();
|
|
589
599
|
});
|
|
590
600
|
})
|
|
591
601
|
);
|
|
592
|
-
await Promise.all(
|
|
602
|
+
await Promise.all(i);
|
|
593
603
|
}
|
|
594
|
-
async function
|
|
604
|
+
async function Bt(e, t, r) {
|
|
595
605
|
try {
|
|
596
|
-
const
|
|
597
|
-
for (const
|
|
598
|
-
await
|
|
606
|
+
const n = c.readdirSync(r).map((o) => d.join(r, o)), i = [];
|
|
607
|
+
for (const o of n)
|
|
608
|
+
await Ut(
|
|
599
609
|
e,
|
|
600
610
|
t,
|
|
601
|
-
|
|
602
|
-
) &&
|
|
603
|
-
return
|
|
604
|
-
} catch (
|
|
605
|
-
return
|
|
611
|
+
o
|
|
612
|
+
) && i.push(o);
|
|
613
|
+
return i;
|
|
614
|
+
} catch (n) {
|
|
615
|
+
return h.warn(`Failed to find stale Playground temp dirs: ${n}`), [];
|
|
606
616
|
}
|
|
607
617
|
}
|
|
608
|
-
async function
|
|
609
|
-
if (!
|
|
618
|
+
async function Ut(e, t, r) {
|
|
619
|
+
if (!c.lstatSync(r).isDirectory())
|
|
610
620
|
return !1;
|
|
611
|
-
const
|
|
612
|
-
if (!
|
|
621
|
+
const i = d.basename(r);
|
|
622
|
+
if (!i.includes(e))
|
|
613
623
|
return !1;
|
|
614
|
-
const
|
|
624
|
+
const o = i.match(
|
|
615
625
|
new RegExp(`^(.+)${e}(\\d+)-`)
|
|
616
626
|
);
|
|
617
|
-
if (!
|
|
627
|
+
if (!o)
|
|
618
628
|
return !1;
|
|
619
|
-
const
|
|
620
|
-
executableName:
|
|
621
|
-
pid:
|
|
629
|
+
const a = {
|
|
630
|
+
executableName: o[1],
|
|
631
|
+
pid: o[2]
|
|
622
632
|
};
|
|
623
|
-
if (
|
|
633
|
+
if (_t(a.pid))
|
|
624
634
|
return !1;
|
|
625
635
|
const l = Date.now() - t;
|
|
626
|
-
return
|
|
636
|
+
return c.statSync(r).mtime.getTime() < l;
|
|
627
637
|
}
|
|
628
|
-
function
|
|
638
|
+
function _t(e, t) {
|
|
629
639
|
try {
|
|
630
640
|
return process.kill(Number(e), 0), !0;
|
|
631
641
|
} catch (r) {
|
|
632
|
-
const
|
|
633
|
-
return
|
|
634
|
-
`Permission denied while checking if process ${e} exists (code: ${
|
|
642
|
+
const n = r, i = n && typeof n.code == "string" ? n.code : void 0;
|
|
643
|
+
return i === "ESRCH" ? !1 : i === "EPERM" || i === "EACCES" ? (h.debug(
|
|
644
|
+
`Permission denied while checking if process ${e} exists (code: ${i}).`,
|
|
635
645
|
r
|
|
636
|
-
), !0) : (
|
|
637
|
-
`Could not determine if process ${e} exists due to unexpected error${
|
|
646
|
+
), !0) : (h.warn(
|
|
647
|
+
`Could not determine if process ${e} exists due to unexpected error${i ? ` (code: ${i})` : ""}.`,
|
|
638
648
|
r
|
|
639
649
|
), !0);
|
|
640
650
|
}
|
|
641
651
|
}
|
|
642
|
-
function
|
|
652
|
+
function Nt(e) {
|
|
643
653
|
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;
|
|
644
654
|
}
|
|
645
|
-
class
|
|
646
|
-
constructor(
|
|
647
|
-
this.lastProgressLine = "", this.progressActive = !1
|
|
648
|
-
}
|
|
649
|
-
get isTTY() {
|
|
650
|
-
return !!this.writeStream.isTTY;
|
|
655
|
+
class Ht extends nt {
|
|
656
|
+
constructor() {
|
|
657
|
+
super(...arguments), this.lastProgressLine = "", this.progressActive = !1;
|
|
651
658
|
}
|
|
652
659
|
/**
|
|
653
660
|
* Determines if progress updates should be rendered.
|
|
@@ -656,35 +663,7 @@ class Ut {
|
|
|
656
663
|
* This prevents progress spam in logs - users only see the final outcome.
|
|
657
664
|
*/
|
|
658
665
|
get shouldRender() {
|
|
659
|
-
return
|
|
660
|
-
}
|
|
661
|
-
get isQuiet() {
|
|
662
|
-
return this.verbosity === "quiet";
|
|
663
|
-
}
|
|
664
|
-
/**
|
|
665
|
-
* ANSI formatting helpers.
|
|
666
|
-
*
|
|
667
|
-
* These only apply color codes when outputting to a terminal (TTY).
|
|
668
|
-
* When piped to files or non-TTY streams, they return plain text to
|
|
669
|
-
* avoid polluting logs with escape sequences.
|
|
670
|
-
*/
|
|
671
|
-
bold(t) {
|
|
672
|
-
return this.isTTY ? `\x1B[1m${t}\x1B[0m` : t;
|
|
673
|
-
}
|
|
674
|
-
dim(t) {
|
|
675
|
-
return this.isTTY ? `\x1B[2m${t}\x1B[0m` : t;
|
|
676
|
-
}
|
|
677
|
-
green(t) {
|
|
678
|
-
return this.isTTY ? `\x1B[32m${t}\x1B[0m` : t;
|
|
679
|
-
}
|
|
680
|
-
cyan(t) {
|
|
681
|
-
return this.isTTY ? `\x1B[36m${t}\x1B[0m` : t;
|
|
682
|
-
}
|
|
683
|
-
yellow(t) {
|
|
684
|
-
return this.isTTY ? `\x1B[33m${t}\x1B[0m` : t;
|
|
685
|
-
}
|
|
686
|
-
red(t) {
|
|
687
|
-
return this.isTTY ? `\x1B[31m${t}\x1B[0m` : t;
|
|
666
|
+
return Nt(this.writeStream);
|
|
688
667
|
}
|
|
689
668
|
printBanner() {
|
|
690
669
|
if (this.isQuiet) return;
|
|
@@ -707,12 +686,12 @@ ${t}
|
|
|
707
686
|
r.push(
|
|
708
687
|
`${this.dim("PHP")} ${this.cyan(t.phpVersion)} ${this.dim("WordPress")} ${this.cyan(t.wpVersion)}`
|
|
709
688
|
);
|
|
710
|
-
const
|
|
711
|
-
if (t.intl &&
|
|
712
|
-
for (const
|
|
713
|
-
const
|
|
689
|
+
const n = [];
|
|
690
|
+
if (t.intl && n.push("intl"), t.redis && n.push("redis"), t.memcached && n.push("memcached"), t.xdebug && n.push(this.yellow("xdebug")), n.length > 0 && r.push(`${this.dim("Extensions")} ${n.join(", ")}`), t.mounts.length > 0)
|
|
691
|
+
for (const i of t.mounts) {
|
|
692
|
+
const o = i.autoMounted ? ` ${this.dim("(auto-mount)")}` : "";
|
|
714
693
|
r.push(
|
|
715
|
-
`${this.dim("Mount")} ${
|
|
694
|
+
`${this.dim("Mount")} ${i.hostPath} ${this.dim("→")} ${i.vfsPath}${o}`
|
|
716
695
|
);
|
|
717
696
|
}
|
|
718
697
|
t.blueprint && r.push(`${this.dim("Blueprint")} ${t.blueprint}`), this.writeStream.write(r.join(`
|
|
@@ -739,8 +718,8 @@ ${t}
|
|
|
739
718
|
updateProgress(t, r) {
|
|
740
719
|
if (this.isQuiet || !this.shouldRender) return;
|
|
741
720
|
this.progressActive || (this.progressActive = !0);
|
|
742
|
-
let
|
|
743
|
-
r !== void 0 && (
|
|
721
|
+
let n = `${t}`;
|
|
722
|
+
r !== void 0 && (n = `${t} ${this.dim(`${r}%`)}`), n !== this.lastProgressLine && (this.lastProgressLine = n, this.isTTY ? (this.writeStream.cursorTo(0), this.writeStream.write(n), this.writeStream.clearLine(1)) : this.writeStream.write(`${n}
|
|
744
723
|
`));
|
|
745
724
|
}
|
|
746
725
|
/**
|
|
@@ -782,18 +761,14 @@ ${t}
|
|
|
782
761
|
*/
|
|
783
762
|
printReady(t, r) {
|
|
784
763
|
if (this.isQuiet) return;
|
|
785
|
-
const
|
|
764
|
+
const n = r === 1 ? "worker" : "workers";
|
|
786
765
|
this.writeStream.write(
|
|
787
766
|
`
|
|
788
|
-
${this.green("Ready!")} WordPress is running on ${this.bold(t)} ${this.dim(`(${r} ${
|
|
767
|
+
${this.green("Ready!")} WordPress is running on ${this.bold(t)} ${this.dim(`(${r} ${n})`)}
|
|
789
768
|
|
|
790
769
|
`
|
|
791
770
|
);
|
|
792
771
|
}
|
|
793
|
-
printWarning(t) {
|
|
794
|
-
this.isQuiet || this.writeStream.write(`${this.yellow("Warning:")} ${t}
|
|
795
|
-
`);
|
|
796
|
-
}
|
|
797
772
|
/**
|
|
798
773
|
* Prints the phpMyAdmin URL when the --phpmyadmin flag is enabled.
|
|
799
774
|
*/
|
|
@@ -806,11 +781,11 @@ ${this.green("Ready!")} WordPress is running on ${this.bold(t)} ${this.dim(`(${r
|
|
|
806
781
|
}
|
|
807
782
|
}
|
|
808
783
|
const J = {
|
|
809
|
-
Quiet: { name: "quiet", severity:
|
|
810
|
-
Normal: { name: "normal", severity:
|
|
811
|
-
Debug: { name: "debug", severity:
|
|
784
|
+
Quiet: { name: "quiet", severity: O.Fatal },
|
|
785
|
+
Normal: { name: "normal", severity: O.Info },
|
|
786
|
+
Debug: { name: "debug", severity: O.Debug }
|
|
812
787
|
};
|
|
813
|
-
async function
|
|
788
|
+
async function Ft(e) {
|
|
814
789
|
try {
|
|
815
790
|
const t = {
|
|
816
791
|
"site-url": {
|
|
@@ -820,8 +795,8 @@ async function Ht(e) {
|
|
|
820
795
|
php: {
|
|
821
796
|
describe: "PHP version to use.",
|
|
822
797
|
type: "string",
|
|
823
|
-
default:
|
|
824
|
-
choices:
|
|
798
|
+
default: T,
|
|
799
|
+
choices: re
|
|
825
800
|
},
|
|
826
801
|
wp: {
|
|
827
802
|
describe: "WordPress version to use.",
|
|
@@ -833,21 +808,21 @@ async function Ht(e) {
|
|
|
833
808
|
type: "string",
|
|
834
809
|
nargs: 2,
|
|
835
810
|
array: !0,
|
|
836
|
-
coerce:
|
|
811
|
+
coerce: wt
|
|
837
812
|
},
|
|
838
813
|
"define-bool": {
|
|
839
814
|
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',
|
|
840
815
|
type: "string",
|
|
841
816
|
nargs: 2,
|
|
842
817
|
array: !0,
|
|
843
|
-
coerce:
|
|
818
|
+
coerce: bt
|
|
844
819
|
},
|
|
845
820
|
"define-number": {
|
|
846
821
|
describe: "Define PHP number constants (can be used multiple times). Format: NAME value. Examples: --define-number LIMIT 100 --define-number RATE 45.67",
|
|
847
822
|
type: "string",
|
|
848
823
|
nargs: 2,
|
|
849
824
|
array: !0,
|
|
850
|
-
coerce:
|
|
825
|
+
coerce: yt
|
|
851
826
|
},
|
|
852
827
|
// @TODO: Support read-only mounts, e.g. via WORKERFS, a custom
|
|
853
828
|
// ReadOnlyNODEFS, or by copying the files into MEMFS
|
|
@@ -856,28 +831,28 @@ async function Ht(e) {
|
|
|
856
831
|
type: "array",
|
|
857
832
|
string: !0,
|
|
858
833
|
nargs: 1,
|
|
859
|
-
coerce:
|
|
834
|
+
coerce: V
|
|
860
835
|
},
|
|
861
836
|
"mount-before-install": {
|
|
862
837
|
describe: "Mount a directory to the PHP runtime before WordPress installation (can be used multiple times). Format: /host/path:/vfs/path",
|
|
863
838
|
type: "array",
|
|
864
839
|
string: !0,
|
|
865
840
|
nargs: 1,
|
|
866
|
-
coerce:
|
|
841
|
+
coerce: V
|
|
867
842
|
},
|
|
868
843
|
"mount-dir": {
|
|
869
844
|
describe: 'Mount a directory to the PHP runtime (can be used multiple times). Format: "/host/path" "/vfs/path"',
|
|
870
845
|
type: "array",
|
|
871
846
|
nargs: 2,
|
|
872
847
|
array: !0,
|
|
873
|
-
coerce:
|
|
848
|
+
coerce: pe
|
|
874
849
|
},
|
|
875
850
|
"mount-dir-before-install": {
|
|
876
851
|
describe: 'Mount a directory before WordPress installation (can be used multiple times). Format: "/host/path" "/vfs/path"',
|
|
877
852
|
type: "string",
|
|
878
853
|
nargs: 2,
|
|
879
854
|
array: !0,
|
|
880
|
-
coerce:
|
|
855
|
+
coerce: pe
|
|
881
856
|
},
|
|
882
857
|
login: {
|
|
883
858
|
describe: "Should log the user in",
|
|
@@ -925,7 +900,7 @@ async function Ht(e) {
|
|
|
925
900
|
describe: "Output logs and progress messages.",
|
|
926
901
|
type: "string",
|
|
927
902
|
choices: Object.values(J).map(
|
|
928
|
-
(
|
|
903
|
+
(s) => s.name
|
|
929
904
|
),
|
|
930
905
|
default: "normal"
|
|
931
906
|
},
|
|
@@ -985,7 +960,7 @@ Warning: Following symlinks will expose files outside mounted directories to Pla
|
|
|
985
960
|
// supported IDEs and, if needed, will create the relevant
|
|
986
961
|
// config file for each.
|
|
987
962
|
choices: ["", "vscode", "phpstorm"],
|
|
988
|
-
coerce: (
|
|
963
|
+
coerce: (s) => s === "" ? ["vscode", "phpstorm"] : [s]
|
|
989
964
|
},
|
|
990
965
|
"experimental-blueprints-v2-runner": {
|
|
991
966
|
describe: "Use the experimental Blueprint V2 runner.",
|
|
@@ -1004,23 +979,39 @@ Warning: Following symlinks will expose files outside mounted directories to Pla
|
|
|
1004
979
|
phpmyadmin: {
|
|
1005
980
|
describe: "Install phpMyAdmin for database management. The phpMyAdmin URL will be printed after boot. Optionally specify a custom URL path (default: /phpmyadmin).",
|
|
1006
981
|
type: "string",
|
|
1007
|
-
coerce: (
|
|
982
|
+
coerce: (s) => s === "" ? "/phpmyadmin" : s
|
|
1008
983
|
}
|
|
1009
984
|
}, r = {
|
|
1010
985
|
port: {
|
|
1011
986
|
describe: "Port to listen on when serving. Defaults to 9400 when available.",
|
|
1012
987
|
type: "number"
|
|
1013
988
|
},
|
|
989
|
+
workers: {
|
|
990
|
+
describe: 'Number of request-handling worker threads. Accepts a positive integer, or "auto" to use one per CPU core (minus one). Defaults to min(6, cpus-1).',
|
|
991
|
+
type: "string",
|
|
992
|
+
coerce: (s) => {
|
|
993
|
+
if (s === void 0)
|
|
994
|
+
return;
|
|
995
|
+
if (s === "auto")
|
|
996
|
+
return "auto";
|
|
997
|
+
const b = Number(s);
|
|
998
|
+
if (!Number.isInteger(b) || b < 1)
|
|
999
|
+
throw new Error(
|
|
1000
|
+
`Invalid --workers value "${s}": expected a positive integer or "auto".`
|
|
1001
|
+
);
|
|
1002
|
+
return b;
|
|
1003
|
+
}
|
|
1004
|
+
},
|
|
1014
1005
|
"experimental-multi-worker": {
|
|
1015
|
-
deprecated: "
|
|
1016
|
-
describe: "
|
|
1006
|
+
deprecated: "Use --workers=<n|auto> instead. The value of this flag is ignored.",
|
|
1007
|
+
describe: "Deprecated. Use --workers=<n|auto> to control the number of request-handling worker threads.",
|
|
1017
1008
|
type: "number"
|
|
1018
1009
|
},
|
|
1019
1010
|
"experimental-devtools": {
|
|
1020
1011
|
describe: "Enable experimental browser development tools.",
|
|
1021
1012
|
type: "boolean"
|
|
1022
1013
|
}
|
|
1023
|
-
},
|
|
1014
|
+
}, n = {
|
|
1024
1015
|
path: {
|
|
1025
1016
|
describe: "Path to the project directory. Playground will auto-detect if this is a plugin, theme, wp-content, or WordPress directory.",
|
|
1026
1017
|
type: "string",
|
|
@@ -1029,8 +1020,8 @@ Warning: Following symlinks will expose files outside mounted directories to Pla
|
|
|
1029
1020
|
php: {
|
|
1030
1021
|
describe: "PHP version to use.",
|
|
1031
1022
|
type: "string",
|
|
1032
|
-
default:
|
|
1033
|
-
choices:
|
|
1023
|
+
default: T,
|
|
1024
|
+
choices: re
|
|
1034
1025
|
},
|
|
1035
1026
|
wp: {
|
|
1036
1027
|
describe: "WordPress version to use.",
|
|
@@ -1075,17 +1066,17 @@ Warning: Following symlinks will expose files outside mounted directories to Pla
|
|
|
1075
1066
|
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.",
|
|
1076
1067
|
type: "array",
|
|
1077
1068
|
string: !0,
|
|
1078
|
-
coerce:
|
|
1069
|
+
coerce: V
|
|
1079
1070
|
},
|
|
1080
1071
|
reset: {
|
|
1081
1072
|
describe: "Deletes the stored site directory and starts a new site from scratch.",
|
|
1082
1073
|
type: "boolean",
|
|
1083
1074
|
default: !1
|
|
1084
1075
|
},
|
|
1085
|
-
"
|
|
1086
|
-
describe: "
|
|
1076
|
+
"auto-mount": {
|
|
1077
|
+
describe: "Automatically detect project type (plugin, theme, wp-content, or WordPress) and mount accordingly. Use --no-auto-mount to disable and --mount to manually specify mounts instead.",
|
|
1087
1078
|
type: "boolean",
|
|
1088
|
-
default: !
|
|
1079
|
+
default: !0
|
|
1089
1080
|
},
|
|
1090
1081
|
// Define constants
|
|
1091
1082
|
define: t.define,
|
|
@@ -1093,16 +1084,16 @@ Warning: Following symlinks will expose files outside mounted directories to Pla
|
|
|
1093
1084
|
"define-number": t["define-number"],
|
|
1094
1085
|
// Tools
|
|
1095
1086
|
phpmyadmin: t.phpmyadmin
|
|
1096
|
-
},
|
|
1087
|
+
}, i = {
|
|
1097
1088
|
outfile: {
|
|
1098
1089
|
describe: "When building, write to this output file.",
|
|
1099
1090
|
type: "string",
|
|
1100
1091
|
default: "wordpress.zip"
|
|
1101
1092
|
}
|
|
1102
|
-
},
|
|
1093
|
+
}, o = ze(e).usage("Usage: wp-playground <command> [options]").command(
|
|
1103
1094
|
"start",
|
|
1104
1095
|
"Start a local WordPress server with automatic project detection (recommended)",
|
|
1105
|
-
(
|
|
1096
|
+
(s) => s.usage(
|
|
1106
1097
|
`Usage: wp-playground start [options]
|
|
1107
1098
|
|
|
1108
1099
|
The easiest way to run WordPress locally. Automatically detects
|
|
@@ -1115,130 +1106,133 @@ Examples:
|
|
|
1115
1106
|
wp-playground start --wp=6.7 --php=8.3 # Use specific versions
|
|
1116
1107
|
wp-playground start --skip-browser # Skip opening browser
|
|
1117
1108
|
wp-playground start --no-auto-mount # Disable auto-detection`
|
|
1118
|
-
).options(
|
|
1109
|
+
).options(n)
|
|
1119
1110
|
).command(
|
|
1120
1111
|
"server",
|
|
1121
1112
|
"Start a local WordPress server (advanced, low-level)",
|
|
1122
|
-
(
|
|
1113
|
+
(s) => s.options({
|
|
1123
1114
|
...t,
|
|
1124
1115
|
...r
|
|
1125
1116
|
})
|
|
1126
1117
|
).command(
|
|
1127
1118
|
"run-blueprint",
|
|
1128
1119
|
"Execute a Blueprint without starting a server",
|
|
1129
|
-
(
|
|
1120
|
+
(s) => s.options({ ...t })
|
|
1130
1121
|
).command(
|
|
1131
1122
|
"build-snapshot",
|
|
1132
1123
|
"Build a ZIP snapshot of a WordPress site based on a Blueprint",
|
|
1133
|
-
(
|
|
1124
|
+
(s) => s.options({
|
|
1134
1125
|
...t,
|
|
1135
|
-
...
|
|
1126
|
+
...i
|
|
1136
1127
|
})
|
|
1137
1128
|
).command(
|
|
1138
1129
|
"php",
|
|
1139
1130
|
"Run a PHP script",
|
|
1140
|
-
(
|
|
1131
|
+
(s) => s.options({ ...t })
|
|
1141
1132
|
).demandCommand(1, "Please specify a command").strictCommands().conflicts(
|
|
1142
1133
|
"experimental-unsafe-ide-integration",
|
|
1143
1134
|
"experimental-devtools"
|
|
1144
|
-
).showHelpOnFail(!1).fail((
|
|
1145
|
-
if (
|
|
1146
|
-
throw
|
|
1147
|
-
|
|
1148
|
-
` +
|
|
1149
|
-
}).strictOptions().check(async (
|
|
1150
|
-
if (
|
|
1135
|
+
).showHelpOnFail(!1).fail((s, b, y) => {
|
|
1136
|
+
if (b)
|
|
1137
|
+
throw b;
|
|
1138
|
+
s && s.includes("Please specify a command") && (y.showHelp(), console.error(`
|
|
1139
|
+
` + s), process.exit(1)), console.error(s), process.exit(1);
|
|
1140
|
+
}).strictOptions().check(async (s) => {
|
|
1141
|
+
if (s["skip-wordpress-install"] === !0 && (s["wordpress-install-mode"] = "do-not-attempt-installing", s.wordpressInstallMode = "do-not-attempt-installing"), s.phpmyadmin && s["skip-sqlite-setup"])
|
|
1142
|
+
throw new Error(
|
|
1143
|
+
"The --phpmyadmin option requires SQLite setup. Remove --skip-sqlite-setup to use phpMyAdmin."
|
|
1144
|
+
);
|
|
1145
|
+
if (s.wp !== void 0 && typeof s.wp == "string" && !It(s.wp))
|
|
1151
1146
|
try {
|
|
1152
|
-
new URL(
|
|
1147
|
+
new URL(s.wp);
|
|
1153
1148
|
} catch {
|
|
1154
1149
|
throw new Error(
|
|
1155
1150
|
'Unrecognized WordPress version. Please use "latest", "beta", "trunk", "nightly", a URL, or a numeric version such as "6.2", "6.0.1", "6.2-beta1", or "6.2-RC1" (see --help for details).'
|
|
1156
1151
|
);
|
|
1157
1152
|
}
|
|
1158
|
-
const
|
|
1159
|
-
if (typeof
|
|
1153
|
+
const b = s["site-url"];
|
|
1154
|
+
if (typeof b == "string" && b.trim() !== "")
|
|
1160
1155
|
try {
|
|
1161
|
-
new URL(
|
|
1156
|
+
new URL(b);
|
|
1162
1157
|
} catch {
|
|
1163
1158
|
throw new Error(
|
|
1164
|
-
`Invalid site-url "${
|
|
1159
|
+
`Invalid site-url "${b}". Please provide a valid URL (e.g., http://localhost:8080 or https://example.com)`
|
|
1165
1160
|
);
|
|
1166
1161
|
}
|
|
1167
|
-
|
|
1168
|
-
|
|
1162
|
+
const y = s.autoMount;
|
|
1163
|
+
if (s._[0] !== "start" && typeof y == "string" && y) {
|
|
1164
|
+
let x = !1;
|
|
1169
1165
|
try {
|
|
1170
|
-
|
|
1171
|
-
a["auto-mount"]
|
|
1172
|
-
).isDirectory();
|
|
1166
|
+
x = c.statSync(y).isDirectory();
|
|
1173
1167
|
} catch {
|
|
1174
|
-
|
|
1168
|
+
x = !1;
|
|
1175
1169
|
}
|
|
1176
|
-
if (!
|
|
1170
|
+
if (!x)
|
|
1177
1171
|
throw new Error(
|
|
1178
|
-
`The specified --auto-mount path is not a directory: '${
|
|
1172
|
+
`The specified --auto-mount path is not a directory: '${y}'.`
|
|
1179
1173
|
);
|
|
1180
1174
|
}
|
|
1181
|
-
if (
|
|
1175
|
+
if (s["experimental-blueprints-v2-runner"] === !0)
|
|
1182
1176
|
throw new Error(
|
|
1183
1177
|
"Blueprints v2 are temporarily disabled while we rework their runtime implementation."
|
|
1184
1178
|
);
|
|
1185
|
-
if (
|
|
1179
|
+
if (s.mode !== void 0)
|
|
1186
1180
|
throw new Error(
|
|
1187
1181
|
"The --mode option requires the --experimentalBlueprintsV2Runner flag."
|
|
1188
1182
|
);
|
|
1189
1183
|
return !0;
|
|
1190
1184
|
});
|
|
1191
|
-
|
|
1192
|
-
const
|
|
1185
|
+
o.wrap(o.terminalWidth());
|
|
1186
|
+
const a = await o.argv, l = a._[0];
|
|
1193
1187
|
[
|
|
1194
1188
|
"start",
|
|
1195
1189
|
"run-blueprint",
|
|
1196
1190
|
"server",
|
|
1197
1191
|
"build-snapshot",
|
|
1198
1192
|
"php"
|
|
1199
|
-
].includes(l) || (
|
|
1200
|
-
const u =
|
|
1201
|
-
|
|
1202
|
-
const
|
|
1203
|
-
...
|
|
1193
|
+
].includes(l) || (o.showHelp(), process.exit(1));
|
|
1194
|
+
const u = a.define || {}, f = a["define-bool"] || {}, A = a["define-number"] || {}, E = (s) => s in u || s in f || s in A, m = a.php || T;
|
|
1195
|
+
Y(m) || (E("WP_DEBUG") || (u.WP_DEBUG = "true"), E("WP_DEBUG_LOG") || (u.WP_DEBUG_LOG = "true"), E("WP_DEBUG_DISPLAY") || (u.WP_DEBUG_DISPLAY = "false"));
|
|
1196
|
+
const k = {
|
|
1197
|
+
...a,
|
|
1204
1198
|
define: u,
|
|
1205
1199
|
command: l,
|
|
1206
1200
|
mount: [
|
|
1207
|
-
...
|
|
1208
|
-
...
|
|
1201
|
+
...a.mount || [],
|
|
1202
|
+
...a["mount-dir"] || []
|
|
1209
1203
|
],
|
|
1210
1204
|
"mount-before-install": [
|
|
1211
|
-
...
|
|
1212
|
-
...
|
|
1205
|
+
...a["mount-before-install"] || [],
|
|
1206
|
+
...a["mount-dir-before-install"] || []
|
|
1213
1207
|
]
|
|
1214
|
-
},
|
|
1215
|
-
|
|
1216
|
-
const
|
|
1217
|
-
let
|
|
1208
|
+
}, M = await Ee(k);
|
|
1209
|
+
M === void 0 && process.exit(0);
|
|
1210
|
+
const D = /* @__PURE__ */ (() => {
|
|
1211
|
+
let s;
|
|
1218
1212
|
return async () => {
|
|
1219
|
-
|
|
1213
|
+
s === void 0 && (s = M[Symbol.asyncDispose]()), await s, process.exit(0);
|
|
1220
1214
|
};
|
|
1221
1215
|
})();
|
|
1222
|
-
return process.on("SIGINT",
|
|
1216
|
+
return process.on("SIGINT", D), process.on("SIGTERM", D), {
|
|
1223
1217
|
[Symbol.asyncDispose]: async () => {
|
|
1224
|
-
process.off("SIGINT",
|
|
1218
|
+
process.off("SIGINT", D), process.off("SIGTERM", D), await M[Symbol.asyncDispose]();
|
|
1225
1219
|
},
|
|
1226
|
-
[K]: { cliServer:
|
|
1220
|
+
[K]: { cliServer: M }
|
|
1227
1221
|
};
|
|
1228
1222
|
} catch (t) {
|
|
1229
1223
|
console.error(t);
|
|
1230
1224
|
const r = process.argv.includes("--debug");
|
|
1231
1225
|
if (t instanceof Error)
|
|
1232
1226
|
if (r)
|
|
1233
|
-
|
|
1227
|
+
Ce(t);
|
|
1234
1228
|
else {
|
|
1235
|
-
const
|
|
1236
|
-
let
|
|
1229
|
+
const n = [];
|
|
1230
|
+
let i = t;
|
|
1237
1231
|
do
|
|
1238
|
-
|
|
1239
|
-
while (
|
|
1232
|
+
n.push(i.message), i = i.cause;
|
|
1233
|
+
while (i instanceof Error);
|
|
1240
1234
|
console.error(
|
|
1241
|
-
"\x1B[1m" +
|
|
1235
|
+
"\x1B[1m" + n.join(" caused by: ") + "\x1B[0m"
|
|
1242
1236
|
);
|
|
1243
1237
|
}
|
|
1244
1238
|
else
|
|
@@ -1266,27 +1260,29 @@ function me(e, t) {
|
|
|
1266
1260
|
(r) => r.vfsPath.replace(/\/$/, "") === t.replace(/\/$/, "")
|
|
1267
1261
|
);
|
|
1268
1262
|
}
|
|
1269
|
-
|
|
1270
|
-
|
|
1263
|
+
function xe(e) {
|
|
1264
|
+
const t = Math.max(1, B.cpus().length - 1);
|
|
1265
|
+
return e === void 0 ? Math.min(6, t) : e === "auto" ? t : e;
|
|
1266
|
+
}
|
|
1267
|
+
const K = Symbol("playground-cli-testing");
|
|
1268
|
+
async function Ee(e) {
|
|
1271
1269
|
let t;
|
|
1272
|
-
const r = e.internalCookieStore ? new
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1270
|
+
const r = e.internalCookieStore ? new Ae() : void 0, n = [], i = /* @__PURE__ */ new Map(), o = new Ht({
|
|
1271
|
+
verbosity: e.verbosity || "normal"
|
|
1272
|
+
});
|
|
1273
|
+
if (e.command === "start" && (e = Ot(e, o)), e.autoMount !== void 0 && (e.autoMount === "" && (e = { ...e, autoMount: process.cwd() }), e = ge(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) {
|
|
1274
|
+
const m = Object.values(J).find(
|
|
1275
|
+
($) => $.name === e.verbosity
|
|
1276
1276
|
).severity;
|
|
1277
|
-
|
|
1277
|
+
h.setSeverityFilterLevel(m);
|
|
1278
1278
|
}
|
|
1279
|
-
e.intl || (e.intl = !0), e.redis === void 0 && (e.redis = await de()), e.memcached === void 0 && (e.memcached = await de()), e.phpmyadmin && (e.phpmyadmin === !0 && (e.phpmyadmin = "/phpmyadmin"), e.pathAliases = [
|
|
1279
|
+
e.intl || (e.intl = !0), e.redis === void 0 && (e.redis = await de()), e.memcached === void 0 && (e.memcached = await de()), Y(e.php || T) && (e.intl = !1, e.redis = !1, e.memcached = !1, e.xdebug = !1), e.phpmyadmin && (e.phpmyadmin === !0 && (e.phpmyadmin = "/phpmyadmin"), e.pathAliases = [
|
|
1280
1280
|
{
|
|
1281
1281
|
urlPrefix: e.phpmyadmin,
|
|
1282
1282
|
fsPath: ue
|
|
1283
1283
|
}
|
|
1284
|
-
])
|
|
1285
|
-
|
|
1286
|
-
verbosity: e.verbosity || "normal"
|
|
1287
|
-
});
|
|
1288
|
-
e.command === "server" && (i.printBanner(), i.printConfig({
|
|
1289
|
-
phpVersion: e.php || D,
|
|
1284
|
+
]), e.command === "server" && (o.printBanner(), o.printConfig({
|
|
1285
|
+
phpVersion: e.php || T,
|
|
1290
1286
|
wpVersion: e.wp || "latest",
|
|
1291
1287
|
port: e.port ?? 9400,
|
|
1292
1288
|
xdebug: !!e.xdebug,
|
|
@@ -1299,125 +1295,150 @@ async function xe(e) {
|
|
|
1299
1295
|
],
|
|
1300
1296
|
blueprint: typeof e.blueprint == "string" ? e.blueprint : void 0
|
|
1301
1297
|
}));
|
|
1302
|
-
const
|
|
1303
|
-
let
|
|
1304
|
-
const
|
|
1305
|
-
port: e.port ? e.port : await
|
|
1306
|
-
onBind: async (
|
|
1307
|
-
const
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1298
|
+
const l = e.command === "server" ? e.port ?? 9400 : 0, u = new De();
|
|
1299
|
+
let f = !1, A = !0;
|
|
1300
|
+
const E = await St({
|
|
1301
|
+
port: e.port ? e.port : await vt(l) ? 0 : l,
|
|
1302
|
+
onBind: async (m, $) => {
|
|
1303
|
+
const k = "127.0.0.1", M = `http://${k}:${$}`, D = e["site-url"] || M;
|
|
1304
|
+
e["experimental-multi-worker"] !== void 0 && h.warn(
|
|
1305
|
+
"--experimental-multi-worker is deprecated and its value is ignored. Use --workers=<n|auto> instead."
|
|
1306
|
+
);
|
|
1307
|
+
const s = xe(e.workers);
|
|
1308
|
+
if (s < 6) {
|
|
1309
|
+
const p = "Running fewer than 6 workers may increase the likelihood of deadlock due to workers blocking on file locks.";
|
|
1310
|
+
e.workers === void 0 ? h.warn(
|
|
1311
|
+
`The default worker count has been reduced to ${s} because this machine has only ${B.cpus().length} CPU(s). ` + p
|
|
1312
|
+
) : h.warn(
|
|
1313
|
+
`Worker count (${s}) is below the recommended threshold (6). ` + p
|
|
1314
|
+
);
|
|
1315
|
+
}
|
|
1316
|
+
const b = "-playground-cli-site-", y = await Lt(b);
|
|
1317
|
+
h.debug(`Native temp dir for VFS root: ${y.path}`);
|
|
1318
|
+
const x = "WP Playground CLI - Listen for Xdebug", N = ".playground-xdebug-root", H = d.join(process.cwd(), N);
|
|
1319
|
+
if (await it(H), e.xdebug) {
|
|
1320
|
+
const p = {
|
|
1321
|
+
hostPath: d.join(".", d.sep, N),
|
|
1313
1322
|
vfsPath: "/"
|
|
1314
|
-
};
|
|
1315
|
-
if (
|
|
1316
|
-
e.php || D
|
|
1317
|
-
) <= U.indexOf("8.5"))
|
|
1323
|
+
}, w = e.php || T;
|
|
1324
|
+
if (j.includes(w) && j.indexOf(w) <= j.indexOf("8.5"))
|
|
1318
1325
|
await ae(
|
|
1319
|
-
|
|
1326
|
+
y.path,
|
|
1320
1327
|
H,
|
|
1321
1328
|
process.platform
|
|
1322
1329
|
), e.xdebug = st({
|
|
1323
1330
|
cwd: process.cwd(),
|
|
1324
1331
|
mounts: [
|
|
1325
|
-
|
|
1332
|
+
p,
|
|
1326
1333
|
...e["mount-before-install"] || [],
|
|
1327
1334
|
...e.mount || []
|
|
1328
1335
|
],
|
|
1329
1336
|
pathSkippings: [...le]
|
|
1330
|
-
}),
|
|
1331
|
-
|
|
1332
|
-
|
|
1337
|
+
}), o.print(
|
|
1338
|
+
o.bold("Xdebug configured successfully")
|
|
1339
|
+
), o.print(
|
|
1340
|
+
o.highlight("Playground source root: ") + ".playground-xdebug-root" + o.italic(
|
|
1341
|
+
o.dim(
|
|
1333
1342
|
" – you can set breakpoints and preview Playground's VFS structure in there."
|
|
1334
1343
|
)
|
|
1335
1344
|
)
|
|
1336
1345
|
);
|
|
1337
1346
|
else if (e.experimentalUnsafeIdeIntegration) {
|
|
1338
1347
|
await ae(
|
|
1339
|
-
|
|
1348
|
+
y.path,
|
|
1340
1349
|
H,
|
|
1341
1350
|
process.platform
|
|
1342
1351
|
);
|
|
1343
1352
|
try {
|
|
1344
|
-
await
|
|
1345
|
-
|
|
1353
|
+
await at(
|
|
1354
|
+
x,
|
|
1346
1355
|
process.cwd()
|
|
1347
1356
|
);
|
|
1348
|
-
const
|
|
1349
|
-
name:
|
|
1350
|
-
host:
|
|
1351
|
-
port:
|
|
1357
|
+
const P = typeof e.xdebug == "object" ? e.xdebug : {}, v = await lt({
|
|
1358
|
+
name: x,
|
|
1359
|
+
host: k,
|
|
1360
|
+
port: $,
|
|
1352
1361
|
ides: e.experimentalUnsafeIdeIntegration,
|
|
1353
1362
|
cwd: process.cwd(),
|
|
1354
1363
|
mounts: [
|
|
1355
|
-
|
|
1364
|
+
p,
|
|
1356
1365
|
...e["mount-before-install"] || [],
|
|
1357
1366
|
...e.mount || []
|
|
1358
1367
|
],
|
|
1359
1368
|
pathSkippings: [...le],
|
|
1360
|
-
ideKey:
|
|
1361
|
-
}),
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
),
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
+
ideKey: P.ideKey || "WPPLAYGROUNDCLI"
|
|
1370
|
+
}), S = e.experimentalUnsafeIdeIntegration, I = S.includes("vscode"), U = S.includes("phpstorm"), L = Object.values(v);
|
|
1371
|
+
o.print(""), L.length > 0 ? (o.print(
|
|
1372
|
+
o.bold(
|
|
1373
|
+
"Xdebug configured successfully"
|
|
1374
|
+
)
|
|
1375
|
+
), o.print(
|
|
1376
|
+
o.highlight(
|
|
1377
|
+
"Updated IDE config: "
|
|
1378
|
+
) + L.join(" ")
|
|
1379
|
+
), o.print(
|
|
1380
|
+
o.highlight(
|
|
1381
|
+
"Playground source root: "
|
|
1382
|
+
) + ".playground-xdebug-root" + o.italic(
|
|
1383
|
+
o.dim(
|
|
1369
1384
|
" – you can set breakpoints and preview Playground's VFS structure in there."
|
|
1370
1385
|
)
|
|
1371
1386
|
)
|
|
1372
|
-
)) : (
|
|
1373
|
-
|
|
1374
|
-
|
|
1387
|
+
)) : (o.print(
|
|
1388
|
+
o.bold(
|
|
1389
|
+
"Xdebug configuration failed."
|
|
1390
|
+
)
|
|
1391
|
+
), o.print(
|
|
1375
1392
|
"No IDE-specific project settings directory was found in the current working directory."
|
|
1376
|
-
)),
|
|
1377
|
-
|
|
1378
|
-
|
|
1393
|
+
)), o.print(""), I && v.vscode && (o.print(
|
|
1394
|
+
o.bold(
|
|
1395
|
+
"VS Code / Cursor instructions:"
|
|
1396
|
+
)
|
|
1397
|
+
), o.print(
|
|
1379
1398
|
" 1. Ensure you have installed an IDE extension for PHP Debugging"
|
|
1380
|
-
),
|
|
1381
|
-
` (The ${
|
|
1399
|
+
), o.print(
|
|
1400
|
+
` (The ${o.bold("PHP Debug")} extension by ${o.bold(
|
|
1382
1401
|
"Xdebug"
|
|
1383
1402
|
)} has been a solid option)`
|
|
1384
|
-
),
|
|
1403
|
+
), o.print(
|
|
1385
1404
|
" 2. Open the Run and Debug panel on the left sidebar"
|
|
1386
|
-
),
|
|
1387
|
-
` 3. Select "${
|
|
1388
|
-
|
|
1405
|
+
), o.print(
|
|
1406
|
+
` 3. Select "${o.italic(
|
|
1407
|
+
x
|
|
1389
1408
|
)}" from the dropdown`
|
|
1390
|
-
),
|
|
1409
|
+
), o.print(' 4. Click "start debugging"'), o.print(
|
|
1391
1410
|
" 5. Set a breakpoint. For example, in .playground-xdebug-root/wordpress/index.php"
|
|
1392
|
-
),
|
|
1411
|
+
), o.print(
|
|
1393
1412
|
" 6. Visit Playground in your browser to hit the breakpoint"
|
|
1394
|
-
),
|
|
1395
|
-
|
|
1396
|
-
|
|
1413
|
+
), U && o.print("")), U && v.phpstorm && (o.print(
|
|
1414
|
+
o.bold("PhpStorm instructions:")
|
|
1415
|
+
), o.print(
|
|
1416
|
+
` 1. Choose "${o.italic(
|
|
1417
|
+
x
|
|
1397
1418
|
)}" debug configuration in the toolbar`
|
|
1398
|
-
),
|
|
1399
|
-
" 2. Click the debug button (bug icon)
|
|
1400
|
-
),
|
|
1419
|
+
), o.print(
|
|
1420
|
+
" 2. Click the debug button (bug icon)"
|
|
1421
|
+
), o.print(
|
|
1401
1422
|
" 3. Set a breakpoint. For example, in .playground-xdebug-root/wordpress/index.php"
|
|
1402
|
-
),
|
|
1423
|
+
), o.print(
|
|
1403
1424
|
" 4. Visit Playground in your browser to hit the breakpoint"
|
|
1404
|
-
)),
|
|
1405
|
-
} catch (
|
|
1425
|
+
)), o.print("");
|
|
1426
|
+
} catch (P) {
|
|
1406
1427
|
throw new Error("Could not configure Xdebug", {
|
|
1407
|
-
cause:
|
|
1428
|
+
cause: P
|
|
1408
1429
|
});
|
|
1409
1430
|
}
|
|
1410
1431
|
}
|
|
1411
1432
|
}
|
|
1412
|
-
const
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1433
|
+
const ke = d.dirname(y.path), Ie = 2 * 24 * 60 * 60 * 1e3;
|
|
1434
|
+
Wt(
|
|
1435
|
+
b,
|
|
1436
|
+
Ie,
|
|
1437
|
+
ke
|
|
1417
1438
|
);
|
|
1418
|
-
const
|
|
1419
|
-
|
|
1420
|
-
const
|
|
1439
|
+
const ee = d.join(y.path, "internal");
|
|
1440
|
+
z(ee);
|
|
1441
|
+
const Me = [
|
|
1421
1442
|
"wordpress",
|
|
1422
1443
|
"tools",
|
|
1423
1444
|
// Note: These dirs are from Emscripten's "default dirs" list:
|
|
@@ -1429,99 +1450,99 @@ async function xe(e) {
|
|
|
1429
1450
|
"tmp",
|
|
1430
1451
|
"home"
|
|
1431
1452
|
];
|
|
1432
|
-
for (const
|
|
1433
|
-
const
|
|
1434
|
-
if (!(e["mount-before-install"]?.some(
|
|
1435
|
-
const
|
|
1436
|
-
|
|
1437
|
-
|
|
1453
|
+
for (const p of Me) {
|
|
1454
|
+
const w = (P) => P.vfsPath === `/${p}`;
|
|
1455
|
+
if (!(e["mount-before-install"]?.some(w) || e.mount?.some(w))) {
|
|
1456
|
+
const P = d.join(
|
|
1457
|
+
y.path,
|
|
1458
|
+
p
|
|
1438
1459
|
);
|
|
1439
|
-
|
|
1440
|
-
vfsPath: `/${
|
|
1441
|
-
hostPath:
|
|
1460
|
+
z(P), e["mount-before-install"] === void 0 && (e["mount-before-install"] = []), e["mount-before-install"].unshift({
|
|
1461
|
+
vfsPath: `/${p}`,
|
|
1462
|
+
hostPath: P
|
|
1442
1463
|
});
|
|
1443
1464
|
}
|
|
1444
1465
|
}
|
|
1445
1466
|
if (e["mount-before-install"])
|
|
1446
|
-
for (const
|
|
1447
|
-
|
|
1448
|
-
`Mount before WP install: ${
|
|
1467
|
+
for (const p of e["mount-before-install"])
|
|
1468
|
+
h.debug(
|
|
1469
|
+
`Mount before WP install: ${p.vfsPath} -> ${p.hostPath}`
|
|
1449
1470
|
);
|
|
1450
1471
|
if (e.mount)
|
|
1451
|
-
for (const
|
|
1452
|
-
|
|
1453
|
-
`Mount after WP install: ${
|
|
1472
|
+
for (const p of e.mount)
|
|
1473
|
+
h.debug(
|
|
1474
|
+
`Mount after WP install: ${p.vfsPath} -> ${p.hostPath}`
|
|
1454
1475
|
);
|
|
1455
|
-
let
|
|
1456
|
-
e["experimental-blueprints-v2-runner"] ?
|
|
1457
|
-
siteUrl:
|
|
1458
|
-
cliOutput:
|
|
1459
|
-
}) : (
|
|
1460
|
-
siteUrl:
|
|
1461
|
-
cliOutput:
|
|
1462
|
-
}), typeof e.blueprint == "string" && (e.blueprint = await
|
|
1476
|
+
let R;
|
|
1477
|
+
e["experimental-blueprints-v2-runner"] ? R = new Tt(e, {
|
|
1478
|
+
siteUrl: D,
|
|
1479
|
+
cliOutput: o
|
|
1480
|
+
}) : (R = new Rt(e, {
|
|
1481
|
+
siteUrl: D,
|
|
1482
|
+
cliOutput: o
|
|
1483
|
+
}), typeof e.blueprint == "string" && (e.blueprint = await Mt({
|
|
1463
1484
|
sourceString: e.blueprint,
|
|
1464
1485
|
blueprintMayReadAdjacentFiles: e["blueprint-may-read-adjacent-files"] === !0
|
|
1465
1486
|
})));
|
|
1466
|
-
let
|
|
1467
|
-
const
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
await
|
|
1487
|
+
let F = !1;
|
|
1488
|
+
const W = async function() {
|
|
1489
|
+
F || (F = !0, await Promise.all(
|
|
1490
|
+
n.map(async (w) => {
|
|
1491
|
+
await i.get(w)?.dispose(), await w.worker.terminate();
|
|
1471
1492
|
})
|
|
1472
|
-
),
|
|
1473
|
-
|
|
1474
|
-
}), await
|
|
1493
|
+
), m && await new Promise((w) => {
|
|
1494
|
+
m.close(w), m.closeAllConnections();
|
|
1495
|
+
}), await y.cleanup());
|
|
1475
1496
|
};
|
|
1476
1497
|
try {
|
|
1477
|
-
const
|
|
1478
|
-
for (let
|
|
1479
|
-
const
|
|
1498
|
+
const p = [], w = R.getWorkerType();
|
|
1499
|
+
for (let g = 0; g < s; g++) {
|
|
1500
|
+
const P = $e(w, {
|
|
1480
1501
|
onExit: (v) => {
|
|
1481
|
-
|
|
1482
|
-
`Worker ${
|
|
1502
|
+
F || v !== 0 && h.error(
|
|
1503
|
+
`Worker ${g} exited with code ${v}
|
|
1483
1504
|
`
|
|
1484
1505
|
);
|
|
1485
1506
|
}
|
|
1486
1507
|
}).then(
|
|
1487
1508
|
async (v) => {
|
|
1488
|
-
|
|
1489
|
-
const S = await
|
|
1509
|
+
n.push(v);
|
|
1510
|
+
const S = await jt(u), I = await R.bootRequestHandler({
|
|
1490
1511
|
worker: v,
|
|
1491
1512
|
fileLockManagerPort: S,
|
|
1492
|
-
nativeInternalDirPath:
|
|
1513
|
+
nativeInternalDirPath: ee
|
|
1493
1514
|
});
|
|
1494
|
-
return
|
|
1515
|
+
return i.set(
|
|
1495
1516
|
v,
|
|
1496
|
-
|
|
1497
|
-
), [v,
|
|
1517
|
+
I
|
|
1518
|
+
), [v, I];
|
|
1498
1519
|
}
|
|
1499
1520
|
);
|
|
1500
|
-
|
|
1521
|
+
p.push(P), g === 0 && await P;
|
|
1501
1522
|
}
|
|
1502
|
-
await Promise.all(
|
|
1503
|
-
|
|
1504
|
-
(
|
|
1523
|
+
await Promise.all(p), t = Re(
|
|
1524
|
+
n.map(
|
|
1525
|
+
(g) => i.get(g)
|
|
1505
1526
|
)
|
|
1506
1527
|
);
|
|
1507
1528
|
{
|
|
1508
|
-
const
|
|
1509
|
-
if (await
|
|
1529
|
+
const g = new we(), P = g.port1, v = g.port2;
|
|
1530
|
+
if (await Le(
|
|
1510
1531
|
{
|
|
1511
1532
|
applyPostInstallMountsToAllWorkers: async () => {
|
|
1512
|
-
for (const S of
|
|
1533
|
+
for (const S of i.values())
|
|
1513
1534
|
await S.mountAfterWordPressInstall(
|
|
1514
1535
|
e.mount || []
|
|
1515
1536
|
);
|
|
1516
1537
|
}
|
|
1517
1538
|
},
|
|
1518
1539
|
void 0,
|
|
1519
|
-
|
|
1520
|
-
), await
|
|
1540
|
+
P
|
|
1541
|
+
), await R.bootWordPress(
|
|
1521
1542
|
t,
|
|
1522
1543
|
v
|
|
1523
|
-
),
|
|
1524
|
-
const S = await
|
|
1544
|
+
), P.close(), f = !0, !e["experimental-blueprints-v2-runner"]) {
|
|
1545
|
+
const S = await R.compileInputBlueprint(
|
|
1525
1546
|
e["additional-blueprint-steps"] || []
|
|
1526
1547
|
);
|
|
1527
1548
|
S && await ie(
|
|
@@ -1532,14 +1553,14 @@ async function xe(e) {
|
|
|
1532
1553
|
if (e.phpmyadmin && !await t.fileExists(
|
|
1533
1554
|
`${ue}/index.php`
|
|
1534
1555
|
)) {
|
|
1535
|
-
const S = await
|
|
1536
|
-
await ie(
|
|
1556
|
+
const S = await dt(), I = await he({ steps: S });
|
|
1557
|
+
await ie(I, t);
|
|
1537
1558
|
}
|
|
1538
1559
|
if (e.command === "build-snapshot") {
|
|
1539
|
-
await
|
|
1560
|
+
await qt(t, e.outfile), o.printStatus(`Exported to ${e.outfile}`), await W();
|
|
1540
1561
|
return;
|
|
1541
1562
|
} else if (e.command === "run-blueprint") {
|
|
1542
|
-
|
|
1563
|
+
o.finishProgress("Done"), await W();
|
|
1543
1564
|
return;
|
|
1544
1565
|
} else if (e.command === "php") {
|
|
1545
1566
|
const S = [
|
|
@@ -1547,79 +1568,79 @@ async function xe(e) {
|
|
|
1547
1568
|
// Hardcoding it feels fragile.
|
|
1548
1569
|
"/internal/shared/bin/php",
|
|
1549
1570
|
...(e._ || []).slice(1)
|
|
1550
|
-
],
|
|
1551
|
-
|
|
1552
|
-
|
|
1571
|
+
], I = await t.cli(S), [U] = await Promise.all([
|
|
1572
|
+
I.exitCode,
|
|
1573
|
+
I.stdout.pipeTo(
|
|
1553
1574
|
new WritableStream({
|
|
1554
|
-
write(
|
|
1555
|
-
process.stdout.write(
|
|
1575
|
+
write(L) {
|
|
1576
|
+
process.stdout.write(L);
|
|
1556
1577
|
}
|
|
1557
1578
|
})
|
|
1558
1579
|
),
|
|
1559
|
-
|
|
1580
|
+
I.stderr.pipeTo(
|
|
1560
1581
|
new WritableStream({
|
|
1561
|
-
write(
|
|
1562
|
-
process.stderr.write(
|
|
1582
|
+
write(L) {
|
|
1583
|
+
process.stderr.write(L);
|
|
1563
1584
|
}
|
|
1564
1585
|
})
|
|
1565
1586
|
)
|
|
1566
1587
|
]);
|
|
1567
|
-
await
|
|
1588
|
+
await W(), process.exit(U);
|
|
1568
1589
|
}
|
|
1569
1590
|
}
|
|
1570
|
-
if (
|
|
1571
|
-
const
|
|
1591
|
+
if (o.finishProgress(), o.printReady(M, s), e.phpmyadmin) {
|
|
1592
|
+
const g = d.join(
|
|
1572
1593
|
e.phpmyadmin,
|
|
1573
|
-
|
|
1594
|
+
pt
|
|
1574
1595
|
);
|
|
1575
|
-
|
|
1576
|
-
new URL(
|
|
1596
|
+
o.printPhpMyAdminUrl(
|
|
1597
|
+
new URL(g, M).toString()
|
|
1577
1598
|
);
|
|
1578
1599
|
}
|
|
1579
|
-
return e.xdebug && e.experimentalDevtools && (await
|
|
1600
|
+
return e.xdebug && e.experimentalDevtools && (await tt({
|
|
1580
1601
|
phpInstance: t,
|
|
1581
1602
|
phpRoot: "/wordpress"
|
|
1582
1603
|
})).start(), {
|
|
1583
1604
|
playground: t,
|
|
1584
|
-
server:
|
|
1585
|
-
serverUrl:
|
|
1586
|
-
[Symbol.asyncDispose]:
|
|
1605
|
+
server: m,
|
|
1606
|
+
serverUrl: M,
|
|
1607
|
+
[Symbol.asyncDispose]: W,
|
|
1587
1608
|
[K]: {
|
|
1588
|
-
workerThreadCount:
|
|
1609
|
+
workerThreadCount: s
|
|
1589
1610
|
}
|
|
1590
1611
|
};
|
|
1591
|
-
} catch (
|
|
1612
|
+
} catch (p) {
|
|
1592
1613
|
if (e.verbosity !== "debug")
|
|
1593
|
-
throw
|
|
1594
|
-
let
|
|
1595
|
-
throw await t?.fileExists(
|
|
1614
|
+
throw p;
|
|
1615
|
+
let w = "";
|
|
1616
|
+
throw await t?.fileExists(te) && (w = await t.readFileAsText(te)), await W(), new Error(w, { cause: p });
|
|
1596
1617
|
}
|
|
1597
1618
|
},
|
|
1598
|
-
async handleRequest(
|
|
1599
|
-
if (!
|
|
1619
|
+
async handleRequest(m) {
|
|
1620
|
+
if (!f)
|
|
1600
1621
|
return oe.forHttpCode(
|
|
1601
1622
|
502,
|
|
1602
1623
|
"WordPress is not ready yet"
|
|
1603
1624
|
);
|
|
1604
|
-
if (
|
|
1605
|
-
|
|
1606
|
-
const
|
|
1625
|
+
if (A) {
|
|
1626
|
+
A = !1;
|
|
1627
|
+
const k = {
|
|
1607
1628
|
"Content-Type": ["text/plain"],
|
|
1608
1629
|
"Content-Length": ["0"],
|
|
1609
|
-
Location: [
|
|
1630
|
+
Location: [m.url]
|
|
1610
1631
|
};
|
|
1611
|
-
return
|
|
1632
|
+
return m.headers?.cookie?.includes(
|
|
1612
1633
|
"playground_auto_login_already_happened"
|
|
1613
|
-
) && (
|
|
1634
|
+
) && (k["Set-Cookie"] = [
|
|
1614
1635
|
"playground_auto_login_already_happened=1; Max-Age=0; Expires=Thu, 01 Jan 1970 00:00:00 GMT; Path=/"
|
|
1615
1636
|
]), oe.fromPHPResponse(
|
|
1616
|
-
new
|
|
1637
|
+
new We(302, k, new Uint8Array())
|
|
1617
1638
|
);
|
|
1618
1639
|
}
|
|
1619
|
-
r && (
|
|
1620
|
-
...
|
|
1640
|
+
r && (m = {
|
|
1641
|
+
...m,
|
|
1621
1642
|
headers: {
|
|
1622
|
-
...
|
|
1643
|
+
...m.headers,
|
|
1623
1644
|
// While we have an internal cookie store, we
|
|
1624
1645
|
// completely replace the incoming request's Cookie
|
|
1625
1646
|
// header with the cookies from our store. This avoids
|
|
@@ -1628,45 +1649,48 @@ async function xe(e) {
|
|
|
1628
1649
|
cookie: r.getCookieRequestHeader()
|
|
1629
1650
|
}
|
|
1630
1651
|
});
|
|
1631
|
-
const
|
|
1652
|
+
const $ = await t.requestStreamed(m);
|
|
1632
1653
|
if (r) {
|
|
1633
|
-
const
|
|
1634
|
-
r.rememberCookiesFromResponseHeaders(
|
|
1654
|
+
const k = await $.headers;
|
|
1655
|
+
r.rememberCookiesFromResponseHeaders(k), delete k["set-cookie"];
|
|
1635
1656
|
}
|
|
1636
|
-
return
|
|
1657
|
+
return $;
|
|
1637
1658
|
}
|
|
1638
|
-
}).catch((
|
|
1639
|
-
|
|
1659
|
+
}).catch((m) => {
|
|
1660
|
+
o.printError(Se(m)), process.exit(1);
|
|
1640
1661
|
});
|
|
1641
|
-
return
|
|
1662
|
+
return E && e.command === "start" && !e.skipBrowser && Vt(E.serverUrl), E;
|
|
1642
1663
|
}
|
|
1643
|
-
function Ot(e) {
|
|
1644
|
-
let
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1664
|
+
function Ot(e, t) {
|
|
1665
|
+
let r = { ...e, command: "server" };
|
|
1666
|
+
const n = e.autoMount !== !1;
|
|
1667
|
+
delete r.autoMount, delete r["auto-mount"], n && (r.autoMount = d.resolve(process.cwd(), r.path ?? ""), r = ge(r), delete r.autoMount);
|
|
1668
|
+
const i = me(
|
|
1669
|
+
r["mount-before-install"] || [],
|
|
1648
1670
|
"/wordpress"
|
|
1649
|
-
) || me(
|
|
1650
|
-
if (
|
|
1651
|
-
|
|
1652
|
-
|
|
1671
|
+
) || me(r.mount || [], "/wordpress");
|
|
1672
|
+
if (i)
|
|
1673
|
+
t.print(
|
|
1674
|
+
`Site files stored at: ${i?.hostPath}`
|
|
1675
|
+
), e.reset && (t.print(""), t.print(
|
|
1676
|
+
t.red(
|
|
1653
1677
|
"This site is not managed by Playground CLI and cannot be reset."
|
|
1654
1678
|
)
|
|
1655
|
-
),
|
|
1679
|
+
), t.print(
|
|
1656
1680
|
"(It's not stored in the ~/.wordpress-playground/sites/<site-id> directory.)"
|
|
1657
|
-
),
|
|
1681
|
+
), t.print(""), t.print(
|
|
1658
1682
|
"You may still remove the site's directory manually if you wish."
|
|
1659
1683
|
), process.exit(1));
|
|
1660
1684
|
else {
|
|
1661
|
-
const o =
|
|
1662
|
-
|
|
1685
|
+
const o = r.autoMount || process.cwd(), a = ut("sha256").update(o).digest("hex"), l = B.homedir(), u = d.join(
|
|
1686
|
+
l,
|
|
1663
1687
|
".wordpress-playground/sites",
|
|
1664
|
-
|
|
1688
|
+
a
|
|
1665
1689
|
);
|
|
1666
|
-
|
|
1667
|
-
...
|
|
1668
|
-
{ vfsPath: "/wordpress", hostPath:
|
|
1669
|
-
],
|
|
1690
|
+
t.print(`Site files stored at: ${u}`), Q(u) && e.reset && (t.print("Resetting site..."), He(u, { recursive: !0 })), z(u, { recursive: !0 }), r["mount-before-install"] = [
|
|
1691
|
+
...r["mount-before-install"] || [],
|
|
1692
|
+
{ vfsPath: "/wordpress", hostPath: u }
|
|
1693
|
+
], r.wordpressInstallMode = Fe(u).length === 0 ? (
|
|
1670
1694
|
// Only download WordPress on the first run when the site directory is still
|
|
1671
1695
|
// empty.
|
|
1672
1696
|
"download-and-install"
|
|
@@ -1675,41 +1699,41 @@ function Ot(e) {
|
|
|
1675
1699
|
"install-from-existing-files-if-needed"
|
|
1676
1700
|
);
|
|
1677
1701
|
}
|
|
1678
|
-
return
|
|
1702
|
+
return r;
|
|
1679
1703
|
}
|
|
1680
|
-
const
|
|
1681
|
-
function
|
|
1704
|
+
const q = new Te();
|
|
1705
|
+
function $e(e, { onExit: t } = {}) {
|
|
1682
1706
|
let r;
|
|
1683
|
-
return e === "v1" ? r = new
|
|
1684
|
-
const
|
|
1707
|
+
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((n, i) => {
|
|
1708
|
+
const o = q.claim();
|
|
1685
1709
|
r.once("message", function(l) {
|
|
1686
|
-
l.command === "worker-script-initialized" &&
|
|
1687
|
-
processId:
|
|
1710
|
+
l.command === "worker-script-initialized" && n({
|
|
1711
|
+
processId: o,
|
|
1688
1712
|
worker: r,
|
|
1689
1713
|
phpPort: l.phpPort
|
|
1690
1714
|
});
|
|
1691
1715
|
}), r.once("error", function(l) {
|
|
1692
|
-
|
|
1693
|
-
const u = l?.message || (l ? String(l) : "unknown error"),
|
|
1716
|
+
q.release(o), console.error(l);
|
|
1717
|
+
const u = l?.message || (l ? String(l) : "unknown error"), f = new Error(
|
|
1694
1718
|
`Worker failed to load. Original error: ${u}`,
|
|
1695
1719
|
{ cause: l }
|
|
1696
1720
|
);
|
|
1697
|
-
|
|
1721
|
+
i(f);
|
|
1698
1722
|
});
|
|
1699
|
-
let
|
|
1723
|
+
let a = !1;
|
|
1700
1724
|
r.once("spawn", () => {
|
|
1701
|
-
|
|
1725
|
+
a = !0;
|
|
1702
1726
|
}), r.once("exit", (l) => {
|
|
1703
|
-
|
|
1727
|
+
q.release(o), a || i(new Error(`Worker exited before spawning: ${l}`)), t?.(l);
|
|
1704
1728
|
});
|
|
1705
1729
|
});
|
|
1706
1730
|
}
|
|
1707
|
-
async function
|
|
1708
|
-
const { port1: t, port2: r } = new
|
|
1709
|
-
return await
|
|
1731
|
+
async function jt(e) {
|
|
1732
|
+
const { port1: t, port2: r } = new we();
|
|
1733
|
+
return await Be(e, t), r;
|
|
1710
1734
|
}
|
|
1711
|
-
function
|
|
1712
|
-
const t =
|
|
1735
|
+
function Vt(e) {
|
|
1736
|
+
const t = B.platform();
|
|
1713
1737
|
let r;
|
|
1714
1738
|
switch (t) {
|
|
1715
1739
|
case "darwin":
|
|
@@ -1722,11 +1746,11 @@ function jt(e) {
|
|
|
1722
1746
|
r = `xdg-open "${e}"`;
|
|
1723
1747
|
break;
|
|
1724
1748
|
}
|
|
1725
|
-
be(r, (
|
|
1726
|
-
|
|
1749
|
+
be(r, (n) => {
|
|
1750
|
+
n && h.debug(`Could not open browser: ${n.message}`);
|
|
1727
1751
|
});
|
|
1728
1752
|
}
|
|
1729
|
-
async function
|
|
1753
|
+
async function qt(e, t) {
|
|
1730
1754
|
await e.run({
|
|
1731
1755
|
code: `<?php
|
|
1732
1756
|
$zip = new ZipArchive();
|
|
@@ -1748,26 +1772,28 @@ async function Vt(e, t) {
|
|
|
1748
1772
|
`
|
|
1749
1773
|
});
|
|
1750
1774
|
const r = await e.readFileAsBuffer("/tmp/build.zip");
|
|
1751
|
-
|
|
1775
|
+
c.writeFileSync(t, r);
|
|
1752
1776
|
}
|
|
1753
|
-
const
|
|
1777
|
+
const Pr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
1754
1778
|
__proto__: null,
|
|
1755
1779
|
LogVerbosity: J,
|
|
1756
1780
|
internalsKeyForTesting: K,
|
|
1757
1781
|
mergeDefinedConstants: Z,
|
|
1758
|
-
parseOptionsAndRunCLI:
|
|
1759
|
-
|
|
1760
|
-
|
|
1782
|
+
parseOptionsAndRunCLI: Ft,
|
|
1783
|
+
resolveWorkerCount: xe,
|
|
1784
|
+
runCLI: Ee,
|
|
1785
|
+
spawnWorkerThread: $e
|
|
1761
1786
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
1762
1787
|
export {
|
|
1763
1788
|
J as L,
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1789
|
+
Ee as a,
|
|
1790
|
+
gr as b,
|
|
1791
|
+
Nt as c,
|
|
1792
|
+
Pr as d,
|
|
1767
1793
|
K as i,
|
|
1768
1794
|
Z as m,
|
|
1769
|
-
|
|
1795
|
+
Ft as p,
|
|
1770
1796
|
xe as r,
|
|
1771
|
-
|
|
1797
|
+
$e as s
|
|
1772
1798
|
};
|
|
1773
|
-
//# sourceMappingURL=run-cli-
|
|
1799
|
+
//# sourceMappingURL=run-cli-CC9V0J3D.js.map
|