]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - scripts/plugin/install.ts
0795d7c935673fee073444be618d0d5672bd9b2a
[github/Chocobozzz/PeerTube.git] / scripts / plugin / install.ts
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'
5
6 program
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')
10 .parse(process.argv)
11
12 const options = program.opts()
13
14 if (!options.npmName && !options.pluginPath) {
15 console.error('You need to specify a plugin name with the desired version, or a plugin path.')
16 process.exit(-1)
17 }
18
19 if (options.pluginPath && !isAbsolute(options.pluginPath)) {
20 console.error('Plugin path should be absolute.')
21 process.exit(-1)
22 }
23
24 run()
25 .then(() => process.exit(0))
26 .catch(err => {
27 console.error(err)
28 process.exit(-1)
29 })
30
31 async function run () {
32 await initDatabaseModels(true)
33
34 const toInstall = options.npmName || options.pluginPath
35 await PluginManager.Instance.install(toInstall, options.pluginVersion, !!options.pluginPath)
36 }