From e52776e1cf448836db924292a128c5e2f174c008 Mon Sep 17 00:00:00 2001 From: zFernand0 <37381190+zFernand0@users.noreply.github.com> Date: Mon, 26 Feb 2024 14:46:46 +0000 Subject: [PATCH 1/3] Fix plug-in peerDep check Signed-off-by: zFernand0 <37381190+zFernand0@users.noreply.github.com> --- packages/imperative/CHANGELOG.md | 3 ++- .../src/plugins/PluginManagementFacility.ts | 27 ++++++++----------- 2 files changed, 13 insertions(+), 17 deletions(-) diff --git a/packages/imperative/CHANGELOG.md b/packages/imperative/CHANGELOG.md index bc11d8f317..6c13ee073d 100644 --- a/packages/imperative/CHANGELOG.md +++ b/packages/imperative/CHANGELOG.md @@ -6,7 +6,8 @@ All notable changes to the Imperative package will be documented in this file. - BugFix: Updated additional dependencies for technical currency. [#2061](https://github.com/zowe/zowe-cli/pull/2061) - BugFix: Updated engine to Node 16.7.0. [#2061](https://github.com/zowe/zowe-cli/pull/2061) -- BugFix: Fixing issue [1689](https://github.com/zowe/zowe-cli/issues/1689) by removing `profileVersion` from response given `--show-inputs-only`. Extended that change to `EnvQuery.ts` where similar soon-to-be obsolete v1 considerations occur +- BugFix: Fixed issue with peerDep warnings showing when a plug-in is installed and the version ranges satisfy the semver requirements. +- BugFix: Fixed issue [#1689](https://github.com/zowe/zowe-cli/issues/1689) by removing `profileVersion` from response given `--show-inputs-only`. Extended that change to `EnvQuery.ts` where similar soon-to-be obsolete v1 considerations occur - BugFix: Change text displayed for configuration from "V2" to "TeamConfig" [#2019](https://github.com/zowe/zowe-cli/issues/2019) - LTS Breaking: [#1703](https://github.com/zowe/zowe-cli/issues/1703) diff --git a/packages/imperative/src/imperative/src/plugins/PluginManagementFacility.ts b/packages/imperative/src/imperative/src/plugins/PluginManagementFacility.ts index cec88ecf4c..2955864793 100644 --- a/packages/imperative/src/imperative/src/plugins/PluginManagementFacility.ts +++ b/packages/imperative/src/imperative/src/plugins/PluginManagementFacility.ts @@ -520,42 +520,37 @@ export class PluginManagementFacility { * Compare the version of a plugin version property with a version property * of its base CLI. * - * If the versions do not intersect (according so semver rules), then a + * If the versions do not satisfies (according so semver rules), then a * PluginIssue is recorded. * * @param pluginName - The name of the plugin. - * * @param pluginVerPropNm - The name of the plugin property containing a version. - * - * @param pluginVerVal - value of the plugin's version. - * + * @param pluginVerRange - value of the plugin's version. * @param cliVerPropNm - The name of the base CLI property containing a version. - * - * @param cliVerVal - value of the base CLI's version. - * + * @param cliVerValue - value of the base CLI's version. */ private comparePluginVersionToCli( pluginName: string, pluginVerPropNm: string, - pluginVerVal: string, + pluginVerRange: string, cliVerPropNm: string, - cliVerVal: string + cliVerValue: string ): void { const cliCmdName = ImperativeConfig.instance.rootCommandName; try { - if (!this.semver.intersects(cliVerVal, pluginVerVal, false)) { + if (!this.semver.satisfies(cliVerValue, pluginVerRange)) { this.pluginIssues.recordIssue(pluginName, IssueSeverity.WARNING, - "The version value (" + pluginVerVal + ") of the plugin's '" + + "The version value (" + pluginVerRange + ") of the plugin's '" + pluginVerPropNm + "' property is incompatible with the version value (" + - cliVerVal + ") of the " + cliCmdName + " command's '" + + cliVerValue + ") of the " + cliCmdName + " command's '" + cliVerPropNm + "' property." ); } } catch (semverExcept) { PluginIssues.instance.recordIssue(pluginName, IssueSeverity.WARNING, "Failed to compare the version value (" + - pluginVerVal + ") of the plugin's '" + pluginVerPropNm + - "' property with the version value (" + cliVerVal + + pluginVerRange + ") of the plugin's '" + pluginVerPropNm + + "' property with the version value (" + cliVerValue + ") of the " + cliCmdName + " command's '" + cliVerPropNm + "' property.\n" + "This can occur when one of the specified values is not a valid version string.\n" + "Reported reason = " + semverExcept.message @@ -937,7 +932,7 @@ export class PluginManagementFacility { * * Both range strings come from the package.json files of the plugin and the * hosting CLI. We consider the version ranges to be compatible if the two - * ranges intersect. This should allow npm to download one common version + * ranges satisfies. This should allow npm to download one common version * of core and of imperative to be owned by the base CLI and shared by the plugin. * * Any errors are recorded in PluginIssues. From ffac0944a236ceb4db9b7702b2799035a8253d27 Mon Sep 17 00:00:00 2001 From: zFernand0 <37381190+zFernand0@users.noreply.github.com> Date: Mon, 26 Feb 2024 15:04:01 +0000 Subject: [PATCH 2/3] forgot to update the unit tests :yum: Signed-off-by: zFernand0 <37381190+zFernand0@users.noreply.github.com> --- .../__tests__/plugins/PluginManagementFacility.unit.test.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/imperative/src/imperative/__tests__/plugins/PluginManagementFacility.unit.test.ts b/packages/imperative/src/imperative/__tests__/plugins/PluginManagementFacility.unit.test.ts index aed70ad3bb..8493e7f1d9 100644 --- a/packages/imperative/src/imperative/__tests__/plugins/PluginManagementFacility.unit.test.ts +++ b/packages/imperative/src/imperative/__tests__/plugins/PluginManagementFacility.unit.test.ts @@ -1902,7 +1902,7 @@ describe("Plugin Management Facility", () => { describe("comparePluginVersionToCli function", () => { beforeEach(() => { PMF.currPluginName = pluginName; - PMF.semver.intersects = jest.fn(); + PMF.semver.satisfies = jest.fn(); // impCfg.getCliCmdName is a getter of a property, so mock the property Object.defineProperty(impCfg, "cliCmdName", { @@ -1914,7 +1914,7 @@ describe("Plugin Management Facility", () => { }); it("should record no issue when version is compatible", () => { - PMF.semver.intersects.mockReturnValueOnce(true); + PMF.semver.satisfies.mockReturnValueOnce(true); PMF.comparePluginVersionToCli(pluginName, "pluginVerVal", "cliVerPropNm", "CliVerVal"); @@ -1922,7 +1922,7 @@ describe("Plugin Management Facility", () => { }); it("should record issue when exception threw by semver", () => { - PMF.semver.intersects.mockImplementationOnce(() => { + PMF.semver.satisfies.mockImplementationOnce(() => { throw new Error("dummy error"); }); From 3a8a2bd2905b30c0349afdb070961330cfdc2951 Mon Sep 17 00:00:00 2001 From: zFernand0 <37381190+zFernand0@users.noreply.github.com> Date: Mon, 26 Feb 2024 15:28:50 +0000 Subject: [PATCH 3/3] update typedoc Signed-off-by: zFernand0 <37381190+zFernand0@users.noreply.github.com> --- .../src/imperative/src/plugins/PluginManagementFacility.ts | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/packages/imperative/src/imperative/src/plugins/PluginManagementFacility.ts b/packages/imperative/src/imperative/src/plugins/PluginManagementFacility.ts index 2955864793..966ac60033 100644 --- a/packages/imperative/src/imperative/src/plugins/PluginManagementFacility.ts +++ b/packages/imperative/src/imperative/src/plugins/PluginManagementFacility.ts @@ -520,8 +520,7 @@ export class PluginManagementFacility { * Compare the version of a plugin version property with a version property * of its base CLI. * - * If the versions do not satisfies (according so semver rules), then a - * PluginIssue is recorded. + * If the versions do not satisfy the semver rules, then a PluginIssue is recorded. * * @param pluginName - The name of the plugin. * @param pluginVerPropNm - The name of the plugin property containing a version. @@ -931,8 +930,8 @@ export class PluginManagementFacility { * with those specified in the host CLI. * * Both range strings come from the package.json files of the plugin and the - * hosting CLI. We consider the version ranges to be compatible if the two - * ranges satisfies. This should allow npm to download one common version + * hosting CLI. We consider the version ranges to be compatible if they satisfy + * the CLI version range. This should allow npm to download one common version * of core and of imperative to be owned by the base CLI and shared by the plugin. * * Any errors are recorded in PluginIssues.