Skip to content

Commit

Permalink
feat: add --target-org to deploy cancel
Browse files Browse the repository at this point in the history
  • Loading branch information
WillieRuemmele committed Mar 18, 2024
1 parent 3169e1a commit 4eaf68f
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 7 deletions.
6 changes: 3 additions & 3 deletions command-snapshot.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,16 +70,16 @@
"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"
},
{
"alias": ["deploy:metadata:preview"],
"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"
},
{
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
8 changes: 5 additions & 3 deletions test/commands/deploy/metadata/cancel.nut.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ function readDeployCache(sessionDir: string): Record<string, CachedOptions> {
return JSON.parse(contents) as Record<string, CachedOptions>;
}

describe('deploy metadata cancel NUTs', () => {
describe.only('deploy metadata cancel NUTs', () => {
let session: TestSession;

before(async () => {
Expand Down Expand Up @@ -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<DeployResultJson>(
'deploy:metadata --source-dir force-app --async --ignore-conflicts --json',
{
Expand Down 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 4eaf68f

Please sign in to comment.