mirror of
https://gitee.com/nocobase/nocobase.git
synced 2025-05-05 21:49:25 +08:00
feat: support adding commands before app initialization
This commit is contained in:
parent
14f843ef79
commit
08ce9fa923
@ -237,6 +237,12 @@ export class Application<StateT = DefaultState, ContextT = DefaultContext> exten
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static staticCommands = [];
|
||||||
|
|
||||||
|
static addCommand(callback: (app: Application) => void) {
|
||||||
|
this.staticCommands.push(callback);
|
||||||
|
}
|
||||||
|
|
||||||
private _sqlLogger: Logger;
|
private _sqlLogger: Logger;
|
||||||
|
|
||||||
get sqlLogger() {
|
get sqlLogger() {
|
||||||
@ -440,6 +446,10 @@ export class Application<StateT = DefaultState, ContextT = DefaultContext> exten
|
|||||||
return packageJson.version;
|
return packageJson.version;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getPackageVersion() {
|
||||||
|
return packageJson.version;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method is deprecated and should not be used.
|
* This method is deprecated and should not be used.
|
||||||
* Use {@link #this.pm.addPreset()} instead.
|
* Use {@link #this.pm.addPreset()} instead.
|
||||||
@ -540,6 +550,11 @@ export class Application<StateT = DefaultState, ContextT = DefaultContext> exten
|
|||||||
this._loaded = false;
|
this._loaded = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async createCacheManager() {
|
||||||
|
this._cacheManager = await createCacheManager(this, this.options.cacheManager);
|
||||||
|
return this._cacheManager;
|
||||||
|
}
|
||||||
|
|
||||||
async load(options?: LoadOptions) {
|
async load(options?: LoadOptions) {
|
||||||
if (this._loaded) {
|
if (this._loaded) {
|
||||||
return;
|
return;
|
||||||
@ -570,7 +585,7 @@ export class Application<StateT = DefaultState, ContextT = DefaultContext> exten
|
|||||||
await this.cacheManager.close();
|
await this.cacheManager.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
this._cacheManager = await createCacheManager(this, this.options.cacheManager);
|
this._cacheManager = await this.createCacheManager();
|
||||||
|
|
||||||
this.log.debug('init plugins');
|
this.log.debug('init plugins');
|
||||||
this.setMaintainingMessage('init plugins');
|
this.setMaintainingMessage('init plugins');
|
||||||
@ -1195,6 +1210,10 @@ export class Application<StateT = DefaultState, ContextT = DefaultContext> exten
|
|||||||
registerCli(this);
|
registerCli(this);
|
||||||
|
|
||||||
this._version = new ApplicationVersion(this);
|
this._version = new ApplicationVersion(this);
|
||||||
|
|
||||||
|
for (const callback of Application.staticCommands) {
|
||||||
|
callback(this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected createMainDataSource(options: ApplicationOptions) {
|
protected createMainDataSource(options: ApplicationOptions) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user