#!/usr/bin/env node const fs = require('fs'); const os = require('os'); const path = require('path'); const { spawnSync } = require('child_process'); const { VIDEO_RESOURCE_HEADER } = require('./create-video-intake-pack'); const root = path.resolve(__dirname, '..'); function main() { const output = fs.mkdtempSync(path.join(os.tmpdir(), 'tihao-video-intake-')); const result = spawnSync(process.execPath, [ path.join(root, 'scripts', 'create-video-intake-pack.js'), '--output', output ], { cwd: root, encoding: 'utf8' }); if (result.status !== 0) { process.stderr.write(result.stderr || result.stdout || ''); throw new Error('create-video-intake-pack failed'); } const videoCsv = path.join(output, 'video-resource-template.csv'); const readme = path.join(output, 'README.md'); assert(fs.existsSync(videoCsv), 'video resource template should exist'); assert(fs.existsSync(readme), 'README should exist'); assert(readHeader(videoCsv) === VIDEO_RESOURCE_HEADER.join(','), 'video resource header should match expected fields'); const allText = [videoCsv, readme].map(file => fs.readFileSync(file, 'utf8')).join('\n'); assert(allText.includes('视频链接'), 'template should include video URL field'); assert(allText.includes('封面链接'), 'template should include cover URL field'); assert(allText.includes('字幕或ASR文本'), 'template should include ASR/subtitle field'); assert(allText.includes('帧图链接'), 'template should include frame URL field'); assert(allText.includes('是否真实资源'), 'template should include real-resource flag'); assert(allText.includes('字段填写验收表'), 'README should include field checklist'); assert(allText.includes('常见退回原因'), 'README should explain common rejection reasons'); assert(allText.includes('npm run video:resource-readiness'), 'README should tell users to run video resource readiness first'); assert(allText.includes('把占位行标成真实资源'), 'README should warn against fake-real rows'); assert(allText.includes('不得声明视频分析完成'), 'README should preserve proof boundary'); assert(allText.includes('acceptance:video-ab'), 'README should point to video A/B audit'); assert(!/(sk-[A-Za-z0-9_-]{20,}|r:[A-Za-z0-9]{20,}|Authorization\s*[:=]\s*Bearer)/i.test(allText), 'video intake pack should not contain secrets'); console.log(JSON.stringify({ ok: true, output, files: 2 }, null, 2)); } function readHeader(file) { return fs.readFileSync(file, 'utf8').replace(/^\uFEFF/, '').split(/\r?\n/)[0]; } function assert(condition, message) { if (!condition) throw new Error(message); } main();