@elementor/wp-lite-env 0.0.7 → 0.0.9
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/.changeset/README.md +8 -0
- package/.changeset/config.json +11 -0
- package/.github/workflows/ci.yml +30 -0
- package/.github/workflows/release.yml +48 -0
- package/.github/workflows/require-changesets.yml +47 -0
- package/CHANGELOG.md +55 -0
- package/LICENSE +674 -0
- package/README.md +76 -0
- package/__tests__/__snapshots__/template.test.ts.snap +71 -0
- package/__tests__/config.test.ts +20 -0
- package/__tests__/e2e.ts +21 -0
- package/__tests__/template.test.ts +103 -0
- package/dist/package.json +46 -0
- package/eslint.config.mjs +13 -0
- package/index.ts +19 -0
- package/jest.config.js +8 -0
- package/package.json +44 -45
- package/src/config.ts +35 -0
- package/src/run.ts +125 -0
- package/src/templates.ts +117 -0
- package/tests/.wp-lite-env.json +16 -0
- package/tsconfig.json +32 -0
- package/index.d.ts.map +0 -1
- package/src/config.d.ts.map +0 -1
- package/src/run.d.ts.map +0 -1
- package/src/templates.d.ts.map +0 -1
- /package/{index.d.ts → dist/index.d.ts} +0 -0
- /package/{index.js → dist/index.js} +0 -0
- /package/{src → dist/src}/config.d.ts +0 -0
- /package/{src → dist/src}/config.js +0 -0
- /package/{src → dist/src}/run.d.ts +0 -0
- /package/{src → dist/src}/run.js +0 -0
- /package/{src → dist/src}/templates.d.ts +0 -0
- /package/{src → dist/src}/templates.js +0 -0
package/src/templates.ts
ADDED
@@ -0,0 +1,117 @@
|
|
1
|
+
import { Config } from './config';
|
2
|
+
import path from 'path';
|
3
|
+
|
4
|
+
export const generateDockerComposeYmlTemplate = ( config: Config, basePath: string, port: string, configPath: string ) => {
|
5
|
+
const mappingsStringArray = Object.keys( config.mappings ).map( ( key ) => {
|
6
|
+
const value = config.mappings[ key ];
|
7
|
+
return ` - >-
|
8
|
+
${ path.resolve( basePath, value ) }:/var/www/html/${ key }\n`;
|
9
|
+
} );
|
10
|
+
const pluginsStringArray = Object.keys( config.plugins ).map( ( key ) => {
|
11
|
+
const value = config.plugins[ key ];
|
12
|
+
return ` - >-
|
13
|
+
${ path.resolve( basePath, value ) }:/var/www/html/wp-content/plugins/${ key }\n`;
|
14
|
+
} );
|
15
|
+
const themesStringArray = Object.keys( config.themes ).map( ( key ) => {
|
16
|
+
const value = config.themes[ key ];
|
17
|
+
return ` - >-
|
18
|
+
${ path.resolve( basePath, value ) }:/var/www/html/wp-content/themes/${ key }\n`;
|
19
|
+
} );
|
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
|
+
`;
|
78
|
+
};
|
79
|
+
|
80
|
+
export const generateWordPressDockerfileTemplate = ( config: Config ) => {
|
81
|
+
return `FROM wordpress:${ config.core }-php${ config.phpVersion }
|
82
|
+
ARG HOST_USERNAME
|
83
|
+
ARG HOST_UID
|
84
|
+
ARG HOST_GID
|
85
|
+
# When the IDs are already in use we can still safely move on.
|
86
|
+
RUN groupadd -o -g $HOST_GID $HOST_USERNAME || true
|
87
|
+
RUN useradd -mlo -u $HOST_UID -g $HOST_GID $HOST_USERNAME || true
|
88
|
+
`;
|
89
|
+
};
|
90
|
+
|
91
|
+
export const generateCliDockerfileTemplate = ( config: Config ) => {
|
92
|
+
return `FROM wordpress:cli-php${ config.phpVersion }
|
93
|
+
ARG HOST_USERNAME
|
94
|
+
ARG HOST_UID
|
95
|
+
ARG HOST_GID
|
96
|
+
# When the IDs are already in use we can still safely move on.
|
97
|
+
RUN addgroup -g $HOST_GID $HOST_USERNAME || true
|
98
|
+
RUN useradd -mlo -u $HOST_UID -g $HOST_GID $HOST_USERNAME || true
|
99
|
+
# RUN adduser -h /home/$HOST_USERNAME -G $( getent group $HOST_GID | cut -d: -f1 ) -u $HOST_UID $HOST_USERNAME || true
|
100
|
+
|
101
|
+
# Have the container sleep infinitely to keep it alive for us to run commands on it.
|
102
|
+
CMD [ "/bin/sh", "-c", "while true; do sleep 2073600; done" ]
|
103
|
+
`;
|
104
|
+
};
|
105
|
+
|
106
|
+
export const generateConfiguration = ( config: Config, port: string ) => {
|
107
|
+
const header = `#!/bin/bash
|
108
|
+
set -eox pipefail
|
109
|
+
`;
|
110
|
+
const configStringArray = Object.keys( config.config ).map( ( key ) => {
|
111
|
+
const value = config.config[ key ];
|
112
|
+
return `wp config set ${ key } ${ value } --raw`;
|
113
|
+
} );
|
114
|
+
const wpCoreInstall = `wp core install --url="http://localhost:${ port }" --title="test" --admin_user=admin --admin_password=password --admin_email=wordpress@example.com --skip-email`;
|
115
|
+
|
116
|
+
return [ header, wpCoreInstall ].concat( configStringArray ).join( '\n' );
|
117
|
+
};
|
package/tsconfig.json
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
{
|
2
|
+
"$schema": "https://json.schemastore.org/tsconfig",
|
3
|
+
"display": "Node 18 + ESM + Strictest",
|
4
|
+
"compilerOptions": {
|
5
|
+
"lib": [
|
6
|
+
"es2022"
|
7
|
+
],
|
8
|
+
"outDir": "dist",
|
9
|
+
"module": "esnext",
|
10
|
+
"target": "ESNext",
|
11
|
+
"declaration": true,
|
12
|
+
"declarationMap": true,
|
13
|
+
"esModuleInterop": true,
|
14
|
+
"skipLibCheck": true,
|
15
|
+
"forceConsistentCasingInFileNames": true,
|
16
|
+
"moduleResolution": "node",
|
17
|
+
"allowUnusedLabels": false,
|
18
|
+
"allowUnreachableCode": false,
|
19
|
+
"noFallthroughCasesInSwitch": true,
|
20
|
+
"noImplicitOverride": true,
|
21
|
+
"noImplicitReturns": true,
|
22
|
+
"noImplicitAny": true,
|
23
|
+
"noPropertyAccessFromIndexSignature": false,
|
24
|
+
"noUncheckedIndexedAccess": true,
|
25
|
+
"noUnusedLocals": true,
|
26
|
+
"noUnusedParameters": true,
|
27
|
+
"checkJs": false,
|
28
|
+
"allowJs": false,
|
29
|
+
"resolveJsonModule": true
|
30
|
+
},
|
31
|
+
"include": ["./package.json", "index.*", "src/**/*"],
|
32
|
+
}
|
package/index.d.ts.map
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":""}
|
package/src/config.d.ts.map
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/config.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,MAAM,GAAG;IACpB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,OAAO,CAAC,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,CAAC;IACpC,MAAM,CAAC,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,CAAC;IACnC,QAAQ,CAAC,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,CAAC;IACrC,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAC,OAAO,CAAC,CAAC;CACxC,CAAA;AAED,eAAO,MAAM,SAAS,oBAAsB,MAAM,KAAI,MAuBrD,CAAC"}
|
package/src/run.d.ts.map
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../../src/run.ts"],"names":[],"mappings":"AAgCA,eAAO,MAAM,KAAK,SAAiB,MAAM,WAAW,MAAM,kBASzD,CAAC;AAEF,eAAO,MAAM,IAAI,SAAiB,MAAM,WAAW,MAAM,kBAOxD,CAAC;AAWF,eAAO,MAAM,UAAU,EAAE;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,CAAE,CAAE,IAAI,EAAE,MAAM,KAAM,OAAO,CAAC,IAAI,CAAC,CAAE,GAAG,CAAE,CAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,KAAM,OAAO,CAAC,IAAI,CAAC,CAAE,CAAA;CAIxJ,CAAC;AAIF,eAAO,MAAM,aAAa,SAAW,MAAM,kBAAkB,MAAM,WA4BlE,CAAC;AAYF,eAAO,MAAM,iBAAiB,gBAAkB,MAAM,EAAE,WAEvD,CAAC;AAEF,eAAO,MAAM,aAAa,gBAAkB,MAAM,EAAE,WAEnD,CAAC;AAEF,eAAO,MAAM,OAAO,gBAAkB,MAAM,EAAE,WAE7C,CAAC;AAEF,eAAO,MAAM,OAAO,SAAW,MAAM,WAAW,MAAM,SAGrD,CAAA"}
|
package/src/templates.d.ts.map
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"templates.d.ts","sourceRoot":"","sources":["../../src/templates.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAGlC,eAAO,MAAM,gCAAgC,WAAa,MAAM,YAAY,MAAM,QAAQ,MAAM,cAAc,MAAM,WA0EnH,CAAC;AAEF,eAAO,MAAM,mCAAmC,WAAa,MAAM,WASlE,CAAC;AAEF,eAAO,MAAM,6BAA6B,WAAa,MAAM,WAa5D,CAAC;AAEF,eAAO,MAAM,qBAAqB,WAAa,MAAM,QAAQ,MAAM,WAWlE,CAAC"}
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
/package/{src → dist/src}/run.js
RENAMED
File without changes
|
File without changes
|
File without changes
|