Skip to content
This repository was archived by the owner on Nov 17, 2023. It is now read-only.

Commit 28fb9cc

Browse files
authored
Merge pull request #569 from mrfelton/feat/lnd-binary
build: auto download lnd-binary on install
2 parents 40655f6 + a846db8 commit 28fb9cc

File tree

5 files changed

+254
-15
lines changed

5 files changed

+254
-15
lines changed

app/lnd/config/index.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@
33
// Linux: ~/.lnd/tls.cert
44
// Windows: TODO find out where cert is located for windows machine
55
import { userInfo, platform } from 'os'
6-
import { join, normalize } from 'path'
6+
import { dirname, join, normalize } from 'path'
77
import Store from 'electron-store'
88
import { app } from 'electron'
9+
import isDev from 'electron-is-dev'
910

1011
// Get a path to prepend to any nodejs calls that are getting at files in the package,
1112
// so that it works both from source and in an asar-packaged mac app.
@@ -51,8 +52,9 @@ switch (plat) {
5152
break
5253
}
5354

54-
if (process.env.NODE_ENV === 'development') {
55-
lndPath = join(appRootPath, 'resources', 'bin', plat, lndBin)
55+
if (isDev) {
56+
const lndBinaryDir = dirname(require.resolve('lnd-binary/package.json'))
57+
lndPath = join(lndBinaryDir, 'vendor', lndBin)
5658
} else {
5759
lndPath = join(appRootPath, 'bin', lndBin)
5860
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
const lndBinary = require('lnd-binary')
2+
3+
function install(platform, arch, dest) {
4+
process.env.LND_BINARY_PLATFORM = platform
5+
process.env.LND_BINARY_ARCH = arch
6+
process.env.LND_BINARY_DIR = dest
7+
8+
return lndBinary.install()
9+
}
10+
11+
return install('darwin', 'amd64', 'resources/bin/mac/x64')
12+
.then(() => install('darwin', '386', 'resources/bin/mac/ia32'))
13+
.then(() => install('windows', 'amd64', 'resources/bin/win/x64'))
14+
.then(() => install('windows', '386', 'resources/bin/win/ia32'))
15+
.then(() => install('linux', 'amd64', 'resources/bin/linux/x64'))
16+
.then(() => install('linux', '386', 'resources/bin/linux/ia32'))

package.json

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@
88
"build-dll": "webpack --require babel-register --config webpack.config.renderer.dev.dll.js --progress",
99
"build-main": "webpack --require babel-register --config webpack.config.main.prod.js --progress",
1010
"build-renderer": "webpack --require babel-register --config webpack.config.renderer.prod.js --progress",
11+
"build-grpc": "rimraf app/node_modules/grpc/src/node && build install-app-deps",
12+
"clean": "rimraf node_modules app/node_modules dll app/dist",
1113
"dev": "cross-env START_HOT=1 npm run start-renderer-dev",
14+
"fetch-lnd": "node ./internals/scripts/fetch-lnd-for-packaging.js",
1215
"flow": "flow",
1316
"flow-typed": "rimraf flow-typed/npm && flow-typed install --overwrite || true",
1417
"lint-base": "eslint --cache --format=node_modules/eslint-formatter-pretty",
@@ -21,11 +24,12 @@
2124
"lint-styles-fix": "npm run lint-styles-fix-base -- $npm_package_config_style_paths",
2225
"lint-check": "eslint --print-config .eslintrc.js | eslint-config-prettier-check",
2326
"lint-ci": "npm run lint && npm run lint-styles && npm run flow",
24-
"package": "npm run build && build --publish never",
25-
"package-all": "npm run build && build -mwl",
26-
"package-linux": "npm run build && build --linux",
27-
"package-win": "npm run build && build --win",
28-
"postinstall": "concurrently --raw \"npm:flow-typed\" \"npm:build-dll\" \"electron-builder install-app-deps\" \"node node_modules/fbjs-scripts/node/check-dev-engines.js package.json\"",
27+
"package": "npm run build && rimraf app/node_modules/grpc/src/node && npm run fetch-lnd && build --publish never",
28+
"package-mac": "npm run package -- --platform mac --arch all && npm run build-grpc",
29+
"package-win": "npm run package -- --platform win --arch all && npm run build-grpc",
30+
"package-linux": "npm_config_target_libc=glibc npm run package -- --platform linux --arch all && npm run build-grpc",
31+
"package-all": "npm run package-mac && npm run package-win && npm run package-linux",
32+
"postinstall": "concurrently --raw \"npm:flow-typed\" \"npm:build-dll\" \"build install-app-deps\" \"node node_modules/fbjs-scripts/node/check-dev-engines.js package.json\"",
2933
"prestart": "npm run build",
3034
"start": "cross-env NODE_ENV=production electron ./app/",
3135
"start-main-dev": "cross-env HOT=1 NODE_ENV=development electron -r babel-register ./app/main.dev",
@@ -37,7 +41,10 @@
3741
"test-watch": "npm test -- --watch"
3842
},
3943
"config": {
40-
"style_paths": "app/styles/*.scss app/components/**/*.scss"
44+
"style_paths": "app/styles/*.scss app/components/**/*.scss",
45+
"lnd-binary": {
46+
"binaryVersion": "0.4.2-beta"
47+
}
4148
},
4249
"browserslist": "electron 2.0",
4350
"engines": {
@@ -81,6 +88,7 @@
8188
]
8289
},
8390
"linux": {
91+
"category": "Utility",
8492
"target": [
8593
"deb",
8694
"AppImage"
@@ -94,7 +102,7 @@
94102
"resources/lnd.conf",
95103
"resources/rpc.proto",
96104
{
97-
"from": "resources/bin/${platform}",
105+
"from": "resources/bin/${os}/${arch}",
98106
"to": "bin",
99107
"filter": [
100108
"lnd*"
@@ -165,6 +173,7 @@
165173
"babel-register": "^6.26.0",
166174
"browserslist": "^4.0.0",
167175
"chalk": "^2.4.1",
176+
"clean-webpack-plugin": "^0.1.19",
168177
"concurrently": "^3.6.0",
169178
"connect-history-api-fallback": "^1.5.0",
170179
"cross-env": "^5.2.0",
@@ -204,6 +213,7 @@
204213
"jsdom": "^11.0.0",
205214
"koa-connect": "^2.0.1",
206215
"lint-staged": "^7.2.0",
216+
"lnd-binary": "^0.3.4",
207217
"minimist": "^1.2.0",
208218
"node-sass": "^4.9.0",
209219
"prettier": "^1.13.5",
@@ -233,6 +243,7 @@
233243
"devtron": "^1.4.0",
234244
"electron": "^2.0.5",
235245
"electron-debug": "^2.0.0",
246+
"electron-is-dev": "^0.3.0",
236247
"electron-store": "^2.0.0",
237248
"font-awesome": "^4.7.0",
238249
"history": "^4.6.3",

webpack.config.renderer.prod.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import ExtractTextPlugin from 'extract-text-webpack-plugin'
77
import HtmlWebpackPlugin from 'html-webpack-plugin'
88
import CspHtmlWebpackPlugin from 'csp-html-webpack-plugin'
99
import { BundleAnalyzerPlugin } from 'webpack-bundle-analyzer'
10+
import CleanWebpackPlugin from 'clean-webpack-plugin'
1011
import merge from 'webpack-merge'
1112
import baseConfig from './webpack.config.base'
1213

@@ -141,6 +142,8 @@ export default merge.smart(baseConfig, {
141142
},
142143

143144
plugins: [
145+
new CleanWebpackPlugin(['app/dist']),
146+
144147
new ExtractTextPlugin('style.css'),
145148

146149
new BundleAnalyzerPlugin({

0 commit comments

Comments
 (0)