]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - scripts/plugin/install.ts
Update translations and support fa
[github/Chocobozzz/PeerTube.git] / scripts / plugin / install.ts
CommitLineData
8cc61201 1import { program } from 'commander'
b5f919ac 2import { isAbsolute } from 'path'
f8360396
C
3import { initDatabaseModels } from '../../server/initializers/database'
4import { PluginManager } from '../../server/lib/plugins/plugin-manager'
b5f919ac
C
5
6program
9b474844 7 .option('-n, --npm-name [npmName]', 'Plugin to install')
b5f919ac
C
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
ba5a8d89
C
12const options = program.opts()
13
14if (!options.npmName && !options.pluginPath) {
b5f919ac
C
15 console.error('You need to specify a plugin name with the desired version, or a plugin path.')
16 process.exit(-1)
17}
18
ba5a8d89 19if (options.pluginPath && !isAbsolute(options.pluginPath)) {
b5f919ac
C
20 console.error('Plugin path should be absolute.')
21 process.exit(-1)
22}
23
24run()
25 .then(() => process.exit(0))
26 .catch(err => {
27 console.error(err)
28 process.exit(-1)
29 })
30
31async function run () {
32 await initDatabaseModels(true)
33
ba5a8d89
C
34 const toInstall = options.npmName || options.pluginPath
35 await PluginManager.Instance.install(toInstall, options.pluginVersion, !!options.pluginPath)
b5f919ac 36}