@wp-playground/blueprints 0.6.8 → 0.6.9
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/blueprint-schema.json +0 -4
- package/index.cjs +15 -15
- package/index.d.ts +2 -6
- package/index.js +8 -17
- package/lib/steps/wp-cli.d.ts +1 -1
- package/package.json +2 -2
- package/schema-readme.md +1 -1
package/index.d.ts
CHANGED
|
@@ -193,6 +193,7 @@ export interface PHPRequestEndEvent {
|
|
|
193
193
|
export interface PHPRequestErrorEvent {
|
|
194
194
|
type: "request.error";
|
|
195
195
|
error: Error;
|
|
196
|
+
source?: "request" | "php-wasm";
|
|
196
197
|
}
|
|
197
198
|
/**
|
|
198
199
|
* Represents a PHP runtime initialization event.
|
|
@@ -658,11 +659,6 @@ export interface PHPRunOptions {
|
|
|
658
659
|
* The code snippet to eval instead of a php file.
|
|
659
660
|
*/
|
|
660
661
|
code?: string;
|
|
661
|
-
/**
|
|
662
|
-
* Whether to throw an error if the PHP process exits with a non-zero code
|
|
663
|
-
* or outputs to stderr.
|
|
664
|
-
*/
|
|
665
|
-
throwOnError?: boolean;
|
|
666
662
|
}
|
|
667
663
|
export interface RmDirOptions {
|
|
668
664
|
/**
|
|
@@ -1648,7 +1644,7 @@ export declare const enableMultisite: StepHandler<EnableMultisiteStep>;
|
|
|
1648
1644
|
*
|
|
1649
1645
|
* <code>
|
|
1650
1646
|
* {
|
|
1651
|
-
* "step": "
|
|
1647
|
+
* "step": "wp-cli",
|
|
1652
1648
|
* "command": "wp post create --post_title='Test post' --post_excerpt='Some content'"
|
|
1653
1649
|
* }
|
|
1654
1650
|
* </code>
|
package/index.js
CHANGED
|
@@ -269,7 +269,6 @@ const activatePlugin = async (e, { pluginPath: t, pluginName: r }, n) => {
|
|
|
269
269
|
n == null || n.tracker.setCaption(`Activating ${r || t}`);
|
|
270
270
|
const s = await e.documentRoot;
|
|
271
271
|
await e.run({
|
|
272
|
-
throwOnError: !0,
|
|
273
272
|
code: `<?php
|
|
274
273
|
define( 'WP_ADMIN', true );
|
|
275
274
|
require_once( ${phpVar(s)}. "/wp-load.php" );
|
|
@@ -301,7 +300,6 @@ exit(1);
|
|
|
301
300
|
r == null || r.tracker.setCaption(`Activating ${t}`);
|
|
302
301
|
const n = await e.documentRoot;
|
|
303
302
|
await e.run({
|
|
304
|
-
throwOnError: !0,
|
|
305
303
|
code: `<?php
|
|
306
304
|
define( 'WP_ADMIN', true );
|
|
307
305
|
require_once( ${phpVar(n)}. "/wp-load.php" );
|
|
@@ -312,7 +310,7 @@ set_current_user( get_users(array('role' => 'Administrator') )[0] );
|
|
|
312
310
|
switch_theme( ${phpVar(t)} );
|
|
313
311
|
`
|
|
314
312
|
});
|
|
315
|
-
}, runPHP = async (e, { code: t }) => await e.run({ code: t
|
|
313
|
+
}, runPHP = async (e, { code: t }) => await e.run({ code: t }), runPHPWithOptions = async (e, { options: t }) => await e.run(t), rm = async (e, { path: t }) => {
|
|
316
314
|
await e.unlink(t);
|
|
317
315
|
}, runSql = async (e, { sql: t }, r) => {
|
|
318
316
|
r == null || r.tracker.setCaption("Executing SQL Queries");
|
|
@@ -712,7 +710,6 @@ async function rewriteDefineCalls(e, t, r) {
|
|
|
712
710
|
consts: r
|
|
713
711
|
});
|
|
714
712
|
return await e.run({
|
|
715
|
-
throwOnError: !0,
|
|
716
713
|
code: `${rewriteWpConfigToDefineConstants}
|
|
717
714
|
$wp_config_path = '/tmp/code.php';
|
|
718
715
|
$wp_config = file_get_contents($wp_config_path);
|
|
@@ -745,7 +742,6 @@ const login = async (e, { username: t = "admin", password: r = "password" } = {}
|
|
|
745
742
|
}, setSiteOptions = async (e, { options: t }) => {
|
|
746
743
|
const r = await e.documentRoot;
|
|
747
744
|
await e.run({
|
|
748
|
-
throwOnError: !0,
|
|
749
745
|
code: `<?php
|
|
750
746
|
include ${phpVar(r)} . '/wp-load.php';
|
|
751
747
|
$site_options = ${phpVar(t)};
|
|
@@ -758,7 +754,6 @@ const login = async (e, { username: t = "admin", password: r = "password" } = {}
|
|
|
758
754
|
}, updateUserMeta = async (e, { meta: t, userId: r }) => {
|
|
759
755
|
const n = await e.documentRoot;
|
|
760
756
|
await e.run({
|
|
761
|
-
throwOnError: !0,
|
|
762
757
|
code: `<?php
|
|
763
758
|
include ${phpVar(n)} . '/wp-load.php';
|
|
764
759
|
$meta = ${phpVar(t)};
|
|
@@ -794,7 +789,6 @@ const enableMultisite = async (e) => {
|
|
|
794
789
|
}
|
|
795
790
|
}), await login(e, {});
|
|
796
791
|
const s = await e.documentRoot, o = (await e.run({
|
|
797
|
-
throwOnError: !0,
|
|
798
792
|
code: `<?php
|
|
799
793
|
define( 'WP_ADMIN', true );
|
|
800
794
|
require_once(${phpVar(s)} . "/wp-load.php");
|
|
@@ -1035,7 +1029,6 @@ function delTree($dir)
|
|
|
1035
1029
|
`;
|
|
1036
1030
|
async function runPhpWithZipFunctions(e, t) {
|
|
1037
1031
|
return await e.run({
|
|
1038
|
-
throwOnError: !0,
|
|
1039
1032
|
code: zipFunctions + t
|
|
1040
1033
|
});
|
|
1041
1034
|
}
|
|
@@ -1101,7 +1094,6 @@ const tmpPath = "/tmp/file.zip", unzip = async (e, { zipFile: t, zipPath: r, ext
|
|
|
1101
1094
|
joinPaths(n, "wp-admin", "upgrade.php")
|
|
1102
1095
|
);
|
|
1103
1096
|
await e.run({
|
|
1104
|
-
throwOnError: !0,
|
|
1105
1097
|
code: `<?php
|
|
1106
1098
|
$_GET['step'] = 'upgrade_db';
|
|
1107
1099
|
require ${u};
|
|
@@ -1942,7 +1934,8 @@ class PHPRequestHandler {
|
|
|
1942
1934
|
/** @inheritDoc */
|
|
1943
1935
|
async request(t) {
|
|
1944
1936
|
const r = t.url.startsWith("http://") || t.url.startsWith("https://"), n = new URL(
|
|
1945
|
-
|
|
1937
|
+
// Remove the hash part of the URL as it's not meant for the server.
|
|
1938
|
+
t.url.split("#")[0],
|
|
1946
1939
|
r ? void 0 : DEFAULT_BASE_URL
|
|
1947
1940
|
), s = applyRewriteRules(
|
|
1948
1941
|
removePathPrefix(n.pathname, H(this, ve)),
|
|
@@ -2353,7 +2346,7 @@ class BasePHP {
|
|
|
2353
2346
|
for (const l in i)
|
|
2354
2347
|
ce(this, Tt, rr).call(this, l, i[l]);
|
|
2355
2348
|
const o = await ce(this, Ot, sr).call(this);
|
|
2356
|
-
if (
|
|
2349
|
+
if (o.exitCode !== 0) {
|
|
2357
2350
|
const l = {
|
|
2358
2351
|
stdout: o.text,
|
|
2359
2352
|
stderr: o.errors
|
|
@@ -2362,13 +2355,15 @@ class BasePHP {
|
|
|
2362
2355
|
const d = new Error(
|
|
2363
2356
|
`PHP.run() failed with exit code ${o.exitCode} and the following output: ` + o.errors
|
|
2364
2357
|
);
|
|
2365
|
-
throw d.output = l, console.error(d), d;
|
|
2358
|
+
throw d.output = l, d.source = "request", console.error(d), d;
|
|
2366
2359
|
}
|
|
2367
2360
|
return o;
|
|
2368
2361
|
} catch (n) {
|
|
2369
2362
|
throw this.dispatchEvent({
|
|
2370
2363
|
type: "request.error",
|
|
2371
|
-
error: n
|
|
2364
|
+
error: n,
|
|
2365
|
+
// Distinguish between PHP request and PHP-wasm errors
|
|
2366
|
+
source: n.source ?? "php-wasm"
|
|
2372
2367
|
}), n;
|
|
2373
2368
|
} finally {
|
|
2374
2369
|
try {
|
|
@@ -9182,10 +9177,6 @@ for existing apps using this option.`
|
|
|
9182
9177
|
code: {
|
|
9183
9178
|
type: "string",
|
|
9184
9179
|
description: "The code snippet to eval instead of a php file."
|
|
9185
|
-
},
|
|
9186
|
-
throwOnError: {
|
|
9187
|
-
type: "boolean",
|
|
9188
|
-
description: "Whether to throw an error if the PHP process exits with a non-zero code or outputs to stderr."
|
|
9189
9180
|
}
|
|
9190
9181
|
},
|
|
9191
9182
|
additionalProperties: !1
|
package/lib/steps/wp-cli.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wp-playground/blueprints",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.9",
|
|
4
4
|
"exports": {
|
|
5
5
|
".": {
|
|
6
6
|
"import": "./index.js",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"access": "public",
|
|
22
22
|
"directory": "../../../dist/packages/playground/blueprints"
|
|
23
23
|
},
|
|
24
|
-
"gitHead": "
|
|
24
|
+
"gitHead": "f6b98ad6d05617ee8cb1234c21318fdde17a6e56",
|
|
25
25
|
"engines": {
|
|
26
26
|
"node": ">=18.18.2",
|
|
27
27
|
"npm": ">=8.11.0"
|
package/schema-readme.md
CHANGED
|
@@ -5,5 +5,5 @@ Whenever the types are modified, the schema needs to be rebuilt using
|
|
|
5
5
|
`nx build playground-blueprints` and then committed to the repository.
|
|
6
6
|
|
|
7
7
|
Unfortunately, it is not auto-rebuilt in `npm run dev` mode as the
|
|
8
|
-
`dts-bundle-generator` utility we use for type
|
|
8
|
+
`dts-bundle-generator` utility we use for type rollups does not support
|
|
9
9
|
watching for changes.
|