1 import { registerTSPaths } from '../helpers/register-ts-paths'
4 import * as repl from 'repl'
5 import * as path from 'path'
6 import * as _ from 'lodash'
7 import { uuidv1, uuidv3, uuidv4, uuidv5 } from 'uuid'
8 import * as Sequelize from 'sequelize'
9 import * as YoutubeDL from 'youtube-dl'
10 import { initDatabaseModels, sequelizeTypescript } from '../initializers'
11 import * as cli from '../tools/cli'
12 import { logger } from '../helpers/logger'
13 import * as constants from '../initializers/constants'
14 import * as modelsUtils from '../models/utils'
15 import * as coreUtils from '../helpers/core-utils'
16 import * as ffmpegUtils from '../helpers/ffmpeg-utils'
17 import * as peertubeCryptoUtils from '../helpers/peertube-crypto'
18 import * as signupUtils from '../helpers/signup'
19 import * as utils from '../helpers/utils'
20 import * as YoutubeDLUtils from '../helpers/youtube-dl'
22 const start = async () => {
23 await initDatabaseModels(true)
25 const versionCommitHash = await utils.getServerCommit()
27 const initContext = (replServer) => {
45 models: sequelizeTypescript.models,
46 transaction: sequelizeTypescript.transaction,
47 query: sequelizeTypescript.query,
48 queryInterface: sequelizeTypescript.getQueryInterface(),
58 for (const prop in properties) {
59 Object.defineProperty(context, prop, {
62 value: properties[prop]
68 const replServer = repl.start({
69 prompt: `PeerTube [${cli.version}] (${versionCommitHash})> `
72 initContext(replServer)(replServer.context)
73 replServer.on('reset', initContext(replServer))
74 replServer.on('exit', () => process.exit())
76 const resetCommand = {
79 this.write('.clear\n')
83 replServer.defineCommand('reset', resetCommand)
84 replServer.defineCommand('r', resetCommand)