@wp-playground/blueprints 0.1.39 → 0.1.40
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/package.json +2 -2
- package/project.json +9 -0
- package/src/lib/steps/common.ts +5 -1
- package/src/lib/steps/define-site-url.ts +7 -15
- package/src/lib/steps/define-wp-config-consts.ts +45 -0
- package/src/lib/steps/handlers.ts +1 -0
- package/src/lib/steps/import-export.ts +1 -1
- package/src/lib/steps/index.ts +2 -0
- package/src/lib/steps/{migration.php → migration.ts} +2 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wp-playground/blueprints",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.40",
|
|
4
4
|
"exports": {
|
|
5
5
|
".": {
|
|
6
6
|
"import": "./index.js",
|
|
@@ -20,5 +20,5 @@
|
|
|
20
20
|
"publishConfig": {
|
|
21
21
|
"access": "public"
|
|
22
22
|
},
|
|
23
|
-
"gitHead": "
|
|
23
|
+
"gitHead": "d4817100bc505f21309e07a5b2cec1f2be38e85d"
|
|
24
24
|
}
|
package/project.json
CHANGED
|
@@ -43,6 +43,15 @@
|
|
|
43
43
|
"options": {
|
|
44
44
|
"lintFilePatterns": ["packages/playground/blueprints/**/*.ts"]
|
|
45
45
|
}
|
|
46
|
+
},
|
|
47
|
+
"typecheck": {
|
|
48
|
+
"executor": "@nrwl/workspace:run-commands",
|
|
49
|
+
"options": {
|
|
50
|
+
"commands": [
|
|
51
|
+
"yarn tsc -p packages/playground/remote/tsconfig.spec.json --noEmit",
|
|
52
|
+
"yarn tsc -p packages/playground/remote/tsconfig.lib.json --noEmit"
|
|
53
|
+
]
|
|
54
|
+
}
|
|
46
55
|
}
|
|
47
56
|
},
|
|
48
57
|
"tags": []
|
package/src/lib/steps/common.ts
CHANGED
|
@@ -18,7 +18,11 @@ export async function updateFile(
|
|
|
18
18
|
path: string,
|
|
19
19
|
callback: PatchFileCallback
|
|
20
20
|
) {
|
|
21
|
-
|
|
21
|
+
let contents = '';
|
|
22
|
+
if (await php.fileExists(path)) {
|
|
23
|
+
contents = await php.readFileAsText(path);
|
|
24
|
+
}
|
|
25
|
+
await php.writeFile(path, callback(contents));
|
|
22
26
|
}
|
|
23
27
|
|
|
24
28
|
export async function fileToUint8Array(file: File) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { StepHandler } from '.';
|
|
2
|
-
import {
|
|
2
|
+
import { defineWpConfigConsts } from './define-wp-config-consts';
|
|
3
3
|
|
|
4
4
|
export interface DefineSiteUrlStep {
|
|
5
5
|
step: 'defineSiteUrl';
|
|
@@ -16,18 +16,10 @@ export const defineSiteUrl: StepHandler<DefineSiteUrlStep> = async (
|
|
|
16
16
|
playground,
|
|
17
17
|
{ siteUrl }
|
|
18
18
|
) => {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
if ( ! defined( 'WP_HOME' ) ) {
|
|
26
|
-
define('WP_HOME', "${siteUrl}");
|
|
27
|
-
}
|
|
28
|
-
if ( ! defined( 'WP_SITEURL' ) ) {
|
|
29
|
-
define('WP_SITEURL', "${siteUrl}");
|
|
30
|
-
}
|
|
31
|
-
?>${contents}`
|
|
32
|
-
);
|
|
19
|
+
return await defineWpConfigConsts(playground, {
|
|
20
|
+
consts: {
|
|
21
|
+
WP_HOME: siteUrl,
|
|
22
|
+
WP_SITEURL: siteUrl,
|
|
23
|
+
},
|
|
24
|
+
});
|
|
33
25
|
};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { StepHandler } from '.';
|
|
2
|
+
import { updateFile } from './common';
|
|
3
|
+
|
|
4
|
+
export interface DefineWpConfigConstsStep {
|
|
5
|
+
step: 'defineWpConfigConsts';
|
|
6
|
+
consts: Record<string, unknown>;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Sets site URL of the WordPress installation.
|
|
11
|
+
*
|
|
12
|
+
* @param playground The playground client.
|
|
13
|
+
* @param wpConfigConst
|
|
14
|
+
*/
|
|
15
|
+
export const defineWpConfigConsts: StepHandler<
|
|
16
|
+
DefineWpConfigConstsStep
|
|
17
|
+
> = async (playground, { consts }) => {
|
|
18
|
+
const documentRoot = await playground.documentRoot;
|
|
19
|
+
await updateFile(
|
|
20
|
+
playground,
|
|
21
|
+
`${documentRoot}/playground-consts.json`,
|
|
22
|
+
(contents) =>
|
|
23
|
+
JSON.stringify({
|
|
24
|
+
...JSON.parse(contents || '{}'),
|
|
25
|
+
...consts,
|
|
26
|
+
})
|
|
27
|
+
);
|
|
28
|
+
await updateFile(
|
|
29
|
+
playground,
|
|
30
|
+
`${documentRoot}/wp-config.php`,
|
|
31
|
+
(contents) => {
|
|
32
|
+
if (!contents.includes('playground-consts.json')) {
|
|
33
|
+
return `<?php
|
|
34
|
+
$consts = json_decode(file_get_contents('./playground-consts.json'), true);
|
|
35
|
+
foreach ($consts as $const => $value) {
|
|
36
|
+
if (!defined($const)) {
|
|
37
|
+
define($const, $value);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
?>${contents}`;
|
|
41
|
+
}
|
|
42
|
+
return contents;
|
|
43
|
+
}
|
|
44
|
+
);
|
|
45
|
+
};
|
|
@@ -19,3 +19,4 @@ export { installTheme } from './install-theme';
|
|
|
19
19
|
export { login } from './login';
|
|
20
20
|
export { runWpInstallationWizard } from './run-wp-installation-wizard';
|
|
21
21
|
export { setSiteOptions, updateUserMeta } from './site-data';
|
|
22
|
+
export { defineWpConfigConsts } from './define-wp-config-consts';
|
package/src/lib/steps/index.ts
CHANGED
|
@@ -22,6 +22,7 @@ import {
|
|
|
22
22
|
RequestStep,
|
|
23
23
|
WriteFileStep,
|
|
24
24
|
} from './client-methods';
|
|
25
|
+
import { DefineWpConfigConstsStep } from './define-wp-config-consts';
|
|
25
26
|
|
|
26
27
|
export type Step = GenericStep<FileReference>;
|
|
27
28
|
export type StepDefinition = Step & {
|
|
@@ -35,6 +36,7 @@ export type GenericStep<Resource> =
|
|
|
35
36
|
| ActivatePluginStep
|
|
36
37
|
| ApplyWordPressPatchesStep
|
|
37
38
|
| CpStep
|
|
39
|
+
| DefineWpConfigConstsStep
|
|
38
40
|
| DefineSiteUrlStep
|
|
39
41
|
| ImportFileStep<Resource>
|
|
40
42
|
| InstallPluginStep<Resource>
|