Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add/ssl #33442

Closed
wants to merge 5 commits into from
Closed

Add/ssl #33442

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions packages/env/lib/build-docker-compose-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,16 @@ module.exports = function buildDockerComposeConfig( config ) {
}

// Set the default ports based on the config values.
const developmentPorts = `\${WP_ENV_PORT:-${ config.env.development.port }}:80`;
const testsPorts = `\${WP_ENV_TESTS_PORT:-${ config.env.tests.port }}:80`;
const developmentPorts = [ `\${WP_ENV_PORT:-${ config.env.development.port }}:80` ];
const testsPorts = [ `\${WP_ENV_TESTS_PORT:-${ config.env.tests.port }}:80` ];

// Set the default SSL ports based on the config values.
if ( config.env.development.ssl ) {
developmentPorts.push( `${ config.env.development.ssl }:443` );
}
if ( config.env.tests.ssl ) {
testsPorts.push( `${ config.env.tests.ssl }:443` );
}

// Set the WordPress, WP-CLI, PHPUnit PHP version if defined.
const developmentPhpVersion = config.env.development.phpVersion
Expand Down
7 changes: 7 additions & 0 deletions packages/env/lib/config/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ module.exports = async function readConfig( configPath ) {
plugins: [],
themes: [],
port: 8888,
ssl: null,
mappings: {},
config: {
WP_DEBUG: true,
Expand All @@ -91,6 +92,7 @@ module.exports = async function readConfig( configPath ) {
tests: {
config: { WP_DEBUG: false, SCRIPT_DEBUG: false },
port: 8889,
ssl: null,
},
},
};
Expand Down Expand Up @@ -272,6 +274,11 @@ function withOverrides( config ) {
// Don't overwrite the port of WP_HOME when set.
if ( ! ( configKey === 'WP_HOME' && !! baseUrl.port ) ) {
baseUrl.port = config.env[ envKey ].port;

if ( config.env[ envKey ].ssl ) {
baseUrl.protocol = 'https';
baseUrl.port = config.env[ envKey ].ssl;
}
}

config.env[ envKey ].config[ configKey ] = baseUrl.toString();
Expand Down
1 change: 1 addition & 0 deletions packages/env/lib/config/parse-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ const HOME_PATH_PREFIX = `~${ path.sep }`;
module.exports = function parseConfig( config, options ) {
return {
port: config.port,
ssl: config.ssl,
phpVersion: config.phpVersion,
coreSource: includeTestsPath(
parseSourceString( config.core, options ),
Expand Down
6 changes: 6 additions & 0 deletions packages/env/lib/config/validate-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,12 @@ function validateConfig( config, envLocation ) {
);
}

if ( config?.ssl && ! Number.isInteger( config.ssl ) ) {
throw new ValidationError(
`Invalid .wp-env.json: "${ envPrefix }ssl" must be an integer.`
);
}

if ( typeof config.config !== 'object' ) {
throw new ValidationError(
`Invalid .wp-env.json: "${ envPrefix }config" must be an object.`
Expand Down