From a7729dae87af5a997652b7a605c1b5f559bfd6da Mon Sep 17 00:00:00 2001 From: smacpherson64 Date: Sun, 8 Jan 2023 13:25:09 -0600 Subject: [PATCH] Adjusts @redux-devtools/cli `--open` flag to respect protocol and host (#1217) * Adjusts the location open uses Currently when using open, the cli will ignore the host and protocol and always open `http://localhost`. This pr adjusts the open script to use the options protocol and host and default back to localhost if not provided. * adds changeset * fixes grammar * adjusts electron path to respect protocol and host as well Co-authored-by: Nathan Bierema --- .changeset/long-doors-shout.md | 5 +++++ packages/redux-devtools-cli/app/electron.js | 6 +++++- packages/redux-devtools-cli/src/bin/openApp.ts | 7 ++++++- 3 files changed, 16 insertions(+), 2 deletions(-) create mode 100644 .changeset/long-doors-shout.md diff --git a/.changeset/long-doors-shout.md b/.changeset/long-doors-shout.md new file mode 100644 index 00000000..822c30f0 --- /dev/null +++ b/.changeset/long-doors-shout.md @@ -0,0 +1,5 @@ +--- +'@redux-devtools/cli': patch +--- + +Updates `--open` flag to respect protocol and host when provided diff --git a/packages/redux-devtools-cli/app/electron.js b/packages/redux-devtools-cli/app/electron.js index cbaa84de..6b70abc8 100644 --- a/packages/redux-devtools-cli/app/electron.js +++ b/packages/redux-devtools-cli/app/electron.js @@ -9,7 +9,11 @@ function createWindow() { height: 600, }); - mainWindow.loadURL('http://localhost:' + (argv.port ? argv.port : 8000)); + const port = argv.port ? argv.port : 8000; + const host = argv.host ? argv.host : 'localhost'; + const protocol = argv.protocol ? argv.protocol : 'http'; + + mainWindow.loadURL(protocol + '://' + host + ':' + port); } app.whenReady().then(() => { diff --git a/packages/redux-devtools-cli/src/bin/openApp.ts b/packages/redux-devtools-cli/src/bin/openApp.ts index f46df3cd..bea1efb2 100644 --- a/packages/redux-devtools-cli/src/bin/openApp.ts +++ b/packages/redux-devtools-cli/src/bin/openApp.ts @@ -11,6 +11,9 @@ export default async function openApp(app: true | string, options: Options) { if (app === true || app === 'electron') { try { const port = options.port ? `--port=${options.port}` : ''; + const host = options.host ? `--host=${options.host}` : ''; + const protocol = options.protocol ? `--protocol=${options.protocol}` : ''; + // eslint-disable-next-line @typescript-eslint/no-var-requires spawn(require('electron') as string, [ path.join( @@ -20,6 +23,8 @@ export default async function openApp(app: true | string, options: Options) { 'app' ), port, + host, + protocol, ]); } catch (error) { /* eslint-disable no-console */ @@ -42,7 +47,7 @@ export default async function openApp(app: true | string, options: Options) { } await open( - `http://localhost:${options.port}/`, + `${options.protocol}://${options.host ?? 'localhost'}:${options.port}/`, app !== 'browser' ? { app: { name: app } } : undefined ); }