Skip to content

Commit

Permalink
fix: add purgeondelete flag to deploy (#394)
Browse files Browse the repository at this point in the history
* fix: add purgeondelete flag to deploy

* chore: Juliet's Update messages/md.deploy.json

Co-authored-by: Juliet Shackell <[email protected]>

Co-authored-by: Juliet Shackell <[email protected]>
  • Loading branch information
WillieRuemmele and jshackell-sfdc authored Jan 27, 2022
1 parent a7e3e1e commit 6b99f44
Show file tree
Hide file tree
Showing 6 changed files with 97 additions and 1 deletion.
2 changes: 2 additions & 0 deletions command-snapshot.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"ignorewarnings",
"json",
"loglevel",
"purgeondelete",
"runtests",
"singlepackage",
"soapdeploy",
Expand Down Expand Up @@ -143,6 +144,7 @@
"metadata",
"postdestructivechanges",
"predestructivechanges",
"purgeondelete",
"runtests",
"soapdeploy",
"sourcepath",
Expand Down
3 changes: 2 additions & 1 deletion messages/deploy.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@
"validateDeployRequestId": "deploy request ID of the validated deployment to run a Quick Deploy",
"soapDeploy": "deploy metadata with SOAP API instead of REST API",
"predestructivechanges": "file path for a manifest (destructiveChangesPre.xml) of components to delete before the deploy",
"postdestructivechanges": "file path for a manifest (destructiveChangesPost.xml) of components to delete after the deploy"
"postdestructivechanges": "file path for a manifest (destructiveChangesPost.xml) of components to delete after the deploy",
"purgeOnDelete": "the deleted components in the destructiveChanges.xml manifest file aren't stored in the Recycle Bin. Instead, they become immediately eligible for deletion."
},
"flagsLong": {
"sourcePath": [
Expand Down
1 change: 1 addition & 0 deletions messages/md.deploy.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"validatedDeployRequestId": "request ID of the validated deployment to run a Quick Deploy",
"singlePackage": "Indicates that the zip file points to a directory structure for a single package",
"soapDeploy": "deploy metadata with SOAP API instead of REST API",
"purgeOnDelete": "specify that deleted components in the destructive changes manifest file are immediately eligible for deletion rather than being stored in the Recycle Bin",
"concise": "omit success messages for smaller JSON output"
},
"flagsLong": {
Expand Down
4 changes: 4 additions & 0 deletions src/commands/force/mdapi/beta/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,9 @@ export class Deploy extends DeployCommand {
description: messages.getMessage('flags.soapDeploy'),
longDescription: messages.getMessage('flagsLong.soapDeploy'),
}),
purgeondelete: flags.boolean({
description: messages.getMessage('flags.purgeOnDelete'),
}),
concise: flags.builtin({
description: messages.getMessage('flags.concise'),
}),
Expand Down Expand Up @@ -123,6 +126,7 @@ export class Deploy extends DeployCommand {
usernameOrConnection: this.org.getUsername(),
...deploymentOptions,
apiOptions: {
purgeOnDelete: this.getFlag('purgeondelete', false),
ignoreWarnings: this.getFlag('ignorewarnings', false),
rollbackOnError: !this.getFlag('ignoreerrors', false),
checkOnly: this.getFlag('checkonly', false),
Expand Down
5 changes: 5 additions & 0 deletions src/commands/force/source/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@ export class Deploy extends DeployCommand {
description: messages.getMessage('flags.ignoreWarnings'),
longDescription: messages.getMessage('flagsLong.ignoreWarnings'),
}),
purgeondelete: flags.boolean({
description: messages.getMessage('flags.purgeOnDelete'),
dependsOn: ['manifest'],
}),
validateddeployrequestid: flags.id({
char: 'q',
description: messages.getMessage('flags.validateDeployRequestId'),
Expand Down Expand Up @@ -150,6 +154,7 @@ export class Deploy extends DeployCommand {
const deploy = await this.componentSet.deploy({
usernameOrConnection: this.org.getUsername(),
apiOptions: {
purgeOnDelete: this.getFlag<boolean>('purgeondelete', false),
ignoreWarnings: this.getFlag<boolean>('ignorewarnings', false),
rollbackOnError: !this.getFlag<boolean>('ignoreerrors', false),
checkOnly: this.getFlag<boolean>('checkonly', false),
Expand Down
83 changes: 83 additions & 0 deletions test/commands/source/deploy.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,11 @@ describe('force:source:deploy', () => {
ignoreWarnings: false,
rollbackOnError: true,
checkOnly: false,
purgeOnDelete: false,
runTests: [],
testLevel: 'NoTestRun',
rest: false,
...overrides?.apiOptions,
},
};
if (overrides?.apiOptions) {
Expand Down Expand Up @@ -263,6 +265,87 @@ describe('force:source:deploy', () => {
ensureProgressBar(0);
});

it('should pass purgeOnDelete flag', async () => {
const manifest = 'package.xml';
const destructiveChanges = 'destructiveChangesPost.xml';
const runTests = ['MyClassTest'];
const testLevel = 'RunSpecifiedTests';
const result = await runDeployCmd([
`--manifest=${manifest}`,
`--postdestructivechanges=${destructiveChanges}`,
'--ignorewarnings',
'--ignoreerrors',
'--checkonly',
`--runtests=${runTests[0]}`,
`--testlevel=${testLevel}`,
'--purgeondelete',
'--json',
]);

expect(result).to.deep.equal(expectedResults);
ensureDeployArgs({
apiOptions: {
checkOnly: true,
ignoreWarnings: true,
purgeOnDelete: true,
rest: false,
rollbackOnError: false,
runTests: ['MyClassTest'],
testLevel: 'RunSpecifiedTests',
},
});
ensureCreateComponentSetArgs({
manifest: {
manifestPath: manifest,
directoryPaths: [defaultDir],
destructiveChangesPost: destructiveChanges,
destructiveChangesPre: undefined,
},
});
ensureHookArgs();
ensureProgressBar(0);
});

it('should pass default purgeondelete flag to false', async () => {
const manifest = 'package.xml';
const destructiveChanges = 'destructiveChangesPost.xml';
const runTests = ['MyClassTest'];
const testLevel = 'RunSpecifiedTests';
const result = await runDeployCmd([
`--manifest=${manifest}`,
`--postdestructivechanges=${destructiveChanges}`,
'--ignorewarnings',
'--ignoreerrors',
'--checkonly',
`--runtests=${runTests[0]}`,
`--testlevel=${testLevel}`,
'--json',
]);

expect(result).to.deep.equal(expectedResults);
ensureDeployArgs({
apiOptions: {
checkOnly: true,
ignoreWarnings: true,
purgeOnDelete: false,
rest: false,
rollbackOnError: false,
runTests: ['MyClassTest'],
testLevel: 'RunSpecifiedTests',
},
});
ensureCreateComponentSetArgs({
manifest: {
manifestPath: manifest,
directoryPaths: [defaultDir],
destructiveChangesPost: destructiveChanges,
destructiveChangesPre: undefined,
},
});
ensureHookArgs();
ensureProgressBar(0);
});

it('should pass along all deploy options', async () => {
const manifest = 'package.xml';
const runTests = ['MyClassTest'];
Expand Down

0 comments on commit 6b99f44

Please sign in to comment.