From 8d74d004492a495f915ac798b0a36fcc3f1474b3 Mon Sep 17 00:00:00 2001 From: Feross Aboukhadijeh Date: Thu, 10 Mar 2016 17:37:43 -0800 Subject: [PATCH 1/8] fix asar option --- bin/package.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/package.js b/bin/package.js index 4d4b02e2..1a3ba31a 100755 --- a/bin/package.js +++ b/bin/package.js @@ -25,7 +25,7 @@ var all = { // Package the application's source code into an archive, using Electron's archive // format. Mitigates issues around long path names on Windows and slightly speeds up // require(). - asar: false, + asar: true, // The build version of the application. Maps to the FileVersion metadata property on // Windows, and CFBundleVersion on OS X. We're using the short git hash (e.g. 'e7d837e') From c0cb19fb9f69e4bd6aeccf6961e538e51f71d773 Mon Sep 17 00:00:00 2001 From: Feross Aboukhadijeh Date: Thu, 10 Mar 2016 18:48:08 -0800 Subject: [PATCH 2/8] Shrink Electron bundle size by lots of MBs! --- bin/package.js | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/package.js b/bin/package.js index 1a3ba31a..4a524753 100755 --- a/bin/package.js +++ b/bin/package.js @@ -33,7 +33,7 @@ var all = { // Pattern which specifies which files to ignore when copying files to create the // package(s). - ignore: /^\/(dist|static\/screenshot.png)$/, + ignore: /^\/dist|\/(appveyor.yml|AUTHORS|CONTRIBUTORS|bench|benchmark|benchmark\.js|bin|bower\.json|component\.json|coverage|doc|docs|docs\.mli|dragdrop\.min\.js|example|examples|example\.html|example\.js|externs|ipaddr\.min\.js|Makefile|min|minimist|perf|rusha|simplepeer\.min\.js|simplewebsocket\.min\.js|static\/screenshot\.png|test|tests|test\.js|tests\.js|webtorrent\.min\.js|ws|\.[^\/]*|.*\.md|.*\.markdown)$/, // The application name. name: config.APP_NAME, diff --git a/package.json b/package.json index c5a5df97..7c5cf634 100644 --- a/package.json +++ b/package.json @@ -49,7 +49,7 @@ "scripts": { "cleanup": "node ./bin/cleanup.js", "debug": "DEBUG=* electron .", - "package": "node ./bin/package.js", + "package": "npm prune && npm dedupe && node ./bin/package.js", "start": "electron .", "test": "standard", "update-authors": "./bin/update-authors.sh" From a2fdea29081382c6fd413a6e826722491c8908d9 Mon Sep 17 00:00:00 2001 From: Feross Aboukhadijeh Date: Thu, 10 Mar 2016 18:48:27 -0800 Subject: [PATCH 3/8] packager: add flags for building for single platform --- bin/package.js | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/bin/package.js b/bin/package.js index 4a524753..fe22ff51 100755 --- a/bin/package.js +++ b/bin/package.js @@ -109,9 +109,31 @@ var linux = { // Note: Application icon for Linux is specified via the BrowserWindow `icon` option. } -electronPackager(Object.assign({}, all, darwin), done) -electronPackager(Object.assign({}, all, win32), done) -electronPackager(Object.assign({}, all, linux), done) +var platform = process.argv[2] + +if (platform === '--darwin') { + buildDarwin() +} else if (platform === '--win32') { + buildWin32() +} else if (platform === '--linux') { + buildLinux() +} else { + buildDarwin() + buildWin32() + buildLinux() +} + +function buildDarwin () { + electronPackager(Object.assign({}, all, darwin), done) +} + +function buildWin32 () { + electronPackager(Object.assign({}, all, win32), done) +} + +function buildLinux () { + electronPackager(Object.assign({}, all, linux), done) +} function done (err, appPath) { if (err) console.error(err.message || err) From 63598cf0ab4aa4ef462f3aa1ef2261b5db70366b Mon Sep 17 00:00:00 2001 From: Feross Aboukhadijeh Date: Thu, 10 Mar 2016 18:48:36 -0800 Subject: [PATCH 4/8] add "npm run size" command --- package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/package.json b/package.json index 7c5cf634..d778b731 100644 --- a/package.json +++ b/package.json @@ -50,6 +50,7 @@ "cleanup": "node ./bin/cleanup.js", "debug": "DEBUG=* electron .", "package": "npm prune && npm dedupe && node ./bin/package.js", + "size": "npm run package -- --darwin && du -ch dist/WebTorrent-darwin-x64 | grep total", "start": "electron .", "test": "standard", "update-authors": "./bin/update-authors.sh" From d90cede3bd0950be65a40d5e5289740f844c26e0 Mon Sep 17 00:00:00 2001 From: Feross Aboukhadijeh Date: Thu, 10 Mar 2016 19:10:07 -0800 Subject: [PATCH 5/8] build packages serially --- bin/package.js | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/bin/package.js b/bin/package.js index fe22ff51..53aa9b05 100755 --- a/bin/package.js +++ b/bin/package.js @@ -118,24 +118,24 @@ if (platform === '--darwin') { } else if (platform === '--linux') { buildLinux() } else { - buildDarwin() - buildWin32() - buildLinux() + // Build all + buildDarwin(() => buildWin32(() => buildLinux())) } -function buildDarwin () { - electronPackager(Object.assign({}, all, darwin), done) +function buildDarwin (cb) { + electronPackager(Object.assign({}, all, darwin), done.bind(null, cb)) } -function buildWin32 () { - electronPackager(Object.assign({}, all, win32), done) +function buildWin32 (cb) { + electronPackager(Object.assign({}, all, win32), done.bind(null, cb)) } -function buildLinux () { - electronPackager(Object.assign({}, all, linux), done) +function buildLinux (cb) { + electronPackager(Object.assign({}, all, linux), done.bind(null, cb)) } -function done (err, appPath) { +function done (cb, err, appPath) { if (err) console.error(err.message || err) else console.log('Built ' + appPath) + if (cb) cb() } From f21d7dd732ec492270095f8d7f574dbcdbecb53d Mon Sep 17 00:00:00 2001 From: Feross Aboukhadijeh Date: Thu, 10 Mar 2016 19:11:49 -0800 Subject: [PATCH 6/8] Move webtorrent icons into static/ --- README.md | 2 +- bin/package.js | 4 ++-- config.js | 2 +- WebTorrent.icns => static/WebTorrent.icns | Bin WebTorrent.ico => static/WebTorrent.ico | Bin WebTorrent.png => static/WebTorrent.png | Bin 6 files changed, 4 insertions(+), 4 deletions(-) rename WebTorrent.icns => static/WebTorrent.icns (100%) rename WebTorrent.ico => static/WebTorrent.ico (100%) rename WebTorrent.png => static/WebTorrent.png (100%) diff --git a/README.md b/README.md index 2a892ffb..edfdc20a 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -#   WebTorrent.app +#   WebTorrent.app [![Gitter][webtorrent-gitter-image]][webtorrent-gitter-url] [![Travis Build][webtorrent-app-travis-image]][webtorrent-app-travis-url] diff --git a/bin/package.js b/bin/package.js index 53aa9b05..ae40b006 100755 --- a/bin/package.js +++ b/bin/package.js @@ -66,7 +66,7 @@ var darwin = { 'helper-bundle-id': 'io.webtorrent.app.helper', // Application icon. - icon: path.join(__dirname, '..', 'WebTorrent.icns') + icon: path.join(__dirname, '..', 'static', 'WebTorrent.icns') } var win32 = { @@ -100,7 +100,7 @@ var win32 = { }, // Application icon. - icon: path.join(__dirname, '..', 'WebTorrent.ico') + icon: path.join(__dirname, '..', 'static', 'WebTorrent.ico') } var linux = { diff --git a/config.js b/config.js index 39ac4c2a..311e0e90 100644 --- a/config.js +++ b/config.js @@ -2,7 +2,7 @@ var path = require('path') module.exports = { APP_NAME: 'WebTorrent', - APP_ICON: path.join(__dirname, 'WebTorrent.png'), + APP_ICON: path.join(__dirname, 'static', 'WebTorrent.png'), INDEX: 'file://' + path.join(__dirname, 'renderer', 'index.html'), SOUND_ADD: 'file://' + path.join(__dirname, 'static', 'sound', 'add.wav'), SOUND_DELETE: 'file://' + path.join(__dirname, 'static', 'sound', 'delete.wav'), diff --git a/WebTorrent.icns b/static/WebTorrent.icns similarity index 100% rename from WebTorrent.icns rename to static/WebTorrent.icns diff --git a/WebTorrent.ico b/static/WebTorrent.ico similarity index 100% rename from WebTorrent.ico rename to static/WebTorrent.ico diff --git a/WebTorrent.png b/static/WebTorrent.png similarity index 100% rename from WebTorrent.png rename to static/WebTorrent.png From e03ed8c3742e790b7a6e13e0923aad435464207f Mon Sep 17 00:00:00 2001 From: Feross Aboukhadijeh Date: Thu, 10 Mar 2016 19:12:40 -0800 Subject: [PATCH 7/8] fix build --- bin/package.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/package.js b/bin/package.js index ae40b006..b1e71c97 100755 --- a/bin/package.js +++ b/bin/package.js @@ -33,7 +33,7 @@ var all = { // Pattern which specifies which files to ignore when copying files to create the // package(s). - ignore: /^\/dist|\/(appveyor.yml|AUTHORS|CONTRIBUTORS|bench|benchmark|benchmark\.js|bin|bower\.json|component\.json|coverage|doc|docs|docs\.mli|dragdrop\.min\.js|example|examples|example\.html|example\.js|externs|ipaddr\.min\.js|Makefile|min|minimist|perf|rusha|simplepeer\.min\.js|simplewebsocket\.min\.js|static\/screenshot\.png|test|tests|test\.js|tests\.js|webtorrent\.min\.js|ws|\.[^\/]*|.*\.md|.*\.markdown)$/, + ignore: /^\/dist|\/(appveyor.yml|AUTHORS|CONTRIBUTORS|bench|benchmark|benchmark\.js|bin|bower\.json|component\.json|coverage|doc|docs|docs\.mli|dragdrop\.min\.js|example|examples|example\.html|example\.js|externs|ipaddr\.min\.js|Makefile|min|minimist|perf|rusha|simplepeer\.min\.js|simplewebsocket\.min\.js|static\/screenshot\.png|test|tests|test\.js|tests\.js|webtorrent\.min\.js|\.[^\/]*|.*\.md|.*\.markdown)$/, // The application name. name: config.APP_NAME, From 8dfd9fe788de83ac4f383d9003610d5a8b2901aa Mon Sep 17 00:00:00 2001 From: Feross Aboukhadijeh Date: Thu, 10 Mar 2016 19:13:40 -0800 Subject: [PATCH 8/8] remove stray console.log --- renderer/index.js | 1 - 1 file changed, 1 deletion(-) diff --git a/renderer/index.js b/renderer/index.js index 848eb3af..d4412518 100644 --- a/renderer/index.js +++ b/renderer/index.js @@ -615,7 +615,6 @@ function onWarning (err) { } function showDoneNotification (torrent) { - console.log(state.window.isFocused) if (state.window.isFocused) return var notif = new window.Notification('Download Complete', {