Skip to content

Commit

Permalink
fix: isRestDeploy correctly handles org-metadata-rest-deploy config c…
Browse files Browse the repository at this point in the history
…onversion (#535)
  • Loading branch information
WillieRuemmele authored Jul 6, 2022
1 parent b4942a7 commit dd7e776
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/commands/force/mdapi/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ export class Deploy extends DeployCommand {
const waitDuration = waitFlag.minutes === -1 ? Duration.days(7) : waitFlag;

this.isAsync = waitDuration.quantity === 0;
this.isRest = await this.isRestDeploy();
this.isRest = this.isRestDeploy();
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/delete.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ export class Delete extends DeployCommand {

// fire predeploy event for the delete
await this.lifecycle.emit('predeploy', this.components);
this.isRest = await this.isRestDeploy();
this.isRest = this.isRestDeploy();
this.ux.log(`*** Deleting with ${this.isRest ? 'REST' : 'SOAP'} API ***`);

const deploy = await this.componentSet.deploy({
Expand Down
4 changes: 2 additions & 2 deletions src/commands/force/source/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { Messages } from '@salesforce/core';
import { Duration, env } from '@salesforce/kit';
import { SourceTracking } from '@salesforce/source-tracking';
import { ComponentSetBuilder } from '@salesforce/source-deploy-retrieve';
import { DeployCommand, reportsFormatters, getVersionMessage, TestLevel } from '../../../deployCommand';
import { DeployCommand, getVersionMessage, reportsFormatters, TestLevel } from '../../../deployCommand';
import { DeployCommandResult, DeployResultFormatter } from '../../../formatters/deployResultFormatter';
import {
DeployAsyncResultFormatter,
Expand Down Expand Up @@ -163,7 +163,7 @@ export class Deploy extends DeployCommand {
protected async deploy(): Promise<void> {
const waitDuration = this.getFlag<Duration>('wait');
this.isAsync = waitDuration.quantity === 0;
this.isRest = await this.isRestDeploy();
this.isRest = this.isRestDeploy();

if (this.isAsync && (this.flags.coverageformatters || this.flags.junit)) {
this.warn(messages.getMessage('asyncCoverageJunitWarning'));
Expand Down
16 changes: 7 additions & 9 deletions src/deployCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,23 @@
import * as path from 'path';
import * as fs from 'fs';
import {
AsyncResult,
ComponentSet,
DeployResult,
MetadataApiDeploy,
MetadataApiDeployStatus,
RequestStatus,
AsyncResult,
} from '@salesforce/source-deploy-retrieve';
import { ConfigAggregator, PollingClient, SfError, StatusResult, Messages } from '@salesforce/core';
import { Messages, PollingClient, SfdxPropertyKeys, SfError, StatusResult } from '@salesforce/core';
import { AnyJson, getBoolean, isString } from '@salesforce/ts-types';
import { Duration, once } from '@salesforce/kit';
import { cloneJson, Duration, once } from '@salesforce/kit';
import {
CoverageReporter,
CoverageReporterOptions,
CoverageReportFormats,
DefaultReportOptions,
JUnitReporter,
} from '@salesforce/apex-node';
import { cloneJson } from '@salesforce/kit';
import { SourceCommand } from './sourceCommand';
import { DeployData, Stash } from './stash';
import { transformCoverageToApexCoverage, transformDeployTestsResultsToTestResult } from './coverageUtils';
Expand Down Expand Up @@ -127,17 +126,16 @@ export abstract class DeployCommand extends SourceCommand {
}
}

// REST is the default unless:
// SOAP is the default unless:
// 1. SOAP is specified with the soapdeploy flag on the command
// 2. The restDeploy SFDX config setting is explicitly false.
protected async isRestDeploy(): Promise<boolean> {
// 2. The restDeploy SFDX config setting is explicitly true.
protected isRestDeploy(): boolean {
if (getBoolean(this.flags, 'soapdeploy') === true) {
this.logger.debug('soapdeploy flag === true. Using SOAP');
return false;
}

const aggregator = await ConfigAggregator.create();
const restDeployConfig = aggregator.getPropertyValue('restDeploy');
const restDeployConfig = this.configAggregator.getInfo(SfdxPropertyKeys.REST_DEPLOY).value;
// aggregator property values are returned as strings
if (restDeployConfig === 'false') {
this.logger.debug('restDeploy SFDX config === false. Using SOAP');
Expand Down

0 comments on commit dd7e776

Please sign in to comment.