diff options
Diffstat (limited to 'server/tools')
-rw-r--r-- | server/tools/cli.ts | 9 | ||||
-rw-r--r-- | server/tools/peertube-auth.ts | 9 | ||||
-rw-r--r-- | server/tools/peertube-get-access-token.ts | 3 | ||||
-rw-r--r-- | server/tools/peertube-import-videos.ts | 10 | ||||
-rw-r--r-- | server/tools/peertube-plugins.ts | 16 | ||||
-rw-r--r-- | server/tools/peertube-redundancy.ts | 5 | ||||
-rw-r--r-- | server/tools/peertube-upload.ts | 3 | ||||
-rw-r--r-- | server/tools/peertube.ts | 3 | ||||
-rw-r--r-- | server/tools/tsconfig.json | 12 |
9 files changed, 31 insertions, 39 deletions
diff --git a/server/tools/cli.ts b/server/tools/cli.ts index 52e6ea593..a844b9dcf 100644 --- a/server/tools/cli.ts +++ b/server/tools/cli.ts | |||
@@ -2,17 +2,19 @@ import { Command } from 'commander' | |||
2 | import { Netrc } from 'netrc-parser' | 2 | import { Netrc } from 'netrc-parser' |
3 | import { join } from 'path' | 3 | import { join } from 'path' |
4 | import { createLogger, format, transports } from 'winston' | 4 | import { createLogger, format, transports } from 'winston' |
5 | import { PeerTubeServer } from '@shared/extra-utils' | 5 | import { loadLanguages } from '@server/initializers/constants' |
6 | import { root } from '@shared/core-utils' | ||
6 | import { UserRole } from '@shared/models' | 7 | import { UserRole } from '@shared/models' |
8 | import { PeerTubeServer } from '@shared/server-commands' | ||
7 | import { VideoPrivacy } from '../../shared/models/videos' | 9 | import { VideoPrivacy } from '../../shared/models/videos' |
8 | import { getAppNumber, isTestInstance, root } from '../helpers/core-utils' | 10 | import { getAppNumber, isTestInstance } from '../helpers/core-utils' |
9 | 11 | ||
10 | let configName = 'PeerTube/CLI' | 12 | let configName = 'PeerTube/CLI' |
11 | if (isTestInstance()) configName += `-${getAppNumber()}` | 13 | if (isTestInstance()) configName += `-${getAppNumber()}` |
12 | 14 | ||
13 | const config = require('application-config')(configName) | 15 | const config = require('application-config')(configName) |
14 | 16 | ||
15 | const version = require('../../../package.json').version | 17 | const version = require(join(root(), 'package.json')).version |
16 | 18 | ||
17 | async function getAdminTokenOrDie (server: PeerTubeServer, username: string, password: string) { | 19 | async function getAdminTokenOrDie (server: PeerTubeServer, username: string, password: string) { |
18 | const token = await server.login.getAccessToken(username, password) | 20 | const token = await server.login.getAccessToken(username, password) |
@@ -180,6 +182,7 @@ function getServerCredentials (program: Command) { | |||
180 | } | 182 | } |
181 | 183 | ||
182 | function buildServer (url: string) { | 184 | function buildServer (url: string) { |
185 | loadLanguages() | ||
183 | return new PeerTubeServer({ url }) | 186 | return new PeerTubeServer({ url }) |
184 | } | 187 | } |
185 | 188 | ||
diff --git a/server/tools/peertube-auth.ts b/server/tools/peertube-auth.ts index afa19ee08..f8ac8b2ab 100644 --- a/server/tools/peertube-auth.ts +++ b/server/tools/peertube-auth.ts | |||
@@ -1,12 +1,7 @@ | |||
1 | // eslint-disable @typescript-eslint/no-unnecessary-type-assertion | 1 | import CliTable3 from 'cli-table3' |
2 | |||
3 | import { registerTSPaths } from '../helpers/register-ts-paths' | ||
4 | registerTSPaths() | ||
5 | |||
6 | import { OptionValues, program } from 'commander' | 2 | import { OptionValues, program } from 'commander' |
7 | import { assignToken, buildServer, getNetrc, getSettings, writeSettings } from './cli' | ||
8 | import { isUserUsernameValid } from '../helpers/custom-validators/users' | 3 | import { isUserUsernameValid } from '../helpers/custom-validators/users' |
9 | import CliTable3 from 'cli-table3' | 4 | import { assignToken, buildServer, getNetrc, getSettings, writeSettings } from './cli' |
10 | 5 | ||
11 | import prompt = require('prompt') | 6 | import prompt = require('prompt') |
12 | 7 | ||
diff --git a/server/tools/peertube-get-access-token.ts b/server/tools/peertube-get-access-token.ts index a67de9180..d59a3632e 100644 --- a/server/tools/peertube-get-access-token.ts +++ b/server/tools/peertube-get-access-token.ts | |||
@@ -1,6 +1,3 @@ | |||
1 | import { registerTSPaths } from '../helpers/register-ts-paths' | ||
2 | registerTSPaths() | ||
3 | |||
4 | import { program } from 'commander' | 1 | import { program } from 'commander' |
5 | import { assignToken, buildServer } from './cli' | 2 | import { assignToken, buildServer } from './cli' |
6 | 3 | ||
diff --git a/server/tools/peertube-import-videos.ts b/server/tools/peertube-import-videos.ts index a758beef9..661a4cf35 100644 --- a/server/tools/peertube-import-videos.ts +++ b/server/tools/peertube-import-videos.ts | |||
@@ -1,11 +1,10 @@ | |||
1 | import { registerTSPaths } from '../helpers/register-ts-paths' | ||
2 | registerTSPaths() | ||
3 | |||
4 | import { program } from 'commander' | 1 | import { program } from 'commander' |
5 | import { accessSync, constants } from 'fs' | 2 | import { accessSync, constants } from 'fs' |
6 | import { remove } from 'fs-extra' | 3 | import { remove } from 'fs-extra' |
7 | import { join } from 'path' | 4 | import { join } from 'path' |
8 | import { sha256 } from '../helpers/core-utils' | 5 | import { YoutubeDLCLI, YoutubeDLInfo, YoutubeDLInfoBuilder } from '@server/helpers/youtube-dl' |
6 | import { wait } from '@shared/core-utils' | ||
7 | import { sha256 } from '@shared/extra-utils' | ||
9 | import { doRequestAndSaveToFile } from '../helpers/requests' | 8 | import { doRequestAndSaveToFile } from '../helpers/requests' |
10 | import { | 9 | import { |
11 | assignToken, | 10 | assignToken, |
@@ -15,8 +14,7 @@ import { | |||
15 | getLogger, | 14 | getLogger, |
16 | getServerCredentials | 15 | getServerCredentials |
17 | } from './cli' | 16 | } from './cli' |
18 | import { wait } from '@shared/extra-utils' | 17 | |
19 | import { YoutubeDLCLI, YoutubeDLInfo, YoutubeDLInfoBuilder } from '@server/helpers/youtube-dl' | ||
20 | import prompt = require('prompt') | 18 | import prompt = require('prompt') |
21 | 19 | ||
22 | const processOptions = { | 20 | const processOptions = { |
diff --git a/server/tools/peertube-plugins.ts b/server/tools/peertube-plugins.ts index ae625114d..47090b3a5 100644 --- a/server/tools/peertube-plugins.ts +++ b/server/tools/peertube-plugins.ts | |||
@@ -1,13 +1,8 @@ | |||
1 | // eslint-disable @typescript-eslint/no-unnecessary-type-assertion | ||
2 | |||
3 | import { registerTSPaths } from '../helpers/register-ts-paths' | ||
4 | registerTSPaths() | ||
5 | |||
6 | import { program, Command, OptionValues } from 'commander' | ||
7 | import { assignToken, buildServer, getServerCredentials } from './cli' | ||
8 | import { PluginType } from '../../shared/models' | ||
9 | import { isAbsolute } from 'path' | ||
10 | import CliTable3 from 'cli-table3' | 1 | import CliTable3 from 'cli-table3' |
2 | import { Command, OptionValues, program } from 'commander' | ||
3 | import { isAbsolute } from 'path' | ||
4 | import { PluginType } from '../../shared/models' | ||
5 | import { assignToken, buildServer, getServerCredentials } from './cli' | ||
11 | 6 | ||
12 | program | 7 | program |
13 | .name('plugins') | 8 | .name('plugins') |
@@ -31,6 +26,7 @@ program | |||
31 | .option('-p, --password <token>', 'Password') | 26 | .option('-p, --password <token>', 'Password') |
32 | .option('-P --path <path>', 'Install from a path') | 27 | .option('-P --path <path>', 'Install from a path') |
33 | .option('-n, --npm-name <npmName>', 'Install from npm') | 28 | .option('-n, --npm-name <npmName>', 'Install from npm') |
29 | .option('--plugin-version <pluginVersion>', 'Specify the plugin version to install (only available when installing from npm)') | ||
34 | .action((options, command) => installPluginCLI(command, options)) | 30 | .action((options, command) => installPluginCLI(command, options)) |
35 | 31 | ||
36 | program | 32 | program |
@@ -109,7 +105,7 @@ async function installPluginCLI (command: Command, options: OptionValues) { | |||
109 | await assignToken(server, username, password) | 105 | await assignToken(server, username, password) |
110 | 106 | ||
111 | try { | 107 | try { |
112 | await server.plugins.install({ npmName: options.npmName, path: options.path }) | 108 | await server.plugins.install({ npmName: options.npmName, path: options.path, pluginVersion: options.pluginVersion }) |
113 | } catch (err) { | 109 | } catch (err) { |
114 | console.error('Cannot install plugin.', err) | 110 | console.error('Cannot install plugin.', err) |
115 | process.exit(-1) | 111 | process.exit(-1) |
diff --git a/server/tools/peertube-redundancy.ts b/server/tools/peertube-redundancy.ts index 7e27ca49e..2c62a3c19 100644 --- a/server/tools/peertube-redundancy.ts +++ b/server/tools/peertube-redundancy.ts | |||
@@ -1,6 +1,3 @@ | |||
1 | import { registerTSPaths } from '../helpers/register-ts-paths' | ||
2 | registerTSPaths() | ||
3 | |||
4 | import CliTable3 from 'cli-table3' | 1 | import CliTable3 from 'cli-table3' |
5 | import { Command, program } from 'commander' | 2 | import { Command, program } from 'commander' |
6 | import { uniq } from 'lodash' | 3 | import { uniq } from 'lodash' |
@@ -12,7 +9,7 @@ import { assignToken, buildServer, getServerCredentials } from './cli' | |||
12 | import bytes = require('bytes') | 9 | import bytes = require('bytes') |
13 | 10 | ||
14 | program | 11 | program |
15 | .name('plugins') | 12 | .name('redundancy') |
16 | .usage('[command] [options]') | 13 | .usage('[command] [options]') |
17 | 14 | ||
18 | program | 15 | program |
diff --git a/server/tools/peertube-upload.ts b/server/tools/peertube-upload.ts index 01fb1fe8d..08bd5f2bb 100644 --- a/server/tools/peertube-upload.ts +++ b/server/tools/peertube-upload.ts | |||
@@ -1,6 +1,3 @@ | |||
1 | import { registerTSPaths } from '../helpers/register-ts-paths' | ||
2 | registerTSPaths() | ||
3 | |||
4 | import { program } from 'commander' | 1 | import { program } from 'commander' |
5 | import { access, constants } from 'fs-extra' | 2 | import { access, constants } from 'fs-extra' |
6 | import { isAbsolute } from 'path' | 3 | import { isAbsolute } from 'path' |
diff --git a/server/tools/peertube.ts b/server/tools/peertube.ts index 9e07640f0..1d3158044 100644 --- a/server/tools/peertube.ts +++ b/server/tools/peertube.ts | |||
@@ -1,8 +1,5 @@ | |||
1 | #!/usr/bin/env node | 1 | #!/usr/bin/env node |
2 | 2 | ||
3 | import { registerTSPaths } from '../helpers/register-ts-paths' | ||
4 | registerTSPaths() | ||
5 | |||
6 | import { CommandOptions, program } from 'commander' | 3 | import { CommandOptions, program } from 'commander' |
7 | import { getSettings, version } from './cli' | 4 | import { getSettings, version } from './cli' |
8 | 5 | ||
diff --git a/server/tools/tsconfig.json b/server/tools/tsconfig.json index 156a8ed22..8264f5b35 100644 --- a/server/tools/tsconfig.json +++ b/server/tools/tsconfig.json | |||
@@ -1,5 +1,17 @@ | |||
1 | { | 1 | { |
2 | "extends": "../../tsconfig.json", | 2 | "extends": "../../tsconfig.json", |
3 | "compilerOptions": { | ||
4 | "baseUrl": "./", | ||
5 | "outDir": "../../dist/server/tools", | ||
6 | "paths": { // FIXME: https://github.com/benyap/resolve-tspaths/issues/10 | ||
7 | "@server/*": [ "../../server/*" ], | ||
8 | "@shared/*": [ "../../shared/*" ] | ||
9 | } | ||
10 | }, | ||
3 | "include": [ ".", "../typings" ], | 11 | "include": [ ".", "../typings" ], |
12 | "references": [ | ||
13 | { "path": "../" } | ||
14 | ], | ||
15 | "files": [], | ||
4 | "exclude": [ ] // Overwrite exclude property | 16 | "exclude": [ ] // Overwrite exclude property |
5 | } | 17 | } |