"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var common_1 = require("../common");
var bundle_1 = require("./bundle");
var stats_1 = require("./stats");
function serve(args) {
    return tslib_1.__awaiter(this, void 0, void 0, function () {
        var settings, prod, out, dir, exists;
        return tslib_1.__generator(this, function (_a) {
            switch (_a.label) {
                case 0:
                    settings = args.settings;
                    prod = true;
                    out = settings.web.out(prod);
                    dir = common_1.fsPath.resolve(out.dir);
                    return [4, common_1.fs.pathExists(dir)];
                case 1:
                    exists = _a.sent();
                    if (!!exists) return [3, 3];
                    return [4, bundle_1.bundleWeb({ settings: settings, prod: prod, stats: false })];
                case 2:
                    _a.sent();
                    return [3, 4];
                case 3:
                    common_1.log.info("\uD83D\uDC49   To build a fresh distribution bundle, run:");
                    common_1.log.info("    " + common_1.log.cyan('yarn ui') + " " + common_1.log.magenta('bundle web'));
                    common_1.log.info();
                    _a.label = 4;
                case 4:
                    stats_1.stats({ settings: settings, prod: prod, target: 'web' });
                    return [4, common_1.command()
                            .addLine("cd " + dir)
                            .add("serve")
                            .run()];
                case 5:
                    _a.sent();
                    return [2];
            }
        });
    });
}
exports.serve = serve;
//# sourceMappingURL=serve.js.map