2019-10-21 10:13:07 -05:00
|
|
|
import { registerTSPaths } from '../../server/helpers/register-ts-paths'
|
|
|
|
registerTSPaths()
|
|
|
|
|
2019-07-12 04:39:58 -05:00
|
|
|
import { initDatabaseModels } from '../../server/initializers/database'
|
|
|
|
import * as program from 'commander'
|
|
|
|
import { PluginManager } from '../../server/lib/plugins/plugin-manager'
|
|
|
|
import { isAbsolute } from 'path'
|
|
|
|
|
|
|
|
program
|
2019-07-19 03:37:35 -05:00
|
|
|
.option('-n, --npm-name [npmName]', 'Plugin to install')
|
2019-07-12 04:39:58 -05:00
|
|
|
.option('-v, --plugin-version [pluginVersion]', 'Plugin version to install')
|
|
|
|
.option('-p, --plugin-path [pluginPath]', 'Path of the plugin you want to install')
|
|
|
|
.parse(process.argv)
|
|
|
|
|
2019-07-19 03:37:35 -05:00
|
|
|
if (!program['npmName'] && !program['pluginPath']) {
|
2019-07-12 04:39:58 -05:00
|
|
|
console.error('You need to specify a plugin name with the desired version, or a plugin path.')
|
|
|
|
process.exit(-1)
|
|
|
|
}
|
|
|
|
|
|
|
|
if (program['pluginPath'] && !isAbsolute(program['pluginPath'])) {
|
|
|
|
console.error('Plugin path should be absolute.')
|
|
|
|
process.exit(-1)
|
|
|
|
}
|
|
|
|
|
|
|
|
run()
|
|
|
|
.then(() => process.exit(0))
|
|
|
|
.catch(err => {
|
|
|
|
console.error(err)
|
|
|
|
process.exit(-1)
|
|
|
|
})
|
|
|
|
|
|
|
|
async function run () {
|
|
|
|
await initDatabaseModels(true)
|
|
|
|
|
2019-07-19 03:37:35 -05:00
|
|
|
const toInstall = program['npmName'] || program['pluginPath']
|
2019-07-12 04:39:58 -05:00
|
|
|
await PluginManager.Instance.install(toInstall, program['pluginVersion'], !!program['pluginPath'])
|
|
|
|
}
|