Files
orangecat/scripts/db/update-supabase-key.js
Your Name 38cc4669d8 chore: comprehensive codebase cleanup and organization
- Move 100+ files from root to proper directories
  - Migration scripts → scripts/db/
  - SQL files → supabase/sql/archive/
  - Test/debug scripts → scripts/test/
  - Documentation → docs/archive/ (organized by category)
  - Shell scripts → scripts/ (organized by category)

- Fix test organization
  - Remove nested tests/unit/tests/unit/ structure
  - Consolidate test files to proper locations

- Update documentation references
  - Update migration script paths in workflow docs
  - Update scripts/README.md with moved file notes

- Delete placeholder files
  - Remove empty placeholder.ipynb

- Result: Root directory now contains only essential config files
- Result: Professional, organized codebase structure
- Result: All files in proper locations per project standards

See docs/CLEANUP_COMPLETE.md for full details.
2025-12-21 22:57:54 +01:00

49 lines
1.4 KiB
JavaScript
Executable File

#!/usr/bin/env node
const fs = require('fs');
const readline = require('readline');
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout
});
console.log('🔑 Supabase API Key Updater');
console.log('===========================');
console.log('');
rl.question('Paste your new Supabase anon public API key: ', (newKey) => {
// Validate key format
if (!newKey.startsWith('eyJ') || newKey.split('.').length !== 3) {
console.log('❌ Invalid key format. Should start with "eyJ" and contain 2 dots.');
process.exit(1);
}
// Read current .env.local
const envPath = '.env.local';
let envContent = fs.readFileSync(envPath, 'utf8');
// Create backup
const backupPath = `${envPath}.backup.${Date.now()}`;
fs.writeFileSync(backupPath, envContent);
console.log(`💾 Created backup: ${backupPath}`);
// Update the key
const keyRegex = /NEXT_PUBLIC_SUPABASE_ANON_KEY=.*/;
if (keyRegex.test(envContent)) {
envContent = envContent.replace(keyRegex, `NEXT_PUBLIC_SUPABASE_ANON_KEY="${newKey}"`);
console.log('✅ Updated existing key');
} else {
envContent += `\nNEXT_PUBLIC_SUPABASE_ANON_KEY="${newKey}"\n`;
console.log('✅ Added new key');
}
// Write back
fs.writeFileSync(envPath, envContent);
console.log('🎉 .env.local updated successfully!');
console.log('');
console.log('🔄 Restart your dev server: npm run dev');
rl.close();
});