From 567d6f5c35ae257d5cb4aca6098a36a5537095ef Mon Sep 17 00:00:00 2001 From: Steve Hetzel Date: Thu, 16 Nov 2023 15:31:38 -0700 Subject: [PATCH] fix: quick deploy polling uses the new deploy ID --- src/commands/project/deploy/quick.ts | 18 +++++++++++------- test/commands/deploy/metadata/quick.nut.ts | 22 +++++++++++++++++++++- 2 files changed, 32 insertions(+), 8 deletions(-) diff --git a/src/commands/project/deploy/quick.ts b/src/commands/project/deploy/quick.ts index 1e3a504c..674fad83 100644 --- a/src/commands/project/deploy/quick.ts +++ b/src/commands/project/deploy/quick.ts @@ -91,16 +91,13 @@ export default class DeployMetadataQuick extends SfCommand { const deployOpts = cache.get(jobId) ?? ({} as DeployOptions); const org = flags['target-org'] ?? (await Org.create({ aliasOrUsername: deployOpts['target-org'] })); const api = await resolveApi(this.configAggregator); + const connection = org.getConnection(flags['api-version']); - const mdapiDeploy = new MetadataApiDeploy({ - usernameOrConnection: org.getConnection(flags['api-version']), + // This is the ID of the deploy (of the validated metadata) + const deployId = await connection.metadata.deployRecentValidation({ id: jobId, - apiOptions: { - rest: api === API['REST'], - }, + rest: api === API['REST'], }); - // This is the ID of the deploy (of the validated metadata) - const deployId = await mdapiDeploy.deployRecentValidation(api === API['REST']); this.log(`Deploy ID: ${chalk.bold(deployId)}`); if (flags.async) { @@ -109,6 +106,13 @@ export default class DeployMetadataQuick extends SfCommand { return asyncFormatter.getJson(); } + const mdapiDeploy = new MetadataApiDeploy({ + usernameOrConnection: connection, + id: deployId, + apiOptions: { + rest: api === API['REST'], + }, + }); const result = await mdapiDeploy.pollStatus({ frequency: Duration.seconds(1), timeout: flags.wait, diff --git a/test/commands/deploy/metadata/quick.nut.ts b/test/commands/deploy/metadata/quick.nut.ts index d7636c33..56d2b97f 100644 --- a/test/commands/deploy/metadata/quick.nut.ts +++ b/test/commands/deploy/metadata/quick.nut.ts @@ -82,7 +82,7 @@ describe('deploy metadata quick NUTs', () => { }); describe('--job-id', () => { - it('should deploy previously validated deployment', async () => { + it('should deploy previously validated deployment (async)', async () => { const validation = await testkit.execute('project:deploy:validate', { args: '--source-dir force-app', json: true, @@ -97,6 +97,26 @@ describe('deploy metadata quick NUTs', () => { exitCode: 0, }); assert(deploy); + assert(deploy.result.id !== validation.result.id, 'deploy result ID should not be the validation ID'); + await testkit.expect.filesToBeDeployed(['force-app/**/*'], ['force-app/test/**/*']); + }); + + it('should deploy previously validated deployment (poll)', async () => { + const validation = await testkit.execute('project:deploy:validate', { + args: '--source-dir force-app', + json: true, + exitCode: 0, + }); + assert(validation); + await testkit.expect.filesToBeDeployed(['force-app/**/*'], ['force-app/test/**/*']); + + const deploy = await testkit.execute('project:deploy:quick', { + args: `--job-id ${validation.result.id} --wait 20`, + json: true, + exitCode: 0, + }); + assert(deploy); + assert(deploy.result.id !== validation.result.id, 'deploy result ID should not be the validation ID'); await testkit.expect.filesToBeDeployed(['force-app/**/*'], ['force-app/test/**/*']); });