Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

draft: fix: stop showing output tab in unnecessary circumstances #4337

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export class ChannelService {

public constructor(channel: OutputChannel) {
this.channel = channel;
this.channel.show(true);
}

public static getInstance(channelName: string) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,23 +124,23 @@ export abstract class LibraryCommandletExecutor<T>
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;
}

/**
Expand All @@ -160,13 +160,12 @@ export abstract class LibraryCommandletExecutor<T>

public async execute(response: ContinueResponse<T>): Promise<void> {
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`
);

Expand All @@ -192,18 +191,18 @@ export abstract class LibraryCommandletExecutor<T>
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);
Expand All @@ -221,8 +220,8 @@ export abstract class LibraryCommandletExecutor<T>
} 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();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,9 @@ export class QuickLaunch {
}

export class TestDebuggerExecutor extends LibraryCommandletExecutor<string[]> {

protected showChannelOutput = true;

constructor() {
super(
nls.localize('debug_test_exec_name'),
Expand Down
5 changes: 2 additions & 3 deletions packages/salesforcedx-vscode-apex/src/channels/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ export class ApexLibraryTestSuiteBuilder extends LibraryCommandletExecutor<
public static diagnostics = vscode.languages.createDiagnosticCollection(
'apex-errors'
);
protected showChannelOutput = true;

constructor() {
super(
Expand Down
5 changes: 2 additions & 3 deletions packages/salesforcedx-vscode-core/src/channels/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -60,12 +59,16 @@ export async function forceAuthLogoutAll() {
}

export class AuthLogoutDefault extends LibraryCommandletExecutor<string> {

protected showChannelOutput = true;

constructor() {
super(
nls.localize('force_auth_logout_default_text'),
'force_auth_logout_default',
OUTPUT_CHANNEL
);

}

public async run(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ export interface DeviceCodeResponse {
export class ForceAuthWebLoginContainerExecutor extends SfdxCommandletExecutor<
AuthParams
> {
protected showChannelOutput = false;
protected deviceCodeReceived = false;
protected stdOut = '';

Expand Down Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import {

export class ForceConfigSetExecutor extends SfdxCommandletExecutor<{}> {
private usernameOrAlias: string;
protected showChannelOutput = false;

public constructor(usernameOrAlias: string) {
super();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ const MANIFEST_SAVE_PROMPT = 'manifest_input_save_prompt';
export class ManifestCreateExecutor extends LibraryCommandletExecutor<string> {
private sourcePaths: string[];
private responseText: string | undefined;
protected showChannelOutput = true;

constructor(sourcePaths: string[], responseText: string | undefined) {
super(
nls.localize(CREATE_MANIFEST_EXECUTOR),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ const TEST_FOLDER = '__tests__';

export class RenameLwcComponentExecutor extends LibraryCommandletExecutor<ComponentName> {
private sourceFsPath: string;
protected showChannelOutput = true;

constructor(sourceFsPath: string) {
super(
nls.localize(RENAME_LIGHTNING_COMPONENT_EXECUTOR),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ import { ContinueResponse } from '@salesforce/salesforcedx-utils-vscode/out/src/
import * as fs from 'fs';

export class ForceFunctionInvoke extends LibraryCommandletExecutor<string> {

protected showChannelOutput = true;

constructor(debug: boolean = false) {
super(
nls.localize('force_function_invoke_text'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down