@wp-playground/blueprints 0.9.14 → 0.9.15
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/index.cjs +41 -61
- package/index.js +398 -1256
- package/package.json +2 -2
package/index.js
CHANGED
|
@@ -1,75 +1,12 @@
|
|
|
1
|
-
import "
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
}();
|
|
11
|
-
if (K === "NODE") {
|
|
12
|
-
let e = function(n) {
|
|
13
|
-
return new Promise(function(r, i) {
|
|
14
|
-
n.onload = n.onerror = function(s) {
|
|
15
|
-
n.onload = n.onerror = null, s.type === "load" ? r(n.result) : i(new Error("Failed to read the blob/file"));
|
|
16
|
-
};
|
|
17
|
-
});
|
|
18
|
-
}, t = function() {
|
|
19
|
-
const n = new Uint8Array([1, 2, 3, 4]), i = new File([n], "test").stream();
|
|
20
|
-
try {
|
|
21
|
-
return i.getReader({ mode: "byob" }), !0;
|
|
22
|
-
} catch {
|
|
23
|
-
return !1;
|
|
24
|
-
}
|
|
25
|
-
};
|
|
26
|
-
if (typeof File > "u") {
|
|
27
|
-
class n extends Blob {
|
|
28
|
-
constructor(i, s, o) {
|
|
29
|
-
super(i);
|
|
30
|
-
let a;
|
|
31
|
-
o != null && o.lastModified && (a = /* @__PURE__ */ new Date()), (!a || isNaN(a.getFullYear())) && (a = /* @__PURE__ */ new Date()), this.lastModifiedDate = a, this.lastModified = a.getMilliseconds(), this.name = s || "";
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
global.File = n;
|
|
35
|
-
}
|
|
36
|
-
typeof Blob.prototype.arrayBuffer > "u" && (Blob.prototype.arrayBuffer = function() {
|
|
37
|
-
const r = new FileReader();
|
|
38
|
-
return r.readAsArrayBuffer(this), e(r);
|
|
39
|
-
}), typeof Blob.prototype.text > "u" && (Blob.prototype.text = function() {
|
|
40
|
-
const r = new FileReader();
|
|
41
|
-
return r.readAsText(this), e(r);
|
|
42
|
-
}), (typeof Blob.prototype.stream > "u" || !t()) && (Blob.prototype.stream = function() {
|
|
43
|
-
let n = 0;
|
|
44
|
-
const r = this;
|
|
45
|
-
return new ReadableStream({
|
|
46
|
-
type: "bytes",
|
|
47
|
-
// 0.5 MB seems like a reasonable chunk size, let's adjust
|
|
48
|
-
// this if needed.
|
|
49
|
-
autoAllocateChunkSize: 512 * 1024,
|
|
50
|
-
async pull(i) {
|
|
51
|
-
const s = i.byobRequest.view, a = await r.slice(
|
|
52
|
-
n,
|
|
53
|
-
n + s.byteLength
|
|
54
|
-
).arrayBuffer(), p = new Uint8Array(a);
|
|
55
|
-
new Uint8Array(s.buffer).set(p);
|
|
56
|
-
const l = p.byteLength;
|
|
57
|
-
i.byobRequest.respond(l), n += l, n >= r.size && i.close();
|
|
58
|
-
}
|
|
59
|
-
});
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
|
-
if (K === "NODE" && typeof CustomEvent > "u") {
|
|
63
|
-
class e extends Event {
|
|
64
|
-
constructor(n, r = {}) {
|
|
65
|
-
super(n, r), this.detail = r.detail;
|
|
66
|
-
}
|
|
67
|
-
initCustomEvent() {
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
globalThis.CustomEvent = e;
|
|
71
|
-
}
|
|
72
|
-
const X = [
|
|
1
|
+
import "@php-wasm/node-polyfills";
|
|
2
|
+
import { phpVar as m, randomFilename as Y, phpVars as S, joinPaths as u, dirname as Z, randomString as X, Semaphore as J } from "@php-wasm/util";
|
|
3
|
+
import { logger as g } from "@php-wasm/logger";
|
|
4
|
+
import { isURLScoped as K, getURLScope as ee } from "@php-wasm/scopes";
|
|
5
|
+
import { unzipFile as te } from "@wp-playground/common";
|
|
6
|
+
import { cloneResponseMonitorProgress as ne, ProgressTracker as ie } from "@php-wasm/progress";
|
|
7
|
+
import { SupportedPHPExtensionsList as re, SupportedPHPExtensionBundles as I, LatestSupportedPHPVersion as se, SupportedPHPVersions as oe } from "@php-wasm/universal";
|
|
8
|
+
import ae from "/home/runner/work/wordpress-playground/wordpress-playground/node_modules/ajv/dist/ajv.js";
|
|
9
|
+
const B = [
|
|
73
10
|
"db.php",
|
|
74
11
|
"plugins/akismet",
|
|
75
12
|
"plugins/hello.php",
|
|
@@ -90,299 +27,13 @@ const X = [
|
|
|
90
27
|
"themes/twentytwentyfour",
|
|
91
28
|
"themes/twentytwentyfive",
|
|
92
29
|
"themes/twentytwentysix"
|
|
93
|
-
],
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
setTimeout(() => t(ee), e);
|
|
97
|
-
});
|
|
98
|
-
}
|
|
99
|
-
class we extends Error {
|
|
100
|
-
constructor() {
|
|
101
|
-
super("Acquiring lock timed out");
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
class $e {
|
|
105
|
-
constructor({ concurrency: t, timeout: n }) {
|
|
106
|
-
this._running = 0, this.concurrency = t, this.timeout = n, this.queue = [];
|
|
107
|
-
}
|
|
108
|
-
get remaining() {
|
|
109
|
-
return this.concurrency - this.running;
|
|
110
|
-
}
|
|
111
|
-
get running() {
|
|
112
|
-
return this._running;
|
|
113
|
-
}
|
|
114
|
-
async acquire() {
|
|
115
|
-
for (; ; )
|
|
116
|
-
if (this._running >= this.concurrency) {
|
|
117
|
-
const t = new Promise((n) => {
|
|
118
|
-
this.queue.push(n);
|
|
119
|
-
});
|
|
120
|
-
this.timeout !== void 0 ? await Promise.race([t, ge(this.timeout)]).then(
|
|
121
|
-
(n) => {
|
|
122
|
-
if (n === ee)
|
|
123
|
-
throw new we();
|
|
124
|
-
}
|
|
125
|
-
) : await t;
|
|
126
|
-
} else {
|
|
127
|
-
this._running++;
|
|
128
|
-
let t = !1;
|
|
129
|
-
return () => {
|
|
130
|
-
t || (t = !0, this._running--, this.queue.length > 0 && this.queue.shift()());
|
|
131
|
-
};
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
async run(t) {
|
|
135
|
-
const n = await this.acquire();
|
|
136
|
-
try {
|
|
137
|
-
return await t();
|
|
138
|
-
} finally {
|
|
139
|
-
n();
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
function f(...e) {
|
|
144
|
-
let t = e.join("/");
|
|
145
|
-
const n = t[0] === "/", r = t.substring(t.length - 1) === "/";
|
|
146
|
-
return t = ne(t), !t && !n && (t = "."), t && r && (t += "/"), t;
|
|
147
|
-
}
|
|
148
|
-
function te(e) {
|
|
149
|
-
if (e === "/")
|
|
150
|
-
return "/";
|
|
151
|
-
e = ne(e);
|
|
152
|
-
const t = e.lastIndexOf("/");
|
|
153
|
-
return t === -1 ? "" : t === 0 ? "/" : e.substr(0, t);
|
|
154
|
-
}
|
|
155
|
-
function ne(e) {
|
|
156
|
-
const t = e[0] === "/";
|
|
157
|
-
return e = be(
|
|
158
|
-
e.split("/").filter((n) => !!n),
|
|
159
|
-
!t
|
|
160
|
-
).join("/"), (t ? "/" : "") + e.replace(/\/$/, "");
|
|
161
|
-
}
|
|
162
|
-
function be(e, t) {
|
|
163
|
-
let n = 0;
|
|
164
|
-
for (let r = e.length - 1; r >= 0; r--) {
|
|
165
|
-
const i = e[r];
|
|
166
|
-
i === "." ? e.splice(r, 1) : i === ".." ? (e.splice(r, 1), n++) : n && (e.splice(r, 1), n--);
|
|
167
|
-
}
|
|
168
|
-
if (t)
|
|
169
|
-
for (; n; n--)
|
|
170
|
-
e.unshift("..");
|
|
171
|
-
return e;
|
|
172
|
-
}
|
|
173
|
-
function re(e = 36, t = "!@#$%^&*()_+=-[]/.,<>?") {
|
|
174
|
-
const n = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" + t;
|
|
175
|
-
let r = "";
|
|
176
|
-
for (let i = e; i > 0; --i)
|
|
177
|
-
r += n[Math.floor(Math.random() * n.length)];
|
|
178
|
-
return r;
|
|
179
|
-
}
|
|
180
|
-
function _e() {
|
|
181
|
-
return re(36, "-_");
|
|
182
|
-
}
|
|
183
|
-
function m(e) {
|
|
184
|
-
return `json_decode(base64_decode('${Pe(
|
|
185
|
-
JSON.stringify(e)
|
|
186
|
-
)}'), true)`;
|
|
187
|
-
}
|
|
188
|
-
function L(e) {
|
|
189
|
-
const t = {};
|
|
190
|
-
for (const n in e)
|
|
191
|
-
t[n] = m(e[n]);
|
|
192
|
-
return t;
|
|
193
|
-
}
|
|
194
|
-
function Pe(e) {
|
|
195
|
-
return Ee(new TextEncoder().encode(e));
|
|
196
|
-
}
|
|
197
|
-
function Ee(e) {
|
|
198
|
-
const t = String.fromCodePoint(...e);
|
|
199
|
-
return btoa(t);
|
|
200
|
-
}
|
|
201
|
-
const ve = "playground-log", G = (e, ...t) => {
|
|
202
|
-
g.dispatchEvent(
|
|
203
|
-
new CustomEvent(ve, {
|
|
204
|
-
detail: {
|
|
205
|
-
log: e,
|
|
206
|
-
args: t
|
|
207
|
-
}
|
|
208
|
-
})
|
|
209
|
-
);
|
|
210
|
-
}, Te = (e, ...t) => {
|
|
211
|
-
switch (typeof e.message == "string" ? e.message = F(e.message) : e.message.message && typeof e.message.message == "string" && (e.message.message = F(e.message.message)), e.severity) {
|
|
212
|
-
case "Debug":
|
|
213
|
-
console.debug(e.message, ...t);
|
|
214
|
-
break;
|
|
215
|
-
case "Info":
|
|
216
|
-
console.info(e.message, ...t);
|
|
217
|
-
break;
|
|
218
|
-
case "Warn":
|
|
219
|
-
console.warn(e.message, ...t);
|
|
220
|
-
break;
|
|
221
|
-
case "Error":
|
|
222
|
-
console.error(e.message, ...t);
|
|
223
|
-
break;
|
|
224
|
-
case "Fatal":
|
|
225
|
-
console.error(e.message, ...t);
|
|
226
|
-
break;
|
|
227
|
-
default:
|
|
228
|
-
console.log(e.message, ...t);
|
|
229
|
-
}
|
|
230
|
-
}, ke = (e) => e instanceof Error ? [e.message, e.stack].join(`
|
|
231
|
-
`) : JSON.stringify(e, null, 2), ie = [], V = (e) => {
|
|
232
|
-
ie.push(e);
|
|
233
|
-
}, q = (e) => {
|
|
234
|
-
if (e.raw === !0)
|
|
235
|
-
V(e.message);
|
|
236
|
-
else {
|
|
237
|
-
const t = Se(
|
|
238
|
-
typeof e.message == "object" ? ke(e.message) : e.message,
|
|
239
|
-
e.severity ?? "Info",
|
|
240
|
-
e.prefix ?? "JavaScript"
|
|
241
|
-
);
|
|
242
|
-
V(t);
|
|
243
|
-
}
|
|
244
|
-
};
|
|
245
|
-
class Re extends EventTarget {
|
|
246
|
-
// constructor
|
|
247
|
-
constructor(t = []) {
|
|
248
|
-
super(), this.handlers = t, this.fatalErrorEvent = "playground-fatal-error";
|
|
249
|
-
}
|
|
250
|
-
/**
|
|
251
|
-
* Get all logs.
|
|
252
|
-
* @returns string[]
|
|
253
|
-
*/
|
|
254
|
-
getLogs() {
|
|
255
|
-
return this.handlers.includes(q) ? [...ie] : (this.error(`Logs aren't stored because the logToMemory handler isn't registered.
|
|
256
|
-
If you're using a custom logger instance, make sure to register logToMemory handler.
|
|
257
|
-
`), []);
|
|
258
|
-
}
|
|
259
|
-
/**
|
|
260
|
-
* Log message with severity.
|
|
261
|
-
*
|
|
262
|
-
* @param message any
|
|
263
|
-
* @param severity LogSeverity
|
|
264
|
-
* @param raw boolean
|
|
265
|
-
* @param args any
|
|
266
|
-
*/
|
|
267
|
-
logMessage(t, ...n) {
|
|
268
|
-
for (const r of this.handlers)
|
|
269
|
-
r(t, ...n);
|
|
270
|
-
}
|
|
271
|
-
/**
|
|
272
|
-
* Log message
|
|
273
|
-
*
|
|
274
|
-
* @param message any
|
|
275
|
-
* @param args any
|
|
276
|
-
*/
|
|
277
|
-
log(t, ...n) {
|
|
278
|
-
this.logMessage(
|
|
279
|
-
{
|
|
280
|
-
message: t,
|
|
281
|
-
severity: void 0,
|
|
282
|
-
prefix: "JavaScript",
|
|
283
|
-
raw: !1
|
|
284
|
-
},
|
|
285
|
-
...n
|
|
286
|
-
);
|
|
287
|
-
}
|
|
288
|
-
/**
|
|
289
|
-
* Log debug message
|
|
290
|
-
*
|
|
291
|
-
* @param message any
|
|
292
|
-
* @param args any
|
|
293
|
-
*/
|
|
294
|
-
debug(t, ...n) {
|
|
295
|
-
this.logMessage(
|
|
296
|
-
{
|
|
297
|
-
message: t,
|
|
298
|
-
severity: "Debug",
|
|
299
|
-
prefix: "JavaScript",
|
|
300
|
-
raw: !1
|
|
301
|
-
},
|
|
302
|
-
...n
|
|
303
|
-
);
|
|
304
|
-
}
|
|
305
|
-
/**
|
|
306
|
-
* Log info message
|
|
307
|
-
*
|
|
308
|
-
* @param message any
|
|
309
|
-
* @param args any
|
|
310
|
-
*/
|
|
311
|
-
info(t, ...n) {
|
|
312
|
-
this.logMessage(
|
|
313
|
-
{
|
|
314
|
-
message: t,
|
|
315
|
-
severity: "Info",
|
|
316
|
-
prefix: "JavaScript",
|
|
317
|
-
raw: !1
|
|
318
|
-
},
|
|
319
|
-
...n
|
|
320
|
-
);
|
|
321
|
-
}
|
|
322
|
-
/**
|
|
323
|
-
* Log warning message
|
|
324
|
-
*
|
|
325
|
-
* @param message any
|
|
326
|
-
* @param args any
|
|
327
|
-
*/
|
|
328
|
-
warn(t, ...n) {
|
|
329
|
-
this.logMessage(
|
|
330
|
-
{
|
|
331
|
-
message: t,
|
|
332
|
-
severity: "Warn",
|
|
333
|
-
prefix: "JavaScript",
|
|
334
|
-
raw: !1
|
|
335
|
-
},
|
|
336
|
-
...n
|
|
337
|
-
);
|
|
338
|
-
}
|
|
339
|
-
/**
|
|
340
|
-
* Log error message
|
|
341
|
-
*
|
|
342
|
-
* @param message any
|
|
343
|
-
* @param args any
|
|
344
|
-
*/
|
|
345
|
-
error(t, ...n) {
|
|
346
|
-
this.logMessage(
|
|
347
|
-
{
|
|
348
|
-
message: t,
|
|
349
|
-
severity: "Error",
|
|
350
|
-
prefix: "JavaScript",
|
|
351
|
-
raw: !1
|
|
352
|
-
},
|
|
353
|
-
...n
|
|
354
|
-
);
|
|
355
|
-
}
|
|
356
|
-
}
|
|
357
|
-
const xe = () => {
|
|
358
|
-
try {
|
|
359
|
-
if (process.env.NODE_ENV === "test")
|
|
360
|
-
return [q, G];
|
|
361
|
-
} catch {
|
|
362
|
-
}
|
|
363
|
-
return [q, Te, G];
|
|
364
|
-
}, g = new Re(xe()), F = (e) => e.replace(/\t/g, ""), Se = (e, t, n) => {
|
|
365
|
-
const r = /* @__PURE__ */ new Date(), i = new Intl.DateTimeFormat("en-GB", {
|
|
366
|
-
year: "numeric",
|
|
367
|
-
month: "short",
|
|
368
|
-
day: "2-digit",
|
|
369
|
-
timeZone: "UTC"
|
|
370
|
-
}).format(r).replace(/ /g, "-"), s = new Intl.DateTimeFormat("en-GB", {
|
|
371
|
-
hour: "2-digit",
|
|
372
|
-
minute: "2-digit",
|
|
373
|
-
second: "2-digit",
|
|
374
|
-
hour12: !1,
|
|
375
|
-
timeZone: "UTC",
|
|
376
|
-
timeZoneName: "short"
|
|
377
|
-
}).format(r), o = i + " " + s;
|
|
378
|
-
return e = F(e), `[${o}] ${n} ${t}: ${e}`;
|
|
379
|
-
}, B = async (e, { pluginPath: t, pluginName: n }, r) => {
|
|
380
|
-
r == null || r.tracker.setCaption(`Activating ${n || t}`);
|
|
381
|
-
const i = await e.documentRoot, s = await e.run({
|
|
30
|
+
], x = async (e, { pluginPath: t, pluginName: n }, i) => {
|
|
31
|
+
i == null || i.tracker.setCaption(`Activating ${n || t}`);
|
|
32
|
+
const r = await e.documentRoot, s = await e.run({
|
|
382
33
|
code: `<?php
|
|
383
34
|
define( 'WP_ADMIN', true );
|
|
384
|
-
require_once( ${m(
|
|
385
|
-
require_once( ${m(
|
|
35
|
+
require_once( ${m(r)}. "/wp-load.php" );
|
|
36
|
+
require_once( ${m(r)}. "/wp-admin/includes/plugin.php" );
|
|
386
37
|
|
|
387
38
|
// Set current user to admin
|
|
388
39
|
wp_set_current_user( get_users(array('role' => 'Administrator') )[0]->ID );
|
|
@@ -417,13 +68,13 @@ const xe = () => {
|
|
|
417
68
|
throw g.debug(s), new Error(
|
|
418
69
|
`Plugin ${t} could not be activated – WordPress exited with no error. Sometimes, when $_SERVER or site options are not configured correctly, WordPress exits early with a 301 redirect. Inspect the "debug" logs in the console for more details`
|
|
419
70
|
);
|
|
420
|
-
},
|
|
71
|
+
}, N = async (e, { themeFolderName: t }, n) => {
|
|
421
72
|
n == null || n.tracker.setCaption(`Activating ${t}`);
|
|
422
|
-
const
|
|
423
|
-
if (!await e.fileExists(
|
|
73
|
+
const i = await e.documentRoot, r = `${i}/wp-content/themes/${t}`;
|
|
74
|
+
if (!await e.fileExists(r))
|
|
424
75
|
throw new Error(`
|
|
425
76
|
Couldn't activate theme ${t}.
|
|
426
|
-
Theme not found at the provided theme path: ${
|
|
77
|
+
Theme not found at the provided theme path: ${r}.
|
|
427
78
|
Check the theme path to ensure it's correct.
|
|
428
79
|
If the theme is not installed, you can install it using the installTheme step.
|
|
429
80
|
More info can be found in the Blueprint documentation: https://wordpress.github.io/wordpress-playground/blueprints-api/steps/#ActivateThemeStep
|
|
@@ -444,7 +95,7 @@ const xe = () => {
|
|
|
444
95
|
die('Theme activated successfully');
|
|
445
96
|
`,
|
|
446
97
|
env: {
|
|
447
|
-
docroot:
|
|
98
|
+
docroot: i,
|
|
448
99
|
themeFolderName: t
|
|
449
100
|
}
|
|
450
101
|
});
|
|
@@ -452,16 +103,16 @@ const xe = () => {
|
|
|
452
103
|
throw g.debug(s), new Error(
|
|
453
104
|
`Theme ${t} could not be activated – WordPress exited with no error. Sometimes, when $_SERVER or site options are not configured correctly, WordPress exits early with a 301 redirect. Inspect the "debug" logs in the console for more details`
|
|
454
105
|
);
|
|
455
|
-
},
|
|
106
|
+
}, pe = async (e, { code: t }) => await e.run({ code: t }), ce = async (e, { options: t }) => await e.run(t), D = async (e, { path: t }) => {
|
|
456
107
|
await e.unlink(t);
|
|
457
|
-
},
|
|
108
|
+
}, de = async (e, { sql: t }, n) => {
|
|
458
109
|
n == null || n.tracker.setCaption("Executing SQL Queries");
|
|
459
|
-
const
|
|
110
|
+
const i = `/tmp/${Y()}.sql`;
|
|
460
111
|
await e.writeFile(
|
|
461
|
-
|
|
112
|
+
i,
|
|
462
113
|
new Uint8Array(await t.arrayBuffer())
|
|
463
114
|
);
|
|
464
|
-
const
|
|
115
|
+
const r = await e.documentRoot, s = S({ docroot: r, sqlFilename: i }), o = await e.run({
|
|
465
116
|
code: `<?php
|
|
466
117
|
require_once ${s.docroot} . '/wp-load.php';
|
|
467
118
|
|
|
@@ -483,8 +134,8 @@ const xe = () => {
|
|
|
483
134
|
}
|
|
484
135
|
`
|
|
485
136
|
});
|
|
486
|
-
return await
|
|
487
|
-
},
|
|
137
|
+
return await D(e, { path: i }), o;
|
|
138
|
+
}, R = async (e, { request: t }) => {
|
|
488
139
|
g.warn(
|
|
489
140
|
'Deprecated: The Blueprint step "request" is deprecated and will be removed in a future release.'
|
|
490
141
|
);
|
|
@@ -494,7 +145,7 @@ const xe = () => {
|
|
|
494
145
|
`Request failed with status ${n.httpStatusCode}`
|
|
495
146
|
);
|
|
496
147
|
return n;
|
|
497
|
-
},
|
|
148
|
+
}, le = `<?php
|
|
498
149
|
|
|
499
150
|
/**
|
|
500
151
|
* Rewrites the wp-config.php file to ensure specific constants are defined
|
|
@@ -825,48 +476,48 @@ function skip_whitespace($tokens) {
|
|
|
825
476
|
}
|
|
826
477
|
return $output;
|
|
827
478
|
}
|
|
828
|
-
`,
|
|
479
|
+
`, T = async (e, { consts: t, method: n = "define-before-run" }) => {
|
|
829
480
|
switch (n) {
|
|
830
481
|
case "define-before-run":
|
|
831
|
-
await
|
|
482
|
+
await ue(e, t);
|
|
832
483
|
break;
|
|
833
484
|
case "rewrite-wp-config": {
|
|
834
|
-
const
|
|
485
|
+
const i = await e.documentRoot, r = u(i, "/wp-config.php"), s = await e.readFileAsText(r), o = await he(
|
|
835
486
|
e,
|
|
836
487
|
s,
|
|
837
488
|
t
|
|
838
489
|
);
|
|
839
|
-
await e.writeFile(
|
|
490
|
+
await e.writeFile(r, o);
|
|
840
491
|
break;
|
|
841
492
|
}
|
|
842
493
|
default:
|
|
843
494
|
throw new Error(`Invalid method: ${n}`);
|
|
844
495
|
}
|
|
845
496
|
};
|
|
846
|
-
async function
|
|
497
|
+
async function ue(e, t) {
|
|
847
498
|
for (const n in t)
|
|
848
499
|
await e.defineConstant(n, t[n]);
|
|
849
500
|
}
|
|
850
|
-
async function
|
|
501
|
+
async function he(e, t, n) {
|
|
851
502
|
await e.writeFile("/tmp/code.php", t);
|
|
852
|
-
const
|
|
503
|
+
const i = S({
|
|
853
504
|
consts: n
|
|
854
505
|
});
|
|
855
506
|
return await e.run({
|
|
856
|
-
code: `${
|
|
507
|
+
code: `${le}
|
|
857
508
|
$wp_config_path = '/tmp/code.php';
|
|
858
509
|
$wp_config = file_get_contents($wp_config_path);
|
|
859
|
-
$new_wp_config = rewrite_wp_config_to_define_constants($wp_config, ${
|
|
510
|
+
$new_wp_config = rewrite_wp_config_to_define_constants($wp_config, ${i.consts});
|
|
860
511
|
file_put_contents($wp_config_path, $new_wp_config);
|
|
861
512
|
`
|
|
862
513
|
}), await e.readFileAsText("/tmp/code.php");
|
|
863
514
|
}
|
|
864
|
-
const
|
|
865
|
-
var s, o,
|
|
866
|
-
|
|
515
|
+
const v = async (e, { username: t = "admin", password: n = "password" } = {}, i) => {
|
|
516
|
+
var s, o, c;
|
|
517
|
+
i == null || i.tracker.setCaption((i == null ? void 0 : i.initialCaption) || "Logging in"), await e.request({
|
|
867
518
|
url: "/wp-login.php"
|
|
868
519
|
});
|
|
869
|
-
const
|
|
520
|
+
const r = await e.request({
|
|
870
521
|
url: "/wp-login.php",
|
|
871
522
|
method: "POST",
|
|
872
523
|
body: {
|
|
@@ -875,14 +526,14 @@ const j = async (e, { username: t = "admin", password: n = "password" } = {}, r)
|
|
|
875
526
|
rememberme: "forever"
|
|
876
527
|
}
|
|
877
528
|
});
|
|
878
|
-
if (!((
|
|
529
|
+
if (!((c = (o = (s = r.headers) == null ? void 0 : s.location) == null ? void 0 : o[0]) != null && c.includes("/wp-admin/")))
|
|
879
530
|
throw g.warn("WordPress response was", {
|
|
880
|
-
response:
|
|
881
|
-
text:
|
|
531
|
+
response: r,
|
|
532
|
+
text: r.text
|
|
882
533
|
}), new Error(
|
|
883
534
|
`Failed to log in as ${t} with password ${n}`
|
|
884
535
|
);
|
|
885
|
-
},
|
|
536
|
+
}, M = async (e, { options: t }) => {
|
|
886
537
|
const n = await e.documentRoot;
|
|
887
538
|
await e.run({
|
|
888
539
|
code: `<?php
|
|
@@ -894,53 +545,46 @@ const j = async (e, { username: t = "admin", password: n = "password" } = {}, r)
|
|
|
894
545
|
echo "Success";
|
|
895
546
|
`
|
|
896
547
|
});
|
|
897
|
-
},
|
|
898
|
-
const
|
|
548
|
+
}, fe = async (e, { meta: t, userId: n }) => {
|
|
549
|
+
const i = await e.documentRoot;
|
|
899
550
|
await e.run({
|
|
900
551
|
code: `<?php
|
|
901
|
-
include ${m(
|
|
552
|
+
include ${m(i)} . '/wp-load.php';
|
|
902
553
|
$meta = ${m(t)};
|
|
903
554
|
foreach($meta as $name => $value) {
|
|
904
555
|
update_user_meta(${m(n)}, $name, $value);
|
|
905
556
|
}
|
|
906
557
|
`
|
|
907
558
|
});
|
|
908
|
-
}
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
}
|
|
912
|
-
function je(e) {
|
|
913
|
-
return pe(e) ? e.pathname.split("/")[1].split(":")[1] : null;
|
|
914
|
-
}
|
|
915
|
-
const Be = async (e) => {
|
|
916
|
-
var h;
|
|
917
|
-
await x(e, {
|
|
559
|
+
}, me = async (e) => {
|
|
560
|
+
var l;
|
|
561
|
+
await T(e, {
|
|
918
562
|
consts: {
|
|
919
563
|
WP_ALLOW_MULTISITE: 1
|
|
920
564
|
}
|
|
921
565
|
});
|
|
922
566
|
const t = new URL(await e.absoluteUrl);
|
|
923
567
|
if (t.port !== "") {
|
|
924
|
-
let
|
|
925
|
-
throw t.hostname === "localhost" && (
|
|
568
|
+
let w = `The current host is ${t.host}, but WordPress multisites do not support custom ports.`;
|
|
569
|
+
throw t.hostname === "localhost" && (w += " For development, you can set up a playground.test domain using the instructions at https://wordpress.github.io/wordpress-playground/contributing/code."), new Error(w);
|
|
926
570
|
}
|
|
927
|
-
const n = t.pathname.replace(/\/$/, "") + "/",
|
|
928
|
-
await
|
|
571
|
+
const n = t.pathname.replace(/\/$/, "") + "/", i = `${t.protocol}//${t.hostname}${n}`;
|
|
572
|
+
await M(e, {
|
|
929
573
|
options: {
|
|
930
|
-
siteurl:
|
|
931
|
-
home:
|
|
574
|
+
siteurl: i,
|
|
575
|
+
home: i
|
|
932
576
|
}
|
|
933
|
-
}), await
|
|
934
|
-
const
|
|
577
|
+
}), await v(e, {});
|
|
578
|
+
const r = await e.documentRoot, o = (await e.run({
|
|
935
579
|
code: `<?php
|
|
936
580
|
define( 'WP_ADMIN', true );
|
|
937
|
-
require_once(${m(
|
|
581
|
+
require_once(${m(r)} . "/wp-load.php");
|
|
938
582
|
|
|
939
583
|
// Set current user to admin
|
|
940
584
|
( get_users(array('role' => 'Administrator') )[0] );
|
|
941
585
|
|
|
942
|
-
require_once(${m(
|
|
943
|
-
$plugins_root = ${m(
|
|
586
|
+
require_once(${m(r)} . "/wp-admin/includes/plugin.php");
|
|
587
|
+
$plugins_root = ${m(r)} . "/wp-content/plugins";
|
|
944
588
|
$plugins = glob($plugins_root . "/*");
|
|
945
589
|
|
|
946
590
|
$deactivated_plugins = [];
|
|
@@ -965,21 +609,21 @@ foreach($plugins as $plugin_path) {
|
|
|
965
609
|
}
|
|
966
610
|
echo json_encode($deactivated_plugins);
|
|
967
611
|
`
|
|
968
|
-
})).json,
|
|
612
|
+
})).json, a = (l = (await R(e, {
|
|
969
613
|
request: {
|
|
970
614
|
url: "/wp-admin/network.php"
|
|
971
615
|
}
|
|
972
616
|
})).text.match(
|
|
973
617
|
/name="_wpnonce"\s+value="([^"]+)"/
|
|
974
|
-
)) == null ? void 0 :
|
|
618
|
+
)) == null ? void 0 : l[1], h = await R(e, {
|
|
975
619
|
request: {
|
|
976
620
|
url: "/wp-admin/network.php",
|
|
977
621
|
method: "POST",
|
|
978
622
|
headers: {
|
|
979
623
|
"Content-Type": "application/x-www-form-urlencoded"
|
|
980
624
|
},
|
|
981
|
-
body:
|
|
982
|
-
_wpnonce:
|
|
625
|
+
body: we({
|
|
626
|
+
_wpnonce: a,
|
|
983
627
|
_wp_http_referer: n + "wp-admin/network.php",
|
|
984
628
|
sitename: "My WordPress Website Sites",
|
|
985
629
|
email: "admin@localhost.com",
|
|
@@ -987,15 +631,15 @@ echo json_encode($deactivated_plugins);
|
|
|
987
631
|
})
|
|
988
632
|
}
|
|
989
633
|
});
|
|
990
|
-
if (
|
|
634
|
+
if (h.httpStatusCode !== 200)
|
|
991
635
|
throw g.warn("WordPress response was", {
|
|
992
|
-
response:
|
|
993
|
-
text:
|
|
994
|
-
headers:
|
|
636
|
+
response: h,
|
|
637
|
+
text: h.text,
|
|
638
|
+
headers: h.headers
|
|
995
639
|
}), new Error(
|
|
996
|
-
`Failed to enable multisite. Response code was ${
|
|
640
|
+
`Failed to enable multisite. Response code was ${h.httpStatusCode}`
|
|
997
641
|
);
|
|
998
|
-
await
|
|
642
|
+
await T(e, {
|
|
999
643
|
consts: {
|
|
1000
644
|
MULTISITE: !0,
|
|
1001
645
|
SUBDOMAIN_INSTALL: !1,
|
|
@@ -1005,11 +649,11 @@ echo json_encode($deactivated_plugins);
|
|
|
1005
649
|
PATH_CURRENT_SITE: n
|
|
1006
650
|
}
|
|
1007
651
|
});
|
|
1008
|
-
const
|
|
652
|
+
const f = new URL(await e.absoluteUrl), d = K(f) ? "scope:" + ee(f) : null;
|
|
1009
653
|
await e.writeFile(
|
|
1010
654
|
"/internal/shared/preload/sunrise.php",
|
|
1011
655
|
`<?php
|
|
1012
|
-
$_SERVER['HTTP_HOST'] = ${m(
|
|
656
|
+
$_SERVER['HTTP_HOST'] = ${m(f.hostname)};
|
|
1013
657
|
$folder = ${m(d)};
|
|
1014
658
|
if ($folder && strpos($_SERVER['REQUEST_URI'],"/$folder") === false) {
|
|
1015
659
|
$_SERVER['REQUEST_URI'] = "/$folder/" . ltrim($_SERVER['REQUEST_URI'], '/');
|
|
@@ -1022,48 +666,48 @@ echo json_encode($deactivated_plugins);
|
|
|
1022
666
|
define( 'BLOG_ID_CURRENT_SITE', 1 );
|
|
1023
667
|
}
|
|
1024
668
|
`
|
|
1025
|
-
), await
|
|
1026
|
-
for (const
|
|
1027
|
-
await
|
|
1028
|
-
pluginPath:
|
|
669
|
+
), await v(e, {});
|
|
670
|
+
for (const w of o)
|
|
671
|
+
await x(e, {
|
|
672
|
+
pluginPath: w
|
|
1029
673
|
});
|
|
1030
674
|
};
|
|
1031
|
-
function
|
|
675
|
+
function we(e) {
|
|
1032
676
|
return Object.keys(e).map(
|
|
1033
677
|
(t) => encodeURIComponent(t) + "=" + encodeURIComponent(e[t])
|
|
1034
678
|
).join("&");
|
|
1035
679
|
}
|
|
1036
|
-
const
|
|
680
|
+
const ye = async (e, { fromPath: t, toPath: n }) => {
|
|
1037
681
|
await e.writeFile(
|
|
1038
682
|
n,
|
|
1039
683
|
await e.readFileAsBuffer(t)
|
|
1040
684
|
);
|
|
1041
|
-
},
|
|
685
|
+
}, ge = async (e, { fromPath: t, toPath: n }) => {
|
|
1042
686
|
await e.mv(t, n);
|
|
1043
|
-
},
|
|
687
|
+
}, $e = async (e, { path: t }) => {
|
|
1044
688
|
await e.mkdir(t);
|
|
1045
|
-
},
|
|
689
|
+
}, _e = async (e, { path: t }) => {
|
|
1046
690
|
await e.rmdir(t);
|
|
1047
|
-
},
|
|
691
|
+
}, H = async (e, { path: t, data: n }) => {
|
|
1048
692
|
n instanceof File && (n = new Uint8Array(await n.arrayBuffer())), t.startsWith("/wordpress/wp-content/mu-plugins") && !await e.fileExists("/wordpress/wp-content/mu-plugins") && await e.mkdir("/wordpress/wp-content/mu-plugins"), await e.writeFile(t, n);
|
|
1049
|
-
},
|
|
1050
|
-
await
|
|
693
|
+
}, z = async (e, { siteUrl: t }) => {
|
|
694
|
+
await T(e, {
|
|
1051
695
|
consts: {
|
|
1052
696
|
WP_HOME: t,
|
|
1053
697
|
WP_SITEURL: t
|
|
1054
698
|
}
|
|
1055
699
|
});
|
|
1056
|
-
},
|
|
1057
|
-
var
|
|
1058
|
-
(
|
|
700
|
+
}, be = async (e, { file: t }, n) => {
|
|
701
|
+
var r;
|
|
702
|
+
(r = n == null ? void 0 : n.tracker) == null || r.setCaption("Importing content"), await H(e, {
|
|
1059
703
|
path: "/tmp/import.wxr",
|
|
1060
704
|
data: t
|
|
1061
705
|
});
|
|
1062
|
-
const
|
|
706
|
+
const i = await e.documentRoot;
|
|
1063
707
|
await e.run({
|
|
1064
708
|
code: `<?php
|
|
1065
|
-
require ${m(
|
|
1066
|
-
require ${m(
|
|
709
|
+
require ${m(i)} . '/wp-load.php';
|
|
710
|
+
require ${m(i)} . '/wp-admin/includes/admin.php';
|
|
1067
711
|
|
|
1068
712
|
kses_remove_filters();
|
|
1069
713
|
$admin_id = get_users(array('role' => 'Administrator') )[0]->ID;
|
|
@@ -1083,194 +727,162 @@ const De = async (e, { fromPath: t, toPath: n }) => {
|
|
|
1083
727
|
$result = $importer->import( '/tmp/import.wxr' );
|
|
1084
728
|
`
|
|
1085
729
|
});
|
|
1086
|
-
},
|
|
1087
|
-
if (t instanceof File) {
|
|
1088
|
-
const i = t;
|
|
1089
|
-
t = O, await e.writeFile(
|
|
1090
|
-
t,
|
|
1091
|
-
new Uint8Array(await i.arrayBuffer())
|
|
1092
|
-
);
|
|
1093
|
-
}
|
|
1094
|
-
const r = L({
|
|
1095
|
-
zipPath: t,
|
|
1096
|
-
extractToPath: n
|
|
1097
|
-
});
|
|
1098
|
-
await e.run({
|
|
1099
|
-
code: `<?php
|
|
1100
|
-
function unzip($zipPath, $extractTo, $overwrite = true)
|
|
1101
|
-
{
|
|
1102
|
-
if (!is_dir($extractTo)) {
|
|
1103
|
-
mkdir($extractTo, 0777, true);
|
|
1104
|
-
}
|
|
1105
|
-
$zip = new ZipArchive;
|
|
1106
|
-
$res = $zip->open($zipPath);
|
|
1107
|
-
if ($res === TRUE) {
|
|
1108
|
-
$zip->extractTo($extractTo);
|
|
1109
|
-
$zip->close();
|
|
1110
|
-
chmod($extractTo, 0777);
|
|
1111
|
-
} else {
|
|
1112
|
-
throw new Exception("Could not unzip file");
|
|
1113
|
-
}
|
|
1114
|
-
}
|
|
1115
|
-
unzip(${r.zipPath}, ${r.extractToPath});
|
|
1116
|
-
`
|
|
1117
|
-
}), await e.fileExists(O) && await e.unlink(O);
|
|
1118
|
-
}, N = async (e, { zipFile: t, zipPath: n, extractToPath: r }) => {
|
|
730
|
+
}, L = async (e, { zipFile: t, zipPath: n, extractToPath: i }) => {
|
|
1119
731
|
if (n)
|
|
1120
732
|
g.warn(
|
|
1121
733
|
'The "zipPath" option of the unzip() Blueprint step is deprecated and will be removed. Use "zipFile" instead.'
|
|
1122
734
|
);
|
|
1123
735
|
else if (!t)
|
|
1124
736
|
throw new Error("Either zipPath or zipFile must be provided");
|
|
1125
|
-
await
|
|
1126
|
-
},
|
|
1127
|
-
const
|
|
1128
|
-
let
|
|
1129
|
-
await e.mkdir(
|
|
737
|
+
await te(e, t || n, i);
|
|
738
|
+
}, Pe = async (e, { wordPressFilesZip: t, pathInZip: n = "" }) => {
|
|
739
|
+
const i = await e.documentRoot;
|
|
740
|
+
let r = u("/tmp", "import");
|
|
741
|
+
await e.mkdir(r), await L(e, {
|
|
1130
742
|
zipFile: t,
|
|
1131
|
-
extractToPath:
|
|
1132
|
-
}),
|
|
1133
|
-
const s =
|
|
1134
|
-
for (const
|
|
1135
|
-
const d =
|
|
743
|
+
extractToPath: r
|
|
744
|
+
}), r = u(r, n);
|
|
745
|
+
const s = u(r, "wp-content"), o = u(i, "wp-content");
|
|
746
|
+
for (const f of B) {
|
|
747
|
+
const d = u(
|
|
1136
748
|
s,
|
|
1137
|
-
|
|
749
|
+
f
|
|
1138
750
|
);
|
|
1139
|
-
await
|
|
1140
|
-
const
|
|
1141
|
-
await e.fileExists(
|
|
751
|
+
await U(e, d);
|
|
752
|
+
const l = u(o, f);
|
|
753
|
+
await e.fileExists(l) && (await e.mkdir(Z(d)), await e.mv(l, d));
|
|
1142
754
|
}
|
|
1143
|
-
const
|
|
1144
|
-
|
|
755
|
+
const c = u(
|
|
756
|
+
r,
|
|
1145
757
|
"wp-content",
|
|
1146
758
|
"database"
|
|
1147
759
|
);
|
|
1148
|
-
await e.fileExists(
|
|
1149
|
-
|
|
1150
|
-
|
|
760
|
+
await e.fileExists(c) || await e.mv(
|
|
761
|
+
u(i, "wp-content", "database"),
|
|
762
|
+
c
|
|
1151
763
|
);
|
|
1152
|
-
const
|
|
1153
|
-
for (const
|
|
1154
|
-
await
|
|
1155
|
-
|
|
1156
|
-
|
|
764
|
+
const a = await e.listFiles(r);
|
|
765
|
+
for (const f of a)
|
|
766
|
+
await U(e, u(i, f)), await e.mv(
|
|
767
|
+
u(r, f),
|
|
768
|
+
u(i, f)
|
|
1157
769
|
);
|
|
1158
|
-
await e.rmdir(
|
|
770
|
+
await e.rmdir(r), await z(e, {
|
|
1159
771
|
siteUrl: await e.absoluteUrl
|
|
1160
772
|
});
|
|
1161
|
-
const
|
|
1162
|
-
|
|
773
|
+
const h = m(
|
|
774
|
+
u(i, "wp-admin", "upgrade.php")
|
|
1163
775
|
);
|
|
1164
776
|
await e.run({
|
|
1165
777
|
code: `<?php
|
|
1166
778
|
$_GET['step'] = 'upgrade_db';
|
|
1167
|
-
require ${
|
|
779
|
+
require ${h};
|
|
1168
780
|
`
|
|
1169
781
|
});
|
|
1170
782
|
};
|
|
1171
|
-
async function
|
|
783
|
+
async function U(e, t) {
|
|
1172
784
|
await e.fileExists(t) && (await e.isDir(t) ? await e.rmdir(t) : await e.unlink(t));
|
|
1173
785
|
}
|
|
1174
|
-
async function
|
|
786
|
+
async function Ee(e) {
|
|
1175
787
|
const t = await e.request({
|
|
1176
788
|
url: "/wp-admin/export.php?download=true&content=all"
|
|
1177
789
|
});
|
|
1178
790
|
return new File([t.bytes], "export.xml");
|
|
1179
791
|
}
|
|
1180
|
-
async function
|
|
792
|
+
async function G(e, {
|
|
1181
793
|
targetPath: t,
|
|
1182
794
|
zipFile: n,
|
|
1183
|
-
ifAlreadyInstalled:
|
|
795
|
+
ifAlreadyInstalled: i = "overwrite"
|
|
1184
796
|
}) {
|
|
1185
|
-
const s = n.name.replace(/\.zip$/, ""), o =
|
|
1186
|
-
await e.fileExists(
|
|
797
|
+
const s = n.name.replace(/\.zip$/, ""), o = u(await e.documentRoot, "wp-content"), c = u(o, X()), a = u(c, "assets", s);
|
|
798
|
+
await e.fileExists(a) && await e.rmdir(c, {
|
|
1187
799
|
recursive: !0
|
|
1188
|
-
}), await e.mkdir(
|
|
800
|
+
}), await e.mkdir(c);
|
|
1189
801
|
try {
|
|
1190
|
-
await
|
|
802
|
+
await L(e, {
|
|
1191
803
|
zipFile: n,
|
|
1192
|
-
extractToPath:
|
|
804
|
+
extractToPath: a
|
|
1193
805
|
});
|
|
1194
|
-
let
|
|
806
|
+
let h = await e.listFiles(a, {
|
|
1195
807
|
prependPath: !0
|
|
1196
808
|
});
|
|
1197
|
-
|
|
1198
|
-
const
|
|
1199
|
-
let d,
|
|
1200
|
-
|
|
1201
|
-
const
|
|
1202
|
-
if (await e.fileExists(
|
|
1203
|
-
if (!await e.isDir(
|
|
809
|
+
h = h.filter((P) => !P.endsWith("/__MACOSX"));
|
|
810
|
+
const f = h.length === 1 && await e.isDir(h[0]);
|
|
811
|
+
let d, l = "";
|
|
812
|
+
f ? (l = h[0], d = h[0].split("/").pop()) : (l = a, d = s);
|
|
813
|
+
const w = `${t}/${d}`;
|
|
814
|
+
if (await e.fileExists(w)) {
|
|
815
|
+
if (!await e.isDir(w))
|
|
1204
816
|
throw new Error(
|
|
1205
|
-
`Cannot install asset ${d} to ${
|
|
817
|
+
`Cannot install asset ${d} to ${w} because a file with the same name already exists. Note it's a file, not a directory! Is this by mistake?`
|
|
1206
818
|
);
|
|
1207
|
-
if (
|
|
1208
|
-
await e.rmdir(
|
|
819
|
+
if (i === "overwrite")
|
|
820
|
+
await e.rmdir(w, {
|
|
1209
821
|
recursive: !0
|
|
1210
822
|
});
|
|
1211
823
|
else {
|
|
1212
|
-
if (
|
|
824
|
+
if (i === "skip")
|
|
1213
825
|
return {
|
|
1214
|
-
assetFolderPath:
|
|
826
|
+
assetFolderPath: w,
|
|
1215
827
|
assetFolderName: d
|
|
1216
828
|
};
|
|
1217
829
|
throw new Error(
|
|
1218
|
-
`Cannot install asset ${d} to ${t} because it already exists and the ifAlreadyInstalled option was set to ${
|
|
830
|
+
`Cannot install asset ${d} to ${t} because it already exists and the ifAlreadyInstalled option was set to ${i}`
|
|
1219
831
|
);
|
|
1220
832
|
}
|
|
1221
833
|
}
|
|
1222
|
-
return await e.mv(
|
|
1223
|
-
assetFolderPath:
|
|
834
|
+
return await e.mv(l, w), {
|
|
835
|
+
assetFolderPath: w,
|
|
1224
836
|
assetFolderName: d
|
|
1225
837
|
};
|
|
1226
838
|
} finally {
|
|
1227
|
-
await e.rmdir(
|
|
839
|
+
await e.rmdir(c, {
|
|
1228
840
|
recursive: !0
|
|
1229
841
|
});
|
|
1230
842
|
}
|
|
1231
843
|
}
|
|
1232
|
-
function
|
|
844
|
+
function k(e) {
|
|
1233
845
|
const t = e.split(".").shift().replace(/-/g, " ");
|
|
1234
846
|
return t.charAt(0).toUpperCase() + t.slice(1).toLowerCase();
|
|
1235
847
|
}
|
|
1236
|
-
const
|
|
1237
|
-
const s = t.name.split("/").pop() || "plugin.zip", o =
|
|
1238
|
-
|
|
1239
|
-
const { assetFolderPath:
|
|
848
|
+
const Te = async (e, { pluginZipFile: t, ifAlreadyInstalled: n, options: i = {} }, r) => {
|
|
849
|
+
const s = t.name.split("/").pop() || "plugin.zip", o = k(s);
|
|
850
|
+
r == null || r.tracker.setCaption(`Installing the ${o} plugin`);
|
|
851
|
+
const { assetFolderPath: c } = await G(e, {
|
|
1240
852
|
ifAlreadyInstalled: n,
|
|
1241
853
|
zipFile: t,
|
|
1242
854
|
targetPath: `${await e.documentRoot}/wp-content/plugins`
|
|
1243
855
|
});
|
|
1244
|
-
("activate" in
|
|
856
|
+
("activate" in i ? i.activate : !0) && await x(
|
|
1245
857
|
e,
|
|
1246
858
|
{
|
|
1247
|
-
pluginPath:
|
|
859
|
+
pluginPath: c,
|
|
1248
860
|
pluginName: o
|
|
1249
861
|
},
|
|
1250
|
-
|
|
862
|
+
r
|
|
1251
863
|
);
|
|
1252
|
-
},
|
|
1253
|
-
const s =
|
|
1254
|
-
|
|
1255
|
-
const { assetFolderName: o } = await
|
|
864
|
+
}, ke = async (e, { themeZipFile: t, ifAlreadyInstalled: n, options: i = {} }, r) => {
|
|
865
|
+
const s = k(t.name);
|
|
866
|
+
r == null || r.tracker.setCaption(`Installing the ${s} theme`);
|
|
867
|
+
const { assetFolderName: o } = await G(e, {
|
|
1256
868
|
ifAlreadyInstalled: n,
|
|
1257
869
|
zipFile: t,
|
|
1258
870
|
targetPath: `${await e.documentRoot}/wp-content/themes`
|
|
1259
871
|
});
|
|
1260
|
-
("activate" in
|
|
872
|
+
("activate" in i ? i.activate : !0) && await N(
|
|
1261
873
|
e,
|
|
1262
874
|
{
|
|
1263
875
|
themeFolderName: o
|
|
1264
876
|
},
|
|
1265
|
-
|
|
877
|
+
r
|
|
1266
878
|
);
|
|
1267
|
-
},
|
|
1268
|
-
var
|
|
1269
|
-
(
|
|
1270
|
-
const
|
|
879
|
+
}, Re = async (e, t, n) => {
|
|
880
|
+
var r;
|
|
881
|
+
(r = n == null ? void 0 : n.tracker) == null || r.setCaption("Resetting WordPress data");
|
|
882
|
+
const i = await e.documentRoot;
|
|
1271
883
|
await e.run({
|
|
1272
884
|
env: {
|
|
1273
|
-
DOCROOT:
|
|
885
|
+
DOCROOT: i
|
|
1274
886
|
},
|
|
1275
887
|
code: `<?php
|
|
1276
888
|
require getenv('DOCROOT') . '/wp-load.php';
|
|
@@ -1288,7 +900,7 @@ const Qe = async (e, { pluginZipFile: t, ifAlreadyInstalled: n, options: r = {}
|
|
|
1288
900
|
$GLOBALS['@pdo']->query("UPDATE SQLITE_SEQUENCE SET SEQ=0 WHERE NAME='wp_commentmeta'");
|
|
1289
901
|
`
|
|
1290
902
|
});
|
|
1291
|
-
},
|
|
903
|
+
}, ve = async (e, { options: t }) => {
|
|
1292
904
|
await e.request({
|
|
1293
905
|
url: "/wp-admin/install.php?step=2",
|
|
1294
906
|
method: "POST",
|
|
@@ -1305,24 +917,24 @@ const Qe = async (e, { pluginZipFile: t, ifAlreadyInstalled: n, options: r = {}
|
|
|
1305
917
|
admin_email: "admin@localhost.com"
|
|
1306
918
|
}
|
|
1307
919
|
});
|
|
1308
|
-
},
|
|
1309
|
-
const n = "/tmp/wordpress-playground.zip",
|
|
1310
|
-
let s =
|
|
1311
|
-
t && (s = s.filter((
|
|
1312
|
-
(
|
|
920
|
+
}, Se = async (e, { selfContained: t = !1 } = {}) => {
|
|
921
|
+
const n = "/tmp/wordpress-playground.zip", i = await e.documentRoot, r = u(i, "wp-content");
|
|
922
|
+
let s = B;
|
|
923
|
+
t && (s = s.filter((a) => !a.startsWith("themes/twenty")).filter(
|
|
924
|
+
(a) => a !== "mu-plugins/sqlite-database-integration"
|
|
1313
925
|
));
|
|
1314
|
-
const o =
|
|
926
|
+
const o = S({
|
|
1315
927
|
zipPath: n,
|
|
1316
|
-
wpContentPath:
|
|
1317
|
-
documentRoot:
|
|
928
|
+
wpContentPath: r,
|
|
929
|
+
documentRoot: i,
|
|
1318
930
|
exceptPaths: s.map(
|
|
1319
|
-
(
|
|
931
|
+
(a) => u(i, "wp-content", a)
|
|
1320
932
|
),
|
|
1321
933
|
additionalPaths: t ? {
|
|
1322
|
-
[
|
|
934
|
+
[u(i, "wp-config.php")]: "wp-config.php"
|
|
1323
935
|
} : {}
|
|
1324
936
|
});
|
|
1325
|
-
await
|
|
937
|
+
await Le(
|
|
1326
938
|
e,
|
|
1327
939
|
`zipDir(${o.wpContentPath}, ${o.zipPath}, array(
|
|
1328
940
|
'exclude_paths' => ${o.exceptPaths},
|
|
@@ -1330,9 +942,9 @@ const Qe = async (e, { pluginZipFile: t, ifAlreadyInstalled: n, options: r = {}
|
|
|
1330
942
|
'additional_paths' => ${o.additionalPaths}
|
|
1331
943
|
));`
|
|
1332
944
|
);
|
|
1333
|
-
const
|
|
1334
|
-
return e.unlink(n),
|
|
1335
|
-
},
|
|
945
|
+
const c = await e.readFileAsBuffer(n);
|
|
946
|
+
return e.unlink(n), c;
|
|
947
|
+
}, xe = `<?php
|
|
1336
948
|
|
|
1337
949
|
function zipDir($root, $output, $options = array())
|
|
1338
950
|
{
|
|
@@ -1392,16 +1004,16 @@ function join_paths()
|
|
|
1392
1004
|
return preg_replace('#/+#', '/', join('/', $paths));
|
|
1393
1005
|
}
|
|
1394
1006
|
`;
|
|
1395
|
-
async function
|
|
1007
|
+
async function Le(e, t) {
|
|
1396
1008
|
return await e.run({
|
|
1397
|
-
code:
|
|
1009
|
+
code: xe + t
|
|
1398
1010
|
});
|
|
1399
1011
|
}
|
|
1400
|
-
const
|
|
1012
|
+
const Oe = async (e, { command: t, wpCliPath: n = "/tmp/wp-cli.phar" }) => {
|
|
1401
1013
|
if (!await e.fileExists(n))
|
|
1402
1014
|
throw new Error(`wp-cli.phar not found at ${n}`);
|
|
1403
|
-
let
|
|
1404
|
-
if (typeof t == "string" ? (t = t.trim(),
|
|
1015
|
+
let i;
|
|
1016
|
+
if (typeof t == "string" ? (t = t.trim(), i = qe(t)) : i = t, i.shift() !== "wp")
|
|
1405
1017
|
throw new Error('The first argument must be "wp".');
|
|
1406
1018
|
await e.writeFile("/tmp/stdout", ""), await e.writeFile("/tmp/stderr", ""), await e.writeFile(
|
|
1407
1019
|
"/wordpress/run-cli.php",
|
|
@@ -1418,7 +1030,7 @@ const tt = async (e, { command: t, wpCliPath: n = "/tmp/wp-cli.phar" }) => {
|
|
|
1418
1030
|
$GLOBALS['argv'] = array_merge([
|
|
1419
1031
|
"/tmp/wp-cli.phar",
|
|
1420
1032
|
"--path=/wordpress"
|
|
1421
|
-
], ${m(
|
|
1033
|
+
], ${m(i)});
|
|
1422
1034
|
|
|
1423
1035
|
// Provide stdin, stdout, stderr streams outside of
|
|
1424
1036
|
// the CLI SAPI.
|
|
@@ -1436,527 +1048,57 @@ const tt = async (e, { command: t, wpCliPath: n = "/tmp/wp-cli.phar" }) => {
|
|
|
1436
1048
|
throw new Error(s.errors);
|
|
1437
1049
|
return s;
|
|
1438
1050
|
};
|
|
1439
|
-
function
|
|
1440
|
-
let
|
|
1051
|
+
function qe(e) {
|
|
1052
|
+
let i = 0, r = "";
|
|
1441
1053
|
const s = [];
|
|
1442
1054
|
let o = "";
|
|
1443
|
-
for (let
|
|
1444
|
-
const
|
|
1445
|
-
|
|
1055
|
+
for (let c = 0; c < e.length; c++) {
|
|
1056
|
+
const a = e[c];
|
|
1057
|
+
i === 0 ? a === '"' || a === "'" ? (i = 1, r = a) : a.match(/\s/) ? (o && s.push(o), o = "") : o += a : i === 1 && (a === "\\" ? (c++, o += e[c]) : a === r ? (i = 0, r = "") : o += a);
|
|
1446
1058
|
}
|
|
1447
1059
|
return o && s.push(o), s;
|
|
1448
1060
|
}
|
|
1449
|
-
const
|
|
1061
|
+
const je = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
1450
1062
|
__proto__: null,
|
|
1451
|
-
activatePlugin:
|
|
1452
|
-
activateTheme:
|
|
1453
|
-
cp:
|
|
1454
|
-
defineSiteUrl:
|
|
1455
|
-
defineWpConfigConsts:
|
|
1456
|
-
enableMultisite:
|
|
1457
|
-
exportWXR:
|
|
1458
|
-
importWordPressFiles:
|
|
1459
|
-
importWxr:
|
|
1460
|
-
installPlugin:
|
|
1461
|
-
installTheme:
|
|
1462
|
-
login:
|
|
1463
|
-
mkdir:
|
|
1464
|
-
mv:
|
|
1465
|
-
request:
|
|
1466
|
-
resetData:
|
|
1467
|
-
rm:
|
|
1468
|
-
rmdir:
|
|
1469
|
-
runPHP:
|
|
1470
|
-
runPHPWithOptions:
|
|
1471
|
-
runSql:
|
|
1472
|
-
runWpInstallationWizard:
|
|
1473
|
-
setSiteOptions:
|
|
1474
|
-
unzip:
|
|
1475
|
-
updateUserMeta:
|
|
1476
|
-
wpCLI:
|
|
1477
|
-
writeFile:
|
|
1478
|
-
zipWpContent:
|
|
1479
|
-
}, Symbol.toStringTag, { value: "Module" })),
|
|
1480
|
-
function st(e, t) {
|
|
1481
|
-
const n = e.headers.get("content-length") || "", r = parseInt(n, 10) || it;
|
|
1482
|
-
function i(s, o) {
|
|
1483
|
-
t(
|
|
1484
|
-
new CustomEvent("progress", {
|
|
1485
|
-
detail: {
|
|
1486
|
-
loaded: s,
|
|
1487
|
-
total: o
|
|
1488
|
-
}
|
|
1489
|
-
})
|
|
1490
|
-
);
|
|
1491
|
-
}
|
|
1492
|
-
return new Response(
|
|
1493
|
-
new ReadableStream({
|
|
1494
|
-
async start(s) {
|
|
1495
|
-
if (!e.body) {
|
|
1496
|
-
s.close();
|
|
1497
|
-
return;
|
|
1498
|
-
}
|
|
1499
|
-
const o = e.body.getReader();
|
|
1500
|
-
let a = 0;
|
|
1501
|
-
for (; ; )
|
|
1502
|
-
try {
|
|
1503
|
-
const { done: p, value: l } = await o.read();
|
|
1504
|
-
if (l && (a += l.byteLength), p) {
|
|
1505
|
-
i(a, a), s.close();
|
|
1506
|
-
break;
|
|
1507
|
-
} else
|
|
1508
|
-
i(a, r), s.enqueue(l);
|
|
1509
|
-
} catch (p) {
|
|
1510
|
-
g.error({ e: p }), s.error(p);
|
|
1511
|
-
break;
|
|
1512
|
-
}
|
|
1513
|
-
}
|
|
1514
|
-
}),
|
|
1515
|
-
{
|
|
1516
|
-
status: e.status,
|
|
1517
|
-
statusText: e.statusText,
|
|
1518
|
-
headers: e.headers
|
|
1519
|
-
}
|
|
1520
|
-
);
|
|
1521
|
-
}
|
|
1522
|
-
const I = 1e-5;
|
|
1523
|
-
class D extends EventTarget {
|
|
1524
|
-
constructor({
|
|
1525
|
-
weight: t = 1,
|
|
1526
|
-
caption: n = "",
|
|
1527
|
-
fillTime: r = 4
|
|
1528
|
-
} = {}) {
|
|
1529
|
-
super(), this._selfWeight = 1, this._selfDone = !1, this._selfProgress = 0, this._selfCaption = "", this._isFilling = !1, this._subTrackers = [], this._weight = t, this._selfCaption = n, this._fillTime = r;
|
|
1530
|
-
}
|
|
1531
|
-
/**
|
|
1532
|
-
* Creates a new sub-tracker with a specific weight.
|
|
1533
|
-
*
|
|
1534
|
-
* The weight determines what percentage of the overall progress
|
|
1535
|
-
* the sub-tracker represents. For example, if the main tracker is
|
|
1536
|
-
* monitoring a process that has two stages, and the first stage
|
|
1537
|
-
* is expected to take twice as long as the second stage, you could
|
|
1538
|
-
* create the first sub-tracker with a weight of 0.67 and the second
|
|
1539
|
-
* sub-tracker with a weight of 0.33.
|
|
1540
|
-
*
|
|
1541
|
-
* The caption is an optional string that describes the current stage
|
|
1542
|
-
* of the operation. If provided, it will be used as the progress caption
|
|
1543
|
-
* for the sub-tracker. If not provided, the main tracker will look for
|
|
1544
|
-
* the next sub-tracker with a non-empty caption and use that as the progress
|
|
1545
|
-
* caption instead.
|
|
1546
|
-
*
|
|
1547
|
-
* Returns the newly-created sub-tracker.
|
|
1548
|
-
*
|
|
1549
|
-
* @throws {Error} If the weight of the new stage would cause the total weight of all stages to exceed 1.
|
|
1550
|
-
*
|
|
1551
|
-
* @param weight The weight of the new stage, as a decimal value between 0 and 1.
|
|
1552
|
-
* @param caption The caption for the new stage, which will be used as the progress caption for the sub-tracker.
|
|
1553
|
-
*
|
|
1554
|
-
* @example
|
|
1555
|
-
* ```ts
|
|
1556
|
-
* const tracker = new ProgressTracker();
|
|
1557
|
-
* const subTracker1 = tracker.stage(0.67, 'Slow stage');
|
|
1558
|
-
* const subTracker2 = tracker.stage(0.33, 'Fast stage');
|
|
1559
|
-
*
|
|
1560
|
-
* subTracker2.set(50);
|
|
1561
|
-
* subTracker1.set(75);
|
|
1562
|
-
* subTracker2.set(100);
|
|
1563
|
-
* subTracker1.set(100);
|
|
1564
|
-
* ```
|
|
1565
|
-
*/
|
|
1566
|
-
stage(t, n = "") {
|
|
1567
|
-
if (t || (t = this._selfWeight), this._selfWeight - t < -I)
|
|
1568
|
-
throw new Error(
|
|
1569
|
-
`Cannot add a stage with weight ${t} as the total weight of registered stages would exceed 1.`
|
|
1570
|
-
);
|
|
1571
|
-
this._selfWeight -= t;
|
|
1572
|
-
const r = new D({
|
|
1573
|
-
caption: n,
|
|
1574
|
-
weight: t,
|
|
1575
|
-
fillTime: this._fillTime
|
|
1576
|
-
});
|
|
1577
|
-
return this._subTrackers.push(r), r.addEventListener("progress", () => this.notifyProgress()), r.addEventListener("done", () => {
|
|
1578
|
-
this.done && this.notifyDone();
|
|
1579
|
-
}), r;
|
|
1580
|
-
}
|
|
1581
|
-
/**
|
|
1582
|
-
* Fills the progress bar slowly over time, simulating progress.
|
|
1583
|
-
*
|
|
1584
|
-
* The progress bar is filled in a 100 steps, and each step, the progress
|
|
1585
|
-
* is increased by 1. If `stopBeforeFinishing` is true, the progress bar
|
|
1586
|
-
* will stop filling when it reaches 99% so that you can call `finish()`
|
|
1587
|
-
* explicitly.
|
|
1588
|
-
*
|
|
1589
|
-
* If the progress bar is filling or already filled, this method does nothing.
|
|
1590
|
-
*
|
|
1591
|
-
* @example
|
|
1592
|
-
* ```ts
|
|
1593
|
-
* const progress = new ProgressTracker({ caption: 'Processing...' });
|
|
1594
|
-
* progress.fillSlowly();
|
|
1595
|
-
* ```
|
|
1596
|
-
*
|
|
1597
|
-
* @param options Optional options.
|
|
1598
|
-
*/
|
|
1599
|
-
fillSlowly({ stopBeforeFinishing: t = !0 } = {}) {
|
|
1600
|
-
if (this._isFilling)
|
|
1601
|
-
return;
|
|
1602
|
-
this._isFilling = !0;
|
|
1603
|
-
const n = 100, r = this._fillTime / n;
|
|
1604
|
-
this._fillInterval = setInterval(() => {
|
|
1605
|
-
this.set(this._selfProgress + 1), t && this._selfProgress >= 99 && clearInterval(this._fillInterval);
|
|
1606
|
-
}, r);
|
|
1607
|
-
}
|
|
1608
|
-
set(t) {
|
|
1609
|
-
this._selfProgress = Math.min(t, 100), this.notifyProgress(), this._selfProgress + I >= 100 && this.finish();
|
|
1610
|
-
}
|
|
1611
|
-
finish() {
|
|
1612
|
-
this._fillInterval && clearInterval(this._fillInterval), this._selfDone = !0, this._selfProgress = 100, this._isFilling = !1, this._fillInterval = void 0, this.notifyProgress(), this.notifyDone();
|
|
1613
|
-
}
|
|
1614
|
-
get caption() {
|
|
1615
|
-
for (let t = this._subTrackers.length - 1; t >= 0; t--)
|
|
1616
|
-
if (!this._subTrackers[t].done) {
|
|
1617
|
-
const n = this._subTrackers[t].caption;
|
|
1618
|
-
if (n)
|
|
1619
|
-
return n;
|
|
1620
|
-
}
|
|
1621
|
-
return this._selfCaption;
|
|
1622
|
-
}
|
|
1623
|
-
setCaption(t) {
|
|
1624
|
-
this._selfCaption = t, this.notifyProgress();
|
|
1625
|
-
}
|
|
1626
|
-
get done() {
|
|
1627
|
-
return this.progress + I >= 100;
|
|
1628
|
-
}
|
|
1629
|
-
get progress() {
|
|
1630
|
-
if (this._selfDone)
|
|
1631
|
-
return 100;
|
|
1632
|
-
const t = this._subTrackers.reduce(
|
|
1633
|
-
(n, r) => n + r.progress * r.weight,
|
|
1634
|
-
this._selfProgress * this._selfWeight
|
|
1635
|
-
);
|
|
1636
|
-
return Math.round(t * 1e4) / 1e4;
|
|
1637
|
-
}
|
|
1638
|
-
get weight() {
|
|
1639
|
-
return this._weight;
|
|
1640
|
-
}
|
|
1641
|
-
get observer() {
|
|
1642
|
-
return this._progressObserver || (this._progressObserver = (t) => {
|
|
1643
|
-
this.set(t);
|
|
1644
|
-
}), this._progressObserver;
|
|
1645
|
-
}
|
|
1646
|
-
get loadingListener() {
|
|
1647
|
-
return this._loadingListener || (this._loadingListener = (t) => {
|
|
1648
|
-
this.set(t.detail.loaded / t.detail.total * 100);
|
|
1649
|
-
}), this._loadingListener;
|
|
1650
|
-
}
|
|
1651
|
-
pipe(t) {
|
|
1652
|
-
t.setProgress({
|
|
1653
|
-
progress: this.progress,
|
|
1654
|
-
caption: this.caption
|
|
1655
|
-
}), this.addEventListener("progress", (n) => {
|
|
1656
|
-
t.setProgress({
|
|
1657
|
-
progress: n.detail.progress,
|
|
1658
|
-
caption: n.detail.caption
|
|
1659
|
-
});
|
|
1660
|
-
}), this.addEventListener("done", () => {
|
|
1661
|
-
t.setLoaded();
|
|
1662
|
-
});
|
|
1663
|
-
}
|
|
1664
|
-
addEventListener(t, n) {
|
|
1665
|
-
super.addEventListener(t, n);
|
|
1666
|
-
}
|
|
1667
|
-
removeEventListener(t, n) {
|
|
1668
|
-
super.removeEventListener(t, n);
|
|
1669
|
-
}
|
|
1670
|
-
notifyProgress() {
|
|
1671
|
-
const t = this;
|
|
1672
|
-
this.dispatchEvent(
|
|
1673
|
-
new CustomEvent("progress", {
|
|
1674
|
-
detail: {
|
|
1675
|
-
get progress() {
|
|
1676
|
-
return t.progress;
|
|
1677
|
-
},
|
|
1678
|
-
get caption() {
|
|
1679
|
-
return t.caption;
|
|
1680
|
-
}
|
|
1681
|
-
}
|
|
1682
|
-
})
|
|
1683
|
-
);
|
|
1684
|
-
}
|
|
1685
|
-
notifyDone() {
|
|
1686
|
-
this.dispatchEvent(new CustomEvent("done"));
|
|
1687
|
-
}
|
|
1688
|
-
}
|
|
1689
|
-
const S = {
|
|
1690
|
-
0: "No error occurred. System call completed successfully.",
|
|
1691
|
-
1: "Argument list too long.",
|
|
1692
|
-
2: "Permission denied.",
|
|
1693
|
-
3: "Address in use.",
|
|
1694
|
-
4: "Address not available.",
|
|
1695
|
-
5: "Address family not supported.",
|
|
1696
|
-
6: "Resource unavailable, or operation would block.",
|
|
1697
|
-
7: "Connection already in progress.",
|
|
1698
|
-
8: "Bad file descriptor.",
|
|
1699
|
-
9: "Bad message.",
|
|
1700
|
-
10: "Device or resource busy.",
|
|
1701
|
-
11: "Operation canceled.",
|
|
1702
|
-
12: "No child processes.",
|
|
1703
|
-
13: "Connection aborted.",
|
|
1704
|
-
14: "Connection refused.",
|
|
1705
|
-
15: "Connection reset.",
|
|
1706
|
-
16: "Resource deadlock would occur.",
|
|
1707
|
-
17: "Destination address required.",
|
|
1708
|
-
18: "Mathematics argument out of domain of function.",
|
|
1709
|
-
19: "Reserved.",
|
|
1710
|
-
20: "File exists.",
|
|
1711
|
-
21: "Bad address.",
|
|
1712
|
-
22: "File too large.",
|
|
1713
|
-
23: "Host is unreachable.",
|
|
1714
|
-
24: "Identifier removed.",
|
|
1715
|
-
25: "Illegal byte sequence.",
|
|
1716
|
-
26: "Operation in progress.",
|
|
1717
|
-
27: "Interrupted function.",
|
|
1718
|
-
28: "Invalid argument.",
|
|
1719
|
-
29: "I/O error.",
|
|
1720
|
-
30: "Socket is connected.",
|
|
1721
|
-
31: "There is a directory under that path.",
|
|
1722
|
-
32: "Too many levels of symbolic links.",
|
|
1723
|
-
33: "File descriptor value too large.",
|
|
1724
|
-
34: "Too many links.",
|
|
1725
|
-
35: "Message too large.",
|
|
1726
|
-
36: "Reserved.",
|
|
1727
|
-
37: "Filename too long.",
|
|
1728
|
-
38: "Network is down.",
|
|
1729
|
-
39: "Connection aborted by network.",
|
|
1730
|
-
40: "Network unreachable.",
|
|
1731
|
-
41: "Too many files open in system.",
|
|
1732
|
-
42: "No buffer space available.",
|
|
1733
|
-
43: "No such device.",
|
|
1734
|
-
44: "There is no such file or directory OR the parent directory does not exist.",
|
|
1735
|
-
45: "Executable file format error.",
|
|
1736
|
-
46: "No locks available.",
|
|
1737
|
-
47: "Reserved.",
|
|
1738
|
-
48: "Not enough space.",
|
|
1739
|
-
49: "No message of the desired type.",
|
|
1740
|
-
50: "Protocol not available.",
|
|
1741
|
-
51: "No space left on device.",
|
|
1742
|
-
52: "Function not supported.",
|
|
1743
|
-
53: "The socket is not connected.",
|
|
1744
|
-
54: "Not a directory or a symbolic link to a directory.",
|
|
1745
|
-
55: "Directory not empty.",
|
|
1746
|
-
56: "State not recoverable.",
|
|
1747
|
-
57: "Not a socket.",
|
|
1748
|
-
58: "Not supported, or operation not supported on socket.",
|
|
1749
|
-
59: "Inappropriate I/O control operation.",
|
|
1750
|
-
60: "No such device or address.",
|
|
1751
|
-
61: "Value too large to be stored in data type.",
|
|
1752
|
-
62: "Previous owner died.",
|
|
1753
|
-
63: "Operation not permitted.",
|
|
1754
|
-
64: "Broken pipe.",
|
|
1755
|
-
65: "Protocol error.",
|
|
1756
|
-
66: "Protocol not supported.",
|
|
1757
|
-
67: "Protocol wrong type for socket.",
|
|
1758
|
-
68: "Result too large.",
|
|
1759
|
-
69: "Read-only file system.",
|
|
1760
|
-
70: "Invalid seek.",
|
|
1761
|
-
71: "No such process.",
|
|
1762
|
-
72: "Reserved.",
|
|
1763
|
-
73: "Connection timed out.",
|
|
1764
|
-
74: "Text file busy.",
|
|
1765
|
-
75: "Cross-device link.",
|
|
1766
|
-
76: "Extension: Capabilities insufficient."
|
|
1767
|
-
};
|
|
1768
|
-
function ot(e) {
|
|
1769
|
-
const t = typeof e == "object" ? e == null ? void 0 : e.errno : null;
|
|
1770
|
-
if (t in S)
|
|
1771
|
-
return S[t];
|
|
1772
|
-
}
|
|
1773
|
-
function b(e = "") {
|
|
1774
|
-
return function(n, r, i) {
|
|
1775
|
-
const s = i.value;
|
|
1776
|
-
i.value = function(...o) {
|
|
1777
|
-
try {
|
|
1778
|
-
return s.apply(this, o);
|
|
1779
|
-
} catch (a) {
|
|
1780
|
-
const p = typeof a == "object" ? a == null ? void 0 : a.errno : null;
|
|
1781
|
-
if (p in S) {
|
|
1782
|
-
const l = S[p], u = typeof o[1] == "string" ? o[1] : null, d = u !== null ? e.replaceAll("{path}", u) : e;
|
|
1783
|
-
throw new Error(`${d}: ${l}`, {
|
|
1784
|
-
cause: a
|
|
1785
|
-
});
|
|
1786
|
-
}
|
|
1787
|
-
throw a;
|
|
1788
|
-
}
|
|
1789
|
-
};
|
|
1790
|
-
};
|
|
1791
|
-
}
|
|
1792
|
-
var at = Object.defineProperty, pt = Object.getOwnPropertyDescriptor, _ = (e, t, n, r) => {
|
|
1793
|
-
for (var i = r > 1 ? void 0 : r ? pt(t, n) : t, s = e.length - 1, o; s >= 0; s--)
|
|
1794
|
-
(o = e[s]) && (i = (r ? o(t, n, i) : o(i)) || i);
|
|
1795
|
-
return r && i && at(t, n, i), i;
|
|
1796
|
-
};
|
|
1797
|
-
const P = class $ {
|
|
1798
|
-
static readFileAsText(t, n) {
|
|
1799
|
-
return new TextDecoder().decode($.readFileAsBuffer(t, n));
|
|
1800
|
-
}
|
|
1801
|
-
static readFileAsBuffer(t, n) {
|
|
1802
|
-
return t.readFile(n);
|
|
1803
|
-
}
|
|
1804
|
-
static writeFile(t, n, r) {
|
|
1805
|
-
t.writeFile(n, r);
|
|
1806
|
-
}
|
|
1807
|
-
static unlink(t, n) {
|
|
1808
|
-
t.unlink(n);
|
|
1809
|
-
}
|
|
1810
|
-
/**
|
|
1811
|
-
* Moves a file or directory in the PHP filesystem to a
|
|
1812
|
-
* new location.
|
|
1813
|
-
*
|
|
1814
|
-
* @param oldPath The path to rename.
|
|
1815
|
-
* @param newPath The new path.
|
|
1816
|
-
*/
|
|
1817
|
-
static mv(t, n, r) {
|
|
1818
|
-
try {
|
|
1819
|
-
const i = t.lookupPath(n).node.mount, s = $.fileExists(t, r) ? t.lookupPath(r).node.mount : t.lookupPath(te(r)).node.mount;
|
|
1820
|
-
i.mountpoint !== s.mountpoint ? ($.copyRecursive(t, n, r), $.rmdir(t, n, { recursive: !0 })) : t.rename(n, r);
|
|
1821
|
-
} catch (i) {
|
|
1822
|
-
const s = ot(i);
|
|
1823
|
-
throw s ? new Error(
|
|
1824
|
-
`Could not move ${n} to ${r}: ${s}`,
|
|
1825
|
-
{
|
|
1826
|
-
cause: i
|
|
1827
|
-
}
|
|
1828
|
-
) : i;
|
|
1829
|
-
}
|
|
1830
|
-
}
|
|
1831
|
-
static rmdir(t, n, r = { recursive: !0 }) {
|
|
1832
|
-
r != null && r.recursive && $.listFiles(t, n).forEach((i) => {
|
|
1833
|
-
const s = `${n}/${i}`;
|
|
1834
|
-
$.isDir(t, s) ? $.rmdir(t, s, r) : $.unlink(t, s);
|
|
1835
|
-
}), t.rmdir(n);
|
|
1836
|
-
}
|
|
1837
|
-
static listFiles(t, n, r = { prependPath: !1 }) {
|
|
1838
|
-
if (!$.fileExists(t, n))
|
|
1839
|
-
return [];
|
|
1840
|
-
try {
|
|
1841
|
-
const i = t.readdir(n).filter(
|
|
1842
|
-
(s) => s !== "." && s !== ".."
|
|
1843
|
-
);
|
|
1844
|
-
if (r.prependPath) {
|
|
1845
|
-
const s = n.replace(/\/$/, "");
|
|
1846
|
-
return i.map((o) => `${s}/${o}`);
|
|
1847
|
-
}
|
|
1848
|
-
return i;
|
|
1849
|
-
} catch (i) {
|
|
1850
|
-
return g.error(i, { path: n }), [];
|
|
1851
|
-
}
|
|
1852
|
-
}
|
|
1853
|
-
static isDir(t, n) {
|
|
1854
|
-
return $.fileExists(t, n) ? t.isDir(t.lookupPath(n).node.mode) : !1;
|
|
1855
|
-
}
|
|
1856
|
-
static fileExists(t, n) {
|
|
1857
|
-
try {
|
|
1858
|
-
return t.lookupPath(n), !0;
|
|
1859
|
-
} catch {
|
|
1860
|
-
return !1;
|
|
1861
|
-
}
|
|
1862
|
-
}
|
|
1863
|
-
static mkdir(t, n) {
|
|
1864
|
-
t.mkdirTree(n);
|
|
1865
|
-
}
|
|
1866
|
-
static copyRecursive(t, n, r) {
|
|
1867
|
-
const i = t.lookupPath(n).node;
|
|
1868
|
-
if (t.isDir(i.mode)) {
|
|
1869
|
-
t.mkdirTree(r);
|
|
1870
|
-
const s = t.readdir(n).filter(
|
|
1871
|
-
(o) => o !== "." && o !== ".."
|
|
1872
|
-
);
|
|
1873
|
-
for (const o of s)
|
|
1874
|
-
$.copyRecursive(
|
|
1875
|
-
t,
|
|
1876
|
-
f(n, o),
|
|
1877
|
-
f(r, o)
|
|
1878
|
-
);
|
|
1879
|
-
} else
|
|
1880
|
-
t.writeFile(r, t.readFile(n));
|
|
1881
|
-
}
|
|
1882
|
-
};
|
|
1883
|
-
_([
|
|
1884
|
-
b('Could not read "{path}"')
|
|
1885
|
-
], P, "readFileAsText", 1);
|
|
1886
|
-
_([
|
|
1887
|
-
b('Could not read "{path}"')
|
|
1888
|
-
], P, "readFileAsBuffer", 1);
|
|
1889
|
-
_([
|
|
1890
|
-
b('Could not write to "{path}"')
|
|
1891
|
-
], P, "writeFile", 1);
|
|
1892
|
-
_([
|
|
1893
|
-
b('Could not unlink "{path}"')
|
|
1894
|
-
], P, "unlink", 1);
|
|
1895
|
-
_([
|
|
1896
|
-
b('Could not remove directory "{path}"')
|
|
1897
|
-
], P, "rmdir", 1);
|
|
1898
|
-
_([
|
|
1899
|
-
b('Could not list files in "{path}"')
|
|
1900
|
-
], P, "listFiles", 1);
|
|
1901
|
-
_([
|
|
1902
|
-
b('Could not stat "{path}"')
|
|
1903
|
-
], P, "isDir", 1);
|
|
1904
|
-
_([
|
|
1905
|
-
b('Could not stat "{path}"')
|
|
1906
|
-
], P, "fileExists", 1);
|
|
1907
|
-
_([
|
|
1908
|
-
b('Could not create directory "{path}"')
|
|
1909
|
-
], P, "mkdir", 1);
|
|
1910
|
-
_([
|
|
1911
|
-
b('Could not copy files from "{path}"')
|
|
1912
|
-
], P, "copyRecursive", 1);
|
|
1913
|
-
(function() {
|
|
1914
|
-
var e;
|
|
1915
|
-
return typeof process < "u" && ((e = process.release) == null ? void 0 : e.name) === "node" ? "NODE" : typeof window < "u" ? "WEB" : typeof WorkerGlobalScope < "u" && self instanceof WorkerGlobalScope ? "WORKER" : "NODE";
|
|
1916
|
-
})();
|
|
1917
|
-
ReadableStream.prototype[Symbol.asyncIterator] || (ReadableStream.prototype[Symbol.asyncIterator] = async function* () {
|
|
1918
|
-
const e = this.getReader();
|
|
1919
|
-
try {
|
|
1920
|
-
for (; ; ) {
|
|
1921
|
-
const { done: t, value: n } = await e.read();
|
|
1922
|
-
if (t)
|
|
1923
|
-
return;
|
|
1924
|
-
yield n;
|
|
1925
|
-
}
|
|
1926
|
-
} finally {
|
|
1927
|
-
e.releaseLock();
|
|
1928
|
-
}
|
|
1929
|
-
}, ReadableStream.prototype.iterate = // @ts-ignore
|
|
1930
|
-
ReadableStream.prototype[Symbol.asyncIterator]);
|
|
1931
|
-
const ue = [
|
|
1932
|
-
"8.3",
|
|
1933
|
-
"8.2",
|
|
1934
|
-
"8.1",
|
|
1935
|
-
"8.0",
|
|
1936
|
-
"7.4",
|
|
1937
|
-
"7.3",
|
|
1938
|
-
"7.2",
|
|
1939
|
-
"7.1",
|
|
1940
|
-
"7.0"
|
|
1941
|
-
], ct = ue[0], fe = [
|
|
1942
|
-
"iconv",
|
|
1943
|
-
"mbstring",
|
|
1944
|
-
"xml-bundle",
|
|
1945
|
-
"gd"
|
|
1946
|
-
], Z = {
|
|
1947
|
-
"kitchen-sink": fe,
|
|
1948
|
-
light: []
|
|
1949
|
-
}, lt = [
|
|
1063
|
+
activatePlugin: x,
|
|
1064
|
+
activateTheme: N,
|
|
1065
|
+
cp: ye,
|
|
1066
|
+
defineSiteUrl: z,
|
|
1067
|
+
defineWpConfigConsts: T,
|
|
1068
|
+
enableMultisite: me,
|
|
1069
|
+
exportWXR: Ee,
|
|
1070
|
+
importWordPressFiles: Pe,
|
|
1071
|
+
importWxr: be,
|
|
1072
|
+
installPlugin: Te,
|
|
1073
|
+
installTheme: ke,
|
|
1074
|
+
login: v,
|
|
1075
|
+
mkdir: $e,
|
|
1076
|
+
mv: ge,
|
|
1077
|
+
request: R,
|
|
1078
|
+
resetData: Re,
|
|
1079
|
+
rm: D,
|
|
1080
|
+
rmdir: _e,
|
|
1081
|
+
runPHP: pe,
|
|
1082
|
+
runPHPWithOptions: ce,
|
|
1083
|
+
runSql: de,
|
|
1084
|
+
runWpInstallationWizard: ve,
|
|
1085
|
+
setSiteOptions: M,
|
|
1086
|
+
unzip: L,
|
|
1087
|
+
updateUserMeta: fe,
|
|
1088
|
+
wpCLI: Oe,
|
|
1089
|
+
writeFile: H,
|
|
1090
|
+
zipWpContent: Se
|
|
1091
|
+
}, Symbol.toStringTag, { value: "Module" })), Ce = [
|
|
1950
1092
|
"vfs",
|
|
1951
1093
|
"literal",
|
|
1952
1094
|
"wordpress.org/themes",
|
|
1953
1095
|
"wordpress.org/plugins",
|
|
1954
1096
|
"url"
|
|
1955
1097
|
];
|
|
1956
|
-
function
|
|
1957
|
-
return e && typeof e == "object" && typeof e.resource == "string" &&
|
|
1098
|
+
function We(e) {
|
|
1099
|
+
return e && typeof e == "object" && typeof e.resource == "string" && Ce.includes(e.resource);
|
|
1958
1100
|
}
|
|
1959
|
-
class
|
|
1101
|
+
class b {
|
|
1960
1102
|
/**
|
|
1961
1103
|
* Creates a new Resource based on the given file reference
|
|
1962
1104
|
*
|
|
@@ -1964,28 +1106,28 @@ class T {
|
|
|
1964
1106
|
* @param options Additional options for the Resource
|
|
1965
1107
|
* @returns A new Resource instance
|
|
1966
1108
|
*/
|
|
1967
|
-
static create(t, { semaphore: n, progress:
|
|
1968
|
-
let
|
|
1109
|
+
static create(t, { semaphore: n, progress: i }) {
|
|
1110
|
+
let r;
|
|
1969
1111
|
switch (t.resource) {
|
|
1970
1112
|
case "vfs":
|
|
1971
|
-
|
|
1113
|
+
r = new Ie(t, i);
|
|
1972
1114
|
break;
|
|
1973
1115
|
case "literal":
|
|
1974
|
-
|
|
1116
|
+
r = new Ue(t, i);
|
|
1975
1117
|
break;
|
|
1976
1118
|
case "wordpress.org/themes":
|
|
1977
|
-
|
|
1119
|
+
r = new Be(t, i);
|
|
1978
1120
|
break;
|
|
1979
1121
|
case "wordpress.org/plugins":
|
|
1980
|
-
|
|
1122
|
+
r = new Ne(t, i);
|
|
1981
1123
|
break;
|
|
1982
1124
|
case "url":
|
|
1983
|
-
|
|
1125
|
+
r = new Ae(t, i);
|
|
1984
1126
|
break;
|
|
1985
1127
|
default:
|
|
1986
1128
|
throw new Error(`Invalid resource: ${t}`);
|
|
1987
1129
|
}
|
|
1988
|
-
return
|
|
1130
|
+
return r = new De(r), n && (r = new Me(r, n)), r;
|
|
1989
1131
|
}
|
|
1990
1132
|
setPlayground(t) {
|
|
1991
1133
|
this.playground = t;
|
|
@@ -1995,7 +1137,7 @@ class T {
|
|
|
1995
1137
|
return !1;
|
|
1996
1138
|
}
|
|
1997
1139
|
}
|
|
1998
|
-
class
|
|
1140
|
+
class Ie extends b {
|
|
1999
1141
|
/**
|
|
2000
1142
|
* Creates a new instance of `VFSResource`.
|
|
2001
1143
|
* @param playground The playground client.
|
|
@@ -2018,7 +1160,7 @@ class ut extends T {
|
|
|
2018
1160
|
return this.resource.path.split("/").pop() || "";
|
|
2019
1161
|
}
|
|
2020
1162
|
}
|
|
2021
|
-
class
|
|
1163
|
+
class Ue extends b {
|
|
2022
1164
|
/**
|
|
2023
1165
|
* Creates a new instance of `LiteralResource`.
|
|
2024
1166
|
* @param resource The literal reference.
|
|
@@ -2037,7 +1179,7 @@ class ft extends T {
|
|
|
2037
1179
|
return this.resource.name;
|
|
2038
1180
|
}
|
|
2039
1181
|
}
|
|
2040
|
-
class
|
|
1182
|
+
class O extends b {
|
|
2041
1183
|
/**
|
|
2042
1184
|
* Creates a new instance of `FetchResource`.
|
|
2043
1185
|
* @param progress The progress tracker.
|
|
@@ -2047,20 +1189,20 @@ class A extends T {
|
|
|
2047
1189
|
}
|
|
2048
1190
|
/** @inheritDoc */
|
|
2049
1191
|
async resolve() {
|
|
2050
|
-
var n,
|
|
1192
|
+
var n, i;
|
|
2051
1193
|
(n = this.progress) == null || n.setCaption(this.caption);
|
|
2052
1194
|
const t = this.getURL();
|
|
2053
1195
|
try {
|
|
2054
|
-
let
|
|
2055
|
-
if (!
|
|
1196
|
+
let r = await fetch(t);
|
|
1197
|
+
if (!r.ok)
|
|
2056
1198
|
throw new Error(`Could not download "${t}"`);
|
|
2057
|
-
if (
|
|
2058
|
-
|
|
2059
|
-
((
|
|
2060
|
-
),
|
|
1199
|
+
if (r = await ne(
|
|
1200
|
+
r,
|
|
1201
|
+
((i = this.progress) == null ? void 0 : i.loadingListener) ?? Fe
|
|
1202
|
+
), r.status !== 200)
|
|
2061
1203
|
throw new Error(`Could not download "${t}"`);
|
|
2062
|
-
return new File([await
|
|
2063
|
-
} catch (
|
|
1204
|
+
return new File([await r.blob()], this.name);
|
|
1205
|
+
} catch (r) {
|
|
2064
1206
|
throw new Error(
|
|
2065
1207
|
`Could not download "${t}".
|
|
2066
1208
|
Check if the URL is correct and the server is reachable.
|
|
@@ -2086,7 +1228,7 @@ class A extends T {
|
|
|
2086
1228
|
https://raw.githubusercontent.com/username/repository/branch/filename
|
|
2087
1229
|
|
|
2088
1230
|
Error:
|
|
2089
|
-
${
|
|
1231
|
+
${r}`
|
|
2090
1232
|
);
|
|
2091
1233
|
}
|
|
2092
1234
|
}
|
|
@@ -2110,9 +1252,9 @@ class A extends T {
|
|
|
2110
1252
|
return !0;
|
|
2111
1253
|
}
|
|
2112
1254
|
}
|
|
2113
|
-
const
|
|
1255
|
+
const Fe = () => {
|
|
2114
1256
|
};
|
|
2115
|
-
class
|
|
1257
|
+
class Ae extends O {
|
|
2116
1258
|
/**
|
|
2117
1259
|
* Creates a new instance of `UrlResource`.
|
|
2118
1260
|
* @param resource The URL reference.
|
|
@@ -2130,34 +1272,34 @@ class mt extends A {
|
|
|
2130
1272
|
return this.resource.caption ?? super.caption;
|
|
2131
1273
|
}
|
|
2132
1274
|
}
|
|
2133
|
-
class
|
|
1275
|
+
class Be extends O {
|
|
2134
1276
|
constructor(t, n) {
|
|
2135
1277
|
super(n), this.resource = t;
|
|
2136
1278
|
}
|
|
2137
1279
|
get name() {
|
|
2138
|
-
return
|
|
1280
|
+
return k(this.resource.slug);
|
|
2139
1281
|
}
|
|
2140
1282
|
getURL() {
|
|
2141
|
-
return `https://downloads.wordpress.org/theme/${
|
|
1283
|
+
return `https://downloads.wordpress.org/theme/${V(this.resource.slug)}`;
|
|
2142
1284
|
}
|
|
2143
1285
|
}
|
|
2144
|
-
class
|
|
1286
|
+
class Ne extends O {
|
|
2145
1287
|
constructor(t, n) {
|
|
2146
1288
|
super(n), this.resource = t;
|
|
2147
1289
|
}
|
|
2148
1290
|
/** @inheritDoc */
|
|
2149
1291
|
get name() {
|
|
2150
|
-
return
|
|
1292
|
+
return k(this.resource.slug);
|
|
2151
1293
|
}
|
|
2152
1294
|
/** @inheritDoc */
|
|
2153
1295
|
getURL() {
|
|
2154
|
-
return `https://downloads.wordpress.org/plugin/${
|
|
1296
|
+
return `https://downloads.wordpress.org/plugin/${V(this.resource.slug)}`;
|
|
2155
1297
|
}
|
|
2156
1298
|
}
|
|
2157
|
-
function
|
|
1299
|
+
function V(e) {
|
|
2158
1300
|
return !e || e.endsWith(".zip") ? e : e + ".latest-stable.zip";
|
|
2159
1301
|
}
|
|
2160
|
-
class
|
|
1302
|
+
class Q extends b {
|
|
2161
1303
|
constructor(t) {
|
|
2162
1304
|
super(), this.resource = t;
|
|
2163
1305
|
}
|
|
@@ -2186,13 +1328,13 @@ class me extends T {
|
|
|
2186
1328
|
return this.resource.isAsync;
|
|
2187
1329
|
}
|
|
2188
1330
|
}
|
|
2189
|
-
class
|
|
1331
|
+
class De extends Q {
|
|
2190
1332
|
/** @inheritDoc */
|
|
2191
1333
|
async resolve() {
|
|
2192
1334
|
return this.promise || (this.promise = super.resolve()), this.promise;
|
|
2193
1335
|
}
|
|
2194
1336
|
}
|
|
2195
|
-
class
|
|
1337
|
+
class Me extends Q {
|
|
2196
1338
|
constructor(t, n) {
|
|
2197
1339
|
super(t), this.semaphore = n;
|
|
2198
1340
|
}
|
|
@@ -2201,7 +1343,7 @@ class $t extends me {
|
|
|
2201
1343
|
return this.isAsync ? this.semaphore.run(() => super.resolve()) : super.resolve();
|
|
2202
1344
|
}
|
|
2203
1345
|
}
|
|
2204
|
-
const
|
|
1346
|
+
const He = "http://json-schema.org/schema", ze = "#/definitions/Blueprint", Ge = {
|
|
2205
1347
|
Blueprint: {
|
|
2206
1348
|
type: "object",
|
|
2207
1349
|
properties: {
|
|
@@ -3782,28 +2924,28 @@ for existing apps using this option.`
|
|
|
3782
2924
|
},
|
|
3783
2925
|
additionalProperties: !1
|
|
3784
2926
|
}
|
|
3785
|
-
},
|
|
3786
|
-
$schema:
|
|
3787
|
-
$ref:
|
|
3788
|
-
definitions:
|
|
3789
|
-
}, { wpCLI:
|
|
3790
|
-
...
|
|
3791
|
-
"wp-cli":
|
|
3792
|
-
importFile:
|
|
2927
|
+
}, Ve = {
|
|
2928
|
+
$schema: He,
|
|
2929
|
+
$ref: ze,
|
|
2930
|
+
definitions: Ge
|
|
2931
|
+
}, { wpCLI: Qe, ...F } = je, Ye = {
|
|
2932
|
+
...F,
|
|
2933
|
+
"wp-cli": Qe,
|
|
2934
|
+
importFile: F.importWxr
|
|
3793
2935
|
};
|
|
3794
|
-
function
|
|
3795
|
-
progress: t = new
|
|
3796
|
-
semaphore: n = new
|
|
3797
|
-
onStepCompleted:
|
|
2936
|
+
function ut(e, {
|
|
2937
|
+
progress: t = new ie(),
|
|
2938
|
+
semaphore: n = new J({ concurrency: 3 }),
|
|
2939
|
+
onStepCompleted: i = () => {
|
|
3798
2940
|
}
|
|
3799
2941
|
} = {}) {
|
|
3800
|
-
var d,
|
|
2942
|
+
var d, l, w, P, q, j, C;
|
|
3801
2943
|
e = {
|
|
3802
2944
|
...e,
|
|
3803
|
-
steps: (e.steps || []).filter(
|
|
2945
|
+
steps: (e.steps || []).filter(et).filter(tt)
|
|
3804
2946
|
};
|
|
3805
|
-
for (const
|
|
3806
|
-
typeof
|
|
2947
|
+
for (const p of e.steps)
|
|
2948
|
+
typeof p == "object" && p.step === "importFile" && (p.step = "importWxr", g.warn(
|
|
3807
2949
|
'The "importFile" step is deprecated. Use "importWxr" instead.'
|
|
3808
2950
|
));
|
|
3809
2951
|
if (e.constants && e.steps.unshift({
|
|
@@ -3813,30 +2955,30 @@ function Wt(e, {
|
|
|
3813
2955
|
step: "setSiteOptions",
|
|
3814
2956
|
options: e.siteOptions
|
|
3815
2957
|
}), e.plugins) {
|
|
3816
|
-
const
|
|
2958
|
+
const p = e.plugins.map((y) => typeof y == "string" ? y.startsWith("https://") ? {
|
|
3817
2959
|
resource: "url",
|
|
3818
|
-
url:
|
|
2960
|
+
url: y
|
|
3819
2961
|
} : {
|
|
3820
2962
|
resource: "wordpress.org/plugins",
|
|
3821
|
-
slug:
|
|
3822
|
-
} :
|
|
2963
|
+
slug: y
|
|
2964
|
+
} : y).map((y) => ({
|
|
3823
2965
|
step: "installPlugin",
|
|
3824
|
-
pluginZipFile:
|
|
2966
|
+
pluginZipFile: y
|
|
3825
2967
|
}));
|
|
3826
|
-
e.steps.unshift(...
|
|
2968
|
+
e.steps.unshift(...p);
|
|
3827
2969
|
}
|
|
3828
2970
|
e.login && e.steps.push({
|
|
3829
2971
|
step: "login",
|
|
3830
2972
|
...e.login === !0 ? { username: "admin", password: "password" } : e.login
|
|
3831
2973
|
}), e.phpExtensionBundles || (e.phpExtensionBundles = []), e.phpExtensionBundles || (e.phpExtensionBundles = []), e.phpExtensionBundles.length === 0 && e.phpExtensionBundles.push("kitchen-sink");
|
|
3832
|
-
const
|
|
3833
|
-
(
|
|
2974
|
+
const r = (d = e.steps) == null ? void 0 : d.findIndex(
|
|
2975
|
+
(p) => typeof p == "object" && (p == null ? void 0 : p.step) === "wp-cli"
|
|
3834
2976
|
);
|
|
3835
|
-
|
|
3836
|
-
(
|
|
2977
|
+
r !== void 0 && r > -1 && (e.phpExtensionBundles.includes("light") && (e.phpExtensionBundles = e.phpExtensionBundles.filter(
|
|
2978
|
+
(p) => p !== "light"
|
|
3837
2979
|
), g.warn(
|
|
3838
2980
|
"The wpCli step used in your Blueprint requires the iconv and mbstring PHP extensions. However, you did not specify the kitchen-sink extension bundle. Playground will override your choice and load the kitchen-sink PHP extensions bundle to prevent the WP-CLI step from failing. "
|
|
3839
|
-
)), (
|
|
2981
|
+
)), (l = e.steps) == null || l.splice(r, 0, {
|
|
3840
2982
|
step: "writeFile",
|
|
3841
2983
|
data: {
|
|
3842
2984
|
resource: "url",
|
|
@@ -3854,14 +2996,14 @@ function Wt(e, {
|
|
|
3854
2996
|
},
|
|
3855
2997
|
path: "/tmp/wp-cli.phar"
|
|
3856
2998
|
}));
|
|
3857
|
-
const s = (
|
|
3858
|
-
(
|
|
2999
|
+
const s = (w = e.steps) == null ? void 0 : w.findIndex(
|
|
3000
|
+
(p) => typeof p == "object" && (p == null ? void 0 : p.step) === "importWxr"
|
|
3859
3001
|
);
|
|
3860
3002
|
s !== void 0 && s > -1 && (e.phpExtensionBundles.includes("light") && (e.phpExtensionBundles = e.phpExtensionBundles.filter(
|
|
3861
|
-
(
|
|
3003
|
+
(p) => p !== "light"
|
|
3862
3004
|
), g.warn(
|
|
3863
3005
|
"The importWxr step used in your Blueprint requires the iconv and mbstring PHP extensions. However, you did not specify the kitchen-sink extension bundle. Playground will override your choice and load the kitchen-sink PHP extensions bundle to prevent the WP-CLI step from failing. "
|
|
3864
|
-
)), (
|
|
3006
|
+
)), (P = e.steps) == null || P.splice(s, 0, {
|
|
3865
3007
|
step: "installPlugin",
|
|
3866
3008
|
pluginZipFile: {
|
|
3867
3009
|
resource: "url",
|
|
@@ -3869,63 +3011,63 @@ function Wt(e, {
|
|
|
3869
3011
|
caption: "Downloading the WordPress Importer plugin"
|
|
3870
3012
|
}
|
|
3871
3013
|
}));
|
|
3872
|
-
const { valid: o, errors:
|
|
3014
|
+
const { valid: o, errors: c } = Xe(e);
|
|
3873
3015
|
if (!o) {
|
|
3874
|
-
const
|
|
3875
|
-
`Invalid blueprint: ${
|
|
3016
|
+
const p = new Error(
|
|
3017
|
+
`Invalid blueprint: ${c[0].message} at ${c[0].instancePath}`
|
|
3876
3018
|
);
|
|
3877
|
-
throw
|
|
3019
|
+
throw p.errors = c, p;
|
|
3878
3020
|
}
|
|
3879
|
-
const
|
|
3880
|
-
(
|
|
3881
|
-
var
|
|
3882
|
-
return
|
|
3021
|
+
const a = e.steps || [], h = a.reduce(
|
|
3022
|
+
(p, y) => {
|
|
3023
|
+
var $;
|
|
3024
|
+
return p + ((($ = y.progress) == null ? void 0 : $.weight) || 1);
|
|
3883
3025
|
},
|
|
3884
3026
|
0
|
|
3885
|
-
),
|
|
3886
|
-
(
|
|
3027
|
+
), f = a.map(
|
|
3028
|
+
(p) => nt(p, {
|
|
3887
3029
|
semaphore: n,
|
|
3888
3030
|
rootProgressTracker: t,
|
|
3889
|
-
totalProgressWeight:
|
|
3031
|
+
totalProgressWeight: h
|
|
3890
3032
|
})
|
|
3891
3033
|
);
|
|
3892
3034
|
return {
|
|
3893
3035
|
versions: {
|
|
3894
|
-
php:
|
|
3895
|
-
(
|
|
3896
|
-
|
|
3897
|
-
|
|
3036
|
+
php: Je(
|
|
3037
|
+
(q = e.preferredVersions) == null ? void 0 : q.php,
|
|
3038
|
+
oe,
|
|
3039
|
+
se
|
|
3898
3040
|
),
|
|
3899
|
-
wp: ((
|
|
3041
|
+
wp: ((j = e.preferredVersions) == null ? void 0 : j.wp) || "latest"
|
|
3900
3042
|
},
|
|
3901
|
-
phpExtensions:
|
|
3043
|
+
phpExtensions: Ke(
|
|
3902
3044
|
[],
|
|
3903
3045
|
e.phpExtensionBundles || []
|
|
3904
3046
|
),
|
|
3905
3047
|
features: {
|
|
3906
3048
|
// Disable networking by default
|
|
3907
|
-
networking: ((
|
|
3049
|
+
networking: ((C = e.features) == null ? void 0 : C.networking) ?? !1
|
|
3908
3050
|
},
|
|
3909
|
-
run: async (
|
|
3051
|
+
run: async (p) => {
|
|
3910
3052
|
try {
|
|
3911
|
-
for (const { resources:
|
|
3912
|
-
for (const
|
|
3913
|
-
|
|
3914
|
-
for (const [
|
|
3053
|
+
for (const { resources: y } of f)
|
|
3054
|
+
for (const $ of y)
|
|
3055
|
+
$.setPlayground(p), $.isAsync && $.resolve();
|
|
3056
|
+
for (const [y, { run: $, step: W }] of Object.entries(f))
|
|
3915
3057
|
try {
|
|
3916
|
-
const
|
|
3917
|
-
|
|
3918
|
-
} catch (
|
|
3919
|
-
throw g.error(
|
|
3920
|
-
`Error when executing the blueprint step #${
|
|
3921
|
-
|
|
3922
|
-
)}) ${
|
|
3923
|
-
{ cause:
|
|
3058
|
+
const _ = await $(p);
|
|
3059
|
+
i(_, W);
|
|
3060
|
+
} catch (_) {
|
|
3061
|
+
throw g.error(_), new Error(
|
|
3062
|
+
`Error when executing the blueprint step #${y} (${JSON.stringify(
|
|
3063
|
+
W
|
|
3064
|
+
)}) ${_ instanceof Error ? `: ${_.message}` : _}`,
|
|
3065
|
+
{ cause: _ }
|
|
3924
3066
|
);
|
|
3925
3067
|
}
|
|
3926
3068
|
} finally {
|
|
3927
3069
|
try {
|
|
3928
|
-
await
|
|
3070
|
+
await p.goTo(
|
|
3929
3071
|
e.landingPage || "/"
|
|
3930
3072
|
);
|
|
3931
3073
|
} catch {
|
|
@@ -3935,132 +3077,132 @@ function Wt(e, {
|
|
|
3935
3077
|
}
|
|
3936
3078
|
};
|
|
3937
3079
|
}
|
|
3938
|
-
const
|
|
3939
|
-
let
|
|
3940
|
-
function
|
|
3941
|
-
var
|
|
3942
|
-
|
|
3943
|
-
const t =
|
|
3080
|
+
const Ze = new ae({ discriminator: !0 });
|
|
3081
|
+
let E;
|
|
3082
|
+
function Xe(e) {
|
|
3083
|
+
var r;
|
|
3084
|
+
E = Ze.compile(Ve);
|
|
3085
|
+
const t = E(e);
|
|
3944
3086
|
if (t)
|
|
3945
3087
|
return { valid: t };
|
|
3946
3088
|
const n = /* @__PURE__ */ new Set();
|
|
3947
|
-
for (const s of
|
|
3089
|
+
for (const s of E.errors)
|
|
3948
3090
|
s.schemaPath.startsWith("#/properties/steps/items/anyOf") || n.add(s.instancePath);
|
|
3949
|
-
const
|
|
3091
|
+
const i = (r = E.errors) == null ? void 0 : r.filter(
|
|
3950
3092
|
(s) => !(s.schemaPath.startsWith("#/properties/steps/items/anyOf") && n.has(s.instancePath))
|
|
3951
3093
|
);
|
|
3952
3094
|
return {
|
|
3953
3095
|
valid: t,
|
|
3954
|
-
errors:
|
|
3096
|
+
errors: i
|
|
3955
3097
|
};
|
|
3956
3098
|
}
|
|
3957
|
-
function
|
|
3099
|
+
function Je(e, t, n) {
|
|
3958
3100
|
return e && t.includes(e) ? e : n;
|
|
3959
3101
|
}
|
|
3960
|
-
function
|
|
3961
|
-
const n =
|
|
3962
|
-
(
|
|
3963
|
-
),
|
|
3964
|
-
(
|
|
3102
|
+
function Ke(e, t) {
|
|
3103
|
+
const n = re.filter(
|
|
3104
|
+
(r) => e.includes(r)
|
|
3105
|
+
), i = t.flatMap(
|
|
3106
|
+
(r) => r in I ? I[r] : []
|
|
3965
3107
|
);
|
|
3966
|
-
return Array.from(/* @__PURE__ */ new Set([...n, ...
|
|
3108
|
+
return Array.from(/* @__PURE__ */ new Set([...n, ...i]));
|
|
3967
3109
|
}
|
|
3968
|
-
function
|
|
3110
|
+
function et(e) {
|
|
3969
3111
|
return !!(typeof e == "object" && e);
|
|
3970
3112
|
}
|
|
3971
|
-
function
|
|
3113
|
+
function tt(e) {
|
|
3972
3114
|
return ["setPhpIniEntry", "request"].includes(e.step) ? (g.warn(
|
|
3973
3115
|
`The "${e.step}" Blueprint is no longer supported and you can remove it from your Blueprint.`
|
|
3974
3116
|
), !1) : !0;
|
|
3975
3117
|
}
|
|
3976
|
-
function
|
|
3118
|
+
function nt(e, {
|
|
3977
3119
|
semaphore: t,
|
|
3978
3120
|
rootProgressTracker: n,
|
|
3979
|
-
totalProgressWeight:
|
|
3121
|
+
totalProgressWeight: i
|
|
3980
3122
|
}) {
|
|
3981
|
-
var
|
|
3982
|
-
const
|
|
3983
|
-
(((
|
|
3123
|
+
var f;
|
|
3124
|
+
const r = n.stage(
|
|
3125
|
+
(((f = e.progress) == null ? void 0 : f.weight) || 1) / i
|
|
3984
3126
|
), s = {};
|
|
3985
3127
|
for (const d of Object.keys(e)) {
|
|
3986
|
-
let
|
|
3987
|
-
|
|
3128
|
+
let l = e[d];
|
|
3129
|
+
We(l) && (l = b.create(l, {
|
|
3988
3130
|
semaphore: t
|
|
3989
|
-
})), s[d] =
|
|
3131
|
+
})), s[d] = l;
|
|
3990
3132
|
}
|
|
3991
3133
|
const o = async (d) => {
|
|
3992
|
-
var
|
|
3134
|
+
var l;
|
|
3993
3135
|
try {
|
|
3994
|
-
return
|
|
3136
|
+
return r.fillSlowly(), await Ye[e.step](
|
|
3995
3137
|
d,
|
|
3996
|
-
await
|
|
3138
|
+
await it(s),
|
|
3997
3139
|
{
|
|
3998
|
-
tracker:
|
|
3999
|
-
initialCaption: (
|
|
3140
|
+
tracker: r,
|
|
3141
|
+
initialCaption: (l = e.progress) == null ? void 0 : l.caption
|
|
4000
3142
|
}
|
|
4001
3143
|
);
|
|
4002
3144
|
} finally {
|
|
4003
|
-
|
|
3145
|
+
r.finish();
|
|
4004
3146
|
}
|
|
4005
|
-
},
|
|
3147
|
+
}, c = A(s), a = A(s).filter(
|
|
4006
3148
|
(d) => d.isAsync
|
|
4007
|
-
),
|
|
4008
|
-
for (const d of
|
|
4009
|
-
d.progress =
|
|
4010
|
-
return { run: o, step: e, resources:
|
|
3149
|
+
), h = 1 / (a.length + 1);
|
|
3150
|
+
for (const d of a)
|
|
3151
|
+
d.progress = r.stage(h);
|
|
3152
|
+
return { run: o, step: e, resources: c };
|
|
4011
3153
|
}
|
|
4012
|
-
function
|
|
3154
|
+
function A(e) {
|
|
4013
3155
|
const t = [];
|
|
4014
3156
|
for (const n in e) {
|
|
4015
|
-
const
|
|
4016
|
-
|
|
3157
|
+
const i = e[n];
|
|
3158
|
+
i instanceof b && t.push(i);
|
|
4017
3159
|
}
|
|
4018
3160
|
return t;
|
|
4019
3161
|
}
|
|
4020
|
-
async function
|
|
3162
|
+
async function it(e) {
|
|
4021
3163
|
const t = {};
|
|
4022
3164
|
for (const n in e) {
|
|
4023
|
-
const
|
|
4024
|
-
|
|
3165
|
+
const i = e[n];
|
|
3166
|
+
i instanceof b ? t[n] = await i.resolve() : t[n] = i;
|
|
4025
3167
|
}
|
|
4026
3168
|
return t;
|
|
4027
3169
|
}
|
|
4028
|
-
async function
|
|
3170
|
+
async function ht(e, t) {
|
|
4029
3171
|
await e.run(t);
|
|
4030
3172
|
}
|
|
4031
|
-
function
|
|
3173
|
+
function ft() {
|
|
4032
3174
|
}
|
|
4033
3175
|
export {
|
|
4034
|
-
|
|
4035
|
-
|
|
4036
|
-
|
|
4037
|
-
|
|
4038
|
-
|
|
4039
|
-
|
|
4040
|
-
|
|
4041
|
-
|
|
4042
|
-
|
|
4043
|
-
|
|
4044
|
-
|
|
4045
|
-
|
|
4046
|
-
|
|
4047
|
-
|
|
4048
|
-
|
|
4049
|
-
|
|
4050
|
-
|
|
4051
|
-
|
|
4052
|
-
|
|
4053
|
-
|
|
4054
|
-
|
|
4055
|
-
|
|
4056
|
-
|
|
4057
|
-
|
|
4058
|
-
|
|
4059
|
-
|
|
4060
|
-
|
|
4061
|
-
|
|
4062
|
-
|
|
4063
|
-
|
|
4064
|
-
|
|
4065
|
-
|
|
3176
|
+
x as activatePlugin,
|
|
3177
|
+
N as activateTheme,
|
|
3178
|
+
ut as compileBlueprint,
|
|
3179
|
+
ye as cp,
|
|
3180
|
+
z as defineSiteUrl,
|
|
3181
|
+
T as defineWpConfigConsts,
|
|
3182
|
+
me as enableMultisite,
|
|
3183
|
+
Ee as exportWXR,
|
|
3184
|
+
Pe as importWordPressFiles,
|
|
3185
|
+
be as importWxr,
|
|
3186
|
+
Te as installPlugin,
|
|
3187
|
+
ke as installTheme,
|
|
3188
|
+
v as login,
|
|
3189
|
+
$e as mkdir,
|
|
3190
|
+
ge as mv,
|
|
3191
|
+
R as request,
|
|
3192
|
+
Re as resetData,
|
|
3193
|
+
D as rm,
|
|
3194
|
+
_e as rmdir,
|
|
3195
|
+
ht as runBlueprintSteps,
|
|
3196
|
+
pe as runPHP,
|
|
3197
|
+
ce as runPHPWithOptions,
|
|
3198
|
+
de as runSql,
|
|
3199
|
+
ve as runWpInstallationWizard,
|
|
3200
|
+
ft as setPluginProxyURL,
|
|
3201
|
+
M as setSiteOptions,
|
|
3202
|
+
L as unzip,
|
|
3203
|
+
fe as updateUserMeta,
|
|
3204
|
+
Oe as wpCLI,
|
|
3205
|
+
B as wpContentFilesExcludedFromExport,
|
|
3206
|
+
H as writeFile,
|
|
3207
|
+
Se as zipWpContent
|
|
4066
3208
|
};
|