diff --git a/common/config/private/PrivateConfigClass.ts b/common/config/private/PrivateConfigClass.ts index c26afe91..c025d447 100644 --- a/common/config/private/PrivateConfigClass.ts +++ b/common/config/private/PrivateConfigClass.ts @@ -74,6 +74,7 @@ export class PrivateConfigClass extends PublicConfigClass implements IPrivateCon } public load() { + this.addComment(); ConfigLoader.loadBackendConfig(this, path.join(__dirname, './../../../config.json'), [['PORT', 'Server-port'], @@ -81,6 +82,7 @@ export class PrivateConfigClass extends PublicConfigClass implements IPrivateCon ['MYSQL_PASSWORD', 'Server-database-mysql-password'], ['MYSQL_USERNAME', 'Server-database-mysql-username'], ['MYSQL_DATABASE', 'Server-database-mysql-database']]); + this.removeComment(); if (Utils.enumToArray(UserRoles).map(r => r.key).indexOf(this.Client.unAuthenticatedUserRole) === -1) { throw new Error('Unknown user role for Client.unAuthenticatedUserRole, found: ' + this.Client.unAuthenticatedUserRole); @@ -96,7 +98,9 @@ export class PrivateConfigClass extends PublicConfigClass implements IPrivateCon public save() { try { + this.addComment(); ConfigLoader.saveConfigFile(path.join(__dirname, './../../../config.json'), this); + this.removeComment(); } catch (e) { throw new Error('Error during saving config: ' + e.toString()); } @@ -107,5 +111,14 @@ export class PrivateConfigClass extends PublicConfigClass implements IPrivateCon cfg.load(); return cfg; } + + private addComment() { + (this)['__NOTE'] = 'NOTE: this config is not intended for manual edit, ' + + 'use the app UI instead as it has comments and descriptions.'; + } + + private removeComment() { + delete (this)['__NOTE']; + } } diff --git a/package.json b/package.json index 529bc6b7..ebe2f6fe 100644 --- a/package.json +++ b/package.json @@ -10,6 +10,7 @@ "scripts": { "install": "tsc && gulp build-prod", "build-release": "gulp build-release", + "build-backend": "tsc", "pretest": "tsc", "test": "ng test && mocha --recursive test/backend/unit && mocha --recursive test/backend/integration && mocha --recursive test/common/unit ", "start": "node ./backend/index",