From 57caf91ef35836fe5c54a64c720bd46794173444 Mon Sep 17 00:00:00 2001 From: Jeromy Date: Thu, 9 Jul 2015 11:46:44 -0700 Subject: [PATCH 1/2] add a better packaging script that works on linux --- package.json | 7 ++++--- pkg.js | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 56 insertions(+), 3 deletions(-) create mode 100644 pkg.js diff --git a/package.json b/package.json index ab4eb91..7c9784c 100644 --- a/package.json +++ b/package.json @@ -25,7 +25,7 @@ }, "devDependencies": { "electron-packager": "^4.1.2", - "electron-prebuilt": "^0.27.2" + "electron-prebuilt": "0.27.2" }, "bin": { "playback": "./app.js" @@ -33,8 +33,9 @@ "scripts": { "start": "electron app.js", "dev": "electron app.js test.mp4", - "mac-bundle": "electron-packager . Playback --platform=darwin --arch=x64 --version=0.27.2 --ignore=node_modules/electron-prebuilt && cp info.plist Playback.app/Contents/Info.plist && cp icon.icns Playback.app/Contents/Resources/atom.icns", - "win-bundle": "electron-packager . Playback --platform=win32 --arch=ia32 --version=0.27.2 --icon=icon.ico" + "mac-bundle": "node pkg.js darwin x64", + "win-bundle": "node pkg.js win32 ia32", + "bundle": "node pkg.js" }, "repository": { "type": "git", diff --git a/pkg.js b/pkg.js new file mode 100644 index 0000000..e770aff --- /dev/null +++ b/pkg.js @@ -0,0 +1,52 @@ +#!/usr/bin/env node + +// from https://github.com/moose-team/friends/blob/master/pkg.js + +var os = require('os') +var pkgjson = require('./package.json') +var path = require('path') +var sh = require('shelljs') + +var appVersion = pkgjson.version +var appName = 'Playback' +var electronPackager = './node_modules/.bin/electron-packager' +var electronVersion = pkgjson.devDependencies['electron-prebuilt'] +var icon = 'icon.icns' + +if (process.argv[2] === '--all') { + // build for all platforms + var archs = ['ia32', 'x64'] + var platforms = ['linux', 'win32', 'darwin'] + + platforms.forEach(function (plat) { + archs.forEach(function (arch) { + pack(plat, arch) + }) + }) +} else if (process.argv[2] && process.argv[3]) { + pack(process.argv[2], process.argv[3]) +} else { + // build for current platform only + pack(os.platform(), os.arch()) +} + +function pack (plat, arch) { + var outputPath = path.join('.', 'pkg', appVersion, plat, arch) + + sh.exec('./node_modules/.bin/rimraf ' + outputPath) + + // there is no darwin ia32 electron + if (plat === 'darwin' && arch === 'ia32') return + + var cmd = electronPackager + ' . "' + appName + '"' + + ' --platform=' + plat + + ' --arch=' + arch + + ' --version=' + electronVersion + + ' --app-version' + appVersion + + ' --icon=' + icon + + ' --out=' + outputPath + + ' --prune' + + ' --ignore=pkg' // ignore the pkg directory or hilarity will ensue + console.log(cmd) + sh.exec(cmd) +} From edddcda3f1ec0c730a729d1be05f30a7e9a0f7c3 Mon Sep 17 00:00:00 2001 From: Jeromy Date: Fri, 10 Jul 2015 09:26:21 -0700 Subject: [PATCH 2/2] address comments from CR --- pkg.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg.js b/pkg.js index e770aff..81e9fba 100644 --- a/pkg.js +++ b/pkg.js @@ -10,7 +10,7 @@ var sh = require('shelljs') var appVersion = pkgjson.version var appName = 'Playback' var electronPackager = './node_modules/.bin/electron-packager' -var electronVersion = pkgjson.devDependencies['electron-prebuilt'] +var electronVersion = require('./node_modules/electron-prebuilt/package.json').version var icon = 'icon.icns' if (process.argv[2] === '--all') { @@ -24,7 +24,7 @@ if (process.argv[2] === '--all') { }) }) } else if (process.argv[2] && process.argv[3]) { - pack(process.argv[2], process.argv[3]) + pack(process.argv[2], process.argv[3]) } else { // build for current platform only pack(os.platform(), os.arch())