// 校验 register_ossbrowser_launch.bat:关键行 + base64 回环解码与源码一致 const fs = require('fs') const path = require('path') const { execFileSync } = require('child_process') const ROOT = path.join(__dirname, '..', '..') const BAT = path.join(ROOT, 'public', 'tools', 'oss_browser_link', 'assets', 'register_ossbrowser_launch.bat') const SRC = path.join(ROOT, 'public', 'tools', 'oss_browser_link', 'assets', 'ossbrowser_wrapper_main.js') const s = fs.readFileSync(BAT, 'utf8') if (s.includes('\r\n') === false) { console.log('[FAIL] bat 不是 CRLF'); process.exit(1) } const lines = s.split(/\r\n/) console.log('total lines:', lines.length) console.log('reg cmd line ok:', !!lines.find(l => l.includes('shell\\open\\command') && l.includes('\\"%EXE%\\"'))) console.log('mkdir line ok:', !!lines.find(l => l.includes('mkdir "%~dp0resources\\app"'))) console.log('txt region line ok:', !!lines.find(l => l.includes('echo oss-cn-shanghai>>'))) const marker = '>> "%~dp0_wrapper.b64"' const b64 = lines.filter(l => l.startsWith('echo ') && l.endsWith(marker)).map(l => l.slice(5, l.length - marker.length)).join('') console.log('b64 len:', b64.length) const b64File = path.join(ROOT, 'temp', 'w2.b64') const outFile = path.join(ROOT, 'temp', 'w2.js') fs.writeFileSync(b64File, b64) try { fs.unlinkSync(outFile) } catch {} execFileSync('certutil', ['-decode', b64File, outFile], { stdio: 'pipe' }) const a = fs.readFileSync(SRC) const b = fs.readFileSync(outFile) console.log('roundtrip identical:', a.equals(b)) if (!a.equals(b)) process.exit(1)