Skip to content

Commit

Permalink
Env: Add support for custom ports. (#17697)
Browse files Browse the repository at this point in the history
  • Loading branch information
epiqueras authored and hypest committed Nov 4, 2019
1 parent 6ab0e32 commit 03414de
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 15 deletions.
1 change: 1 addition & 0 deletions packages/env/.npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package-lock=false
17 changes: 11 additions & 6 deletions packages/env/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@ wp-env <command>

Commands:
wp-env start [ref] Starts WordPress for development on port 8888
(​http://localhost:8888​) and tests on port 8889
(​http://localhost:8889​). If the current working
(​http://localhost:8888​) (override with
WP_ENV_PORT) and tests on port 8889
(​http://localhost:8889​) (override with
WP_ENV_TESTS_PORT). If the current working
directory is a plugin and/or has e2e-tests with
plugins and/or mu-plugins, they will be mounted
appropiately.
Expand All @@ -34,10 +36,11 @@ Options:
```sh
wp-env start [ref]

Starts WordPress for development on port 8888 (​http://localhost:8888​) and
tests on port 8889 (​http://localhost:8889​). If the current working directory
is a plugin and/or has e2e-tests with plugins and/or mu-plugins, they will be
mounted appropiately.
Starts WordPress for development on port 8888 (​http://localhost:8888​)
(override with WP_ENV_PORT) and tests on port 8889 (​http://localhost:8889​)
(override with WP_ENV_TESTS_PORT). If the current working directory is a plugin
and/or has e2e-tests with plugins and/or mu-plugins, they will be mounted
appropiately.

Positionals:
ref A `https://github.com/WordPress/WordPress` git repo branch or commit for
Expand All @@ -63,3 +66,5 @@ Positionals:
environment Which environments' databases to clean.
[string] [choices: "all", "development", "tests"] [default: "tests"]
```
<br/><br/><p align="center"><img src="https://s.w.org/style/images/codeispoetry.png?1" alt="Code is Poetry." /></p>
4 changes: 2 additions & 2 deletions packages/env/lib/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@ module.exports = function cli() {
chalk`Starts WordPress for development on port {bold.underline ${ terminalLink(
'8888',
'http://localhost:8888'
) }} and tests on port {bold.underline ${ terminalLink(
) }} (override with WP_ENV_PORT) and tests on port {bold.underline ${ terminalLink(
'8889',
'http://localhost:8889'
) }}. If the current working directory is a plugin and/or has e2e-tests with plugins and/or mu-plugins, they will be mounted appropiately.`
) }} (override with WP_ENV_TESTS_PORT). If the current working directory is a plugin and/or has e2e-tests with plugins and/or mu-plugins, they will be mounted appropiately.`
),
( args ) => {
args.positional( 'ref', {
Expand Down
6 changes: 3 additions & 3 deletions packages/env/lib/create-docker-compose-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ module.exports = function createDockerComposeConfig(
- ${ pluginPath }/../${ pluginName }-wordpress/:/var/www/html/${ commonVolumes }`;
const testsVolumes = `
- tests-wordpress:/var/www/html/${ commonVolumes }`;
return `version: '2'
return `version: '2.1'
volumes:
tests-wordpress:
services:
Expand All @@ -28,7 +28,7 @@ services:
WORDPRESS_DB_PASSWORD: password
image: wordpress
ports:
- 8888:80
- \${WP_ENV_PORT:-8888}:80
volumes:${ volumes }
wordpress-cli:
depends_on:
Expand All @@ -44,7 +44,7 @@ services:
WORDPRESS_DB_PASSWORD: password
image: wordpress
ports:
- 8889:80
- \${WP_ENV_TESTS_PORT:-8889}:80
volumes:${ testsVolumes }
tests-wordpress-cli:
depends_on:
Expand Down
8 changes: 5 additions & 3 deletions packages/env/lib/env.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,11 @@ const wpCliRun = ( command, isTests = false ) =>
);
const setupSite = ( isTests = false ) =>
wpCliRun(
`wp core install --url=localhost:888${
isTests ? '9' : '8'
} --title=Gutenberg --admin_user=admin --admin_password=password [email protected]`,
`wp core install --url=localhost:${
isTests ?
process.env.WP_ENV_TESTS_PORT || 8889 :
process.env.WP_ENV_PORT || 8888
} --title=${ pluginName } --admin_user=admin --admin_password=password [email protected]`,
isTests
);
const activatePlugin = ( isTests = false ) =>
Expand Down
2 changes: 1 addition & 1 deletion packages/env/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@wordpress/env",
"version": "1.0.0",
"version": "0.0.0",
"description": "A zero-config, self contained local WordPress environment for development and testing.",
"author": "The WordPress Contributors",
"license": "GPL-2.0-or-later",
Expand Down

0 comments on commit 03414de

Please sign in to comment.