mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
chore: Fix build of open-lens
- Remove need for using relative paths during build Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
1 parent
6167ad2c25
commit
91354eae01
40 files changed
+284
-160
No files matched your search
@@ -0,0 +1,50 @@
|
||||
/**
|
||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
import { getInjectable } from "@ogre-tools/injectable";
|
||||
import packageJson from "../../package.json";
|
||||
import { applicationInformationToken } from "@k8slens/application";
|
||||
|
||||
const applicationInformationInjectable = getInjectable({
|
||||
id: "application-information",
|
||||
instantiate: () => {
|
||||
const {
|
||||
version,
|
||||
config: {
|
||||
bundledHelmVersion,
|
||||
bundledKubectlVersion,
|
||||
contentSecurityPolicy,
|
||||
k8sProxyVersion,
|
||||
sentryDsn,
|
||||
welcomeRoute,
|
||||
},
|
||||
productName,
|
||||
build,
|
||||
copyright,
|
||||
description,
|
||||
name,
|
||||
dependencies,
|
||||
} = packageJson;
|
||||
|
||||
return {
|
||||
version,
|
||||
productName,
|
||||
copyright,
|
||||
description,
|
||||
name,
|
||||
k8sProxyVersion,
|
||||
bundledKubectlVersion,
|
||||
bundledHelmVersion,
|
||||
sentryDsn,
|
||||
contentSecurityPolicy,
|
||||
welcomeRoute,
|
||||
updatingIsEnabled: (build as any)?.publish?.length > 0,
|
||||
dependencies,
|
||||
};
|
||||
},
|
||||
causesSideEffects: true,
|
||||
injectionToken: applicationInformationToken,
|
||||
});
|
||||
|
||||
export default applicationInformationInjectable;
|
||||
@@ -0,0 +1,14 @@
|
||||
/**
|
||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
import { lensBuildEnvironmentInjectionToken } from "@k8slens/application";
|
||||
import { getInjectable } from "@ogre-tools/injectable";
|
||||
|
||||
const lensBuildEnvironmentInjectable = getInjectable({
|
||||
id: "lens-build-environment",
|
||||
instantiate: () => "unknown",
|
||||
injectionToken: lensBuildEnvironmentInjectionToken,
|
||||
});
|
||||
|
||||
export default lensBuildEnvironmentInjectable;
|
||||
@@ -0,0 +1,21 @@
|
||||
import { bundledExtensionInjectionToken } from "@k8slens/legacy-extensions";
|
||||
import { getInjectable } from "@ogre-tools/injectable";
|
||||
import exampleBundledExtensionManifest from "@k8slens/legacy-extension-example/package.json";
|
||||
|
||||
const exampleBundledExtensionInjectable = getInjectable({
|
||||
id: "example-bundled-extension",
|
||||
instantiate: (di) => ({
|
||||
manifest: exampleBundledExtensionManifest,
|
||||
/**
|
||||
* Inline `require` is needed as to delay the loading and execution of the JS file until it is needed.
|
||||
*
|
||||
* Futhermore there might be code that runs "during load" and shouldn't be executed until everything is
|
||||
* setup for the extensions (ie globals).
|
||||
*/
|
||||
main: () => require("@k8slens/legacy-extension-example/main").default,
|
||||
renderer: () => require("@k8slens/legacy-extension-example/renderer").default,
|
||||
}),
|
||||
injectionToken: bundledExtensionInjectionToken,
|
||||
});
|
||||
|
||||
export default exampleBundledExtensionInjectable;
|
||||
@@ -0,0 +1,67 @@
|
||||
import { autoRegister } from "@ogre-tools/injectable-extension-for-auto-registration";
|
||||
import { runInAction } from "mobx";
|
||||
import {
|
||||
mainExtensionApi as Main,
|
||||
commonExtensionApi as Common,
|
||||
registerLensCore,
|
||||
} from "@k8slens/core/main";
|
||||
import { createContainer } from "@ogre-tools/injectable";
|
||||
import { registerMobX } from "@ogre-tools/injectable-extension-for-mobx";
|
||||
import { registerFeature } from "@k8slens/feature-core";
|
||||
import { applicationFeature, startApplicationInjectionToken } from '@k8slens/application'
|
||||
import { applicationFeatureForElectronMain } from '@k8slens/application-for-electron-main'
|
||||
import { messagingFeatureForMain } from "@k8slens/messaging-for-main";
|
||||
import { loggerFeature } from "@k8slens/logger";
|
||||
|
||||
const environment = "main";
|
||||
|
||||
const di = createContainer(environment, {
|
||||
detectCycles: false,
|
||||
});
|
||||
|
||||
registerMobX(di);
|
||||
|
||||
runInAction(() => {
|
||||
registerLensCore(di, environment);
|
||||
|
||||
registerFeature(di,
|
||||
loggerFeature,
|
||||
);
|
||||
|
||||
registerFeature(di,
|
||||
applicationFeature,
|
||||
applicationFeatureForElectronMain,
|
||||
messagingFeatureForMain,
|
||||
);
|
||||
|
||||
try {
|
||||
autoRegister({
|
||||
di,
|
||||
targetModule: module,
|
||||
getRequireContexts: () => [
|
||||
require.context("./", true, CONTEXT_MATCHER_FOR_NON_FEATURES),
|
||||
require.context("../common", true, CONTEXT_MATCHER_FOR_NON_FEATURES),
|
||||
],
|
||||
});
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
process.exit(1);
|
||||
}
|
||||
});
|
||||
|
||||
const startApplication = di.inject(startApplicationInjectionToken);
|
||||
|
||||
startApplication().catch((error) => {
|
||||
console.error(error);
|
||||
process.exit(1);
|
||||
})
|
||||
|
||||
export {
|
||||
Mobx,
|
||||
Pty,
|
||||
} from "@k8slens/core/main";
|
||||
|
||||
export const LensExtensions = {
|
||||
Main,
|
||||
Common,
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
import { getInjectable } from "@ogre-tools/injectable";
|
||||
import { nodeEnvInjectionToken } from "@k8slens/core/main";
|
||||
|
||||
export const nodeEnvInjectable = getInjectable({
|
||||
id: "node-env",
|
||||
instantiate: () => process.env.NODE_ENV || "development",
|
||||
injectionToken: nodeEnvInjectionToken,
|
||||
});
|
||||
@@ -0,0 +1,79 @@
|
||||
import "@k8slens/core/styles";
|
||||
import "@k8slens/button/dist/index.css";
|
||||
import "@k8slens/error-boundary/dist/index.css";
|
||||
import "@k8slens/tooltip/dist/index.css";
|
||||
import { runInAction } from "mobx";
|
||||
import {
|
||||
rendererExtensionApi as Renderer,
|
||||
commonExtensionApi as Common,
|
||||
registerLensCore,
|
||||
metricsFeature
|
||||
} from "@k8slens/core/renderer";
|
||||
import { autoRegister } from "@ogre-tools/injectable-extension-for-auto-registration";
|
||||
import { registerFeature } from "@k8slens/feature-core";
|
||||
import {
|
||||
applicationFeature,
|
||||
startApplicationInjectionToken
|
||||
} from "@k8slens/application";
|
||||
import { createContainer } from "@ogre-tools/injectable";
|
||||
import { registerMobX } from "@ogre-tools/injectable-extension-for-mobx";
|
||||
import { registerInjectableReact } from "@ogre-tools/injectable-react";
|
||||
import { messagingFeatureForRenderer } from "@k8slens/messaging-for-renderer";
|
||||
import { keyboardShortcutsFeature } from "@k8slens/keyboard-shortcuts";
|
||||
import { reactApplicationFeature } from "@k8slens/react-application";
|
||||
import { routingFeature } from "@k8slens/routing";
|
||||
import { loggerFeature } from "@k8slens/logger";
|
||||
|
||||
const environment = "renderer";
|
||||
|
||||
const di = createContainer(environment, {
|
||||
detectCycles: false,
|
||||
});
|
||||
|
||||
runInAction(() => {
|
||||
registerMobX(di);
|
||||
registerInjectableReact(di);
|
||||
registerLensCore(di, environment);
|
||||
|
||||
registerFeature(
|
||||
di,
|
||||
loggerFeature,
|
||||
);
|
||||
|
||||
registerFeature(
|
||||
di,
|
||||
applicationFeature,
|
||||
messagingFeatureForRenderer,
|
||||
keyboardShortcutsFeature,
|
||||
reactApplicationFeature,
|
||||
routingFeature,
|
||||
metricsFeature
|
||||
);
|
||||
|
||||
autoRegister({
|
||||
di,
|
||||
targetModule: module,
|
||||
getRequireContexts: () => [
|
||||
require.context("./", true, CONTEXT_MATCHER_FOR_NON_FEATURES),
|
||||
require.context("../common", true, CONTEXT_MATCHER_FOR_NON_FEATURES),
|
||||
],
|
||||
});
|
||||
});
|
||||
|
||||
const startApplication = di.inject(startApplicationInjectionToken);
|
||||
|
||||
startApplication();
|
||||
|
||||
export {
|
||||
React,
|
||||
ReactDOM,
|
||||
ReactRouter,
|
||||
ReactRouterDom,
|
||||
Mobx,
|
||||
MobxReact,
|
||||
} from "@k8slens/core/renderer";
|
||||
|
||||
export const LensExtensions = {
|
||||
Renderer,
|
||||
Common,
|
||||
};
|
||||
@@ -0,0 +1,8 @@
|
||||
import { getInjectable } from "@ogre-tools/injectable";
|
||||
import { nodeEnvInjectionToken } from "@k8slens/core/renderer";
|
||||
|
||||
export const nodeEnvInjectable = getInjectable({
|
||||
id: "node-env",
|
||||
instantiate: () => process.env.NODE_ENV || "development",
|
||||
injectionToken: nodeEnvInjectionToken,
|
||||
});
|
||||
Reference in new issue
Block a user