Upgarade dependencies
This commit is contained in:
parent
f211fdb484
commit
6a2fa28383
4
app.js
4
app.js
|
@ -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'));
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/**
|
/**
|
||||||
* Share
|
* Share
|
||||||
* Upload a recording file and get a link for an online player
|
* Upload a recording file and get a link for an online player
|
||||||
*
|
*
|
||||||
* @author Mohammad Fares <faressoft.com@gmail.com>
|
* @author Mohammad Fares <faressoft.com@gmail.com>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -11,30 +11,26 @@
|
||||||
* @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();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if the value is not an empty value
|
* Check if the value is not an empty value
|
||||||
*
|
*
|
||||||
* - Throw `Required field` if empty
|
* - Throw `Required field` if empty
|
||||||
*
|
*
|
||||||
* @param {String} input
|
* @param {String} input
|
||||||
* @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
|
||||||
|
@ -61,14 +56,12 @@ function getToken(context) {
|
||||||
console.log(di.chalk.dim(BASEURL + '/token?token=' + token) + '\n');
|
console.log(di.chalk.dim(BASEURL + '/token?token=' + token) + '\n');
|
||||||
|
|
||||||
// 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,40 +95,39 @@ 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',
|
{
|
||||||
name: 'title',
|
type: 'input',
|
||||||
message: 'Title',
|
name: 'title',
|
||||||
validate: isSet
|
message: 'Title',
|
||||||
},
|
validate: isSet,
|
||||||
{
|
},
|
||||||
type: 'input',
|
{
|
||||||
name: 'description',
|
type: 'input',
|
||||||
message: 'Description',
|
name: 'description',
|
||||||
validate: isSet
|
message: 'Description',
|
||||||
},
|
validate: isSet,
|
||||||
{
|
},
|
||||||
type: 'input',
|
{
|
||||||
name: 'tags',
|
type: 'input',
|
||||||
message: 'Tags ' + di.chalk.dim('such as git,bash,game'),
|
name: 'tags',
|
||||||
validate: isSet,
|
message: 'Tags ' + di.chalk.dim('such as git,bash,game'),
|
||||||
default: platform
|
validate: isSet,
|
||||||
}
|
default: platform,
|
||||||
]).then(function(answers) {
|
},
|
||||||
|
])
|
||||||
|
.then(function (answers) {
|
||||||
|
var params = Object.assign({}, answers);
|
||||||
|
|
||||||
var params = Object.assign({}, answers);
|
// Add the platform
|
||||||
|
params.platform = platform;
|
||||||
|
|
||||||
// Add the platform
|
// Print a new line
|
||||||
params.platform = platform;
|
console.log();
|
||||||
|
|
||||||
// Print a new line
|
|
||||||
console.log();
|
|
||||||
|
|
||||||
return params;
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
|
return params;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -150,12 +138,11 @@ function getMeta(context) {
|
||||||
* - Jump into the getToken task
|
* - Jump into the getToken task
|
||||||
*
|
*
|
||||||
* - Resolve with the url of the uploaded recording
|
* - Resolve with the url of the uploaded recording
|
||||||
*
|
*
|
||||||
* @param {Object} context
|
* @param {Object} 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,56 +161,49 @@ 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;
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The command's main function
|
* The command's main function
|
||||||
*
|
*
|
||||||
* @param {Object} argv
|
* @param {Object} argv
|
||||||
*/
|
*/
|
||||||
function command(argv) {
|
function command(argv) {
|
||||||
|
@ -232,21 +212,21 @@ function command(argv) {
|
||||||
require('./init.js').handler();
|
require('./init.js').handler();
|
||||||
}
|
}
|
||||||
|
|
||||||
var context = {...argv};
|
var context = { ...argv };
|
||||||
|
|
||||||
// Get a token for uploading recordings
|
// Get a token for uploading recordings
|
||||||
getToken(context)
|
getToken(context)
|
||||||
.then(function(token) {
|
.then(function (token) {
|
||||||
context.getToken = token;
|
context.getToken = token;
|
||||||
// Ask the user to enter meta data about the recording
|
// Ask the user to enter meta data about the recording
|
||||||
return getMeta(context);
|
return getMeta(context);
|
||||||
})
|
})
|
||||||
.then(function(meta) {
|
.then(function (meta) {
|
||||||
context.getMeta = meta;
|
context.getMeta = meta;
|
||||||
// Upload the recording
|
// Upload the recording
|
||||||
return shareRecording(context);
|
return shareRecording(context);
|
||||||
})
|
})
|
||||||
.then(function(url) {
|
.then(function (url) {
|
||||||
done(url);
|
done(url);
|
||||||
})
|
})
|
||||||
.catch(di.errorHandler);
|
.catch(di.errorHandler);
|
||||||
|
@ -276,16 +256,14 @@ module.exports.handler = command;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Builder
|
* Builder
|
||||||
*
|
*
|
||||||
* @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'),
|
||||||
});
|
});
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -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"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue