import fs from "fs";

const rootPkg = JSON.parse(fs.readFileSync("./package.json"), "utf-8");
const version = rootPkg.version;

const targets = [
    "./lib/module/package.json",
    "./lib/typescript/package.json"
];

targets.forEach(target => {
    if (fs.existsSync(target)) {
        const pkg = JSON.parse(fs.readFileSync(target, "utf-8"));

        pkg.version = version;

        fs.writeFileSync(target, JSON.stringify(pkg, null, 2));
        console.log(`✅ ${target} güncellendi: version ${version} eklendi.`);
    }
});

fs.writeFileSync("./lib/package.json", JSON.stringify({
    version: version,
    type: "module"
}, null, 4));
console.log(`✅ Main package.json eklendi.`);
