diff options
Diffstat (limited to 'server/tools/peertube-auth.ts')
-rw-r--r-- | server/tools/peertube-auth.ts | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/server/tools/peertube-auth.ts b/server/tools/peertube-auth.ts index a962944a4..8bc3d332c 100644 --- a/server/tools/peertube-auth.ts +++ b/server/tools/peertube-auth.ts | |||
@@ -1,22 +1,25 @@ | |||
1 | import * as program from 'commander' | 1 | import * as program from 'commander' |
2 | import * as prompt from 'prompt' | 2 | import * as prompt from 'prompt' |
3 | const Table = require('cli-table') | 3 | import { getSettings, writeSettings, getNetrc } from './cli' |
4 | import { getSettings, writeSettings, netrc } from './cli' | ||
5 | import { isHostValid } from '../helpers/custom-validators/servers' | 4 | import { isHostValid } from '../helpers/custom-validators/servers' |
6 | import { isUserUsernameValid } from '../helpers/custom-validators/users' | 5 | import { isUserUsernameValid } from '../helpers/custom-validators/users' |
7 | 6 | ||
7 | const Table = require('cli-table') | ||
8 | |||
8 | async function delInstance (url: string) { | 9 | async function delInstance (url: string) { |
9 | const settings = await getSettings() | 10 | const [ settings, netrc ] = await Promise.all([ getSettings(), getNetrc() ]) |
10 | 11 | ||
11 | settings.remotes.splice(settings.remotes.indexOf(url)) | 12 | settings.remotes.splice(settings.remotes.indexOf(url)) |
12 | await writeSettings(settings) | 13 | await writeSettings(settings) |
13 | 14 | ||
14 | delete netrc.machines[url] | 15 | delete netrc.machines[url] |
16 | |||
15 | await netrc.save() | 17 | await netrc.save() |
16 | } | 18 | } |
17 | 19 | ||
18 | async function setInstance (url: string, username: string, password: string) { | 20 | async function setInstance (url: string, username: string, password: string) { |
19 | const settings = await getSettings() | 21 | const [ settings, netrc ] = await Promise.all([ getSettings(), getNetrc() ]) |
22 | |||
20 | if (settings.remotes.indexOf(url) === -1) { | 23 | if (settings.remotes.indexOf(url) === -1) { |
21 | settings.remotes.push(url) | 24 | settings.remotes.push(url) |
22 | } | 25 | } |
@@ -82,12 +85,13 @@ program | |||
82 | .command('list') | 85 | .command('list') |
83 | .description('lists registered remote instances') | 86 | .description('lists registered remote instances') |
84 | .action(async () => { | 87 | .action(async () => { |
85 | const settings = await getSettings() | 88 | const [ settings, netrc ] = await Promise.all([ getSettings(), getNetrc() ]) |
89 | |||
86 | const table = new Table({ | 90 | const table = new Table({ |
87 | head: ['instance', 'login'], | 91 | head: ['instance', 'login'], |
88 | colWidths: [30, 30] | 92 | colWidths: [30, 30] |
89 | }) | 93 | }) |
90 | netrc.loadSync() | 94 | |
91 | settings.remotes.forEach(element => { | 95 | settings.remotes.forEach(element => { |
92 | table.push([ | 96 | table.push([ |
93 | element, | 97 | element, |