From 1c401350435c850dfea217e051240db7372d0ebd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E0=A4=95=E0=A4=BE=E0=A4=B0=E0=A4=A4=E0=A5=8B=E0=A4=AB?= =?UTF-8?q?=E0=A5=8D=E0=A4=AB=E0=A5=87=E0=A4=B2=E0=A4=B8=E0=A5=8D=E0=A4=95?= =?UTF-8?q?=E0=A5=8D=E0=A4=B0=E0=A4=BF=E0=A4=AA=E0=A5=8D=E0=A4=9F=E2=84=A2?= Date: Tue, 27 Aug 2024 14:33:25 +0200 Subject: [PATCH] refactor(core): Delete InternalHooks (no-changelog) (#10561) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Iván Ovejero --- packages/cli/src/commands/base-command.ts | 6 +++-- packages/cli/src/internal-hooks.ts | 24 ------------------- .../integration/shared/utils/testCommand.ts | 4 ++-- 3 files changed, 6 insertions(+), 28 deletions(-) delete mode 100644 packages/cli/src/internal-hooks.ts diff --git a/packages/cli/src/commands/base-command.ts b/packages/cli/src/commands/base-command.ts index db6897c252..c41fe16d7f 100644 --- a/packages/cli/src/commands/base-command.ts +++ b/packages/cli/src/commands/base-command.ts @@ -16,7 +16,6 @@ import { NodeTypes } from '@/node-types'; import { LoadNodesAndCredentials } from '@/load-nodes-and-credentials'; import type { N8nInstanceType } from '@/Interfaces'; import { PostHogClient } from '@/posthog'; -import { InternalHooks } from '@/internal-hooks'; import { License } from '@/license'; import { ExternalSecretsManager } from '@/external-secrets/external-secrets-manager.ee'; import { initExpressionEvaluator } from '@/expression-evaluator'; @@ -24,6 +23,7 @@ import { generateHostInstanceId } from '@db/utils/generators'; import { WorkflowHistoryManager } from '@/workflows/workflow-history/workflow-history-manager.ee'; import { ShutdownService } from '@/shutdown/shutdown.service'; import { TelemetryEventRelay } from '@/events/telemetry-event-relay'; +import { MessageEventBus } from '@/eventbus/message-event-bus/message-event-bus'; export abstract class BaseCommand extends Command { protected logger = Container.get(Logger); @@ -120,8 +120,10 @@ export abstract class BaseCommand extends Command { await Container.get(CommunityPackagesService).checkForMissingPackages(); } + // TODO: remove this after the cyclic dependencies around the event-bus are resolved + Container.get(MessageEventBus); + await Container.get(PostHogClient).init(); - await Container.get(InternalHooks).init(); await Container.get(TelemetryEventRelay).init(); } diff --git a/packages/cli/src/internal-hooks.ts b/packages/cli/src/internal-hooks.ts deleted file mode 100644 index 378a01ecaa..0000000000 --- a/packages/cli/src/internal-hooks.ts +++ /dev/null @@ -1,24 +0,0 @@ -import { Service } from 'typedi'; -import { Telemetry } from '@/telemetry'; -import { MessageEventBus } from './eventbus/message-event-bus/message-event-bus'; - -/** - * @deprecated Do not add to this class. It will be removed once we remove - * further dep cycles. To add log streaming or telemetry events, use - * `EventService` to emit the event and then use the `LogStreamingEventRelay` or - * `TelemetryEventRelay` to forward them to the event bus or telemetry. - */ -@Service() -export class InternalHooks { - constructor( - private readonly telemetry: Telemetry, - // Can't use @ts-expect-error because only dev time tsconfig considers this as an error, but not build time - // eslint-disable-next-line @typescript-eslint/ban-ts-comment - // @ts-ignore - needed until we decouple telemetry - private readonly _eventBus: MessageEventBus, // needed until we decouple telemetry - ) {} - - async init() { - await this.telemetry.init(); - } -} diff --git a/packages/cli/test/integration/shared/utils/testCommand.ts b/packages/cli/test/integration/shared/utils/testCommand.ts index 4e796316bb..4043725a8d 100644 --- a/packages/cli/test/integration/shared/utils/testCommand.ts +++ b/packages/cli/test/integration/shared/utils/testCommand.ts @@ -6,9 +6,9 @@ import type { BaseCommand } from '@/commands/base-command'; import * as testDb from '../testDb'; import { TelemetryEventRelay } from '@/events/telemetry-event-relay'; import { mockInstance } from '@test/mocking'; -import { InternalHooks } from '@/internal-hooks'; +import { MessageEventBus } from '@/eventbus/message-event-bus/message-event-bus'; -mockInstance(InternalHooks); +mockInstance(MessageEventBus); export const setupTestCommand = (Command: Class) => { const config = mock();