Skip to content

Commit

Permalink
Allow other plugins using these scripts to override the docker-compos…
Browse files Browse the repository at this point in the history
…e template with their own.
  • Loading branch information
pento committed Aug 19, 2019
1 parent 64e361e commit 5e1c8c2
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 12 deletions.
17 changes: 17 additions & 0 deletions bin/docker-compose.override.yml.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
services:
wordpress-develop:
volumes:
- %PLUGIN_MOUNT_DIR%:/var/www/${LOCAL_DIR-src}/wp-content/plugins/%PLUGIN_INSTALL_DIR%
- %PLUGIN_MOUNT_DIR%/packages/e2e-tests/plugins:/var/www/${LOCAL_DIR-src}/wp-content/plugins/gutenberg-test-plugins
- %PLUGIN_MOUNT_DIR%/packages/e2e-tests/mu-plugins:/var/www/${LOCAL_DIR-src}/wp-content/mu-plugins
php:
volumes:
- %PLUGIN_MOUNT_DIR%:/var/www/${LOCAL_DIR-src}/wp-content/plugins/%PLUGIN_INSTALL_DIR%
- %PLUGIN_MOUNT_DIR%/packages/e2e-tests/plugins:/var/www/${LOCAL_DIR-src}/wp-content/plugins/gutenberg-test-plugins
- %PLUGIN_MOUNT_DIR%/packages/e2e-tests/mu-plugins:/var/www/${LOCAL_DIR-src}/wp-content/mu-plugins
cli:
volumes:
- %PLUGIN_MOUNT_DIR%:/var/www/${LOCAL_DIR-src}/wp-content/plugins/%PLUGIN_INSTALL_DIR%
phpunit:
volumes:
- %PLUGIN_MOUNT_DIR%:/var/www/${LOCAL_DIR-src}/wp-content/plugins/%PLUGIN_INSTALL_DIR%
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,7 @@
]
},
"wp-env": {
"plugin-dir": "gutenberg"
"plugin-dir": "gutenberg",
"docker-template": "./bin/docker-compose.override.yml.template"
}
}
12 changes: 4 additions & 8 deletions packages/scripts/config/docker-compose.override.yml.template
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
services:
wordpress-develop:
volumes:
- %PLUGIN_MOUNT_DIR%:/var/www/${LOCAL_DIR-src}/wp-content/plugins/gutenberg
- %PLUGIN_MOUNT_DIR%/packages/e2e-tests/plugins:/var/www/${LOCAL_DIR-src}/wp-content/plugins/gutenberg-test-plugins
- %PLUGIN_MOUNT_DIR%/packages/e2e-tests/mu-plugins:/var/www/${LOCAL_DIR-src}/wp-content/mu-plugins
- %PLUGIN_MOUNT_DIR%:/var/www/${LOCAL_DIR-src}/wp-content/plugins/%PLUGIN_INSTALL_DIR%
php:
volumes:
- %PLUGIN_MOUNT_DIR%:/var/www/${LOCAL_DIR-src}/wp-content/plugins/gutenberg
- %PLUGIN_MOUNT_DIR%/packages/e2e-tests/plugins:/var/www/${LOCAL_DIR-src}/wp-content/plugins/gutenberg-test-plugins
- %PLUGIN_MOUNT_DIR%/packages/e2e-tests/mu-plugins:/var/www/${LOCAL_DIR-src}/wp-content/mu-plugins
- %PLUGIN_MOUNT_DIR%:/var/www/${LOCAL_DIR-src}/wp-content/plugins/%PLUGIN_INSTALL_DIR%
cli:
volumes:
- %PLUGIN_MOUNT_DIR%:/var/www/${LOCAL_DIR-src}/wp-content/plugins/gutenberg
- %PLUGIN_MOUNT_DIR%:/var/www/${LOCAL_DIR-src}/wp-content/plugins/%PLUGIN_INSTALL_DIR%
phpunit:
volumes:
- %PLUGIN_MOUNT_DIR%:/var/www/${LOCAL_DIR-src}/wp-content/plugins/gutenberg
- %PLUGIN_MOUNT_DIR%:/var/www/${LOCAL_DIR-src}/wp-content/plugins/%PLUGIN_INSTALL_DIR%
7 changes: 5 additions & 2 deletions packages/scripts/scripts/env/connect.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,11 @@ try {

const pluginMountDir = normalize( cwd() );

const composeTemplate = readFileSync( fromConfigRoot( 'docker-compose.override.yml.template' ), 'utf8' )
.replace( /%PLUGIN_MOUNT_DIR%/gi, pluginMountDir );
const composeTemplateFile = env.npm_package_wp_env_docker_template ? normalize( cwd() + `/${ env.npm_package_wp_env_docker_template }` ) : fromConfigRoot( 'docker-compose.override.yml.template' );

const composeTemplate = readFileSync( composeTemplateFile, 'utf8' )
.replace( /%PLUGIN_MOUNT_DIR%/gi, pluginMountDir )
.replace( /%PLUGIN_INSTALL_DIR%/gi, env.npm_package_wp_env_plugin_dir );

const pluginCompose = yaml.safeLoad( composeTemplate );

Expand Down
2 changes: 1 addition & 1 deletion packages/scripts/scripts/env/install.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,5 @@ function buildWordPress() {

// Mount Gutenberg into the WordPress install.
execSync( 'npm run env connect', { stdio: 'inherit' } );
execSync( 'npm run env cli plugin activate gutenberg', { stdio: 'inherit' } );
execSync( `npm run env cli plugin activate ${ env.npm_package_wp_env_plugin_dir }`, { stdio: 'inherit' } );
}

0 comments on commit 5e1c8c2

Please sign in to comment.