@elementor/wp-lite-env 0.0.18 → 0.0.19
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/.github/workflows/release.yml +1 -1
- package/.github/workflows/require-changesets.yml +1 -1
- package/CHANGELOG.md +8 -0
- package/__tests__/__snapshots__/template.test.ts.snap +66 -1
- package/__tests__/e2e.ts +15 -8
- package/__tests__/template.test.ts +19 -1
- package/dist/bin.cjs +2 -1
- package/dist/bin.js +1 -1
- package/dist/{chunk-FNPCY3S6.js → chunk-WLKYS3XU.js} +3 -2
- package/dist/index.cjs +2 -1
- package/dist/index.js +1 -1
- package/package.json +1 -1
- package/src/run.ts +2 -1
package/CHANGELOG.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
2
2
|
|
3
|
-
exports[`templates compose file generation
|
3
|
+
exports[`templates compose file generation compose generated with correct empty values 1`] = `
|
4
4
|
"services:
|
5
5
|
mysql:
|
6
6
|
image: mariadb:lts
|
@@ -57,6 +57,71 @@ volumes:
|
|
57
57
|
"
|
58
58
|
`;
|
59
59
|
|
60
|
+
exports[`templates compose file generation compose generated with correct values 1`] = `
|
61
|
+
"services:
|
62
|
+
mysql:
|
63
|
+
image: mariadb:lts
|
64
|
+
ports:
|
65
|
+
- \${WP_ENV_MYSQL_PORT:-}:3306
|
66
|
+
environment:
|
67
|
+
MYSQL_ROOT_HOST: '%'
|
68
|
+
MYSQL_ROOT_PASSWORD: password
|
69
|
+
MYSQL_DATABASE: wordpress
|
70
|
+
volumes:
|
71
|
+
- mysql:/var/lib/mysql
|
72
|
+
wordpress:
|
73
|
+
depends_on:
|
74
|
+
- mysql
|
75
|
+
build:
|
76
|
+
context: .
|
77
|
+
dockerfile: WordPress.Dockerfile
|
78
|
+
no_cache: true
|
79
|
+
args: &ref_0
|
80
|
+
HOST_USERNAME: someuser
|
81
|
+
HOST_UID: '502'
|
82
|
+
HOST_GID: '20'
|
83
|
+
ports:
|
84
|
+
- \${WP_ENV_PORT:-1234}:80
|
85
|
+
environment:
|
86
|
+
APACHE_RUN_USER: '#502'
|
87
|
+
APACHE_RUN_GROUP: '#20'
|
88
|
+
WORDPRESS_DB_USER: root
|
89
|
+
WORDPRESS_DB_PASSWORD: password
|
90
|
+
WORDPRESS_DB_NAME: wordpress
|
91
|
+
volumes: &ref_1
|
92
|
+
- /some/base/path/some/container/path:/var/www/html/some/host/path
|
93
|
+
- >-
|
94
|
+
/some/base/path/some/other/container/path:/var/www/html/some/other/host/path
|
95
|
+
- /some/base/some/plugin/path:/var/www/html/wp-content/plugins/plugin1
|
96
|
+
- >-
|
97
|
+
/some/base/some/other/plugin/path:/var/www/html/wp-content/plugins/plugin2
|
98
|
+
- /some/base/some/theme/path:/var/www/html/wp-content/themes/theme1
|
99
|
+
- /some/base/some/other/theme/path:/var/www/html/wp-content/themes/theme2
|
100
|
+
- wpcontent:/var/www/html
|
101
|
+
- /some/wp-config/path:/var/www/html/wp-config
|
102
|
+
extra_hosts:
|
103
|
+
- host.docker.internal:host-gateway
|
104
|
+
cli:
|
105
|
+
depends_on:
|
106
|
+
- wordpress
|
107
|
+
build:
|
108
|
+
context: .
|
109
|
+
dockerfile: CLI.Dockerfile
|
110
|
+
args: *ref_0
|
111
|
+
volumes: *ref_1
|
112
|
+
user: '502:20'
|
113
|
+
environment:
|
114
|
+
WORDPRESS_DB_USER: root
|
115
|
+
WORDPRESS_DB_PASSWORD: password
|
116
|
+
WORDPRESS_DB_NAME: wordpress
|
117
|
+
extra_hosts:
|
118
|
+
- host.docker.internal:host-gateway
|
119
|
+
volumes:
|
120
|
+
mysql: {}
|
121
|
+
wpcontent: {}
|
122
|
+
"
|
123
|
+
`;
|
124
|
+
|
60
125
|
exports[`templates configuration file generation config file is generated with the correct values 1`] = `
|
61
126
|
"#!/bin/bash
|
62
127
|
set -eox pipefail
|
package/__tests__/e2e.ts
CHANGED
@@ -1,19 +1,26 @@
|
|
1
|
-
import {
|
1
|
+
import {describe, expect, test} from "@jest/globals";
|
2
2
|
import {generateFiles, getConfigFilePath, start, stop} from "../src/run";
|
3
|
+
import {execSync} from "node:child_process";
|
3
4
|
|
4
5
|
const port = 1234;
|
5
6
|
|
6
7
|
describe('end to end tests', () => {
|
7
|
-
beforeAll(async () => {
|
8
|
-
await generateFiles(port, getConfigFilePath(['', '', '', 'config=./__tests__/.wp-lite-env.json']));
|
9
|
-
})
|
10
|
-
afterEach(async () => {
|
11
|
-
await stop(port);
|
12
|
-
}, 30000);
|
13
8
|
test('WordPress is up and running', async () => {
|
14
|
-
await
|
9
|
+
await generateFiles(port, getConfigFilePath(['', '', '', 'config=./__tests__/.wp-lite-env.json']));
|
10
|
+
try {
|
11
|
+
await start(port);
|
12
|
+
const response = await fetch(`http://localhost:${port}`);
|
13
|
+
expect(response.ok).toBe(true);
|
14
|
+
expect(await response.text()).toContain('Welcome to WordPress');
|
15
|
+
} finally {
|
16
|
+
await stop(port);
|
17
|
+
}
|
18
|
+
}, 60000);
|
19
|
+
test('WordPress is up and running using binary (requires building the library!)', async () => {
|
20
|
+
execSync('npx wp-lite-env start --config=./__tests__/.wp-lite-env.json --port=1234');
|
15
21
|
const response = await fetch(`http://localhost:${port}`);
|
16
22
|
expect(response.ok).toBe(true);
|
17
23
|
expect(await response.text()).toContain('Welcome to WordPress');
|
24
|
+
execSync('npx wp-lite-env stop --config=./__tests__/.wp-lite-env.json --port=1234');
|
18
25
|
}, 60000);
|
19
26
|
});
|
@@ -36,7 +36,7 @@ describe('templates', () => {
|
|
36
36
|
});
|
37
37
|
|
38
38
|
describe('compose file generation', () => {
|
39
|
-
test('
|
39
|
+
test('compose generated with correct empty values', () => {
|
40
40
|
const config = {
|
41
41
|
mappings: {},
|
42
42
|
plugins: {},
|
@@ -45,6 +45,24 @@ describe('templates', () => {
|
|
45
45
|
const composeYml = generateDockerComposeYmlTemplate( config, '/some/base/path', 1234, '/some/wp-config/path' );
|
46
46
|
expect(composeYml).toMatchSnapshot();
|
47
47
|
});
|
48
|
+
test('compose generated with correct values', () => {
|
49
|
+
const config = {
|
50
|
+
mappings: {
|
51
|
+
'some/host/path': 'some/container/path',
|
52
|
+
'some/other/host/path': 'some/other/container/path',
|
53
|
+
},
|
54
|
+
plugins: {
|
55
|
+
'plugin1': '../some/plugin/path',
|
56
|
+
'plugin2': '../some/other/plugin/path',
|
57
|
+
},
|
58
|
+
themes: {
|
59
|
+
'theme1': '../some/theme/path',
|
60
|
+
'theme2': '../some/other/theme/path',
|
61
|
+
},
|
62
|
+
}
|
63
|
+
const composeYml = generateDockerComposeYmlTemplate( config, '/some/base/path', 1234, '/some/wp-config/path' );
|
64
|
+
expect(composeYml).toMatchSnapshot();
|
65
|
+
});
|
48
66
|
test('mappings are mounted correctly', () => {
|
49
67
|
const config = {
|
50
68
|
mappings: {
|
package/dist/bin.cjs
CHANGED
@@ -201,9 +201,10 @@ var waitForServer = async (url, timeoutMs) => {
|
|
201
201
|
console.warn(`Encountered an error while waiting for server to start: ${e.message}
|
202
202
|
Trying to reach server again.`);
|
203
203
|
}
|
204
|
+
} finally {
|
205
|
+
retries--;
|
204
206
|
}
|
205
207
|
await sleep(pollEveryMs);
|
206
|
-
retries--;
|
207
208
|
}
|
208
209
|
console.error(`Server did not start within ${timeoutMs}ms`);
|
209
210
|
return false;
|
package/dist/bin.js
CHANGED
@@ -174,9 +174,10 @@ var waitForServer = async (url, timeoutMs) => {
|
|
174
174
|
console.warn(`Encountered an error while waiting for server to start: ${e.message}
|
175
175
|
Trying to reach server again.`);
|
176
176
|
}
|
177
|
+
} finally {
|
178
|
+
retries--;
|
177
179
|
}
|
178
180
|
await sleep(pollEveryMs);
|
179
|
-
retries--;
|
180
181
|
}
|
181
182
|
console.error(`Server did not start within ${timeoutMs}ms`);
|
182
183
|
return false;
|
@@ -250,4 +251,4 @@ export {
|
|
250
251
|
commandMap,
|
251
252
|
generateFiles
|
252
253
|
};
|
253
|
-
//# sourceMappingURL=chunk-
|
254
|
+
//# sourceMappingURL=chunk-WLKYS3XU.js.map
|
package/dist/index.cjs
CHANGED
@@ -60,9 +60,10 @@ var waitForServer = async (url, timeoutMs) => {
|
|
60
60
|
console.warn(`Encountered an error while waiting for server to start: ${e.message}
|
61
61
|
Trying to reach server again.`);
|
62
62
|
}
|
63
|
+
} finally {
|
64
|
+
retries--;
|
63
65
|
}
|
64
66
|
await sleep(pollEveryMs);
|
65
|
-
retries--;
|
66
67
|
}
|
67
68
|
console.error(`Server did not start within ${timeoutMs}ms`);
|
68
69
|
return false;
|
package/dist/index.js
CHANGED
package/package.json
CHANGED
package/src/run.ts
CHANGED
@@ -27,9 +27,10 @@ const waitForServer = async ( url: string, timeoutMs: number ) => {
|
|
27
27
|
if ( 'ECONNREFUSED' !== e.cause?.code ) {
|
28
28
|
console.warn( `Encountered an error while waiting for server to start: ${ e.message }\nTrying to reach server again.` );
|
29
29
|
}
|
30
|
+
} finally {
|
31
|
+
retries--;
|
30
32
|
}
|
31
33
|
await sleep (pollEveryMs);
|
32
|
-
retries--;
|
33
34
|
}
|
34
35
|
console.error( `Server did not start within ${ timeoutMs }ms` );
|
35
36
|
return false;
|