Skip to content

Commit

Permalink
fix: pass --soapdeploy flag to method, add org-metadata (#815)
Browse files Browse the repository at this point in the history
  • Loading branch information
WillieRuemmele authored Apr 19, 2023
1 parent cb017af commit 240884f
Show file tree
Hide file tree
Showing 6 changed files with 235 additions and 629 deletions.
775 changes: 151 additions & 624 deletions CHANGELOG.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -283,4 +283,4 @@
"output": []
}
}
}
}
2 changes: 1 addition & 1 deletion src/commands/force/mdapi/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ export class Deploy extends DeployCommand {
const waitDuration = waitFlag.minutes === -1 ? Duration.days(7) : waitFlag;

this.isAsync = waitDuration.quantity === 0;
this.isRest = this.isRestDeploy();
this.isRest = this.isRestDeploy(this.flags.soapdeploy);
if (this.isAsync && (this.flags.coverageformatters || this.flags.junit)) {
this.warn(messages.getMessage('asyncCoverageJunitWarning'));
}
Expand Down
2 changes: 1 addition & 1 deletion src/commands/force/source/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ export class Deploy extends DeployCommand {
protected async deploy(): Promise<void> {
const waitDuration = this.flags.wait;
this.isAsync = waitDuration.quantity === 0;
this.isRest = this.isRestDeploy();
this.isRest = this.isRestDeploy(this.flags.soapdeploy);

if (this.isAsync && (this.flags.coverageformatters || this.flags.junit)) {
this.warn(messages.getMessage('asyncCoverageJunitWarning'));
Expand Down
4 changes: 3 additions & 1 deletion src/deployCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,9 @@ export abstract class DeployCommand extends SourceCommand {
return false;
}

const restDeployConfig = this.configAggregator.getInfo(SfdxPropertyKeys.REST_DEPLOY).value;
const restDeployConfig =
this.configAggregator.getInfo(SfdxPropertyKeys.REST_DEPLOY).value ??
this.configAggregator.getInfo('org-metadata-rest-deploy').value;
// aggregator property values are returned as strings
if (restDeployConfig === 'false') {
this.debug('restDeploy SFDX config === false. Using SOAP');
Expand Down
79 changes: 78 additions & 1 deletion test/commands/source/deploy.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import * as sinon from 'sinon';
import { expect } from 'chai';
import { ComponentSetBuilder, ComponentSetOptions, MetadataApiDeployOptions } from '@salesforce/source-deploy-retrieve';
import { fromStub, stubInterface, stubMethod } from '@salesforce/ts-sinon';
import { ConfigAggregator, Lifecycle, Messages, SfProject } from '@salesforce/core';
import { ConfigAggregator, Lifecycle, Messages, SfdxConfigAggregator, SfProject } from '@salesforce/core';
import { Config } from '@oclif/core';
import { SfCommand } from '@salesforce/sf-plugins-core';
import { MockTestOrgData, TestContext } from '@salesforce/core/lib/testSetup';
Expand Down Expand Up @@ -85,6 +85,8 @@ describe('force:source:deploy', () => {
const runDeployCmd = async (params: string[], options?: { sourceApiVersion?: string }) => {
const cmd = new TestDeploy(params, oclifConfigStub);
cmd.project = SfProject.getInstance();
cmd.configAggregator = await SfdxConfigAggregator.create();

sandbox.stub(cmd.project, 'getDefaultPackage').returns({ name: '', path: '', fullPath: defaultDir });
sandbox.stub(cmd.project, 'getUniquePackageDirectories').returns([{ fullPath: defaultDir, path: '', name: '' }]);
sandbox.stub(cmd.project, 'getPackageDirectories').returns([{ fullPath: defaultDir, path: '', name: '' }]);
Expand Down Expand Up @@ -373,6 +375,81 @@ describe('force:source:deploy', () => {
});

describe('SOAP/REST', () => {
it('should override env var with --soapdeploy', async () => {
process.env.SFDX_REST_DEPLOY = 'true';
const manifest = 'package.xml';
const result = await runDeployCmd(['--manifest', manifest, '--soapdeploy', '--json']);
expect(result).to.deep.equal(expectedResults);
ensureCreateComponentSetArgs({
manifest: {
manifestPath: manifest,
directoryPaths: [defaultDir],
destructiveChangesPost: undefined,
destructiveChangesPre: undefined,
},
});
ensureDeployArgs();
ensureHookArgs();
ensureProgressBar(0);
process.env.SFDX_REST_DEPLOY = 'false';
});

it('should override config with --soapdeploy', async () => {
await $$.stubConfig({ restDeploy: 'true', 'target-org': testOrg.username });
const manifest = 'package.xml';
const result = await runDeployCmd(['--manifest', manifest, '--soapdeploy', '--json']);
expect(result).to.deep.equal(expectedResults);
ensureCreateComponentSetArgs({
manifest: {
manifestPath: manifest,
directoryPaths: [defaultDir],
destructiveChangesPost: undefined,
destructiveChangesPre: undefined,
},
});
ensureDeployArgs();
ensureHookArgs();
ensureProgressBar(0);
});

it('should REST deploy with config', async () => {
await $$.stubConfig({ restDeploy: 'true', 'target-org': testOrg.username });

const manifest = 'package.xml';
const result = await runDeployCmd(['--manifest', manifest, '--json']);
expect(result).to.deep.equal(expectedResults);
ensureCreateComponentSetArgs({
manifest: {
manifestPath: manifest,
directoryPaths: [defaultDir],
destructiveChangesPost: undefined,
destructiveChangesPre: undefined,
},
});
ensureDeployArgs({ apiOptions: { rest: true } });
ensureHookArgs();
ensureProgressBar(0);
});

it('should REST deploy', async () => {
process.env.SFDX_REST_DEPLOY = 'true';
const manifest = 'package.xml';
const result = await runDeployCmd(['--manifest', manifest, '--json']);
expect(result).to.deep.equal(expectedResults);
ensureCreateComponentSetArgs({
manifest: {
manifestPath: manifest,
directoryPaths: [defaultDir],
destructiveChangesPost: undefined,
destructiveChangesPre: undefined,
},
});
ensureDeployArgs({ apiOptions: { rest: true } });
ensureHookArgs();
ensureProgressBar(0);
process.env.SFDX_REST_DEPLOY = 'false';
});

it('should use SOAP by default', () => {
delete process.env.SFDX_REST_DEPLOY;
const sourcepath = ['somepath'];
Expand Down

0 comments on commit 240884f

Please sign in to comment.