aboutsummaryrefslogtreecommitdiffhomepage
path: root/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts')
-rw-r--r--scripts/benchmark.ts5
-rwxr-xr-xscripts/build/client.sh2
-rwxr-xr-xscripts/build/server.sh5
-rwxr-xr-xscripts/ci.sh7
-rwxr-xr-xscripts/clean/server/test.sh6
-rw-r--r--scripts/client-build-stats.ts5
-rw-r--r--scripts/create-import-video-file-job.ts7
-rw-r--r--scripts/create-move-video-storage-job.ts21
-rwxr-xr-xscripts/create-transcoding-job.ts21
-rwxr-xr-xscripts/dev/cli.sh3
-rwxr-xr-xscripts/dev/server.sh13
-rwxr-xr-xscripts/e2e/browserstack.sh6
-rwxr-xr-xscripts/e2e/local.sh14
-rwxr-xr-xscripts/generate-code-contributors.ts5
-rwxr-xr-xscripts/i18n/create-custom-files.ts11
-rwxr-xr-xscripts/i18n/update.sh2
-rw-r--r--scripts/migrations/peertube-2.1.ts15
-rw-r--r--scripts/migrations/peertube-4.0.ts11
-rwxr-xr-xscripts/nightly.sh2
-rwxr-xr-xscripts/parse-log.ts7
-rwxr-xr-xscripts/plugin/install.ts7
-rwxr-xr-xscripts/plugin/uninstall.ts5
-rw-r--r--scripts/print-transcode-command.ts5
-rwxr-xr-xscripts/prune-storage.ts33
-rw-r--r--scripts/regenerate-thumbnails.ts5
-rwxr-xr-xscripts/release.sh7
-rwxr-xr-xscripts/reset-password.ts5
-rwxr-xr-xscripts/setup/cli.sh6
-rwxr-xr-xscripts/test.sh1
-rw-r--r--scripts/tsconfig.json10
-rwxr-xr-xscripts/update-host.ts23
31 files changed, 131 insertions, 144 deletions
diff --git a/scripts/benchmark.ts b/scripts/benchmark.ts
index 788318313..3c3c666a1 100644
--- a/scripts/benchmark.ts
+++ b/scripts/benchmark.ts
@@ -1,10 +1,7 @@
1import { registerTSPaths } from '../server/helpers/register-ts-paths'
2registerTSPaths()
3
4import autocannon, { printResult } from 'autocannon' 1import autocannon, { printResult } from 'autocannon'
5import { writeJson } from 'fs-extra' 2import { writeJson } from 'fs-extra'
6import { createSingleServer, killallServers, PeerTubeServer, setAccessTokensToServers } from '@shared/extra-utils'
7import { Video, VideoPrivacy } from '@shared/models' 3import { Video, VideoPrivacy } from '@shared/models'
4import { createSingleServer, killallServers, PeerTubeServer, setAccessTokensToServers } from '@shared/server-commands'
8 5
9let server: PeerTubeServer 6let server: PeerTubeServer
10let video: Video 7let video: Video
diff --git a/scripts/build/client.sh b/scripts/build/client.sh
index e891b217c..bae91a2b6 100755
--- a/scripts/build/client.sh
+++ b/scripts/build/client.sh
@@ -35,6 +35,8 @@ languages=(
35 ["de"]="de-DE" 35 ["de"]="de-DE"
36 ["it"]="it-IT" 36 ["it"]="it-IT"
37 ["sq"]="sq" 37 ["sq"]="sq"
38 ["nn"]="nn"
39 ["nb"]="nb-NO"
38 ["kab"]="kab" 40 ["kab"]="kab"
39) 41)
40 42
diff --git a/scripts/build/server.sh b/scripts/build/server.sh
index b903f8250..a2dfc3dd9 100755
--- a/scripts/build/server.sh
+++ b/scripts/build/server.sh
@@ -4,7 +4,8 @@ set -eu
4 4
5rm -rf ./dist 5rm -rf ./dist
6 6
7npm run tsc 7npm run tsc -- -b --verbose
8cp "./tsconfig.json" "./dist" 8npm run resolve-tspaths:server
9
9cp -r "./server/static" "./server/assets" "./dist/server" 10cp -r "./server/static" "./server/assets" "./dist/server"
10cp -r "./server/lib/emails" "./dist/server/lib" 11cp -r "./server/lib/emails" "./dist/server/lib"
diff --git a/scripts/ci.sh b/scripts/ci.sh
index a628cbced..2bacf2a2e 100755
--- a/scripts/ci.sh
+++ b/scripts/ci.sh
@@ -23,7 +23,7 @@ runTest () {
23 joblog="$jobname-ci.log" 23 joblog="$jobname-ci.log"
24 24
25 parallel -j $jobs --retries $retries \ 25 parallel -j $jobs --retries $retries \
26 "echo Trying {} >> $joblog; npm run mocha -- -c --timeout 30000 --exit --require ./dist/server/tests/register.js --bail {}" \ 26 "echo Trying {} >> $joblog; npm run mocha -- -c --timeout 30000 --exit --bail {}" \
27 ::: $files 27 ::: $files
28 28
29 cat "$joblog" | uniq -c 29 cat "$joblog" | uniq -c
@@ -40,7 +40,10 @@ findTestFiles () {
40 find $1 -type f -name "*.js" $exception | xargs echo 40 find $1 -type f -name "*.js" $exception | xargs echo
41} 41}
42 42
43if [ "$1" = "client" ]; then 43if [ "$1" = "types-package" ]; then
44 npm run generate-types-package 0.0.0
45 npm run tsc -- --noEmit --esModuleInterop packages/types/tests/test.ts
46elif [ "$1" = "client" ]; then
44 npm run build 47 npm run build
45 48
46 feedsFiles=$(findTestFiles ./dist/server/tests/feeds) 49 feedsFiles=$(findTestFiles ./dist/server/tests/feeds)
diff --git a/scripts/clean/server/test.sh b/scripts/clean/server/test.sh
index f85daf810..5c30c7639 100755
--- a/scripts/clean/server/test.sh
+++ b/scripts/clean/server/test.sh
@@ -20,9 +20,9 @@ dropRedis () {
20 port=$((9000+$1)) 20 port=$((9000+$1))
21 host="localhost" 21 host="localhost"
22 22
23 redis-cli -h "$host" KEYS "bull-localhost:$port*" | grep -v empty | xargs --no-run-if-empty redis-cli -h "$host" DEL 23 redis-cli -h "$host" KEYS "bull-localhost:$port*" | grep -v empty | xargs -r redis-cli -h "$host" DEL
24 redis-cli -h "$host" KEYS "redis-localhost:$port*" | grep -v empty | xargs --no-run-if-empty redis-cli -h "$host" DEL 24 redis-cli -h "$host" KEYS "redis-localhost:$port*" | grep -v empty | xargs -r redis-cli -h "$host" DEL
25 redis-cli -h "$host" KEYS "*redis-localhost:$port-" | grep -v empty | xargs --no-run-if-empty redis-cli -h "$host" DEL 25 redis-cli -h "$host" KEYS "*redis-localhost:$port-" | grep -v empty | xargs -r redis-cli -h "$host" DEL
26} 26}
27 27
28seq=$(seq 1 6) 28seq=$(seq 1 6)
diff --git a/scripts/client-build-stats.ts b/scripts/client-build-stats.ts
index 70ceda975..d5ecd5fea 100644
--- a/scripts/client-build-stats.ts
+++ b/scripts/client-build-stats.ts
@@ -1,9 +1,6 @@
1import { registerTSPaths } from '../server/helpers/register-ts-paths'
2registerTSPaths()
3
4import { readdir, stat } from 'fs-extra' 1import { readdir, stat } from 'fs-extra'
5import { join } from 'path' 2import { join } from 'path'
6import { root } from '@server/helpers/core-utils' 3import { root } from '@shared/core-utils'
7 4
8async function run () { 5async function run () {
9 const result = { 6 const result = {
diff --git a/scripts/create-import-video-file-job.ts b/scripts/create-import-video-file-job.ts
index 071d36df4..97e9c7933 100644
--- a/scripts/create-import-video-file-job.ts
+++ b/scripts/create-import-video-file-job.ts
@@ -1,12 +1,9 @@
1import { registerTSPaths } from '../server/helpers/register-ts-paths'
2registerTSPaths()
3
4import { program } from 'commander' 1import { program } from 'commander'
5import { resolve } from 'path' 2import { resolve } from 'path'
6import { VideoModel } from '../server/models/video/video' 3import { isUUIDValid, toCompleteUUID } from '@server/helpers/custom-validators/misc'
7import { initDatabaseModels } from '../server/initializers/database' 4import { initDatabaseModels } from '../server/initializers/database'
8import { JobQueue } from '../server/lib/job-queue' 5import { JobQueue } from '../server/lib/job-queue'
9import { isUUIDValid, toCompleteUUID } from '@server/helpers/custom-validators/misc' 6import { VideoModel } from '../server/models/video/video'
10 7
11program 8program
12 .option('-v, --video [videoUUID]', 'Video UUID') 9 .option('-v, --video [videoUUID]', 'Video UUID')
diff --git a/scripts/create-move-video-storage-job.ts b/scripts/create-move-video-storage-job.ts
index 505bbd61b..7465c1ce0 100644
--- a/scripts/create-move-video-storage-job.ts
+++ b/scripts/create-move-video-storage-job.ts
@@ -1,13 +1,10 @@
1import { registerTSPaths } from '../server/helpers/register-ts-paths'
2registerTSPaths()
3
4import { program } from 'commander' 1import { program } from 'commander'
5import { VideoModel } from '@server/models/video/video' 2import { CONFIG } from '@server/initializers/config'
6import { initDatabaseModels } from '@server/initializers/database' 3import { initDatabaseModels } from '@server/initializers/database'
7import { VideoStorage } from '@shared/models'
8import { moveToExternalStorageState } from '@server/lib/video-state'
9import { JobQueue } from '@server/lib/job-queue' 4import { JobQueue } from '@server/lib/job-queue'
10import { CONFIG } from '@server/initializers/config' 5import { moveToExternalStorageState } from '@server/lib/video-state'
6import { VideoModel } from '@server/models/video/video'
7import { VideoState, VideoStorage } from '@shared/models'
11 8
12program 9program
13 .description('Move videos to another storage.') 10 .description('Move videos to another storage.')
@@ -57,6 +54,16 @@ async function run () {
57 process.exit(-1) 54 process.exit(-1)
58 } 55 }
59 56
57 if (video.isLive) {
58 console.error('Cannot process live video')
59 process.exit(-1)
60 }
61
62 if (video.state === VideoState.TO_MOVE_TO_EXTERNAL_STORAGE) {
63 console.error('This video is already being moved to external storage')
64 process.exit(-1)
65 }
66
60 ids.push(video.id) 67 ids.push(video.id)
61 } else { 68 } else {
62 ids = await VideoModel.listLocalIds() 69 ids = await VideoModel.listLocalIds()
diff --git a/scripts/create-transcoding-job.ts b/scripts/create-transcoding-job.ts
index 244c38fcd..95e1e66cf 100755
--- a/scripts/create-transcoding-job.ts
+++ b/scripts/create-transcoding-job.ts
@@ -1,15 +1,12 @@
1import { registerTSPaths } from '../server/helpers/register-ts-paths'
2registerTSPaths()
3
4import { program } from 'commander' 1import { program } from 'commander'
5import { VideoModel } from '../server/models/video/video' 2import { isUUIDValid, toCompleteUUID } from '@server/helpers/custom-validators/misc'
6import { initDatabaseModels } from '../server/initializers/database'
7import { JobQueue } from '../server/lib/job-queue'
8import { computeLowerResolutionsToTranscode } from '@server/helpers/ffprobe-utils' 3import { computeLowerResolutionsToTranscode } from '@server/helpers/ffprobe-utils'
9import { VideoState, VideoTranscodingPayload } from '@shared/models'
10import { CONFIG } from '@server/initializers/config' 4import { CONFIG } from '@server/initializers/config'
11import { isUUIDValid, toCompleteUUID } from '@server/helpers/custom-validators/misc'
12import { addTranscodingJob } from '@server/lib/video' 5import { addTranscodingJob } from '@server/lib/video'
6import { VideoState, VideoTranscodingPayload } from '@shared/models'
7import { initDatabaseModels } from '../server/initializers/database'
8import { JobQueue } from '../server/lib/job-queue'
9import { VideoModel } from '../server/models/video/video'
13 10
14program 11program
15 .option('-v, --video [videoUUID]', 'Video UUID') 12 .option('-v, --video [videoUUID]', 'Video UUID')
@@ -63,7 +60,11 @@ async function run () {
63 type: 'new-resolution-to-hls', 60 type: 'new-resolution-to-hls',
64 videoUUID: video.uuid, 61 videoUUID: video.uuid,
65 resolution, 62 resolution,
63
64 // FIXME: check the file has audio and is not in portrait mode
66 isPortraitMode: false, 65 isPortraitMode: false,
66 hasAudio: true,
67
67 copyCodecs: false, 68 copyCodecs: false,
68 isNewVideo: false, 69 isNewVideo: false,
69 isMaxQuality: maxResolution === resolution, 70 isMaxQuality: maxResolution === resolution,
@@ -75,6 +76,10 @@ async function run () {
75 dataInput.push({ 76 dataInput.push({
76 type: 'new-resolution-to-webtorrent', 77 type: 'new-resolution-to-webtorrent',
77 videoUUID: video.uuid, 78 videoUUID: video.uuid,
79
80 // FIXME: check the file has audio
81 hasAudio: true,
82
78 isNewVideo: false, 83 isNewVideo: false,
79 resolution: parseInt(options.resolution) 84 resolution: parseInt(options.resolution)
80 }) 85 })
diff --git a/scripts/dev/cli.sh b/scripts/dev/cli.sh
index 4bf4808b8..327792a19 100755
--- a/scripts/dev/cli.sh
+++ b/scripts/dev/cli.sh
@@ -12,4 +12,5 @@ rm -rf ./dist/server/tools/
12mkdir -p "./dist/server/tools" 12mkdir -p "./dist/server/tools"
13cp -r "./server/tools/node_modules" "./dist/server/tools" 13cp -r "./server/tools/node_modules" "./dist/server/tools"
14 14
15npm run tsc -- --watch --sourceMap --project ./server/tools/tsconfig.json 15cd ./server/tools
16../../node_modules/.bin/tsc-watch --build --verbose --onSuccess 'sh -c "cd ../../ && npm run resolve-tspaths:all"'
diff --git a/scripts/dev/server.sh b/scripts/dev/server.sh
index 5aac470eb..9dae43a63 100755
--- a/scripts/dev/server.sh
+++ b/scripts/dev/server.sh
@@ -5,7 +5,7 @@ set -eu
5if [ ! -f "./client/dist/en-US/index.html" ]; then 5if [ ! -f "./client/dist/en-US/index.html" ]; then
6 if [ -z ${1+x} ] || [ "$1" != "--skip-client" ]; then 6 if [ -z ${1+x} ] || [ "$1" != "--skip-client" ]; then
7 echo "client/dist/en-US/index.html does not exist, compile client files..." 7 echo "client/dist/en-US/index.html does not exist, compile client files..."
8 npm run build:client -- --light 8 npm run build:client
9 fi 9 fi
10fi 10fi
11 11
@@ -14,15 +14,12 @@ mkdir -p "./client/dist"
14rm -rf "./client/dist/locale" 14rm -rf "./client/dist/locale"
15cp -r "./client/src/locale" "./client/dist/locale" 15cp -r "./client/src/locale" "./client/dist/locale"
16 16
17rm -rf "./dist" 17mkdir -p "./dist/server/lib"
18 18
19mkdir "./dist" 19npm run tsc -- -b -v --incremental
20cp "./tsconfig.json" "./dist" 20npm run resolve-tspaths:server
21 21
22npm run tsc -- --incremental --sourceMap
23cp -r ./server/static ./server/assets ./dist/server 22cp -r ./server/static ./server/assets ./dist/server
24cp -r "./server/lib/emails" "./dist/server/lib" 23cp -r "./server/lib/emails" "./dist/server/lib"
25 24
26NODE_ENV=test node node_modules/.bin/concurrently -k \ 25./node_modules/.bin/tsc-watch --build --preserveWatchOutput --verbose --onSuccess 'sh -c "npm run resolve-tspaths:server && NODE_ENV=test node dist/server"'
27 "node_modules/.bin/nodemon --delay 1 --watch ./dist dist/server" \
28 "node_modules/.bin/tsc --incremental --sourceMap --preserveWatchOutput -w"
diff --git a/scripts/e2e/browserstack.sh b/scripts/e2e/browserstack.sh
index fb125ea23..ad6268d42 100755
--- a/scripts/e2e/browserstack.sh
+++ b/scripts/e2e/browserstack.sh
@@ -2,8 +2,4 @@
2 2
3set -eu 3set -eu
4 4
5npm run clean:server:test 5cd client/e2e && ../node_modules/.bin/wdio run ./wdio.browserstack.conf.ts
6
7npm run concurrently -- -k -s first \
8 "cd client/e2e && ../node_modules/.bin/wdio run ./wdio.browserstack.conf.ts" \
9 "NODE_ENV=test NODE_APP_INSTANCE=1 NODE_CONFIG='{ \"rates_limit\": { \"api\": { \"max\": 5000 }, \"login\": { \"max\": 5000 } }, \"log\": { \"level\": \"warn\" }, \"signup\": { \"enabled\": false } }' node dist/server"
diff --git a/scripts/e2e/local.sh b/scripts/e2e/local.sh
index fe8b7f559..0e0368c52 100755
--- a/scripts/e2e/local.sh
+++ b/scripts/e2e/local.sh
@@ -2,16 +2,6 @@
2 2
3set -eu 3set -eu
4 4
5npm run clean:server:test 5cd client/e2e
6 6
7config="{" 7../node_modules/.bin/wdio run ./wdio.local.conf.ts
8config+=" \"rates_limit\": { \"api\": { \"max\": 5000 }, \"login\": { \"max\": 5000 } }"
9config+=", \"log\": { \"level\": \"warn\" }"
10config+=", \"signup\": { \"enabled\": false }"
11config+=", \"transcoding\": { \"enabled\": false }"
12config+="}"
13
14npm run concurrently -- -k -s first \
15 "cd client/e2e && ../node_modules/.bin/wdio run ./wdio.local.conf.ts" \
16 "NODE_ENV=test NODE_CONFIG='$config' NODE_APP_INSTANCE=1 node dist/server" \
17 "NODE_ENV=test NODE_CONFIG='$config' NODE_APP_INSTANCE=2 node dist/server"
diff --git a/scripts/generate-code-contributors.ts b/scripts/generate-code-contributors.ts
index 70b33c0d3..5357daf04 100755
--- a/scripts/generate-code-contributors.ts
+++ b/scripts/generate-code-contributors.ts
@@ -1,7 +1,4 @@
1import { registerTSPaths } from '../server/helpers/register-ts-paths' 1import { CLICommand } from '@shared/server-commands'
2registerTSPaths()
3
4import { CLICommand } from '@shared/extra-utils'
5 2
6run() 3run()
7 .then(() => process.exit(0)) 4 .then(() => process.exit(0))
diff --git a/scripts/i18n/create-custom-files.ts b/scripts/i18n/create-custom-files.ts
index b363a1bdc..7556866e6 100755
--- a/scripts/i18n/create-custom-files.ts
+++ b/scripts/i18n/create-custom-files.ts
@@ -1,7 +1,7 @@
1import { writeJSON } from 'fs-extra' 1import { writeJSON } from 'fs-extra'
2import { values } from 'lodash' 2import { values } from 'lodash'
3import { join } from 'path' 3import { join } from 'path'
4import { registerTSPaths } from '../../server/helpers/register-ts-paths' 4import { root } from '@shared/core-utils'
5import { 5import {
6 buildLanguages, 6 buildLanguages,
7 VIDEO_CATEGORIES, 7 VIDEO_CATEGORIES,
@@ -14,9 +14,7 @@ import {
14} from '../../server/initializers/constants' 14} from '../../server/initializers/constants'
15import { I18N_LOCALES } from '../../shared/core-utils/i18n' 15import { I18N_LOCALES } from '../../shared/core-utils/i18n'
16 16
17registerTSPaths() 17const videojs = require(join(root(), 'client', 'src', 'locale', 'videojs.en-US.json'))
18
19const videojs = require(join(__dirname, '../../../client/src/locale/videojs.en-US.json'))
20const playerKeys = { 18const playerKeys = {
21 'Quality': 'Quality', 19 'Quality': 'Quality',
22 'Auto': 'Auto', 20 'Auto': 'Auto',
@@ -51,6 +49,9 @@ const playerKeys = {
51 'Buffer Progress': 'Buffer Progress', 49 'Buffer Progress': 'Buffer Progress',
52 'Buffer State': 'Buffer State', 50 'Buffer State': 'Buffer State',
53 'Live Latency': 'Live Latency', 51 'Live Latency': 'Live Latency',
52 'P2P': 'P2P',
53 'enabled': 'enabled',
54 'disabled': 'disabled',
54 ' off': ' off', 55 ' off': ' off',
55 'Player mode': 'Player mode' 56 'Player mode': 'Player mode'
56} 57}
@@ -97,7 +98,7 @@ writeAll().catch(err => {
97}) 98})
98 99
99async function writeAll () { 100async function writeAll () {
100 const localePath = join(__dirname, '../../../client/src/locale') 101 const localePath = join(root(), 'client', 'src', 'locale')
101 102
102 await writeJSON(join(localePath, 'player.en-US.json'), playerKeys, { spaces: 4 }) 103 await writeJSON(join(localePath, 'player.en-US.json'), playerKeys, { spaces: 4 })
103 await writeJSON(join(localePath, 'server.en-US.json'), serverKeys, { spaces: 4 }) 104 await writeJSON(join(localePath, 'server.en-US.json'), serverKeys, { spaces: 4 })
diff --git a/scripts/i18n/update.sh b/scripts/i18n/update.sh
index 0524c9e5d..4cf0d65b7 100755
--- a/scripts/i18n/update.sh
+++ b/scripts/i18n/update.sh
@@ -8,7 +8,7 @@ cd client
8npm run ng -- extract-i18n --out-file src/locale/angular.xlf 8npm run ng -- extract-i18n --out-file src/locale/angular.xlf
9 9
10# Merge new translations in other language files 10# Merge new translations in other language files
11node ./node_modules/.bin/xliffmerge -p ./.xliffmerge.json "ar" "ca-ES" "gl-ES" "cs-CZ" "da-DK" "de-DE" "el-GR" "en-GB" "en-US" "eo" "es-ES" "eu-ES" "fa-IR" "fi-FI" "fr-FR" "gd" "gl-ES" "hu-HU" "it-IT" "ja-JP" "jbo" "kab" "ko-KR" "lt-LT" "nb-NO" "nl-NL" "oc" "pl-PL" "pt-BR" "pt-PT" "ru-RU" "sk-SK" "sl-SI" "sv-SE" "ta" "th-TH" "tr-TR" "uk-UA" "vi-VN" "zh-Hans-CN" "zh-Hant-TW" 11node ./node_modules/.bin/xliffmerge -p ./.xliffmerge.json "ar" "ca-ES" "gl-ES" "cs-CZ" "da-DK" "de-DE" "el-GR" "en-GB" "en-US" "eo" "es-ES" "eu-ES" "fa-IR" "fi-FI" "fr-FR" "gd" "gl-ES" "hu-HU" "it-IT" "ja-JP" "jbo" "kab" "ko-KR" "lt-LT" "nb-NO" "nl-NL" "oc" "pl-PL" "pt-BR" "pt-PT" "ru-RU" "sk-SK" "sl-SI" "sv-SE" "ta" "th-TH" "tr-TR" "uk-UA" "vi-VN" "zh-Hans-CN" "zh-Hant-TW" "nn" "nb-NO"
12 12
13# Add our strings too 13# Add our strings too
14cd ../ 14cd ../
diff --git a/scripts/migrations/peertube-2.1.ts b/scripts/migrations/peertube-2.1.ts
index 4bbc203c1..2e316d996 100644
--- a/scripts/migrations/peertube-2.1.ts
+++ b/scripts/migrations/peertube-2.1.ts
@@ -1,15 +1,12 @@
1import { registerTSPaths } from '../../server/helpers/register-ts-paths'
2registerTSPaths()
3
4import { initDatabaseModels, sequelizeTypescript } from '../../server/initializers/database'
5import * as Sequelize from 'sequelize'
6import { join } from 'path'
7import { HLS_STREAMING_PLAYLIST_DIRECTORY, STATIC_PATHS, WEBSERVER } from '@server/initializers/constants'
8import { pathExists, stat, writeFile } from 'fs-extra' 1import { pathExists, stat, writeFile } from 'fs-extra'
9import { createTorrentPromise } from '@server/helpers/webtorrent'
10import { CONFIG } from '@server/initializers/config'
11import parseTorrent from 'parse-torrent' 2import parseTorrent from 'parse-torrent'
3import { join } from 'path'
4import * as Sequelize from 'sequelize'
12import { logger } from '@server/helpers/logger' 5import { logger } from '@server/helpers/logger'
6import { createTorrentPromise } from '@server/helpers/webtorrent'
7import { CONFIG } from '@server/initializers/config'
8import { HLS_STREAMING_PLAYLIST_DIRECTORY, STATIC_PATHS, WEBSERVER } from '@server/initializers/constants'
9import { initDatabaseModels, sequelizeTypescript } from '../../server/initializers/database'
13 10
14run() 11run()
15 .then(() => process.exit(0)) 12 .then(() => process.exit(0))
diff --git a/scripts/migrations/peertube-4.0.ts b/scripts/migrations/peertube-4.0.ts
index abf431888..64cf45474 100644
--- a/scripts/migrations/peertube-4.0.ts
+++ b/scripts/migrations/peertube-4.0.ts
@@ -1,16 +1,13 @@
1import { registerTSPaths } from '../../server/helpers/register-ts-paths' 1import Bluebird from 'bluebird'
2registerTSPaths() 2import { move, readFile, writeFile } from 'fs-extra'
3
4import { join } from 'path' 3import { join } from 'path'
4import { federateVideoIfNeeded } from '@server/lib/activitypub/videos'
5import { JobQueue } from '@server/lib/job-queue' 5import { JobQueue } from '@server/lib/job-queue'
6import { initDatabaseModels } from '../../server/initializers/database'
7import { generateHLSMasterPlaylistFilename, generateHlsSha256SegmentsFilename, getHlsResolutionPlaylistFilename } from '@server/lib/paths' 6import { generateHLSMasterPlaylistFilename, generateHlsSha256SegmentsFilename, getHlsResolutionPlaylistFilename } from '@server/lib/paths'
8import { VideoPathManager } from '@server/lib/video-path-manager' 7import { VideoPathManager } from '@server/lib/video-path-manager'
9import { VideoModel } from '@server/models/video/video' 8import { VideoModel } from '@server/models/video/video'
10import { VideoStreamingPlaylistModel } from '@server/models/video/video-streaming-playlist' 9import { VideoStreamingPlaylistModel } from '@server/models/video/video-streaming-playlist'
11import { move, readFile, writeFile } from 'fs-extra' 10import { initDatabaseModels } from '../../server/initializers/database'
12import Bluebird from 'bluebird'
13import { federateVideoIfNeeded } from '@server/lib/activitypub/videos'
14 11
15run() 12run()
16 .then(() => process.exit(0)) 13 .then(() => process.exit(0))
diff --git a/scripts/nightly.sh b/scripts/nightly.sh
index 5ad603929..572277f9d 100755
--- a/scripts/nightly.sh
+++ b/scripts/nightly.sh
@@ -32,7 +32,7 @@ sed -i 's/"version": "\([^"]\+\)"/"version": "\1-'"$nightly_version"'"/' ./packa
32 "$directory_name/client/package.json" "$directory_name/config" \ 32 "$directory_name/client/package.json" "$directory_name/config" \
33 "$directory_name/dist" "$directory_name/package.json" \ 33 "$directory_name/dist" "$directory_name/package.json" \
34 "$directory_name/scripts" "$directory_name/support" \ 34 "$directory_name/scripts" "$directory_name/support" \
35 "$directory_name/tsconfig.json" "$directory_name/yarn.lock") 35 "$directory_name/yarn.lock")
36 36
37 # temporary setup 37 # temporary setup
38 cd .. 38 cd ..
diff --git a/scripts/parse-log.ts b/scripts/parse-log.ts
index 6cd3a1860..d3c93cee5 100755
--- a/scripts/parse-log.ts
+++ b/scripts/parse-log.ts
@@ -1,15 +1,12 @@
1import { registerTSPaths } from '../server/helpers/register-ts-paths'
2registerTSPaths()
3
4import { program } from 'commander' 1import { program } from 'commander'
5import { createReadStream, readdir } from 'fs-extra' 2import { createReadStream, readdir } from 'fs-extra'
6import { join } from 'path' 3import { join } from 'path'
7import { createInterface } from 'readline' 4import { createInterface } from 'readline'
5import { format as sqlFormat } from 'sql-formatter'
6import { inspect } from 'util'
8import * as winston from 'winston' 7import * as winston from 'winston'
9import { labelFormatter, mtimeSortFilesDesc } from '../server/helpers/logger' 8import { labelFormatter, mtimeSortFilesDesc } from '../server/helpers/logger'
10import { CONFIG } from '../server/initializers/config' 9import { CONFIG } from '../server/initializers/config'
11import { inspect } from 'util'
12import { format as sqlFormat } from 'sql-formatter'
13 10
14program 11program
15 .option('-l, --level [level]', 'Level log (debug/info/warn/error)') 12 .option('-l, --level [level]', 'Level log (debug/info/warn/error)')
diff --git a/scripts/plugin/install.ts b/scripts/plugin/install.ts
index de045c2d2..0795d7c93 100755
--- a/scripts/plugin/install.ts
+++ b/scripts/plugin/install.ts
@@ -1,10 +1,7 @@
1import { registerTSPaths } from '../../server/helpers/register-ts-paths'
2registerTSPaths()
3
4import { initDatabaseModels } from '../../server/initializers/database'
5import { program } from 'commander' 1import { program } from 'commander'
6import { PluginManager } from '../../server/lib/plugins/plugin-manager'
7import { isAbsolute } from 'path' 2import { isAbsolute } from 'path'
3import { initDatabaseModels } from '../../server/initializers/database'
4import { PluginManager } from '../../server/lib/plugins/plugin-manager'
8 5
9program 6program
10 .option('-n, --npm-name [npmName]', 'Plugin to install') 7 .option('-n, --npm-name [npmName]', 'Plugin to install')
diff --git a/scripts/plugin/uninstall.ts b/scripts/plugin/uninstall.ts
index 1e14cc18f..152b651dd 100755
--- a/scripts/plugin/uninstall.ts
+++ b/scripts/plugin/uninstall.ts
@@ -1,8 +1,5 @@
1import { registerTSPaths } from '../../server/helpers/register-ts-paths'
2registerTSPaths()
3
4import { initDatabaseModels } from '../../server/initializers/database'
5import { program } from 'commander' 1import { program } from 'commander'
2import { initDatabaseModels } from '../../server/initializers/database'
6import { PluginManager } from '../../server/lib/plugins/plugin-manager' 3import { PluginManager } from '../../server/lib/plugins/plugin-manager'
7 4
8program 5program
diff --git a/scripts/print-transcode-command.ts b/scripts/print-transcode-command.ts
index 352145252..21667f544 100644
--- a/scripts/print-transcode-command.ts
+++ b/scripts/print-transcode-command.ts
@@ -1,10 +1,7 @@
1import { registerTSPaths } from '../server/helpers/register-ts-paths'
2registerTSPaths()
3
4import { program } from 'commander' 1import { program } from 'commander'
5import ffmpeg from 'fluent-ffmpeg' 2import ffmpeg from 'fluent-ffmpeg'
6import { buildx264VODCommand, runCommand, TranscodeOptions } from '@server/helpers/ffmpeg-utils'
7import { exit } from 'process' 3import { exit } from 'process'
4import { buildx264VODCommand, runCommand, TranscodeOptions } from '@server/helpers/ffmpeg-utils'
8import { VideoTranscodingProfilesManager } from '@server/lib/transcoding/video-transcoding-profiles' 5import { VideoTranscodingProfilesManager } from '@server/lib/transcoding/video-transcoding-profiles'
9 6
10program 7program
diff --git a/scripts/prune-storage.ts b/scripts/prune-storage.ts
index 9df80d503..bb1e8e024 100755
--- a/scripts/prune-storage.ts
+++ b/scripts/prune-storage.ts
@@ -1,21 +1,19 @@
1import { registerTSPaths } from '../server/helpers/register-ts-paths' 1import { map } from 'bluebird'
2registerTSPaths() 2import { readdir, remove, stat } from 'fs-extra'
3 3import { uniq, values } from 'lodash'
4import { start, get } from 'prompt' 4import { basename, join } from 'path'
5import { join, basename } from 'path' 5import { get, start } from 'prompt'
6import { HLS_REDUNDANCY_DIRECTORY, HLS_STREAMING_PLAYLIST_DIRECTORY } from '@server/initializers/constants'
7import { VideoFileModel } from '@server/models/video/video-file'
8import { VideoStreamingPlaylistModel } from '@server/models/video/video-streaming-playlist'
9import { ThumbnailType } from '@shared/models'
10import { getUUIDFromFilename } from '../server/helpers/utils'
6import { CONFIG } from '../server/initializers/config' 11import { CONFIG } from '../server/initializers/config'
7import { VideoModel } from '../server/models/video/video'
8import { initDatabaseModels } from '../server/initializers/database' 12import { initDatabaseModels } from '../server/initializers/database'
9import { readdir, remove, stat } from 'fs-extra' 13import { ActorImageModel } from '../server/models/actor/actor-image'
10import { VideoRedundancyModel } from '../server/models/redundancy/video-redundancy' 14import { VideoRedundancyModel } from '../server/models/redundancy/video-redundancy'
11import { map } from 'bluebird'
12import { getUUIDFromFilename } from '../server/helpers/utils'
13import { ThumbnailModel } from '../server/models/video/thumbnail' 15import { ThumbnailModel } from '../server/models/video/thumbnail'
14import { ActorImageModel } from '../server/models/actor/actor-image' 16import { VideoModel } from '../server/models/video/video'
15import { uniq, values } from 'lodash'
16import { ThumbnailType } from '@shared/models'
17import { VideoFileModel } from '@server/models/video/video-file'
18import { HLS_REDUNDANCY_DIRECTORY } from '@server/initializers/constants'
19 17
20run() 18run()
21 .then(() => process.exit(0)) 19 .then(() => process.exit(0))
@@ -40,6 +38,9 @@ async function run () {
40 38
41 toDelete = toDelete.concat( 39 toDelete = toDelete.concat(
42 await pruneDirectory(CONFIG.STORAGE.VIDEOS_DIR, doesWebTorrentFileExist()), 40 await pruneDirectory(CONFIG.STORAGE.VIDEOS_DIR, doesWebTorrentFileExist()),
41
42 await pruneDirectory(HLS_STREAMING_PLAYLIST_DIRECTORY, doesHLSPlaylistExist()),
43
43 await pruneDirectory(CONFIG.STORAGE.TORRENTS_DIR, doesTorrentFileExist()), 44 await pruneDirectory(CONFIG.STORAGE.TORRENTS_DIR, doesTorrentFileExist()),
44 45
45 await pruneDirectory(CONFIG.STORAGE.REDUNDANCY_DIR, doesRedundancyExist), 46 await pruneDirectory(CONFIG.STORAGE.REDUNDANCY_DIR, doesRedundancyExist),
@@ -94,6 +95,10 @@ function doesWebTorrentFileExist () {
94 return (filePath: string) => VideoFileModel.doesOwnedWebTorrentVideoFileExist(basename(filePath)) 95 return (filePath: string) => VideoFileModel.doesOwnedWebTorrentVideoFileExist(basename(filePath))
95} 96}
96 97
98function doesHLSPlaylistExist () {
99 return (hlsPath: string) => VideoStreamingPlaylistModel.doesOwnedHLSPlaylistExist(basename(hlsPath))
100}
101
97function doesTorrentFileExist () { 102function doesTorrentFileExist () {
98 return (filePath: string) => VideoFileModel.doesOwnedTorrentFileExist(basename(filePath)) 103 return (filePath: string) => VideoFileModel.doesOwnedTorrentFileExist(basename(filePath))
99} 104}
diff --git a/scripts/regenerate-thumbnails.ts b/scripts/regenerate-thumbnails.ts
index 50d06f6fd..a377baa61 100644
--- a/scripts/regenerate-thumbnails.ts
+++ b/scripts/regenerate-thumbnails.ts
@@ -1,13 +1,10 @@
1import { registerTSPaths } from '../server/helpers/register-ts-paths'
2registerTSPaths()
3
4import { map } from 'bluebird' 1import { map } from 'bluebird'
5import { program } from 'commander' 2import { program } from 'commander'
6import { pathExists, remove } from 'fs-extra' 3import { pathExists, remove } from 'fs-extra'
7import { generateImageFilename, processImage } from '@server/helpers/image-utils' 4import { generateImageFilename, processImage } from '@server/helpers/image-utils'
8import { THUMBNAILS_SIZE } from '@server/initializers/constants' 5import { THUMBNAILS_SIZE } from '@server/initializers/constants'
9import { VideoModel } from '@server/models/video/video'
10import { initDatabaseModels } from '@server/initializers/database' 6import { initDatabaseModels } from '@server/initializers/database'
7import { VideoModel } from '@server/models/video/video'
11 8
12program 9program
13 .description('Regenerate local thumbnails using preview files') 10 .description('Regenerate local thumbnails using preview files')
diff --git a/scripts/release.sh b/scripts/release.sh
index 6423d17ee..313087a29 100755
--- a/scripts/release.sh
+++ b/scripts/release.sh
@@ -76,7 +76,7 @@ rm -f "./client/dist/embed-stats.json"
76 "$directory_name/client/package.json" "$directory_name/config" \ 76 "$directory_name/client/package.json" "$directory_name/config" \
77 "$directory_name/dist" "$directory_name/package.json" \ 77 "$directory_name/dist" "$directory_name/package.json" \
78 "$directory_name/scripts" "$directory_name/support" \ 78 "$directory_name/scripts" "$directory_name/support" \
79 "$directory_name/tsconfig.json" "$directory_name/yarn.lock") 79 "$directory_name/yarn.lock")
80 80
81 # temporary setup 81 # temporary setup
82 cd .. 82 cd ..
@@ -118,3 +118,8 @@ rm -f "./client/dist/embed-stats.json"
118 git checkout "$branch" 118 git checkout "$branch"
119 fi 119 fi
120) 120)
121
122# Release types package
123npm run generate-types-package
124cd types/dist
125npm publish --access public
diff --git a/scripts/reset-password.ts b/scripts/reset-password.ts
index 4c45396d4..b2e5639fb 100755
--- a/scripts/reset-password.ts
+++ b/scripts/reset-password.ts
@@ -1,10 +1,7 @@
1import { registerTSPaths } from '../server/helpers/register-ts-paths'
2registerTSPaths()
3
4import { program } from 'commander' 1import { program } from 'commander'
2import { isUserPasswordValid } from '../server/helpers/custom-validators/users'
5import { initDatabaseModels } from '../server/initializers/database' 3import { initDatabaseModels } from '../server/initializers/database'
6import { UserModel } from '../server/models/user/user' 4import { UserModel } from '../server/models/user/user'
7import { isUserPasswordValid } from '../server/helpers/custom-validators/users'
8 5
9program 6program
10 .option('-u, --user [user]', 'User') 7 .option('-u, --user [user]', 'User')
diff --git a/scripts/setup/cli.sh b/scripts/setup/cli.sh
index ea327e5a1..f84260f23 100755
--- a/scripts/setup/cli.sh
+++ b/scripts/setup/cli.sh
@@ -9,8 +9,10 @@ rm -rf ./dist/server/tools/
9( 9(
10 cd ./server/tools 10 cd ./server/tools
11 yarn install --pure-lockfile 11 yarn install --pure-lockfile
12 ../../node_modules/.bin/tsc --build --verbose
12) 13)
13 14
14npm run tsc -- --build ./server/tools/tsconfig.json
15cp -r "./server/tools/node_modules" "./dist/server/tools" 15cp -r "./server/tools/node_modules" "./dist/server/tools"
16cp "./tsconfig.json" "./dist" 16
17npm run resolve-tspaths:cli
18npm run resolve-tspaths:server
diff --git a/scripts/test.sh b/scripts/test.sh
index 2dc79c6ce..4d1d8720a 100755
--- a/scripts/test.sh
+++ b/scripts/test.sh
@@ -2,6 +2,7 @@
2 2
3set -eu 3set -eu
4 4
5npm run ci -- types
5npm run ci -- client 6npm run ci -- client
6npm run ci -- cli-plugin 7npm run ci -- cli-plugin
7npm run ci -- api-1 8npm run ci -- api-1
diff --git a/scripts/tsconfig.json b/scripts/tsconfig.json
new file mode 100644
index 000000000..0cfd927a6
--- /dev/null
+++ b/scripts/tsconfig.json
@@ -0,0 +1,10 @@
1{
2 "extends": "../tsconfig.base.json",
3 "compilerOptions": {
4 "outDir": "../dist/scripts"
5 },
6 "references": [
7 { "path": "../shared" },
8 { "path": "../server" }
9 ]
10}
diff --git a/scripts/update-host.ts b/scripts/update-host.ts
index c6eb9d533..bb54290a4 100755
--- a/scripts/update-host.ts
+++ b/scripts/update-host.ts
@@ -1,10 +1,7 @@
1import { registerTSPaths } from '../server/helpers/register-ts-paths' 1import { updateTorrentMetadata } from '@server/helpers/webtorrent'
2registerTSPaths() 2import { getServerActor } from '@server/models/application/application'
3
4import { WEBSERVER } from '../server/initializers/constants' 3import { WEBSERVER } from '../server/initializers/constants'
5import { ActorFollowModel } from '../server/models/actor/actor-follow' 4import { initDatabaseModels } from '../server/initializers/database'
6import { VideoModel } from '../server/models/video/video'
7import { ActorModel } from '../server/models/actor/actor'
8import { 5import {
9 getLocalAccountActivityPubUrl, 6 getLocalAccountActivityPubUrl,
10 getLocalVideoActivityPubUrl, 7 getLocalVideoActivityPubUrl,
@@ -12,13 +9,13 @@ import {
12 getLocalVideoChannelActivityPubUrl, 9 getLocalVideoChannelActivityPubUrl,
13 getLocalVideoCommentActivityPubUrl 10 getLocalVideoCommentActivityPubUrl
14} from '../server/lib/activitypub/url' 11} from '../server/lib/activitypub/url'
15import { VideoShareModel } from '../server/models/video/video-share'
16import { VideoCommentModel } from '../server/models/video/video-comment'
17import { AccountModel } from '../server/models/account/account' 12import { AccountModel } from '../server/models/account/account'
13import { ActorModel } from '../server/models/actor/actor'
14import { ActorFollowModel } from '../server/models/actor/actor-follow'
15import { VideoModel } from '../server/models/video/video'
18import { VideoChannelModel } from '../server/models/video/video-channel' 16import { VideoChannelModel } from '../server/models/video/video-channel'
19import { initDatabaseModels } from '../server/initializers/database' 17import { VideoCommentModel } from '../server/models/video/video-comment'
20import { updateTorrentUrls } from '@server/helpers/webtorrent' 18import { VideoShareModel } from '../server/models/video/video-share'
21import { getServerActor } from '@server/models/application/application'
22 19
23run() 20run()
24 .then(() => process.exit(0)) 21 .then(() => process.exit(0))
@@ -126,7 +123,7 @@ async function run () {
126 123
127 for (const file of video.VideoFiles) { 124 for (const file of video.VideoFiles) {
128 console.log('Updating torrent file %s of video %s.', file.resolution, video.uuid) 125 console.log('Updating torrent file %s of video %s.', file.resolution, video.uuid)
129 await updateTorrentUrls(video, file) 126 await updateTorrentMetadata(video, file)
130 127
131 await file.save() 128 await file.save()
132 } 129 }
@@ -135,7 +132,7 @@ async function run () {
135 for (const file of (playlist?.VideoFiles || [])) { 132 for (const file of (playlist?.VideoFiles || [])) {
136 console.log('Updating fragmented torrent file %s of video %s.', file.resolution, video.uuid) 133 console.log('Updating fragmented torrent file %s of video %s.', file.resolution, video.uuid)
137 134
138 await updateTorrentUrls(video, file) 135 await updateTorrentMetadata(playlist, file)
139 136
140 await file.save() 137 await file.save()
141 } 138 }