@wp-playground/blueprints 0.5.2 → 0.5.3
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 +5 -0
- package/index.cjs +453 -112
- package/index.d.ts +15 -1
- package/index.js +2292 -1895
- package/lib/steps/define-wp-config-consts.d.ts +18 -1
- package/lib/steps/index.d.ts +1 -1
- package/lib/utils/flatten-directory.d.ts +12 -0
- package/lib/utils/run-php-with-zip-functions.d.ts +2 -0
- package/lib/utils/update-file.d.ts +12 -0
- package/lib/utils/wp-content-files-excluded-from-exports.d.ts +6 -0
- package/lib/utils/zip-name-to-human-name.d.ts +9 -0
- package/package.json +3 -3
- package/lib/steps/common.d.ts +0 -13
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { StepHandler } from '.';
|
|
2
|
+
import { UniversalPHP } from '../../../../../php-wasm/universal/src/index.ts';
|
|
2
3
|
/**
|
|
3
4
|
* @inheritDoc defineWpConfigConsts
|
|
4
5
|
* @hasRunnableExample
|
|
@@ -17,6 +18,20 @@ export interface DefineWpConfigConstsStep {
|
|
|
17
18
|
step: 'defineWpConfigConsts';
|
|
18
19
|
/** The constants to define */
|
|
19
20
|
consts: Record<string, unknown>;
|
|
21
|
+
/**
|
|
22
|
+
* The method of defining the constants. Possible values are:
|
|
23
|
+
*
|
|
24
|
+
* - rewrite-wp-config: Default. Rewrites the wp-config.php file to
|
|
25
|
+
* explicitly call define() with the requested
|
|
26
|
+
* name and value. This method alters the file
|
|
27
|
+
* on the disk, but it doesn't conflict with
|
|
28
|
+
* existing define() calls in wp-config.php.
|
|
29
|
+
* - define-before-run: Defines the constant before running the requested
|
|
30
|
+
* script. It doesn't alter any files on the disk, but
|
|
31
|
+
* constants defined this way may conflict with existing
|
|
32
|
+
* define() calls in wp-config.php.
|
|
33
|
+
*/
|
|
34
|
+
method?: 'rewrite-wp-config' | 'define-before-run';
|
|
20
35
|
/**
|
|
21
36
|
* @deprecated This option is noop and will be removed in a future version.
|
|
22
37
|
* This option is only kept in here to avoid breaking Blueprint schema validation
|
|
@@ -25,7 +40,7 @@ export interface DefineWpConfigConstsStep {
|
|
|
25
40
|
virtualize?: boolean;
|
|
26
41
|
}
|
|
27
42
|
/**
|
|
28
|
-
* Defines constants
|
|
43
|
+
* Defines constants in a wp-config.php file.
|
|
29
44
|
*
|
|
30
45
|
* This step can be called multiple times, and the constants will be merged.
|
|
31
46
|
*
|
|
@@ -33,3 +48,5 @@ export interface DefineWpConfigConstsStep {
|
|
|
33
48
|
* @param wpConfigConst
|
|
34
49
|
*/
|
|
35
50
|
export declare const defineWpConfigConsts: StepHandler<DefineWpConfigConstsStep>;
|
|
51
|
+
export declare function defineBeforeRun(playground: UniversalPHP, consts: Record<string, unknown>): Promise<void>;
|
|
52
|
+
export declare function rewriteDefineCalls(playground: UniversalPHP, phpCode: string, consts: Record<string, unknown>): Promise<string>;
|
package/lib/steps/index.d.ts
CHANGED
|
@@ -32,7 +32,7 @@ export type StepDefinition = Step & {
|
|
|
32
32
|
caption?: string;
|
|
33
33
|
};
|
|
34
34
|
};
|
|
35
|
-
export { wpContentFilesExcludedFromExport } from '
|
|
35
|
+
export { wpContentFilesExcludedFromExport } from '../utils/wp-content-files-excluded-from-exports';
|
|
36
36
|
/**
|
|
37
37
|
* If you add a step here, make sure to also
|
|
38
38
|
* add it to the exports below.
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { UniversalPHP } from '../../../../../php-wasm/universal/src/index.ts';
|
|
2
|
+
/**
|
|
3
|
+
* Flattens a directory.
|
|
4
|
+
* If the directory contains only one file, it will be moved to the parent directory.
|
|
5
|
+
* Otherwise, the directory will be renamed to the default name.
|
|
6
|
+
*
|
|
7
|
+
* @param php Playground client.
|
|
8
|
+
* @param directoryPath The directory to flatten.
|
|
9
|
+
* @param defaultName The name to use if the directory contains only one file.
|
|
10
|
+
* @returns The final path of the directory.
|
|
11
|
+
*/
|
|
12
|
+
export declare function flattenDirectory(php: UniversalPHP, directoryPath: string, defaultName: string): Promise<string>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { UniversalPHP } from '../../../../../php-wasm/universal/src/index.ts';
|
|
2
|
+
type PatchFileCallback = (contents: string) => string | Uint8Array;
|
|
3
|
+
/**
|
|
4
|
+
* Updates a file in the PHP filesystem.
|
|
5
|
+
* If the file does not exist, it will be created.
|
|
6
|
+
*
|
|
7
|
+
* @param php The PHP instance.
|
|
8
|
+
* @param path The path to the file.
|
|
9
|
+
* @param callback A function that maps the old file contents to the new file contents.
|
|
10
|
+
*/
|
|
11
|
+
export declare function updateFile(php: UniversalPHP, path: string, callback: PatchFileCallback): Promise<void>;
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Converts a zip file name to a nice, human-readable name.
|
|
3
|
+
*
|
|
4
|
+
* @example `hello-dolly.zip` -> `Hello dolly`
|
|
5
|
+
*
|
|
6
|
+
* @param zipName A zip filename.
|
|
7
|
+
* @returns A nice, human-readable name.
|
|
8
|
+
*/
|
|
9
|
+
export declare function zipNameToHumanName(zipName: string): string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wp-playground/blueprints",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.3",
|
|
4
4
|
"exports": {
|
|
5
5
|
".": {
|
|
6
6
|
"import": "./index.js",
|
|
@@ -21,9 +21,9 @@
|
|
|
21
21
|
"access": "public",
|
|
22
22
|
"directory": "../../../dist/packages/playground/blueprints"
|
|
23
23
|
},
|
|
24
|
-
"gitHead": "
|
|
24
|
+
"gitHead": "3d0f04ee35f15e9a7906818352f6ccdd34f46fbe",
|
|
25
25
|
"engines": {
|
|
26
|
-
"node": ">=
|
|
26
|
+
"node": ">=18.18.2",
|
|
27
27
|
"npm": ">=8.11.0"
|
|
28
28
|
}
|
|
29
29
|
}
|
package/lib/steps/common.d.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type { UniversalPHP } from '../../../../../php-wasm/universal/src/index.ts';
|
|
2
|
-
/**
|
|
3
|
-
* Used by the export step to exclude the Playground-specific files
|
|
4
|
-
* from the zip file. Keep it in sync with the list of files created
|
|
5
|
-
* by WordPressPatcher.
|
|
6
|
-
*/
|
|
7
|
-
export declare const wpContentFilesExcludedFromExport: string[];
|
|
8
|
-
export declare function zipNameToHumanName(zipName: string): string;
|
|
9
|
-
type PatchFileCallback = (contents: string) => string | Uint8Array;
|
|
10
|
-
export declare function updateFile(php: UniversalPHP, path: string, callback: PatchFileCallback): Promise<void>;
|
|
11
|
-
export declare function fileToUint8Array(file: File): Promise<Uint8Array>;
|
|
12
|
-
export declare function runPhpWithZipFunctions(playground: UniversalPHP, code: string): Promise<import('../../../../../php-wasm/universal/src/index.ts').PHPResponse>;
|
|
13
|
-
export {};
|