2023-02-08 10:02:21 -05:00
|
|
|
const ProjectFlusher = require('../app/js/ProjectFlusher')
|
2024-10-11 11:13:44 -04:00
|
|
|
const minimist = require('minimist')
|
2023-02-08 10:02:21 -05:00
|
|
|
|
|
|
|
async function main() {
|
2024-10-11 11:13:44 -04:00
|
|
|
const argv = minimist(process.argv.slice(2), {
|
|
|
|
default: {
|
2023-02-08 10:02:21 -05:00
|
|
|
limit: 100000,
|
|
|
|
concurrency: 5,
|
2024-10-11 11:13:44 -04:00
|
|
|
'dry-run': false,
|
|
|
|
},
|
|
|
|
boolean: ['dry-run', 'help'],
|
|
|
|
alias: { h: 'help', n: 'dry-run', j: 'concurrency' },
|
|
|
|
})
|
|
|
|
|
|
|
|
if (argv.help) {
|
|
|
|
console.log(`
|
|
|
|
Usage: node scripts/flush_all.js [options]
|
|
|
|
|
|
|
|
Options:
|
|
|
|
--limit Number of projects to flush (default: 100000)
|
|
|
|
--concurrency, -j Number of concurrent flush operations (default: 5)
|
|
|
|
--dryRun, -n Perform a dry run without making any changes (default: false)
|
|
|
|
--help, -h Show this help message
|
|
|
|
`)
|
|
|
|
process.exit(0)
|
|
|
|
}
|
|
|
|
|
|
|
|
const options = {
|
|
|
|
limit: argv.limit,
|
|
|
|
concurrency: argv.concurrency,
|
|
|
|
dryRun: argv['dry-run'],
|
|
|
|
}
|
|
|
|
console.log('Flushing all projects with options:', options)
|
|
|
|
|
|
|
|
return await new Promise((resolve, reject) => {
|
2023-02-08 10:02:21 -05:00
|
|
|
ProjectFlusher.flushAllProjects(options, err => {
|
|
|
|
if (err) {
|
|
|
|
reject(err)
|
|
|
|
} else {
|
|
|
|
resolve()
|
|
|
|
}
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
main()
|
|
|
|
.then(() => {
|
|
|
|
console.log('Done flushing all projects')
|
|
|
|
process.exit(0)
|
|
|
|
})
|
|
|
|
.catch(error => {
|
|
|
|
console.error('There was an error flushing all projects', { error })
|
|
|
|
process.exit(1)
|
|
|
|
})
|