From 0e7636959a09a106edd2c98de7299873615f182c Mon Sep 17 00:00:00 2001 From: James Sweetman Date: Wed, 20 Sep 2017 10:57:11 -0700 Subject: [PATCH] List config vars, aliases, display default org details @W-4285402, W-4285397, W-4285377@ --- .../salesforcedx-vscode-core/package.json | 16 +++++++ .../salesforcedx-vscode-core/package.nls.json | 9 +++- .../src/commands/commands.ts | 19 ++++++++ .../src/commands/forceAliasList.ts | 40 ++++++++++++++++ .../src/commands/forceConfigList.ts | 40 ++++++++++++++++ .../src/commands/forceOrgDisplay.ts | 48 +++++++++++++++++++ .../src/commands/forceSourceStatus.ts | 7 +-- .../src/commands/index.ts | 3 ++ .../salesforcedx-vscode-core/src/index.ts | 18 +++++++ .../src/messages/i18n.ts | 13 +++-- .../test/commands/forceAliasList.test.ts | 22 +++++++++ .../test/commands/forceConfigList.test.ts | 22 +++++++++ .../test/commands/forceOrgDisplay.test.ts | 22 +++++++++ 13 files changed, 269 insertions(+), 10 deletions(-) create mode 100644 packages/salesforcedx-vscode-core/src/commands/forceAliasList.ts create mode 100644 packages/salesforcedx-vscode-core/src/commands/forceConfigList.ts create mode 100644 packages/salesforcedx-vscode-core/src/commands/forceOrgDisplay.ts create mode 100644 packages/salesforcedx-vscode-core/test/commands/forceAliasList.test.ts create mode 100644 packages/salesforcedx-vscode-core/test/commands/forceConfigList.test.ts create mode 100644 packages/salesforcedx-vscode-core/test/commands/forceOrgDisplay.test.ts diff --git a/packages/salesforcedx-vscode-core/package.json b/packages/salesforcedx-vscode-core/package.json index dbd4b92..d265c44 100644 --- a/packages/salesforcedx-vscode-core/package.json +++ b/packages/salesforcedx-vscode-core/package.json @@ -181,6 +181,10 @@ { "command": "sfdx.force.debugger.stop", "when": "sfdx:project_opened" + }, + { + "command": "sfdx.force.config.list", + "when": "sfdx:project_opened" } ] }, @@ -256,6 +260,18 @@ { "command": "sfdx.force.debugger.stop", "title": "%force_debugger_stop_text%" + }, + { + "command": "sfdx.force.config.list", + "title": "%force_config_list_text%" + }, + { + "command": "sfdx.force.alias.list", + "title": "%force_alias_list_text%" + }, + { + "command": "sfdx.force.org.display.default", + "title": "%force_org_display_default_text%" } ] } diff --git a/packages/salesforcedx-vscode-core/package.nls.json b/packages/salesforcedx-vscode-core/package.nls.json index 2a66f5e..08c5621 100644 --- a/packages/salesforcedx-vscode-core/package.nls.json +++ b/packages/salesforcedx-vscode-core/package.nls.json @@ -22,6 +22,11 @@ "force_lightning_event_create_text": "SFDX: Create Lightning Event", "force_lightning_interface_create_text": "SFDX: Create Lightning Interface", "force_source_status_local_text": "SFDX: View Local Changes", - "force_source_status_remote_text": "SFDX: View Changes in Default Scratch Org", - "force_debugger_stop_text": "SFDX: Stop Apex Debugger Session" + "force_source_status_remote_text": + "SFDX: View Changes in Default Scratch Org", + "force_debugger_stop_text": "SFDX: Stop Apex Debugger Session", + "force_config_list_text": "SFDX: List All Config Variables", + "force_alias_list_text": "SFDX: List All Aliases", + "force_org_display_default_text": + "SFDX: Display Org Details for Default Scratch Org" } diff --git a/packages/salesforcedx-vscode-core/src/commands/commands.ts b/packages/salesforcedx-vscode-core/src/commands/commands.ts index bc96d83..0969b6c 100644 --- a/packages/salesforcedx-vscode-core/src/commands/commands.ts +++ b/packages/salesforcedx-vscode-core/src/commands/commands.ts @@ -287,6 +287,25 @@ export class SelectStrictDirPath extends SelectDirPath { } } +export interface FlagParameter { + flag: T; +} + +export class SelectUsername + implements ParametersGatherer<{ username: string }> { + public async gather(): Promise< + CancelResponse | ContinueResponse<{ username: string }> + > { + const usernameInputOptions = { + prompt: nls.localize('parameter_gatherer_enter_username_name') + }; + const username = await vscode.window.showInputBox(usernameInputOptions); + return username + ? { type: 'CONTINUE', data: { username } } + : { type: 'CANCEL' }; + } +} + // Command Execution //////////////////// export interface CommandletExecutor { diff --git a/packages/salesforcedx-vscode-core/src/commands/forceAliasList.ts b/packages/salesforcedx-vscode-core/src/commands/forceAliasList.ts new file mode 100644 index 0000000..e6e07e1 --- /dev/null +++ b/packages/salesforcedx-vscode-core/src/commands/forceAliasList.ts @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2017, salesforce.com, inc. + * All rights reserved. + * Licensed under the BSD 3-Clause license. + * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause + */ + +import { + Command, + SfdxCommandBuilder +} from '@salesforce/salesforcedx-utils-vscode/out/src/cli'; +import { nls } from '../messages'; +import { + EmptyParametersGatherer, + SfdxCommandlet, + SfdxCommandletExecutor, + SfdxWorkspaceChecker +} from './commands'; + +export class ForceAliasList extends SfdxCommandletExecutor<{}> { + public build(data: {}): Command { + return new SfdxCommandBuilder() + .withDescription(nls.localize('force_alias_list_text')) + .withArg('force:alias:list') + .build(); + } +} + +const workspaceChecker = new SfdxWorkspaceChecker(); +const parameterGatherer = new EmptyParametersGatherer(); +const executor = new ForceAliasList(); +const commandlet = new SfdxCommandlet( + workspaceChecker, + parameterGatherer, + executor +); + +export function forceAliasList() { + commandlet.run(); +} diff --git a/packages/salesforcedx-vscode-core/src/commands/forceConfigList.ts b/packages/salesforcedx-vscode-core/src/commands/forceConfigList.ts new file mode 100644 index 0000000..968763e --- /dev/null +++ b/packages/salesforcedx-vscode-core/src/commands/forceConfigList.ts @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2017, salesforce.com, inc. + * All rights reserved. + * Licensed under the BSD 3-Clause license. + * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause + */ + +import { + Command, + SfdxCommandBuilder +} from '@salesforce/salesforcedx-utils-vscode/out/src/cli'; +import { nls } from '../messages'; +import { + EmptyParametersGatherer, + SfdxCommandlet, + SfdxCommandletExecutor, + SfdxWorkspaceChecker +} from './commands'; + +export class ForceConfigList extends SfdxCommandletExecutor<{}> { + public build(data: {}): Command { + return new SfdxCommandBuilder() + .withDescription(nls.localize('force_config_list_text')) + .withArg('force:config:list') + .build(); + } +} + +const workspaceChecker = new SfdxWorkspaceChecker(); +const parameterGatherer = new EmptyParametersGatherer(); +const executor = new ForceConfigList(); +const commandlet = new SfdxCommandlet( + workspaceChecker, + parameterGatherer, + executor +); + +export function forceConfigList() { + commandlet.run(); +} diff --git a/packages/salesforcedx-vscode-core/src/commands/forceOrgDisplay.ts b/packages/salesforcedx-vscode-core/src/commands/forceOrgDisplay.ts new file mode 100644 index 0000000..db029bc --- /dev/null +++ b/packages/salesforcedx-vscode-core/src/commands/forceOrgDisplay.ts @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2017, salesforce.com, inc. + * All rights reserved. + * Licensed under the BSD 3-Clause license. + * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause + */ + +import { + Command, + SfdxCommandBuilder +} from '@salesforce/salesforcedx-utils-vscode/out/src/cli'; +import { nls } from '../messages'; +import { + EmptyParametersGatherer, + FlagParameter, + SfdxCommandlet, + SfdxCommandletExecutor, + SfdxWorkspaceChecker +} from './commands'; + +export class ForceOrgDisplay extends SfdxCommandletExecutor<{}> { + private flag: string | undefined; + + public constructor(flag?: string) { + super(); + this.flag = flag; + } + + public build(data: { username?: string }): Command { + return new SfdxCommandBuilder() + .withDescription(nls.localize('force_org_display_default_text')) + .withArg('force:org:display') + .build(); + } +} + +const workspaceChecker = new SfdxWorkspaceChecker(); +const parameterGatherer = new EmptyParametersGatherer(); +const executor = new ForceOrgDisplay(); +const commandlet = new SfdxCommandlet( + workspaceChecker, + parameterGatherer, + executor +); + +export function forceOrgDisplay(this: FlagParameter) { + commandlet.run(); +} diff --git a/packages/salesforcedx-vscode-core/src/commands/forceSourceStatus.ts b/packages/salesforcedx-vscode-core/src/commands/forceSourceStatus.ts index 4ce5757..b195565 100644 --- a/packages/salesforcedx-vscode-core/src/commands/forceSourceStatus.ts +++ b/packages/salesforcedx-vscode-core/src/commands/forceSourceStatus.ts @@ -12,6 +12,7 @@ import { import { nls } from '../messages'; import { EmptyParametersGatherer, + FlagParameter, SfdxCommandlet, SfdxCommandletExecutor, SfdxWorkspaceChecker @@ -48,11 +49,7 @@ export class ForceSourceStatusExecutor extends SfdxCommandletExecutor<{}> { const workspaceChecker = new SfdxWorkspaceChecker(); const parameterGatherer = new EmptyParametersGatherer(); -export interface FlagParameter { - flag: SourceStatusFlags; -} - -export function forceSourceStatus(this: FlagParameter) { +export function forceSourceStatus(this: FlagParameter) { // tslint:disable-next-line:no-invalid-this const flag = this ? this.flag : undefined; const executor = new ForceSourceStatusExecutor(flag); diff --git a/packages/salesforcedx-vscode-core/src/commands/index.ts b/packages/salesforcedx-vscode-core/src/commands/index.ts index d8e94f6..dc59901 100644 --- a/packages/salesforcedx-vscode-core/src/commands/index.ts +++ b/packages/salesforcedx-vscode-core/src/commands/index.ts @@ -23,3 +23,6 @@ export { forceLightningComponentCreate } from './forceLightningComponentCreate'; export { forceLightningEventCreate } from './forceLightningEventCreate'; export { forceLightningInterfaceCreate } from './forceLightningInterfaceCreate'; export { forceDebuggerStop } from './forceDebuggerStop'; +export { forceConfigList } from './forceConfigList'; +export { forceAliasList } from './forceAliasList'; +export { forceOrgDisplay } from './forceOrgDisplay'; diff --git a/packages/salesforcedx-vscode-core/src/index.ts b/packages/salesforcedx-vscode-core/src/index.ts index 184fd18..4f313e4 100644 --- a/packages/salesforcedx-vscode-core/src/index.ts +++ b/packages/salesforcedx-vscode-core/src/index.ts @@ -8,15 +8,18 @@ import * as vscode from 'vscode'; import { + forceAliasList, forceApexClassCreate, forceApexTestRun, forceAuthWebLogin, + forceConfigList, forceDebuggerStop, forceLightningAppCreate, forceLightningComponentCreate, forceLightningEventCreate, forceLightningInterfaceCreate, forceOrgCreate, + forceOrgDisplay, forceOrgOpen, forceSourcePull, forceSourcePush, @@ -105,6 +108,18 @@ function registerCommands(): vscode.Disposable { 'sfdx.force.debugger.stop', forceDebuggerStop ); + const forceConfigListCmd = vscode.commands.registerCommand( + 'sfdx.force.config.list', + forceConfigList + ); + const forceAliasListCmd = vscode.commands.registerCommand( + 'sfdx.force.alias.list', + forceAliasList + ); + const forceOrgDisplayDefaultCmd = vscode.commands.registerCommand( + 'sfdx.force.org.display.default', + forceOrgDisplay + ); // Internal commands const internalCancelCommandExecution = vscode.commands.registerCommand( @@ -131,6 +146,9 @@ function registerCommands(): vscode.Disposable { forceSourceStatusLocalCmd, forceSourceStatusRemoteCmd, forceDebuggerStopCmd, + forceConfigListCmd, + forceAliasListCmd, + forceOrgDisplayDefaultCmd, internalCancelCommandExecution ); } diff --git a/packages/salesforcedx-vscode-core/src/messages/i18n.ts b/packages/salesforcedx-vscode-core/src/messages/i18n.ts index a905e50..995fea1 100644 --- a/packages/salesforcedx-vscode-core/src/messages/i18n.ts +++ b/packages/salesforcedx-vscode-core/src/messages/i18n.ts @@ -41,9 +41,12 @@ export const messages = { force_auth_web_login_authorize_dev_hub_text: 'SFDX: Authorize a Dev Hub', - parameter_gatherer_enter_file_name: 'Enter desired filename', + parameter_gatherer_enter_file_name: + 'Enter desired filename (Press Enter to confirm or Esc to cancel)', parameter_gatherer_enter_dir_name: - "Enter desired directory (Press 'Enter' to confirm or 'Escape' to cancel)", + 'Enter desired directory (Press Enter to confirm or Esc to cancel)', + parameter_gatherer_enter_username_name: + 'Enter target username (Press Enter to confirm or Esc to cancel)', force_org_create_default_scratch_org_text: 'SFDX: Create a Default Scratch Org...', @@ -78,5 +81,9 @@ export const messages = { warning_prompt_lightning_bundle_overwrite: 'A Lightning bundle with the specified path already exists in your workspace. Do you want to overwrite any existing files in this bundle?', warning_prompt_yes: 'Yes', - warning_prompt_no: 'No' + warning_prompt_no: 'No', + force_config_list_text: 'SFDX: List All Config Variables', + force_alias_list_text: 'SFDX: List All Aliases', + force_org_display_default_text: + 'SFDX: Display Org Details for Default Scratch Org' }; diff --git a/packages/salesforcedx-vscode-core/test/commands/forceAliasList.test.ts b/packages/salesforcedx-vscode-core/test/commands/forceAliasList.test.ts new file mode 100644 index 0000000..843e8de --- /dev/null +++ b/packages/salesforcedx-vscode-core/test/commands/forceAliasList.test.ts @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2017, salesforce.com, inc. + * All rights reserved. + * Licensed under the BSD 3-Clause license. + * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause + */ + +import { expect } from 'chai'; +import { ForceAliasList } from '../../src/commands/forceAliasList'; +import { nls } from '../../src/messages'; + +// tslint:disable:no-unused-expression +describe('Force Alias List', () => { + it('Should build the alias list command', async () => { + const aliasList = new ForceAliasList(); + const aliasListCommand = aliasList.build({}); + expect(aliasListCommand.toCommand()).to.equal('sfdx force:alias:list'); + expect(aliasListCommand.description).to.equal( + nls.localize('force_alias_list_text') + ); + }); +}); diff --git a/packages/salesforcedx-vscode-core/test/commands/forceConfigList.test.ts b/packages/salesforcedx-vscode-core/test/commands/forceConfigList.test.ts new file mode 100644 index 0000000..9c0e354 --- /dev/null +++ b/packages/salesforcedx-vscode-core/test/commands/forceConfigList.test.ts @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2017, salesforce.com, inc. + * All rights reserved. + * Licensed under the BSD 3-Clause license. + * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause + */ + +import { expect } from 'chai'; +import { ForceConfigList } from '../../src/commands/forceConfigList'; +import { nls } from '../../src/messages'; + +// tslint:disable:no-unused-expression +describe('Force Config List', () => { + it('Should build the config list command', async () => { + const configList = new ForceConfigList(); + const configListCommand = configList.build({}); + expect(configListCommand.toCommand()).to.equal('sfdx force:config:list'); + expect(configListCommand.description).to.equal( + nls.localize('force_config_list_text') + ); + }); +}); diff --git a/packages/salesforcedx-vscode-core/test/commands/forceOrgDisplay.test.ts b/packages/salesforcedx-vscode-core/test/commands/forceOrgDisplay.test.ts new file mode 100644 index 0000000..aed07af --- /dev/null +++ b/packages/salesforcedx-vscode-core/test/commands/forceOrgDisplay.test.ts @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2017, salesforce.com, inc. + * All rights reserved. + * Licensed under the BSD 3-Clause license. + * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause + */ + +import { expect } from 'chai'; +import { ForceOrgDisplay } from '../../src/commands/forceOrgDisplay'; +import { nls } from '../../src/messages'; + +// tslint:disable:no-unused-expression +describe('Force Source Status', () => { + it('Should build the source command no flag', async () => { + const forceOrgDisplay = new ForceOrgDisplay(); + const displayCommand = forceOrgDisplay.build({}); + expect(displayCommand.toCommand()).to.equal('sfdx force:org:display'); + expect(displayCommand.description).to.equal( + nls.localize('force_org_display_default_text') + ); + }); +});