undelete_project_to_user.mjs 689 B

12345678910111213141516171819202122232425
  1. import minimist from 'minimist'
  2. import { waitForDb } from '../app/src/infrastructure/mongodb.js'
  3. import ProjectDeleter from '../app/src/Features/Project/ProjectDeleter.js'
  4. async function main() {
  5. const argv = minimist(process.argv.slice(2))
  6. const projectId = argv['project-id']
  7. const userId = argv['user-id']
  8. if (!projectId || !userId) {
  9. throw new Error('set --project-id and --user-id')
  10. }
  11. console.log(`Restoring project ${projectId} to user ${userId}`)
  12. await waitForDb()
  13. await ProjectDeleter.promises.undeleteProject(projectId, { userId })
  14. }
  15. try {
  16. await main()
  17. console.log('Done.')
  18. process.exit(0)
  19. } catch (error) {
  20. console.error(error)
  21. process.exit(1)
  22. }