Use typescript paths in cli scripts too

pull/2191/head
Chocobozzz 2019-10-21 17:13:07 +02:00
parent 576ddf645f
commit 2aaa1a3fdc
No known key found for this signature in database
GPG Key ID: 583A612D890159BE
23 changed files with 82 additions and 9 deletions

View 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'

View File

@ -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'

View 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'

View File

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

View File

@ -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'

View File

@ -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'

View 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'

View File

@ -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'

View File

@ -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'

View File

@ -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']

View File

@ -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'

View File

@ -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'

View File

@ -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'

View File

@ -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'

View File

@ -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
}

View 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'

View 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'

View 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'

View 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'

View 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'

View 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'

View 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'

View File

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