10 changed files with 1541 additions and 4057 deletions
-
54README.md
-
3app.js
-
0bin/app.js
-
149commands/partager.js
-
2commands/render.js
-
6config.yml
-
5228package-lock.json
-
3package.json
-
4render/index.js
-
149utility.js
@ -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'), |
|||
}); |
|||
}; |
5228
package-lock.json
File diff suppressed because it is too large
View File
File diff suppressed because it is too large
View File
Write
Preview
Loading…
Cancel
Save
Reference in new issue