Skip to content

Commit

Permalink
Merge pull request #945 from salesforcecli/wr/cancelWithOrg
Browse files Browse the repository at this point in the history
feat: add --target-org to deploy cancel
  • Loading branch information
WillieRuemmele authored Mar 25, 2024
2 parents 9929ea7 + e6910d1 commit 8fbf9e6
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
4 changes: 2 additions & 2 deletions command-snapshot.json
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@
"alias": ["deploy:metadata:cancel"],
"command": "project:deploy:cancel",
"flagAliases": [],
"flagChars": ["i", "r", "w"],
"flags": ["async", "flags-dir", "job-id", "json", "use-most-recent", "wait"],
"flagChars": ["i", "o", "r", "w"],
"flags": ["async", "flags-dir", "job-id", "json", "target-org", "use-most-recent", "wait"],
"plugin": "@salesforce/plugin-deploy-retrieve"
},
{
Expand Down
12 changes: 11 additions & 1 deletion src/commands/project/deploy/cancel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { DeployResultJson } from '../../../utils/types.js';

Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
const messages = Messages.loadMessages('@salesforce/plugin-deploy-retrieve', 'deploy.metadata.cancel');
const deployMessages = Messages.loadMessages('@salesforce/plugin-deploy-retrieve', 'deploy.metadata');

export default class DeployMetadataCancel extends SfCommand<DeployResultJson> {
public static readonly description = messages.getMessage('description');
Expand All @@ -26,6 +27,11 @@ export default class DeployMetadataCancel extends SfCommand<DeployResultJson> {
public static readonly deprecateAliases = true;

public static readonly flags = {
'target-org': Flags.optionalOrg({
char: 'o',
description: deployMessages.getMessage('flags.target-org.description'),
summary: deployMessages.getMessage('flags.target-org.summary'),
}),
async: Flags.boolean({
summary: messages.getMessage('flags.async.summary'),
description: messages.getMessage('flags.async.description'),
Expand Down Expand Up @@ -63,7 +69,11 @@ export default class DeployMetadataCancel extends SfCommand<DeployResultJson> {
const jobId = cache.resolveLatest(flags['use-most-recent'], flags['job-id']);

// cancel don't care about your tracking conflicts
const deployOpts = { ...cache.maybeGet(jobId), 'ignore-conflicts': true };
const deployOpts = {
'target-org': flags['target-org']?.getUsername(),
...cache.maybeGet(jobId),
'ignore-conflicts': true,
};
// we may already know the job finished
if (
deployOpts.status &&
Expand Down
4 changes: 3 additions & 1 deletion test/commands/deploy/metadata/cancel.nut.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,9 @@ describe('deploy metadata cancel NUTs', () => {
const cacheBefore = readDeployCache(session.dir);
expect(cacheBefore).to.have.property(first.id);

const cancel = execCmd<DeployResultJson>(`deploy:metadata:cancel --job-id ${first.id} --json`);
const cancel = execCmd<DeployResultJson>(
`deploy:metadata:cancel --job-id ${first.id} --target-org ${session.orgs.get('default')?.username} --json`
);
assert(cancel.jsonOutput);

if (cancel.jsonOutput.status === 0) {
Expand Down

0 comments on commit 8fbf9e6

Please sign in to comment.