-
Notifications
You must be signed in to change notification settings - Fork 446
Add preference clear output channel #4318
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
Changes from all commits
17ccdb1
57e0cd7
a7c735f
ad8a81e
a5462c2
5c03345
f8ef55d
91d3250
9609855
f45f5f4
1e188d5
b7bbdef
290668f
11b591b
f1f2d7d
72fff9f
1b57559
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,6 +14,7 @@ import { | |
| TelemetryService | ||
| } from '../index'; | ||
| import { nls } from '../messages'; | ||
| import { SfdxSettingsService } from '../settings'; | ||
| import { CommandletExecutor, ContinueResponse } from '../types'; | ||
| import { getRootWorkspacePath } from '../workspaces'; | ||
| import { ChannelService } from './channelService'; | ||
|
|
@@ -161,6 +162,9 @@ export abstract class LibraryCommandletExecutor<T> | |
| const startTime = process.hrtime(); | ||
| const channelService = new ChannelService(this.outputChannel); | ||
| const telemetryService = TelemetryService.getInstance(); | ||
| if (SfdxSettingsService.getEnableClearOutputBeforeEachCommand()) { | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The LibraryCommandletExecutor is exported from |
||
| channelService.clear(); | ||
| } | ||
|
|
||
| channelService.showCommandWithTimestamp( | ||
| `${nls.localize('channel_starting_message')}${this.executionName}\n` | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| export const SETTING_CLEAR_OUTPUT_TAB = 'clearOutputTab'; | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These are now all exported by |
||
| export const SFDX_CORE_CONFIGURATION_NAME = 'salesforcedx-vscode-core'; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What's your thought here having these two identical strings with different names?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I decided that since they represent 2 different things, that we should have 2 constants, even though they are the same string. I wanted anyone changing these in the future to be more aware of what this constant represents. |
||
| export const SFDX_CORE_EXTENSION_NAME = 'salesforcedx-vscode-core'; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| export * from './sfdxSettingsService'; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| import * as vscode from 'vscode'; | ||
| import { SETTING_CLEAR_OUTPUT_TAB, SFDX_CORE_CONFIGURATION_NAME } from '../constants'; | ||
|
|
||
| export class SfdxSettingsService { | ||
| public static getEnableClearOutputBeforeEachCommand(): boolean { | ||
| return vscode.workspace | ||
| .getConfiguration(SFDX_CORE_CONFIGURATION_NAME) | ||
| .get<boolean>(SETTING_CLEAR_OUTPUT_TAB, false); | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| import { expect } from 'chai'; | ||
| import * as proxyquire from 'proxyquire'; | ||
| import { createSandbox, SinonSandbox } from 'sinon'; | ||
| import { vscodeStub } from '../commands/mocks'; | ||
|
|
||
| const { SfdxSettingsService } = proxyquire.noCallThru()( | ||
| '../../../src/settings/index', | ||
| { | ||
| vscode: vscodeStub | ||
| } | ||
| ); | ||
|
|
||
| describe('SfdxSettingsService', () => { | ||
| let sb: SinonSandbox; | ||
| beforeEach(() => { | ||
| sb = createSandbox(); | ||
| }); | ||
| afterEach(() => { | ||
| sb.restore(); | ||
| }); | ||
| describe('when reading workspace preference for clearing output', () => { | ||
| it('should return true when underlying workspace configuration for preference', () => { | ||
| sb.stub(vscodeStub.workspace, 'getConfiguration').returns({ | ||
| get: () => true | ||
| }); | ||
| expect(SfdxSettingsService.getEnableClearOutputBeforeEachCommand()).equals(true); | ||
| }); | ||
| it('should return false if underlying configuration is false', () => { | ||
| sb.stub(vscodeStub.workspace, 'getConfiguration').returns({ | ||
| get: () => false | ||
| }); | ||
| expect(SfdxSettingsService.getEnableClearOutputBeforeEachCommand()).equals(false); | ||
| }); | ||
| }); | ||
| }); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -24,6 +24,7 @@ import * as vscode from 'vscode'; | |
| import { EmptyPostChecker } from '.'; | ||
| import { channelService } from '../../channels'; | ||
| import { notificationService, ProgressNotification } from '../../notifications'; | ||
| import { sfdxCoreSettings } from '../../settings'; | ||
| import { taskViewService } from '../../statuses'; | ||
| import { telemetryService } from '../../telemetry'; | ||
| import { getRootWorkspacePath } from '../../util'; | ||
|
|
@@ -165,6 +166,9 @@ export class SfdxCommandlet<T> { | |
| } | ||
|
|
||
| public async run(): Promise<void> { | ||
| if (sfdxCoreSettings.getEnableClearOutputBeforeEachCommand()) { | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Adding this to the run() method here basically adds this feature to all the commands that extend |
||
| channelService.clear(); | ||
| } | ||
| if (await this.prechecker.check()) { | ||
| let inputs = await this.gatherer.gather(); | ||
| inputs = await this.postchecker.check(inputs); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,15 +5,14 @@ | |
| * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause | ||
| */ | ||
|
|
||
| import { SETTING_CLEAR_OUTPUT_TAB, SFDX_CORE_CONFIGURATION_NAME } from '@salesforce/salesforcedx-utils-vscode/out/src'; | ||
| import * as vscode from 'vscode'; | ||
| import { | ||
| BETA_DEPLOY_RETRIEVE, | ||
| CONFLICT_DETECTION_ENABLED, | ||
| INTERNAL_DEVELOPMENT_FLAG, | ||
| PUSH_OR_DEPLOY_ON_SAVE_ENABLED, | ||
| PUSH_OR_DEPLOY_ON_SAVE_OVERRIDE_CONFLICTS, | ||
| RETRIEVE_TEST_CODE_COVERAGE, | ||
| SFDX_CORE_CONFIGURATION_NAME, | ||
| SHOW_CLI_SUCCESS_INFO_MSG, | ||
| TELEMETRY_ENABLED | ||
| } from '../constants'; | ||
|
|
@@ -75,6 +74,10 @@ export class SfdxCoreSettings { | |
| return this.getConfigValue(CONFLICT_DETECTION_ENABLED, false); | ||
| } | ||
|
|
||
| public getEnableClearOutputBeforeEachCommand(): boolean { | ||
| return this.getConfigValue(SETTING_CLEAR_OUTPUT_TAB, false); | ||
| } | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit pick: please add an extra carriage return after the closing curly brace. |
||
|
|
||
| private getConfigValue<T>(key: string, defaultValue: T): T { | ||
| return this.getConfiguration().get<T>(key, defaultValue); | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The channel service is my first choice to attempt to handle this preference in one central location. Unfortunately, the way the channel service is used throughout the app is very inconsistent. This "streamCommandStartStop()" is used by some of the abstract executors ( SfdxCommandletExecutor, LibraryExectutor ) that are exported from salesforcedx-utils-vscode.