Skip to content

Commit

Permalink
fix: push source commands from sfdx to sf style (#5362)
Browse files Browse the repository at this point in the history
* chore: sfdx to sf approach

* chore: rest of push stuff

* chore: labels

* chore: ignore conflicts on push setting

* chore: remove unused import

* chore: update command to ignore conflicts

---------

Co-authored-by: peternhale <[email protected]>
  • Loading branch information
CristiCanizales and peternhale authored Jan 29, 2024
1 parent 059aaa7 commit 1e86a1a
Show file tree
Hide file tree
Showing 27 changed files with 221 additions and 214 deletions.
6 changes: 2 additions & 4 deletions docs/_articles/en/deploy-changes/deploy-on-save.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,9 @@ To enable deploy on save, you can:
- Select **File** > **Preferences** > **Settings** (Windows or Linux) or **Code** > **Preferences** > **Settings** (macOS).
- Under Salesforce Core Configuration, select `Push-or-deploy-on-save: Enabled`.


**Note:**
We recommend that you enable deploy on save at a project level (Workspace settings) rather than globally on all Salesforce projects you work on (User settings). While working on large sandboxes, be mindful of enabling deploy on save to avoid inadvertently overwriting changes by other developers.


## How it Works

When you enable deploy on save for your project:
Expand All @@ -31,8 +29,8 @@ When you enable deploy on save for your project:

- If there isn’t an active deployment and no files are queued for deployment, a file save triggers an immediate deployment.

If you enable deploy on save while working against a source-tracked org, every time you save a file, **SFDX: Push Source to Default Org** is initiated and runs `force:source:push` under the hood. For non-source-tracked orgs, every file save initiates **SFDX: Deploy Source to Org**, which runs `force:source:deploy`.
If you enable deploy on save while working against a source-tracked org, every time you save a file, **SFDX: Push Source to Default Org** is initiated and runs `project:deploy:start` under the hood. For non-source-tracked orgs, every file save initiates **SFDX: Deploy Source to Org**, which runs `force:source:deploy`.

## Detect Conflicts At Sync

Check the setting, **File** > **Preferences** > **Settings** (Windows or Linux) or **Code** > **Preferences** > **Settings** (macOS)> **Salesforce Core Configurations** `Detect Conflicts At Sync` to enable conflict detection for all deploy commands executed from VS Code. See [Detect Conflicts on Deploy](detect-conflicts.md)for more information on conflict detection.
Check the setting, **File** > **Preferences** > **Settings** (Windows or Linux) or **Code** > **Preferences** > **Settings** (macOS)> **Salesforce Core Configurations** `Detect Conflicts At Sync` to enable conflict detection for all deploy commands executed from VS Code. See [Detect Conflicts on Deploy](detect-conflicts.md)for more information on conflict detection.
2 changes: 1 addition & 1 deletion docs/_articles/ja/deploy-changes/deploy-on-save.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ lang: ja

- アクティブなデプロイがなく、デプロイのためにファイルがキューに入っていない場合、ファイルの保存するとただちにデプロイが開始されます。

スクラッチ組織で作業しているときに保存時のデプロイを有効にすると、拡張機能のコンテキストはパッケージ開発モデルになります。つまり、ファイルを保存するたびに **SFDX: デフォルトのスクラッチ組織にソースをプッシュ (SFDX: Push Source to Default Scratch Org)** が起動し、`force:source:push` が実行されます。ソース追跡されていない組織で動作する、組織開発モデルでは、ファイルを保存するたびに **SFDX: 組織へソースをデプロイ (SFDX: Deploy Source to Org)** が起動し、`force:source:deploy` が実行されます。
スクラッチ組織で作業しているときに保存時のデプロイを有効にすると、拡張機能のコンテキストはパッケージ開発モデルになります。つまり、ファイルを保存するたびに **SFDX: デフォルトのスクラッチ組織にソースをプッシュ (SFDX: Push Source to Default Scratch Org)** が起動し、`project:deploy:start` が実行されます。ソース追跡されていない組織で動作する、組織開発モデルでは、ファイルを保存するたびに **SFDX: 組織へソースをデプロイ (SFDX: Deploy Source to Org)** が起動し、`force:source:deploy` が実行されます。
8 changes: 4 additions & 4 deletions packages/salesforcedx-test-utils-vscode/src/orgUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,15 +88,15 @@ export const pushSource = async (
cp('-R', sourceFolder, targetFolder);
const execution = new CliCommandExecutor(
new SfdxCommandBuilder()
.withArg('force:source:push')
.withFlag('--targetusername', username)
.withJson()
.withArg('project:deploy:start')
.withFlag('--target-org', username)
.withJson(false)
.build(),
{ cwd: path.join(process.cwd(), projectName) }
).execute();
const cmdOutput = new CommandOutput();
const result = await cmdOutput.getCmdResult(execution);
const source = JSON.parse(result).result.pushedSource;
const source = JSON.parse(result).result.files;
return Promise.resolve(source);
};

Expand Down
10 changes: 5 additions & 5 deletions packages/salesforcedx-utils-vscode/src/cli/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ export {
export { ForcePullResultParser, PullResult } from './parsers/pullResultParser';
export {
CONFLICT_ERROR_NAME,
ForcePushResultParser,
ForceSourcePushErrorResponse,
ForceSourcePushSuccessResponse,
PushResult
} from './parsers/pushResultParser';
ProjectDeployStartResultParser,
ProjectDeployStartErrorResponse,
ProjectDeployStartSuccessResponse,
ProjectDeployStartResult
} from './parsers/projectDeployStartResultParser';
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { extractJsonObject } from '../../helpers';

export const CONFLICT_ERROR_NAME = 'sourceConflictDetected';

export interface PushResult {
export interface ProjectDeployStartResult {
columnNumber?: string;
error?: string;
filePath: string;
Expand All @@ -19,52 +19,52 @@ export interface PushResult {
type: string;
}

export interface ForceSourcePushErrorResponse {
export interface ProjectDeployStartErrorResponse {
message: string;
name: string;
data: PushResult[];
data: ProjectDeployStartResult[];
stack: string;
status: number;
warnings: any[];
}

export interface ForceSourcePushSuccessResponse {
export interface ProjectDeployStartSuccessResponse {
status: number;
result: {
pushedSource: PushResult[];
files: ProjectDeployStartResult[];
};
}

export class ForcePushResultParser {
export class ProjectDeployStartResultParser {
private response: any;

constructor(stdout: string) {
try {
this.response = extractJsonObject(stdout);
} catch (e) {
const err = new Error('Error parsing push result');
err.name = 'PushParserFail';
const err = new Error('Error parsing project deploy start result');
err.name = 'ProjectDeployStartParserFail';
throw err;
}
}

public getErrors(): ForceSourcePushErrorResponse | undefined {
public getErrors(): ProjectDeployStartErrorResponse | undefined {
if (this.response.status === 1) {
return this.response as ForceSourcePushErrorResponse;
return this.response as ProjectDeployStartErrorResponse;
}
}

public getSuccesses(): ForceSourcePushSuccessResponse | undefined {
public getSuccesses(): ProjectDeployStartSuccessResponse | undefined {
const { status, result, partialSuccess } = this.response;
if (status === 0) {
const { pushedSource } = result;
if (pushedSource) {
return { status, result: { pushedSource } };
return { status, result: { files: pushedSource } };
}
return this.response as ForceSourcePushSuccessResponse;
return this.response as ProjectDeployStartSuccessResponse;
}
if (partialSuccess) {
return { status, result: { pushedSource: partialSuccess } };
return { status, result: { files: partialSuccess } };
}
}

Expand Down
16 changes: 8 additions & 8 deletions packages/salesforcedx-vscode-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -384,11 +384,11 @@
"when": "sfdx:project_opened && !sfdx:isv_debug_project && sfdx:default_username_has_change_tracking"
},
{
"command": "sfdx.force.source.push",
"command": "sfdx.project.deploy.start",
"when": "sfdx:project_opened && !sfdx:isv_debug_project && sfdx:default_username_has_change_tracking"
},
{
"command": "sfdx.force.source.push.force",
"command": "sfdx.project.deploy.start.ignore.conflicts",
"when": "sfdx:project_opened && !sfdx:isv_debug_project && sfdx:default_username_has_change_tracking"
},
{
Expand Down Expand Up @@ -663,12 +663,12 @@
"title": "%force_source_pull_force_default_org_text%"
},
{
"command": "sfdx.force.source.push",
"title": "%force_source_push_default_org_text%"
"command": "sfdx.project.deploy.start",
"title": "%project_deploy_start_default_org_text%"
},
{
"command": "sfdx.force.source.push.force",
"title": "%force_source_push_force_default_org_text%"
"command": "sfdx.project.deploy.start.ignore.conflicts",
"title": "%project_deploy_start_ignore_conflicts_default_org_text%"
},
{
"command": "sfdx.force.source.status",
Expand Down Expand Up @@ -924,10 +924,10 @@
"default": false,
"description": "%setting_clear_output_tab_description%"
},
"salesforcedx-vscode-core.push-or-deploy-on-save.overrideConflictsOnPush": {
"salesforcedx-vscode-core.push-or-deploy-on-save.ignoreConflictsOnPush": {
"type": "boolean",
"default": false,
"description": "%override_conflicts_on_push_description%"
"description": "%ignore_conflicts_on_push_description%"
},
"salesforcedx-vscode-core.show-cli-success-msg": {
"type": "boolean",
Expand Down
8 changes: 4 additions & 4 deletions packages/salesforcedx-vscode-core/package.nls.ja.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
"force_source_deploy_this_source_text": "SFDX: このソースを組織へデプロイ",
"force_source_pull_default_org_text": "SFDX: デフォルトのスクラッチ組織からソースをプル",
"force_source_pull_force_default_org_text": "SFDX: デフォルトのスクラッチ組織からソースをプルして競合を上書き",
"force_source_push_default_org_text": "SFDX: デフォルトのスクラッチ組織へソースをプッシュ",
"force_source_push_force_default_org_text": "SFDX: デフォルトのスクラッチ組織へソースをプッシュして競合を上書き",
"project_deploy_start_default_org_text": "SFDX: デフォルトのスクラッチ組織へソースをプッシュ",
"project_deploy_start_ignore_conflicts_default_org_text": "SFDX: デフォルトのスクラッチ組織へソースをプッシュして競合を上書き",
"force_source_retrieve_and_open_display_text": "ソースを取得して開く",
"force_source_retrieve_display_text": "組織からソースを取得",
"force_source_retrieve_in_manifest_text": "SFDX: マニフェストファイルのソースを組織から取得",
Expand All @@ -56,10 +56,10 @@
"org_logout_all_text": "SFDX: すべての認証済み組織からログアウト",
"org_logout_default_text": "SFDX: Log Out from Default Org",
"org_open_default_scratch_org_text": "SFDX: デフォルトの組織を開く",
"override_conflicts_on_push_description": "保存時の force:source:push コマンド実行時に、常に --forceoverwrite オプションを使用するかどうかを指定します。",
"ignore_conflicts_on_push_description": "保存時の project:deploy:start コマンド実行時に、常に --ignore-conflicts オプションを使用するかどうかを指定します。",
"project_generate_text": "SFDX: プロジェクトを作成",
"project_generate_with_manifest_text": "SFDX: マニフェストファイルを使用してプロジェクトを作成",
"push_or_deploy_on_save_enabled_description": "ローカルのソースファイルを保存した際に、自動的に force:source:push コマンド (ソースが追跡される組織) または、force:source:deploy コマンド (ソースが追跡されない組織) を実行するかどうかを指定します。",
"push_or_deploy_on_save_enabled_description": "ローカルのソースファイルを保存した際に、自動的に project:deploy:start コマンド (ソースが追跡される組織) または、force:source:deploy コマンド (ソースが追跡されない組織) を実行するかどうかを指定します。",
"refresh_components_text": "SFDX: コンポーネントを更新",
"refresh_types_text": "SFDX: メタデータ型を更新",
"retrieve_test_code_coverage_text": "Apex テストの実行時にコードカバレッジの結果を計算して取得するかどうかを指定します。",
Expand Down
8 changes: 4 additions & 4 deletions packages/salesforcedx-vscode-core/package.nls.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@
"force_source_deploy_this_source_text": "SFDX: Deploy This Source to Org",
"force_source_pull_default_org_text": "SFDX: Pull Source from Default Org",
"force_source_pull_force_default_org_text": "SFDX: Pull Source from Default Org and Override Conflicts",
"force_source_push_default_org_text": "SFDX: Push Source to Default Org",
"force_source_push_force_default_org_text": "SFDX: Push Source to Default Org and Override Conflicts",
"project_deploy_start_default_org_text": "SFDX: Push Source to Default Org",
"project_deploy_start_ignore_conflicts_default_org_text": "SFDX: Push Source to Default Org and Ignore Conflicts",
"force_source_retrieve_and_open_display_text": "Retrieve and Open Source",
"force_source_retrieve_display_text": "Retrieve Source from Org",
"force_source_retrieve_in_manifest_text": "SFDX: Retrieve Source in Manifest from Org",
Expand Down Expand Up @@ -62,11 +62,11 @@
"org_logout_all_text": "SFDX: Log Out from All Authorized Orgs",
"org_logout_default_text": "SFDX: Log Out from Default Org",
"org_open_default_scratch_org_text": "SFDX: Open Default Org",
"override_conflicts_on_push_description": "Specifies whether to always use --forceoverwrite when you run force:source:push on save",
"ignore_conflicts_on_push_description": "Specifies whether to always use --ignore-conflicts when you run project:deploy:start on save",
"prefer_deploy_on_save_enabled_description": "Specifies whether to always run deploy instead of push when a local source file is saved and `Push or deploy on save` is enabled.",
"project_generate_text": "SFDX: Create Project",
"project_generate_with_manifest_text": "SFDX: Create Project with Manifest",
"push_or_deploy_on_save_enabled_description": "Specifies whether or not to automatically run force:source:push (for source-tracked orgs) or force:source:deploy (for non-source-tracked orgs) when a local source file is saved.",
"push_or_deploy_on_save_enabled_description": "Specifies whether or not to automatically run project:deploy:start (for source-tracked orgs) or force:source:deploy (for non-source-tracked orgs) when a local source file is saved.",
"refresh_components_text": "SFDX: Refresh Components",
"refresh_types_text": "SFDX: Refresh Types",
"retrieve_test_code_coverage_text": "Specifies whether code coverage results are calculated and retrieved when you run Apex tests.",
Expand Down
5 changes: 4 additions & 1 deletion packages/salesforcedx-vscode-core/src/commands/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,10 @@ export {
handleCacheResults
} from './forceSourceDiff';
export { ForceSourcePullExecutor, forceSourcePull } from './forceSourcePull';
export { ForceSourcePushExecutor, forceSourcePush } from './forceSourcePush';
export {
ProjectDeployStartExecutor,
projectDeployStart
} from './projectDeployStart';
export { forceSourceRetrieveManifest } from './forceSourceRetrieveManifest';
export { forceSourceRetrieveCmp } from './forceSourceRetrieveMetadata';
export {
Expand Down
Loading

0 comments on commit 1e86a1a

Please sign in to comment.