Upgarade dependencies

This commit is contained in:
Mohammad Anas Fares 2024-08-29 02:37:59 +02:00
parent f211fdb484
commit 6a2fa28383
5 changed files with 2402 additions and 4000 deletions

4
app.js
View File

@ -23,7 +23,7 @@ global.BASEURL = 'https://www.terminalizer.com';
// Dependency Injection // Dependency Injection
di.require('chalk'); di.require('chalk');
di.require('async'); di.require('async');
di.require('request'); di.require('axios');
di.require('death'); di.require('death');
di.require('path'); di.require('path');
di.require('os'); di.require('os');
@ -41,7 +41,7 @@ di.require('progress', 'ProgressBar');
di.require('gif-encoder', 'GIFEncoder'); di.require('gif-encoder', 'GIFEncoder');
di.require('inquirer'); di.require('inquirer');
di.set('pty', require('node-pty-prebuilt-multiarch')); di.set('pty', require('@homebridge/node-pty-prebuilt-multiarch'));
di.set('PNG', require('pngjs').PNG); di.set('PNG', require('pngjs').PNG);
di.set('spawn', require('child_process').spawn); di.set('spawn', require('child_process').spawn);
di.set('utility', require('./utility.js')); di.set('utility', require('./utility.js'));

View File

@ -11,12 +11,10 @@
* @param {String} url the url of the uploaded recording * @param {String} url the url of the uploaded recording
*/ */
function done(url) { function done(url) {
console.log(di.chalk.green('Successfully Uploaded')); console.log(di.chalk.green('Successfully Uploaded'));
console.log('The recording is available on the link:'); console.log('The recording is available on the link:');
console.log(di.chalk.magenta(url)); console.log(di.chalk.magenta(url));
process.exit(); process.exit();
} }
/** /**
@ -28,13 +26,11 @@ function done(url) {
* @return {Boolean} * @return {Boolean}
*/ */
function isSet(input) { function isSet(input) {
if (!input) { if (!input) {
return new Error('Required field'); return new Error('Required field');
} }
return true; return true;
} }
/** /**
@ -47,7 +43,6 @@ function isSet(input) {
* @return {Promise} * @return {Promise}
*/ */
function getToken(context) { function getToken(context) {
var token = di.utility.getToken(); var token = di.utility.getToken();
// Already registered // Already registered
@ -62,13 +57,11 @@ function getToken(context) {
// Continue action // Continue action
return new Promise(function (resolve, reject) { return new Promise(function (resolve, reject) {
console.log('When you do it, press any key to continue'); console.log('When you do it, press any key to continue');
process.stdin.setRawMode(true); process.stdin.setRawMode(true);
process.stdin.resume(); process.stdin.resume();
process.stdin.once('data', function handler(data) { process.stdin.once('data', function handler(data) {
// Check if CTRL+C is pressed to exit // Check if CTRL+C is pressed to exit
if (data == '\u0003' || data == '\u0003') { if (data == '\u0003' || data == '\u0003') {
process.exit(); process.exit();
@ -79,11 +72,8 @@ function getToken(context) {
process.stdin.setRawMode(false); process.stdin.setRawMode(false);
resolve(token); resolve(token);
}); });
}); });
} }
/** /**
@ -96,7 +86,6 @@ function getToken(context) {
* @return {Promise} * @return {Promise}
*/ */
function getMeta(context) { function getMeta(context) {
var platform = di.utility.getOS(); var platform = di.utility.getOS();
// Already executed // Already executed
@ -106,28 +95,29 @@ function getMeta(context) {
console.log('Please enter some details about your recording'); console.log('Please enter some details about your recording');
return di.inquirer.prompt([ return di.inquirer
.prompt([
{ {
type: 'input', type: 'input',
name: 'title', name: 'title',
message: 'Title', message: 'Title',
validate: isSet validate: isSet,
}, },
{ {
type: 'input', type: 'input',
name: 'description', name: 'description',
message: 'Description', message: 'Description',
validate: isSet validate: isSet,
}, },
{ {
type: 'input', type: 'input',
name: 'tags', name: 'tags',
message: 'Tags ' + di.chalk.dim('such as git,bash,game'), message: 'Tags ' + di.chalk.dim('such as git,bash,game'),
validate: isSet, validate: isSet,
default: platform default: platform,
} },
]).then(function(answers) { ])
.then(function (answers) {
var params = Object.assign({}, answers); var params = Object.assign({}, answers);
// Add the platform // Add the platform
@ -137,9 +127,7 @@ function getMeta(context) {
console.log(); console.log();
return params; return params;
}); });
} }
/** /**
@ -155,7 +143,6 @@ function getMeta(context) {
* @return {Promise} * @return {Promise}
*/ */
function shareRecording(context) { function shareRecording(context) {
var self = this; var self = this;
var token = context.getToken; var token = context.getToken;
var meta = context.getMeta; var meta = context.getMeta;
@ -174,51 +161,44 @@ function shareRecording(context) {
value: di.fs.createReadStream(recordingFile), value: di.fs.createReadStream(recordingFile),
options: { options: {
filename: 'recording.yml', filename: 'recording.yml',
contentType: 'application/x-yaml' contentType: 'application/x-yaml',
} },
} },
} },
}; };
return new Promise(function(resolve, reject) { return di
.axios(options)
di.request(options, function(error, response, body) { .then((response) => {
if (error) {
return reject(error);
}
// Internal server error // Internal server error
if (response.statusCode == 500) { if (response.status === 500) {
return reject(body.errors.join('\n')); throw new Error(response.data.errors.join('\n'));
} }
// Invalid input // Invalid input
if (response.statusCode == 400) { if (response.status === 400) {
return reject(body.errors.join('\n')); throw new Error(response.data.errors.join('\n'));
} }
// Invalid token // Invalid token
if (response.statusCode == 401) { if (response.status === 401) {
di.utility.removeToken(); di.utility.removeToken();
self.jump('getToken'); self.jump('getToken');
return resolve(); return;
} }
// Unexpected error // Unexpected error
if (response.statusCode != 200) { if (response.status !== 200) {
return reject(new Error('Something went wrong, try again later')); throw new Error('Something went wrong, try again later');
} }
// Parse the response body // Resolve with the URL from the response body
body = JSON.parse(body); return response.data.url;
})
resolve(body.url); .catch((error) => {
// Reject the promise with the error
throw error;
}); });
});
} }
/** /**
@ -280,12 +260,10 @@ module.exports.handler = command;
* @param {Object} yargs * @param {Object} yargs
*/ */
module.exports.builder = function (yargs) { module.exports.builder = function (yargs) {
// Define the recordingFile argument // Define the recordingFile argument
yargs.positional('recordingFile', { yargs.positional('recordingFile', {
describe: 'the recording file', describe: 'the recording file',
type: 'string', type: 'string',
coerce: di._.partial(di.utility.resolveFilePath, di._, 'yml') coerce: di._.partial(di.utility.resolveFilePath, di._, 'yml'),
}); });
}; };

3909
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -41,8 +41,10 @@
"pty" "pty"
], ],
"dependencies": { "dependencies": {
"@homebridge/node-pty-prebuilt-multiarch": "^0.11.14",
"async": "^2.6.3", "async": "^2.6.3",
"async-promises": "^0.2.2", "async-promises": "^0.2.2",
"axios": "^1.7.5",
"chalk": "^2.4.2", "chalk": "^2.4.2",
"death": "^1.1.0", "death": "^1.1.0",
"deepmerge": "^2.2.1", "deepmerge": "^2.2.1",
@ -52,15 +54,13 @@
"inquirer": "^6.5.2", "inquirer": "^6.5.2",
"js-yaml": "^3.13.1", "js-yaml": "^3.13.1",
"lodash": "^4.17.15", "lodash": "^4.17.15",
"node-pty-prebuilt-multiarch": "^0.10.1-pre.5",
"performance-now": "^2.1.0", "performance-now": "^2.1.0",
"pngjs": "^3.4.0", "pngjs": "^3.4.0",
"progress": "^2.0.3", "progress": "^2.0.3",
"request": "^2.88.2",
"require-dir": "^1.1.0", "require-dir": "^1.1.0",
"string-argv": "0.0.2", "string-argv": "0.0.2",
"tmp": "^0.2.1", "tmp": "^0.2.1",
"uuid": "^3.4.0", "uuid": "^10.0.0",
"yargs": "^17.7.2" "yargs": "^17.7.2"
}, },
"devDependencies": { "devDependencies": {
@ -72,6 +72,6 @@
"terminalizer-player": "^0.4.1", "terminalizer-player": "^0.4.1",
"webpack": "^5.88.1", "webpack": "^5.88.1",
"webpack-cli": "^4.10.0", "webpack-cli": "^4.10.0",
"xterm": "^3.14.5" "xterm": "^v3.14.5"
} }
} }

2333
yarn.lock Normal file

File diff suppressed because it is too large Load Diff