"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.upperCase = upperCase;
exports.capitalize = capitalize;
exports.appModuleGenerator = appModuleGenerator;
const tslib_1 = require("tslib");
const devkit_1 = require("@nx/devkit");
const path = require("path");
function upperCase(text) {
    return text.toUpperCase();
}
function capitalize(text) {
    return text.charAt(0).toUpperCase() + text.slice(1);
}
function appModuleGenerator(tree, options) {
    return tslib_1.__awaiter(this, void 0, void 0, function* () {
        const projectRoot = `apps/${options.name}`;
        (0, devkit_1.addProjectConfiguration)(tree, options.name, {
            root: projectRoot,
            projectType: 'application',
            sourceRoot: `${projectRoot}/src`,
            targets: {},
        });
        options['upperCase'] = upperCase;
        options['className'] = capitalize(options.name);
        (0, devkit_1.generateFiles)(tree, path.join(__dirname, 'files'), projectRoot, options);
        // Rename root module to match the module name
        tree.rename(`${projectRoot}/src/app/modules/root/root.module.ts`, `${projectRoot}/src/app/modules/${options.name}/${options.name}-root.module.ts`);
        tree.rename(`${projectRoot}/src/app/modules/root`, `${projectRoot}/src/app/modules/${options.name}`);
        // Rename i18n files to match the module name
        tree.rename(`${projectRoot}/src/assets/i18n/en-US/module.json`, `${projectRoot}/src/assets/i18n/en-US/${options.name}-module.json`);
        tree.rename(`${projectRoot}/src/assets/i18n/fa-IR/module.json`, `${projectRoot}/src/assets/i18n/fa-IR/${options.name}-module.json`);
        yield (0, devkit_1.formatFiles)(tree);
    });
}
exports.default = appModuleGenerator;
//# sourceMappingURL=generator.js.map