#!/usr/bin/env node
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
/* eslint-disable import/first -- should add module alias before use */
const path_1 = tslib_1.__importDefault(require("path"));
const module_alias_1 = tslib_1.__importDefault(require("module-alias"));
module_alias_1.default.addAliases({
    '@debug-server-next': __dirname,
});
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("@debug-server-next/@types/enum");
const { argv } = yargs_1.default
    .alias('v', 'version')
    .alias('h', 'help')
    .help()
    .version()
    .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: '0.0.0.0',
    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,
    describe: 'Auto open chrome debug page',
})
    .option('enableIOS', {
    type: 'boolean',
    default: true,
    describe: 'Enable debug iOS by chrome, by default is enabled. Notice Safari and Chrome could not work at the same time, so if you want debug iOS by safari, you must disable chrome by set false.',
})
    .option('log', {
    type: 'string',
    default: enum_1.LogLevel.Info,
    describe: 'Log level',
    choices: Object.values(enum_1.LogLevel),
})
    .option('iWDPPort', {
    type: 'number',
    default: 9000,
    describe: 'Device list port of ios_webkit_debug_proxy',
})
    .option('iWDPStartPort', {
    type: 'number',
    default: 9200,
    describe: 'Start port of ios_webkit_debug_proxy for iOS device',
})
    .option('iWDPEndPort', {
    type: 'number',
    default: 9300,
    describe: 'End port of ios_webkit_debug_proxy for iOS device',
})
    .option('env', {
    type: 'string',
    default: "hippy" /* Hippy */,
    describe: 'Debug framework',
    choices: ["hippy" /* Hippy */, "TDFCore" /* TDFCore */, "HippyTDF" /* HippyTDF */],
})
    .option('tunnel', {
    type: 'string',
    describe: 'Debug protocol transport, by default Hippy use WS, TDFCore use TCP, HippyTDF use WS',
    choices: [enum_1.DebugTunnel.WS, enum_1.DebugTunnel.TCP],
})
    .epilog(`Copyright (C) 2017-${new Date().getFullYear()} THL A29 Limited, a Tencent company.`);
global.debugAppArgv = argv;
if (debugAppArgv.help)
    yargs_1.default.showHelp().exit(0, null);
if (debugAppArgv.version)
    yargs_1.default.version().exit(0, null);
/**
 * import after global.debugAppArgv is set
 */
require("@debug-server-next/utils/aegis");
const log_1 = require("@debug-server-next/utils/log");
const app_debug_1 = require("@debug-server-next/app-debug");
const package_json_1 = require("../package.json");
require("./process-handler");
const log = new log_1.Logger('entry');
log.info('version: %s', package_json_1.version);
app_debug_1.startDebugServer();
