debug-server-next
Version:
Dev server for hippy-core.
101 lines (100 loc) • 3.22 kB
JavaScript
#!/usr/bin/env node
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
/* eslint-disable import/first -- 本文件禁用,要在入口最前面注册别名,后面的 import 才能使用别名;另外要先加载 dotenv,才能创建 redis 连接 */
const path_1 = tslib_1.__importDefault(require("path"));
const module_alias_1 = tslib_1.__importDefault(require("module-alias"));
module_alias_1.default.addAliases({
'@': __dirname,
'package.json': '../package.json',
});
const yargs_1 = tslib_1.__importDefault(require("yargs"));
const dotenv_1 = tslib_1.__importDefault(require("dotenv"));
dotenv_1.default.config({ path: path_1.default.join(__dirname, './.env') });
const enum_1 = require("@/@types/enum");
const log_1 = require("@/utils/log");
const app_debug_1 = require("@/app-debug");
const package_json_1 = require("package.json");
require("./process-handler");
const { argv } = yargs_1.default
.alias('v', 'version')
.alias('h', 'help')
.alias('c', 'config')
.help()
.version()
.option('dbType', {
type: 'string',
default: enum_1.DBType.Memory,
choices: [enum_1.DBType.Memory, enum_1.DBType.Redis],
describe: 'Localhost debug server please select memory. Remote debug server please select redis.',
})
.option('entry', {
type: 'string',
default: 'dist/dev/index.bundle',
describe: 'Path of the jsbundle for debugging',
})
.option('static', {
type: 'string',
describe: 'Path of the static files such as images',
})
.option('host', {
type: 'string',
default: 'localhost',
describe: 'The host the debug server will listen to',
})
.option('port', {
type: 'number',
default: 38989,
describe: 'The port the debug server will listen to',
})
.option('open', {
type: 'boolean',
default: true,
descript: 'Auto open chrome debug page',
})
.option('verbose', {
type: 'boolean',
default: false,
describe: 'Output error details',
})
.option('config', {
type: 'string',
default: '',
describe: 'webpack config file',
})
.option('iWDPPort', {
type: 'number',
default: 9000,
describe: 'Device list port of ios_webkit_debug_proxy',
})
.option('iWDPStartPort', {
type: 'number',
default: 9200,
describe: 'Start device port of ios_webkit_debug_proxy',
})
.option('iWDPEndPort', {
type: 'number',
default: 9300,
describe: 'End device port of ios_webkit_debug_proxy',
})
.option('env', {
type: 'string',
default: "hippy" /* Hippy */,
choices: ["hippy" /* Hippy */, "voltron" /* Voltron */, "TDF" /* TDF */, "TDFCore" /* TDFCore */],
})
.option('isRemote', {
type: 'boolean',
default: false,
describe: 'Whether use remote debug',
})
.epilog(`Copyright (C) 2017-${new Date().getFullYear()} THL A29 Limited, a Tencent company.`);
const fullArgv = argv;
if (fullArgv.help)
yargs_1.default.showHelp().exit(0, null);
if (fullArgv.version)
yargs_1.default.version().exit(0, null);
global.debugAppArgv = fullArgv;
const log = new log_1.Logger('entry');
log.info('version: %s', package_json_1.version);
app_debug_1.startServer();