diff options
author | Chocobozzz <me@florianbigard.com> | 2021-07-16 09:47:51 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2021-07-20 15:27:18 +0200 |
commit | 254d3579f5338f5fd775c17d15cdfc37078bcfb4 (patch) | |
tree | eaeb13fda16c16e98cd6991d202b0ca6a4cbdb63 /server/tools/cli.ts | |
parent | 89d241a79c262b9775c233b73cff080043ebb5e6 (diff) | |
download | PeerTube-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.ts | 15 |
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' | |||
2 | import { Netrc } from 'netrc-parser' | 2 | import { Netrc } from 'netrc-parser' |
3 | import { join } from 'path' | 3 | import { join } from 'path' |
4 | import { createLogger, format, transports } from 'winston' | 4 | import { createLogger, format, transports } from 'winston' |
5 | import { assignCommands, ServerInfo } from '@shared/extra-utils' | 5 | import { PeerTubeServer } from '@shared/extra-utils' |
6 | import { UserRole } from '@shared/models' | 6 | import { UserRole } from '@shared/models' |
7 | import { VideoPrivacy } from '../../shared/models/videos' | 7 | import { VideoPrivacy } from '../../shared/models/videos' |
8 | import { getAppNumber, isTestInstance, root } from '../helpers/core-utils' | 8 | import { getAppNumber, isTestInstance, root } from '../helpers/core-utils' |
@@ -14,7 +14,7 @@ const config = require('application-config')(configName) | |||
14 | 14 | ||
15 | const version = require('../../../package.json').version | 15 | const version = require('../../../package.json').version |
16 | 16 | ||
17 | async function getAdminTokenOrDie (server: ServerInfo, username: string, password: string) { | 17 | async 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 | ||
127 | async function buildVideoAttributesFromCommander (server: ServerInfo, command: Command, defaultAttributes: any = {}) { | 127 | async 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 | ||
182 | function buildServer (url: string): ServerInfo { | 182 | function 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 | ||
189 | async function assignToken (server: ServerInfo, username: string, password: string) { | 186 | async 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 | ||