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: change org open commands and flags to sf style #5059

Merged
merged 7 commits into from
Sep 19, 2023
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
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
} from '../../../src/cli';

// tslint:disable:no-unused-expression
describe('force:org:open container parser', () => {
describe('org:open container parser', () => {
const orgOpenSuccessResult: OrgOpenSuccessResult = {
status: 0,
result: {
Expand Down Expand Up @@ -73,10 +73,10 @@ describe('force:org:open container parser', () => {

it('Should parse success info successfully when provided along other info', () => {
const parser = new OrgOpenContainerResultParser(
`Warning: sfdx-cli update available from 7.7.0 to 7.14.0.${EOL} sfdx force:org:open --json --loglevel fatal ${EOL}
`Warning: sfdx-cli update available from 7.7.0 to 7.14.0.${EOL} sfdx org:open --json --loglevel fatal ${EOL}
${JSON.stringify(
orgOpenSuccessResult
)} ${EOL} sfdx force:org:open --json --loglevel fatal ended with exit code 0`
)} ${EOL} sfdx org:open --json --loglevel fatal ended with exit code 0`
);

expect(parser.openIsSuccessful()).to.be.true;
Expand All @@ -94,7 +94,7 @@ describe('force:org:open container parser', () => {
it('should throw an error when cli does not respond with json result info', () => {
try {
new OrgOpenContainerResultParser(
'sfdx force:org:open --urlonly --json --loglevel fatal ended with exit code 0'
'sfdx org:open --url-only --json --loglevel fatal ended with exit code 0'
);
} catch (err) {
if (err instanceof Error) {
Expand Down
6 changes: 3 additions & 3 deletions packages/salesforcedx-vscode-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@
"when": "sfdx:project_opened"
},
{
"command": "sfdx.force.org.open",
"command": "sfdx.org.open",
"when": "sfdx:project_opened"
},
{
Expand Down Expand Up @@ -656,8 +656,8 @@
"title": "%force_org_create_default_scratch_org_text%"
},
{
"command": "sfdx.force.org.open",
"title": "%force_org_open_default_scratch_org_text%"
"command": "sfdx.org.open",
"title": "%org_open_default_scratch_org_text%"
},
{
"command": "sfdx.force.source.pull",
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 @@ -6,7 +6,7 @@
"force_auth_logout_all_text": "SFDX: すべての認証済み組織からログアウト",
"force_auth_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: デフォルトの組織を開く",
"org_open_default_scratch_org_text": "SFDX: デフォルトの組織を開く",
"force_source_pull_default_org_text": "SFDX: デフォルトのスクラッチ組織からソースをプル",
"force_source_pull_force_default_org_text": "SFDX: デフォルトのスクラッチ組織からソースをプルして競合を上書き",
"force_source_push_default_org_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 @@ -7,7 +7,7 @@
"force_auth_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",
"org_open_default_scratch_org_text": "SFDX: Open Default 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",
"force_source_push_default_org_text": "SFDX: Push Source to Default Org",
Expand Down
8 changes: 4 additions & 4 deletions packages/salesforcedx-vscode-core/src/commands/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@ export {
ForceOrgCreateExecutor
} from './forceOrgCreate';
export {
forceOrgOpen,
ForceOrgOpenContainerExecutor,
ForceOrgOpenExecutor,
orgOpen,
OrgOpenContainerExecutor,
OrgOpenExecutor,
getExecutor
} from './forceOrgOpen';
} from './orgOpen';
export {
forceSourceDelete,
ConfirmationAndSourcePathGatherer,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,20 +31,20 @@ import {
SfdxWorkspaceChecker
} from './util';

export class ForceOrgOpenContainerExecutor extends SfdxCommandletExecutor<{}> {
export class OrgOpenContainerExecutor extends SfdxCommandletExecutor<{}> {
public build(data: {}): Command {
return new SfdxCommandBuilder()
.withDescription(nls.localize('force_org_open_default_scratch_org_text'))
.withArg('force:org:open')
.withDescription(nls.localize('org_open_default_scratch_org_text'))
.withArg('org:open')
.withLogName('force_org_open_default_scratch_org')
.withArg('--urlonly')
.withArg('--url-only')
.withJson()
.build();
}

public buildUserMessageWith(orgData: OrgOpenSuccessResult): string {
return nls.localize(
'force_org_open_container_mode_message_text',
'org_open_container_mode_message_text',
orgData.result.orgId,
orgData.result.username,
orgData.result.url
Expand All @@ -57,7 +57,7 @@ export class ForceOrgOpenContainerExecutor extends SfdxCommandletExecutor<{}> {
const cancellationToken = cancellationTokenSource.token;
const execution = new CliCommandExecutor(this.build(response.data), {
cwd: workspaceUtils.getRootWorkspacePath(),
env: { SFDX_JSON_TO_STDOUT: 'true' }
env: { SF_JSON_TO_STDOUT: 'true' }
}).execute(cancellationToken);

channelService.streamCommandStartStop(execution);
Expand Down Expand Up @@ -85,7 +85,7 @@ export class ForceOrgOpenContainerExecutor extends SfdxCommandletExecutor<{}> {
}
} catch (error) {
channelService.appendLine(
nls.localize('force_org_open_default_scratch_org_container_error')
nls.localize('org_open_default_scratch_org_container_error')
);
telemetryService.sendException(
'force_org_open_container',
Expand All @@ -103,27 +103,27 @@ export class ForceOrgOpenContainerExecutor extends SfdxCommandletExecutor<{}> {
}
}

export class ForceOrgOpenExecutor extends SfdxCommandletExecutor<{}> {
export class OrgOpenExecutor extends SfdxCommandletExecutor<{}> {
protected showChannelOutput = false;
public build(data: {}): Command {
return new SfdxCommandBuilder()
.withDescription(nls.localize('force_org_open_default_scratch_org_text'))
.withArg('force:org:open')
.withDescription(nls.localize('org_open_default_scratch_org_text'))
.withArg('org:open')
.withLogName('force_org_open_default_scratch_org')
.build();
}
}

export function getExecutor(): SfdxCommandletExecutor<{}> {
return isSFContainerMode()
? new ForceOrgOpenContainerExecutor()
: new ForceOrgOpenExecutor();
? new OrgOpenContainerExecutor()
: new OrgOpenExecutor();
}

const workspaceChecker = new SfdxWorkspaceChecker();
const parameterGatherer = new EmptyParametersGatherer();

export async function forceOrgOpen() {
export async function orgOpen() {
const commandlet = new SfdxCommandlet(
workspaceChecker,
parameterGatherer,
Expand Down
5 changes: 3 additions & 2 deletions packages/salesforcedx-vscode-core/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ export const ENABLE_SOBJECT_REFRESH_ON_STARTUP =
'enable-sobject-refresh-on-startup';
export const ENABLE_DEPLOY_AND_RETRIEVE_FOR_SOURCE_TRACKED_ORGS =
'enableDeployAndRetrieveForSourceTrackedOrgs.enabled';
export const ENABLE_SOURCE_TRACKING_FOR_DEPLOY_RETRIEVE = 'experimental.enableSourceTrackingForDeployAndRetrieve';
export const ENABLE_SOURCE_TRACKING_FOR_DEPLOY_RETRIEVE =
'experimental.enableSourceTrackingForDeployAndRetrieve';
export const CLI = {
AUTH_DEVICE_LOGIN: 'force:auth:device:login',
AUTH_WEB_LOGIN: 'force:auth:web:login'
Expand All @@ -58,7 +59,7 @@ export const LWC_PATH = '/force-app/main/default/lwc/';
export const FUNCTIONS_PATH = '/functions/';

// Commands
export const ORG_OPEN_COMMAND = 'sfdx.force.org.open';
export const ORG_OPEN_COMMAND = 'sfdx.org.open';
export const FORCE_SOURCE_PULL_LOG_NAME =
'force_source_pull_default_scratch_org';
export const FORCE_SOURCE_PUSH_LOG_NAME =
Expand Down
17 changes: 3 additions & 14 deletions packages/salesforcedx-vscode-core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ import {
forceOrgDelete,
forceOrgDisplay,
forceOrgList,
forceOrgOpen,
forcePackageInstall,
forceProjectWithManifestCreate,
forceRefreshSObjects,
Expand All @@ -66,15 +65,14 @@ import {
forceSourceRetrieveCmp,
forceSourceRetrieveManifest,
forceSourceRetrieveSourcePaths,
forceSourceStatus,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is not used in the file, so I removed it

forceStartApexDebugLogging,
forceStopApexDebugLogging,
forceTaskStop,
forceVisualforceComponentCreate,
forceVisualforcePageCreate,
initSObjectDefinitions,
orgOpen,
registerFunctionInvokeCodeLensProvider,
SourceStatusFlags,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here. Not used

turnOffLogging,
viewAllChanges,
viewLocalChanges,
Expand Down Expand Up @@ -123,12 +121,6 @@ import { OrgAuthInfo } from './util/authInfo';
const flagOverwrite: FlagParameter<string> = {
flag: '--forceoverwrite'
};
const flagStatusLocal: FlagParameter<SourceStatusFlags> = {
flag: SourceStatusFlags.Local
};
const flagStatusRemote: FlagParameter<SourceStatusFlags> = {
flag: SourceStatusFlags.Remote
};
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here with these 2 above. Not used


function registerCommands(
extensionContext: vscode.ExtensionContext
Expand Down Expand Up @@ -162,10 +154,7 @@ function registerCommands(
'sfdx.force.org.create',
forceOrgCreate
);
const forceOrgOpenCmd = vscode.commands.registerCommand(
ORG_OPEN_COMMAND,
forceOrgOpen
);
const orgOpenCmd = vscode.commands.registerCommand(ORG_OPEN_COMMAND, orgOpen);
const forceSourceDeleteCmd = vscode.commands.registerCommand(
'sfdx.force.source.delete',
forceSourceDelete
Expand Down Expand Up @@ -425,7 +414,7 @@ function registerCommands(
forceFunctionStopCmd,
forceOpenDocumentationCmd,
forceOrgCreateCmd,
forceOrgOpenCmd,
orgOpenCmd,
forceOrgDeleteDefaultCmd,
forceOrgDeleteUsernameCmd,
forceOrgListCleanCmd,
Expand Down
6 changes: 3 additions & 3 deletions packages/salesforcedx-vscode-core/src/messages/i18n.ja.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,10 @@ export const messages = {
force_org_create_result_parsing_error:
'組織を作成するレスポンスの処理中に予期せぬエラーが発生しました。',

force_org_open_default_scratch_org_text: 'SFDX: デフォルトの組織を開く',
force_org_open_default_scratch_org_container_error:
org_open_default_scratch_org_text: 'SFDX: デフォルトの組織を開く',
org_open_default_scratch_org_container_error:
'組織を開くレスポンスの処理中に予期せぬエラーが発生しました。',
force_org_open_container_mode_message_text:
org_open_container_mode_message_text:
'組織 %s にユーザ %s として次の URL: %s を使用してアクセス',

force_source_pull_default_org_text:
Expand Down
6 changes: 3 additions & 3 deletions packages/salesforcedx-vscode-core/src/messages/i18n.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,10 @@ export const messages = {
force_org_create_result_parsing_error:
'An unexpected error occurred while processing the org create response.',

force_org_open_default_scratch_org_text: 'SFDX: Open Default Org',
force_org_open_default_scratch_org_container_error:
org_open_default_scratch_org_text: 'SFDX: Open Default Org',
org_open_default_scratch_org_container_error:
'There was an unexpected error when processing the org open response.',
force_org_open_container_mode_message_text:
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:
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/*
* Copyright (c) 2019, 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 {
getExecutor,
OrgOpenContainerExecutor,
OrgOpenExecutor
} from '../../../src/commands';
import { nls } from '../../../src/messages';

// tslint:disable:no-unused-expression
describe('Org Open', () => {
it('should build the org open command', () => {
const orgOpenContainer = new OrgOpenExecutor();
const orgOpenCommand = orgOpenContainer.build({});

expect(orgOpenCommand.toCommand()).to.equal('sfdx org:open');
expect(orgOpenCommand.description).to.equal(
nls.localize('org_open_default_scratch_org_text')
);
});

it('should build the org open command for use in a container', () => {
const orgOpenContainer = new OrgOpenContainerExecutor();
const orgOpenCommand = orgOpenContainer.build({});

expect(orgOpenCommand.toCommand()).to.equal(
'sfdx org:open --url-only --json --loglevel fatal'
);
expect(orgOpenCommand.description).to.equal(
nls.localize('org_open_default_scratch_org_text')
);
});

describe('Executor is chosen based on environment', () => {
afterEach(() => {
delete process.env.SF_CONTAINER_MODE;
});
it('should use OrgOpenExecutor if container mode is not defined', () => {
expect(getExecutor()).to.be.instanceOf(OrgOpenExecutor);
});
it('should use OrgOpenExecutor if container mode is empty', () => {
process.env.SF_CONTAINER_MODE = '';
expect(getExecutor()).to.be.instanceOf(OrgOpenExecutor);
});

it('should use OrgOpenContainerExecutor if container mode is defined', () => {
process.env.SF_CONTAINER_MODE = 'true';
expect(getExecutor()).to.be.instanceOf(OrgOpenContainerExecutor);
});
});
});