mirror of
https://github.com/Llewellynvdm/nativefier.git
synced 2025-02-02 11:48:25 +00:00
Implement setting of verbose log level
This commit is contained in:
parent
7b10e16ddb
commit
e7390b9e33
@ -26,6 +26,7 @@
|
|||||||
- [[inject]](#inject)
|
- [[inject]](#inject)
|
||||||
- [[full-screen]](#full-screen)
|
- [[full-screen]](#full-screen)
|
||||||
- [[maximize]](#maximize)
|
- [[maximize]](#maximize)
|
||||||
|
- [[verbose]](#verbose)
|
||||||
- [Programmatic API](#programmatic-api)
|
- [Programmatic API](#programmatic-api)
|
||||||
|
|
||||||
## Command Line
|
## Command Line
|
||||||
@ -236,6 +237,14 @@ Makes the packaged app start in full screen.
|
|||||||
|
|
||||||
Makes the packaged app start maximized.
|
Makes the packaged app start maximized.
|
||||||
|
|
||||||
|
#### [verbose]
|
||||||
|
|
||||||
|
```
|
||||||
|
--verbose
|
||||||
|
```
|
||||||
|
|
||||||
|
Shows detailed logs in the console.
|
||||||
|
|
||||||
## Programmatic API
|
## Programmatic API
|
||||||
|
|
||||||
You can use the Nativefier programmatic API as well.
|
You can use the Nativefier programmatic API as well.
|
||||||
|
@ -45,6 +45,7 @@
|
|||||||
"gitcloud": "^0.1.0",
|
"gitcloud": "^0.1.0",
|
||||||
"hasbin": "^1.2.0",
|
"hasbin": "^1.2.0",
|
||||||
"lodash": "^4.0.0",
|
"lodash": "^4.0.0",
|
||||||
|
"loglevel": "^1.4.0",
|
||||||
"ncp": "^2.0.0",
|
"ncp": "^2.0.0",
|
||||||
"page-icon": "^0.3.0",
|
"page-icon": "^0.3.0",
|
||||||
"progress": "^1.1.8",
|
"progress": "^1.1.8",
|
||||||
|
@ -4,6 +4,7 @@ import tmp from 'tmp';
|
|||||||
import ncp from 'ncp';
|
import ncp from 'ncp';
|
||||||
import async from 'async';
|
import async from 'async';
|
||||||
import hasBinary from 'hasbin';
|
import hasBinary from 'hasbin';
|
||||||
|
import log from 'loglevel';
|
||||||
import DishonestProgress from './../helpers/dishonestProgress';
|
import DishonestProgress from './../helpers/dishonestProgress';
|
||||||
import optionsFactory from './../options/optionsMain';
|
import optionsFactory from './../options/optionsMain';
|
||||||
import iconBuild from './iconBuild';
|
import iconBuild from './iconBuild';
|
||||||
@ -107,7 +108,7 @@ function getAppPath(appPathArray) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (appPathArray.length > 1) {
|
if (appPathArray.length > 1) {
|
||||||
console.warn('Warning: This should not be happening, packaged app path contains more than one element:', appPathArray);
|
log.warn('Warning: This should not be happening, packaged app path contains more than one element:', appPathArray);
|
||||||
}
|
}
|
||||||
|
|
||||||
return appPathArray[0];
|
return appPathArray[0];
|
||||||
@ -121,7 +122,7 @@ function maybeNoIconOption(options) {
|
|||||||
const packageOptions = JSON.parse(JSON.stringify(options));
|
const packageOptions = JSON.parse(JSON.stringify(options));
|
||||||
if (options.platform === 'win32' && !isWindows()) {
|
if (options.platform === 'win32' && !isWindows()) {
|
||||||
if (!hasBinary.sync('wine')) {
|
if (!hasBinary.sync('wine')) {
|
||||||
console.warn('Wine is required to set the icon for a Windows app when packaging on non-windows platforms');
|
log.warn('Wine is required to set the icon for a Windows app when packaging on non-windows platforms');
|
||||||
packageOptions.icon = null;
|
packageOptions.icon = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import path from 'path';
|
import path from 'path';
|
||||||
|
import log from 'loglevel';
|
||||||
import helpers from './../helpers/helpers';
|
import helpers from './../helpers/helpers';
|
||||||
import iconShellHelpers from './../helpers/iconShellHelpers';
|
import iconShellHelpers from './../helpers/iconShellHelpers';
|
||||||
|
|
||||||
@ -41,7 +42,7 @@ function iconBuild(options, callback) {
|
|||||||
returnCallback();
|
returnCallback();
|
||||||
})
|
})
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
console.warn('Skipping icon conversion to .ico', error);
|
log.warn('Skipping icon conversion to .ico', error);
|
||||||
returnCallback();
|
returnCallback();
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
@ -59,7 +60,7 @@ function iconBuild(options, callback) {
|
|||||||
returnCallback();
|
returnCallback();
|
||||||
})
|
})
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
console.warn('Skipping icon conversion to .png', error);
|
log.warn('Skipping icon conversion to .png', error);
|
||||||
returnCallback();
|
returnCallback();
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
@ -71,7 +72,7 @@ function iconBuild(options, callback) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!isOSX()) {
|
if (!isOSX()) {
|
||||||
console.warn('Skipping icon conversion to .icns, conversion is only supported on OSX');
|
log.warn('Skipping icon conversion to .icns, conversion is only supported on OSX');
|
||||||
returnCallback();
|
returnCallback();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -82,7 +83,7 @@ function iconBuild(options, callback) {
|
|||||||
returnCallback();
|
returnCallback();
|
||||||
})
|
})
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
console.warn('Skipping icon conversion to .icns', error);
|
log.warn('Skipping icon conversion to .icns', error);
|
||||||
returnCallback();
|
returnCallback();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -40,6 +40,7 @@ if (require.main === module) {
|
|||||||
.option('--inject <value>', 'path to a file to be injected', collect, [])
|
.option('--inject <value>', 'path to a file to be injected', collect, [])
|
||||||
.option('--full-screen', 'if the app should always be started in full screen')
|
.option('--full-screen', 'if the app should always be started in full screen')
|
||||||
.option('--maximize', 'if the app should always be started maximized')
|
.option('--maximize', 'if the app should always be started maximized')
|
||||||
|
.option('--verbose', 'if verbose logs should be displayed')
|
||||||
.parse(process.argv);
|
.parse(process.argv);
|
||||||
|
|
||||||
if (!process.argv.slice(2).length) {
|
if (!process.argv.slice(2).length) {
|
||||||
|
@ -6,8 +6,7 @@ function inferPlatform() {
|
|||||||
return platform;
|
return platform;
|
||||||
}
|
}
|
||||||
|
|
||||||
console.warn(`Warning: Untested platform ${platform} detected, assuming linux`);
|
throw `Untested platform ${platform} detected`;
|
||||||
return 'linux';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function inferArch() {
|
function inferArch() {
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
|
import log from 'loglevel';
|
||||||
|
|
||||||
const ELECTRON_VERSIONS_URL = 'https://atom.io/download/atom-shell/index.json';
|
const ELECTRON_VERSIONS_URL = 'https://atom.io/download/atom-shell/index.json';
|
||||||
const DEFAULT_CHROME_VERSION = '47.0.2526.73';
|
const DEFAULT_CHROME_VERSION = '47.0.2526.73';
|
||||||
|
|
||||||
function getChromeVersionForElectronVersion(electronVersion, url = ELECTRON_VERSIONS_URL) {
|
function getChromeVersionForElectronVersion(electronVersion, url = ELECTRON_VERSIONS_URL) {
|
||||||
|
|
||||||
return axios.get(url, {timeout: 5000})
|
return axios.get(url, {timeout: 5000})
|
||||||
.then(response => {
|
.then(response => {
|
||||||
if (response.status !== 200) {
|
if (response.status !== 200) {
|
||||||
@ -47,7 +47,7 @@ function inferUserAgent(electronVersion, platform, url = ELECTRON_VERSIONS_URL)
|
|||||||
return getUserAgentString(chromeVersion, platform);
|
return getUserAgentString(chromeVersion, platform);
|
||||||
})
|
})
|
||||||
.catch(() => {
|
.catch(() => {
|
||||||
// console.warn(`Unable to infer chrome version for user agent, using ${DEFAULT_CHROME_VERSION}`);
|
log.warn(`Unable to infer chrome version for user agent, using ${DEFAULT_CHROME_VERSION}`);
|
||||||
return getUserAgentString(DEFAULT_CHROME_VERSION, platform);
|
return getUserAgentString(DEFAULT_CHROME_VERSION, platform);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import path from 'path';
|
import path from 'path';
|
||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
import async from 'async';
|
import async from 'async';
|
||||||
|
import log from 'loglevel';
|
||||||
import sanitizeFilenameLib from 'sanitize-filename';
|
import sanitizeFilenameLib from 'sanitize-filename';
|
||||||
|
|
||||||
import inferIcon from './../infer/inferIcon';
|
import inferIcon from './../infer/inferIcon';
|
||||||
@ -52,9 +53,16 @@ function optionsFactory(inpOptions, callback) {
|
|||||||
flashPluginDir: inpOptions.flash || null,
|
flashPluginDir: inpOptions.flash || null,
|
||||||
inject: inpOptions.inject || null,
|
inject: inpOptions.inject || null,
|
||||||
fullScreen: inpOptions.fullScreen || false,
|
fullScreen: inpOptions.fullScreen || false,
|
||||||
maximize: inpOptions.maximize || false
|
maximize: inpOptions.maximize || false,
|
||||||
|
verbose: inpOptions.verbose
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (options.verbose) {
|
||||||
|
log.setLevel('trace');
|
||||||
|
} else {
|
||||||
|
log.setLevel('error');
|
||||||
|
}
|
||||||
|
|
||||||
if (inpOptions.honest) {
|
if (inpOptions.honest) {
|
||||||
options.userAgent = null;
|
options.userAgent = null;
|
||||||
}
|
}
|
||||||
@ -91,7 +99,7 @@ function optionsFactory(inpOptions, callback) {
|
|||||||
callback();
|
callback();
|
||||||
})
|
})
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
console.warn('Cannot automatically retrieve the app icon:', error);
|
log.warn('Cannot automatically retrieve the app icon:', error);
|
||||||
callback();
|
callback();
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
@ -104,7 +112,7 @@ function optionsFactory(inpOptions, callback) {
|
|||||||
|
|
||||||
inferTitle(options.targetUrl, function(error, pageTitle) {
|
inferTitle(options.targetUrl, function(error, pageTitle) {
|
||||||
if (error) {
|
if (error) {
|
||||||
console.warn(`Unable to automatically determine app name, falling back to '${DEFAULT_APP_NAME}'`);
|
log.warn(`Unable to automatically determine app name, falling back to '${DEFAULT_APP_NAME}'`);
|
||||||
options.name = DEFAULT_APP_NAME;
|
options.name = DEFAULT_APP_NAME;
|
||||||
} else {
|
} else {
|
||||||
options.name = pageTitle.trim();
|
options.name = pageTitle.trim();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user