"dev": true
},
"@types/node": {
- "version": "14.14.8",
- "resolved": "https://registry.npmjs.org/@types/node/-/node-14.14.8.tgz",
- "integrity": "sha512-z/5Yd59dCKI5kbxauAJgw6dLPzW+TNOItNE00PkpzNwUIEwdj/Lsqwq94H5DdYBX7C13aRA0CY32BK76+neEUA==",
+ "version": "14.14.9",
+ "resolved": "https://registry.npmjs.org/@types/node/-/node-14.14.9.tgz",
+ "integrity": "sha512-JsoLXFppG62tWTklIoO4knA+oDTYsmqWxHRvd4lpmfQRNhX6osheUOWETP2jMoV/2bEHuMra8Pp3Dmo/stBFcw==",
"dev": true
},
"@types/offscreencanvas": {
import Configuration from './utils/Configuration';
import { StationTemplateURL } from './types/ConfigurationData';
-import Utils from './utils/Utils';
import Wrk from './charging-station/Worker';
-import logger from './utils/Logger';
class Bootstrap {
static start() {
try {
- logger.debug('%s Configuration: %j', Utils.logPrefix(), Configuration.getConfig());
let numStationsTotal = 0;
// Start each ChargingStation object in a worker thread
if (Configuration.getStationTemplateURLs()) {
import fs from 'fs';
export default class Configuration {
- static configuration: ConfigurationData;
-
- // Read the config file
- static getConfig(): ConfigurationData {
- if (!Configuration.configuration) {
- Configuration.configuration = JSON.parse(fs.readFileSync('./src/assets/config.json', 'utf8')) as ConfigurationData;
- }
- return Configuration.configuration;
- }
+ private static configuration: ConfigurationData;
static getStatisticsDisplayInterval(): number {
+ Configuration.deprecateConfigurationKey('');
// Read conf
return Utils.objectHasOwnProperty(Configuration.getConfig(), 'statisticsDisplayInterval') ? Configuration.getConfig().statisticsDisplayInterval : 60;
}
}
static getStationTemplateURLs(): StationTemplateURL[] {
+ Configuration.getConfig().stationTemplateURLs.forEach((stationURL: StationTemplateURL) => {
+ if (!Utils.isUndefined(stationURL['numberOfStation'])) {
+ console.error(`Deprecated configuration key 'numberOfStation' usage for template file '${stationURL.file}' in 'stationTemplateURLs'. Use 'numberOfStations' instead`);
+ }
+ });
// Read conf
return Configuration.getConfig().stationTemplateURLs;
}
}
static getLogConsole(): boolean {
+ Configuration.deprecateConfigurationKey('consoleLog', 'Use \'logConsole\' instead');
return Utils.objectHasOwnProperty(Configuration.getConfig(), 'logConsole') ? Configuration.getConfig().logConsole : false;
}
}
static getLogErrorFile(): string {
+ Configuration.deprecateConfigurationKey('errorFile', 'Use \'logErrorFile\' instead');
return Utils.objectHasOwnProperty(Configuration.getConfig(), 'logErrorFile') ? Configuration.getConfig().logErrorFile : 'error.log';
}
}
static getDistributeStationsToTenantsEqually(): boolean {
+ Configuration.deprecateConfigurationKey('distributeStationToTenantEqually', 'Use \'distributeStationsToTenantsEqually\' instead');
return Utils.objectHasOwnProperty(Configuration.getConfig(), 'distributeStationsToTenantsEqually') ? Configuration.getConfig().distributeStationsToTenantsEqually : true;
}
+
+ private static deprecateConfigurationKey(key: string, logMsgToAppend = '') {
+ if (!Utils.isUndefined(Configuration.getConfig()[key])) {
+ console.error(`Deprecated configuration key '${key}' usage${logMsgToAppend && '. ' + logMsgToAppend}`);
+ }
+ }
+
+ // Read the config file
+ private static getConfig(): ConfigurationData {
+ if (!Configuration.configuration) {
+ Configuration.configuration = JSON.parse(fs.readFileSync('./src/assets/config.json', 'utf8')) as ConfigurationData;
+ }
+ return Configuration.configuration;
+ }
}