"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = update;
const devkit_1 = require("@nx/devkit");
const has_gradle_plugin_1 = require("../../utils/has-gradle-plugin");
const gradle_project_graph_plugin_utils_1 = require("../../generators/init/gradle-project-graph-plugin-utils");
const version_catalog_ast_utils_1 = require("../../utils/version-catalog-ast-utils");
/* Change the plugin version to 0.1.5
 */
async function update(tree) {
    const nxJson = (0, devkit_1.readNxJson)(tree);
    if (!nxJson) {
        return;
    }
    if (!(0, has_gradle_plugin_1.hasGradlePlugin)(tree)) {
        return;
    }
    const gradlePluginVersionToUpdate = '0.1.5';
    // Update version in version catalogs using AST-based approach to preserve formatting
    await (0, version_catalog_ast_utils_1.updateNxPluginVersionInCatalogsAst)(tree, gradlePluginVersionToUpdate);
    // Then update in build.gradle(.kts) files
    await (0, gradle_project_graph_plugin_utils_1.addNxProjectGraphPlugin)(tree, gradlePluginVersionToUpdate);
}
