chore: scripts Dokploy/BPS (cron secret, Ads MCC, sync y probes)

Incluye utilidades de ops para CRON_SECRET, login customer Google Ads, sync de seguimiento BPS y probes de conexiones.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
4Ventures
2026-09-29 16:48:44 +02:00
parent 8c5acb626f
commit 1a58af129d
17 changed files with 2913 additions and 0 deletions

View File

@@ -0,0 +1,33 @@
import { config } from 'dotenv';
import { resolve } from 'path';
import { writeFileSync, mkdirSync } from 'fs';
config({ path: resolve(process.cwd(), '.env.local') });
import { getValidAccessToken } from '../src/lib/google-drive';
const ID = '1YPcHBjioiHHQy22Q2xevkvUqA5jMq87v6IviV7VTL2s';
const OCT = '1-Zss1suBLDxAgqUuP9DrJYWHiicyin8aQqMOTIIekAg';
async function exportXlsx(token: string, id: string, path: string) {
const mime =
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet';
const r = await fetch(
`https://www.googleapis.com/drive/v3/files/${id}/export?mimeType=${encodeURIComponent(mime)}`,
{ headers: { Authorization: `Bearer ${token}` } }
);
if (!r.ok) throw new Error(`${id} ${r.status} ${(await r.text()).slice(0, 300)}`);
const buf = Buffer.from(await r.arrayBuffer());
writeFileSync(path, buf);
console.log('wrote', path, buf.length);
}
async function main() {
const token = await getValidAccessToken();
mkdirSync('/tmp/bps-cal', { recursive: true });
await exportXlsx(token, ID, '/tmp/bps-cal/bps-calendario.xlsx');
await exportXlsx(token, OCT, '/tmp/bps-cal/bps-octubre.xlsx');
}
main().catch((e) => {
console.error(e);
process.exit(1);
});