@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/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
- export const generateDockerComposeYmlTemplate = ( config: Config, basePath: string, port: string, configPath: string ) => {
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
- wpcontent:/var/www/html\n`;
22
- const wpConfig = ` - >-
23
- ${ configPath }:/var/www/html/wp-config\n`;
24
- const volumes = mappingsStringArray.concat( pluginsStringArray ).concat( themesStringArray ).concat( [ wpContent, wpConfig ] ).join( '' );
25
- return `services:
26
- mysql:
27
- image: 'mariadb:lts'
28
- ports:
29
- - '\${WP_ENV_MYSQL_PORT:-}:3306'
30
- environment:
31
- MYSQL_ROOT_HOST: '%'
32
- MYSQL_ROOT_PASSWORD: password
33
- MYSQL_DATABASE: wordpress
34
- volumes:
35
- - 'mysql:/var/lib/mysql'
36
- wordpress:
37
- depends_on:
38
- - mysql
39
- build:
40
- context: .
41
- dockerfile: WordPress.Dockerfile
42
- no_cache: true
43
- args: &ref_0
44
- HOST_USERNAME: yotams
45
- HOST_UID: '502'
46
- HOST_GID: '20'
47
- ports:
48
- - '\${WP_ENV_PORT:-${ port }}:80'
49
- environment:
50
- APACHE_RUN_USER: '#502'
51
- APACHE_RUN_GROUP: '#20'
52
- WORDPRESS_DB_USER: root
53
- WORDPRESS_DB_PASSWORD: password
54
- WORDPRESS_DB_NAME: wordpress
55
- volumes: &ref_1
56
- ${ volumes }
57
- extra_hosts:
58
- - 'host.docker.internal:host-gateway'
59
- cli:
60
- depends_on:
61
- - wordpress
62
- build:
63
- context: .
64
- dockerfile: CLI.Dockerfile
65
- args: *ref_0
66
- volumes: *ref_1
67
- user: '502:20'
68
- environment:
69
- WORDPRESS_DB_USER: root
70
- WORDPRESS_DB_PASSWORD: password
71
- WORDPRESS_DB_NAME: wordpress
72
- extra_hosts:
73
- - 'host.docker.internal:host-gateway'
74
- volumes:
75
- mysql: {}
76
- wpcontent: {}
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: string ) => {
127
+ export const generateConfiguration = ( config: Config, port: number ) => {
107
128
  const header = `#!/bin/bash
108
129
  set -eox pipefail
109
130
  `;
File without changes