From 516d61e157060d460aadd99b556153b703ec4f64 Mon Sep 17 00:00:00 2001 From: Sean Yesmunt Date: Fri, 20 Jul 2018 16:43:49 -0400 Subject: [PATCH 1/6] fix clean build --- build/downloadDaemon.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/downloadDaemon.js b/build/downloadDaemon.js index 11b0b5ba2..e25fb945e 100644 --- a/build/downloadDaemon.js +++ b/build/downloadDaemon.js @@ -19,7 +19,7 @@ const downloadDaemon = targetPlatform => if (currentPlatform === 'win32') currentPlatform = 'windows'; const daemonPlatform = targetPlatform || currentPlatform; - + const tmpZipPath = path.join(__dirname,'daemon.zip'); const daemonURL = daemonURLTemplate .replace(/DAEMONVER/g, daemonVersion) .replace(/OSNAME/g, daemonPlatform); -- 2.45.2 From 80f75096b66864e5f81bbc0b5c86c72c12aa4461 Mon Sep 17 00:00:00 2001 From: Sean Yesmunt Date: Sat, 21 Jul 2018 04:46:14 -0400 Subject: [PATCH 2/6] create dist folder if it doesn't exist --- build/downloadDaemon.js | 66 +++++++++++++++++++++++++++-------------- 1 file changed, 43 insertions(+), 23 deletions(-) diff --git a/build/downloadDaemon.js b/build/downloadDaemon.js index e25fb945e..964f7a6c0 100644 --- a/build/downloadDaemon.js +++ b/build/downloadDaemon.js @@ -19,34 +19,54 @@ const downloadDaemon = targetPlatform => if (currentPlatform === 'win32') currentPlatform = 'windows'; const daemonPlatform = targetPlatform || currentPlatform; - const tmpZipPath = path.join(__dirname,'daemon.zip'); + const tmpZipPath = path.join(__dirname, '..', 'dist', 'daemon.zip'); const daemonURL = daemonURLTemplate .replace(/DAEMONVER/g, daemonVersion) .replace(/OSNAME/g, daemonPlatform); const tmpZipPath = 'dist/daemon.zip'; - console.log('\x1b[34minfo\x1b[0m Downloading daemon...'); - axios - .request({ - responseType: 'arraybuffer', - url: daemonURL, - method: 'get', - headers: { - 'Content-Type': 'application/zip', - }, - }) - .then( - result => - new Promise((newResolve, newReject) => { - fs.writeFile(tmpZipPath, result.data, error => { - if (error) return newReject(error); - return newResolve(); - }); - }) - ) - .then(() => del(`${daemonDir}/${daemonFileName}*`)) - .then(() => - decompress(tmpZipPath, daemonDir, { + + // If a daemon and daemon.ver exists, check to see if it matches the current daemon version + const hasDaemonDownloaded = fs.existsSync(daemonFilePath); + const hasDaemonVersion = fs.existsSync(daemonVersionPath); + let downloadedDaemonVersion; + if (hasDaemonVersion) { + downloadedDaemonVersion = fs.readFileSync(daemonVersionPath, "utf8"); + } + + if (hasDaemonDownloaded && hasDaemonVersion && downloadedDaemonVersion === daemonVersion) { + console.log('\x1b[34minfo\x1b[0m Daemon already downloaded'); + resolve('Done'); + return; + } else { + console.log('\x1b[34minfo\x1b[0m Downloading daemon...'); + axios + .request({ + responseType: 'arraybuffer', + url: daemonURL, + method: 'get', + headers: { + 'Content-Type': 'application/zip', + }, + }) + .then( + result => + new Promise((newResolve, newReject) => { + const distPath = path.join(__dirname, '..', 'dist'); + const hasDistFolder = fs.existsSync(distPath); + + if (!hasDistFolder) { + fs.mkdirSync(distPath); + } + + fs.writeFile(tmpZipPath, result.data, error => { + if (error) return newReject(error); + return newResolve(); + }); + }) + ) + .then(() => del(`${daemonFilePath}*`)) + .then(() => decompress(tmpZipPath, daemonDir, { filter: file => path.basename(file.path).replace(path.extname(file.path), '') === daemonFileName, }) -- 2.45.2 From fc3c7fd94d149982eb923b04dbcf7a1b5137023d Mon Sep 17 00:00:00 2001 From: Sean Yesmunt Date: Sat, 21 Jul 2018 04:51:13 -0400 Subject: [PATCH 3/6] don't delete dist folder --- build/downloadDaemon.js | 11 ++++++++++- static/daemon/.gitkeep | 0 2 files changed, 10 insertions(+), 1 deletion(-) delete mode 100644 static/daemon/.gitkeep diff --git a/build/downloadDaemon.js b/build/downloadDaemon.js index 964f7a6c0..29dbe049f 100644 --- a/build/downloadDaemon.js +++ b/build/downloadDaemon.js @@ -68,7 +68,16 @@ const downloadDaemon = targetPlatform => .then(() => del(`${daemonFilePath}*`)) .then(() => decompress(tmpZipPath, daemonDir, { filter: file => - path.basename(file.path).replace(path.extname(file.path), '') === daemonFileName, + path.basename(file.path) === daemonFileName, + })) + .then(() => { + console.log('\x1b[32msuccess\x1b[0m Daemon downloaded!'); + if (hasDaemonVersion) { + del(daemonVersionPath); + } + + fs.writeFileSync(daemonVersionPath, daemonVersion, "utf8") + resolve('Done'); }) ) .then(() => { diff --git a/static/daemon/.gitkeep b/static/daemon/.gitkeep deleted file mode 100644 index e69de29bb..000000000 -- 2.45.2 From 7b6662fa3f1d59b39aa9fe96046a29160d009a32 Mon Sep 17 00:00:00 2001 From: Sean Yesmunt Date: Sat, 21 Jul 2018 05:26:47 -0400 Subject: [PATCH 4/6] remove macos from checkPlatform --- build/checkDaemonPlatform.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/build/checkDaemonPlatform.js b/build/checkDaemonPlatform.js index 4ae40a7c4..5bc39e095 100644 --- a/build/checkDaemonPlatform.js +++ b/build/checkDaemonPlatform.js @@ -12,11 +12,9 @@ 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( -- 2.45.2 From a46bfe4b17cc84b2fc4412b935cf226382cc8dfc Mon Sep 17 00:00:00 2001 From: Sean Yesmunt Date: Sat, 21 Jul 2018 05:55:32 -0400 Subject: [PATCH 5/6] cleanup --- build/downloadDaemon.js | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/build/downloadDaemon.js b/build/downloadDaemon.js index 29dbe049f..8f84d33aa 100644 --- a/build/downloadDaemon.js +++ b/build/downloadDaemon.js @@ -1,6 +1,6 @@ /* eslint-disable no-console,import/no-extraneous-dependencies,import/no-commonjs */ const path = require('path'); -const fs = require('fs-path'); +const fs = require('fs'); const packageJSON = require('../package.json'); const axios = require('axios'); const decompress = require('decompress'); @@ -18,12 +18,13 @@ const downloadDaemon = targetPlatform => if (currentPlatform === 'darwin') currentPlatform = 'macos'; if (currentPlatform === 'win32') currentPlatform = 'windows'; + const daemonFilePath = path.join(daemonDir, daemonFileName); + const daemonVersionPath = path.join(__dirname, 'daemon.ver'); const daemonPlatform = targetPlatform || currentPlatform; const tmpZipPath = path.join(__dirname, '..', 'dist', 'daemon.zip'); const daemonURL = daemonURLTemplate .replace(/DAEMONVER/g, daemonVersion) .replace(/OSNAME/g, daemonPlatform); - const tmpZipPath = 'dist/daemon.zip'; // If a daemon and daemon.ver exists, check to see if it matches the current daemon version @@ -63,7 +64,7 @@ const downloadDaemon = targetPlatform => if (error) return newReject(error); return newResolve(); }); - }) + }) ) .then(() => del(`${daemonFilePath}*`)) .then(() => decompress(tmpZipPath, daemonDir, { @@ -79,17 +80,13 @@ const downloadDaemon = targetPlatform => fs.writeFileSync(daemonVersionPath, daemonVersion, "utf8") resolve('Done'); }) - ) - .then(() => { - console.log('\x1b[32msuccess\x1b[0m Daemon downloaded!'); - resolve(true); - }) - .catch(error => { - console.error( - `\x1b[31merror\x1b[0m Daemon download failed due to: \x1b[35m${error}\x1b[0m` - ); - reject(error); - }); + .catch(error => { + console.error( + `\x1b[31merror\x1b[0m Daemon download failed due to: \x1b[35m${error}\x1b[0m` + ); + reject(error); + }) + }; }); module.exports = downloadDaemon; -- 2.45.2 From 0a5d071cf3d98a880c20f5636b5186c87693da01 Mon Sep 17 00:00:00 2001 From: Sean Yesmunt Date: Mon, 23 Jul 2018 11:49:42 -0400 Subject: [PATCH 6/6] add target for windows --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index b200a1689..da95738cf 100644 --- a/.travis.yml +++ b/.travis.yml @@ -33,7 +33,7 @@ script: - | if [ "$TARGET" == "windows" ]; then docker run --rm \ - --env-file <(env | grep -iE 'DEBUG|NODE_|ELECTRON_|YARN_|NPM_|CI|CIRCLE|TRAVIS|APPVEYOR_|CSC_|GH_|GITHUB_|BT_|AWS_|STRIP|BUILD_') \ + --env-file <(env | grep -iE 'DEBUG|TARGET|NODE_|ELECTRON_|YARN_|NPM_|CI|CIRCLE|TRAVIS|APPVEYOR_|CSC_|GH_|GITHUB_|BT_|AWS_|STRIP|BUILD_') \ -v ${PWD}:/project \ electronuserland/builder:wine \ /bin/bash -c "yarn --link-duplicates --pure-lockfile && yarn build --win --publish onTag"; -- 2.45.2