fix(server): adjust the position of beforeInstall

This commit is contained in:
chenos 2022-02-07 10:07:39 +08:00
parent 8e4336cbe1
commit 851c97b52a
4 changed files with 10 additions and 5 deletions

View File

@ -1,5 +1,5 @@
import { resolve } from 'path';
import { Application } from '@nocobase/server';
import { resolve } from 'path';
const start = Date.now();
@ -9,6 +9,12 @@ const api = new Application({
? {
dialect: process.env.DB_DIALECT as any,
storage: resolve(process.cwd(), './db.sqlite'),
pool: {
max: 5,
min: 0,
acquire: 60000,
idle: 10000,
},
logging: process.env.DB_LOG_SQL === 'on' ? console.log : false,
define: {},
sync: {

View File

@ -21,7 +21,7 @@ describe('application life cycle', () => {
return 'Test';
}
load() {
async load() {
loadFn();
this.app.on('beforeInstall', () => {
installFn();

View File

@ -208,12 +208,11 @@ export class Application<StateT = DefaultState, ContextT = DefaultContext> exten
}
async install(options?: InstallOptions) {
await this.emitAsync('beforeInstall', this, options);
if (options?.clean) {
await this.db.clean(isBoolean(options.clean) ? { drop: options.clean } : options.clean);
}
await this.db.sync(options?.sync);
await this.emitAsync('beforeInstall', this, options);
await this.emitAsync('installing', this, options);
await this.emitAsync('afterInstall', this, options);
}

View File

@ -31,7 +31,7 @@ export function createI18n(options: ApplicationOptions) {
return instance;
}
export function createCli(app: Application, options: ApplicationOptions) {
export function createCli(app: Application, options: ApplicationOptions): Command {
const cli = new Command();
cli