Update tools dependencies

This commit is contained in:
Chocobozzz 2021-06-25 17:48:27 +02:00
parent 8cc6120118
commit 12152aa09f
No known key found for this signature in database
GPG Key ID: 583A612D890159BE
10 changed files with 25 additions and 27 deletions

View File

@ -3,12 +3,12 @@ import { getAppNumber, isTestInstance } from '../helpers/core-utils'
import { join } from 'path' import { join } from 'path'
import { root } from '../../shared/extra-utils/miscs/miscs' import { root } from '../../shared/extra-utils/miscs/miscs'
import { getVideoChannel } from '../../shared/extra-utils/videos/video-channels' import { getVideoChannel } from '../../shared/extra-utils/videos/video-channels'
import { CommanderStatic } from 'commander'
import { VideoChannel, VideoPrivacy } from '../../shared/models/videos' import { VideoChannel, VideoPrivacy } from '../../shared/models/videos'
import { createLogger, format, transports } from 'winston' import { createLogger, format, transports } from 'winston'
import { getMyUserInformation } from '@shared/extra-utils/users/users' import { getMyUserInformation } from '@shared/extra-utils/users/users'
import { User, UserRole } from '@shared/models' import { User, UserRole } from '@shared/models'
import { getAccessToken } from '@shared/extra-utils/users/login' import { getAccessToken } from '@shared/extra-utils/users/login'
import { Command } from 'commander'
let configName = 'PeerTube/CLI' let configName = 'PeerTube/CLI'
if (isTestInstance()) configName += `-${getAppNumber()}` if (isTestInstance()) configName += `-${getAppNumber()}`
@ -69,7 +69,7 @@ function deleteSettings () {
} }
function getRemoteObjectOrDie ( function getRemoteObjectOrDie (
program: CommanderStatic, program: Command,
settings: Settings, settings: Settings,
netrc: Netrc netrc: Netrc
): { url: string, username: string, password: string } { ): { url: string, username: string, password: string } {
@ -106,7 +106,7 @@ function getRemoteObjectOrDie (
} }
} }
function buildCommonVideoOptions (command: CommanderStatic) { function buildCommonVideoOptions (command: Command) {
function list (val) { function list (val) {
return val.split(',') return val.split(',')
} }
@ -128,7 +128,7 @@ function buildCommonVideoOptions (command: CommanderStatic) {
.option('-v, --verbose <verbose>', 'Verbosity, from 0/\'error\' to 4/\'debug\'', 'info') .option('-v, --verbose <verbose>', 'Verbosity, from 0/\'error\' to 4/\'debug\'', 'info')
} }
async function buildVideoAttributesFromCommander (url: string, command: CommanderStatic, defaultAttributes: any = {}) { async function buildVideoAttributesFromCommander (url: string, command: Command, defaultAttributes: any = {}) {
const options = command.opts() const options = command.opts()
const defaultBooleanAttributes = { const defaultBooleanAttributes = {
@ -177,7 +177,7 @@ async function buildVideoAttributesFromCommander (url: string, command: Commande
return videoAttributes return videoAttributes
} }
function getServerCredentials (program: CommanderStatic) { function getServerCredentials (program: Command) {
return Promise.all([ getSettings(), getNetrc() ]) return Promise.all([ getSettings(), getNetrc() ])
.then(([ settings, netrc ]) => { .then(([ settings, netrc ]) => {
return getRemoteObjectOrDie(program, settings, netrc) return getRemoteObjectOrDie(program, settings, netrc)

View File

@ -3,7 +3,7 @@
import { registerTSPaths } from '../helpers/register-ts-paths' import { registerTSPaths } from '../helpers/register-ts-paths'
registerTSPaths() registerTSPaths()
import * as program from 'commander' import { OptionValues, program } from 'commander'
import * as prompt from 'prompt' import * as prompt from 'prompt'
import { getNetrc, getSettings, writeSettings } from './cli' import { getNetrc, getSettings, writeSettings } from './cli'
import { isUserUsernameValid } from '../helpers/custom-validators/users' import { isUserUsernameValid } from '../helpers/custom-validators/users'
@ -66,7 +66,7 @@ program
.option('-U, --username <username>', 'Username') .option('-U, --username <username>', 'Username')
.option('-p, --password <token>', 'Password') .option('-p, --password <token>', 'Password')
.option('--default', 'add the entry as the new default') .option('--default', 'add the entry as the new default')
.action((options: program.OptionValues) => { .action((options: OptionValues) => {
/* eslint-disable no-import-assign */ /* eslint-disable no-import-assign */
prompt.override = options prompt.override = options
prompt.start() prompt.start()

View File

@ -1,7 +1,7 @@
import { registerTSPaths } from '../helpers/register-ts-paths' import { registerTSPaths } from '../helpers/register-ts-paths'
registerTSPaths() registerTSPaths()
import * as program from 'commander' import { program } from 'commander'
import { getClient, Server, serverLogin } from '../../shared/extra-utils' import { getClient, Server, serverLogin } from '../../shared/extra-utils'
program program

View File

@ -1,7 +1,7 @@
import { registerTSPaths } from '../helpers/register-ts-paths' import { registerTSPaths } from '../helpers/register-ts-paths'
registerTSPaths() registerTSPaths()
import * as program from 'commander' import { program } from 'commander'
import { accessSync, constants } from 'fs' import { accessSync, constants } from 'fs'
import { remove } from 'fs-extra' import { remove } from 'fs-extra'
import { truncate } from 'lodash' import { truncate } from 'lodash'

View File

@ -3,13 +3,12 @@
import { registerTSPaths } from '../helpers/register-ts-paths' import { registerTSPaths } from '../helpers/register-ts-paths'
registerTSPaths() registerTSPaths()
import * as program from 'commander' import { program, Command, OptionValues } from 'commander'
import { installPlugin, listPlugins, uninstallPlugin, updatePlugin } from '../../shared/extra-utils/server/plugins' import { installPlugin, listPlugins, uninstallPlugin, updatePlugin } from '../../shared/extra-utils/server/plugins'
import { getAdminTokenOrDie, getServerCredentials } from './cli' import { getAdminTokenOrDie, getServerCredentials } from './cli'
import { PeerTubePlugin, PluginType } from '../../shared/models' import { PeerTubePlugin, PluginType } from '../../shared/models'
import { isAbsolute } from 'path' import { isAbsolute } from 'path'
import * as CliTable3 from 'cli-table3' import * as CliTable3 from 'cli-table3'
import commander = require('commander')
program program
.name('plugins') .name('plugins')
@ -62,7 +61,7 @@ program.parse(process.argv)
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
async function pluginsListCLI (command: commander.CommanderStatic, options: commander.OptionValues) { async function pluginsListCLI (command: Command, options: OptionValues) {
const { url, username, password } = await getServerCredentials(command) const { url, username, password } = await getServerCredentials(command)
const accessToken = await getAdminTokenOrDie(url, username, password) const accessToken = await getAdminTokenOrDie(url, username, password)
@ -101,7 +100,7 @@ async function pluginsListCLI (command: commander.CommanderStatic, options: comm
process.exit(0) process.exit(0)
} }
async function installPluginCLI (command: commander.CommanderStatic, options: commander.OptionValues) { async function installPluginCLI (command: Command, options: OptionValues) {
if (!options.path && !options.npmName) { if (!options.path && !options.npmName) {
console.error('You need to specify the npm name or the path of the plugin you want to install.\n') console.error('You need to specify the npm name or the path of the plugin you want to install.\n')
program.outputHelp() program.outputHelp()
@ -132,7 +131,7 @@ async function installPluginCLI (command: commander.CommanderStatic, options: co
process.exit(0) process.exit(0)
} }
async function updatePluginCLI (command: commander.CommanderStatic, options: commander.OptionValues) { async function updatePluginCLI (command: Command, options: OptionValues) {
if (!options.path && !options.npmName) { if (!options.path && !options.npmName) {
console.error('You need to specify the npm name or the path of the plugin you want to update.\n') console.error('You need to specify the npm name or the path of the plugin you want to update.\n')
program.outputHelp() program.outputHelp()
@ -163,7 +162,7 @@ async function updatePluginCLI (command: commander.CommanderStatic, options: com
process.exit(0) process.exit(0)
} }
async function uninstallPluginCLI (command: commander.CommanderStatic, options: commander.OptionValues) { async function uninstallPluginCLI (command: Command, options: OptionValues) {
if (!options.npmName) { if (!options.npmName) {
console.error('You need to specify the npm name of the plugin/theme you want to uninstall.\n') console.error('You need to specify the npm name of the plugin/theme you want to uninstall.\n')
program.outputHelp() program.outputHelp()

View File

@ -3,7 +3,7 @@
import { registerTSPaths } from '../helpers/register-ts-paths' import { registerTSPaths } from '../helpers/register-ts-paths'
registerTSPaths() registerTSPaths()
import * as program from 'commander' import { program, Command } from 'commander'
import { getAdminTokenOrDie, getServerCredentials } from './cli' import { getAdminTokenOrDie, getServerCredentials } from './cli'
import { VideoRedundanciesTarget, VideoRedundancy } from '@shared/models' import { VideoRedundanciesTarget, VideoRedundancy } from '@shared/models'
import { addVideoRedundancy, listVideoRedundancies, removeVideoRedundancy } from '@shared/extra-utils/server/redundancy' import { addVideoRedundancy, listVideoRedundancies, removeVideoRedundancy } from '@shared/extra-utils/server/redundancy'
@ -14,7 +14,6 @@ import { URL } from 'url'
import { uniq } from 'lodash' import { uniq } from 'lodash'
import bytes = require('bytes') import bytes = require('bytes')
import commander = require('commander')
program program
.name('plugins') .name('plugins')
@ -105,7 +104,7 @@ async function listRedundanciesCLI (target: VideoRedundanciesTarget) {
process.exit(0) process.exit(0)
} }
async function addRedundancyCLI (options: { video: number }, command: commander.CommanderStatic) { async function addRedundancyCLI (options: { video: number }, command: Command) {
const { url, username, password } = await getServerCredentials(command) const { url, username, password } = await getServerCredentials(command)
const accessToken = await getAdminTokenOrDie(url, username, password) const accessToken = await getAdminTokenOrDie(url, username, password)
@ -138,7 +137,7 @@ async function addRedundancyCLI (options: { video: number }, command: commander.
} }
} }
async function removeRedundancyCLI (options: { video: number }, command: commander.CommanderStatic) { async function removeRedundancyCLI (options: { video: number }, command: Command) {
const { url, username, password } = await getServerCredentials(command) const { url, username, password } = await getServerCredentials(command)
const accessToken = await getAdminTokenOrDie(url, username, password) const accessToken = await getAdminTokenOrDie(url, username, password)

View File

@ -1,7 +1,7 @@
import { registerTSPaths } from '../helpers/register-ts-paths' import { registerTSPaths } from '../helpers/register-ts-paths'
registerTSPaths() registerTSPaths()
import * as program from 'commander' import { program } from 'commander'
import { access, constants } from 'fs-extra' import { access, constants } from 'fs-extra'
import { isAbsolute } from 'path' import { isAbsolute } from 'path'
import { getAccessToken } from '../../shared/extra-utils' import { getAccessToken } from '../../shared/extra-utils'

View File

@ -1,7 +1,7 @@
import { registerTSPaths } from '../helpers/register-ts-paths' import { registerTSPaths } from '../helpers/register-ts-paths'
registerTSPaths() registerTSPaths()
import * as program from 'commander' import { program, Option, OptionValues } from 'commander'
import { join } from 'path' import { join } from 'path'
import { execSync } from 'child_process' import { execSync } from 'child_process'
@ -9,7 +9,7 @@ program
.name('watch') .name('watch')
.arguments('<url>') .arguments('<url>')
.addOption( .addOption(
new program.Option('-g, --gui <player>', 'player type') new Option('-g, --gui <player>', 'player type')
.default('vlc') .default('vlc')
.choices([ 'airplay', 'stdout', 'chromecast', 'mpv', 'vlc', 'mplayer', 'xbmc' ]) .choices([ 'airplay', 'stdout', 'chromecast', 'mpv', 'vlc', 'mplayer', 'xbmc' ])
) )
@ -22,7 +22,7 @@ program
.action((url, options) => run(url, options)) .action((url, options) => run(url, options))
.parse(process.argv) .parse(process.argv)
function run (url: string, options: program.OptionValues) { function run (url: string, options: OptionValues) {
if (!url) { if (!url) {
console.error('<url> positional argument is required.') console.error('<url> positional argument is required.')
process.exit(-1) process.exit(-1)

View File

@ -5,7 +5,7 @@
import { registerTSPaths } from '../helpers/register-ts-paths' import { registerTSPaths } from '../helpers/register-ts-paths'
registerTSPaths() registerTSPaths()
import * as program from 'commander' import { CommandOptions, program } from 'commander'
import { getSettings, version } from './cli' import { getSettings, version } from './cli'
program program
@ -28,11 +28,11 @@ program
.command( .command(
'diagnostic [action]', 'diagnostic [action]',
'like couple therapy, but for your instance', 'like couple therapy, but for your instance',
{ noHelp: true } as program.CommandOptions { noHelp: true } as CommandOptions
).alias('d') ).alias('d')
.command('admin', .command('admin',
'manage an instance where you have elevated rights', 'manage an instance where you have elevated rights',
{ noHelp: true } as program.CommandOptions { noHelp: true } as CommandOptions
).alias('a') ).alias('a')
// help on no command // help on no command

View File

@ -2,7 +2,7 @@ import { registerTSPaths } from '../helpers/register-ts-paths'
registerTSPaths() registerTSPaths()
import { LiveVideo, LiveVideoCreate, VideoPrivacy } from '@shared/models' import { LiveVideo, LiveVideoCreate, VideoPrivacy } from '@shared/models'
import * as program from 'commander' import { program } from 'commander'
import { import {
createLive, createLive,
flushAndRunServer, flushAndRunServer,