flush_all.js 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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. return await new Promise((resolve, reject) => {
  31. ProjectFlusher.flushAllProjects(options, err => {
  32. if (err) {
  33. reject(err)
  34. } else {
  35. resolve()
  36. }
  37. })
  38. })
  39. }
  40. main()
  41. .then(() => {
  42. console.log('Done flushing all projects')
  43. process.exit(0)
  44. })
  45. .catch(error => {
  46. console.error('There was an error flushing all projects', { error })
  47. process.exit(1)
  48. })