1 import { registerTSPaths } from '../helpers/register-ts-paths'
2 import * as repl from 'repl'
3 import * as path from 'path'
4 import * as _ from 'lodash'
5 import * as uuidv1 from 'uuid/v1'
6 import * as uuidv3 from 'uuid/v3'
7 import * as uuidv4 from 'uuid/v4'
8 import * as uuidv5 from 'uuid/v5'
9 import * as Sequelize from 'sequelize'
10 import * as YoutubeDL from 'youtube-dl'
12 import { initDatabaseModels, sequelizeTypescript } from '../initializers'
13 import * as cli from '../tools/cli'
14 import { logger } from '../helpers/logger'
15 import * as constants from '../initializers/constants'
16 import * as modelsUtils from '../models/utils'
17 import * as coreUtils from '../helpers/core-utils'
18 import * as ffmpegUtils from '../helpers/ffmpeg-utils'
19 import * as peertubeCryptoUtils from '../helpers/peertube-crypto'
20 import * as signupUtils from '../helpers/signup'
21 import * as utils from '../helpers/utils'
22 import * as YoutubeDLUtils from '../helpers/youtube-dl'
26 const start = async () => {
27 await initDatabaseModels(true)
29 const versionCommitHash = await utils.getServerCommit()
31 const initContext = (replServer) => {
49 models: sequelizeTypescript.models,
50 transaction: sequelizeTypescript.transaction,
51 query: sequelizeTypescript.query,
52 queryInterface: sequelizeTypescript.getQueryInterface(),
62 for (const prop in properties) {
63 Object.defineProperty(context, prop, {
66 value: properties[prop]
72 const replServer = repl.start({
73 prompt: `PeerTube [${cli.version}] (${versionCommitHash})> `
76 initContext(replServer)(replServer.context)
77 replServer.on('reset', initContext(replServer))
78 replServer.on('exit', () => process.exit())
80 const resetCommand = {
83 this.write('.clear\n')
87 replServer.defineCommand('reset', resetCommand)
88 replServer.defineCommand('r', resetCommand)