From 4eaf68fc5872706f1f448b419db099d19d487555 Mon Sep 17 00:00:00 2001 From: Willie Ruemmele Date: Mon, 18 Mar 2024 15:41:29 -0600 Subject: [PATCH] feat: add --target-org to deploy cancel --- command-snapshot.json | 6 +++--- src/commands/project/deploy/cancel.ts | 12 +++++++++++- test/commands/deploy/metadata/cancel.nut.ts | 8 +++++--- 3 files changed, 19 insertions(+), 7 deletions(-) diff --git a/command-snapshot.json b/command-snapshot.json index 6a05a526..c74d50a3 100644 --- a/command-snapshot.json +++ b/command-snapshot.json @@ -70,8 +70,8 @@ "alias": ["deploy:metadata:cancel"], "command": "project:deploy:cancel", "flagAliases": [], - "flagChars": ["i", "r", "w"], - "flags": ["async", "job-id", "json", "use-most-recent", "wait"], + "flagChars": ["i", "o", "r", "w"], + "flags": ["async", "job-id", "json", "target-org", "use-most-recent", "wait"], "plugin": "@salesforce/plugin-deploy-retrieve" }, { @@ -79,7 +79,7 @@ "command": "project:deploy:preview", "flagAliases": [], "flagChars": ["c", "d", "m", "o", "x"], - "flags": ["ignore-conflicts", "json", "manifest", "metadata", "source-dir", "target-org", "concise"], + "flags": ["concise", "ignore-conflicts", "json", "manifest", "metadata", "source-dir", "target-org"], "plugin": "@salesforce/plugin-deploy-retrieve" }, { diff --git a/src/commands/project/deploy/cancel.ts b/src/commands/project/deploy/cancel.ts index 0dfc39af..6c56eac8 100644 --- a/src/commands/project/deploy/cancel.ts +++ b/src/commands/project/deploy/cancel.ts @@ -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 { public static readonly description = messages.getMessage('description'); @@ -26,6 +27,11 @@ export default class DeployMetadataCancel extends SfCommand { 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'), @@ -63,7 +69,11 @@ export default class DeployMetadataCancel extends SfCommand { 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 && diff --git a/test/commands/deploy/metadata/cancel.nut.ts b/test/commands/deploy/metadata/cancel.nut.ts index f875d007..2e8ecda0 100644 --- a/test/commands/deploy/metadata/cancel.nut.ts +++ b/test/commands/deploy/metadata/cancel.nut.ts @@ -19,7 +19,7 @@ function readDeployCache(sessionDir: string): Record { return JSON.parse(contents) as Record; } -describe('deploy metadata cancel NUTs', () => { +describe.only('deploy metadata cancel NUTs', () => { let session: TestSession; before(async () => { @@ -65,7 +65,7 @@ describe('deploy metadata cancel NUTs', () => { } }); - it.skip('should cancel most recently started deployment without specifying the flag', () => { + it('should cancel most recently started deployment without specifying the flag', () => { const first = execCmd( 'deploy:metadata --source-dir force-app --async --ignore-conflicts --json', { @@ -105,7 +105,9 @@ describe('deploy metadata cancel NUTs', () => { const cacheBefore = readDeployCache(session.dir); expect(cacheBefore).to.have.property(first.id); - const cancel = execCmd(`deploy:metadata:cancel --job-id ${first.id} --json`); + const cancel = execCmd( + `deploy:metadata:cancel --job-id ${first.id} --target-org ${session.orgs.get('default')?.username}--json` + ); assert(cancel.jsonOutput); if (cancel.jsonOutput.status === 0) {