mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
fix: parse extension's version via semver-package
Signed-off-by: Roman <ixrock@gmail.com>
This commit is contained in:
parent
4509dcb1a6
commit
2af33ad042
@ -2,8 +2,7 @@
|
|||||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||||
*/
|
*/
|
||||||
import type { SemVer } from "semver";
|
import semver, { SemVer } from "semver";
|
||||||
import semver from "semver";
|
|
||||||
import type { LensExtensionManifest } from "../../lens-extension";
|
import type { LensExtensionManifest } from "../../lens-extension";
|
||||||
|
|
||||||
interface Dependencies {
|
interface Dependencies {
|
||||||
@ -11,16 +10,17 @@ interface Dependencies {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const isCompatibleExtension = (deps: Dependencies): ((manifest: LensExtensionManifest) => boolean) => {
|
export const isCompatibleExtension = (deps: Dependencies): ((manifest: LensExtensionManifest) => boolean) => {
|
||||||
const { major: appMajor } = deps.appSemVer;
|
const { major: appVersion } = deps.appSemVer;
|
||||||
|
|
||||||
return (manifest: LensExtensionManifest): boolean => {
|
return (manifest: LensExtensionManifest): boolean => {
|
||||||
if (manifest?.engines.lens) {
|
if (manifest?.engines.lens) {
|
||||||
const [extMajor, extMinor] = manifest.engines.lens.split(".");
|
const { major: extMajor, minor: extMinor } = new SemVer(manifest.engines.lens, {
|
||||||
|
loose: true,
|
||||||
|
});
|
||||||
|
|
||||||
return semver.gte(`${extMajor}.${extMinor}`, `${appMajor}.0`);
|
return semver.gte(`${extMajor}.${extMinor}`, `${appVersion}.0`);
|
||||||
}
|
}
|
||||||
|
|
||||||
// all extensions by default should be compatible with any Lens-engine (if not specified)
|
return false; // not compatible by default
|
||||||
return true;
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
@ -26,7 +26,7 @@ export interface LensExtensionManifest extends PackageJson {
|
|||||||
* Only MAJOR.MINOR version is taken in consideration.
|
* Only MAJOR.MINOR version is taken in consideration.
|
||||||
*/
|
*/
|
||||||
engines?: {
|
engines?: {
|
||||||
lens?: string;
|
lens?: string; // "semver"-package format
|
||||||
npm?: string;
|
npm?: string;
|
||||||
node?: string;
|
node?: string;
|
||||||
};
|
};
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user