uninstall.ts 698 B

1234567891011121314151617181920212223242526272829
  1. import { program } from 'commander'
  2. import { initDatabaseModels } from '@server/initializers/database.js'
  3. import { PluginManager } from '@server/lib/plugins/plugin-manager.js'
  4. program
  5. .option('-n, --npm-name [npmName]', 'Package name to install')
  6. .parse(process.argv)
  7. const options = program.opts()
  8. if (!options.npmName) {
  9. console.error('You need to specify the plugin name.')
  10. process.exit(-1)
  11. }
  12. run()
  13. .then(() => process.exit(0))
  14. .catch(err => {
  15. console.error(err)
  16. process.exit(-1)
  17. })
  18. async function run () {
  19. await initDatabaseModels(true)
  20. const toUninstall = options.npmName
  21. await PluginManager.Instance.uninstall({ npmName: toUninstall, unregister: false })
  22. }