From 6aeaeffdb4f6bd61e6e022311c25e7b78f98e6b1 Mon Sep 17 00:00:00 2001 From: Steve Hetzel Date: Fri, 17 May 2024 11:47:10 -0600 Subject: [PATCH] fix: keep original error and fail the diagnostic test * fix: keep original error and fail the diagnostic test * fix: update test for code changes * chore: dedupe lockfile --------- Co-authored-by: mshanemc --- package.json | 2 +- src/commands/org/login/web.ts | 4 ++-- src/hooks/diagnostics.ts | 2 +- test/hooks/diagnostics.test.ts | 6 +++--- yarn.lock | 39 ++++++---------------------------- 5 files changed, 14 insertions(+), 39 deletions(-) diff --git a/package.json b/package.json index 38dfb099..6c29c4a5 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,7 @@ "@inquirer/checkbox": "^1.5.2", "@inquirer/select": "^1.3.3", "@oclif/core": "^3.26.5", - "@salesforce/core": "^7.3.5", + "@salesforce/core": "^7.3.8", "@salesforce/kit": "^3.1.1", "@salesforce/plugin-info": "^3.2.7", "@salesforce/sf-plugins-core": "^9.0.7", diff --git a/src/commands/org/login/web.ts b/src/commands/org/login/web.ts index 0a0b203a..509fdc24 100644 --- a/src/commands/org/login/web.ts +++ b/src/commands/org/login/web.ts @@ -102,8 +102,8 @@ export default class LoginWeb extends SfCommand { return fields; } catch (err) { Logger.childFromRoot('LoginWebCommand').debug(err); - if (err instanceof Error && err.name === 'AuthCodeExchangeError') { - throw new SfError(messages.getMessage('invalidClientId', [err.message]), undefined, undefined, err); + if (err instanceof SfError && err.name === 'AuthCodeExchangeError') { + err.message = messages.getMessage('invalidClientId', [err.message]); } throw err; } diff --git a/src/hooks/diagnostics.ts b/src/hooks/diagnostics.ts index b63d5172..95879d39 100644 --- a/src/hooks/diagnostics.ts +++ b/src/hooks/diagnostics.ts @@ -100,7 +100,7 @@ const cryptoVersionTest = async (doctor: SfDoctor): Promise => { const testName1 = `[${pluginName}] CLI supports v2 crypto`; let status1 = 'pass'; if (!sfCryptoV2Support) { - status1 = 'warn'; + status1 = 'fail'; doctor.addSuggestion(messages.getMessage('sfCryptoV2Support')); } void Lifecycle.getInstance().emit('Doctor:diagnostic', { testName: testName1, status: status1 }); diff --git a/test/hooks/diagnostics.test.ts b/test/hooks/diagnostics.test.ts index be8a97cb..bddbeefe 100644 --- a/test/hooks/diagnostics.test.ts +++ b/test/hooks/diagnostics.test.ts @@ -64,7 +64,7 @@ describe('Doctor diagnostics', () => { sandbox.restore(); }); - it('should warn when CLI does not support v2 crypto', async () => { + it('should fail when CLI does not support v2 crypto', async () => { sandbox.stub(util, 'promisify').returns(() => ({ stdout: JSON.stringify([{ version: '6.5.0' }]) })); process.env.SF_USE_GENERIC_UNIX_KEYCHAIN = 'false'; @@ -86,7 +86,7 @@ describe('Doctor diagnostics', () => { expect(lifecycleEmitStub.args[0][0]).to.equal('Doctor:diagnostic'); expect(lifecycleEmitStub.args[0][1]).to.deep.equal({ testName: `[${pluginName}] CLI supports v2 crypto`, - status: 'warn', + status: 'fail', }); }); @@ -135,7 +135,7 @@ describe('Doctor diagnostics', () => { expect(lifecycleEmitStub.args[0][0]).to.equal('Doctor:diagnostic'); expect(lifecycleEmitStub.args[0][1]).to.deep.equal({ testName: `[${pluginName}] CLI supports v2 crypto`, - status: 'warn', + status: 'fail', }); expect(addSuggestionStub.args[1][0]).to.equal(messages.getMessage('sfCryptoV2Unstable')); expect(lifecycleEmitStub.args[1][0]).to.equal('Doctor:diagnostic'); diff --git a/yarn.lock b/yarn.lock index af3b8313..ff178595 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1445,10 +1445,10 @@ strip-ansi "6.0.1" ts-retry-promise "^0.8.0" -"@salesforce/core@^7.3.1", "@salesforce/core@^7.3.3", "@salesforce/core@^7.3.4", "@salesforce/core@^7.3.5": - version "7.3.6" - resolved "https://registry.yarnpkg.com/@salesforce/core/-/core-7.3.6.tgz#b2769abf3d8cee6fef26741dd9bdbe977a497023" - integrity sha512-LngaY4GxixZ7X5oPGa00NdRzpqTXC8jPOQ/H+oFNiZb8nhMfYTBsQob258z33sIBf+G/5RZOJgX10Z+teJzt6A== +"@salesforce/core@^7.3.1", "@salesforce/core@^7.3.3", "@salesforce/core@^7.3.4", "@salesforce/core@^7.3.8": + version "7.3.8" + resolved "https://registry.yarnpkg.com/@salesforce/core/-/core-7.3.8.tgz#8a646b5321f08c0fb4d22e2fa8b1d60b3a20df9b" + integrity sha512-VWhXHfjwjtC3pJWYp8wt5/fnNQ5tK61ovMG5eteXzVD2oFd7og1f6YjwuAzoYIZK7kYWWv7KJfGtCsPs7Zw+Ww== dependencies: "@jsforce/jsforce-node" "^3.2.0" "@salesforce/kit" "^3.1.1" @@ -6956,16 +6956,7 @@ srcset@^5.0.0: resolved "https://registry.yarnpkg.com/srcset/-/srcset-5.0.1.tgz#e660a728f195419e4afa95121099bc9efb7a1e36" integrity sha512-/P1UYbGfJVlxZag7aABNRrulEXAwCSDo7fklafOQrantuPTDmYgijJMks2zusPCVzgW9+4P69mq7w6pYuZpgxw== -"string-width-cjs@npm:string-width@^4.2.0": - version "4.2.3" - resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010" - integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g== - dependencies: - emoji-regex "^8.0.0" - is-fullwidth-code-point "^3.0.0" - strip-ansi "^6.0.1" - -string-width@^4.0.0, string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.3: +"string-width-cjs@npm:string-width@^4.2.0", string-width@^4.0.0, string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.3: version "4.2.3" resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010" integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g== @@ -7024,14 +7015,7 @@ string_decoder@~1.1.1: dependencies: safe-buffer "~5.1.0" -"strip-ansi-cjs@npm:strip-ansi@^6.0.1": - version "6.0.1" - resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9" - integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A== - dependencies: - ansi-regex "^5.0.1" - -strip-ansi@6.0.1, strip-ansi@^6.0.0, strip-ansi@^6.0.1: +"strip-ansi-cjs@npm:strip-ansi@^6.0.1", strip-ansi@6.0.1, strip-ansi@^6.0.0, strip-ansi@^6.0.1: version "6.0.1" resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9" integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A== @@ -7579,7 +7563,7 @@ workerpool@6.2.1: resolved "https://registry.yarnpkg.com/workerpool/-/workerpool-6.2.1.tgz#46fc150c17d826b86a008e5a4508656777e9c343" integrity sha512-ILEIE97kDZvF9Wb9f6h5aXK4swSlKGUcOEGiIYb2OOu/IrDU9iwj0fD//SsA6E5ibwJxpEvhullJY4Sl4GcpAw== -"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0": +"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0", wrap-ansi@^7.0.0: version "7.0.0" resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43" integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q== @@ -7597,15 +7581,6 @@ wrap-ansi@^6.2.0: string-width "^4.1.0" strip-ansi "^6.0.0" -wrap-ansi@^7.0.0: - version "7.0.0" - resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43" - integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q== - dependencies: - ansi-styles "^4.0.0" - string-width "^4.1.0" - strip-ansi "^6.0.0" - wrap-ansi@^8.1.0: version "8.1.0" resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-8.1.0.tgz#56dc22368ee570face1b49819975d9b9a5ead214"