From 089fdb4316be40397ccdefa8facc927b65057057 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cristina=20Ca=C3=B1izales?= <113132642+CristiCanizales@users.noreply.github.com> Date: Wed, 7 Feb 2024 16:52:31 +0000 Subject: [PATCH] fix: update pull commands to sf style (#5388) * 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 <139700604+daphne-sfdc@users.noreply.github.com> --- .../src/orgUtils.ts | 8 +-- .../src/cli/index.ts | 5 +- ...ts => projectRetrieveStartResultParser.ts} | 34 ++++++----- .../salesforcedx-vscode-core/package.json | 12 ++-- .../package.nls.ja.json | 10 ++-- .../salesforcedx-vscode-core/package.nls.json | 10 ++-- .../src/commands/index.ts | 13 +++-- .../src/commands/projectDeployStart.ts | 3 +- ...eSourcePull.ts => projectRetrieveStart.ts} | 56 ++++++++++--------- .../commands/util/sfdxCommandletExecutor.ts | 6 +- .../src/conflict/persistentStorageService.ts | 4 +- .../salesforcedx-vscode-core/src/constants.ts | 4 +- .../salesforcedx-vscode-core/src/index.ts | 29 +++++----- .../src/messages/i18n.ja.ts | 12 ++-- .../src/messages/i18n.ts | 10 ++-- .../test/jest/commands/data/testData.ts | 7 +-- ...l.test.ts => projectRetrieveStart.test.ts} | 8 +-- .../test/jest/commands/util/data/testData.ts | 2 +- .../jest/commands/util/sfdxCommandlet.test.ts | 42 +++++++------- .../commands/forceSourcePullInteg.test.ts | 34 ----------- .../projectRetrieveStartInteg.test.ts | 36 ++++++++++++ 21 files changed, 177 insertions(+), 168 deletions(-) rename packages/salesforcedx-utils-vscode/src/cli/parsers/{pullResultParser.ts => projectRetrieveStartResultParser.ts} (53%) rename packages/salesforcedx-vscode-core/src/commands/{forceSourcePull.ts => projectRetrieveStart.ts} (79%) rename packages/salesforcedx-vscode-core/test/jest/commands/{forceSourcePull.test.ts => projectRetrieveStart.test.ts} (78%) delete mode 100644 packages/salesforcedx-vscode-core/test/vscode-integration/commands/forceSourcePullInteg.test.ts create mode 100644 packages/salesforcedx-vscode-core/test/vscode-integration/commands/projectRetrieveStartInteg.test.ts diff --git a/packages/salesforcedx-test-utils-vscode/src/orgUtils.ts b/packages/salesforcedx-test-utils-vscode/src/orgUtils.ts index b02dd9464..5bb32a5b2 100644 --- a/packages/salesforcedx-test-utils-vscode/src/orgUtils.ts +++ b/packages/salesforcedx-test-utils-vscode/src/orgUtils.ts @@ -106,15 +106,15 @@ export const pullSource = async ( ): Promise => { 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); }; diff --git a/packages/salesforcedx-utils-vscode/src/cli/index.ts b/packages/salesforcedx-utils-vscode/src/cli/index.ts index cb75a2ea8..127e7771e 100644 --- a/packages/salesforcedx-utils-vscode/src/cli/index.ts +++ b/packages/salesforcedx-utils-vscode/src/cli/index.ts @@ -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, diff --git a/packages/salesforcedx-utils-vscode/src/cli/parsers/pullResultParser.ts b/packages/salesforcedx-utils-vscode/src/cli/parsers/projectRetrieveStartResultParser.ts similarity index 53% rename from packages/salesforcedx-utils-vscode/src/cli/parsers/pullResultParser.ts rename to packages/salesforcedx-utils-vscode/src/cli/parsers/projectRetrieveStartResultParser.ts index 89fa7542d..40d92f75b 100644 --- a/packages/salesforcedx-utils-vscode/src/cli/parsers/pullResultParser.ts +++ b/packages/salesforcedx-utils-vscode/src/cli/parsers/projectRetrieveStartResultParser.ts @@ -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; @@ -19,23 +19,22 @@ 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) { @@ -43,28 +42,33 @@ export class ForcePullResultParser { 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 } }; } } diff --git a/packages/salesforcedx-vscode-core/package.json b/packages/salesforcedx-vscode-core/package.json index 2d69fc296..b86a18872 100644 --- a/packages/salesforcedx-vscode-core/package.json +++ b/packages/salesforcedx-vscode-core/package.json @@ -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" }, { @@ -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", diff --git a/packages/salesforcedx-vscode-core/package.nls.ja.json b/packages/salesforcedx-vscode-core/package.nls.ja.json index b8a9d62c5..7b0410e78 100644 --- a/packages/salesforcedx-vscode-core/package.nls.ja.json +++ b/packages/salesforcedx-vscode-core/package.nls.ja.json @@ -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: マニフェストファイルのソースを組織から取得", @@ -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 コンポーネントを作成", @@ -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: メタデータ型を更新", diff --git a/packages/salesforcedx-vscode-core/package.nls.json b/packages/salesforcedx-vscode-core/package.nls.json index b2c07aa8b..7ac111b7c 100644 --- a/packages/salesforcedx-vscode-core/package.nls.json +++ b/packages/salesforcedx-vscode-core/package.nls.json @@ -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", @@ -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", @@ -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", diff --git a/packages/salesforcedx-vscode-core/src/commands/index.ts b/packages/salesforcedx-vscode-core/src/commands/index.ts index 8a03720d8..50716db78 100644 --- a/packages/salesforcedx-vscode-core/src/commands/index.ts +++ b/packages/salesforcedx-vscode-core/src/commands/index.ts @@ -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 { @@ -104,6 +99,10 @@ export { getExecutor, orgOpen } from './orgOpen'; +export { + ProjectDeployStartExecutor, + projectDeployStart +} from './projectDeployStart'; export { PathExistsChecker, ProjectNameAndPathAndTemplate, @@ -115,6 +114,10 @@ export { projectTemplateEnum, sfProjectGenerate } from './projectGenerate'; +export { + ProjectRetrieveStartExecutor, + projectRetrieveStart +} from './projectRetrieveStart'; export { viewAllChanges, viewLocalChanges, diff --git a/packages/salesforcedx-vscode-core/src/commands/projectDeployStart.ts b/packages/salesforcedx-vscode-core/src/commands/projectDeployStart.ts index 5ed42036d..41a090b7c 100644 --- a/packages/salesforcedx-vscode-core/src/commands/projectDeployStart.ts +++ b/packages/salesforcedx-vscode-core/src/commands/projectDeployStart.ts @@ -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); diff --git a/packages/salesforcedx-vscode-core/src/commands/forceSourcePull.ts b/packages/salesforcedx-vscode-core/src/commands/projectRetrieveStart.ts similarity index 79% rename from packages/salesforcedx-vscode-core/src/commands/forceSourcePull.ts rename to packages/salesforcedx-vscode-core/src/commands/projectRetrieveStart.ts index 1301b0d40..85344b0d6 100644 --- a/packages/salesforcedx-vscode-core/src/commands/forceSourcePull.ts +++ b/packages/salesforcedx-vscode-core/src/commands/projectRetrieveStart.ts @@ -10,8 +10,8 @@ import { CliCommandExecutor, Command, ContinueResponse, - ForcePullResultParser, - PullResult, + ProjectRetrieveStartResultParser, + ProjectRetrieveStartResult, Row, SfdxCommandBuilder, Table @@ -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, @@ -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( @@ -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) .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(); } @@ -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); @@ -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(); @@ -141,21 +141,21 @@ 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 rows = pulledSource || errors?.files; const tableTitle = !parser.hasConflicts() ? nls.localize(`table_title_${titleType}ed_source`) : undefined; @@ -171,15 +171,17 @@ export class ForceSourcePullExecutor extends SfdxCommandletExecutor<{}> { } if (errors && !parser.hasConflicts()) { - const { name, message, data } = errors; - if (data) { - const outputTable = this.getErrorTable(table, data, titleType); + const { name, message, files } = errors; + if (files) { + const outputTable = this.getErrorTable(table, files, titleType); channelService.appendLine(outputTable); } else if (name && message) { 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 + )}` ); } } @@ -187,11 +189,11 @@ export class ForceSourcePullExecutor extends SfdxCommandletExecutor<{}> { protected getOutputTable( table: Table, - rows: PullResult[] | undefined, + rows: ProjectRetrieveStartResult[] | undefined, 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') }, @@ -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', @@ -222,9 +224,9 @@ export class ForceSourcePullExecutor extends SfdxCommandletExecutor<{}> { const workspaceChecker = new SfdxWorkspaceChecker(); const parameterGatherer = new EmptyParametersGatherer(); -export async function forceSourcePull(this: FlagParameter) { +export async function projectRetrieveStart(this: FlagParameter) { const { flag } = this || {}; - const executor = new ForceSourcePullExecutor(flag, pullCommand); + const executor = new ProjectRetrieveStartExecutor(flag, pullCommand); const commandlet = new SfdxCommandlet( workspaceChecker, parameterGatherer, diff --git a/packages/salesforcedx-vscode-core/src/commands/util/sfdxCommandletExecutor.ts b/packages/salesforcedx-vscode-core/src/commands/util/sfdxCommandletExecutor.ts index 5ee8dbad3..de5a2340a 100644 --- a/packages/salesforcedx-vscode-core/src/commands/util/sfdxCommandletExecutor.ts +++ b/packages/salesforcedx-vscode-core/src/commands/util/sfdxCommandletExecutor.ts @@ -17,7 +17,7 @@ import { import * as vscode from 'vscode'; import { channelService } from '../../channels'; import { - FORCE_SOURCE_PULL_LOG_NAME, + PROJECT_RETRIEVE_START_LOG_NAME, PROJECT_DEPLOY_START_LOG_NAME } from '../../constants'; import { nls } from '../../messages'; @@ -50,7 +50,7 @@ export abstract class SfdxCommandletExecutor // generated later using a parser. if ( !( - commandLogName === FORCE_SOURCE_PULL_LOG_NAME || + commandLogName === PROJECT_RETRIEVE_START_LOG_NAME || commandLogName === PROJECT_DEPLOY_START_LOG_NAME ) ) { @@ -155,7 +155,7 @@ export abstract class SfdxCommandletExecutor /** * Base method (no-op) that is overridden by sub-classes - * projectDeployStart and forceSourcePull to update the local cache's + * projectDeployStart and projectRetrieveStart to update the local cache's * timestamps post-operation, in order to be in sync for the * "Detect Conflicts at Sync" setting. */ diff --git a/packages/salesforcedx-vscode-core/src/conflict/persistentStorageService.ts b/packages/salesforcedx-vscode-core/src/conflict/persistentStorageService.ts index 99ef8f507..0ca72f327 100644 --- a/packages/salesforcedx-vscode-core/src/conflict/persistentStorageService.ts +++ b/packages/salesforcedx-vscode-core/src/conflict/persistentStorageService.ts @@ -6,7 +6,7 @@ */ import { getRootWorkspacePath, - PullResult, + ProjectRetrieveStartResult, ProjectDeployStartResult } from '@salesforce/salesforcedx-utils-vscode'; import { @@ -80,7 +80,7 @@ export class PersistentStorageService { } public setPropertiesForFilesPushPull( - pushOrPullResults: ProjectDeployStartResult[] | PullResult[] + pushOrPullResults: ProjectDeployStartResult[] | ProjectRetrieveStartResult[] ) { const afterPushPullTimestamp = new Date().toISOString(); for (const file of pushOrPullResults) { diff --git a/packages/salesforcedx-vscode-core/src/constants.ts b/packages/salesforcedx-vscode-core/src/constants.ts index 331158043..c43dff21f 100644 --- a/packages/salesforcedx-vscode-core/src/constants.ts +++ b/packages/salesforcedx-vscode-core/src/constants.ts @@ -62,7 +62,7 @@ export const FUNCTIONS_PATH = '/functions/'; // Commands export const ORG_OPEN_COMMAND = 'sfdx.org.open'; -export const FORCE_SOURCE_PULL_LOG_NAME = - 'force_source_pull_default_scratch_org'; +export const PROJECT_RETRIEVE_START_LOG_NAME = + 'project_retrieve_start_default_scratch_org'; export const PROJECT_DEPLOY_START_LOG_NAME = 'project_deploy_start_default_scratch_org'; diff --git a/packages/salesforcedx-vscode-core/src/index.ts b/packages/salesforcedx-vscode-core/src/index.ts index 9606dfa68..f2445e82b 100644 --- a/packages/salesforcedx-vscode-core/src/index.ts +++ b/packages/salesforcedx-vscode-core/src/index.ts @@ -39,8 +39,6 @@ import { forceSourceDeploySourcePaths, forceSourceDiff, forceSourceFolderDiff, - forceSourcePull, - projectDeployStart, forceSourceRetrieveCmp, forceSourceRetrieveManifest, forceSourceRetrieveSourcePaths, @@ -65,7 +63,9 @@ import { orgLogoutAll, orgLogoutDefault, orgOpen, + projectDeployStart, projectGenerateWithManifest, + projectRetrieveStart, sfProjectGenerate, startApexDebugLogging, stopApexDebugLogging, @@ -124,10 +124,6 @@ import { } from './util'; import { OrgAuthInfo } from './util/authInfo'; -const flagOverwrite: FlagParameter = { - flag: '--forceoverwrite' -}; - const flagIgnoreConflicts: FlagParameter = { flag: '--ignore-conflicts' }; @@ -193,19 +189,20 @@ function registerCommands( 'sfdx.force.source.deploy.source.path', forceSourceDeploySourcePaths ); - const forceSourcePullCmd = vscode.commands.registerCommand( - 'sfdx.force.source.pull', - forceSourcePull - ); - const forceSourcePullForceCmd = vscode.commands.registerCommand( - 'sfdx.force.source.pull.force', - forceSourcePull, - flagOverwrite + const projectRetrieveStartCmd = vscode.commands.registerCommand( + 'sfdx.project.retrieve.start', + projectRetrieveStart ); const projectDeployStartCmd = vscode.commands.registerCommand( 'sfdx.project.deploy.start', projectDeployStart ); + const projectRetrieveStartIgnoreConflictsCmd = + vscode.commands.registerCommand( + 'sfdx.project.retrieve.start.ignore.conflicts', + projectRetrieveStart, + flagIgnoreConflicts + ); const projectDeployStartIgnoreConflictsCmd = vscode.commands.registerCommand( 'sfdx.project.deploy.start.ignore.conflicts', projectDeployStart, @@ -411,10 +408,10 @@ function registerCommands( forceSourceDeployInManifestCmd, forceSourceDeployMultipleSourcePathsCmd, forceSourceDeploySourcePathCmd, - forceSourcePullCmd, - forceSourcePullForceCmd, projectDeployStartCmd, projectDeployStartIgnoreConflictsCmd, + projectRetrieveStartCmd, + projectRetrieveStartIgnoreConflictsCmd, forceSourceRetrieveCmd, forceSourceRetrieveCurrentFileCmd, forceSourceRetrieveInManifestCmd, diff --git a/packages/salesforcedx-vscode-core/src/messages/i18n.ja.ts b/packages/salesforcedx-vscode-core/src/messages/i18n.ja.ts index b9983a7cd..273022426 100644 --- a/packages/salesforcedx-vscode-core/src/messages/i18n.ja.ts +++ b/packages/salesforcedx-vscode-core/src/messages/i18n.ja.ts @@ -81,15 +81,15 @@ export const messages = { org_open_container_mode_message_text: '組織 %s にユーザ %s として次の URL: %s を使用してアクセス', - force_source_pull_default_org_text: + project_retrieve_start_default_org_text: 'SFDX: デフォルトのスクラッチ組織からソースをプル', - force_source_pull_force_default_org_text: - 'SFDX: デフォルトのスクラッチ組織からソースをプルして競合を上書き', + project_retrieve_start_ignore_conflicts_default_org_text: + 'SFDX: Pull Source from Default Org and Ignore Conflicts', project_deploy_start_default_org_text: 'SFDX: デフォルトのスクラッチ組織へソースを転送', project_deploy_start_ignore_conflicts_default_org_text: - 'SFDX: デフォルトのスクラッチ組織へソースを転送して競合を上書き', + 'SFDX: Push Source to Default Org and Ignore Conflicts', force_source_deploy_text: 'SFDX: 組織へソースをデプロイ', force_source_deploy_select_file_or_directory: @@ -269,7 +269,9 @@ export const messages = { table_title_pushed_source: 'Pushed Source', table_title_push_errors: 'Push Errors', push_conflicts_error: - '競合のためソースをプッシュできませんでした。組織のメタデータをローカルファイルで上書きしても良い場合は、 "SFDX: ソースをデフォルトのスクラッチ組織にプッシュし競合を上書き" を実行してください。', + 'We couldn’t push your source due to conflicts. Make sure that you want to overwrite the metadata in your org with your local files, then run "SFDX: Push Source to Default Scratch Org and Ignore Conflicts".', + pull_conflicts_error: + 'We couldn’t pull your source due to conflicts. Make sure that you want to overwrite the metadata in your local project, then run "SFDX: Pull Source to Default Scratch Org and Ignore Conflicts".', error_no_default_username: 'デフォルトの組織が設定されていません。"SFDX: デフォルトのスクラッチ組織を作成" または "SFDX: 組織を認証" を実行し組織を設定してください。', error_no_default_devhubusername: diff --git a/packages/salesforcedx-vscode-core/src/messages/i18n.ts b/packages/salesforcedx-vscode-core/src/messages/i18n.ts index 7f8ef7037..c5795e71c 100644 --- a/packages/salesforcedx-vscode-core/src/messages/i18n.ts +++ b/packages/salesforcedx-vscode-core/src/messages/i18n.ts @@ -100,9 +100,9 @@ export const messages = { 'There was an unexpected error when processing the org open response.', org_open_container_mode_message_text: 'Access org %s as user %s with the following URL: %s', - 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_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', 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', @@ -313,9 +313,9 @@ export const messages = { table_title_pushed_source: 'Pushed Source', table_title_push_errors: 'Push Errors', push_conflicts_error: - 'We couldn’t push your source due to conflicts. Make sure that you want to overwrite the metadata in your org with your local files, then run "SFDX: Push Source to Default Scratch Org and Override Conflicts".', + 'We couldn’t push your source due to conflicts. Make sure that you want to overwrite the metadata in your org with your local files, then run "SFDX: Push Source to Default Scratch Org and Ignore Conflicts".', pull_conflicts_error: - 'We couldn’t pull your source due to conflicts. Make sure that you want to overwrite the metadata in your local project, then run "SFDX: Pull Source to Default Scratch Org and Override Conflicts".', + 'We couldn’t pull your source due to conflicts. Make sure that you want to overwrite the metadata in your local project, then run "SFDX: Pull Source to Default Scratch Org and Ignore Conflicts".', error_no_default_username: 'No default org is set. Run "SFDX: Create a Default Scratch Org" or "SFDX: Authorize an Org" to set one.', error_no_default_devhubusername: diff --git a/packages/salesforcedx-vscode-core/test/jest/commands/data/testData.ts b/packages/salesforcedx-vscode-core/test/jest/commands/data/testData.ts index 6d9674aed..a5a4e9786 100644 --- a/packages/salesforcedx-vscode-core/test/jest/commands/data/testData.ts +++ b/packages/salesforcedx-vscode-core/test/jest/commands/data/testData.ts @@ -8,7 +8,7 @@ export const dummyPullResult = { status: 0, result: { - pulledSource: [ + files: [ { state: 'Created', fullName: 'F9', @@ -86,10 +86,7 @@ export const dummyPushResult = { } ] }, - warnings: [ - 'We plan to deprecate this command in the future. Try using the "project deploy start" command instead.', - 'The loglevel flag is no longer in use on this command. You may use it without error, but it will be ignored.\nSet the log level using the `SFDX_LOG_LEVEL` environment variable.' - ] + warnings: [] }; export const dummyStdOut = diff --git a/packages/salesforcedx-vscode-core/test/jest/commands/forceSourcePull.test.ts b/packages/salesforcedx-vscode-core/test/jest/commands/projectRetrieveStart.test.ts similarity index 78% rename from packages/salesforcedx-vscode-core/test/jest/commands/forceSourcePull.test.ts rename to packages/salesforcedx-vscode-core/test/jest/commands/projectRetrieveStart.test.ts index b8d8b7b7f..90e974a58 100644 --- a/packages/salesforcedx-vscode-core/test/jest/commands/forceSourcePull.test.ts +++ b/packages/salesforcedx-vscode-core/test/jest/commands/projectRetrieveStart.test.ts @@ -5,11 +5,11 @@ * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause */ -import { ForceSourcePullExecutor } from '../../../src/commands/forceSourcePull'; +import { ProjectRetrieveStartExecutor } from '../../../src/commands/projectRetrieveStart'; import { PersistentStorageService } from '../../../src/conflict'; import { dummyPullResult } from './data/testData'; -describe('ForceSourcePullExecutor', () => { +describe('ProjectRetrieveStartExecutor', () => { describe('updateCache', () => { const setPropertiesForFilesPushPullMock = jest.fn(); @@ -20,12 +20,12 @@ describe('ForceSourcePullExecutor', () => { }); it('should update the local cache for the pulled source components after pull', async () => { - const pullExecutor = new ForceSourcePullExecutor(); + const pullExecutor = new ProjectRetrieveStartExecutor(); (pullExecutor as any).updateCache(dummyPullResult); expect(setPropertiesForFilesPushPullMock).toHaveBeenCalledWith( - dummyPullResult.result.pulledSource + dummyPullResult.result.files ); }); }); diff --git a/packages/salesforcedx-vscode-core/test/jest/commands/util/data/testData.ts b/packages/salesforcedx-vscode-core/test/jest/commands/util/data/testData.ts index 037c61f53..816c90e04 100644 --- a/packages/salesforcedx-vscode-core/test/jest/commands/util/data/testData.ts +++ b/packages/salesforcedx-vscode-core/test/jest/commands/util/data/testData.ts @@ -6,4 +6,4 @@ */ export const dummyOutputPull = - '{\n "status": 0,\n "result": {\n "pulledSource": [\n {\n "state": "Created",\n "fullName": "F10",\n "type": "ApexClass",\n "filePath": "/Users/kenneth.lewis/scratchpad/NewProj1/force-app/main/default/classes/F10.cls"\n },\n {\n "state": "Created",\n "fullName": "F10",\n "type": "ApexClass",\n "filePath": "/Users/kenneth.lewis/scratchpad/NewProj1/force-app/main/default/classes/F10.cls-meta.xml"\n },\n {\n "state": "Changed",\n "fullName": "Admin",\n "type": "Profile",\n "filePath": "/Users/kenneth.lewis/scratchpad/NewProj1/force-app/main/default/profiles/Admin.profile-meta.xml"\n }\n ]\n },\n "warnings": [\n "We plan to deprecate this command in the future. Try using the \\"project retrieve start\\" command instead.",\n "The loglevel flag is no longer in use on this command. You may use it without error, but it will be ignored.\\nSet the log level using the `SFDX_LOG_LEVEL` environment variable."\n ]\n}\n'; + '{\n "status": 0,\n "result": {\n "files": [\n {\n "state": "Created",\n "fullName": "F10",\n "type": "ApexClass",\n "filePath": "/Users/kenneth.lewis/scratchpad/NewProj1/force-app/main/default/classes/F10.cls"\n },\n {\n "state": "Created",\n "fullName": "F10",\n "type": "ApexClass",\n "filePath": "/Users/kenneth.lewis/scratchpad/NewProj1/force-app/main/default/classes/F10.cls-meta.xml"\n },\n {\n "state": "Changed",\n "fullName": "Admin",\n "type": "Profile",\n "filePath": "/Users/kenneth.lewis/scratchpad/NewProj1/force-app/main/default/profiles/Admin.profile-meta.xml"\n }\n ]\n },\n "warnings": []\n}\n'; diff --git a/packages/salesforcedx-vscode-core/test/jest/commands/util/sfdxCommandlet.test.ts b/packages/salesforcedx-vscode-core/test/jest/commands/util/sfdxCommandlet.test.ts index bdff06967..e69b7a656 100644 --- a/packages/salesforcedx-vscode-core/test/jest/commands/util/sfdxCommandlet.test.ts +++ b/packages/salesforcedx-vscode-core/test/jest/commands/util/sfdxCommandlet.test.ts @@ -4,31 +4,31 @@ * Licensed under the BSD 3-Clause license. * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause */ -import { ForcePullResultParser } from '@salesforce/salesforcedx-utils-vscode'; +import { ProjectRetrieveStartResultParser } from '@salesforce/salesforcedx-utils-vscode'; import { - ForceSourcePullErrorResponse, - ForceSourcePullSuccessResponse -} from '@salesforce/salesforcedx-utils-vscode/src/cli/parsers/pullResultParser'; + ProjectRetrieveStartErrorResponse, + ProjectRetrieveStartSuccessResponse +} from '@salesforce/salesforcedx-utils-vscode/src/cli/parsers/projectRetrieveStartResultParser'; import { channelService } from '../../../../src/channels'; import { - ForceSourcePullExecutor, - ProjectDeployStartExecutor + ProjectDeployStartExecutor, + ProjectRetrieveStartExecutor } from '../../../../src/commands'; import { DeployType } from '../../../../src/commands/projectDeployStart'; import { CommandParams } from '../../../../src/commands/util'; import { PersistentStorageService } from '../../../../src/conflict'; -import { FORCE_SOURCE_PULL_LOG_NAME } from '../../../../src/constants'; +import { PROJECT_RETRIEVE_START_LOG_NAME } from '../../../../src/constants'; import { notificationService } from '../../../../src/notifications'; import { dummyStdOut } from '../data/testData'; import { dummyOutputPull } from './data/testData'; 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 } }; const pushCommand: CommandParams = { @@ -63,7 +63,7 @@ describe('SfdxCommandletExecutor', () => { }); it('should update the local cache for the components that were retrieved after a pull', () => { - const executor = new ForceSourcePullExecutor(undefined, pullCommand); + const executor = new ProjectRetrieveStartExecutor(undefined, pullCommand); const updateCacheAfterPushPullMock = jest.spyOn( executor as any, 'updateCache' @@ -72,7 +72,7 @@ describe('SfdxCommandletExecutor', () => { (executor as any).exitProcessHandlerPull( 0, - { command: { logName: FORCE_SOURCE_PULL_LOG_NAME } }, + { command: { logName: PROJECT_RETRIEVE_START_LOG_NAME } }, '', '', dummyOutputPull @@ -134,15 +134,15 @@ describe('SfdxCommandletExecutor', () => { describe('outputResultPull', () => { it('should output a message to the channel when there are errors and no data', () => { // Arrange - const executor = new ForceSourcePullExecutor(undefined, pullCommand); + const executor = new ProjectRetrieveStartExecutor(undefined, pullCommand); (executor as any).channel = { appendLine: appendLineMock }; const dummyMsg = 'a message'; const dummyName = 'a test name'; - class TestParser extends ForcePullResultParser { - public getErrors(): ForceSourcePullErrorResponse | undefined { + class TestParser extends ProjectRetrieveStartResultParser { + public getErrors(): ProjectRetrieveStartErrorResponse | undefined { return { message: dummyMsg, name: dummyName, @@ -152,7 +152,7 @@ describe('SfdxCommandletExecutor', () => { warnings: [] } as any; } - public getSuccesses(): ForceSourcePullSuccessResponse | undefined { + public getSuccesses(): ProjectRetrieveStartSuccessResponse | undefined { return undefined; } } @@ -169,7 +169,7 @@ describe('SfdxCommandletExecutor', () => { it('should output at least something to the console when there are errors and no data and the response is missing information', () => { // Arrange - const executor = new ForceSourcePullExecutor(undefined, pullCommand); + const executor = new ProjectRetrieveStartExecutor(undefined, pullCommand); (executor as any).channel = { appendLine: appendLineMock }; @@ -177,8 +177,8 @@ describe('SfdxCommandletExecutor', () => { const dummyName = undefined; const consoleLogMock = jest.spyOn(console, 'log'); - class TestParser extends ForcePullResultParser { - public getErrors(): ForceSourcePullErrorResponse | undefined { + class TestParser extends ProjectRetrieveStartResultParser { + public getErrors(): ProjectRetrieveStartErrorResponse | undefined { return { message: dummyMsg, name: dummyName, @@ -188,7 +188,7 @@ describe('SfdxCommandletExecutor', () => { warnings: [] } as any; } - public getSuccesses(): ForceSourcePullSuccessResponse | undefined { + public getSuccesses(): ProjectRetrieveStartSuccessResponse | undefined { return undefined; } } diff --git a/packages/salesforcedx-vscode-core/test/vscode-integration/commands/forceSourcePullInteg.test.ts b/packages/salesforcedx-vscode-core/test/vscode-integration/commands/forceSourcePullInteg.test.ts deleted file mode 100644 index ced7bc0c8..000000000 --- a/packages/salesforcedx-vscode-core/test/vscode-integration/commands/forceSourcePullInteg.test.ts +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (c) 2017, salesforce.com, inc. - * All rights reserved. - * Licensed under the BSD 3-Clause license. - * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause - */ - -import { expect } from 'chai'; -import { ForceSourcePullExecutor } from '../../../src/commands'; -import { nls } from '../../../src/messages'; - -describe('Force Source Pull', () => { - it('Should build the source pull command with the --json flag', async () => { - const sourcePullNoFlag = new ForceSourcePullExecutor(); - const pullCommand = sourcePullNoFlag.build({}); - expect(pullCommand.toCommand()).to.equal( - 'sfdx force:source:pull --json --loglevel fatal' - ); - expect(pullCommand.description).to.equal( - nls.localize('force_source_pull_default_org_text') - ); - }); - - it('Should build the source pull command with overwrite flag', async () => { - const sourcePullOverwrite = new ForceSourcePullExecutor('--forceoverwrite'); - const pullCommand = sourcePullOverwrite.build({}); - expect(pullCommand.toCommand()).to.equal( - 'sfdx force:source:pull --json --loglevel fatal --forceoverwrite' - ); - expect(pullCommand.description).to.equal( - nls.localize('force_source_pull_force_default_org_text') - ); - }); -}); diff --git a/packages/salesforcedx-vscode-core/test/vscode-integration/commands/projectRetrieveStartInteg.test.ts b/packages/salesforcedx-vscode-core/test/vscode-integration/commands/projectRetrieveStartInteg.test.ts new file mode 100644 index 000000000..be3325cb1 --- /dev/null +++ b/packages/salesforcedx-vscode-core/test/vscode-integration/commands/projectRetrieveStartInteg.test.ts @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2017, salesforce.com, inc. + * All rights reserved. + * Licensed under the BSD 3-Clause license. + * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause + */ + +import { expect } from 'chai'; +import { ProjectRetrieveStartExecutor } from '../../../src/commands'; +import { nls } from '../../../src/messages'; + +describe('Project Retrieve Start', () => { + it('Should build the source pull command with the --json flag', async () => { + const projectRetrieveStartNoFlag = new ProjectRetrieveStartExecutor(); + const projectRetrieveStartCommand = projectRetrieveStartNoFlag.build({}); + expect(projectRetrieveStartCommand.toCommand()).to.equal( + 'sfdx project:retrieve:start --json' + ); + expect(projectRetrieveStartCommand.description).to.equal( + nls.localize('project_retrieve_start_default_org_text') + ); + }); + + it('Should build the source pull command with ignore conflicts flag', async () => { + const sourcePullOverwrite = new ProjectRetrieveStartExecutor( + '--ignore-conflicts' + ); + const projectRetrieveStartCommand = sourcePullOverwrite.build({}); + expect(projectRetrieveStartCommand.toCommand()).to.equal( + 'sfdx project:retrieve:start --json --ignore-conflicts' + ); + expect(projectRetrieveStartCommand.description).to.equal( + nls.localize('project_retrieve_start_ignore_conflicts_default_org_text') + ); + }); +});