@wp-playground/blueprints 0.1.45 → 0.1.49
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 +27 -20
- package/index.js +305 -277
- package/lib/steps/activate-plugin.d.ts +1 -1
- package/lib/steps/activate-theme.d.ts +12 -0
- package/lib/steps/client-methods.d.ts +174 -0
- package/lib/steps/handlers.d.ts +1 -0
- package/lib/steps/index.d.ts +16 -3
- package/lib/steps/install-plugin.d.ts +8 -3
- package/lib/steps/install-theme.d.ts +34 -1
- package/lib/steps/login.d.ts +19 -4
- package/lib/steps/site-data.d.ts +43 -0
- package/package.json +2 -2
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { StepHandler } from '.';
|
|
2
|
+
export interface ActivateThemeStep {
|
|
3
|
+
step: 'activateTheme';
|
|
4
|
+
themeFolderName: string;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Activates a WordPress theme in the Playground.
|
|
8
|
+
*
|
|
9
|
+
* @param playground The playground client.
|
|
10
|
+
* @param themeFolderName The theme folder name.
|
|
11
|
+
*/
|
|
12
|
+
export declare const activateTheme: StepHandler<ActivateThemeStep>;
|
|
@@ -1,56 +1,230 @@
|
|
|
1
1
|
import { PHPRunOptions, PHPRequest } from '@php-wasm/universal';
|
|
2
2
|
import { StepHandler } from '.';
|
|
3
|
+
/**
|
|
4
|
+
* @inheritDoc runPHP
|
|
5
|
+
* @hasRunnableExample
|
|
6
|
+
* @example
|
|
7
|
+
*
|
|
8
|
+
* <code>
|
|
9
|
+
* {
|
|
10
|
+
* "step": "runPHP",
|
|
11
|
+
* "code": "<?php echo 'Hello World'; ?>"
|
|
12
|
+
* }
|
|
13
|
+
* </code>
|
|
14
|
+
*/
|
|
3
15
|
export interface RunPHPStep {
|
|
16
|
+
/** The step identifier. */
|
|
4
17
|
step: 'runPHP';
|
|
18
|
+
/** The PHP code to run. */
|
|
5
19
|
code: string;
|
|
6
20
|
}
|
|
21
|
+
/**
|
|
22
|
+
* Runs PHP code.
|
|
23
|
+
*/
|
|
7
24
|
export declare const runPHP: StepHandler<RunPHPStep>;
|
|
25
|
+
/**
|
|
26
|
+
* @inheritDoc runPHP
|
|
27
|
+
* @hasRunnableExample
|
|
28
|
+
* @example
|
|
29
|
+
*
|
|
30
|
+
* <code>
|
|
31
|
+
* {
|
|
32
|
+
* "step": "runPHP",
|
|
33
|
+
* "options": {
|
|
34
|
+
* "code": "<?php echo $_SERVER['HTTP_CONTENT_TYPE']; ?>",
|
|
35
|
+
* "headers": {
|
|
36
|
+
* "Content-type": "text/plain"
|
|
37
|
+
* }
|
|
38
|
+
* }
|
|
39
|
+
* }
|
|
40
|
+
* </code>
|
|
41
|
+
*/
|
|
8
42
|
export interface RunPHPWithOptionsStep {
|
|
9
43
|
step: 'runPHPWithOptions';
|
|
10
44
|
options: PHPRunOptions;
|
|
11
45
|
}
|
|
46
|
+
/**
|
|
47
|
+
* Runs PHP code with the given options.
|
|
48
|
+
*/
|
|
12
49
|
export declare const runPHPWithOptions: StepHandler<RunPHPWithOptionsStep>;
|
|
50
|
+
/**
|
|
51
|
+
* @inheritDoc setPhpIniEntry
|
|
52
|
+
* @hasRunnableExample
|
|
53
|
+
* @example
|
|
54
|
+
*
|
|
55
|
+
* <code>
|
|
56
|
+
* {
|
|
57
|
+
* "step": "setPhpIniEntry",
|
|
58
|
+
* "key": "display_errors",
|
|
59
|
+
* "value": "1"
|
|
60
|
+
* }
|
|
61
|
+
* </code>
|
|
62
|
+
*/
|
|
13
63
|
export interface SetPhpIniEntryStep {
|
|
14
64
|
step: 'setPhpIniEntry';
|
|
15
65
|
key: string;
|
|
16
66
|
value: string;
|
|
17
67
|
}
|
|
68
|
+
/**
|
|
69
|
+
* Sets a PHP ini entry.
|
|
70
|
+
*/
|
|
18
71
|
export declare const setPhpIniEntry: StepHandler<SetPhpIniEntryStep>;
|
|
72
|
+
/**
|
|
73
|
+
* @inheritDoc request
|
|
74
|
+
* @needsLogin
|
|
75
|
+
* @hasRunnableExample
|
|
76
|
+
* @example
|
|
77
|
+
*
|
|
78
|
+
* <code>
|
|
79
|
+
* {
|
|
80
|
+
* "step": "request",
|
|
81
|
+
* "request": {
|
|
82
|
+
* "method": "POST",
|
|
83
|
+
* "url": "/wp-admin/admin-ajax.php",
|
|
84
|
+
* "formData": {
|
|
85
|
+
* "action": "my_action",
|
|
86
|
+
* "foo": "bar"
|
|
87
|
+
* }
|
|
88
|
+
* }
|
|
89
|
+
* }
|
|
90
|
+
* </code>
|
|
91
|
+
*/
|
|
19
92
|
export interface RequestStep {
|
|
20
93
|
step: 'request';
|
|
21
94
|
request: PHPRequest;
|
|
22
95
|
}
|
|
96
|
+
/**
|
|
97
|
+
* Sends a HTTP request to the Playground.
|
|
98
|
+
*/
|
|
23
99
|
export declare const request: StepHandler<RequestStep>;
|
|
100
|
+
/**
|
|
101
|
+
* @inheritDoc cp
|
|
102
|
+
* @hasRunnableExample
|
|
103
|
+
* @landingPage /index2.php
|
|
104
|
+
* @example
|
|
105
|
+
*
|
|
106
|
+
* <code>
|
|
107
|
+
* {
|
|
108
|
+
* "step": "cp",
|
|
109
|
+
* "fromPath": "/wordpress/index.php",
|
|
110
|
+
* "toPath": "/wordpress/index2.php"
|
|
111
|
+
* }
|
|
112
|
+
* </code>
|
|
113
|
+
*/
|
|
24
114
|
export interface CpStep {
|
|
25
115
|
step: 'cp';
|
|
26
116
|
fromPath: string;
|
|
27
117
|
toPath: string;
|
|
28
118
|
}
|
|
119
|
+
/**
|
|
120
|
+
* Copies a file from one path to another.
|
|
121
|
+
*/
|
|
29
122
|
export declare const cp: StepHandler<CpStep>;
|
|
123
|
+
/**
|
|
124
|
+
* @inheritDoc mv
|
|
125
|
+
* @hasRunnableExample
|
|
126
|
+
* @landingPage /index2.php
|
|
127
|
+
* @example
|
|
128
|
+
*
|
|
129
|
+
* <code>
|
|
130
|
+
* {
|
|
131
|
+
* "step": "mv",
|
|
132
|
+
* "fromPath": "/wordpress/index.php",
|
|
133
|
+
* "toPath": "/wordpress/index2.php"
|
|
134
|
+
* }
|
|
135
|
+
* </code>
|
|
136
|
+
*/
|
|
30
137
|
export interface MvStep {
|
|
31
138
|
step: 'mv';
|
|
32
139
|
fromPath: string;
|
|
33
140
|
toPath: string;
|
|
34
141
|
}
|
|
142
|
+
/**
|
|
143
|
+
* Moves a file or directory from one path to another.
|
|
144
|
+
*/
|
|
35
145
|
export declare const mv: StepHandler<MvStep>;
|
|
146
|
+
/**
|
|
147
|
+
* @inheritDoc mkdir
|
|
148
|
+
* @hasRunnableExample
|
|
149
|
+
* @example
|
|
150
|
+
*
|
|
151
|
+
* <code>
|
|
152
|
+
* {
|
|
153
|
+
* "step": "mkdir",
|
|
154
|
+
* "path": "/wordpress/my-new-folder"
|
|
155
|
+
* }
|
|
156
|
+
* </code>
|
|
157
|
+
*/
|
|
36
158
|
export interface MkdirStep {
|
|
37
159
|
step: 'mkdir';
|
|
38
160
|
path: string;
|
|
39
161
|
}
|
|
162
|
+
/**
|
|
163
|
+
* Creates a directory at the specified path.
|
|
164
|
+
*/
|
|
40
165
|
export declare const mkdir: StepHandler<MkdirStep>;
|
|
166
|
+
/**
|
|
167
|
+
* @inheritDoc rm
|
|
168
|
+
* @hasRunnableExample
|
|
169
|
+
* @landingPage /index.php
|
|
170
|
+
* @example
|
|
171
|
+
*
|
|
172
|
+
* <code>
|
|
173
|
+
* {
|
|
174
|
+
* "step": "rm",
|
|
175
|
+
* "path": "/wordpress/index.php"
|
|
176
|
+
* }
|
|
177
|
+
* </code>
|
|
178
|
+
*/
|
|
41
179
|
export interface RmStep {
|
|
42
180
|
step: 'rm';
|
|
43
181
|
path: string;
|
|
44
182
|
}
|
|
183
|
+
/**
|
|
184
|
+
* Removes a file at the specified path.
|
|
185
|
+
*/
|
|
45
186
|
export declare const rm: StepHandler<RmStep>;
|
|
187
|
+
/**
|
|
188
|
+
* @inheritDoc rmdir
|
|
189
|
+
* @hasRunnableExample
|
|
190
|
+
* @landingPage /wp-admin/
|
|
191
|
+
* @example
|
|
192
|
+
*
|
|
193
|
+
* <code>
|
|
194
|
+
* {
|
|
195
|
+
* "step": "rm",
|
|
196
|
+
* "path": "/wordpress/wp-admin"
|
|
197
|
+
* }
|
|
198
|
+
* </code>
|
|
199
|
+
*/
|
|
46
200
|
export interface RmdirStep {
|
|
47
201
|
step: 'rmdir';
|
|
48
202
|
path: string;
|
|
49
203
|
}
|
|
204
|
+
/**
|
|
205
|
+
* Removes a directory at the specified path.
|
|
206
|
+
*/
|
|
50
207
|
export declare const rmdir: StepHandler<RmdirStep>;
|
|
208
|
+
/**
|
|
209
|
+
* @inheritDoc writeFile
|
|
210
|
+
* @hasRunnableExample
|
|
211
|
+
* @landingPage /test.php
|
|
212
|
+
* @example
|
|
213
|
+
*
|
|
214
|
+
* <code>
|
|
215
|
+
* {
|
|
216
|
+
* "step": "writeFile",
|
|
217
|
+
* "path": "/wordpress/test.php",
|
|
218
|
+
* "data": "<?php echo 'Hello World!'; ?>"
|
|
219
|
+
* }
|
|
220
|
+
* </code>
|
|
221
|
+
*/
|
|
51
222
|
export interface WriteFileStep<ResourceType> {
|
|
52
223
|
step: 'writeFile';
|
|
53
224
|
path: string;
|
|
54
225
|
data: ResourceType | string | Uint8Array;
|
|
55
226
|
}
|
|
227
|
+
/**
|
|
228
|
+
* Writes data to a file at the specified path.
|
|
229
|
+
*/
|
|
56
230
|
export declare const writeFile: StepHandler<WriteFileStep<File>>;
|
package/lib/steps/handlers.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { activatePlugin } from './activate-plugin';
|
|
2
|
+
export { activateTheme } from './activate-theme';
|
|
2
3
|
export { applyWordPressPatches } from './apply-wordpress-patches';
|
|
3
4
|
export { rm, cp, mkdir, rmdir, mv, setPhpIniEntry, runPHP, runPHPWithOptions, request, writeFile, } from './client-methods';
|
|
4
5
|
export { defineSiteUrl } from './define-site-url';
|
package/lib/steps/index.d.ts
CHANGED
|
@@ -12,6 +12,7 @@ import { RunWpInstallationWizardStep, WordPressInstallationOptions } from './run
|
|
|
12
12
|
import { SetSiteOptionsStep, UpdateUserMetaStep } from './site-data';
|
|
13
13
|
import { RmStep, CpStep, MkdirStep, RmdirStep, MvStep, SetPhpIniEntryStep, RunPHPStep, RunPHPWithOptionsStep, RequestStep, WriteFileStep } from './client-methods';
|
|
14
14
|
import { DefineWpConfigConstsStep } from './define-wp-config-consts';
|
|
15
|
+
import { ActivateThemeStep } from './activate-theme';
|
|
15
16
|
import { DefineVirtualWpConfigConstsStep } from './define-virtual-wp-config-consts';
|
|
16
17
|
export type Step = GenericStep<FileReference>;
|
|
17
18
|
export type StepDefinition = Step & {
|
|
@@ -20,9 +21,21 @@ export type StepDefinition = Step & {
|
|
|
20
21
|
caption?: string;
|
|
21
22
|
};
|
|
22
23
|
};
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
24
|
+
/**
|
|
25
|
+
* If you add a step here, make sure to also
|
|
26
|
+
* add it to the exports below.
|
|
27
|
+
*/
|
|
28
|
+
export type GenericStep<Resource> = ActivatePluginStep | ActivateThemeStep | ApplyWordPressPatchesStep | CpStep | DefineWpConfigConstsStep | DefineVirtualWpConfigConstsStep | DefineSiteUrlStep | ImportFileStep<Resource> | InstallPluginStep<Resource> | InstallThemeStep<Resource> | LoginStep | MkdirStep | MvStep | RequestStep | ReplaceSiteStep<Resource> | RmStep | RmdirStep | RunPHPStep | RunPHPWithOptionsStep | RunWpInstallationWizardStep | SetPhpIniEntryStep | SetSiteOptionsStep | UnzipStep | UpdateUserMetaStep | WriteFileStep<Resource>;
|
|
29
|
+
export type { ActivatePluginStep, ActivateThemeStep, ApplyWordPressPatchesStep, CpStep, DefineWpConfigConstsStep, DefineVirtualWpConfigConstsStep, DefineSiteUrlStep, ImportFileStep, InstallPluginStep, InstallPluginOptions, InstallThemeStep, InstallThemeOptions, LoginStep, MkdirStep, MvStep, RequestStep, ReplaceSiteStep, RmStep, RmdirStep, RunPHPStep, RunPHPWithOptionsStep, RunWpInstallationWizardStep, WordPressInstallationOptions, SetPhpIniEntryStep, SetSiteOptionsStep, UnzipStep, UpdateUserMetaStep, WriteFileStep, };
|
|
30
|
+
export type StepHandler<S extends GenericStep<File>> = (
|
|
31
|
+
/**
|
|
32
|
+
* A PHP instance or Playground client.
|
|
33
|
+
*/
|
|
34
|
+
php: UniversalPHP, args: Omit<S, 'step'>,
|
|
35
|
+
/**
|
|
36
|
+
* Progress reporting details.
|
|
37
|
+
*/
|
|
38
|
+
progressArgs?: {
|
|
26
39
|
tracker: ProgressTracker;
|
|
27
40
|
initialCaption?: string;
|
|
28
41
|
}) => any;
|
|
@@ -1,13 +1,18 @@
|
|
|
1
1
|
import { StepHandler } from '.';
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
4
|
-
*
|
|
3
|
+
* @inheritDoc installPlugin
|
|
4
|
+
* @hasRunnableExample
|
|
5
|
+
* @needsLogin
|
|
6
|
+
* @landingPage /wp-admin/plugins.php
|
|
5
7
|
* @example
|
|
6
8
|
*
|
|
7
9
|
* <code>
|
|
8
10
|
* {
|
|
9
11
|
* "step": "installPlugin",
|
|
10
|
-
* "pluginZipFile":
|
|
12
|
+
* "pluginZipFile": {
|
|
13
|
+
* "resource": "wordpress.org/plugins",
|
|
14
|
+
* "slug": "gutenberg"
|
|
15
|
+
* },
|
|
11
16
|
* "options": {
|
|
12
17
|
* "activate": true
|
|
13
18
|
* }
|
|
@@ -1,8 +1,41 @@
|
|
|
1
1
|
import { StepHandler } from '.';
|
|
2
|
+
/**
|
|
3
|
+
* @inheritDoc installTheme
|
|
4
|
+
* @hasRunnableExample
|
|
5
|
+
* @needsLogin
|
|
6
|
+
* @example
|
|
7
|
+
*
|
|
8
|
+
* <code>
|
|
9
|
+
* {
|
|
10
|
+
* "step": "installTheme",
|
|
11
|
+
* "themeZipFile": {
|
|
12
|
+
* "resource": "wordpress.org/themes",
|
|
13
|
+
* "slug": "pendant"
|
|
14
|
+
* },
|
|
15
|
+
* "options": {
|
|
16
|
+
* "activate": true
|
|
17
|
+
* }
|
|
18
|
+
* }
|
|
19
|
+
* </code>
|
|
20
|
+
*/
|
|
2
21
|
export interface InstallThemeStep<ResourceType> {
|
|
22
|
+
/**
|
|
23
|
+
* The step identifier.
|
|
24
|
+
*/
|
|
3
25
|
step: 'installTheme';
|
|
26
|
+
/**
|
|
27
|
+
* The theme zip file to install.
|
|
28
|
+
*/
|
|
4
29
|
themeZipFile: ResourceType;
|
|
5
|
-
|
|
30
|
+
/**
|
|
31
|
+
* Optional installation options.
|
|
32
|
+
*/
|
|
33
|
+
options?: {
|
|
34
|
+
/**
|
|
35
|
+
* Whether to activate the theme after installing it.
|
|
36
|
+
*/
|
|
37
|
+
activate?: boolean;
|
|
38
|
+
};
|
|
6
39
|
}
|
|
7
40
|
export interface InstallThemeOptions {
|
|
8
41
|
/**
|
package/lib/steps/login.d.ts
CHANGED
|
@@ -1,16 +1,31 @@
|
|
|
1
1
|
import { StepHandler } from '.';
|
|
2
|
+
/**
|
|
3
|
+
* @inheritDoc login
|
|
4
|
+
* @hasRunnableExample
|
|
5
|
+
* @example
|
|
6
|
+
*
|
|
7
|
+
* <code>
|
|
8
|
+
* {
|
|
9
|
+
* "step": "login",
|
|
10
|
+
* "username": "admin",
|
|
11
|
+
* "password": "password"
|
|
12
|
+
* }
|
|
13
|
+
* </code>
|
|
14
|
+
*/
|
|
2
15
|
export type LoginStep = {
|
|
3
16
|
step: 'login';
|
|
17
|
+
/**
|
|
18
|
+
* The user to log in as. Defaults to 'admin'.
|
|
19
|
+
*/
|
|
4
20
|
username?: string;
|
|
21
|
+
/**
|
|
22
|
+
* The password to log in with. Defaults to 'password'.
|
|
23
|
+
*/
|
|
5
24
|
password?: string;
|
|
6
25
|
};
|
|
7
26
|
/**
|
|
8
27
|
* Logs in to the Playground.
|
|
9
28
|
* Under the hood, this function submits the wp-login.php form
|
|
10
29
|
* just like a user would.
|
|
11
|
-
*
|
|
12
|
-
* @param playground The playground client.
|
|
13
|
-
* @param user The user to log in as. Defaults to 'admin'.
|
|
14
|
-
* @param password The password to log in with. Defaults to 'password'.
|
|
15
30
|
*/
|
|
16
31
|
export declare const login: StepHandler<LoginStep>;
|
package/lib/steps/site-data.d.ts
CHANGED
|
@@ -1,12 +1,55 @@
|
|
|
1
1
|
import { StepHandler } from '.';
|
|
2
|
+
/**
|
|
3
|
+
* @inheritDoc setSiteOptions
|
|
4
|
+
* @hasRunnableExample
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
*
|
|
8
|
+
* <code>
|
|
9
|
+
* {
|
|
10
|
+
* "step": "setSiteOptions",
|
|
11
|
+
* "options": {
|
|
12
|
+
* "blogname": "My Blog",
|
|
13
|
+
* "blogdescription": "A great blog"
|
|
14
|
+
* }
|
|
15
|
+
* }
|
|
16
|
+
* </code>
|
|
17
|
+
*/
|
|
2
18
|
export type SetSiteOptionsStep = {
|
|
19
|
+
/** The name of the step. Must be "setSiteOptions". */
|
|
3
20
|
step: 'setSiteOptions';
|
|
21
|
+
/** The options to set on the site. */
|
|
4
22
|
options: Record<string, unknown>;
|
|
5
23
|
};
|
|
24
|
+
/**
|
|
25
|
+
* Sets site options. This is equivalent to calling `update_option` for each
|
|
26
|
+
* option in the `options` object.
|
|
27
|
+
*/
|
|
6
28
|
export declare const setSiteOptions: StepHandler<SetSiteOptionsStep>;
|
|
29
|
+
/**
|
|
30
|
+
* @inheritDoc updateUserMeta
|
|
31
|
+
* @hasRunnableExample
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
*
|
|
35
|
+
* <code>
|
|
36
|
+
* {
|
|
37
|
+
* "step": "updateUserMeta",
|
|
38
|
+
* "meta": {
|
|
39
|
+
* "first_name": "John",
|
|
40
|
+
* "last_name": "Doe"
|
|
41
|
+
* },
|
|
42
|
+
* "userId": 1
|
|
43
|
+
* }
|
|
44
|
+
* </code>
|
|
45
|
+
*/
|
|
7
46
|
export interface UpdateUserMetaStep {
|
|
8
47
|
step: 'updateUserMeta';
|
|
9
48
|
meta: Record<string, unknown>;
|
|
10
49
|
userId: number;
|
|
11
50
|
}
|
|
51
|
+
/**
|
|
52
|
+
* Updates user meta. This is equivalent to calling `update_user_meta` for each
|
|
53
|
+
* meta value in the `meta` object.
|
|
54
|
+
*/
|
|
12
55
|
export declare const updateUserMeta: StepHandler<UpdateUserMetaStep>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wp-playground/blueprints",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.49",
|
|
4
4
|
"exports": {
|
|
5
5
|
".": {
|
|
6
6
|
"import": "./index.js",
|
|
@@ -21,5 +21,5 @@
|
|
|
21
21
|
"access": "public",
|
|
22
22
|
"directory": "../../../dist/packages/playground/blueprints"
|
|
23
23
|
},
|
|
24
|
-
"gitHead": "
|
|
24
|
+
"gitHead": "93834fa77a89c21be2ade4c1d67430981ed92c83"
|
|
25
25
|
}
|