Skip to content

Commit

Permalink
Update server dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
Chocobozzz committed Feb 3, 2021
1 parent 29f148a commit ba5a8d8
Show file tree
Hide file tree
Showing 42 changed files with 1,328 additions and 1,559 deletions.
28 changes: 14 additions & 14 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -97,13 +97,13 @@
"bull": "^3.4.2",
"bytes": "^3.0.0",
"chokidar": "^3.4.2",
"commander": "^6.0.0",
"commander": "^7.0.0",
"config": "^3.0.0",
"cookie-parser": "^1.4.3",
"cors": "^2.8.1",
"create-torrent": "^4.0.0",
"deep-object-diff": "^1.1.0",
"email-templates": "^7.0.4",
"email-templates": "^8.0.3",
"express": "^4.12.4",
"express-oauth-server": "^2.0.0",
"express-rate-limit": "^5.0.0",
Expand All @@ -118,12 +118,12 @@
"is-cidr": "^4.0.0",
"iso-639-3": "^2.0.0",
"jimp": "^0.16.0",
"js-yaml": "^3.5.4",
"jsonld": "~3.2.0",
"js-yaml": "^4.0.0",
"jsonld": "~3.3.0",
"lodash": "^4.17.10",
"lru-cache": "^6.0.0",
"magnet-uri": "^6.1.0",
"markdown-it": "12.0.2",
"markdown-it": "12.0.4",
"markdown-it-emoji": "^2.0.0",
"memoizee": "^0.4.14",
"morgan": "^1.5.3",
Expand All @@ -143,7 +143,7 @@
"request": "^2.81.0",
"sanitize-html": "2.x",
"scripty": "^2.0.0",
"sequelize": "6.3.5",
"sequelize": "6.5.0",
"sequelize-typescript": "^2.0.0-beta.1",
"sitemap": "^6.1.0",
"socket.io": "^3.0.2",
Expand All @@ -155,7 +155,7 @@
"uuid": "^8.1.0",
"validator": "^13.0.0",
"webfinger.js": "^2.6.6",
"webtorrent": "^0.111.0",
"webtorrent": "^0.112.3",
"winston": "3.3.3",
"ws": "^7.0.0",
"youtube-dl": "^3.0.2"
Expand All @@ -168,13 +168,13 @@
"@types/bcrypt": "^3.0.0",
"@types/bluebird": "3.5.33",
"@types/body-parser": "^1.16.3",
"@types/bull": "3.14.4",
"@types/bull": "3.15.0",
"@types/bytes": "^3.0.0",
"@types/chai": "^4.0.4",
"@types/chai-json-schema": "^1.4.3",
"@types/chai-xml": "^0.3.1",
"@types/config": "^0.0.36",
"@types/express": "^4.0.35",
"@types/config": "^0.0.38",
"@types/express": "4.17.9",
"@types/express-rate-limit": "^5.0.0",
"@types/fluent-ffmpeg": "^2.1.16",
"@types/fs-extra": "^9.0.1",
Expand All @@ -188,7 +188,7 @@
"@types/mocha": "^8.0.3",
"@types/morgan": "^1.7.32",
"@types/multer": "^1.3.3",
"@types/node": "^14.0.13",
"@types/node": "^12",
"@types/nodemailer": "^6.2.0",
"@types/oauth2-server": "^3.0.8",
"@types/pem": "^1.9.3",
Expand All @@ -204,11 +204,11 @@
"chai-xml": "^0.4.0",
"concurrently": "^5.0.0",
"eslint": "^7.2.0",
"eslint-config-standard-with-typescript": "^19.0.1",
"eslint-config-standard-with-typescript": "^20.0.0",
"eslint-plugin-import": "^2.20.1",
"eslint-plugin-node": "^11.0.0",
"eslint-plugin-promise": "^4.2.1",
"eslint-plugin-standard": "^4.0.1",
"eslint-plugin-standard": "^5.0.0",
"libxmljs": "0.19.7",
"maildev": "^1.0.0-rc3",
"marked": "^1.1.0",
Expand All @@ -219,7 +219,7 @@
"source-map-support": "^0.5.0",
"supertest": "^6.0.1",
"swagger-cli": "^4.0.2",
"ts-node": "9.0.0",
"ts-node": "9.1.1",
"typescript": "^4.0.5"
},
"scripty": {
Expand Down
8 changes: 5 additions & 3 deletions scripts/create-import-video-file-job.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ program
.description('Import a video file to replace an already uploaded file or to add a new resolution')
.parse(process.argv)

if (program['video'] === undefined || program['import'] === undefined) {
const options = program.opts()

if (options.video === undefined || options.import === undefined) {
console.error('All parameters are mandatory.')
process.exit(-1)
}
Expand All @@ -28,13 +30,13 @@ run()
async function run () {
await initDatabaseModels(true)

const video = await VideoModel.loadByUUID(program['video'])
const video = await VideoModel.loadByUUID(options.video)
if (!video) throw new Error('Video not found.')
if (video.isOwned() === false) throw new Error('Cannot import files of a non owned video.')

const dataInput = {
videoUUID: video.uuid,
filePath: resolve(program['import'])
filePath: resolve(options.import)
}

await JobQueue.Instance.init()
Expand Down
18 changes: 10 additions & 8 deletions scripts/create-transcoding-job.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,14 @@ program
.option('--generate-hls', 'Generate HLS playlist')
.parse(process.argv)

if (program['video'] === undefined) {
const options = program.opts()

if (options.video === undefined) {
console.error('All parameters are mandatory.')
process.exit(-1)
}

if (program.resolution !== undefined && Number.isNaN(+program.resolution)) {
if (options.resolution !== undefined && Number.isNaN(+options.resolution)) {
console.error('The resolution must be an integer (example: 1080).')
process.exit(-1)
}
Expand All @@ -34,15 +36,15 @@ run()
async function run () {
await initDatabaseModels(true)

const video = await VideoModel.loadAndPopulateAccountAndServerAndTags(program['video'])
const video = await VideoModel.loadAndPopulateAccountAndServerAndTags(options.video)
if (!video) throw new Error('Video not found.')

const dataInput: VideoTranscodingPayload[] = []
const { videoFileResolution } = await video.getMaxQualityResolution()

if (program.generateHls) {
const resolutionsEnabled = program.resolution
? [ program.resolution ]
if (options.generateHls) {
const resolutionsEnabled = options.resolution
? [ options.resolution ]
: computeResolutionsToTranscode(videoFileResolution, 'vod').concat([ videoFileResolution ])

for (const resolution of resolutionsEnabled) {
Expand All @@ -54,12 +56,12 @@ async function run () {
copyCodecs: false
})
}
} else if (program.resolution !== undefined) {
} else if (options.resolution !== undefined) {
dataInput.push({
type: 'new-resolution-to-webtorrent',
videoUUID: video.uuid,
isNewVideo: false,
resolution: program.resolution
resolution: options.resolution
})
} else {
dataInput.push({
Expand Down
10 changes: 6 additions & 4 deletions scripts/parse-log.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ program
.option('-f, --files [file...]', 'Files to parse. If not provided, the script will parse the latest log file from config)')
.parse(process.argv)

const options = program.opts()

const excludedKeys = {
level: true,
message: true,
Expand All @@ -38,7 +40,7 @@ const loggerFormat = winston.format.printf((info) => {
if (CONFIG.LOG.PRETTIFY_SQL) {
additionalInfos += '\n' + sqlFormat(info.sql, {
language: 'sql',
ident: ' '
indent: ' '
})
} else {
additionalInfos += ' - ' + info.sql
Expand All @@ -51,7 +53,7 @@ const loggerFormat = winston.format.printf((info) => {
const logger = winston.createLogger({
transports: [
new winston.transports.Console({
level: program['level'] || 'debug',
level: options.level || 'debug',
stderrLevels: [],
format: winston.format.combine(
winston.format.splat(),
Expand All @@ -76,7 +78,7 @@ run()
.catch(err => console.error(err))

function run () {
return new Promise(async res => {
return new Promise<void>(async res => {
const files = await getFiles()

for (const file of files) {
Expand Down Expand Up @@ -114,7 +116,7 @@ async function getNewestFile (files: string[], basePath: string) {
}

async function getFiles () {
if (program['files']) return program['files']
if (options.files) return options.files

const logFiles = await readdir(CONFIG.STORAGE.LOG_DIR)

Expand Down
10 changes: 6 additions & 4 deletions scripts/plugin/install.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,14 @@ program
.option('-p, --plugin-path [pluginPath]', 'Path of the plugin you want to install')
.parse(process.argv)

if (!program['npmName'] && !program['pluginPath']) {
const options = program.opts()

if (!options.npmName && !options.pluginPath) {
console.error('You need to specify a plugin name with the desired version, or a plugin path.')
process.exit(-1)
}

if (program['pluginPath'] && !isAbsolute(program['pluginPath'])) {
if (options.pluginPath && !isAbsolute(options.pluginPath)) {
console.error('Plugin path should be absolute.')
process.exit(-1)
}
Expand All @@ -32,6 +34,6 @@ run()
async function run () {
await initDatabaseModels(true)

const toInstall = program['npmName'] || program['pluginPath']
await PluginManager.Instance.install(toInstall, program['pluginVersion'], !!program['pluginPath'])
const toInstall = options.npmName || options.pluginPath
await PluginManager.Instance.install(toInstall, options.pluginVersion, !!options.pluginPath)
}
6 changes: 4 additions & 2 deletions scripts/plugin/uninstall.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ program
.option('-n, --npm-name [npmName]', 'Package name to install')
.parse(process.argv)

if (!program['npmName']) {
const options = program.opts()

if (!options.npmName) {
console.error('You need to specify the plugin name.')
process.exit(-1)
}
Expand All @@ -25,6 +27,6 @@ async function run () {

await initDatabaseModels(true)

const toUninstall = program['npmName']
const toUninstall = options.npmName
await PluginManager.Instance.uninstall(toUninstall)
}
8 changes: 5 additions & 3 deletions scripts/reset-password.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,16 @@ program
.option('-u, --user [user]', 'User')
.parse(process.argv)

if (program['user'] === undefined) {
const options = program.opts()

if (options.user === undefined) {
console.error('All parameters are mandatory.')
process.exit(-1)
}

initDatabaseModels(true)
.then(() => {
return UserModel.loadByUsername(program['user'])
return UserModel.loadByUsername(options.user)
})
.then(user => {
if (!user) {
Expand All @@ -28,7 +30,7 @@ initDatabaseModels(true)
const readline = require('readline')
const Writable = require('stream').Writable
const mutableStdout = new Writable({
write: function (chunk, encoding, callback) {
write: function (_chunk, _encoding, callback) {
callback()
}
})
Expand Down
5 changes: 3 additions & 2 deletions server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,8 @@ app.use('/', staticRouter)
app.use('/', lazyStaticRouter)

// Client files, last valid routes!
if (cli.client) app.use('/', clientsRouter)
const cliOptions = cli.opts()
if (cliOptions.client) app.use('/', clientsRouter)

// ----------- Errors -----------

Expand Down Expand Up @@ -277,7 +278,7 @@ async function startApplication () {
updateStreamingPlaylistsInfohashesIfNeeded()
.catch(err => logger.error('Cannot update streaming playlist infohashes.', { err }))

if (cli.plugins) await PluginManager.Instance.registerPluginsAndThemes()
if (cliOptions.plugins) await PluginManager.Instance.registerPluginsAndThemes()

LiveManager.Instance.init()
if (CONFIG.LIVE.ENABLED) LiveManager.Instance.run()
Expand Down
2 changes: 1 addition & 1 deletion server/helpers/captions-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export {
// ---------------------------------------------------------------------------

function convertSrtToVtt (source: string, destination: string) {
return new Promise((res, rej) => {
return new Promise<void>((res, rej) => {
const file = createReadStream(source)
const converter = srt2vtt()
const writer = createWriteStream(destination)
Expand Down
10 changes: 5 additions & 5 deletions server/helpers/core-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
Useful to avoid circular dependencies.
*/

import { createHash, HexBase64Latin1Encoding, randomBytes } from 'crypto'
import { exec, ExecOptions } from 'child_process'
import { BinaryToTextEncoding, createHash, randomBytes } from 'crypto'
import { truncate } from 'lodash'
import { basename, isAbsolute, join, resolve } from 'path'
import * as pem from 'pem'
import { URL } from 'url'
import { truncate } from 'lodash'
import { exec, ExecOptions } from 'child_process'

const objectConverter = (oldObject: any, keyConverter: (e: string) => string, valueConverter: (e: any) => any) => {
if (!oldObject || typeof oldObject !== 'object') {
Expand Down Expand Up @@ -205,11 +205,11 @@ function peertubeTruncate (str: string, options: { length: number, separator?: R
return truncate(str, options)
}

function sha256 (str: string | Buffer, encoding: HexBase64Latin1Encoding = 'hex') {
function sha256 (str: string | Buffer, encoding: BinaryToTextEncoding = 'hex') {
return createHash('sha256').update(str).digest(encoding)
}

function sha1 (str: string | Buffer, encoding: HexBase64Latin1Encoding = 'hex') {
function sha1 (str: string | Buffer, encoding: BinaryToTextEncoding = 'hex') {
return createHash('sha1').update(str).digest(encoding)
}

Expand Down
1 change: 1 addition & 0 deletions server/helpers/custom-jsonld-signature.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ const lru = new AsyncLRU({
}
})

/* eslint-disable no-import-assign */
jsonld.documentLoader = (url) => {
return new Promise((res, rej) => {
lru.get(url, (err, value) => {
Expand Down
2 changes: 1 addition & 1 deletion server/helpers/logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ const consoleLoggerFormat = winston.format.printf(info => {
if (CONFIG.LOG.PRETTIFY_SQL) {
additionalInfos += '\n' + sqlFormat(info.sql, {
language: 'sql',
ident: ' '
indent: ' '
})
} else {
additionalInfos += ' - ' + info.sql
Expand Down
2 changes: 1 addition & 1 deletion server/helpers/webtorrent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ function safeWebtorrentDestroy (
downloadedFile?: { directoryPath: string, filepath: string },
torrentName?: string
) {
return new Promise(res => {
return new Promise<void>(res => {
webtorrent.destroy(err => {
// Delete torrent file
if (torrentName) {
Expand Down
2 changes: 1 addition & 1 deletion server/helpers/youtube-dl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ async function updateYoutubeDLBinary () {

await ensureDir(binDirectory)

return new Promise(res => {
return new Promise<void>(res => {
request.get(url, { followRedirect: false }, (err, result) => {
if (err) {
logger.error('Cannot update youtube-dl.', { err })
Expand Down
1 change: 1 addition & 0 deletions server/lib/activitypub/inbox-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ class InboxManager {

addInboxMessage (options: QueueParam) {
this.inboxQueue.push(options)
.catch(err => logger.error('Cannot add options in inbox queue.', { options, err }))
}

static get Instance () {
Expand Down
Loading

0 comments on commit ba5a8d8

Please sign in to comment.