Skip to content

Commit

Permalink
Merge pull request #2 from erha19/master
Browse files Browse the repository at this point in the history
  • Loading branch information
erha19 committed Jan 18, 2018
2 parents 7af3bda + 5eb1509 commit 2e4632a
Show file tree
Hide file tree
Showing 43 changed files with 2,043 additions and 1,464 deletions.
5 changes: 2 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
node_modules
/lib/
demo
coverage/
.idea/
.DS_Store
.vscode/
lib
dest
lib/
dest/
frontend/weex
4 changes: 1 addition & 3 deletions .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ frontend/devtools
.git
.vscode

src

dest
src/


10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ We advise you to use weex-toolkit which will call weex-devtool.
## usage

``` bash
$ weex xbind debugx weex-debugger
$ weex debugx [options] [vue_file|bundles_dir]
$ weex debug [options] [vue_file|bundles_dir]
```
| Options | Description |
| :--- | :--- |
Expand All @@ -42,7 +41,7 @@ $ weex debugx [options] [vue_file|bundles_dir]
#### start debugger
```
$weex debugx
$ weex debug
```
his command will start debug server and launch a chrome opening `DeviceList` page.
this page will display a QR code, you can use [Playground](https://weex.apache.org/cn/playground.html) scan it for starting debug or integrate [Weex devtools](#Integrate devtool) into your application.
Expand All @@ -67,6 +66,7 @@ This command will compile each of the files in `your/vue/path` and deploy them o

## How to access devtools in native

Android: pls refer to [Weex Devtool Android](https://github.com/weexteam/weex_devtools_android/blob/master/README.md)
- Android: pls refer to [Weex Devtool Android](https://github.com/weexteam/weex_devtools_android/blob/master/README.md)

IOS: pls refer to [Weex Devtool IOS](https://github.com/weexteam/weex-devtool-iOS/blob/master/README-zh.md)
- IOS: pls refer to [Weex Devtool IOS](https://github.com/weexteam/weex-devtool-iOS/blob/master/README-zh.md)

36 changes: 24 additions & 12 deletions bin/weex-devtool.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ const exit = require('exit');
const path = require('path');
const detect = require('detect-port');
const del = require('del');
const mlink = require('mlink');
const os = require('os');
const packageInfo = require('../package.json');
const debugRun = require('../lib/util/debug_run');
Expand All @@ -18,16 +17,20 @@ const hook = require('../lib/util/hook');
const env = require('../lib/util/env');
const hosts = require('../lib/util/hosts');
const headless = require('../lib/server/headless');
const {
LOGLEVELS,
logger
} =require('../lib/util/logger')

program
.option('-v, --version', 'display version')
.option('-h, --help', 'display help')
.option('-H --host [host]', 'set the host ip of debugger server')
.option('-V, --verbose', 'display logs of debugger server')
.option('-p, --port [port]', 'set debugger server port', '8088')
.option('-m, --manual', 'manual mode,this mode will not auto open chrome')
.option('--min', 'minimize the jsbundle')
.option('--debug', 'set log level to debug mode')
.option('--telemetry', 'upload usage data to help us improve the toolkit')
.option('--verbose', 'display all logs of debugger server')
.option('--loglevel [loglevel]', 'set log level silent|error|warn|info|log|debug', 'error')
.option('--remotedebugport [remotedebugport]', 'set the remote debug port', config.remoteDebugPort);

Expand All @@ -44,19 +47,31 @@ if (program.help === undefined) {
program.outputHelp();
exit(0);
}

// Fix tj's commander bug overwrite --version
if (program.version === undefined) {
console.log(packageInfo.version);
logger.log(packageInfo.version);
exit(0);
}

if (program.host && !hosts.isValidLocalHost(program.host)) {
console.log('[' + program.host + '] is not your local address!');
logger.error('[' + program.host + '] is not your local address!');
exit(0);
}

if (program.telemetry) {
hook.allowTarck()
}

if (program.loglevel) {
program.loglevel = program.loglevel.toLowercase && program.loglevel.toLowercase()
if(LOGLEVELS.indexOf(program.loglevel) > -1) {
logger.setLevel(program.loglevel)
}
}

if (program.verbose) {
config.logLevel = 'debug';
logger.setLevel('verbose')
}

if (program.remotedebugport) {
Expand All @@ -76,10 +91,8 @@ env.getVersionOf('node', (v) => {

// Formate config
config.ip = program.host || ip.address();
config.verbose = program.verbose;
config.manual = program.manual;
config.min = program.min;
config.logLevel = program.loglevel;

process.on('uncaughtException', (err) => {
try {
Expand All @@ -96,19 +109,19 @@ process.on('uncaughtException', (err) => {
}, 30000);
killTimer.unref();
} catch (e) {
console.log('Error Message: ', e.stack);
logger.error('Error Message: ', e.stack);
}
});

process.on('unhandledRejection', (reason, p) => {
process.on('unhandledRejection', (reason, p) => {logger
const params = Object.assign({
stack: reason,
os: os.platform(),
node: config.nodeVersion,
npm: config.npmVersion
}, config.weexVersion);
hook.record('/weex_tool.weex_debugger.app_crash', params);
console.log('Unhandled Rejection at:', p, 'reason:', reason);
logger.error(reason);
// application specific logging, throwing an error, or other logic here
});

Expand All @@ -132,7 +145,6 @@ detect(program.port).then( (open) => {
debugRun(__filename, config);
}
else {
mlink.Logger.setLogLevel(mlink.Logger.LogLevel[config.logLevel.toUpperCase()]);
// Clear files on bundleDir
try {
del.sync(path.join(__dirname, '../frontend/', config.bundleDir, '/*'), {
Expand Down
Binary file added frontend/assets/bug.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 19 additions & 1 deletion frontend/assets/debugger.css
Original file line number Diff line number Diff line change
Expand Up @@ -454,4 +454,22 @@ legend {
#prophet-menu .menu-btn:hover {
background: #ffffff;
color: #000000;
}
}
.bug_report{
display: block;
cursor: pointer;
width: 50px;
height: 50px;
border-radius: 50%;
position: fixed;
right: 20px;
bottom: 20px;
z-index: 999;
opacity: .2;
transition: all .2s ease;
background: url('./bug.png') center center no-repeat #000;
}

.bug_report:hover{
opacity: 1;
}
1 change: 1 addition & 0 deletions frontend/debug.html
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@
</div>
</div>
<div class="widget-anchor-mask tips-mask"></div>
<a class="bug_report" title="Bug Report" target="_blank" href="https://github.com/weexteam/weex-debugger/issues"></a>

<script src="lib/debug/debugger.js"></script>
<script src="lib/prophet/preprocessTracingData.js"></script>
Expand Down
Empty file added frontend/devtool_fake.html
Empty file.
Loading

0 comments on commit 2e4632a

Please sign in to comment.