Use typescript paths in cli scripts too
This commit is contained in:
parent
576ddf645f
commit
2aaa1a3fdc
23 changed files with 82 additions and 9 deletions
|
@ -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'
|
||||
|
|
|
@ -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'
|
||||
|
|
|
@ -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'
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
import { registerTSPaths } from '../server/helpers/register-ts-paths'
|
||||
registerTSPaths()
|
||||
|
||||
import { doRequest } from '../server/helpers/requests'
|
||||
import { readFileSync } from 'fs-extra'
|
||||
|
||||
|
|
|
@ -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'
|
||||
|
|
|
@ -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'
|
||||
|
|
|
@ -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'
|
||||
|
|
|
@ -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'
|
||||
|
|
|
@ -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'
|
||||
|
|
|
@ -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']
|
||||
|
|
|
@ -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'
|
||||
|
|
|
@ -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'
|
||||
|
|
|
@ -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'
|
||||
|
|
11
server.ts
11
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'
|
||||
|
|
16
server/helpers/register-ts-paths.ts
Normal file
16
server/helpers/register-ts-paths.ts
Normal 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
|
||||
}
|
|
@ -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'
|
||||
|
|
|
@ -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'
|
||||
|
||||
|
|
|
@ -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'
|
||||
|
||||
|
|
|
@ -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'
|
||||
|
|
|
@ -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'
|
||||
|
|
|
@ -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'
|
||||
|
|
|
@ -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'
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
#!/usr/bin/env node
|
||||
|
||||
import { registerTSPaths } from '../helpers/register-ts-paths'
|
||||
registerTSPaths()
|
||||
|
||||
import * as program from 'commander'
|
||||
import {
|
||||
version,
|
||||
|
|
Loading…
Reference in a new issue