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

fix: update pull commands to sf style #5388

Merged
merged 8 commits into from
Feb 7, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,
PullResult
} from './parsers/projectRetrieveStartResultParser';
export {
CONFLICT_ERROR_NAME,
ProjectDeployStartResultParser,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export interface PullResult {
type: string;
}

export interface ForceSourcePullErrorResponse {
export interface ProjectRetrieveStartErrorResponse {
message: string;
name: string;
data: PullResult[];
Expand All @@ -28,43 +28,43 @@ export interface ForceSourcePullErrorResponse {
warnings: any[];
}

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

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 this.response 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 @@ -82,11 +82,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 @@ -110,6 +105,10 @@ export {
getExecutor,
orgOpen
} from './orgOpen';
export {
ProjectDeployStartExecutor,
projectDeployStart
} from './projectDeployStart';
export {
PathExistsChecker,
ProjectNameAndPathAndTemplate,
Expand All @@ -121,6 +120,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 @@ -21,7 +21,7 @@ import {
import * as vscode from 'vscode';
import { channelService } from '../channels';
import { PersistentStorageService } from '../conflict';
import { FORCE_SOURCE_PUSH_LOG_NAME } from '../constants';
import { PROJECT_DEPLOY_START_LOG_NAME } from '../constants';
import { handleDiagnosticErrors } from '../diagnostics';
import { nls } from '../messages';
import { telemetryService } from '../telemetry';
Expand Down Expand Up @@ -124,7 +124,7 @@ export class ProjectDeployStartExecutor extends SfdxCommandletExecutor<{}> {
cancellationTokenSource: vscode.CancellationTokenSource
/* eslint-enable @typescript-eslint/no-unused-vars */
): Promise<void> {
if (execution.command.logName === FORCE_SOURCE_PUSH_LOG_NAME) {
if (execution.command.logName === PROJECT_DEPLOY_START_LOG_NAME) {
const pushResult = this.parseOutput(stdOut);
if (exitCode === 0) {
this.updateCache(pushResult);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
CliCommandExecutor,
Command,
ContinueResponse,
ForcePullResultParser,
ProjectRetrieveStartResultParser,
PullResult,
Row,
SfdxCommandBuilder,
Expand All @@ -19,7 +19,7 @@ import {
import * as vscode from 'vscode';
import { channelService } from '../channels';
import { PersistentStorageService } from '../conflict';
import { FORCE_SOURCE_PULL_LOG_NAME } from '../constants';
import { PROJECT_RETRIEVE_START_LOG_NAME } from '../constants';
import { nls } from '../messages';
import {
CommandParams,
Expand All @@ -31,15 +31,15 @@ import {
} from './util';

export const pullCommand: CommandParams = {
command: 'force:source:pull',
command: 'project:retrieve:start',
description: {
default: 'force_source_pull_default_org_text',
forceoverwrite: 'force_source_pull_force_default_org_text'
default: 'project_retrieve_start_default_org_text',
ignoreConflicts: 'project_retrieve_start_ignore_conflicts_default_org_text'
},
logName: { default: FORCE_SOURCE_PULL_LOG_NAME }
logName: { default: PROJECT_RETRIEVE_START_LOG_NAME }
};

export class ForceSourcePullExecutor extends SfdxCommandletExecutor<{}> {
export class ProjectRetrieveStartExecutor extends SfdxCommandletExecutor<{}> {
private flag: string | undefined;

public constructor(
Expand All @@ -55,13 +55,13 @@ export class ForceSourcePullExecutor extends SfdxCommandletExecutor<{}> {
const builder = new SfdxCommandBuilder()
.withDescription(nls.localize(this.params.description.default))
.withArg(this.params.command)
.withJson()
.withJson(false)
daphne-sfdc marked this conversation as resolved.
Show resolved Hide resolved
.withLogName(this.params.logName.default);

if (this.flag === '--forceoverwrite') {
if (this.flag === '--ignore-conflicts') {
builder
.withArg(this.flag)
.withDescription(nls.localize(this.params.description.forceoverwrite));
.withDescription(nls.localize(this.params.description.ignoreConflicts));
}
return builder.build();
}
Expand All @@ -72,7 +72,7 @@ export class ForceSourcePullExecutor extends SfdxCommandletExecutor<{}> {
const cancellationToken = cancellationTokenSource.token;
const execution = new CliCommandExecutor(this.build(response.data), {
cwd: this.executionCwd,
env: { SFDX_JSON_TO_STDOUT: 'true' }
env: { SF_JSON_TO_STDOUT: 'true' }
}).execute(cancellationToken);
channelService.streamCommandStartStop(execution);

Expand Down Expand Up @@ -101,12 +101,12 @@ export class ForceSourcePullExecutor extends SfdxCommandletExecutor<{}> {
startTime: [number, number],
output: string
): void {
if (execution.command.logName === FORCE_SOURCE_PULL_LOG_NAME) {
if (execution.command.logName === PROJECT_RETRIEVE_START_LOG_NAME) {
const pullResult = this.parseOutput(output);
if (exitCode === 0) {
this.updateCache(pullResult);
}
const pullParser = new ForcePullResultParser(output);
const pullParser = new ProjectRetrieveStartResultParser(output);
const errors = pullParser.getErrors();
if (errors) {
channelService.showChannelOutput();
Expand Down Expand Up @@ -141,19 +141,19 @@ export class ForceSourcePullExecutor extends SfdxCommandletExecutor<{}> {
* @param pullResult that comes from stdOut after cli pull operation
*/
protected updateCache(pullResult: any): void {
const pulledSource = pullResult.result.pulledSource;
const pulledSource = pullResult.result.files;

const instance = PersistentStorageService.getInstance();
instance.setPropertiesForFilesPushPull(pulledSource);
}

public outputResultPull(parser: ForcePullResultParser) {
public outputResultPull(parser: ProjectRetrieveStartResultParser) {
const table = new Table();
const titleType = 'pull';

const successes = parser.getSuccesses();
const errors = parser.getErrors();
const pulledSource = successes ? successes?.result.pulledSource : undefined;
const pulledSource = successes ? successes?.result.files : undefined;
if (pulledSource || parser.hasConflicts()) {
const rows = pulledSource || errors?.data;
const tableTitle = !parser.hasConflicts()
Expand All @@ -179,7 +179,9 @@ export class ForceSourcePullExecutor extends SfdxCommandletExecutor<{}> {
channelService.appendLine(`${name}: ${message}\n`);
} else {
console.log(
`There were errors parsing the pull operation response. Raw response: ${JSON.stringify(errors)}`
`There were errors parsing the pull operation response. Raw response: ${JSON.stringify(
errors
)}`
);
}
}
Expand All @@ -191,7 +193,7 @@ export class ForceSourcePullExecutor extends SfdxCommandletExecutor<{}> {
outputTableTitle: string | undefined
) {
const outputTable = table.createTable(
(rows as unknown) as Row[],
rows as unknown as Row[],
[
{ key: 'state', label: nls.localize('table_header_state') },
{ key: 'fullName', label: nls.localize('table_header_full_name') },
Expand All @@ -205,7 +207,7 @@ export class ForceSourcePullExecutor extends SfdxCommandletExecutor<{}> {

protected getErrorTable(table: Table, result: unknown, titleType: string) {
const outputTable = table.createTable(
(result ) as Row[],
result as Row[],
[
{
key: 'filePath',
Expand All @@ -222,9 +224,9 @@ export class ForceSourcePullExecutor extends SfdxCommandletExecutor<{}> {
const workspaceChecker = new SfdxWorkspaceChecker();
const parameterGatherer = new EmptyParametersGatherer();

export async function forceSourcePull(this: FlagParameter<string>) {
export async function projectRetrieveStart(this: FlagParameter<string>) {
const { flag } = this || {};
const executor = new ForceSourcePullExecutor(flag, pullCommand);
const executor = new ProjectRetrieveStartExecutor(flag, pullCommand);
const commandlet = new SfdxCommandlet(
workspaceChecker,
parameterGatherer,
Expand Down
Loading
Loading