From 3a2e436933a710d56505a15c0bb8fdc8f7deb734 Mon Sep 17 00:00:00 2001 From: Sebastian Malton Date: Thu, 2 Mar 2023 09:41:36 -0500 Subject: [PATCH] Move run-many and run-many-sync to separate package Signed-off-by: Sebastian Malton --- packages/utility-features/run-many/README.md | 3 ++ packages/utility-features/run-many/index.ts | 2 ++ .../utility-features/run-many/jest.config.js | 2 ++ .../utility-features/run-many/package.json | 33 +++++++++++++++++++ .../run-many/src}/helpers.ts | 2 +- .../run-many/src}/run-many-for.test.ts | 3 +- .../run-many/src}/run-many-for.ts | 4 +-- .../run-many/src}/run-many-sync-for.test.ts | 0 .../run-many/src}/run-many-sync-for.ts | 2 +- .../run-many/src}/types.ts | 2 +- .../utility-features/run-many/tsconfig.json | 3 ++ .../run-many/webpack.config.js | 1 + 12 files changed, 50 insertions(+), 7 deletions(-) create mode 100644 packages/utility-features/run-many/README.md create mode 100644 packages/utility-features/run-many/index.ts create mode 100644 packages/utility-features/run-many/jest.config.js create mode 100644 packages/utility-features/run-many/package.json rename packages/{core/src/common/runnable => utility-features/run-many/src}/helpers.ts (98%) rename packages/{core/src/common/runnable => utility-features/run-many/src}/run-many-for.test.ts (99%) rename packages/{core/src/common/runnable => utility-features/run-many/src}/run-many-for.ts (94%) rename packages/{core/src/common/runnable => utility-features/run-many/src}/run-many-sync-for.test.ts (100%) rename packages/{core/src/common/runnable => utility-features/run-many/src}/run-many-sync-for.ts (97%) rename packages/{core/src/common/runnable => utility-features/run-many/src}/types.ts (95%) create mode 100644 packages/utility-features/run-many/tsconfig.json create mode 100644 packages/utility-features/run-many/webpack.config.js diff --git a/packages/utility-features/run-many/README.md b/packages/utility-features/run-many/README.md new file mode 100644 index 0000000000..b24cf0fccd --- /dev/null +++ b/packages/utility-features/run-many/README.md @@ -0,0 +1,3 @@ +# @k8slens/run-many + +This package contains the functions `runMany` and `runManySync` diff --git a/packages/utility-features/run-many/index.ts b/packages/utility-features/run-many/index.ts new file mode 100644 index 0000000000..7944895d01 --- /dev/null +++ b/packages/utility-features/run-many/index.ts @@ -0,0 +1,2 @@ +export * from "./src/run-many-for"; +export * from "./src/run-many-sync-for"; diff --git a/packages/utility-features/run-many/jest.config.js b/packages/utility-features/run-many/jest.config.js new file mode 100644 index 0000000000..23be80353b --- /dev/null +++ b/packages/utility-features/run-many/jest.config.js @@ -0,0 +1,2 @@ +module.exports = + require("@k8slens/jest").monorepoPackageConfig(__dirname).configForReact; diff --git a/packages/utility-features/run-many/package.json b/packages/utility-features/run-many/package.json new file mode 100644 index 0000000000..e469c50730 --- /dev/null +++ b/packages/utility-features/run-many/package.json @@ -0,0 +1,33 @@ +{ + "name": "@k8slens/run-many", + "version": "1.0.0", + "type": "commonjs", + "description": "A package containing runMany and runManySync", + "publishConfig": { + "access": "public", + "registry": "https://registry.npmjs.org/" + }, + "private": false, + "files": [ + "dist" + ], + "main": "dist/index.js", + "types": "dist/index.d.ts", + "author": { + "name": "OpenLens Authors", + "email": "info@k8slens.dev" + }, + "license": "MIT", + "homepage": "https://github.com/lensapp/lens", + "scripts": { + "build": "webpack", + "dev": "webpack --mode=development --watch", + "test": "jest --coverage --runInBand" + }, + "peerDependencies": { + "@k8slens/test-utils": "^1.0.0", + "@k8slens/utilities": "^1.0.0", + "@ogre-tools/fp": "^15.1.1", + "@ogre-tools/injectable": "^15.1.1" + } +} diff --git a/packages/core/src/common/runnable/helpers.ts b/packages/utility-features/run-many/src/helpers.ts similarity index 98% rename from packages/core/src/common/runnable/helpers.ts rename to packages/utility-features/run-many/src/helpers.ts index d7763eb34b..adb0126cbf 100644 --- a/packages/core/src/common/runnable/helpers.ts +++ b/packages/utility-features/run-many/src/helpers.ts @@ -3,7 +3,7 @@ * Licensed under MIT License. See LICENSE in root directory for more information. */ import type { DiContainerForInjection, InjectionInstanceWithMeta } from "@ogre-tools/injectable"; -import { getOrInsertSetFor, isDefined } from "../utils"; +import { getOrInsertSetFor, isDefined } from "@k8slens/utilities"; import * as uuid from "uuid"; import assert from "assert"; import type { Runnable, RunnableSync, RunnableSyncWithId, RunnableWithId } from "./types"; diff --git a/packages/core/src/common/runnable/run-many-for.test.ts b/packages/utility-features/run-many/src/run-many-for.test.ts similarity index 99% rename from packages/core/src/common/runnable/run-many-for.test.ts rename to packages/utility-features/run-many/src/run-many-for.test.ts index ffbde3c92b..8fe753378c 100644 --- a/packages/core/src/common/runnable/run-many-for.test.ts +++ b/packages/utility-features/run-many/src/run-many-for.test.ts @@ -7,9 +7,8 @@ import asyncFn from "@async-fn/jest"; import { createContainer, getInjectable, getInjectionToken } from "@ogre-tools/injectable"; import type { Runnable } from "./types"; import { runManyFor } from "./run-many-for"; -import { getPromiseStatus } from "../test-utils/get-promise-status"; +import { getPromiseStatus, flushPromises } from "@k8slens/test-utils"; import { runInAction } from "mobx"; -import { flushPromises } from "../test-utils/flush-promises"; describe("runManyFor", () => { describe("given no hierarchy, when running many", () => { diff --git a/packages/core/src/common/runnable/run-many-for.ts b/packages/utility-features/run-many/src/run-many-for.ts similarity index 94% rename from packages/core/src/common/runnable/run-many-for.ts rename to packages/utility-features/run-many/src/run-many-for.ts index 4396809626..4d33c009e2 100644 --- a/packages/core/src/common/runnable/run-many-for.ts +++ b/packages/utility-features/run-many/src/run-many-for.ts @@ -3,7 +3,7 @@ * Licensed under MIT License. See LICENSE in root directory for more information. */ import type { DiContainerForInjection, InjectionToken } from "@ogre-tools/injectable"; -import { getOrInsert } from "../utils"; +import { getOrInsert } from "@k8slens/utilities"; import type TypedEventEmitter from "typed-emitter"; import EventEmitter from "events"; import { convertToWithIdWith, verifyRunnablesAreDAG } from "./helpers"; @@ -21,7 +21,7 @@ class DynamicBarrier { private readonly events: TypedEventEmitter = new EventEmitter(); private initFinishingPromise(id: string): Promise { - return getOrInsert(this.finishedIds, id, new Promise(resolve => { + return getOrInsert(this.finishedIds, id, new Promise(resolve => { const handler = (finishedId: string) => { if (finishedId === id) { resolve(); diff --git a/packages/core/src/common/runnable/run-many-sync-for.test.ts b/packages/utility-features/run-many/src/run-many-sync-for.test.ts similarity index 100% rename from packages/core/src/common/runnable/run-many-sync-for.test.ts rename to packages/utility-features/run-many/src/run-many-sync-for.test.ts diff --git a/packages/core/src/common/runnable/run-many-sync-for.ts b/packages/utility-features/run-many/src/run-many-sync-for.ts similarity index 97% rename from packages/core/src/common/runnable/run-many-sync-for.ts rename to packages/utility-features/run-many/src/run-many-sync-for.ts index f324cc4d29..f93b41470e 100644 --- a/packages/core/src/common/runnable/run-many-sync-for.ts +++ b/packages/utility-features/run-many/src/run-many-sync-for.ts @@ -3,7 +3,7 @@ * Licensed under MIT License. See LICENSE in root directory for more information. */ import type { DiContainerForInjection, InjectionToken } from "@ogre-tools/injectable"; -import type { Disposer } from "../utils"; +import type { Disposer } from "@k8slens/utilities"; import type { RunnableSync, RunSync, RunnableSyncWithId } from "./types"; import { convertToWithIdWith, verifyRunnablesAreDAG } from "./helpers"; import type TypedEventEmitter from "typed-emitter"; diff --git a/packages/core/src/common/runnable/types.ts b/packages/utility-features/run-many/src/types.ts similarity index 95% rename from packages/core/src/common/runnable/types.ts rename to packages/utility-features/run-many/src/types.ts index 4fa7647cad..007d9bcef1 100644 --- a/packages/core/src/common/runnable/types.ts +++ b/packages/utility-features/run-many/src/types.ts @@ -4,7 +4,7 @@ */ import type { Injectable } from "@ogre-tools/injectable"; -import type { SingleOrMany } from "../utils"; +import type { SingleOrMany } from "@k8slens/utilities"; export type Run = (parameter: Param) => Promise | void; diff --git a/packages/utility-features/run-many/tsconfig.json b/packages/utility-features/run-many/tsconfig.json new file mode 100644 index 0000000000..a4f6fa613e --- /dev/null +++ b/packages/utility-features/run-many/tsconfig.json @@ -0,0 +1,3 @@ +{ + "extends": "@k8slens/typescript/config/base.json" +} diff --git a/packages/utility-features/run-many/webpack.config.js b/packages/utility-features/run-many/webpack.config.js new file mode 100644 index 0000000000..3183f30179 --- /dev/null +++ b/packages/utility-features/run-many/webpack.config.js @@ -0,0 +1 @@ +module.exports = require("@k8slens/webpack").configForNode;