"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const cli_core_1 = require("@igniteui/cli-core");
function addHomeHeaderStyles(host) {
    const homeCss = "src/app/home/home.component.css";
    if (host.exists(homeCss)) {
        let content = host.read(homeCss).toString();
        content +=
            `
h1 {
  font-size: 3rem;
  font-weight: 600;
  color: rgba(0, 0, 0, .74);
}

h3 {
  font-size: 1.75rem;
  font-weight: 600;
}
`;
        host.overwrite(homeCss, content);
    }
}
function removeGridForRoot(host) {
    const appModulePath = "src/app/app.module.ts";
    if (host.exists(appModulePath)) {
        let content = host.read(appModulePath).toString();
        if (content.indexOf("IgxGridModule.forRoot()") !== -1) {
            content = content.replace(`IgxGridModule.forRoot()`, `IgxGridModule`);
            host.overwrite(appModulePath, content);
        }
    }
}
function updateConfig(host) {
    const configPath = "ignite-ui-cli.json";
    if (host.exists(configPath)) {
        let overwrite = false;
        let content = host.read(configPath).toString();
        const config = JSON.parse(content);
        if (config.project.framework === "angular"
            && config.project.projectType === "igx-ts"
            && !config.project.projectTemplate) {
            config.project.projectTemplate = "side-nav";
            overwrite = true;
        }
        if (!config.version) {
            config.version = "3.0.0";
            overwrite = true;
        }
        if (overwrite) {
            content = JSON.stringify(config, null, 4) + "\n";
            host.overwrite(configPath, content);
        }
    }
}
function default_1() {
    return (host, context) => {
        context.logger.info("Updating project to Ignite UI CLI 3.0.0");
        (0, cli_core_1.addClassToBody)(host, "ig-typography");
        addHomeHeaderStyles(host);
        removeGridForRoot(host);
        updateConfig(host);
    };
}
exports.default = default_1;
