"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = update;
const devkit_1 = require("@nx/devkit");
const fs_1 = require("fs");
const path_1 = require("path");
async function update(tree) {
    devkit_1.logger.info('🔄 Updating .npmrc file');
    try {
        // Update .npmrc
        const npmrcPath = '.npmrc';
        const npmrcTemplatePath = (0, path_1.join)(__dirname, 'templates', '.npmrc.template');
        const npmrcTemplateContent = (0, fs_1.readFileSync)(npmrcTemplatePath, 'utf-8');
        const exists = tree.exists(npmrcPath);
        tree.write(npmrcPath, npmrcTemplateContent);
        if (exists) {
            devkit_1.logger.info(`✅ Updated ${npmrcPath}`);
        }
        else {
            devkit_1.logger.info(`✅ Created ${npmrcPath}`);
        }
    }
    catch (error) {
        devkit_1.logger.error(`❌ Failed to update .npmrc: ${error?.message || 'Unknown error'}`);
        throw error;
    }
}
