remove_oauth_application.mjs 879 B

12345678910111213141516171819202122232425262728293031323334
  1. import { OauthApplication } from '../app/src/models/OauthApplication.js'
  2. import parseArgs from 'minimist'
  3. import OError from '@overleaf/o-error'
  4. import { scriptRunner } from './lib/ScriptRunner.mjs'
  5. async function _removeOauthApplication(appId) {
  6. if (!appId) {
  7. throw new OError('No app id supplied')
  8. }
  9. console.log(`Removing oauthApplication with id=${appId}`)
  10. const result = await OauthApplication.deleteOne({ id: appId })
  11. console.log('Result', result)
  12. }
  13. async function main() {
  14. const argv = parseArgs(process.argv.slice(2), {
  15. string: ['id'],
  16. unknown: function (arg) {
  17. console.error('unrecognised argument', arg)
  18. process.exit(1)
  19. },
  20. })
  21. const appId = argv.id
  22. await _removeOauthApplication(appId)
  23. }
  24. try {
  25. await scriptRunner(main)
  26. console.log('Done')
  27. process.exit(0)
  28. } catch (error) {
  29. console.error(error)
  30. process.exit(1)
  31. }