From 7ab0024617eb4669c01c44aff14431c36082dc74 Mon Sep 17 00:00:00 2001 From: meriadec Date: Thu, 11 Jan 2018 14:59:55 +0100 Subject: [PATCH 1/4] Prevent shrink globally --- src/styles/global.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/styles/global.js b/src/styles/global.js index fba9bcf4..e2315e5d 100644 --- a/src/styles/global.js +++ b/src/styles/global.js @@ -13,6 +13,9 @@ injectGlobal` user-select: none; cursor: inherit; min-width: 0; + + // it will surely make problem in the future... to be inspected. + flex-shrink: 0; } body { From a89645cfd0d955f1c9697242c6d56cbd30c4afd1 Mon Sep 17 00:00:00 2001 From: meriadec Date: Thu, 11 Jan 2018 15:06:39 +0100 Subject: [PATCH 2/4] Move electron to devDeps because electron-builder requires it --- package.json | 2 +- src/main/app.js | 2 +- src/main/bridge.js | 2 +- src/renderer/initEvents.js | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index 75ff699d..c053f246 100644 --- a/package.json +++ b/package.json @@ -32,7 +32,6 @@ "@ledgerhq/hw-app-eth": "^1.0.4", "babel-loader": "^7.1.2", "color": "^2.0.1", - "electron": "1.7.10", "electron-devtools-installer": "^2.2.3", "file-loader": "^1.1.6", "history": "^4.7.2", @@ -61,6 +60,7 @@ "babel-preset-flow": "^6.23.0", "babel-preset-react": "^6.24.1", "babel-preset-stage-0": "^6.24.1", + "electron": "1.7.10", "electron-builder": "^19.49.0", "electron-rebuild": "^1.6.1", "electron-webpack": "1.11.0", diff --git a/src/main/app.js b/src/main/app.js index 3a8e84e8..138765ea 100644 --- a/src/main/app.js +++ b/src/main/app.js @@ -1,6 +1,6 @@ // @flow -import { app, BrowserWindow } from 'electron' +import { app, BrowserWindow } from 'electron' // eslint-disable-line import/no-extraneous-dependencies // Global reference to mainWindow // Necessary to prevent win from being garbage collected diff --git a/src/main/bridge.js b/src/main/bridge.js index a25405b0..5e8ff55e 100644 --- a/src/main/bridge.js +++ b/src/main/bridge.js @@ -1,7 +1,7 @@ // @flow import { fork } from 'child_process' -import { ipcMain } from 'electron' +import { ipcMain } from 'electron' // eslint-disable-line import/no-extraneous-dependencies import { resolve } from 'path' // $FlowFixMe diff --git a/src/renderer/initEvents.js b/src/renderer/initEvents.js index 129388bb..092f3c48 100644 --- a/src/renderer/initEvents.js +++ b/src/renderer/initEvents.js @@ -1,6 +1,6 @@ // @flow -import { ipcRenderer } from 'electron' +import { ipcRenderer } from 'electron' // eslint-disable-line import/no-extraneous-dependencies import objectPath from 'object-path' import { devicesUpdate, deviceAdd, deviceRemove } from 'actions/devices' From 6be3fb02dc9c84adda74bf43e69d556919e9b1c2 Mon Sep 17 00:00:00 2001 From: meriadec Date: Thu, 11 Jan 2018 16:08:15 +0100 Subject: [PATCH 3/4] Re-order deps --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index c053f246..1c4668c3 100644 --- a/package.json +++ b/package.json @@ -27,9 +27,9 @@ }, "dependencies": { "@ledgerhq/hw-app-btc": "^1.0.4", + "@ledgerhq/hw-app-eth": "^1.0.4", "@ledgerhq/hw-transport": "^1.0.4", "@ledgerhq/hw-transport-node-hid": "^1.0.4", - "@ledgerhq/hw-app-eth": "^1.0.4", "babel-loader": "^7.1.2", "color": "^2.0.1", "electron-devtools-installer": "^2.2.3", From ae4edce36c4507092f714f78116733f5bb4d5cd6 Mon Sep 17 00:00:00 2001 From: meriadec Date: Thu, 11 Jan 2018 18:41:07 +0100 Subject: [PATCH 4/4] Make build work (at least on Linux) --- .gitignore | 1 + package.json | 9 ++++++--- scripts/postbuild.js | 26 ++++++++++++++++++++++++++ src/globals.js | 2 +- src/main/bridge.js | 4 ++-- webpack.renderer.js | 15 +++++++++++---- yarn.lock | 16 ++++++++-------- 7 files changed, 55 insertions(+), 18 deletions(-) create mode 100644 scripts/postbuild.js diff --git a/.gitignore b/.gitignore index 14d96116..e9813554 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ .DS_Store +/static/ /dist/ /node_modules/ /flow-typed/ diff --git a/package.json b/package.json index 1c4668c3..d098eeee 100644 --- a/package.json +++ b/package.json @@ -11,9 +11,9 @@ } }, "scripts": { - "start": "electron-webpack dev", + "start": "NODE_ENV=development electron-webpack dev", "compile": "electron-webpack", - "dist": "yarn compile && electron-builder", + "dist": "yarn compile && node scripts/postbuild && electron-builder", "dist:dir": "yarn dist --dir -c.compression=store -c.mac.identity=null", "prettier": "prettier --write \"src/**/*.js\"", "postinstall": "electron-rebuild && flow-typed install -s", @@ -25,11 +25,14 @@ "webpackConfig": "webpack.renderer.js" } }, + "resolutions": { + "webpack-sources": "1.0.1" + }, "dependencies": { "@ledgerhq/hw-app-btc": "^1.0.4", "@ledgerhq/hw-app-eth": "^1.0.4", "@ledgerhq/hw-transport": "^1.0.4", - "@ledgerhq/hw-transport-node-hid": "^1.0.4", + "@ledgerhq/hw-transport-node-hid": "^1.0.7", "babel-loader": "^7.1.2", "color": "^2.0.1", "electron-devtools-installer": "^2.2.3", diff --git a/scripts/postbuild.js b/scripts/postbuild.js new file mode 100644 index 00000000..98cc38de --- /dev/null +++ b/scripts/postbuild.js @@ -0,0 +1,26 @@ +const path = require('path') +const fs = require('fs') + +function folderExists(p) { + try { + fs.accessSync(p, fs.constants.R_OK | fs.constants.W_OK) // eslint-disable-line no-bitwise + return true + } catch (err) { + return false + } +} + +try { + const DEST_FOLDER = path.resolve(__dirname, '../static') + const USB_FILE = path.resolve(__dirname, '../dist/main/usb.js') + const DEST_USB_FILE = path.join(DEST_FOLDER, 'usb.js') + if (!folderExists(DEST_FOLDER)) { + fs.mkdirSync(DEST_FOLDER) + } + const stream = fs.createReadStream(USB_FILE).pipe(fs.createWriteStream(DEST_USB_FILE)) + stream.on('error', err => { + throw err + }) +} catch (err) { + console.log(`x Something went wrong`, err) +} diff --git a/src/globals.js b/src/globals.js index fdca57e0..f1a4fb70 100644 --- a/src/globals.js +++ b/src/globals.js @@ -2,6 +2,6 @@ const { NODE_ENV } = process.env -global.__ENV__ = NODE_ENV || 'development' +global.__ENV__ = NODE_ENV global.__DEV__ = global.__ENV__ === 'development' global.__PROD__ = global.__ENV__ === 'production' diff --git a/src/main/bridge.js b/src/main/bridge.js index 5e8ff55e..16f1a067 100644 --- a/src/main/bridge.js +++ b/src/main/bridge.js @@ -5,13 +5,13 @@ import { ipcMain } from 'electron' // eslint-disable-line import/no-extraneous-d import { resolve } from 'path' // $FlowFixMe -import usbBridge from 'file-loader!babel-loader!./usb' // eslint-disable-line import/no-webpack-loader-syntax +import usbBridge from 'file-loader?name=usb.js!babel-loader!./usb' // eslint-disable-line import/no-webpack-loader-syntax ipcMain.on('msg', (event: any, payload) => { const { type, data } = payload const compute = fork(usbBridge, { - cwd: resolve(__dirname, '../../dist/main'), + cwd: resolve(__dirname, __DEV__ ? '../../dist/main' : '../static'), }) compute.send({ type, data }) diff --git a/webpack.renderer.js b/webpack.renderer.js index 2bba9be0..dc6c6f3a 100644 --- a/webpack.renderer.js +++ b/webpack.renderer.js @@ -2,10 +2,7 @@ const webpack = require('webpack') require('./src/globals') -module.exports = { - output: { - publicPath: '/', - }, +const config = { plugins: [ new webpack.DefinePlugin({ __DEV__, @@ -16,3 +13,13 @@ module.exports = { historyApiFallback: true, }, } + +if (__DEV__) { + Object.assign(config, { + output: { + publicPath: '/', + }, + }) +} + +module.exports = config diff --git a/yarn.lock b/yarn.lock index 498b077c..17e4e937 100644 --- a/yarn.lock +++ b/yarn.lock @@ -90,9 +90,9 @@ dependencies: "@ledgerhq/hw-transport" "^1.0.5" -"@ledgerhq/hw-transport-node-hid@^1.0.4": - version "1.0.5" - resolved "https://registry.yarnpkg.com/@ledgerhq/hw-transport-node-hid/-/hw-transport-node-hid-1.0.5.tgz#2f35773ece17d856a42868fd2d9497c6a7ed20dc" +"@ledgerhq/hw-transport-node-hid@^1.0.7": + version "1.0.7" + resolved "https://registry.yarnpkg.com/@ledgerhq/hw-transport-node-hid/-/hw-transport-node-hid-1.0.7.tgz#93aa2d0ce868eb469c9a0f095c46f5b2a27bdce4" dependencies: "@ledgerhq/hw-transport" "^1.0.5" node-hid "^0.7.2" @@ -6849,7 +6849,7 @@ source-map@0.5.6: version "0.5.6" resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.5.6.tgz#75ce38f52bf0733c5a7f0c118d81334a2bb5f412" -source-map@0.5.x, source-map@^0.5.3, source-map@^0.5.6, source-map@~0.5.0, source-map@~0.5.1: +source-map@0.5.x, source-map@^0.5.3, source-map@^0.5.6, source-map@~0.5.0, source-map@~0.5.1, source-map@~0.5.3: version "0.5.7" resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.5.7.tgz#8a039d2d1021d22d1ea14c80d8ea468ba2ef3fcc" @@ -7641,12 +7641,12 @@ webpack-merge@^4.1.0: dependencies: lodash "^4.17.4" -webpack-sources@^1.0.1: - version "1.1.0" - resolved "https://registry.yarnpkg.com/webpack-sources/-/webpack-sources-1.1.0.tgz#a101ebae59d6507354d71d8013950a3a8b7a5a54" +webpack-sources@1.0.1, webpack-sources@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/webpack-sources/-/webpack-sources-1.0.1.tgz#c7356436a4d13123be2e2426a05d1dad9cbe65cf" dependencies: source-list-map "^2.0.0" - source-map "~0.6.1" + source-map "~0.5.3" webpack@^3.10.0: version "3.10.0"