]>
Commit | Line | Data |
---|---|---|
8cc61201 | 1 | import { program } from 'commander' |
b5f919ac | 2 | import { isAbsolute } from 'path' |
f8360396 C |
3 | import { initDatabaseModels } from '../../server/initializers/database' |
4 | import { PluginManager } from '../../server/lib/plugins/plugin-manager' | |
b5f919ac C |
5 | |
6 | program | |
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 |
12 | const options = program.opts() |
13 | ||
14 | if (!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 | 19 | if (options.pluginPath && !isAbsolute(options.pluginPath)) { |
b5f919ac C |
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 | ||
ba5a8d89 C |
34 | const toInstall = options.npmName || options.pluginPath |
35 | await PluginManager.Instance.install(toInstall, options.pluginVersion, !!options.pluginPath) | |
b5f919ac | 36 | } |