#!/usr/bin/env node /** * D3: sleep-checkin.vue 睡眠主题清理 (debt 126) * - script 4 行质量条渐变 -> BrandColors 模板字符串 * - style 7 色映射全局等值令牌 * - 睡眠主题专属色(雪夜蓝 + 米黄族 + 极浅蓝)收编为页面级局部变量 */ const fs = require('fs'); const F = 'pages/growth/sleep-checkin.vue'; let src = fs.readFileSync(F, 'utf8'); // --- 1. script 渐变 -> BrandColors --- const SCRIPT_REPL = [ [ "if (score >= 8) item._barBg = 'linear-gradient(90deg,#818CF8,#6366F1)'", "if (score >= 8) item._barBg = `linear-gradient(90deg, ${BrandColors.wisdomLight}, ${BrandColors.wisdom})`", ], [ "else if (score >= 6) item._barBg = 'linear-gradient(90deg,#34D399,#10B981)'", "else if (score >= 6) item._barBg = `linear-gradient(90deg, ${BrandColors.successLight3}, ${BrandColors.success})`", ], [ "else if (score >= 4) item._barBg = 'linear-gradient(90deg,#FBBF24,#F59E0B)'", "else if (score >= 4) item._barBg = `linear-gradient(90deg, ${BrandColors.warning}, ${BrandColors.wealth})`", ], [ "else item._barBg = 'linear-gradient(90deg,#FB7185,#EF4444)'", "else item._barBg = `linear-gradient(90deg, ${BrandColors.dangerLight2}, ${BrandColors.danger})`", ], ]; for (const [from, to] of SCRIPT_REPL) { if (!src.includes(from)) { console.warn('SCRIPT LINE NOT FOUND:', from.slice(0, 50)); continue; } src = src.replace(from, to); } // --- 2. import BrandColors(若未存在)--- if (!src.includes('brand-colors')) { src = src.replace(/(