flush_all.js 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. const ProjectFlusher = require('../app/js/ProjectFlusher')
  2. const minimist = require('minimist')
  3. async function main() {
  4. const argv = minimist(process.argv.slice(2), {
  5. default: {
  6. limit: 100000,
  7. concurrency: 5,
  8. 'dry-run': false,
  9. },
  10. boolean: ['dry-run', 'help'],
  11. alias: { h: 'help', n: 'dry-run', j: 'concurrency' },
  12. })
  13. if (argv.help) {
  14. console.log(`
  15. Usage: node scripts/flush_all.js [options]
  16. Options:
  17. --limit Number of projects to flush (default: 100000)
  18. --concurrency, -j Number of concurrent flush operations (default: 5)
  19. --dryRun, -n Perform a dry run without making any changes (default: false)
  20. --help, -h Show this help message
  21. `)
  22. process.exit(0)
  23. }
  24. const options = {
  25. limit: argv.limit,
  26. concurrency: argv.concurrency,
  27. dryRun: argv['dry-run'],
  28. }
  29. console.log('Flushing all projects with options:', options)
  30. await ProjectFlusher.promises.flushAllProjects(options)
  31. }
  32. main()
  33. .then(() => {
  34. console.log('Done flushing all projects')
  35. process.exit(0)
  36. })
  37. .catch(error => {
  38. console.error('There was an error flushing all projects', { error })
  39. process.exit(1)
  40. })