From 58d8a5043b4ec5c90fdb9071ea3a66e4898f4b53 Mon Sep 17 00:00:00 2001 From: "Patrik J. Braun" Date: Fri, 5 Apr 2024 18:36:40 +0200 Subject: [PATCH 1/7] test flaky test on github --- test/backend/integration/routers/admin/SettingsRouter.ts | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/test/backend/integration/routers/admin/SettingsRouter.ts b/test/backend/integration/routers/admin/SettingsRouter.ts index 4808edc9..222433e4 100644 --- a/test/backend/integration/routers/admin/SettingsRouter.ts +++ b/test/backend/integration/routers/admin/SettingsRouter.ts @@ -48,9 +48,7 @@ describe('SettingsRouter', () => { attachVolatile: true, skipTags: {secret: true} as TAGS }))); - //TODO: fix broken test. - // It breaks if config. sets value through constructor -/* + const result = await chai.request(server.Server) .get(Config.Server.apiPath + '/settings'); @@ -58,7 +56,7 @@ describe('SettingsRouter', () => { result.body.should.be.a('object'); should.equal(result.body.error, null); (result.body.result as ServerConfig).Environment.upTime = null; - result.body.result.should.deep.equal(originalJSON);*/ + result.body.result.should.deep.equal(originalJSON); }); }); }); From 3380fef63ae3366be357202f550789e455415264 Mon Sep 17 00:00:00 2001 From: "Patrik J. Braun" Date: Fri, 12 Apr 2024 23:16:59 +0200 Subject: [PATCH 2/7] Fix default loading flakyness before first json load. --- package-lock.json | 14 +++++----- package.json | 2 +- .../model/extension/ExtensionConfigWrapper.ts | 14 ++++++++++ .../extension/ExtensionConfigWrapper.spec.ts | 26 +++++++++++++++++++ 4 files changed, 48 insertions(+), 8 deletions(-) create mode 100644 test/backend/unit/model/extension/ExtensionConfigWrapper.spec.ts diff --git a/package-lock.json b/package-lock.json index 06dc3a97..46ee58e8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -27,7 +27,7 @@ "reflect-metadata": "0.1.13", "sharp": "0.31.3", "ts-node-iptc": "1.0.11", - "typeconfig": "2.2.11", + "typeconfig": "2.2.13", "typeorm": "0.3.12", "xml2js": "0.6.2" }, @@ -20361,9 +20361,9 @@ } }, "node_modules/typeconfig": { - "version": "2.2.11", - "resolved": "https://registry.npmjs.org/typeconfig/-/typeconfig-2.2.11.tgz", - "integrity": "sha512-Knj+1kbIJ4zOZlUm2TPSWZUoiOW4txrmPyf6oyuBhaDQDlGxpSL5jobF3vVV9mZElK1V3ZQVeTgvGaiDyeT8mQ==", + "version": "2.2.13", + "resolved": "https://registry.npmjs.org/typeconfig/-/typeconfig-2.2.13.tgz", + "integrity": "sha512-eT9FqQVJTacuJELZ2XKN9s1phUnaceQd1NhzgTHZuULDWSOpcMTw8jRvg2Uyp14IRe9W9N8DOItz38QQJcwctQ==", "dependencies": { "minimist": "1.2.8" } @@ -35280,9 +35280,9 @@ } }, "typeconfig": { - "version": "2.2.11", - "resolved": "https://registry.npmjs.org/typeconfig/-/typeconfig-2.2.11.tgz", - "integrity": "sha512-Knj+1kbIJ4zOZlUm2TPSWZUoiOW4txrmPyf6oyuBhaDQDlGxpSL5jobF3vVV9mZElK1V3ZQVeTgvGaiDyeT8mQ==", + "version": "2.2.13", + "resolved": "https://registry.npmjs.org/typeconfig/-/typeconfig-2.2.13.tgz", + "integrity": "sha512-eT9FqQVJTacuJELZ2XKN9s1phUnaceQd1NhzgTHZuULDWSOpcMTw8jRvg2Uyp14IRe9W9N8DOItz38QQJcwctQ==", "requires": { "minimist": "1.2.8" } diff --git a/package.json b/package.json index 65e65868..c6281a54 100644 --- a/package.json +++ b/package.json @@ -54,7 +54,7 @@ "reflect-metadata": "0.1.13", "sharp": "0.31.3", "ts-node-iptc": "1.0.11", - "typeconfig": "2.2.11", + "typeconfig": "2.2.13", "typeorm": "0.3.12", "xml2js": "0.6.2" }, diff --git a/src/backend/model/extension/ExtensionConfigWrapper.ts b/src/backend/model/extension/ExtensionConfigWrapper.ts index eaa7270f..c4e0e827 100644 --- a/src/backend/model/extension/ExtensionConfigWrapper.ts +++ b/src/backend/model/extension/ExtensionConfigWrapper.ts @@ -3,6 +3,9 @@ import {PrivateConfigClass} from '../../../common/config/private/PrivateConfigCl import {ConfigClassBuilder} from 'typeconfig/node'; import {ExtensionConfigTemplateLoader} from './ExtensionConfigTemplateLoader'; import {NotificationManager} from '../NotifocationManager'; +import {ServerConfig} from '../../../common/config/private/PrivateConfig'; +import {ConfigClassOptions} from 'typeconfig/src/decorators/class/IConfigClass'; +import * as fs from 'fs'; const LOG_TAG = '[ExtensionConfigWrapper]'; @@ -16,6 +19,12 @@ export class ExtensionConfigWrapper { const pc = ConfigClassBuilder.attachPrivateInterface(new PrivateConfigClass()); ExtensionConfigTemplateLoader.Instance.loadExtensionTemplates(pc); try { + // make sure the config file exists by the time we load it. + // TODO: remove this once typeconfig is fixed and can properly load defaults in arrays + if (!fs.existsSync((pc.__options as ConfigClassOptions).configPath)) { + await pc.save(); + } + await pc.load(); // loading the basic configs, but we do not know the extension config hierarchy yet } catch (e) { @@ -34,6 +43,11 @@ export class ExtensionConfigWrapper { const pc = ConfigClassBuilder.attachPrivateInterface(new PrivateConfigClass()); ExtensionConfigTemplateLoader.Instance.loadExtensionTemplates(pc); try { + // make sure the config file exists by the time we load it. + // TODO: remove this once typeconfig is fixed and can properly load defaults in arrays + if (!fs.existsSync((pc.__options as ConfigClassOptions).configPath)) { + pc.saveSync(); + } pc.loadSync(); // loading the basic configs, but we do not know the extension config hierarchy yet } catch (e) { diff --git a/test/backend/unit/model/extension/ExtensionConfigWrapper.spec.ts b/test/backend/unit/model/extension/ExtensionConfigWrapper.spec.ts new file mode 100644 index 00000000..52b9facc --- /dev/null +++ b/test/backend/unit/model/extension/ExtensionConfigWrapper.spec.ts @@ -0,0 +1,26 @@ +import {expect} from 'chai'; +import {ExtensionConfigWrapper} from '../../../../../src/backend/model/extension/ExtensionConfigWrapper'; +import {TAGS} from '../../../../../src/common/config/public/ClientConfig'; + +// to help WebStorm to handle the test cases +declare let describe: any; +declare const after: any; +declare const before: any; +declare const it: any; + + +describe('ExtensionConfigWrapper', () => { + + it('should load original config multiple times with the same result', async () => { + const get = async () => JSON.parse(JSON.stringify((await ExtensionConfigWrapper.original()).toJSON({ + attachState: true, + attachVolatile: true, + skipTags: {secret: true} as TAGS + }))); + const a = await get(); + const b = await get(); + expect(b).to.deep.equal(a); + const c = await get(); + expect(c).to.deep.equal(a); + }); +}); From 01e9490d4f85e5b9295f9fbfe556be4414d8474b Mon Sep 17 00:00:00 2001 From: "Patrik J. Braun" Date: Fri, 5 Apr 2024 18:36:40 +0200 Subject: [PATCH 3/7] test flaky test on github --- test/backend/integration/routers/admin/SettingsRouter.ts | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/test/backend/integration/routers/admin/SettingsRouter.ts b/test/backend/integration/routers/admin/SettingsRouter.ts index 4808edc9..222433e4 100644 --- a/test/backend/integration/routers/admin/SettingsRouter.ts +++ b/test/backend/integration/routers/admin/SettingsRouter.ts @@ -48,9 +48,7 @@ describe('SettingsRouter', () => { attachVolatile: true, skipTags: {secret: true} as TAGS }))); - //TODO: fix broken test. - // It breaks if config. sets value through constructor -/* + const result = await chai.request(server.Server) .get(Config.Server.apiPath + '/settings'); @@ -58,7 +56,7 @@ describe('SettingsRouter', () => { result.body.should.be.a('object'); should.equal(result.body.error, null); (result.body.result as ServerConfig).Environment.upTime = null; - result.body.result.should.deep.equal(originalJSON);*/ + result.body.result.should.deep.equal(originalJSON); }); }); }); From 2da12edd9f33998b8e1f9b431e4d320a77d57d10 Mon Sep 17 00:00:00 2001 From: "Patrik J. Braun" Date: Fri, 12 Apr 2024 23:16:59 +0200 Subject: [PATCH 4/7] merge package.json --- package.json | 3 ++- .../model/extension/ExtensionConfigWrapper.ts | 14 ++++++++++ .../extension/ExtensionConfigWrapper.spec.ts | 26 +++++++++++++++++++ 3 files changed, 42 insertions(+), 1 deletion(-) create mode 100644 test/backend/unit/model/extension/ExtensionConfigWrapper.spec.ts diff --git a/package.json b/package.json index 08c10923..c4b859b6 100644 --- a/package.json +++ b/package.json @@ -53,7 +53,8 @@ "nodemailer": "6.9.4", "reflect-metadata": "0.1.13", "sharp": "0.31.3", - "typeconfig": "2.2.11", + "ts-node-iptc": "1.0.11", + "typeconfig": "2.2.13", "typeorm": "0.3.12", "xml2js": "0.6.2" }, diff --git a/src/backend/model/extension/ExtensionConfigWrapper.ts b/src/backend/model/extension/ExtensionConfigWrapper.ts index eaa7270f..c4e0e827 100644 --- a/src/backend/model/extension/ExtensionConfigWrapper.ts +++ b/src/backend/model/extension/ExtensionConfigWrapper.ts @@ -3,6 +3,9 @@ import {PrivateConfigClass} from '../../../common/config/private/PrivateConfigCl import {ConfigClassBuilder} from 'typeconfig/node'; import {ExtensionConfigTemplateLoader} from './ExtensionConfigTemplateLoader'; import {NotificationManager} from '../NotifocationManager'; +import {ServerConfig} from '../../../common/config/private/PrivateConfig'; +import {ConfigClassOptions} from 'typeconfig/src/decorators/class/IConfigClass'; +import * as fs from 'fs'; const LOG_TAG = '[ExtensionConfigWrapper]'; @@ -16,6 +19,12 @@ export class ExtensionConfigWrapper { const pc = ConfigClassBuilder.attachPrivateInterface(new PrivateConfigClass()); ExtensionConfigTemplateLoader.Instance.loadExtensionTemplates(pc); try { + // make sure the config file exists by the time we load it. + // TODO: remove this once typeconfig is fixed and can properly load defaults in arrays + if (!fs.existsSync((pc.__options as ConfigClassOptions).configPath)) { + await pc.save(); + } + await pc.load(); // loading the basic configs, but we do not know the extension config hierarchy yet } catch (e) { @@ -34,6 +43,11 @@ export class ExtensionConfigWrapper { const pc = ConfigClassBuilder.attachPrivateInterface(new PrivateConfigClass()); ExtensionConfigTemplateLoader.Instance.loadExtensionTemplates(pc); try { + // make sure the config file exists by the time we load it. + // TODO: remove this once typeconfig is fixed and can properly load defaults in arrays + if (!fs.existsSync((pc.__options as ConfigClassOptions).configPath)) { + pc.saveSync(); + } pc.loadSync(); // loading the basic configs, but we do not know the extension config hierarchy yet } catch (e) { diff --git a/test/backend/unit/model/extension/ExtensionConfigWrapper.spec.ts b/test/backend/unit/model/extension/ExtensionConfigWrapper.spec.ts new file mode 100644 index 00000000..52b9facc --- /dev/null +++ b/test/backend/unit/model/extension/ExtensionConfigWrapper.spec.ts @@ -0,0 +1,26 @@ +import {expect} from 'chai'; +import {ExtensionConfigWrapper} from '../../../../../src/backend/model/extension/ExtensionConfigWrapper'; +import {TAGS} from '../../../../../src/common/config/public/ClientConfig'; + +// to help WebStorm to handle the test cases +declare let describe: any; +declare const after: any; +declare const before: any; +declare const it: any; + + +describe('ExtensionConfigWrapper', () => { + + it('should load original config multiple times with the same result', async () => { + const get = async () => JSON.parse(JSON.stringify((await ExtensionConfigWrapper.original()).toJSON({ + attachState: true, + attachVolatile: true, + skipTags: {secret: true} as TAGS + }))); + const a = await get(); + const b = await get(); + expect(b).to.deep.equal(a); + const c = await get(); + expect(c).to.deep.equal(a); + }); +}); From 37c0a212b09290b07f481d4cf3b361278b102f49 Mon Sep 17 00:00:00 2001 From: "Patrik J. Braun" Date: Fri, 12 Apr 2024 23:31:25 +0200 Subject: [PATCH 5/7] fix package lock --- package-lock.json | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/package-lock.json b/package-lock.json index 9e43eca4..8ada0fa4 100644 --- a/package-lock.json +++ b/package-lock.json @@ -26,7 +26,8 @@ "nodemailer": "6.9.4", "reflect-metadata": "0.1.13", "sharp": "0.31.3", - "typeconfig": "2.2.11", + "ts-node-iptc": "1.0.11", + "typeconfig": "2.2.13", "typeorm": "0.3.12", "xml2js": "0.6.2" }, @@ -20361,9 +20362,9 @@ } }, "node_modules/typeconfig": { - "version": "2.2.11", - "resolved": "https://registry.npmjs.org/typeconfig/-/typeconfig-2.2.11.tgz", - "integrity": "sha512-Knj+1kbIJ4zOZlUm2TPSWZUoiOW4txrmPyf6oyuBhaDQDlGxpSL5jobF3vVV9mZElK1V3ZQVeTgvGaiDyeT8mQ==", + "version": "2.2.13", + "resolved": "https://registry.npmjs.org/typeconfig/-/typeconfig-2.2.13.tgz", + "integrity": "sha512-eT9FqQVJTacuJELZ2XKN9s1phUnaceQd1NhzgTHZuULDWSOpcMTw8jRvg2Uyp14IRe9W9N8DOItz38QQJcwctQ==", "dependencies": { "minimist": "1.2.8" } @@ -35282,9 +35283,9 @@ } }, "typeconfig": { - "version": "2.2.11", - "resolved": "https://registry.npmjs.org/typeconfig/-/typeconfig-2.2.11.tgz", - "integrity": "sha512-Knj+1kbIJ4zOZlUm2TPSWZUoiOW4txrmPyf6oyuBhaDQDlGxpSL5jobF3vVV9mZElK1V3ZQVeTgvGaiDyeT8mQ==", + "version": "2.2.13", + "resolved": "https://registry.npmjs.org/typeconfig/-/typeconfig-2.2.13.tgz", + "integrity": "sha512-eT9FqQVJTacuJELZ2XKN9s1phUnaceQd1NhzgTHZuULDWSOpcMTw8jRvg2Uyp14IRe9W9N8DOItz38QQJcwctQ==", "requires": { "minimist": "1.2.8" } From 1ae44e8d7f0e62b778b2178ee28b7053cb37874a Mon Sep 17 00:00:00 2001 From: "Patrik J. Braun" Date: Fri, 12 Apr 2024 23:45:49 +0200 Subject: [PATCH 6/7] Add reminder todos for better extension loading #784 --- src/backend/model/extension/ExtensionConfigTemplateLoader.ts | 2 ++ src/common/config/private/subconfigs/ServerExtensionsConfig.ts | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/backend/model/extension/ExtensionConfigTemplateLoader.ts b/src/backend/model/extension/ExtensionConfigTemplateLoader.ts index fc989b9e..435189f9 100644 --- a/src/backend/model/extension/ExtensionConfigTemplateLoader.ts +++ b/src/backend/model/extension/ExtensionConfigTemplateLoader.ts @@ -102,6 +102,8 @@ export class ExtensionConfigTemplateLoader { if (ext.template) { c.configs = new ext.template(); } + // TODO: this does not hold if the order of the extensions mixes up. + // TODO: experiment with a map instead of an array config.Extensions.extensions.push(c); } diff --git a/src/common/config/private/subconfigs/ServerExtensionsConfig.ts b/src/common/config/private/subconfigs/ServerExtensionsConfig.ts index 589f50ee..d84932c7 100644 --- a/src/common/config/private/subconfigs/ServerExtensionsConfig.ts +++ b/src/common/config/private/subconfigs/ServerExtensionsConfig.ts @@ -59,7 +59,8 @@ export class ServerExtensionsConfig extends ClientExtensionsConfig { }) folder: string = 'extensions'; - + // TODO: this does not hold if the order of the extensions mixes up. + // TODO: experiment with a map instead of an array @ConfigProperty({ arrayType: ServerExtensionsEntryConfig, tags: { From 055862f2753f621fb521b8c9b68731cbc709dc2e Mon Sep 17 00:00:00 2001 From: "Patrik J. Braun" Date: Sat, 13 Apr 2024 01:21:05 +0200 Subject: [PATCH 7/7] Improving extension loading. It mostly solves #847 and #784 --- package-lock.json | 14 +++++------ package.json | 2 +- .../ExtensionConfigTemplateLoader.ts | 23 +++++++++++------- .../model/extension/ExtensionConfigWrapper.ts | 3 ++- src/backend/model/extension/IExtension.ts | 24 +++++++++++++------ src/common/config/private/Config.ts | 6 +++-- 6 files changed, 46 insertions(+), 26 deletions(-) diff --git a/package-lock.json b/package-lock.json index 8ada0fa4..ee0ed6d5 100644 --- a/package-lock.json +++ b/package-lock.json @@ -27,7 +27,7 @@ "reflect-metadata": "0.1.13", "sharp": "0.31.3", "ts-node-iptc": "1.0.11", - "typeconfig": "2.2.13", + "typeconfig": "2.2.15", "typeorm": "0.3.12", "xml2js": "0.6.2" }, @@ -20362,9 +20362,9 @@ } }, "node_modules/typeconfig": { - "version": "2.2.13", - "resolved": "https://registry.npmjs.org/typeconfig/-/typeconfig-2.2.13.tgz", - "integrity": "sha512-eT9FqQVJTacuJELZ2XKN9s1phUnaceQd1NhzgTHZuULDWSOpcMTw8jRvg2Uyp14IRe9W9N8DOItz38QQJcwctQ==", + "version": "2.2.15", + "resolved": "https://registry.npmjs.org/typeconfig/-/typeconfig-2.2.15.tgz", + "integrity": "sha512-aqiuT5BtV0/0MYMMG78c1IqeJrF85r1W1pJckkGolPjHpE0ajA3oOgnRtX5DRDHsn3YzsY5FKMxj1B3J+ISx1g==", "dependencies": { "minimist": "1.2.8" } @@ -35283,9 +35283,9 @@ } }, "typeconfig": { - "version": "2.2.13", - "resolved": "https://registry.npmjs.org/typeconfig/-/typeconfig-2.2.13.tgz", - "integrity": "sha512-eT9FqQVJTacuJELZ2XKN9s1phUnaceQd1NhzgTHZuULDWSOpcMTw8jRvg2Uyp14IRe9W9N8DOItz38QQJcwctQ==", + "version": "2.2.15", + "resolved": "https://registry.npmjs.org/typeconfig/-/typeconfig-2.2.15.tgz", + "integrity": "sha512-aqiuT5BtV0/0MYMMG78c1IqeJrF85r1W1pJckkGolPjHpE0ajA3oOgnRtX5DRDHsn3YzsY5FKMxj1B3J+ISx1g==", "requires": { "minimist": "1.2.8" } diff --git a/package.json b/package.json index c4b859b6..9b5c036e 100644 --- a/package.json +++ b/package.json @@ -54,7 +54,7 @@ "reflect-metadata": "0.1.13", "sharp": "0.31.3", "ts-node-iptc": "1.0.11", - "typeconfig": "2.2.13", + "typeconfig": "2.2.15", "typeorm": "0.3.12", "xml2js": "0.6.2" }, diff --git a/src/backend/model/extension/ExtensionConfigTemplateLoader.ts b/src/backend/model/extension/ExtensionConfigTemplateLoader.ts index 435189f9..f4235df8 100644 --- a/src/backend/model/extension/ExtensionConfigTemplateLoader.ts +++ b/src/backend/model/extension/ExtensionConfigTemplateLoader.ts @@ -2,7 +2,9 @@ import {PrivateConfigClass} from '../../../common/config/private/PrivateConfigCl import * as fs from 'fs'; import * as path from 'path'; import {ServerExtensionsEntryConfig} from '../../../common/config/private/subconfigs/ServerExtensionsConfig'; +import * as child_process from 'child_process'; +const execSync = child_process.execSync; const LOG_TAG = '[ExtensionConfigTemplateLoader]'; @@ -52,20 +54,25 @@ export class ExtensionConfigTemplateLoader { for (let i = 0; i < this.extensionList.length; ++i) { const extFolder = this.extensionList[i]; const extPath = path.join(this.extensionsFolder, extFolder); + const configExtPath = path.join(extPath, 'config.js'); const serverExtPath = path.join(extPath, 'server.js'); + + // if server.js is missing, it's not a valid extension if (!fs.existsSync(serverExtPath)) { continue; } - // eslint-disable-next-line @typescript-eslint/no-var-requires - const ext = require(serverExtPath); - if (typeof ext?.initConfig === 'function') { - ext?.initConfig({ - setConfigTemplate: (template: { new(): unknown }): void => { - this.extensionTemplates.push({folder: extFolder, template: template}); - } - }); + if (fs.existsSync(configExtPath)) { + // eslint-disable-next-line @typescript-eslint/no-var-requires + const extCfg = require(configExtPath); + if (typeof extCfg?.initConfig === 'function') { + extCfg?.initConfig({ + setConfigTemplate: (template: { new(): unknown }): void => { + this.extensionTemplates.push({folder: extFolder, template: template}); + } + }); + } } else { //also create basic config extensions that do not have any this.extensionTemplates.push({folder: extFolder}); diff --git a/src/backend/model/extension/ExtensionConfigWrapper.ts b/src/backend/model/extension/ExtensionConfigWrapper.ts index c4e0e827..d96e4bc7 100644 --- a/src/backend/model/extension/ExtensionConfigWrapper.ts +++ b/src/backend/model/extension/ExtensionConfigWrapper.ts @@ -27,6 +27,7 @@ export class ExtensionConfigWrapper { await pc.load(); // loading the basic configs, but we do not know the extension config hierarchy yet + // TODO make sure that all extensions are present even after loading them from file } catch (e) { console.error(LOG_TAG, 'Error during loading config. Reverting to defaults.'); console.error(e); @@ -49,7 +50,7 @@ export class ExtensionConfigWrapper { pc.saveSync(); } pc.loadSync(); // loading the basic configs, but we do not know the extension config hierarchy yet - + // TODO make sure that all extensions are present even after loading them from file } catch (e) { console.error(LOG_TAG, 'Error during loading config. Reverting to defaults.'); console.error(e); diff --git a/src/backend/model/extension/IExtension.ts b/src/backend/model/extension/IExtension.ts index 6a156831..48434fb2 100644 --- a/src/backend/model/extension/IExtension.ts +++ b/src/backend/model/extension/IExtension.ts @@ -217,16 +217,11 @@ export interface IExtensionConfigInit { } /** - * Extension interface. All extension is expected to implement and export these methods + * Extension interface. All extension is expected to implement and export these methods. + * This is the content of the server.js file */ export interface IServerExtension { - /** - * This function can be called any time. It should only set the config template class - * @param extension - */ - initConfig(extension: IExtensionConfigInit): void; - /** * Extension init function. Extension should at minimum expose this function. * @param extension @@ -235,3 +230,18 @@ export interface IServerExtension { cleanUp?: (extension: IExtensionObject) => Promise; } + + +/** + * Extension config interface. All extension can implement and export these methods. + * This is the content of the config.js file. + */ +export interface IServerExtensionConfig { + + /** + * This function can be called any time. It should only set the config template class + * @param extension + */ + initConfig(extension: IExtensionConfigInit): void; + +} diff --git a/src/common/config/private/Config.ts b/src/common/config/private/Config.ts index 143bc5e9..7a14e5c0 100644 --- a/src/common/config/private/Config.ts +++ b/src/common/config/private/Config.ts @@ -4,10 +4,12 @@ import {ConfigClassBuilder} from 'typeconfig/node'; import {ExtensionConfigTemplateLoader} from '../../../backend/model/extension/ExtensionConfigTemplateLoader'; import * as path from 'path'; +// we need to know the location of the extensions to load the full config (including the extensions) const pre = ConfigClassBuilder.attachPrivateInterface(new PrivateConfigClass()); try { - pre.loadSync(); -} catch (e) { /* empty */ } + pre.loadSync({preventSaving: true}); +} catch (e) { /* empty */ +} ExtensionConfigTemplateLoader.Instance.init(path.join(__dirname, '/../../../../', pre.Extensions.folder)); export const Config = ExtensionConfigWrapper.originalSync(true);