1 import { program } from 'commander'
2 import { isAbsolute } from 'path'
3 import { initDatabaseModels } from '../../server/initializers/database'
4 import { PluginManager } from '../../server/lib/plugins/plugin-manager'
7 .option('-n, --npm-name [npmName]', 'Plugin to install')
8 .option('-v, --plugin-version [pluginVersion]', 'Plugin version to install')
9 .option('-p, --plugin-path [pluginPath]', 'Path of the plugin you want to install')
12 const options = program.opts()
14 if (!options.npmName && !options.pluginPath) {
15 console.error('You need to specify a plugin name with the desired version, or a plugin path.')
19 if (options.pluginPath && !isAbsolute(options.pluginPath)) {
20 console.error('Plugin path should be absolute.')
25 .then(() => process.exit(0))
31 async function run () {
32 await initDatabaseModels(true)
34 const toInstall = options.npmName || options.pluginPath
35 await PluginManager.Instance.install(toInstall, options.pluginVersion, !!options.pluginPath)