Add packager build script
This add lots of missing options for packaging Electron apps correctly for all platforms.
This commit is contained in:
103
bin/build.js
Executable file
103
bin/build.js
Executable file
@@ -0,0 +1,103 @@
|
|||||||
|
#!/usr/bin/env node
|
||||||
|
|
||||||
|
var cp = require('child_process')
|
||||||
|
var electronPackager = require('electron-packager')
|
||||||
|
var fs = require('fs')
|
||||||
|
var path = require('path')
|
||||||
|
var pkg = require('../package.json')
|
||||||
|
|
||||||
|
var all = {
|
||||||
|
// Build 64 bit binaries only.
|
||||||
|
arch: 'x64',
|
||||||
|
|
||||||
|
// The application source directory.
|
||||||
|
dir: path.join(__dirname, '..'),
|
||||||
|
|
||||||
|
// The release version of the application. Maps to the `ProductVersion` metadata
|
||||||
|
// property on Windows, and `CFBundleShortVersionString` on OS X.
|
||||||
|
'app-version': pkg.version,
|
||||||
|
|
||||||
|
// 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,
|
||||||
|
|
||||||
|
// 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')
|
||||||
|
'build-version': cp.execSync('git rev-parse --short HEAD').toString().replace('\n', ''),
|
||||||
|
|
||||||
|
// Pattern which specifies which files to ignore when copying files to create the
|
||||||
|
// package(s).
|
||||||
|
ignore: /^\/(dist|resources\/screenshot.png)$/,
|
||||||
|
|
||||||
|
// The base directory where the finished package(s) are created.
|
||||||
|
out: path.join(__dirname, '..', 'dist'),
|
||||||
|
|
||||||
|
// Replace an already existing output directory.
|
||||||
|
overwrite: true,
|
||||||
|
|
||||||
|
// Runs `npm prune --production` which remove the packages specified in
|
||||||
|
// "devDependencies" before starting to package the app.
|
||||||
|
prune: true,
|
||||||
|
|
||||||
|
// The Electron version with which the app is built (without the leading 'v')
|
||||||
|
version: pkg.devDependencies['electron-prebuilt']
|
||||||
|
}
|
||||||
|
|
||||||
|
var darwin = {
|
||||||
|
platform: 'darwin',
|
||||||
|
|
||||||
|
// The bundle identifier to use in the application's plist (OS X only).
|
||||||
|
'app-bundle-id': 'io.webtorrent.app',
|
||||||
|
|
||||||
|
// The application category type, as shown in the Finder via "View" -> "Arrange by
|
||||||
|
// Application Category" when viewing the Applications directory (OS X only).
|
||||||
|
'app-category-type': 'public.app-category.utilities',
|
||||||
|
|
||||||
|
// The bundle identifier to use in the application helper's plist (OS X only).
|
||||||
|
'helper-bundle-id': 'io.webtorrent.app.helper',
|
||||||
|
}
|
||||||
|
|
||||||
|
var win32 = {
|
||||||
|
platform: 'win32',
|
||||||
|
|
||||||
|
// Object hash of application metadata to embed into the executable (Windows only)
|
||||||
|
'version-string': {
|
||||||
|
|
||||||
|
// Company that produced the file.
|
||||||
|
CompanyName: 'WebTorrent',
|
||||||
|
|
||||||
|
// Copyright notices that apply to the file. This should include the full text of all
|
||||||
|
// notices, legal symbols, copyright dates, and so on.
|
||||||
|
LegalCopyright: fs.readFileSync(path.join(__dirname, '..', 'LICENSE'), 'utf8'),
|
||||||
|
|
||||||
|
// File description to be presented to users.
|
||||||
|
FileDescription: 'Streaming torrent client',
|
||||||
|
|
||||||
|
// Original name of the file, not including a path. This information enables an
|
||||||
|
// application to determine whether a file has been renamed by a user. The format of
|
||||||
|
// the name depends on the file system for which the file was created.
|
||||||
|
OriginalFilename: 'WebTorrent.exe',
|
||||||
|
|
||||||
|
// Name of the product with which the file is distributed.
|
||||||
|
ProductName: 'WebTorrent',
|
||||||
|
|
||||||
|
// Internal name of the file, if one exists, for example, a module name if the file
|
||||||
|
// is a dynamic-link library. If the file has no internal name, this string should be
|
||||||
|
// the original filename, without extension. This string is required.
|
||||||
|
InternalName: 'WebTorrent'
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
var linux = {
|
||||||
|
platform: 'linux'
|
||||||
|
}
|
||||||
|
|
||||||
|
electronPackager(Object.assign({}, all, darwin), done)
|
||||||
|
electronPackager(Object.assign({}, all, win32), done)
|
||||||
|
electronPackager(Object.assign({}, all, linux), done)
|
||||||
|
|
||||||
|
function done (err, appPath) {
|
||||||
|
if (err) console.error(err.message || err)
|
||||||
|
else console.log('Built ' + appPath)
|
||||||
|
}
|
||||||
@@ -45,7 +45,7 @@
|
|||||||
"url": "git://github.com/feross/webtorrent-app.git"
|
"url": "git://github.com/feross/webtorrent-app.git"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "electron-packager . $npm_package_productName --overwrite --out=dist --ignore='^/dist$' --prune --asar --all --version=$npm_package_devDependencies_electron_prebuilt",
|
"build": "node ./bin/build.js",
|
||||||
"debug": "DEBUG=* electron .",
|
"debug": "DEBUG=* electron .",
|
||||||
"start": "electron .",
|
"start": "electron .",
|
||||||
"test": "standard",
|
"test": "standard",
|
||||||
|
|||||||
Reference in New Issue
Block a user