mirror of
https://gitee.com/nocobase/nocobase.git
synced 2025-05-05 05:29:26 +08:00
fix: runPluginStaticImports (#6528)
This commit is contained in:
parent
437e9dba52
commit
436af4b9f3
@ -61,8 +61,8 @@ function customLogger(queryString, queryObject) {
|
||||
export async function createMockDatabase(options: IDatabaseOptions = {}) {
|
||||
try {
|
||||
// @ts-ignore
|
||||
const { staticImport } = await import('@nocobase/plugin-data-source-external-mssql/server/static-import');
|
||||
await staticImport();
|
||||
const { runPluginStaticImports } = await import('@nocobase/server');
|
||||
await runPluginStaticImports();
|
||||
} catch (error) {
|
||||
// error
|
||||
}
|
||||
|
@ -10,8 +10,8 @@
|
||||
import winston, { LeveledLogMethod, Logger as WinstonLogger } from 'winston';
|
||||
import 'winston-daily-rotate-file';
|
||||
import { getLoggerLevel } from './config';
|
||||
import { getTransports } from './transports';
|
||||
import { consoleFormat } from './format';
|
||||
import { getTransports } from './transports';
|
||||
|
||||
interface Logger extends WinstonLogger {
|
||||
trace: LeveledLogMethod;
|
||||
|
@ -7,11 +7,12 @@
|
||||
* For more information, please refer to: https://www.nocobase.com/agreement.
|
||||
*/
|
||||
|
||||
import winston, { format } from 'winston';
|
||||
import { createLogger, levels, Logger, LoggerOptions } from './logger';
|
||||
import Transport from 'winston-transport';
|
||||
import { SPLAT } from 'triple-beam';
|
||||
import winston, { format } from 'winston';
|
||||
import Transport from 'winston-transport';
|
||||
import { getLoggerFilePath } from './config';
|
||||
import { getFormat } from './format';
|
||||
import { createLogger, levels, Logger, LoggerOptions } from './logger';
|
||||
|
||||
export interface SystemLoggerOptions extends LoggerOptions {
|
||||
seperateError?: boolean; // print error seperately, default true
|
||||
@ -138,3 +139,12 @@ export const createSystemLogger = (options: SystemLoggerOptions): SystemLogger =
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
export const logger = createSystemLogger({
|
||||
dirname: getLoggerFilePath('main'),
|
||||
filename: 'system',
|
||||
defaultMeta: {
|
||||
app: 'main',
|
||||
module: 'cli',
|
||||
},
|
||||
});
|
||||
|
@ -6,18 +6,22 @@
|
||||
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
||||
* For more information, please refer to: https://www.nocobase.com/agreement.
|
||||
*/
|
||||
import { logger } from '@nocobase/logger';
|
||||
import { findAllPlugins, PluginManager } from '@nocobase/server';
|
||||
import { importModule } from '@nocobase/utils';
|
||||
|
||||
export async function runPluginStaticImports() {
|
||||
const packages = await findAllPlugins();
|
||||
for (const name of packages) {
|
||||
const { packageName } = await PluginManager.parseName(name);
|
||||
try {
|
||||
const plugin = require(packageName);
|
||||
const plugin = await importModule(packageName);
|
||||
if (plugin && plugin.staticImport) {
|
||||
logger.info('run static import', { packageName });
|
||||
await plugin.staticImport();
|
||||
}
|
||||
} catch (error) {
|
||||
logger.error(error, { packageName });
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,13 @@
|
||||
/**
|
||||
* This file is part of the NocoBase (R) project.
|
||||
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
||||
* Authors: NocoBase Team.
|
||||
*
|
||||
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
||||
* For more information, please refer to: https://www.nocobase.com/agreement.
|
||||
*/
|
||||
|
||||
export * from './interfaces/async-task-manager';
|
||||
export * from './task-type';
|
||||
export * from './static-import';
|
||||
|
||||
export { default } from './plugin';
|
||||
|
@ -1,5 +0,0 @@
|
||||
import { appendToBuiltInPlugins } from '@nocobase/server';
|
||||
|
||||
export async function staticImport() {
|
||||
await appendToBuiltInPlugins('@nocobase/plugin-async-task-manager');
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user