diff --git a/command-snapshot.json b/command-snapshot.json index bb043608..8175ffac 100644 --- a/command-snapshot.json +++ b/command-snapshot.json @@ -165,6 +165,7 @@ "async", "concise", "coverage-formatters", + "ignore-warnings", "json", "junit", "manifest", @@ -183,7 +184,7 @@ "wait" ], "alias": ["deploy:metadata:validate"], - "flagChars": ["a", "d", "l", "m", "o", "t", "w", "x"], + "flagChars": ["a", "d", "g", "l", "m", "o", "t", "w", "x"], "flagAliases": [] }, { diff --git a/src/commands/project/deploy/validate.ts b/src/commands/project/deploy/validate.ts index b924f522..d5ea2716 100644 --- a/src/commands/project/deploy/validate.ts +++ b/src/commands/project/deploy/validate.ts @@ -111,6 +111,12 @@ export default class DeployMetadataValidate extends SfCommand helpValue: '', min: 1, }), + 'ignore-warnings': Flags.boolean({ + char: 'g', + summary: deployMessages.getMessage('flags.ignore-warnings.summary'), + description: deployMessages.getMessage('flags.ignore-warnings.description'), + default: false, + }), 'coverage-formatters': { ...coverageFormattersFlag, helpGroup: testFlags }, junit: Flags.boolean({ summary: messages.getMessage('flags.junit.summary'), diff --git a/test/commands/deploy/metadata/validate.nut.ts b/test/commands/deploy/metadata/validate.nut.ts index 7751bc41..83042650 100644 --- a/test/commands/deploy/metadata/validate.nut.ts +++ b/test/commands/deploy/metadata/validate.nut.ts @@ -67,5 +67,35 @@ describe('deploy metadata validate NUTs', () => { expect(deployPost?.result.numberComponentsDeployed).to.equal(12); expect(deployPost?.result.checkOnly).to.be.true; }); + + it('should validate deploy with destructive changes and --ignore-warnings', async () => { + // If you try to delete something in the org that isn't there, a warning is returned + // so this test tries to delete an apex class that isn't in the org. + + execCmd('project deploy start -d force-app -d my-app -d foo-bar'); + // create package.xml + execCmd('project generate manifest -p force-app'); + + const destroyXmlContents = ` + + + NonExistantClass + ApexClass + + 58.0 + `; + // create destroy.xml + await testkit.writeFile(path.join(testkit.projectDir, 'destroy.xml'), destroyXmlContents); + + const deploy = await testkit.execute('project:deploy:validate', { + args: '--manifest package.xml --pre-destructive-changes destroy.xml --ignore-warnings', + json: true, + exitCode: 0, + }); + expect(deploy?.result.success).to.be.true; + expect(deploy?.result.numberComponentsDeployed).to.equal(10); + expect(deploy?.result.checkOnly).to.be.true; + expect(deploy?.result.ignoreWarnings).to.be.true; + }); }); });