Move from GitHub to Tangled
at main 3.5 kB view raw
1import dotenv from "dotenv"; 2import fs from "fs"; 3import path from "path"; 4import { fileURLToPath } from "url"; 5 6const __filename = fileURLToPath(import.meta.url); 7const __dirname = path.dirname(__filename); 8 9dotenv.config({ path: "./src/.env" }); 10 11console.log("🔍 Validating Tangled Sync Configuration...\n"); 12 13const checks: { name: string; status: boolean; message: string }[] = []; 14 15// Check .env file exists 16const envPath = path.join(__dirname, ".env"); 17const envExists = fs.existsSync(envPath); 18checks.push({ 19 name: ".env file", 20 status: envExists, 21 message: envExists ? "Found at src/.env" : "Missing! Copy src/.env.example to src/.env" 22}); 23 24// Check required environment variables 25const requiredVars = [ 26 { name: "BASE_DIR", description: "Base directory for repos" }, 27 { name: "GITHUB_USER", description: "GitHub username" }, 28 { name: "ATPROTO_DID", description: "AT Proto DID" }, 29 { name: "BLUESKY_PDS", description: "Bluesky PDS URL" }, 30 { name: "BLUESKY_USERNAME", description: "Bluesky username" }, 31 { name: "BLUESKY_PASSWORD", description: "Bluesky app password" }, 32]; 33 34requiredVars.forEach(({ name, description }) => { 35 const value = process.env[name]; 36 const exists = !!value && value.trim().length > 0; 37 checks.push({ 38 name: `${name}`, 39 status: exists, 40 message: exists ? `✓ Set (${description})` : `✗ Missing (${description})` 41 }); 42}); 43 44// Validate BASE_DIR 45const baseDir = process.env.BASE_DIR; 46if (baseDir) { 47 const baseDirExists = fs.existsSync(baseDir); 48 checks.push({ 49 name: "BASE_DIR exists", 50 status: baseDirExists, 51 message: baseDirExists ? `Directory exists: ${baseDir}` : `Directory missing: ${baseDir} (will be created)` 52 }); 53} 54 55// Validate DID format 56const did = process.env.ATPROTO_DID; 57if (did) { 58 const validDid = did.startsWith("did:plc:") || did.startsWith("did:web:"); 59 checks.push({ 60 name: "DID format", 61 status: validDid, 62 message: validDid ? "Valid DID format" : "Invalid! Should start with 'did:plc:' or 'did:web:'" 63 }); 64} 65 66// Validate PDS URL 67const pds = process.env.BLUESKY_PDS; 68if (pds) { 69 const validPds = pds.startsWith("http://") || pds.startsWith("https://"); 70 checks.push({ 71 name: "PDS URL format", 72 status: validPds, 73 message: validPds ? `Valid URL: ${pds}` : "Invalid! Should start with 'https://'" 74 }); 75} 76 77// Print results 78console.log("Configuration Check Results:\n"); 79let allPassed = true; 80 81checks.forEach((check) => { 82 const icon = check.status ? "✅" : "❌"; 83 console.log(`${icon} ${check.name}: ${check.message}`); 84 if (!check.status) allPassed = false; 85}); 86 87console.log("\n" + "=".repeat(50) + "\n"); 88 89if (allPassed) { 90 console.log("✅ All checks passed! You're ready to run:"); 91 console.log(" npm run test-atproto # Test AT Proto connection"); 92 console.log(" npm run sync # Run the full sync"); 93} else { 94 console.log("❌ Some checks failed. Please fix the issues above."); 95 console.log(" See SETUP.md for detailed instructions."); 96 process.exit(1); 97} 98 99// Additional recommendations 100console.log("\n💡 Recommendations:"); 101 102if (process.env.BLUESKY_PASSWORD && !process.env.BLUESKY_PASSWORD.includes("-")) { 103 console.log(" ⚠️ Your password looks like it might be a regular password."); 104 console.log(" Consider using an App Password from Bluesky settings."); 105} 106 107console.log(" 📚 Read SETUP.md for detailed setup instructions"); 108console.log(" 🔐 Never commit your .env file to version control"); 109console.log(" 🔑 Make sure your SSH key is added to Tangled");