From 794c5e8276e2b14d463fc4e6e440add9657406a4 Mon Sep 17 00:00:00 2001 From: Steve Hetzel Date: Tue, 7 Nov 2023 15:47:02 -0700 Subject: [PATCH 1/3] fix: add ignore-warnings flag to deploy validate --- command-snapshot.json | 3 +- src/commands/project/deploy/validate.ts | 6 ++++ test/commands/deploy/metadata/validate.nut.ts | 29 +++++++++++++++++++ 3 files changed, 37 insertions(+), 1 deletion(-) 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..ff2c290d 100644 --- a/test/commands/deploy/metadata/validate.nut.ts +++ b/test/commands/deploy/metadata/validate.nut.ts @@ -67,5 +67,34 @@ 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(12); + expect(deploy?.result.checkOnly).to.be.true; + }); }); }); From 6ab0e4ea8cb1466f1089bc1cab05ad35b01b6d73 Mon Sep 17 00:00:00 2001 From: Steve Hetzel Date: Tue, 7 Nov 2023 16:34:59 -0700 Subject: [PATCH 2/3] fix: update the nut --- test/commands/deploy/metadata/validate.nut.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/commands/deploy/metadata/validate.nut.ts b/test/commands/deploy/metadata/validate.nut.ts index ff2c290d..fdce4ae2 100644 --- a/test/commands/deploy/metadata/validate.nut.ts +++ b/test/commands/deploy/metadata/validate.nut.ts @@ -93,7 +93,7 @@ describe('deploy metadata validate NUTs', () => { exitCode: 0, }); expect(deploy?.result.success).to.be.true; - expect(deploy?.result.numberComponentsDeployed).to.equal(12); + expect(deploy?.result.numberComponentsDeployed).to.equal(10); expect(deploy?.result.checkOnly).to.be.true; }); }); From 32c06223bfa7b94605317b7f0d677b082fea7947 Mon Sep 17 00:00:00 2001 From: Steve Hetzel Date: Wed, 8 Nov 2023 11:43:58 -0700 Subject: [PATCH 3/3] chore: update NUT --- test/commands/deploy/metadata/validate.nut.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/test/commands/deploy/metadata/validate.nut.ts b/test/commands/deploy/metadata/validate.nut.ts index fdce4ae2..83042650 100644 --- a/test/commands/deploy/metadata/validate.nut.ts +++ b/test/commands/deploy/metadata/validate.nut.ts @@ -95,6 +95,7 @@ describe('deploy metadata validate NUTs', () => { 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; }); }); });