chore: 清理macOS同步产生的重复文件

详细说明:
- 删除了352个带数字后缀的重复文件
- 更新.gitignore防止未来产生此类文件
- 这些文件是由iCloud或其他同步服务冲突产生的
- 不影响项目功能,仅清理冗余文件
This commit is contained in:
Yep_Q
2025-09-08 12:06:01 +08:00
parent 1564396449
commit d6f48d6d14
365 changed files with 2039 additions and 68301 deletions

View File

@@ -1,12 +0,0 @@
import type { Logger } from '@n8n/backend-common';
import { mock } from 'jest-mock-extended';
export const mockLogger = (): Logger =>
mock<Logger>({ scoped: jest.fn().mockReturnValue(mock<Logger>()) });
export * from './random';
export * as testDb from './test-db';
export * as testModules from './test-modules';
export * from './db/workflows';
export * from './db/projects';
export * from './mocking';

View File

@@ -1,12 +0,0 @@
import { Container, type Constructable } from '@n8n/di';
import { mock } from 'jest-mock-extended';
import type { DeepPartial } from 'ts-essentials';
export const mockInstance = <T>(
serviceClass: Constructable<T>,
data: DeepPartial<T> | undefined = undefined,
) => {
const instance = mock<T>(data);
Container.set(serviceClass, instance);
return instance;
};

View File

@@ -1,63 +0,0 @@
import { MIN_PASSWORD_CHAR_LENGTH, MAX_PASSWORD_CHAR_LENGTH } from '@n8n/constants';
import { randomInt, randomString, UPPERCASE_LETTERS } from 'n8n-workflow';
import type { ICredentialDataDecryptedObject } from 'n8n-workflow';
import { v4 as uuid } from 'uuid';
export type CredentialPayload = {
name: string;
type: string;
data: ICredentialDataDecryptedObject;
isManaged?: boolean;
};
export const randomApiKey = () => `n8n_api_${randomString(40)}`;
export const chooseRandomly = <T>(array: T[]) => array[randomInt(array.length)];
const randomUppercaseLetter = () => chooseRandomly(UPPERCASE_LETTERS.split(''));
export const randomValidPassword = () =>
randomString(MIN_PASSWORD_CHAR_LENGTH, MAX_PASSWORD_CHAR_LENGTH - 2) +
randomUppercaseLetter() +
randomInt(10);
export const randomInvalidPassword = () =>
chooseRandomly([
randomString(1, MIN_PASSWORD_CHAR_LENGTH - 1),
randomString(MAX_PASSWORD_CHAR_LENGTH + 2, MAX_PASSWORD_CHAR_LENGTH + 100),
'abcdefgh', // valid length, no number, no uppercase
'abcdefg1', // valid length, has number, no uppercase
'abcdefgA', // valid length, no number, has uppercase
'abcdefA', // invalid length, no number, has uppercase
'abcdef1', // invalid length, has number, no uppercase
'abcdeA1', // invalid length, has number, has uppercase
'abcdefg', // invalid length, no number, no uppercase
]);
const POPULAR_TOP_LEVEL_DOMAINS = ['com', 'org', 'net', 'io', 'edu'];
const randomTopLevelDomain = () => chooseRandomly(POPULAR_TOP_LEVEL_DOMAINS);
export const randomName = () => randomString(4, 8).toLowerCase();
export const randomEmail = () => `${randomName()}@${randomName()}.${randomTopLevelDomain()}`;
export const randomCredentialPayload = ({
isManaged = false,
}: { isManaged?: boolean } = {}): CredentialPayload => ({
name: randomName(),
type: randomName(),
data: { accessToken: randomString(6, 16) },
isManaged,
});
export const randomCredentialPayloadWithOauthTokenData = ({
isManaged = false,
}: { isManaged?: boolean } = {}): CredentialPayload => ({
name: randomName(),
type: randomName(),
data: { accessToken: randomString(6, 16), oauthTokenData: { access_token: randomString(6, 16) } },
isManaged,
});
export const uniqueId = () => uuid();

View File

@@ -1,86 +0,0 @@
import { GlobalConfig } from '@n8n/config';
import type { entities } from '@n8n/db';
import { DbConnection, DbConnectionOptions } from '@n8n/db';
import { Container } from '@n8n/di';
import type { DataSourceOptions } from '@n8n/typeorm';
import { DataSource as Connection } from '@n8n/typeorm';
import { randomString } from 'n8n-workflow';
export const testDbPrefix = 'n8n_test_';
/**
* Generate options for a bootstrap DB connection, to create and drop test databases.
*/
export const getBootstrapDBOptions = (dbType: 'postgresdb' | 'mysqldb'): DataSourceOptions => {
const globalConfig = Container.get(GlobalConfig);
const type = dbType === 'postgresdb' ? 'postgres' : 'mysql';
return {
type,
...Container.get(DbConnectionOptions).getOverrides(dbType),
database: type,
entityPrefix: globalConfig.database.tablePrefix,
schema: dbType === 'postgresdb' ? globalConfig.database.postgresdb.schema : undefined,
};
};
/**
* Initialize one test DB per suite run, with bootstrap connection if needed.
*/
export async function init() {
const globalConfig = Container.get(GlobalConfig);
const dbType = globalConfig.database.type;
const testDbName = `${testDbPrefix}${randomString(6, 10).toLowerCase()}_${Date.now()}`;
if (dbType === 'postgresdb') {
const bootstrapPostgres = await new Connection(
getBootstrapDBOptions('postgresdb'),
).initialize();
await bootstrapPostgres.query(`CREATE DATABASE ${testDbName}`);
await bootstrapPostgres.destroy();
globalConfig.database.postgresdb.database = testDbName;
} else if (dbType === 'mysqldb' || dbType === 'mariadb') {
const bootstrapMysql = await new Connection(getBootstrapDBOptions('mysqldb')).initialize();
await bootstrapMysql.query(`CREATE DATABASE ${testDbName} DEFAULT CHARACTER SET utf8mb4`);
await bootstrapMysql.destroy();
globalConfig.database.mysqldb.database = testDbName;
}
const dbConnection = Container.get(DbConnection);
await dbConnection.init();
await dbConnection.migrate();
}
export function isReady() {
const { connectionState } = Container.get(DbConnection);
return connectionState.connected && connectionState.migrated;
}
/**
* Drop test DB, closing bootstrap connection if existing.
*/
export async function terminate() {
const dbConnection = Container.get(DbConnection);
await dbConnection.close();
dbConnection.connectionState.connected = false;
}
type EntityName =
| keyof typeof entities
| 'InsightsRaw'
| 'InsightsByPeriod'
| 'InsightsMetadata'
| 'DataStore'
| 'DataStoreColumn';
/**
* Truncate specific DB tables in a test DB.
*/
export async function truncate(entities: EntityName[]) {
const connection = Container.get(Connection);
for (const name of entities) {
await connection.getRepository(name).delete({});
}
}

View File

@@ -1,7 +0,0 @@
import { ModuleRegistry } from '@n8n/backend-common';
import type { ModuleName } from '@n8n/backend-common';
import { Container } from '@n8n/di';
export async function loadModules(moduleNames: ModuleName[]) {
await Container.get(ModuleRegistry).loadModules(moduleNames);
}