Skip to content

Commit

Permalink
SDA-4544 Allow to load react dev tools chrome extension (#2145)
Browse files Browse the repository at this point in the history
* SDA-4561 - SDA branch cut

* SDA-4544 Allow to load react dev tools chrome extension

---------

Co-authored-by: Kiran Niranjan <kiran.niranjan@symphony.com>
  • Loading branch information
baphony and KiranNiranjan committed May 7, 2024
1 parent 1709479 commit e6cdae2
Show file tree
Hide file tree
Showing 4 changed files with 249 additions and 0 deletions.
216 changes: 216 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@
"del": "3.0.0",
"electron": "29.3.1",
"electron-builder": "^24.13.2",
"electron-devtools-installer": "^3.2.0",
"electron-icon-maker": "0.0.5",
"electron-osx-sign": "^0.6.0",
"enzyme": "^3.11.0",
Expand Down
29 changes: 29 additions & 0 deletions src/app/extension-handler.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import installExtension, {
REACT_DEVELOPER_TOOLS,
} from 'electron-devtools-installer';

import { Logger } from '../common/loggerBase';
import { getCommandLineArgs } from '../common/utils';

const isCommandLineArgEnabled = (name: string) =>
getCommandLineArgs(process.argv, `--${name}`, true) ||
getCommandLineArgs(process.argv, `--${name}=1`, true) ||
getCommandLineArgs(process.argv, `--${name}=true`, true);

/**
* Load React Dev Tools extension
* @param logger
* @returns Promise<void>
*/
export const loadReactDevToolsExtension = async (logger: Logger) => {
if (!isCommandLineArgEnabled('enableReactDevTools')) {
return;
}

try {
const name = await installExtension(REACT_DEVELOPER_TOOLS);
logger.info(`main: Added Extension: ${name}`);
} catch (error) {
logger.error(`main: Error while loading ReactDevTool Extension: ${error}`);
}
};
3 changes: 3 additions & 0 deletions src/app/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { ICustomBrowserWindow, windowHandler } from './window-handler';

import { autoLaunchInstance } from './auto-launch-controller';
import { autoUpdate } from './auto-update-handler';
import { loadReactDevToolsExtension } from './extension-handler';
import { presenceStatusStore } from './stores';

// Set automatic period substitution to false because of a bug in draft js on the client app
Expand Down Expand Up @@ -111,6 +112,8 @@ const startApplication = async () => {
await autoUpdate.init();
await windowHandler.createApplication();
logger.info(`main: created application`);

await loadReactDevToolsExtension(logger);
};

// Handle multiple/single instances
Expand Down

0 comments on commit e6cdae2

Please sign in to comment.