From 874a3cde1c6d79ebd290e4987eeb143f6c6cb631 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Tue, 5 Jan 2021 14:16:28 +0100 Subject: [PATCH] This is my contribution to Superalgos --- Client/httpInterface.js | 37 ++++++++++++++----- .../UI/Spaces/Docs-Space/CommandInterface.js | 4 +- 2 files changed, 30 insertions(+), 11 deletions(-) diff --git a/Client/httpInterface.js b/Client/httpInterface.js index ae7630235..286ad105b 100644 --- a/Client/httpInterface.js +++ b/Client/httpInterface.js @@ -525,16 +525,35 @@ exports.newHttpInterface = function newHttpInterface(WEB_SERVER, DATA_FILE_SERVE case 'App': { switch (requestParameters[2]) { // switch by command case 'Contribute': { - const simpleGit = require('simple-git'); - const options = { - baseDir: process.cwd(), - binary: 'git', - maxConcurrentProcesses: 6, + try { + const simpleGit = require('simple-git'); + const options = { + baseDir: process.cwd(), + binary: 'git', + maxConcurrentProcesses: 6, + } + const git = simpleGit(options) + const commitMessage = unescape(requestParameters[3]) + git.add('./*') + git.commit(commitMessage, onCommit) + + function onCommit(err) { + console.log(err) + if (err) {throw err} + respondWithContent(JSON.stringify(global.DEFAULT_OK_RESPONSE), httpResponse) + } + } catch (err) { + console.log('[ERROR] httpInterface -> App -> Contribute -> Method call produced an error.') + console.log('[ERROR] httpInterface -> App -> Contribute -> err.stack = ' + err.stack) + console.log('[ERROR] httpInterface -> App -> Contribute -> Params Received = ' + requestParameters[3]) + + let error = { + result: 'Fail Because', + message: err.message, + stack: err.stack + } + respondWithContent(JSON.stringify(error), httpResponse) } - const git = simpleGit(options) - const commitMessage = unescape(requestParameters[3]) - console.log('baseDir = ' + process.cwd(), commitMessage) - respondWithContent(JSON.stringify(global.DEFAULT_OK_RESPONSE), httpResponse) break } } diff --git a/Projects/Superalgos/UI/Spaces/Docs-Space/CommandInterface.js b/Projects/Superalgos/UI/Spaces/Docs-Space/CommandInterface.js index 751908f1c..6d5438ad7 100644 --- a/Projects/Superalgos/UI/Spaces/Docs-Space/CommandInterface.js +++ b/Projects/Superalgos/UI/Spaces/Docs-Space/CommandInterface.js @@ -43,9 +43,9 @@ function newSuperalgosDocsCommmandInterface() { /* Lets check the result of the call through the http interface */ data = JSON.parse(data) if (err.result === GLOBAL.DEFAULT_OK_RESPONSE.result && data.result === GLOBAL.DEFAULT_OK_RESPONSE.result) { - UI.projects.superalgos.spaces.docsSpace.navigateTo('Superalgos', 'Topic', 'App Error Contribution Not Sent', 'Anchor Contribution Not Sent') - } else { UI.projects.superalgos.spaces.docsSpace.navigateTo('Superalgos', 'Topic', 'App Message Contribution Succeed') + } else { + UI.projects.superalgos.spaces.docsSpace.navigateTo('Superalgos', 'Topic', 'App Error Contribution Not Sent', 'Anchor Contribution Not Sent') } } }