@wp-playground/cli 3.0.16 → 3.0.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cli.cjs +1 -1
- package/cli.js +1 -1
- package/index.cjs +1 -1
- package/index.js +1 -1
- package/package.json +12 -12
- package/{run-cli-B59N7dQd.js → run-cli-BBfr5tmj.js} +427 -416
- package/run-cli-BBfr5tmj.js.map +1 -0
- package/run-cli-Dz_ghzvE.cjs +46 -0
- package/run-cli-Dz_ghzvE.cjs.map +1 -0
- package/run-cli.d.ts +7 -2
- package/start-server.d.ts +2 -2
- package/temp-dir.d.ts +1 -1
- package/run-cli-B59N7dQd.js.map +0 -1
- package/run-cli-BKsGTaC9.cjs +0 -46
- package/run-cli-BKsGTaC9.cjs.map +0 -1
|
@@ -1,67 +1,67 @@
|
|
|
1
|
-
import { logger as
|
|
2
|
-
import { PHPResponse as
|
|
3
|
-
import { resolveRemoteBlueprint as
|
|
4
|
-
import { zipDirectory as
|
|
5
|
-
import u, { mkdirSync as
|
|
6
|
-
import { Worker as
|
|
7
|
-
import { p as
|
|
8
|
-
import
|
|
9
|
-
import { FileLockManagerForNode as
|
|
10
|
-
import
|
|
11
|
-
import { jspi as
|
|
12
|
-
import
|
|
13
|
-
import g, { basename as
|
|
14
|
-
import { NodeJsFilesystem as
|
|
15
|
-
import { EmscriptenDownloadMonitor as
|
|
16
|
-
import { resolveWordPressRelease as
|
|
17
|
-
import
|
|
18
|
-
import { startBridge as
|
|
19
|
-
import { dir as
|
|
20
|
-
import
|
|
21
|
-
import { XMLParser as
|
|
22
|
-
import
|
|
23
|
-
async function
|
|
24
|
-
const o =
|
|
25
|
-
const
|
|
26
|
-
const
|
|
27
|
-
|
|
1
|
+
import { logger as h, LogSeverity as A, errorLogPath as q } from "@php-wasm/logger";
|
|
2
|
+
import { PHPResponse as V, consumeAPI as j, SupportedPHPVersions as ue, printDebugDetails as de, exposeAPI as fe, exposeSyncAPI as me } from "@php-wasm/universal";
|
|
3
|
+
import { resolveRemoteBlueprint as he, resolveRuntimeConfiguration as ge, compileBlueprintV1 as ye, isBlueprintBundle as we, runBlueprintV1Steps as be } from "@wp-playground/blueprints";
|
|
4
|
+
import { zipDirectory as ve, RecommendedPHPVersion as G } from "@wp-playground/common";
|
|
5
|
+
import u, { mkdirSync as z } from "fs";
|
|
6
|
+
import { Worker as X, MessageChannel as Pe } from "worker_threads";
|
|
7
|
+
import { p as J, a as Se, e as ke } from "./mounts-D1_eXSTw.js";
|
|
8
|
+
import xe from "express";
|
|
9
|
+
import { FileLockManagerForNode as Ee } from "@php-wasm/node";
|
|
10
|
+
import K, { cpus as Ie } from "os";
|
|
11
|
+
import { jspi as Ce } from "wasm-feature-detect";
|
|
12
|
+
import Le from "yargs";
|
|
13
|
+
import g, { basename as $e } from "path";
|
|
14
|
+
import { NodeJsFilesystem as We, OverlayFilesystem as Te, InMemoryFilesystem as Be, ZipFilesystem as je } from "@wp-playground/storage";
|
|
15
|
+
import { EmscriptenDownloadMonitor as Re, ProgressTracker as Fe } from "@php-wasm/progress";
|
|
16
|
+
import { resolveWordPressRelease as Me } from "@wp-playground/wordpress";
|
|
17
|
+
import $ from "fs-extra";
|
|
18
|
+
import { startBridge as De } from "@php-wasm/xdebug-bridge";
|
|
19
|
+
import { dir as Ae, setGracefulCleanup as Ue } from "tmp-promise";
|
|
20
|
+
import Ne from "ps-man";
|
|
21
|
+
import { XMLParser as Q, XMLBuilder as ee } from "fast-xml-parser";
|
|
22
|
+
import P from "jsonc-parser";
|
|
23
|
+
async function Ve(e) {
|
|
24
|
+
const o = xe(), t = await new Promise((n, r) => {
|
|
25
|
+
const a = o.listen(e.port, () => {
|
|
26
|
+
const l = a.address();
|
|
27
|
+
l === null || typeof l == "string" ? r(new Error("Server address is not available")) : n(a);
|
|
28
28
|
});
|
|
29
29
|
});
|
|
30
|
-
o.use("/", async (n,
|
|
31
|
-
let
|
|
30
|
+
o.use("/", async (n, r) => {
|
|
31
|
+
let a;
|
|
32
32
|
try {
|
|
33
|
-
|
|
33
|
+
a = await e.handleRequest({
|
|
34
34
|
url: n.url,
|
|
35
|
-
headers:
|
|
35
|
+
headers: _e(n),
|
|
36
36
|
method: n.method,
|
|
37
|
-
body: await
|
|
37
|
+
body: await Oe(n)
|
|
38
38
|
});
|
|
39
|
-
} catch (
|
|
40
|
-
|
|
39
|
+
} catch (l) {
|
|
40
|
+
h.error(l), a = V.forHttpCode(500);
|
|
41
41
|
}
|
|
42
|
-
|
|
43
|
-
for (const
|
|
44
|
-
|
|
45
|
-
|
|
42
|
+
r.statusCode = a.httpStatusCode;
|
|
43
|
+
for (const l in a.headers)
|
|
44
|
+
r.setHeader(l, a.headers[l]);
|
|
45
|
+
r.end(a.bytes);
|
|
46
46
|
});
|
|
47
|
-
const
|
|
48
|
-
return await e.onBind(t,
|
|
47
|
+
const s = t.address().port;
|
|
48
|
+
return await e.onBind(t, s);
|
|
49
49
|
}
|
|
50
|
-
const
|
|
50
|
+
const Oe = async (e) => await new Promise((o) => {
|
|
51
51
|
const t = [];
|
|
52
52
|
e.on("data", (i) => {
|
|
53
53
|
t.push(i);
|
|
54
54
|
}), e.on("end", () => {
|
|
55
55
|
o(new Uint8Array(Buffer.concat(t)));
|
|
56
56
|
});
|
|
57
|
-
}),
|
|
57
|
+
}), _e = (e) => {
|
|
58
58
|
const o = {};
|
|
59
59
|
if (e.rawHeaders && e.rawHeaders.length)
|
|
60
60
|
for (let t = 0; t < e.rawHeaders.length; t += 2)
|
|
61
61
|
o[e.rawHeaders[t].toLowerCase()] = e.rawHeaders[t + 1];
|
|
62
62
|
return o;
|
|
63
63
|
};
|
|
64
|
-
class
|
|
64
|
+
class He {
|
|
65
65
|
constructor(o) {
|
|
66
66
|
this.workerLoads = [], this.addWorker(o);
|
|
67
67
|
}
|
|
@@ -73,8 +73,8 @@ class Oe {
|
|
|
73
73
|
}
|
|
74
74
|
async handleRequest(o) {
|
|
75
75
|
let t = this.workerLoads[0];
|
|
76
|
-
for (let
|
|
77
|
-
const n = this.workerLoads[
|
|
76
|
+
for (let s = 1; s < this.workerLoads.length; s++) {
|
|
77
|
+
const n = this.workerLoads[s];
|
|
78
78
|
n.activeRequests.size < t.activeRequests.size && (t = n);
|
|
79
79
|
}
|
|
80
80
|
const i = t.worker.request(o);
|
|
@@ -83,17 +83,17 @@ class Oe {
|
|
|
83
83
|
});
|
|
84
84
|
}
|
|
85
85
|
}
|
|
86
|
-
function
|
|
86
|
+
function qe(e) {
|
|
87
87
|
return /^latest$|^trunk$|^nightly$|^(?:(\d+)\.(\d+)(?:\.(\d+))?)((?:-beta(?:\d+)?)|(?:-RC(?:\d+)?))?$/.test(e);
|
|
88
88
|
}
|
|
89
|
-
async function
|
|
89
|
+
async function ze({
|
|
90
90
|
sourceString: e,
|
|
91
91
|
blueprintMayReadAdjacentFiles: o
|
|
92
92
|
}) {
|
|
93
93
|
if (!e)
|
|
94
94
|
return;
|
|
95
95
|
if (e.startsWith("http://") || e.startsWith("https://"))
|
|
96
|
-
return await
|
|
96
|
+
return await he(e);
|
|
97
97
|
let t = g.resolve(process.cwd(), e);
|
|
98
98
|
if (!u.existsSync(t))
|
|
99
99
|
throw new Error(`Blueprint file does not exist: ${t}`);
|
|
@@ -102,10 +102,10 @@ async function He({
|
|
|
102
102
|
throw new Error(
|
|
103
103
|
`Blueprint path is neither a file nor a directory: ${t}`
|
|
104
104
|
);
|
|
105
|
-
const
|
|
106
|
-
switch (
|
|
105
|
+
const s = g.extname(t);
|
|
106
|
+
switch (s) {
|
|
107
107
|
case ".zip":
|
|
108
|
-
return
|
|
108
|
+
return je.fromArrayBuffer(
|
|
109
109
|
u.readFileSync(t).buffer
|
|
110
110
|
);
|
|
111
111
|
case ".json": {
|
|
@@ -117,9 +117,9 @@ async function He({
|
|
|
117
117
|
`Blueprint file at ${t} is not a valid JSON file`
|
|
118
118
|
);
|
|
119
119
|
}
|
|
120
|
-
const
|
|
121
|
-
return new
|
|
122
|
-
new
|
|
120
|
+
const r = g.dirname(t), a = new We(r);
|
|
121
|
+
return new Te([
|
|
122
|
+
new Be({
|
|
123
123
|
"blueprint.json": n
|
|
124
124
|
}),
|
|
125
125
|
/**
|
|
@@ -127,25 +127,25 @@ async function He({
|
|
|
127
127
|
* unless the user explicitly allowed it.
|
|
128
128
|
*/
|
|
129
129
|
{
|
|
130
|
-
read(
|
|
130
|
+
read(l) {
|
|
131
131
|
if (!o)
|
|
132
132
|
throw new Error(
|
|
133
|
-
`Error: Blueprint contained tried to read a local file at path "${
|
|
133
|
+
`Error: Blueprint contained tried to read a local file at path "${l}" (via a resource of type "bundled"). Playground restricts access to local resources by default as a security measure.
|
|
134
134
|
|
|
135
135
|
You can allow this Blueprint to read files from the same parent directory by explicitly adding the --blueprint-may-read-adjacent-files option to your command.`
|
|
136
136
|
);
|
|
137
|
-
return
|
|
137
|
+
return a.read(l);
|
|
138
138
|
}
|
|
139
139
|
}
|
|
140
140
|
]);
|
|
141
141
|
}
|
|
142
142
|
default:
|
|
143
143
|
throw new Error(
|
|
144
|
-
`Unsupported blueprint file extension: ${
|
|
144
|
+
`Unsupported blueprint file extension: ${s}. Only .zip and .json files are supported.`
|
|
145
145
|
);
|
|
146
146
|
}
|
|
147
147
|
}
|
|
148
|
-
class
|
|
148
|
+
class Xe {
|
|
149
149
|
constructor(o, t) {
|
|
150
150
|
this.lastProgressMessage = "", this.args = o, this.siteUrl = t.siteUrl, this.processIdSpaceLength = t.processIdSpaceLength, this.phpVersion = o.php;
|
|
151
151
|
}
|
|
@@ -153,8 +153,8 @@ class qe {
|
|
|
153
153
|
return "v2";
|
|
154
154
|
}
|
|
155
155
|
async bootPrimaryWorker(o, t, i) {
|
|
156
|
-
const
|
|
157
|
-
await
|
|
156
|
+
const s = j(o);
|
|
157
|
+
await s.useFileLockManager(t);
|
|
158
158
|
const n = {
|
|
159
159
|
...this.args,
|
|
160
160
|
phpVersion: this.phpVersion,
|
|
@@ -167,17 +167,17 @@ class qe {
|
|
|
167
167
|
xdebug: typeof this.args.xdebug == "object" ? this.args.xdebug : void 0,
|
|
168
168
|
nativeInternalDirPath: i
|
|
169
169
|
};
|
|
170
|
-
return await
|
|
170
|
+
return await s.bootAsPrimaryWorker(n), s;
|
|
171
171
|
}
|
|
172
172
|
async bootSecondaryWorker({
|
|
173
173
|
worker: o,
|
|
174
174
|
fileLockManagerPort: t,
|
|
175
175
|
firstProcessId: i,
|
|
176
|
-
nativeInternalDirPath:
|
|
176
|
+
nativeInternalDirPath: s
|
|
177
177
|
}) {
|
|
178
178
|
const n = j(o.phpPort);
|
|
179
179
|
await n.useFileLockManager(t);
|
|
180
|
-
const
|
|
180
|
+
const r = {
|
|
181
181
|
...this.args,
|
|
182
182
|
phpVersion: this.phpVersion,
|
|
183
183
|
siteUrl: this.siteUrl,
|
|
@@ -185,11 +185,11 @@ class qe {
|
|
|
185
185
|
processIdSpaceLength: this.processIdSpaceLength,
|
|
186
186
|
trace: this.args.debug || !1,
|
|
187
187
|
withXdebug: !!this.args.xdebug,
|
|
188
|
-
nativeInternalDirPath:
|
|
188
|
+
nativeInternalDirPath: s,
|
|
189
189
|
mountsBeforeWpInstall: this.args["mount-before-install"] || [],
|
|
190
190
|
mountsAfterWpInstall: this.args.mount || []
|
|
191
191
|
};
|
|
192
|
-
return await n.bootAsSecondaryWorker(
|
|
192
|
+
return await n.bootAsSecondaryWorker(r), n;
|
|
193
193
|
}
|
|
194
194
|
writeProgressUpdate(o, t, i) {
|
|
195
195
|
t !== this.lastProgressMessage && (this.lastProgressMessage = t, o.isTTY ? (o.cursorTo(0), o.write(t), o.clearLine(1), i && o.write(`
|
|
@@ -197,37 +197,37 @@ class qe {
|
|
|
197
197
|
`));
|
|
198
198
|
}
|
|
199
199
|
}
|
|
200
|
-
const
|
|
201
|
-
async function
|
|
202
|
-
return await
|
|
200
|
+
const O = g.join(K.homedir(), ".wordpress-playground");
|
|
201
|
+
async function Je(e) {
|
|
202
|
+
return await te(
|
|
203
203
|
"https://github.com/WordPress/sqlite-database-integration/archive/refs/heads/develop.zip",
|
|
204
204
|
"sqlite.zip",
|
|
205
205
|
e
|
|
206
206
|
);
|
|
207
207
|
}
|
|
208
|
-
async function
|
|
209
|
-
const i = g.join(
|
|
210
|
-
return
|
|
208
|
+
async function te(e, o, t) {
|
|
209
|
+
const i = g.join(O, o);
|
|
210
|
+
return $.existsSync(i) || ($.ensureDirSync(O), await Ze(e, i, t)), oe(i);
|
|
211
211
|
}
|
|
212
|
-
async function
|
|
213
|
-
const
|
|
212
|
+
async function Ze(e, o, t) {
|
|
213
|
+
const s = (await t.monitorFetch(fetch(e))).body.getReader(), n = `${o}.partial`, r = $.createWriteStream(n);
|
|
214
214
|
for (; ; ) {
|
|
215
|
-
const { done:
|
|
216
|
-
if (
|
|
215
|
+
const { done: a, value: l } = await s.read();
|
|
216
|
+
if (l && r.write(l), a)
|
|
217
217
|
break;
|
|
218
218
|
}
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
}),
|
|
223
|
-
|
|
219
|
+
r.close(), r.closed || await new Promise((a, l) => {
|
|
220
|
+
r.on("finish", () => {
|
|
221
|
+
$.renameSync(n, o), a(null);
|
|
222
|
+
}), r.on("error", (p) => {
|
|
223
|
+
$.removeSync(n), l(p);
|
|
224
224
|
});
|
|
225
225
|
});
|
|
226
226
|
}
|
|
227
|
-
function
|
|
228
|
-
return new File([
|
|
227
|
+
function oe(e, o) {
|
|
228
|
+
return new File([$.readFileSync(e)], $e(e));
|
|
229
229
|
}
|
|
230
|
-
class
|
|
230
|
+
class Ye {
|
|
231
231
|
constructor(o, t) {
|
|
232
232
|
this.lastProgressMessage = "", this.args = o, this.siteUrl = t.siteUrl, this.processIdSpaceLength = t.processIdSpaceLength;
|
|
233
233
|
}
|
|
@@ -235,47 +235,47 @@ class Je {
|
|
|
235
235
|
return "v1";
|
|
236
236
|
}
|
|
237
237
|
async bootPrimaryWorker(o, t, i) {
|
|
238
|
-
let
|
|
239
|
-
const n = new
|
|
238
|
+
let s;
|
|
239
|
+
const n = new Re();
|
|
240
240
|
if (!this.args.skipWordPressSetup) {
|
|
241
|
-
let
|
|
242
|
-
n.addEventListener("progress", (
|
|
243
|
-
if (
|
|
241
|
+
let I = !1;
|
|
242
|
+
n.addEventListener("progress", (k) => {
|
|
243
|
+
if (I)
|
|
244
244
|
return;
|
|
245
|
-
const { loaded:
|
|
246
|
-
Math.min(100, 100 *
|
|
245
|
+
const { loaded: x, total: f } = k.detail, W = Math.floor(
|
|
246
|
+
Math.min(100, 100 * x / f)
|
|
247
247
|
);
|
|
248
|
-
|
|
248
|
+
I = W === 100, this.writeProgressUpdate(
|
|
249
249
|
process.stdout,
|
|
250
|
-
`Downloading WordPress ${
|
|
251
|
-
|
|
250
|
+
`Downloading WordPress ${W}%...`,
|
|
251
|
+
I
|
|
252
252
|
);
|
|
253
|
-
}),
|
|
254
|
-
`Resolved WordPress release URL: ${
|
|
253
|
+
}), s = await Me(this.args.wp), h.log(
|
|
254
|
+
`Resolved WordPress release URL: ${s?.releaseUrl}`
|
|
255
255
|
);
|
|
256
256
|
}
|
|
257
|
-
const
|
|
258
|
-
|
|
259
|
-
`prebuilt-wp-content-for-wp-${
|
|
260
|
-
),
|
|
261
|
-
|
|
262
|
-
`${
|
|
257
|
+
const r = s && g.join(
|
|
258
|
+
O,
|
|
259
|
+
`prebuilt-wp-content-for-wp-${s.version}.zip`
|
|
260
|
+
), a = s ? u.existsSync(r) ? oe(r) : await te(
|
|
261
|
+
s.releaseUrl,
|
|
262
|
+
`${s.version}.zip`,
|
|
263
263
|
n
|
|
264
264
|
) : void 0;
|
|
265
|
-
|
|
266
|
-
const
|
|
267
|
-
await
|
|
268
|
-
const
|
|
265
|
+
h.log("Fetching SQLite integration plugin...");
|
|
266
|
+
const l = this.args.skipSqliteSetup ? void 0 : await Je(n), p = this.args.followSymlinks === !0, c = this.args.experimentalTrace === !0, d = this.args["mount-before-install"] || [], m = this.args.mount || [], b = j(o);
|
|
267
|
+
await b.isConnected(), h.log("Booting WordPress...");
|
|
268
|
+
const v = await ge(
|
|
269
269
|
this.getEffectiveBlueprint()
|
|
270
270
|
);
|
|
271
|
-
return await
|
|
272
|
-
phpVersion:
|
|
273
|
-
wpVersion:
|
|
271
|
+
return await b.useFileLockManager(t), await b.bootAsPrimaryWorker({
|
|
272
|
+
phpVersion: v.phpVersion,
|
|
273
|
+
wpVersion: v.wpVersion,
|
|
274
274
|
siteUrl: this.siteUrl,
|
|
275
275
|
mountsBeforeWpInstall: d,
|
|
276
|
-
mountsAfterWpInstall:
|
|
277
|
-
wordPressZip:
|
|
278
|
-
sqliteIntegrationPluginZip: await
|
|
276
|
+
mountsAfterWpInstall: m,
|
|
277
|
+
wordPressZip: a && await a.arrayBuffer(),
|
|
278
|
+
sqliteIntegrationPluginZip: await l?.arrayBuffer(),
|
|
279
279
|
firstProcessId: 0,
|
|
280
280
|
processIdSpaceLength: this.processIdSpaceLength,
|
|
281
281
|
followSymlinks: p,
|
|
@@ -283,16 +283,16 @@ class Je {
|
|
|
283
283
|
internalCookieStore: this.args.internalCookieStore,
|
|
284
284
|
withXdebug: !!this.args.xdebug,
|
|
285
285
|
nativeInternalDirPath: i
|
|
286
|
-
}),
|
|
287
|
-
|
|
288
|
-
await
|
|
289
|
-
),
|
|
286
|
+
}), s && !this.args["mount-before-install"] && !u.existsSync(r) && (h.log("Caching preinstalled WordPress for the next boot..."), u.writeFileSync(
|
|
287
|
+
r,
|
|
288
|
+
await ve(b, "/wordpress")
|
|
289
|
+
), h.log("Cached!")), b;
|
|
290
290
|
}
|
|
291
291
|
async bootSecondaryWorker({
|
|
292
292
|
worker: o,
|
|
293
293
|
fileLockManagerPort: t,
|
|
294
294
|
firstProcessId: i,
|
|
295
|
-
nativeInternalDirPath:
|
|
295
|
+
nativeInternalDirPath: s
|
|
296
296
|
}) {
|
|
297
297
|
const n = j(
|
|
298
298
|
o.phpPort
|
|
@@ -310,49 +310,49 @@ class Je {
|
|
|
310
310
|
// will have a separate cookie store.
|
|
311
311
|
internalCookieStore: this.args.internalCookieStore,
|
|
312
312
|
withXdebug: !!this.args.xdebug,
|
|
313
|
-
nativeInternalDirPath:
|
|
313
|
+
nativeInternalDirPath: s
|
|
314
314
|
}), await n.isReady(), n;
|
|
315
315
|
}
|
|
316
316
|
async compileInputBlueprint(o) {
|
|
317
|
-
const t = this.getEffectiveBlueprint(), i = new
|
|
318
|
-
let
|
|
319
|
-
return i.addEventListener("progress", (
|
|
317
|
+
const t = this.getEffectiveBlueprint(), i = new Fe();
|
|
318
|
+
let s = "", n = !1;
|
|
319
|
+
return i.addEventListener("progress", (r) => {
|
|
320
320
|
if (n)
|
|
321
321
|
return;
|
|
322
|
-
n =
|
|
323
|
-
const
|
|
324
|
-
|
|
325
|
-
const
|
|
322
|
+
n = r.detail.progress === 100;
|
|
323
|
+
const a = Math.floor(r.detail.progress);
|
|
324
|
+
s = r.detail.caption || s || "Running the Blueprint";
|
|
325
|
+
const l = `${s.trim()} – ${a}%`;
|
|
326
326
|
this.writeProgressUpdate(
|
|
327
327
|
process.stdout,
|
|
328
|
-
|
|
328
|
+
l,
|
|
329
329
|
n
|
|
330
330
|
);
|
|
331
|
-
}), await
|
|
331
|
+
}), await ye(t, {
|
|
332
332
|
progress: i,
|
|
333
333
|
additionalSteps: o
|
|
334
334
|
});
|
|
335
335
|
}
|
|
336
336
|
getEffectiveBlueprint() {
|
|
337
337
|
const o = this.args.blueprint;
|
|
338
|
-
return
|
|
338
|
+
return we(o) ? o : {
|
|
339
339
|
login: this.args.login,
|
|
340
340
|
...o || {},
|
|
341
341
|
preferredVersions: {
|
|
342
|
-
php: this.args.php ?? o?.preferredVersions?.php ??
|
|
342
|
+
php: this.args.php ?? o?.preferredVersions?.php ?? G,
|
|
343
343
|
wp: this.args.wp ?? o?.preferredVersions?.wp ?? "latest",
|
|
344
344
|
...o?.preferredVersions || {}
|
|
345
345
|
}
|
|
346
346
|
};
|
|
347
347
|
}
|
|
348
348
|
writeProgressUpdate(o, t, i) {
|
|
349
|
-
this.args.verbosity !==
|
|
349
|
+
this.args.verbosity !== _.Quiet.name && t !== this.lastProgressMessage && (this.lastProgressMessage = t, o.isTTY ? (o.cursorTo(0), o.write(t), o.clearLine(1), i && o.write(`
|
|
350
350
|
`)) : o.write(`${t}
|
|
351
351
|
`));
|
|
352
352
|
}
|
|
353
353
|
}
|
|
354
|
-
async function
|
|
355
|
-
const i = `${g.basename(process.argv0)}${e}${process.pid}-`,
|
|
354
|
+
async function Ge(e, o = !0) {
|
|
355
|
+
const i = `${g.basename(process.argv0)}${e}${process.pid}-`, s = await Ae({
|
|
356
356
|
prefix: i,
|
|
357
357
|
/*
|
|
358
358
|
* Allow recursive cleanup on process exit.
|
|
@@ -363,81 +363,81 @@ async function Ze(e, o = !0) {
|
|
|
363
363
|
* https://github.com/raszi/node-tmp/blob/3d2fe387f3f91b13830b9182faa02c3231ea8258/lib/tmp.js#L318
|
|
364
364
|
*/
|
|
365
365
|
unsafeCleanup: !0
|
|
366
|
-
})
|
|
367
|
-
return o &&
|
|
366
|
+
});
|
|
367
|
+
return o && Ue(), s;
|
|
368
368
|
}
|
|
369
|
-
async function
|
|
370
|
-
const
|
|
369
|
+
async function Ke(e, o, t) {
|
|
370
|
+
const s = (await Qe(
|
|
371
371
|
e,
|
|
372
372
|
o,
|
|
373
373
|
t
|
|
374
374
|
)).map(
|
|
375
|
-
(n) => new Promise((
|
|
376
|
-
u.rm(n, { recursive: !0 }, (
|
|
377
|
-
|
|
375
|
+
(n) => new Promise((r) => {
|
|
376
|
+
u.rm(n, { recursive: !0 }, (a) => {
|
|
377
|
+
a ? h.warn(
|
|
378
378
|
`Failed to delete stale Playground temp dir: ${n}`,
|
|
379
|
-
|
|
380
|
-
) :
|
|
379
|
+
a
|
|
380
|
+
) : h.info(
|
|
381
381
|
`Deleted stale Playground temp dir: ${n}`
|
|
382
|
-
),
|
|
382
|
+
), r();
|
|
383
383
|
});
|
|
384
384
|
})
|
|
385
385
|
);
|
|
386
|
-
await Promise.all(
|
|
386
|
+
await Promise.all(s);
|
|
387
387
|
}
|
|
388
|
-
async function
|
|
388
|
+
async function Qe(e, o, t) {
|
|
389
389
|
try {
|
|
390
|
-
const i = u.readdirSync(t).map((n) => g.join(t, n)),
|
|
390
|
+
const i = u.readdirSync(t).map((n) => g.join(t, n)), s = [];
|
|
391
391
|
for (const n of i)
|
|
392
|
-
await
|
|
392
|
+
await et(
|
|
393
393
|
e,
|
|
394
394
|
o,
|
|
395
395
|
n
|
|
396
|
-
) &&
|
|
397
|
-
return
|
|
396
|
+
) && s.push(n);
|
|
397
|
+
return s;
|
|
398
398
|
} catch (i) {
|
|
399
|
-
return
|
|
399
|
+
return h.warn(`Failed to find stale Playground temp dirs: ${i}`), [];
|
|
400
400
|
}
|
|
401
401
|
}
|
|
402
|
-
async function
|
|
402
|
+
async function et(e, o, t) {
|
|
403
403
|
if (!u.lstatSync(t).isDirectory())
|
|
404
404
|
return !1;
|
|
405
|
-
const
|
|
406
|
-
if (!
|
|
405
|
+
const s = g.basename(t);
|
|
406
|
+
if (!s.includes(e))
|
|
407
407
|
return !1;
|
|
408
|
-
const n =
|
|
408
|
+
const n = s.match(
|
|
409
409
|
new RegExp(`^(.+)${e}(\\d+)-`)
|
|
410
410
|
);
|
|
411
411
|
if (!n)
|
|
412
412
|
return !1;
|
|
413
|
-
const
|
|
413
|
+
const r = {
|
|
414
414
|
executableName: n[1],
|
|
415
415
|
pid: n[2]
|
|
416
416
|
};
|
|
417
|
-
if (await
|
|
417
|
+
if (await tt(r.pid, r.executableName))
|
|
418
418
|
return !1;
|
|
419
|
-
const
|
|
420
|
-
return u.statSync(t).mtime.getTime() <
|
|
419
|
+
const a = Date.now() - o;
|
|
420
|
+
return u.statSync(t).mtime.getTime() < a;
|
|
421
421
|
}
|
|
422
|
-
async function
|
|
422
|
+
async function tt(e, o) {
|
|
423
423
|
const [t] = await new Promise(
|
|
424
|
-
(i,
|
|
425
|
-
|
|
424
|
+
(i, s) => {
|
|
425
|
+
Ne.list(
|
|
426
426
|
{
|
|
427
427
|
pid: e,
|
|
428
428
|
name: o,
|
|
429
429
|
// Remove path from executable name in the results.
|
|
430
430
|
clean: !0
|
|
431
431
|
},
|
|
432
|
-
(n,
|
|
433
|
-
n ?
|
|
432
|
+
(n, r) => {
|
|
433
|
+
n ? s(n) : i(r);
|
|
434
434
|
}
|
|
435
435
|
);
|
|
436
436
|
}
|
|
437
437
|
);
|
|
438
438
|
return !!t && t.pid === e && t.command === o;
|
|
439
439
|
}
|
|
440
|
-
async function
|
|
440
|
+
async function ot(e, o, t) {
|
|
441
441
|
const i = t === "win32" ? (
|
|
442
442
|
// On Windows, creating a 'dir' symlink can require elevated permissions.
|
|
443
443
|
// In this case, let's make junction points because they function like
|
|
@@ -446,23 +446,23 @@ async function et(e, o, t) {
|
|
|
446
446
|
) : "dir";
|
|
447
447
|
u.symlinkSync(e, o, i);
|
|
448
448
|
}
|
|
449
|
-
async function
|
|
449
|
+
async function rt(e) {
|
|
450
450
|
try {
|
|
451
451
|
u.lstatSync(e).isSymbolicLink() && u.unlinkSync(e);
|
|
452
452
|
} catch {
|
|
453
453
|
}
|
|
454
454
|
}
|
|
455
|
-
function
|
|
455
|
+
function nt(e, o) {
|
|
456
456
|
return o.filter((t) => {
|
|
457
|
-
const i = g.resolve(t.hostPath),
|
|
457
|
+
const i = g.resolve(t.hostPath), s = g.join(e, g.sep);
|
|
458
458
|
return (
|
|
459
459
|
// If auto-mounting from the current directory,
|
|
460
460
|
// the entire project directory can be mapped.
|
|
461
|
-
i === e || i.startsWith(
|
|
461
|
+
i === e || i.startsWith(s)
|
|
462
462
|
);
|
|
463
463
|
});
|
|
464
464
|
}
|
|
465
|
-
const
|
|
465
|
+
const E = {
|
|
466
466
|
ignoreAttributes: !1,
|
|
467
467
|
attributeNamePrefix: "",
|
|
468
468
|
preserveOrder: !0,
|
|
@@ -470,23 +470,23 @@ const I = {
|
|
|
470
470
|
commentPropName: "__xmlComment",
|
|
471
471
|
allowBooleanAttributes: !0,
|
|
472
472
|
trimValues: !0
|
|
473
|
-
},
|
|
474
|
-
ignoreAttributes:
|
|
475
|
-
attributeNamePrefix:
|
|
476
|
-
preserveOrder:
|
|
477
|
-
cdataPropName:
|
|
478
|
-
commentPropName:
|
|
479
|
-
suppressBooleanAttributes: !
|
|
473
|
+
}, re = {
|
|
474
|
+
ignoreAttributes: E.ignoreAttributes,
|
|
475
|
+
attributeNamePrefix: E.attributeNamePrefix,
|
|
476
|
+
preserveOrder: E.preserveOrder,
|
|
477
|
+
cdataPropName: E.cdataPropName,
|
|
478
|
+
commentPropName: E.commentPropName,
|
|
479
|
+
suppressBooleanAttributes: !E.allowBooleanAttributes,
|
|
480
480
|
format: !0,
|
|
481
481
|
indentBy: " "
|
|
482
|
-
},
|
|
482
|
+
}, R = {
|
|
483
483
|
allowEmptyContent: !0,
|
|
484
484
|
allowTrailingComma: !0
|
|
485
485
|
};
|
|
486
|
-
function
|
|
487
|
-
const { name: t, host: i, port:
|
|
486
|
+
function it(e, o) {
|
|
487
|
+
const { name: t, host: i, port: s, mappings: n, ideKey: r } = o, a = new Q(E), l = (() => {
|
|
488
488
|
try {
|
|
489
|
-
return
|
|
489
|
+
return a.parse(e, !0);
|
|
490
490
|
} catch {
|
|
491
491
|
throw new Error("PhpStorm configuration file is not valid XML.");
|
|
492
492
|
}
|
|
@@ -510,11 +510,11 @@ function rt(e, o) {
|
|
|
510
510
|
// NOTE: PhpStorm quirk: Xdebug only works when the full URL (including port)
|
|
511
511
|
// is provided in `host`. The separate `port` field is ignored or misinterpreted,
|
|
512
512
|
// so we rely solely on host: "host:port".
|
|
513
|
-
host: `${i}:${
|
|
513
|
+
host: `${i}:${s}`,
|
|
514
514
|
use_path_mappings: "true"
|
|
515
515
|
}
|
|
516
516
|
};
|
|
517
|
-
let c =
|
|
517
|
+
let c = l?.find((f) => !!f?.project);
|
|
518
518
|
if (c) {
|
|
519
519
|
const f = c[":@"]?.version;
|
|
520
520
|
if (f === void 0)
|
|
@@ -529,7 +529,7 @@ function rt(e, o) {
|
|
|
529
529
|
c === void 0 && (c = {
|
|
530
530
|
project: [],
|
|
531
531
|
":@": { version: "4" }
|
|
532
|
-
},
|
|
532
|
+
}, l.push(c));
|
|
533
533
|
let d = c.project?.find(
|
|
534
534
|
(f) => !!f?.component && f?.[":@"]?.name === "PhpServers"
|
|
535
535
|
);
|
|
@@ -537,21 +537,21 @@ function rt(e, o) {
|
|
|
537
537
|
component: [],
|
|
538
538
|
":@": { name: "PhpServers" }
|
|
539
539
|
}, c.project === void 0 && (c.project = []), c.project.push(d));
|
|
540
|
-
let
|
|
540
|
+
let m = d.component?.find(
|
|
541
541
|
(f) => !!f?.servers
|
|
542
542
|
);
|
|
543
|
-
|
|
544
|
-
const
|
|
543
|
+
m === void 0 && (m = { servers: [] }, d.component === void 0 && (d.component = []), d.component.push(m));
|
|
544
|
+
const b = m.servers?.findIndex(
|
|
545
545
|
(f) => !!f?.server && f?.[":@"]?.name === t
|
|
546
546
|
);
|
|
547
|
-
(
|
|
548
|
-
let
|
|
547
|
+
(b === void 0 || b < 0) && (m.servers === void 0 && (m.servers = []), m.servers.push(p));
|
|
548
|
+
let v = c.project?.find(
|
|
549
549
|
(f) => !!f?.component && f?.[":@"]?.name === "RunManager"
|
|
550
550
|
);
|
|
551
|
-
if (
|
|
551
|
+
if (v === void 0 && (v = {
|
|
552
552
|
component: [],
|
|
553
553
|
":@": { name: "RunManager" }
|
|
554
|
-
}, c.project === void 0 && (c.project = []), c.project.push(
|
|
554
|
+
}, c.project === void 0 && (c.project = []), c.project.push(v)), (v.component?.findIndex(
|
|
555
555
|
(f) => !!f?.configuration && f?.[":@"]?.name === t
|
|
556
556
|
) ?? -1) < 0) {
|
|
557
557
|
const f = {
|
|
@@ -567,47 +567,47 @@ function rt(e, o) {
|
|
|
567
567
|
factoryName: "PHP Remote Debug",
|
|
568
568
|
filter_connections: "FILTER",
|
|
569
569
|
server_name: t,
|
|
570
|
-
session_id:
|
|
570
|
+
session_id: r
|
|
571
571
|
}
|
|
572
572
|
};
|
|
573
|
-
|
|
573
|
+
v.component === void 0 && (v.component = []), v.component.push(f);
|
|
574
574
|
}
|
|
575
|
-
const
|
|
575
|
+
const x = new ee(re).build(l);
|
|
576
576
|
try {
|
|
577
|
-
|
|
577
|
+
a.parse(x, !0);
|
|
578
578
|
} catch {
|
|
579
579
|
throw new Error(
|
|
580
580
|
"The resulting PhpStorm configuration file is not valid XML."
|
|
581
581
|
);
|
|
582
582
|
}
|
|
583
|
-
return
|
|
583
|
+
return x;
|
|
584
584
|
}
|
|
585
|
-
function
|
|
586
|
-
const { name: t, mappings: i } = o,
|
|
587
|
-
let n = e,
|
|
588
|
-
if (
|
|
585
|
+
function st(e, o) {
|
|
586
|
+
const { name: t, mappings: i } = o, s = [];
|
|
587
|
+
let n = e, r = P.parseTree(n, s, R);
|
|
588
|
+
if (r === void 0 || s.length)
|
|
589
589
|
throw new Error("VS Code configuration file is not valid JSON.");
|
|
590
|
-
let
|
|
591
|
-
if (
|
|
592
|
-
const p =
|
|
593
|
-
n =
|
|
590
|
+
let a = P.findNodeAtLocation(r, ["configurations"]);
|
|
591
|
+
if (a === void 0 || a.children === void 0) {
|
|
592
|
+
const p = P.modify(n, ["configurations"], [], {});
|
|
593
|
+
n = P.applyEdits(n, p), r = P.parseTree(n, [], R), a = P.findNodeAtLocation(r, [
|
|
594
594
|
"configurations"
|
|
595
595
|
]);
|
|
596
596
|
}
|
|
597
|
-
const
|
|
598
|
-
(p) =>
|
|
597
|
+
const l = a?.children?.findIndex(
|
|
598
|
+
(p) => P.findNodeAtLocation(p, ["name"])?.value === t
|
|
599
599
|
);
|
|
600
|
-
if (
|
|
600
|
+
if (l === void 0 || l < 0) {
|
|
601
601
|
const p = {
|
|
602
602
|
name: t,
|
|
603
603
|
type: "php",
|
|
604
604
|
request: "launch",
|
|
605
605
|
port: 9003,
|
|
606
|
-
pathMappings: i.reduce((
|
|
606
|
+
pathMappings: i.reduce((m, b) => (m[b.vfsPath] = `\${workspaceFolder}/${b.hostPath.replace(
|
|
607
607
|
/^\.\/?/,
|
|
608
608
|
""
|
|
609
|
-
)}`,
|
|
610
|
-
}, c =
|
|
609
|
+
)}`, m), {})
|
|
610
|
+
}, c = a?.children?.length || 0, d = P.modify(
|
|
611
611
|
n,
|
|
612
612
|
["configurations", c],
|
|
613
613
|
p,
|
|
@@ -620,23 +620,23 @@ function nt(e, o) {
|
|
|
620
620
|
}
|
|
621
621
|
}
|
|
622
622
|
);
|
|
623
|
-
n =
|
|
623
|
+
n = ne(n, d);
|
|
624
624
|
}
|
|
625
625
|
return n;
|
|
626
626
|
}
|
|
627
|
-
async function
|
|
627
|
+
async function at({
|
|
628
628
|
name: e,
|
|
629
629
|
ides: o,
|
|
630
630
|
host: t,
|
|
631
631
|
port: i,
|
|
632
|
-
cwd:
|
|
632
|
+
cwd: s,
|
|
633
633
|
mounts: n,
|
|
634
|
-
ideKey:
|
|
634
|
+
ideKey: r = "PLAYGROUNDCLI"
|
|
635
635
|
}) {
|
|
636
|
-
const
|
|
636
|
+
const a = nt(s, n), l = [];
|
|
637
637
|
if (o.includes("phpstorm")) {
|
|
638
638
|
const p = ".idea/workspace.xml", c = g.join(
|
|
639
|
-
|
|
639
|
+
s,
|
|
640
640
|
p
|
|
641
641
|
);
|
|
642
642
|
if (!u.existsSync(c)) {
|
|
@@ -653,20 +653,20 @@ async function it({
|
|
|
653
653
|
);
|
|
654
654
|
}
|
|
655
655
|
if (u.existsSync(c)) {
|
|
656
|
-
const d = u.readFileSync(c, "utf8"),
|
|
656
|
+
const d = u.readFileSync(c, "utf8"), m = it(d, {
|
|
657
657
|
name: e,
|
|
658
658
|
host: t,
|
|
659
659
|
port: i,
|
|
660
|
-
mappings:
|
|
661
|
-
ideKey:
|
|
660
|
+
mappings: a,
|
|
661
|
+
ideKey: r
|
|
662
662
|
});
|
|
663
|
-
u.writeFileSync(c,
|
|
663
|
+
u.writeFileSync(c, m);
|
|
664
664
|
}
|
|
665
|
-
|
|
665
|
+
l.push(p);
|
|
666
666
|
}
|
|
667
667
|
if (o.includes("vscode")) {
|
|
668
668
|
const p = ".vscode/launch.json", c = g.join(
|
|
669
|
-
|
|
669
|
+
s,
|
|
670
670
|
p
|
|
671
671
|
);
|
|
672
672
|
if (!u.existsSync(c)) {
|
|
@@ -683,27 +683,27 @@ async function it({
|
|
|
683
683
|
);
|
|
684
684
|
}
|
|
685
685
|
if (u.existsSync(c)) {
|
|
686
|
-
const d = u.readFileSync(c, "utf-8"),
|
|
686
|
+
const d = u.readFileSync(c, "utf-8"), m = st(d, {
|
|
687
687
|
name: e,
|
|
688
|
-
mappings:
|
|
688
|
+
mappings: a
|
|
689
689
|
});
|
|
690
|
-
|
|
690
|
+
m !== d && (u.writeFileSync(c, m), l.push(p));
|
|
691
691
|
}
|
|
692
692
|
}
|
|
693
|
-
return
|
|
693
|
+
return l;
|
|
694
694
|
}
|
|
695
|
-
async function
|
|
695
|
+
async function lt(e, o) {
|
|
696
696
|
const t = g.join(o, ".idea/workspace.xml");
|
|
697
697
|
if (u.existsSync(t)) {
|
|
698
|
-
const
|
|
698
|
+
const s = u.readFileSync(t, "utf8"), n = new Q(E), r = (() => {
|
|
699
699
|
try {
|
|
700
|
-
return n.parse(
|
|
700
|
+
return n.parse(s, !0);
|
|
701
701
|
} catch {
|
|
702
702
|
throw new Error(
|
|
703
703
|
"PhpStorm configuration file is not valid XML."
|
|
704
704
|
);
|
|
705
705
|
}
|
|
706
|
-
})(), p =
|
|
706
|
+
})(), p = r.find(
|
|
707
707
|
(d) => !!d?.project
|
|
708
708
|
)?.project?.find(
|
|
709
709
|
(d) => !!d?.component && d?.[":@"]?.name === "PhpServers"
|
|
@@ -714,36 +714,36 @@ async function st(e, o) {
|
|
|
714
714
|
);
|
|
715
715
|
if (c !== void 0 && c >= 0) {
|
|
716
716
|
p.servers.splice(c, 1);
|
|
717
|
-
const
|
|
717
|
+
const m = new ee(re).build(r);
|
|
718
718
|
try {
|
|
719
|
-
n.parse(
|
|
719
|
+
n.parse(m, !0);
|
|
720
720
|
} catch {
|
|
721
721
|
throw new Error(
|
|
722
722
|
"The resulting PhpStorm configuration file is not valid XML."
|
|
723
723
|
);
|
|
724
724
|
}
|
|
725
|
-
|
|
725
|
+
m === `<?xml version="1.0" encoding="UTF-8"?>
|
|
726
726
|
<project version="4">
|
|
727
727
|
<component name="PhpServers">
|
|
728
728
|
<servers></servers>
|
|
729
729
|
</component>
|
|
730
|
-
</project>` ? u.unlinkSync(t) : u.writeFileSync(t,
|
|
730
|
+
</project>` ? u.unlinkSync(t) : u.writeFileSync(t, m);
|
|
731
731
|
}
|
|
732
732
|
}
|
|
733
733
|
const i = g.join(o, ".vscode/launch.json");
|
|
734
734
|
if (u.existsSync(i)) {
|
|
735
|
-
const
|
|
736
|
-
if (
|
|
735
|
+
const s = [], n = u.readFileSync(i, "utf-8"), r = P.parseTree(n, s, R);
|
|
736
|
+
if (r === void 0 || s.length)
|
|
737
737
|
throw new Error("VS Code configuration file is not valid JSON.");
|
|
738
|
-
const
|
|
738
|
+
const l = P.findNodeAtLocation(r, [
|
|
739
739
|
"configurations"
|
|
740
740
|
])?.children?.findIndex(
|
|
741
|
-
(p) =>
|
|
741
|
+
(p) => P.findNodeAtLocation(p, ["name"])?.value === e
|
|
742
742
|
);
|
|
743
|
-
if (
|
|
744
|
-
const p =
|
|
743
|
+
if (l !== void 0 && l >= 0) {
|
|
744
|
+
const p = P.modify(
|
|
745
745
|
n,
|
|
746
|
-
["configurations",
|
|
746
|
+
["configurations", l],
|
|
747
747
|
void 0,
|
|
748
748
|
{
|
|
749
749
|
formattingOptions: {
|
|
@@ -753,28 +753,28 @@ async function st(e, o) {
|
|
|
753
753
|
`
|
|
754
754
|
}
|
|
755
755
|
}
|
|
756
|
-
), c =
|
|
756
|
+
), c = ne(n, p);
|
|
757
757
|
c === `{
|
|
758
758
|
"configurations": []
|
|
759
759
|
}` ? u.unlinkSync(i) : u.writeFileSync(i, c);
|
|
760
760
|
}
|
|
761
761
|
}
|
|
762
762
|
}
|
|
763
|
-
function
|
|
764
|
-
const t = [], i =
|
|
765
|
-
if (t.length = 0,
|
|
766
|
-
const
|
|
767
|
-
message:
|
|
768
|
-
offset:
|
|
769
|
-
length:
|
|
763
|
+
function ne(e, o) {
|
|
764
|
+
const t = [], i = P.applyEdits(e, o);
|
|
765
|
+
if (t.length = 0, P.parseTree(i, t, R), t.length) {
|
|
766
|
+
const s = t.map((r) => ({
|
|
767
|
+
message: P.printParseErrorCode(r.error),
|
|
768
|
+
offset: r.offset,
|
|
769
|
+
length: r.length,
|
|
770
770
|
fragment: i.slice(
|
|
771
|
-
Math.max(0,
|
|
772
|
-
Math.min(i.length,
|
|
771
|
+
Math.max(0, r.offset - 20),
|
|
772
|
+
Math.min(i.length, r.offset + r.length + 10)
|
|
773
773
|
)
|
|
774
774
|
})).map(
|
|
775
|
-
(
|
|
775
|
+
(r) => `${r.message} at ${r.offset}:${r.length} (${r.fragment})`
|
|
776
776
|
), n = o.map(
|
|
777
|
-
(
|
|
777
|
+
(r) => `At ${r.offset}:${r.length} - (${r.content})`
|
|
778
778
|
);
|
|
779
779
|
throw new Error(
|
|
780
780
|
`VS Code configuration file (.vscode/launch.json) is not valid a JSONC after Playground CLI modifications. This is likely a Playground CLI bug. Please report it at https://github.com/WordPress/wordpress-playground/issues and include the contents of your ".vscode/launch.json" file.
|
|
@@ -784,20 +784,20 @@ function oe(e, o) {
|
|
|
784
784
|
`
|
|
785
785
|
)}
|
|
786
786
|
|
|
787
|
-
The errors are: ${
|
|
787
|
+
The errors are: ${s.join(`
|
|
788
788
|
`)}`
|
|
789
789
|
);
|
|
790
790
|
}
|
|
791
791
|
return i;
|
|
792
792
|
}
|
|
793
|
-
const
|
|
794
|
-
Quiet: { name: "quiet", severity:
|
|
795
|
-
Normal: { name: "normal", severity:
|
|
796
|
-
Debug: { name: "debug", severity:
|
|
793
|
+
const _ = {
|
|
794
|
+
Quiet: { name: "quiet", severity: A.Fatal },
|
|
795
|
+
Normal: { name: "normal", severity: A.Info },
|
|
796
|
+
Debug: { name: "debug", severity: A.Debug }
|
|
797
797
|
};
|
|
798
|
-
async function
|
|
798
|
+
async function Dt() {
|
|
799
799
|
try {
|
|
800
|
-
const e =
|
|
800
|
+
const e = Le(process.argv.slice(2)).usage("Usage: wp-playground <command> [options]").positional("command", {
|
|
801
801
|
describe: "Command to run",
|
|
802
802
|
choices: ["server", "run-blueprint", "build-snapshot"],
|
|
803
803
|
demandOption: !0
|
|
@@ -815,8 +815,8 @@ async function Rt() {
|
|
|
815
815
|
}).option("php", {
|
|
816
816
|
describe: "PHP version to use.",
|
|
817
817
|
type: "string",
|
|
818
|
-
default:
|
|
819
|
-
choices:
|
|
818
|
+
default: G,
|
|
819
|
+
choices: ue
|
|
820
820
|
}).option("wp", {
|
|
821
821
|
describe: "WordPress version to use.",
|
|
822
822
|
type: "string",
|
|
@@ -825,12 +825,12 @@ async function Rt() {
|
|
|
825
825
|
describe: "Mount a directory to the PHP runtime (can be used multiple times). Format: /host/path:/vfs/path",
|
|
826
826
|
type: "array",
|
|
827
827
|
string: !0,
|
|
828
|
-
coerce:
|
|
828
|
+
coerce: J
|
|
829
829
|
}).option("mount-before-install", {
|
|
830
830
|
describe: "Mount a directory to the PHP runtime before WordPress installation (can be used multiple times). Format: /host/path:/vfs/path",
|
|
831
831
|
type: "array",
|
|
832
832
|
string: !0,
|
|
833
|
-
coerce:
|
|
833
|
+
coerce: J
|
|
834
834
|
}).option("mount-dir", {
|
|
835
835
|
describe: 'Mount a directory to the PHP runtime (can be used multiple times). Format: "/host/path" "/vfs/path"',
|
|
836
836
|
type: "array",
|
|
@@ -842,7 +842,7 @@ async function Rt() {
|
|
|
842
842
|
type: "string",
|
|
843
843
|
nargs: 2,
|
|
844
844
|
array: !0,
|
|
845
|
-
coerce:
|
|
845
|
+
coerce: Se
|
|
846
846
|
}).option("login", {
|
|
847
847
|
describe: "Should log the user in",
|
|
848
848
|
type: "boolean",
|
|
@@ -870,7 +870,7 @@ async function Rt() {
|
|
|
870
870
|
}).option("verbosity", {
|
|
871
871
|
describe: "Output logs and progress messages.",
|
|
872
872
|
type: "string",
|
|
873
|
-
choices: Object.values(
|
|
873
|
+
choices: Object.values(_).map(
|
|
874
874
|
(r) => r.name
|
|
875
875
|
),
|
|
876
876
|
default: "normal"
|
|
@@ -917,7 +917,7 @@ Warning: Following symlinks will expose files outside mounted directories to Pla
|
|
|
917
917
|
).option("experimental-multi-worker", {
|
|
918
918
|
describe: "Enable experimental multi-worker support which requires a /wordpress directory backed by a real filesystem. Pass a positive number to specify the number of workers to use. Otherwise, default to the number of CPUs minus 1.",
|
|
919
919
|
type: "number",
|
|
920
|
-
coerce: (r) => r ??
|
|
920
|
+
coerce: (r) => r ?? Ie().length - 1
|
|
921
921
|
}).option("experimental-blueprints-v2-runner", {
|
|
922
922
|
describe: "Use the experimental Blueprint V2 runner.",
|
|
923
923
|
type: "boolean",
|
|
@@ -931,7 +931,7 @@ Warning: Following symlinks will expose files outside mounted directories to Pla
|
|
|
931
931
|
// Remove the "hidden" flag once Blueprint V2 is fully supported
|
|
932
932
|
hidden: !0
|
|
933
933
|
}).showHelpOnFail(!1).strictOptions().check(async (r) => {
|
|
934
|
-
if ((r["skip-wordpress-setup"] || r.skipWordpressSetup) && (r.skipWordPressSetup = !0), r.wp !== void 0 && !
|
|
934
|
+
if ((r["skip-wordpress-setup"] || r.skipWordpressSetup) && (r.skipWordPressSetup = !0), r.wp !== void 0 && !qe(r.wp))
|
|
935
935
|
try {
|
|
936
936
|
new URL(r.wp);
|
|
937
937
|
} catch {
|
|
@@ -948,13 +948,13 @@ Warning: Following symlinks will expose files outside mounted directories to Pla
|
|
|
948
948
|
);
|
|
949
949
|
}
|
|
950
950
|
if (r["auto-mount"]) {
|
|
951
|
-
let
|
|
951
|
+
let a = !1;
|
|
952
952
|
try {
|
|
953
|
-
|
|
953
|
+
a = u.statSync(r["auto-mount"]).isDirectory();
|
|
954
954
|
} catch {
|
|
955
|
-
|
|
955
|
+
a = !1;
|
|
956
956
|
}
|
|
957
|
-
if (!
|
|
957
|
+
if (!a)
|
|
958
958
|
throw new Error(
|
|
959
959
|
`The specified --auto-mount path is not a directory: '${r["auto-mount"]}'.`
|
|
960
960
|
);
|
|
@@ -979,8 +979,8 @@ Warning: Following symlinks will expose files outside mounted directories to Pla
|
|
|
979
979
|
);
|
|
980
980
|
} else
|
|
981
981
|
r["skip-wordpress-setup"] === !0 ? r.mode = "apply-to-existing-site" : r.mode = "create-new-site";
|
|
982
|
-
const
|
|
983
|
-
r.followSymlinks === !0 &&
|
|
982
|
+
const a = r.allow || [];
|
|
983
|
+
r.followSymlinks === !0 && a.push("follow-symlinks"), r["blueprint-may-read-adjacent-files"] === !0 && a.push("read-local-fs"), r.allow = a;
|
|
984
984
|
} else if (r.mode !== void 0)
|
|
985
985
|
throw new Error(
|
|
986
986
|
"The --mode option requires the --experimentalBlueprintsV2Runner flag."
|
|
@@ -998,13 +998,20 @@ Warning: Following symlinks will expose files outside mounted directories to Pla
|
|
|
998
998
|
...o["mount-before-install"] || [],
|
|
999
999
|
...o["mount-dir-before-install"] || []
|
|
1000
1000
|
]
|
|
1001
|
-
};
|
|
1002
|
-
|
|
1001
|
+
}, s = await pt(i);
|
|
1002
|
+
s === void 0 && process.exit(0);
|
|
1003
|
+
const n = /* @__PURE__ */ (() => {
|
|
1004
|
+
let r;
|
|
1005
|
+
return async () => {
|
|
1006
|
+
r !== void 0 && (r = s[Symbol.asyncDispose]()), await r, process.exit(0);
|
|
1007
|
+
};
|
|
1008
|
+
})();
|
|
1009
|
+
process.on("SIGINT", n), process.on("SIGTERM", n);
|
|
1003
1010
|
} catch (e) {
|
|
1004
1011
|
if (!(e instanceof Error))
|
|
1005
1012
|
throw e;
|
|
1006
1013
|
if (process.argv.includes("--debug"))
|
|
1007
|
-
|
|
1014
|
+
de(e);
|
|
1008
1015
|
else {
|
|
1009
1016
|
const t = [];
|
|
1010
1017
|
let i = e;
|
|
@@ -1018,39 +1025,39 @@ Warning: Following symlinks will expose files outside mounted directories to Pla
|
|
|
1018
1025
|
process.exit(1);
|
|
1019
1026
|
}
|
|
1020
1027
|
}
|
|
1021
|
-
const
|
|
1022
|
-
async function
|
|
1028
|
+
const U = (e) => process.stdout.isTTY ? "\x1B[1m" + e + "\x1B[0m" : e, ct = (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;
|
|
1029
|
+
async function pt(e) {
|
|
1023
1030
|
let o, t;
|
|
1024
1031
|
const i = [];
|
|
1025
|
-
if (e.autoMount !== void 0 && (e.autoMount === "" && (e = { ...e, autoMount: process.cwd() }), e =
|
|
1026
|
-
const
|
|
1032
|
+
if (e.autoMount !== void 0 && (e.autoMount === "" && (e = { ...e, autoMount: process.cwd() }), e = ke(e)), e.quiet && (e.verbosity = "quiet", delete e.quiet), e.debug ? e.verbosity = "debug" : e.verbosity === "debug" && (e.debug = !0), e.verbosity) {
|
|
1033
|
+
const l = Object.values(_).find(
|
|
1027
1034
|
(p) => p.name === e.verbosity
|
|
1028
1035
|
).severity;
|
|
1029
|
-
|
|
1036
|
+
h.setSeverityFilterLevel(l);
|
|
1030
1037
|
}
|
|
1031
|
-
const
|
|
1038
|
+
const s = K.platform() === "win32" ? (
|
|
1032
1039
|
// @TODO: Enable fs-ext here when it works with Windows.
|
|
1033
1040
|
void 0
|
|
1034
|
-
) : await import("fs-ext").then((
|
|
1035
|
-
|
|
1041
|
+
) : await import("fs-ext").then((l) => l.flockSync).catch(() => {
|
|
1042
|
+
h.warn(
|
|
1036
1043
|
"The fs-ext package is not installed. Internal file locking will not be integrated with host OS file locking."
|
|
1037
1044
|
);
|
|
1038
|
-
}), n = new
|
|
1039
|
-
let
|
|
1040
|
-
return
|
|
1045
|
+
}), n = new Ee(s);
|
|
1046
|
+
let r = !1, a = !0;
|
|
1047
|
+
return h.log("Starting a PHP server..."), Ve({
|
|
1041
1048
|
port: e.port,
|
|
1042
|
-
onBind: async (
|
|
1043
|
-
const c = "127.0.0.1", d = `http://${c}:${p}`,
|
|
1044
|
-
Number.MAX_SAFE_INTEGER /
|
|
1045
|
-
),
|
|
1046
|
-
|
|
1049
|
+
onBind: async (l, p) => {
|
|
1050
|
+
const c = "127.0.0.1", d = `http://${c}:${p}`, m = e["site-url"] || d, b = e.experimentalMultiWorker ?? 1, v = Math.floor(
|
|
1051
|
+
Number.MAX_SAFE_INTEGER / b
|
|
1052
|
+
), I = "-playground-cli-site-", k = await Ge(
|
|
1053
|
+
I
|
|
1047
1054
|
);
|
|
1048
|
-
|
|
1049
|
-
const
|
|
1050
|
-
if (await
|
|
1051
|
-
await
|
|
1052
|
-
|
|
1053
|
-
|
|
1055
|
+
h.debug(`Native temp dir for VFS root: ${k.path}`);
|
|
1056
|
+
const x = "WP Playground CLI - Listen for Xdebug", f = ".playground-xdebug-root", W = g.join(process.cwd(), f);
|
|
1057
|
+
if (await rt(W), e.xdebug && e.experimentalUnsafeIdeIntegration) {
|
|
1058
|
+
await ot(
|
|
1059
|
+
k.path,
|
|
1060
|
+
W,
|
|
1054
1061
|
process.platform
|
|
1055
1062
|
);
|
|
1056
1063
|
const y = {
|
|
@@ -1058,9 +1065,9 @@ async function lt(e) {
|
|
|
1058
1065
|
vfsPath: "/"
|
|
1059
1066
|
};
|
|
1060
1067
|
try {
|
|
1061
|
-
await
|
|
1062
|
-
const
|
|
1063
|
-
name:
|
|
1068
|
+
await lt(x, process.cwd());
|
|
1069
|
+
const w = typeof e.xdebug == "object" ? e.xdebug : void 0, L = await at({
|
|
1070
|
+
name: x,
|
|
1064
1071
|
host: c,
|
|
1065
1072
|
port: p,
|
|
1066
1073
|
ides: e.experimentalUnsafeIdeIntegration,
|
|
@@ -1070,51 +1077,50 @@ async function lt(e) {
|
|
|
1070
1077
|
...e["mount-before-install"] || [],
|
|
1071
1078
|
...e.mount || []
|
|
1072
1079
|
],
|
|
1073
|
-
ideKey:
|
|
1074
|
-
}),
|
|
1075
|
-
console.log(""), console.log(
|
|
1076
|
-
|
|
1080
|
+
ideKey: w?.ideKey
|
|
1081
|
+
}), S = e.experimentalUnsafeIdeIntegration, T = S.includes("vscode"), B = S.includes("phpstorm");
|
|
1082
|
+
console.log(""), console.log(U("Xdebug configured successfully")), console.log(
|
|
1083
|
+
Z("Updated IDE config: ") + L.join(" ")
|
|
1077
1084
|
), console.log(
|
|
1078
|
-
|
|
1079
|
-
|
|
1085
|
+
Z("Playground source root: ") + ".playground-xdebug-root" + N(
|
|
1086
|
+
ct(
|
|
1080
1087
|
" – you can set breakpoints and preview Playground's VFS structure in there."
|
|
1081
1088
|
)
|
|
1082
1089
|
)
|
|
1083
|
-
), console.log(""),
|
|
1090
|
+
), console.log(""), T && (console.log(U("VS Code / Cursor instructions:")), console.log(
|
|
1084
1091
|
" 1. Open the Run and Debug panel on the left sidebar"
|
|
1085
1092
|
), console.log(
|
|
1086
|
-
` 2. Select "${
|
|
1087
|
-
|
|
1093
|
+
` 2. Select "${N(
|
|
1094
|
+
x
|
|
1088
1095
|
)}" from the dropdown`
|
|
1089
1096
|
), console.log(' 3. Click "start debugging"'), console.log(
|
|
1090
1097
|
" 4. Set a breakpoint. For example, in .playground-xdebug-root/wordpress/index.php"
|
|
1091
1098
|
), console.log(
|
|
1092
1099
|
" 5. Visit Playground in your browser to hit the breakpoint"
|
|
1093
|
-
),
|
|
1094
|
-
` 1. Choose "${
|
|
1095
|
-
|
|
1100
|
+
), B && console.log("")), B && (console.log(U("PhpStorm instructions:")), console.log(
|
|
1101
|
+
` 1. Choose "${N(
|
|
1102
|
+
x
|
|
1096
1103
|
)}" debug configuration in the toolbar`
|
|
1097
1104
|
), console.log(" 2. Click the debug button (bug icon)`"), console.log(
|
|
1098
1105
|
" 3. Set a breakpoint. For example, in .playground-xdebug-root/wordpress/index.php"
|
|
1099
1106
|
), console.log(
|
|
1100
1107
|
" 4. Visit Playground in your browser to hit the breakpoint"
|
|
1101
1108
|
)), console.log("");
|
|
1102
|
-
} catch (
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
), process.exit(1);
|
|
1109
|
+
} catch (w) {
|
|
1110
|
+
throw new Error("Could not configure Xdebug", {
|
|
1111
|
+
cause: w
|
|
1112
|
+
});
|
|
1107
1113
|
}
|
|
1108
1114
|
}
|
|
1109
|
-
const
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1115
|
+
const ie = g.dirname(k.path), se = 2 * 24 * 60 * 60 * 1e3;
|
|
1116
|
+
Ke(
|
|
1117
|
+
I,
|
|
1118
|
+
se,
|
|
1119
|
+
ie
|
|
1114
1120
|
);
|
|
1115
|
-
const
|
|
1116
|
-
|
|
1117
|
-
const
|
|
1121
|
+
const F = g.join(k.path, "internal");
|
|
1122
|
+
z(F);
|
|
1123
|
+
const ae = [
|
|
1118
1124
|
"wordpress",
|
|
1119
1125
|
// Note: These dirs are from Emscripten's "default dirs" list:
|
|
1120
1126
|
// https://github.com/emscripten-core/emscripten/blob/f431ec220e472e1f8d3db6b52fe23fb377facf30/src/lib/libfs.js#L1400-L1402
|
|
@@ -1125,175 +1131,180 @@ async function lt(e) {
|
|
|
1125
1131
|
"tmp",
|
|
1126
1132
|
"home"
|
|
1127
1133
|
];
|
|
1128
|
-
for (const y of
|
|
1129
|
-
const
|
|
1130
|
-
if (!(e["mount-before-install"]?.some(
|
|
1131
|
-
const
|
|
1132
|
-
|
|
1134
|
+
for (const y of ae) {
|
|
1135
|
+
const w = (S) => S.vfsPath === `/${y}`;
|
|
1136
|
+
if (!(e["mount-before-install"]?.some(w) || e.mount?.some(w))) {
|
|
1137
|
+
const S = g.join(
|
|
1138
|
+
k.path,
|
|
1133
1139
|
y
|
|
1134
1140
|
);
|
|
1135
|
-
|
|
1141
|
+
z(S), e["mount-before-install"] === void 0 && (e["mount-before-install"] = []), e["mount-before-install"].unshift({
|
|
1136
1142
|
vfsPath: `/${y}`,
|
|
1137
|
-
hostPath:
|
|
1143
|
+
hostPath: S
|
|
1138
1144
|
});
|
|
1139
1145
|
}
|
|
1140
1146
|
}
|
|
1141
1147
|
if (e["mount-before-install"])
|
|
1142
1148
|
for (const y of e["mount-before-install"])
|
|
1143
|
-
|
|
1149
|
+
h.debug(
|
|
1144
1150
|
`Mount before WP install: ${y.vfsPath} -> ${y.hostPath}`
|
|
1145
1151
|
);
|
|
1146
1152
|
if (e.mount)
|
|
1147
1153
|
for (const y of e.mount)
|
|
1148
|
-
|
|
1154
|
+
h.debug(
|
|
1149
1155
|
`Mount after WP install: ${y.vfsPath} -> ${y.hostPath}`
|
|
1150
1156
|
);
|
|
1151
|
-
let
|
|
1152
|
-
e["experimental-blueprints-v2-runner"] ?
|
|
1153
|
-
siteUrl:
|
|
1154
|
-
processIdSpaceLength:
|
|
1155
|
-
}) : (
|
|
1156
|
-
siteUrl:
|
|
1157
|
-
processIdSpaceLength:
|
|
1158
|
-
}), typeof e.blueprint == "string" && (e.blueprint = await
|
|
1157
|
+
let C;
|
|
1158
|
+
e["experimental-blueprints-v2-runner"] ? C = new Xe(e, {
|
|
1159
|
+
siteUrl: m,
|
|
1160
|
+
processIdSpaceLength: v
|
|
1161
|
+
}) : (C = new Ye(e, {
|
|
1162
|
+
siteUrl: m,
|
|
1163
|
+
processIdSpaceLength: v
|
|
1164
|
+
}), typeof e.blueprint == "string" && (e.blueprint = await ze({
|
|
1159
1165
|
sourceString: e.blueprint,
|
|
1160
1166
|
blueprintMayReadAdjacentFiles: e["blueprint-may-read-adjacent-files"] === !0
|
|
1161
1167
|
})));
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
+
let M = !1;
|
|
1169
|
+
const D = async function() {
|
|
1170
|
+
M || (M = !0, await Promise.all(
|
|
1171
|
+
i.map(async ({ playground: w, worker: L }) => {
|
|
1172
|
+
await w.dispose(), await L.terminate();
|
|
1173
|
+
})
|
|
1174
|
+
), l && await new Promise((w) => l.close(w)), await k.cleanup());
|
|
1175
|
+
}, le = ut(
|
|
1176
|
+
b,
|
|
1177
|
+
C.getWorkerType(),
|
|
1178
|
+
({ exitCode: y, workerIndex: w }) => {
|
|
1179
|
+
M || y === 0 && h.error(
|
|
1180
|
+
`Worker ${w} exited with code ${y}
|
|
1168
1181
|
`
|
|
1169
|
-
)
|
|
1182
|
+
);
|
|
1170
1183
|
}
|
|
1171
1184
|
);
|
|
1172
|
-
|
|
1185
|
+
h.log(`Setting up WordPress ${e.wp}`);
|
|
1173
1186
|
try {
|
|
1174
|
-
const [y, ...
|
|
1187
|
+
const [y, ...w] = await le, L = await Y(
|
|
1175
1188
|
n
|
|
1176
1189
|
);
|
|
1177
|
-
if (t = await
|
|
1190
|
+
if (t = await C.bootPrimaryWorker(
|
|
1178
1191
|
y.phpPort,
|
|
1179
|
-
|
|
1180
|
-
|
|
1192
|
+
L,
|
|
1193
|
+
F
|
|
1181
1194
|
), i.push({
|
|
1182
1195
|
playground: t,
|
|
1183
1196
|
worker: y.worker
|
|
1184
|
-
}), await t.isReady(),
|
|
1185
|
-
const
|
|
1197
|
+
}), await t.isReady(), r = !0, h.log("Booted!"), o = new He(t), !e["experimental-blueprints-v2-runner"]) {
|
|
1198
|
+
const S = await C.compileInputBlueprint(
|
|
1186
1199
|
e["additional-blueprint-steps"] || []
|
|
1187
1200
|
);
|
|
1188
|
-
|
|
1189
|
-
|
|
1201
|
+
S && (h.log("Running the Blueprint..."), await be(
|
|
1202
|
+
S,
|
|
1190
1203
|
t
|
|
1191
|
-
),
|
|
1204
|
+
), h.log("Finished running the blueprint"));
|
|
1192
1205
|
}
|
|
1193
|
-
if (e.command === "build-snapshot"
|
|
1194
|
-
|
|
1195
|
-
|
|
1206
|
+
if (e.command === "build-snapshot") {
|
|
1207
|
+
await ft(t, e.outfile), h.log(`WordPress exported to ${e.outfile}`), await D();
|
|
1208
|
+
return;
|
|
1209
|
+
} else if (e.command === "run-blueprint") {
|
|
1210
|
+
h.log("Blueprint executed"), await D();
|
|
1211
|
+
return;
|
|
1212
|
+
}
|
|
1213
|
+
if (e.experimentalMultiWorker && e.experimentalMultiWorker > 1) {
|
|
1214
|
+
h.log("Preparing additional workers...");
|
|
1215
|
+
const S = v;
|
|
1196
1216
|
await Promise.all(
|
|
1197
|
-
|
|
1198
|
-
const
|
|
1199
|
-
worker:
|
|
1200
|
-
fileLockManagerPort:
|
|
1201
|
-
firstProcessId:
|
|
1202
|
-
nativeInternalDirPath:
|
|
1217
|
+
w.map(async (T, B) => {
|
|
1218
|
+
const ce = S + B * v, pe = await Y(n), H = await C.bootSecondaryWorker({
|
|
1219
|
+
worker: T,
|
|
1220
|
+
fileLockManagerPort: pe,
|
|
1221
|
+
firstProcessId: ce,
|
|
1222
|
+
nativeInternalDirPath: F
|
|
1203
1223
|
});
|
|
1204
1224
|
i.push({
|
|
1205
|
-
playground:
|
|
1206
|
-
worker:
|
|
1207
|
-
}), o.addWorker(
|
|
1225
|
+
playground: H,
|
|
1226
|
+
worker: T.worker
|
|
1227
|
+
}), o.addWorker(H);
|
|
1208
1228
|
})
|
|
1209
1229
|
);
|
|
1210
1230
|
}
|
|
1211
|
-
return
|
|
1212
|
-
`WordPress is running on ${d} with ${
|
|
1213
|
-
), e.xdebug && e.experimentalDevtools && (await
|
|
1231
|
+
return h.log(
|
|
1232
|
+
`WordPress is running on ${d} with ${b} worker(s)`
|
|
1233
|
+
), e.xdebug && e.experimentalDevtools && (await De({
|
|
1214
1234
|
phpInstance: t,
|
|
1215
1235
|
phpRoot: "/wordpress"
|
|
1216
1236
|
})).start(), {
|
|
1217
1237
|
playground: t,
|
|
1218
|
-
server:
|
|
1238
|
+
server: l,
|
|
1219
1239
|
serverUrl: d,
|
|
1220
|
-
[Symbol.asyncDispose]:
|
|
1221
|
-
|
|
1222
|
-
i.map(
|
|
1223
|
-
async ({ playground: E, worker: $ }) => {
|
|
1224
|
-
await E.dispose(), await $.terminate();
|
|
1225
|
-
}
|
|
1226
|
-
)
|
|
1227
|
-
), await new Promise((E) => a.close(E));
|
|
1228
|
-
},
|
|
1229
|
-
workerThreadCount: w
|
|
1240
|
+
[Symbol.asyncDispose]: D,
|
|
1241
|
+
workerThreadCount: b
|
|
1230
1242
|
};
|
|
1231
1243
|
} catch (y) {
|
|
1232
1244
|
if (!e.debug)
|
|
1233
1245
|
throw y;
|
|
1234
|
-
let
|
|
1235
|
-
throw await t?.fileExists(
|
|
1246
|
+
let w = "";
|
|
1247
|
+
throw await t?.fileExists(q) && (w = await t.readFileAsText(q)), new Error(w, { cause: y });
|
|
1236
1248
|
}
|
|
1237
1249
|
},
|
|
1238
|
-
async handleRequest(
|
|
1239
|
-
if (!
|
|
1240
|
-
return
|
|
1250
|
+
async handleRequest(l) {
|
|
1251
|
+
if (!r)
|
|
1252
|
+
return V.forHttpCode(
|
|
1241
1253
|
502,
|
|
1242
1254
|
"WordPress is not ready yet"
|
|
1243
1255
|
);
|
|
1244
|
-
if (
|
|
1245
|
-
|
|
1256
|
+
if (a) {
|
|
1257
|
+
a = !1;
|
|
1246
1258
|
const p = {
|
|
1247
1259
|
"Content-Type": ["text/plain"],
|
|
1248
1260
|
"Content-Length": ["0"],
|
|
1249
|
-
Location: [
|
|
1261
|
+
Location: [l.url]
|
|
1250
1262
|
};
|
|
1251
|
-
return
|
|
1263
|
+
return l.headers?.cookie?.includes(
|
|
1252
1264
|
"playground_auto_login_already_happened"
|
|
1253
1265
|
) && (p["Set-Cookie"] = [
|
|
1254
1266
|
"playground_auto_login_already_happened=1; Max-Age=0; Expires=Thu, 01 Jan 1970 00:00:00 GMT; Path=/"
|
|
1255
|
-
]), new
|
|
1267
|
+
]), new V(302, p, new Uint8Array());
|
|
1256
1268
|
}
|
|
1257
|
-
return await o.handleRequest(
|
|
1269
|
+
return await o.handleRequest(l);
|
|
1258
1270
|
}
|
|
1259
1271
|
});
|
|
1260
1272
|
}
|
|
1261
|
-
async function
|
|
1273
|
+
async function ut(e, o, t) {
|
|
1262
1274
|
const i = [];
|
|
1263
|
-
for (let
|
|
1264
|
-
const n = await
|
|
1275
|
+
for (let s = 0; s < e; s++) {
|
|
1276
|
+
const n = await dt(o), r = (a) => {
|
|
1265
1277
|
t({
|
|
1266
|
-
exitCode:
|
|
1267
|
-
|
|
1268
|
-
workerIndex: r
|
|
1278
|
+
exitCode: a,
|
|
1279
|
+
workerIndex: s
|
|
1269
1280
|
});
|
|
1270
1281
|
};
|
|
1271
1282
|
i.push(
|
|
1272
1283
|
new Promise(
|
|
1273
|
-
(
|
|
1284
|
+
(a, l) => {
|
|
1274
1285
|
n.once("message", function(p) {
|
|
1275
|
-
p.command === "worker-script-initialized" &&
|
|
1286
|
+
p.command === "worker-script-initialized" && a({ worker: n, phpPort: p.phpPort });
|
|
1276
1287
|
}), n.once("error", function(p) {
|
|
1277
1288
|
console.error(p);
|
|
1278
1289
|
const c = new Error(
|
|
1279
1290
|
`Worker failed to load worker. ${p.message ? `Original error: ${p.message}` : ""}`
|
|
1280
1291
|
);
|
|
1281
|
-
|
|
1282
|
-
}), n.once("exit",
|
|
1292
|
+
l(c);
|
|
1293
|
+
}), n.once("exit", r);
|
|
1283
1294
|
}
|
|
1284
1295
|
)
|
|
1285
1296
|
);
|
|
1286
1297
|
}
|
|
1287
1298
|
return Promise.all(i);
|
|
1288
1299
|
}
|
|
1289
|
-
async function
|
|
1290
|
-
return e === "v1" ? new
|
|
1300
|
+
async function dt(e) {
|
|
1301
|
+
return e === "v1" ? new X(new URL("./worker-thread-v1.js", import.meta.url)) : new X(new URL("./worker-thread-v2.js", import.meta.url));
|
|
1291
1302
|
}
|
|
1292
|
-
async function
|
|
1293
|
-
const { port1: o, port2: t } = new
|
|
1294
|
-
return await
|
|
1303
|
+
async function Y(e) {
|
|
1304
|
+
const { port1: o, port2: t } = new Pe();
|
|
1305
|
+
return await Ce() ? fe(e, null, o) : await me(e, o), t;
|
|
1295
1306
|
}
|
|
1296
|
-
async function
|
|
1307
|
+
async function ft(e, o) {
|
|
1297
1308
|
await e.run({
|
|
1298
1309
|
code: `<?php
|
|
1299
1310
|
$zip = new ZipArchive();
|
|
@@ -1318,8 +1329,8 @@ async function ut(e, o) {
|
|
|
1318
1329
|
u.writeFileSync(o, t);
|
|
1319
1330
|
}
|
|
1320
1331
|
export {
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1332
|
+
_ as L,
|
|
1333
|
+
Dt as p,
|
|
1334
|
+
pt as r
|
|
1324
1335
|
};
|
|
1325
|
-
//# sourceMappingURL=run-cli-
|
|
1336
|
+
//# sourceMappingURL=run-cli-BBfr5tmj.js.map
|