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

Add 'SFDX: Deploy Source to Org' command #531

Merged
merged 6 commits into from
Jul 20, 2018
Merged
Show file tree
Hide file tree
Changes from all 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
26 changes: 26 additions & 0 deletions packages/salesforcedx-vscode-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,11 @@
"command": "sfdx.force.source.retrieve.current.file",
"when":
"sfdx:project_opened && config.salesforcedx-vscode-core.change_set_based_tools.enabled"
},
{
"command": "sfdx.force.source.deploy.current.file",
"when":
"sfdx:project_opened && config.salesforcedx-vscode-core.change_set_based_tools.enabled"
}
],
"explorer/context": [
Expand Down Expand Up @@ -140,6 +145,11 @@
"command": "sfdx.force.source.retrieve",
"when":
"sfdx:project_opened && config.salesforcedx-vscode-core.change_set_based_tools.enabled"
},
{
"command": "sfdx.force.source.deploy",
"when":
"sfdx:project_opened && config.salesforcedx-vscode-core.change_set_based_tools.enabled"
}
],
"commandPalette": [
Expand Down Expand Up @@ -315,9 +325,17 @@
"command": "sfdx.force.source.retrieve",
"when": "false"
},
{
"command": "sfdx.force.source.deploy",
"when": "false"
},
{
"command": "sfdx.force.source.retrieve.current.file",
"when": "false"
},
{
"command": "sfdx.force.source.deploy.current.file",
"when": "false"
}
]
},
Expand Down Expand Up @@ -497,6 +515,14 @@
{
"command": "sfdx.force.source.retrieve.current.file",
"title": "%force_source_retrieve_this_source_file_text%"
},
{
"command": "sfdx.force.source.deploy",
"title": "%force_source_deploy_text%"
},
{
"command": "sfdx.force.source.deploy.current.file",
"title": "%force_source_deploy_this_source_file_text%"
}
],
"configuration": {
Expand Down
5 changes: 4 additions & 1 deletion packages/salesforcedx-vscode-core/package.nls.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,5 +74,8 @@
"force_manifest_editor_show_text": "SFDX: Show Package Manifest Editor",
"force_source_retrieve_text": "SFDX: Retrieve Source from Org",
"force_source_retrieve_this_source_file_text":
"SFDX: Retrieve This Source File from Org"
"SFDX: Retrieve This Source File from Org",
"force_source_deploy_text": "SFDX: Deploy Source to Org",
"force_source_deploy_this_source_file_text":
"SFDX: Deploy This Source File to Org"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/*
* Copyright (c) 2018, 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 {
Command,
SfdxCommandBuilder
} from '@salesforce/salesforcedx-utils-vscode/out/src/cli';
import { nls } from '../messages';
import {
SfdxCommandlet,
SfdxCommandletExecutor,
SfdxWorkspaceChecker
} from './commands';
import {
FileType,
ManifestOrSourcePathGatherer,
SelectedPath
} from './forceSourceRetrieve';

export class ForceSourceDeployExecutor extends SfdxCommandletExecutor<
SelectedPath
> {
public build(data: SelectedPath): Command {
const commandBuilder = new SfdxCommandBuilder()
.withDescription(nls.localize('force_source_deploy_text'))
.withArg('force:source:deploy');
if (data.type === FileType.Manifest) {
commandBuilder.withFlag('--manifest', data.filePath);
} else {
commandBuilder.withFlag('--sourcepath', data.filePath);
}
return commandBuilder.build();
}
}

const workspaceChecker = new SfdxWorkspaceChecker();

export async function forceSourceDeploy(explorerPath: any) {
const commandlet = new SfdxCommandlet(
workspaceChecker,
new ManifestOrSourcePathGatherer(explorerPath),
new ForceSourceDeployExecutor()
);
await commandlet.run();
}
1 change: 1 addition & 0 deletions packages/salesforcedx-vscode-core/src/commands/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export {
export { forceDataSoqlQuery } from './forceDataSoqlQuery';
export { forceOrgCreate } from './forceOrgCreate';
export { forceOrgOpen } from './forceOrgOpen';
export { forceSourceDeploy } from './forceSourceDeploy';
export { forceSourcePull } from './forceSourcePull';
export { forceSourcePush } from './forceSourcePush';
export { forceSourceRetrieve } from './forceSourceRetrieve';
Expand Down
7 changes: 6 additions & 1 deletion packages/salesforcedx-vscode-core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
* 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 * as path from 'path';
import { ConfigurationTarget } from 'vscode';
import * as vscode from 'vscode';
Expand Down Expand Up @@ -37,6 +36,7 @@ import {
forceOrgDisplay,
forceOrgOpen,
forceSfdxProjectCreate,
forceSourceDeploy,
forceSourcePull,
forceSourcePush,
forceSourceRetrieve,
Expand Down Expand Up @@ -93,6 +93,10 @@ function registerCommands(
'sfdx.force.org.open',
forceOrgOpen
);
const forceSourceDeployCmd = vscode.commands.registerCommand(
'sfdx.force.source.deploy',
forceSourceDeploy
);
const forceSourcePullCmd = vscode.commands.registerCommand(
'sfdx.force.source.pull',
forceSourcePull
Expand Down Expand Up @@ -292,6 +296,7 @@ function registerCommands(
forceDataSoqlQuerySelectionCmd,
forceOrgCreateCmd,
forceOrgOpenCmd,
forceSourceDeployCmd,
forceSourcePullCmd,
forceSourcePullForceCmd,
forceSourcePushCmd,
Expand Down
2 changes: 2 additions & 0 deletions packages/salesforcedx-vscode-core/src/messages/i18n.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,9 @@ export const messages = {
force_source_push_force_default_scratch_org_text:
'SFDX: Push Source to Default Scratch Org and Override Conflicts',

force_source_deploy_text: 'SFDX: Deploy Source to Org',
force_source_retrieve_text: 'SFDX: Retrieve Source from Org',

force_source_status_text:
'View All Changes (Local and in Default Scratch Org)',

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*
* Copyright (c) 2018, 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 * as path from 'path';

import { ForceSourceDeployExecutor } from './../../src/commands/forceSourceDeploy';
import { FileType } from './../../src/commands/forceSourceRetrieve';

import { nls } from '../../src/messages';

describe('Force Source Deploy with Manifest Option', () => {
it('Should build the source deploy command', () => {
const manifestPath = path.join('path', 'to', 'manifest', 'package.xml');
const sourceDeploy = new ForceSourceDeployExecutor();
const sourceDeployCommand = sourceDeploy.build({
filePath: manifestPath,
type: FileType.Manifest
});
expect(sourceDeployCommand.toCommand()).to.equal(
`sfdx force:source:deploy --manifest ${manifestPath}`
);
expect(sourceDeployCommand.description).to.equal(
nls.localize('force_source_deploy_text')
);
});
});

describe('Force Source Deploy with Sourcepath Option', () => {
it('Should build the source deploy command', () => {
const sourcePath = path.join('path', 'to', 'sourceFile');
const sourceDeploy = new ForceSourceDeployExecutor();
const sourceDeployCommand = sourceDeploy.build({
filePath: sourcePath,
type: FileType.Source
});
expect(sourceDeployCommand.toCommand()).to.equal(
`sfdx force:source:deploy --sourcepath ${sourcePath}`
);
expect(sourceDeployCommand.description).to.equal(
nls.localize('force_source_deploy_text')
);
});
});