fix: daemon not launching on Windows #1101

Merged
IGassmann merged 2 commits from issue/1094 into master 2018-03-14 21:38:56 +01:00
5 changed files with 145 additions and 77 deletions

View file

@ -0,0 +1,29 @@
/* eslint-disable no-console,import/no-extraneous-dependencies,import/no-commonjs */
/**
* This script is necessary for checking that the daemon that has been downloaded during the
* yarn installing process is the one for the building target. For example, on Travis the
* Windows package is built on Linux, thus yarn will download the daemon for Linux instead of
* Windows. The script will test that and then download the right daemon for the targeted platform.
*/
const os = require('os');
const downloadDaemon = require('./downloadDaemon');
module.exports = context => {
let currentPlatform = os.platform();
if (currentPlatform === 'darwin') currentPlatform = 'macoss';
if (currentPlatform === 'win32') currentPlatform = 'windows';
let buildingPlatformTarget = context.platform.toString();
if (buildingPlatformTarget === 'mac') buildingPlatformTarget = 'macos';
if (buildingPlatformTarget !== currentPlatform) {
console.log(
"\x1b[34minfo\x1b[0m Daemon platform doesn't match target platform. Redownloading the daemon."
);
return downloadDaemon(buildingPlatformTarget);
}
return Promise.resolve();
};

View file

@ -1,22 +1,28 @@
/* eslint-disable no-console,import/no-commonjs */ /* eslint-disable no-console,import/no-extraneous-dependencies,import/no-commonjs */
const path = require('path'); const path = require('path');
const fs = require('fs'); const fs = require('fs');
const packageJSON = require('../package.json'); const packageJSON = require('../package.json');
// eslint-disable-next-line import/no-extraneous-dependencies
const axios = require('axios'); const axios = require('axios');
// eslint-disable-next-line import/no-extraneous-dependencies
const decompress = require('decompress'); const decompress = require('decompress');
const os = require('os'); const os = require('os');
const del = require('del');
const downloadDaemon = targetPlatform =>
new Promise((resolve, reject) => {
const daemonURLTemplate = packageJSON.lbrySettings.lbrynetDaemonUrlTemplate; const daemonURLTemplate = packageJSON.lbrySettings.lbrynetDaemonUrlTemplate;
const daemonVersion = packageJSON.lbrySettings.lbrynetDaemonVersion; const daemonVersion = packageJSON.lbrySettings.lbrynetDaemonVersion;
const daemonDir = packageJSON.lbrySettings.lbrynetDaemonDir;
const daemonFileName = packageJSON.lbrySettings.lbrynetDaemonFileName;
let currentPlatform = os.platform(); let currentPlatform = os.platform();
if (currentPlatform === 'darwin') currentPlatform = 'macos'; if (currentPlatform === 'darwin') currentPlatform = 'macos';
if (currentPlatform === 'win32') currentPlatform = 'windows'; if (currentPlatform === 'win32') currentPlatform = 'windows';
const daemonPlatform = targetPlatform || currentPlatform;
const daemonURL = daemonURLTemplate const daemonURL = daemonURLTemplate
.replace(/DAEMONVER/g, daemonVersion) .replace(/DAEMONVER/g, daemonVersion)
.replace(/OSNAME/g, currentPlatform); .replace(/OSNAME/g, daemonPlatform);
const tmpZipPath = 'build/daemon.zip'; const tmpZipPath = 'build/daemon.zip';
console.log('\x1b[34minfo\x1b[0m Downloading daemon...'); console.log('\x1b[34minfo\x1b[0m Downloading daemon...');
@ -29,19 +35,36 @@ axios
'Content-Type': 'application/zip', 'Content-Type': 'application/zip',
}, },
}) })
.then(result => { .then(
fs.writeFileSync(tmpZipPath, result.data); result =>
return true; new Promise((newResolve, newReject) => {
}) fs.writeFile(tmpZipPath, result.data, error => {
.then(() => { if (error) return newReject(error);
decompress(tmpZipPath, 'static/daemon', { return newResolve();
filter: file =>
path.basename(file.path).replace(path.extname(file.path), '') === 'lbrynet-daemon',
}); });
}) })
)
.then(() => del(`${daemonDir}/${daemonFileName}*`))
.then(() =>
decompress(tmpZipPath, daemonDir, {
filter: file =>
path.basename(file.path).replace(path.extname(file.path), '') === daemonFileName,
})
)
.then(() => { .then(() => {
console.log('\x1b[32msuccess\x1b[0m Daemon downloaded!'); console.log('\x1b[32msuccess\x1b[0m Daemon downloaded!');
resolve(true);
}) })
.catch(error => { .catch(error => {
console.error(`\x1b[31merror\x1b[0m Daemon download failed due to: \x1b[35m${error}\x1b[0m`); console.error(
`\x1b[31merror\x1b[0m Daemon download failed due to: \x1b[35m${error}\x1b[0m`
);
reject(error);
});
});
module.exports = downloadDaemon;
require('make-runnable/custom')({
printOutputFrame: false
}); });

View file

@ -50,5 +50,6 @@
"nsis": { "nsis": {
"perMachine": true "perMachine": true
}, },
"beforeBuild": "./build/checkDaemonPlatform.js",
"artifactName": "${productName}_${version}.${ext}" "artifactName": "${productName}_${version}.${ext}"
} }

View file

@ -44,7 +44,7 @@
"install": "^0.10.2", "install": "^0.10.2",
"jayson": "^2.0.2", "jayson": "^2.0.2",
"jshashes": "^1.0.7", "jshashes": "^1.0.7",
"keytar-prebuild": "^4.1.1", "keytar-prebuild": "4.0.4",
"localforage": "^1.5.0", "localforage": "^1.5.0",
"mixpanel-browser": "^2.17.1", "mixpanel-browser": "^2.17.1",
"moment": "^2.20.1", "moment": "^2.20.1",
@ -82,8 +82,9 @@
"babel-preset-react": "^6.24.1", "babel-preset-react": "^6.24.1",
"babel-preset-stage-2": "^6.18.0", "babel-preset-stage-2": "^6.18.0",
"decompress": "^4.2.0", "decompress": "^4.2.0",
"del": "^3.0.0",
"devtron": "^1.4.0", "devtron": "^1.4.0",
"electron": "^1.8.3", "electron": "1.7.10",
"electron-builder": "^20.3.1", "electron-builder": "^20.3.1",
"electron-devtools-installer": "^2.2.3", "electron-devtools-installer": "^2.2.3",
"electron-webpack": "^1.13.0", "electron-webpack": "^1.13.0",
@ -103,6 +104,7 @@
"i18n-extract": "^0.5.1", "i18n-extract": "^0.5.1",
"json-loader": "^0.5.4", "json-loader": "^0.5.4",
"lint-staged": "^7.0.0", "lint-staged": "^7.0.0",
"make-runnable": "^1.3.6",
"node-loader": "^0.6.0", "node-loader": "^0.6.0",
"node-sass": "^4.7.2", "node-sass": "^4.7.2",
"prettier": "^1.11.1", "prettier": "^1.11.1",
@ -117,6 +119,8 @@
"license": "MIT", "license": "MIT",
"lbrySettings": { "lbrySettings": {
"lbrynetDaemonVersion": "0.19.0", "lbrynetDaemonVersion": "0.19.0",
"lbrynetDaemonUrlTemplate": "https://github.com/lbryio/lbry/releases/download/vDAEMONVER/lbrynet-daemon-vDAEMONVER-OSNAME.zip" "lbrynetDaemonUrlTemplate": "https://github.com/lbryio/lbry/releases/download/vDAEMONVER/lbrynet-daemon-vDAEMONVER-OSNAME.zip",
"lbrynetDaemonDir": "static/daemon",
"lbrynetDaemonFileName": "lbrynet-daemon"
} }
} }

View file

@ -110,9 +110,9 @@
lodash "^4.2.0" lodash "^4.2.0"
to-fast-properties "^2.0.0" to-fast-properties "^2.0.0"
"@types/node@^8.0.24": "@types/node@^7.0.18":
version "8.9.4" version "7.0.56"
resolved "https://registry.yarnpkg.com/@types/node/-/node-8.9.4.tgz#dfd327582a06c114eb6e0441fa3d6fab35edad48" resolved "https://registry.yarnpkg.com/@types/node/-/node-7.0.56.tgz#b6b659049191822be43c14610c1785d4b9cddecf"
"@types/webpack-env@^1.13.5": "@types/webpack-env@^1.13.5":
version "1.13.5" version "1.13.5"
@ -2539,7 +2539,7 @@ decode-uri-component@^0.2.0:
version "0.2.0" version "0.2.0"
resolved "https://registry.yarnpkg.com/decode-uri-component/-/decode-uri-component-0.2.0.tgz#eb3913333458775cb84cd1a1fae062106bb87545" resolved "https://registry.yarnpkg.com/decode-uri-component/-/decode-uri-component-0.2.0.tgz#eb3913333458775cb84cd1a1fae062106bb87545"
decompress-response@^3.2.0: decompress-response@^3.2.0, decompress-response@^3.3.0:
version "3.3.0" version "3.3.0"
resolved "https://registry.yarnpkg.com/decompress-response/-/decompress-response-3.3.0.tgz#80a4dd323748384bfa248083622aedec982adff3" resolved "https://registry.yarnpkg.com/decompress-response/-/decompress-response-3.3.0.tgz#80a4dd323748384bfa248083622aedec982adff3"
dependencies: dependencies:
@ -3123,11 +3123,11 @@ electron-webpack@^1.13.0:
webpack-merge "^4.1.1" webpack-merge "^4.1.1"
yargs "^11.0.0" yargs "^11.0.0"
electron@^1.8.3: electron@1.7.10:
version "1.8.3" version "1.7.10"
resolved "https://registry.yarnpkg.com/electron/-/electron-1.8.3.tgz#001416ea3a25ce594e317cb5531bc41eadd22f7f" resolved "https://registry.yarnpkg.com/electron/-/electron-1.7.10.tgz#3a3e83d965fd7fafe473be8ddf8f472561b6253d"
dependencies: dependencies:
"@types/node" "^8.0.24" "@types/node" "^7.0.18"
electron-download "^3.0.1" electron-download "^3.0.1"
extract-zip "^1.0.3" extract-zip "^1.0.3"
@ -5718,12 +5718,12 @@ keypress@0.1.x:
version "0.1.0" version "0.1.0"
resolved "https://registry.yarnpkg.com/keypress/-/keypress-0.1.0.tgz#4a3188d4291b66b4f65edb99f806aa9ae293592a" resolved "https://registry.yarnpkg.com/keypress/-/keypress-0.1.0.tgz#4a3188d4291b66b4f65edb99f806aa9ae293592a"
keytar-prebuild@^4.1.1: keytar-prebuild@4.0.4:
version "4.1.1" version "4.0.4"
resolved "https://registry.yarnpkg.com/keytar-prebuild/-/keytar-prebuild-4.1.1.tgz#f31cd3b2e5de743303f8c2f607f29f0117981295" resolved "https://registry.yarnpkg.com/keytar-prebuild/-/keytar-prebuild-4.0.4.tgz#eb6354c68f2b3609dc325ef8709844632652d602"
dependencies: dependencies:
nan "2.8.0" nan "2.7.0"
prebuild-install "^2.5.0" prebuild-install "^2.2.2"
killable@^1.0.0: killable@^1.0.0:
version "1.0.0" version "1.0.0"
@ -6170,6 +6170,13 @@ make-fetch-happen@^2.4.13, make-fetch-happen@^2.5.0:
socks-proxy-agent "^3.0.1" socks-proxy-agent "^3.0.1"
ssri "^5.0.0" ssri "^5.0.0"
make-runnable@^1.3.6:
version "1.3.6"
resolved "https://registry.yarnpkg.com/make-runnable/-/make-runnable-1.3.6.tgz#ca9b1d31b06f051e37570fb7ad98bc5369f982be"
dependencies:
bluebird "^3.5.0"
yargs "^4.7.1"
map-cache@^0.2.2: map-cache@^0.2.2:
version "0.2.2" version "0.2.2"
resolved "https://registry.yarnpkg.com/map-cache/-/map-cache-0.2.2.tgz#c32abd0bd6525d9b051645bb4f26ac5dc98a0dbf" resolved "https://registry.yarnpkg.com/map-cache/-/map-cache-0.2.2.tgz#c32abd0bd6525d9b051645bb4f26ac5dc98a0dbf"
@ -6521,9 +6528,9 @@ mute-stream@0.0.7, mute-stream@~0.0.4:
version "0.0.7" version "0.0.7"
resolved "https://registry.yarnpkg.com/mute-stream/-/mute-stream-0.0.7.tgz#3075ce93bc21b8fab43e1bc4da7e8115ed1e7bab" resolved "https://registry.yarnpkg.com/mute-stream/-/mute-stream-0.0.7.tgz#3075ce93bc21b8fab43e1bc4da7e8115ed1e7bab"
nan@2.8.0: nan@2.7.0:
version "2.8.0" version "2.7.0"
resolved "https://registry.yarnpkg.com/nan/-/nan-2.8.0.tgz#ed715f3fe9de02b57a5e6252d90a96675e1f085a" resolved "https://registry.yarnpkg.com/nan/-/nan-2.7.0.tgz#d95bf721ec877e08db276ed3fc6eb78f9083ad46"
nan@^2.3.0: nan@^2.3.0:
version "2.9.2" version "2.9.2"
@ -6582,9 +6589,9 @@ no-case@^2.2.0:
dependencies: dependencies:
lower-case "^1.1.1" lower-case "^1.1.1"
node-abi@^2.1.1: node-abi@^2.2.0:
version "2.2.0" version "2.3.0"
resolved "https://registry.yarnpkg.com/node-abi/-/node-abi-2.2.0.tgz#e802ac7a2408e2c0593fb3176ffdf8a99a9b4dec" resolved "https://registry.yarnpkg.com/node-abi/-/node-abi-2.3.0.tgz#f3d554d6ac72a9ee16f0f4dc9548db7c08de4986"
dependencies: dependencies:
semver "^5.4.1" semver "^5.4.1"
@ -7677,25 +7684,25 @@ postcss@^6.0.1:
source-map "^0.6.1" source-map "^0.6.1"
supports-color "^4.4.0" supports-color "^4.4.0"
prebuild-install@^2.5.0: prebuild-install@^2.2.2:
version "2.5.0" version "2.5.1"
resolved "https://registry.yarnpkg.com/prebuild-install/-/prebuild-install-2.5.0.tgz#6fdd8436069971c76688071f4847d4c891a119f4" resolved "https://registry.yarnpkg.com/prebuild-install/-/prebuild-install-2.5.1.tgz#0f234140a73760813657c413cdccdda58296b1da"
dependencies: dependencies:
detect-libc "^1.0.3" detect-libc "^1.0.3"
expand-template "^1.0.2" expand-template "^1.0.2"
github-from-package "0.0.0" github-from-package "0.0.0"
minimist "^1.2.0" minimist "^1.2.0"
mkdirp "^0.5.1" mkdirp "^0.5.1"
node-abi "^2.1.1" node-abi "^2.2.0"
noop-logger "^0.1.1" noop-logger "^0.1.1"
npmlog "^4.0.1" npmlog "^4.0.1"
os-homedir "^1.0.1" os-homedir "^1.0.1"
pump "^1.0.1" pump "^2.0.1"
rc "^1.1.6" rc "^1.1.6"
simple-get "^1.4.2" simple-get "^2.7.0"
tar-fs "^1.13.0" tar-fs "^1.13.0"
tunnel-agent "^0.6.0" tunnel-agent "^0.6.0"
xtend "4.0.1" which-pm-runs "^1.0.0"
prelude-ls@~1.1.2: prelude-ls@~1.1.2:
version "1.1.2" version "1.1.2"
@ -8888,13 +8895,17 @@ signal-exit@^3.0.0, signal-exit@^3.0.2:
version "3.0.2" version "3.0.2"
resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-3.0.2.tgz#b5fdc08f1287ea1178628e415e25132b73646c6d" resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-3.0.2.tgz#b5fdc08f1287ea1178628e415e25132b73646c6d"
simple-get@^1.4.2: simple-concat@^1.0.0:
version "1.4.3" version "1.0.0"
resolved "https://registry.yarnpkg.com/simple-get/-/simple-get-1.4.3.tgz#e9755eda407e96da40c5e5158c9ea37b33becbeb" resolved "https://registry.yarnpkg.com/simple-concat/-/simple-concat-1.0.0.tgz#7344cbb8b6e26fb27d66b2fc86f9f6d5997521c6"
simple-get@^2.7.0:
version "2.7.0"
resolved "https://registry.yarnpkg.com/simple-get/-/simple-get-2.7.0.tgz#ad37f926d08129237ff08c4f2edfd6f10e0380b5"
dependencies: dependencies:
decompress-response "^3.3.0"
once "^1.3.1" once "^1.3.1"
unzip-response "^1.0.0" simple-concat "^1.0.0"
xtend "^4.0.0"
simplemde@^1.11.2: simplemde@^1.11.2:
version "1.11.2" version "1.11.2"
@ -9867,10 +9878,6 @@ unused-filename@^1.0.0:
modify-filename "^1.1.0" modify-filename "^1.1.0"
path-exists "^3.0.0" path-exists "^3.0.0"
unzip-response@^1.0.0:
version "1.0.2"
resolved "https://registry.yarnpkg.com/unzip-response/-/unzip-response-1.0.2.tgz#b984f0877fc0a89c2c773cc1ef7b5b232b5b06fe"
unzip-response@^2.0.1: unzip-response@^2.0.1:
version "2.0.1" version "2.0.1"
resolved "https://registry.yarnpkg.com/unzip-response/-/unzip-response-2.0.1.tgz#d2f0f737d16b0615e72a6935ed04214572d56f97" resolved "https://registry.yarnpkg.com/unzip-response/-/unzip-response-2.0.1.tgz#d2f0f737d16b0615e72a6935ed04214572d56f97"
@ -10240,6 +10247,10 @@ which-module@^2.0.0:
version "2.0.0" version "2.0.0"
resolved "https://registry.yarnpkg.com/which-module/-/which-module-2.0.0.tgz#d9ef07dce77b9902b8a3a8fa4b31c3e3f7e6e87a" resolved "https://registry.yarnpkg.com/which-module/-/which-module-2.0.0.tgz#d9ef07dce77b9902b8a3a8fa4b31c3e3f7e6e87a"
which-pm-runs@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/which-pm-runs/-/which-pm-runs-1.0.0.tgz#670b3afbc552e0b55df6b7780ca74615f23ad1cb"
which@1, which@^1.2.10, which@^1.2.12, which@^1.2.14, which@^1.2.9, which@^1.3.0, which@~1.3.0: which@1, which@^1.2.10, which@^1.2.12, which@^1.2.14, which@^1.2.9, which@^1.3.0, which@~1.3.0:
version "1.3.0" version "1.3.0"
resolved "https://registry.yarnpkg.com/which/-/which-1.3.0.tgz#ff04bdfc010ee547d780bec38e1ac1c2777d253a" resolved "https://registry.yarnpkg.com/which/-/which-1.3.0.tgz#ff04bdfc010ee547d780bec38e1ac1c2777d253a"
@ -10384,7 +10395,7 @@ xss-filters@^1.2.6:
version "1.2.7" version "1.2.7"
resolved "https://registry.yarnpkg.com/xss-filters/-/xss-filters-1.2.7.tgz#59fa1de201f36f2f3470dcac5f58ccc2830b0a9a" resolved "https://registry.yarnpkg.com/xss-filters/-/xss-filters-1.2.7.tgz#59fa1de201f36f2f3470dcac5f58ccc2830b0a9a"
xtend@4.0.1, "xtend@>=4.0.0 <4.1.0-0", xtend@^4.0.0, xtend@^4.0.1, xtend@~4.0.1: "xtend@>=4.0.0 <4.1.0-0", xtend@^4.0.0, xtend@^4.0.1, xtend@~4.0.1:
version "4.0.1" version "4.0.1"
resolved "https://registry.yarnpkg.com/xtend/-/xtend-4.0.1.tgz#a5c6d532be656e23db820efb943a1f04998d63af" resolved "https://registry.yarnpkg.com/xtend/-/xtend-4.0.1.tgz#a5c6d532be656e23db820efb943a1f04998d63af"
@ -10476,7 +10487,7 @@ yargs@^11.0.0:
y18n "^3.2.1" y18n "^3.2.1"
yargs-parser "^9.0.2" yargs-parser "^9.0.2"
yargs@^4.2.0: yargs@^4.2.0, yargs@^4.7.1:
version "4.8.1" version "4.8.1"
resolved "https://registry.yarnpkg.com/yargs/-/yargs-4.8.1.tgz#c0c42924ca4aaa6b0e6da1739dfb216439f9ddc0" resolved "https://registry.yarnpkg.com/yargs/-/yargs-4.8.1.tgz#c0c42924ca4aaa6b0e6da1739dfb216439f9ddc0"
dependencies: dependencies: