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