From f8360396ffabd2f95e9ece9c5755173bae0114b6 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Mon, 3 Jan 2022 17:13:11 +0100 Subject: Stop using tsconfig register Prefer to replace paths at compile time --- server/tools/cli.ts | 8 ++++---- server/tools/peertube-auth.ts | 9 ++------- server/tools/peertube-get-access-token.ts | 3 --- server/tools/peertube-import-videos.ts | 8 +++----- server/tools/peertube-plugins.ts | 13 ++++--------- server/tools/peertube-redundancy.ts | 3 --- server/tools/peertube-upload.ts | 3 --- server/tools/peertube.ts | 3 --- server/tools/tsconfig.json | 9 +++++++-- 9 files changed, 20 insertions(+), 39 deletions(-) (limited to 'server/tools') diff --git a/server/tools/cli.ts b/server/tools/cli.ts index 00adcedeb..a844b9dcf 100644 --- a/server/tools/cli.ts +++ b/server/tools/cli.ts @@ -2,19 +2,19 @@ import { Command } from 'commander' import { Netrc } from 'netrc-parser' import { join } from 'path' import { createLogger, format, transports } from 'winston' -import { PeerTubeServer } from '@shared/server-commands' +import { loadLanguages } from '@server/initializers/constants' +import { root } from '@shared/core-utils' import { UserRole } from '@shared/models' +import { PeerTubeServer } from '@shared/server-commands' import { VideoPrivacy } from '../../shared/models/videos' import { getAppNumber, isTestInstance } from '../helpers/core-utils' -import { root } from '@shared/core-utils' -import { loadLanguages } from '@server/initializers/constants' let configName = 'PeerTube/CLI' if (isTestInstance()) configName += `-${getAppNumber()}` const config = require('application-config')(configName) -const version = require('../../../package.json').version +const version = require(join(root(), 'package.json')).version async function getAdminTokenOrDie (server: PeerTubeServer, username: string, password: string) { const token = await server.login.getAccessToken(username, password) 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 @@ -// eslint-disable @typescript-eslint/no-unnecessary-type-assertion - -import { registerTSPaths } from '../helpers/register-ts-paths' -registerTSPaths() - +import CliTable3 from 'cli-table3' import { OptionValues, program } from 'commander' -import { assignToken, buildServer, getNetrc, getSettings, writeSettings } from './cli' import { isUserUsernameValid } from '../helpers/custom-validators/users' -import CliTable3 from 'cli-table3' +import { assignToken, buildServer, getNetrc, getSettings, writeSettings } from './cli' import prompt = require('prompt') 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 @@ -import { registerTSPaths } from '../helpers/register-ts-paths' -registerTSPaths() - import { program } from 'commander' import { assignToken, buildServer } from './cli' diff --git a/server/tools/peertube-import-videos.ts b/server/tools/peertube-import-videos.ts index 87aec60ef..661a4cf35 100644 --- a/server/tools/peertube-import-videos.ts +++ b/server/tools/peertube-import-videos.ts @@ -1,12 +1,10 @@ -import { registerTSPaths } from '../helpers/register-ts-paths' -registerTSPaths() - import { program } from 'commander' import { accessSync, constants } from 'fs' import { remove } from 'fs-extra' import { join } from 'path' -import { sha256 } from '@shared/extra-utils' +import { YoutubeDLCLI, YoutubeDLInfo, YoutubeDLInfoBuilder } from '@server/helpers/youtube-dl' import { wait } from '@shared/core-utils' +import { sha256 } from '@shared/extra-utils' import { doRequestAndSaveToFile } from '../helpers/requests' import { assignToken, @@ -16,7 +14,7 @@ import { getLogger, getServerCredentials } from './cli' -import { YoutubeDLCLI, YoutubeDLInfo, YoutubeDLInfoBuilder } from '@server/helpers/youtube-dl' + import prompt = require('prompt') const processOptions = { diff --git a/server/tools/peertube-plugins.ts b/server/tools/peertube-plugins.ts index 9dd3f08c9..47090b3a5 100644 --- a/server/tools/peertube-plugins.ts +++ b/server/tools/peertube-plugins.ts @@ -1,13 +1,8 @@ -// eslint-disable @typescript-eslint/no-unnecessary-type-assertion - -import { registerTSPaths } from '../helpers/register-ts-paths' -registerTSPaths() - -import { program, Command, OptionValues } from 'commander' -import { assignToken, buildServer, getServerCredentials } from './cli' -import { PluginType } from '../../shared/models' -import { isAbsolute } from 'path' import CliTable3 from 'cli-table3' +import { Command, OptionValues, program } from 'commander' +import { isAbsolute } from 'path' +import { PluginType } from '../../shared/models' +import { assignToken, buildServer, getServerCredentials } from './cli' program .name('plugins') diff --git a/server/tools/peertube-redundancy.ts b/server/tools/peertube-redundancy.ts index 12c412b67..2c62a3c19 100644 --- a/server/tools/peertube-redundancy.ts +++ b/server/tools/peertube-redundancy.ts @@ -1,6 +1,3 @@ -import { registerTSPaths } from '../helpers/register-ts-paths' -registerTSPaths() - import CliTable3 from 'cli-table3' import { Command, program } from 'commander' import { uniq } from 'lodash' 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 @@ -import { registerTSPaths } from '../helpers/register-ts-paths' -registerTSPaths() - import { program } from 'commander' import { access, constants } from 'fs-extra' 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 @@ #!/usr/bin/env node -import { registerTSPaths } from '../helpers/register-ts-paths' -registerTSPaths() - import { CommandOptions, program } from 'commander' import { getSettings, version } from './cli' diff --git a/server/tools/tsconfig.json b/server/tools/tsconfig.json index 61e6b8739..8264f5b35 100644 --- a/server/tools/tsconfig.json +++ b/server/tools/tsconfig.json @@ -1,11 +1,16 @@ { "extends": "../../tsconfig.json", "compilerOptions": { - "outDir": "../../dist/server/tools" + "baseUrl": "./", + "outDir": "../../dist/server/tools", + "paths": { // FIXME: https://github.com/benyap/resolve-tspaths/issues/10 + "@server/*": [ "../../server/*" ], + "@shared/*": [ "../../shared/*" ] + } }, "include": [ ".", "../typings" ], "references": [ - { "path": "../" }, + { "path": "../" } ], "files": [], "exclude": [ ] // Overwrite exclude property -- cgit v1.2.3