release-check.js 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. 'use strict';
  2. const fs = require('fs');
  3. const os = require('os');
  4. const path = require('path');
  5. const { spawnSync } = require('child_process');
  6. const ROOT = path.resolve(__dirname, '..');
  7. const tempRoot = fs.mkdtempSync(path.join(os.tmpdir(), 'qiwei-release-check-'));
  8. const outputsDir = path.join(tempRoot, 'outputs');
  9. const npmCli = process.env.npm_execpath || path.join(path.dirname(process.execPath), 'node_modules', 'npm', 'bin', 'npm-cli.js');
  10. const checks = [
  11. 'check',
  12. 'smoke',
  13. 'agent:smoke',
  14. 'library:smoke',
  15. 'excel:smoke',
  16. 'outputs:validate',
  17. 'install:check',
  18. 'package:smoke',
  19. ];
  20. try {
  21. for (const check of checks) {
  22. const result = spawnSync(process.execPath, [npmCli, 'run', check], {
  23. cwd: ROOT,
  24. env: {
  25. ...process.env,
  26. QIWEI_OUTPUTS_DIR: outputsDir,
  27. QIWEI_AGENT_DB_PATH: path.join(outputsDir, 'messages', 'agent-workbench.db'),
  28. },
  29. stdio: 'inherit',
  30. windowsHide: true,
  31. });
  32. if (result.error) throw result.error;
  33. if (result.status !== 0) process.exit(result.status || 1);
  34. }
  35. process.stdout.write(`\n发布检查通过:${checks.length} 组检查均已完成,测试输出已隔离。\n`);
  36. } finally {
  37. fs.rmSync(tempRoot, { recursive: true, force: true });
  38. }