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:
Jari Kolehmainen authored and GitHub committed 2023-01-24 10:46:26 -08:00
1 parent 0066ca4ea2
commit 2657df2293
3321 files changed
+28699 -11447

No files matched your search

@@ -0,0 +1,108 @@
/**
* Copyright (c) OpenLens Authors. All rights reserved.
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
import React from "react";
import type { RenderResult } from "@testing-library/react";
import type { ApplicationBuilder } from "../../../renderer/components/test-utils/get-application-builder";
import { getApplicationBuilder } from "../../../renderer/components/test-utils/get-application-builder";
import type { FakeExtensionOptions } from "../../../renderer/components/test-utils/get-extension-fake";
describe("extendability-using-extension-api", () => {
let rendered: RenderResult;
let applicationBuilder: ApplicationBuilder;
beforeEach(async () => {
applicationBuilder = getApplicationBuilder();
rendered = await applicationBuilder.render();
});
it("renders", () => {
expect(rendered.baseElement).toMatchSnapshot();
});
it("given an extension with top-bar items has not been enabled yet, does not render the top-bar item", () => {
expect(rendered.queryByTestId("some-top-bar-item")).not.toBeInTheDocument();
});
describe("given an extension with top-bar items is enabled", () => {
let testExtension: FakeExtensionOptions;
beforeEach(() => {
testExtension = {
id: "test-extension",
name: "Test Extension",
rendererOptions: {
topBarItems: [
{
components: {
Item: () => (
<div data-testid="some-top-bar-item">Some-content</div>
),
},
},
],
},
};
applicationBuilder.extensions.enable(testExtension);
});
it("renders", () => {
expect(rendered.baseElement).toMatchSnapshot();
});
it("renders the top-bar item", () => {
expect(rendered.getByTestId("some-top-bar-item")).toBeInTheDocument();
});
describe("when the extension is disabled", () => {
beforeEach(() => {
applicationBuilder.extensions.disable(testExtension);
});
it("renders", () => {
expect(rendered.baseElement).toMatchSnapshot();
});
it("no longer renders the top-bar item", () => {
expect(rendered.queryByTestId("some-top-bar-item")).not.toBeInTheDocument();
});
});
});
describe("given an extension with a weakly typed and invalid top-bar item is enabled", () => {
beforeEach(() => {
const testExtension: FakeExtensionOptions = {
id: "test-extension",
name: "Test Extension",
rendererOptions: {
topBarItems: [
{
components: {
// Note: this makes the item invalid.
Item: undefined,
},
} as any,
// Note: empty object makes the item invalid.
{} as any,
// Note: non-object makes the item invalid.
undefined as any,
],
},
};
applicationBuilder.extensions.enable(testExtension);
});
it("renders without blowing up", () => {
expect(rendered.baseElement).toMatchSnapshot();
});
});
});
@@ -0,0 +1,48 @@
/**
* 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 { reject } from "lodash/fp";
import { extensionRegistratorInjectionToken } from "../../../../extensions/extension-loader/extension-registrator-injection-token";
import type { LensRendererExtension } from "../../../../extensions/lens-renderer-extension";
import { pipeline } from "@ogre-tools/fp";
import { topBarItemOnRightSideInjectionToken } from "../../../../renderer/components/layout/top-bar/top-bar-items/top-bar-item-injection-token";
import { computed } from "mobx";
const legacyExtensionApiRegistratorForTopBarItemsInjectable = getInjectable({
id: "legacy-extension-api-registrator-for-top-bar-items",
instantiate: () => (ext) => {
const extension = ext as LensRendererExtension;
return pipeline(
extension.topBarItems,
reject((registration) => !registration?.components?.Item),
(validTopBarRegistrations) =>
validTopBarRegistrations.map((registration, index) => {
const id = `extension-top-bar-item-for-${extension.sanitizedExtensionId}-${index}`;
return getInjectable({
id,
injectionToken: topBarItemOnRightSideInjectionToken,
instantiate: () => ({
id,
isShown: computed(() => true),
// Note: legacy extension-API does not specify order of top-bar items, and therefore an arbitrary number is used. This makes items originating from extension appear in volatile order between each other.
orderNumber: 100,
Component: registration.components.Item,
}),
});
}),
);
},
injectionToken: extensionRegistratorInjectionToken,
});
export default legacyExtensionApiRegistratorForTopBarItemsInjectable;