app.update implementation part 2

This commit is contained in:
Luis Fernando Molina committed 2021-01-12 10:04:28 +01:00
1 parent 526684fea0
commit bf07bf9af1
3 files changed
+85 -24

No files matched your search

+2 -2
View File
@@ -661,9 +661,9 @@ exports.newHttpInterface = function newHttpInterface(WEB_SERVER, DATA_FILE_SERVE
await git.pull((err, update) => {
if (update) {
if (update.summary.changes) {
return 'App Changed'
return 'New Version Found'
} else {
return 'App Not Changed'
return 'Already Up-To-Date'
}
} else {
if (err) {
@@ -3,14 +3,14 @@
"pageNumber": "1",
"type": "App Error Contribution Not Sent",
"definition": {
"text": "There was a problmen trying to send your contribution to your fork of the Superalgos repository.",
"updated": 1609859551082
"text": "There was a problmen trying to send your contribution to your fork of the Superalgos repository, or from your fork to the Superalgos/Superalgos main repository.",
"updated": 1610441932801
},
"paragraphs": [
{
"style": "Text",
"text": "Left click and Edit to enter edit mode and change this text. ENTER to write new paragraphs. ESC to exit edit mode. 2",
"updated": 1609860582103
"text": "You will need to check for the Client's console for details on what happened. After you fix the issue that prevented the App Contribute Command to run, you might try again.",
"updated": 1610441999433
}
]
}
@@ -20,18 +20,20 @@ function newSuperalgosDocsCommmandInterface() {
if (detectAppCommands() === true) { return }
if (detectDocsCommands() === true) { return }
/* If we can not detect any app or docs commands, then we assume the users is running a search query */
UI.projects.superalgos.spaces.docsSpace.searchResultsPage.render()
}
function detectAppCommands() {
if (checkContributeCommand() === undefined) { return } else { return true }
if (checkContributeCommand() === undefined) { return true }
if (checkUpdateCommand() === undefined) { return true }
function checkContributeCommand() {
if (UI.projects.superalgos.spaces.docsSpace.commandInterface.command.toLowerCase() === 'app.help app.contribute') {
UI.projects.superalgos.spaces.docsSpace.navigateTo('Superalgos', 'Topic', 'App Contribute Command')
return
}
if (UI.projects.superalgos.spaces.docsSpace.commandInterface.command.indexOf('App.Contribute') !== 0 && UI.projects.superalgos.spaces.docsSpace.commandInterface.command.indexOf('app.contribute') !== 0) { return }
if (UI.projects.superalgos.spaces.docsSpace.commandInterface.command.indexOf('App.Contribute') !== 0 && UI.projects.superalgos.spaces.docsSpace.commandInterface.command.indexOf('app.contribute') !== 0) { return 'Not Contribute Commands' }
/* Set up the commit message */
let message = UI.projects.superalgos.spaces.docsSpace.commandInterface.command.trim().substring(UI.projects.superalgos.spaces.docsSpace.commandInterface.command.indexOf(' ') + 1, UI.projects.superalgos.spaces.docsSpace.commandInterface.command.length)
@@ -43,27 +45,27 @@ function newSuperalgosDocsCommmandInterface() {
let apisNode = UI.projects.superalgos.spaces.designSpace.workspace.getHierarchyHeadsByType('APIs')
if (apisNode === undefined) {
UI.projects.superalgos.spaces.docsSpace.navigateTo('Superalgos', 'Topic', 'App Error Github Credentials Missing', 'Anchor Github Credentials Missing')
return true
return
}
if (apisNode.githubAPI === undefined) {
UI.projects.superalgos.spaces.docsSpace.navigateTo('Superalgos', 'Topic', 'App Error Github Credentials Missing', 'Anchor Github Credentials Missing')
return true
return
}
let config = JSON.parse(apisNode.githubAPI.config)
if (config.username === undefined || config.username === "") {
UI.projects.superalgos.spaces.docsSpace.navigateTo('Superalgos', 'Topic', 'App Error Github Credentials Missing', 'Anchor Github Credentials Missing')
return true
return
}
if (config.token === undefined || config.token === "") {
UI.projects.superalgos.spaces.docsSpace.navigateTo('Superalgos', 'Topic', 'App Error Github Credentials Missing', 'Anchor Github Credentials Missing')
return true
return
}
httpRequest(undefined, 'App/Contribute/' + message + '/' + config.username + '/' + config.token, onResponse)
UI.projects.superalgos.spaces.docsSpace.navigateTo('Superalgos', 'Topic', 'App Message Creating Pull Request')
return true
return
function onResponse(err, data) {
/* Lets check the result of the call through the http interface */
@@ -71,11 +73,70 @@ function newSuperalgosDocsCommmandInterface() {
if (err.result === GLOBAL.DEFAULT_OK_RESPONSE.result && data.result === GLOBAL.DEFAULT_OK_RESPONSE.result) {
UI.projects.superalgos.spaces.docsSpace.navigateTo('Superalgos', 'Topic', 'App Message Contribution Succeed')
} else {
if (data.message === 'File Github.json does not exist.') {
UI.projects.superalgos.spaces.docsSpace.navigateTo('Superalgos', 'Topic', 'App Error Github Credentials Missing', 'Anchor Github Credentials Missing')
} else {
UI.projects.superalgos.spaces.docsSpace.navigateTo('Superalgos', 'Topic', 'App Error Contribution Not Sent', 'Anchor Contribution Not Sent')
UI.projects.superalgos.spaces.docsSpace.navigateTo('Superalgos', 'Topic', 'App Error Contribution Not Sent', 'Anchor Contribution Not Sent')
}
}
}
function checkUpdateCommand() {
if (UI.projects.superalgos.spaces.docsSpace.commandInterface.command.toLowerCase() === 'app.help app.update') {
UI.projects.superalgos.spaces.docsSpace.navigateTo('Superalgos', 'Topic', 'App Update Command')
return
}
if (UI.projects.superalgos.spaces.docsSpace.commandInterface.command.indexOf('App.Update') !== 0 && UI.projects.superalgos.spaces.docsSpace.commandInterface.command.indexOf('app.update') !== 0) { return 'Not Update Commands' }
/* Set up the commit message */
let message = UI.projects.superalgos.spaces.docsSpace.commandInterface.command.trim().substring(UI.projects.superalgos.spaces.docsSpace.commandInterface.command.indexOf(' ') + 1, UI.projects.superalgos.spaces.docsSpace.commandInterface.command.length)
if (message.toLowerCase() === 'app.update') {
message = 'Updating my Superalgos Fork and local Repository'
}
/* Find the Username and Password */
let apisNode = UI.projects.superalgos.spaces.designSpace.workspace.getHierarchyHeadsByType('APIs')
if (apisNode === undefined) {
UI.projects.superalgos.spaces.docsSpace.navigateTo('Superalgos', 'Topic', 'App Error Github Credentials Missing', 'Anchor Github Credentials Missing')
return
}
if (apisNode.githubAPI === undefined) {
UI.projects.superalgos.spaces.docsSpace.navigateTo('Superalgos', 'Topic', 'App Error Github Credentials Missing', 'Anchor Github Credentials Missing')
return
}
let config = JSON.parse(apisNode.githubAPI.config)
if (config.username === undefined || config.username === "") {
UI.projects.superalgos.spaces.docsSpace.navigateTo('Superalgos', 'Topic', 'App Error Github Credentials Missing', 'Anchor Github Credentials Missing')
return
}
if (config.token === undefined || config.token === "") {
UI.projects.superalgos.spaces.docsSpace.navigateTo('Superalgos', 'Topic', 'App Error Github Credentials Missing', 'Anchor Github Credentials Missing')
return
}
httpRequest(undefined, 'App/Update/' + message + '/' + config.username + '/' + config.token, onResponse)
UI.projects.superalgos.spaces.docsSpace.navigateTo('Superalgos', 'Topic', 'App Message Updating Your Local App')
return
function onResponse(err, data) {
/* 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.CUSTOM_OK_RESPONSE.result) {
switch (data.message) {
case 'New Version Found': {
UI.projects.superalgos.spaces.docsSpace.navigateTo('Superalgos', 'Topic', 'App Message Update Succeed - New Version Found')
break
}
case 'Already Up-To-Date': {
UI.projects.superalgos.spaces.docsSpace.navigateTo('Superalgos', 'Topic', 'App Message Update Succeed - Already Up-To-Date')
break
}
case 'Not Updated': {
UI.projects.superalgos.spaces.docsSpace.navigateTo('Superalgos', 'Topic', 'App Message Not Updated')
break
}
}
} else {
UI.projects.superalgos.spaces.docsSpace.navigateTo('Superalgos', 'Topic', 'App Error Update Failed', 'Anchor Update Failed')
}
}
}
@@ -83,13 +144,13 @@ function newSuperalgosDocsCommmandInterface() {
function detectDocsCommands() {
if (checkHelpCommand() === undefined) { return true}
if (checkGotoCommand() === undefined) { return true}
if (checkAddCommand() === undefined) { return true}
if (checkDeleteCommand() === undefined) { return true}
if (checkRepaginateCommand() === undefined) { return true}
if (checkUReIndexCommand() === undefined) { return true}
if (checkUSaveCommand() === undefined) { return true}
if (checkHelpCommand() === undefined) { return true }
if (checkGotoCommand() === undefined) { return true }
if (checkAddCommand() === undefined) { return true }
if (checkDeleteCommand() === undefined) { return true }
if (checkRepaginateCommand() === undefined) { return true }
if (checkUReIndexCommand() === undefined) { return true }
if (checkUSaveCommand() === undefined) { return true }
function checkHelpCommand() {
if (UI.projects.superalgos.spaces.docsSpace.commandInterface.command.toLowerCase() === 'docs.help') {