import { execSync } from 'child_process'; const TOKEN = '53c0cc31a6cb27901dd29f1215d4ee5fe5064a19'; const DOMAIN = 'forgejo.seureview.com.br'; const USER = 'marciobever'; const REPO = 'festa-magica-ia'; async function deploy() { try { console.log(`Acessando API do Forgejo (${DOMAIN})...`); const createRes = await fetch(`https://${DOMAIN}/api/v1/user/repos`, { method: 'POST', headers: { 'Authorization': `token ${TOKEN}`, 'Content-Type': 'application/json' }, body: JSON.stringify({ name: REPO, private: true, description: 'Landing Page Festa Mágica IA (Gerada no AI Studio)' }) }); if (!createRes.ok) { const errorText = await createRes.text(); console.log(`Aviso ao criar repo (Provavelmente já existe): ${errorText}`); } else { console.log('✅ Repositório criado com sucesso.'); } console.log('\nConfigurando Git local e preparando commit...'); try { execSync('rm -rf .git'); } catch(e){} execSync('git init', { stdio: 'inherit' }); execSync('git config user.name "AI Studio Assistant"', { stdio: 'inherit' }); execSync('git config user.email "macrolojauk@gmail.com"', { stdio: 'inherit' }); execSync('git add .', { stdio: 'inherit' }); try { execSync('git commit -m "Deploy automático da Landing Page"', { stdio: 'inherit' }); } catch (e) { console.log('Nada para commitar.'); } execSync('git branch -M main', { stdio: 'inherit' }); // Montamos a URL autenticada usando as credenciais providenciadas const remoteUrl = `https://${USER}:${TOKEN}@${DOMAIN}/${USER}/${REPO}.git`; execSync(`git remote add origin ${remoteUrl}`, { stdio: 'inherit' }); console.log('\nFazendo push do código (Forçando atualização no main)...'); execSync('git push -u origin main --force', { stdio: 'inherit' }); console.log(`\n🎉 Deploy concluído com sucesso!`); console.log(`🔗 URL do Repositório: https://${DOMAIN}/${USER}/${REPO}`); } catch (error: any) { console.error('\n❌ Ocorreu um erro no script de deploy:', error.message); if (error.stdout) console.error('STDOUT:', error.stdout.toString()); if (error.stderr) console.error('STDERR:', error.stderr.toString()); } } deploy();