// scripts/ci/push-to-chanpaca-git.mjs // Pushes the monorepo to the user's git.chanpaca.net remote repository import { spawnSync } from 'node:child_process'; import { readFileSync, existsSync } from 'node:fs'; let user = 'yunchan'; let pass = 'ONVI2v4J#y'; let repo = 'd3ro-voice'; if (existsSync('.env')) { const envContent = readFileSync('.env', 'utf8'); for (const line of envContent.split('\n')) { const trimmed = line.trim(); if (trimmed.startsWith('GIT_USERNAME=')) user = trimmed.split('=')[1].trim(); if (trimmed.startsWith('GIT_PASSWORD=')) pass = trimmed.split('=')[1].trim(); if (trimmed.startsWith('GIT_REPO_NAME=')) repo = trimmed.split('=')[1].trim(); } } const encodedPass = encodeURIComponent(pass); const remoteUrl = `https://${user}:${encodedPass}@git.chanpaca.net/${user}/${repo}.git`; function run(cmd, args) { console.log(`ā–¶ Running: ${cmd} ${args.join(' ')}`); const res = spawnSync(cmd, args, { stdio: 'inherit', shell: process.platform === 'win32' }); if (res.status !== 0) { console.error(`Command failed with status ${res.status}`); } return res.status === 0; } console.log('--- Configuring Git Remote for git.chanpaca.net ---'); // Check if chanpaca remote exists const remoteCheck = spawnSync('git', ['remote', 'get-url', 'chanpaca'], { encoding: 'utf8' }); if (remoteCheck.status === 0) { run('git', ['remote', 'set-url', 'chanpaca', remoteUrl]); } else { run('git', ['remote', 'add', 'chanpaca', remoteUrl]); } console.log('\n--- Staging and committing all changes ---'); run('git', ['add', '-A']); run('git', ['commit', '-m', 'feat: add 10+ ad networks mediation, full CI/CD workflows, admin CRM, and production packaging']); console.log('\n--- Pushing to git.chanpaca.net (main & tags) ---'); const pushMain = run('git', ['push', '-u', 'chanpaca', 'HEAD:main', '--force']); const pushTags = run('git', ['push', 'chanpaca', '--tags']); if (pushMain) { console.log('\nšŸŽ‰ Successfully pushed full codebase to https://git.chanpaca.net/' + user + '/' + repo); } else { console.error('\nāŒ Push to git.chanpaca.net failed.'); process.exit(1); }