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 * as Sequelize from 'sequelize'
8 import * as YoutubeDL from 'youtube-dl'
9 import { initDatabaseModels, sequelizeTypescript } from '../initializers/database'
10 import * as cli from '../tools/cli'
11 import { logger } from '../helpers/logger'
12 import * as constants from '../initializers/constants'
13 import * as modelsUtils from '../models/utils'
14 import * as coreUtils from '../helpers/core-utils'
15 import * as ffmpegUtils from '../helpers/ffmpeg-utils'
16 import * as peertubeCryptoUtils from '../helpers/peertube-crypto'
17 import * as utils from '../helpers/utils'
18 import * as YoutubeDLUtils from '../helpers/youtube-dl'
20 const start = async () => {
21 await initDatabaseModels(true)
23 const versionCommitHash = await utils.getServerCommit()
25 const initContext = (replServer) => {
39 models: sequelizeTypescript.models,
40 transaction: sequelizeTypescript.transaction,
41 query: sequelizeTypescript.query,
42 queryInterface: sequelizeTypescript.getQueryInterface(),
51 for (const prop in properties) {
52 Object.defineProperty(context, prop, {
55 value: properties[prop]
61 const replServer = repl.start({
62 prompt: `PeerTube [${cli.version}] (${versionCommitHash})> `
65 initContext(replServer)(replServer.context)
66 replServer.on('reset', initContext(replServer))
67 replServer.on('exit', () => process.exit())
69 const resetCommand = {
72 this.write('.clear\n')
76 replServer.defineCommand('reset', resetCommand)
77 replServer.defineCommand('r', resetCommand)