From 671fa30f0a43b3f02a2d7eb84811c57ea98e130c Mon Sep 17 00:00:00 2001 From: Volodymyr Kolesnykov Date: Thu, 2 May 2024 21:38:51 +0300 Subject: [PATCH 1/2] refactor!(dev-env): remove support for MailHog; use Mailpit instead --- .../dev-env-e2e/instance_data_mariadb.json | 2 +- src/bin/vip-dev-env-create.js | 3 --- src/bin/vip-dev-env-shell.js | 1 - src/bin/vip-dev-env-update.js | 5 +---- .../dev-environment/dev-environment-cli.ts | 21 ------------------- .../dev-environment-configuration-file.ts | 4 ++-- .../dev-environment/dev-environment-core.ts | 7 +------ src/lib/dev-environment/types.ts | 3 --- 8 files changed, 5 insertions(+), 41 deletions(-) diff --git a/__fixtures__/dev-env-e2e/instance_data_mariadb.json b/__fixtures__/dev-env-e2e/instance_data_mariadb.json index 82701fdba..b40d6a142 100644 --- a/__fixtures__/dev-env-e2e/instance_data_mariadb.json +++ b/__fixtures__/dev-env-e2e/instance_data_mariadb.json @@ -1 +1 @@ -{"wpTitle":"VIP Dev","multisite":false,"elasticsearch":false,"php":"ghcr.io/automattic/vip-container-images/php-fpm:8.0","mariadb":"10.3","mediaRedirectDomain":"","wordpress":{"mode":"image","tag":"6.1"},"muPlugins":{"mode":"image"},"appCode":{"mode":"image"},"phpmyadmin":false,"xdebug":false,"xdebugConfig":"","siteSlug":"vip-local","mailhog":false} \ No newline at end of file +{"wpTitle":"VIP Dev","multisite":false,"elasticsearch":false,"php":"ghcr.io/automattic/vip-container-images/php-fpm:8.0","mariadb":"10.3","mediaRedirectDomain":"","wordpress":{"mode":"image","tag":"6.1"},"muPlugins":{"mode":"image"},"appCode":{"mode":"image"},"phpmyadmin":false,"xdebug":false,"xdebugConfig":"","siteSlug":"vip-local"} \ No newline at end of file diff --git a/src/bin/vip-dev-env-create.js b/src/bin/vip-dev-env-create.js index e6fbe0dbc..3587dd658 100755 --- a/src/bin/vip-dev-env-create.js +++ b/src/bin/vip-dev-env-create.js @@ -19,7 +19,6 @@ import { handleCLIException, validateDependencies, processStringOrBooleanOption, - handleDeprecatedOptions, processSlug, } from '../lib/dev-environment/dev-environment-cli'; import { @@ -99,8 +98,6 @@ cmd.argv( process.argv, async ( arg, opt ) => { debug( 'Args: ', arg, 'Options: ', opt ); - handleDeprecatedOptions( opt ); - const trackingInfo = { slug, app: opt.app, diff --git a/src/bin/vip-dev-env-shell.js b/src/bin/vip-dev-env-shell.js index b7821ec04..10e736fdb 100755 --- a/src/bin/vip-dev-env-shell.js +++ b/src/bin/vip-dev-env-shell.js @@ -24,7 +24,6 @@ const userMap = { memcached: 'memcache', elasticsearch: 'elasticsearch', phpmyadmin: 'www-data', - mailhog: 'mailhog', mailpit: 'root', photon: 'root', }; diff --git a/src/bin/vip-dev-env-update.js b/src/bin/vip-dev-env-update.js index 65fedaa70..5bcf2098c 100755 --- a/src/bin/vip-dev-env-update.js +++ b/src/bin/vip-dev-env-update.js @@ -14,7 +14,6 @@ import { getEnvTrackingInfo, getEnvironmentName, handleCLIException, - handleDeprecatedOptions, processSlug, promptForArguments, validateDependencies, @@ -53,8 +52,6 @@ cmd.examples( examples ); cmd.argv( process.argv, async ( arg, opt ) => { const slug = await getEnvironmentName( opt ); - handleDeprecatedOptions( opt ); - const lando = await bootstrapLando(); await validateDependencies( lando, slug ); @@ -97,7 +94,7 @@ cmd.argv( process.argv, async ( arg, opt ) => { mariadb: currentInstanceData.mariadb, phpmyadmin: currentInstanceData.phpmyadmin, xdebug: currentInstanceData.xdebug, - mailpit: currentInstanceData.mailpit ?? currentInstanceData.mailhog, + mailpit: currentInstanceData.mailpit, photon: currentInstanceData.photon, mediaRedirectDomain: currentInstanceData.mediaRedirectDomain, multisite: false, diff --git a/src/lib/dev-environment/dev-environment-cli.ts b/src/lib/dev-environment/dev-environment-cli.ts index 0df1091e2..ea8393f7c 100644 --- a/src/lib/dev-environment/dev-environment-cli.ts +++ b/src/lib/dev-environment/dev-environment-cli.ts @@ -857,12 +857,6 @@ export function addDevEnvConfigurationOptions( command: Args ): Args { 'Domain to redirect for missing media files. This can be used to still have images without the need to import them locally.' ) .option( 'php', 'Explicitly choose PHP version to use', undefined, processVersionOption ) - .option( - [ 'G', 'mailhog' ], - 'Enable Mailpit. By default it is disabled (deprecated option, please use --mailpit instead)', - undefined, - processBooleanOption - ) .option( [ 'A', 'mailpit' ], 'Enable Mailpit. By default it is disabled', @@ -995,18 +989,3 @@ const getVSCodeExecutable = () => { } return null; }; - -export function handleDeprecatedOptions( opts: Record< string, unknown > ): void { - if ( opts.mailhog ) { - console.warn( - chalk.yellow( - 'Warning: --mailhog is deprecated and will be removed in a future release. Please use --mailpit instead.' - ) - ); - if ( opts.mailpit === undefined ) { - opts.mailpit = opts.mailhog; - } - - delete opts.mailhog; - } -} diff --git a/src/lib/dev-environment/dev-environment-configuration-file.ts b/src/lib/dev-environment/dev-environment-configuration-file.ts index 1eac0dea5..bcbefacce 100644 --- a/src/lib/dev-environment/dev-environment-configuration-file.ts +++ b/src/lib/dev-environment/dev-environment-configuration-file.ts @@ -112,7 +112,7 @@ function sanitizeConfiguration( elasticsearch: stringToBooleanIfDefined( configuration.elasticsearch ), phpmyadmin: stringToBooleanIfDefined( configuration.phpmyadmin ), xdebug: stringToBooleanIfDefined( configuration.xdebug ), - mailpit: stringToBooleanIfDefined( configuration.mailpit ?? configuration.mailhog ), + mailpit: stringToBooleanIfDefined( configuration.mailpit ), 'media-redirect-domain': configuration[ 'media-redirect-domain' ]?.toString(), photon: stringToBooleanIfDefined( configuration.photon ), meta: configurationMeta, @@ -166,7 +166,7 @@ export function mergeConfigurationFileOptions( phpmyadmin: configurationFileOptions.phpmyadmin, xdebug: configurationFileOptions.xdebug, xdebugConfig: configurationFileOptions[ 'xdebug-config' ], - mailpit: configurationFileOptions.mailpit ?? configurationFileOptions.mailhog, + mailpit: configurationFileOptions.mailpit, mediaRedirectDomain: configurationFileOptions[ 'media-redirect-domain' ], photon: configurationFileOptions.photon, }; diff --git a/src/lib/dev-environment/dev-environment-core.ts b/src/lib/dev-environment/dev-environment-core.ts index 41470f72f..3231031b0 100644 --- a/src/lib/dev-environment/dev-environment-core.ts +++ b/src/lib/dev-environment/dev-environment-core.ts @@ -225,7 +225,7 @@ function preProcessInstanceData( instanceData: InstanceData ): InstanceData { // Mailpit migration if ( ! newInstanceData.mailpit ) { - newInstanceData.mailpit = newInstanceData.mailhog ?? false; + newInstanceData.mailpit = false; } // MariaDB migration @@ -447,11 +447,6 @@ export function readEnvironmentData( slug: string ): InstanceData { instanceData.appCode = instanceData.clientCode as ComponentConfig; } - if ( instanceData.mailhog ) { - instanceData.mailpit = instanceData.mailhog; - delete instanceData.mailhog; - } - return instanceData; } diff --git a/src/lib/dev-environment/types.ts b/src/lib/dev-environment/types.ts index 6bc3b0df2..839093c75 100644 --- a/src/lib/dev-environment/types.ts +++ b/src/lib/dev-environment/types.ts @@ -13,7 +13,6 @@ export interface InstanceOptions { phpmyadmin?: boolean; xdebug?: boolean; xdebugConfig?: string; - mailhog?: boolean; // Legacy mailpit?: boolean; photon?: boolean; @@ -69,7 +68,6 @@ export interface ConfigurationFileOptions { phpmyadmin?: boolean; xdebug?: boolean; 'xdebug-config'?: string; - mailhog?: boolean; // Legacy mailpit?: boolean; 'media-redirect-domain'?: string; photon?: boolean; @@ -97,7 +95,6 @@ export interface InstanceData { mariadb?: string; // Legacy php: string; elasticsearch?: string | boolean; - mailhog?: boolean; // Legacy mailpit: boolean; photon: boolean; pullAfter?: number; From 38f89fdd94a782768f3682805cf6015f6b85c949 Mon Sep 17 00:00:00 2001 From: Volodymyr Kolesnykov Date: Thu, 2 May 2024 21:50:41 +0300 Subject: [PATCH 2/2] fix: address code review comments --- src/lib/dev-environment/dev-environment-core.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/lib/dev-environment/dev-environment-core.ts b/src/lib/dev-environment/dev-environment-core.ts index 3231031b0..5c590baef 100644 --- a/src/lib/dev-environment/dev-environment-core.ts +++ b/src/lib/dev-environment/dev-environment-core.ts @@ -224,9 +224,7 @@ function preProcessInstanceData( instanceData: InstanceData ): InstanceData { } // Mailpit migration - if ( ! newInstanceData.mailpit ) { - newInstanceData.mailpit = false; - } + newInstanceData.mailpit ??= false; // MariaDB migration if ( ! newInstanceData.mariadb ) {