overleaf-cep/services/web/scripts/remove_oauth_application.mjs
Liangjun Song 2f87db9c0d Merge pull request #24790 from overleaf/ls-use-script-runner
Update some scripts to use Script Runner

GitOrigin-RevId: aaa11f94dcfd328c158bb02d1b9fb2adfb1bb146
2025-05-23 08:05:23 +00:00

34 lines
879 B
JavaScript

import { OauthApplication } from '../app/src/models/OauthApplication.js'
import parseArgs from 'minimist'
import OError from '@overleaf/o-error'
import { scriptRunner } from './lib/ScriptRunner.mjs'
async function _removeOauthApplication(appId) {
if (!appId) {
throw new OError('No app id supplied')
}
console.log(`Removing oauthApplication with id=${appId}`)
const result = await OauthApplication.deleteOne({ id: appId })
console.log('Result', result)
}
async function main() {
const argv = parseArgs(process.argv.slice(2), {
string: ['id'],
unknown: function (arg) {
console.error('unrecognised argument', arg)
process.exit(1)
},
})
const appId = argv.id
await _removeOauthApplication(appId)
}
try {
await scriptRunner(main)
console.log('Done')
process.exit(0)
} catch (error) {
console.error(error)
process.exit(1)
}