From ba5a8d89bbf049e4afc41543bcc072cccdb02669 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 3 Feb 2021 09:33:05 +0100 Subject: Update server dependencies --- scripts/create-import-video-file-job.ts | 8 +++++--- scripts/create-transcoding-job.ts | 18 ++++++++++-------- scripts/parse-log.ts | 10 ++++++---- scripts/plugin/install.ts | 10 ++++++---- scripts/plugin/uninstall.ts | 6 ++++-- scripts/reset-password.ts | 8 +++++--- 6 files changed, 36 insertions(+), 24 deletions(-) (limited to 'scripts') diff --git a/scripts/create-import-video-file-job.ts b/scripts/create-import-video-file-job.ts index d71e82c14..f5271c7a3 100644 --- a/scripts/create-import-video-file-job.ts +++ b/scripts/create-import-video-file-job.ts @@ -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) } @@ -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() diff --git a/scripts/create-transcoding-job.ts b/scripts/create-transcoding-job.ts index ca9e2a99a..eb620aeca 100755 --- a/scripts/create-transcoding-job.ts +++ b/scripts/create-transcoding-job.ts @@ -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) } @@ -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) { @@ -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({ diff --git a/scripts/parse-log.ts b/scripts/parse-log.ts index 045348e86..3679dab74 100755 --- a/scripts/parse-log.ts +++ b/scripts/parse-log.ts @@ -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, @@ -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 @@ -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(), @@ -76,7 +78,7 @@ run() .catch(err => console.error(err)) function run () { - return new Promise(async res => { + return new Promise(async res => { const files = await getFiles() for (const file of files) { @@ -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) diff --git a/scripts/plugin/install.ts b/scripts/plugin/install.ts index 54738f50f..2ea8a658b 100755 --- a/scripts/plugin/install.ts +++ b/scripts/plugin/install.ts @@ -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) } @@ -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) } diff --git a/scripts/plugin/uninstall.ts b/scripts/plugin/uninstall.ts index c56f18466..8710b1750 100755 --- a/scripts/plugin/uninstall.ts +++ b/scripts/plugin/uninstall.ts @@ -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) } @@ -25,6 +27,6 @@ async function run () { await initDatabaseModels(true) - const toUninstall = program['npmName'] + const toUninstall = options.npmName await PluginManager.Instance.uninstall(toUninstall) } diff --git a/scripts/reset-password.ts b/scripts/reset-password.ts index 6372095d6..7e7de6b8a 100755 --- a/scripts/reset-password.ts +++ b/scripts/reset-password.ts @@ -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) { @@ -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() } }) -- cgit v1.2.3