Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add purgeondelete flag to deploy #394

Merged
merged 4 commits into from
Jan 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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."
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jshackell-sfdc I took this description right from here but let me know if it should be different

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I reworked it a bit, see below.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"purgeOnDelete": "the deleted components in the destructiveChanges.xml manifest file aren't stored in the Recycle Bin. Instead, they become immediately eligible for deletion."
"purgeOnDelete": "specify that deleted components in the destructive changes manifest file are immediately eligible for deletion rather than being stored in the Recycle Bin"

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

committed 👍

},
"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