Skip to content
Merged
22 changes: 12 additions & 10 deletions src/utils/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,8 @@ export type DeployOptions = {
concise?: boolean;
'single-package'?: boolean;
status?: RequestStatus;

'pre-destructive-changes'?: string;
'post-destructive-changes'?: string;

'purge-on-delete'?: boolean;
};

Expand Down Expand Up @@ -145,14 +143,18 @@ export async function executeDeploy(
} else {
// instantiate source tracking
// stl will decide, based on the org's properties, what needs to be done
const stl = await SourceTracking.create({
org,
// mdapi format deploys don't require a project, but at this point we need one
project: project ?? (await SfProject.resolve()),
subscribeSDREvents: true,
ignoreConflicts: opts['ignore-conflicts'],
});
registry = stl.registry;
let stl: SourceTracking | undefined;
if (!opts['dry-run'] || !(await org.tracksSource())) {
stl = await SourceTracking.create({
org,
// mdapi format deploys don't require a project, but at this point we need one
project: project ?? (await SfProject.resolve()),
subscribeSDREvents: true,
ignoreConflicts: opts['ignore-conflicts'],
});
registry = stl.registry;
}

componentSet = await buildComponentSet(opts, stl);
if (componentSet.size === 0) {
if (opts['source-dir'] ?? opts.manifest ?? opts.metadata ?? throwOnEmpty) {
Expand Down
4 changes: 2 additions & 2 deletions test/commands/deploy/metadata/quick.nut.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,8 @@ describe('deploy metadata quick NUTs', () => {
});

it('should fail to deploy previously deployed deployment', async () => {
const first = await testkit.execute<DeployResultJson>('deploy:metadata', {
args: '--source-dir force-app',
const first = await testkit.execute<DeployResultJson>('project:deploy:start', {
args: '--source-dir force-app --ignore-conflicts',
json: true,
exitCode: 0,
});
Expand Down
32 changes: 32 additions & 0 deletions test/nuts/deploy/start.nut.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
* Copyright (c) 2023, salesforce.com, inc.
* All rights reserved.
* Licensed under the BSD 3-Clause license.
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
*/
import { fileURLToPath } from 'node:url';
import { execCmd } from '@salesforce/cli-plugins-testkit';
import { expect } from 'chai';
import { SourceTestkit } from '@salesforce/source-testkit';
import { DeployResultJson } from '../../../src/utils/types.js';

describe('project deploy start NUTs', () => {
let testkit: SourceTestkit;

before(async () => {
testkit = await SourceTestkit.create({
repository: 'https://github.com/trailheadapps/dreamhouse-lwc.git',
nut: fileURLToPath(import.meta.url),
});
});

after(async () => {
await testkit?.clean();
});

it('--source-dir --dry-run should NOT affect source-tracking', async () => {
execCmd('project:deploy:start --dry-run --source-dir force-app', { ensureExitCode: 0 });
const actual = execCmd<DeployResultJson>('project:deploy:start --json', { ensureExitCode: 0 }).jsonOutput; // should deploy everything since previous attempt was --dry-run
expect(actual?.result?.numberComponentsDeployed).to.be.greaterThan(1);
});
});
Loading