X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Ftools%2Fpeertube-repl.ts;h=a38d51801afc5498804902df81d0dbb2fdeeb981;hb=f479685678406a5df864d89615b33d29085ebfc6;hp=6800ff8ab99b10259ee69ad425cbdfd720c3e644;hpb=c141f68be14193fb92d3f5cfc82cd1e156823c17;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/tools/peertube-repl.ts b/server/tools/peertube-repl.ts index 6800ff8ab..a38d51801 100644 --- a/server/tools/peertube-repl.ts +++ b/server/tools/peertube-repl.ts @@ -1,14 +1,13 @@ +import { registerTSPaths } from '../helpers/register-ts-paths' +registerTSPaths() + import * as repl from 'repl' import * as path from 'path' import * as _ from 'lodash' -import * as uuidv1 from 'uuid/v1' -import * as uuidv3 from 'uuid/v3' -import * as uuidv4 from 'uuid/v4' -import * as uuidv5 from 'uuid/v5' +import { uuidv1, uuidv3, uuidv4, uuidv5 } from 'uuid' import * as Sequelize from 'sequelize' import * as YoutubeDL from 'youtube-dl' - -import { initDatabaseModels, sequelizeTypescript } from '../initializers' +import { initDatabaseModels, sequelizeTypescript } from '../initializers/database' import * as cli from '../tools/cli' import { logger } from '../helpers/logger' import * as constants from '../initializers/constants' @@ -20,30 +19,43 @@ import * as signupUtils from '../helpers/signup' import * as utils from '../helpers/utils' import * as YoutubeDLUtils from '../helpers/youtube-dl' -let versionCommitHash - const start = async () => { await initDatabaseModels(true) - await utils.getVersion().then((data) => { - versionCommitHash = data - }) + const versionCommitHash = await utils.getServerCommit() const initContext = (replServer) => { return (context) => { const properties = { - context, repl: replServer, env: process.env, - lodash: _, path, - uuidv1, uuidv3, uuidv4, uuidv5, - cli, logger, constants, - Sequelize, sequelizeTypescript, modelsUtils, - models: sequelizeTypescript.models, transaction: sequelizeTypescript.transaction, - query: sequelizeTypescript.query, queryInterface: sequelizeTypescript.getQueryInterface(), + context, + repl: replServer, + env: process.env, + lodash: _, + path, + uuidv1, + uuidv3, + uuidv4, + uuidv5, + cli, + logger, + constants, + Sequelize, + sequelizeTypescript, + modelsUtils, + models: sequelizeTypescript.models, + transaction: sequelizeTypescript.transaction, + query: sequelizeTypescript.query, + queryInterface: sequelizeTypescript.getQueryInterface(), YoutubeDL, - coreUtils, ffmpegUtils, peertubeCryptoUtils, signupUtils, utils, YoutubeDLUtils + coreUtils, + ffmpegUtils, + peertubeCryptoUtils, + signupUtils, + utils, + YoutubeDLUtils } - for (let prop in properties) { + for (const prop in properties) { Object.defineProperty(context, prop, { configurable: false, enumerable: true, @@ -59,6 +71,7 @@ const start = async () => { initContext(replServer)(replServer.context) replServer.on('reset', initContext(replServer)) + replServer.on('exit', () => process.exit()) const resetCommand = { help: 'Reset REPL', @@ -69,11 +82,9 @@ const start = async () => { } replServer.defineCommand('reset', resetCommand) replServer.defineCommand('r', resetCommand) - } -start().then((data) => { - // do nothing -}).catch((err) => { - console.error(err) -}) +start() + .catch((err) => { + console.error(err) + })