diff --git a/src/browser/chrome-flags.ts b/src/browser/chrome-flags.ts index 94740d86..3811783c 100644 --- a/src/browser/chrome-flags.ts +++ b/src/browser/chrome-flags.ts @@ -4,6 +4,9 @@ import { isDevEnv } from '../common/env'; import { getCommandLineArgs } from '../common/utils'; import { config, IConfig } from './config-handler'; +/** + * Sets chrome flags + */ export default function setChromeFlags() { const { customFlags } = config.getGlobalConfigFields([ 'customFlags' ]) as IConfig; diff --git a/src/browser/config-handler.ts b/src/browser/config-handler.ts index dfcb8fe9..29481f8b 100644 --- a/src/browser/config-handler.ts +++ b/src/browser/config-handler.ts @@ -126,6 +126,10 @@ class Config { fs.writeFileSync(this.userConfigPath, JSON.stringify(this.userConfig), { encoding: 'utf8' }); } + /** + * Return true if the app is launched for the first time + * otherwise false + */ public isFirstTimeLaunch(): boolean { return this.isFirstTime; } diff --git a/src/browser/main.ts b/src/browser/main.ts index e8f44d41..29483f97 100644 --- a/src/browser/main.ts +++ b/src/browser/main.ts @@ -2,7 +2,7 @@ import { app } from 'electron'; import { isDevEnv } from '../common/env'; import { logger } from '../common/logger'; -import {getCommandLineArgs} from '../common/utils'; +import { getCommandLineArgs } from '../common/utils'; import { cleanUpAppCache, createAppCacheFile } from './app-cache-handler'; import { autoLaunchInstance } from './auto-launch-controller'; import setChromeFlags from './chrome-flags'; @@ -18,6 +18,9 @@ if (!singleInstanceLock) { main(); } +/** + * Main function that init the application + */ async function main() { await app.whenReady(); createAppCacheFile(); diff --git a/src/browser/window-handler.ts b/src/browser/window-handler.ts index ae95b27a..18d2db8e 100644 --- a/src/browser/window-handler.ts +++ b/src/browser/window-handler.ts @@ -7,6 +7,9 @@ import { config, IConfig } from './config-handler'; export class WindowHandler { + /** + * Main window opts + */ private static getMainWindowOpts() { return { alwaysOnTop: false, @@ -24,6 +27,9 @@ export class WindowHandler { }; } + /** + * Loading window opts + */ private static getLoadingWindowOpts() { return { alwaysOnTop: false, @@ -39,6 +45,12 @@ export class WindowHandler { }; } + /** + * Verifies if the url is valid and + * forcefully appends https if not present + * + * @param configURL {string} + */ private static validateURL(configURL: string): string { const parsedUrl = url.parse(configURL); @@ -68,6 +80,9 @@ export class WindowHandler { } } + /** + * Starting point of the app + */ public createApplication() { this.mainWindow = new BrowserWindow(this.windowOpts); @@ -83,6 +98,9 @@ export class WindowHandler { return this.mainWindow; } + /** + * Gets the main window + */ public getMainWindow(): Electron.BrowserWindow | null { return this.mainWindow; } diff --git a/src/common/logger.ts b/src/common/logger.ts index 28e8fd61..d407cf0d 100644 --- a/src/common/logger.ts +++ b/src/common/logger.ts @@ -53,30 +53,71 @@ export class Logger { } } + /** + * Log error + * + * @param message {string} - message to be logged + * @param data {object} - extra data that needs to be logged + */ public error(message: string, data?: object): void { this.log('error', message, data); } + /** + * Log warn + * + * @param message {string} - message to be logged + * @param data {object} - extra data that needs to be logged + */ public warn(message: string, data?: object): void { this.log('warn', message, data); } + /** + * Log info + * + * @param message {string} - message to be logged + * @param data {object} - extra data that needs to be logged + */ public info(message: string, data?: object): void { this.log('info', message, data); } + /** + * Log verbose + * + * @param message {string} - message to be logged + * @param data {object} - extra data that needs to be logged + */ public verbose(message: string, data?: object): void { this.log('verbose', message, data); } + /** + * Log debug + * + * @param message {string} - message to be logged + * @param data {object} - extra data that needs to be logged + */ public debug(message: string, data?: object): void { this.log('debug', message, data); } + /** + * Log silly + * + * @param message {string} - message to be logged + * @param data {object} - extra data that needs to be logged + */ public silly(message: string, data?: object): void { this.log('silly', message, data); } + /** + * Sets the renderer window for sending logs to the client + * + * @param window {WebContents} - renderer window + */ public setLoggerWindow(window: Electron.WebContents): void { this.loggerWindow = window; @@ -88,6 +129,13 @@ export class Logger { } } + /** + * Main instance of the logger method + * + * @param logLevel {LogLevel} - Different type of log levels + * @param message {string} - Log message + * @param data {object} - extra data to be logged + */ private log(logLevel: LogLevel, message: string, data?: object): void { message = formatString(message, data); if (!isElectronQA) { @@ -104,6 +152,13 @@ export class Logger { this.sendToCloud(this.formatLogMsg(logLevel, message)); } + /** + * Formats the logs in the format that required + * to send to the client + * + * @param level {LogLevel} - Different type of log levels + * @param details {any} - log format that required to send to client + */ private formatLogMsg(level: LogLevel, details: any): ILogMsg { return { details,