<commit_before>import {app, BrowserWindow, ipcMain} from 'electron';
import {contains} from 'ramda';

import {Logger} from './logger';
import {SequelizeManager, OPTIONS} from './sequelizeManager';
import {ipcMessageReceive,
        CHANNEL} from './messageHandler';
import {setupHTTP, setupHTTPS, findSelfSignedCert} from './setupServers';
import {setupMenus} from './menus';

if (process.env.NODE_ENV === 'development') {
    require('electron-debug')();
}

const isUnix = () => {
    return (process.platform === 'darwin' || process.platform === 'linux');
};

const isTestRun = () => {
    return (contains('--test-type=webdriver', process.argv.slice(2)));
};

// TODO: issue #65 shell scripts for HTTPS setup may not work on windows atm
const canSetupHTTPS = isUnix() && !isTestRun();


app.on('ready', () => {

    let mainWindow = new BrowserWindow({
        show: false,
        width: 1024,
        height: OPTIONS.large ? 1024 : 728
    });

    const logger = new Logger(OPTIONS, mainWindow, CHANNEL);
    const sequelizeManager = new SequelizeManager(logger);
    /*
        'responseTools' is generic for the things required to handle
        responses from either the app through IPC CHANNEL or from a API
        request
    */
    const responseTools = {sequelizeManager, mainWindow, OPTIONS};

    sequelizeManager.log('Starting Application...', 0);

    mainWindow.loadURL(`file://${__dirname}/../app/app.html`);

    // startup main window
    mainWindow.webContents.on('did-finish-load', () => {

        // show window if it's not running in headless mode and not a test
        if (!OPTIONS.headless && !isTestRun()) {
            sequelizeManager.log('Opening main window.', 2);
            mainWindow.show();
            mainWindow.focus();
        }

        ipcMain.removeAllListeners(CHANNEL);
        // what to do when a message through IPC is received
        ipcMain.on(CHANNEL, ipcMessageReceive(responseTools));
        // what to do when a message through API is received
        setupHTTP(responseTools);

        mainWindow.webContents.send(CHANNEL, {canSetupHTTPS});

        if (canSetupHTTPS) {
            const hasSelfSignedCert = findSelfSignedCert();
            mainWindow.webContents.send(CHANNEL, {hasSelfSignedCert});
            // if user has certificates, setup the HTTPS server right away<commit_msg>:wrench: include elasticManager in the responseTools<commit_after>import {app, BrowserWindow, ipcMain} from 'electron';
import {contains} from 'ramda';

import {Logger} from './logger';
import {SequelizeManager, OPTIONS} from './sequelizeManager';
import {ElasticManager} from './elasticManager';
import {ipcMessageReceive,
        CHANNEL} from './messageHandler';
import {setupHTTP, setupHTTPS, findSelfSignedCert} from './setupServers';
import {setupMenus} from './menus';

if (process.env.NODE_ENV === 'development') {
    require('electron-debug')();
}

const isUnix = () => {
    return (process.platform === 'darwin' || process.platform === 'linux');
};

const isTestRun = () => {
    return (contains('--test-type=webdriver', process.argv.slice(2)));
};

// TODO: issue #65 shell scripts for HTTPS setup may not work on windows atm
const canSetupHTTPS = isUnix() && !isTestRun();


app.on('ready', () => {

    let mainWindow = new BrowserWindow({
        show: false,
        width: 1024,
        height: OPTIONS.large ? 1024 : 728
    });

    const logger = new Logger(OPTIONS, mainWindow, CHANNEL);
    const sequelizeManager = new SequelizeManager(logger);
    const elasticManager = new ElasticManager(logger);
    /*
        'responseTools' is generic for the things required to handle
        responses from either the app through IPC CHANNEL or from a API
        request
    */
    const responseTools = {
        sequelizeManager, elasticManager, mainWindow, OPTIONS
    };

    sequelizeManager.log('Starting Application...', 0);

    mainWindow.loadURL(`file://${__dirname}/../app/app.html`);

    // startup main window
    mainWindow.webContents.on('did-finish-load', () => {

        // show window if it's not running in headless mode and not a test
        if (!OPTIONS.headless && !isTestRun()) {
            sequelizeManager.log('Opening main window.', 2);
            mainWindow.show();
            mainWindow.focus();
        }

        ipcMain.removeAllListeners(CHANNEL);
        // what to do when a message through IPC is received
        ipcMain.on(CHANNEL, ipcMessageReceive(responseTools));
        // what to do when a message through API is received
        setupHTTP(responseTools);

        mainWindow.webContents.send(CHANNEL, {canSetupHTTPS});

        if (canSetupHTTPS) {
            const hasSelfSignedCert = findSelfSignedCert();
            mainWindow.webContents.send(CHANNEL, {hasSelfSignedCert});
            // if user has certificates, setup the HTTPS server right away
{'fraction_non_alphanumeric': 0.12523095873537263, 'fraction_numerical': 0.006569492917265448, 'mean_word_length': 3.087248322147651, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '92033', 'n_tokens_mistral': 1428, 'n_tokens_neox': 1351, 'n_words': 395}