refactor(core): Move dependencies of Logger to standalone packages (#15338)

This commit is contained in:
Iván Ovejero
2025-05-13 16:55:42 +02:00
committed by GitHub
parent 3840cbabbf
commit 3176f6fc89
27 changed files with 58 additions and 59 deletions

View File

@@ -38,6 +38,7 @@
"dependencies": {
"@aws-sdk/client-s3": "3.808.0",
"@langchain/core": "catalog:",
"@n8n/backend-common": "workspace:^",
"@n8n/client-oauth2": "workspace:*",
"@n8n/config": "workspace:*",
"@n8n/decorators": "workspace:*",

View File

@@ -1,8 +1,3 @@
const { NODE_ENV } = process.env;
export const inProduction = NODE_ENV === 'production';
export const inDevelopment = !NODE_ENV || NODE_ENV === 'development';
export const inTest = NODE_ENV === 'test';
export const CUSTOM_EXTENSION_ENV = 'N8N_CUSTOM_EXTENSIONS';
export const PLACEHOLDER_EMPTY_EXECUTION_ID = '__UNKNOWN__';
export const PLACEHOLDER_EMPTY_WORKFLOW_ID = '__EMPTY__';

View File

@@ -1,3 +1,4 @@
import { inTest } from '@n8n/backend-common';
import { InstanceSettingsConfig } from '@n8n/config';
import { Memoized } from '@n8n/decorators';
import { Service } from '@n8n/di';
@@ -27,8 +28,6 @@ type InstanceRole = 'unset' | 'leader' | 'follower';
export type InstanceType = 'main' | 'webhook' | 'worker';
const inTest = process.env.NODE_ENV === 'test';
@Service()
export class InstanceSettings {
/** The path to the n8n folder in which all n8n related data gets saved */

View File

@@ -1,3 +1,4 @@
import { inDevelopment, inProduction } from '@n8n/backend-common';
import type { LogScope } from '@n8n/config';
import { GlobalConfig, InstanceSettingsConfig } from '@n8n/config';
import { Service } from '@n8n/di';
@@ -14,7 +15,6 @@ import path, { basename } from 'node:path';
import pc from 'picocolors';
import winston from 'winston';
import { inDevelopment, inProduction } from '@/constants';
import { isObjectLiteral } from '@/utils/is-object-literal';
const noOp = () => {};

View File

@@ -2,9 +2,12 @@ import vm from 'vm';
import { loadClassInIsolation } from '../load-class-in-isolation';
jest.mock('@/constants', () => ({
inTest: false,
}));
jest.mock('@n8n/backend-common', () => {
return {
...jest.requireActual('@n8n/backend-common'),
inTest: false,
};
});
describe('loadClassInIsolation', () => {
const filePath = '/path/to/TestClass.js';

View File

@@ -1,7 +1,6 @@
import { inTest } from '@n8n/backend-common';
import { createContext, Script } from 'vm';
import { inTest } from '@/constants';
const context = createContext({ require });
export const loadClassInIsolation = <T>(filePath: string, className: string) => {
if (process.platform === 'win32') {