"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.FrontHandler = void 0;
/* eslint-disable unicorn/no-static-only-class */
const template_generator_1 = require("../utils/template-generator");
const front_1 = require("../functions/front");
const types_1 = require("../types");
const common_1 = require("../functions/common");
const store_1 = require("../store");
const fs = require("node:fs");
const path = require("node:path");
class FrontHandler {
    static async new(newFrontCommandState) {
        if (!newFrontCommandState.appName)
            throw new Error('To create front application is required app name');
        // create directory for dashboard
        if (!fs.existsSync(newFrontCommandState.appName))
            fs.mkdirSync(newFrontCommandState.appName, { recursive: true });
        await template_generator_1.TemplateGenerator.generateStaticContents(newFrontCommandState.command, types_1.TemplateElement.FRONT_APPLICATION, path.join(newFrontCommandState.appName), '.', {
            verbose: newFrontCommandState.flags.verbose,
            force: newFrontCommandState.flags.force,
            useTemplateEngine: false,
        });
    }
    static async generateModule(generateCommandState) {
        // generate dashboard module translations empty
        await (0, front_1.generateTranslationFiles)(generateCommandState);
        // generate dashboard module files
        await (0, front_1.generateModuleFiles)(generateCommandState);
        // create references, write imports in ts files
        (0, front_1.addReferences)(generateCommandState);
        (0, common_1.generateJsonLockFile)(generateCommandState, store_1.GlobalState.hasValue('lockFiles') ? store_1.GlobalState.getValue('lockFiles') : []);
    }
    static async addPackage(addCommandState) {
        await (0, front_1.addPackageFiles)(addCommandState);
    }
}
exports.FrontHandler = FrontHandler;
