aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tools/peertube-repl.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/tools/peertube-repl.ts')
-rw-r--r--server/tools/peertube-repl.ts83
1 files changed, 0 insertions, 83 deletions
diff --git a/server/tools/peertube-repl.ts b/server/tools/peertube-repl.ts
deleted file mode 100644
index eb0a776b8..000000000
--- a/server/tools/peertube-repl.ts
+++ /dev/null
@@ -1,83 +0,0 @@
1import { registerTSPaths } from '../helpers/register-ts-paths'
2registerTSPaths()
3
4import * as repl from 'repl'
5import * as path from 'path'
6import * as _ from 'lodash'
7import * as Sequelize from 'sequelize'
8import * as YoutubeDL from 'youtube-dl'
9import { initDatabaseModels, sequelizeTypescript } from '../initializers/database'
10import * as cli from '../tools/cli'
11import { logger } from '../helpers/logger'
12import * as constants from '../initializers/constants'
13import * as modelsUtils from '../models/utils'
14import * as coreUtils from '../helpers/core-utils'
15import * as ffmpegUtils from '../helpers/ffmpeg-utils'
16import * as peertubeCryptoUtils from '../helpers/peertube-crypto'
17import * as utils from '../helpers/utils'
18import * as YoutubeDLUtils from '../helpers/youtube-dl'
19
20const start = async () => {
21 await initDatabaseModels(true)
22
23 const versionCommitHash = await utils.getServerCommit()
24
25 const initContext = (replServer) => {
26 return (context) => {
27 const properties = {
28 context,
29 repl: replServer,
30 env: process.env,
31 lodash: _,
32 path,
33 cli,
34 logger,
35 constants,
36 Sequelize,
37 sequelizeTypescript,
38 modelsUtils,
39 models: sequelizeTypescript.models,
40 transaction: sequelizeTypescript.transaction,
41 query: sequelizeTypescript.query,
42 queryInterface: sequelizeTypescript.getQueryInterface(),
43 YoutubeDL,
44 coreUtils,
45 ffmpegUtils,
46 peertubeCryptoUtils,
47 utils,
48 YoutubeDLUtils
49 }
50
51 for (const prop in properties) {
52 Object.defineProperty(context, prop, {
53 configurable: false,
54 enumerable: true,
55 value: properties[prop]
56 })
57 }
58 }
59 }
60
61 const replServer = repl.start({
62 prompt: `PeerTube [${cli.version}] (${versionCommitHash})> `
63 })
64
65 initContext(replServer)(replServer.context)
66 replServer.on('reset', initContext(replServer))
67 replServer.on('exit', () => process.exit())
68
69 const resetCommand = {
70 help: 'Reset REPL',
71 action () {
72 this.write('.clear\n')
73 this.displayPrompt()
74 }
75 }
76 replServer.defineCommand('reset', resetCommand)
77 replServer.defineCommand('r', resetCommand)
78}
79
80start()
81 .catch((err) => {
82 console.error(err)
83 })