Skip to content

Commit

Permalink
Merge branch 'develop' into mz/telemetry-orgshape
Browse files Browse the repository at this point in the history
  • Loading branch information
peternhale authored Nov 12, 2024
2 parents 6cddd10 + 22df9f8 commit 3689da8
Show file tree
Hide file tree
Showing 8 changed files with 62 additions and 9 deletions.
5 changes: 5 additions & 0 deletions packages/salesforcedx-vscode-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -957,6 +957,11 @@
"default": false,
"description": "%prefer_deploy_on_save_enabled_description%"
},
"salesforcedx-vscode-core.push-or-deploy-on-save.showOutputPanel": {
"type": "boolean",
"default": false,
"description": "%push_or_deploy_on_save_show_output_panel%"
},
"salesforcedx-vscode-core.detectConflictsAtSync": {
"type": "boolean",
"default": false,
Expand Down
1 change: 1 addition & 0 deletions packages/salesforcedx-vscode-core/package.nls.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
"project_retrieve_start_default_org_text": "SFDX: Pull Source from Default Org",
"project_retrieve_start_ignore_conflicts_default_org_text": "SFDX: Pull Source from Default Org and Ignore Conflicts",
"push_or_deploy_on_save_enabled_description": "Specifies whether or not to automatically push (for source-tracked orgs) or deploy (for non-source-tracked orgs) when a local source file is saved.",
"push_or_deploy_on_save_show_output_panel": "Specifies whether to switch to the Output panel when a local source file is saved.",
"refresh_components_text": "SFDX: Refresh Components",
"refresh_types_text": "SFDX: Refresh Types",
"rename_lightning_component_text": "SFDX: Rename Component",
Expand Down
13 changes: 10 additions & 3 deletions packages/salesforcedx-vscode-core/src/commands/deploySourcePath.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { channelService } from '../channels';
import { getConflictMessagesFor } from '../conflict/messages';
import { nls } from '../messages';
import { notificationService } from '../notifications';
import { salesforceCoreSettings } from '../settings';
import { telemetryService } from '../telemetry';
import { DeployExecutor } from './baseDeployRetrieve';
import { SourcePathChecker } from './retrieveSourcePath';
Expand All @@ -19,8 +20,9 @@ import { CompositePostconditionChecker } from './util/compositePostconditionChec
import { TimestampConflictChecker } from './util/timestampConflictChecker';

export class LibraryDeploySourcePathExecutor extends DeployExecutor<string[]> {
constructor() {
constructor(showChannelOutput: boolean = true) {
super(nls.localize('deploy_this_source_text'), 'deploy_with_sourcepath');
this.showChannelOutput = showChannelOutput;
}

public async getComponents(
Expand All @@ -36,7 +38,8 @@ export class LibraryDeploySourcePathExecutor extends DeployExecutor<string[]> {

export const deploySourcePaths = async (
sourceUri: vscode.Uri | vscode.Uri[] | undefined,
uris: vscode.Uri[] | undefined
uris: vscode.Uri[] | undefined,
isDeployOnSave?: boolean | undefined
) => {
if (!sourceUri) {
// When the source is deployed via the command palette, both sourceUri and uris are
Expand Down Expand Up @@ -70,10 +73,14 @@ export const deploySourcePaths = async (
const messages = getConflictMessagesFor('deploy_with_sourcepath');

if (messages) {
const showOutputPanel = !(
isDeployOnSave && !salesforceCoreSettings.getDeployOnSaveShowOutputPanel()
);

const commandlet = new SfCommandlet<string[]>(
new SfWorkspaceChecker(),
new LibraryPathsGatherer(uris),
new LibraryDeploySourcePathExecutor(),
new LibraryDeploySourcePathExecutor(showOutputPanel),
new CompositePostconditionChecker(
new SourcePathChecker(),
new TimestampConflictChecker(false, messages)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import { PersistentStorageService } from '../conflict';
import { PROJECT_DEPLOY_START_LOG_NAME } from '../constants';
import { handlePushDiagnosticErrors } from '../diagnostics';
import { nls } from '../messages';
import { salesforceCoreSettings } from '../settings';
import { telemetryService } from '../telemetry';
import { DeployRetrieveExecutor } from './baseDeployRetrieve';
import {
Expand Down Expand Up @@ -53,10 +54,12 @@ export class ProjectDeployStartExecutor extends SfCommandletExecutor<{}> {
private flag: string | undefined;
public constructor(
flag?: string,
public params: CommandParams = pushCommand
public params: CommandParams = pushCommand,
showChannelOutput: boolean = true
) {
super();
this.flag = flag;
this.showChannelOutput = showChannelOutput;
}

protected getDeployType() {
Expand Down Expand Up @@ -263,9 +266,21 @@ export class ProjectDeployStartExecutor extends SfCommandletExecutor<{}> {
const workspaceChecker = new SfWorkspaceChecker();
const parameterGatherer = new EmptyParametersGatherer();

export async function projectDeployStart(this: FlagParameter<string>) {
export async function projectDeployStart(
this: FlagParameter<string>,
isDeployOnSave: boolean
) {
const showOutputPanel = !(
isDeployOnSave && !salesforceCoreSettings.getDeployOnSaveShowOutputPanel()
);

const { flag } = this || {};
const executor = new ProjectDeployStartExecutor(flag, pushCommand);
const executor = new ProjectDeployStartExecutor(
flag,
pushCommand,
showOutputPanel
);

const commandlet = new SfCommandlet(
workspaceChecker,
parameterGatherer,
Expand Down
2 changes: 2 additions & 0 deletions packages/salesforcedx-vscode-core/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ export const PREFER_DEPLOY_ON_SAVE_ENABLED =
'push-or-deploy-on-save.preferDeployOnSave';
export const PUSH_OR_DEPLOY_ON_SAVE_IGNORE_CONFLICTS =
'push-or-deploy-on-save.ignoreConflictsOnPush';
export const DEPLOY_ON_SAVE_SHOW_OUTPUT_PANEL =
'push-or-deploy-on-save.showOutputPanel';
export const RETRIEVE_TEST_CODE_COVERAGE = 'retrieve-test-code-coverage';
export const SHOW_CLI_SUCCESS_INFO_MSG = 'show-cli-success-msg';
export const TELEMETRY_ENABLED = 'telemetry.enabled';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,12 @@ export class DeployQueue {
}

private async executeDeployCommand(toDeploy: vscode.Uri[]) {
vscode.commands.executeCommand('sf.deploy.multiple.source.paths', toDeploy);
await vscode.commands.executeCommand(
'sf.deploy.multiple.source.paths',
toDeploy,
null,
true
);
}

private async executePushCommand() {
Expand All @@ -76,7 +81,7 @@ export class DeployQueue {
? '.ignore.conflicts'
: '';
const command = `sf.project.deploy.start${ignoreConflictsCommand}`;
vscode.commands.executeCommand(command);
vscode.commands.executeCommand(command, true);
}

private async doDeploy(): Promise<void> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {
PREFER_DEPLOY_ON_SAVE_ENABLED,
PUSH_OR_DEPLOY_ON_SAVE_ENABLED,
PUSH_OR_DEPLOY_ON_SAVE_IGNORE_CONFLICTS,
DEPLOY_ON_SAVE_SHOW_OUTPUT_PANEL,
RETRIEVE_TEST_CODE_COVERAGE,
SHOW_CLI_SUCCESS_INFO_MSG,
TELEMETRY_ENABLED
Expand Down Expand Up @@ -76,6 +77,10 @@ export class SalesforceCoreSettings {
return this.getConfigValue(PREFER_DEPLOY_ON_SAVE_ENABLED, false);
}

public getDeployOnSaveShowOutputPanel(): boolean {
return this.getConfigValue(DEPLOY_ON_SAVE_SHOW_OUTPUT_PANEL, false);
}

public getEnableSourceTrackingForDeployAndRetrieve(): boolean {
return this.getConfigValue(
ENABLE_SOURCE_TRACKING_FOR_DEPLOY_RETRIEVE,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ describe('DeployQueue', () => {
let getWorkspaceOrgTypeMock: jest.SpyInstance;
let executeDeployCommandSpy: jest.SpyInstance;
let executePushCommandSpy: jest.SpyInstance;
let vscodeExecuteCommandSpy: jest.SpyInstance;

beforeEach(() => {
getPushOrDeployOnSaveEnabledMock = jest.spyOn(
Expand All @@ -37,10 +38,12 @@ describe('DeployQueue', () => {
(DeployQueue as any).prototype,
'executePushCommand'
);
vscodeExecuteCommandSpy = jest.spyOn(vscode.commands, 'executeCommand');
});

afterEach(() => {
DeployQueue.reset();
jest.restoreAllMocks();
});

it('should execute a push command when org type is source-tracked, "Push or deploy on save" is enabled, and "Prefer deploy on save" is disabled', async () => {
Expand All @@ -53,6 +56,10 @@ describe('DeployQueue', () => {
expect(getPreferDeployOnSaveEnabledMock).toHaveBeenCalled();
expect(executePushCommandSpy).toHaveBeenCalled();
expect(executeDeployCommandSpy).not.toHaveBeenCalled();
expect(vscodeExecuteCommandSpy).toHaveBeenCalledWith(
'sf.project.deploy.start.ignore.conflicts',
true
);
});

it('should execute a deploy command when "Push or deploy on save" and "Prefer deploy on save" are enabled', async () => {
Expand All @@ -62,8 +69,14 @@ describe('DeployQueue', () => {
await DeployQueue.get().enqueue(vscode.Uri.file('/sample'));

expect(getPreferDeployOnSaveEnabledMock).toHaveBeenCalled();
expect(executeDeployCommandSpy).toHaveBeenCalled();
expect(executePushCommandSpy).not.toHaveBeenCalled();
expect(executeDeployCommandSpy).toHaveBeenCalled();
expect(vscodeExecuteCommandSpy).toHaveBeenCalledWith(
'sf.deploy.multiple.source.paths',
[undefined],
null,
true
);
});
});
});

0 comments on commit 3689da8

Please sign in to comment.