mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Fix bundled extensions not being loaded (#7359)
* Fix bundled extensions not being loaded - Also show that this fixes it by added an example bundled extension to 'open-lens' Signed-off-by: Sebastian Malton <sebastian@malton.name> * Fix build Signed-off-by: Sebastian Malton <sebastian@malton.name> * Add explanatory comment for inline require Signed-off-by: Sebastian Malton <sebastian@malton.name> --------- Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
1 parent
ae9a8c3c41
commit
2c3c88be04
51 files changed
+521
-159
No files matched your search
@@ -3,8 +3,8 @@
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
|
||||
import type { LensExtensionManifest } from "@k8slens/legacy-extensions";
|
||||
import { isCompatibleExtension } from "../extension-discovery/is-compatible-extension/is-compatible-extension";
|
||||
import type { LensExtensionManifest } from "../lens-extension";
|
||||
|
||||
describe("Extension/App versions compatibility checks", () => {
|
||||
it("is compatible with exact version matching", () => {
|
||||
|
||||
@@ -16,8 +16,8 @@ export * as Types from "./types";
|
||||
export * as Proxy from "./proxy";
|
||||
|
||||
export type { Logger } from "../../common/logger";
|
||||
export type { LensExtension, LensExtensionManifest } from "../lens-extension";
|
||||
export type { InstalledExtension } from "../extension-discovery/extension-discovery";
|
||||
export type { LensExtension } from "../lens-extension";
|
||||
export type { PackageJson } from "type-fest";
|
||||
export type { LensExtensionManifest, InstalledExtension } from "@k8slens/legacy-extensions";
|
||||
|
||||
export const logger = asLegacyGlobalForExtensionApi(loggerInjectable);
|
||||
@@ -1,17 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
|
||||
import { getInjectionToken } from "@ogre-tools/injectable";
|
||||
import type { LensExtensionConstructor, LensExtensionManifest } from "../lens-extension";
|
||||
|
||||
export interface BundledExtension {
|
||||
readonly manifest: LensExtensionManifest;
|
||||
main: () => LensExtensionConstructor | null;
|
||||
renderer: () => LensExtensionConstructor | null;
|
||||
}
|
||||
|
||||
export const bundledExtensionInjectionToken = getInjectionToken<BundledExtension>({
|
||||
id: "bundled-extension-path",
|
||||
});
|
||||
@@ -11,7 +11,7 @@ import { toJS } from "../../common/utils";
|
||||
import { isErrnoException } from "@k8slens/utilities";
|
||||
import type { ExtensionsStore } from "../extensions-store/extensions-store";
|
||||
import type { ExtensionLoader } from "../extension-loader";
|
||||
import type { LensExtensionId, LensExtensionManifest } from "../lens-extension";
|
||||
import type { InstalledExtension, LensExtensionId, LensExtensionManifest } from "@k8slens/legacy-extensions";
|
||||
import type { ExtensionInstallationStateStore } from "../extension-installation-state-store/extension-installation-state-store";
|
||||
import { extensionDiscoveryStateChannel } from "../../common/ipc/extension-handling";
|
||||
import { requestInitialExtensionDiscovery } from "../../renderer/ipc";
|
||||
@@ -59,22 +59,6 @@ interface Dependencies {
|
||||
getRelativePath: GetRelativePath;
|
||||
}
|
||||
|
||||
export interface InstalledExtension {
|
||||
id: LensExtensionId;
|
||||
|
||||
readonly manifest: LensExtensionManifest;
|
||||
|
||||
// Absolute path to the non-symlinked source folder,
|
||||
// e.g. "/Users/user/.k8slens/extensions/helloworld"
|
||||
readonly absolutePath: string;
|
||||
|
||||
// Absolute to the symlinked package.json file
|
||||
readonly manifestPath: string;
|
||||
readonly isBundled: boolean; // defined in project root's package.json
|
||||
readonly isCompatible: boolean;
|
||||
isEnabled: boolean;
|
||||
}
|
||||
|
||||
const logModule = "[EXTENSION-DISCOVERY]";
|
||||
|
||||
export const manifestFilename = "package.json";
|
||||
|
||||
+1
-1
@@ -2,8 +2,8 @@
|
||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
import type { LensExtensionManifest } from "@k8slens/legacy-extensions";
|
||||
import semver from "semver";
|
||||
import type { LensExtensionManifest } from "../../lens-extension";
|
||||
|
||||
interface Dependencies {
|
||||
extensionApiVersion: string;
|
||||
|
||||
@@ -3,9 +3,9 @@
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
|
||||
import type { LensExtensionConstructor, InstalledExtension } from "@k8slens/legacy-extensions";
|
||||
import { getInjectionToken } from "@ogre-tools/injectable";
|
||||
import type { InstalledExtension } from "../extension-discovery/extension-discovery";
|
||||
import type { LensExtension, LensExtensionConstructor } from "../lens-extension";
|
||||
import type { LensExtension } from "../lens-extension";
|
||||
|
||||
export type CreateExtensionInstance = (ExtensionClass: LensExtensionConstructor, extension: InstalledExtension) => LensExtension;
|
||||
|
||||
|
||||
@@ -2,9 +2,10 @@
|
||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
import type { LensExtensionId } from "@k8slens/legacy-extensions";
|
||||
import { getInjectable } from "@ogre-tools/injectable";
|
||||
import { observable } from "mobx";
|
||||
import type { LensExtensionId, LensExtension } from "../lens-extension";
|
||||
import type { LensExtension } from "../lens-extension";
|
||||
|
||||
const extensionInstancesInjectable = getInjectable({
|
||||
id: "extension-instances",
|
||||
|
||||
@@ -12,7 +12,7 @@ import extensionInjectable from "./extension/extension.injectable";
|
||||
import loggerInjectable from "../../common/logger.injectable";
|
||||
import joinPathsInjectable from "../../common/path/join-paths.injectable";
|
||||
import getDirnameOfPathInjectable from "../../common/path/get-dirname.injectable";
|
||||
import { bundledExtensionInjectionToken } from "../extension-discovery/bundled-extension-token";
|
||||
import { bundledExtensionInjectionToken } from "@k8slens/legacy-extensions";
|
||||
import { extensionEntryPointNameInjectionToken } from "./entry-point-name";
|
||||
|
||||
const extensionLoaderInjectable = getInjectable({
|
||||
|
||||
@@ -9,8 +9,7 @@ import type { ObservableMap } from "mobx";
|
||||
import { action, computed, makeObservable, toJS, observable, observe, reaction, when } from "mobx";
|
||||
import { broadcastMessage, ipcMainOn, ipcRendererOn, ipcMainHandle } from "../../common/ipc";
|
||||
import { isDefined } from "@k8slens/utilities";
|
||||
import type { InstalledExtension } from "../extension-discovery/extension-discovery";
|
||||
import type { LensExtension, LensExtensionConstructor, LensExtensionId } from "../lens-extension";
|
||||
import type { LensExtension } from "../lens-extension";
|
||||
import type { LensExtensionState } from "../extensions-store/extensions-store";
|
||||
import { extensionLoaderFromMainChannel, extensionLoaderFromRendererChannel } from "../../common/ipc/extension-handling";
|
||||
import { requestExtensionLoaderInitialState } from "../../renderer/ipc";
|
||||
@@ -21,7 +20,7 @@ import type { Extension } from "./extension/extension.injectable";
|
||||
import type { Logger } from "../../common/logger";
|
||||
import type { JoinPaths } from "../../common/path/join-paths.injectable";
|
||||
import type { GetDirnameOfPath } from "../../common/path/get-dirname.injectable";
|
||||
import type { BundledExtension } from "../extension-discovery/bundled-extension-token";
|
||||
import type { LensExtensionId, BundledExtension, InstalledExtension, LensExtensionConstructor } from "@k8slens/legacy-extensions";
|
||||
|
||||
const logModule = "[EXTENSIONS-LOADER]";
|
||||
|
||||
|
||||
+1
-1
@@ -3,11 +3,11 @@
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
|
||||
import type { LensExtensionId } from "@k8slens/legacy-extensions";
|
||||
import type { ObservableMap } from "mobx";
|
||||
import { action, makeObservable } from "mobx";
|
||||
import type { BaseStoreDependencies } from "../../../common/base-store/base-store";
|
||||
import { BaseStore } from "../../../common/base-store/base-store";
|
||||
import type { LensExtensionId } from "../../lens-extension";
|
||||
import type { EnsureHashedDirectoryForExtension } from "./ensure-hashed-directory-for-extension.injectable";
|
||||
|
||||
interface FSProvisionModel {
|
||||
|
||||
+1
-1
@@ -2,9 +2,9 @@
|
||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
import type { LensExtensionId } from "@k8slens/legacy-extensions";
|
||||
import { getInjectable } from "@ogre-tools/injectable";
|
||||
import { observable } from "mobx";
|
||||
import type { LensExtensionId } from "../../lens-extension";
|
||||
|
||||
export const registeredExtensionsInjectable = getInjectable({
|
||||
id: "registered-extensions",
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
|
||||
import type { LensExtensionId } from "../lens-extension";
|
||||
import type { LensExtensionId } from "@k8slens/legacy-extensions";
|
||||
import { action, computed, makeObservable, observable } from "mobx";
|
||||
import type { BaseStoreDependencies } from "../../common/base-store/base-store";
|
||||
import { BaseStore } from "../../common/base-store/base-store";
|
||||
|
||||
@@ -3,35 +3,12 @@
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
|
||||
import type { InstalledExtension } from "./extension-discovery/extension-discovery";
|
||||
import { action, computed, makeObservable, observable } from "mobx";
|
||||
import type { PackageJson } from "type-fest";
|
||||
import { disposer } from "@k8slens/utilities";
|
||||
import type { LensExtensionDependencies } from "./lens-extension-set-dependencies";
|
||||
import type { ProtocolHandlerRegistration } from "../common/protocol-handler/registration";
|
||||
import type { InstalledExtension, LegacyLensExtension, LensExtensionId, LensExtensionManifest } from "@k8slens/legacy-extensions";
|
||||
|
||||
export type LensExtensionId = string; // path to manifest (package.json)
|
||||
export type LensExtensionConstructor = new (...args: ConstructorParameters<typeof LensExtension>) => LensExtension;
|
||||
|
||||
export interface LensExtensionManifest extends PackageJson {
|
||||
name: string;
|
||||
version: string;
|
||||
main?: string; // path to %ext/dist/main.js
|
||||
renderer?: string; // path to %ext/dist/renderer.js
|
||||
/**
|
||||
* Supported Lens version engine by extension could be defined in `manifest.engines.lens`
|
||||
* Only MAJOR.MINOR version is taken in consideration.
|
||||
*/
|
||||
engines: {
|
||||
lens: string; // "semver"-package format
|
||||
npm?: string;
|
||||
node?: string;
|
||||
};
|
||||
|
||||
// Specify extension name used for persisting data.
|
||||
// Useful if extension is renamed but the data should not be lost.
|
||||
storeName?: string;
|
||||
}
|
||||
|
||||
export const lensExtensionDependencies = Symbol("lens-extension-dependencies");
|
||||
export const Disposers = Symbol("disposers");
|
||||
@@ -41,7 +18,7 @@ export class LensExtension<
|
||||
* @ignore
|
||||
*/
|
||||
Dependencies extends LensExtensionDependencies = LensExtensionDependencies,
|
||||
> {
|
||||
> implements LegacyLensExtension {
|
||||
readonly id: LensExtensionId;
|
||||
readonly manifest: LensExtensionManifest;
|
||||
readonly manifestPath: string;
|
||||
|
||||
Reference in new issue
Block a user