From 8d2be0ed7bb87283a1ec98609df6b82d83db706a Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 11 Jul 2019 17:23:24 +0200 Subject: WIP plugins: move plugin CLI in peertube script Install/uninstall/list plugins remotely --- server/tools/cli.ts | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'server/tools/cli.ts') diff --git a/server/tools/cli.ts b/server/tools/cli.ts index 2eec51aa4..67755022c 100644 --- a/server/tools/cli.ts +++ b/server/tools/cli.ts @@ -1,7 +1,8 @@ import { Netrc } from 'netrc-parser' import { getAppNumber, isTestInstance } from '../helpers/core-utils' import { join } from 'path' -import { getVideoChannel, root } from '../../shared/extra-utils' +import { root } from '../../shared/extra-utils/miscs/miscs' +import { getVideoChannel } from '../../shared/extra-utils/videos/video-channels' import { Command } from 'commander' import { VideoChannel, VideoPrivacy } from '../../shared/models/videos' @@ -64,7 +65,11 @@ function deleteSettings () { }) } -function getRemoteObjectOrDie (program: any, settings: Settings, netrc: Netrc) { +function getRemoteObjectOrDie ( + program: any, + settings: Settings, + netrc: Netrc +): { url: string, username: string, password: string } { if (!program['url'] || !program['username'] || !program['password']) { // No remote and we don't have program parameters: quit if (settings.remotes.length === 0 || Object.keys(netrc.machines).length === 0) { @@ -161,6 +166,13 @@ async function buildVideoAttributesFromCommander (url: string, command: Command, return videoAttributes } +function getServerCredentials (program: any) { + return Promise.all([ getSettings(), getNetrc() ]) + .then(([ settings, netrc ]) => { + return getRemoteObjectOrDie(program, settings, netrc) + }) +} + // --------------------------------------------------------------------------- export { @@ -172,6 +184,8 @@ export { writeSettings, deleteSettings, + getServerCredentials, + buildCommonVideoOptions, buildVideoAttributesFromCommander } -- cgit v1.2.3