@elementor/wp-lite-env 0.0.16 → 0.0.18
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/CHANGELOG.md +18 -0
- package/__tests__/__snapshots__/template.test.ts.snap +9 -12
- package/__tests__/config.test.ts +2 -2
- package/__tests__/e2e.ts +2 -2
- package/__tests__/template.test.ts +6 -6
- package/dist/bin.cjs +127 -129
- package/dist/bin.js +15 -14
- package/dist/{chunk-UBXF6D42.js → chunk-FNPCY3S6.js} +114 -125
- package/dist/index.cjs +24 -13
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +1 -1
- package/package.json +6 -2
- package/src/bin.ts +14 -11
- package/src/config.ts +1 -8
- package/src/run.ts +31 -38
- package/src/templates.ts +87 -66
- /package/{tests → __tests__}/.wp-lite-env.json +0 -0
package/src/templates.ts
CHANGED
@@ -1,80 +1,101 @@
|
|
1
1
|
import { Config } from './config';
|
2
2
|
import path from 'path';
|
3
|
+
import {dump} from "js-yaml";
|
3
4
|
|
4
|
-
|
5
|
+
const generateVolumeMapping = ( basePath: string, configPath: string, config: Config ) => {
|
5
6
|
const mappingsStringArray = Object.keys( config.mappings ).map( ( key ) => {
|
6
7
|
const value = config.mappings[ key ];
|
7
|
-
return
|
8
|
-
${ path.resolve( basePath, value ) }:/var/www/html/${ key }\n`;
|
8
|
+
return `${ path.resolve( basePath, value ) }:/var/www/html/${ key }`;
|
9
9
|
} );
|
10
10
|
const pluginsStringArray = Object.keys( config.plugins ).map( ( key ) => {
|
11
11
|
const value = config.plugins[ key ];
|
12
|
-
return
|
13
|
-
${ path.resolve( basePath, value ) }:/var/www/html/wp-content/plugins/${ key }\n`;
|
12
|
+
return `${ path.resolve( basePath, value ) }:/var/www/html/wp-content/plugins/${ key }`;
|
14
13
|
} );
|
15
14
|
const themesStringArray = Object.keys( config.themes ).map( ( key ) => {
|
16
15
|
const value = config.themes[ key ];
|
17
|
-
return
|
18
|
-
${ path.resolve( basePath, value ) }:/var/www/html/wp-content/themes/${ key }\n`;
|
16
|
+
return `${ path.resolve( basePath, value ) }:/var/www/html/wp-content/themes/${ key }`;
|
19
17
|
} );
|
20
|
-
const wpContent = `
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
18
|
+
const wpContent = `wpcontent:/var/www/html`;
|
19
|
+
const wpConfig = `${ configPath }:/var/www/html/wp-config`;
|
20
|
+
return mappingsStringArray.concat( pluginsStringArray ).concat( themesStringArray ).concat( [ wpContent, wpConfig ] );
|
21
|
+
};
|
22
|
+
|
23
|
+
export const generateDockerComposeYmlTemplate = ( config: Config, basePath: string, port: number, configPath: string ) => {
|
24
|
+
const hostUid = '502';
|
25
|
+
const hostGid = '20';
|
26
|
+
const wordpressDbUser = 'root';
|
27
|
+
const wordpressDbPassword= 'password';
|
28
|
+
const wordpressDbName = 'wordpress';
|
29
|
+
const args = {
|
30
|
+
HOST_USERNAME: 'someuser',
|
31
|
+
HOST_UID: hostUid,
|
32
|
+
HOST_GID: hostGid,
|
33
|
+
}
|
34
|
+
const volumes = generateVolumeMapping( basePath, configPath, config );
|
35
|
+
const compose = {
|
36
|
+
services: {
|
37
|
+
mysql: {
|
38
|
+
image: 'mariadb:lts',
|
39
|
+
ports: [
|
40
|
+
'${WP_ENV_MYSQL_PORT:-}:3306'
|
41
|
+
],
|
42
|
+
environment: {
|
43
|
+
MYSQL_ROOT_HOST: '%',
|
44
|
+
MYSQL_ROOT_PASSWORD: 'password',
|
45
|
+
MYSQL_DATABASE: 'wordpress'
|
46
|
+
},
|
47
|
+
volumes: [
|
48
|
+
'mysql:/var/lib/mysql'
|
49
|
+
]
|
50
|
+
},
|
51
|
+
wordpress: {
|
52
|
+
depends_on: ['mysql'],
|
53
|
+
build: {
|
54
|
+
context: '.',
|
55
|
+
dockerfile: 'WordPress.Dockerfile',
|
56
|
+
no_cache: true,
|
57
|
+
args,
|
58
|
+
},
|
59
|
+
ports: [
|
60
|
+
`\${WP_ENV_PORT:-${ port }}:80`,
|
61
|
+
],
|
62
|
+
environment: {
|
63
|
+
APACHE_RUN_USER: `#${ hostUid }`,
|
64
|
+
APACHE_RUN_GROUP: `#${ hostGid }`,
|
65
|
+
WORDPRESS_DB_USER: wordpressDbUser,
|
66
|
+
WORDPRESS_DB_PASSWORD: wordpressDbPassword,
|
67
|
+
WORDPRESS_DB_NAME: wordpressDbName,
|
68
|
+
},
|
69
|
+
volumes,
|
70
|
+
extra_hosts: [
|
71
|
+
'host.docker.internal:host-gateway',
|
72
|
+
],
|
73
|
+
},
|
74
|
+
cli: {
|
75
|
+
depends_on: ['wordpress'],
|
76
|
+
build: {
|
77
|
+
context: '.',
|
78
|
+
dockerfile: 'CLI.Dockerfile',
|
79
|
+
args,
|
80
|
+
},
|
81
|
+
volumes,
|
82
|
+
user: `${ hostUid }:${ hostGid }`,
|
83
|
+
environment: {
|
84
|
+
WORDPRESS_DB_USER: wordpressDbUser,
|
85
|
+
WORDPRESS_DB_PASSWORD: wordpressDbPassword,
|
86
|
+
WORDPRESS_DB_NAME: wordpressDbName,
|
87
|
+
},
|
88
|
+
extra_hosts: [
|
89
|
+
'host.docker.internal:host-gateway',
|
90
|
+
],
|
91
|
+
}
|
92
|
+
},
|
93
|
+
volumes: {
|
94
|
+
mysql: {},
|
95
|
+
wpcontent: {}
|
96
|
+
},
|
97
|
+
};
|
98
|
+
return dump( compose );
|
78
99
|
};
|
79
100
|
|
80
101
|
export const generateWordPressDockerfileTemplate = ( config: Config ) => {
|
@@ -103,7 +124,7 @@ CMD [ "/bin/sh", "-c", "while true; do sleep 2073600; done" ]
|
|
103
124
|
`;
|
104
125
|
};
|
105
126
|
|
106
|
-
export const generateConfiguration = ( config: Config, port:
|
127
|
+
export const generateConfiguration = ( config: Config, port: number ) => {
|
107
128
|
const header = `#!/bin/bash
|
108
129
|
set -eox pipefail
|
109
130
|
`;
|
File without changes
|