@wp-playground/blueprints 0.1.51 → 0.1.58
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 +37 -31
- package/index.js +676 -683
- package/lib/steps/activate-plugin.d.ts +1 -1
- package/lib/steps/client-methods.d.ts +1 -1
- package/lib/steps/common.d.ts +6 -5
- package/lib/steps/define-wp-config-consts.d.ts +10 -1
- package/lib/steps/handlers.d.ts +0 -1
- package/lib/steps/index.d.ts +9 -10
- package/lib/steps/install-asset.d.ts +23 -0
- package/lib/steps/install-plugin.d.ts +0 -2
- package/lib/steps/install-theme.d.ts +0 -2
- package/package.json +2 -2
- package/lib/steps/define-virtual-wp-config-consts.d.ts +0 -19
|
@@ -2,11 +2,11 @@ import { StepHandler } from '.';
|
|
|
2
2
|
export interface ActivatePluginStep {
|
|
3
3
|
step: 'activatePlugin';
|
|
4
4
|
pluginPath: string;
|
|
5
|
+
pluginName?: string;
|
|
5
6
|
}
|
|
6
7
|
/**
|
|
7
8
|
* Activates a WordPress plugin in the Playground.
|
|
8
9
|
*
|
|
9
10
|
* @param playground The playground client.
|
|
10
|
-
* @param plugin The plugin slug.
|
|
11
11
|
*/
|
|
12
12
|
export declare const activatePlugin: StepHandler<ActivatePluginStep>;
|
|
@@ -31,7 +31,7 @@ export declare const runPHP: StepHandler<RunPHPStep>;
|
|
|
31
31
|
* {
|
|
32
32
|
* "step": "runPHP",
|
|
33
33
|
* "options": {
|
|
34
|
-
* "code": "<?php echo $_SERVER['
|
|
34
|
+
* "code": "<?php echo $_SERVER['CONTENT_TYPE']; ?>",
|
|
35
35
|
* "headers": {
|
|
36
36
|
* "Content-type": "text/plain"
|
|
37
37
|
* }
|
package/lib/steps/common.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export declare function asDOM(response: PHPResponse): Document;
|
|
1
|
+
import type { UniversalPHP } from '@php-wasm/universal';
|
|
3
2
|
export declare function zipNameToHumanName(zipName: string): string;
|
|
4
3
|
type PatchFileCallback = (contents: string) => string | Uint8Array;
|
|
5
4
|
export declare function updateFile(php: UniversalPHP, path: string, callback: PatchFileCallback): Promise<void>;
|
|
6
5
|
export declare function fileToUint8Array(file: File): Promise<Uint8Array>;
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
declare const FileWithArrayBuffer: {
|
|
7
|
+
new (fileBits: BlobPart[], fileName: string, options?: FilePropertyBag | undefined): File;
|
|
8
|
+
prototype: File;
|
|
9
|
+
};
|
|
10
|
+
export { FileWithArrayBuffer as File };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { StepHandler } from '.';
|
|
2
|
+
export declare const VFS_TMP_DIRECTORY = "/vfs-blueprints";
|
|
2
3
|
/**
|
|
3
4
|
* The step object for defining constants in the wp-config.php file of a WordPress installation.
|
|
4
5
|
*/
|
|
@@ -6,11 +7,19 @@ export interface DefineWpConfigConstsStep {
|
|
|
6
7
|
step: 'defineWpConfigConsts';
|
|
7
8
|
/** The constants to define */
|
|
8
9
|
consts: Record<string, unknown>;
|
|
10
|
+
/**
|
|
11
|
+
* Enables the virtualization of wp-config.php and playground-consts.json files, leaving the local system files untouched.
|
|
12
|
+
* The variables defined in the /vfs-blueprints/playground-consts.json file are loaded via the auto_prepend_file directive in the php.ini file.
|
|
13
|
+
* @default false
|
|
14
|
+
* @see https://www.php.net/manual/en/ini.core.php#ini.auto-prepend-file
|
|
15
|
+
*/
|
|
16
|
+
virtualize?: boolean;
|
|
9
17
|
}
|
|
10
18
|
/**
|
|
11
19
|
* Sets site URL of the WordPress installation.
|
|
12
20
|
*
|
|
13
21
|
* @param playground The playground client.
|
|
14
|
-
* @param wpConfigConst
|
|
22
|
+
* @param wpConfigConst An object containing the constants to be defined and the optional virtual file system configuration file path.
|
|
23
|
+
* @returns Returns the virtual file system configuration file path.
|
|
15
24
|
*/
|
|
16
25
|
export declare const defineWpConfigConsts: StepHandler<DefineWpConfigConstsStep>;
|
package/lib/steps/handlers.d.ts
CHANGED
|
@@ -10,4 +10,3 @@ export { login } from './login';
|
|
|
10
10
|
export { runWpInstallationWizard } from './run-wp-installation-wizard';
|
|
11
11
|
export { setSiteOptions, updateUserMeta } from './site-data';
|
|
12
12
|
export { defineWpConfigConsts } from './define-wp-config-consts';
|
|
13
|
-
export { defineVirtualWpConfigConsts } from './define-virtual-wp-config-consts';
|
package/lib/steps/index.d.ts
CHANGED
|
@@ -13,7 +13,6 @@ 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
15
|
import { ActivateThemeStep } from './activate-theme';
|
|
16
|
-
import { DefineVirtualWpConfigConstsStep } from './define-virtual-wp-config-consts';
|
|
17
16
|
export type Step = GenericStep<FileReference>;
|
|
18
17
|
export type StepDefinition = Step & {
|
|
19
18
|
progress?: {
|
|
@@ -25,17 +24,17 @@ export type StepDefinition = Step & {
|
|
|
25
24
|
* If you add a step here, make sure to also
|
|
26
25
|
* add it to the exports below.
|
|
27
26
|
*/
|
|
28
|
-
export type GenericStep<Resource> = ActivatePluginStep | ActivateThemeStep | ApplyWordPressPatchesStep | CpStep | DefineWpConfigConstsStep |
|
|
29
|
-
export type { ActivatePluginStep, ActivateThemeStep, ApplyWordPressPatchesStep, CpStep, DefineWpConfigConstsStep,
|
|
30
|
-
export type StepHandler<S extends GenericStep<File>> = (
|
|
31
|
-
/**
|
|
32
|
-
* A PHP instance or Playground client.
|
|
33
|
-
*/
|
|
34
|
-
php: UniversalPHP, args: Omit<S, 'step'>,
|
|
27
|
+
export type GenericStep<Resource> = ActivatePluginStep | ActivateThemeStep | ApplyWordPressPatchesStep | CpStep | DefineWpConfigConstsStep | DefineSiteUrlStep | ImportFileStep<Resource> | InstallPluginStep<Resource> | InstallThemeStep<Resource> | LoginStep | MkdirStep | MvStep | RequestStep | ReplaceSiteStep<Resource> | RmStep | RmdirStep | RunPHPStep | RunPHPWithOptionsStep | RunWpInstallationWizardStep | SetPhpIniEntryStep | SetSiteOptionsStep | UnzipStep | UpdateUserMetaStep | WriteFileStep<Resource>;
|
|
28
|
+
export type { ActivatePluginStep, ActivateThemeStep, ApplyWordPressPatchesStep, CpStep, DefineWpConfigConstsStep, DefineSiteUrlStep, ImportFileStep, InstallPluginStep, InstallPluginOptions, InstallThemeStep, InstallThemeOptions, LoginStep, MkdirStep, MvStep, RequestStep, ReplaceSiteStep, RmStep, RmdirStep, RunPHPStep, RunPHPWithOptionsStep, RunWpInstallationWizardStep, WordPressInstallationOptions, SetPhpIniEntryStep, SetSiteOptionsStep, UnzipStep, UpdateUserMetaStep, WriteFileStep, };
|
|
35
29
|
/**
|
|
36
30
|
* Progress reporting details.
|
|
37
31
|
*/
|
|
38
|
-
|
|
32
|
+
export type StepProgress = {
|
|
39
33
|
tracker: ProgressTracker;
|
|
40
34
|
initialCaption?: string;
|
|
41
|
-
}
|
|
35
|
+
};
|
|
36
|
+
export type StepHandler<S extends GenericStep<File>> = (
|
|
37
|
+
/**
|
|
38
|
+
* A PHP instance or Playground client.
|
|
39
|
+
*/
|
|
40
|
+
php: UniversalPHP, args: Omit<S, 'step'>, progressArgs?: StepProgress) => any;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { UniversalPHP } from '@php-wasm/universal';
|
|
2
|
+
export interface InstallAssetOptions {
|
|
3
|
+
/**
|
|
4
|
+
* The zip file to install.
|
|
5
|
+
*/
|
|
6
|
+
zipFile: File;
|
|
7
|
+
/**
|
|
8
|
+
* Target path to extract the main folder.
|
|
9
|
+
* @example
|
|
10
|
+
*
|
|
11
|
+
* <code>
|
|
12
|
+
* const targetPath = `${await playground.documentRoot}/wp-content/plugins`;
|
|
13
|
+
* </code>
|
|
14
|
+
*/
|
|
15
|
+
targetPath: string;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Install asset: Extract folder from zip file and move it to target
|
|
19
|
+
*/
|
|
20
|
+
export declare function installAsset(playground: UniversalPHP, { targetPath, zipFile }: InstallAssetOptions): Promise<{
|
|
21
|
+
assetFolderPath: string;
|
|
22
|
+
assetFolderName: string;
|
|
23
|
+
}>;
|
|
@@ -41,8 +41,6 @@ export interface InstallPluginOptions {
|
|
|
41
41
|
}
|
|
42
42
|
/**
|
|
43
43
|
* Installs a WordPress plugin in the Playground.
|
|
44
|
-
* Technically, it uses the same plugin upload form as a WordPress user
|
|
45
|
-
* would, and then activates the plugin if needed.
|
|
46
44
|
*
|
|
47
45
|
* @param playground The playground client.
|
|
48
46
|
* @param pluginZipFile The plugin zip file.
|
|
@@ -45,8 +45,6 @@ export interface InstallThemeOptions {
|
|
|
45
45
|
}
|
|
46
46
|
/**
|
|
47
47
|
* Installs a WordPress theme in the Playground.
|
|
48
|
-
* Technically, it uses the same theme upload form as a WordPress user
|
|
49
|
-
* would, and then activates the theme if needed.
|
|
50
48
|
*
|
|
51
49
|
* @param playground The playground client.
|
|
52
50
|
* @param themeZipFile The theme zip file.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wp-playground/blueprints",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.58",
|
|
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": "dbc77ed4c0b0a2625cfbe08722fade036c69a425"
|
|
25
25
|
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { StepHandler } from '.';
|
|
2
|
-
/**
|
|
3
|
-
* The step object for defining constants in the VFS_CONFIG_FILE_PATH php file and loaded using the auto_prepend_file php.ini directive.
|
|
4
|
-
*/
|
|
5
|
-
export interface DefineVirtualWpConfigConstsStep {
|
|
6
|
-
step: 'defineVirtualWpConfigConsts';
|
|
7
|
-
/** The constants to define */
|
|
8
|
-
consts: Record<string, unknown>;
|
|
9
|
-
}
|
|
10
|
-
/**
|
|
11
|
-
* Function to define constants in the virtual VFS_CONFIG_FILE_PATH php file of a WordPress installation.
|
|
12
|
-
* The file should be dynamically loaded using the auto_prepend_file php.ini directive after this step.
|
|
13
|
-
*
|
|
14
|
-
* @param playground The playground client.
|
|
15
|
-
* @param wpConfigConst An object containing the constants to be defined and the optional virtual file system configuration file path.
|
|
16
|
-
* @returns Returns the virtual file system configuration file path.
|
|
17
|
-
* @see {@link https://www.php.net/manual/en/ini.core.php#ini.auto-prepend-file}
|
|
18
|
-
*/
|
|
19
|
-
export declare const defineVirtualWpConfigConsts: StepHandler<DefineVirtualWpConfigConstsStep>;
|