From 5afea2251bd30260a45ff3d1e2b2a6d587ce4d1f Mon Sep 17 00:00:00 2001 From: CristiCanizales Date: Sun, 3 Sep 2023 15:58:33 -0300 Subject: [PATCH 1/2] fix: change org logout commands and flags to sf style --- .../salesforcedx-vscode-core/package.json | 12 +++---- .../package.nls.ja.json | 4 +-- .../salesforcedx-vscode-core/package.nls.json | 4 +-- .../src/commands/auth/authParamsGatherer.ts | 4 +-- .../src/commands/auth/forceAuthWebLogin.ts | 4 +-- .../auth/{forceAuthLogout.ts => orgLogout.ts} | 26 ++++++++-------- .../src/commands/index.ts | 6 +--- .../salesforcedx-vscode-core/src/index.ts | 20 ++++++------ .../src/messages/i18n.ja.ts | 10 +++--- .../src/messages/i18n.ts | 10 +++--- ...ceAuthLogout.test.ts => orgLogout.test.ts} | 31 +++++++++---------- 11 files changed, 62 insertions(+), 69 deletions(-) rename packages/salesforcedx-vscode-core/src/commands/auth/{forceAuthLogout.ts => orgLogout.ts} (84%) rename packages/salesforcedx-vscode-core/test/vscode-integration/commands/auth/{forceAuthLogout.test.ts => orgLogout.test.ts} (89%) diff --git a/packages/salesforcedx-vscode-core/package.json b/packages/salesforcedx-vscode-core/package.json index 68533e0c6f..5654b22053 100644 --- a/packages/salesforcedx-vscode-core/package.json +++ b/packages/salesforcedx-vscode-core/package.json @@ -353,11 +353,11 @@ "when": "sfdx:project_opened" }, { - "command": "sfdx.force.auth.logout.all", + "command": "sfdx.org.logout.all", "when": "sfdx:project_opened" }, { - "command": "sfdx.force.auth.logout.default", + "command": "sfdx.org.logout.default", "when": "sfdx:project_opened && sfdx:has_default_username" }, { @@ -640,12 +640,12 @@ "title": "%force_auth_access_token_authorize_org_text%" }, { - "command": "sfdx.force.auth.logout.all", - "title": "%force_auth_logout_all_text%" + "command": "sfdx.org.logout.all", + "title": "%org_logout_all_text%" }, { - "command": "sfdx.force.auth.logout.default", - "title": "%force_auth_logout_default_text%" + "command": "sfdx.org.logout.default", + "title": "%org_logout_default_text%" }, { "command": "sfdx.force.open.documentation", diff --git a/packages/salesforcedx-vscode-core/package.nls.ja.json b/packages/salesforcedx-vscode-core/package.nls.ja.json index 7dbd869831..29dd730569 100644 --- a/packages/salesforcedx-vscode-core/package.nls.ja.json +++ b/packages/salesforcedx-vscode-core/package.nls.ja.json @@ -3,8 +3,8 @@ "force_auth_web_login_authorize_dev_hub_text": "SFDX: Dev Hub を認証", "force_auth_web_login_authorize_org_text": "SFDX: 組織を認証", "force_auth_access_token_authorize_org_text": "SFDX: Authorize an Org using Session ID", - "force_auth_logout_all_text": "SFDX: すべての認証済み組織からログアウト", - "force_auth_logout_default_text": "SFDX: Log Out from Default Org", + "org_logout_all_text": "SFDX: すべての認証済み組織からログアウト", + "org_logout_default_text": "SFDX: Log Out from Default Org", "force_org_create_default_scratch_org_text": "SFDX: デフォルトのスクラッチ組織を作成...", "force_org_open_default_scratch_org_text": "SFDX: デフォルトの組織を開く", "force_source_pull_default_org_text": "SFDX: デフォルトのスクラッチ組織からソースをプル", diff --git a/packages/salesforcedx-vscode-core/package.nls.json b/packages/salesforcedx-vscode-core/package.nls.json index b2e607fa47..e7f891eac4 100644 --- a/packages/salesforcedx-vscode-core/package.nls.json +++ b/packages/salesforcedx-vscode-core/package.nls.json @@ -3,8 +3,8 @@ "force_auth_web_login_authorize_dev_hub_text": "SFDX: Authorize a Dev Hub", "force_auth_web_login_authorize_org_text": "SFDX: Authorize an Org", "force_auth_access_token_authorize_org_text": "SFDX: Authorize an Org using Session ID", - "force_auth_logout_all_text": "SFDX: Log Out from All Authorized Orgs", - "force_auth_logout_default_text": "SFDX: Log Out from Default Org", + "org_logout_all_text": "SFDX: Log Out from All Authorized Orgs", + "org_logout_default_text": "SFDX: Log Out from Default Org", "force_open_documentation_text": "SFDX: Open Documentation", "force_org_create_default_scratch_org_text": "SFDX: Create a Default Scratch Org...", "force_org_open_default_scratch_org_text": "SFDX: Open Default Org", diff --git a/packages/salesforcedx-vscode-core/src/commands/auth/authParamsGatherer.ts b/packages/salesforcedx-vscode-core/src/commands/auth/authParamsGatherer.ts index 9d17ead01a..ccfe28e60f 100644 --- a/packages/salesforcedx-vscode-core/src/commands/auth/authParamsGatherer.ts +++ b/packages/salesforcedx-vscode-core/src/commands/auth/authParamsGatherer.ts @@ -202,10 +202,10 @@ export class ScratchOrgLogoutParamsGatherer public async gather(): Promise> { const prompt = nls.localize( - 'auth_logout_scratch_prompt', + 'org_logout_scratch_prompt', this.alias || this.username ); - const logoutResponse = nls.localize('auth_logout_scratch_logout'); + const logoutResponse = nls.localize('org_logout_scratch_logout'); const confirm = await vscode.window.showInformationMessage( prompt, diff --git a/packages/salesforcedx-vscode-core/src/commands/auth/forceAuthWebLogin.ts b/packages/salesforcedx-vscode-core/src/commands/auth/forceAuthWebLogin.ts index d16e1d8c40..38b5b981fd 100644 --- a/packages/salesforcedx-vscode-core/src/commands/auth/forceAuthWebLogin.ts +++ b/packages/salesforcedx-vscode-core/src/commands/auth/forceAuthWebLogin.ts @@ -37,7 +37,7 @@ import { SfdxWorkspaceChecker } from '../util'; import { AuthParams, AuthParamsGatherer } from './authParamsGatherer'; -import { ForceAuthLogoutAll } from './forceAuthLogout'; +import { OrgLogoutAll } from './orgLogout'; export interface DeviceCodeResponse { user_code: string; @@ -230,7 +230,7 @@ export async function promptLogOutForProdOrg() { await new SfdxCommandlet( new SfdxWorkspaceChecker(), new DemoModePromptGatherer(), - ForceAuthLogoutAll.withoutShowingChannel() + OrgLogoutAll.withoutShowingChannel() ).run(); } diff --git a/packages/salesforcedx-vscode-core/src/commands/auth/forceAuthLogout.ts b/packages/salesforcedx-vscode-core/src/commands/auth/orgLogout.ts similarity index 84% rename from packages/salesforcedx-vscode-core/src/commands/auth/forceAuthLogout.ts rename to packages/salesforcedx-vscode-core/src/commands/auth/orgLogout.ts index 19ae04a71e..ba001cf45f 100644 --- a/packages/salesforcedx-vscode-core/src/commands/auth/forceAuthLogout.ts +++ b/packages/salesforcedx-vscode-core/src/commands/auth/orgLogout.ts @@ -28,19 +28,19 @@ import { } from '../util'; import { ScratchOrgLogoutParamsGatherer } from './authParamsGatherer'; -export class ForceAuthLogoutAll extends SfdxCommandletExecutor<{}> { - public static withoutShowingChannel(): ForceAuthLogoutAll { - const instance = new ForceAuthLogoutAll(); +export class OrgLogoutAll extends SfdxCommandletExecutor<{}> { + public static withoutShowingChannel(): OrgLogoutAll { + const instance = new OrgLogoutAll(); instance.showChannelOutput = false; return instance; } public build(data: {}): Command { return new SfdxCommandBuilder() - .withDescription(nls.localize('force_auth_logout_all_text')) - .withArg('force:auth:logout') + .withDescription(nls.localize('org_logout_all_text')) + .withArg('org:logout') .withArg('--all') - .withArg('--noprompt') + .withArg('--no-prompt') .withLogName('force_auth_logout') .build(); } @@ -48,21 +48,21 @@ export class ForceAuthLogoutAll extends SfdxCommandletExecutor<{}> { const workspaceChecker = new SfdxWorkspaceChecker(); const parameterGatherer = new EmptyParametersGatherer(); -const executor = new ForceAuthLogoutAll(); +const executor = new OrgLogoutAll(); const commandlet = new SfdxCommandlet( workspaceChecker, parameterGatherer, executor ); -export async function forceAuthLogoutAll() { +export async function orgLogoutAll() { await commandlet.run(); } -export class AuthLogoutDefault extends LibraryCommandletExecutor { +export class OrgLogoutDefault extends LibraryCommandletExecutor { constructor() { super( - nls.localize('force_auth_logout_default_text'), + nls.localize('org_logout_default_text'), 'force_auth_logout_default', OUTPUT_CHANNEL ); @@ -86,7 +86,7 @@ export class AuthLogoutDefault extends LibraryCommandletExecutor { } } -export async function forceAuthLogoutDefault() { +export async function orgLogoutDefault() { const { username, isScratch, alias, error } = await resolveDefaultUsername(); if (error) { telemetryService.sendException(error.name, error.message); @@ -99,12 +99,12 @@ export async function forceAuthLogoutDefault() { isScratch ? new ScratchOrgLogoutParamsGatherer(username, alias) : new SimpleGatherer(username), - new AuthLogoutDefault() + new OrgLogoutDefault() ); await logoutCommandlet.run(); } else { notificationService.showInformationMessage( - nls.localize('auth_logout_no_default_org') + nls.localize('org_logout_no_default_org') ); } } diff --git a/packages/salesforcedx-vscode-core/src/commands/index.ts b/packages/salesforcedx-vscode-core/src/commands/index.ts index 2c98cb0b8b..f4f852ff4d 100644 --- a/packages/salesforcedx-vscode-core/src/commands/index.ts +++ b/packages/salesforcedx-vscode-core/src/commands/index.ts @@ -135,11 +135,7 @@ export { turnOffLogging, ForceStopApexDebugLoggingExecutor } from './forceStopApexDebugLogging'; -export { - forceAuthLogoutAll, - ForceAuthLogoutAll, - forceAuthLogoutDefault -} from './auth/forceAuthLogout'; +export { orgLogoutAll, orgLogoutDefault, OrgLogoutAll } from './auth/orgLogout'; import { DeveloperLogTraceFlag } from '../traceflag/developerLogTraceFlag'; export const developerLogTraceFlag = DeveloperLogTraceFlag.getInstance(); export { forceConfigSet, ForceConfigSetExecutor } from './forceConfigSet'; diff --git a/packages/salesforcedx-vscode-core/src/index.ts b/packages/salesforcedx-vscode-core/src/index.ts index e8e73200e1..ae55e718ce 100644 --- a/packages/salesforcedx-vscode-core/src/index.ts +++ b/packages/salesforcedx-vscode-core/src/index.ts @@ -21,8 +21,6 @@ import { forceApexTriggerCreate, forceAuthAccessToken, forceAuthDevHub, - forceAuthLogoutAll, - forceAuthLogoutDefault, forceAuthWebLogin, forceConfigList, forceConfigSet, @@ -73,6 +71,8 @@ import { forceVisualforceComponentCreate, forceVisualforcePageCreate, initSObjectDefinitions, + orgLogoutAll, + orgLogoutDefault, registerFunctionInvokeCodeLensProvider, SourceStatusFlags, turnOffLogging, @@ -146,13 +146,13 @@ function registerCommands( 'sfdx.force.auth.dev.hub', forceAuthDevHub ); - const forceAuthLogoutAllCmd = vscode.commands.registerCommand( - 'sfdx.force.auth.logout.all', - forceAuthLogoutAll + const orgLogoutAllCmd = vscode.commands.registerCommand( + 'sfdx.org.logout.all', + orgLogoutAll ); - const forceAuthLogoutDefaultCmd = vscode.commands.registerCommand( - 'sfdx.force.auth.logout.default', - forceAuthLogoutDefault + const orgLogoutDefaultCmd = vscode.commands.registerCommand( + 'sfdx.org.logout.default', + orgLogoutDefault ); const forceOpenDocumentationCmd = vscode.commands.registerCommand( 'sfdx.force.open.documentation', @@ -413,8 +413,8 @@ function registerCommands( forceAuthAccessTokenCmd, forceAuthWebLoginCmd, forceAuthDevHubCmd, - forceAuthLogoutAllCmd, - forceAuthLogoutDefaultCmd, + orgLogoutAllCmd, + orgLogoutDefaultCmd, forceDataSoqlQueryInputCmd, forceDataSoqlQuerySelectionCmd, forceDiffFile, diff --git a/packages/salesforcedx-vscode-core/src/messages/i18n.ja.ts b/packages/salesforcedx-vscode-core/src/messages/i18n.ja.ts index 7323dade98..f82db64076 100644 --- a/packages/salesforcedx-vscode-core/src/messages/i18n.ja.ts +++ b/packages/salesforcedx-vscode-core/src/messages/i18n.ja.ts @@ -208,8 +208,8 @@ export const messages = { 'VS Code のSalesforce 拡張機能をデモモードで実行しています。本番環境に接続するときに確認を求められます。', demo_mode_prompt: 'デモモードまたは共有マシンで、ビジネスまたは本番組織を認証することは推奨されません。認証を続ける場合、組織を使用した後、必ず "SFDX: すべての認証済み組織からログアウト" を実行してください。', - force_auth_logout_all_text: 'SFDX: すべての認証済み組織からログアウト', - force_auth_logout_default_text: 'SFDX: Log Out from Default Org', + org_logout_all_text: 'SFDX: すべての認証済み組織からログアウト', + org_logout_default_text: 'SFDX: Log Out from Default Org', manifest_editor_title_message: 'マニフェストエディタ', REST_API: 'REST API', tooling_API: 'Tooling API', @@ -229,10 +229,10 @@ export const messages = { auth_custom_label: 'カスタム', auth_custom_detail: 'カスタムログイン URL を入力', auth_invalid_url: 'URL は http:// か https:// で始める必要があります。', - auth_logout_scratch_prompt: + org_logout_scratch_prompt: 'Log out of this scratch org?\n\nBefore logging out, ensure that you or someone on your team has a username and password for %s scratch org. Otherwise you might lose all access to this scratch org.', - auth_logout_scratch_logout: 'Logout', - auth_logout_no_default_org: 'No default org to logout from', + org_logout_scratch_logout: 'Logout', + org_logout_no_default_org: 'No default org to logout from', error_fetching_auth_info_text: '保存時のプッシュまたはデプロイ実行中にエラー: デフォルトの組織に接続できませんでした。"SFDX: デフォルトのスクラッチ組織を作成" または "SFDX: 組織を認証" を実行して、保存したソースをプッシュまたはデプロイしてください。もしくは、保存時のプッシュまたはデプロイを無効化するため、VS Code のユーザまたはワークスペース設定で "salesforcedx-vscode-core.push-or-deploy-on-save.enabled" を false に設定してください。', error_no_package_directories_found_on_setup_text: diff --git a/packages/salesforcedx-vscode-core/src/messages/i18n.ts b/packages/salesforcedx-vscode-core/src/messages/i18n.ts index 4718dafc11..8d61b59517 100644 --- a/packages/salesforcedx-vscode-core/src/messages/i18n.ts +++ b/packages/salesforcedx-vscode-core/src/messages/i18n.ts @@ -242,8 +242,8 @@ export const messages = { 'You are running Salesforce Extensions for VS Code in demo mode. You will be prompted for confirmation when connecting to production orgs.', demo_mode_prompt: 'Authorizing a business or production org is not recommended on a demo or shared machine. If you continue with the authentication, be sure to run "SFDX: Log Out from All Authorized Orgs" when you\'re done using this org.', - force_auth_logout_all_text: 'SFDX: Log Out from All Authorized Orgs', - force_auth_logout_default_text: 'SFDX: Log Out from Default Org', + org_logout_all_text: 'SFDX: Log Out from All Authorized Orgs', + org_logout_default_text: 'SFDX: Log Out from Default Org', manifest_input_dupe_error: 'Manifest with the name %s already exists. Delete this manifest or use another name.', manifest_input_save_placeholder: @@ -268,10 +268,10 @@ export const messages = { auth_custom_label: 'Custom', auth_custom_detail: 'Enter a custom login URL', auth_invalid_url: 'URL must begin with http:// or https://', - auth_logout_scratch_prompt: + org_logout_scratch_prompt: 'Log out of this scratch org?\n\nBefore logging out, ensure that you or someone on your team has a username and password for %s scratch org. Otherwise you might lose all access to this scratch org.', - auth_logout_scratch_logout: 'Logout', - auth_logout_no_default_org: 'No default org to logout from', + org_logout_scratch_logout: 'Logout', + org_logout_no_default_org: 'No default org to logout from', error_fetching_auth_info_text: 'Error running push or deploy on save: We couldn\'t connect to your default org. Run "SFDX: Create a Default Scratch Org" or "SFDX: Authorize an Org", then push or deploy the source that you just saved. Or, to disable push or deploy on save, set "salesforcedx-vscode-core.push-or-deploy-on-save.enabled" to false in your user or workspace settings for VS Code.', error_no_package_directories_found_on_setup_text: diff --git a/packages/salesforcedx-vscode-core/test/vscode-integration/commands/auth/forceAuthLogout.test.ts b/packages/salesforcedx-vscode-core/test/vscode-integration/commands/auth/orgLogout.test.ts similarity index 89% rename from packages/salesforcedx-vscode-core/test/vscode-integration/commands/auth/forceAuthLogout.test.ts rename to packages/salesforcedx-vscode-core/test/vscode-integration/commands/auth/orgLogout.test.ts index dfd146215c..047308a183 100644 --- a/packages/salesforcedx-vscode-core/test/vscode-integration/commands/auth/forceAuthLogout.test.ts +++ b/packages/salesforcedx-vscode-core/test/vscode-integration/commands/auth/orgLogout.test.ts @@ -10,10 +10,7 @@ import { notificationService } from '@salesforce/salesforcedx-utils-vscode'; import { expect } from 'chai'; import { createSandbox, SinonSandbox, SinonStub } from 'sinon'; import * as vscode from 'vscode'; -import { - ForceAuthLogoutAll, - forceAuthLogoutDefault -} from '../../../../src/commands'; +import { OrgLogoutAll, orgLogoutDefault } from '../../../../src/commands'; import { SfdxCommandlet } from '../../../../src/commands/util'; import { nls } from '../../../../src/messages'; import { telemetryService } from '../../../../src/telemetry'; @@ -21,13 +18,13 @@ import { OrgAuthInfo } from '../../../../src/util'; describe('Force Auth Logout All', () => { it('Should build the auth logout all command', async () => { - const authLogoutAll = new ForceAuthLogoutAll(); + const authLogoutAll = new OrgLogoutAll(); const authLogoutAllCommand = authLogoutAll.build({}); expect(authLogoutAllCommand.toCommand()).to.equal( - 'sfdx force:auth:logout --all --noprompt' + 'sfdx org:logout --all --no-prompt' ); expect(authLogoutAllCommand.description).to.equal( - nls.localize('force_auth_logout_all_text') + nls.localize('org_logout_all_text') ); }); }); @@ -64,7 +61,7 @@ describe('Force Auth Logout Default', () => { scratchOrgStub.resolves(false); notificationStub.resolves(); - await forceAuthLogoutDefault(); + await orgLogoutDefault(); expect( getUsernameStub.called, @@ -86,7 +83,7 @@ describe('Force Auth Logout Default', () => { scratchOrgStub.resolves(false); notificationStub.resolves(); - await forceAuthLogoutDefault(); + await orgLogoutDefault(); expect( getUsernameStub.called, @@ -104,7 +101,7 @@ describe('Force Auth Logout Default', () => { scratchOrgStub.resolves(false); notificationStub.resolves(); - await forceAuthLogoutDefault(); + await orgLogoutDefault(); expect( getUsernameStub.called, @@ -122,7 +119,7 @@ describe('Force Auth Logout Default', () => { scratchOrgStub.resolves(true); notificationStub.resolves(); - await forceAuthLogoutDefault(); + await orgLogoutDefault(); expect( getUsernameStub.called, @@ -146,7 +143,7 @@ describe('Force Auth Logout Default', () => { inputMessageStub.returns(undefined); commandletStub.restore(); - await forceAuthLogoutDefault(); + await orgLogoutDefault(); expect( sendExceptionStub.called, @@ -161,15 +158,15 @@ describe('Force Auth Logout Default', () => { ); const messageArgs = inputMessageStub.getCall(0).args; expect(messageArgs).to.deep.equal([ - nls.localize('auth_logout_scratch_prompt', username), + nls.localize('org_logout_scratch_prompt', username), { modal: true }, - nls.localize('auth_logout_scratch_logout') + nls.localize('org_logout_scratch_logout') ]); }); it('Should allow logout for a scratch org', async () => { let removedUsername; - const logoutResponse = nls.localize('auth_logout_scratch_logout'); + const logoutResponse = nls.localize('org_logout_scratch_logout'); getUsernameStub.resolves(username); scratchOrgStub.resolves(true); @@ -182,7 +179,7 @@ describe('Force Auth Logout Default', () => { } }); - await forceAuthLogoutDefault(); + await orgLogoutDefault(); expect( sendExceptionStub.called, @@ -203,7 +200,7 @@ describe('Force Auth Logout Default', () => { ); const messageArgs = inputMessageStub.getCall(0).args; expect(messageArgs).to.deep.equal([ - nls.localize('auth_logout_scratch_prompt', username), + nls.localize('org_logout_scratch_prompt', username), { modal: true }, logoutResponse ]); From 1449e6ba7e9a6869ba8c84629acd92e694472fcc Mon Sep 17 00:00:00 2001 From: CristiCanizales Date: Sun, 3 Sep 2023 16:01:12 -0300 Subject: [PATCH 2/2] chore: sfdx_json_to_stdout to sf_json_to_stdout --- .../src/commands/commandletExecutors.ts | 2 +- .../src/commands/util/sfdxCommandletExecutor.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/salesforcedx-utils-vscode/src/commands/commandletExecutors.ts b/packages/salesforcedx-utils-vscode/src/commands/commandletExecutors.ts index 4fa06f9e18..a2f26cba93 100644 --- a/packages/salesforcedx-utils-vscode/src/commands/commandletExecutors.ts +++ b/packages/salesforcedx-utils-vscode/src/commands/commandletExecutors.ts @@ -76,7 +76,7 @@ export abstract class 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); let output = ''; diff --git a/packages/salesforcedx-vscode-core/src/commands/util/sfdxCommandletExecutor.ts b/packages/salesforcedx-vscode-core/src/commands/util/sfdxCommandletExecutor.ts index 80d490086c..1138a31cb3 100644 --- a/packages/salesforcedx-vscode-core/src/commands/util/sfdxCommandletExecutor.ts +++ b/packages/salesforcedx-vscode-core/src/commands/util/sfdxCommandletExecutor.ts @@ -89,7 +89,7 @@ export abstract class 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); let output = '';