"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const schematics_1 = require("@angular-devkit/schematics");
const enable_1 = require("@ionic/cli/commands/integrations/enable");
const utility_1 = require("../../lib/utility");
const ionic_1 = require("../../lib/ionic");
const angular_utility_1 = require("../../lib/angular-utility");
function default_1(_options) {
    return schematics_1.chain([
        angular_utility_1.toPromiseRule(async (tree, _context) => {
            if (_options.overwrite) {
                if (tree.exists('config.xml')) {
                    tree.delete('config.xml');
                }
                ionic_1.updateIonicConfig(tree, (config) => {
                    if (config.integrations) {
                        console.info(`Deleting cordova integration from ionic config`);
                        delete config.integrations['cordova'];
                    }
                    return config;
                });
            }
            if (!tree.exists('config.xml')) {
                await utility_1.runIonicCommand((namespace) => new enable_1.IntegrationsEnableCommand(namespace), [
                    'cordova'
                ]);
                // refreshTreeFromFile(tree, 'config.xml');
            }
        })
    ]);
}
exports.default = default_1;
//# sourceMappingURL=index.js.map