diff --git a/packages/salesforcedx-utils-vscode/src/commands/channelService.ts b/packages/salesforcedx-utils-vscode/src/commands/channelService.ts index c2c8e30c43..56b2f85399 100644 --- a/packages/salesforcedx-utils-vscode/src/commands/channelService.ts +++ b/packages/salesforcedx-utils-vscode/src/commands/channelService.ts @@ -17,6 +17,7 @@ export class ChannelService { public constructor(channel: OutputChannel) { this.channel = channel; + this.channel.show(true); } public static getInstance(channelName: string) { diff --git a/packages/salesforcedx-utils-vscode/src/commands/commandletExecutors.ts b/packages/salesforcedx-utils-vscode/src/commands/commandletExecutors.ts index d356039d02..3f8be9579c 100644 --- a/packages/salesforcedx-utils-vscode/src/commands/commandletExecutors.ts +++ b/packages/salesforcedx-utils-vscode/src/commands/commandletExecutors.ts @@ -124,23 +124,23 @@ export abstract class LibraryCommandletExecutor private cancelled: boolean = false; private readonly executionName: string; private readonly logName: string; - private readonly outputChannel: vscode.OutputChannel; - protected showChannelOutput = true; + private readonly channelService: ChannelService; + protected showChannelOutput = false; protected readonly telemetry = new TelemetryBuilder(); /** * @param executionName Name visible to user while executing. * @param logName Name for logging purposes such as telemetry. - * @param outputChannel VS Code output channel to report execution status to. + * @param channelService ChannelService to report */ constructor( executionName: string, logName: string, - outputChannel: vscode.OutputChannel + channelService: ChannelService ) { this.executionName = executionName; this.logName = logName; - this.outputChannel = outputChannel; + this.channelService = channelService; } /** @@ -160,13 +160,12 @@ export abstract class LibraryCommandletExecutor public async execute(response: ContinueResponse): Promise { const startTime = process.hrtime(); - const channelService = new ChannelService(this.outputChannel); const telemetryService = TelemetryService.getInstance(); if (SfdxSettingsService.getEnableClearOutputBeforeEachCommand()) { channelService.clear(); } - channelService.showCommandWithTimestamp( + this.channelService.showCommandWithTimestamp( `${nls.localize('channel_starting_message')}${this.executionName}\n` ); @@ -192,18 +191,18 @@ export abstract class LibraryCommandletExecutor return this.run(response, progress, token); } ); - channelService.showCommandWithTimestamp( + this.channelService.showCommandWithTimestamp( `${nls.localize('channel_end')} ${this.executionName}` ); if (this.showChannelOutput) { - channelService.showChannelOutput(); + this.channelService.showChannelOutput(); } if (!this.cancelled) { if (success) { notificationService - .showSuccessfulExecution(this.executionName, channelService) + .showSuccessfulExecution(this.executionName, this.channelService) .catch(e => console.error(e)); } else { notificationService.showFailedExecution(this.executionName); @@ -221,8 +220,8 @@ export abstract class LibraryCommandletExecutor } catch (e) { telemetryService.sendException(e.name, e.message); notificationService.showFailedExecution(this.executionName); - channelService.appendLine(e.message); - channelService.showChannelOutput(); + this.channelService.appendLine(e.message); + this.channelService.showChannelOutput(); } } diff --git a/packages/salesforcedx-vscode-apex-replay-debugger/src/channels/index.ts b/packages/salesforcedx-vscode-apex-replay-debugger/src/channels/index.ts index 710f55b168..a024e041a8 100644 --- a/packages/salesforcedx-vscode-apex-replay-debugger/src/channels/index.ts +++ b/packages/salesforcedx-vscode-apex-replay-debugger/src/channels/index.ts @@ -5,10 +5,9 @@ * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause */ import { ChannelService } from '@salesforce/salesforcedx-utils-vscode/out/src/commands'; -import * as vscode from 'vscode'; import { nls } from '../messages'; -export const OUTPUT_CHANNEL = vscode.window.createOutputChannel( +export const OUTPUT_CHANNEL = ChannelService.getInstance( nls.localize('channel_name') ); -export const channelService = new ChannelService(OUTPUT_CHANNEL); +export const channelService = OUTPUT_CHANNEL; diff --git a/packages/salesforcedx-vscode-apex-replay-debugger/src/commands/quickLaunch.ts b/packages/salesforcedx-vscode-apex-replay-debugger/src/commands/quickLaunch.ts index 012bda462c..e207e0215f 100644 --- a/packages/salesforcedx-vscode-apex-replay-debugger/src/commands/quickLaunch.ts +++ b/packages/salesforcedx-vscode-apex-replay-debugger/src/commands/quickLaunch.ts @@ -148,6 +148,9 @@ export class QuickLaunch { } export class TestDebuggerExecutor extends LibraryCommandletExecutor { + + protected showChannelOutput = true; + constructor() { super( nls.localize('debug_test_exec_name'), diff --git a/packages/salesforcedx-vscode-apex/src/channels/index.ts b/packages/salesforcedx-vscode-apex/src/channels/index.ts index 710f55b168..a024e041a8 100644 --- a/packages/salesforcedx-vscode-apex/src/channels/index.ts +++ b/packages/salesforcedx-vscode-apex/src/channels/index.ts @@ -5,10 +5,9 @@ * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause */ import { ChannelService } from '@salesforce/salesforcedx-utils-vscode/out/src/commands'; -import * as vscode from 'vscode'; import { nls } from '../messages'; -export const OUTPUT_CHANNEL = vscode.window.createOutputChannel( +export const OUTPUT_CHANNEL = ChannelService.getInstance( nls.localize('channel_name') ); -export const channelService = new ChannelService(OUTPUT_CHANNEL); +export const channelService = OUTPUT_CHANNEL; diff --git a/packages/salesforcedx-vscode-apex/src/commands/forceApexTestSuite.ts b/packages/salesforcedx-vscode-apex/src/commands/forceApexTestSuite.ts index b0d823fb74..75b30ab6a2 100644 --- a/packages/salesforcedx-vscode-apex/src/commands/forceApexTestSuite.ts +++ b/packages/salesforcedx-vscode-apex/src/commands/forceApexTestSuite.ts @@ -152,6 +152,7 @@ export class ApexLibraryTestSuiteBuilder extends LibraryCommandletExecutor< public static diagnostics = vscode.languages.createDiagnosticCollection( 'apex-errors' ); + protected showChannelOutput = true; constructor() { super( diff --git a/packages/salesforcedx-vscode-core/src/channels/index.ts b/packages/salesforcedx-vscode-core/src/channels/index.ts index b659865d9f..2636e93285 100644 --- a/packages/salesforcedx-vscode-core/src/channels/index.ts +++ b/packages/salesforcedx-vscode-core/src/channels/index.ts @@ -5,10 +5,9 @@ * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause */ import { ChannelService } from '@salesforce/salesforcedx-utils-vscode/out/src/commands'; -import * as vscode from 'vscode'; import { nls } from '../messages'; -export const OUTPUT_CHANNEL = vscode.window.createOutputChannel( +export const OUTPUT_CHANNEL = ChannelService.getInstance( nls.localize('channel_name') ); -export const channelService = new ChannelService(OUTPUT_CHANNEL); +export const channelService = OUTPUT_CHANNEL; diff --git a/packages/salesforcedx-vscode-core/src/commands/auth/forceAuthAccessTokenLogin.ts b/packages/salesforcedx-vscode-core/src/commands/auth/forceAuthAccessTokenLogin.ts index 6ead3e019d..fede625a87 100644 --- a/packages/salesforcedx-vscode-core/src/commands/auth/forceAuthAccessTokenLogin.ts +++ b/packages/salesforcedx-vscode-core/src/commands/auth/forceAuthAccessTokenLogin.ts @@ -21,6 +21,9 @@ import { export class ForceAuthAccessTokenExecutor extends LibraryCommandletExecutor< AccessTokenParams > { + + protected showChannelOutput = true; + constructor() { super( nls.localize('force_auth_access_token_authorize_org_text'), diff --git a/packages/salesforcedx-vscode-core/src/commands/auth/forceAuthDevHub.ts b/packages/salesforcedx-vscode-core/src/commands/auth/forceAuthDevHub.ts index 81870f988b..d32063370e 100644 --- a/packages/salesforcedx-vscode-core/src/commands/auth/forceAuthDevHub.ts +++ b/packages/salesforcedx-vscode-core/src/commands/auth/forceAuthDevHub.ts @@ -54,7 +54,6 @@ export class ForceAuthDevHubContainerExecutor extends ForceAuthWebLoginContainer } export class ForceAuthDevHubExecutor extends SfdxCommandletExecutor<{}> { - protected showChannelOutput = false; public build(data: {}): Command { const command = new SfdxCommandBuilder().withDescription( diff --git a/packages/salesforcedx-vscode-core/src/commands/auth/forceAuthLogout.ts b/packages/salesforcedx-vscode-core/src/commands/auth/forceAuthLogout.ts index 6662e1e161..52aef7c6bd 100644 --- a/packages/salesforcedx-vscode-core/src/commands/auth/forceAuthLogout.ts +++ b/packages/salesforcedx-vscode-core/src/commands/auth/forceAuthLogout.ts @@ -31,7 +31,6 @@ import { ScratchOrgLogoutParamsGatherer } from './authParamsGatherer'; export class ForceAuthLogoutAll extends SfdxCommandletExecutor<{}> { public static withoutShowingChannel(): ForceAuthLogoutAll { const instance = new ForceAuthLogoutAll(); - instance.showChannelOutput = false; return instance; } @@ -60,12 +59,16 @@ export async function forceAuthLogoutAll() { } export class AuthLogoutDefault extends LibraryCommandletExecutor { + + protected showChannelOutput = true; + constructor() { super( nls.localize('force_auth_logout_default_text'), 'force_auth_logout_default', OUTPUT_CHANNEL ); + } public async run( diff --git a/packages/salesforcedx-vscode-core/src/commands/auth/forceAuthWebLogin.ts b/packages/salesforcedx-vscode-core/src/commands/auth/forceAuthWebLogin.ts index 2ea08d04c4..b4a1e38c9c 100644 --- a/packages/salesforcedx-vscode-core/src/commands/auth/forceAuthWebLogin.ts +++ b/packages/salesforcedx-vscode-core/src/commands/auth/forceAuthWebLogin.ts @@ -46,7 +46,6 @@ export interface DeviceCodeResponse { export class ForceAuthWebLoginContainerExecutor extends SfdxCommandletExecutor< AuthParams > { - protected showChannelOutput = false; protected deviceCodeReceived = false; protected stdOut = ''; @@ -147,7 +146,6 @@ export class ForceAuthWebLoginContainerExecutor extends SfdxCommandletExecutor< export class ForceAuthWebLoginExecutor extends SfdxCommandletExecutor< AuthParams > { - protected showChannelOutput = false; public build(data: AuthParams): Command { const command = new SfdxCommandBuilder().withDescription( diff --git a/packages/salesforcedx-vscode-core/src/commands/forceConfigSet.ts b/packages/salesforcedx-vscode-core/src/commands/forceConfigSet.ts index 33508d0f2a..2f01c0cb50 100644 --- a/packages/salesforcedx-vscode-core/src/commands/forceConfigSet.ts +++ b/packages/salesforcedx-vscode-core/src/commands/forceConfigSet.ts @@ -18,7 +18,6 @@ import { export class ForceConfigSetExecutor extends SfdxCommandletExecutor<{}> { private usernameOrAlias: string; - protected showChannelOutput = false; public constructor(usernameOrAlias: string) { super(); diff --git a/packages/salesforcedx-vscode-core/src/commands/forceCreateManifest.ts b/packages/salesforcedx-vscode-core/src/commands/forceCreateManifest.ts index 22eb6735dc..35e7016329 100644 --- a/packages/salesforcedx-vscode-core/src/commands/forceCreateManifest.ts +++ b/packages/salesforcedx-vscode-core/src/commands/forceCreateManifest.ts @@ -25,6 +25,8 @@ const MANIFEST_SAVE_PROMPT = 'manifest_input_save_prompt'; export class ManifestCreateExecutor extends LibraryCommandletExecutor { private sourcePaths: string[]; private responseText: string | undefined; + protected showChannelOutput = true; + constructor(sourcePaths: string[], responseText: string | undefined) { super( nls.localize(CREATE_MANIFEST_EXECUTOR), diff --git a/packages/salesforcedx-vscode-core/src/commands/forceOrgOpen.ts b/packages/salesforcedx-vscode-core/src/commands/forceOrgOpen.ts index 8ff3692eea..3dade3e678 100644 --- a/packages/salesforcedx-vscode-core/src/commands/forceOrgOpen.ts +++ b/packages/salesforcedx-vscode-core/src/commands/forceOrgOpen.ts @@ -101,7 +101,7 @@ export class ForceOrgOpenContainerExecutor extends SfdxCommandletExecutor<{}> { } export class ForceOrgOpenExecutor extends SfdxCommandletExecutor<{}> { - protected showChannelOutput = false; + public build(data: {}): Command { return new SfdxCommandBuilder() .withDescription(nls.localize('force_org_open_default_scratch_org_text')) diff --git a/packages/salesforcedx-vscode-core/src/commands/forceRenameLightningComponent.ts b/packages/salesforcedx-vscode-core/src/commands/forceRenameLightningComponent.ts index b25e757471..bc5c41f7bf 100644 --- a/packages/salesforcedx-vscode-core/src/commands/forceRenameLightningComponent.ts +++ b/packages/salesforcedx-vscode-core/src/commands/forceRenameLightningComponent.ts @@ -30,6 +30,8 @@ const TEST_FOLDER = '__tests__'; export class RenameLwcComponentExecutor extends LibraryCommandletExecutor { private sourceFsPath: string; + protected showChannelOutput = true; + constructor(sourceFsPath: string) { super( nls.localize(RENAME_LIGHTNING_COMPONENT_EXECUTOR), diff --git a/packages/salesforcedx-vscode-core/src/commands/functions/forceFunctionInvoke.ts b/packages/salesforcedx-vscode-core/src/commands/functions/forceFunctionInvoke.ts index 00d4b77f20..c05d5eba10 100644 --- a/packages/salesforcedx-vscode-core/src/commands/functions/forceFunctionInvoke.ts +++ b/packages/salesforcedx-vscode-core/src/commands/functions/forceFunctionInvoke.ts @@ -27,6 +27,9 @@ import { ContinueResponse } from '@salesforce/salesforcedx-utils-vscode/out/src/ import * as fs from 'fs'; export class ForceFunctionInvoke extends LibraryCommandletExecutor { + + protected showChannelOutput = true; + constructor(debug: boolean = false) { super( nls.localize('force_function_invoke_text'), diff --git a/packages/salesforcedx-vscode-core/src/commands/functions/forceFunctionStart/ForceFunctionStartExecutor.ts b/packages/salesforcedx-vscode-core/src/commands/functions/forceFunctionStart/ForceFunctionStartExecutor.ts index 6435283d6a..2fc8854fb1 100644 --- a/packages/salesforcedx-vscode-core/src/commands/functions/forceFunctionStart/ForceFunctionStartExecutor.ts +++ b/packages/salesforcedx-vscode-core/src/commands/functions/forceFunctionStart/ForceFunctionStartExecutor.ts @@ -26,6 +26,8 @@ export abstract class ForceFunctionStartExecutor extends LibraryCommandletExecut > { protected UNEXPECTED_ERROR_KEY = 'force_function_start_unexpected_error'; + protected showChannelOutput = true; + constructor(startMessageKey: string, logName: string) { super(nls.localize(startMessageKey), logName, OUTPUT_CHANNEL); this.cancellable = true; diff --git a/packages/salesforcedx-vscode-core/src/commands/templates/forceFunctionCreate.ts b/packages/salesforcedx-vscode-core/src/commands/templates/forceFunctionCreate.ts index bbd431332b..fce6840401 100644 --- a/packages/salesforcedx-vscode-core/src/commands/templates/forceFunctionCreate.ts +++ b/packages/salesforcedx-vscode-core/src/commands/templates/forceFunctionCreate.ts @@ -41,6 +41,9 @@ const LOG_NAME = 'force_function_create'; export class ForceFunctionCreateExecutor extends LibraryCommandletExecutor< any > { + + protected showChannelOutput = true; + constructor() { super(nls.localize('force_function_create_text'), LOG_NAME, OUTPUT_CHANNEL); }