]>
Commit | Line | Data |
---|---|---|
2aaa1a3f C |
1 | import { registerTSPaths } from '../../server/helpers/register-ts-paths' |
2 | registerTSPaths() | |
3 | ||
b5f919ac C |
4 | import { initDatabaseModels } from '../../server/initializers/database' |
5 | import * as program from 'commander' | |
6 | import { PluginManager } from '../../server/lib/plugins/plugin-manager' | |
7 | import { isAbsolute } from 'path' | |
8 | ||
9 | program | |
9b474844 | 10 | .option('-n, --npm-name [npmName]', 'Plugin to install') |
b5f919ac C |
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 | ||
ba5a8d89 C |
15 | const options = program.opts() |
16 | ||
17 | if (!options.npmName && !options.pluginPath) { | |
b5f919ac C |
18 | console.error('You need to specify a plugin name with the desired version, or a plugin path.') |
19 | process.exit(-1) | |
20 | } | |
21 | ||
ba5a8d89 | 22 | if (options.pluginPath && !isAbsolute(options.pluginPath)) { |
b5f919ac C |
23 | console.error('Plugin path should be absolute.') |
24 | process.exit(-1) | |
25 | } | |
26 | ||
27 | run() | |
28 | .then(() => process.exit(0)) | |
29 | .catch(err => { | |
30 | console.error(err) | |
31 | process.exit(-1) | |
32 | }) | |
33 | ||
34 | async function run () { | |
35 | await initDatabaseModels(true) | |
36 | ||
ba5a8d89 C |
37 | const toInstall = options.npmName || options.pluginPath |
38 | await PluginManager.Instance.install(toInstall, options.pluginVersion, !!options.pluginPath) | |
b5f919ac | 39 | } |