diff options
Diffstat (limited to 'server/tools')
-rw-r--r-- | server/tools/cli.ts | 10 | ||||
-rw-r--r-- | server/tools/peertube-auth.ts | 4 | ||||
-rw-r--r-- | server/tools/peertube-get-access-token.ts | 2 | ||||
-rw-r--r-- | server/tools/peertube-import-videos.ts | 2 | ||||
-rw-r--r-- | server/tools/peertube-plugins.ts | 11 | ||||
-rw-r--r-- | server/tools/peertube-redundancy.ts | 7 | ||||
-rw-r--r-- | server/tools/peertube-upload.ts | 2 | ||||
-rw-r--r-- | server/tools/peertube-watch.ts | 6 | ||||
-rw-r--r-- | server/tools/peertube.ts | 6 | ||||
-rw-r--r-- | server/tools/test.ts | 2 |
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' | |||
3 | import { join } from 'path' | 3 | import { join } from 'path' |
4 | import { root } from '../../shared/extra-utils/miscs/miscs' | 4 | import { root } from '../../shared/extra-utils/miscs/miscs' |
5 | import { getVideoChannel } from '../../shared/extra-utils/videos/video-channels' | 5 | import { getVideoChannel } from '../../shared/extra-utils/videos/video-channels' |
6 | import { CommanderStatic } from 'commander' | ||
7 | import { VideoChannel, VideoPrivacy } from '../../shared/models/videos' | 6 | import { VideoChannel, VideoPrivacy } from '../../shared/models/videos' |
8 | import { createLogger, format, transports } from 'winston' | 7 | import { createLogger, format, transports } from 'winston' |
9 | import { getMyUserInformation } from '@shared/extra-utils/users/users' | 8 | import { getMyUserInformation } from '@shared/extra-utils/users/users' |
10 | import { User, UserRole } from '@shared/models' | 9 | import { User, UserRole } from '@shared/models' |
11 | import { getAccessToken } from '@shared/extra-utils/users/login' | 10 | import { getAccessToken } from '@shared/extra-utils/users/login' |
11 | import { Command } from 'commander' | ||
12 | 12 | ||
13 | let configName = 'PeerTube/CLI' | 13 | let configName = 'PeerTube/CLI' |
14 | if (isTestInstance()) configName += `-${getAppNumber()}` | 14 | if (isTestInstance()) configName += `-${getAppNumber()}` |
@@ -69,7 +69,7 @@ function deleteSettings () { | |||
69 | } | 69 | } |
70 | 70 | ||
71 | function getRemoteObjectOrDie ( | 71 | function 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 | ||
109 | function buildCommonVideoOptions (command: CommanderStatic) { | 109 | function 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 | ||
131 | async function buildVideoAttributesFromCommander (url: string, command: CommanderStatic, defaultAttributes: any = {}) { | 131 | async 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 | ||
180 | function getServerCredentials (program: CommanderStatic) { | 180 | function 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 @@ | |||
3 | import { registerTSPaths } from '../helpers/register-ts-paths' | 3 | import { registerTSPaths } from '../helpers/register-ts-paths' |
4 | registerTSPaths() | 4 | registerTSPaths() |
5 | 5 | ||
6 | import * as program from 'commander' | 6 | import { OptionValues, program } from 'commander' |
7 | import * as prompt from 'prompt' | 7 | import * as prompt from 'prompt' |
8 | import { getNetrc, getSettings, writeSettings } from './cli' | 8 | import { getNetrc, getSettings, writeSettings } from './cli' |
9 | import { isUserUsernameValid } from '../helpers/custom-validators/users' | 9 | import { 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 @@ | |||
1 | import { registerTSPaths } from '../helpers/register-ts-paths' | 1 | import { registerTSPaths } from '../helpers/register-ts-paths' |
2 | registerTSPaths() | 2 | registerTSPaths() |
3 | 3 | ||
4 | import * as program from 'commander' | 4 | import { program } from 'commander' |
5 | import { getClient, Server, serverLogin } from '../../shared/extra-utils' | 5 | import { getClient, Server, serverLogin } from '../../shared/extra-utils' |
6 | 6 | ||
7 | program | 7 | program |
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 @@ | |||
1 | import { registerTSPaths } from '../helpers/register-ts-paths' | 1 | import { registerTSPaths } from '../helpers/register-ts-paths' |
2 | registerTSPaths() | 2 | registerTSPaths() |
3 | 3 | ||
4 | import * as program from 'commander' | 4 | import { program } from 'commander' |
5 | import { accessSync, constants } from 'fs' | 5 | import { accessSync, constants } from 'fs' |
6 | import { remove } from 'fs-extra' | 6 | import { remove } from 'fs-extra' |
7 | import { truncate } from 'lodash' | 7 | import { 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 @@ | |||
3 | import { registerTSPaths } from '../helpers/register-ts-paths' | 3 | import { registerTSPaths } from '../helpers/register-ts-paths' |
4 | registerTSPaths() | 4 | registerTSPaths() |
5 | 5 | ||
6 | import * as program from 'commander' | 6 | import { program, Command, OptionValues } from 'commander' |
7 | import { installPlugin, listPlugins, uninstallPlugin, updatePlugin } from '../../shared/extra-utils/server/plugins' | 7 | import { installPlugin, listPlugins, uninstallPlugin, updatePlugin } from '../../shared/extra-utils/server/plugins' |
8 | import { getAdminTokenOrDie, getServerCredentials } from './cli' | 8 | import { getAdminTokenOrDie, getServerCredentials } from './cli' |
9 | import { PeerTubePlugin, PluginType } from '../../shared/models' | 9 | import { PeerTubePlugin, PluginType } from '../../shared/models' |
10 | import { isAbsolute } from 'path' | 10 | import { isAbsolute } from 'path' |
11 | import * as CliTable3 from 'cli-table3' | 11 | import * as CliTable3 from 'cli-table3' |
12 | import commander = require('commander') | ||
13 | 12 | ||
14 | program | 13 | program |
15 | .name('plugins') | 14 | .name('plugins') |
@@ -62,7 +61,7 @@ program.parse(process.argv) | |||
62 | 61 | ||
63 | // ---------------------------------------------------------------------------- | 62 | // ---------------------------------------------------------------------------- |
64 | 63 | ||
65 | async function pluginsListCLI (command: commander.CommanderStatic, options: commander.OptionValues) { | 64 | async 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 | ||
104 | async function installPluginCLI (command: commander.CommanderStatic, options: commander.OptionValues) { | 103 | async 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 | ||
135 | async function updatePluginCLI (command: commander.CommanderStatic, options: commander.OptionValues) { | 134 | async 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 | ||
166 | async function uninstallPluginCLI (command: commander.CommanderStatic, options: commander.OptionValues) { | 165 | async 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 @@ | |||
3 | import { registerTSPaths } from '../helpers/register-ts-paths' | 3 | import { registerTSPaths } from '../helpers/register-ts-paths' |
4 | registerTSPaths() | 4 | registerTSPaths() |
5 | 5 | ||
6 | import * as program from 'commander' | 6 | import { program, Command } from 'commander' |
7 | import { getAdminTokenOrDie, getServerCredentials } from './cli' | 7 | import { getAdminTokenOrDie, getServerCredentials } from './cli' |
8 | import { VideoRedundanciesTarget, VideoRedundancy } from '@shared/models' | 8 | import { VideoRedundanciesTarget, VideoRedundancy } from '@shared/models' |
9 | import { addVideoRedundancy, listVideoRedundancies, removeVideoRedundancy } from '@shared/extra-utils/server/redundancy' | 9 | import { addVideoRedundancy, listVideoRedundancies, removeVideoRedundancy } from '@shared/extra-utils/server/redundancy' |
@@ -14,7 +14,6 @@ import { URL } from 'url' | |||
14 | import { uniq } from 'lodash' | 14 | import { uniq } from 'lodash' |
15 | 15 | ||
16 | import bytes = require('bytes') | 16 | import bytes = require('bytes') |
17 | import commander = require('commander') | ||
18 | 17 | ||
19 | program | 18 | program |
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 | ||
108 | async function addRedundancyCLI (options: { video: number }, command: commander.CommanderStatic) { | 107 | async 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 | ||
141 | async function removeRedundancyCLI (options: { video: number }, command: commander.CommanderStatic) { | 140 | async 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 @@ | |||
1 | import { registerTSPaths } from '../helpers/register-ts-paths' | 1 | import { registerTSPaths } from '../helpers/register-ts-paths' |
2 | registerTSPaths() | 2 | registerTSPaths() |
3 | 3 | ||
4 | import * as program from 'commander' | 4 | import { program } from 'commander' |
5 | import { access, constants } from 'fs-extra' | 5 | import { access, constants } from 'fs-extra' |
6 | import { isAbsolute } from 'path' | 6 | import { isAbsolute } from 'path' |
7 | import { getAccessToken } from '../../shared/extra-utils' | 7 | import { 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 @@ | |||
1 | import { registerTSPaths } from '../helpers/register-ts-paths' | 1 | import { registerTSPaths } from '../helpers/register-ts-paths' |
2 | registerTSPaths() | 2 | registerTSPaths() |
3 | 3 | ||
4 | import * as program from 'commander' | 4 | import { program, Option, OptionValues } from 'commander' |
5 | import { join } from 'path' | 5 | import { join } from 'path' |
6 | import { execSync } from 'child_process' | 6 | import { 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 | ||
25 | function run (url: string, options: program.OptionValues) { | 25 | function 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 @@ | |||
5 | import { registerTSPaths } from '../helpers/register-ts-paths' | 5 | import { registerTSPaths } from '../helpers/register-ts-paths' |
6 | registerTSPaths() | 6 | registerTSPaths() |
7 | 7 | ||
8 | import * as program from 'commander' | 8 | import { CommandOptions, program } from 'commander' |
9 | import { getSettings, version } from './cli' | 9 | import { getSettings, version } from './cli' |
10 | 10 | ||
11 | program | 11 | program |
@@ -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' | |||
2 | registerTSPaths() | 2 | registerTSPaths() |
3 | 3 | ||
4 | import { LiveVideo, LiveVideoCreate, VideoPrivacy } from '@shared/models' | 4 | import { LiveVideo, LiveVideoCreate, VideoPrivacy } from '@shared/models' |
5 | import * as program from 'commander' | 5 | import { program } from 'commander' |
6 | import { | 6 | import { |
7 | createLive, | 7 | createLive, |
8 | flushAndRunServer, | 8 | flushAndRunServer, |