From ecbb035b827462e458dd78d684c0ff645710b30f Mon Sep 17 00:00:00 2001 From: mshanemc Date: Tue, 26 Sep 2023 16:56:29 -0500 Subject: [PATCH 1/3] fix: default value for wait on report --- src/commands/project/deploy/report.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/commands/project/deploy/report.ts b/src/commands/project/deploy/report.ts index 043a5fda..7a55a222 100644 --- a/src/commands/project/deploy/report.ts +++ b/src/commands/project/deploy/report.ts @@ -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'; @@ -57,15 +58,14 @@ export default class DeployMetadataReport extends SfCommand { 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: '', - min: 1, + min: 0, + default: new Duration(0, Duration.Unit.MINUTES), }), }; From be6b3013a0c7991a3a30340e5d48b785da6317f2 Mon Sep 17 00:00:00 2001 From: mshanemc Date: Tue, 26 Sep 2023 17:03:21 -0500 Subject: [PATCH 2/3] fix: pass undefined for wait=0 to the original deploy jobs --- src/commands/project/deploy/report.ts | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/commands/project/deploy/report.ts b/src/commands/project/deploy/report.ts index 7a55a222..ce4f2761 100644 --- a/src/commands/project/deploy/report.ts +++ b/src/commands/project/deploy/report.ts @@ -74,7 +74,6 @@ export default class DeployMetadataReport extends SfCommand { 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 @@ -85,12 +84,18 @@ export default class DeployMetadataReport extends SfCommand { 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'].quantity > 0 ? flags['wait'] : undefined, + }); } 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'].quantity > 0 ? flags['wait'] : undefined, + }); } } const mdapiDeploy = new MetadataApiDeploy({ @@ -117,11 +122,11 @@ export default class DeployMetadataReport extends SfCommand { }; 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...'); From 0b0ec2ced053ebd60da08c6726ce133d0b4510b2 Mon Sep 17 00:00:00 2001 From: mshanemc Date: Tue, 26 Sep 2023 17:06:03 -0500 Subject: [PATCH 3/3] refactor: send 0 when no wait specified --- src/commands/project/deploy/report.ts | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/src/commands/project/deploy/report.ts b/src/commands/project/deploy/report.ts index ce4f2761..e1f7c4cd 100644 --- a/src/commands/project/deploy/report.ts +++ b/src/commands/project/deploy/report.ts @@ -84,18 +84,12 @@ export default class DeployMetadataReport extends SfCommand { try { this.project = await SfProject.resolve(); const sourcepath = this.project.getUniquePackageDirectories().map((pDir) => pDir.fullPath); - componentSet = await buildComponentSet({ - 'source-dir': sourcepath, - wait: flags['wait'].quantity > 0 ? flags['wait'] : undefined, - }); + 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: flags['wait'].quantity > 0 ? flags['wait'] : undefined, - }); + componentSet = await buildComponentSet({ ...deployOpts, wait: flags['wait'] }); } } const mdapiDeploy = new MetadataApiDeploy({