Skip to content

Commit 0148b80

Browse files
authored
Merge pull request #651 from salesforcecli/wr/quickDeployMdapi
fix: allow mdapi --dry-runs to be quick deploy'd if valid
2 parents c24f6eb + b07d870 commit 0148b80

File tree

4 files changed

+37
-27
lines changed

4 files changed

+37
-27
lines changed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@
241241
"output": []
242242
},
243243
"test:command-reference": {
244-
"command": "\"./bin/dev\" commandreference:generate --erroronwarnings",
244+
"command": "\"./bin/dev\" commandreference:generate --error-on-warnings",
245245
"files": [
246246
"src/**/*.ts",
247247
"messages/**",
@@ -270,4 +270,4 @@
270270
"output": []
271271
}
272272
}
273-
}
273+
}

src/commands/project/deploy/quick.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { Messages, Org } from '@salesforce/core';
1010
import { SfCommand, toHelpSection, Flags } from '@salesforce/sf-plugins-core';
1111
import { RequestStatus } from '@salesforce/source-deploy-retrieve';
1212
import { Duration } from '@salesforce/kit';
13-
import { buildComponentSet, DeployOptions, determineExitCode, poll, resolveApi } from '../../../utils/deploy';
13+
import { DeployOptions, determineExitCode, poll, resolveApi } from '../../../utils/deploy';
1414
import { DeployCache } from '../../../utils/deployCache';
1515
import { DEPLOY_STATUS_CODES_DESCRIPTIONS } from '../../../utils/errorCodes';
1616
import { AsyncDeployResultFormatter } from '../../../formatters/asyncDeployResultFormatter';
@@ -91,7 +91,6 @@ export default class DeployMetadataQuick extends SfCommand<DeployResultJson> {
9191
const api = await resolveApi(this.configAggregator);
9292

9393
await org.getConnection(flags['api-version']).metadata.deployRecentValidation({ id: jobId, rest: api === 'REST' });
94-
const componentSet = await buildComponentSet({ ...deployOpts, wait: flags.wait });
9594
this.log(`Deploy ID: ${bold(jobId)}`);
9695

9796
if (flags.async) {
@@ -100,8 +99,7 @@ export default class DeployMetadataQuick extends SfCommand<DeployResultJson> {
10099
return asyncFormatter.getJson();
101100
}
102101

103-
const result = await poll(org, jobId, flags.wait, componentSet);
104-
102+
const result = await poll(org, jobId, flags.wait);
105103
const formatter = new DeployResultFormatter(result, flags);
106104

107105
if (!this.jsonEnabled()) formatter.display();

src/utils/deploy.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -219,10 +219,10 @@ export async function cancelDeployAsync(opts: Partial<DeployOptions>, id: string
219219
return { id: deploy.id };
220220
}
221221

222-
export async function poll(org: Org, id: string, wait: Duration, componentSet: ComponentSet): Promise<DeployResult> {
222+
export async function poll(org: Org, id: string, wait: Duration, componentSet?: ComponentSet): Promise<DeployResult> {
223223
const report = async (): Promise<DeployResult> => {
224224
const res = await org.getConnection().metadata.checkDeployStatus(id, true);
225-
const deployStatus = res as unknown as MetadataApiDeployStatus;
225+
const deployStatus = res as MetadataApiDeployStatus;
226226
return new DeployResult(deployStatus, componentSet);
227227
};
228228

@@ -238,7 +238,7 @@ export async function poll(org: Org, id: string, wait: Duration, componentSet: C
238238
},
239239
};
240240
const pollingClient = await PollingClient.create(opts);
241-
return pollingClient.subscribe() as unknown as Promise<DeployResult>;
241+
return pollingClient.subscribe();
242242
}
243243

244244
export function determineExitCode(result: DeployResult, async = false): number {

test/commands/deploy/metadata/quick.nut.ts

Lines changed: 30 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,10 @@
66
*/
77

88
import { SourceTestkit } from '@salesforce/source-testkit';
9-
import { assert } from 'chai';
9+
import { assert, config } from 'chai';
10+
import { execCmd } from '@salesforce/cli-plugins-testkit';
1011
import { DeployResultJson } from '../../../../src/utils/types';
12+
config.truncateThreshold = 0;
1113

1214
describe('deploy metadata quick NUTs', () => {
1315
let testkit: SourceTestkit;
@@ -25,49 +27,59 @@ describe('deploy metadata quick NUTs', () => {
2527

2628
describe('--use-most-recent', () => {
2729
it('should deploy previously validated deployment', async () => {
28-
const validation = await testkit.execute<DeployResultJson>('deploy:metadata:validate', {
30+
const validation = await testkit.execute<DeployResultJson>('project:deploy:validate', {
2931
args: '--source-dir force-app',
3032
json: true,
3133
exitCode: 0,
3234
});
3335
assert(validation);
34-
await testkit.expect.filesToBeDeployedViaResult(
35-
['force-app/**/*'],
36-
['force-app/test/**/*'],
37-
validation.result.files
38-
);
36+
await testkit.expect.filesToBeDeployed(['force-app/**/*'], ['force-app/test/**/*']);
3937

40-
const deploy = await testkit.execute<DeployResultJson>('deploy:metadata:quick', {
38+
const deploy = await testkit.execute<DeployResultJson>('project:deploy:quick', {
4139
args: '--use-most-recent',
4240
json: true,
4341
exitCode: 0,
4442
});
4543
assert(deploy);
46-
await testkit.expect.filesToBeDeployedViaResult(['force-app/**/*'], ['force-app/test/**/*'], deploy.result.files);
44+
await testkit.expect.filesToBeDeployed(['force-app/**/*'], ['force-app/test/**/*']);
45+
});
46+
it('should deploy previously validated deployment with metadata format', async () => {
47+
execCmd('project:convert:source --source-dir force-app --output-dir metadata');
48+
const validation = await testkit.execute<DeployResultJson>('project:deploy:validate', {
49+
args: '--metadata-dir metadata',
50+
json: true,
51+
exitCode: 0,
52+
});
53+
assert(validation);
54+
await testkit.expect.filesToBeDeployed(['force-app/**/*'], ['force-app/test/**/*']);
55+
56+
const deploy = await testkit.execute<DeployResultJson>('project:deploy:quick', {
57+
args: '--use-most-recent',
58+
json: true,
59+
exitCode: 0,
60+
});
61+
assert(deploy);
62+
await testkit.expect.filesToBeDeployed(['force-app/**/*'], ['force-app/test/**/*']);
4763
});
4864
});
4965

5066
describe('--job-id', () => {
5167
it('should deploy previously validated deployment', async () => {
52-
const validation = await testkit.execute<DeployResultJson>('deploy:metadata:validate', {
68+
const validation = await testkit.execute<DeployResultJson>('project:deploy:validate', {
5369
args: '--source-dir force-app',
5470
json: true,
5571
exitCode: 0,
5672
});
5773
assert(validation);
58-
await testkit.expect.filesToBeDeployedViaResult(
59-
['force-app/**/*'],
60-
['force-app/test/**/*'],
61-
validation.result.files
62-
);
74+
await testkit.expect.filesToBeDeployed(['force-app/**/*'], ['force-app/test/**/*']);
6375

64-
const deploy = await testkit.execute<DeployResultJson>('deploy:metadata:quick', {
76+
const deploy = await testkit.execute<DeployResultJson>('project:deploy:quick', {
6577
args: `--job-id ${validation.result.id}`,
6678
json: true,
6779
exitCode: 0,
6880
});
6981
assert(deploy);
70-
await testkit.expect.filesToBeDeployedViaResult(['force-app/**/*'], ['force-app/test/**/*'], deploy.result.files);
82+
await testkit.expect.filesToBeDeployed(['force-app/**/*'], ['force-app/test/**/*']);
7183
});
7284

7385
it('should fail to deploy previously deployed deployment', async () => {
@@ -77,7 +89,7 @@ describe('deploy metadata quick NUTs', () => {
7789
exitCode: 0,
7890
});
7991
assert(first);
80-
const deploy = await testkit.execute<DeployResultJson>('deploy:metadata:quick', {
92+
const deploy = await testkit.execute<DeployResultJson>('project:deploy:quick', {
8193
args: `--job-id ${first.result.id}`,
8294
json: true,
8395
exitCode: 1,

0 commit comments

Comments
 (0)