mirror of
https://github.com/finos/SymphonyElectron.git
synced 2025-02-25 18:55:29 -06:00
Typescript:
Add code documentation Add pre-commit hooks
This commit is contained in:
parent
eb829e2c68
commit
feac64ea62
@ -4,6 +4,9 @@ import { isDevEnv } from '../common/env';
|
|||||||
import { getCommandLineArgs } from '../common/utils';
|
import { getCommandLineArgs } from '../common/utils';
|
||||||
import { config, IConfig } from './config-handler';
|
import { config, IConfig } from './config-handler';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets chrome flags
|
||||||
|
*/
|
||||||
export default function setChromeFlags() {
|
export default function setChromeFlags() {
|
||||||
const { customFlags } = config.getGlobalConfigFields([ 'customFlags' ]) as IConfig;
|
const { customFlags } = config.getGlobalConfigFields([ 'customFlags' ]) as IConfig;
|
||||||
|
|
||||||
|
@ -126,6 +126,10 @@ class Config {
|
|||||||
fs.writeFileSync(this.userConfigPath, JSON.stringify(this.userConfig), { encoding: 'utf8' });
|
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 {
|
public isFirstTimeLaunch(): boolean {
|
||||||
return this.isFirstTime;
|
return this.isFirstTime;
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,7 @@ import { app } from 'electron';
|
|||||||
|
|
||||||
import { isDevEnv } from '../common/env';
|
import { isDevEnv } from '../common/env';
|
||||||
import { logger } from '../common/logger';
|
import { logger } from '../common/logger';
|
||||||
import {getCommandLineArgs} from '../common/utils';
|
import { getCommandLineArgs } from '../common/utils';
|
||||||
import { cleanUpAppCache, createAppCacheFile } from './app-cache-handler';
|
import { cleanUpAppCache, createAppCacheFile } from './app-cache-handler';
|
||||||
import { autoLaunchInstance } from './auto-launch-controller';
|
import { autoLaunchInstance } from './auto-launch-controller';
|
||||||
import setChromeFlags from './chrome-flags';
|
import setChromeFlags from './chrome-flags';
|
||||||
@ -18,6 +18,9 @@ if (!singleInstanceLock) {
|
|||||||
main();
|
main();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Main function that init the application
|
||||||
|
*/
|
||||||
async function main() {
|
async function main() {
|
||||||
await app.whenReady();
|
await app.whenReady();
|
||||||
createAppCacheFile();
|
createAppCacheFile();
|
||||||
|
@ -7,6 +7,9 @@ import { config, IConfig } from './config-handler';
|
|||||||
|
|
||||||
export class WindowHandler {
|
export class WindowHandler {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Main window opts
|
||||||
|
*/
|
||||||
private static getMainWindowOpts() {
|
private static getMainWindowOpts() {
|
||||||
return {
|
return {
|
||||||
alwaysOnTop: false,
|
alwaysOnTop: false,
|
||||||
@ -24,6 +27,9 @@ export class WindowHandler {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Loading window opts
|
||||||
|
*/
|
||||||
private static getLoadingWindowOpts() {
|
private static getLoadingWindowOpts() {
|
||||||
return {
|
return {
|
||||||
alwaysOnTop: false,
|
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 {
|
private static validateURL(configURL: string): string {
|
||||||
const parsedUrl = url.parse(configURL);
|
const parsedUrl = url.parse(configURL);
|
||||||
|
|
||||||
@ -68,6 +80,9 @@ export class WindowHandler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Starting point of the app
|
||||||
|
*/
|
||||||
public createApplication() {
|
public createApplication() {
|
||||||
this.mainWindow = new BrowserWindow(this.windowOpts);
|
this.mainWindow = new BrowserWindow(this.windowOpts);
|
||||||
|
|
||||||
@ -83,6 +98,9 @@ export class WindowHandler {
|
|||||||
return this.mainWindow;
|
return this.mainWindow;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the main window
|
||||||
|
*/
|
||||||
public getMainWindow(): Electron.BrowserWindow | null {
|
public getMainWindow(): Electron.BrowserWindow | null {
|
||||||
return this.mainWindow;
|
return this.mainWindow;
|
||||||
}
|
}
|
||||||
|
@ -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 {
|
public error(message: string, data?: object): void {
|
||||||
this.log('error', message, data);
|
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 {
|
public warn(message: string, data?: object): void {
|
||||||
this.log('warn', message, data);
|
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 {
|
public info(message: string, data?: object): void {
|
||||||
this.log('info', message, data);
|
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 {
|
public verbose(message: string, data?: object): void {
|
||||||
this.log('verbose', message, data);
|
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 {
|
public debug(message: string, data?: object): void {
|
||||||
this.log('debug', message, data);
|
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 {
|
public silly(message: string, data?: object): void {
|
||||||
this.log('silly', message, data);
|
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 {
|
public setLoggerWindow(window: Electron.WebContents): void {
|
||||||
this.loggerWindow = window;
|
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 {
|
private log(logLevel: LogLevel, message: string, data?: object): void {
|
||||||
message = formatString(message, data);
|
message = formatString(message, data);
|
||||||
if (!isElectronQA) {
|
if (!isElectronQA) {
|
||||||
@ -104,6 +152,13 @@ export class Logger {
|
|||||||
this.sendToCloud(this.formatLogMsg(logLevel, message));
|
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 {
|
private formatLogMsg(level: LogLevel, details: any): ILogMsg {
|
||||||
return {
|
return {
|
||||||
details,
|
details,
|
||||||
|
Loading…
Reference in New Issue
Block a user