diff options
author | Chocobozzz <me@florianbigard.com> | 2019-07-12 11:39:58 +0200 |
---|---|---|
committer | Chocobozzz <chocobozzz@cpy.re> | 2019-07-24 10:58:16 +0200 |
commit | b5f919ac8eb2a1c20e26582fdfd377d687710d8f (patch) | |
tree | 5ec28be6f750f54bba560803ddba681103c2d82e /scripts | |
parent | 8d2be0ed7bb87283a1ec98609df6b82d83db706a (diff) | |
download | PeerTube-b5f919ac8eb2a1c20e26582fdfd377d687710d8f.tar.gz PeerTube-b5f919ac8eb2a1c20e26582fdfd377d687710d8f.tar.zst PeerTube-b5f919ac8eb2a1c20e26582fdfd377d687710d8f.zip |
WIP plugins: update plugin
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/plugin/install.ts | 39 | ||||
-rwxr-xr-x | scripts/plugin/uninstall.ts | 26 |
2 files changed, 65 insertions, 0 deletions
diff --git a/scripts/plugin/install.ts b/scripts/plugin/install.ts new file mode 100755 index 000000000..1725cbeb6 --- /dev/null +++ b/scripts/plugin/install.ts | |||
@@ -0,0 +1,39 @@ | |||
1 | import { initDatabaseModels } from '../../server/initializers/database' | ||
2 | import * as program from 'commander' | ||
3 | import { PluginManager } from '../../server/lib/plugins/plugin-manager' | ||
4 | import { isAbsolute } from 'path' | ||
5 | |||
6 | program | ||
7 | .option('-n, --plugin-name [pluginName]', 'Plugin name to install') | ||
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 | |||
12 | if (!program['pluginName'] && !program['pluginPath']) { | ||
13 | console.error('You need to specify a plugin name with the desired version, or a plugin path.') | ||
14 | process.exit(-1) | ||
15 | } | ||
16 | |||
17 | if (program['pluginName'] && !program['pluginVersion']) { | ||
18 | console.error('You need to specify a the version of the plugin you want to install.') | ||
19 | process.exit(-1) | ||
20 | } | ||
21 | |||
22 | if (program['pluginPath'] && !isAbsolute(program['pluginPath'])) { | ||
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 | |||
37 | const toInstall = program['pluginName'] || program['pluginPath'] | ||
38 | await PluginManager.Instance.install(toInstall, program['pluginVersion'], !!program['pluginPath']) | ||
39 | } | ||
diff --git a/scripts/plugin/uninstall.ts b/scripts/plugin/uninstall.ts new file mode 100755 index 000000000..b5e1ddea2 --- /dev/null +++ b/scripts/plugin/uninstall.ts | |||
@@ -0,0 +1,26 @@ | |||
1 | import { initDatabaseModels } from '../../server/initializers/database' | ||
2 | import * as program from 'commander' | ||
3 | import { PluginManager } from '../../server/lib/plugins/plugin-manager' | ||
4 | |||
5 | program | ||
6 | .option('-n, --npm-name [npmName]', 'Package name to install') | ||
7 | .parse(process.argv) | ||
8 | |||
9 | if (!program['npmName']) { | ||
10 | console.error('You need to specify the plugin name.') | ||
11 | process.exit(-1) | ||
12 | } | ||
13 | |||
14 | run() | ||
15 | .then(() => process.exit(0)) | ||
16 | .catch(err => { | ||
17 | console.error(err) | ||
18 | process.exit(-1) | ||
19 | }) | ||
20 | |||
21 | async function run () { | ||
22 | await initDatabaseModels(true) | ||
23 | |||
24 | const toUninstall = program['npmName'] | ||
25 | await PluginManager.Instance.uninstall(toUninstall) | ||
26 | } | ||