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