"use strict";
/**
 * Migration: Remove outdated rollup patch file
 *
 * Removes any patches/@nx+rollup+*.patch file if it exists.
 * Catches cases where the 3.6.3 migration missed patches with non-22.1.3 versions.
 * Migration succeeds whether file exists or not.
 */
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = update;
const devkit_1 = require("@nx/devkit");
const PATCH_PREFIX = '@nx+rollup+';
async function update(tree) {
    devkit_1.logger.info('🔄 Removing outdated rollup patch file...');
    const patchesDir = 'patches';
    if (!tree.exists(patchesDir)) {
        devkit_1.logger.info('ℹ️ No patches directory found');
        return;
    }
    const rollupPatches = tree
        .children(patchesDir)
        .filter((file) => file.startsWith(PATCH_PREFIX));
    if (rollupPatches.length === 0) {
        devkit_1.logger.info('ℹ️ No rollup patch file found (already removed or never existed)');
        return;
    }
    for (const patch of rollupPatches) {
        const patchPath = `${patchesDir}/${patch}`;
        tree.delete(patchPath);
        devkit_1.logger.info(`✅ Removed ${patchPath}`);
    }
}
