aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tools/cli.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2019-07-11 17:23:24 +0200
committerChocobozzz <chocobozzz@cpy.re>2019-07-24 10:58:16 +0200
commit8d2be0ed7bb87283a1ec98609df6b82d83db706a (patch)
tree31a36b252df32be83ceb77658a53b57f9d15e8ac /server/tools/cli.ts
parentdba85a1e9e9f603ba52e1ea42deaf3fdd799b1d8 (diff)
downloadPeerTube-8d2be0ed7bb87283a1ec98609df6b82d83db706a.tar.gz
PeerTube-8d2be0ed7bb87283a1ec98609df6b82d83db706a.tar.zst
PeerTube-8d2be0ed7bb87283a1ec98609df6b82d83db706a.zip
WIP plugins: move plugin CLI in peertube script
Install/uninstall/list plugins remotely
Diffstat (limited to 'server/tools/cli.ts')
-rw-r--r--server/tools/cli.ts18
1 files changed, 16 insertions, 2 deletions
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 @@
1import { Netrc } from 'netrc-parser' 1import { Netrc } from 'netrc-parser'
2import { getAppNumber, isTestInstance } from '../helpers/core-utils' 2import { getAppNumber, isTestInstance } from '../helpers/core-utils'
3import { join } from 'path' 3import { join } from 'path'
4import { getVideoChannel, root } from '../../shared/extra-utils' 4import { root } from '../../shared/extra-utils/miscs/miscs'
5import { getVideoChannel } from '../../shared/extra-utils/videos/video-channels'
5import { Command } from 'commander' 6import { Command } from 'commander'
6import { VideoChannel, VideoPrivacy } from '../../shared/models/videos' 7import { VideoChannel, VideoPrivacy } from '../../shared/models/videos'
7 8
@@ -64,7 +65,11 @@ function deleteSettings () {
64 }) 65 })
65} 66}
66 67
67function getRemoteObjectOrDie (program: any, settings: Settings, netrc: Netrc) { 68function getRemoteObjectOrDie (
69 program: any,
70 settings: Settings,
71 netrc: Netrc
72): { url: string, username: string, password: string } {
68 if (!program['url'] || !program['username'] || !program['password']) { 73 if (!program['url'] || !program['username'] || !program['password']) {
69 // No remote and we don't have program parameters: quit 74 // No remote and we don't have program parameters: quit
70 if (settings.remotes.length === 0 || Object.keys(netrc.machines).length === 0) { 75 if (settings.remotes.length === 0 || Object.keys(netrc.machines).length === 0) {
@@ -161,6 +166,13 @@ async function buildVideoAttributesFromCommander (url: string, command: Command,
161 return videoAttributes 166 return videoAttributes
162} 167}
163 168
169function getServerCredentials (program: any) {
170 return Promise.all([ getSettings(), getNetrc() ])
171 .then(([ settings, netrc ]) => {
172 return getRemoteObjectOrDie(program, settings, netrc)
173 })
174}
175
164// --------------------------------------------------------------------------- 176// ---------------------------------------------------------------------------
165 177
166export { 178export {
@@ -172,6 +184,8 @@ export {
172 writeSettings, 184 writeSettings,
173 deleteSettings, 185 deleteSettings,
174 186
187 getServerCredentials,
188
175 buildCommonVideoOptions, 189 buildCommonVideoOptions,
176 buildVideoAttributesFromCommander 190 buildVideoAttributesFromCommander
177} 191}