ニジカ投稿局 https://tv.nizika.tv
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

42 lines
1.2 KiB

  1. import { program } from 'commander'
  2. import { isAbsolute } from 'path'
  3. import { initDatabaseModels } from '../../core/initializers/database.js'
  4. import { PluginManager } from '../../core/lib/plugins/plugin-manager.js'
  5. program
  6. .option('-n, --npm-name [npmName]', 'Plugin to install')
  7. .option('-v, --plugin-version [pluginVersion]', 'Plugin version to install')
  8. .option('-p, --plugin-path [pluginPath]', 'Path of the plugin you want to install')
  9. .parse(process.argv)
  10. const options = program.opts()
  11. if (!options.npmName && !options.pluginPath) {
  12. console.error('You need to specify a plugin name with the desired version, or a plugin path.')
  13. process.exit(-1)
  14. }
  15. if (options.pluginPath && !isAbsolute(options.pluginPath)) {
  16. console.error('Plugin path should be absolute.')
  17. process.exit(-1)
  18. }
  19. run()
  20. .then(() => process.exit(0))
  21. .catch(err => {
  22. console.error(err)
  23. process.exit(-1)
  24. })
  25. async function run () {
  26. await initDatabaseModels(true)
  27. const toInstall = options.npmName || options.pluginPath
  28. await PluginManager.Instance.install({
  29. toInstall,
  30. version: options.pluginVersion,
  31. fromDisk: !!options.pluginPath,
  32. register: false
  33. })
  34. }