@wordpress/env 10.13.1-next.cd6172eb0.0 → 10.15.0
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/LICENSE.md +1 -1
- package/README.md +1 -1
- package/lib/build-docker-compose-config.js +27 -0
- package/lib/commands/destroy.js +13 -9
- package/lib/commands/start.js +74 -24
- package/lib/config/get-config-from-environment-vars.js +7 -0
- package/lib/config/parse-config.js +25 -8
- package/lib/config/test/__snapshots__/config-integration.js.snap +16 -0
- package/lib/config/test/parse-config.js +55 -0
- package/lib/download-sources.js +1 -1
- package/lib/validate-run-container.js +1 -0
- package/lib/wordpress.js +30 -1
- package/package.json +4 -4
package/LICENSE.md
CHANGED
package/README.md
CHANGED
|
@@ -349,7 +349,7 @@ containers.
|
|
|
349
349
|
Positionals:
|
|
350
350
|
container The Docker service to run the command on.
|
|
351
351
|
[string] [required] [choices: "mysql", "tests-mysql", "wordpress",
|
|
352
|
-
"tests-wordpress", "cli", "tests-cli", "composer", "
|
|
352
|
+
"tests-wordpress", "cli", "tests-cli", "composer", "phpmyadmin"]
|
|
353
353
|
command The command to run. [required]
|
|
354
354
|
|
|
355
355
|
Options:
|
|
@@ -174,6 +174,13 @@ module.exports = function buildDockerComposeConfig( config ) {
|
|
|
174
174
|
config.env.tests.mysqlPort ?? ''
|
|
175
175
|
}}:3306`;
|
|
176
176
|
|
|
177
|
+
const developmentPhpmyadminPorts = `\${WP_ENV_PHPMYADMIN_PORT:-${
|
|
178
|
+
config.env.development.phpmyadminPort ?? ''
|
|
179
|
+
}}:80`;
|
|
180
|
+
const testsPhpmyadminPorts = `\${WP_ENV_TESTS_PHPMYADMIN_PORT:-${
|
|
181
|
+
config.env.tests.phpmyadminPort ?? ''
|
|
182
|
+
}}:80`;
|
|
183
|
+
|
|
177
184
|
return {
|
|
178
185
|
services: {
|
|
179
186
|
mysql: {
|
|
@@ -266,6 +273,26 @@ module.exports = function buildDockerComposeConfig( config ) {
|
|
|
266
273
|
},
|
|
267
274
|
extra_hosts: [ 'host.docker.internal:host-gateway' ],
|
|
268
275
|
},
|
|
276
|
+
phpmyadmin: {
|
|
277
|
+
image: 'phpmyadmin',
|
|
278
|
+
ports: [ developmentPhpmyadminPorts ],
|
|
279
|
+
environment: {
|
|
280
|
+
PMA_PORT: 3306,
|
|
281
|
+
PMA_HOST: 'mysql',
|
|
282
|
+
PMA_USER: 'root',
|
|
283
|
+
PMA_PASSWORD: 'password',
|
|
284
|
+
},
|
|
285
|
+
},
|
|
286
|
+
'tests-phpmyadmin': {
|
|
287
|
+
image: 'phpmyadmin',
|
|
288
|
+
ports: [ testsPhpmyadminPorts ],
|
|
289
|
+
environment: {
|
|
290
|
+
PMA_PORT: 3306,
|
|
291
|
+
PMA_HOST: 'tests-mysql',
|
|
292
|
+
PMA_USER: 'root',
|
|
293
|
+
PMA_PASSWORD: 'password',
|
|
294
|
+
},
|
|
295
|
+
},
|
|
269
296
|
},
|
|
270
297
|
volumes: {
|
|
271
298
|
...( ! config.env.development.coreSource && { wordpress: {} } ),
|
package/lib/commands/destroy.js
CHANGED
|
@@ -3,15 +3,14 @@
|
|
|
3
3
|
* External dependencies
|
|
4
4
|
*/
|
|
5
5
|
const { v2: dockerCompose } = require( 'docker-compose' );
|
|
6
|
-
const util = require( 'util' );
|
|
7
6
|
const fs = require( 'fs' ).promises;
|
|
8
7
|
const path = require( 'path' );
|
|
9
|
-
const
|
|
8
|
+
const { confirm } = require( '@inquirer/prompts' );
|
|
10
9
|
|
|
11
10
|
/**
|
|
12
11
|
* Promisified dependencies
|
|
13
12
|
*/
|
|
14
|
-
const rimraf =
|
|
13
|
+
const { rimraf } = require( 'rimraf' );
|
|
15
14
|
|
|
16
15
|
/**
|
|
17
16
|
* Internal dependencies
|
|
@@ -41,14 +40,19 @@ module.exports = async function destroy( { spinner, scripts, debug } ) {
|
|
|
41
40
|
'WARNING! This will remove Docker containers, volumes, networks, and images associated with the WordPress instance.'
|
|
42
41
|
);
|
|
43
42
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
name: 'yesDelete',
|
|
43
|
+
let yesDelete = false;
|
|
44
|
+
try {
|
|
45
|
+
yesDelete = await confirm( {
|
|
48
46
|
message: 'Are you sure you want to continue?',
|
|
49
47
|
default: false,
|
|
50
|
-
}
|
|
51
|
-
|
|
48
|
+
} );
|
|
49
|
+
} catch ( error ) {
|
|
50
|
+
if ( error.name === 'ExitPromptError' ) {
|
|
51
|
+
console.log( 'Cancelled.' );
|
|
52
|
+
process.exit( 1 );
|
|
53
|
+
}
|
|
54
|
+
throw error;
|
|
55
|
+
}
|
|
52
56
|
|
|
53
57
|
spinner.start();
|
|
54
58
|
|
package/lib/commands/start.js
CHANGED
|
@@ -6,13 +6,13 @@ const { v2: dockerCompose } = require( 'docker-compose' );
|
|
|
6
6
|
const util = require( 'util' );
|
|
7
7
|
const path = require( 'path' );
|
|
8
8
|
const fs = require( 'fs' ).promises;
|
|
9
|
-
const
|
|
9
|
+
const { confirm } = require( '@inquirer/prompts' );
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
12
|
* Promisified dependencies
|
|
13
13
|
*/
|
|
14
14
|
const sleep = util.promisify( setTimeout );
|
|
15
|
-
const rimraf =
|
|
15
|
+
const { rimraf } = require( 'rimraf' );
|
|
16
16
|
const exec = util.promisify( require( 'child_process' ).exec );
|
|
17
17
|
|
|
18
18
|
/**
|
|
@@ -180,6 +180,24 @@ module.exports = async function start( {
|
|
|
180
180
|
}
|
|
181
181
|
);
|
|
182
182
|
|
|
183
|
+
if ( config.env.development.phpmyadminPort ) {
|
|
184
|
+
await dockerCompose.upOne( 'phpmyadmin', {
|
|
185
|
+
...dockerComposeConfig,
|
|
186
|
+
commandOptions: shouldConfigureWp
|
|
187
|
+
? [ '--build', '--force-recreate' ]
|
|
188
|
+
: [],
|
|
189
|
+
} );
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
if ( config.env.tests.phpmyadminPort ) {
|
|
193
|
+
await dockerCompose.upOne( 'tests-phpmyadmin', {
|
|
194
|
+
...dockerComposeConfig,
|
|
195
|
+
commandOptions: shouldConfigureWp
|
|
196
|
+
? [ '--build', '--force-recreate' ]
|
|
197
|
+
: [],
|
|
198
|
+
} );
|
|
199
|
+
}
|
|
200
|
+
|
|
183
201
|
// Make sure we've consumed the custom CLI dockerfile.
|
|
184
202
|
if ( shouldConfigureWp ) {
|
|
185
203
|
await dockerCompose.buildOne( [ 'cli' ], { ...dockerComposeConfig } );
|
|
@@ -225,35 +243,61 @@ module.exports = async function start( {
|
|
|
225
243
|
const siteUrl = config.env.development.config.WP_SITEURL;
|
|
226
244
|
const testsSiteUrl = config.env.tests.config.WP_SITEURL;
|
|
227
245
|
|
|
228
|
-
const
|
|
246
|
+
const mySQLPort = await getPublicDockerPort(
|
|
229
247
|
'mysql',
|
|
230
248
|
3306,
|
|
231
249
|
dockerComposeConfig
|
|
232
250
|
);
|
|
233
|
-
const mySQLPort = mySQLAddress.split( ':' ).pop();
|
|
234
251
|
|
|
235
|
-
const
|
|
252
|
+
const testsMySQLPort = await getPublicDockerPort(
|
|
236
253
|
'tests-mysql',
|
|
237
254
|
3306,
|
|
238
255
|
dockerComposeConfig
|
|
239
256
|
);
|
|
240
|
-
const testsMySQLPort = testsMySQLAddress.split( ':' ).pop();
|
|
241
|
-
|
|
242
|
-
spinner.prefixText = 'WordPress development site started'
|
|
243
|
-
.concat( siteUrl ? ` at ${ siteUrl }` : '.' )
|
|
244
|
-
.concat( '\n' )
|
|
245
|
-
.concat( 'WordPress test site started' )
|
|
246
|
-
.concat( testsSiteUrl ? ` at ${ testsSiteUrl }` : '.' )
|
|
247
|
-
.concat( '\n' )
|
|
248
|
-
.concat( `MySQL is listening on port ${ mySQLPort }` )
|
|
249
|
-
.concat(
|
|
250
|
-
`MySQL for automated testing is listening on port ${ testsMySQLPort }`
|
|
251
|
-
)
|
|
252
|
-
.concat( '\n' );
|
|
253
257
|
|
|
258
|
+
const phpmyadminPort = config.env.development.phpmyadminPort
|
|
259
|
+
? await getPublicDockerPort( 'phpmyadmin', 80, dockerComposeConfig )
|
|
260
|
+
: null;
|
|
261
|
+
|
|
262
|
+
const testsPhpmyadminPort = config.env.tests.phpmyadminPort
|
|
263
|
+
? await getPublicDockerPort(
|
|
264
|
+
'tests-phpmyadmin',
|
|
265
|
+
80,
|
|
266
|
+
dockerComposeConfig
|
|
267
|
+
)
|
|
268
|
+
: null;
|
|
269
|
+
|
|
270
|
+
spinner.prefixText = [
|
|
271
|
+
'WordPress development site started' +
|
|
272
|
+
( siteUrl ? ` at ${ siteUrl }` : '.' ),
|
|
273
|
+
'WordPress test site started' +
|
|
274
|
+
( testsSiteUrl ? ` at ${ testsSiteUrl }` : '.' ),
|
|
275
|
+
`MySQL is listening on port ${ mySQLPort }`,
|
|
276
|
+
`MySQL for automated testing is listening on port ${ testsMySQLPort }`,
|
|
277
|
+
phpmyadminPort &&
|
|
278
|
+
`phpMyAdmin started at http://localhost:${ phpmyadminPort }`,
|
|
279
|
+
testsPhpmyadminPort &&
|
|
280
|
+
`phpMyAdmin for automated testing started at http://localhost:${ testsPhpmyadminPort }`,
|
|
281
|
+
]
|
|
282
|
+
.filter( Boolean )
|
|
283
|
+
.join( '\n' );
|
|
284
|
+
spinner.prefixText += '\n\n';
|
|
254
285
|
spinner.text = 'Done!';
|
|
255
286
|
};
|
|
256
287
|
|
|
288
|
+
async function getPublicDockerPort(
|
|
289
|
+
service,
|
|
290
|
+
containerPort,
|
|
291
|
+
dockerComposeConfig
|
|
292
|
+
) {
|
|
293
|
+
const { out: address } = await dockerCompose.port(
|
|
294
|
+
service,
|
|
295
|
+
containerPort,
|
|
296
|
+
dockerComposeConfig
|
|
297
|
+
);
|
|
298
|
+
return address.split( ':' ).pop().trim();
|
|
299
|
+
}
|
|
300
|
+
|
|
257
301
|
/**
|
|
258
302
|
* Checks for legacy installs and provides
|
|
259
303
|
* the user the option to delete them.
|
|
@@ -284,15 +328,21 @@ async function checkForLegacyInstall( spinner ) {
|
|
|
284
328
|
' and '
|
|
285
329
|
) }. Installs are now in your home folder.\n`
|
|
286
330
|
);
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
name: 'yesDelete',
|
|
331
|
+
let yesDelete = false;
|
|
332
|
+
try {
|
|
333
|
+
yesDelete = confirm( {
|
|
291
334
|
message:
|
|
292
335
|
'Do you wish to delete these old installs to reclaim disk space?',
|
|
293
336
|
default: true,
|
|
294
|
-
}
|
|
295
|
-
|
|
337
|
+
} );
|
|
338
|
+
} catch ( error ) {
|
|
339
|
+
if ( error.name === 'ExitPromptError' ) {
|
|
340
|
+
console.log( 'Cancelled.' );
|
|
341
|
+
process.exit( 1 );
|
|
342
|
+
}
|
|
343
|
+
throw error;
|
|
344
|
+
}
|
|
345
|
+
|
|
296
346
|
if ( yesDelete ) {
|
|
297
347
|
await Promise.all( installs.map( ( install ) => rimraf( install ) ) );
|
|
298
348
|
spinner.info( 'Old installs deleted successfully.' );
|
|
@@ -20,6 +20,7 @@ const { checkPort, checkVersion, checkString } = require( './validate-config' );
|
|
|
20
20
|
* @property {?number} mysqlPort An override for the development environment's MySQL port.
|
|
21
21
|
* @property {?number} testsPort An override for the testing environment's port.
|
|
22
22
|
* @property {?number} testsMysqlPort An override for the testing environment's MySQL port.
|
|
23
|
+
* @property {?number} phpmyadminPort An override for the development environment's phpMyAdmin port.
|
|
23
24
|
* @property {?WPSource} coreSource An override for all environment's coreSource.
|
|
24
25
|
* @property {?string} phpVersion An override for all environment's PHP version.
|
|
25
26
|
* @property {?Object.<string, string>} lifecycleScripts An override for various lifecycle scripts.
|
|
@@ -40,6 +41,12 @@ module.exports = function getConfigFromEnvironmentVars( cacheDirectoryPath ) {
|
|
|
40
41
|
testsMysqlPort: getPortFromEnvironmentVariable(
|
|
41
42
|
'WP_ENV_TESTS_MYSQL_PORT'
|
|
42
43
|
),
|
|
44
|
+
phpmyadminPort: getPortFromEnvironmentVariable(
|
|
45
|
+
'WP_ENV_PHPMYADMIN_PORT'
|
|
46
|
+
),
|
|
47
|
+
testsPhpmyadminPort: getPortFromEnvironmentVariable(
|
|
48
|
+
'WP_ENV_TESTS_PHPMYADMIN_PORT'
|
|
49
|
+
),
|
|
43
50
|
lifecycleScripts: getLifecycleScriptOverrides(),
|
|
44
51
|
};
|
|
45
52
|
|
|
@@ -46,14 +46,16 @@ const mergeConfigs = require( './merge-configs' );
|
|
|
46
46
|
* The environment-specific configuration options. (development/tests/etc)
|
|
47
47
|
*
|
|
48
48
|
* @typedef WPEnvironmentConfig
|
|
49
|
-
* @property {WPSource} coreSource
|
|
50
|
-
* @property {WPSource[]} pluginSources
|
|
51
|
-
* @property {WPSource[]} themeSources
|
|
52
|
-
* @property {number} port
|
|
53
|
-
* @property {number} mysqlPort
|
|
54
|
-
* @property {
|
|
55
|
-
* @property {
|
|
56
|
-
* @property {
|
|
49
|
+
* @property {WPSource} coreSource The WordPress installation to load in the environment.
|
|
50
|
+
* @property {WPSource[]} pluginSources Plugins to load in the environment.
|
|
51
|
+
* @property {WPSource[]} themeSources Themes to load in the environment.
|
|
52
|
+
* @property {number} port The port to use.
|
|
53
|
+
* @property {number} mysqlPort The port to use for MySQL. Random if empty.
|
|
54
|
+
* @property {number} phpmyadminPort The port to use for phpMyAdmin. If empty, disabled phpMyAdmin.
|
|
55
|
+
* @property {boolean} multisite Whether to set up a multisite installation.
|
|
56
|
+
* @property {Object} config Mapping of wp-config.php constants to their desired values.
|
|
57
|
+
* @property {Object.<string, WPSource>} mappings Mapping of WordPress directories to local directories which should be mounted.
|
|
58
|
+
* @property {string|null} phpVersion Version of PHP to use in the environments, of the format 0.0.
|
|
57
59
|
*/
|
|
58
60
|
|
|
59
61
|
/**
|
|
@@ -87,6 +89,8 @@ const DEFAULT_ENVIRONMENT_CONFIG = {
|
|
|
87
89
|
port: 8888,
|
|
88
90
|
testsPort: 8889,
|
|
89
91
|
mysqlPort: null,
|
|
92
|
+
phpmyadminPort: null,
|
|
93
|
+
multisite: false,
|
|
90
94
|
mappings: {},
|
|
91
95
|
config: {
|
|
92
96
|
FS_METHOD: 'direct',
|
|
@@ -282,6 +286,11 @@ function getEnvironmentVarOverrides( cacheDirectoryPath ) {
|
|
|
282
286
|
overrideConfig.env.development.mysqlPort = overrides.mysqlPort;
|
|
283
287
|
}
|
|
284
288
|
|
|
289
|
+
if ( overrides.phpmyadminPort ) {
|
|
290
|
+
overrideConfig.env.development.phpmyadminPort =
|
|
291
|
+
overrides.phpmyadminPort;
|
|
292
|
+
}
|
|
293
|
+
|
|
285
294
|
if ( overrides.testsPort ) {
|
|
286
295
|
overrideConfig.testsPort = overrides.testsPort;
|
|
287
296
|
overrideConfig.env.tests.port = overrides.testsPort;
|
|
@@ -455,6 +464,14 @@ async function parseEnvironmentConfig(
|
|
|
455
464
|
parsedConfig.mysqlPort = config.mysqlPort;
|
|
456
465
|
}
|
|
457
466
|
|
|
467
|
+
if ( config.phpmyadminPort !== undefined ) {
|
|
468
|
+
parsedConfig.phpmyadminPort = config.phpmyadminPort;
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
if ( config.multisite !== undefined ) {
|
|
472
|
+
parsedConfig.multisite = config.multisite;
|
|
473
|
+
}
|
|
474
|
+
|
|
458
475
|
if ( config.phpVersion !== undefined ) {
|
|
459
476
|
// Support null as a valid input.
|
|
460
477
|
if ( config.phpVersion !== null ) {
|
|
@@ -29,8 +29,10 @@ exports[`Config Integration should load local and override configuration files 1
|
|
|
29
29
|
"url": "https://github.com/WordPress/WordPress.git",
|
|
30
30
|
},
|
|
31
31
|
"mappings": {},
|
|
32
|
+
"multisite": false,
|
|
32
33
|
"mysqlPort": 23306,
|
|
33
34
|
"phpVersion": null,
|
|
35
|
+
"phpmyadminPort": null,
|
|
34
36
|
"pluginSources": [],
|
|
35
37
|
"port": 999,
|
|
36
38
|
"themeSources": [],
|
|
@@ -58,8 +60,10 @@ exports[`Config Integration should load local and override configuration files 1
|
|
|
58
60
|
"url": "https://github.com/WordPress/WordPress.git",
|
|
59
61
|
},
|
|
60
62
|
"mappings": {},
|
|
63
|
+
"multisite": false,
|
|
61
64
|
"mysqlPort": 23307,
|
|
62
65
|
"phpVersion": null,
|
|
66
|
+
"phpmyadminPort": null,
|
|
63
67
|
"pluginSources": [],
|
|
64
68
|
"port": 456,
|
|
65
69
|
"themeSources": [],
|
|
@@ -104,8 +108,10 @@ exports[`Config Integration should load local configuration file 1`] = `
|
|
|
104
108
|
"url": "https://github.com/WordPress/WordPress.git",
|
|
105
109
|
},
|
|
106
110
|
"mappings": {},
|
|
111
|
+
"multisite": false,
|
|
107
112
|
"mysqlPort": 13306,
|
|
108
113
|
"phpVersion": null,
|
|
114
|
+
"phpmyadminPort": null,
|
|
109
115
|
"pluginSources": [],
|
|
110
116
|
"port": 123,
|
|
111
117
|
"themeSources": [],
|
|
@@ -133,8 +139,10 @@ exports[`Config Integration should load local configuration file 1`] = `
|
|
|
133
139
|
"url": "https://github.com/WordPress/WordPress.git",
|
|
134
140
|
},
|
|
135
141
|
"mappings": {},
|
|
142
|
+
"multisite": false,
|
|
136
143
|
"mysqlPort": 23307,
|
|
137
144
|
"phpVersion": null,
|
|
145
|
+
"phpmyadminPort": null,
|
|
138
146
|
"pluginSources": [],
|
|
139
147
|
"port": 8889,
|
|
140
148
|
"themeSources": [],
|
|
@@ -179,8 +187,10 @@ exports[`Config Integration should use default configuration 1`] = `
|
|
|
179
187
|
"url": "https://github.com/WordPress/WordPress.git",
|
|
180
188
|
},
|
|
181
189
|
"mappings": {},
|
|
190
|
+
"multisite": false,
|
|
182
191
|
"mysqlPort": null,
|
|
183
192
|
"phpVersion": null,
|
|
193
|
+
"phpmyadminPort": null,
|
|
184
194
|
"pluginSources": [],
|
|
185
195
|
"port": 8888,
|
|
186
196
|
"themeSources": [],
|
|
@@ -208,8 +218,10 @@ exports[`Config Integration should use default configuration 1`] = `
|
|
|
208
218
|
"url": "https://github.com/WordPress/WordPress.git",
|
|
209
219
|
},
|
|
210
220
|
"mappings": {},
|
|
221
|
+
"multisite": false,
|
|
211
222
|
"mysqlPort": null,
|
|
212
223
|
"phpVersion": null,
|
|
224
|
+
"phpmyadminPort": null,
|
|
213
225
|
"pluginSources": [],
|
|
214
226
|
"port": 8889,
|
|
215
227
|
"themeSources": [],
|
|
@@ -254,8 +266,10 @@ exports[`Config Integration should use environment variables over local and over
|
|
|
254
266
|
"url": "https://github.com/WordPress/WordPress.git",
|
|
255
267
|
},
|
|
256
268
|
"mappings": {},
|
|
269
|
+
"multisite": false,
|
|
257
270
|
"mysqlPort": 23306,
|
|
258
271
|
"phpVersion": null,
|
|
272
|
+
"phpmyadminPort": null,
|
|
259
273
|
"pluginSources": [],
|
|
260
274
|
"port": 12345,
|
|
261
275
|
"testsPort": 61234,
|
|
@@ -284,8 +298,10 @@ exports[`Config Integration should use environment variables over local and over
|
|
|
284
298
|
"url": "https://github.com/WordPress/WordPress.git",
|
|
285
299
|
},
|
|
286
300
|
"mappings": {},
|
|
301
|
+
"multisite": false,
|
|
287
302
|
"mysqlPort": 23307,
|
|
288
303
|
"phpVersion": null,
|
|
304
|
+
"phpmyadminPort": null,
|
|
289
305
|
"pluginSources": [],
|
|
290
306
|
"port": 61234,
|
|
291
307
|
"testsPort": 61234,
|
|
@@ -22,6 +22,8 @@ const DEFAULT_CONFIG = {
|
|
|
22
22
|
port: 8888,
|
|
23
23
|
testsPort: 8889,
|
|
24
24
|
mysqlPort: null,
|
|
25
|
+
phpmyadminPort: null,
|
|
26
|
+
multisite: false,
|
|
25
27
|
phpVersion: null,
|
|
26
28
|
coreSource: {
|
|
27
29
|
type: 'git',
|
|
@@ -400,4 +402,57 @@ describe( 'parseConfig', () => {
|
|
|
400
402
|
)
|
|
401
403
|
);
|
|
402
404
|
} );
|
|
405
|
+
|
|
406
|
+
it( 'should parse phpmyadmin configuration for a given environment', async () => {
|
|
407
|
+
readRawConfigFile.mockImplementation( async ( configFile ) => {
|
|
408
|
+
if ( configFile === '/test/gutenberg/.wp-env.json' ) {
|
|
409
|
+
return {
|
|
410
|
+
core: 'WordPress/WordPress#Test',
|
|
411
|
+
phpVersion: '1.0',
|
|
412
|
+
lifecycleScripts: {
|
|
413
|
+
afterStart: 'test',
|
|
414
|
+
},
|
|
415
|
+
env: {
|
|
416
|
+
development: {
|
|
417
|
+
phpmyadminPort: 9001,
|
|
418
|
+
},
|
|
419
|
+
},
|
|
420
|
+
};
|
|
421
|
+
}
|
|
422
|
+
} );
|
|
423
|
+
|
|
424
|
+
const parsed = await parseConfig( '/test/gutenberg', '/cache' );
|
|
425
|
+
|
|
426
|
+
const expected = {
|
|
427
|
+
development: {
|
|
428
|
+
...DEFAULT_CONFIG.env.development,
|
|
429
|
+
phpmyadminPort: 9001,
|
|
430
|
+
},
|
|
431
|
+
tests: DEFAULT_CONFIG.env.tests,
|
|
432
|
+
};
|
|
433
|
+
expect( parsed.env ).toEqual( expected );
|
|
434
|
+
} );
|
|
435
|
+
|
|
436
|
+
it( 'should ignore root-level configuration for phpmyadmin', async () => {
|
|
437
|
+
readRawConfigFile.mockImplementation( async ( configFile ) => {
|
|
438
|
+
if ( configFile === '/test/gutenberg/.wp-env.json' ) {
|
|
439
|
+
return {
|
|
440
|
+
core: 'WordPress/WordPress#Test',
|
|
441
|
+
phpVersion: '1.0',
|
|
442
|
+
lifecycleScripts: {
|
|
443
|
+
afterStart: 'test',
|
|
444
|
+
},
|
|
445
|
+
phpmyadminPort: 9001,
|
|
446
|
+
};
|
|
447
|
+
}
|
|
448
|
+
} );
|
|
449
|
+
|
|
450
|
+
const parsed = await parseConfig( '/test/gutenberg', '/cache' );
|
|
451
|
+
|
|
452
|
+
const expected = {
|
|
453
|
+
development: DEFAULT_CONFIG.env.development,
|
|
454
|
+
tests: DEFAULT_CONFIG.env.tests,
|
|
455
|
+
};
|
|
456
|
+
expect( parsed.env ).toEqual( expected );
|
|
457
|
+
} );
|
|
403
458
|
} );
|
package/lib/download-sources.js
CHANGED
|
@@ -13,7 +13,7 @@ const path = require( 'path' );
|
|
|
13
13
|
*/
|
|
14
14
|
const pipeline = util.promisify( require( 'stream' ).pipeline );
|
|
15
15
|
const extractZip = util.promisify( require( 'extract-zip' ) );
|
|
16
|
-
const rimraf =
|
|
16
|
+
const { rimraf } = require( 'rimraf' );
|
|
17
17
|
|
|
18
18
|
/**
|
|
19
19
|
* @typedef {import('./config').WPConfig} WPConfig
|
package/lib/wordpress.js
CHANGED
|
@@ -86,11 +86,40 @@ async function configureWordPress( environment, config, spinner ) {
|
|
|
86
86
|
// Ignore error.
|
|
87
87
|
}
|
|
88
88
|
|
|
89
|
-
const
|
|
89
|
+
const isMultisite = config.env[ environment ].multisite;
|
|
90
|
+
|
|
91
|
+
const installMethod = isMultisite ? 'multisite-install' : 'install';
|
|
92
|
+
const installCommand = `wp core ${ installMethod } --url="${ config.env[ environment ].config.WP_SITEURL }" --title="${ config.name }" --admin_user=admin --admin_password=password --admin_email=wordpress@example.com --skip-email`;
|
|
90
93
|
|
|
91
94
|
// -eo pipefail exits the command as soon as anything fails in bash.
|
|
92
95
|
const setupCommands = [ 'set -eo pipefail', installCommand ];
|
|
93
96
|
|
|
97
|
+
// Bootstrap .htaccess for multisite
|
|
98
|
+
if ( isMultisite ) {
|
|
99
|
+
// Using a subshell with `exec` was the best tradeoff I could come up
|
|
100
|
+
// with between readability of this source and compatibility with the
|
|
101
|
+
// way that all strings in `setupCommands` are later joined with '&&'.
|
|
102
|
+
setupCommands.push(
|
|
103
|
+
`(
|
|
104
|
+
exec > /var/www/html/.htaccess
|
|
105
|
+
echo 'RewriteEngine On'
|
|
106
|
+
echo 'RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]'
|
|
107
|
+
echo 'RewriteBase /'
|
|
108
|
+
echo 'RewriteRule ^index\.php$ - [L]'
|
|
109
|
+
echo ''
|
|
110
|
+
echo '# add a trailing slash to /wp-admin'
|
|
111
|
+
echo 'RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]'
|
|
112
|
+
echo ''
|
|
113
|
+
echo 'RewriteCond %{REQUEST_FILENAME} -f [OR]'
|
|
114
|
+
echo 'RewriteCond %{REQUEST_FILENAME} -d'
|
|
115
|
+
echo 'RewriteRule ^ - [L]'
|
|
116
|
+
echo 'RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) $2 [L]'
|
|
117
|
+
echo 'RewriteRule ^([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 [L]'
|
|
118
|
+
echo 'RewriteRule . index.php [L]'
|
|
119
|
+
)`
|
|
120
|
+
);
|
|
121
|
+
}
|
|
122
|
+
|
|
94
123
|
// WordPress versions below 5.1 didn't use proper spacing in wp-config.
|
|
95
124
|
const configAnchor =
|
|
96
125
|
wpVersion && isWPMajorMinorVersionLower( wpVersion, '5.1' )
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/env",
|
|
3
|
-
"version": "10.
|
|
3
|
+
"version": "10.15.0",
|
|
4
4
|
"description": "A zero-config, self contained local WordPress environment for development and testing.",
|
|
5
5
|
"author": "The WordPress Contributors",
|
|
6
6
|
"license": "GPL-2.0-or-later",
|
|
@@ -36,15 +36,15 @@
|
|
|
36
36
|
"wp-env": "bin/wp-env"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
+
"@inquirer/prompts": "^7.2.0",
|
|
39
40
|
"chalk": "^4.0.0",
|
|
40
41
|
"copy-dir": "^1.3.0",
|
|
41
42
|
"docker-compose": "^0.24.3",
|
|
42
43
|
"extract-zip": "^1.6.7",
|
|
43
44
|
"got": "^11.8.5",
|
|
44
|
-
"inquirer": "^7.1.0",
|
|
45
45
|
"js-yaml": "^3.13.1",
|
|
46
46
|
"ora": "^4.0.2",
|
|
47
|
-
"rimraf": "^
|
|
47
|
+
"rimraf": "^5.0.10",
|
|
48
48
|
"simple-git": "^3.5.0",
|
|
49
49
|
"terminal-link": "^2.0.0",
|
|
50
50
|
"yargs": "^17.3.0"
|
|
@@ -55,5 +55,5 @@
|
|
|
55
55
|
"scripts": {
|
|
56
56
|
"test": "echo \"Error: run tests from root\" && exit 1"
|
|
57
57
|
},
|
|
58
|
-
"gitHead": "
|
|
58
|
+
"gitHead": "75a65eb8ffc168a92042544052f46d080a71ea45"
|
|
59
59
|
}
|