UNPKG

gmail-to-exchange365

Version:

Complete Gmail to Exchange 365 migration tool with UI - Migrate emails, attachments, and folders seamlessly

89 lines (86 loc) 3.42 kB
#!/usr/bin/env node "use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const dotenv_1 = __importDefault(require("dotenv")); const fs_1 = require("fs"); const path_1 = require("path"); const app_1 = __importDefault(require("./server/app")); // Load environment variables dotenv_1.default.config(); const PORT = process.env.PORT || 3000; // Check if .env exists, if not, create a template const envPath = (0, path_1.join)(process.cwd(), ".env"); if (!(0, fs_1.existsSync)(envPath)) { console.log("📝 Creating .env file template..."); const envTemplate = `# Google OAuth Credentials GOOGLE_CLIENT_ID=your_google_client_id_here GOOGLE_CLIENT_SECRET=your_google_client_secret_here GOOGLE_REDIRECT=http://localhost:${PORT}/google/callback # Microsoft OAuth Credentials MS_CLIENT_ID=your_ms_client_id_here MS_CLIENT_SECRET=your_ms_client_secret_here MS_TENANT_ID=common MS_REDIRECT=http://localhost:${PORT}/ms/callback # Session Configuration SESSION_SECRET=${generateRandomSecret()} # Server Configuration PORT=${PORT} `; (0, fs_1.writeFileSync)(envPath, envTemplate); console.log("✅ Created .env file. Please fill in your OAuth credentials."); console.log("📖 See SETUP.md or README.md for instructions on getting OAuth credentials."); console.log(""); } // Validate required environment variables const requiredEnvVars = [ "GOOGLE_CLIENT_ID", "GOOGLE_CLIENT_SECRET", "MS_CLIENT_ID", "MS_CLIENT_SECRET" ]; const env = dotenv_1.default.config().parsed || {}; const missingVars = requiredEnvVars.filter(varName => { const value = env[varName] || process.env[varName]; return !value || value.includes("your_") || value.includes("_here"); }); if (missingVars.length > 0) { console.log("⚠️ Missing or incomplete OAuth credentials in .env file:"); missingVars.forEach(varName => console.log(` - ${varName}`)); console.log(""); console.log("📖 Please:"); console.log(" 1. Edit the .env file with your OAuth credentials"); console.log(" 2. See SETUP.md or README.md for detailed setup instructions"); console.log(""); console.log("🔗 Quick links:"); console.log(" - Google: https://console.cloud.google.com/"); console.log(" - Microsoft: https://portal.azure.com/"); console.log(""); process.exit(1); } // Start server console.log("🚀 Starting Gmail → Exchange 365 Migrator..."); console.log(`📧 Server running on http://localhost:${PORT}`); console.log(`🌐 Open your browser and navigate to: http://localhost:${PORT}`); console.log(""); app_1.default.listen(PORT, () => { console.log("✅ Ready to migrate emails!"); console.log(""); console.log("📋 Next steps:"); console.log(" 1. Connect your Google account"); console.log(" 2. Connect your Microsoft account"); console.log(" 3. Start the migration"); console.log(""); console.log("Press Ctrl+C to stop the server"); }); function generateRandomSecret() { const chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; let result = ""; for (let i = 0; i < 32; i++) { result += chars.charAt(Math.floor(Math.random() * chars.length)); } return result; } //# sourceMappingURL=cli.js.map