]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame_incremental - scripts/plugin/install.ts
Translated using Weblate (Catalan)
[github/Chocobozzz/PeerTube.git] / scripts / plugin / install.ts
... / ...
CommitLineData
1import { registerTSPaths } from '../../server/helpers/register-ts-paths'
2registerTSPaths()
3
4import { initDatabaseModels } from '../../server/initializers/database'
5import * as program from 'commander'
6import { PluginManager } from '../../server/lib/plugins/plugin-manager'
7import { isAbsolute } from 'path'
8
9program
10 .option('-n, --npm-name [npmName]', 'Plugin to install')
11 .option('-v, --plugin-version [pluginVersion]', 'Plugin version to install')
12 .option('-p, --plugin-path [pluginPath]', 'Path of the plugin you want to install')
13 .parse(process.argv)
14
15if (!program['npmName'] && !program['pluginPath']) {
16 console.error('You need to specify a plugin name with the desired version, or a plugin path.')
17 process.exit(-1)
18}
19
20if (program['pluginPath'] && !isAbsolute(program['pluginPath'])) {
21 console.error('Plugin path should be absolute.')
22 process.exit(-1)
23}
24
25run()
26 .then(() => process.exit(0))
27 .catch(err => {
28 console.error(err)
29 process.exit(-1)
30 })
31
32async function run () {
33 await initDatabaseModels(true)
34
35 const toInstall = program['npmName'] || program['pluginPath']
36 await PluginManager.Instance.install(toInstall, program['pluginVersion'], !!program['pluginPath'])
37}