@@ -12,13 +12,7 @@ process.env.NODE_TLS_REJECT_UNAUTHORIZED = 0;
1212// ipcMain - Communicate asynchronously from the main process to renderer processes
1313
1414// npm libraries
15- const {
16- app,
17- BrowserWindow,
18- TouchBar,
19- ipcMain,
20- dialog
21- } = require ( "electron" ) ;
15+ const { app, BrowserWindow, TouchBar, ipcMain, dialog } = require ( "electron" ) ;
2216const {
2317 default : installExtension ,
2418 REACT_DEVELOPER_TOOLS ,
@@ -27,10 +21,7 @@ const {
2721// Import Auto-Updater- Swell will update itself
2822// const { autoUpdater } = require("electron-updater");
2923// TouchBarButtons are our nav buttons(ex: Select All, Deselect All, Open Selected, Close Selected, Clear All)
30- const {
31- TouchBarButton,
32- TouchBarSpacer
33- } = TouchBar ;
24+ const { TouchBarButton, TouchBarSpacer } = TouchBar ;
3425
3526const path = require ( "path" ) ;
3627const url = require ( "url" ) ;
@@ -43,19 +34,11 @@ const cookie = require("cookie");
4334const fetch2 = require ( "node-fetch" ) ;
4435
4536// GraphQL imports
46- const {
47- ApolloClient
48- } = require ( "apollo-client" ) ;
37+ const { ApolloClient } = require ( "apollo-client" ) ;
4938const gql = require ( "graphql-tag" ) ;
50- const {
51- InMemoryCache
52- } = require ( "apollo-cache-inmemory" ) ;
53- const {
54- createHttpLink
55- } = require ( "apollo-link-http" ) ;
56- const {
57- ApolloLink
58- } = require ( "apollo-link" ) ;
39+ const { InMemoryCache } = require ( "apollo-cache-inmemory" ) ;
40+ const { createHttpLink } = require ( "apollo-link-http" ) ;
41+ const { ApolloLink } = require ( "apollo-link" ) ;
5942
6043// require menu file
6144require ( "./menu/mainMenu" ) ;
@@ -154,23 +137,22 @@ const touchBar = new TouchBar([
154137
155138let isDev ;
156139// if using Spectron, run it in production
157- process . argv . includes ( "--noDevServer" ) || process . argv . includes ( "TEST_MODE" ) ?
158- ( isDev = false ) :
159- ( isDev = true ) ;
140+ process . argv . includes ( "--noDevServer" ) || process . argv . includes ( "TEST_MODE" )
141+ ? ( isDev = false )
142+ : ( isDev = true ) ;
160143
161144/*************************
162145 ******* MODE DISPLAY ****
163146 *************************/
164147
165148isDev
166- ?
167- console . log ( `
149+ ? console . log ( `
168150
169151========================
170152 Launching in DEV mode
171153========================
172- ` ) :
173- console . log ( `
154+ ` )
155+ : console . log ( `
174156
175157==============================
176158 Launching in PRODUCTION mode
@@ -233,8 +215,8 @@ function createWindow() {
233215 // if we are in dev mode load up 'http://localhost:8080/index.html'
234216 indexPath = url . format ( {
235217 protocol : "http:" ,
236- host : "localhost:8090 " ,
237- pathname : "test- index.html" ,
218+ host : "localhost:8080 " ,
219+ pathname : "index.html" ,
238220 slashes : true ,
239221 } ) ;
240222
@@ -250,7 +232,7 @@ function createWindow() {
250232 indexPath = url . format ( {
251233 // if we are not in dev mode load production build file
252234 protocol : "file:" ,
253- pathname : path . resolve ( __dirname , "dist" , "test- index.html" ) ,
235+ pathname : path . join ( __dirname , "dist" , "index.html" ) ,
254236 slashes : true ,
255237 } ) ;
256238 }
@@ -470,26 +452,16 @@ ipcMain.on("import-collection", (event, args) => {
470452 }
471453
472454 // send data to chromium for state update
473- event . sender . send ( "add-collection" , {
474- data
475- } ) ;
455+ event . sender . send ( "add-collection" , { data } ) ;
476456 } ) ;
477457 } ) ;
478458} ) ;
479459
480460// ipcMain listener that
481461ipcMain . on ( "http1-fetch-message" , ( event , arg ) => {
482- const {
483- method,
484- headers,
485- body
486- } = arg . options ;
462+ const { method, headers, body } = arg . options ;
487463
488- fetch2 ( headers . url , {
489- method,
490- headers,
491- body
492- } )
464+ fetch2 ( headers . url , { method, headers, body } )
493465 . then ( ( response ) => {
494466 const headers = response . headers . raw ( ) ;
495467 // check if the endpoint sends SSE
@@ -500,25 +472,20 @@ ipcMain.on("http1-fetch-message", (event, arg) => {
500472 // params: method, headers, body
501473 event . sender . send ( "http1-fetch-reply" , {
502474 headers,
503- body : {
504- error : "This Is An SSE endpoint"
505- } ,
475+ body : { error : "This Is An SSE endpoint" } ,
506476 } ) ;
507477 } else {
508478 headers [ ":status" ] = response . status ;
509479
510480 const receivedCookie = headers [ "set-cookie" ] ;
511481 headers . cookies = receivedCookie ;
512482
513- const contents = / j s o n / . test ( response . headers . get ( "content-type" ) ) ?
514- response . json ( ) :
515- response . text ( ) ;
483+ const contents = / j s o n / . test ( response . headers . get ( "content-type" ) )
484+ ? response . json ( )
485+ : response . text ( ) ;
516486 contents
517487 . then ( ( body ) => {
518- event . sender . send ( "http1-fetch-reply" , {
519- headers,
520- body
521- } ) ;
488+ event . sender . send ( "http1-fetch-reply" , { headers, body } ) ;
522489 } )
523490 . catch ( ( error ) => console . log ( "ERROR" , error ) ) ;
524491 }
@@ -605,42 +572,28 @@ ipcMain.on("open-gql", (event, args) => {
605572 cache : new InMemoryCache ( ) ,
606573 } ) ;
607574
608- const body = gql `
575+ const body = gql `
609576 ${ reqResObj . request . body }
610577 ` ;
611- const variables = reqResObj . request . bodyVariables ?
612- JSON . parse ( reqResObj . request . bodyVariables ) : { } ;
578+ const variables = reqResObj . request . bodyVariables
579+ ? JSON . parse ( reqResObj . request . bodyVariables )
580+ : { } ;
613581
614582 if ( reqResObj . request . method === "QUERY" ) {
615583 client
616- . query ( {
617- query : body ,
618- variables
619- } )
584+ . query ( { query : body , variables } )
620585
621586 . then ( ( data ) => {
622- event . sender . send ( "reply-gql" , {
623- reqResObj,
624- data
625- } ) ;
587+ event . sender . send ( "reply-gql" , { reqResObj, data } ) ;
626588 } )
627589 . catch ( ( err ) => {
628590 console . error ( err ) ;
629- event . sender . send ( "reply-gql" , {
630- error : err . networkError ,
631- reqResObj
632- } ) ;
591+ event . sender . send ( "reply-gql" , { error : err . networkError , reqResObj } ) ;
633592 } ) ;
634593 } else if ( reqResObj . request . method === "MUTATION" ) {
635594 client
636- . mutate ( {
637- mutation : body ,
638- variables
639- } )
640- . then ( ( data ) => event . sender . send ( "reply-gql" , {
641- reqResObj,
642- data
643- } ) )
595+ . mutate ( { mutation : body , variables } )
596+ . then ( ( data ) => event . sender . send ( "reply-gql" , { reqResObj, data } ) )
644597 . catch ( ( err ) => {
645598 console . error ( err ) ;
646599 } ) ;
0 commit comments