@wp-playground/blueprints 0.9.46 → 1.0.1

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.
@@ -1,4 +1,4 @@
1
- import { SupportedPHPExtensionBundle, SupportedPHPVersion } from '@php-wasm/universal';
1
+ import { SupportedPHPVersion } from '@php-wasm/universal';
2
2
  import { StepDefinition } from './steps';
3
3
  import { FileReference } from './resources';
4
4
  export type ExtraLibrary = 'wp-cli';
@@ -84,9 +84,9 @@ export interface Blueprint {
84
84
  password: string;
85
85
  };
86
86
  /**
87
- * The PHP extensions to use.
87
+ * @deprecated No longer used. Feel free to remove it from your Blueprint.
88
88
  */
89
- phpExtensionBundles?: SupportedPHPExtensionBundle[];
89
+ phpExtensionBundles?: any;
90
90
  /**
91
91
  * The steps to run after every other operation in this Blueprint was
92
92
  * executed.
package/lib/compile.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { ProgressTracker } from '@php-wasm/progress';
2
2
  import { Semaphore } from '@php-wasm/util';
3
- import { SupportedPHPExtension, SupportedPHPVersion, UniversalPHP } from '@php-wasm/universal';
3
+ import { SupportedPHPVersion, UniversalPHP } from '@php-wasm/universal';
4
4
  import { StepDefinition } from './steps';
5
5
  import { Blueprint, ExtraLibrary } from './blueprint';
6
6
  export type CompiledStep = (php: UniversalPHP) => Promise<void> | void;
@@ -10,8 +10,6 @@ export interface CompiledBlueprint {
10
10
  php: SupportedPHPVersion;
11
11
  wp: string;
12
12
  };
13
- /** The requested PHP extensions to load */
14
- phpExtensions: SupportedPHPExtension[];
15
13
  features: {
16
14
  /** Should boot with support for network request via wp_safe_remote_get? */
17
15
  networking: boolean;
@@ -28,6 +26,14 @@ export interface CompileBlueprintOptions {
28
26
  semaphore?: Semaphore;
29
27
  /** Optional callback with step output */
30
28
  onStepCompleted?: OnStepCompleted;
29
+ /**
30
+ * Proxy URL to use for cross-origin requests.
31
+ *
32
+ * For example, if corsProxy is set to "https://cors.wordpress.net/proxy.php",
33
+ * then the CORS requests to https://github.com/WordPress/gutenberg.git would actually
34
+ * be made to https://cors.wordpress.net/proxy.php/https://github.com/WordPress/gutenberg.git.
35
+ */
36
+ corsProxy?: string;
31
37
  }
32
38
  /**
33
39
  * Compiles Blueprint into a form that can be executed.
@@ -37,7 +43,7 @@ export interface CompileBlueprintOptions {
37
43
  * @param options Additional options for the compilation
38
44
  * @returns The compiled blueprint
39
45
  */
40
- export declare function compileBlueprint(blueprint: Blueprint, { progress, semaphore, onStepCompleted, }?: CompileBlueprintOptions): CompiledBlueprint;
46
+ export declare function compileBlueprint(blueprint: Blueprint, { progress, semaphore, onStepCompleted, corsProxy, }?: CompileBlueprintOptions): CompiledBlueprint;
41
47
  export declare function validateBlueprint(blueprintMaybe: object): {
42
48
  valid: true;
43
49
  errors?: undefined;
@@ -1,7 +1,8 @@
1
1
  import { ProgressTracker } from '@php-wasm/progress';
2
- import { UniversalPHP } from '@php-wasm/universal';
2
+ import { FileTree, UniversalPHP } from '@php-wasm/universal';
3
3
  import { Semaphore } from '@php-wasm/util';
4
- export declare const ResourceTypes: readonly ["vfs", "literal", "wordpress.org/themes", "wordpress.org/plugins", "url"];
4
+ export type { FileTree };
5
+ export declare const ResourceTypes: readonly ["vfs", "literal", "wordpress.org/themes", "wordpress.org/plugins", "url", "git:directory"];
5
6
  export type VFSReference = {
6
7
  /** Identifies the file resource as Virtual File System (VFS) */
7
8
  resource: 'vfs';
@@ -36,19 +37,41 @@ export type UrlReference = {
36
37
  /** Optional caption for displaying a progress message */
37
38
  caption?: string;
38
39
  };
39
- export type FileReference = VFSReference | LiteralReference | CoreThemeReference | CorePluginReference | UrlReference;
40
- export declare function isFileReference(ref: any): ref is FileReference;
41
- export interface ResourceOptions {
42
- /** Optional semaphore to limit concurrent downloads */
43
- semaphore?: Semaphore;
44
- progress?: ProgressTracker;
40
+ export type GitDirectoryReference = {
41
+ /** Identifies the file resource as a git directory */
42
+ resource: 'git:directory';
43
+ /** The URL of the git repository */
44
+ url: string;
45
+ /** The branch of the git repository */
46
+ ref: string;
47
+ /** The path to the directory in the git repository */
48
+ path: string;
49
+ };
50
+ export interface Directory {
51
+ files: FileTree;
52
+ name: string;
45
53
  }
46
- export declare abstract class Resource {
54
+ export type DirectoryLiteralReference = Directory & {
55
+ /** Identifies the file resource as a git directory */
56
+ resource: 'literal:directory';
57
+ };
58
+ export type FileReference = VFSReference | LiteralReference | CoreThemeReference | CorePluginReference | UrlReference;
59
+ export type DirectoryReference = GitDirectoryReference | DirectoryLiteralReference;
60
+ export declare function isResourceReference(ref: any): ref is FileReference;
61
+ export declare abstract class Resource<T extends File | Directory> {
47
62
  /** Optional progress tracker to monitor progress */
48
- abstract progress?: ProgressTracker;
63
+ protected _progress?: ProgressTracker;
64
+ get progress(): ProgressTracker | undefined;
65
+ set progress(value: ProgressTracker | undefined);
49
66
  /** A Promise that resolves to the file contents */
50
- protected promise?: Promise<File>;
67
+ protected promise?: Promise<T>;
51
68
  protected playground?: UniversalPHP;
69
+ setPlayground(playground: UniversalPHP): void;
70
+ abstract resolve(): Promise<T>;
71
+ /** The name of the referenced file */
72
+ abstract get name(): string;
73
+ /** Whether this Resource is loaded asynchronously */
74
+ get isAsync(): boolean;
52
75
  /**
53
76
  * Creates a new Resource based on the given file reference
54
77
  *
@@ -56,32 +79,43 @@ export declare abstract class Resource {
56
79
  * @param options Additional options for the Resource
57
80
  * @returns A new Resource instance
58
81
  */
59
- static create(ref: FileReference, { semaphore, progress }: ResourceOptions): Resource;
60
- setPlayground(playground: UniversalPHP): void;
61
- /**
62
- * Resolves the file contents
63
- * @returns The resolved file.
64
- */
65
- abstract resolve(): Promise<File>;
66
- /** The name of the referenced file */
67
- abstract get name(): string;
68
- /** Whether this Resource is loaded asynchronously */
82
+ static create(ref: FileReference | DirectoryReference, { semaphore, progress, corsProxy, }: {
83
+ /** Optional semaphore to limit concurrent downloads */
84
+ semaphore?: Semaphore;
85
+ progress?: ProgressTracker;
86
+ corsProxy?: string;
87
+ }): Resource<File | Directory>;
88
+ }
89
+ export declare abstract class ResourceDecorator<T extends File | Directory> extends Resource<T> {
90
+ protected resource: Resource<T>;
91
+ constructor(resource: Resource<T>);
92
+ /** @inheritDoc */
93
+ get progress(): ProgressTracker | undefined;
94
+ /** @inheritDoc */
95
+ set progress(value: ProgressTracker | undefined);
96
+ /** @inheritDoc */
97
+ abstract resolve(): Promise<T>;
98
+ /** @inheritDoc */
99
+ get name(): string;
100
+ /** @inheritDoc */
69
101
  get isAsync(): boolean;
102
+ /** @inheritDoc */
103
+ setPlayground(playground: UniversalPHP): void;
70
104
  }
71
105
  /**
72
106
  * A `Resource` that represents a file in the VFS (virtual file system) of the
73
107
  * playground.
74
108
  */
75
- export declare class VFSResource extends Resource {
109
+ export declare class VFSResource extends Resource<File> {
76
110
  private resource;
77
- progress?: ProgressTracker | undefined;
111
+ _progress?: ProgressTracker | undefined;
78
112
  /**
79
113
  * Creates a new instance of `VFSResource`.
80
114
  * @param playground The playground client.
81
115
  * @param resource The VFS reference.
82
116
  * @param progress The progress tracker.
83
117
  */
84
- constructor(resource: VFSReference, progress?: ProgressTracker | undefined);
118
+ constructor(resource: VFSReference, _progress?: ProgressTracker | undefined);
85
119
  /** @inheritDoc */
86
120
  resolve(): Promise<File>;
87
121
  /** @inheritDoc */
@@ -90,15 +124,15 @@ export declare class VFSResource extends Resource {
90
124
  /**
91
125
  * A `Resource` that represents a literal file.
92
126
  */
93
- export declare class LiteralResource extends Resource {
127
+ export declare class LiteralResource extends Resource<File> {
94
128
  private resource;
95
- progress?: ProgressTracker | undefined;
129
+ _progress?: ProgressTracker | undefined;
96
130
  /**
97
131
  * Creates a new instance of `LiteralResource`.
98
132
  * @param resource The literal reference.
99
133
  * @param progress The progress tracker.
100
134
  */
101
- constructor(resource: LiteralReference, progress?: ProgressTracker | undefined);
135
+ constructor(resource: LiteralReference, _progress?: ProgressTracker | undefined);
102
136
  /** @inheritDoc */
103
137
  resolve(): Promise<File>;
104
138
  /** @inheritDoc */
@@ -107,13 +141,13 @@ export declare class LiteralResource extends Resource {
107
141
  /**
108
142
  * A base class for `Resource`s that require fetching data from a remote URL.
109
143
  */
110
- export declare abstract class FetchResource extends Resource {
111
- progress?: ProgressTracker | undefined;
144
+ export declare abstract class FetchResource extends Resource<File> {
145
+ _progress?: ProgressTracker | undefined;
112
146
  /**
113
147
  * Creates a new instance of `FetchResource`.
114
148
  * @param progress The progress tracker.
115
149
  */
116
- constructor(progress?: ProgressTracker | undefined);
150
+ constructor(_progress?: ProgressTracker | undefined);
117
151
  /** @inheritDoc */
118
152
  resolve(): Promise<File>;
119
153
  /**
@@ -147,6 +181,34 @@ export declare class UrlResource extends FetchResource {
147
181
  /** @inheritDoc */
148
182
  protected get caption(): string;
149
183
  }
184
+ /**
185
+ * A `Resource` that represents a git directory.
186
+ */
187
+ export declare class GitDirectoryResource extends Resource<Directory> {
188
+ private reference;
189
+ _progress?: ProgressTracker | undefined;
190
+ private options?;
191
+ constructor(reference: GitDirectoryReference, _progress?: ProgressTracker | undefined, options?: {
192
+ corsProxy?: string | undefined;
193
+ } | undefined);
194
+ resolve(): Promise<{
195
+ name: string;
196
+ files: Record<string, any>;
197
+ }>;
198
+ /** @inheritDoc */
199
+ get name(): string;
200
+ }
201
+ /**
202
+ * A `Resource` that represents a git directory.
203
+ */
204
+ export declare class LiteralDirectoryResource extends Resource<Directory> {
205
+ private reference;
206
+ _progress?: ProgressTracker | undefined;
207
+ constructor(reference: DirectoryLiteralReference, _progress?: ProgressTracker | undefined);
208
+ resolve(): Promise<DirectoryLiteralReference>;
209
+ /** @inheritDoc */
210
+ get name(): string;
211
+ }
150
212
  /**
151
213
  * A `Resource` that represents a WordPress core theme.
152
214
  */
@@ -173,41 +235,21 @@ export declare class CorePluginResource extends FetchResource {
173
235
  * Otherwise, appends ".latest-stable.zip".
174
236
  */
175
237
  export declare function toDirectoryZipName(rawInput: string): string;
176
- /**
177
- * A decorator for a resource that adds functionality such as progress tracking
178
- * and caching.
179
- */
180
- export declare class DecoratedResource<T extends Resource> extends Resource {
181
- private resource;
182
- constructor(resource: T);
183
- /** @inheritDoc */
184
- resolve(): Promise<File>;
185
- /** @inheritDoc */
186
- setPlayground(playground: UniversalPHP): Promise<void>;
187
- /** @inheritDoc */
188
- get progress(): ProgressTracker | undefined;
189
- /** @inheritDoc */
190
- set progress(value: ProgressTracker | undefined);
191
- /** @inheritDoc */
192
- get name(): string;
193
- /** @inheritDoc */
194
- get isAsync(): boolean;
195
- }
196
238
  /**
197
239
  * A decorator for a resource that adds caching functionality.
198
240
  */
199
- export declare class CachedResource<T extends Resource> extends DecoratedResource<T> {
200
- protected promise?: Promise<File>;
241
+ export declare class CachedResource<T extends File | Directory> extends ResourceDecorator<T> {
242
+ protected promise?: Promise<T>;
201
243
  /** @inheritDoc */
202
- resolve(): Promise<File>;
244
+ resolve(): Promise<T>;
203
245
  }
204
246
  /**
205
247
  * A decorator for a resource that adds concurrency control functionality
206
248
  * through a semaphore.
207
249
  */
208
- export declare class SemaphoreResource<T extends Resource> extends DecoratedResource<T> {
250
+ export declare class SemaphoreResource<T extends File | Directory> extends ResourceDecorator<T> {
209
251
  private readonly semaphore;
210
- constructor(resource: T, semaphore: Semaphore);
252
+ constructor(resource: Resource<T>, semaphore: Semaphore);
211
253
  /** @inheritDoc */
212
- resolve(): Promise<File>;
254
+ resolve(): Promise<T>;
213
255
  }
@@ -12,6 +12,8 @@ import { StepHandler } from '.';
12
12
  */
13
13
  export interface EnableMultisiteStep {
14
14
  step: 'enableMultisite';
15
+ /** wp-cli.phar path */
16
+ wpCliPath?: string;
15
17
  }
16
18
  /**
17
19
  * Defines the [Multisite](https://developer.wordpress.org/advanced-administration/multisite/create-network/) constants in a `wp-config.php` file.
@@ -11,6 +11,7 @@ export { rm } from './rm';
11
11
  export { mkdir } from './mkdir';
12
12
  export { rmdir } from './rmdir';
13
13
  export { writeFile } from './write-file';
14
+ export { writeFiles } from './write-files';
14
15
  export { defineSiteUrl } from './define-site-url';
15
16
  export { importWxr as importWxr } from './import-wxr';
16
17
  export { importThemeStarterContent as importThemeStarterContent } from './import-theme-starter-content';
@@ -1,6 +1,6 @@
1
1
  import { ProgressTracker } from '@php-wasm/progress';
2
2
  import { UniversalPHP } from '@php-wasm/universal';
3
- import { FileReference } from '../resources';
3
+ import { FileReference, DirectoryReference, Directory } from '../resources';
4
4
  import { ActivatePluginStep } from './activate-plugin';
5
5
  import { DefineSiteUrlStep } from './define-site-url';
6
6
  import { InstallPluginStep, InstallPluginOptions } from './install-plugin';
@@ -18,6 +18,7 @@ import { RunPHPStep } from './run-php';
18
18
  import { RunPHPWithOptionsStep } from './run-php-with-options';
19
19
  import { RequestStep } from './request';
20
20
  import { WriteFileStep } from './write-file';
21
+ import { WriteFilesStep } from './write-files';
21
22
  import { DefineWpConfigConstsStep } from './define-wp-config-consts';
22
23
  import { ActivateThemeStep } from './activate-theme';
23
24
  import { UnzipStep } from './unzip';
@@ -28,7 +29,7 @@ import { EnableMultisiteStep } from './enable-multisite';
28
29
  import { WPCLIStep } from './wp-cli';
29
30
  import { ResetDataStep } from './reset-data';
30
31
  import { SetSiteLanguageStep } from './set-site-language';
31
- export type Step = GenericStep<FileReference>;
32
+ export type Step = GenericStep<FileReference, DirectoryReference>;
32
33
  export type StepDefinition = Step & {
33
34
  progress?: {
34
35
  weight?: number;
@@ -40,8 +41,8 @@ export { wpContentFilesExcludedFromExport } from '../utils/wp-content-files-excl
40
41
  * If you add a step here, make sure to also
41
42
  * add it to the exports below.
42
43
  */
43
- export type GenericStep<Resource> = ActivatePluginStep | ActivateThemeStep | CpStep | DefineWpConfigConstsStep | DefineSiteUrlStep | EnableMultisiteStep | ImportWxrStep<Resource> | ImportThemeStarterContentStep | ImportWordPressFilesStep<Resource> | InstallPluginStep<Resource> | InstallThemeStep<Resource> | LoginStep | MkdirStep | MvStep | ResetDataStep | RequestStep | RmStep | RmdirStep | RunPHPStep | RunPHPWithOptionsStep | RunWpInstallationWizardStep | RunSqlStep<Resource> | SetSiteOptionsStep | UnzipStep<Resource> | UpdateUserMetaStep | WriteFileStep<Resource> | WPCLIStep | SetSiteLanguageStep;
44
- export type { ActivatePluginStep, ActivateThemeStep, CpStep, DefineWpConfigConstsStep, DefineSiteUrlStep, EnableMultisiteStep, ImportWxrStep, ImportThemeStarterContentStep, ImportWordPressFilesStep, InstallPluginStep, InstallPluginOptions, InstallThemeStep, InstallThemeOptions, LoginStep, MkdirStep, MvStep, ResetDataStep, RequestStep, RmStep, RmdirStep, RunPHPStep, RunPHPWithOptionsStep, RunWpInstallationWizardStep, RunSqlStep, WordPressInstallationOptions, SetSiteOptionsStep, UnzipStep, UpdateUserMetaStep, WriteFileStep, WPCLIStep, SetSiteLanguageStep, };
44
+ export type GenericStep<FileResource, DirectoryResource> = ActivatePluginStep | ActivateThemeStep | CpStep | DefineWpConfigConstsStep | DefineSiteUrlStep | EnableMultisiteStep | ImportWxrStep<FileResource> | ImportThemeStarterContentStep | ImportWordPressFilesStep<FileResource> | InstallPluginStep<FileResource, DirectoryResource> | InstallThemeStep<FileResource, DirectoryResource> | LoginStep | MkdirStep | MvStep | ResetDataStep | RequestStep | RmStep | RmdirStep | RunPHPStep | RunPHPWithOptionsStep | RunWpInstallationWizardStep | RunSqlStep<FileResource> | SetSiteOptionsStep | UnzipStep<FileResource> | UpdateUserMetaStep | WriteFileStep<FileResource> | WriteFilesStep<DirectoryResource> | WPCLIStep | SetSiteLanguageStep;
45
+ export type { ActivatePluginStep, ActivateThemeStep, CpStep, DefineWpConfigConstsStep, DefineSiteUrlStep, EnableMultisiteStep, ImportWxrStep, ImportThemeStarterContentStep, ImportWordPressFilesStep, InstallPluginStep, InstallPluginOptions, InstallThemeStep, InstallThemeOptions, LoginStep, MkdirStep, MvStep, ResetDataStep, RequestStep, RmStep, RmdirStep, RunPHPStep, RunPHPWithOptionsStep, RunWpInstallationWizardStep, RunSqlStep, WordPressInstallationOptions, SetSiteOptionsStep, UnzipStep, UpdateUserMetaStep, WriteFileStep, WriteFilesStep, WPCLIStep, SetSiteLanguageStep, };
45
46
  /**
46
47
  * Progress reporting details.
47
48
  */
@@ -49,7 +50,7 @@ export type StepProgress = {
49
50
  tracker: ProgressTracker;
50
51
  initialCaption?: string;
51
52
  };
52
- export type StepHandler<S extends GenericStep<File>, Return = any> = (
53
+ export type StepHandler<S extends GenericStep<File, Directory>, Return = any> = (
53
54
  /**
54
55
  * A PHP instance or Playground client.
55
56
  */
@@ -13,6 +13,10 @@ export interface InstallAssetOptions {
13
13
  * </code>
14
14
  */
15
15
  targetPath: string;
16
+ /**
17
+ * Target folder name to install the asset into.
18
+ */
19
+ targetFolderName?: string;
16
20
  /**
17
21
  * What to do if the asset already exists.
18
22
  */
@@ -21,7 +25,7 @@ export interface InstallAssetOptions {
21
25
  /**
22
26
  * Install asset: Extract folder from zip file and move it to target
23
27
  */
24
- export declare function installAsset(playground: UniversalPHP, { targetPath, zipFile, ifAlreadyInstalled, }: InstallAssetOptions): Promise<{
28
+ export declare function installAsset(playground: UniversalPHP, { targetPath, zipFile, ifAlreadyInstalled, targetFolderName }: InstallAssetOptions): Promise<{
25
29
  assetFolderPath: string;
26
30
  assetFolderName: string;
27
31
  }>;
@@ -1,5 +1,6 @@
1
1
  import { StepHandler } from '.';
2
2
  import { InstallAssetOptions } from './install-asset';
3
+ import { Directory } from '../resources';
3
4
  /**
4
5
  * @inheritDoc installPlugin
5
6
  * @hasRunnableExample
@@ -9,8 +10,8 @@ import { InstallAssetOptions } from './install-asset';
9
10
  *
10
11
  * <code>
11
12
  * {
12
- * "step": "installPlugin",
13
- * "pluginZipFile": {
13
+ * "step": "installPlugin",
14
+ * "pluginData": {
14
15
  * "resource": "wordpress.org/plugins",
15
16
  * "slug": "gutenberg"
16
17
  * },
@@ -19,16 +20,38 @@ import { InstallAssetOptions } from './install-asset';
19
20
  * }
20
21
  * }
21
22
  * </code>
23
+ *
24
+ * @example
25
+ *
26
+ * <code>
27
+ * {
28
+ * "step": "installPlugin",
29
+ * "pluginData": {
30
+ * "resource": "git:directory",
31
+ * "url": "https://github.com/wordpress/wordpress-playground.git",
32
+ * "ref": "HEAD",
33
+ * "path": "wp-content/plugins/hello-dolly"
34
+ * },
35
+ * "options": {
36
+ * "activate": true
37
+ * }
38
+ * }
39
+ * </code>
22
40
  */
23
- export interface InstallPluginStep<ResourceType> extends Pick<InstallAssetOptions, 'ifAlreadyInstalled'> {
41
+ export interface InstallPluginStep<FileResource, DirectoryResource> extends Pick<InstallAssetOptions, 'ifAlreadyInstalled'> {
24
42
  /**
25
43
  * The step identifier.
26
44
  */
27
45
  step: 'installPlugin';
28
46
  /**
29
- * The plugin zip file to install.
47
+ * The plugin files to install. It can be either a plugin zip file, or a
48
+ * directory containing all the plugin files at its root.
30
49
  */
31
- pluginZipFile: ResourceType;
50
+ pluginData: FileResource | DirectoryResource;
51
+ /**
52
+ * @deprecated. Use `pluginData` instead.
53
+ */
54
+ pluginZipFile?: FileResource;
32
55
  /**
33
56
  * Optional installation options.
34
57
  */
@@ -39,12 +62,16 @@ export interface InstallPluginOptions {
39
62
  * Whether to activate the plugin after installing it.
40
63
  */
41
64
  activate?: boolean;
65
+ /**
66
+ * The name of the folder to install the plugin to. Defaults to guessing from pluginData
67
+ */
68
+ targetFolderName?: string;
42
69
  }
43
70
  /**
44
71
  * Installs a WordPress plugin in the Playground.
45
72
  *
46
73
  * @param playground The playground client.
47
- * @param pluginZipFile The plugin zip file.
74
+ * @param pluginData The plugin zip file.
48
75
  * @param options Optional. Set `activate` to false if you don't want to activate the plugin.
49
76
  */
50
- export declare const installPlugin: StepHandler<InstallPluginStep<File>>;
77
+ export declare const installPlugin: StepHandler<InstallPluginStep<File, Directory>>;
@@ -1,5 +1,6 @@
1
1
  import { StepHandler } from '.';
2
2
  import { InstallAssetOptions } from './install-asset';
3
+ import { Directory } from '../resources';
3
4
  /**
4
5
  * @inheritDoc installTheme
5
6
  * @hasRunnableExample
@@ -9,7 +10,7 @@ import { InstallAssetOptions } from './install-asset';
9
10
  * <code>
10
11
  * {
11
12
  * "step": "installTheme",
12
- * "themeZipFile": {
13
+ * "themeData": {
13
14
  * "resource": "wordpress.org/themes",
14
15
  * "slug": "pendant"
15
16
  * },
@@ -20,34 +21,38 @@ import { InstallAssetOptions } from './install-asset';
20
21
  * }
21
22
  * </code>
22
23
  */
23
- export interface InstallThemeStep<ResourceType> extends Pick<InstallAssetOptions, 'ifAlreadyInstalled'> {
24
+ export interface InstallThemeStep<FileResource, DirectoryResource> extends Pick<InstallAssetOptions, 'ifAlreadyInstalled'> {
24
25
  /**
25
26
  * The step identifier.
26
27
  */
27
28
  step: 'installTheme';
28
29
  /**
29
- * The theme zip file to install.
30
+ * The theme files to install. It can be either a theme zip file, or a
31
+ * directory containing all the theme files at its root.
30
32
  */
31
- themeZipFile: ResourceType;
33
+ themeData: FileResource | DirectoryResource;
34
+ /**
35
+ * @deprecated. Use `themeData` instead.
36
+ */
37
+ themeZipFile?: FileResource;
32
38
  /**
33
39
  * Optional installation options.
34
40
  */
35
- options?: {
36
- /**
37
- * Whether to activate the theme after installing it.
38
- */
39
- activate?: boolean;
40
- /**
41
- * Whether to import the theme's starter content after installing it.
42
- */
43
- importStarterContent?: boolean;
44
- };
41
+ options?: InstallThemeOptions;
45
42
  }
46
43
  export interface InstallThemeOptions {
47
44
  /**
48
45
  * Whether to activate the theme after installing it.
49
46
  */
50
47
  activate?: boolean;
48
+ /**
49
+ * Whether to import the theme's starter content after installing it.
50
+ */
51
+ importStarterContent?: boolean;
52
+ /**
53
+ * The name of the folder to install the theme to. Defaults to guessing from themeData
54
+ */
55
+ targetFolderName?: string;
51
56
  }
52
57
  /**
53
58
  * Installs a WordPress theme in the Playground.
@@ -56,4 +61,4 @@ export interface InstallThemeOptions {
56
61
  * @param themeZipFile The theme zip file.
57
62
  * @param options Optional. Set `activate` to false if you don't want to activate the theme.
58
63
  */
59
- export declare const installTheme: StepHandler<InstallThemeStep<File>>;
64
+ export declare const installTheme: StepHandler<InstallThemeStep<File, Directory>>;
@@ -8,7 +8,6 @@ import { StepHandler } from '.';
8
8
  * {
9
9
  * "step": "login",
10
10
  * "username": "admin",
11
- * "password": "password"
12
11
  * }
13
12
  * </code>
14
13
  */
@@ -19,13 +18,16 @@ export type LoginStep = {
19
18
  */
20
19
  username?: string;
21
20
  /**
22
- * The password to log in with. Defaults to 'password'.
21
+ * @deprecated The password field is deprecated and will be removed in a future version.
22
+ * Only the username field is required for user authentication.
23
23
  */
24
24
  password?: string;
25
25
  };
26
26
  /**
27
27
  * Logs in to Playground.
28
- * Under the hood, this function submits the [`wp-login.php`](https://developer.wordpress.org/reference/files/wp-login.php/) [form](https://developer.wordpress.org/reference/functions/wp_login_form/)
29
- * just like a user would.
28
+ * Under the hood, this function sets the `PLAYGROUND_AUTO_LOGIN_AS_USER` constant.
29
+ * The `0-auto-login.php` mu-plugin uses that constant to log in the user on the first load.
30
+ * This step depends on the `@wp-playground/wordpress` package because
31
+ * the plugin is located in and loaded automatically by the `@wp-playground/wordpress` package.
30
32
  */
31
33
  export declare const login: StepHandler<LoginStep>;
@@ -1,5 +1,9 @@
1
- import { PHPResponse } from '@php-wasm/universal';
1
+ import { PHPResponse, UniversalPHP } from '@php-wasm/universal';
2
2
  import { StepHandler } from '.';
3
+ import { FileReference } from '../resources';
4
+ export declare const defaultWpCliPath = "/tmp/wp-cli.phar";
5
+ export declare const defaultWpCliResource: FileReference;
6
+ export declare const assertWpCli: (playground: UniversalPHP, wpCliPath?: string) => Promise<void>;
3
7
  /**
4
8
  * @inheritDoc wpCLI
5
9
  * @hasRunnableExample
@@ -13,12 +13,12 @@ import { StepHandler } from '.';
13
13
  * }
14
14
  * </code>
15
15
  */
16
- export interface WriteFileStep<ResourceType> {
16
+ export interface WriteFileStep<FileResource> {
17
17
  step: 'writeFile';
18
18
  /** The path of the file to write to */
19
19
  path: string;
20
20
  /** The data to write */
21
- data: ResourceType | string | Uint8Array;
21
+ data: FileResource | string | Uint8Array;
22
22
  }
23
23
  /**
24
24
  * Writes data to a file at the specified path.
@@ -0,0 +1,36 @@
1
+ import { StepHandler } from '.';
2
+ import { Directory } from '../resources';
3
+ /**
4
+ * @inheritDoc writeFiles
5
+ * @hasRunnableExample
6
+ * @landingPage /test.php
7
+ * @example
8
+ *
9
+ * <code>
10
+ * {
11
+ * "step": "writeFiles",
12
+ * "writeToPath": "/wordpress/wp-content/plugins/my-plugin",
13
+ * "filesTree": {
14
+ * "name": "my-plugin",
15
+ * "files": {
16
+ * "index.php": "<?php echo '<a>Hello World!</a>'; ?>",
17
+ * "public": {
18
+ * "style.css": "a { color: red; }"
19
+ * }
20
+ * }
21
+ * }
22
+ * }
23
+ * </code>
24
+ */
25
+ export interface WriteFilesStep<DirectoryResource> {
26
+ step: 'writeFiles';
27
+ /** The path of the file to write to */
28
+ writeToPath: string;
29
+ /** The data to write */
30
+ filesTree: DirectoryResource;
31
+ }
32
+ /**
33
+ * Writes multiple files to a specified directory in the Playground
34
+ * filesystem.
35
+ */
36
+ export declare const writeFiles: StepHandler<WriteFilesStep<Directory>>;