Skip to content
This repository has been archived by the owner on Mar 13, 2024. It is now read-only.

Commit

Permalink
fix: update pull commands to sf style (#5388)
Browse files Browse the repository at this point in the history
* fix: update pull commands to sf style

* chore: labels

* chore: modify test data

* chore: fix constant for conflicts

* chore: final changes

---------

Co-authored-by: Daphne Yang <[email protected]>
  • Loading branch information
CristiCanizales and daphne-sfdc authored Feb 7, 2024
1 parent 7cf4bf9 commit 089fdb4
Show file tree
Hide file tree
Showing 21 changed files with 177 additions and 168 deletions.
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 @@ -106,15 +106,15 @@ export const pullSource = async (
): Promise<string> => {
const execution = new CliCommandExecutor(
new SfdxCommandBuilder()
.withArg('force:source:pull')
.withFlag('--targetusername', username)
.withJson()
.withArg('project:retrieve: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.pulledSource;
const source = JSON.parse(result).result.files;
return Promise.resolve(source);
};

Expand Down
5 changes: 4 additions & 1 deletion packages/salesforcedx-utils-vscode/src/cli/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,10 @@ export {
OrgOpenErrorResult,
OrgOpenSuccessResult
} from './orgOpenContainerResultParser';
export { ForcePullResultParser, PullResult } from './parsers/pullResultParser';
export {
ProjectRetrieveStartResultParser,
ProjectRetrieveStartResult
} from './parsers/projectRetrieveStartResultParser';
export {
CONFLICT_ERROR_NAME,
ProjectDeployStartResultParser,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@

import { extractJsonObject } from '../../helpers';

export const CONFLICT_ERROR_NAME = 'sourceConflictDetected';
export const CONFLICT_ERROR_NAME = 'SourceConflictError';

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

export interface ForceSourcePullErrorResponse {
export interface ProjectRetrieveStartErrorResponse {
message: string;
name: string;
data: PullResult[];
stack: string;
status: number;
files: ProjectRetrieveStartResult[];
warnings: any[];
}

export interface ForceSourcePullSuccessResponse {
export interface ProjectRetrieveStartSuccessResponse {
status: number;
result: {
pulledSource: PullResult[];
files: ProjectRetrieveStartResult[];
};
}

export class ForcePullResultParser {
export class ProjectRetrieveStartResultParser {
private response: any;

constructor(stdout: string) {
try {
this.response = extractJsonObject(stdout);
} catch (e) {
const err = new Error('Error parsing pull result');
err.name = 'PullParserFail';
err.name = 'ProjectRetrieveStartParserFail';
throw err;
}
}

public getErrors(): ForceSourcePullErrorResponse | undefined {
public getErrors(): ProjectRetrieveStartErrorResponse | undefined {
if (this.response.status === 1) {
return this.response as ForceSourcePullErrorResponse;
return {
message: this.response.message ?? 'Pull failed. ',
name: this.response.name ?? 'RetrieveFailed',
status: this.response.status,
files: this.response.data ?? this.response.result.files
} as ProjectRetrieveStartErrorResponse;
}
}

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

Expand Down
12 changes: 6 additions & 6 deletions packages/salesforcedx-vscode-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -376,11 +376,11 @@
"when": "sfdx:project_opened"
},
{
"command": "sfdx.force.source.pull",
"command": "sfdx.project.retrieve.start",
"when": "sfdx:project_opened && !sfdx:isv_debug_project && sfdx:default_username_has_change_tracking"
},
{
"command": "sfdx.force.source.pull.force",
"command": "sfdx.project.retrieve.start.ignore.conflicts",
"when": "sfdx:project_opened && !sfdx:isv_debug_project && sfdx:default_username_has_change_tracking"
},
{
Expand Down Expand Up @@ -655,12 +655,12 @@
"title": "%org_open_default_scratch_org_text%"
},
{
"command": "sfdx.force.source.pull",
"title": "%force_source_pull_default_org_text%"
"command": "sfdx.project.retrieve.start",
"title": "%project_retrieve_start_default_org_text%"
},
{
"command": "sfdx.force.source.pull.force",
"title": "%force_source_pull_force_default_org_text%"
"command": "sfdx.project.retrieve.start.ignore.conflicts",
"title": "%project_retrieve_start_ignore_conflicts_default_org_text%"
},
{
"command": "sfdx.project.deploy.start",
Expand Down
10 changes: 5 additions & 5 deletions packages/salesforcedx-vscode-core/package.nls.ja.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,6 @@
"force_source_deploy_in_manifest_text": "SFDX: マニフェストファイルのソースを組織へデプロイ",
"force_source_deploy_text": "SFDX: 組織へソースをデプロイ",
"force_source_deploy_this_source_text": "SFDX: このソースを組織へデプロイ",
"force_source_pull_default_org_text": "SFDX: デフォルトのスクラッチ組織からソースをプル",
"force_source_pull_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 @@ -38,6 +34,7 @@
"force_source_status_local_text": "SFDX: ローカルの変更を表示",
"force_source_status_remote_text": "SFDX: デフォルトのスクラッチ組織内の変更を表示",
"force_source_status_text": "SFDX: すべての変更を表示 (ローカルとデフォルトのスクラッチ組織内)",
"ignore_conflicts_on_push_description": "保存時の project:deploy:start コマンド実行時に、常に --ignore-conflicts オプションを使用するかどうかを指定します。",
"isv_bootstrap_command_text": "SFDX: ISV デバッグ用のプロジェクトを新規作成し設定",
"lightning_generate_app_text": "SFDX: Aura アプリケーションを作成",
"lightning_generate_aura_component_text": "SFDX: Aura コンポーネントを作成",
Expand All @@ -56,9 +53,12 @@
"org_logout_all_text": "SFDX: すべての認証済み組織からログアウト",
"org_logout_default_text": "SFDX: Log Out from Default Org",
"org_open_default_scratch_org_text": "SFDX: デフォルトの組織を開く",
"ignore_conflicts_on_push_description": "保存時の project:deploy:start コマンド実行時に、常に --ignore-conflicts オプションを使用するかどうかを指定します。",
"project_deploy_start_default_org_text": "SFDX: デフォルトのスクラッチ組織へソースをプッシュ",
"project_deploy_start_ignore_conflicts_default_org_text": "SFDX: Push Source to Default Org and Ignore Conflicts",
"project_generate_text": "SFDX: プロジェクトを作成",
"project_generate_with_manifest_text": "SFDX: マニフェストファイルを使用してプロジェクトを作成",
"project_retrieve_start_default_org_text": "SFDX: デフォルトのスクラッチ組織からソースをプル",
"project_retrieve_start_ignore_conflicts_default_org_text": "SFDX: Pull Source from Default Org and Ignore Conflicts",
"push_or_deploy_on_save_enabled_description": "ローカルのソースファイルを保存した際に、自動的に project:deploy:start コマンド (ソースが追跡される組織) または、force:source:deploy コマンド (ソースが追跡されない組織) を実行するかどうかを指定します。",
"refresh_components_text": "SFDX: コンポーネントを更新",
"refresh_types_text": "SFDX: メタデータ型を更新",
Expand Down
10 changes: 5 additions & 5 deletions packages/salesforcedx-vscode-core/package.nls.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,6 @@
"force_source_deploy_in_manifest_text": "SFDX: Deploy Source in Manifest to Org",
"force_source_deploy_text": "SFDX: Deploy Source to Org",
"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",
"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 All @@ -43,6 +39,7 @@
"force_source_status_local_text": "SFDX: View Local Changes",
"force_source_status_remote_text": "SFDX: View Changes in Default Org",
"force_source_status_text": "SFDX: View All Changes (Local and in Default Org)",
"ignore_conflicts_on_push_description": "Specifies whether to always use --ignore-conflicts when you run project:deploy:start on save",
"isv_bootstrap_command_text": "SFDX: Create and Set Up Project for ISV Debugging",
"lightning_generate_app_text": "SFDX: Create Aura App",
"lightning_generate_aura_component_text": "SFDX: Create Aura Component",
Expand All @@ -62,10 +59,13 @@
"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",
"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_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",
"project_generate_text": "SFDX: Create Project",
"project_generate_with_manifest_text": "SFDX: Create Project with Manifest",
"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 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",
Expand Down
13 changes: 8 additions & 5 deletions packages/salesforcedx-vscode-core/src/commands/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,6 @@ export {
forceSourceFolderDiff,
handleCacheResults
} from './forceSourceDiff';
export { ForceSourcePullExecutor, forceSourcePull } from './forceSourcePull';
export {
ProjectDeployStartExecutor,
projectDeployStart
} from './projectDeployStart';
export { forceSourceRetrieveManifest } from './forceSourceRetrieveManifest';
export { forceSourceRetrieveCmp } from './forceSourceRetrieveMetadata';
export {
Expand All @@ -104,6 +99,10 @@ export {
getExecutor,
orgOpen
} from './orgOpen';
export {
ProjectDeployStartExecutor,
projectDeployStart
} from './projectDeployStart';
export {
PathExistsChecker,
ProjectNameAndPathAndTemplate,
Expand All @@ -115,6 +114,10 @@ export {
projectTemplateEnum,
sfProjectGenerate
} from './projectGenerate';
export {
ProjectRetrieveStartExecutor,
projectRetrieveStart
} from './projectRetrieveStart';
export {
viewAllChanges,
viewLocalChanges,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,8 +207,7 @@ export class ProjectDeployStartExecutor extends SfdxCommandletExecutor<{}> {
}

if (errors && !parser.hasConflicts()) {
const { name, message } = errors;
const files = errors.files;
const { name, message, files } = errors;
if (files) {
const outputTable = this.getErrorTable(table, files, titleType);
channelService.appendLine(outputTable);
Expand Down
Loading

0 comments on commit 089fdb4

Please sign in to comment.