Skip to content

Commit

Permalink
fix: change delete source commands and flags to sf style (#5060)
Browse files Browse the repository at this point in the history
* fix: change delete source commands and flags to sf style

* chore: remove project from commands

* chore: reorder funcs
  • Loading branch information
CristiCanizales authored Sep 19, 2023
1 parent dd837db commit 3df63eb
Show file tree
Hide file tree
Showing 10 changed files with 51 additions and 51 deletions.
16 changes: 8 additions & 8 deletions packages/salesforcedx-vscode-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@
"when": "sfdx:project_opened && resourceLangId == 'forcesourcemanifest'"
},
{
"command": "sfdx.force.source.delete.current.file",
"command": "sfdx.delete.source.current.file",
"when": "sfdx:project_opened && resourceLangId != 'forcesourcemanifest'"
},
{
Expand Down Expand Up @@ -319,7 +319,7 @@
"when": "sfdx:project_opened && resourceLangId == 'forcesourcemanifest'"
},
{
"command": "sfdx.force.source.delete",
"command": "sfdx.delete.source",
"when": "sfdx:project_opened && resourceLangId != 'forcesourcemanifest'"
},
{
Expand Down Expand Up @@ -513,7 +513,7 @@
"when": "sfdx:project_opened && resourceLangId == 'forcesourcemanifest'"
},
{
"command": "sfdx.force.source.delete",
"command": "sfdx.delete.source",
"when": "false"
},
{
Expand All @@ -529,7 +529,7 @@
"when": "sfdx:project_opened"
},
{
"command": "sfdx.force.source.delete.current.file",
"command": "sfdx.delete.source.current.file",
"when": "sfdx:project_opened && resourceLangId != 'forcesourcemanifest' && editorIsOpen"
},
{
Expand Down Expand Up @@ -828,12 +828,12 @@
"title": "%force_source_deploy_in_manifest_text%"
},
{
"command": "sfdx.force.source.delete",
"title": "%force_source_delete_text%"
"command": "sfdx.delete.source",
"title": "%delete_source_text%"
},
{
"command": "sfdx.force.source.delete.current.file",
"title": "%force_source_delete_this_source_text%"
"command": "sfdx.delete.source.current.file",
"title": "%delete_source_this_source_text%"
},
{
"command": "sfdx.force.set.default.org",
Expand Down
4 changes: 2 additions & 2 deletions packages/salesforcedx-vscode-core/package.nls.ja.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@
"force_source_deploy_text": "SFDX: 組織へソースをデプロイ",
"force_source_deploy_this_source_text": "SFDX: このソースを組織へデプロイ",
"force_source_deploy_in_manifest_text": "SFDX: マニフェストファイルのソースを組織へデプロイ",
"force_source_delete_text": "SFDX: プロジェクトおよび組織から削除",
"force_source_delete_this_source_text": "SFDX: このソースをプロジェクトと組織から削除",
"delete_source_text": "SFDX: プロジェクトおよび組織から削除",
"delete_source_this_source_text": "SFDX: このソースをプロジェクトと組織から削除",
"force_config_set_org_text": "SFDX: デフォルトの組織を設定",
"refresh_types_text": "メタデータ型を更新",
"refresh_components_text": "コンポーネントを更新",
Expand Down
4 changes: 2 additions & 2 deletions packages/salesforcedx-vscode-core/package.nls.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@
"force_source_deploy_text": "SFDX: Deploy Source to Org",
"force_source_deploy_this_source_text": "SFDX: Deploy This Source to Org",
"force_source_deploy_in_manifest_text": "SFDX: Deploy Source in Manifest to Org",
"force_source_delete_text": "SFDX: Delete from Project and Org",
"force_source_delete_this_source_text": "SFDX: Delete This from Project and Org",
"delete_source_text": "SFDX: Delete from Project and Org",
"delete_source_this_source_text": "SFDX: Delete This from Project and Org",
"force_config_set_org_text": "SFDX: Set a Default Org",
"refresh_types_text": "Refresh Types",
"refresh_components_text": "Refresh Components",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import { workspaceUtils } from '../util';
import { SfdxCommandlet } from './util/sfdxCommandlet';
import { SfdxCommandletExecutor } from './util/sfdxCommandletExecutor';

export class ForceSourceDeleteExecutor extends SfdxCommandletExecutor<{
export class DeleteSourceExecutor extends SfdxCommandletExecutor<{
filePath: string;
}> {
private isSourceTracked: boolean;
Expand All @@ -38,13 +38,13 @@ export class ForceSourceDeleteExecutor extends SfdxCommandletExecutor<{
}
public build(data: { filePath: string }): Command {
const commandBuilder = new SfdxCommandBuilder()
.withDescription(nls.localize('force_source_delete_text'))
.withArg('force:source:delete')
.withDescription(nls.localize('delete_source_text'))
.withArg('project:delete:source')
.withLogName('force_source_delete')
.withFlag('--sourcepath', data.filePath)
.withArg('--noprompt');
.withFlag('--source-dir', data.filePath)
.withArg('--no-prompt');
if (this.isSourceTracked) {
commandBuilder.args.push('--tracksource');
commandBuilder.args.push('--track-source');
}
return commandBuilder.build();
}
Expand All @@ -64,7 +64,7 @@ export class ManifestChecker implements PreconditionChecker {
const isManifestFile = this.explorerPath.includes(manifestPath);
if (isManifestFile) {
notificationService.showErrorMessage(
nls.localize('force_source_delete_manifest_unsupported_message')
nls.localize('delete_source_manifest_unsupported_message')
);
return false;
}
Expand All @@ -87,7 +87,7 @@ export class ConfirmationAndSourcePathGatherer
public async gather(): Promise<
CancelResponse | ContinueResponse<{ filePath: string }>
> {
const prompt = nls.localize('force_source_delete_confirmation_message');
const prompt = nls.localize('delete_source_confirmation_message');
const response = await vscode.window.showInformationMessage(
prompt,
this.PROCEED,
Expand All @@ -100,7 +100,7 @@ export class ConfirmationAndSourcePathGatherer
}
}

export async function forceSourceDelete(sourceUri: vscode.Uri) {
export async function deleteSource(sourceUri: vscode.Uri) {
let isSourceTracked: boolean = false;
const orgType = await workspaceContextUtils.getWorkspaceOrgType();
if (orgType === OrgType.SourceTracked) {
Expand All @@ -112,7 +112,7 @@ export async function forceSourceDelete(sourceUri: vscode.Uri) {
sourceUri = editor.document.uri;
} else {
const errorMessage = nls.localize(
'force_source_delete_select_file_or_directory'
'delete_source_select_file_or_directory'
);
telemetryService.sendException('force_source_delete', errorMessage);
notificationService.showErrorMessage(errorMessage);
Expand All @@ -125,7 +125,7 @@ export async function forceSourceDelete(sourceUri: vscode.Uri) {
const commandlet = new SfdxCommandlet(
manifestChecker,
new ConfirmationAndSourcePathGatherer(sourceUri),
new ForceSourceDeleteExecutor(isSourceTracked)
new DeleteSourceExecutor(isSourceTracked)
);
await commandlet.run();
}
6 changes: 3 additions & 3 deletions packages/salesforcedx-vscode-core/src/commands/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,11 @@ export {
getExecutor
} from './orgOpen';
export {
forceSourceDelete,
deleteSource,
ConfirmationAndSourcePathGatherer,
ForceSourceDeleteExecutor,
DeleteSourceExecutor,
ManifestChecker
} from './forceSourceDelete';
} from './deleteSource';
export { forceSourceDeployManifest } from './forceSourceDeployManifest';
export {
forceSourceDeploySourcePaths,
Expand Down
18 changes: 9 additions & 9 deletions packages/salesforcedx-vscode-core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import * as vscode from 'vscode';
import { channelService } from './channels';
import {
checkSObjectsAndRefresh,
deleteSource,
forceAliasList,
forceAnalyticsTemplateCreate,
forceApexClassCreate,
Expand Down Expand Up @@ -52,7 +53,6 @@ import {
forceRefreshSObjects,
forceRenameLightningComponent,
forceSfdxProjectCreate,
forceSourceDelete,
forceSourceDeployManifest,
forceSourceDeploySourcePaths,
forceSourceDiff,
Expand Down Expand Up @@ -155,13 +155,13 @@ function registerCommands(
forceOrgCreate
);
const orgOpenCmd = vscode.commands.registerCommand(ORG_OPEN_COMMAND, orgOpen);
const forceSourceDeleteCmd = vscode.commands.registerCommand(
'sfdx.force.source.delete',
forceSourceDelete
const deleteSourceCmd = vscode.commands.registerCommand(
'sfdx.delete.source',
deleteSource
);
const forceSourceDeleteCurrentFileCmd = vscode.commands.registerCommand(
'sfdx.force.source.delete.current.file',
forceSourceDelete
const deleteSourceCurrentFileCmd = vscode.commands.registerCommand(
'sfdx.delete.source.current.file',
deleteSource
);
const forceSourceDeployCurrentSourceFileCmd = vscode.commands.registerCommand(
'sfdx.force.source.deploy.current.source.file',
Expand Down Expand Up @@ -415,8 +415,8 @@ function registerCommands(
forceOrgDeleteDefaultCmd,
forceOrgDeleteUsernameCmd,
forceRefreshSObjectsCmd,
forceSourceDeleteCmd,
forceSourceDeleteCurrentFileCmd,
deleteSourceCmd,
deleteSourceCurrentFileCmd,
forceSourceDeployCurrentSourceFileCmd,
forceSourceDeployInManifestCmd,
forceSourceDeployMultipleSourcePathsCmd,
Expand Down
8 changes: 4 additions & 4 deletions packages/salesforcedx-vscode-core/src/messages/i18n.ja.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,12 +103,12 @@ export const messages = {
'ソースファイルかディレクトリ上でのみ SFDX: 組織からソースを取得 を実行できます。',
force_source_retrieve_select_manifest:
'マニフェストファイル上でのみ SFDX: マニフェストのソースを組織から取得 を実行できます。',
force_source_delete_text: 'SFDX: プロジェクトおよび組織から削除',
force_source_delete_manifest_unsupported_message:
delete_source_text: 'SFDX: プロジェクトおよび組織から削除',
delete_source_manifest_unsupported_message:
'SFDX: 組織およびプロジェクトから削除 はマニフェストファイルでサポートされていません。削除するソースファイルやディレクトリを選択してください。',
force_source_delete_select_file_or_directory:
delete_source_select_file_or_directory:
'ソースファイルかディレクトリ上でのみ SFDX: プロジェクトおよび組織から削除 を実行できます。',
force_source_delete_confirmation_message:
delete_source_confirmation_message:
'ソースファイルを削除すると、コンピュータからファイルが削除され、デフォルトの組織から対応するメタデータが取り除かれます。このソースをプロジェクトおよび組織から削除してもよろしいですか?',
confirm_delete_source_button_text: 'ソースを削除',
cancel_delete_source_button_text: 'キャンセル',
Expand Down
8 changes: 4 additions & 4 deletions packages/salesforcedx-vscode-core/src/messages/i18n.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,12 +120,12 @@ export const messages = {
'You can run SFDX: Retrieve Source from Org only on a source file or directory.',
force_source_retrieve_select_manifest:
'You can run SFDX: Retrieve Source in Manifest from Org only on a manifest file.',
force_source_delete_text: 'SFDX: Delete from Project and Org',
force_source_delete_manifest_unsupported_message:
delete_source_text: 'SFDX: Delete from Project and Org',
delete_source_manifest_unsupported_message:
'SFDX: Delete from Project and Org is not supported for manifest files. Select a source file or directory to delete.',
force_source_delete_select_file_or_directory:
delete_source_select_file_or_directory:
'You can run SFDX: Delete from Project and Org only on a source file or directory.',
force_source_delete_confirmation_message:
delete_source_confirmation_message:
'Deleting source files deletes the files from your computer and removes the corresponding metadata from your default org. Are you sure you want to delete this source from your project and your org?',
confirm_delete_source_button_text: 'Delete Source',
cancel_delete_source_button_text: 'Cancel',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,27 @@
*/

import * as path from 'path';
import { ForceSourceDeleteExecutor } from '../../../../src/commands';
import { DeleteSourceExecutor } from '../../../../src/commands';

describe('Force Source Delete', () => {
describe('Project Delete Source', () => {
let isSourceTracked: boolean;
const sourcePath: string = path.join('example', 'path');

it('Should build the source delete command with --tracksource flag when connected to a source-tracked org', () => {
it('Should build the delete source command with --track-source flag when connected to a source-tracked org', () => {
isSourceTracked = true;
const executor = new ForceSourceDeleteExecutor(isSourceTracked);
const executor = new DeleteSourceExecutor(isSourceTracked);
const sourceDeleteCommand = executor.build({ filePath: sourcePath });
expect(sourceDeleteCommand.toCommand()).toEqual(
`sfdx force:source:delete --sourcepath ${sourcePath} --noprompt --tracksource`
`sfdx project:delete:source --source-dir ${sourcePath} --no-prompt --track-source`
);
});

it('Should build the source delete command without --tracksource flag when connected to a non-source-tracked org', () => {
it('Should build the delete source command without --track-source flag when connected to a non-source-tracked org', () => {
isSourceTracked = false;
const executor = new ForceSourceDeleteExecutor(isSourceTracked);
const executor = new DeleteSourceExecutor(isSourceTracked);
const sourceDeleteCommand = executor.build({ filePath: sourcePath });
expect(sourceDeleteCommand.toCommand()).toEqual(
`sfdx force:source:delete --sourcepath ${sourcePath} --noprompt`
`sfdx project:delete:source --source-dir ${sourcePath} --no-prompt`
);
});
});

0 comments on commit 3df63eb

Please sign in to comment.