Merge branch 'in-app-documentation' of https://github.com/Superalgos/Superalgos into in-app-documentation
This commit is contained in:
commit
e515256180
12 files changed
+251
-29
No files matched your search
@@ -602,6 +602,52 @@ exports.newHttpInterface = function newHttpInterface(WEB_SERVER, DATA_FILE_SERVE
|
||||
}
|
||||
break
|
||||
}
|
||||
case 'Update': {
|
||||
try {
|
||||
const message = unescape(requestParameters[3])
|
||||
const username = unescape(requestParameters[4])
|
||||
const token = unescape(requestParameters[5])
|
||||
|
||||
update()
|
||||
|
||||
async function update() {
|
||||
let message = await doGit()
|
||||
|
||||
let customResponse = {
|
||||
result: global.CUSTOM_OK_RESPONSE.result,
|
||||
message: message
|
||||
}
|
||||
respondWithContent(JSON.stringify(customResponse), httpResponse)
|
||||
}
|
||||
|
||||
async function doGit() {
|
||||
const simpleGit = require('simple-git');
|
||||
const options = {
|
||||
baseDir: process.cwd(),
|
||||
binary: 'git',
|
||||
maxConcurrentProcesses: 6,
|
||||
}
|
||||
const git = simpleGit(options)
|
||||
|
||||
return await git.pull('upstream', 'in-app-documentation')
|
||||
}
|
||||
|
||||
} catch (err) {
|
||||
console.log('[ERROR] httpInterface -> App -> Update -> Method call produced an error.')
|
||||
console.log('[ERROR] httpInterface -> App -> Update -> err.stack = ' + err.stack)
|
||||
console.log('[ERROR] httpInterface -> App -> Update -> commitMessage = ' + commitMessage)
|
||||
console.log('[ERROR] httpInterface -> App -> Update -> username = ' + username)
|
||||
console.log('[ERROR] httpInterface -> App -> Update -> token = ' + token)
|
||||
|
||||
let error = {
|
||||
result: 'Fail Because',
|
||||
message: err.message,
|
||||
stack: err.stack
|
||||
}
|
||||
respondWithContent(JSON.stringify(error), httpResponse)
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
break
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
{
|
||||
"topic": "App Commands",
|
||||
"pageNumber": "2",
|
||||
"type": "App Update Command",
|
||||
"definition": {
|
||||
"text": "Use this command to update your local installation of Superalgos to the latest version available. ",
|
||||
"updated": 1610449365984
|
||||
},
|
||||
"paragraphs": [
|
||||
{
|
||||
"style": "Title",
|
||||
"text": "Syntax",
|
||||
"updated": 1610449451990
|
||||
},
|
||||
{
|
||||
"style": "Json",
|
||||
"text": "docs.update Message"
|
||||
},
|
||||
{
|
||||
"style": "Title",
|
||||
"text": "Parameters"
|
||||
},
|
||||
{
|
||||
"style": "List",
|
||||
"text": "Message: This is optional. It is the message that is going to be recorded at Github.com when we merge for you the branch of the main repository into the branch of your fork.",
|
||||
"updated": 1610449466750
|
||||
},
|
||||
{
|
||||
"style": "Title",
|
||||
"text": "Examples"
|
||||
},
|
||||
{
|
||||
"style": "Json",
|
||||
"text": "app.update"
|
||||
}
|
||||
]
|
||||
}
|
||||
+4
-4
@@ -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
|
||||
}
|
||||
]
|
||||
}
|
||||
+14
-2
@@ -3,8 +3,8 @@
|
||||
"pageNumber": "2",
|
||||
"type": "App Error Github Credentials Missing",
|
||||
"definition": {
|
||||
"text": "In order to manage contributions from within the app, you first need to provide your Github.com credentials so that we can get you authenticated when pushing your changes to the remote repository.",
|
||||
"updated": 1609945324462
|
||||
"text": "In order to manage contributions from within the app, or update the app by running a command; you first need to provide your Github.com credentials so that we can get you authenticated when pushing your changes to the remote repository.",
|
||||
"updated": 1610449696988
|
||||
},
|
||||
"paragraphs": [
|
||||
{
|
||||
@@ -21,6 +21,18 @@
|
||||
"text": "To solve this issue follow the following instructions on how to set up your GitHub.com credentials so that the system can automate the tasks needed to submit your contributions to the main repository of the Superalgos project.",
|
||||
"updated": 1609945787577
|
||||
},
|
||||
{
|
||||
"style": "Title",
|
||||
"text": "Applies to"
|
||||
},
|
||||
{
|
||||
"style": "List",
|
||||
"text": "App Contribute Command"
|
||||
},
|
||||
{
|
||||
"style": "List",
|
||||
"text": "App Update Command"
|
||||
},
|
||||
{
|
||||
"style": "Include",
|
||||
"text": "Superalgos->Topic->App Contribute Command->Block Authentication",
|
||||
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"topic": "App Commands Errors",
|
||||
"pageNumber": "3",
|
||||
"type": "App Error Update Failed",
|
||||
"definition": {
|
||||
"text": "Write here a summary for this topic page."
|
||||
},
|
||||
"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."
|
||||
}
|
||||
]
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"topic": "App Commands Messages",
|
||||
"pageNumber": "3",
|
||||
"type": "App Message Updating Your Local App",
|
||||
"definition": {
|
||||
"text": "Write here a summary for this topic page."
|
||||
},
|
||||
"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."
|
||||
}
|
||||
]
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"topic": "App Commands Messages",
|
||||
"pageNumber": "4",
|
||||
"type": "App Message Update Succeed - New Version Found",
|
||||
"definition": {
|
||||
"text": "The update process ran successfully. It found a new version of Superalgos and it download it replacing the current one. In order for the new changes to take effect, you need to restart the Client and refresh the UI page.",
|
||||
"updated": 1610454363656
|
||||
},
|
||||
"paragraphs": [
|
||||
{
|
||||
"style": "Success",
|
||||
"text": "You now have the latest version of Superalgos. Just remeber to restart the Client and the UI.",
|
||||
"updated": 1610454408134
|
||||
}
|
||||
]
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"topic": "App Commands Messages",
|
||||
"pageNumber": "5",
|
||||
"type": "App Message Update Succeed - Already Up-To-Date",
|
||||
"definition": {
|
||||
"text": "The update process was executed successfully, but no changes where found since you were running the latest version of Superalgos. No further action need to be taken.",
|
||||
"updated": 1610454235682
|
||||
},
|
||||
"paragraphs": [
|
||||
{
|
||||
"style": "Success",
|
||||
"text": "You are up-to-date. No need to reboot the Client or refresh the UI page.",
|
||||
"updated": 1610454271911
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -18,18 +18,22 @@ function newSuperalgosDocsCommmandInterface() {
|
||||
|
||||
function detectCommands() {
|
||||
if (detectAppCommands() === true) { return }
|
||||
detectDocsCommands()
|
||||
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)
|
||||
@@ -41,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 */
|
||||
@@ -69,11 +73,61 @@ 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')
|
||||
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) {
|
||||
if (data.message.summary.changes + data.message.summary.deletions + data.message.summary.insertions > 0) {
|
||||
UI.projects.superalgos.spaces.docsSpace.navigateTo('Superalgos', 'Topic', 'App Message Update Succeed - New Version Found')
|
||||
} 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 Message Update Succeed - Already Up-To-Date')
|
||||
}
|
||||
} else {
|
||||
UI.projects.superalgos.spaces.docsSpace.navigateTo('Superalgos', 'Topic', 'App Error Update Failed', 'Anchor Update Failed')
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -81,15 +135,13 @@ function newSuperalgosDocsCommmandInterface() {
|
||||
|
||||
function detectDocsCommands() {
|
||||
|
||||
if (checkHelpCommand() === undefined) { return }
|
||||
if (checkGotoCommand() === undefined) { return }
|
||||
if (checkAddCommand() === undefined) { return }
|
||||
if (checkDeleteCommand() === undefined) { return }
|
||||
if (checkRepaginateCommand() === undefined) { return }
|
||||
if (checkUReIndexCommand() === undefined) { return }
|
||||
if (checkUSaveCommand() === undefined) { return }
|
||||
|
||||
UI.projects.superalgos.spaces.docsSpace.searchResultsPage.render()
|
||||
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') {
|
||||
|
||||
@@ -195,7 +195,12 @@ function newSuperalgosDocSpace() {
|
||||
thisObject.mainSearchPage.render()
|
||||
|
||||
} else {
|
||||
UI.projects.superalgos.spaces.docsSpace.navigateTo(UI.projects.superalgos.spaces.docsSpace.currentDocumentBeingRendered.project, UI.projects.superalgos.spaces.docsSpace.currentDocumentBeingRendered.category, UI.projects.superalgos.spaces.docsSpace.currentDocumentBeingRendered.type)
|
||||
UI.projects.superalgos.spaces.docsSpace.navigateTo(
|
||||
UI.projects.superalgos.spaces.docsSpace.currentDocumentBeingRendered.project,
|
||||
UI.projects.superalgos.spaces.docsSpace.currentDocumentBeingRendered.category,
|
||||
UI.projects.superalgos.spaces.docsSpace.currentDocumentBeingRendered.type,
|
||||
UI.projects.superalgos.spaces.docsSpace.currentDocumentBeingRendered.anchor
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1874,8 +1874,6 @@ function newSuperalgosDocsDocumentPage() {
|
||||
}
|
||||
|
||||
function exitEditMode() {
|
||||
/* This will make the Client to save this in a file overwritting the previous version*/
|
||||
thisObject.docsSchemaDocument.updated = true
|
||||
|
||||
/* We will update the paragraph that was being edited*/
|
||||
let editing
|
||||
|
||||
@@ -111,8 +111,13 @@ function newSuperalgosUtilitiesDocs() {
|
||||
function setTextBasedOnLanguage(paragraph, text) {
|
||||
if (UI.projects.superalgos.spaces.docsSpace.language === UI.projects.superalgos.globals.docs.DEFAULT_LANGUAGE) {
|
||||
if (paragraph.text !== text) {
|
||||
|
||||
/* This will make the Client to save this in a file overwritting the previous version*/
|
||||
UI.projects.superalgos.spaces.docsSpace.documentPage.docsSchemaDocument.updated = true
|
||||
|
||||
paragraph.text = text
|
||||
paragraph.updated = (new Date()).valueOf()
|
||||
|
||||
}
|
||||
return
|
||||
} else {
|
||||
@@ -131,6 +136,10 @@ function newSuperalgosUtilitiesDocs() {
|
||||
let translation = paragraph.translations[i]
|
||||
if (translation.language === UI.projects.superalgos.spaces.docsSpace.language) {
|
||||
if (translation.text !== text) {
|
||||
|
||||
/* This will make the Client to save this in a file overwritting the previous version*/
|
||||
UI.projects.superalgos.spaces.docsSpace.documentPage.docsSchemaDocument.updated = true
|
||||
|
||||
translation.text = text
|
||||
translation.updated = (new Date()).valueOf()
|
||||
}
|
||||
@@ -143,6 +152,9 @@ function newSuperalgosUtilitiesDocs() {
|
||||
updated: (new Date()).valueOf()
|
||||
}
|
||||
paragraph.translations.push(translation)
|
||||
|
||||
/* This will make the Client to save this in a file overwritting the previous version*/
|
||||
UI.projects.superalgos.spaces.docsSpace.documentPage.docsSchemaDocument.updated = true
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user