diff --git a/src/base-command.ts b/src/base-command.ts index 47bd1f6..570b3b0 100644 --- a/src/base-command.ts +++ b/src/base-command.ts @@ -68,15 +68,16 @@ export abstract class BaseCommand extends Command { ux.registerSearchPlugin(); this.registerConfig(); - this.validateRegionAndAuth(); - + this.developerHubBaseUrl = - this.sharedConfig.developerHubBaseUrl || (await getDeveloperHubUrl()); + this.sharedConfig.developerHubBaseUrl || (await getDeveloperHubUrl()); await this.initCmaSDK(); - + // Init logger const logger = new Logger(this.sharedConfig); this.log = logger.log.bind(logger); + + this.validateRegionAndAuth(); } protected async catch(err: Error & { exitCode?: number }): Promise { @@ -161,12 +162,11 @@ export abstract class BaseCommand extends Command { * The `validateRegionAndAuth` function verify whether region is set and user is logged in or not */ validateRegionAndAuth() { - //Step1: check region if (this.region) { - //Step2: user logged in or not if (!isAuthenticated()) { - throw new Error(this.messages.CLI_APP_CLI_LOGIN_FAILED); - } + this.log(this.messages.CLI_APP_CLI_LOGIN_FAILED, "error"); + this.exit(1); + } } } } diff --git a/src/commands/app/install.ts b/src/commands/app/install.ts index 908f46d..d70965c 100644 --- a/src/commands/app/install.ts +++ b/src/commands/app/install.ts @@ -132,8 +132,8 @@ export default class Install extends AppCLIBaseCommand { displayStackUrl(): void { const stackPath = `${this.uiHost}/#!/stack/${this.flags["stack-api-key"]}/dashboard`; this.log( - `Start using the stack using the following url: ${stackPath}`, + `Please use the following URL to start using the stack: ${stackPath}`, "info" ); } -} +} \ No newline at end of file diff --git a/src/util/inquirer.ts b/src/util/inquirer.ts index df3eeab..14667e7 100644 --- a/src/util/inquirer.ts +++ b/src/util/inquirer.ts @@ -1,4 +1,5 @@ import find from "lodash/find"; +import isEmpty from "lodash/isEmpty"; import { existsSync } from "fs"; import { basename, dirname, join } from "path"; import { @@ -228,13 +229,19 @@ async function getInstallation( if (uninstallAll) { return installations.map(installation => installation.uid).join(',') } - let _selectedInstallation = await cliux + let _selectedInstallation: string[] = await cliux .inquire({ type: 'checkbox', name: 'appInstallation', choices: installations, - message: messages.CHOOSE_AN_INSTALLATION - }) as string[] + message: messages.CHOOSE_AN_INSTALLATION, + validate: (input) => { + if (isEmpty(input)) { + return $t(errors.NOT_EMPTY, { value: "stack value"}); + } + return true; + } + }) selectedInstallation = _selectedInstallation.join(',') } else { // as this is an organization app, and it is supposed to only be installed on the source organization