vibecodingreviewer
Version:
AI-powered code review tool with enhanced analysis
98 lines (75 loc) ⢠2.47 kB
JavaScript
import crypto from 'crypto'
/**
* Generate a license key for a customer
*/
function generateLicenseKey(customerEmail) {
const timestamp = Date.now().toString()
const data = `${customerEmail}:${timestamp}`
const hash = crypto.createHmac('sha256', 'vibecodingreviewer-secret-2024').update(data).digest('hex')
return `VIBE-${hash.substring(0, 8).toUpperCase()}-${hash.substring(8, 16).toUpperCase()}-${hash.substring(16, 24).toUpperCase()}`
}
/**
* Validate a license key
*/
function validateLicenseKey(licenseKey) {
if (!licenseKey) {
return { valid: false, reason: 'No license key provided' }
}
if (!licenseKey.startsWith('VIBE-')) {
return { valid: false, reason: 'Invalid license key format' }
}
const parts = licenseKey.split('-')
if (parts.length !== 4 || parts[0] !== 'VIBE') {
return { valid: false, reason: 'Invalid license key format' }
}
// Check if each part is 8 characters and alphanumeric
for (let i = 1; i < parts.length; i++) {
if (parts[i].length !== 8 || !/^[A-Z0-9]+$/.test(parts[i])) {
return { valid: false, reason: 'Invalid license key format' }
}
}
return { valid: true }
}
// Command line usage
if (process.argv.length < 3) {
console.log(`
š VibeCodingReviewer License Key Generator
Usage:
node generate-license.js <customer-email> # Generate new license
node generate-license.js validate <key> # Validate existing license
Examples:
node generate-license.js john@example.com
node generate-license.js validate VIBE-ABC123-DEF456-GHI789
`.trim())
process.exit(1)
}
const command = process.argv[2]
if (command === 'validate') {
const licenseKey = process.argv[3]
const validation = validateLicenseKey(licenseKey)
if (validation.valid) {
console.log('ā
License key is valid')
} else {
console.log(`ā License key is invalid: ${validation.reason}`)
}
} else {
const customerEmail = command
const licenseKey = generateLicenseKey(customerEmail)
console.log(`
š License Key Generated
Customer: ${customerEmail}
License Key: ${licenseKey}
š§ Email Template:
Subject: Your VibeCodingReviewer License Key
Hi there,
Thank you for purchasing VibeCodingReviewer!
Your license key: ${licenseKey}
Installation Instructions:
1. npm install -g vibecodingreviewer
2. export VIBECHECK_LICENSE_KEY=${licenseKey}
3. vibecheck run
Support: your-email@domain.com
Happy coding! š
`.trim())
}