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

Commit

Permalink
Merge pull request #569 from mrfelton/feat/lnd-binary
Browse files Browse the repository at this point in the history
build: auto download lnd-binary on install
  • Loading branch information
JimmyMow authored Jul 24, 2018
2 parents 40655f6 + a846db8 commit 28fb9cc
Show file tree
Hide file tree
Showing 5 changed files with 254 additions and 15 deletions.
8 changes: 5 additions & 3 deletions app/lnd/config/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
// Linux: ~/.lnd/tls.cert
// Windows: TODO find out where cert is located for windows machine
import { userInfo, platform } from 'os'
import { join, normalize } from 'path'
import { dirname, join, normalize } from 'path'
import Store from 'electron-store'
import { app } from 'electron'
import isDev from 'electron-is-dev'

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

if (process.env.NODE_ENV === 'development') {
lndPath = join(appRootPath, 'resources', 'bin', plat, lndBin)
if (isDev) {
const lndBinaryDir = dirname(require.resolve('lnd-binary/package.json'))
lndPath = join(lndBinaryDir, 'vendor', lndBin)
} else {
lndPath = join(appRootPath, 'bin', lndBin)
}
Expand Down
16 changes: 16 additions & 0 deletions internals/scripts/fetch-lnd-for-packaging.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
const lndBinary = require('lnd-binary')

function install(platform, arch, dest) {
process.env.LND_BINARY_PLATFORM = platform
process.env.LND_BINARY_ARCH = arch
process.env.LND_BINARY_DIR = dest

return lndBinary.install()
}

return install('darwin', 'amd64', 'resources/bin/mac/x64')
.then(() => install('darwin', '386', 'resources/bin/mac/ia32'))
.then(() => install('windows', 'amd64', 'resources/bin/win/x64'))
.then(() => install('windows', '386', 'resources/bin/win/ia32'))
.then(() => install('linux', 'amd64', 'resources/bin/linux/x64'))
.then(() => install('linux', '386', 'resources/bin/linux/ia32'))
25 changes: 18 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@
"build-dll": "webpack --require babel-register --config webpack.config.renderer.dev.dll.js --progress",
"build-main": "webpack --require babel-register --config webpack.config.main.prod.js --progress",
"build-renderer": "webpack --require babel-register --config webpack.config.renderer.prod.js --progress",
"build-grpc": "rimraf app/node_modules/grpc/src/node && build install-app-deps",
"clean": "rimraf node_modules app/node_modules dll app/dist",
"dev": "cross-env START_HOT=1 npm run start-renderer-dev",
"fetch-lnd": "node ./internals/scripts/fetch-lnd-for-packaging.js",
"flow": "flow",
"flow-typed": "rimraf flow-typed/npm && flow-typed install --overwrite || true",
"lint-base": "eslint --cache --format=node_modules/eslint-formatter-pretty",
Expand All @@ -21,11 +24,12 @@
"lint-styles-fix": "npm run lint-styles-fix-base -- $npm_package_config_style_paths",
"lint-check": "eslint --print-config .eslintrc.js | eslint-config-prettier-check",
"lint-ci": "npm run lint && npm run lint-styles && npm run flow",
"package": "npm run build && build --publish never",
"package-all": "npm run build && build -mwl",
"package-linux": "npm run build && build --linux",
"package-win": "npm run build && build --win",
"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\"",
"package": "npm run build && rimraf app/node_modules/grpc/src/node && npm run fetch-lnd && build --publish never",
"package-mac": "npm run package -- --platform mac --arch all && npm run build-grpc",
"package-win": "npm run package -- --platform win --arch all && npm run build-grpc",
"package-linux": "npm_config_target_libc=glibc npm run package -- --platform linux --arch all && npm run build-grpc",
"package-all": "npm run package-mac && npm run package-win && npm run package-linux",
"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\"",
"prestart": "npm run build",
"start": "cross-env NODE_ENV=production electron ./app/",
"start-main-dev": "cross-env HOT=1 NODE_ENV=development electron -r babel-register ./app/main.dev",
Expand All @@ -37,7 +41,10 @@
"test-watch": "npm test -- --watch"
},
"config": {
"style_paths": "app/styles/*.scss app/components/**/*.scss"
"style_paths": "app/styles/*.scss app/components/**/*.scss",
"lnd-binary": {
"binaryVersion": "0.4.2-beta"
}
},
"browserslist": "electron 2.0",
"engines": {
Expand Down Expand Up @@ -81,6 +88,7 @@
]
},
"linux": {
"category": "Utility",
"target": [
"deb",
"AppImage"
Expand All @@ -94,7 +102,7 @@
"resources/lnd.conf",
"resources/rpc.proto",
{
"from": "resources/bin/${platform}",
"from": "resources/bin/${os}/${arch}",
"to": "bin",
"filter": [
"lnd*"
Expand Down Expand Up @@ -165,6 +173,7 @@
"babel-register": "^6.26.0",
"browserslist": "^4.0.0",
"chalk": "^2.4.1",
"clean-webpack-plugin": "^0.1.19",
"concurrently": "^3.6.0",
"connect-history-api-fallback": "^1.5.0",
"cross-env": "^5.2.0",
Expand Down Expand Up @@ -204,6 +213,7 @@
"jsdom": "^11.0.0",
"koa-connect": "^2.0.1",
"lint-staged": "^7.2.0",
"lnd-binary": "^0.3.4",
"minimist": "^1.2.0",
"node-sass": "^4.9.0",
"prettier": "^1.13.5",
Expand Down Expand Up @@ -233,6 +243,7 @@
"devtron": "^1.4.0",
"electron": "^2.0.5",
"electron-debug": "^2.0.0",
"electron-is-dev": "^0.3.0",
"electron-store": "^2.0.0",
"font-awesome": "^4.7.0",
"history": "^4.6.3",
Expand Down
3 changes: 3 additions & 0 deletions webpack.config.renderer.prod.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import ExtractTextPlugin from 'extract-text-webpack-plugin'
import HtmlWebpackPlugin from 'html-webpack-plugin'
import CspHtmlWebpackPlugin from 'csp-html-webpack-plugin'
import { BundleAnalyzerPlugin } from 'webpack-bundle-analyzer'
import CleanWebpackPlugin from 'clean-webpack-plugin'
import merge from 'webpack-merge'
import baseConfig from './webpack.config.base'

Expand Down Expand Up @@ -141,6 +142,8 @@ export default merge.smart(baseConfig, {
},

plugins: [
new CleanWebpackPlugin(['app/dist']),

new ExtractTextPlugin('style.css'),

new BundleAnalyzerPlugin({
Expand Down
Loading

0 comments on commit 28fb9cc

Please sign in to comment.