1
0
Fork 0
mirror of https://github.com/Chocobozzz/PeerTube.git synced 2025-10-05 19:42:24 +02:00

Stop using tsconfig register

Prefer to replace paths at compile time
This commit is contained in:
Chocobozzz 2022-01-03 17:13:11 +01:00
parent cea093bca5
commit f8360396ff
No known key found for this signature in database
GPG key ID: 583A612D890159BE
47 changed files with 191 additions and 609 deletions

View file

@ -1,10 +1,7 @@
import { registerTSPaths } from '../server/helpers/register-ts-paths'
registerTSPaths()
import autocannon, { printResult } from 'autocannon'
import { writeJson } from 'fs-extra'
import { createSingleServer, killallServers, PeerTubeServer, setAccessTokensToServers } from '@shared/server-commands'
import { Video, VideoPrivacy } from '@shared/models'
import { createSingleServer, killallServers, PeerTubeServer, setAccessTokensToServers } from '@shared/server-commands'
let server: PeerTubeServer
let video: Video

View file

@ -5,9 +5,7 @@ set -eu
rm -rf ./dist
npm run tsc -- -b --verbose
cp "./tsconfig.base.json" "./tsconfig.json" "./dist/"
cp "./scripts/tsconfig.json" "./dist/scripts/"
cp "./server/tsconfig.json" "./dist/server/"
cp "./shared/tsconfig.json" "./dist/shared/"
npm run resolve-tspaths:server
cp -r "./server/static" "./server/assets" "./dist/server"
cp -r "./server/lib/emails" "./dist/server/lib"

View file

@ -23,7 +23,7 @@ runTest () {
joblog="$jobname-ci.log"
parallel -j $jobs --retries $retries \
"echo Trying {} >> $joblog; npm run mocha -- -c --timeout 30000 --exit --require ./dist/server/tests/register.js --bail {}" \
"echo Trying {} >> $joblog; npm run mocha -- -c --timeout 30000 --exit --bail {}" \
::: $files
cat "$joblog" | uniq -c

View file

@ -1,6 +1,3 @@
import { registerTSPaths } from '../server/helpers/register-ts-paths'
registerTSPaths()
import { readdir, stat } from 'fs-extra'
import { join } from 'path'
import { root } from '@shared/core-utils'

View file

@ -1,12 +1,9 @@
import { registerTSPaths } from '../server/helpers/register-ts-paths'
registerTSPaths()
import { program } from 'commander'
import { resolve } from 'path'
import { VideoModel } from '../server/models/video/video'
import { isUUIDValid, toCompleteUUID } from '@server/helpers/custom-validators/misc'
import { initDatabaseModels } from '../server/initializers/database'
import { JobQueue } from '../server/lib/job-queue'
import { isUUIDValid, toCompleteUUID } from '@server/helpers/custom-validators/misc'
import { VideoModel } from '../server/models/video/video'
program
.option('-v, --video [videoUUID]', 'Video UUID')

View file

@ -1,13 +1,10 @@
import { registerTSPaths } from '../server/helpers/register-ts-paths'
registerTSPaths()
import { program } from 'commander'
import { VideoModel } from '@server/models/video/video'
import { initDatabaseModels } from '@server/initializers/database'
import { VideoState, VideoStorage } from '@shared/models'
import { moveToExternalStorageState } from '@server/lib/video-state'
import { JobQueue } from '@server/lib/job-queue'
import { CONFIG } from '@server/initializers/config'
import { initDatabaseModels } from '@server/initializers/database'
import { JobQueue } from '@server/lib/job-queue'
import { moveToExternalStorageState } from '@server/lib/video-state'
import { VideoModel } from '@server/models/video/video'
import { VideoState, VideoStorage } from '@shared/models'
program
.description('Move videos to another storage.')

View file

@ -1,15 +1,12 @@
import { registerTSPaths } from '../server/helpers/register-ts-paths'
registerTSPaths()
import { program } from 'commander'
import { VideoModel } from '../server/models/video/video'
import { isUUIDValid, toCompleteUUID } from '@server/helpers/custom-validators/misc'
import { computeLowerResolutionsToTranscode } from '@server/helpers/ffprobe-utils'
import { CONFIG } from '@server/initializers/config'
import { addTranscodingJob } from '@server/lib/video'
import { VideoState, VideoTranscodingPayload } from '@shared/models'
import { initDatabaseModels } from '../server/initializers/database'
import { JobQueue } from '../server/lib/job-queue'
import { computeLowerResolutionsToTranscode } from '@server/helpers/ffprobe-utils'
import { VideoState, VideoTranscodingPayload } from '@shared/models'
import { CONFIG } from '@server/initializers/config'
import { isUUIDValid, toCompleteUUID } from '@server/helpers/custom-validators/misc'
import { addTranscodingJob } from '@server/lib/video'
import { VideoModel } from '../server/models/video/video'
program
.option('-v, --video [videoUUID]', 'Video UUID')

View file

@ -12,4 +12,5 @@ rm -rf ./dist/server/tools/
mkdir -p "./dist/server/tools"
cp -r "./server/tools/node_modules" "./dist/server/tools"
npm run tsc -- --watch --sourceMap --project ./server/tools/tsconfig.json
cd ./server/tools
../../node_modules/.bin/tsc-watch --build --verbose --onSuccess 'sh -c "cd ../../ && npm run resolve-tspaths:all"'

View file

@ -14,15 +14,12 @@ mkdir -p "./client/dist"
rm -rf "./client/dist/locale"
cp -r "./client/src/locale" "./client/dist/locale"
rm -rf "./dist"
mkdir "./dist"
cp "./tsconfig.json" "./dist"
mkdir -p "./dist/server/lib"
npm run tsc -- -b -v --incremental
npm run resolve-tspaths:server
cp -r ./server/static ./server/assets ./dist/server
cp -r "./server/lib/emails" "./dist/server/lib"
NODE_ENV=test node node_modules/.bin/concurrently -k \
"node_modules/.bin/nodemon --enable-source-maps --delay 1 --watch ./dist dist/server" \
"node_modules/.bin/tsc -b -w --preserveWatchOutput"
./node_modules/.bin/tsc-watch --build --preserveWatchOutput --verbose --onSuccess 'sh -c "npm run resolve-tspaths:server && NODE_ENV=test node dist/server"'

View file

@ -1,6 +1,3 @@
import { registerTSPaths } from '../server/helpers/register-ts-paths'
registerTSPaths()
import { CLICommand } from '@shared/server-commands'
run()

View file

@ -1,9 +1,7 @@
import { registerTSPaths } from '../../server/helpers/register-ts-paths'
registerTSPaths()
import { writeJSON } from 'fs-extra'
import { values } from 'lodash'
import { join } from 'path'
import { root } from '@shared/core-utils'
import {
buildLanguages,
VIDEO_CATEGORIES,
@ -16,7 +14,7 @@ import {
} from '../../server/initializers/constants'
import { I18N_LOCALES } from '../../shared/core-utils/i18n'
const videojs = require(join(__dirname, '../../../client/src/locale/videojs.en-US.json'))
const videojs = require(join(root(), 'client', 'src', 'locale', 'videojs.en-US.json'))
const playerKeys = {
'Quality': 'Quality',
'Auto': 'Auto',
@ -100,7 +98,7 @@ writeAll().catch(err => {
})
async function writeAll () {
const localePath = join(__dirname, '../../../client/src/locale')
const localePath = join(root(), 'client', 'src', 'locale')
await writeJSON(join(localePath, 'player.en-US.json'), playerKeys, { spaces: 4 })
await writeJSON(join(localePath, 'server.en-US.json'), serverKeys, { spaces: 4 })

View file

@ -1,15 +1,12 @@
import { registerTSPaths } from '../../server/helpers/register-ts-paths'
registerTSPaths()
import { initDatabaseModels, sequelizeTypescript } from '../../server/initializers/database'
import * as Sequelize from 'sequelize'
import { join } from 'path'
import { HLS_STREAMING_PLAYLIST_DIRECTORY, STATIC_PATHS, WEBSERVER } from '@server/initializers/constants'
import { pathExists, stat, writeFile } from 'fs-extra'
import parseTorrent from 'parse-torrent'
import { join } from 'path'
import * as Sequelize from 'sequelize'
import { logger } from '@server/helpers/logger'
import { createTorrentPromise } from '@server/helpers/webtorrent'
import { CONFIG } from '@server/initializers/config'
import parseTorrent from 'parse-torrent'
import { logger } from '@server/helpers/logger'
import { HLS_STREAMING_PLAYLIST_DIRECTORY, STATIC_PATHS, WEBSERVER } from '@server/initializers/constants'
import { initDatabaseModels, sequelizeTypescript } from '../../server/initializers/database'
run()
.then(() => process.exit(0))

View file

@ -1,16 +1,13 @@
import { registerTSPaths } from '../../server/helpers/register-ts-paths'
registerTSPaths()
import Bluebird from 'bluebird'
import { move, readFile, writeFile } from 'fs-extra'
import { join } from 'path'
import { federateVideoIfNeeded } from '@server/lib/activitypub/videos'
import { JobQueue } from '@server/lib/job-queue'
import { initDatabaseModels } from '../../server/initializers/database'
import { generateHLSMasterPlaylistFilename, generateHlsSha256SegmentsFilename, getHlsResolutionPlaylistFilename } from '@server/lib/paths'
import { VideoPathManager } from '@server/lib/video-path-manager'
import { VideoModel } from '@server/models/video/video'
import { VideoStreamingPlaylistModel } from '@server/models/video/video-streaming-playlist'
import { move, readFile, writeFile } from 'fs-extra'
import Bluebird from 'bluebird'
import { federateVideoIfNeeded } from '@server/lib/activitypub/videos'
import { initDatabaseModels } from '../../server/initializers/database'
run()
.then(() => process.exit(0))

View file

@ -32,7 +32,7 @@ sed -i 's/"version": "\([^"]\+\)"/"version": "\1-'"$nightly_version"'"/' ./packa
"$directory_name/client/package.json" "$directory_name/config" \
"$directory_name/dist" "$directory_name/package.json" \
"$directory_name/scripts" "$directory_name/support" \
"$directory_name/tsconfig.json" "$directory_name/yarn.lock")
"$directory_name/yarn.lock")
# temporary setup
cd ..

View file

@ -1,15 +1,12 @@
import { registerTSPaths } from '../server/helpers/register-ts-paths'
registerTSPaths()
import { program } from 'commander'
import { createReadStream, readdir } from 'fs-extra'
import { join } from 'path'
import { createInterface } from 'readline'
import { format as sqlFormat } from 'sql-formatter'
import { inspect } from 'util'
import * as winston from 'winston'
import { labelFormatter, mtimeSortFilesDesc } from '../server/helpers/logger'
import { CONFIG } from '../server/initializers/config'
import { inspect } from 'util'
import { format as sqlFormat } from 'sql-formatter'
program
.option('-l, --level [level]', 'Level log (debug/info/warn/error)')

View file

@ -1,10 +1,7 @@
import { registerTSPaths } from '../../server/helpers/register-ts-paths'
registerTSPaths()
import { initDatabaseModels } from '../../server/initializers/database'
import { program } from 'commander'
import { PluginManager } from '../../server/lib/plugins/plugin-manager'
import { isAbsolute } from 'path'
import { initDatabaseModels } from '../../server/initializers/database'
import { PluginManager } from '../../server/lib/plugins/plugin-manager'
program
.option('-n, --npm-name [npmName]', 'Plugin to install')

View file

@ -1,8 +1,5 @@
import { registerTSPaths } from '../../server/helpers/register-ts-paths'
registerTSPaths()
import { initDatabaseModels } from '../../server/initializers/database'
import { program } from 'commander'
import { initDatabaseModels } from '../../server/initializers/database'
import { PluginManager } from '../../server/lib/plugins/plugin-manager'
program

View file

@ -1,10 +1,7 @@
import { registerTSPaths } from '../server/helpers/register-ts-paths'
registerTSPaths()
import { program } from 'commander'
import ffmpeg from 'fluent-ffmpeg'
import { buildx264VODCommand, runCommand, TranscodeOptions } from '@server/helpers/ffmpeg-utils'
import { exit } from 'process'
import { buildx264VODCommand, runCommand, TranscodeOptions } from '@server/helpers/ffmpeg-utils'
import { VideoTranscodingProfilesManager } from '@server/lib/transcoding/video-transcoding-profiles'
program

View file

@ -1,22 +1,19 @@
import { registerTSPaths } from '../server/helpers/register-ts-paths'
registerTSPaths()
import { start, get } from 'prompt'
import { join, basename } from 'path'
import { CONFIG } from '../server/initializers/config'
import { VideoModel } from '../server/models/video/video'
import { initDatabaseModels } from '../server/initializers/database'
import { readdir, remove, stat } from 'fs-extra'
import { VideoRedundancyModel } from '../server/models/redundancy/video-redundancy'
import { map } from 'bluebird'
import { getUUIDFromFilename } from '../server/helpers/utils'
import { ThumbnailModel } from '../server/models/video/thumbnail'
import { ActorImageModel } from '../server/models/actor/actor-image'
import { readdir, remove, stat } from 'fs-extra'
import { uniq, values } from 'lodash'
import { ThumbnailType } from '@shared/models'
import { VideoFileModel } from '@server/models/video/video-file'
import { basename, join } from 'path'
import { get, start } from 'prompt'
import { HLS_REDUNDANCY_DIRECTORY, HLS_STREAMING_PLAYLIST_DIRECTORY } from '@server/initializers/constants'
import { VideoFileModel } from '@server/models/video/video-file'
import { VideoStreamingPlaylistModel } from '@server/models/video/video-streaming-playlist'
import { ThumbnailType } from '@shared/models'
import { getUUIDFromFilename } from '../server/helpers/utils'
import { CONFIG } from '../server/initializers/config'
import { initDatabaseModels } from '../server/initializers/database'
import { ActorImageModel } from '../server/models/actor/actor-image'
import { VideoRedundancyModel } from '../server/models/redundancy/video-redundancy'
import { ThumbnailModel } from '../server/models/video/thumbnail'
import { VideoModel } from '../server/models/video/video'
run()
.then(() => process.exit(0))

View file

@ -1,13 +1,10 @@
import { registerTSPaths } from '../server/helpers/register-ts-paths'
registerTSPaths()
import { map } from 'bluebird'
import { program } from 'commander'
import { pathExists, remove } from 'fs-extra'
import { generateImageFilename, processImage } from '@server/helpers/image-utils'
import { THUMBNAILS_SIZE } from '@server/initializers/constants'
import { VideoModel } from '@server/models/video/video'
import { initDatabaseModels } from '@server/initializers/database'
import { VideoModel } from '@server/models/video/video'
program
.description('Regenerate local thumbnails using preview files')

View file

@ -76,7 +76,7 @@ rm -f "./client/dist/embed-stats.json"
"$directory_name/client/package.json" "$directory_name/config" \
"$directory_name/dist" "$directory_name/package.json" \
"$directory_name/scripts" "$directory_name/support" \
"$directory_name/tsconfig.json" "$directory_name/yarn.lock")
"$directory_name/yarn.lock")
# temporary setup
cd ..

View file

@ -1,10 +1,7 @@
import { registerTSPaths } from '../server/helpers/register-ts-paths'
registerTSPaths()
import { program } from 'commander'
import { isUserPasswordValid } from '../server/helpers/custom-validators/users'
import { initDatabaseModels } from '../server/initializers/database'
import { UserModel } from '../server/models/user/user'
import { isUserPasswordValid } from '../server/helpers/custom-validators/users'
program
.option('-u, --user [user]', 'User')

View file

@ -9,8 +9,10 @@ rm -rf ./dist/server/tools/
(
cd ./server/tools
yarn install --pure-lockfile
../../node_modules/.bin/tsc --build --verbose
)
npm run tsc -- --build --verbose ./server/tools/tsconfig.json
cp -r "./server/tools/node_modules" "./dist/server/tools"
cp "./tsconfig.json" "./dist"
npm run resolve-tspaths:cli
npm run resolve-tspaths:server

View file

@ -1,10 +1,7 @@
import { registerTSPaths } from '../server/helpers/register-ts-paths'
registerTSPaths()
import { updateTorrentMetadata } from '@server/helpers/webtorrent'
import { getServerActor } from '@server/models/application/application'
import { WEBSERVER } from '../server/initializers/constants'
import { ActorFollowModel } from '../server/models/actor/actor-follow'
import { VideoModel } from '../server/models/video/video'
import { ActorModel } from '../server/models/actor/actor'
import { initDatabaseModels } from '../server/initializers/database'
import {
getLocalAccountActivityPubUrl,
getLocalVideoActivityPubUrl,
@ -12,13 +9,13 @@ import {
getLocalVideoChannelActivityPubUrl,
getLocalVideoCommentActivityPubUrl
} from '../server/lib/activitypub/url'
import { VideoShareModel } from '../server/models/video/video-share'
import { VideoCommentModel } from '../server/models/video/video-comment'
import { AccountModel } from '../server/models/account/account'
import { ActorModel } from '../server/models/actor/actor'
import { ActorFollowModel } from '../server/models/actor/actor-follow'
import { VideoModel } from '../server/models/video/video'
import { VideoChannelModel } from '../server/models/video/video-channel'
import { initDatabaseModels } from '../server/initializers/database'
import { updateTorrentMetadata } from '@server/helpers/webtorrent'
import { getServerActor } from '@server/models/application/application'
import { VideoCommentModel } from '../server/models/video/video-comment'
import { VideoShareModel } from '../server/models/video/video-share'
run()
.then(() => process.exit(0))