1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00

chore: Upgrade versions of @ogre-tools/* to 15.3.0

Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
Sebastian Malton 2023-03-30 12:05:37 -04:00
parent 7dc0ce7192
commit ba8f7f916d
27 changed files with 5445 additions and 17542 deletions

22402
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -33,9 +33,9 @@
"peerDependencies": {
"@k8slens/feature-core": "^6.5.0-alpha.0",
"@k8slens/react-application": "^1.0.0-alpha.0",
"@ogre-tools/fp": "^15.1.2",
"@ogre-tools/injectable": "^15.1.2",
"@ogre-tools/injectable-extension-for-auto-registration": "^15.1.2",
"@ogre-tools/fp": "^15.3.0",
"@ogre-tools/injectable": "^15.3.0",
"@ogre-tools/injectable-extension-for-auto-registration": "^15.3.0",
"@ogre-tools/injectable-react": "^15.1.2",
"lodash": "^4.17.21",
"react": "^17"

View File

@ -23,11 +23,13 @@
"prepare:test": "npm run build"
},
"devDependencies": {
"@ogre-tools/injectable": "^15.1.2",
"@swc/cli": "^0.1.61",
"@swc/core": "^1.3.44",
"@types/node": "^16.18.11",
"@types/semver": "^7.3.13",
"rimraf": "^4.4.1"
},
"peerDependencies": {
"@ogre-tools/injectable": "^15.3.0"
}
}

View File

@ -117,11 +117,6 @@
"@k8slens/react-application": "^1.0.0-alpha.1",
"@kubernetes/client-node": "^0.18.1",
"@material-ui/styles": "^4.11.5",
"@ogre-tools/fp": "^15.1.2",
"@ogre-tools/injectable": "^15.1.2",
"@ogre-tools/injectable-extension-for-auto-registration": "^15.1.2",
"@ogre-tools/injectable-extension-for-mobx": "^15.3.0",
"@ogre-tools/injectable-react": "^15.1.2",
"@sentry/electron": "^3.0.8",
"@sentry/integrations": "^6.19.3",
"@side/jest-runtime": "^1.1.0",
@ -326,6 +321,11 @@
"@k8slens/startable-stoppable": "^1.0.0-alpha.1",
"@k8slens/test-utils": "^1.0.0-alpha.1",
"@k8slens/utilities": "^1.0.0-alpha.1",
"@ogre-tools/fp": "^15.3.0",
"@ogre-tools/injectable": "^15.3.0",
"@ogre-tools/injectable-extension-for-auto-registration": "^15.3.0",
"@ogre-tools/injectable-extension-for-mobx": "^15.3.0",
"@ogre-tools/injectable-react": "^15.3.0",
"@types/byline": "^4.2.33",
"@types/chart.js": "^2.9.36",
"@types/color": "^3.0.3",

View File

@ -72,7 +72,7 @@ describe("computeUnixShellEnvironment technical tests", () => {
});
});
di.override(spawnInjectable, () => spawnMock);
di.override(randomUUIDInjectable, () => () => "deadbeef");
di.override(randomUUIDInjectable, () => () => "dead-foo-bar-foo-beef");
di.override(processEnvInjectable, () => ({
SOME_ENV_VAR: "some-env-value",
@ -110,7 +110,7 @@ describe("computeUnixShellEnvironment technical tests", () => {
});
it("should send the command via stdin", () => {
expect(stdinValue).toBe(`'/some/process/exec/path' -p '"deadbeef" + JSON.stringify(process.env) + "deadbeef"'`);
expect(stdinValue).toBe(`'/some/process/exec/path' -p '"deadfoobarfoobeef" + JSON.stringify(process.env) + "deadfoobarfoobeef"'`);
});
it("should close stdin", () => {
@ -167,7 +167,7 @@ describe("computeUnixShellEnvironment technical tests", () => {
...expectedEnv,
};
shellStdout.emit("data", Buffer.from(`some-other-datadeadbeef${JSON.stringify(fakeInnerEnv)}deadbeefsome-third-other-data`));
shellStdout.emit("data", Buffer.from(`some-other-datadeadfoobarfoobeef${JSON.stringify(fakeInnerEnv)}deadfoobarfoobeefsome-third-other-data`));
});
describe("when process successfully exits", () => {
@ -216,7 +216,7 @@ describe("computeUnixShellEnvironment technical tests", () => {
});
it("should send the command via stdin", () => {
expect(stdinValue).toBe(` '/some/process/exec/path' -p '"deadbeef" + JSON.stringify(process.env) + "deadbeef"'`);
expect(stdinValue).toBe(` '/some/process/exec/path' -p '"deadfoobarfoobeef" + JSON.stringify(process.env) + "deadfoobarfoobeef"'`);
});
it("should close stdin", () => {
@ -273,7 +273,7 @@ describe("computeUnixShellEnvironment technical tests", () => {
...expectedEnv,
};
shellStdout.emit("data", Buffer.from(`some-other-datadeadbeef${JSON.stringify(fakeInnerEnv)}deadbeefsome-third-other-data`));
shellStdout.emit("data", Buffer.from(`some-other-datadeadfoobarfoobeef${JSON.stringify(fakeInnerEnv)}deadfoobarfoobeefsome-third-other-data`));
});
describe("when process successfully exits", () => {
@ -312,7 +312,7 @@ describe("computeUnixShellEnvironment technical tests", () => {
[
"-l",
"-c",
`'/some/process/exec/path' -p '"deadbeef" + JSON.stringify(process.env) + "deadbeef"'`,
`'/some/process/exec/path' -p '"deadfoobarfoobeef" + JSON.stringify(process.env) + "deadfoobarfoobeef"'`,
],
expect.objectContaining({
env: expectedEnv,
@ -378,7 +378,7 @@ describe("computeUnixShellEnvironment technical tests", () => {
...expectedEnv,
};
shellStdout.emit("data", Buffer.from(`some-other-datadeadbeef${JSON.stringify(fakeInnerEnv)}deadbeefsome-third-other-data`));
shellStdout.emit("data", Buffer.from(`some-other-datadeadfoobarfoobeef${JSON.stringify(fakeInnerEnv)}deadfoobarfoobeefsome-third-other-data`));
});
describe("when process successfully exits", () => {
@ -425,7 +425,7 @@ describe("computeUnixShellEnvironment technical tests", () => {
});
it("should send the command via stdin", () => {
expect(stdinValue).toBe(`Command '/some/process/exec/path' -p '\\"deadbeef\\" + JSON.stringify(process.env) + \\"deadbeef\\"'`);
expect(stdinValue).toBe(`Command '/some/process/exec/path' -p '\\"deadfoobarfoobeef\\" + JSON.stringify(process.env) + \\"deadfoobarfoobeef\\"'`);
});
it("should close stdin", () => {
@ -482,7 +482,7 @@ describe("computeUnixShellEnvironment technical tests", () => {
...expectedEnv,
};
shellStdout.emit("data", Buffer.from(`some-other-datadeadbeef${JSON.stringify(fakeInnerEnv)}deadbeefsome-third-other-data`));
shellStdout.emit("data", Buffer.from(`some-other-datadeadfoobarfoobeef${JSON.stringify(fakeInnerEnv)}deadfoobarfoobeefsome-third-other-data`));
});
describe("when process successfully exits", () => {

View File

@ -2,56 +2,39 @@
* Copyright (c) OpenLens Authors. All rights reserved.
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
import type { DiContainerForInjection } from "@ogre-tools/injectable";
import {
getInjectable,
instantiationDecoratorToken,
lifecycleEnum,
} from "@ogre-tools/injectable";
import { injectionDecoratorToken, getInjectable } from "@ogre-tools/injectable";
import assert from "assert";
import { isFunction } from "lodash/fp";
import emitTelemetryInjectable from "./emit-telemetry.injectable";
import type { WhiteListItem } from "./telemetry-white-list-for-functions.injectable";
import telemetryWhiteListForFunctionsInjectable from "./telemetry-white-list-for-functions.injectable";
import logErrorInjectable from "../../../common/log-error.injectable";
import { isFunction, isString } from "@k8slens/utilities";
const telemetryDecoratorInjectable = getInjectable({
id: "telemetry-decorator",
instantiate: (diForDecorator) => ({
decorate:
(instantiateToBeDecorated: any) =>
(di: DiContainerForInjection, instantiationParameter: any) => {
decorate: (instantiateToBeDecorated) =>
(di, instantiationParameter) => {
const instance = instantiateToBeDecorated(di, instantiationParameter);
if (isFunction(instance)) {
return (...args: any[]) => {
return (...args: unknown[]) => {
const currentContext = di.context.at(-1);
assert(currentContext);
const emitTelemetry = diForDecorator.inject(
emitTelemetryInjectable,
);
const emitTelemetry = diForDecorator.inject(emitTelemetryInjectable);
const logError = diForDecorator.inject(logErrorInjectable);
const whiteList = diForDecorator.inject(telemetryWhiteListForFunctionsInjectable);
const whiteList = diForDecorator.inject(
telemetryWhiteListForFunctionsInjectable,
);
const { isWhiteListed, getParams } = findWhiteListEntry(whiteList, currentContext.injectable.id);
const whiteListMap = getWhiteListMap(whiteList);
const whiteListed = whiteListMap.get(currentContext.injectable.id);
if (whiteListed) {
if (isWhiteListed) {
let params;
try {
params = whiteListed.getParams(...args);
params = getParams(...args);
} catch (e) {
params = {
error:
@ -79,28 +62,40 @@ const telemetryDecoratorInjectable = getInjectable({
}),
decorable: false,
// Todo: this is required because of imperfect typing in injectable.
lifecycle: lifecycleEnum.singleton,
injectionToken: instantiationDecoratorToken,
injectionToken: injectionDecoratorToken,
});
const getWhiteListMap = (whiteList: WhiteListItem[]) =>
new Map(
whiteList.map((item) =>
typeof item === "string"
? [
item,
{
type WhiteListEntry = {
isWhiteListed: true;
getParams: (...args: unknown[]) => Record<string, any> | undefined;
} | {
isWhiteListed: false;
getParams?: undefined;
};
const findWhiteListEntry = (whiteList: WhiteListItem[], id: string): WhiteListEntry => {
for (const entry of whiteList) {
if (isString(entry)) {
if (entry === id) {
return {
isWhiteListed: true,
getParams: () => undefined,
},
]
: [
item.id,
{
getParams: item.getParams,
},
],
),
);
};
}
} else {
if (entry.id === id) {
return {
isWhiteListed: true,
getParams: entry.getParams,
};
}
}
}
return {
isWhiteListed: false,
};
};
export default telemetryDecoratorInjectable;

View File

@ -37,7 +37,7 @@ class NonInjectedSidebarItem extends React.Component<
}
get id(): string {
return this.registration.id;
return this.item.id;
}
@computed get expanded(): boolean {
@ -52,8 +52,8 @@ class NonInjectedSidebarItem extends React.Component<
return this.props.item.isActive.get();
}
get registration() {
return this.props.item.registration;
get item() {
return this.props.item;
}
toggleExpand = () => {
@ -71,7 +71,7 @@ class NonInjectedSidebarItem extends React.Component<
return (
<ul className={cssNames(styles.subMenu, { [styles.active]: this.isActive })}>
{this.props.item.children.map(item => <SidebarItem key={item.registration.id} item={item} />)}
{this.props.item.children.map(item => <SidebarItem key={item.id} item={item} />)}
</ul>
);
}
@ -82,7 +82,7 @@ class NonInjectedSidebarItem extends React.Component<
className={styles.SidebarItem}
data-testid={`sidebar-item-${this.id}`}
data-is-active-test={this.isActive}
data-parent-id-test={this.registration.parentId}
data-parent-id-test={this.item.parentId}
>
<NavLink
to={""}
@ -95,13 +95,13 @@ class NonInjectedSidebarItem extends React.Component<
if (this.isExpandable) {
this.toggleExpand();
} else {
this.registration.onClick();
this.item.onClick();
}
}}
data-testid={`sidebar-item-link-for-${this.id}`}
>
{this.registration.getIcon?.()}
<span>{this.registration.title}</span>
{this.item.getIcon?.()}
<span>{this.item.title}</span>
{this.isExpandable && (
<Icon
className={styles.expandIcon}

View File

@ -5,18 +5,9 @@
import { getInjectable, getInjectionToken } from "@ogre-tools/injectable";
import type { IComputedValue } from "mobx";
import { computed } from "mobx";
import { pipeline } from "@ogre-tools/fp";
import { computedInjectManyInjectable } from "@ogre-tools/injectable-extension-for-mobx";
import {
filter,
flatMap,
identity,
invokeMap,
isEmpty,
map,
orderBy,
some,
} from "lodash/fp";
import { byOrderNumber } from "../../../common/utils/composable-responsibilities/orderable/orderable";
import type { SetRequired } from "type-fest";
export interface SidebarItemRegistration {
id: string;
@ -33,10 +24,8 @@ export const sidebarItemsInjectionToken = getInjectionToken<
IComputedValue<SidebarItemRegistration[]>
>({ id: "sidebar-items-injection-token" });
export interface HierarchicalSidebarItem {
registration: SidebarItemRegistration;
export interface HierarchicalSidebarItem extends SetRequired<SidebarItemRegistration, "isActive" | "isVisible"> {
children: HierarchicalSidebarItem[];
isActive: IComputedValue<boolean>;
}
const sidebarItemsInjectable = getInjectable({
@ -44,54 +33,42 @@ const sidebarItemsInjectable = getInjectable({
instantiate: (di) => {
const computedInjectMany = di.inject(computedInjectManyInjectable);
const sidebarItemRegistrations = computedInjectMany(sidebarItemsInjectionToken);
return computed((): HierarchicalSidebarItem[] => {
const registrations = pipeline(
sidebarItemRegistrations.get(),
flatMap(dereference),
);
const registrations = sidebarItemRegistrations
.get()
.flatMap(reg => reg.get());
const getSidebarItemsHierarchy = (registrations: SidebarItemRegistration[]) => {
const _getSidebarItemsHierarchy = (parentId: string | null): HierarchicalSidebarItem[] =>
pipeline(
registrations,
filter((item) => item.parentId === parentId),
map((registration) => {
const children = _getSidebarItemsHierarchy(registration.id);
const impl = (parentId: string | null): HierarchicalSidebarItem[] => (
registrations
.filter((item) => item.parentId === parentId)
.map(({
isActive = computed(() => false),
isVisible = computed(() => true),
...registration
}) => {
const children = impl(registration.id);
return {
registration,
...registration,
children,
isVisible,
isActive: computed(() => {
if (isEmpty(children)) {
return registration.isActive ? registration.isActive.get() : false;
if (children.length === 0) {
return isActive.get();
}
return pipeline(
children,
invokeMap("isActive.get"),
some(identity),
);
return children.some(child => child.isActive.get());
}),
};
}),
filter(item => item.registration.isVisible?.get() ?? true),
(items) =>
orderBy(
["registration.orderNumber"],
["asc"],
items,
),
})
.filter(({ isVisible }) => isVisible.get())
.sort(byOrderNumber)
);
return _getSidebarItemsHierarchy(null);
return impl(null);
};
return getSidebarItemsHierarchy(registrations);
@ -99,7 +76,4 @@ const sidebarItemsInjectable = getInjectable({
},
});
const dereference = (items: IComputedValue<SidebarItemRegistration[]>) =>
items.get();
export default sidebarItemsInjectable;

View File

@ -35,7 +35,7 @@ const NonInjectedSidebar = observer(({
.map(hierarchicalSidebarItem => (
<SidebarItem
item={hierarchicalSidebarItem}
key={hierarchicalSidebarItem.registration.id}
key={hierarchicalSidebarItem.id}
/>
))
}

View File

@ -34,21 +34,17 @@ export const TabLayout = observer(
{hasTabs && (
<Tabs center>
{tabs.map(({ registration, isActive }) => {
const active = isActive.get();
return (
{tabs.map(({ onClick, id, title, isActive }) => (
<Tab
onClick={registration.onClick}
key={registration.id}
label={registration.title}
active={active}
data-is-active-test={active}
data-testid={`tab-link-for-${registration.id}`}
onClick={onClick}
key={id}
label={title}
active={isActive.get()}
data-is-active-test={isActive.get()}
data-testid={`tab-link-for-${id}`}
value={undefined}
/>
);
})}
))}
</Tabs>
)}

View File

@ -122,7 +122,7 @@ function VirtualListInner<T extends { getId(): string } | string>({
? renderList(fixedHeight)
: (
<AutoSizer disableWidth>
{({ height }) => renderList(height)}
{({ height = 0 }) => renderList(height)}
</AutoSizer>
)
}

View File

@ -1,49 +1,53 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`get-multi-export-config given maximal package.json, when creating configuration works 1`] = `
Array [
Object {
"entry": Object {
[
{
"entry": {
"index": "./index.ts",
},
"externalsPresets": Object {
"externals": [
[Function],
[Function],
],
"externalsPresets": {
"node": true,
},
"mode": "production",
"module": Object {
"rules": Array [
Object {
"module": {
"rules": [
{
"loader": "ts-loader",
"test": /\\\\\\.ts\\(x\\)\\?\\$/,
},
],
},
"name": "./index.ts",
"node": Object {
"node": {
"__dirname": true,
"__filename": true,
},
"output": Object {
"output": {
"filename": [Function],
"libraryTarget": "commonjs2",
"path": "/some-working-directory/dist",
},
"performance": Object {
"performance": {
"hints": "error",
"maxEntrypointSize": 100000,
},
"plugins": Array [
"plugins": [
MakePeerDependenciesExternalPlugin {},
ProtectFromImportingNonDependencies {},
ForkTsCheckerWebpackPlugin {
"options": Object {
"typescript": Object {
"configOverwrite": Object {
"compilerOptions": Object {
"options": {
"typescript": {
"configOverwrite": {
"compilerOptions": {
"declaration": true,
"declarationDir": "/some-working-directory/dist",
},
"include": Array [
"include": [
"./index.ts",
],
},
@ -52,8 +56,8 @@ Array [
},
},
],
"resolve": Object {
"extensions": Array [
"resolve": {
"extensions": [
".ts",
".tsx",
".js",
@ -61,48 +65,52 @@ Array [
},
"target": "node",
},
Object {
"entry": Object {
{
"entry": {
"index": "./some-entrypoint/index.ts",
},
"externalsPresets": Object {
"externals": [
[Function],
[Function],
],
"externalsPresets": {
"node": true,
},
"mode": "production",
"module": Object {
"rules": Array [
Object {
"module": {
"rules": [
{
"loader": "ts-loader",
"test": /\\\\\\.ts\\(x\\)\\?\\$/,
},
],
},
"name": "./some-entrypoint/index.ts",
"node": Object {
"node": {
"__dirname": true,
"__filename": true,
},
"output": Object {
"output": {
"filename": [Function],
"libraryTarget": "commonjs2",
"path": "/some-working-directory/dist/some-entrypoint",
},
"performance": Object {
"performance": {
"hints": "error",
"maxEntrypointSize": 100000,
},
"plugins": Array [
"plugins": [
MakePeerDependenciesExternalPlugin {},
ProtectFromImportingNonDependencies {},
ForkTsCheckerWebpackPlugin {
"options": Object {
"typescript": Object {
"configOverwrite": Object {
"compilerOptions": Object {
"options": {
"typescript": {
"configOverwrite": {
"compilerOptions": {
"declaration": true,
"declarationDir": "/some-working-directory/dist/some-entrypoint",
},
"include": Array [
"include": [
"./some-entrypoint/index.ts",
],
},
@ -111,8 +119,8 @@ Array [
},
},
],
"resolve": Object {
"extensions": Array [
"resolve": {
"extensions": [
".ts",
".tsx",
".js",
@ -120,30 +128,34 @@ Array [
},
"target": "node",
},
Object {
"entry": Object {
{
"entry": {
"index": "./some-other-entrypoint/index.ts",
},
"externalsPresets": Object {
"externals": [
[Function],
[Function],
],
"externalsPresets": {
"node": true,
},
"mode": "production",
"module": Object {
"rules": Array [
Object {
"module": {
"rules": [
{
"loader": "ts-loader",
"test": /\\\\\\.ts\\(x\\)\\?\\$/,
},
Object {
{
"test": /\\\\\\.s\\?css\\$/,
"use": Array [
Object {
"use": [
{
"some": "miniCssExtractPluginLoader",
},
Object {
{
"loader": "css-loader",
"options": Object {
"modules": Object {
"options": {
"modules": {
"auto": /\\\\\\.module\\\\\\./i,
"localIdentName": "[name]__[local]--[hash:base64:5]",
"mode": "local",
@ -151,7 +163,7 @@ Array [
"sourceMap": false,
},
},
Object {
{
"loader": "postcss-loader",
"options": Object {
"postcssOptions": Object {
@ -162,9 +174,9 @@ Array [
"sourceMap": false,
},
},
Object {
{
"loader": "sass-loader",
"options": Object {
"options": {
"sourceMap": false,
},
},
@ -185,31 +197,31 @@ Array [
],
},
"name": "./some-other-entrypoint/index.ts",
"node": Object {
"node": {
"__dirname": true,
"__filename": true,
},
"output": Object {
"output": {
"filename": [Function],
"libraryTarget": "commonjs2",
"path": "/some-working-directory/dist/some-other-entrypoint",
},
"performance": Object {
"performance": {
"hints": "error",
"maxEntrypointSize": 100000,
},
"plugins": Array [
"plugins": [
MakePeerDependenciesExternalPlugin {},
ProtectFromImportingNonDependencies {},
ForkTsCheckerWebpackPlugin {
"options": Object {
"typescript": Object {
"configOverwrite": Object {
"compilerOptions": Object {
"options": {
"typescript": {
"configOverwrite": {
"compilerOptions": {
"declaration": true,
"declarationDir": "/some-working-directory/dist/some-other-entrypoint",
},
"include": Array [
"include": [
"./some-other-entrypoint/index.ts",
],
},
@ -219,22 +231,22 @@ Array [
},
MiniCssExtractPlugin {
"_sortedModulesCache": WeakMap {},
"options": Object {
"options": {
"chunkFilename": "[name].css",
"experimentalUseImportModule": undefined,
"filename": "[name].css",
"ignoreOrder": false,
"runtime": true,
},
"runtimeOptions": Object {
"runtimeOptions": {
"attributes": undefined,
"insert": undefined,
"linkType": "text/css",
},
},
],
"resolve": Object {
"extensions": Array [
"resolve": {
"extensions": [
".ts",
".tsx",
".js",

View File

@ -201,11 +201,11 @@
"@k8slens/run-many": "^1.0.0-alpha.2",
"@k8slens/startable-stoppable": "^1.0.0-alpha.2",
"@k8slens/utilities": "^1.0.0-alpha.2",
"@ogre-tools/fp": "^15.1.2",
"@ogre-tools/injectable": "^15.1.2",
"@ogre-tools/injectable-extension-for-auto-registration": "^15.1.2",
"@ogre-tools/fp": "^15.3.0",
"@ogre-tools/injectable": "^15.3.0",
"@ogre-tools/injectable-extension-for-auto-registration": "^15.3.0",
"@ogre-tools/injectable-extension-for-mobx": "^15.3.0",
"@ogre-tools/injectable-react": "^15.1.2",
"@ogre-tools/injectable-react": "^15.3.0",
"mobx": "^6.8.0",
"rimraf": "^4.4.1"
},

View File

@ -33,9 +33,9 @@
"peerDependencies": {
"@k8slens/feature-core": "^6.5.0-alpha.0",
"@k8slens/run-many": "^1.0.0-alpha.1",
"@ogre-tools/fp": "^15.1.2",
"@ogre-tools/injectable": "^15.1.2",
"@ogre-tools/injectable-extension-for-auto-registration": "^15.1.2",
"@ogre-tools/fp": "^15.3.0",
"@ogre-tools/injectable": "^15.3.0",
"@ogre-tools/injectable-extension-for-auto-registration": "^15.3.0",
"lodash": "^4.17.15"
},
"devDependencies": {

View File

@ -34,8 +34,8 @@
"@k8slens/application": "^6.5.0-alpha.0",
"@k8slens/feature-core": "^6.5.0-alpha.0",
"@k8slens/run-many": "^1.0.0-alpha.1",
"@ogre-tools/injectable": "^15.1.2",
"@ogre-tools/injectable-extension-for-auto-registration": "^15.1.2",
"@ogre-tools/injectable": "^15.3.0",
"@ogre-tools/injectable-extension-for-auto-registration": "^15.3.0",
"electron": "^22.3.3",
"lodash": "^4.17.21"
},

View File

@ -1,44 +1,39 @@
import { DiContainer, getInjectable, instantiationDecoratorToken, lifecycleEnum } from "@ogre-tools/injectable";
import {
getInjectable,
instantiationDecoratorToken,
createInstantiationTargetDecorator,
} from "@ogre-tools/injectable";
import { startApplicationInjectionToken } from "@k8slens/application";
import whenAppIsReadyInjectable from "./when-app-is-ready.injectable";
import { beforeAnythingInjectionToken, beforeElectronIsReadyInjectionToken } from "./time-slots";
import { runManySyncFor } from "@k8slens/run-many";
import { curry } from "lodash";
type ToBeDecorated = (di: DiContainer, ...args: unknown[]) => (...args: unknown[]) => unknown;
const decorator = (toBeDecorated: unknown, di: DiContainer, ...args: unknown[]) => {
const startElectronApplicationInjectable = getInjectable({
id: "start-electron-application",
instantiate: () =>
createInstantiationTargetDecorator({
target: startApplicationInjectionToken,
decorate: (targetInstantiate) => (di) => {
const whenAppIsReady = di.inject(whenAppIsReadyInjectable);
const runManySync = runManySyncFor(di);
const beforeAnything = runManySync(beforeAnythingInjectionToken);
const beforeElectronIsReady = runManySync(beforeElectronIsReadyInjectionToken);
const startApplication = (toBeDecorated as ToBeDecorated)(di, ...args);
const startApplication = targetInstantiate(di);
return (...startApplicationArgs: unknown[]) => {
return () => {
beforeAnything();
beforeElectronIsReady();
return (async () => {
await whenAppIsReady();
return startApplication(...startApplicationArgs);
return startApplication();
})();
};
};
const startElectronApplicationInjectable = getInjectable({
id: "start-electron-application",
instantiate: () => ({
decorate: curry(decorator),
target: startApplicationInjectionToken,
},
}),
decorable: false,
injectionToken: instantiationDecoratorToken,
lifecycle: lifecycleEnum.singleton,
});
export default startElectronApplicationInjectable;

View File

@ -30,7 +30,7 @@
"lint:fix": "lens-lint --fix"
},
"peerDependencies": {
"@ogre-tools/injectable": "^15.1.2"
"@ogre-tools/injectable": "^15.3.0"
},
"devDependencies": {
"@k8slens/eslint-config": "^6.5.0-alpha.2"

View File

@ -31,7 +31,7 @@
"lint:fix": "lens-lint --fix"
},
"peerDependencies": {
"@ogre-tools/injectable": "^15.1.2"
"@ogre-tools/injectable": "^15.3.0"
},
"devDependencies": {
"@k8slens/eslint-config": "^6.5.0-alpha.2"

View File

@ -109,7 +109,9 @@ describe("register-feature", () => {
instantiate: (di) => di.inject(someInjectable),
});
const di = createContainer("some-container");
const di = createContainer("some-container", {
detectCycles: false,
});
const someFeature = getFeature({
id: "some-feature-1",
@ -132,9 +134,9 @@ describe("register-feature", () => {
expect(() => {
di.inject(someInjectable);
}).toThrow(
// 'Cycle of injectables encountered: "some-container" -> "some-feature-1:some-injectable-1"
// -> "some-feature-2:some-injectable-2" -> "some-feature-1:some-injectable-1"'
"Maximum call stack size exceeded",
// eslint-disable-next-line max-len
// 'Cycle of injectables encountered: "some-feature-1:some-injectable-1" -> "some-feature-2:some-injectable-2" -> "some-feature-1:some-injectable-1"',
);
});
});

View File

@ -34,9 +34,9 @@
"@k8slens/application": "^6.5.0-alpha.0",
"@k8slens/feature-core": "^6.5.0-alpha.0",
"@k8slens/startable-stoppable": "^1.0.0-alpha.1",
"@ogre-tools/injectable": "^15.1.2",
"@ogre-tools/injectable-extension-for-auto-registration": "^15.1.2",
"@ogre-tools/injectable-extension-for-mobx": "^15.1.2",
"@ogre-tools/injectable": "^15.3.0",
"@ogre-tools/injectable-extension-for-auto-registration": "^15.3.0",
"@ogre-tools/injectable-extension-for-mobx": "^15.3.0",
"lodash": "^4.17.21",
"mobx": "^6.7.0"
},

View File

@ -34,10 +34,10 @@
"@k8slens/application": "^6.5.0-alpha.0",
"@k8slens/feature-core": "^6.5.0-alpha.0",
"@k8slens/messaging": "^1.0.0-alpha.1",
"@ogre-tools/fp": "^15.1.2",
"@ogre-tools/injectable": "^15.1.2",
"@ogre-tools/injectable-extension-for-auto-registration": "^15.1.2",
"@ogre-tools/injectable-extension-for-mobx": "^15.1.2",
"@ogre-tools/fp": "^15.3.0",
"@ogre-tools/injectable": "^15.3.0",
"@ogre-tools/injectable-extension-for-auto-registration": "^15.3.0",
"@ogre-tools/injectable-extension-for-mobx": "^15.3.0",
"lodash": "^4.17.21",
"mobx": "^6.8.0"
},

View File

@ -34,8 +34,8 @@
"@k8slens/application": "^6.5.0-alpha.0",
"@k8slens/feature-core": "^6.5.0-alpha.0",
"@k8slens/messaging": "^1.0.0-alpha.1",
"@ogre-tools/injectable": "^15.1.2",
"@ogre-tools/injectable-extension-for-auto-registration": "^15.1.2",
"@ogre-tools/injectable": "^15.3.0",
"@ogre-tools/injectable-extension-for-auto-registration": "^15.3.0",
"@ogre-tools/fp": "^15.1.2",
"electron": "^22.3.3",
"lodash": "^4.17.21"

View File

@ -36,8 +36,8 @@
"@k8slens/messaging": "^1.0.0-alpha.1",
"@k8slens/run-many": "^1.0.0-alpha.1",
"@k8slens/startable-stoppable": "^1.0.0-alpha.1",
"@ogre-tools/injectable": "^15.1.2",
"@ogre-tools/injectable-extension-for-auto-registration": "^15.1.2",
"@ogre-tools/injectable": "^15.3.0",
"@ogre-tools/injectable-extension-for-auto-registration": "^15.3.0",
"electron": "^22.3.3",
"lodash": "^4.17.21"
},

View File

@ -32,15 +32,15 @@
},
"peerDependencies": {
"@async-fn/jest": "^1.6.4",
"@k8slens/feature-core": "^6.5.0-alpha.2",
"@k8slens/messaging": "^1.0.0-alpha.1",
"@ogre-tools/fp": "^15.1.2",
"@ogre-tools/injectable": "^15.1.2",
"lodash": "^4.17.21"
"@ogre-tools/fp": "^15.3.0",
"@ogre-tools/injectable": "^15.3.0",
"@ogre-tools/injectable-extension-for-mobx": "^15.3.0",
"lodash": "^4.17.21",
"mobx": "^6.9.0"
},
"devDependencies": {
"@k8slens/eslint-config": "^6.5.0-alpha.2",
"@k8slens/feature-core": "^6.5.0-alpha.2",
"@ogre-tools/injectable-extension-for-mobx": "^15.3.0",
"mobx": "^6.7.0"
"@k8slens/eslint-config": "^6.5.0-alpha.2"
}
}

View File

@ -33,11 +33,11 @@
"peerDependencies": {
"@k8slens/application": "^6.5.0-alpha.2",
"@k8slens/feature-core": "^6.5.0-alpha.0",
"@ogre-tools/fp": "^15.1.2",
"@ogre-tools/injectable": "^15.1.2",
"@ogre-tools/injectable-extension-for-auto-registration": "^15.1.2",
"@ogre-tools/injectable-extension-for-mobx": "^15.1.2",
"@ogre-tools/injectable-react": "^15.1.2",
"@ogre-tools/fp": "^15.3.0",
"@ogre-tools/injectable": "^15.3.0",
"@ogre-tools/injectable-extension-for-auto-registration": "^15.3.0",
"@ogre-tools/injectable-extension-for-mobx": "^15.3.0",
"@ogre-tools/injectable-react": "^15.3.0",
"lodash": "^4.17.15",
"mobx": "^6.8.0",
"mobx-react": "^7.6.0",

View File

@ -27,8 +27,8 @@
"peerDependencies": {
"@k8slens/test-utils": "^1.0.0-alpha.1",
"@k8slens/utilities": "^1.0.0-alpha.1",
"@ogre-tools/fp": "^15.1.2",
"@ogre-tools/injectable": "^15.1.2",
"@ogre-tools/fp": "^15.3.0",
"@ogre-tools/injectable": "^15.3.0",
"type-fest": "^2.19.0",
"typed-emitter": "^1.4.0",
"uuid": "^8.3.2"

View File

@ -24,12 +24,13 @@
"build": "webpack"
},
"peerDependencies": {
"@ogre-tools/injectable": "^15.1.2",
"@ogre-tools/injectable-react": "^15.1.2",
"@ogre-tools/injectable": "^15.3.0",
"@ogre-tools/injectable-react": "^15.3.0",
"@testing-library/react": "^12.1.5",
"lodash": "^4.17.21",
"mobx": "^6.8.0",
"react": "^17.0.2"
"react": "^17.0.2",
"react-dom": "^17.0.2"
},
"devDependencies": {
"@types/lodash": "^4.14.191"