]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - scripts/plugin/install.ts
WIP plugins: list installed plugins in client
[github/Chocobozzz/PeerTube.git] / scripts / plugin / install.ts
CommitLineData
f023a19c
C
1import { initDatabaseModels } from '../../server/initializers/database'
2import * as program from 'commander'
3import { PluginManager } from '../../server/lib/plugins/plugin-manager'
4import { isAbsolute } from 'path'
5
6program
2c053942
C
7 .option('-n, --plugin-name [pluginName]', 'Plugin name 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')
f023a19c
C
10 .parse(process.argv)
11
12if (!program['pluginName'] && !program['pluginPath']) {
13 console.error('You need to specify a plugin name with the desired version, or a plugin path.')
14 process.exit(-1)
15}
16
17if (program['pluginName'] && !program['pluginVersion']) {
18 console.error('You need to specify a the version of the plugin you want to install.')
19 process.exit(-1)
20}
21
22if (program['pluginPath'] && !isAbsolute(program['pluginPath'])) {
23 console.error('Plugin path should be absolute.')
24 process.exit(-1)
25}
26
27run()
28 .then(() => process.exit(0))
29 .catch(err => {
30 console.error(err)
31 process.exit(-1)
32 })
33
34async function run () {
35 await initDatabaseModels(true)
36
37 const toInstall = program['pluginName'] || program['pluginPath']
38 await PluginManager.Instance.install(toInstall, program['pluginVersion'], !!program['pluginPath'])
39}