Skip to content

Commit

Permalink
fix: change org list commands and flags to sf style (#5061)
Browse files Browse the repository at this point in the history
* fix: change org list commands and flags to sf style

* chore: shadowed name tslint error

* chore: sfdx_json_to_stdout to sf_json_to_stdout
  • Loading branch information
CristiCanizales authored Sep 19, 2023
1 parent 42a5d48 commit b340f1d
Show file tree
Hide file tree
Showing 10 changed files with 36 additions and 38 deletions.
6 changes: 3 additions & 3 deletions packages/salesforcedx-vscode-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,7 @@
"when": "sfdx:project_opened"
},
{
"command": "sfdx.force.org.list.clean",
"command": "sfdx.org.list.clean",
"when": "sfdx:project_opened"
},
{
Expand Down Expand Up @@ -768,8 +768,8 @@
"title": "%force_org_display_username_text%"
},
{
"command": "sfdx.force.org.list.clean",
"title": "%force_org_list_clean_text%"
"command": "sfdx.org.list.clean",
"title": "%org_list_clean_text%"
},
{
"command": "sfdx.force.data.soql.query.input",
Expand Down
2 changes: 1 addition & 1 deletion packages/salesforcedx-vscode-core/package.nls.ja.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"force_org_delete_username_text": "SFDX: 組織を削除...",
"force_org_display_default_text": "SFDX: デフォルトの組織の詳細を表示",
"force_org_display_username_text": "SFDX: 組織の詳細を表示...",
"force_org_list_clean_text": "SFDX: 削除済みまたは期限切れの組織を一覧から削除",
"org_list_clean_text": "SFDX: 削除済みまたは期限切れの組織を一覧から削除",
"force_data_soql_query_input_text": "SFDX: SOQL クエリを実行...",
"force_data_soql_query_selection_text": "SFDX: 現在選択されているテキストを使用して SOQL クエリを実行",
"force_package_install_text": "SFDX: パッケージをインストール",
Expand Down
2 changes: 1 addition & 1 deletion packages/salesforcedx-vscode-core/package.nls.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"force_org_delete_username_text": "SFDX: Delete Org...",
"force_org_display_default_text": "SFDX: Display Org Details for Default Org",
"force_org_display_username_text": "SFDX: Display Org Details...",
"force_org_list_clean_text": "SFDX: Remove Deleted and Expired Orgs",
"org_list_clean_text": "SFDX: Remove Deleted and Expired Orgs",
"force_data_soql_query_input_text": "SFDX: Execute SOQL Query...",
"force_data_soql_query_selection_text": "SFDX: Execute SOQL Query with Currently Selected Text",
"force_package_install_text": "SFDX: Install Package",
Expand Down
2 changes: 1 addition & 1 deletion packages/salesforcedx-vscode-core/src/commands/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ export {
handleCacheResults
} from './forceSourceDiff';
export { forceCreateManifest } from './forceCreateManifest';
export { forceOrgList } from './forceOrgList';
export { orgList } from './orgList';
export { forceOrgDelete } from './forceOrgDelete';
export { forceFunctionCreate } from './templates/forceFunctionCreate';
export {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,25 +17,25 @@ import {
SfdxWorkspaceChecker
} from './util';

export class ForceOrgListExecutor extends SfdxCommandletExecutor<{}> {
export class OrgListExecutor extends SfdxCommandletExecutor<{}> {
public build(data: { choice?: string }): Command {
return new SfdxCommandBuilder()
.withDescription(nls.localize('force_org_list_clean_text'))
.withArg('force:org:list')
.withDescription(nls.localize('org_list_clean_text'))
.withArg('org:list')
.withArg('--clean')
.withArg('--noprompt')
.withArg('--no-prompt')
.withLogName('force_org_list_clean')
.build();
}
}

const workspaceChecker = new SfdxWorkspaceChecker();

export async function forceOrgList() {
export async function orgList() {
const parameterGatherer = new PromptConfirmGatherer(
nls.localize('parameter_gatherer_placeholder_org_list_clean')
);
const executor = new ForceOrgListExecutor();
const executor = new OrgListExecutor();
const commandlet = new SfdxCommandlet(
workspaceChecker,
parameterGatherer,
Expand Down
20 changes: 10 additions & 10 deletions packages/salesforcedx-vscode-core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ import {
forceOrgCreate,
forceOrgDelete,
forceOrgDisplay,
forceOrgList,
forcePackageInstall,
forceProjectWithManifestCreate,
forceRefreshSObjects,
Expand All @@ -69,6 +68,7 @@ import {
forceVisualforceComponentCreate,
forceVisualforcePageCreate,
initSObjectDefinitions,
orgList,
orgLoginWeb,
orgLoginWebDevHub,
orgOpen,
Expand Down Expand Up @@ -302,9 +302,9 @@ function registerCommands(
forceOrgDisplay,
{ flag: '--targetusername' }
);
const forceOrgListCleanCmd = vscode.commands.registerCommand(
'sfdx.force.org.list.clean',
forceOrgList
const orgListCleanCmd = vscode.commands.registerCommand(
'sfdx.org.list.clean',
orgList
);
const forceDataSoqlQueryInputCmd = vscode.commands.registerCommand(
'sfdx.force.data.soql.query.input',
Expand Down Expand Up @@ -414,7 +414,6 @@ function registerCommands(
forceOrgCreateCmd,
forceOrgDeleteDefaultCmd,
forceOrgDeleteUsernameCmd,
forceOrgListCleanCmd,
forceRefreshSObjectsCmd,
forceSourceDeleteCmd,
forceSourceDeleteCurrentFileCmd,
Expand Down Expand Up @@ -456,6 +455,7 @@ function registerCommands(
forceStopApexDebugLoggingCmd,
isvDebugBootstrapCmd,
forceConfigSetCmd,
orgListCleanCmd,
orgLoginWebCmd,
orgLoginWebDevHubCmd,
orgOpenCmd
Expand Down Expand Up @@ -499,10 +499,10 @@ function registerInternalDevCommands(
);
}

function registerOrgPickerCommands(orgList: OrgList): vscode.Disposable {
function registerOrgPickerCommands(orgListParam: OrgList): vscode.Disposable {
const forceSetDefaultOrgCmd = vscode.commands.registerCommand(
'sfdx.force.set.default.org',
() => orgList.setDefaultOrg()
() => orgListParam.setDefaultOrg()
);
return vscode.Disposable.from(forceSetDefaultOrgCmd);
}
Expand Down Expand Up @@ -702,8 +702,8 @@ async function initializeProject(extensionContext: vscode.ExtensionContext) {
await WorkspaceContext.getInstance().initialize(extensionContext);

// Register org picker commands
const orgList = new OrgList();
extensionContext.subscriptions.push(registerOrgPickerCommands(orgList));
const newOrgList = new OrgList();
extensionContext.subscriptions.push(registerOrgPickerCommands(newOrgList));

await setupOrgBrowser(extensionContext);
await setupConflictView(extensionContext);
Expand All @@ -714,7 +714,7 @@ async function initializeProject(extensionContext: vscode.ExtensionContext) {
await registerPushOrDeployOnSave();
await decorators.showOrg();

await setUpOrgExpirationWatcher(orgList);
await setUpOrgExpirationWatcher(newOrgList);

// Demo mode decorator
if (isDemoMode()) {
Expand Down
2 changes: 1 addition & 1 deletion packages/salesforcedx-vscode-core/src/messages/i18n.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ export const messages = {
force_org_delete_username_text: 'SFDX: Delete Org...',
force_org_display_default_text: 'SFDX: Display Org Details for Default Org',
force_org_display_username_text: 'SFDX: Display Org Details...',
force_org_list_clean_text: 'SFDX: Remove Deleted and Expired Orgs',
org_list_clean_text: 'SFDX: Remove Deleted and Expired Orgs',
force_debugger_query_session_text: 'query for Apex Debugger session',
force_debugger_stop_text: 'SFDX: Stop Apex Debugger Session',
force_debugger_stop_none_found_text: 'No Apex Debugger session found.',
Expand Down
6 changes: 3 additions & 3 deletions packages/salesforcedx-vscode-core/src/orgPicker/orgList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ export class OrgList implements vscode.Disposable {
'$(plus) ' + nls.localize('org_login_web_authorize_dev_hub_text'),
'$(plus) ' + nls.localize('force_org_create_default_scratch_org_text'),
'$(plus) ' + nls.localize('force_auth_access_token_authorize_org_text'),
'$(plus) ' + nls.localize('force_org_list_clean_text')
'$(plus) ' + nls.localize('org_list_clean_text')
];

const authInfoList = await this.updateOrgList();
Expand Down Expand Up @@ -157,8 +157,8 @@ export class OrgList implements vscode.Disposable {
vscode.commands.executeCommand('sfdx.force.auth.accessToken');
return { type: 'CONTINUE', data: {} };
}
case '$(plus) ' + nls.localize('force_org_list_clean_text'): {
vscode.commands.executeCommand('sfdx.force.org.list.clean');
case '$(plus) ' + nls.localize('org_list_clean_text'): {
vscode.commands.executeCommand('sfdx.org.list.clean');
return { type: 'CONTINUE', data: {} };
}
default: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,18 @@
*/

import { expect } from 'chai';
import { ForceOrgListExecutor } from '../../../src/commands/forceOrgList';
import { OrgListExecutor } from '../../../src/commands/orgList';
import { nls } from '../../../src/messages';

describe('Force Org List', () => {
it('Should build the list command with --clean option', async () => {
const forceOrgList = new ForceOrgListExecutor();
const listCommand = forceOrgList.build({});
const orgList = new OrgListExecutor();
const listCommand = orgList.build({});
expect(listCommand.toCommand()).to.equal(
'sfdx force:org:list --clean --noprompt'
'sfdx org:list --clean --no-prompt'
);
expect(listCommand.description).to.equal(
nls.localize('force_org_list_clean_text')
nls.localize('org_list_clean_text')
);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -377,16 +377,14 @@ describe('orgList Tests', () => {
).to.equal(true);
});

it('should return Continue and call force:org:list:clean command if SFDX: Remove Deleted and Expired Orgs is selected', async () => {
it('should return Continue and call org:list:clean command if SFDX: Remove Deleted and Expired Orgs is selected', async () => {
orgListStub.returns(orgsList);
quickPickStub.returns(
'$(plus) ' + nls.localize('force_org_list_clean_text')
);
quickPickStub.returns('$(plus) ' + nls.localize('org_list_clean_text'));
const response = await orgList.setDefaultOrg();
expect(response.type).to.equal('CONTINUE');
expect(
executeCommandStub.calledWith('sfdx.force.org.list.clean')
).to.equal(true);
expect(executeCommandStub.calledWith('sfdx.org.list.clean')).to.equal(
true
);
});

it('should return Continue and call force:config:set command if a username/alias is selected', async () => {
Expand Down

0 comments on commit b340f1d

Please sign in to comment.