"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.bumpPackageVersion = void 0;
const semver_1 = require("semver");
const logger_1 = require("../../../logger");
const util_1 = require("./util");
async function bumpPackageVersion(content, currentValue, bumpVersion, packageFile) {
    logger_1.logger.debug({ bumpVersion, currentValue }, 'Checking if we should bump Chart.yaml version');
    const chartYamlContent = await (0, util_1.getSiblingChartYamlContent)(packageFile);
    const newChartVersion = (0, semver_1.inc)(currentValue, bumpVersion);
    if (!newChartVersion || chartYamlContent === null) {
        logger_1.logger.warn({
            chartYamlContent,
            currentValue,
            bumpVersion,
        }, 'Failed to bumpVersion');
        return {
            bumpedContent: content,
        };
    }
    logger_1.logger.debug({ newChartVersion });
    const bumpedContent = chartYamlContent?.replace(/^(version:\s*).*$/m, `$1${newChartVersion}`);
    if (bumpedContent === chartYamlContent) {
        logger_1.logger.debug('Version was already bumped');
    }
    else {
        logger_1.logger.debug('Bumped Chart.yaml version');
    }
    return {
        bumpedContent: content,
    };
}
exports.bumpPackageVersion = bumpPackageVersion;
//# sourceMappingURL=update.js.map