const bcrypt = require('bcryptjs');

const password = process.argv[2];

if (!password) {
    console.error('Please provide a password to hash.');
    console.error('Usage: node scripts/hash-password.js <password>');
    process.exit(1);
}

const saltRounds = 10;

bcrypt.hash(password, saltRounds, (err, hash) => {
    if (err) {
        console.error('Error hashing password:', err);
        return;
    }
    console.log('Plaintext:', password);
    console.log('Bcrypt Hash:', hash);
    console.log('\n⚠️  IMPORTANT FOR DOCKER COMPOSE:');
    console.log('If you use this hash directly in docker-compose.yml, you MUST escape the $ signs:');
    console.log('Docker Hash:', hash.replace(/\$/g, '$$$$'));
    console.log('\nSet this hash as your ADMIN_PASSWORD environment variable.');
});
