Skip to content

Commit d7b4367

Browse files
fix: emit warning when PPDS=true
1 parent 0e10dff commit d7b4367

File tree

3 files changed

+89
-0
lines changed

3 files changed

+89
-0
lines changed

messages/deploy.metadata.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,3 +238,7 @@ output directory for code coverage and JUnit results; defaults to the deploy ID
238238
# asyncCoverageJunitWarning
239239

240240
You requested an async deploy with code coverage or JUnit results. The reports will be available when the deploy completes.
241+
242+
# pushPackageDirsWarning
243+
244+
The `pushPackageDirectoriesSequentially` property is no longer respected by this command. Please specify directories by using the `--source-dir | -d` flag in their deployment order.

src/commands/project/deploy/start.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,17 @@ export default class DeployMetadata extends SfCommand<DeployResultJson> {
173173

174174
public async run(): Promise<DeployResultJson> {
175175
const { flags } = await this.parse(DeployMetadata);
176+
if (
177+
this.project.getSfProjectJson().getContents()['pushPackageDirectoriesSequentially'] &&
178+
// flag exclusivity is handled correctly above - but to avoid short-circuiting the check, we need to check all of them
179+
!flags.manifest &&
180+
!flags.metadata &&
181+
!flags['source-dir']
182+
) {
183+
// if pushPackageDirectoriesSequentially = true, and they're not using any of the flags that would modify their deploy
184+
// e.g. they're recreating a `source:push` command, which is the only one that respects this config value, warn them about it not working like it used to
185+
this.warn(messages.getMessage('pushPackageDirsWarning'));
186+
}
176187
if (!validateTests(flags['test-level'], flags.tests)) {
177188
throw messages.createError('error.NoTestsSpecified');
178189
}

test/commands/deploy/start.test.ts

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
/*
2+
* Copyright (c) 2020, salesforce.com, inc.
3+
* All rights reserved.
4+
* Licensed under the BSD 3-Clause license.
5+
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
6+
*/
7+
8+
import { expect } from 'chai';
9+
import { MockTestOrgData, TestContext } from '@salesforce/core/lib/testSetup';
10+
import { stubSfCommandUx } from '@salesforce/sf-plugins-core';
11+
import DeployMetadata from '../../../src/commands/project/deploy/start';
12+
13+
describe('project deploy start', () => {
14+
const $$ = new TestContext();
15+
const testOrg = new MockTestOrgData();
16+
testOrg.isScratchOrg = true;
17+
let warnStub: sinon.SinonStub;
18+
19+
beforeEach(async () => {
20+
await $$.stubAuths(testOrg);
21+
await $$.stubConfig({ 'target-org': testOrg.username });
22+
warnStub = stubSfCommandUx($$.SANDBOX).warn;
23+
});
24+
25+
afterEach(() => {
26+
$$.restore();
27+
});
28+
29+
it('should emit warning when PPDS=true', async () => {
30+
$$.setConfigStubContents('SfProjectJson', {
31+
contents: {
32+
packageDirectories: [{ path: 'force-app', default: true }],
33+
pushPackageDirectoriesSequentially: true,
34+
},
35+
});
36+
try {
37+
await DeployMetadata.run([]);
38+
} catch (e) {
39+
expect(warnStub.firstCall.args[0]).to.contain('pushPackageDirectoriesSequentially');
40+
expect(warnStub.called).to.be.true;
41+
// do nothing, only need to assert that it warns correctly, avoid too much UT setup
42+
}
43+
});
44+
45+
it('should not emit warning when PPDS=true and flags', async () => {
46+
$$.setConfigStubContents('SfProjectJson', {
47+
contents: {
48+
packageDirectories: [{ path: 'force-app', default: true }],
49+
pushPackageDirectoriesSequentially: true,
50+
},
51+
});
52+
try {
53+
await DeployMetadata.run(['--source-dir', 'test']);
54+
} catch (e) {
55+
expect(warnStub.called).to.be.false;
56+
// do nothing, only need to assert that it warns correctly, avoid too much UT setup
57+
}
58+
});
59+
60+
it('should not emit warning when PPDS=false and a flag', async () => {
61+
$$.setConfigStubContents('SfProjectJson', {
62+
contents: {
63+
packageDirectories: [{ path: 'force-app', default: true }],
64+
pushPackageDirectoriesSequentially: false,
65+
},
66+
});
67+
try {
68+
await DeployMetadata.run(['--source-dir', 'test']);
69+
} catch (e) {
70+
expect(warnStub.called).to.be.false;
71+
// do nothing, only need to assert that it warns correctly, avoid too much UT setup
72+
}
73+
});
74+
});

0 commit comments

Comments
 (0)