"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.addBtpPackage = addBtpPackage;
const schematics_1 = require("@angular-devkit/schematics");
const tasks_1 = require("@angular-devkit/schematics/tasks");
const dependencies_1 = require("@schematics/angular/utility/dependencies");
/**
 * Adds the @fundamental-ngx/btp package to the package.json
 */
function addBtpPackage() {
    return (tree, ctx) => {
        const btpVersion = (0, dependencies_1.getPackageJsonDependency)(tree, '@fundamental-ngx/btp');
        if (btpVersion) {
            return tree;
        }
        const coreVersion = (0, dependencies_1.getPackageJsonDependency)(tree, '@fundamental-ngx/core');
        if (!coreVersion) {
            throw new schematics_1.SchematicsException('Could not find @fundamental-ngx/core in package.json');
        }
        (0, dependencies_1.addPackageJsonDependency)(tree, Object.assign(Object.assign({}, coreVersion), { name: '@fundamental-ngx/btp' }));
        ctx.addTask(new tasks_1.NodePackageInstallTask());
    };
}
//# sourceMappingURL=add-btp-package.js.map