Skip to content

Commit 6b99f44

Browse files
fix: add purgeondelete flag to deploy (#394)
* 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]>
1 parent a7e3e1e commit 6b99f44

File tree

6 files changed

+97
-1
lines changed

6 files changed

+97
-1
lines changed

command-snapshot.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
"ignorewarnings",
1717
"json",
1818
"loglevel",
19+
"purgeondelete",
1920
"runtests",
2021
"singlepackage",
2122
"soapdeploy",
@@ -143,6 +144,7 @@
143144
"metadata",
144145
"postdestructivechanges",
145146
"predestructivechanges",
147+
"purgeondelete",
146148
"runtests",
147149
"soapdeploy",
148150
"sourcepath",

messages/deploy.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@
2929
"validateDeployRequestId": "deploy request ID of the validated deployment to run a Quick Deploy",
3030
"soapDeploy": "deploy metadata with SOAP API instead of REST API",
3131
"predestructivechanges": "file path for a manifest (destructiveChangesPre.xml) of components to delete before the deploy",
32-
"postdestructivechanges": "file path for a manifest (destructiveChangesPost.xml) of components to delete after the deploy"
32+
"postdestructivechanges": "file path for a manifest (destructiveChangesPost.xml) of components to delete after the deploy",
33+
"purgeOnDelete": "the deleted components in the destructiveChanges.xml manifest file aren't stored in the Recycle Bin. Instead, they become immediately eligible for deletion."
3334
},
3435
"flagsLong": {
3536
"sourcePath": [

messages/md.deploy.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
"validatedDeployRequestId": "request ID of the validated deployment to run a Quick Deploy",
2727
"singlePackage": "Indicates that the zip file points to a directory structure for a single package",
2828
"soapDeploy": "deploy metadata with SOAP API instead of REST API",
29+
"purgeOnDelete": "specify that deleted components in the destructive changes manifest file are immediately eligible for deletion rather than being stored in the Recycle Bin",
2930
"concise": "omit success messages for smaller JSON output"
3031
},
3132
"flagsLong": {

src/commands/force/mdapi/beta/deploy.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,9 @@ export class Deploy extends DeployCommand {
9494
description: messages.getMessage('flags.soapDeploy'),
9595
longDescription: messages.getMessage('flagsLong.soapDeploy'),
9696
}),
97+
purgeondelete: flags.boolean({
98+
description: messages.getMessage('flags.purgeOnDelete'),
99+
}),
97100
concise: flags.builtin({
98101
description: messages.getMessage('flags.concise'),
99102
}),
@@ -123,6 +126,7 @@ export class Deploy extends DeployCommand {
123126
usernameOrConnection: this.org.getUsername(),
124127
...deploymentOptions,
125128
apiOptions: {
129+
purgeOnDelete: this.getFlag('purgeondelete', false),
126130
ignoreWarnings: this.getFlag('ignorewarnings', false),
127131
rollbackOnError: !this.getFlag('ignoreerrors', false),
128132
checkOnly: this.getFlag('checkonly', false),

src/commands/force/source/deploy.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,10 @@ export class Deploy extends DeployCommand {
7070
description: messages.getMessage('flags.ignoreWarnings'),
7171
longDescription: messages.getMessage('flagsLong.ignoreWarnings'),
7272
}),
73+
purgeondelete: flags.boolean({
74+
description: messages.getMessage('flags.purgeOnDelete'),
75+
dependsOn: ['manifest'],
76+
}),
7377
validateddeployrequestid: flags.id({
7478
char: 'q',
7579
description: messages.getMessage('flags.validateDeployRequestId'),
@@ -150,6 +154,7 @@ export class Deploy extends DeployCommand {
150154
const deploy = await this.componentSet.deploy({
151155
usernameOrConnection: this.org.getUsername(),
152156
apiOptions: {
157+
purgeOnDelete: this.getFlag<boolean>('purgeondelete', false),
153158
ignoreWarnings: this.getFlag<boolean>('ignorewarnings', false),
154159
rollbackOnError: !this.getFlag<boolean>('ignoreerrors', false),
155160
checkOnly: this.getFlag<boolean>('checkonly', false),

test/commands/source/deploy.test.ts

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,9 +156,11 @@ describe('force:source:deploy', () => {
156156
ignoreWarnings: false,
157157
rollbackOnError: true,
158158
checkOnly: false,
159+
purgeOnDelete: false,
159160
runTests: [],
160161
testLevel: 'NoTestRun',
161162
rest: false,
163+
...overrides?.apiOptions,
162164
},
163165
};
164166
if (overrides?.apiOptions) {
@@ -263,6 +265,87 @@ describe('force:source:deploy', () => {
263265
ensureProgressBar(0);
264266
});
265267

268+
it('should pass purgeOnDelete flag', async () => {
269+
const manifest = 'package.xml';
270+
const destructiveChanges = 'destructiveChangesPost.xml';
271+
const runTests = ['MyClassTest'];
272+
const testLevel = 'RunSpecifiedTests';
273+
const result = await runDeployCmd([
274+
`--manifest=${manifest}`,
275+
`--postdestructivechanges=${destructiveChanges}`,
276+
'--ignorewarnings',
277+
'--ignoreerrors',
278+
'--checkonly',
279+
`--runtests=${runTests[0]}`,
280+
`--testlevel=${testLevel}`,
281+
'--purgeondelete',
282+
'--json',
283+
]);
284+
285+
expect(result).to.deep.equal(expectedResults);
286+
ensureDeployArgs({
287+
apiOptions: {
288+
checkOnly: true,
289+
ignoreWarnings: true,
290+
purgeOnDelete: true,
291+
rest: false,
292+
rollbackOnError: false,
293+
runTests: ['MyClassTest'],
294+
testLevel: 'RunSpecifiedTests',
295+
},
296+
});
297+
ensureCreateComponentSetArgs({
298+
manifest: {
299+
manifestPath: manifest,
300+
directoryPaths: [defaultDir],
301+
destructiveChangesPost: destructiveChanges,
302+
destructiveChangesPre: undefined,
303+
},
304+
});
305+
ensureHookArgs();
306+
ensureProgressBar(0);
307+
});
308+
309+
it('should pass default purgeondelete flag to false', async () => {
310+
const manifest = 'package.xml';
311+
const destructiveChanges = 'destructiveChangesPost.xml';
312+
const runTests = ['MyClassTest'];
313+
const testLevel = 'RunSpecifiedTests';
314+
const result = await runDeployCmd([
315+
`--manifest=${manifest}`,
316+
`--postdestructivechanges=${destructiveChanges}`,
317+
'--ignorewarnings',
318+
'--ignoreerrors',
319+
'--checkonly',
320+
`--runtests=${runTests[0]}`,
321+
`--testlevel=${testLevel}`,
322+
'--json',
323+
]);
324+
325+
expect(result).to.deep.equal(expectedResults);
326+
ensureDeployArgs({
327+
apiOptions: {
328+
checkOnly: true,
329+
ignoreWarnings: true,
330+
purgeOnDelete: false,
331+
rest: false,
332+
rollbackOnError: false,
333+
runTests: ['MyClassTest'],
334+
testLevel: 'RunSpecifiedTests',
335+
},
336+
});
337+
ensureCreateComponentSetArgs({
338+
manifest: {
339+
manifestPath: manifest,
340+
directoryPaths: [defaultDir],
341+
destructiveChangesPost: destructiveChanges,
342+
destructiveChangesPre: undefined,
343+
},
344+
});
345+
ensureHookArgs();
346+
ensureProgressBar(0);
347+
});
348+
266349
it('should pass along all deploy options', async () => {
267350
const manifest = 'package.xml';
268351
const runTests = ['MyClassTest'];

0 commit comments

Comments
 (0)