add a command to share recording on oisux nextcloud

This commit is contained in:
Association Oisux
2022-10-31 22:56:37 +01:00
parent dc65dbebf1
commit 8f79521cf5
10 changed files with 1440 additions and 3956 deletions

149
commands/partager.js Normal file
View File

@@ -0,0 +1,149 @@
/**
* Share
* Upload a recording file and get a link for an online player
*
* @author Mohammad Fares <faressoft.com@gmail.com>
* @author Oisux <contact@oisux.org>
*/
/**
* Executed after the command completes its task
*
* @param {String} url the url of the uploaded recording
*/
function done(url) {
console.log(di.chalk.green('téléversement réussi'));
console.log("L'enregistrement est disponible sur le NexCloud de Oisux dans le dossier:");
console.log(di.chalk.magenta(url));
process.exit();
}
/**
* Check if the value is not an empty value
*
* - Throw `Required field` if empty
*
* @param {String} input
* @return {Boolean}
*/
function isSet(input) {
if (!input) {
return new Error('Champ requis');
}
return true;
}
/**
* Ask the user to enter meta data about the recording
*
* - Skip the task if already executed before
* and resolve with the last result
*
* @param {Object} context
* @return {Promise}
*/
function getMeta(context) {
const platform = di.utility.getOS();
const username = di.utility.getUsername();
// Already executed
if (typeof context.getMeta != 'undefined') {
return Promise.resolve(context.getMeta);
}
console.log('Entrer les metadonnées (attributs étendus) du fichier:');
return di.inquirer
.prompt([
{
type: 'input',
name: 'comments',
message: 'Commentaires',
default: 'Commentaires non fonctionnels pour l\'instant. Pressez la touche entrée',
validate: isSet,
},
])
.then(function (answers) {
const params = Object.assign({}, answers);
params.platform = platform;
params.username = username;
console.log();
return params;
});
}
/**
* Upload the recording
*
* @param {Object} context
* @return {Promise}
*/
function shareRecording(context) {
const { createWebdavClient, sendFile } = di.utility;
return sendFile(createWebdavClient(), context);
}
/**
* The command's main function
*
* @param {Object} argv
*/
function command(argv) {
// No global config
if (!di.utility.isGlobalDirectoryCreated()) {
require('./init.js').handler();
}
di.Flowa.run(
{
// Ask the user to enter meta data about the recording
getMeta: getMeta,
// Upload the recording
shareRecording: shareRecording,
},
argv
)
.then(function (context) {
done(context.shareRecording);
})
.catch(di.errorHandler);
}
////////////////////////////////////////////////////
// Command Definition //////////////////////////////
////////////////////////////////////////////////////
/**
* Command's usage
* @type {String}
*/
module.exports.command = 'partager <recordingFile>';
/**
* Command's description
* @type {String}
*/
module.exports.describe = 'Upload sur le dossier "terminalizer" partagé par le groupe CA';
/**
* Command's handler function
* @type {Function}
*/
module.exports.handler = command;
/**
* Builder
*
* @param {Object} yargs
*/
module.exports.builder = function (yargs) {
// Define the recordingFile argument
yargs.positional('recordingFile', {
describe: 'le fichier',
type: 'string',
coerce: di._.partial(di.utility.resolveFilePath, di._, 'yml'),
});
};

View File

@@ -112,7 +112,7 @@ function renderFrames(records, options) {
// Execute the rendering process
var render = di.spawn(
di.electron,
[di.path.join(ROOT_PATH, "render/index.js"), options.step],
[di.path.join(ROOT_PATH, "render/index.js"), options.step ],
{ detached: false }
);