@elementor/wp-lite-env 0.0.15 → 0.0.17

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 CHANGED
@@ -1,5 +1,18 @@
1
1
  # wp-lite-env
2
2
 
3
+ ## 0.0.17
4
+
5
+ ### Patch Changes
6
+
7
+ - 34f7b7c: code review fixes
8
+ - a021f2d: code review fixes
9
+
10
+ ## 0.0.16
11
+
12
+ ### Patch Changes
13
+
14
+ - 8d278b0: clean up only after stopping the server
15
+
3
16
  ## 0.0.15
4
17
 
5
18
  ### Patch Changes
package/__tests__/e2e.ts CHANGED
@@ -1,15 +1,14 @@
1
1
  import {afterEach, beforeAll, describe, expect, test} from "@jest/globals";
2
- import {cleanup, generateFiles, getConfigFilePath, start, stop} from "../src/run";
2
+ import {generateFiles, getConfigFilePath, start, stop} from "../src/run";
3
3
 
4
4
  const port = '1234';
5
5
 
6
6
  describe('end to end tests', () => {
7
7
  beforeAll(async () => {
8
- generateFiles(port, getConfigFilePath(['', '', '', 'config=./tests/.wp-lite-env.json']));
8
+ generateFiles(port, getConfigFilePath(['', '', '', 'config=./__tests__/.wp-lite-env.json']));
9
9
  })
10
10
  afterEach(async () => {
11
11
  await stop(port);
12
- cleanup(port);
13
12
  }, 30000);
14
13
  test('WordPress is up and running', async () => {
15
14
  await start( port );
package/dist/bin.cjs CHANGED
@@ -185,10 +185,13 @@ var waitForServer = async (url, timeoutMs) => {
185
185
  return true;
186
186
  }
187
187
  } catch (e) {
188
+ console.warn(`Encountered an error while waiting for server to start: ${e.message}
189
+ Trying to reach server again.`);
188
190
  } finally {
189
191
  await sleep(100);
190
192
  }
191
193
  }
194
+ console.error(`Server did not start within ${timeoutMs}ms`);
192
195
  return false;
193
196
  };
194
197
  var getRunPath = (port2) => import_path2.default.resolve(import_node_os.default.tmpdir(), port2);
@@ -200,7 +203,7 @@ var start = async (port2) => {
200
203
  cwd: runPath,
201
204
  log: true
202
205
  });
203
- await waitForServer(`http://localhost:${port2}`, 1e4);
206
+ await waitForServer(`http://0.0.0.0:${port2}`, 1e4);
204
207
  await cli(port2, "bash wp-config/configure-wp.sh");
205
208
  };
206
209
  var stop = async (port2) => {
@@ -211,6 +214,7 @@ var stop = async (port2) => {
211
214
  composeOptions: ["-p", `port${port2}`],
212
215
  log: true
213
216
  });
217
+ cleanup(port2);
214
218
  };
215
219
  var cli = async (port2, command2) => {
216
220
  const runPath = getRunPath(port2);
@@ -283,7 +287,5 @@ var port = getPort(process.argv);
283
287
  var configFilePath = getConfigFilePath(process.argv);
284
288
  var cliCommand = getCliCommand(process.argv);
285
289
  generateFiles(port, configFilePath);
286
- commandMap[command](port, cliCommand).finally(() => {
287
- cleanup(port);
288
- });
290
+ commandMap[command](port, cliCommand);
289
291
  //# sourceMappingURL=bin.cjs.map
package/dist/bin.js CHANGED
@@ -1,12 +1,11 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
- cleanup,
4
3
  commandMap,
5
4
  generateFiles,
6
5
  getCliCommand,
7
6
  getConfigFilePath,
8
7
  getPort
9
- } from "./chunk-BYFZ2VGL.js";
8
+ } from "./chunk-MP53H5K3.js";
10
9
 
11
10
  // src/bin.ts
12
11
  var command = process.argv[2];
@@ -17,7 +16,5 @@ var port = getPort(process.argv);
17
16
  var configFilePath = getConfigFilePath(process.argv);
18
17
  var cliCommand = getCliCommand(process.argv);
19
18
  generateFiles(port, configFilePath);
20
- commandMap[command](port, cliCommand).finally(() => {
21
- cleanup(port);
22
- });
19
+ commandMap[command](port, cliCommand);
23
20
  //# sourceMappingURL=bin.js.map
@@ -161,10 +161,13 @@ var waitForServer = async (url, timeoutMs) => {
161
161
  return true;
162
162
  }
163
163
  } catch (e) {
164
+ console.warn(`Encountered an error while waiting for server to start: ${e.message}
165
+ Trying to reach server again.`);
164
166
  } finally {
165
167
  await sleep(100);
166
168
  }
167
169
  }
170
+ console.error(`Server did not start within ${timeoutMs}ms`);
168
171
  return false;
169
172
  };
170
173
  var getRunPath = (port) => path2.resolve(os.tmpdir(), port);
@@ -176,7 +179,7 @@ var start = async (port) => {
176
179
  cwd: runPath,
177
180
  log: true
178
181
  });
179
- await waitForServer(`http://localhost:${port}`, 1e4);
182
+ await waitForServer(`http://0.0.0.0:${port}`, 1e4);
180
183
  await cli(port, "bash wp-config/configure-wp.sh");
181
184
  };
182
185
  var stop = async (port) => {
@@ -187,6 +190,7 @@ var stop = async (port) => {
187
190
  composeOptions: ["-p", `port${port}`],
188
191
  log: true
189
192
  });
193
+ cleanup(port);
190
194
  };
191
195
  var cli = async (port, command) => {
192
196
  const runPath = getRunPath(port);
@@ -258,7 +262,6 @@ export {
258
262
  generateFiles,
259
263
  getConfigFilePath,
260
264
  getCliCommand,
261
- getPort,
262
- cleanup
265
+ getPort
263
266
  };
264
- //# sourceMappingURL=chunk-BYFZ2VGL.js.map
267
+ //# sourceMappingURL=chunk-MP53H5K3.js.map
package/dist/index.cjs CHANGED
@@ -38,6 +38,7 @@ module.exports = __toCommonJS(src_exports);
38
38
  // src/run.ts
39
39
  var import_docker_compose = require("docker-compose");
40
40
  var import_path = __toESM(require("path"), 1);
41
+ var import_fs = __toESM(require("fs"), 1);
41
42
  var import_node_os = __toESM(require("os"), 1);
42
43
  var waitForServer = async (url, timeoutMs) => {
43
44
  const startTime = Date.now();
@@ -49,10 +50,13 @@ var waitForServer = async (url, timeoutMs) => {
49
50
  return true;
50
51
  }
51
52
  } catch (e) {
53
+ console.warn(`Encountered an error while waiting for server to start: ${e.message}
54
+ Trying to reach server again.`);
52
55
  } finally {
53
56
  await sleep(100);
54
57
  }
55
58
  }
59
+ console.error(`Server did not start within ${timeoutMs}ms`);
56
60
  return false;
57
61
  };
58
62
  var getRunPath = (port) => import_path.default.resolve(import_node_os.default.tmpdir(), port);
@@ -64,7 +68,7 @@ var start = async (port) => {
64
68
  cwd: runPath,
65
69
  log: true
66
70
  });
67
- await waitForServer(`http://localhost:${port}`, 1e4);
71
+ await waitForServer(`http://0.0.0.0:${port}`, 1e4);
68
72
  await cli(port, "bash wp-config/configure-wp.sh");
69
73
  };
70
74
  var stop = async (port) => {
@@ -75,6 +79,7 @@ var stop = async (port) => {
75
79
  composeOptions: ["-p", `port${port}`],
76
80
  log: true
77
81
  });
82
+ cleanup(port);
78
83
  };
79
84
  var cli = async (port, command) => {
80
85
  const runPath = getRunPath(port);
@@ -85,6 +90,12 @@ var cli = async (port, command) => {
85
90
  log: true
86
91
  });
87
92
  };
93
+ var getWpConfigPath = (port) => import_path.default.resolve(process.cwd(), port);
94
+ var cleanup = (port) => {
95
+ const runPath = getRunPath(port);
96
+ import_fs.default.rmSync(getWpConfigPath(port), { recursive: true, force: true });
97
+ import_fs.default.rmSync(runPath, { recursive: true, force: true });
98
+ };
88
99
  // Annotate the CommonJS export names for ESM import in node:
89
100
  0 && (module.exports = {
90
101
  cli,
package/dist/index.js CHANGED
@@ -2,7 +2,7 @@ import {
2
2
  cli,
3
3
  start,
4
4
  stop
5
- } from "./chunk-BYFZ2VGL.js";
5
+ } from "./chunk-MP53H5K3.js";
6
6
  export {
7
7
  cli,
8
8
  start,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elementor/wp-lite-env",
3
- "version": "0.0.15",
3
+ "version": "0.0.17",
4
4
  "private": false,
5
5
  "description": "A simple, lightweight, docker-based WordPress environment",
6
6
  "main": "dist/index.cjs",
package/src/bin.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- import {cleanup, commandMap, generateFiles, getCliCommand, getConfigFilePath, getPort} from './run';
3
+ import {commandMap, generateFiles, getCliCommand, getConfigFilePath, getPort} from './run';
4
4
 
5
5
  const command = process.argv[ 2 ];
6
6
  if ( ! commandMap[ command ] ) {
@@ -12,6 +12,4 @@ const configFilePath = getConfigFilePath( process.argv )
12
12
  const cliCommand = getCliCommand( process.argv );
13
13
  generateFiles( port, configFilePath );
14
14
 
15
- commandMap[command](port, cliCommand).finally( () => {
16
- cleanup( port );
17
- } );
15
+ commandMap[command](port, cliCommand);
package/src/run.ts CHANGED
@@ -21,12 +21,13 @@ const waitForServer = async ( url: string, timeoutMs: number ) => {
21
21
  if ( response.ok && ( 200 === response.status || 302 === response.status ) ) {
22
22
  return true;
23
23
  }
24
- } catch ( e ) { // eslint-disable-line @typescript-eslint/no-unused-vars
25
- // Ignore
24
+ } catch ( e ) {
25
+ console.warn( `Encountered an error while waiting for server to start: ${ e.message }\nTrying to reach server again.` );
26
26
  } finally {
27
27
  await sleep( 100 );
28
28
  }
29
29
  }
30
+ console.error( `Server did not start within ${ timeoutMs }ms` );
30
31
  return false;
31
32
  };
32
33
 
@@ -40,7 +41,7 @@ export const start = async ( port: string ) => {
40
41
  cwd: runPath,
41
42
  log: true,
42
43
  } );
43
- await waitForServer( `http://localhost:${ port }`, 10000 );
44
+ await waitForServer( `http://0.0.0.0:${ port }`, 10000 );
44
45
  await cli( port, 'bash wp-config/configure-wp.sh' );
45
46
  };
46
47
 
@@ -52,6 +53,7 @@ export const stop = async ( port: string ) => {
52
53
  composeOptions: [ '-p', `port${ port }` ],
53
54
  log: true,
54
55
  } );
56
+ cleanup( port );
55
57
  };
56
58
 
57
59
  export const cli = async ( port: string, command: string ) => {
@@ -124,7 +126,7 @@ export const getPort = ( processArgs: string[] ) => {
124
126
  return getArgument( 'port', processArgs ) || '8888';
125
127
  };
126
128
 
127
- export const cleanup = ( port: string ) => {
129
+ const cleanup = ( port: string ) => {
128
130
  const runPath = getRunPath( port );
129
131
  fs.rmSync( getWpConfigPath( port ), { recursive: true, force: true } );
130
132
  fs.rmSync( runPath, { recursive: true, force: true } );
File without changes