Changed default host from localhost to 127.0.0.1

Made dev shortcuts not global
Added host and port arguments in electron launcher
This commit is contained in:
RemixDev 2021-06-29 15:58:25 +02:00
parent 00e2d0724b
commit 2a005b513f
5 changed files with 33 additions and 24 deletions

View File

@ -1,14 +1,20 @@
const { app, BrowserWindow, globalShortcut, ipcMain, shell, dialog, Menu} = require('electron')
const { app, BrowserWindow, ipcMain, shell, dialog, Menu, MenuItem } = require('electron')
const contextMenu = require('electron-context-menu')
const WindowStateManager = require('electron-window-state-manager')
const path = require('path')
const os = require('os')
const yargs = require('yargs/yargs')
const { hideBin } = require('yargs/helpers')
const argv = yargs(hideBin(process.argv)).options({
port: { type: 'string', default: '6595' },
host: { type: 'string', default: '127.0.0.1' },
dev: { type: 'boolean', default: false}
}).argv
const PORT = process.env.PORT || '6595'
const PORT = process.env.DEEMIX_PORT || argv.port
function isDev() {
return process.argv[2] == '--dev';
}
process.env.DEEMIX_PORT = PORT
process.env.DEEMIX_HOST = argv.host
let win
const windowState = new WindowStateManager('mainWindow', {
@ -33,13 +39,16 @@ function createWindow () {
win.setMenu(null)
if (isDev()){
globalShortcut.register('f5', function() {
win.reload()
})
globalShortcut.register('f12', function() {
win.webContents.openDevTools()
})
if (argv.dev){
const menu = new Menu()
menu.append(new MenuItem({
label: 'DevTools',
submenu: [
{ role: 'reload', accelerator: 'f5', click: () => { win.reload() } },
{ role: 'devtools', accelerator: 'f12', click: () => { win.webContents.toggleDevTools() } }
]
}))
Menu.setApplicationMenu(menu)
}
// Open links in external browser
@ -48,7 +57,7 @@ function createWindow () {
shell.openExternal(url)
})
win.loadURL(`http://localhost:${PORT}`)
win.loadURL(`http://${argv.host}:${PORT}`)
if (windowState.maximized) {
win.maximize();

View File

@ -54,7 +54,7 @@
"electron-window-state-manager": "^0.3.2",
"cookie-parser": "1.4.5",
"debug": "2.6.9",
"deemix": "3.0.0",
"deemix": "3.0.1",
"deezer-js": "1.0.0",
"dotenv": "8.2.0",
"express": "4.17.1",

6
server/dist/app.js vendored
View File

@ -21,10 +21,10 @@ const errors_1 = require("./helpers/errors");
// TODO: Remove type assertion while keeping correct types
const argv = yargs_1.default(helpers_1.hideBin(process.argv)).options({
port: { type: 'string', default: '6595' },
host: { type: 'string', default: 'localhost' }
host: { type: 'string', default: '127.0.0.1' }
}).argv;
const DEEMIX_PORT = port_1.normalizePort((_a = process.env.PORT) !== null && _a !== void 0 ? _a : argv.port);
const DEEMIX_HOST = (_b = process.env.HOST) !== null && _b !== void 0 ? _b : argv.host;
const DEEMIX_PORT = port_1.normalizePort((_a = process.env.DEEMIX_PORT) !== null && _a !== void 0 ? _a : argv.port);
const DEEMIX_HOST = (_b = process.env.DEEMIX_HOST) !== null && _b !== void 0 ? _b : argv.host;
const debug = debug_1.default('deemix-gui:server');
exports.app = express_1.default();
exports.wss = new ws_1.Server({ noServer: true });

View File

@ -19,11 +19,11 @@ import { consoleInfo } from './helpers/errors'
// TODO: Remove type assertion while keeping correct types
const argv = yargs(hideBin(process.argv)).options({
port: { type: 'string', default: '6595' },
host: { type: 'string', default: 'localhost' }
host: { type: 'string', default: '127.0.0.1' }
}).argv as Arguments
const DEEMIX_PORT = normalizePort(process.env.PORT ?? argv.port)
const DEEMIX_HOST = process.env.HOST ?? argv.host
const DEEMIX_PORT = normalizePort(process.env.DEEMIX_PORT ?? argv.port)
const DEEMIX_HOST = process.env.DEEMIX_HOST ?? argv.host
const debug = initDebug('deemix-gui:server')
export const app: Application = express()

View File

@ -2269,10 +2269,10 @@ decompress-response@^6.0.0:
dependencies:
mimic-response "^3.1.0"
deemix@3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/deemix/-/deemix-3.0.0.tgz#4a0ae0d5ebb75331b8909f60bbe444a0557ae201"
integrity sha512-tRtx6brWVm2ZMh79E61gXQGs2tD7h12TL9jmrRtucK9fZxZl59mH4S0QIZeLLovjF4/13MCWwtx/QvFLauM96g==
deemix@3.0.1:
version "3.0.1"
resolved "https://registry.yarnpkg.com/deemix/-/deemix-3.0.1.tgz#692f14b799000516d1b91fa768c145978bbe1b5e"
integrity sha512-wxI3aRs2NELf7U/bEEd0MMJkKxqEt5Y+U5B3xNjHp3hzmq6BTt5C50q8qBL7hE6vaytkG/P4HX7oFJmJVoYyUw==
dependencies:
async "^3.2.0"
crypto "^1.0.1"