36 lines
1.4 KiB
JavaScript
36 lines
1.4 KiB
JavaScript
const fs = require('fs');
|
|
const path = require('path');
|
|
|
|
const scriptsDir = '/home/ubuntu/zhuiguang-ai/scripts';
|
|
const files = fs.readdirSync(scriptsDir).filter(f => f.endsWith('.mjs'));
|
|
|
|
const oldLine = 'const base = process.env.DATABASE_URL || "mysql://localhost:3306/zhuiguang_ai?charset=utf8mb4";';
|
|
const newLine = 'const base = (process.env.DATABASE_URL || "mysql://localhost:3306/zhuiguang_ai?charset=utf8mb4").replace("mysql://", "mariadb://");';
|
|
|
|
let fixed = 0;
|
|
let skipped = 0;
|
|
|
|
for (const file of files) {
|
|
const filePath = path.join(scriptsDir, file);
|
|
let content = fs.readFileSync(filePath, 'utf8');
|
|
|
|
if (content.includes('PrismaMariaDb') && content.includes(oldLine)) {
|
|
content = content.replace(oldLine, newLine);
|
|
fs.writeFileSync(filePath, content, 'utf8');
|
|
console.log('Fixed: ' + file);
|
|
fixed++;
|
|
} else if (content.includes('PrismaMariaDb')) {
|
|
console.log('Skipped (already fixed or different pattern): ' + file);
|
|
skipped++;
|
|
}
|
|
}
|
|
|
|
console.log('\nTotal fixed: ' + fixed + ', skipped: ' + skipped);
|
|
console.log('\n=== Verification ===');
|
|
// Show the fixed lines
|
|
const verifyFiles = ['task5-update-stars.mjs', 'task1-discover-tools.mjs', 'daily-news.mjs', 'task7-news-to-community.mjs'];
|
|
for (const f of verifyFiles) {
|
|
const content = fs.readFileSync(path.join(scriptsDir, f), 'utf8');
|
|
const match = content.match(/const base = .*/);
|
|
if (match) console.log(f + ': ' + match[0]);
|
|
} |