diff --git a/.github/workflows/devenv-e2e.yml b/.github/workflows/devenv-e2e.yml index d5cf36901c..636d672120 100644 --- a/.github/workflows/devenv-e2e.yml +++ b/.github/workflows/devenv-e2e.yml @@ -40,7 +40,7 @@ jobs: - name: Preload Docker images run: | - vip dev-env create --app-code image --php 8.0 --mu-plugins image -e false -p true --mailhog true && \ + vip dev-env create --app-code image --php 8.0 --mu-plugins image -e false -p true --mailpit true && \ vip dev-env start -w && \ vip dev-env destroy diff --git a/__tests__/devenv-e2e/001-create.spec.js b/__tests__/devenv-e2e/001-create.spec.js index f8000c10c6..dcc804f5e6 100644 --- a/__tests__/devenv-e2e/001-create.spec.js +++ b/__tests__/devenv-e2e/001-create.spec.js @@ -69,7 +69,7 @@ describe( 'vip dev-env create', () => { const expectedElasticsearch = false; const expectedPhpMyAdmin = false; const expectedXDebug = false; - const expectedMailHog = false; + const expectedMailpit = false; expect( await checkEnvExists( slug ) ).toBe( false ); @@ -91,7 +91,7 @@ describe( 'vip dev-env create', () => { wordpress: expect.objectContaining( { mode: 'image', tag: expect.any( String ) } ), phpmyadmin: expectedPhpMyAdmin, xdebug: expectedXDebug, - mailhog: expectedMailHog, + mailpit: expectedMailpit, } ); } ); @@ -104,7 +104,7 @@ describe( 'vip dev-env create', () => { const expectedElasticsearch = true; const expectedPhpMyAdmin = true; const expectedXDebug = true; - const expectedMailHog = true; + const expectedMailpit = true; expect( await checkEnvExists( slug ) ).toBe( false ); @@ -121,7 +121,7 @@ describe( 'vip dev-env create', () => { '-e', `${ expectedElasticsearch }`, '-p', `${ expectedPhpMyAdmin }`, '-x', `${ expectedXDebug }`, - '--mailhog', `${ expectedMailHog }`, + '-A', `${ expectedMailpit }`, ], { env }, true ); expect( result.rc ).toBe( 0 ); expect( await checkEnvExists( slug ) ).toBe( true ); @@ -140,7 +140,7 @@ describe( 'vip dev-env create', () => { wordpress: expect.objectContaining( { mode: 'image', tag: expectedWordPressVersion } ), phpmyadmin: expectedPhpMyAdmin, xdebug: expectedXDebug, - mailhog: expectedMailHog, + mailpit: expectedMailpit, } ); } ); } ); diff --git a/__tests__/devenv-e2e/005-update.spec.js b/__tests__/devenv-e2e/005-update.spec.js index c4162b52d9..b54392971d 100644 --- a/__tests__/devenv-e2e/005-update.spec.js +++ b/__tests__/devenv-e2e/005-update.spec.js @@ -68,7 +68,7 @@ describe( 'vip dev-env update', () => { const expectedElasticsearch = false; const expectedPhpMyAdmin = false; const expectedXDebug = false; - const expectedMailHog = false; + const expectedMailpit = false; expect( await checkEnvExists( slug ) ).toBe( false ); @@ -82,7 +82,7 @@ describe( 'vip dev-env update', () => { elasticsearch: expectedElasticsearch, phpmyadmin: expectedPhpMyAdmin, xdebug: expectedXDebug, - mailhog: expectedMailHog, + mailpit: expectedMailpit, } ); result = await cliTest.spawn( [ @@ -91,7 +91,7 @@ describe( 'vip dev-env update', () => { '-e', `${ ! expectedElasticsearch }`, '-p', `${ ! expectedPhpMyAdmin }`, '-x', `${ ! expectedXDebug }`, - '--mailhog', `${ ! expectedMailHog }`, + '-A', `${ ! expectedMailpit }`, ], { env }, true ); expect( result.rc ).toBe( 0 ); expect( await checkEnvExists( slug ) ).toBe( true ); @@ -102,7 +102,7 @@ describe( 'vip dev-env update', () => { elasticsearch: ! expectedElasticsearch, phpmyadmin: ! expectedPhpMyAdmin, xdebug: ! expectedXDebug, - mailhog: ! expectedMailHog, + mailpit: ! expectedMailpit, } ); } ); @@ -166,19 +166,19 @@ describe( 'vip dev-env update', () => { const result = await cliTest.spawn( [ process.argv[ 0 ], vipDevEnvUpdate, '--slug', slug, - '--mailhog', 'true', + '--mailpit', 'true', ], { env }, true ); expect( result.rc ).toBe( 0 ); const dataAfter = readEnvironmentData( slug ); expect( dataAfter ).toMatchObject( { mariadb: expect.any( String ), - mailhog: true, + mailpit: true, } ); const landofile = await readFile( dst[ 1 ], 'utf8' ); expect( landofile ).not.toContain( 'image: mysql:' ); expect( landofile ).toContain( 'image: mariadb:' ); - expect( landofile ).toContain( 'mailhog:' ); + expect( landofile ).toContain( 'mailpit:' ); } ); } ); diff --git a/__tests__/devenv-e2e/011-configuration-file.spec.js b/__tests__/devenv-e2e/011-configuration-file.spec.js index fe6082f8b8..d646ee6d24 100644 --- a/__tests__/devenv-e2e/011-configuration-file.spec.js +++ b/__tests__/devenv-e2e/011-configuration-file.spec.js @@ -109,7 +109,7 @@ describe( 'vip dev-env configuration file', () => { const expectedElasticsearch = true; const expectedPhpMyAdmin = true; const expectedXDebug = true; - const expectedMailHog = true; + const expectedMailpit = true; expect( await checkEnvExists( expectedSlug ) ).toBe( false ); @@ -123,7 +123,7 @@ describe( 'vip dev-env configuration file', () => { elasticsearch: expectedElasticsearch, phpmyadmin: expectedPhpMyAdmin, xdebug: expectedXDebug, - mailhog: expectedMailHog, + mailpit: expectedMailpit, 'mu-plugins': 'image', 'app-code': 'image', } ); @@ -152,7 +152,7 @@ describe( 'vip dev-env configuration file', () => { wordpress: expect.objectContaining( { mode: 'image', tag: expectedWordPressVersion } ), phpmyadmin: expectedPhpMyAdmin, xdebug: expectedXDebug, - mailhog: expectedMailHog, + mailpit: expectedMailpit, } ); return expect( checkEnvExists( expectedSlug ) ).resolves.toBe( true ); @@ -163,7 +163,7 @@ describe( 'vip dev-env configuration file', () => { const expectedElasticsearch = false; const expectedPhpMyAdmin = false; const expectedXDebug = false; - const expectedMailHog = false; + const expectedMailpit = false; expect( await checkEnvExists( slug ) ).toBe( false ); @@ -174,7 +174,7 @@ describe( 'vip dev-env configuration file', () => { elasticsearch: expectedElasticsearch, phpmyadmin: expectedPhpMyAdmin, xdebug: expectedXDebug, - mailhog: expectedMailHog, + mailpit: expectedMailpit, } ); const spawnOptions = { @@ -192,7 +192,7 @@ describe( 'vip dev-env configuration file', () => { elasticsearch: expectedElasticsearch, phpmyadmin: expectedPhpMyAdmin, xdebug: expectedXDebug, - mailhog: expectedMailHog, + mailpit: expectedMailpit, } ); // Update environment from changed configuration file @@ -202,7 +202,7 @@ describe( 'vip dev-env configuration file', () => { elasticsearch: ! expectedElasticsearch, phpmyadmin: ! expectedPhpMyAdmin, xdebug: ! expectedXDebug, - mailhog: ! expectedMailHog, + mailpit: ! expectedMailpit, } ); result = await cliTest.spawn( [ process.argv[ 0 ], vipDevEnvUpdate ], spawnOptions, true ); @@ -215,7 +215,7 @@ describe( 'vip dev-env configuration file', () => { elasticsearch: ! expectedElasticsearch, phpmyadmin: ! expectedPhpMyAdmin, xdebug: ! expectedXDebug, - mailhog: ! expectedMailHog, + mailpit: ! expectedMailpit, } ); } ); } ); diff --git a/__tests__/e2e_test.bat b/__tests__/e2e_test.bat index c56b38e4f2..64513e5dde 100644 --- a/__tests__/e2e_test.bat +++ b/__tests__/e2e_test.bat @@ -14,7 +14,7 @@ rem dev-env tests echo "== Creating dev-env" -call vip dev-env create --app-code image --title Test --multisite false --php 8.0 --wordpress 6.0 --mu-plugins image -e false -p false -x false --mailhog false +call vip dev-env create --app-code image --title Test --multisite false --php 8.0 --wordpress 6.0 --mu-plugins image -e false -p false -x false --mailpit false if NOT %errorlevel% == 0 ( echo "== Failed to create dev-env" diff --git a/assets/dev-env.lando.template.yml.ejs b/assets/dev-env.lando.template.yml.ejs index a72343fe51..e74a0b84bf 100644 --- a/assets/dev-env.lando.template.yml.ejs +++ b/assets/dev-env.lando.template.yml.ejs @@ -9,6 +9,8 @@ proxy: <% } %> phpmyadmin: - <%= siteSlug %>-pma.vipdev.lndo.site + mailpit: + - <%= siteSlug %>-mailpit.vipdev.lndo.site:8025 services: devtools: @@ -197,9 +199,19 @@ services: clientcode_vipconfig: {} <% } %> -<% if ( mailhog ) { %> - mailhog: - type: mailhog +<% if ( mailpit ) { %> + mailpit: + type: compose + services: + image: axllent/mailpit:latest + command: /mailpit + ports: + - ":1025" + - ":8025" + environment: + LANDO_NO_USER_PERMS: 1 + LANDO_NO_SCRIPTS: 1 + LANDO_NEEDS_EXEC: 1 <% } %> tooling: diff --git a/src/bin/vip-dev-env-shell.js b/src/bin/vip-dev-env-shell.js index 0432595293..fc4802442c 100755 --- a/src/bin/vip-dev-env-shell.js +++ b/src/bin/vip-dev-env-shell.js @@ -32,6 +32,7 @@ const userMap = { elasticsearch: 'elasticsearch', phpmyadmin: 'www-data', mailhog: 'mailhog', + mailpit: 'root', }; const examples = [ diff --git a/src/bin/vip-dev-env-update.js b/src/bin/vip-dev-env-update.js index 785cc8e614..9a3444b629 100755 --- a/src/bin/vip-dev-env-update.js +++ b/src/bin/vip-dev-env-update.js @@ -77,7 +77,7 @@ cmd.argv( process.argv, async ( arg, opt ) => { mariadb: currentInstanceData.mariadb, phpmyadmin: currentInstanceData.phpmyadmin, xdebug: currentInstanceData.xdebug, - mailhog: currentInstanceData.mailhog, + mailpit: currentInstanceData.mailpit ?? currentInstanceData.mailhog, mediaRedirectDomain: currentInstanceData.mediaRedirectDomain, multisite: false, title: '', diff --git a/src/lib/dev-environment/dev-environment-cli.js b/src/lib/dev-environment/dev-environment-cli.js index 1ea25417e0..e94638c019 100644 --- a/src/lib/dev-environment/dev-environment-cli.js +++ b/src/lib/dev-environment/dev-environment-cli.js @@ -317,13 +317,13 @@ export async function promptForArguments( preselectedOptions: InstanceOptions, d xdebug: false, xdebugConfig: preselectedOptions.xdebugConfig, siteSlug: '', - mailhog: false, + mailpit: false, }; const promptLabels = { xdebug: 'XDebug', phpmyadmin: 'phpMyAdmin', - mailhog: 'MailHog', + mailpit: 'Mailpit', }; if ( ! instanceData.mediaRedirectDomain && defaultOptions.mediaRedirectDomain ) { @@ -354,7 +354,7 @@ export async function promptForArguments( preselectedOptions: InstanceOptions, d instanceData.elasticsearch = await promptForBoolean( 'Enable Elasticsearch (needed by Enterprise Search)?', !! defaultOptions.elasticsearch ); } - for ( const service of [ 'phpmyadmin', 'xdebug', 'mailhog' ] ) { + for ( const service of [ 'phpmyadmin', 'xdebug', 'mailpit' ] ) { if ( service in instanceData ) { if ( service in preselectedOptions ) { instanceData[ service ] = preselectedOptions[ service ]; @@ -639,7 +639,7 @@ export function addDevEnvConfigurationOptions( command: Command ): any { .option( 'elasticsearch', 'Enable Elasticsearch (needed by Enterprise Search)', undefined, processBooleanOption ) .option( [ 'r', 'media-redirect-domain' ], '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( [ 'A', 'mailhog' ], 'Enable MailHog. By default it is disabled', undefined, processBooleanOption ); + .option( [ 'A', 'mailpit' ], 'Enable Mailpit. By default it is disabled', undefined, processBooleanOption ); } /** diff --git a/src/lib/dev-environment/dev-environment-configuration-file.js b/src/lib/dev-environment/dev-environment-configuration-file.js index 14675ca100..dcc4c0b136 100644 --- a/src/lib/dev-environment/dev-environment-configuration-file.js +++ b/src/lib/dev-environment/dev-environment-configuration-file.js @@ -105,7 +105,7 @@ async function sanitizeConfiguration( configuration: Object ): Promise> { diff --git a/src/lib/dev-environment/types.js b/src/lib/dev-environment/types.js index 4379a6c59b..dd7ca4210b 100644 --- a/src/lib/dev-environment/types.js +++ b/src/lib/dev-environment/types.js @@ -6,13 +6,14 @@ export interface InstanceOptions { muPlugins?: string; appCode?: string; elasticsearch?: boolean; - mariadb?: string; + mariadb?: string; // Legacy php?: string; mediaRedirectDomain?: string; phpmyadmin?: boolean; xdebug?: boolean; xdebugConfig?: string; - mailhog?: boolean; + mailhog?: boolean; // Legacy + mailpit?: boolean; [index: string]: string | boolean; } @@ -65,7 +66,8 @@ export type ConfigurationFileOptions = { elasticsearch?: boolean; phpmyadmin?: boolean; xdebug?: boolean; - mailhog?: boolean; + mailhog?: boolean; // Legacy + mailpit?: boolean; } export interface InstanceData { @@ -79,10 +81,11 @@ export interface InstanceData { phpmyadmin: boolean; xdebug: boolean; xdebugConfig?: string; - mariadb?: string; + mariadb?: string; // Legacy php: string; elasticsearch?: string | boolean; - mailhog: boolean; + mailhog?: boolean; // Legacy + mailpit: boolean; pullAfter?: number; [index: string]: WordPressConfig | ComponentConfig | string | boolean;