From 078f17e6d90376050f43ce639e88e11869b49ee7 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 9 Jul 2021 15:03:44 +0200 Subject: Fix CLI tools --- shared/extra-utils/server/servers.ts | 89 +++++++++++++++++++----------------- shared/extra-utils/users/login.ts | 4 +- 2 files changed, 49 insertions(+), 44 deletions(-) (limited to 'shared') diff --git a/shared/extra-utils/server/servers.ts b/shared/extra-utils/server/servers.ts index 8e80a9842..41b48a8ee 100644 --- a/shared/extra-utils/server/servers.ts +++ b/shared/extra-utils/server/servers.ts @@ -41,25 +41,25 @@ import { RedundancyCommand } from './redundancy-command' import { StatsCommand } from './stats-command' interface ServerInfo { - app: ChildProcess + app?: ChildProcess url: string - host: string - hostname: string - port: number + host?: string + hostname?: string + port?: number - rtmpPort: number + rtmpPort?: number - parallel: boolean + parallel?: boolean internalServerNumber: number - serverNumber: number + serverNumber?: number - client: { - id: string - secret: string + client?: { + id?: string + secret?: string } - user: { + user?: { username: string password: string email?: string @@ -328,43 +328,47 @@ async function runServer (server: ServerInfo, configOverrideArg?: any, args = [] } catch { /* empty */ } }) - server.bulkCommand = new BulkCommand(server) - server.cliCommand = new CLICommand(server) - server.customPageCommand = new CustomPagesCommand(server) - server.feedCommand = new FeedCommand(server) - server.logsCommand = new LogsCommand(server) - server.abusesCommand = new AbusesCommand(server) - server.overviewsCommand = new OverviewsCommand(server) - server.searchCommand = new SearchCommand(server) - server.contactFormCommand = new ContactFormCommand(server) - server.debugCommand = new DebugCommand(server) - server.followsCommand = new FollowsCommand(server) - server.jobsCommand = new JobsCommand(server) - server.pluginsCommand = new PluginsCommand(server) - server.redundancyCommand = new RedundancyCommand(server) - server.statsCommand = new StatsCommand(server) - server.configCommand = new ConfigCommand(server) - server.socketIOCommand = new SocketIOCommand(server) - server.accountsCommand = new AccountsCommand(server) - server.blocklistCommand = new BlocklistCommand(server) - server.subscriptionsCommand = new SubscriptionsCommand(server) - server.liveCommand = new LiveCommand(server) - server.servicesCommand = new ServicesCommand(server) - server.blacklistCommand = new BlacklistCommand(server) - server.captionsCommand = new CaptionsCommand(server) - server.changeOwnershipCommand = new ChangeOwnershipCommand(server) - server.playlistsCommand = new PlaylistsCommand(server) - server.historyCommand = new HistoryCommand(server) - server.importsCommand = new ImportsCommand(server) - server.streamingPlaylistsCommand = new StreamingPlaylistsCommand(server) - server.channelsCommand = new ChannelsCommand(server) - server.commentsCommand = new CommentsCommand(server) + assignCommands(server) res(server) }) }) } +function assignCommands (server: ServerInfo) { + server.bulkCommand = new BulkCommand(server) + server.cliCommand = new CLICommand(server) + server.customPageCommand = new CustomPagesCommand(server) + server.feedCommand = new FeedCommand(server) + server.logsCommand = new LogsCommand(server) + server.abusesCommand = new AbusesCommand(server) + server.overviewsCommand = new OverviewsCommand(server) + server.searchCommand = new SearchCommand(server) + server.contactFormCommand = new ContactFormCommand(server) + server.debugCommand = new DebugCommand(server) + server.followsCommand = new FollowsCommand(server) + server.jobsCommand = new JobsCommand(server) + server.pluginsCommand = new PluginsCommand(server) + server.redundancyCommand = new RedundancyCommand(server) + server.statsCommand = new StatsCommand(server) + server.configCommand = new ConfigCommand(server) + server.socketIOCommand = new SocketIOCommand(server) + server.accountsCommand = new AccountsCommand(server) + server.blocklistCommand = new BlocklistCommand(server) + server.subscriptionsCommand = new SubscriptionsCommand(server) + server.liveCommand = new LiveCommand(server) + server.servicesCommand = new ServicesCommand(server) + server.blacklistCommand = new BlacklistCommand(server) + server.captionsCommand = new CaptionsCommand(server) + server.changeOwnershipCommand = new ChangeOwnershipCommand(server) + server.playlistsCommand = new PlaylistsCommand(server) + server.historyCommand = new HistoryCommand(server) + server.importsCommand = new ImportsCommand(server) + server.streamingPlaylistsCommand = new StreamingPlaylistsCommand(server) + server.channelsCommand = new ChannelsCommand(server) + server.commentsCommand = new CommentsCommand(server) +} + async function reRunServer (server: ServerInfo, configOverride?: any) { const newServer = await runServer(server, configOverride) server.app = newServer.app @@ -475,5 +479,6 @@ export { flushAndRunServer, killallServers, reRunServer, + assignCommands, waitUntilLog } diff --git a/shared/extra-utils/users/login.ts b/shared/extra-utils/users/login.ts index 39e1a2747..c14367542 100644 --- a/shared/extra-utils/users/login.ts +++ b/shared/extra-utils/users/login.ts @@ -4,9 +4,9 @@ import { ServerInfo } from '../server/servers' import { getClient } from '../server/clients' import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes' -type Client = { id: string, secret: string } +type Client = { id?: string, secret?: string } type User = { username: string, password: string } -type Server = { url: string, client: Client, user: User } +type Server = { url?: string, client?: Client, user?: User } function login (url: string, client: Client, user: User, expectedStatus = HttpStatusCode.OK_200) { const path = '/api/v1/users/token' -- cgit v1.2.3