"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var command_1 = require("./command");
var libs_1 = require("./libs");
var logging = require("./logging");
var defaultValue = libs_1.value.defaultValue;
function logInfo(args) {
    var target = args.target, settings = args.settings, port = args.port;
    switch (target) {
        case 'electron':
            return logElectronInfo({ settings: settings, port: port });
        case 'web':
            return logWebInfo({ settings: settings, port: port });
        default:
            libs_1.log.warn("\uD83D\uDE29  The target \"" + libs_1.log.yellow(target) + "\" is not supported.");
    }
}
exports.logInfo = logInfo;
function logElectronInfo(args) {
    var settings = args.settings;
    var pkg = settings.package;
    var formatPath = function (path) { return logging.formatPath(path, true); };
    var electron = settings.electron;
    var entry = electron.entry;
    var showPort = Boolean(args.port);
    var port = typeof args.port === 'number' ? args.port : electron.port;
    libs_1.log.info.gray("package:          " + libs_1.log.magenta(pkg.name));
    libs_1.log.info.gray("\u2022 version:        " + pkg.version);
    if (showPort) {
        libs_1.log.info.gray("\u2022 port:           " + port);
    }
    if (entry.main) {
        libs_1.log.info.gray("\u2022 entry:          " + formatPath(entry.main));
        libs_1.log.info.gray("                  " + formatPath(entry.renderer));
    }
    libs_1.log.info();
}
exports.logElectronInfo = logElectronInfo;
function logWebInfo(args) {
    var settings = args.settings;
    var pkg = settings.package;
    var formatPath = function (path) { return logging.formatPath(path, true); };
    var web = settings.web;
    var entry = web.entry;
    var showPort = Boolean(args.port);
    var port = typeof args.port === 'number' ? args.port : web.port;
    libs_1.log.info.gray("package:          " + libs_1.log.magenta(pkg.name));
    libs_1.log.info.gray("\u2022 version:        " + pkg.version);
    if (showPort) {
        libs_1.log.info.gray("\u2022 port:           " + port);
    }
    if (entry) {
        libs_1.log.info.gray("\u2022 entry:          " + formatPath(entry));
    }
    libs_1.log.info();
}
exports.logWebInfo = logWebInfo;
function toBundlerArgs(data) {
    if (data === void 0) { data = {}; }
    var sourcemaps = defaultValue(data.sourcemaps, true);
    var treeshake = defaultValue(data.treeshake, false);
    var cmd = command_1.command()
        .add('--no-source-maps', sourcemaps)
        .add('--experimental-scope-hoisting', treeshake);
    return { sourcemaps: sourcemaps, treeshake: treeshake, cmd: cmd.toString() };
}
exports.toBundlerArgs = toBundlerArgs;
//# sourceMappingURL=util.js.map