mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Restructure to monorepo (#6907)
* wip: restructure to monorepo Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com> * refactor create-release-pr to a package Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com> * build fixes Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com> * github workflow fixes Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com> * fix typo Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com> * add webpack-env types to core Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com> * fix github workflows Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com> * refactor/fix integration tests Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com> * lint fix Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com> * yarn run dev Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com> * eslint settings for vscode Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com> * move templates to right package Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com> * open-lens build fixes Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com> * integration test fix Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com> * fix nx task dependencies Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com> * use bash shell for unit tests in test workflow Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com> * fix test:unit for windows Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com> * fix win-ca webpack error in open-lens Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com> * fix win-ca webpack error in open-lens Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com> * fix build:app on windows Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com> * remove ELECTRON_BUILDER_EXTRA_ARGS Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com> * sync src/ from master Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com> * remove Makefile from core Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com> Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com>
This commit is contained in:
1 parent
0066ca4ea2
commit
2657df2293
3321 files changed
+28699
-11447
No files matched your search
+21
@@ -0,0 +1,21 @@
|
||||
/**
|
||||
* 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 { sendMessageToChannelInjectionToken } from "../../../common/utils/channel/message-to-channel-injection-token";
|
||||
import { rootFrameHasRenderedChannel } from "../../../common/root-frame/root-frame-rendered-channel";
|
||||
|
||||
const broadcastThatRootFrameIsRenderedInjectable = getInjectable({
|
||||
id: "broadcast-that-root-frame-is-rendered",
|
||||
|
||||
instantiate: (di) => {
|
||||
const messageToChannel = di.inject(sendMessageToChannelInjectionToken);
|
||||
|
||||
return () => {
|
||||
messageToChannel(rootFrameHasRenderedChannel);
|
||||
};
|
||||
},
|
||||
});
|
||||
|
||||
export default broadcastThatRootFrameIsRenderedInjectable;
|
||||
@@ -0,0 +1,69 @@
|
||||
/**
|
||||
* 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 ipcRendererInjectable from "../../utils/channel/ipc-renderer.injectable";
|
||||
import bindProtocolAddRouteHandlersInjectable from "../../protocol-handler/bind-protocol-add-route-handlers/bind-protocol-add-route-handlers.injectable";
|
||||
import lensProtocolRouterRendererInjectable from "../../protocol-handler/lens-protocol-router-renderer/lens-protocol-router-renderer.injectable";
|
||||
import catalogEntityRegistryInjectable from "../../api/catalog/entity/registry.injectable";
|
||||
import registerIpcListenersInjectable from "../../ipc/register-ipc-listeners.injectable";
|
||||
import loadExtensionsInjectable from "../load-extensions.injectable";
|
||||
import loggerInjectable from "../../../common/logger.injectable";
|
||||
import { delay } from "../../../common/utils";
|
||||
import { broadcastMessage } from "../../../common/ipc";
|
||||
import { bundledExtensionsLoaded } from "../../../common/ipc/extension-handling";
|
||||
|
||||
const initRootFrameInjectable = getInjectable({
|
||||
id: "init-root-frame",
|
||||
instantiate: (di) => {
|
||||
const loadExtensions = di.inject(loadExtensionsInjectable);
|
||||
const registerIpcListeners = di.inject(registerIpcListenersInjectable);
|
||||
const ipcRenderer = di.inject(ipcRendererInjectable);
|
||||
const bindProtocolAddRouteHandlers = di.inject(bindProtocolAddRouteHandlersInjectable);
|
||||
const lensProtocolRouterRenderer = di.inject(lensProtocolRouterRendererInjectable);
|
||||
const catalogEntityRegistry = di.inject(catalogEntityRegistryInjectable);
|
||||
const logger = di.inject(loggerInjectable);
|
||||
|
||||
return async (unmountRoot: () => void) => {
|
||||
catalogEntityRegistry.init();
|
||||
|
||||
try {
|
||||
// maximum time to let bundled extensions finish loading
|
||||
const timeout = delay(10000);
|
||||
|
||||
const loadingExtensions = await loadExtensions();
|
||||
|
||||
const loadingBundledExtensions = loadingExtensions
|
||||
.filter((e) => e.isBundled)
|
||||
.map((e) => e.loaded);
|
||||
|
||||
const bundledExtensionsFinished = Promise.all(loadingBundledExtensions);
|
||||
|
||||
await Promise.race([bundledExtensionsFinished, timeout]);
|
||||
} finally {
|
||||
ipcRenderer.send(bundledExtensionsLoaded);
|
||||
}
|
||||
|
||||
lensProtocolRouterRenderer.init();
|
||||
|
||||
bindProtocolAddRouteHandlers();
|
||||
|
||||
window.addEventListener("offline", () =>
|
||||
broadcastMessage("network:offline"),
|
||||
);
|
||||
|
||||
window.addEventListener("online", () => broadcastMessage("network:online"));
|
||||
|
||||
registerIpcListeners();
|
||||
|
||||
window.addEventListener("beforeunload", () => {
|
||||
logger.info("[ROOT-FRAME]: Unload app");
|
||||
|
||||
unmountRoot();
|
||||
});
|
||||
};
|
||||
},
|
||||
});
|
||||
|
||||
export default initRootFrameInjectable;
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
/**
|
||||
* 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 { IComputedValue } from "mobx";
|
||||
|
||||
export interface RootFrameChildComponent {
|
||||
id: string;
|
||||
Component: React.ElementType;
|
||||
shouldRender: IComputedValue<boolean>;
|
||||
}
|
||||
|
||||
export const rootFrameChildComponentInjectionToken = getInjectionToken<RootFrameChildComponent>({
|
||||
id: "root-frame-child-component",
|
||||
});
|
||||
@@ -0,0 +1,49 @@
|
||||
/**
|
||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
|
||||
import React from "react";
|
||||
import { Observer } from "mobx-react";
|
||||
import { withInjectables } from "@ogre-tools/injectable-react";
|
||||
import broadcastThatRootFrameIsRenderedInjectable from "./broadcast-that-root-frame-is-rendered.injectable";
|
||||
import type { RootFrameChildComponent } from "./root-frame-child-component-injection-token";
|
||||
import { rootFrameChildComponentInjectionToken } from "./root-frame-child-component-injection-token";
|
||||
|
||||
interface Dependencies {
|
||||
broadcastThatRootFrameIsRendered: () => void;
|
||||
childComponents: RootFrameChildComponent[];
|
||||
}
|
||||
|
||||
class NonInjectedRootFrame extends React.Component<Dependencies> {
|
||||
static displayName = "RootFrame";
|
||||
|
||||
componentDidMount() {
|
||||
this.props.broadcastThatRootFrameIsRendered();
|
||||
}
|
||||
|
||||
render() {
|
||||
return (
|
||||
<>
|
||||
{this.props.childComponents
|
||||
.map((child) => (
|
||||
<Observer key={child.id}>
|
||||
{() => (child.shouldRender.get() ? <child.Component /> : null) }
|
||||
</Observer>
|
||||
))}
|
||||
</>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export const RootFrame = withInjectables<Dependencies>(
|
||||
NonInjectedRootFrame,
|
||||
|
||||
{
|
||||
getProps: (di, props) => ({
|
||||
broadcastThatRootFrameIsRendered: di.inject(broadcastThatRootFrameIsRenderedInjectable),
|
||||
childComponents: di.injectMany(rootFrameChildComponentInjectionToken),
|
||||
...props,
|
||||
}),
|
||||
},
|
||||
);
|
||||
@@ -0,0 +1,18 @@
|
||||
/**
|
||||
* 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 { beforeFrameStartsSecondInjectionToken } from "../../before-frame-starts/tokens";
|
||||
import injectSystemCAsInjectable from "../../../features/certificate-authorities/common/inject-system-cas.injectable";
|
||||
|
||||
const setupSystemCaInjectable = getInjectable({
|
||||
id: "setup-system-ca",
|
||||
instantiate: (di) => ({
|
||||
id: "setup-system-ca",
|
||||
run: di.inject(injectSystemCAsInjectable),
|
||||
}),
|
||||
injectionToken: beforeFrameStartsSecondInjectionToken,
|
||||
});
|
||||
|
||||
export default setupSystemCaInjectable;
|
||||
Reference in new issue
Block a user