aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tools
diff options
context:
space:
mode:
Diffstat (limited to 'server/tools')
-rw-r--r--server/tools/peertube-plugins.ts44
1 files changed, 43 insertions, 1 deletions
diff --git a/server/tools/peertube-plugins.ts b/server/tools/peertube-plugins.ts
index d5e024383..10cff7dd7 100644
--- a/server/tools/peertube-plugins.ts
+++ b/server/tools/peertube-plugins.ts
@@ -2,7 +2,7 @@ import * as program from 'commander'
2import { PluginType } from '../../shared/models/plugins/plugin.type' 2import { PluginType } from '../../shared/models/plugins/plugin.type'
3import { getAccessToken } from '../../shared/extra-utils/users/login' 3import { getAccessToken } from '../../shared/extra-utils/users/login'
4import { getMyUserInformation } from '../../shared/extra-utils/users/users' 4import { getMyUserInformation } from '../../shared/extra-utils/users/users'
5import { installPlugin, listPlugins, uninstallPlugin } from '../../shared/extra-utils/server/plugins' 5import { installPlugin, listPlugins, uninstallPlugin, updatePlugin } from '../../shared/extra-utils/server/plugins'
6import { getServerCredentials } from './cli' 6import { getServerCredentials } from './cli'
7import { User, UserRole } from '../../shared/models/users' 7import { User, UserRole } from '../../shared/models/users'
8import { PeerTubePlugin } from '../../shared/models/plugins/peertube-plugin.model' 8import { PeerTubePlugin } from '../../shared/models/plugins/peertube-plugin.model'
@@ -35,6 +35,16 @@ program
35 .action((options) => installPluginCLI(options)) 35 .action((options) => installPluginCLI(options))
36 36
37program 37program
38 .command('update')
39 .description('Update a plugin or a theme')
40 .option('-u, --url <url>', 'Server url')
41 .option('-U, --username <username>', 'Username')
42 .option('-p, --password <token>', 'Password')
43 .option('-P --path <path>', 'Update from a path')
44 .option('-n, --npm-name <npmName>', 'Update from npm')
45 .action((options) => updatePluginCLI(options))
46
47program
38 .command('uninstall') 48 .command('uninstall')
39 .description('Uninstall a plugin or a theme') 49 .description('Uninstall a plugin or a theme')
40 .option('-u, --url <url>', 'Server url') 50 .option('-u, --url <url>', 'Server url')
@@ -122,6 +132,38 @@ async function installPluginCLI (options: any) {
122 process.exit(0) 132 process.exit(0)
123} 133}
124 134
135async function updatePluginCLI (options: any) {
136 if (!options['path'] && !options['npmName']) {
137 console.error('You need to specify the npm name or the path of the plugin you want to update.\n')
138 program.outputHelp()
139 process.exit(-1)
140 }
141
142 if (options['path'] && !isAbsolute(options['path'])) {
143 console.error('Path should be absolute.')
144 process.exit(-1)
145 }
146
147 const { url, username, password } = await getServerCredentials(options)
148 const accessToken = await getAdminTokenOrDie(url, username, password)
149
150 try {
151 await updatePlugin({
152 url,
153 accessToken,
154 npmName: options['npmName'],
155 path: options['path']
156 })
157 } catch (err) {
158 console.error('Cannot update plugin.', err)
159 process.exit(-1)
160 return
161 }
162
163 console.log('Plugin updated.')
164 process.exit(0)
165}
166
125async function uninstallPluginCLI (options: any) { 167async function uninstallPluginCLI (options: any) {
126 if (!options['npmName']) { 168 if (!options['npmName']) {
127 console.error('You need to specify the npm name of the plugin/theme you want to uninstall.\n') 169 console.error('You need to specify the npm name of the plugin/theme you want to uninstall.\n')