Skip to content

Commit

Permalink
fix: fixed handling of wait in the formatter
Browse files Browse the repository at this point in the history
  • Loading branch information
shetzel committed Sep 26, 2023
1 parent 7eed027 commit e9ca2fe
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
10 changes: 5 additions & 5 deletions src/commands/project/deploy/report.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export default class DeployMetadataReport extends SfCommand<DeployResultJson> {
const jobId = cache.resolveLatest(flags['use-most-recent'], flags['job-id'], false);

const deployOpts = cache.get(jobId) ?? {};
const waitDuration = flags['wait'];
const wait = flags['wait'];
const org = flags['target-org'] ?? (await Org.create({ aliasOrUsername: deployOpts['target-org'] }));

// if we're using mdapi we won't have a component set
Expand All @@ -85,12 +85,12 @@ export default class DeployMetadataReport extends SfCommand<DeployResultJson> {
try {
this.project = await SfProject.resolve();
const sourcepath = this.project.getUniquePackageDirectories().map((pDir) => pDir.fullPath);
componentSet = await buildComponentSet({ 'source-dir': sourcepath, wait: waitDuration });
componentSet = await buildComponentSet({ 'source-dir': sourcepath, wait });
} catch (err) {
// ignore the error. this was just to get improved command output.
}
} else {
componentSet = await buildComponentSet({ ...deployOpts, wait: waitDuration });
componentSet = await buildComponentSet({ ...deployOpts, wait });
}
}
const mdapiDeploy = new MetadataApiDeploy({
Expand All @@ -117,11 +117,11 @@ export default class DeployMetadataReport extends SfCommand<DeployResultJson> {
};

let result: DeployResult;
if (waitDuration) {
if (wait) {
// poll for deploy results
try {
new DeployProgress(mdapiDeploy, this.jsonEnabled()).start();
result = await mdapiDeploy.pollStatus(500, waitDuration.seconds);
result = await mdapiDeploy.pollStatus(500, wait.seconds);
} catch (error) {
if (error instanceof Error && error.message.includes('The client has timed out')) {
this.debug('[project deploy report] polling timed out. Requesting status...');
Expand Down
6 changes: 4 additions & 2 deletions src/formatters/deployReportResultFormatter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import { ux } from '@oclif/core';
import { RequestStatus } from '@salesforce/source-deploy-retrieve';
import { StandardColors } from '@salesforce/sf-plugins-core';
import { Duration } from '@salesforce/kit';
import { tableHeader } from '../utils/output';
import { DeployResultFormatter } from './deployResultFormatter';

Expand Down Expand Up @@ -38,8 +39,9 @@ export class DeployReportResultFormatter extends DeployResultFormatter {
if (key === 'target-org') {
return result.concat({ key: 'target-org', value: this.flags['target-org']?.getUsername() });
}
if (key === 'wait') {
return result.concat({ key: 'wait', value: `${this.flags['wait']?.quantity} minutes` });
if (key === 'wait' && this.flags['wait']) {
const wait = this.flags['wait'] instanceof Duration ? this.flags['wait'].quantity : this.flags['wait'];
return result.concat({ key: 'wait', value: `${wait} minutes` });
}
return result.concat({ key, value });
}, []);
Expand Down
2 changes: 1 addition & 1 deletion src/formatters/deployResultFormatter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export class DeployResultFormatter extends TestResultsFormatter implements Forma
junit: boolean;
'results-dir': string;
'target-org': Org;
wait: Duration;
wait: Duration | number;
}>
) {
super(result, flags);
Expand Down

0 comments on commit e9ca2fe

Please sign in to comment.