1 import { initDatabaseModels } from '../../server/initializers/database'
2 import * as program from 'commander'
3 import { PluginManager } from '../../server/lib/plugins/plugin-manager'
4 import { isAbsolute } from 'path'
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 if (!program['npmName'] && !program['pluginPath']) {
13 console.error('You need to specify a plugin name with the desired version, or a plugin path.')
17 if (program['pluginPath'] && !isAbsolute(program['pluginPath'])) {
18 console.error('Plugin path should be absolute.')
23 .then(() => process.exit(0))
29 async function run () {
30 await initDatabaseModels(true)
32 const toInstall = program['npmName'] || program['pluginPath']
33 await PluginManager.Instance.install(toInstall, program['pluginVersion'], !!program['pluginPath'])