"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
/*
 * Copyright (c) 2019, salesforce.com, inc.
 * All rights reserved.
 * Licensed under the BSD 3-Clause license.
 * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
 */
const path = require("path");
const i18n_1 = require("../i18n");
const utils_1 = require("../utils");
const baseGenerator_1 = require("./baseGenerator");
class AnalyticsTemplateGenerator extends baseGenerator_1.BaseGenerator {
    validateOptions() {
        utils_1.CreateUtil.checkInputs(this.options.templatename);
        const fileparts = path.resolve(this.outputdir).split(path.sep);
        if (!fileparts.includes('waveTemplates')) {
            throw new Error(i18n_1.nls.localize('MissingWaveTemplatesDir'));
        }
    }
    generate() {
        return tslib_1.__awaiter(this, void 0, void 0, function* () {
            const { templatename } = this.options;
            this.sourceRootWithPartialPath(path.join('analytics', 'waveTemplates'));
            yield this.render(this.templatePath(path.join('DefaultAnalyticsTemplate', 'dashboards', 'basicDashboard.json')), this.destinationPath(path.join(this.outputdir, templatename, 'dashboards', templatename + 'Dashboard.json')), { templateName: templatename });
            yield this.render(this.templatePath(path.join('DefaultAnalyticsTemplate', 'app-to-template-rules.json')), this.destinationPath(path.join(this.outputdir, templatename, 'app-to-template-rules.json')), {});
            yield this.render(this.templatePath(path.join('DefaultAnalyticsTemplate', 'folder.json')), this.destinationPath(path.join(this.outputdir, templatename, 'folder.json')), { templateName: templatename });
            yield this.render(this.templatePath(path.join('DefaultAnalyticsTemplate', 'releaseNotes.html')), this.destinationPath(path.join(this.outputdir, templatename, 'releaseNotes.html')), {});
            yield this.render(this.templatePath(path.join('DefaultAnalyticsTemplate', 'template-info.json')), this.destinationPath(path.join(this.outputdir, templatename, 'template-info.json')), {
                templateName: templatename,
                sourceApiVersion: this.apiversion,
            });
            yield this.render(this.templatePath(path.join('DefaultAnalyticsTemplate', 'template-to-app-rules.json')), this.destinationPath(path.join(this.outputdir, templatename, 'template-to-app-rules.json')), {});
            yield this.render(this.templatePath(path.join('DefaultAnalyticsTemplate', 'ui.json')), this.destinationPath(path.join(this.outputdir, templatename, 'ui.json')), {});
            yield this.render(this.templatePath(path.join('DefaultAnalyticsTemplate', 'variables.json')), this.destinationPath(path.join(this.outputdir, templatename, 'variables.json')), {});
        });
    }
}
exports.default = AnalyticsTemplateGenerator;
//# sourceMappingURL=analyticsTemplateGenerator.js.map