aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tools/cli.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-07-16 09:47:51 +0200
committerChocobozzz <me@florianbigard.com>2021-07-20 15:27:18 +0200
commit254d3579f5338f5fd775c17d15cdfc37078bcfb4 (patch)
treeeaeb13fda16c16e98cd6991d202b0ca6a4cbdb63 /server/tools/cli.ts
parent89d241a79c262b9775c233b73cff080043ebb5e6 (diff)
downloadPeerTube-254d3579f5338f5fd775c17d15cdfc37078bcfb4.tar.gz
PeerTube-254d3579f5338f5fd775c17d15cdfc37078bcfb4.tar.zst
PeerTube-254d3579f5338f5fd775c17d15cdfc37078bcfb4.zip
Use an object to represent a server
Diffstat (limited to 'server/tools/cli.ts')
-rw-r--r--server/tools/cli.ts15
1 files changed, 6 insertions, 9 deletions
diff --git a/server/tools/cli.ts b/server/tools/cli.ts
index 7d5eb72ed..52e6ea593 100644
--- a/server/tools/cli.ts
+++ b/server/tools/cli.ts
@@ -2,7 +2,7 @@ import { Command } from 'commander'
2import { Netrc } from 'netrc-parser' 2import { Netrc } from 'netrc-parser'
3import { join } from 'path' 3import { join } from 'path'
4import { createLogger, format, transports } from 'winston' 4import { createLogger, format, transports } from 'winston'
5import { assignCommands, ServerInfo } from '@shared/extra-utils' 5import { PeerTubeServer } from '@shared/extra-utils'
6import { UserRole } from '@shared/models' 6import { UserRole } from '@shared/models'
7import { VideoPrivacy } from '../../shared/models/videos' 7import { VideoPrivacy } from '../../shared/models/videos'
8import { getAppNumber, isTestInstance, root } from '../helpers/core-utils' 8import { getAppNumber, isTestInstance, root } from '../helpers/core-utils'
@@ -14,7 +14,7 @@ const config = require('application-config')(configName)
14 14
15const version = require('../../../package.json').version 15const version = require('../../../package.json').version
16 16
17async function getAdminTokenOrDie (server: ServerInfo, username: string, password: string) { 17async function getAdminTokenOrDie (server: PeerTubeServer, username: string, password: string) {
18 const token = await server.login.getAccessToken(username, password) 18 const token = await server.login.getAccessToken(username, password)
19 const me = await server.users.getMyInfo({ token }) 19 const me = await server.users.getMyInfo({ token })
20 20
@@ -124,7 +124,7 @@ function buildCommonVideoOptions (command: Command) {
124 .option('-v, --verbose <verbose>', 'Verbosity, from 0/\'error\' to 4/\'debug\'', 'info') 124 .option('-v, --verbose <verbose>', 'Verbosity, from 0/\'error\' to 4/\'debug\'', 'info')
125} 125}
126 126
127async function buildVideoAttributesFromCommander (server: ServerInfo, command: Command, defaultAttributes: any = {}) { 127async function buildVideoAttributesFromCommander (server: PeerTubeServer, command: Command, defaultAttributes: any = {}) {
128 const options = command.opts() 128 const options = command.opts()
129 129
130 const defaultBooleanAttributes = { 130 const defaultBooleanAttributes = {
@@ -179,14 +179,11 @@ function getServerCredentials (program: Command) {
179 }) 179 })
180} 180}
181 181
182function buildServer (url: string): ServerInfo { 182function buildServer (url: string) {
183 const server = { url, internalServerNumber: undefined } 183 return new PeerTubeServer({ url })
184 assignCommands(server)
185
186 return server
187} 184}
188 185
189async function assignToken (server: ServerInfo, username: string, password: string) { 186async function assignToken (server: PeerTubeServer, username: string, password: string) {
190 const bodyClient = await server.login.getClient() 187 const bodyClient = await server.login.getClient()
191 const client = { id: bodyClient.client_id, secret: bodyClient.client_secret } 188 const client = { id: bodyClient.client_id, secret: bodyClient.client_secret }
192 189