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 uuidv1 from 'uuid/v1'
8 import * as uuidv3 from 'uuid/v3'
9 import * as uuidv4 from 'uuid/v4'
10 import * as uuidv5 from 'uuid/v5'
11 import * as Sequelize from 'sequelize'
12 import * as YoutubeDL from 'youtube-dl'
14 import { initDatabaseModels, sequelizeTypescript } from '../initializers'
15 import * as cli from '../tools/cli'
16 import { logger } from '../helpers/logger'
17 import * as constants from '../initializers/constants'
18 import * as modelsUtils from '../models/utils'
19 import * as coreUtils from '../helpers/core-utils'
20 import * as ffmpegUtils from '../helpers/ffmpeg-utils'
21 import * as peertubeCryptoUtils from '../helpers/peertube-crypto'
22 import * as signupUtils from '../helpers/signup'
23 import * as utils from '../helpers/utils'
24 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) => {
34 context, repl: replServer, env: process.env,
36 uuidv1, uuidv3, uuidv4, uuidv5,
37 cli, logger, constants,
38 Sequelize, sequelizeTypescript, modelsUtils,
39 models: sequelizeTypescript.models, transaction: sequelizeTypescript.transaction,
40 query: sequelizeTypescript.query, queryInterface: sequelizeTypescript.getQueryInterface(),
42 coreUtils, ffmpegUtils, peertubeCryptoUtils, signupUtils, utils, YoutubeDLUtils
45 for (let prop in properties) {
46 Object.defineProperty(context, prop, {
49 value: properties[ prop ]
55 const replServer = repl.start({
56 prompt: `PeerTube [${cli.version}] (${versionCommitHash})> `
59 initContext(replServer)(replServer.context)
60 replServer.on('reset', initContext(replServer))
61 replServer.on('exit', () => process.exit())
63 const resetCommand = {
66 this.write('.clear\n')
70 replServer.defineCommand('reset', resetCommand)
71 replServer.defineCommand('r', resetCommand)