electron-devtools-installer icon indicating copy to clipboard operation
electron-devtools-installer copied to clipboard

Feature Request: CLI

Open scottrippey opened this issue 4 years ago • 7 comments

I would love to be able to install devtools from a CLI command, instead of by adding this temporary code to my Electron app. This could be done as an interactive prompt from running:

npx electron-devtools-installer

What do you think of this?

scottrippey avatar Mar 31 '20 18:03 scottrippey

It would be really difficult to make the code changes necessary for an extension to be installed from a cli tool. I don't really think there is a way to get around adding the code.

nklayman avatar Apr 01 '20 01:04 nklayman

@nklayman I think there's a common misconception that these devtools require app code changes. Once you run the "install" code (eg in the devtools console), the extension stays installed, even after a restart. No code changes are necessary.

At my work, we actually investigated why the installed devtools seemed to persist for some folks, while others needed to reinstall them every time. We discovered that Electron does save the list of installed DevTools extensions -- but it only saves the list on quit. So, some people were accustomed to killing the process in the Terminal (eg. Ctrl+C), which never saved the list, and those people would have to reinstall the extensions every run. But others, who used ⌘Q to quit the app properly, the extensions would persist.

All this to say: in my project, I just finished a custom npm run install-devtools script, which runs Electron with an interactive prompt, lets them choose the extensions they want installed (or uninstalled), then quits the app. And it works perfectly.

So I'd be happy to contribute a script for performing this action from a CLI prompt, so that installing these tools is as easy as npx electron-devtools-installer

scottrippey avatar Apr 05 '20 15:04 scottrippey

If you found a way to do it than that is awesome, I'm glad to be wrong on this. However, the maintainer of this repo seems to be MIA and hasn't been merging PRs. You may have to create a fork or an entirely separate project. Best of luck either way, I might have to start using it instead of the code change.

nklayman avatar Apr 05 '20 17:04 nklayman

However, the maintainer of this repo seems to be MIA

🤔 👀

MarshallOfSound avatar Apr 07 '20 01:04 MarshallOfSound

@scottrippey I would be on board with this but I know that the way that Electron devtools extensions are persisted across restarts will change and be less modifiable from Electron 9 onwards. If you can find a solution that works with Electron 9 I'd be more than happy to review a PR to add a CLI to this module 🙇

MarshallOfSound avatar Apr 07 '20 01:04 MarshallOfSound

Let me investigate E9 and see what's different. I'm currently on E8 so thanks for letting me know ahead-of-time about this change!

scottrippey avatar Apr 07 '20 18:04 scottrippey

Looking at the E9 source code, I can see how they've changed BrowserWindow.addDevToolsExtension to internally use session.loadExtension, but I still see all the same exact "persist the devtools between app runs" code, so it seems like there will be no differences needed for the CLI to work correctly. https://github.com/electron/electron/blob/9-x-y/lib/browser/chrome-extension.js#L533

I currently have a (private repo) CLI script that is working great. I'll see if I can take some time to create a PR.
image

My only concern with adding a CLI script is: any CLI tools will have to be prod dependencies ... Personally I like using inquirer to present a nice installation prompt, but I wouldn't want to inflate this repo's dependencies for an optional CLI feature. So maybe we could consider making a new electron-devtools-installer-cli repo for this. Thoughts?

scottrippey avatar Apr 07 '20 18:04 scottrippey