Skip to content

Commit

Permalink
fix(dev-env): Handle --mailhog command line option
Browse files Browse the repository at this point in the history
  • Loading branch information
sjinks committed Apr 18, 2023
1 parent af7ef4d commit 12c45e2
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/bin/vip-dev-env-create.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import {
handleCLIException,
processBooleanOption,
validateDependencies,
handleDeprecatedOptions,
} from '../lib/dev-environment/dev-environment-cli';
import {
DEV_ENVIRONMENT_FULL_COMMAND,
Expand Down Expand Up @@ -96,6 +97,8 @@ cmd.argv( process.argv, async ( arg, opt ) => {

debug( 'Args: ', arg, 'Options: ', opt );

handleDeprecatedOptions( opt );

const trackingInfo = {
slug,
app: opt.app,
Expand Down
12 changes: 11 additions & 1 deletion src/bin/vip-dev-env-update.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,15 @@ import chalk from 'chalk';
import { trackEvent } from '../lib/tracker';
import command from '../lib/cli/command';
import { DEV_ENVIRONMENT_FULL_COMMAND, DEV_ENVIRONMENT_NOT_FOUND, DEV_ENVIRONMENT_PHP_VERSIONS } from '../lib/constants/dev-environment';
import { addDevEnvConfigurationOptions, getEnvTrackingInfo, getEnvironmentName, handleCLIException, promptForArguments, validateDependencies } from '../lib/dev-environment/dev-environment-cli';
import {
addDevEnvConfigurationOptions,
getEnvTrackingInfo,
getEnvironmentName,
handleCLIException,
handleDeprecatedOptions,
promptForArguments,
validateDependencies,
} from '../lib/dev-environment/dev-environment-cli';
import type { InstanceOptions } from '../lib/dev-environment/types';
import { doesEnvironmentExist, getEnvironmentPath, readEnvironmentData, updateEnvironment } from '../lib/dev-environment/dev-environment-core';
import { bootstrapLando } from '../lib/dev-environment/dev-environment-lando';
Expand All @@ -42,6 +50,8 @@ 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 );

Expand Down
12 changes: 12 additions & 0 deletions src/lib/dev-environment/dev-environment-cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -639,6 +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( [ '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', undefined, processBooleanOption );
}

Expand Down Expand Up @@ -711,3 +712,14 @@ export function getEnvTrackingInfo( slug: string ): any {
};
}
}

export function handleDeprecatedOptions( opts: any ): 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;
}
}

0 comments on commit 12c45e2

Please sign in to comment.