Windows: Create installer .exe file

This commit is contained in:
Feross Aboukhadijeh
2016-03-22 04:57:51 -07:00
parent a8c25d705a
commit 5eef284c6d
5 changed files with 70 additions and 7 deletions

View File

@@ -210,6 +210,7 @@ function buildDarwin (cb) {
// Create .zip file (used by the auto-updater)
var zipPath = path.join(config.ROOT_PATH, 'dist', BUILD_NAME + '.zip')
cp.execSync(`pushd ${buildPath[0]} && zip -r -y ${zipPath} ${config.APP_NAME + '.app'} && popd`)
console.log('Created OS X .zip file.')
// Create a .dmg (OS X disk image) file, for easy user installation.
var dmgOpts = {
@@ -239,6 +240,7 @@ function buildDarwin (cb) {
if (info.type === 'step-begin') console.log(info.title + '...')
})
dmg.on('finish', function (info) {
console.log('Created OS X disk image (.dmg) file.')
cb(null, buildPath)
})
})
@@ -247,7 +249,32 @@ function buildDarwin (cb) {
}
function buildWin32 (cb) {
electronPackager(Object.assign({}, all, win32), cb)
var installer = require('electron-winstaller')
electronPackager(Object.assign({}, all, win32), function (err, buildPath) {
if (err) return cb(err)
installer.createWindowsInstaller({
name: config.APP_NAME,
productName: config.APP_NAME,
title: config.APP_NAME,
exe: config.APP_NAME + '.exe',
appDirectory: buildPath[0],
outputDirectory: path.join(config.ROOT_PATH, 'dist'),
version: pkg.version,
description: config.APP_NAME,
authors: config.APP_TEAM
// iconUrl: config.APP_ICON + '.ico',
// setupIcon: config.APP_ICON + '.ico',
// certificateFile: '',
// usePackageJson: false
// loadingGif: '',
}).then(function () {
console.log('Created Windows installer.')
cb(null, buildPath)
}).catch(cb)
})
}
function buildLinux (cb) {

View File

@@ -2,13 +2,15 @@ var applicationConfigPath = require('application-config-path')
var path = require('path')
var APP_NAME = 'WebTorrent'
var APP_TEAM = 'The WebTorrent Project'
var APP_VERSION = require('./package.json').version
module.exports = {
APP_COPYRIGHT: 'Copyright © 2014-2016 The WebTorrent Project',
APP_COPYRIGHT: 'Copyright © 2014-2016 ' + APP_TEAM,
APP_FILE_ICON: path.join(__dirname, 'static', 'WebTorrentFile'),
APP_ICON: path.join(__dirname, 'static', 'WebTorrent'),
APP_NAME: APP_NAME,
APP_TEAM: APP_TEAM,
APP_VERSION: APP_VERSION,
AUTO_UPDATE_URL: 'https://webtorrent.io/app/update?version=' + APP_VERSION,

View File

@@ -1,6 +1,10 @@
module.exports = {
init
}
var log = require('./log')
module.exports = function () {
function init () {
if (process.platform === 'win32') {
var path = require('path')
var iconPath = path.join(process.resourcesPath, 'app.asar.unpacked', 'static', 'WebTorrentFile.ico')

View File

@@ -4,13 +4,44 @@ var app = electron.app
var autoUpdater = require('./auto-updater')
var config = require('../config')
var handlers = require('./handlers')
var ipc = require('./ipc')
var log = require('./log')
var menu = require('./menu')
var registerProtocolHandler = require('./register-handlers')
var shortcuts = require('./shortcuts')
var windows = require('./windows')
var argv = sliceArgv(process.argv)
if (process.platform === 'win32') {
var squirrelCmd = argv[0]
if (squirrelCmd === '--squirrel-install' || squirrelCmd === '--squirrel-updated') {
handlers.init()
// TODO:
// - Install desktop and start menu shortcuts
// - Add explorer context menus
// Always quit when done
app.quit()
}
if (squirrelCmd === '--squirrel-uninstall') {
// Undo anything we did in the --squirrel-install and --squirrel-updated handlers
// TODO: implement this
// Always quit when done
app.quit()
}
if (squirrelCmd === '--squirrel-obsolete') {
// This is called on the outgoing version of your app before we update to the new
// version - it's the opposite of --squirrel-updated
// Always quit when done
app.quit()
}
}
// Prevent multiple instances of the app from running at the same time. New instances
// signal this instance and exit.
var shouldQuit = app.makeSingleInstance(function (newArgv) {
@@ -32,8 +63,6 @@ if (shouldQuit) {
app.quit()
}
var argv = sliceArgv(process.argv)
app.on('open-file', onOpen)
app.on('open-url', onOpen)
app.on('will-finish-launching', function () {
@@ -48,7 +77,7 @@ app.on('ready', function () {
menu.init()
windows.createMainWindow()
shortcuts.init()
registerProtocolHandler()
if (process.platform !== 'win32') handlers.init()
})
app.on('ipcReady', function () {

View File

@@ -34,6 +34,7 @@
"electron-osx-sign": "^0.3.0",
"electron-packager": "^5.0.0",
"electron-prebuilt": "0.37.2",
"electron-winstaller": "^2.0.5",
"gh-release": "^2.0.2",
"path-exists": "^2.1.0",
"plist": "^1.2.0",