mirror of
https://gitee.com/nocobase/nocobase.git
synced 2025-05-05 13:39:24 +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 = {}) {
|
export async function createMockDatabase(options: IDatabaseOptions = {}) {
|
||||||
try {
|
try {
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
const { staticImport } = await import('@nocobase/plugin-data-source-external-mssql/server/static-import');
|
const { runPluginStaticImports } = await import('@nocobase/server');
|
||||||
await staticImport();
|
await runPluginStaticImports();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
// error
|
// error
|
||||||
}
|
}
|
||||||
|
@ -10,8 +10,8 @@
|
|||||||
import winston, { LeveledLogMethod, Logger as WinstonLogger } from 'winston';
|
import winston, { LeveledLogMethod, Logger as WinstonLogger } from 'winston';
|
||||||
import 'winston-daily-rotate-file';
|
import 'winston-daily-rotate-file';
|
||||||
import { getLoggerLevel } from './config';
|
import { getLoggerLevel } from './config';
|
||||||
import { getTransports } from './transports';
|
|
||||||
import { consoleFormat } from './format';
|
import { consoleFormat } from './format';
|
||||||
|
import { getTransports } from './transports';
|
||||||
|
|
||||||
interface Logger extends WinstonLogger {
|
interface Logger extends WinstonLogger {
|
||||||
trace: LeveledLogMethod;
|
trace: LeveledLogMethod;
|
||||||
|
@ -7,11 +7,12 @@
|
|||||||
* For more information, please refer to: https://www.nocobase.com/agreement.
|
* 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 { SPLAT } from 'triple-beam';
|
||||||
|
import winston, { format } from 'winston';
|
||||||
|
import Transport from 'winston-transport';
|
||||||
|
import { getLoggerFilePath } from './config';
|
||||||
import { getFormat } from './format';
|
import { getFormat } from './format';
|
||||||
|
import { createLogger, levels, Logger, LoggerOptions } from './logger';
|
||||||
|
|
||||||
export interface SystemLoggerOptions extends LoggerOptions {
|
export interface SystemLoggerOptions extends LoggerOptions {
|
||||||
seperateError?: boolean; // print error seperately, default true
|
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.
|
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
||||||
* For more information, please refer to: https://www.nocobase.com/agreement.
|
* For more information, please refer to: https://www.nocobase.com/agreement.
|
||||||
*/
|
*/
|
||||||
|
import { logger } from '@nocobase/logger';
|
||||||
import { findAllPlugins, PluginManager } from '@nocobase/server';
|
import { findAllPlugins, PluginManager } from '@nocobase/server';
|
||||||
|
import { importModule } from '@nocobase/utils';
|
||||||
|
|
||||||
export async function runPluginStaticImports() {
|
export async function runPluginStaticImports() {
|
||||||
const packages = await findAllPlugins();
|
const packages = await findAllPlugins();
|
||||||
for (const name of packages) {
|
for (const name of packages) {
|
||||||
const { packageName } = await PluginManager.parseName(name);
|
const { packageName } = await PluginManager.parseName(name);
|
||||||
try {
|
try {
|
||||||
const plugin = require(packageName);
|
const plugin = await importModule(packageName);
|
||||||
if (plugin && plugin.staticImport) {
|
if (plugin && plugin.staticImport) {
|
||||||
|
logger.info('run static import', { packageName });
|
||||||
await plugin.staticImport();
|
await plugin.staticImport();
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
logger.error(error, { packageName });
|
||||||
continue;
|
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 './interfaces/async-task-manager';
|
||||||
export * from './task-type';
|
export * from './task-type';
|
||||||
export * from './static-import';
|
|
||||||
|
|
||||||
export { default } from './plugin';
|
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