From 48267f25776499f7c41a35cc8b463958aa57afdb Mon Sep 17 00:00:00 2001 From: Yoni Date: Thu, 2 Nov 2017 14:34:54 -0700 Subject: [PATCH] main process can toggle url served based on production or development environment --- .gitignore | 1 + config/keys.js | 8 ++++++++ index.js | 10 ++++++---- package-lock.json | 40 ++++++++++++++++++++-------------------- package.json | 2 ++ 5 files changed, 37 insertions(+), 24 deletions(-) diff --git a/.gitignore b/.gitignore index d30f40e..f53349d 100644 --- a/.gitignore +++ b/.gitignore @@ -11,6 +11,7 @@ # misc .DS_Store +.env .env.local .env.development.local .env.test.local diff --git a/config/keys.js b/config/keys.js index e69de29..86f2861 100644 --- a/config/keys.js +++ b/config/keys.js @@ -0,0 +1,8 @@ +module.exports = { + startUrl: process.env.DEV_URL || + url.format({ + pathname: path.join(__dirname, './build/index.html'), + protocol: 'file:', + slashes: true + }) +} diff --git a/index.js b/index.js index eac3e6a..8f6c0de 100644 --- a/index.js +++ b/index.js @@ -1,9 +1,11 @@ +require('dotenv').config(); const electron = require('electron'); const path = require('path'); +const url = require('url'); const MainWindow = require('./app/MainWindow'); const CaptureTray = require('./app/CaptureTray'); const { app, BrowserWIndow, Tray, Menu } = electron; -const startUrl = process.env.DEV_URL; +const startUrl = require('./config/keys').startUrl; let mainWindow; let tray; @@ -14,9 +16,9 @@ app.on('ready', () => { {label: 'Record', type: 'radio'}, {label: 'Stop', type: 'radio'}, ]) - console.log('url', startUrl); - // use the below once a build bundle is created - // mainWindow.loadURL(`file://${__dirname}/public/index.html`); + + console.log('env', process.env.NODE_ENV) + mainWindow = new MainWindow(startUrl); tray = new CaptureTray(iconPath, contextMenu); diff --git a/package-lock.json b/package-lock.json index 4d54c22..bf1a908 100644 --- a/package-lock.json +++ b/package-lock.json @@ -199,7 +199,7 @@ "arr-flatten": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/arr-flatten/-/arr-flatten-1.1.0.tgz", - "integrity": "sha512-L3hKV5R/p5o81R7O02IGnwpDmkp6E982XhtbuwSe3O4qOtMMMtodicASA1Cny2U+aCXcNpml+m4dPsvsJ3jatg==" + "integrity": "sha1-NgSLv/TntH4TZkQxbJlmnqWukfE=" }, "array-equal": { "version": "1.0.0", @@ -304,7 +304,7 @@ "async": { "version": "2.5.0", "resolved": "https://registry.npmjs.org/async/-/async-2.5.0.tgz", - "integrity": "sha512-e+lJAJeNWuPCNyxZKOBdaJGyLGHugXVQtrAwtuAe2vhxTYxFTKE73p8JuTmdH0qdQZtDvI4dhJwjZc5zsfIsYw==", + "integrity": "sha1-hDGQ/WtzV6C54clW7d3V7IRitU0=", "requires": { "lodash": "https://registry.npmjs.org/lodash/-/lodash-4.17.4.tgz" } @@ -1162,7 +1162,7 @@ "base64-js": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.2.1.tgz", - "integrity": "sha512-dwVUVIXsBZXwTuwnXI9RK8sBmgq09NDHzyR9SAph9eqk76gKK2JSQmZARC2zRC81JC2QTtxD0ARU5qTS25gIGw==" + "integrity": "sha1-qRlH2h9KUW6jjltOwOw3c2deCIY=" }, "batch": { "version": "0.6.1", @@ -1583,7 +1583,7 @@ "cipher-base": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/cipher-base/-/cipher-base-1.0.4.tgz", - "integrity": "sha512-Kkht5ye6ZGmwv40uUDZztayT2ThLQGfnj/T71N/XzeZeo3nf8foyW7zGTsPYkEya3m5f3cAypH+qe7YOrM1U2Q==", + "integrity": "sha1-h2Dk7MJy9MNjUy+SbYdKriwTl94=", "requires": { "inherits": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", "safe-buffer": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.1.tgz" @@ -2043,7 +2043,7 @@ "crypto-browserify": { "version": "3.11.1", "resolved": "https://registry.npmjs.org/crypto-browserify/-/crypto-browserify-3.11.1.tgz", - "integrity": "sha512-Na7ZlwCOqoaW5RwUK1WpXws2kv8mNhWdTlzob0UXulk6G9BDbyiJaGTYBIX61Ozn9l1EPPJpICZb4DaOpT9NlQ==", + "integrity": "sha1-lIlF78Z1ekANbl5a9HGU0QBkJ58=", "requires": { "browserify-cipher": "1.0.0", "browserify-sign": "4.0.4", @@ -2971,7 +2971,7 @@ "eslint-module-utils": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/eslint-module-utils/-/eslint-module-utils-2.1.1.tgz", - "integrity": "sha512-jDI/X5l/6D1rRD/3T43q8Qgbls2nq5km5KSqiwlyUbGo5+04fXhMKdCPhjwbqAa6HXWaMxj8Q4hQDIh7IadJQw==", + "integrity": "sha1-q67IJBd2E7ipWymWOeG2+s9HNEk=", "requires": { "debug": "https://registry.npmjs.org/debug/-/debug-2.6.8.tgz", "pkg-dir": "1.0.0" @@ -3622,7 +3622,7 @@ "fsevents": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-1.1.2.tgz", - "integrity": "sha512-Sn44E5wQW4bTHXvQmvSHwqbuiXtduD6Rrjm2ZtUEGbyrig+nUH3t/QD4M4/ZXViY556TBpRgZkHLDx3JxPwxiw==", + "integrity": "sha1-MoK3E/s62A7eDp/PRhG1qm/AM/Q=", "optional": true, "requires": { "nan": "2.7.0", @@ -4495,7 +4495,7 @@ "globals": { "version": "9.18.0", "resolved": "https://registry.npmjs.org/globals/-/globals-9.18.0.tgz", - "integrity": "sha512-S0nG3CLEQiY/ILxqtztTWH/3iRRdyBLw6KMDxnKMchrtbj2OFmehVh0WUCfW3DUrIgx/qFrJPICrq4Z4sTR9UQ==" + "integrity": "sha1-qjiWs+abSH8X4x7SFD1pqOMMLYo=" }, "globby": { "version": "5.0.0", @@ -4655,7 +4655,7 @@ "hash.js": { "version": "1.1.3", "resolved": "https://registry.npmjs.org/hash.js/-/hash.js-1.1.3.tgz", - "integrity": "sha512-/UETyP0W22QILqS+6HowevwhEFJ3MBJnwTf75Qob9Wz9t0DPuisL8kW8YZMK62dHAKE1c1p+gY1TtOLY+USEHA==", + "integrity": "sha1-NA3tvmKQGHFRweodd3o0SJNd+EY=", "requires": { "inherits": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", "minimalistic-assert": "1.0.0" @@ -5377,7 +5377,7 @@ "istanbul-lib-coverage": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/istanbul-lib-coverage/-/istanbul-lib-coverage-1.1.1.tgz", - "integrity": "sha512-0+1vDkmzxqJIn5rcoEqapSB4DmPxE31EtI2dF2aCkV5esN9EWHxZ0dwgDClivMXJqE7zaYQxq30hj5L0nlTN5Q==" + "integrity": "sha1-c7+5mIhSmUFck9OKPprfeEp3qdo=" }, "istanbul-lib-hook": { "version": "1.1.0", @@ -6117,7 +6117,7 @@ "lru-cache": { "version": "4.1.1", "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-4.1.1.tgz", - "integrity": "sha512-q4spe4KTfsAS1SUHLO0wz8Qiyf1+vMIAgpRYioFYDMNqKfHQbg+AVDH3i4fvpl71/P1L0dBl+fQi+P37UYf0ew==", + "integrity": "sha1-Yi4y6CSItJJ5EUpPns9F581rulU=", "requires": { "pseudomap": "1.0.2", "yallist": "2.1.2" @@ -6603,7 +6603,7 @@ "opn": { "version": "5.1.0", "resolved": "https://registry.npmjs.org/opn/-/opn-5.1.0.tgz", - "integrity": "sha512-iPNl7SyM8L30Rm1sjGdLLheyHVw5YXVfi3SKWJzBI7efxRwHojfRFjwE/OLM6qp9xJYMgab8WicTU1cPoY+Hpg==", + "integrity": "sha1-cs4jBqF9vqWP8QQYUzUrSo/HdRk=", "requires": { "is-wsl": "1.1.0" } @@ -8217,7 +8217,7 @@ "randomatic": { "version": "1.1.7", "resolved": "https://registry.npmjs.org/randomatic/-/randomatic-1.1.7.tgz", - "integrity": "sha512-D5JUjPyJbaJDkuAazpVnSfVkLlpeO3wDlPROTMLGKG1zMFNFRgrciKo1ltz/AzNTkqE0HzDx655QOL51N06how==", + "integrity": "sha1-x6vpzIuHwLqodrGf3oP9RkeX44w=", "requires": { "is-number": "3.0.0", "kind-of": "4.0.0" @@ -8254,7 +8254,7 @@ "randombytes": { "version": "2.0.5", "resolved": "https://registry.npmjs.org/randombytes/-/randombytes-2.0.5.tgz", - "integrity": "sha512-8T7Zn1AhMsQ/HI1SjcCfT/t4ii3eAqco3yOcSzS4mozsOz69lHLsoMXmF9nZgnFanYscnSlUSgs8uZyKzpE6kg==", + "integrity": "sha1-3ACaJGuNCaF3tLegrne8Vw9LG3k=", "requires": { "safe-buffer": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.1.tgz" } @@ -8907,7 +8907,7 @@ "sax": { "version": "1.2.4", "resolved": "https://registry.npmjs.org/sax/-/sax-1.2.4.tgz", - "integrity": "sha512-NqVDv9TpANUjFm0N8uM5GxL36UgKi9/atZw+x7YFnQ8ckwFGKrl4xX4yWtrey3UJm5nP1kUbnYgLopqWNSRhWw==" + "integrity": "sha1-KBYjTiN4vdxOU1T6tcqold9xANk=" }, "schema-utils": { "version": "0.3.0", @@ -9301,7 +9301,7 @@ "stream-http": { "version": "2.7.2", "resolved": "https://registry.npmjs.org/stream-http/-/stream-http-2.7.2.tgz", - "integrity": "sha512-c0yTD2rbQzXtSsFSVhtpvY/vS6u066PcXOX9kBB3mSO76RiUQzL340uJkGBWnlBg4/HZzqiUXtaVA7wcRcJgEw==", + "integrity": "sha1-QKBQ7I3DtTsz2ZCUFcAsC/Gr+60=", "requires": { "builtin-status-codes": "3.0.0", "inherits": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", @@ -9415,7 +9415,7 @@ "sw-precache": { "version": "5.2.0", "resolved": "https://registry.npmjs.org/sw-precache/-/sw-precache-5.2.0.tgz", - "integrity": "sha512-sKctdX+5hUxkqJ/1DM88ubQ+QRvyw7CnxWdk909N2DgvxMqc1gcQFrwL7zpVc87wFmCA/OvRQd0iMC2XdFopYg==", + "integrity": "sha1-62IlzlgM6q4UgZRXigrQGrfqGZw=", "requires": { "dom-urls": "1.1.0", "es6-promise": "https://registry.npmjs.org/es6-promise/-/es6-promise-4.1.1.tgz", @@ -9528,7 +9528,7 @@ "test-exclude": { "version": "4.1.1", "resolved": "https://registry.npmjs.org/test-exclude/-/test-exclude-4.1.1.tgz", - "integrity": "sha512-35+Asrsk3XHJDBgf/VRFexPgh3UyETv8IAn/LRTiZjVy6rjPVqdEk8dJcJYBzl1w0XCJM48lvTy8SfEsCWS4nA==", + "integrity": "sha1-TYSWSwlmsAh+zDNKLOAC09k0HiY=", "requires": { "arrify": "1.0.1", "micromatch": "2.3.11", @@ -9545,7 +9545,7 @@ "throat": { "version": "3.2.0", "resolved": "https://registry.npmjs.org/throat/-/throat-3.2.0.tgz", - "integrity": "sha512-/EY8VpvlqJ+sFtLPeOgc8Pl7kQVOWv0woD87KTXVHPIAE842FGT+rokxIhe8xIUP1cfgrkt0as0vDLjDiMtr8w==" + "integrity": "sha1-UMsGcO28QCN7njR9fh+I5GIK+DY=" }, "throttleit": { "version": "https://registry.npmjs.org/throttleit/-/throttleit-0.0.2.tgz", @@ -10395,7 +10395,7 @@ "webpack-sources": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/webpack-sources/-/webpack-sources-1.0.1.tgz", - "integrity": "sha512-05tMxipUCwHqYaVS8xc7sYPTly8PzXayRCB4dTxLhWTqlKUiwH6ezmEe0OSreL1c30LAuA3Zqmc+uEBUGFJDjw==", + "integrity": "sha1-xzVkNqTRMSO+LiQmoF0drZy+Zc8=", "requires": { "source-list-map": "2.0.0", "source-map": "0.5.7" diff --git a/package.json b/package.json index 2f74d59..c981f1c 100644 --- a/package.json +++ b/package.json @@ -7,6 +7,7 @@ }, "dependencies": { "concurrently": "^3.5.0", + "dotenv": "^4.0.0", "electron": "^1.6.11", "react": "^15.6.1", "react-desktop": "^0.3.1", @@ -23,6 +24,7 @@ "build": "react-scripts build", "test": "react-scripts test --env=jsdom", "eject": "react-scripts eject", + "electron": "electron .", "electron-dev": "set DEV_URL=http://localhost:3000 && electron .", "start": "concurrently \"npm run react-start\" \"wait-on http://localhost:3000/ && npm run electron-dev\"" }