Browse Source

Use typescript paths in cli scripts too

Chocobozzz 1 month ago
parent
commit
2aaa1a3fdc
No account linked to committer's email address

+ 3
- 0
scripts/create-import-video-file-job.ts View File

@@ -1,3 +1,6 @@
1
+import { registerTSPaths } from '../server/helpers/register-ts-paths'
2
+registerTSPaths()
3
+
1 4
 import * as program from 'commander'
2 5
 import { resolve } from 'path'
3 6
 import { VideoModel } from '../server/models/video/video'

+ 3
- 0
scripts/create-transcoding-job.ts View File

@@ -1,3 +1,6 @@
1
+import { registerTSPaths } from '../server/helpers/register-ts-paths'
2
+registerTSPaths()
3
+
1 4
 import * as program from 'commander'
2 5
 import { VideoModel } from '../server/models/video/video'
3 6
 import { initDatabaseModels } from '../server/initializers'

+ 3
- 0
scripts/danger/clean/cleaner.ts View File

@@ -1,3 +1,6 @@
1
+import { registerTSPaths } from '../../../server/helpers/register-ts-paths'
2
+registerTSPaths()
3
+
1 4
 import * as Promise from 'bluebird'
2 5
 import * as rimraf from 'rimraf'
3 6
 import { initDatabaseModels, sequelizeTypescript } from '../../../server/initializers'

+ 3
- 0
scripts/generate-code-contributors.ts View File

@@ -1,3 +1,6 @@
1
+import { registerTSPaths } from '../server/helpers/register-ts-paths'
2
+registerTSPaths()
3
+
1 4
 import { doRequest } from '../server/helpers/requests'
2 5
 import { readFileSync } from 'fs-extra'
3 6
 

+ 3
- 0
scripts/i18n/create-custom-files.ts View File

@@ -1,3 +1,6 @@
1
+import { registerTSPaths } from '../../server/helpers/register-ts-paths'
2
+registerTSPaths()
3
+
1 4
 import * as jsToXliff12 from 'xliff/jsToXliff12'
2 5
 import { writeFile } from 'fs-extra'
3 6
 import { join } from 'path'

+ 3
- 0
scripts/i18n/xliff2json.ts View File

@@ -1,3 +1,6 @@
1
+import { registerTSPaths } from '../../server/helpers/register-ts-paths'
2
+registerTSPaths()
3
+
1 4
 import * as xliff12ToJs from 'xliff/xliff12ToJs'
2 5
 import { readFileSync, unlink, writeFile } from 'fs-extra'
3 6
 import { join } from 'path'

+ 3
- 0
scripts/optimize-old-videos.ts View File

@@ -1,3 +1,6 @@
1
+import { registerTSPaths } from '../server/helpers/register-ts-paths'
2
+registerTSPaths()
3
+
1 4
 import { VIDEO_TRANSCODING_FPS } from '../server/initializers/constants'
2 5
 import { getDurationFromVideoFile, getVideoFileBitrate, getVideoFileFPS, getVideoFileResolution } from '../server/helpers/ffmpeg-utils'
3 6
 import { getMaxBitrate } from '../shared/models/videos'

+ 3
- 0
scripts/parse-log.ts View File

@@ -1,3 +1,6 @@
1
+import { registerTSPaths } from '../server/helpers/register-ts-paths'
2
+registerTSPaths()
3
+
1 4
 import * as program from 'commander'
2 5
 import { createReadStream, readdir } from 'fs-extra'
3 6
 import { join } from 'path'

+ 3
- 0
scripts/plugin/install.ts View File

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

+ 4
- 0
scripts/plugin/uninstall.ts View File

@@ -1,3 +1,6 @@
1
+import { registerTSPaths } from '../../server/helpers/register-ts-paths'
2
+registerTSPaths()
3
+
1 4
 import { initDatabaseModels } from '../../server/initializers/database'
2 5
 import * as program from 'commander'
3 6
 import { PluginManager } from '../../server/lib/plugins/plugin-manager'
@@ -19,6 +22,7 @@ run()
19 22
   })
20 23
 
21 24
 async function run () {
25
+
22 26
   await initDatabaseModels(true)
23 27
 
24 28
   const toUninstall = program['npmName']

+ 3
- 0
scripts/prune-storage.ts View File

@@ -1,3 +1,6 @@
1
+import { registerTSPaths } from '../server/helpers/register-ts-paths'
2
+registerTSPaths()
3
+
1 4
 import * as prompt from 'prompt'
2 5
 import { join } from 'path'
3 6
 import { CONFIG } from '../server/initializers/config'

+ 3
- 0
scripts/reset-password.ts View File

@@ -1,3 +1,6 @@
1
+import { registerTSPaths } from '../server/helpers/register-ts-paths'
2
+registerTSPaths()
3
+
1 4
 import * as program from 'commander'
2 5
 import { initDatabaseModels } from '../server/initializers'
3 6
 import { UserModel } from '../server/models/account/user'

+ 3
- 0
scripts/update-host.ts View File

@@ -1,3 +1,6 @@
1
+import { registerTSPaths } from '../server/helpers/register-ts-paths'
2
+registerTSPaths()
3
+
1 4
 import { WEBSERVER } from '../server/initializers/constants'
2 5
 import { ActorFollowModel } from '../server/models/activitypub/actor-follow'
3 6
 import { VideoModel } from '../server/models/video/video'

+ 2
- 9
server.ts View File

@@ -1,13 +1,6 @@
1
-import { resolve } from 'path'
1
+import { registerTSPaths } from './server/helpers/register-ts-paths'
2 2
 
3
-const tsConfig = require('./tsconfig.json')
4
-const tsConfigPaths = require('tsconfig-paths')
5
-
6
-// Thanks: https://github.com/dividab/tsconfig-paths/issues/75#issuecomment-458936883
7
-tsConfigPaths.register({
8
-  baseUrl: resolve(tsConfig.compilerOptions.baseUrl || '', tsConfig.compilerOptions.outDir || ''),
9
-  paths: tsConfig.compilerOptions.paths
10
-})
3
+registerTSPaths()
11 4
 
12 5
 // FIXME: https://github.com/nodejs/node/pull/16853
13 6
 require('tls').DEFAULT_ECDH_CURVE = 'auto'

+ 16
- 0
server/helpers/register-ts-paths.ts View File

@@ -0,0 +1,16 @@
1
+import { resolve } from 'path'
2
+const 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
+}

+ 3
- 0
server/tools/peertube-auth.ts View File

@@ -1,3 +1,6 @@
1
+import { registerTSPaths } from '../helpers/register-ts-paths'
2
+registerTSPaths()
3
+
1 4
 import * as program from 'commander'
2 5
 import * as prompt from 'prompt'
3 6
 import { getNetrc, getSettings, writeSettings } from './cli'

+ 3
- 0
server/tools/peertube-get-access-token.ts View File

@@ -1,3 +1,6 @@
1
+import { registerTSPaths } from '../helpers/register-ts-paths'
2
+registerTSPaths()
3
+
1 4
 import * as program from 'commander'
2 5
 import { getClient, Server, serverLogin } from '../../shared/extra-utils'
3 6
 

+ 3
- 0
server/tools/peertube-import-videos.ts View File

@@ -1,3 +1,6 @@
1
+import { registerTSPaths } from '../helpers/register-ts-paths'
2
+registerTSPaths()
3
+
1 4
 // FIXME: https://github.com/nodejs/node/pull/16853
2 5
 require('tls').DEFAULT_ECDH_CURVE = 'auto'
3 6
 

+ 3
- 0
server/tools/peertube-plugins.ts View File

@@ -1,3 +1,6 @@
1
+import { registerTSPaths } from '../helpers/register-ts-paths'
2
+registerTSPaths()
3
+
1 4
 import * as program from 'commander'
2 5
 import { PluginType } from '../../shared/models/plugins/plugin.type'
3 6
 import { getAccessToken } from '../../shared/extra-utils/users/login'

+ 3
- 0
server/tools/peertube-repl.ts View File

@@ -1,3 +1,6 @@
1
+import { registerTSPaths } from '../helpers/register-ts-paths'
2
+registerTSPaths()
3
+
1 4
 import * as repl from 'repl'
2 5
 import * as path from 'path'
3 6
 import * as _ from 'lodash'

+ 3
- 0
server/tools/peertube-upload.ts View File

@@ -1,3 +1,6 @@
1
+import { registerTSPaths } from '../helpers/register-ts-paths'
2
+registerTSPaths()
3
+
1 4
 import * as program from 'commander'
2 5
 import { access, constants } from 'fs-extra'
3 6
 import { isAbsolute } from 'path'

+ 3
- 0
server/tools/peertube-watch.ts View File

@@ -1,3 +1,6 @@
1
+import { registerTSPaths } from '../helpers/register-ts-paths'
2
+registerTSPaths()
3
+
1 4
 import * as program from 'commander'
2 5
 import { join } from 'path'
3 6
 import { execSync } from 'child_process'

+ 3
- 0
server/tools/peertube.ts View File

@@ -1,5 +1,8 @@
1 1
 #!/usr/bin/env node
2 2
 
3
+import { registerTSPaths } from '../helpers/register-ts-paths'
4
+registerTSPaths()
5
+
3 6
 import * as program from 'commander'
4 7
 import {
5 8
   version,

Loading…
Cancel
Save