2016-03-25 13:50:52 +01:00
|
|
|
import log from 'loglevel';
|
2016-01-29 04:37:54 +01:00
|
|
|
|
2016-02-20 03:39:51 +01:00
|
|
|
import inferOs from './../infer/inferOs';
|
|
|
|
import normalizeUrl from './normalizeUrl';
|
|
|
|
import packageJson from './../../package.json';
|
2017-05-07 09:49:15 +02:00
|
|
|
import { ELECTRON_VERSION, PLACEHOLDER_APP_DIR } from './../constants';
|
|
|
|
import asyncConfig from './asyncConfig';
|
2016-01-29 04:37:54 +01:00
|
|
|
|
2017-04-29 16:52:12 +02:00
|
|
|
const { inferPlatform, inferArch } = inferOs;
|
2016-01-18 16:56:59 +01:00
|
|
|
|
2016-01-29 04:37:54 +01:00
|
|
|
/**
|
|
|
|
* Extracts only desired keys from inpOptions and augments it with defaults
|
2017-05-07 09:49:15 +02:00
|
|
|
* @param {Object} inpOptions
|
|
|
|
* @returns {Promise}
|
2016-01-29 04:37:54 +01:00
|
|
|
*/
|
2017-05-07 09:49:15 +02:00
|
|
|
export default function (inpOptions) {
|
2017-04-29 16:52:12 +02:00
|
|
|
const options = {
|
|
|
|
dir: PLACEHOLDER_APP_DIR,
|
|
|
|
name: inpOptions.name,
|
|
|
|
targetUrl: normalizeUrl(inpOptions.targetUrl),
|
|
|
|
platform: inpOptions.platform || inferPlatform(),
|
|
|
|
arch: inpOptions.arch || inferArch(),
|
|
|
|
electronVersion: inpOptions.electronVersion || ELECTRON_VERSION,
|
|
|
|
nativefierVersion: packageJson.version,
|
|
|
|
out: inpOptions.out || process.cwd(),
|
|
|
|
overwrite: inpOptions.overwrite,
|
|
|
|
asar: inpOptions.conceal || false,
|
|
|
|
icon: inpOptions.icon,
|
|
|
|
counter: inpOptions.counter || false,
|
|
|
|
width: inpOptions.width || 1280,
|
|
|
|
height: inpOptions.height || 800,
|
|
|
|
minWidth: inpOptions.minWidth,
|
|
|
|
minHeight: inpOptions.minHeight,
|
|
|
|
maxWidth: inpOptions.maxWidth,
|
|
|
|
maxHeight: inpOptions.maxHeight,
|
|
|
|
showMenuBar: inpOptions.showMenuBar || false,
|
|
|
|
fastQuit: inpOptions.fastQuit || false,
|
|
|
|
userAgent: inpOptions.userAgent,
|
|
|
|
ignoreCertificate: inpOptions.ignoreCertificate || false,
|
2017-07-13 18:23:07 +02:00
|
|
|
ignoreGpuBlacklist: inpOptions.ignoreGpuBlacklist || false,
|
|
|
|
enableEs3Apis: inpOptions.enableEs3Apis || false,
|
2017-04-29 16:52:12 +02:00
|
|
|
insecure: inpOptions.insecure || false,
|
|
|
|
flashPluginDir: inpOptions.flashPath || inpOptions.flash || null,
|
2017-07-05 15:07:31 +02:00
|
|
|
diskCacheSize: inpOptions.diskCacheSize || null,
|
2017-04-29 16:52:12 +02:00
|
|
|
inject: inpOptions.inject || null,
|
|
|
|
ignore: 'src',
|
|
|
|
fullScreen: inpOptions.fullScreen || false,
|
|
|
|
maximize: inpOptions.maximize || false,
|
|
|
|
hideWindowFrame: inpOptions.hideWindowFrame,
|
|
|
|
verbose: inpOptions.verbose,
|
|
|
|
disableContextMenu: inpOptions.disableContextMenu,
|
|
|
|
disableDevTools: inpOptions.disableDevTools,
|
|
|
|
crashReporter: inpOptions.crashReporter,
|
2017-05-07 09:49:15 +02:00
|
|
|
// workaround for electron-packager#375
|
2017-04-29 16:52:12 +02:00
|
|
|
tmpdir: false,
|
|
|
|
zoom: inpOptions.zoom || 1.0,
|
|
|
|
internalUrls: inpOptions.internalUrls || null,
|
|
|
|
singleInstance: inpOptions.singleInstance || false,
|
2017-08-16 16:20:43 +02:00
|
|
|
appVersion: inpOptions.appVersion,
|
|
|
|
buildVersion: inpOptions.buildVersion,
|
|
|
|
appCopyright: inpOptions.appCopyright,
|
|
|
|
versionString: inpOptions.versionString,
|
|
|
|
win32metadata: inpOptions.win32metadata || {
|
|
|
|
ProductName: inpOptions.name,
|
|
|
|
InternalName: inpOptions.name,
|
|
|
|
FileDescription: inpOptions.name,
|
|
|
|
},
|
|
|
|
processEnvs: inpOptions.processEnvs,
|
2017-10-06 01:32:48 +02:00
|
|
|
tray: inpOptions.tray || false,
|
2017-10-06 00:44:03 +02:00
|
|
|
basicAuthUsername: inpOptions.basicAuthUsername || null,
|
|
|
|
basicAuthPassword: inpOptions.basicAuthPassword || null,
|
2017-04-29 16:52:12 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
if (options.verbose) {
|
|
|
|
log.setLevel('trace');
|
|
|
|
} else {
|
|
|
|
log.setLevel('error');
|
|
|
|
}
|
|
|
|
|
|
|
|
if (options.flashPluginDir) {
|
|
|
|
options.insecure = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (inpOptions.honest) {
|
|
|
|
options.userAgent = null;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (options.platform.toLowerCase() === 'windows') {
|
|
|
|
options.platform = 'win32';
|
|
|
|
}
|
|
|
|
|
|
|
|
if (options.platform.toLowerCase() === 'osx' || options.platform.toLowerCase() === 'mac') {
|
|
|
|
options.platform = 'darwin';
|
|
|
|
}
|
|
|
|
|
|
|
|
if (options.width > options.maxWidth) {
|
|
|
|
options.width = options.maxWidth;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (options.height > options.maxHeight) {
|
|
|
|
options.height = options.maxHeight;
|
|
|
|
}
|
|
|
|
|
2017-05-07 09:49:15 +02:00
|
|
|
return asyncConfig(options);
|
2016-01-26 02:51:39 +01:00
|
|
|
}
|