#!/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') });
require("@debug-server-next/utils/report");
const app_dev_1 = require("@debug-server-next/app-dev");
const webpack_1 = require("@debug-server-next/utils/webpack");
const log_1 = require("@debug-server-next/utils/log");
const package_json_1 = require("../package.json");
require("./process-handler");
const log_2 = require("@debug-server-next/logger/log");
const { argv } = yargs_1.default
    .alias('v', 'version')
    .describe('v', 'show version information ')
    .alias('h', 'help')
    .alias('c', 'config')
    .demand('config')
    .help()
    .version()
    .option('config', {
    type: 'string',
    default: '',
    describe: 'webpack config file ',
})
    .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);
const log = new log_1.Logger('entry');
log.info('version: %s', package_json_1.version);
(async () => {
    log.info('start dev argv: %j', fullArgv);
    (0, log_2.info)('es dev running....');
    const webpackConfig = await (0, webpack_1.getWebpackConfig)(fullArgv.config);
    (0, app_dev_1.webpack)(webpackConfig);
})();
