@wp-playground/cli 1.2.2 → 2.0.0
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 +3 -0
- package/blueprints-BQYAZ9gc.js +9 -0
- package/blueprints-BQYAZ9gc.js.map +1 -0
- package/blueprints-DLntJtVr.js +9 -0
- package/blueprints-DLntJtVr.js.map +1 -0
- package/blueprints-ZBrY1bvK.cjs +2 -0
- package/blueprints-ZBrY1bvK.cjs.map +1 -0
- package/blueprints-v1/blueprints-v1-handler.d.ts +31 -0
- package/{worker-thread.d.ts → blueprints-v1/worker-thread-v1.d.ts} +5 -3
- package/blueprints-v2/blueprint-v2-declaration.d.ts +10 -0
- package/blueprints-v2/blueprints-v2-handler.d.ts +31 -0
- package/blueprints-v2/get-v2-runner.d.ts +1 -0
- package/blueprints-v2/run-blueprint-v2.d.ts +35 -0
- package/blueprints-v2/worker-thread-v2.d.ts +49 -0
- package/blueprints.phar +0 -0
- package/cli.cjs +1 -1
- package/cli.cjs.map +1 -1
- package/cli.js +2 -4
- package/cli.js.map +1 -1
- package/index.cjs +1 -1
- package/index.js +1 -1
- package/load-balancer.d.ts +3 -1
- package/mounts-B-Qdcyyt.js +124 -0
- package/mounts-B-Qdcyyt.js.map +1 -0
- package/mounts-D7bhhGq3.cjs +15 -0
- package/mounts-D7bhhGq3.cjs.map +1 -0
- package/{mount.d.ts → mounts.d.ts} +10 -1
- package/package.json +11 -11
- package/run-cli-CY1lYIJH.js +674 -0
- package/run-cli-CY1lYIJH.js.map +1 -0
- package/run-cli-opqDVXKw.cjs +27 -0
- package/run-cli-opqDVXKw.cjs.map +1 -0
- package/run-cli.d.ts +30 -6
- package/worker-thread-v1-BTJIbQLy.js +133 -0
- package/worker-thread-v1-BTJIbQLy.js.map +1 -0
- package/worker-thread-v1.cjs +3 -0
- package/worker-thread-v1.cjs.map +1 -0
- package/worker-thread-v1.js +128 -0
- package/worker-thread-v1.js.map +1 -0
- package/worker-thread-v2-Pfv6UYF4.js +429 -0
- package/worker-thread-v2-Pfv6UYF4.js.map +1 -0
- package/worker-thread-v2.cjs +92 -0
- package/worker-thread-v2.cjs.map +1 -0
- package/worker-thread-v2.js +432 -0
- package/worker-thread-v2.js.map +1 -0
- package/cli-auto-mount.d.ts +0 -19
- package/index-CddYZc1x.js +0 -5
- package/index-CddYZc1x.js.map +0 -1
- package/index-CyPmrjJv.cjs +0 -2
- package/index-CyPmrjJv.cjs.map +0 -1
- package/reportable-error.d.ts +0 -5
- package/run-cli-Bon3Rz_F.cjs +0 -43
- package/run-cli-Bon3Rz_F.cjs.map +0 -1
- package/run-cli-DyJ6_Vj8.js +0 -8449
- package/run-cli-DyJ6_Vj8.js.map +0 -1
- package/worker-thread-CQBM_bGk.js +0 -171
- package/worker-thread-CQBM_bGk.js.map +0 -1
- package/worker-thread.cjs +0 -3
- package/worker-thread.cjs.map +0 -1
- package/worker-thread.js +0 -124
- package/worker-thread.js.map +0 -1
- /package/{download.d.ts → blueprints-v1/download.d.ts} +0 -0
- /package/{server.d.ts → start-server.d.ts} +0 -0
|
@@ -0,0 +1,432 @@
|
|
|
1
|
+
import { logger as P, errorLogPath as $ } from "@php-wasm/logger";
|
|
2
|
+
import { createNodeFsMountHandler as _, loadNodeRuntime as v } from "@php-wasm/node";
|
|
3
|
+
import { EmscriptenDownloadMonitor as x } from "@php-wasm/progress";
|
|
4
|
+
import { exposeAPI as W, PHPWorker as S, consumeAPI as k, consumeAPISync as M, PHPResponse as R, PHPExecutionFailureError as H, sandboxedSpawnHandlerFactory as A } from "@php-wasm/universal";
|
|
5
|
+
import { phpVar as y, sprintf as B } from "@php-wasm/util";
|
|
6
|
+
import { bootRequestHandler as E } from "@wp-playground/wordpress";
|
|
7
|
+
import { existsSync as T } from "fs";
|
|
8
|
+
import w from "path";
|
|
9
|
+
import { rootCertificates as F } from "tls";
|
|
10
|
+
import { MessageChannel as O, parentPort as j } from "worker_threads";
|
|
11
|
+
import { jspi as C } from "wasm-feature-detect";
|
|
12
|
+
async function L() {
|
|
13
|
+
let t = null;
|
|
14
|
+
const e = (await import("./blueprints-BQYAZ9gc.js")).default;
|
|
15
|
+
if (typeof process < "u" && process.versions?.node) {
|
|
16
|
+
let s = e;
|
|
17
|
+
s.startsWith("/@fs/") && (s = s.slice(4)), s.startsWith("file://") && (s = s.slice(7));
|
|
18
|
+
const { readFile: o } = await import("node:fs/promises");
|
|
19
|
+
t = await o(s);
|
|
20
|
+
} else
|
|
21
|
+
t = await (await fetch(e)).blob();
|
|
22
|
+
return new File([t], "blueprints.phar", {
|
|
23
|
+
type: "application/zip"
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
function q(t) {
|
|
27
|
+
if (typeof t == "object" && "type" in t && ["inline-file", "file-reference"].includes(t.type))
|
|
28
|
+
return t;
|
|
29
|
+
if (!t)
|
|
30
|
+
return {
|
|
31
|
+
type: "inline-file",
|
|
32
|
+
contents: "{}"
|
|
33
|
+
};
|
|
34
|
+
if (typeof t != "string")
|
|
35
|
+
return {
|
|
36
|
+
type: "inline-file",
|
|
37
|
+
contents: JSON.stringify(t)
|
|
38
|
+
};
|
|
39
|
+
try {
|
|
40
|
+
return JSON.parse(t), {
|
|
41
|
+
type: "inline-file",
|
|
42
|
+
contents: t
|
|
43
|
+
};
|
|
44
|
+
} catch {
|
|
45
|
+
return {
|
|
46
|
+
type: "file-reference",
|
|
47
|
+
reference: t
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
async function D(t) {
|
|
52
|
+
const e = t.cliArgs || [];
|
|
53
|
+
for (const i of e)
|
|
54
|
+
if (i.startsWith("--site-path="))
|
|
55
|
+
throw new Error(
|
|
56
|
+
"The --site-path CLI argument must not be provided. In Playground, it is always set to /wordpress."
|
|
57
|
+
);
|
|
58
|
+
e.push("--site-path=/wordpress"), e.find((i) => i.startsWith("--db-engine=")) || e.push("--db-engine=sqlite");
|
|
59
|
+
const o = t.php, u = t?.onMessage || (() => {
|
|
60
|
+
}), f = await L();
|
|
61
|
+
o.writeFile(
|
|
62
|
+
"/tmp/blueprints.phar",
|
|
63
|
+
new Uint8Array(await f.arrayBuffer())
|
|
64
|
+
);
|
|
65
|
+
const c = q(
|
|
66
|
+
t.blueprint
|
|
67
|
+
);
|
|
68
|
+
let n = "";
|
|
69
|
+
switch (c.type) {
|
|
70
|
+
case "inline-file":
|
|
71
|
+
o.writeFile(
|
|
72
|
+
"/tmp/blueprint.json",
|
|
73
|
+
c.contents
|
|
74
|
+
), n = "/tmp/blueprint.json";
|
|
75
|
+
break;
|
|
76
|
+
case "file-reference":
|
|
77
|
+
n = c.reference;
|
|
78
|
+
break;
|
|
79
|
+
}
|
|
80
|
+
const l = await o.onMessage(async (i) => {
|
|
81
|
+
try {
|
|
82
|
+
const r = typeof i == "string" ? JSON.parse(i) : i;
|
|
83
|
+
if (!r)
|
|
84
|
+
return;
|
|
85
|
+
await new Promise((d) => setTimeout(d, 0)), r.type.startsWith("blueprint.") && await u(r);
|
|
86
|
+
} catch (r) {
|
|
87
|
+
P.warn("Failed to parse message as JSON:", i, r);
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
await o?.writeFile(
|
|
91
|
+
"/tmp/run-blueprints.php",
|
|
92
|
+
`<?php
|
|
93
|
+
function playground_http_client_factory() {
|
|
94
|
+
return new WordPress\\HttpClient\\Client([
|
|
95
|
+
// sockets transport is somehow faster than curl in Playground. Maybe
|
|
96
|
+
// it uses a larger chunk size?
|
|
97
|
+
'transport' => 'sockets',
|
|
98
|
+
]);
|
|
99
|
+
}
|
|
100
|
+
playground_add_filter('blueprint.http_client', 'playground_http_client_factory');
|
|
101
|
+
|
|
102
|
+
function playground_on_blueprint_target_resolved() {
|
|
103
|
+
post_message_to_js(json_encode([
|
|
104
|
+
'type' => 'blueprint.target_resolved',
|
|
105
|
+
]));
|
|
106
|
+
}
|
|
107
|
+
playground_add_filter('blueprint.target_resolved', 'playground_on_blueprint_target_resolved');
|
|
108
|
+
|
|
109
|
+
playground_add_filter('blueprint.resolved', 'playground_on_blueprint_resolved');
|
|
110
|
+
function playground_on_blueprint_resolved($blueprint) {
|
|
111
|
+
$additional_blueprint_steps = json_decode(${y(
|
|
112
|
+
JSON.stringify(t.blueprintOverrides?.additionalSteps || [])
|
|
113
|
+
)}, true);
|
|
114
|
+
if(count($additional_blueprint_steps) > 0) {
|
|
115
|
+
$blueprint['additionalStepsAfterExecution'] = array_merge(
|
|
116
|
+
$blueprint['additionalStepsAfterExecution'] ?? [],
|
|
117
|
+
$additional_blueprint_steps
|
|
118
|
+
);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
$wp_version_override = json_decode(${y(
|
|
122
|
+
JSON.stringify(t.blueprintOverrides?.wordpressVersion || null)
|
|
123
|
+
)}, true);
|
|
124
|
+
if($wp_version_override) {
|
|
125
|
+
$blueprint['wordpressVersion'] = $wp_version_override;
|
|
126
|
+
}
|
|
127
|
+
return $blueprint;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
function playground_progress_reporter() {
|
|
131
|
+
class PlaygroundProgressReporter implements ProgressReporter {
|
|
132
|
+
|
|
133
|
+
public function reportProgress(float $progress, string $caption): void {
|
|
134
|
+
$this->writeJsonMessage([
|
|
135
|
+
'type' => 'blueprint.progress',
|
|
136
|
+
'progress' => round($progress, 2),
|
|
137
|
+
'caption' => $caption
|
|
138
|
+
]);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
public function reportError(string $message, ?Throwable $exception = null): void {
|
|
142
|
+
$errorData = [
|
|
143
|
+
'type' => 'blueprint.error',
|
|
144
|
+
'message' => $message
|
|
145
|
+
];
|
|
146
|
+
|
|
147
|
+
if ($exception) {
|
|
148
|
+
$errorData['details'] = [
|
|
149
|
+
'exception' => get_class($exception),
|
|
150
|
+
'message' => $exception->getMessage(),
|
|
151
|
+
'file' => $exception->getFile(),
|
|
152
|
+
'line' => $exception->getLine(),
|
|
153
|
+
'trace' => $exception->getTraceAsString()
|
|
154
|
+
];
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
$this->writeJsonMessage($errorData);
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
public function reportCompletion(string $message): void {
|
|
161
|
+
$this->writeJsonMessage([
|
|
162
|
+
'type' => 'blueprint.completion',
|
|
163
|
+
'message' => $message
|
|
164
|
+
]);
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
public function close(): void {}
|
|
168
|
+
|
|
169
|
+
private function writeJsonMessage(array $data): void {
|
|
170
|
+
post_message_to_js(json_encode($data));
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
return new PlaygroundProgressReporter();
|
|
174
|
+
}
|
|
175
|
+
playground_add_filter('blueprint.progress_reporter', 'playground_progress_reporter');
|
|
176
|
+
require( "/tmp/blueprints.phar" );
|
|
177
|
+
`
|
|
178
|
+
);
|
|
179
|
+
const a = await o.cli([
|
|
180
|
+
"/internal/shared/bin/php",
|
|
181
|
+
"/tmp/run-blueprints.php",
|
|
182
|
+
"exec",
|
|
183
|
+
n,
|
|
184
|
+
...e
|
|
185
|
+
]);
|
|
186
|
+
return a.finished.finally(l), a;
|
|
187
|
+
}
|
|
188
|
+
async function h(t, e) {
|
|
189
|
+
for (const s of e)
|
|
190
|
+
try {
|
|
191
|
+
t.mkdir(s.vfsPath), await t.mount(
|
|
192
|
+
s.vfsPath,
|
|
193
|
+
_(s.hostPath)
|
|
194
|
+
);
|
|
195
|
+
} catch {
|
|
196
|
+
p.stderr(
|
|
197
|
+
`\x1B[31m\x1B[1mError mounting path ${s.hostPath} at ${s.vfsPath}\x1B[0m
|
|
198
|
+
`
|
|
199
|
+
), process.exit(1);
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
function I(t, e, ...s) {
|
|
203
|
+
console.log(
|
|
204
|
+
performance.now().toFixed(6).padStart(15, "0"),
|
|
205
|
+
t.toString().padStart(16, "0"),
|
|
206
|
+
B(e, ...s)
|
|
207
|
+
);
|
|
208
|
+
}
|
|
209
|
+
Object.defineProperty(process.stdout, "isTTY", { value: !0 });
|
|
210
|
+
Object.defineProperty(process.stderr, "isTTY", { value: !0 });
|
|
211
|
+
const p = {
|
|
212
|
+
lastWriteWasProgress: !1,
|
|
213
|
+
progress(t) {
|
|
214
|
+
process.stdout.isTTY ? (p.lastWriteWasProgress || process.stdout.write(`
|
|
215
|
+
`), process.stdout.write("\r\x1B[K" + t), p.lastWriteWasProgress = !0) : console.log(t);
|
|
216
|
+
},
|
|
217
|
+
stdout(t) {
|
|
218
|
+
p.lastWriteWasProgress && (process.stdout.write(`
|
|
219
|
+
`), p.lastWriteWasProgress = !1), process.stdout.write(t);
|
|
220
|
+
},
|
|
221
|
+
stderr(t) {
|
|
222
|
+
p.lastWriteWasProgress && (process.stdout.write(`
|
|
223
|
+
`), p.lastWriteWasProgress = !1), process.stderr.write(t);
|
|
224
|
+
}
|
|
225
|
+
};
|
|
226
|
+
class J extends S {
|
|
227
|
+
constructor(e) {
|
|
228
|
+
super(void 0, e), this.booted = !1;
|
|
229
|
+
}
|
|
230
|
+
/**
|
|
231
|
+
* Call this method before boot() to use file locking.
|
|
232
|
+
*
|
|
233
|
+
* This method is separate from boot() to simplify the related Comlink.transferHandlers
|
|
234
|
+
* setup – if an argument is a MessagePort, we're transferring it, not copying it.
|
|
235
|
+
*
|
|
236
|
+
* @see comlink-sync.ts
|
|
237
|
+
* @see phpwasm-emscripten-library-file-locking-for-node.js
|
|
238
|
+
*/
|
|
239
|
+
async useFileLockManager(e) {
|
|
240
|
+
await C() ? this.fileLockManager = k(e) : this.fileLockManager = await M(e);
|
|
241
|
+
}
|
|
242
|
+
async bootAsPrimaryWorker(e) {
|
|
243
|
+
await this.bootRequestHandler(e);
|
|
244
|
+
const s = this.__internal_getPHP();
|
|
245
|
+
if (await h(s, e["mount-before-install"] || []), e.mode === "mount-only") {
|
|
246
|
+
await h(s, e.mount || []);
|
|
247
|
+
return;
|
|
248
|
+
}
|
|
249
|
+
await this.runBlueprintV2(e);
|
|
250
|
+
}
|
|
251
|
+
async bootAsSecondaryWorker(e) {
|
|
252
|
+
await this.bootRequestHandler(e);
|
|
253
|
+
const s = this.__internal_getPHP();
|
|
254
|
+
await h(s, e["mount-before-install"] || []), await h(s, e.mount || []);
|
|
255
|
+
}
|
|
256
|
+
async runBlueprintV2(e) {
|
|
257
|
+
const s = this.__internal_getRequestHandler(), { php: o, reap: u } = await s.processManager.acquirePHPInstance({
|
|
258
|
+
considerPrimary: !1
|
|
259
|
+
}), f = this.__internal_getPHP();
|
|
260
|
+
let c = () => {
|
|
261
|
+
};
|
|
262
|
+
if (typeof e.blueprint == "string") {
|
|
263
|
+
const n = w.resolve(process.cwd(), e.blueprint);
|
|
264
|
+
T(n) && (f.mkdir("/internal/shared/cwd"), c = await f.mount(
|
|
265
|
+
"/internal/shared/cwd",
|
|
266
|
+
_(w.dirname(n))
|
|
267
|
+
), e.blueprint = w.join(
|
|
268
|
+
"/internal/shared/cwd",
|
|
269
|
+
w.basename(e.blueprint)
|
|
270
|
+
));
|
|
271
|
+
}
|
|
272
|
+
try {
|
|
273
|
+
const l = [
|
|
274
|
+
"mode",
|
|
275
|
+
"db-engine",
|
|
276
|
+
"db-host",
|
|
277
|
+
"db-user",
|
|
278
|
+
"db-pass",
|
|
279
|
+
"db-name",
|
|
280
|
+
"db-path",
|
|
281
|
+
"truncate-new-site-directory",
|
|
282
|
+
"allow"
|
|
283
|
+
].filter((r) => r in e).map((r) => `--${r}=${e[r]}`);
|
|
284
|
+
l.push(`--site-url=${e.siteUrl}`);
|
|
285
|
+
let a = !1;
|
|
286
|
+
const i = await D({
|
|
287
|
+
php: o,
|
|
288
|
+
blueprint: e.blueprint,
|
|
289
|
+
blueprintOverrides: {
|
|
290
|
+
additionalSteps: e["additional-blueprint-steps"],
|
|
291
|
+
wordpressVersion: e.wp
|
|
292
|
+
},
|
|
293
|
+
cliArgs: l,
|
|
294
|
+
onMessage: async (r) => {
|
|
295
|
+
switch (r.type) {
|
|
296
|
+
case "blueprint.target_resolved": {
|
|
297
|
+
a || (await h(
|
|
298
|
+
f,
|
|
299
|
+
e.mount || []
|
|
300
|
+
), a = !0);
|
|
301
|
+
break;
|
|
302
|
+
}
|
|
303
|
+
case "blueprint.progress": {
|
|
304
|
+
const d = `${r.caption.trim()} – ${r.progress.toFixed(
|
|
305
|
+
2
|
|
306
|
+
)}%`;
|
|
307
|
+
p.progress(d);
|
|
308
|
+
break;
|
|
309
|
+
}
|
|
310
|
+
case "blueprint.error": {
|
|
311
|
+
const d = "\x1B[31m", g = "\x1B[1m", m = "\x1B[0m";
|
|
312
|
+
e.debug && r.details ? p.stderr(
|
|
313
|
+
`${d}${g}Fatal error:${m} Uncaught ${r.details.exception}: ${r.details.message}
|
|
314
|
+
at ${r.details.file}:${r.details.line}
|
|
315
|
+
` + (r.details.trace ? r.details.trace + `
|
|
316
|
+
` : "")
|
|
317
|
+
) : p.stderr(
|
|
318
|
+
`${d}${g}Error:${m} ${r.message}
|
|
319
|
+
`
|
|
320
|
+
);
|
|
321
|
+
break;
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
});
|
|
326
|
+
if (e.debug && (i.stdout.pipeTo(
|
|
327
|
+
new WritableStream({
|
|
328
|
+
write(r) {
|
|
329
|
+
process.stdout.write(r);
|
|
330
|
+
}
|
|
331
|
+
})
|
|
332
|
+
), i.stderr.pipeTo(
|
|
333
|
+
new WritableStream({
|
|
334
|
+
write(r) {
|
|
335
|
+
process.stderr.write(r);
|
|
336
|
+
}
|
|
337
|
+
})
|
|
338
|
+
)), await i.finished, await i.exitCode !== 0) {
|
|
339
|
+
const r = await R.fromStreamedResponse(
|
|
340
|
+
i
|
|
341
|
+
);
|
|
342
|
+
throw new H(
|
|
343
|
+
`PHP.run() failed with exit code ${r.exitCode}.`,
|
|
344
|
+
r,
|
|
345
|
+
"request"
|
|
346
|
+
);
|
|
347
|
+
}
|
|
348
|
+
} catch (n) {
|
|
349
|
+
let l = "";
|
|
350
|
+
try {
|
|
351
|
+
l = o.readFileAsText($);
|
|
352
|
+
} catch {
|
|
353
|
+
}
|
|
354
|
+
throw n.phpLogs = l, n;
|
|
355
|
+
} finally {
|
|
356
|
+
u(), c();
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
async bootRequestHandler({
|
|
360
|
+
siteUrl: e,
|
|
361
|
+
allow: s,
|
|
362
|
+
php: o,
|
|
363
|
+
firstProcessId: u,
|
|
364
|
+
processIdSpaceLength: f,
|
|
365
|
+
trace: c
|
|
366
|
+
}) {
|
|
367
|
+
if (this.booted)
|
|
368
|
+
throw new Error("Playground already booted");
|
|
369
|
+
this.booted = !0;
|
|
370
|
+
let n = u;
|
|
371
|
+
const l = u + f - 1;
|
|
372
|
+
try {
|
|
373
|
+
const a = {
|
|
374
|
+
WP_DEBUG: !0,
|
|
375
|
+
WP_DEBUG_LOG: !0,
|
|
376
|
+
WP_DEBUG_DISPLAY: !1
|
|
377
|
+
}, i = await E({
|
|
378
|
+
siteUrl: e,
|
|
379
|
+
createPhpRuntime: async () => {
|
|
380
|
+
const d = n;
|
|
381
|
+
return n < l ? n++ : n = u, await v(o, {
|
|
382
|
+
emscriptenOptions: {
|
|
383
|
+
fileLockManager: this.fileLockManager,
|
|
384
|
+
processId: d,
|
|
385
|
+
trace: c ? I : void 0,
|
|
386
|
+
ENV: {
|
|
387
|
+
DOCROOT: "/wordpress"
|
|
388
|
+
}
|
|
389
|
+
},
|
|
390
|
+
followSymlinks: s?.includes("follow-symlinks")
|
|
391
|
+
});
|
|
392
|
+
},
|
|
393
|
+
sapiName: "cli",
|
|
394
|
+
createFiles: {
|
|
395
|
+
"/internal/shared/ca-bundle.crt": F.join(`
|
|
396
|
+
`)
|
|
397
|
+
},
|
|
398
|
+
constants: a,
|
|
399
|
+
phpIniEntries: {
|
|
400
|
+
"openssl.cafile": "/internal/shared/ca-bundle.crt"
|
|
401
|
+
},
|
|
402
|
+
cookieStore: !1,
|
|
403
|
+
spawnHandler: A
|
|
404
|
+
});
|
|
405
|
+
this.__internal_setRequestHandler(i);
|
|
406
|
+
const r = await i.getPrimaryPhp();
|
|
407
|
+
await this.setPrimaryPHP(r), N();
|
|
408
|
+
} catch (a) {
|
|
409
|
+
throw V(a), a;
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
// Provide a named disposal method that can be invoked via comlink.
|
|
413
|
+
async dispose() {
|
|
414
|
+
await this[Symbol.asyncDispose]();
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
const b = new O(), [N, V] = W(
|
|
418
|
+
new J(new x()),
|
|
419
|
+
void 0,
|
|
420
|
+
b.port1
|
|
421
|
+
);
|
|
422
|
+
j.postMessage(
|
|
423
|
+
{
|
|
424
|
+
command: "worker-script-initialized",
|
|
425
|
+
phpPort: b.port2
|
|
426
|
+
},
|
|
427
|
+
[b.port2]
|
|
428
|
+
);
|
|
429
|
+
export {
|
|
430
|
+
J as PlaygroundCliBlueprintV2Worker
|
|
431
|
+
};
|
|
432
|
+
//# sourceMappingURL=worker-thread-v2.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"worker-thread-v2.js","sources":["../../../../packages/playground/cli/src/blueprints-v2/get-v2-runner.ts","../../../../packages/playground/cli/src/blueprints-v2/blueprint-v2-declaration.ts","../../../../packages/playground/cli/src/blueprints-v2/run-blueprint-v2.ts","../../../../packages/playground/cli/src/blueprints-v2/worker-thread-v2.ts"],"sourcesContent":["export async function getV2Runner(): Promise<File> {\n\tlet data = null;\n\n\t/**\n\t * Avoid a static dependency for now.\n\t *\n\t * Playground.wordpress.net does not need to know about the new runner yet, and\n\t * a static import would force it to download the v2 runner even when it's not needed.\n\t * This breaks the offline mode as the static assets list is not yet updated to accommodate\n\t * for the new .phar file.\n\t */\n\t// @ts-ignore\n\tconst v2_runner_url = (await import('../../public/blueprints.phar?url'))\n\t\t.default;\n\n\t/**\n\t * Only load the v2 runner via node:fs when running in Node.js.\n\t */\n\tif (typeof process !== 'undefined' && process.versions?.node) {\n\t\tlet path = v2_runner_url;\n\t\tif (path.startsWith('/@fs/')) {\n\t\t\tpath = path.slice('/@fs'.length);\n\t\t}\n\t\tif (path.startsWith('file://')) {\n\t\t\tpath = path.slice('file://'.length);\n\t\t}\n\n\t\tconst { readFile } = await import('node:fs/promises');\n\t\tdata = await readFile(path);\n\t} else {\n\t\tconst response = await fetch(v2_runner_url);\n\t\tdata = await response.blob();\n\t}\n\treturn new File([data], `blueprints.phar`, {\n\t\ttype: 'application/zip',\n\t});\n}\n","import type { BlueprintDeclaration } from '@wp-playground/blueprints';\n\nexport type BlueprintV2Declaration = string | BlueprintDeclaration | undefined;\nexport type ParsedBlueprintV2Declaration =\n\t| { type: 'inline-file'; contents: string }\n\t| { type: 'file-reference'; reference: string };\n\nexport function parseBlueprintDeclaration(\n\tsource: BlueprintV2Declaration | ParsedBlueprintV2Declaration\n): ParsedBlueprintV2Declaration {\n\tif (\n\t\ttypeof source === 'object' &&\n\t\t'type' in source &&\n\t\t['inline-file', 'file-reference'].includes(source.type)\n\t) {\n\t\treturn source;\n\t}\n\tif (!source) {\n\t\treturn {\n\t\t\ttype: 'inline-file',\n\t\t\tcontents: '{}',\n\t\t};\n\t}\n\tif (typeof source !== 'string') {\n\t\t// If source is an object, assume it's a Blueprint declaration object and\n\t\t// convert it to a JSON string.\n\t\treturn {\n\t\t\ttype: 'inline-file',\n\t\t\tcontents: JSON.stringify(source),\n\t\t};\n\t}\n\ttry {\n\t\t// If source is valid JSON, return it as is.\n\t\tJSON.parse(source);\n\t\treturn {\n\t\t\ttype: 'inline-file',\n\t\t\tcontents: source,\n\t\t};\n\t} catch {\n\t\treturn {\n\t\t\ttype: 'file-reference',\n\t\t\treference: source,\n\t\t};\n\t}\n}\n","import { logger } from '@php-wasm/logger';\nimport {\n\ttype StreamedPHPResponse,\n\ttype UniversalPHP,\n} from '@php-wasm/universal';\nimport { phpVar } from '@php-wasm/util';\nimport { getV2Runner } from './get-v2-runner';\nimport {\n\ttype BlueprintV2Declaration,\n\ttype ParsedBlueprintV2Declaration,\n\tparseBlueprintDeclaration,\n} from './blueprint-v2-declaration';\n\nexport type PHPExceptionDetails = {\n\texception: string;\n\tmessage: string;\n\tfile: string;\n\tline: number;\n\ttrace: string;\n};\n\nexport type BlueprintMessage =\n\t| { type: 'blueprint.target_resolved' }\n\t| { type: 'blueprint.progress'; progress: number; caption: string }\n\t| {\n\t\t\ttype: 'blueprint.error';\n\t\t\tmessage: string;\n\t\t\tdetails?: PHPExceptionDetails;\n\t }\n\t| { type: 'blueprint.completion'; message: string };\n\ninterface RunV2Options {\n\tphp: UniversalPHP;\n\tcliArgs?: string[];\n\tblueprint: BlueprintV2Declaration | ParsedBlueprintV2Declaration;\n\tblueprintOverrides?: {\n\t\twordpressVersion?: string;\n\t\tadditionalSteps?: any[];\n\t};\n\tonMessage?: (message: BlueprintMessage) => void | Promise<void>;\n}\n\nexport async function runBlueprintV2(\n\toptions: RunV2Options\n): Promise<StreamedPHPResponse> {\n\tconst cliArgs = options.cliArgs || [];\n\tfor (const arg of cliArgs) {\n\t\tif (arg.startsWith('--site-path=')) {\n\t\t\tthrow new Error(\n\t\t\t\t'The --site-path CLI argument must not be provided. In Playground, it is always set to /wordpress.'\n\t\t\t);\n\t\t}\n\t}\n\tcliArgs.push('--site-path=/wordpress');\n\n\t/**\n\t * Divergence from blueprints.phar – the default database engine is\n\t * SQLite. Why? Because in Playground we'll use SQLite far more often than\n\t * MySQL.\n\t */\n\tconst dbEngine = cliArgs.find((arg) => arg.startsWith('--db-engine='));\n\tif (!dbEngine) {\n\t\tcliArgs.push('--db-engine=sqlite');\n\t}\n\n\tconst php = options.php;\n\tconst onMessage = options?.onMessage || (() => {});\n\n\tconst file = await getV2Runner();\n\tphp.writeFile(\n\t\t'/tmp/blueprints.phar',\n\t\tnew Uint8Array(await file.arrayBuffer())\n\t);\n\n\tconst parsedBlueprintDeclaration = parseBlueprintDeclaration(\n\t\toptions.blueprint\n\t);\n\tlet blueprintReference = '';\n\tswitch (parsedBlueprintDeclaration.type) {\n\t\tcase 'inline-file':\n\t\t\tphp.writeFile(\n\t\t\t\t'/tmp/blueprint.json',\n\t\t\t\tparsedBlueprintDeclaration.contents\n\t\t\t);\n\t\t\tblueprintReference = '/tmp/blueprint.json';\n\t\t\tbreak;\n\t\tcase 'file-reference':\n\t\t\tblueprintReference = parsedBlueprintDeclaration.reference;\n\t\t\tbreak;\n\t}\n\n\tconst unbindMessageListener = await php.onMessage(async (message) => {\n\t\ttry {\n\t\t\tconst parsed =\n\t\t\t\ttypeof message === 'string' ? JSON.parse(message) : message;\n\t\t\tif (!parsed) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Make sure stdout and stderr data is emited before the next message is processed.\n\t\t\t// Otherwise a code such as `echo \"Hello\"; post_message_to_js(json_encode([\n\t\t\t// 'type' => 'blueprint.error',\n\t\t\t// 'message' => 'Error'\n\t\t\t// ]));`\n\t\t\t// might emit the message before we process the stdout data.\n\t\t\t//\n\t\t\t// This is a workaround to ensure that the message is emitted after the stdout data is processed.\n\t\t\t// @TODO: Remove this workaround. Find the root cause why stdout data is delayed and address it\n\t\t\t// directly.\n\t\t\tawait new Promise((resolve) => setTimeout(resolve, 0));\n\n\t\t\tif (parsed.type.startsWith('blueprint.')) {\n\t\t\t\tawait onMessage(parsed);\n\t\t\t}\n\t\t} catch (e) {\n\t\t\tlogger.warn('Failed to parse message as JSON:', message, e);\n\t\t}\n\t});\n\n\t/**\n\t * Prepare hooks, filters, and run the Blueprint:\n\t */\n\tawait php?.writeFile(\n\t\t'/tmp/run-blueprints.php',\n\t\t`<?php\nfunction playground_http_client_factory() {\n\treturn new WordPress\\\\HttpClient\\\\Client([\n\t\t// sockets transport is somehow faster than curl in Playground. Maybe\n\t\t// it uses a larger chunk size?\n\t\t'transport' => 'sockets',\n\t]);\n}\nplayground_add_filter('blueprint.http_client', 'playground_http_client_factory');\n\nfunction playground_on_blueprint_target_resolved() {\n\tpost_message_to_js(json_encode([\n\t\t'type' => 'blueprint.target_resolved',\n\t]));\n}\nplayground_add_filter('blueprint.target_resolved', 'playground_on_blueprint_target_resolved');\n\nplayground_add_filter('blueprint.resolved', 'playground_on_blueprint_resolved');\nfunction playground_on_blueprint_resolved($blueprint) {\n\t$additional_blueprint_steps = json_decode(${phpVar(\n\t\tJSON.stringify(options.blueprintOverrides?.additionalSteps || [])\n\t)}, true);\n\tif(count($additional_blueprint_steps) > 0) {\n\t\t$blueprint['additionalStepsAfterExecution'] = array_merge(\n\t\t\t$blueprint['additionalStepsAfterExecution'] ?? [],\n\t\t\t$additional_blueprint_steps\n\t\t);\n\t}\n\n\t$wp_version_override = json_decode(${phpVar(\n\t\tJSON.stringify(options.blueprintOverrides?.wordpressVersion || null)\n\t)}, true);\n\tif($wp_version_override) {\n\t\t$blueprint['wordpressVersion'] = $wp_version_override;\n\t}\n\treturn $blueprint;\n}\n\nfunction playground_progress_reporter() {\n\tclass PlaygroundProgressReporter implements ProgressReporter {\n\n\t\tpublic function reportProgress(float $progress, string $caption): void {\n\t\t\t$this->writeJsonMessage([\n\t\t\t\t'type' => 'blueprint.progress',\n\t\t\t\t'progress' => round($progress, 2),\n\t\t\t\t'caption' => $caption\n\t\t\t]);\n\t\t}\n\n\t\tpublic function reportError(string $message, ?Throwable $exception = null): void {\n\t\t\t$errorData = [\n\t\t\t\t'type' => 'blueprint.error',\n\t\t\t\t'message' => $message\n\t\t\t];\n\n\t\t\tif ($exception) {\n\t\t\t\t$errorData['details'] = [\n\t\t\t\t\t'exception' => get_class($exception),\n\t\t\t\t\t'message' => $exception->getMessage(),\n\t\t\t\t\t'file' => $exception->getFile(),\n\t\t\t\t\t'line' => $exception->getLine(),\n\t\t\t\t\t'trace' => $exception->getTraceAsString()\n\t\t\t\t];\n\t\t\t}\n\n\t\t\t$this->writeJsonMessage($errorData);\n\t\t}\n\n\t\tpublic function reportCompletion(string $message): void {\n\t\t\t$this->writeJsonMessage([\n\t\t\t\t'type' => 'blueprint.completion',\n\t\t\t\t'message' => $message\n\t\t\t]);\n\t\t}\n\n\t\tpublic function close(): void {}\n\n\t\tprivate function writeJsonMessage(array $data): void {\n\t\t\tpost_message_to_js(json_encode($data));\n\t\t}\n\t}\n\treturn new PlaygroundProgressReporter();\n}\nplayground_add_filter('blueprint.progress_reporter', 'playground_progress_reporter');\nrequire( \"/tmp/blueprints.phar\" );\n`\n\t);\n\tconst streamedResponse = (await (php as any).cli([\n\t\t'/internal/shared/bin/php',\n\t\t'/tmp/run-blueprints.php',\n\t\t'exec',\n\t\tblueprintReference,\n\t\t...cliArgs,\n\t])) as StreamedPHPResponse;\n\n\tstreamedResponse.finished.finally(unbindMessageListener);\n\n\treturn streamedResponse;\n}\n","import { errorLogPath } from '@php-wasm/logger';\nimport type { FileLockManager } from '@php-wasm/node';\nimport { createNodeFsMountHandler, loadNodeRuntime } from '@php-wasm/node';\nimport { EmscriptenDownloadMonitor } from '@php-wasm/progress';\nimport type { PHP, RemoteAPI, SupportedPHPVersion } from '@php-wasm/universal';\nimport {\n\tPHPExecutionFailureError,\n\tPHPResponse,\n\tPHPWorker,\n\tconsumeAPI,\n\tconsumeAPISync,\n\texposeAPI,\n\tsandboxedSpawnHandlerFactory,\n} from '@php-wasm/universal';\nimport { sprintf } from '@php-wasm/util';\nimport { type BlueprintMessage, runBlueprintV2 } from './run-blueprint-v2';\nimport {\n\ttype ParsedBlueprintV2Declaration,\n\ttype BlueprintV2Declaration,\n} from './blueprint-v2-declaration';\nimport { bootRequestHandler } from '@wp-playground/wordpress';\nimport { existsSync } from 'fs';\nimport path from 'path';\nimport { rootCertificates } from 'tls';\nimport { MessageChannel, type MessagePort, parentPort } from 'worker_threads';\nimport type { Mount } from '../mounts';\nimport { jspi } from 'wasm-feature-detect';\nimport { type RunCLIArgs } from '../run-cli';\n\nasync function mountResources(php: PHP, mounts: Mount[]) {\n\tfor (const mount of mounts) {\n\t\ttry {\n\t\t\tphp.mkdir(mount.vfsPath);\n\t\t\tawait php.mount(\n\t\t\t\tmount.vfsPath,\n\t\t\t\tcreateNodeFsMountHandler(mount.hostPath)\n\t\t\t);\n\t\t} catch {\n\t\t\toutput.stderr(\n\t\t\t\t`\\x1b[31m\\x1b[1mError mounting path ${mount.hostPath} at ${mount.vfsPath}\\x1b[0m\\n`\n\t\t\t);\n\t\t\tprocess.exit(1);\n\t\t}\n\t}\n}\n\n/**\n * Print trace messages from PHP-WASM.\n *\n * @param {number} processId - The process ID.\n * @param {string} format - The format string.\n * @param {...any} args - The arguments.\n */\nfunction tracePhpWasm(processId: number, format: string, ...args: any[]) {\n\t// eslint-disable-next-line no-console\n\tconsole.log(\n\t\tperformance.now().toFixed(6).padStart(15, '0'),\n\t\tprocessId.toString().padStart(16, '0'),\n\t\tsprintf(format, ...args)\n\t);\n}\n\n/**\n * Force TTY status to preserve ANSI control codes in the output.\n *\n * This script is spawned as `new Worker()` and process.stdout and process.stderr are\n * WritableWorkerStdio objects. By default, they strip ANSI control codes from the output\n * causing every progress bar update to be printed in a new line instead of updating the\n * same line.\n */\nObject.defineProperty(process.stdout, 'isTTY', { value: true });\nObject.defineProperty(process.stderr, 'isTTY', { value: true });\n\n/**\n * Output writer that ensures that progress bars are not printed on the same line as other output.\n */\nconst output = {\n\tlastWriteWasProgress: false,\n\tprogress(data: string) {\n\t\tif (!process.stdout.isTTY) {\n\t\t\t// eslint-disable-next-line no-console\n\t\t\tconsole.log(data);\n\t\t} else {\n\t\t\tif (!output.lastWriteWasProgress) {\n\t\t\t\tprocess.stdout.write('\\n');\n\t\t\t}\n\t\t\tprocess.stdout.write('\\r\\x1b[K' + data);\n\t\t\toutput.lastWriteWasProgress = true;\n\t\t}\n\t},\n\tstdout(data: string) {\n\t\tif (output.lastWriteWasProgress) {\n\t\t\tprocess.stdout.write('\\n');\n\t\t\toutput.lastWriteWasProgress = false;\n\t\t}\n\t\tprocess.stdout.write(data);\n\t},\n\tstderr(data: string) {\n\t\tif (output.lastWriteWasProgress) {\n\t\t\tprocess.stdout.write('\\n');\n\t\t\toutput.lastWriteWasProgress = false;\n\t\t}\n\t\tprocess.stderr.write(data);\n\t},\n};\n\nexport type WorkerBootArgs = RunCLIArgs & {\n\tphp: SupportedPHPVersion;\n\tsiteUrl: string;\n\tfirstProcessId: number;\n\tprocessIdSpaceLength: number;\n\ttrace: boolean;\n\tblueprint: BlueprintV2Declaration | ParsedBlueprintV2Declaration;\n};\n\ntype WorkerRunBlueprintArgs = RunCLIArgs & {\n\tsiteUrl: string;\n\tblueprint: BlueprintV2Declaration | ParsedBlueprintV2Declaration;\n};\n\ninterface WorkerBootRequestHandlerOptions {\n\tsiteUrl: string;\n\tphp: SupportedPHPVersion;\n\tallow?: string;\n\tfirstProcessId: number;\n\tprocessIdSpaceLength: number;\n\ttrace: boolean;\n}\n\nexport class PlaygroundCliBlueprintV2Worker extends PHPWorker {\n\tbooted = false;\n\tfileLockManager: RemoteAPI<FileLockManager> | FileLockManager | undefined;\n\n\tconstructor(monitor: EmscriptenDownloadMonitor) {\n\t\tsuper(undefined, monitor);\n\t}\n\n\t/**\n\t * Call this method before boot() to use file locking.\n\t *\n\t * This method is separate from boot() to simplify the related Comlink.transferHandlers\n\t * setup – if an argument is a MessagePort, we're transferring it, not copying it.\n\t *\n\t * @see comlink-sync.ts\n\t * @see phpwasm-emscripten-library-file-locking-for-node.js\n\t */\n\tasync useFileLockManager(port: MessagePort) {\n\t\tif (await jspi()) {\n\t\t\t/**\n\t\t\t * If JSPI is available, php.js supports both synchronous and asynchronous locking syscalls.\n\t\t\t * Web browsers, however, only support asynchronous message passing so let's use the\n\t\t\t * asynchronous API. Every method call will return a promise.\n\t\t\t *\n\t\t\t * @see comlink-sync.ts\n\t\t\t * @see phpwasm-emscripten-library-file-locking-for-node.js\n\t\t\t */\n\t\t\tthis.fileLockManager = consumeAPI<FileLockManager>(port);\n\t\t} else {\n\t\t\t/**\n\t\t\t * If JSPI is not available, php.js only supports synchronous locking syscalls.\n\t\t\t * Let's use the synchronous API. Every method call will block this thread\n\t\t\t * until the result is available.\n\t\t\t *\n\t\t\t * @see comlink-sync.ts\n\t\t\t * @see phpwasm-emscripten-library-file-locking-for-node.js\n\t\t\t */\n\t\t\tthis.fileLockManager = await consumeAPISync<FileLockManager>(port);\n\t\t}\n\t}\n\n\tasync bootAsPrimaryWorker(args: WorkerBootArgs) {\n\t\tawait this.bootRequestHandler(args);\n\n\t\tconst primaryPhp = this.__internal_getPHP()!;\n\t\tawait mountResources(primaryPhp, args['mount-before-install'] || []);\n\n\t\tif (args.mode === 'mount-only') {\n\t\t\tawait mountResources(primaryPhp, args.mount || []);\n\t\t\treturn;\n\t\t}\n\n\t\tawait this.runBlueprintV2(args);\n\t}\n\n\tasync bootAsSecondaryWorker(args: WorkerBootArgs) {\n\t\tawait this.bootRequestHandler(args);\n\t\tconst primaryPhp = this.__internal_getPHP()!;\n\t\t// When secondary workers are spawned, WordPress is already installed.\n\t\tawait mountResources(primaryPhp, args['mount-before-install'] || []);\n\t\tawait mountResources(primaryPhp, args.mount || []);\n\t}\n\n\tasync runBlueprintV2(args: WorkerRunBlueprintArgs) {\n\t\tconst requestHandler = this.__internal_getRequestHandler()!;\n\t\tconst { php, reap } =\n\t\t\tawait requestHandler.processManager.acquirePHPInstance({\n\t\t\t\tconsiderPrimary: false,\n\t\t\t});\n\n\t\t// Mount the current working directory to the PHP runtime for the purposes of\n\t\t// Blueprint resolution.\n\t\tconst primaryPhp = this.__internal_getPHP()!;\n\t\tlet unmountCwd = () => {};\n\t\tif (typeof args.blueprint === 'string') {\n\t\t\tconst blueprintPath = path.resolve(process.cwd(), args.blueprint);\n\t\t\tif (existsSync(blueprintPath)) {\n\t\t\t\tprimaryPhp.mkdir('/internal/shared/cwd');\n\t\t\t\tunmountCwd = await primaryPhp.mount(\n\t\t\t\t\t'/internal/shared/cwd',\n\t\t\t\t\tcreateNodeFsMountHandler(path.dirname(blueprintPath))\n\t\t\t\t);\n\t\t\t\targs.blueprint = path.join(\n\t\t\t\t\t'/internal/shared/cwd',\n\t\t\t\t\tpath.basename(args.blueprint)\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\ttry {\n\t\t\tconst cliArgsToPass: (keyof WorkerRunBlueprintArgs)[] = [\n\t\t\t\t'mode',\n\t\t\t\t'db-engine',\n\t\t\t\t'db-host',\n\t\t\t\t'db-user',\n\t\t\t\t'db-pass',\n\t\t\t\t'db-name',\n\t\t\t\t'db-path',\n\t\t\t\t'truncate-new-site-directory',\n\t\t\t\t'allow',\n\t\t\t];\n\t\t\tconst cliArgs = cliArgsToPass\n\t\t\t\t.filter((arg) => arg in args)\n\t\t\t\t.map((arg) => `--${arg}=${args[arg]}`);\n\t\t\tcliArgs.push(`--site-url=${args.siteUrl}`);\n\n\t\t\tlet afterBlueprintTargetResolvedCalled = false;\n\n\t\t\tconst streamedResponse = await runBlueprintV2({\n\t\t\t\tphp,\n\t\t\t\tblueprint: args.blueprint,\n\t\t\t\tblueprintOverrides: {\n\t\t\t\t\tadditionalSteps: args['additional-blueprint-steps'],\n\t\t\t\t\twordpressVersion: args.wp,\n\t\t\t\t},\n\t\t\t\tcliArgs,\n\t\t\t\tonMessage: async (message: BlueprintMessage) => {\n\t\t\t\t\tswitch (message.type) {\n\t\t\t\t\t\tcase 'blueprint.target_resolved': {\n\t\t\t\t\t\t\tif (!afterBlueprintTargetResolvedCalled) {\n\t\t\t\t\t\t\t\tawait mountResources(\n\t\t\t\t\t\t\t\t\tprimaryPhp,\n\t\t\t\t\t\t\t\t\targs.mount || []\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\tafterBlueprintTargetResolvedCalled = true;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcase 'blueprint.progress': {\n\t\t\t\t\t\t\tconst progressMessage = `${message.caption.trim()} – ${message.progress.toFixed(\n\t\t\t\t\t\t\t\t2\n\t\t\t\t\t\t\t)}%`;\n\t\t\t\t\t\t\toutput.progress(progressMessage);\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcase 'blueprint.error': {\n\t\t\t\t\t\t\tconst red = '\\x1b[31m';\n\t\t\t\t\t\t\tconst bold = '\\x1b[1m';\n\t\t\t\t\t\t\tconst reset = '\\x1b[0m';\n\t\t\t\t\t\t\tif (args.debug && message.details) {\n\t\t\t\t\t\t\t\toutput.stderr(\n\t\t\t\t\t\t\t\t\t`${red}${bold}Fatal error:${reset} Uncaught ${message.details.exception}: ${message.details.message}\\n` +\n\t\t\t\t\t\t\t\t\t\t` at ${message.details.file}:${message.details.line}\\n` +\n\t\t\t\t\t\t\t\t\t\t(message.details.trace\n\t\t\t\t\t\t\t\t\t\t\t? message.details.trace + '\\n'\n\t\t\t\t\t\t\t\t\t\t\t: '')\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\toutput.stderr(\n\t\t\t\t\t\t\t\t\t`${red}${bold}Error:${reset} ${message.message}\\n`\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t});\n\t\t\t/**\n\t\t\t * When we're debugging, every bit of information matters – let's immediately output\n\t\t\t * everything we get from the PHP output streams.\n\t\t\t */\n\t\t\tif (args.debug) {\n\t\t\t\tstreamedResponse!.stdout.pipeTo(\n\t\t\t\t\tnew WritableStream({\n\t\t\t\t\t\twrite(chunk) {\n\t\t\t\t\t\t\tprocess.stdout.write(chunk);\n\t\t\t\t\t\t},\n\t\t\t\t\t})\n\t\t\t\t);\n\t\t\t\tstreamedResponse!.stderr.pipeTo(\n\t\t\t\t\tnew WritableStream({\n\t\t\t\t\t\twrite(chunk) {\n\t\t\t\t\t\t\tprocess.stderr.write(chunk);\n\t\t\t\t\t\t},\n\t\t\t\t\t})\n\t\t\t\t);\n\t\t\t}\n\t\t\tawait streamedResponse!.finished;\n\t\t\tif ((await streamedResponse!.exitCode) !== 0) {\n\t\t\t\t// exitCode != 1 means the blueprint execution failed. Let's throw an error.\n\t\t\t\t// and clean up.\n\t\t\t\tconst syncResponse = await PHPResponse.fromStreamedResponse(\n\t\t\t\t\tstreamedResponse\n\t\t\t\t);\n\t\t\t\tthrow new PHPExecutionFailureError(\n\t\t\t\t\t`PHP.run() failed with exit code ${syncResponse.exitCode}.`,\n\t\t\t\t\tsyncResponse,\n\t\t\t\t\t'request'\n\t\t\t\t);\n\t\t\t}\n\t\t} catch (error) {\n\t\t\t// Capture the PHP error log details to provide more context for debugging.\n\t\t\tlet phpLogs = '';\n\t\t\ttry {\n\t\t\t\t// @TODO: Don't assume errorLogPath starts with /wordpress/\n\t\t\t\t// ...or maybe we can assume that in Playground CLI?\n\t\t\t\tphpLogs = php.readFileAsText(errorLogPath);\n\t\t\t} catch {\n\t\t\t\t// Ignore errors reading the PHP error log.\n\t\t\t}\n\t\t\t(error as any).phpLogs = phpLogs;\n\t\t\tthrow error;\n\t\t} finally {\n\t\t\treap();\n\t\t\tunmountCwd();\n\t\t}\n\t}\n\n\tasync bootRequestHandler({\n\t\tsiteUrl,\n\t\tallow,\n\t\tphp,\n\t\tfirstProcessId,\n\t\tprocessIdSpaceLength,\n\t\ttrace,\n\t}: WorkerBootRequestHandlerOptions) {\n\t\tif (this.booted) {\n\t\t\tthrow new Error('Playground already booted');\n\t\t}\n\t\tthis.booted = true;\n\n\t\tlet nextProcessId = firstProcessId;\n\t\tconst lastProcessId = firstProcessId + processIdSpaceLength - 1;\n\n\t\ttry {\n\t\t\tconst constants: Record<string, string | number | boolean | null> =\n\t\t\t\t{\n\t\t\t\t\tWP_DEBUG: true,\n\t\t\t\t\tWP_DEBUG_LOG: true,\n\t\t\t\t\tWP_DEBUG_DISPLAY: false,\n\t\t\t\t};\n\n\t\t\tconst requestHandler = await bootRequestHandler({\n\t\t\t\tsiteUrl,\n\t\t\t\tcreatePhpRuntime: async () => {\n\t\t\t\t\tconst processId = nextProcessId;\n\n\t\t\t\t\tif (nextProcessId < lastProcessId) {\n\t\t\t\t\t\tnextProcessId++;\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// We've reached the end of the process ID space. Start over.\n\t\t\t\t\t\tnextProcessId = firstProcessId;\n\t\t\t\t\t}\n\n\t\t\t\t\treturn await loadNodeRuntime(php!, {\n\t\t\t\t\t\temscriptenOptions: {\n\t\t\t\t\t\t\tfileLockManager: this.fileLockManager!,\n\t\t\t\t\t\t\tprocessId,\n\t\t\t\t\t\t\ttrace: trace ? tracePhpWasm : undefined,\n\t\t\t\t\t\t\tENV: {\n\t\t\t\t\t\t\t\tDOCROOT: '/wordpress',\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t\tfollowSymlinks: allow?.includes('follow-symlinks'),\n\t\t\t\t\t});\n\t\t\t\t},\n\t\t\t\tsapiName: 'cli',\n\t\t\t\tcreateFiles: {\n\t\t\t\t\t'/internal/shared/ca-bundle.crt':\n\t\t\t\t\t\trootCertificates.join('\\n'),\n\t\t\t\t},\n\t\t\t\tconstants,\n\t\t\t\tphpIniEntries: {\n\t\t\t\t\t'openssl.cafile': '/internal/shared/ca-bundle.crt',\n\t\t\t\t},\n\t\t\t\tcookieStore: false,\n\t\t\t\tspawnHandler: sandboxedSpawnHandlerFactory,\n\t\t\t});\n\t\t\tthis.__internal_setRequestHandler(requestHandler);\n\n\t\t\tconst primaryPhp = await requestHandler.getPrimaryPhp();\n\t\t\tawait this.setPrimaryPHP(primaryPhp);\n\n\t\t\tsetApiReady();\n\t\t} catch (e) {\n\t\t\tsetAPIError(e as Error);\n\t\t\tthrow e;\n\t\t}\n\t}\n\n\t// Provide a named disposal method that can be invoked via comlink.\n\tasync dispose() {\n\t\tawait this[Symbol.asyncDispose]();\n\t}\n}\n\nconst phpChannel = new MessageChannel();\n\nconst [setApiReady, setAPIError] = exposeAPI(\n\tnew PlaygroundCliBlueprintV2Worker(new EmscriptenDownloadMonitor()),\n\tundefined,\n\tphpChannel.port1\n);\n\nparentPort!.postMessage(\n\t{\n\t\tcommand: 'worker-script-initialized',\n\t\tphpPort: phpChannel.port2,\n\t},\n\t[phpChannel.port2 as any]\n);\n"],"names":["getV2Runner","data","v2_runner_url","path","readFile","parseBlueprintDeclaration","source","runBlueprintV2","options","cliArgs","arg","php","onMessage","file","parsedBlueprintDeclaration","blueprintReference","unbindMessageListener","message","parsed","resolve","e","logger","phpVar","streamedResponse","mountResources","mounts","mount","createNodeFsMountHandler","output","tracePhpWasm","processId","format","args","sprintf","PlaygroundCliBlueprintV2Worker","PHPWorker","monitor","port","jspi","consumeAPI","consumeAPISync","primaryPhp","requestHandler","reap","unmountCwd","blueprintPath","existsSync","afterBlueprintTargetResolvedCalled","progressMessage","red","bold","reset","chunk","syncResponse","PHPResponse","PHPExecutionFailureError","error","phpLogs","errorLogPath","siteUrl","allow","firstProcessId","processIdSpaceLength","trace","nextProcessId","lastProcessId","constants","bootRequestHandler","loadNodeRuntime","rootCertificates","sandboxedSpawnHandlerFactory","setApiReady","setAPIError","phpChannel","MessageChannel","exposeAPI","EmscriptenDownloadMonitor","parentPort"],"mappings":";;;;;;;;;;;AAAA,eAAsBA,IAA6B;AAClD,MAAIC,IAAO;AAWX,QAAMC,KAAiB,MAAM,OAAO,0BAAkC,GACpE;AAKF,MAAI,OAAO,UAAY,OAAe,QAAQ,UAAU,MAAM;AAC7D,QAAIC,IAAOD;AACP,IAAAC,EAAK,WAAW,OAAO,MACnBA,IAAAA,EAAK,MAAM,CAAa,IAE5BA,EAAK,WAAW,SAAS,MACrBA,IAAAA,EAAK,MAAM,CAAgB;AAGnC,UAAM,EAAE,UAAAC,EAAA,IAAa,MAAM,OAAO,kBAAkB;AAC7C,IAAAH,IAAA,MAAMG,EAASD,CAAI;AAAA,EAAA;AAGnB,IAAAF,IAAA,OADU,MAAM,MAAMC,CAAa,GACpB,KAAK;AAE5B,SAAO,IAAI,KAAK,CAACD,CAAI,GAAG,mBAAmB;AAAA,IAC1C,MAA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AAA,KAAK,OAAO,YAAY,EAAE;AAAA,EAAA;AAElC;AAEA,MAAMqD,IAAa,IAAIC,EAAe,GAEhC,CAACH,GAAaC,CAAW,IAAIG;AAAA,EAClC,IAAIzC,EAA+B,IAAI0C,GAA2B;AAAA,EAClE;AAAA,EACAH,EAAW;AACZ;AAEAI,EAAY;AAAA,EACX;AAAA,IACC,SAAS;AAAA,IACT,SAASJ,EAAW;AAAA,EACrB;AAAA,EACA,CAACA,EAAW,KAAY;AACzB;"}
|
package/cli-auto-mount.d.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import type { StepDefinition } from '@wp-playground/blueprints';
|
|
2
|
-
import type { RunCLIArgs } from './run-cli';
|
|
3
|
-
import type { Mount } from './mount';
|
|
4
|
-
export declare function expandAutoMounts(args: RunCLIArgs): RunCLIArgs;
|
|
5
|
-
export declare function containsFullWordPressInstallation(path: string): boolean;
|
|
6
|
-
export declare function containsWpContentDirectories(path: string): boolean;
|
|
7
|
-
export declare function isThemeDirectory(path: string): boolean;
|
|
8
|
-
export declare function isPluginDirectory(path: string): boolean;
|
|
9
|
-
/**
|
|
10
|
-
* Returns a list of files and directories in the wp-content directory
|
|
11
|
-
* to be mounted individually.
|
|
12
|
-
*
|
|
13
|
-
* This is needed because WordPress needs to be able to write to the
|
|
14
|
-
* wp-content directory without Playground modifying the OS filesystem.
|
|
15
|
-
*
|
|
16
|
-
* See expandAutoMounts for more details.
|
|
17
|
-
*/
|
|
18
|
-
export declare function wpContentMounts(wpContentDir: string): Mount[];
|
|
19
|
-
export declare function getSteps(path: string): StepDefinition[];
|
package/index-CddYZc1x.js
DELETED
package/index-CddYZc1x.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index-CddYZc1x.js","sources":["../../../../node_modules/wasm-feature-detect/dist/esm/index.js"],"sourcesContent":["export const bigInt=()=>(async e=>{try{return(await WebAssembly.instantiate(e)).instance.exports.b(BigInt(0))===BigInt(0)}catch(e){return!1}})(new Uint8Array([0,97,115,109,1,0,0,0,1,6,1,96,1,126,1,126,3,2,1,0,7,5,1,1,98,0,0,10,6,1,4,0,32,0,11])),bulkMemory=async()=>WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,5,3,1,0,1,10,14,1,12,0,65,0,65,0,65,0,252,10,0,0,11])),exceptions=async()=>WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,10,8,1,6,0,6,64,25,11,11])),exceptionsFinal=()=>(async()=>{try{return new WebAssembly.Module(Uint8Array.from(atob(\"AGFzbQEAAAABBAFgAAADAgEAChABDgACaR9AAQMAAAsACxoL\"),(e=>e.codePointAt(0)))),!0}catch(e){return!1}})(),extendedConst=async()=>WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,5,3,1,0,1,11,9,1,0,65,1,65,2,106,11,0])),gc=()=>(async()=>WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,5,1,95,1,120,0])))(),jsStringBuiltins=()=>(async()=>{try{return await WebAssembly.instantiate(Uint8Array.from(atob(\"AGFzbQEAAAABBgFgAW8BfwIXAQ53YXNtOmpzLXN0cmluZwR0ZXN0AAA=\"),(e=>e.codePointAt(0))),{},{builtins:[\"js-string\"]}),!0}catch(e){return!1}})(),jspi=()=>(async()=>\"Suspending\"in WebAssembly)(),memory64=async()=>WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,5,3,1,4,1])),multiMemory=()=>(async()=>{try{return new WebAssembly.Module(new Uint8Array([0,97,115,109,1,0,0,0,5,5,2,0,0,0,0])),!0}catch(e){return!1}})(),multiValue=async()=>WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,6,1,96,0,2,127,127,3,2,1,0,10,8,1,6,0,65,0,65,0,11])),mutableGlobals=async()=>WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,2,8,1,1,97,1,98,3,127,1,6,6,1,127,1,65,0,11,7,5,1,1,97,3,1])),referenceTypes=async()=>WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,10,7,1,5,0,208,112,26,11])),relaxedSimd=async()=>WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,5,1,96,0,1,123,3,2,1,0,10,15,1,13,0,65,1,253,15,65,2,253,15,253,128,2,11])),saturatedFloatToInt=async()=>WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,10,12,1,10,0,67,0,0,0,0,252,0,26,11])),signExtensions=async()=>WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,10,8,1,6,0,65,0,192,26,11])),simd=async()=>WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,5,1,96,0,1,123,3,2,1,0,10,10,1,8,0,65,0,253,15,253,98,11])),streamingCompilation=()=>(async()=>\"compileStreaming\"in WebAssembly)(),tailCall=async()=>WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,10,6,1,4,0,18,0,11])),threads=()=>(async e=>{try{return\"undefined\"!=typeof MessageChannel&&(new MessageChannel).port1.postMessage(new SharedArrayBuffer(1)),WebAssembly.validate(e)}catch(e){return!1}})(new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,5,4,1,3,1,1,10,11,1,9,0,65,0,254,16,2,0,26,11])),typeReflection=()=>(async()=>\"Function\"in WebAssembly)(),typedFunctionReferences=()=>(async()=>{try{return new WebAssembly.Module(Uint8Array.from(atob(\"AGFzbQEAAAABEANgAX8Bf2ABZAABf2AAAX8DBAMBAAIJBQEDAAEBChwDCwBBCkEqIAAUAGoLBwAgAEEBagsGANIBEAAL\"),(e=>e.codePointAt(0)))),!0}catch(e){return!1}})();\n"],"names":["jspi"],"mappings":"AAAY,MAAmoCA,IAAK,OAAK,YAAS,gBAAe,aAAc;","x_google_ignoreList":[0]}
|
package/index-CyPmrjJv.cjs
DELETED
package/index-CyPmrjJv.cjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index-CyPmrjJv.cjs","sources":["../../../../node_modules/wasm-feature-detect/dist/esm/index.js"],"sourcesContent":["export const bigInt=()=>(async e=>{try{return(await WebAssembly.instantiate(e)).instance.exports.b(BigInt(0))===BigInt(0)}catch(e){return!1}})(new Uint8Array([0,97,115,109,1,0,0,0,1,6,1,96,1,126,1,126,3,2,1,0,7,5,1,1,98,0,0,10,6,1,4,0,32,0,11])),bulkMemory=async()=>WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,5,3,1,0,1,10,14,1,12,0,65,0,65,0,65,0,252,10,0,0,11])),exceptions=async()=>WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,10,8,1,6,0,6,64,25,11,11])),exceptionsFinal=()=>(async()=>{try{return new WebAssembly.Module(Uint8Array.from(atob(\"AGFzbQEAAAABBAFgAAADAgEAChABDgACaR9AAQMAAAsACxoL\"),(e=>e.codePointAt(0)))),!0}catch(e){return!1}})(),extendedConst=async()=>WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,5,3,1,0,1,11,9,1,0,65,1,65,2,106,11,0])),gc=()=>(async()=>WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,5,1,95,1,120,0])))(),jsStringBuiltins=()=>(async()=>{try{return await WebAssembly.instantiate(Uint8Array.from(atob(\"AGFzbQEAAAABBgFgAW8BfwIXAQ53YXNtOmpzLXN0cmluZwR0ZXN0AAA=\"),(e=>e.codePointAt(0))),{},{builtins:[\"js-string\"]}),!0}catch(e){return!1}})(),jspi=()=>(async()=>\"Suspending\"in WebAssembly)(),memory64=async()=>WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,5,3,1,4,1])),multiMemory=()=>(async()=>{try{return new WebAssembly.Module(new Uint8Array([0,97,115,109,1,0,0,0,5,5,2,0,0,0,0])),!0}catch(e){return!1}})(),multiValue=async()=>WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,6,1,96,0,2,127,127,3,2,1,0,10,8,1,6,0,65,0,65,0,11])),mutableGlobals=async()=>WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,2,8,1,1,97,1,98,3,127,1,6,6,1,127,1,65,0,11,7,5,1,1,97,3,1])),referenceTypes=async()=>WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,10,7,1,5,0,208,112,26,11])),relaxedSimd=async()=>WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,5,1,96,0,1,123,3,2,1,0,10,15,1,13,0,65,1,253,15,65,2,253,15,253,128,2,11])),saturatedFloatToInt=async()=>WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,10,12,1,10,0,67,0,0,0,0,252,0,26,11])),signExtensions=async()=>WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,10,8,1,6,0,65,0,192,26,11])),simd=async()=>WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,5,1,96,0,1,123,3,2,1,0,10,10,1,8,0,65,0,253,15,253,98,11])),streamingCompilation=()=>(async()=>\"compileStreaming\"in WebAssembly)(),tailCall=async()=>WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,10,6,1,4,0,18,0,11])),threads=()=>(async e=>{try{return\"undefined\"!=typeof MessageChannel&&(new MessageChannel).port1.postMessage(new SharedArrayBuffer(1)),WebAssembly.validate(e)}catch(e){return!1}})(new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,5,4,1,3,1,1,10,11,1,9,0,65,0,254,16,2,0,26,11])),typeReflection=()=>(async()=>\"Function\"in WebAssembly)(),typedFunctionReferences=()=>(async()=>{try{return new WebAssembly.Module(Uint8Array.from(atob(\"AGFzbQEAAAABEANgAX8Bf2ABZAABf2AAAX8DBAMBAAIJBQEDAAEBChwDCwBBCkEqIAAUAGoLBwAgAEEBagsGANIBEAAL\"),(e=>e.codePointAt(0)))),!0}catch(e){return!1}})();\n"],"names":["jspi"],"mappings":"aAAY,MAAmoCA,EAAK,KAAK,SAAS,eAAe,aAAc","x_google_ignoreList":[0]}
|