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