Skip to content

Commit 58e84c8

Browse files
Merge pull request #1372 from salesforcecli/wr/noSourceTrackingWithDryRun
fix: no source tracking after a dry-run @W-18067034@
2 parents a5de5d6 + 00a8383 commit 58e84c8

File tree

4 files changed

+827
-773
lines changed

4 files changed

+827
-773
lines changed

src/utils/deploy.ts

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,8 @@ export type DeployOptions = {
5050
concise?: boolean;
5151
'single-package'?: boolean;
5252
status?: RequestStatus;
53-
5453
'pre-destructive-changes'?: string;
5554
'post-destructive-changes'?: string;
56-
5755
'purge-on-delete'?: boolean;
5856
};
5957

@@ -145,14 +143,18 @@ export async function executeDeploy(
145143
} else {
146144
// instantiate source tracking
147145
// stl will decide, based on the org's properties, what needs to be done
148-
const stl = await SourceTracking.create({
149-
org,
150-
// mdapi format deploys don't require a project, but at this point we need one
151-
project: project ?? (await SfProject.resolve()),
152-
subscribeSDREvents: true,
153-
ignoreConflicts: opts['ignore-conflicts'],
154-
});
155-
registry = stl.registry;
146+
let stl: SourceTracking | undefined;
147+
if (!opts['dry-run'] || !(await org.tracksSource())) {
148+
stl = await SourceTracking.create({
149+
org,
150+
// mdapi format deploys don't require a project, but at this point we need one
151+
project: project ?? (await SfProject.resolve()),
152+
subscribeSDREvents: true,
153+
ignoreConflicts: opts['ignore-conflicts'],
154+
});
155+
registry = stl.registry;
156+
}
157+
156158
componentSet = await buildComponentSet(opts, stl);
157159
if (componentSet.size === 0) {
158160
if (opts['source-dir'] ?? opts.manifest ?? opts.metadata ?? throwOnEmpty) {

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,8 @@ describe('deploy metadata quick NUTs', () => {
125125
});
126126

127127
it('should fail to deploy previously deployed deployment', async () => {
128-
const first = await testkit.execute<DeployResultJson>('deploy:metadata', {
129-
args: '--source-dir force-app',
128+
const first = await testkit.execute<DeployResultJson>('project:deploy:start', {
129+
args: '--source-dir force-app --ignore-conflicts',
130130
json: true,
131131
exitCode: 0,
132132
});

test/nuts/deploy/start.nut.ts

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/*
2+
* Copyright (c) 2023, 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+
import { fileURLToPath } from 'node:url';
8+
import { execCmd } from '@salesforce/cli-plugins-testkit';
9+
import { expect } from 'chai';
10+
import { SourceTestkit } from '@salesforce/source-testkit';
11+
import { DeployResultJson } from '../../../src/utils/types.js';
12+
13+
describe('project deploy start NUTs', () => {
14+
let testkit: SourceTestkit;
15+
16+
before(async () => {
17+
testkit = await SourceTestkit.create({
18+
repository: 'https://github.com/trailheadapps/dreamhouse-lwc.git',
19+
nut: fileURLToPath(import.meta.url),
20+
});
21+
});
22+
23+
after(async () => {
24+
await testkit?.clean();
25+
});
26+
27+
it('--source-dir --dry-run should NOT affect source-tracking', async () => {
28+
execCmd('project:deploy:start --dry-run --source-dir force-app', { ensureExitCode: 0 });
29+
const actual = execCmd<DeployResultJson>('project:deploy:start --json', { ensureExitCode: 0 }).jsonOutput; // should deploy everything since previous attempt was --dry-run
30+
expect(actual?.result?.numberComponentsDeployed).to.be.greaterThan(1);
31+
});
32+
});

0 commit comments

Comments
 (0)