diff options
author | Chocobozzz <me@florianbigard.com> | 2022-01-03 17:13:11 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2022-01-06 08:26:14 +0100 |
commit | f8360396ffabd2f95e9ece9c5755173bae0114b6 (patch) | |
tree | 83467f70bb5d5c2faa61c45e1d87b538c6c8fe5e /server | |
parent | cea093bca5b9d311b5c1d0539d53e965c901015b (diff) | |
download | PeerTube-f8360396ffabd2f95e9ece9c5755173bae0114b6.tar.gz PeerTube-f8360396ffabd2f95e9ece9c5755173bae0114b6.tar.zst PeerTube-f8360396ffabd2f95e9ece9c5755173bae0114b6.zip |
Stop using tsconfig register
Prefer to replace paths at compile time
Diffstat (limited to 'server')
-rw-r--r-- | server/helpers/register-ts-paths.ts | 16 | ||||
-rw-r--r-- | server/lib/client-html.ts | 5 | ||||
-rw-r--r-- | server/middlewares/async.ts | 2 | ||||
-rw-r--r-- | server/middlewares/validators/videos/video-playlists.ts | 2 | ||||
-rw-r--r-- | server/middlewares/validators/videos/videos.ts | 2 | ||||
-rw-r--r-- | server/tests/register.ts | 3 | ||||
-rw-r--r-- | server/tools/cli.ts | 8 | ||||
-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 | 8 | ||||
-rw-r--r-- | server/tools/peertube-plugins.ts | 13 | ||||
-rw-r--r-- | server/tools/peertube-redundancy.ts | 3 | ||||
-rw-r--r-- | server/tools/peertube-upload.ts | 3 | ||||
-rw-r--r-- | server/tools/peertube.ts | 3 | ||||
-rw-r--r-- | server/tools/tsconfig.json | 9 | ||||
-rw-r--r-- | server/types/express-handler.ts (renamed from server/types/express.ts) | 0 | ||||
-rw-r--r-- | server/types/express.d.ts (renamed from server/typings/express/index.d.ts) | 0 |
17 files changed, 26 insertions, 63 deletions
diff --git a/server/helpers/register-ts-paths.ts b/server/helpers/register-ts-paths.ts deleted file mode 100644 index eec7fed3e..000000000 --- a/server/helpers/register-ts-paths.ts +++ /dev/null | |||
@@ -1,16 +0,0 @@ | |||
1 | import { resolve } from 'path' | ||
2 | import tsConfigPaths = require('tsconfig-paths') | ||
3 | |||
4 | const tsConfig = require('../../tsconfig.json') | ||
5 | |||
6 | function registerTSPaths () { | ||
7 | // Thanks: https://github.com/dividab/tsconfig-paths/issues/75#issuecomment-458936883 | ||
8 | tsConfigPaths.register({ | ||
9 | baseUrl: resolve(tsConfig.compilerOptions.baseUrl || '', tsConfig.compilerOptions.outDir || ''), | ||
10 | paths: tsConfig.compilerOptions.paths | ||
11 | }) | ||
12 | } | ||
13 | |||
14 | export { | ||
15 | registerTSPaths | ||
16 | } | ||
diff --git a/server/lib/client-html.ts b/server/lib/client-html.ts index e7e439bfe..74788af52 100644 --- a/server/lib/client-html.ts +++ b/server/lib/client-html.ts | |||
@@ -3,6 +3,7 @@ import { readFile } from 'fs-extra' | |||
3 | import { join } from 'path' | 3 | import { join } from 'path' |
4 | import validator from 'validator' | 4 | import validator from 'validator' |
5 | import { toCompleteUUID } from '@server/helpers/custom-validators/misc' | 5 | import { toCompleteUUID } from '@server/helpers/custom-validators/misc' |
6 | import { root } from '@shared/core-utils' | ||
6 | import { escapeHTML } from '@shared/core-utils/renderer' | 7 | import { escapeHTML } from '@shared/core-utils/renderer' |
7 | import { sha256 } from '@shared/extra-utils' | 8 | import { sha256 } from '@shared/extra-utils' |
8 | import { HTMLServerConfig } from '@shared/models' | 9 | import { HTMLServerConfig } from '@shared/models' |
@@ -344,11 +345,11 @@ class ClientHtml { | |||
344 | { cookie: req.cookies?.clientLanguage, paramLang, acceptLanguage: req.headers['accept-language'] } | 345 | { cookie: req.cookies?.clientLanguage, paramLang, acceptLanguage: req.headers['accept-language'] } |
345 | ) | 346 | ) |
346 | 347 | ||
347 | return join(__dirname, '../../../client/dist/' + buildFileLocale(lang) + '/index.html') | 348 | return join(root(), 'client', 'dist', buildFileLocale(lang), 'index.html') |
348 | } | 349 | } |
349 | 350 | ||
350 | private static getEmbedPath () { | 351 | private static getEmbedPath () { |
351 | return join(__dirname, '../../../client/dist/standalone/videos/embed.html') | 352 | return join(root(), 'client', 'dist', 'standalone', 'videos', 'embed.html') |
352 | } | 353 | } |
353 | 354 | ||
354 | private static addManifestContentHash (htmlStringPage: string) { | 355 | private static addManifestContentHash (htmlStringPage: string) { |
diff --git a/server/middlewares/async.ts b/server/middlewares/async.ts index 3d6e38809..9d0193536 100644 --- a/server/middlewares/async.ts +++ b/server/middlewares/async.ts | |||
@@ -1,7 +1,7 @@ | |||
1 | import { eachSeries } from 'async' | 1 | import { eachSeries } from 'async' |
2 | import { NextFunction, Request, RequestHandler, Response } from 'express' | 2 | import { NextFunction, Request, RequestHandler, Response } from 'express' |
3 | import { ValidationChain } from 'express-validator' | 3 | import { ValidationChain } from 'express-validator' |
4 | import { ExpressPromiseHandler } from '@server/types/express' | 4 | import { ExpressPromiseHandler } from '@server/types/express-handler' |
5 | import { retryTransactionWrapper } from '../helpers/database-utils' | 5 | import { retryTransactionWrapper } from '../helpers/database-utils' |
6 | 6 | ||
7 | // Syntactic sugar to avoid try/catch in express controllers | 7 | // Syntactic sugar to avoid try/catch in express controllers |
diff --git a/server/middlewares/validators/videos/video-playlists.ts b/server/middlewares/validators/videos/video-playlists.ts index ec5a3a9c8..f5fee845e 100644 --- a/server/middlewares/validators/videos/video-playlists.ts +++ b/server/middlewares/validators/videos/video-playlists.ts | |||
@@ -1,6 +1,6 @@ | |||
1 | import express from 'express' | 1 | import express from 'express' |
2 | import { body, param, query, ValidationChain } from 'express-validator' | 2 | import { body, param, query, ValidationChain } from 'express-validator' |
3 | import { ExpressPromiseHandler } from '@server/types/express' | 3 | import { ExpressPromiseHandler } from '@server/types/express-handler' |
4 | import { MUserAccountId } from '@server/types/models' | 4 | import { MUserAccountId } from '@server/types/models' |
5 | import { | 5 | import { |
6 | HttpStatusCode, | 6 | HttpStatusCode, |
diff --git a/server/middlewares/validators/videos/videos.ts b/server/middlewares/validators/videos/videos.ts index 1e727533b..bf5f1c97b 100644 --- a/server/middlewares/validators/videos/videos.ts +++ b/server/middlewares/validators/videos/videos.ts | |||
@@ -5,7 +5,7 @@ import { getResumableUploadPath } from '@server/helpers/upload' | |||
5 | import { Redis } from '@server/lib/redis' | 5 | import { Redis } from '@server/lib/redis' |
6 | import { isAbleToUploadVideo } from '@server/lib/user' | 6 | import { isAbleToUploadVideo } from '@server/lib/user' |
7 | import { getServerActor } from '@server/models/application/application' | 7 | import { getServerActor } from '@server/models/application/application' |
8 | import { ExpressPromiseHandler } from '@server/types/express' | 8 | import { ExpressPromiseHandler } from '@server/types/express-handler' |
9 | import { MUserAccountId, MVideoFullLight } from '@server/types/models' | 9 | import { MUserAccountId, MVideoFullLight } from '@server/types/models' |
10 | import { getAllPrivacies } from '@shared/core-utils' | 10 | import { getAllPrivacies } from '@shared/core-utils' |
11 | import { HttpStatusCode, ServerErrorCode, UserRight, VideoInclude, VideoPrivacy } from '@shared/models' | 11 | import { HttpStatusCode, ServerErrorCode, UserRight, VideoInclude, VideoPrivacy } from '@shared/models' |
diff --git a/server/tests/register.ts b/server/tests/register.ts deleted file mode 100644 index af6c8c644..000000000 --- a/server/tests/register.ts +++ /dev/null | |||
@@ -1,3 +0,0 @@ | |||
1 | import { registerTSPaths } from '../helpers/register-ts-paths' | ||
2 | |||
3 | registerTSPaths() | ||
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' | |||
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/server-commands' | 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 } from '../helpers/core-utils' | 10 | import { getAppNumber, isTestInstance } from '../helpers/core-utils' |
9 | import { root } from '@shared/core-utils' | ||
10 | import { loadLanguages } from '@server/initializers/constants' | ||
11 | 11 | ||
12 | let configName = 'PeerTube/CLI' | 12 | let configName = 'PeerTube/CLI' |
13 | if (isTestInstance()) configName += `-${getAppNumber()}` | 13 | if (isTestInstance()) configName += `-${getAppNumber()}` |
14 | 14 | ||
15 | const config = require('application-config')(configName) | 15 | const config = require('application-config')(configName) |
16 | 16 | ||
17 | const version = require('../../../package.json').version | 17 | const version = require(join(root(), 'package.json')).version |
18 | 18 | ||
19 | async function getAdminTokenOrDie (server: PeerTubeServer, username: string, password: string) { | 19 | async function getAdminTokenOrDie (server: PeerTubeServer, username: string, password: string) { |
20 | const token = await server.login.getAccessToken(username, password) | 20 | 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 @@ | |||
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 87aec60ef..661a4cf35 100644 --- a/server/tools/peertube-import-videos.ts +++ b/server/tools/peertube-import-videos.ts | |||
@@ -1,12 +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 '@shared/extra-utils' | 5 | import { YoutubeDLCLI, YoutubeDLInfo, YoutubeDLInfoBuilder } from '@server/helpers/youtube-dl' |
9 | import { wait } from '@shared/core-utils' | 6 | import { wait } from '@shared/core-utils' |
7 | import { sha256 } from '@shared/extra-utils' | ||
10 | import { doRequestAndSaveToFile } from '../helpers/requests' | 8 | import { doRequestAndSaveToFile } from '../helpers/requests' |
11 | import { | 9 | import { |
12 | assignToken, | 10 | assignToken, |
@@ -16,7 +14,7 @@ import { | |||
16 | getLogger, | 14 | getLogger, |
17 | getServerCredentials | 15 | getServerCredentials |
18 | } from './cli' | 16 | } from './cli' |
19 | import { YoutubeDLCLI, YoutubeDLInfo, YoutubeDLInfoBuilder } from '@server/helpers/youtube-dl' | 17 | |
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 9dd3f08c9..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') |
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 @@ | |||
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' |
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 61e6b8739..8264f5b35 100644 --- a/server/tools/tsconfig.json +++ b/server/tools/tsconfig.json | |||
@@ -1,11 +1,16 @@ | |||
1 | { | 1 | { |
2 | "extends": "../../tsconfig.json", | 2 | "extends": "../../tsconfig.json", |
3 | "compilerOptions": { | 3 | "compilerOptions": { |
4 | "outDir": "../../dist/server/tools" | 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 | } | ||
5 | }, | 10 | }, |
6 | "include": [ ".", "../typings" ], | 11 | "include": [ ".", "../typings" ], |
7 | "references": [ | 12 | "references": [ |
8 | { "path": "../" }, | 13 | { "path": "../" } |
9 | ], | 14 | ], |
10 | "files": [], | 15 | "files": [], |
11 | "exclude": [ ] // Overwrite exclude property | 16 | "exclude": [ ] // Overwrite exclude property |
diff --git a/server/types/express.ts b/server/types/express-handler.ts index e72be36e4..e72be36e4 100644 --- a/server/types/express.ts +++ b/server/types/express-handler.ts | |||
diff --git a/server/typings/express/index.d.ts b/server/types/express.d.ts index 1a99b598a..1a99b598a 100644 --- a/server/typings/express/index.d.ts +++ b/server/types/express.d.ts | |||