"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const commander_1 = require("commander");
const utils_1 = require("../../utils");
const paths_1 = require("../../utils/paths");
const templates_1 = require("../../utils/templates");
const watch_1 = require("./watch");
function getNamespace() {
    return utils_1.CONFIGS.GRUND.config.namespace;
}
function getCurrentTemplates() {
    return utils_1.CONFIGS.GRUND.config.templates;
}
function getOpts() {
    const templatesDir = paths_1.GRUND_TEMPLATES_DIR;
    const targetDir = paths_1.GRUND_TEMPLATE_DIR;
    const namespace = getNamespace();
    return templates_1.createGrundTemplateOpts({ mode: 'dev', templatesDir, targetDir, namespace });
}
commander_1.program
    .command('dev:templates')
    .option('-w, --watch', 'Watch for templates file changes', false)
    .option('-r, --reset', 'Delete the template files before generating new ones', false)
    .description('Development server for the templates. Only for internal grund development.')
    .action(async (cmd) => {
    const { watch, reset } = cmd;
    const opts = getOpts();
    const templateNames = getCurrentTemplates();
    const templates = templates_1.getTemplatesFromNames(templateNames, opts);
    if (reset) {
        utils_1.rimraf.sync(paths_1.GRUND_TEMPLATE_DIR);
    }
    await templates_1.generateTemplates(templates, opts);
    if (watch) {
        watch_1.watchTemplates(templates, opts);
    }
});
//# sourceMappingURL=index.js.map