Skip to content

Commit

Permalink
Do not display the local option for muPlugins selector if the user is…
Browse files Browse the repository at this point in the history
… not VIP
  • Loading branch information
rinatkhaziev committed Jan 27, 2025
1 parent e171bde commit bc66707
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions src/lib/dev-environment/dev-environment-cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import {
readEnvironmentData,
} from './dev-environment-core';
import { validateDockerInstalled } from './dev-environment-lando';
import { getCurrentUserInfo } from '../api/user';
import { Args } from '../cli/command';
import {
DEV_ENVIRONMENT_FULL_COMMAND,
Expand Down Expand Up @@ -62,7 +63,7 @@ const componentDisplayNames: Record<
string
> = {
wordpress: 'WordPress',
muPlugins: 'vip-go-mu-plugins',
muPlugins: 'VIP MU Plugins',
appCode: 'application code',
} as const;

Expand Down Expand Up @@ -410,7 +411,18 @@ async function processComponent(
);
let result: ComponentConfig;

const allowLocal = true;
let allowLocal: boolean = true;

if ( component === 'muPlugins' ) {
let currentUser = null;
try {
currentUser = await getCurrentUserInfo();
allowLocal = currentUser?.isVIP || false;
} catch ( err ) {
allowLocal = false;
}
}

const defaultObject = defaultValue
? processComponentOptionInput( defaultValue, allowLocal )

Check failure on line 427 in src/lib/dev-environment/dev-environment-cli.ts

View workflow job for this annotation

GitHub Actions / Type Checker

No overload matches this call.
: null;
Expand Down Expand Up @@ -746,7 +758,7 @@ export async function promptForComponent(
const messagePrefix = selectMode ? '\t' : `${ componentDisplayName } - `;
if ( 'local' === modeResult ) {
const directoryPath = await promptForText(
`${ messagePrefix }What is a path to your local ${ componentDisplayName }`,
`${ messagePrefix }What is a path to your local ${ componentDisplayName }?`,
defaultObject?.dir ?? ''
);
return {
Expand Down

0 comments on commit bc66707

Please sign in to comment.