Use typescript paths in cli scripts too
authorChocobozzz <me@florianbigard.com>
Mon, 21 Oct 2019 15:13:07 +0000 (17:13 +0200)
committerChocobozzz <me@florianbigard.com>
Mon, 21 Oct 2019 15:13:22 +0000 (17:13 +0200)
23 files changed:
scripts/create-import-video-file-job.ts
scripts/create-transcoding-job.ts
scripts/danger/clean/cleaner.ts
scripts/generate-code-contributors.ts
scripts/i18n/create-custom-files.ts
scripts/i18n/xliff2json.ts
scripts/optimize-old-videos.ts
scripts/parse-log.ts
scripts/plugin/install.ts
scripts/plugin/uninstall.ts
scripts/prune-storage.ts
scripts/reset-password.ts
scripts/update-host.ts
server.ts
server/helpers/register-ts-paths.ts [new file with mode: 0644]
server/tools/peertube-auth.ts
server/tools/peertube-get-access-token.ts
server/tools/peertube-import-videos.ts
server/tools/peertube-plugins.ts
server/tools/peertube-repl.ts
server/tools/peertube-upload.ts
server/tools/peertube-watch.ts
server/tools/peertube.ts

index 2b636014a6636b228cfb7b54fe9bceb610d17f8d..204337d551fccf1c14325c56b5382415093aea3d 100644 (file)
@@ -1,3 +1,6 @@
+import { registerTSPaths } from '../server/helpers/register-ts-paths'
+registerTSPaths()
+
 import * as program from 'commander'
 import { resolve } from 'path'
 import { VideoModel } from '../server/models/video/video'
index 2eb872169f00cfad6a07737ba220be51d5b28523..67a270a8660ba88f5d5769a9fa24a0e616ac9bf5 100755 (executable)
@@ -1,3 +1,6 @@
+import { registerTSPaths } from '../server/helpers/register-ts-paths'
+registerTSPaths()
+
 import * as program from 'commander'
 import { VideoModel } from '../server/models/video/video'
 import { initDatabaseModels } from '../server/initializers'
index d575af283211dd1df8d22f7ccab5e720f3e2ff48..ed35ef79f87e77441de93e07ba9d2c4e0760b987 100644 (file)
@@ -1,3 +1,6 @@
+import { registerTSPaths } from '../../../server/helpers/register-ts-paths'
+registerTSPaths()
+
 import * as Promise from 'bluebird'
 import * as rimraf from 'rimraf'
 import { initDatabaseModels, sequelizeTypescript } from '../../../server/initializers'
index c745b1cb243057b2e81edd181f40dc8ead25401b..8493d3d0ca2e04f7d74203c66452e6a8334325ea 100755 (executable)
@@ -1,3 +1,6 @@
+import { registerTSPaths } from '../server/helpers/register-ts-paths'
+registerTSPaths()
+
 import { doRequest } from '../server/helpers/requests'
 import { readFileSync } from 'fs-extra'
 
index 95897afa35b5768e6a0f2499a4ccdd3914a92780..e946b8fd63f27977eef21657f0253a7bcaf57cda 100755 (executable)
@@ -1,3 +1,6 @@
+import { registerTSPaths } from '../../server/helpers/register-ts-paths'
+registerTSPaths()
+
 import * as jsToXliff12 from 'xliff/jsToXliff12'
 import { writeFile } from 'fs-extra'
 import { join } from 'path'
index 7e6de28935069e03aa485700178a6821574c61fa..68fc95f3497ec551e67e3fef1a194384e0f66cf7 100755 (executable)
@@ -1,3 +1,6 @@
+import { registerTSPaths } from '../../server/helpers/register-ts-paths'
+registerTSPaths()
+
 import * as xliff12ToJs from 'xliff/xliff12ToJs'
 import { readFileSync, unlink, writeFile } from 'fs-extra'
 import { join } from 'path'
index 0b0e6037e4da688575e360f8122a2a195a8b71ad..eb61ec43c4ae0255a8c7d172a8e9ceabf56573bb 100644 (file)
@@ -1,3 +1,6 @@
+import { registerTSPaths } from '../server/helpers/register-ts-paths'
+registerTSPaths()
+
 import { VIDEO_TRANSCODING_FPS } from '../server/initializers/constants'
 import { getDurationFromVideoFile, getVideoFileBitrate, getVideoFileFPS, getVideoFileResolution } from '../server/helpers/ffmpeg-utils'
 import { getMaxBitrate } from '../shared/models/videos'
index 83ad45b72a84fa46637023161b123233bde21efc..9e6653ca3ed73d42712b289153902a10343b9b58 100755 (executable)
@@ -1,3 +1,6 @@
+import { registerTSPaths } from '../server/helpers/register-ts-paths'
+registerTSPaths()
+
 import * as program from 'commander'
 import { createReadStream, readdir } from 'fs-extra'
 import { join } from 'path'
index 5d7fe4ba04688f30a155c9c1342edfa1f316a639..54738f50f15c3b68e731f19c76bd5daef6d8defe 100755 (executable)
@@ -1,3 +1,6 @@
+import { registerTSPaths } from '../../server/helpers/register-ts-paths'
+registerTSPaths()
+
 import { initDatabaseModels } from '../../server/initializers/database'
 import * as program from 'commander'
 import { PluginManager } from '../../server/lib/plugins/plugin-manager'
index b5e1ddea296d1e2944c0baa39a66ae0161ef095e..c56f184663fb75a93c5f8dd76c1d6b81035c2062 100755 (executable)
@@ -1,3 +1,6 @@
+import { registerTSPaths } from '../../server/helpers/register-ts-paths'
+registerTSPaths()
+
 import { initDatabaseModels } from '../../server/initializers/database'
 import * as program from 'commander'
 import { PluginManager } from '../../server/lib/plugins/plugin-manager'
@@ -19,6 +22,7 @@ run()
   })
 
 async function run () {
+
   await initDatabaseModels(true)
 
   const toUninstall = program['npmName']
index df4bdeebe0c2b18f01694cfe899993e8b8070331..c8968013b8dbfd0573c17af4d35d73013aa6bcf9 100755 (executable)
@@ -1,3 +1,6 @@
+import { registerTSPaths } from '../server/helpers/register-ts-paths'
+registerTSPaths()
+
 import * as prompt from 'prompt'
 import { join } from 'path'
 import { CONFIG } from '../server/initializers/config'
index 4a9037280804c52095e402c967721271962c7eec..6126c3cd09fa9da04c57b1c52852ad3196627f66 100755 (executable)
@@ -1,3 +1,6 @@
+import { registerTSPaths } from '../server/helpers/register-ts-paths'
+registerTSPaths()
+
 import * as program from 'commander'
 import { initDatabaseModels } from '../server/initializers'
 import { UserModel } from '../server/models/account/user'
index 57919b9981a4f40bf27b48bb541d1738466aa0e1..a946d2e4229523a4f5278d6999ef8e8500588a98 100755 (executable)
@@ -1,3 +1,6 @@
+import { registerTSPaths } from '../server/helpers/register-ts-paths'
+registerTSPaths()
+
 import { WEBSERVER } from '../server/initializers/constants'
 import { ActorFollowModel } from '../server/models/activitypub/actor-follow'
 import { VideoModel } from '../server/models/video/video'
index b49d10344bb5a38b83739afe30fe7b350a85322d..b2541eed680c525a033ec3825de69245e96fe975 100644 (file)
--- a/server.ts
+++ b/server.ts
@@ -1,13 +1,6 @@
-import { resolve } from 'path'
+import { registerTSPaths } from './server/helpers/register-ts-paths'
 
-const tsConfig = require('./tsconfig.json')
-const tsConfigPaths = require('tsconfig-paths')
-
-// Thanks: https://github.com/dividab/tsconfig-paths/issues/75#issuecomment-458936883
-tsConfigPaths.register({
-  baseUrl: resolve(tsConfig.compilerOptions.baseUrl || '', tsConfig.compilerOptions.outDir || ''),
-  paths: tsConfig.compilerOptions.paths
-})
+registerTSPaths()
 
 // FIXME: https://github.com/nodejs/node/pull/16853
 require('tls').DEFAULT_ECDH_CURVE = 'auto'
diff --git a/server/helpers/register-ts-paths.ts b/server/helpers/register-ts-paths.ts
new file mode 100644 (file)
index 0000000..e8db369
--- /dev/null
@@ -0,0 +1,16 @@
+import { resolve } from 'path'
+const tsConfigPaths = require('tsconfig-paths')
+
+const tsConfig = require('../../tsconfig.json')
+
+function registerTSPaths () {
+  // Thanks: https://github.com/dividab/tsconfig-paths/issues/75#issuecomment-458936883
+  tsConfigPaths.register({
+    baseUrl: resolve(tsConfig.compilerOptions.baseUrl || '', tsConfig.compilerOptions.outDir || ''),
+    paths: tsConfig.compilerOptions.paths
+  })
+}
+
+export {
+  registerTSPaths
+}
index b5ecbd4706f1095079c1c88cc9f1c797e7e60b35..6597a5c367e78d3d0c9a92f920c70ae990584db2 100644 (file)
@@ -1,3 +1,6 @@
+import { registerTSPaths } from '../helpers/register-ts-paths'
+registerTSPaths()
+
 import * as program from 'commander'
 import * as prompt from 'prompt'
 import { getNetrc, getSettings, writeSettings } from './cli'
index 103495347c7ca6025d3a23ba365ecb51749e7c08..6d47d8922076b95479d302ce2b543c68b2a32925 100644 (file)
@@ -1,3 +1,6 @@
+import { registerTSPaths } from '../helpers/register-ts-paths'
+registerTSPaths()
+
 import * as program from 'commander'
 import { getClient, Server, serverLogin } from '../../shared/extra-utils'
 
index fcb90cca3f30af56493c1cc211d47eca62d23b7a..39184f46d5d4ea520705ca7d22c27faa111945ad 100644 (file)
@@ -1,3 +1,6 @@
+import { registerTSPaths } from '../helpers/register-ts-paths'
+registerTSPaths()
+
 // FIXME: https://github.com/nodejs/node/pull/16853
 require('tls').DEFAULT_ECDH_CURVE = 'auto'
 
index 20254b3b4547a43933f6a9a14073ccb8ed50c44d..e40606107249e5b7ab8ea81be2dd14c5b9cfbd4e 100644 (file)
@@ -1,3 +1,6 @@
+import { registerTSPaths } from '../helpers/register-ts-paths'
+registerTSPaths()
+
 import * as program from 'commander'
 import { PluginType } from '../../shared/models/plugins/plugin.type'
 import { getAccessToken } from '../../shared/extra-utils/users/login'
index fbdec16132ad0580ae500a9b15be6cdf47eae3b3..ab6e215d9dc26f431797bf4166506ea14b64ac52 100644 (file)
@@ -1,3 +1,6 @@
+import { registerTSPaths } from '../helpers/register-ts-paths'
+registerTSPaths()
+
 import * as repl from 'repl'
 import * as path from 'path'
 import * as _ from 'lodash'
index 4569cbb85b31dd89802d1d36304bb29403f521a8..f604c9bee8fb96eecb3b6f7428c6b02435bc12c5 100644 (file)
@@ -1,3 +1,6 @@
+import { registerTSPaths } from '../helpers/register-ts-paths'
+registerTSPaths()
+
 import * as program from 'commander'
 import { access, constants } from 'fs-extra'
 import { isAbsolute } from 'path'
index 7c27c13642c5ab4880812637b332f3059dec2230..9ac1d05f91022ce49212eb9747257d79f7c1a29c 100644 (file)
@@ -1,3 +1,6 @@
+import { registerTSPaths } from '../helpers/register-ts-paths'
+registerTSPaths()
+
 import * as program from 'commander'
 import { join } from 'path'
 import { execSync } from 'child_process'
index ddfe5b771a5a22d44f3b7b36158c0e9afeaf42e0..fc85c421097c17056695fcda67cbce9d23e9a376 100644 (file)
@@ -1,5 +1,8 @@
 #!/usr/bin/env node
 
+import { registerTSPaths } from '../helpers/register-ts-paths'
+registerTSPaths()
+
 import * as program from 'commander'
 import {
   version,