概览页增加表格统计

This commit is contained in:
2026-08-02 11:16:51 +08:00
parent 6a23e79f4c
commit 50ba6e9c56
11 changed files with 1618 additions and 5 deletions
@@ -0,0 +1,27 @@
const fs = require('fs');
const path = require('path');
const apiRoot = path.join(__dirname, '..');
const prod = fs.readFileSync(path.join(apiRoot, '.env.production'), 'utf8');
const m = prod.match(/^DATABASE_URL=(.*)$/m);
if (!m) throw new Error('no prod DATABASE_URL');
let url = m[1].trim();
if (
(url.startsWith('"') && url.endsWith('"')) ||
(url.startsWith("'") && url.endsWith("'"))
) {
url = url.slice(1, -1);
}
if (!url.includes('/dukang_prod')) throw new Error('unexpected prod url');
const stg = url.replace('/dukang_prod', '/dukang_staging');
const envPath = path.join(apiRoot, '.env.staging');
let t = fs.readFileSync(envPath, 'utf8');
if (!/^DATABASE_URL=/m.test(t)) {
t = `DATABASE_URL=\n${t}`;
}
t = t.replace(/^DATABASE_URL=.*$/m, `DATABASE_URL=${JSON.stringify(stg)}`);
fs.writeFileSync(envPath, t);
const u = new URL(stg);
console.log(`ok ${u.hostname}:${u.port || 3306}${u.pathname}`);