mirror of
https://github.com/shishantbiswas/bknd.git
synced 2026-03-16 12:37:20 +00:00
fix tests: replace initialConfig with config
This commit is contained in:
@@ -72,9 +72,9 @@ export class DbModuleManager extends ModuleManager {
|
||||
|
||||
if (options?.initial) {
|
||||
if ("version" in options.initial && options.initial.version) {
|
||||
const { version: _v, ...initialConfig } = options.initial;
|
||||
const { version: _v, ...config } = options.initial;
|
||||
version = _v as number;
|
||||
initial = stripMark(initialConfig) as any;
|
||||
initial = stripMark(config) as any;
|
||||
|
||||
booted_with = "provided";
|
||||
} else {
|
||||
@@ -241,7 +241,7 @@ export class DbModuleManager extends ModuleManager {
|
||||
}
|
||||
|
||||
// re-apply configs to all modules (important for system entities)
|
||||
this.setConfigs(configs);
|
||||
await this.setConfigs(configs);
|
||||
|
||||
// @todo: cleanup old versions?
|
||||
|
||||
@@ -249,10 +249,10 @@ export class DbModuleManager extends ModuleManager {
|
||||
return this;
|
||||
}
|
||||
|
||||
private revertModules() {
|
||||
private async revertModules() {
|
||||
if (this._stable_configs) {
|
||||
$console.warn("ModuleManager: Reverting modules");
|
||||
this.setConfigs(this._stable_configs as any);
|
||||
await this.setConfigs(this._stable_configs as any);
|
||||
} else {
|
||||
$console.error("ModuleManager: No stable configs to revert to");
|
||||
}
|
||||
@@ -339,12 +339,12 @@ export class DbModuleManager extends ModuleManager {
|
||||
$console.log("Migrated config from", version_before, "to", this.version());
|
||||
|
||||
// @ts-expect-error
|
||||
this.setConfigs(_configs);
|
||||
await this.setConfigs(_configs);
|
||||
await this.buildModules();
|
||||
} else {
|
||||
this.logger.log("version is current", this.version());
|
||||
|
||||
this.setConfigs(result.json);
|
||||
await this.setConfigs(result.json);
|
||||
await this.buildModules();
|
||||
}
|
||||
}
|
||||
@@ -505,4 +505,8 @@ export class DbModuleManager extends ModuleManager {
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
override version() {
|
||||
return this._version;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -200,19 +200,19 @@ export class ModuleManager {
|
||||
};
|
||||
}
|
||||
|
||||
protected setConfigs(configs: ModuleConfigs): void {
|
||||
protected async setConfigs(configs: ModuleConfigs): Promise<void> {
|
||||
this.logger.log("setting configs");
|
||||
objectEach(configs, (config, key) => {
|
||||
for await (const [key, config] of Object.entries(configs)) {
|
||||
try {
|
||||
// setting "noEmit" to true, to not force listeners to update
|
||||
this.modules[key].schema().set(config as any, true);
|
||||
const result = await this.modules[key].schema().set(config as any, true);
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
throw new Error(
|
||||
`Failed to set config for module ${key}: ${JSON.stringify(config, null, 2)}`,
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
async build(opts?: any) {
|
||||
@@ -293,7 +293,7 @@ export class ModuleManager {
|
||||
}
|
||||
|
||||
version() {
|
||||
return CURRENT_VERSION;
|
||||
return 0;
|
||||
}
|
||||
|
||||
built() {
|
||||
|
||||
Reference in New Issue
Block a user