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

Sm/default-wait-on-report #763

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
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
15 changes: 7 additions & 8 deletions src/commands/project/deploy/report.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import { Messages, Org, SfProject } from '@salesforce/core';
import { SfCommand, Flags } from '@salesforce/sf-plugins-core';
import { ComponentSet, DeployResult, MetadataApiDeploy } from '@salesforce/source-deploy-retrieve';
import { Duration } from '@salesforce/kit';
import { buildComponentSet } from '../../../utils/deploy';
import { DeployProgress } from '../../../utils/progressBar';
import { DeployCache } from '../../../utils/deployCache';
Expand Down Expand Up @@ -57,15 +58,14 @@ export default class DeployMetadataReport extends SfCommand<DeployResultJson> {
summary: messages.getMessage('flags.results-dir.summary'),
helpGroup: testFlags,
}),
// we want to allow undefined for a simple check deploy status
// eslint-disable-next-line sf-plugin/flag-min-max-default
wait: Flags.duration({
char: 'w',
summary: deployMessages.getMessage('flags.wait.summary'),
description: deployMessages.getMessage('flags.wait.description'),
unit: 'minutes',
helpValue: '<minutes>',
min: 1,
min: 0,
default: new Duration(0, Duration.Unit.MINUTES),
}),
};

Expand All @@ -74,7 +74,6 @@ 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 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 +84,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: flags['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: flags['wait'] });
}
}
const mdapiDeploy = new MetadataApiDeploy({
Expand All @@ -117,11 +116,11 @@ export default class DeployMetadataReport extends SfCommand<DeployResultJson> {
};

let result: DeployResult;
if (waitDuration) {
if (flags.wait.quantity > 0) {
// poll for deploy results
try {
new DeployProgress(mdapiDeploy, this.jsonEnabled()).start();
result = await mdapiDeploy.pollStatus(500, waitDuration.seconds);
result = await mdapiDeploy.pollStatus(500, flags.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