aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tools
diff options
context:
space:
mode:
Diffstat (limited to 'server/tools')
-rw-r--r--server/tools/cli.ts10
-rw-r--r--server/tools/peertube-auth.ts4
-rw-r--r--server/tools/peertube-get-access-token.ts2
-rw-r--r--server/tools/peertube-import-videos.ts2
-rw-r--r--server/tools/peertube-plugins.ts11
-rw-r--r--server/tools/peertube-redundancy.ts7
-rw-r--r--server/tools/peertube-upload.ts2
-rw-r--r--server/tools/peertube-watch.ts6
-rw-r--r--server/tools/peertube.ts6
-rw-r--r--server/tools/test.ts2
10 files changed, 25 insertions, 27 deletions
diff --git a/server/tools/cli.ts b/server/tools/cli.ts
index cc89fe46e..7b94306cd 100644
--- a/server/tools/cli.ts
+++ b/server/tools/cli.ts
@@ -3,12 +3,12 @@ import { getAppNumber, isTestInstance } from '../helpers/core-utils'
3import { join } from 'path' 3import { join } from 'path'
4import { root } from '../../shared/extra-utils/miscs/miscs' 4import { root } from '../../shared/extra-utils/miscs/miscs'
5import { getVideoChannel } from '../../shared/extra-utils/videos/video-channels' 5import { getVideoChannel } from '../../shared/extra-utils/videos/video-channels'
6import { CommanderStatic } from 'commander'
7import { VideoChannel, VideoPrivacy } from '../../shared/models/videos' 6import { VideoChannel, VideoPrivacy } from '../../shared/models/videos'
8import { createLogger, format, transports } from 'winston' 7import { createLogger, format, transports } from 'winston'
9import { getMyUserInformation } from '@shared/extra-utils/users/users' 8import { getMyUserInformation } from '@shared/extra-utils/users/users'
10import { User, UserRole } from '@shared/models' 9import { User, UserRole } from '@shared/models'
11import { getAccessToken } from '@shared/extra-utils/users/login' 10import { getAccessToken } from '@shared/extra-utils/users/login'
11import { Command } from 'commander'
12 12
13let configName = 'PeerTube/CLI' 13let configName = 'PeerTube/CLI'
14if (isTestInstance()) configName += `-${getAppNumber()}` 14if (isTestInstance()) configName += `-${getAppNumber()}`
@@ -69,7 +69,7 @@ function deleteSettings () {
69} 69}
70 70
71function getRemoteObjectOrDie ( 71function getRemoteObjectOrDie (
72 program: CommanderStatic, 72 program: Command,
73 settings: Settings, 73 settings: Settings,
74 netrc: Netrc 74 netrc: Netrc
75): { url: string, username: string, password: string } { 75): { url: string, username: string, password: string } {
@@ -106,7 +106,7 @@ function getRemoteObjectOrDie (
106 } 106 }
107} 107}
108 108
109function buildCommonVideoOptions (command: CommanderStatic) { 109function buildCommonVideoOptions (command: Command) {
110 function list (val) { 110 function list (val) {
111 return val.split(',') 111 return val.split(',')
112 } 112 }
@@ -128,7 +128,7 @@ function buildCommonVideoOptions (command: CommanderStatic) {
128 .option('-v, --verbose <verbose>', 'Verbosity, from 0/\'error\' to 4/\'debug\'', 'info') 128 .option('-v, --verbose <verbose>', 'Verbosity, from 0/\'error\' to 4/\'debug\'', 'info')
129} 129}
130 130
131async function buildVideoAttributesFromCommander (url: string, command: CommanderStatic, defaultAttributes: any = {}) { 131async function buildVideoAttributesFromCommander (url: string, command: Command, defaultAttributes: any = {}) {
132 const options = command.opts() 132 const options = command.opts()
133 133
134 const defaultBooleanAttributes = { 134 const defaultBooleanAttributes = {
@@ -177,7 +177,7 @@ async function buildVideoAttributesFromCommander (url: string, command: Commande
177 return videoAttributes 177 return videoAttributes
178} 178}
179 179
180function getServerCredentials (program: CommanderStatic) { 180function getServerCredentials (program: Command) {
181 return Promise.all([ getSettings(), getNetrc() ]) 181 return Promise.all([ getSettings(), getNetrc() ])
182 .then(([ settings, netrc ]) => { 182 .then(([ settings, netrc ]) => {
183 return getRemoteObjectOrDie(program, settings, netrc) 183 return getRemoteObjectOrDie(program, settings, netrc)
diff --git a/server/tools/peertube-auth.ts b/server/tools/peertube-auth.ts
index e54649002..1934e7986 100644
--- a/server/tools/peertube-auth.ts
+++ b/server/tools/peertube-auth.ts
@@ -3,7 +3,7 @@
3import { registerTSPaths } from '../helpers/register-ts-paths' 3import { registerTSPaths } from '../helpers/register-ts-paths'
4registerTSPaths() 4registerTSPaths()
5 5
6import * as program from 'commander' 6import { OptionValues, program } from 'commander'
7import * as prompt from 'prompt' 7import * as prompt from 'prompt'
8import { getNetrc, getSettings, writeSettings } from './cli' 8import { getNetrc, getSettings, writeSettings } from './cli'
9import { isUserUsernameValid } from '../helpers/custom-validators/users' 9import { isUserUsernameValid } from '../helpers/custom-validators/users'
@@ -66,7 +66,7 @@ program
66 .option('-U, --username <username>', 'Username') 66 .option('-U, --username <username>', 'Username')
67 .option('-p, --password <token>', 'Password') 67 .option('-p, --password <token>', 'Password')
68 .option('--default', 'add the entry as the new default') 68 .option('--default', 'add the entry as the new default')
69 .action((options: program.OptionValues) => { 69 .action((options: OptionValues) => {
70 /* eslint-disable no-import-assign */ 70 /* eslint-disable no-import-assign */
71 prompt.override = options 71 prompt.override = options
72 prompt.start() 72 prompt.start()
diff --git a/server/tools/peertube-get-access-token.ts b/server/tools/peertube-get-access-token.ts
index b2c278c48..9488eba0e 100644
--- a/server/tools/peertube-get-access-token.ts
+++ b/server/tools/peertube-get-access-token.ts
@@ -1,7 +1,7 @@
1import { registerTSPaths } from '../helpers/register-ts-paths' 1import { registerTSPaths } from '../helpers/register-ts-paths'
2registerTSPaths() 2registerTSPaths()
3 3
4import * as program from 'commander' 4import { program } from 'commander'
5import { getClient, Server, serverLogin } from '../../shared/extra-utils' 5import { getClient, Server, serverLogin } from '../../shared/extra-utils'
6 6
7program 7program
diff --git a/server/tools/peertube-import-videos.ts b/server/tools/peertube-import-videos.ts
index b3f57a8f9..101a95b2a 100644
--- a/server/tools/peertube-import-videos.ts
+++ b/server/tools/peertube-import-videos.ts
@@ -1,7 +1,7 @@
1import { registerTSPaths } from '../helpers/register-ts-paths' 1import { registerTSPaths } from '../helpers/register-ts-paths'
2registerTSPaths() 2registerTSPaths()
3 3
4import * as program from 'commander' 4import { program } from 'commander'
5import { accessSync, constants } from 'fs' 5import { accessSync, constants } from 'fs'
6import { remove } from 'fs-extra' 6import { remove } from 'fs-extra'
7import { truncate } from 'lodash' 7import { truncate } from 'lodash'
diff --git a/server/tools/peertube-plugins.ts b/server/tools/peertube-plugins.ts
index cb591377b..54ea1264d 100644
--- a/server/tools/peertube-plugins.ts
+++ b/server/tools/peertube-plugins.ts
@@ -3,13 +3,12 @@
3import { registerTSPaths } from '../helpers/register-ts-paths' 3import { registerTSPaths } from '../helpers/register-ts-paths'
4registerTSPaths() 4registerTSPaths()
5 5
6import * as program from 'commander' 6import { program, Command, OptionValues } from 'commander'
7import { installPlugin, listPlugins, uninstallPlugin, updatePlugin } from '../../shared/extra-utils/server/plugins' 7import { installPlugin, listPlugins, uninstallPlugin, updatePlugin } from '../../shared/extra-utils/server/plugins'
8import { getAdminTokenOrDie, getServerCredentials } from './cli' 8import { getAdminTokenOrDie, getServerCredentials } from './cli'
9import { PeerTubePlugin, PluginType } from '../../shared/models' 9import { PeerTubePlugin, PluginType } from '../../shared/models'
10import { isAbsolute } from 'path' 10import { isAbsolute } from 'path'
11import * as CliTable3 from 'cli-table3' 11import * as CliTable3 from 'cli-table3'
12import commander = require('commander')
13 12
14program 13program
15 .name('plugins') 14 .name('plugins')
@@ -62,7 +61,7 @@ program.parse(process.argv)
62 61
63// ---------------------------------------------------------------------------- 62// ----------------------------------------------------------------------------
64 63
65async function pluginsListCLI (command: commander.CommanderStatic, options: commander.OptionValues) { 64async function pluginsListCLI (command: Command, options: OptionValues) {
66 const { url, username, password } = await getServerCredentials(command) 65 const { url, username, password } = await getServerCredentials(command)
67 const accessToken = await getAdminTokenOrDie(url, username, password) 66 const accessToken = await getAdminTokenOrDie(url, username, password)
68 67
@@ -101,7 +100,7 @@ async function pluginsListCLI (command: commander.CommanderStatic, options: comm
101 process.exit(0) 100 process.exit(0)
102} 101}
103 102
104async function installPluginCLI (command: commander.CommanderStatic, options: commander.OptionValues) { 103async function installPluginCLI (command: Command, options: OptionValues) {
105 if (!options.path && !options.npmName) { 104 if (!options.path && !options.npmName) {
106 console.error('You need to specify the npm name or the path of the plugin you want to install.\n') 105 console.error('You need to specify the npm name or the path of the plugin you want to install.\n')
107 program.outputHelp() 106 program.outputHelp()
@@ -132,7 +131,7 @@ async function installPluginCLI (command: commander.CommanderStatic, options: co
132 process.exit(0) 131 process.exit(0)
133} 132}
134 133
135async function updatePluginCLI (command: commander.CommanderStatic, options: commander.OptionValues) { 134async function updatePluginCLI (command: Command, options: OptionValues) {
136 if (!options.path && !options.npmName) { 135 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') 136 console.error('You need to specify the npm name or the path of the plugin you want to update.\n')
138 program.outputHelp() 137 program.outputHelp()
@@ -163,7 +162,7 @@ async function updatePluginCLI (command: commander.CommanderStatic, options: com
163 process.exit(0) 162 process.exit(0)
164} 163}
165 164
166async function uninstallPluginCLI (command: commander.CommanderStatic, options: commander.OptionValues) { 165async function uninstallPluginCLI (command: Command, options: OptionValues) {
167 if (!options.npmName) { 166 if (!options.npmName) {
168 console.error('You need to specify the npm name of the plugin/theme you want to uninstall.\n') 167 console.error('You need to specify the npm name of the plugin/theme you want to uninstall.\n')
169 program.outputHelp() 168 program.outputHelp()
diff --git a/server/tools/peertube-redundancy.ts b/server/tools/peertube-redundancy.ts
index 5bc80ddb9..4810deee0 100644
--- a/server/tools/peertube-redundancy.ts
+++ b/server/tools/peertube-redundancy.ts
@@ -3,7 +3,7 @@
3import { registerTSPaths } from '../helpers/register-ts-paths' 3import { registerTSPaths } from '../helpers/register-ts-paths'
4registerTSPaths() 4registerTSPaths()
5 5
6import * as program from 'commander' 6import { program, Command } from 'commander'
7import { getAdminTokenOrDie, getServerCredentials } from './cli' 7import { getAdminTokenOrDie, getServerCredentials } from './cli'
8import { VideoRedundanciesTarget, VideoRedundancy } from '@shared/models' 8import { VideoRedundanciesTarget, VideoRedundancy } from '@shared/models'
9import { addVideoRedundancy, listVideoRedundancies, removeVideoRedundancy } from '@shared/extra-utils/server/redundancy' 9import { addVideoRedundancy, listVideoRedundancies, removeVideoRedundancy } from '@shared/extra-utils/server/redundancy'
@@ -14,7 +14,6 @@ import { URL } from 'url'
14import { uniq } from 'lodash' 14import { uniq } from 'lodash'
15 15
16import bytes = require('bytes') 16import bytes = require('bytes')
17import commander = require('commander')
18 17
19program 18program
20 .name('plugins') 19 .name('plugins')
@@ -105,7 +104,7 @@ async function listRedundanciesCLI (target: VideoRedundanciesTarget) {
105 process.exit(0) 104 process.exit(0)
106} 105}
107 106
108async function addRedundancyCLI (options: { video: number }, command: commander.CommanderStatic) { 107async function addRedundancyCLI (options: { video: number }, command: Command) {
109 const { url, username, password } = await getServerCredentials(command) 108 const { url, username, password } = await getServerCredentials(command)
110 const accessToken = await getAdminTokenOrDie(url, username, password) 109 const accessToken = await getAdminTokenOrDie(url, username, password)
111 110
@@ -138,7 +137,7 @@ async function addRedundancyCLI (options: { video: number }, command: commander.
138 } 137 }
139} 138}
140 139
141async function removeRedundancyCLI (options: { video: number }, command: commander.CommanderStatic) { 140async function removeRedundancyCLI (options: { video: number }, command: Command) {
142 const { url, username, password } = await getServerCredentials(command) 141 const { url, username, password } = await getServerCredentials(command)
143 const accessToken = await getAdminTokenOrDie(url, username, password) 142 const accessToken = await getAdminTokenOrDie(url, username, password)
144 143
diff --git a/server/tools/peertube-upload.ts b/server/tools/peertube-upload.ts
index 86c7f3d91..02edbd809 100644
--- a/server/tools/peertube-upload.ts
+++ b/server/tools/peertube-upload.ts
@@ -1,7 +1,7 @@
1import { registerTSPaths } from '../helpers/register-ts-paths' 1import { registerTSPaths } from '../helpers/register-ts-paths'
2registerTSPaths() 2registerTSPaths()
3 3
4import * as program from 'commander' 4import { program } from 'commander'
5import { access, constants } from 'fs-extra' 5import { access, constants } from 'fs-extra'
6import { isAbsolute } from 'path' 6import { isAbsolute } from 'path'
7import { getAccessToken } from '../../shared/extra-utils' 7import { getAccessToken } from '../../shared/extra-utils'
diff --git a/server/tools/peertube-watch.ts b/server/tools/peertube-watch.ts
index 3ca3e242a..892c9e7a6 100644
--- a/server/tools/peertube-watch.ts
+++ b/server/tools/peertube-watch.ts
@@ -1,7 +1,7 @@
1import { registerTSPaths } from '../helpers/register-ts-paths' 1import { registerTSPaths } from '../helpers/register-ts-paths'
2registerTSPaths() 2registerTSPaths()
3 3
4import * as program from 'commander' 4import { program, Option, OptionValues } from 'commander'
5import { join } from 'path' 5import { join } from 'path'
6import { execSync } from 'child_process' 6import { execSync } from 'child_process'
7 7
@@ -9,7 +9,7 @@ program
9 .name('watch') 9 .name('watch')
10 .arguments('<url>') 10 .arguments('<url>')
11 .addOption( 11 .addOption(
12 new program.Option('-g, --gui <player>', 'player type') 12 new Option('-g, --gui <player>', 'player type')
13 .default('vlc') 13 .default('vlc')
14 .choices([ 'airplay', 'stdout', 'chromecast', 'mpv', 'vlc', 'mplayer', 'xbmc' ]) 14 .choices([ 'airplay', 'stdout', 'chromecast', 'mpv', 'vlc', 'mplayer', 'xbmc' ])
15 ) 15 )
@@ -22,7 +22,7 @@ program
22 .action((url, options) => run(url, options)) 22 .action((url, options) => run(url, options))
23 .parse(process.argv) 23 .parse(process.argv)
24 24
25function run (url: string, options: program.OptionValues) { 25function run (url: string, options: OptionValues) {
26 if (!url) { 26 if (!url) {
27 console.error('<url> positional argument is required.') 27 console.error('<url> positional argument is required.')
28 process.exit(-1) 28 process.exit(-1)
diff --git a/server/tools/peertube.ts b/server/tools/peertube.ts
index 655f07f0c..a40c1332e 100644
--- a/server/tools/peertube.ts
+++ b/server/tools/peertube.ts
@@ -5,7 +5,7 @@
5import { registerTSPaths } from '../helpers/register-ts-paths' 5import { registerTSPaths } from '../helpers/register-ts-paths'
6registerTSPaths() 6registerTSPaths()
7 7
8import * as program from 'commander' 8import { CommandOptions, program } from 'commander'
9import { getSettings, version } from './cli' 9import { getSettings, version } from './cli'
10 10
11program 11program
@@ -28,11 +28,11 @@ program
28 .command( 28 .command(
29 'diagnostic [action]', 29 'diagnostic [action]',
30 'like couple therapy, but for your instance', 30 'like couple therapy, but for your instance',
31 { noHelp: true } as program.CommandOptions 31 { noHelp: true } as CommandOptions
32 ).alias('d') 32 ).alias('d')
33 .command('admin', 33 .command('admin',
34 'manage an instance where you have elevated rights', 34 'manage an instance where you have elevated rights',
35 { noHelp: true } as program.CommandOptions 35 { noHelp: true } as CommandOptions
36 ).alias('a') 36 ).alias('a')
37 37
38// help on no command 38// help on no command
diff --git a/server/tools/test.ts b/server/tools/test.ts
index fc7f8d769..fbdbae0b0 100644
--- a/server/tools/test.ts
+++ b/server/tools/test.ts
@@ -2,7 +2,7 @@ import { registerTSPaths } from '../helpers/register-ts-paths'
2registerTSPaths() 2registerTSPaths()
3 3
4import { LiveVideo, LiveVideoCreate, VideoPrivacy } from '@shared/models' 4import { LiveVideo, LiveVideoCreate, VideoPrivacy } from '@shared/models'
5import * as program from 'commander' 5import { program } from 'commander'
6import { 6import {
7 createLive, 7 createLive,
8 flushAndRunServer, 8 flushAndRunServer,