aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tools
diff options
context:
space:
mode:
Diffstat (limited to 'server/tools')
-rw-r--r--server/tools/cli.ts15
-rw-r--r--server/tools/peertube-import-videos.ts4
-rw-r--r--server/tools/test-live.ts8
3 files changed, 12 insertions, 15 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
diff --git a/server/tools/peertube-import-videos.ts b/server/tools/peertube-import-videos.ts
index caf1facc7..52aae3d2c 100644
--- a/server/tools/peertube-import-videos.ts
+++ b/server/tools/peertube-import-videos.ts
@@ -20,7 +20,7 @@ import {
20 getLogger, 20 getLogger,
21 getServerCredentials 21 getServerCredentials
22} from './cli' 22} from './cli'
23import { ServerInfo } from '@shared/extra-utils' 23import { PeerTubeServer } from '@shared/extra-utils'
24 24
25const processOptions = { 25const processOptions = {
26 maxBuffer: Infinity 26 maxBuffer: Infinity
@@ -270,7 +270,7 @@ async function uploadVideoOnPeerTube (parameters: {
270 270
271/* ---------------------------------------------------------- */ 271/* ---------------------------------------------------------- */
272 272
273async function getCategory (server: ServerInfo, categories: string[]) { 273async function getCategory (server: PeerTubeServer, categories: string[]) {
274 if (!categories) return undefined 274 if (!categories) return undefined
275 275
276 const categoryString = categories[0] 276 const categoryString = categories[0]
diff --git a/server/tools/test-live.ts b/server/tools/test-live.ts
index bc31b6926..0cb0c3668 100644
--- a/server/tools/test-live.ts
+++ b/server/tools/test-live.ts
@@ -1,10 +1,10 @@
1import { program } from 'commander' 1import { program } from 'commander'
2import { LiveVideoCreate, VideoPrivacy } from '@shared/models' 2import { LiveVideoCreate, VideoPrivacy } from '@shared/models'
3import { 3import {
4 flushAndRunServer, 4 createSingleServer,
5 killallServers, 5 killallServers,
6 sendRTMPStream, 6 sendRTMPStream,
7 ServerInfo, 7 PeerTubeServer,
8 setAccessTokensToServers, 8 setAccessTokensToServers,
9 setDefaultVideoChannel 9 setDefaultVideoChannel
10} from '../../shared/extra-utils' 10} from '../../shared/extra-utils'
@@ -36,7 +36,7 @@ async function run () {
36 36
37 console.log('Starting server.') 37 console.log('Starting server.')
38 38
39 const server = await flushAndRunServer(1, {}, [], { hideLogs: false, execArgv: [ '--inspect' ] }) 39 const server = await createSingleServer(1, {}, [], { hideLogs: false, execArgv: [ '--inspect' ] })
40 40
41 const cleanup = async () => { 41 const cleanup = async () => {
42 console.log('Killing server') 42 console.log('Killing server')
@@ -81,7 +81,7 @@ async function run () {
81 81
82// ---------------------------------------------------------------------------- 82// ----------------------------------------------------------------------------
83 83
84async function buildConfig (server: ServerInfo, commandType: CommandType) { 84async function buildConfig (server: PeerTubeServer, commandType: CommandType) {
85 await server.config.updateCustomSubConfig({ 85 await server.config.updateCustomSubConfig({
86 newConfig: { 86 newConfig: {
87 instance: { 87 instance: {