create-video-intake-pack-smoke.js 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. #!/usr/bin/env node
  2. const fs = require('fs');
  3. const os = require('os');
  4. const path = require('path');
  5. const { spawnSync } = require('child_process');
  6. const { VIDEO_RESOURCE_HEADER } = require('./create-video-intake-pack');
  7. const root = path.resolve(__dirname, '..');
  8. function main() {
  9. const output = fs.mkdtempSync(path.join(os.tmpdir(), 'tihao-video-intake-'));
  10. const result = spawnSync(process.execPath, [
  11. path.join(root, 'scripts', 'create-video-intake-pack.js'),
  12. '--output',
  13. output
  14. ], { cwd: root, encoding: 'utf8' });
  15. if (result.status !== 0) {
  16. process.stderr.write(result.stderr || result.stdout || '');
  17. throw new Error('create-video-intake-pack failed');
  18. }
  19. const videoCsv = path.join(output, 'video-resource-template.csv');
  20. const readme = path.join(output, 'README.md');
  21. assert(fs.existsSync(videoCsv), 'video resource template should exist');
  22. assert(fs.existsSync(readme), 'README should exist');
  23. assert(readHeader(videoCsv) === VIDEO_RESOURCE_HEADER.join(','), 'video resource header should match expected fields');
  24. const allText = [videoCsv, readme].map(file => fs.readFileSync(file, 'utf8')).join('\n');
  25. assert(allText.includes('视频链接'), 'template should include video URL field');
  26. assert(allText.includes('封面链接'), 'template should include cover URL field');
  27. assert(allText.includes('字幕或ASR文本'), 'template should include ASR/subtitle field');
  28. assert(allText.includes('帧图链接'), 'template should include frame URL field');
  29. assert(allText.includes('是否真实资源'), 'template should include real-resource flag');
  30. assert(allText.includes('字段填写验收表'), 'README should include field checklist');
  31. assert(allText.includes('常见退回原因'), 'README should explain common rejection reasons');
  32. assert(allText.includes('npm run video:resource-readiness'), 'README should tell users to run video resource readiness first');
  33. assert(allText.includes('把占位行标成真实资源'), 'README should warn against fake-real rows');
  34. assert(allText.includes('不得声明视频分析完成'), 'README should preserve proof boundary');
  35. assert(allText.includes('acceptance:video-ab'), 'README should point to video A/B audit');
  36. 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');
  37. console.log(JSON.stringify({ ok: true, output, files: 2 }, null, 2));
  38. }
  39. function readHeader(file) {
  40. return fs.readFileSync(file, 'utf8').replace(/^\uFEFF/, '').split(/\r?\n/)[0];
  41. }
  42. function assert(condition, message) {
  43. if (!condition) throw new Error(message);
  44. }
  45. main();