From 526684fea034d507c02c29c1a5d43e2d7a9e620d Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Tue, 12 Jan 2021 09:32:31 +0100 Subject: [PATCH 1/8] app.update implementation part1 --- Client/httpInterface.js | 89 +++++++++++++++++++ .../UI/Spaces/Docs-Space/CommandInterface.js | 20 ++--- 2 files changed, 99 insertions(+), 10 deletions(-) diff --git a/Client/httpInterface.js b/Client/httpInterface.js index d974b3a78..2f178b018 100644 --- a/Client/httpInterface.js +++ b/Client/httpInterface.js @@ -602,6 +602,95 @@ 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() { + await doGithub() + let message = await doGit() + + let customResponse = { + result: global.CUSTOM_OK_RESPONSE.result, + message: message + } + respondWithContent(JSON.stringify(customResponse), httpResponse) + } + + async function doGithub() { + + const { Octokit } = require("@octokit/rest") + + const octokit = new Octokit({ + auth: token, + userAgent: 'Superalgos Beta 8' + }) + + const repo = 'Superalgos' + const owner = 'Superalgos' + const head = 'in-app-documentation' + const base = username + ':in-app-documentation' + const commitMessage = 'Update: ' + message + + try { + await octokit.repos.merge({ + owner, + repo, + base, + head, + commitMessage + }); + } catch (err) { + throw (err) + } + } + + async function doGit() { + const simpleGit = require('simple-git'); + const options = { + baseDir: process.cwd(), + binary: 'git', + maxConcurrentProcesses: 6, + } + const git = simpleGit(options) + + await git.pull((err, update) => { + if (update) { + if (update.summary.changes) { + return 'App Changed' + } else { + return 'App Not Changed' + } + } else { + if (err) { + throw (err) + } else { + return 'Not Updated' + } + } + }) + } + + } 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 diff --git a/Projects/Superalgos/UI/Spaces/Docs-Space/CommandInterface.js b/Projects/Superalgos/UI/Spaces/Docs-Space/CommandInterface.js index 66e155ebc..9f1252d51 100644 --- a/Projects/Superalgos/UI/Spaces/Docs-Space/CommandInterface.js +++ b/Projects/Superalgos/UI/Spaces/Docs-Space/CommandInterface.js @@ -18,7 +18,9 @@ function newSuperalgosDocsCommmandInterface() { function detectCommands() { if (detectAppCommands() === true) { return } - detectDocsCommands() + if (detectDocsCommands() === true) { return } + + UI.projects.superalgos.spaces.docsSpace.searchResultsPage.render() } function detectAppCommands() { @@ -81,15 +83,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') { From bf07bf9af1aea6cb5e69f4dd4e49934deacde4c0 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Tue, 12 Jan 2021 10:04:28 +0100 Subject: [PATCH 2/8] app.update implementation part 2 --- Client/httpInterface.js | 4 +- ...s-001-app-error-contribution-not-sent.json | 8 +- .../UI/Spaces/Docs-Space/CommandInterface.js | 97 +++++++++++++++---- 3 files changed, 85 insertions(+), 24 deletions(-) diff --git a/Client/httpInterface.js b/Client/httpInterface.js index 2f178b018..12c8935fc 100644 --- a/Client/httpInterface.js +++ b/Client/httpInterface.js @@ -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) { diff --git a/Projects/Superalgos/Schemas/Docs-Topics/app-commands-errors-001-app-error-contribution-not-sent.json b/Projects/Superalgos/Schemas/Docs-Topics/app-commands-errors-001-app-error-contribution-not-sent.json index c56501b93..f08d1fe9c 100644 --- a/Projects/Superalgos/Schemas/Docs-Topics/app-commands-errors-001-app-error-contribution-not-sent.json +++ b/Projects/Superalgos/Schemas/Docs-Topics/app-commands-errors-001-app-error-contribution-not-sent.json @@ -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 } ] } \ No newline at end of file diff --git a/Projects/Superalgos/UI/Spaces/Docs-Space/CommandInterface.js b/Projects/Superalgos/UI/Spaces/Docs-Space/CommandInterface.js index 9f1252d51..3ac7f8eab 100644 --- a/Projects/Superalgos/UI/Spaces/Docs-Space/CommandInterface.js +++ b/Projects/Superalgos/UI/Spaces/Docs-Space/CommandInterface.js @@ -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') { From 3033ec3326d2f8546c760943a5f9070937dd4449 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Tue, 12 Jan 2021 12:18:14 +0100 Subject: [PATCH 3/8] App Update related pages --- .../app-commands-002-app-update-command.json | 37 +++++++++++++++++++ ...-app-error-github-credentials-missing.json | 16 +++++++- ...ds-errors-003-app-error-update-failed.json | 14 +++++++ ...3-app-message-updating-your-local-app.json | 14 +++++++ ...sage-update-succeed-new-version-found.json | 14 +++++++ ...age-update-succeed-already-up-to-date.json | 14 +++++++ .../UI/Spaces/Docs-Space/CommandInterface.js | 2 +- 7 files changed, 108 insertions(+), 3 deletions(-) create mode 100644 Projects/Superalgos/Schemas/Docs-Topics/app-commands-002-app-update-command.json create mode 100644 Projects/Superalgos/Schemas/Docs-Topics/app-commands-errors-003-app-error-update-failed.json create mode 100644 Projects/Superalgos/Schemas/Docs-Topics/app-commands-messages-003-app-message-updating-your-local-app.json create mode 100644 Projects/Superalgos/Schemas/Docs-Topics/app-commands-messages-004-app-message-update-succeed-new-version-found.json create mode 100644 Projects/Superalgos/Schemas/Docs-Topics/app-commands-messages-005-app-message-update-succeed-already-up-to-date.json diff --git a/Projects/Superalgos/Schemas/Docs-Topics/app-commands-002-app-update-command.json b/Projects/Superalgos/Schemas/Docs-Topics/app-commands-002-app-update-command.json new file mode 100644 index 000000000..3c7341b28 --- /dev/null +++ b/Projects/Superalgos/Schemas/Docs-Topics/app-commands-002-app-update-command.json @@ -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" + } + ] +} \ No newline at end of file diff --git a/Projects/Superalgos/Schemas/Docs-Topics/app-commands-errors-002-app-error-github-credentials-missing.json b/Projects/Superalgos/Schemas/Docs-Topics/app-commands-errors-002-app-error-github-credentials-missing.json index 5688aad8e..e767a40c3 100644 --- a/Projects/Superalgos/Schemas/Docs-Topics/app-commands-errors-002-app-error-github-credentials-missing.json +++ b/Projects/Superalgos/Schemas/Docs-Topics/app-commands-errors-002-app-error-github-credentials-missing.json @@ -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", diff --git a/Projects/Superalgos/Schemas/Docs-Topics/app-commands-errors-003-app-error-update-failed.json b/Projects/Superalgos/Schemas/Docs-Topics/app-commands-errors-003-app-error-update-failed.json new file mode 100644 index 000000000..9cce99af6 --- /dev/null +++ b/Projects/Superalgos/Schemas/Docs-Topics/app-commands-errors-003-app-error-update-failed.json @@ -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." + } + ] +} \ No newline at end of file diff --git a/Projects/Superalgos/Schemas/Docs-Topics/app-commands-messages-003-app-message-updating-your-local-app.json b/Projects/Superalgos/Schemas/Docs-Topics/app-commands-messages-003-app-message-updating-your-local-app.json new file mode 100644 index 000000000..d1f82b8dc --- /dev/null +++ b/Projects/Superalgos/Schemas/Docs-Topics/app-commands-messages-003-app-message-updating-your-local-app.json @@ -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." + } + ] +} \ No newline at end of file diff --git a/Projects/Superalgos/Schemas/Docs-Topics/app-commands-messages-004-app-message-update-succeed-new-version-found.json b/Projects/Superalgos/Schemas/Docs-Topics/app-commands-messages-004-app-message-update-succeed-new-version-found.json new file mode 100644 index 000000000..91839a5d7 --- /dev/null +++ b/Projects/Superalgos/Schemas/Docs-Topics/app-commands-messages-004-app-message-update-succeed-new-version-found.json @@ -0,0 +1,14 @@ +{ + "topic": "App Commands Messages", + "pageNumber": "4", + "type": "App Message Update Succeed - New Version Found", + "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." + } + ] +} \ No newline at end of file diff --git a/Projects/Superalgos/Schemas/Docs-Topics/app-commands-messages-005-app-message-update-succeed-already-up-to-date.json b/Projects/Superalgos/Schemas/Docs-Topics/app-commands-messages-005-app-message-update-succeed-already-up-to-date.json new file mode 100644 index 000000000..7265b22d2 --- /dev/null +++ b/Projects/Superalgos/Schemas/Docs-Topics/app-commands-messages-005-app-message-update-succeed-already-up-to-date.json @@ -0,0 +1,14 @@ +{ + "topic": "App Commands Messages", + "pageNumber": "5", + "type": "App Message Update Succeed - Already Up-To-Date", + "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." + } + ] +} \ No newline at end of file diff --git a/Projects/Superalgos/UI/Spaces/Docs-Space/CommandInterface.js b/Projects/Superalgos/UI/Spaces/Docs-Space/CommandInterface.js index 3ac7f8eab..cbba59209 100644 --- a/Projects/Superalgos/UI/Spaces/Docs-Space/CommandInterface.js +++ b/Projects/Superalgos/UI/Spaces/Docs-Space/CommandInterface.js @@ -131,7 +131,7 @@ function newSuperalgosDocsCommmandInterface() { break } case 'Not Updated': { - UI.projects.superalgos.spaces.docsSpace.navigateTo('Superalgos', 'Topic', 'App Message Not Updated') + UI.projects.superalgos.spaces.docsSpace.navigateTo('Superalgos', 'Topic', 'App Error Update Failed', 'Anchor Update Failed') break } } From 3e543a3ee0aaadfacfd03b6583f277269e7a016e Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Tue, 12 Jan 2021 13:08:45 +0100 Subject: [PATCH 4/8] test only git --- Client/httpInterface.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/Client/httpInterface.js b/Client/httpInterface.js index 12c8935fc..510427de3 100644 --- a/Client/httpInterface.js +++ b/Client/httpInterface.js @@ -611,7 +611,7 @@ exports.newHttpInterface = function newHttpInterface(WEB_SERVER, DATA_FILE_SERVE update() async function update() { - await doGithub() + //await doGithub() let message = await doGit() let customResponse = { @@ -631,9 +631,9 @@ exports.newHttpInterface = function newHttpInterface(WEB_SERVER, DATA_FILE_SERVE }) const repo = 'Superalgos' - const owner = 'Superalgos' - const head = 'in-app-documentation' - const base = username + ':in-app-documentation' + const owner = username + const head = 'upstream/in-app-documentation' + const base = 'in-app-documentation' const commitMessage = 'Update: ' + message try { @@ -658,7 +658,9 @@ exports.newHttpInterface = function newHttpInterface(WEB_SERVER, DATA_FILE_SERVE } const git = simpleGit(options) - await git.pull((err, update) => { + return await git.pull('upstream', 'in-app-documentation', onPull) + + function onPull(err, update) { if (update) { if (update.summary.changes) { return 'New Version Found' @@ -672,7 +674,7 @@ exports.newHttpInterface = function newHttpInterface(WEB_SERVER, DATA_FILE_SERVE return 'Not Updated' } } - }) + } } } catch (err) { From 83354c5c10c6a6dce6e6abbc243bfa1967157782 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Tue, 12 Jan 2021 13:22:38 +0100 Subject: [PATCH 5/8] Only git working --- Client/httpInterface.js | 47 +------------------ .../UI/Spaces/Docs-Space/CommandInterface.js | 17 ++----- 2 files changed, 5 insertions(+), 59 deletions(-) diff --git a/Client/httpInterface.js b/Client/httpInterface.js index 510427de3..e5858d785 100644 --- a/Client/httpInterface.js +++ b/Client/httpInterface.js @@ -611,7 +611,6 @@ exports.newHttpInterface = function newHttpInterface(WEB_SERVER, DATA_FILE_SERVE update() async function update() { - //await doGithub() let message = await doGit() let customResponse = { @@ -621,34 +620,6 @@ exports.newHttpInterface = function newHttpInterface(WEB_SERVER, DATA_FILE_SERVE respondWithContent(JSON.stringify(customResponse), httpResponse) } - async function doGithub() { - - const { Octokit } = require("@octokit/rest") - - const octokit = new Octokit({ - auth: token, - userAgent: 'Superalgos Beta 8' - }) - - const repo = 'Superalgos' - const owner = username - const head = 'upstream/in-app-documentation' - const base = 'in-app-documentation' - const commitMessage = 'Update: ' + message - - try { - await octokit.repos.merge({ - owner, - repo, - base, - head, - commitMessage - }); - } catch (err) { - throw (err) - } - } - async function doGit() { const simpleGit = require('simple-git'); const options = { @@ -658,23 +629,7 @@ exports.newHttpInterface = function newHttpInterface(WEB_SERVER, DATA_FILE_SERVE } const git = simpleGit(options) - return await git.pull('upstream', 'in-app-documentation', onPull) - - function onPull(err, update) { - if (update) { - if (update.summary.changes) { - return 'New Version Found' - } else { - return 'Already Up-To-Date' - } - } else { - if (err) { - throw (err) - } else { - return 'Not Updated' - } - } - } + return await git.pull('upstream', 'in-app-documentation') } } catch (err) { diff --git a/Projects/Superalgos/UI/Spaces/Docs-Space/CommandInterface.js b/Projects/Superalgos/UI/Spaces/Docs-Space/CommandInterface.js index cbba59209..e645b8790 100644 --- a/Projects/Superalgos/UI/Spaces/Docs-Space/CommandInterface.js +++ b/Projects/Superalgos/UI/Spaces/Docs-Space/CommandInterface.js @@ -121,19 +121,10 @@ 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.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 Error Update Failed', 'Anchor Update Failed') - break - } + 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 Message Update Succeed - Already Up-To-Date') } } else { UI.projects.superalgos.spaces.docsSpace.navigateTo('Superalgos', 'Topic', 'App Error Update Failed', 'Anchor Update Failed') From e04eabfdaeb27191f2e71b94375d7bfa1bc4719f Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Tue, 12 Jan 2021 14:18:33 +0100 Subject: [PATCH 6/8] App Update Command --- ...-004-app-message-update-succeed-new-version-found.json | 8 +++++--- ...005-app-message-update-succeed-already-up-to-date.json | 8 +++++--- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/Projects/Superalgos/Schemas/Docs-Topics/app-commands-messages-004-app-message-update-succeed-new-version-found.json b/Projects/Superalgos/Schemas/Docs-Topics/app-commands-messages-004-app-message-update-succeed-new-version-found.json index 91839a5d7..509eb2f5d 100644 --- a/Projects/Superalgos/Schemas/Docs-Topics/app-commands-messages-004-app-message-update-succeed-new-version-found.json +++ b/Projects/Superalgos/Schemas/Docs-Topics/app-commands-messages-004-app-message-update-succeed-new-version-found.json @@ -3,12 +3,14 @@ "pageNumber": "4", "type": "App Message Update Succeed - New Version Found", "definition": { - "text": "Write here a summary for this topic page." + "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": "Text", - "text": "Left click and Edit to enter edit mode and change this text. ENTER to write new paragraphs. ESC to exit edit mode." + "style": "Success", + "text": "You now have the latest version of Superalgos. Just remeber to restart the Client and the UI.", + "updated": 1610454408134 } ] } \ No newline at end of file diff --git a/Projects/Superalgos/Schemas/Docs-Topics/app-commands-messages-005-app-message-update-succeed-already-up-to-date.json b/Projects/Superalgos/Schemas/Docs-Topics/app-commands-messages-005-app-message-update-succeed-already-up-to-date.json index 7265b22d2..31c015f14 100644 --- a/Projects/Superalgos/Schemas/Docs-Topics/app-commands-messages-005-app-message-update-succeed-already-up-to-date.json +++ b/Projects/Superalgos/Schemas/Docs-Topics/app-commands-messages-005-app-message-update-succeed-already-up-to-date.json @@ -3,12 +3,14 @@ "pageNumber": "5", "type": "App Message Update Succeed - Already Up-To-Date", "definition": { - "text": "Write here a summary for this topic page." + "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": "Text", - "text": "Left click and Edit to enter edit mode and change this text. ENTER to write new paragraphs. ESC to exit edit mode." + "style": "Success", + "text": "You are up-to-date. No need to reboot the Client or refresh the UI page.", + "updated": 1610454271911 } ] } \ No newline at end of file From 9db1797cb3073203b5cb1252529ebb295e5bba05 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Tue, 12 Jan 2021 14:38:20 +0100 Subject: [PATCH 7/8] Bug Fix Anchor in Tutorials --- Projects/Superalgos/UI/Spaces/Docs-Space/DocsSpace.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Projects/Superalgos/UI/Spaces/Docs-Space/DocsSpace.js b/Projects/Superalgos/UI/Spaces/Docs-Space/DocsSpace.js index 737fea298..f0a85ed6c 100644 --- a/Projects/Superalgos/UI/Spaces/Docs-Space/DocsSpace.js +++ b/Projects/Superalgos/UI/Spaces/Docs-Space/DocsSpace.js @@ -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 + ) } } From bc5def6af688900553646d6b5a7ce221d14d25cc Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Tue, 12 Jan 2021 14:48:52 +0100 Subject: [PATCH 8/8] Update Command --- .../Superalgos/UI/Spaces/Docs-Space/DocumentPage.js | 2 -- Projects/Superalgos/UI/Utilities/Docs.js | 12 ++++++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/Projects/Superalgos/UI/Spaces/Docs-Space/DocumentPage.js b/Projects/Superalgos/UI/Spaces/Docs-Space/DocumentPage.js index c87ffc495..661ff43f6 100644 --- a/Projects/Superalgos/UI/Spaces/Docs-Space/DocumentPage.js +++ b/Projects/Superalgos/UI/Spaces/Docs-Space/DocumentPage.js @@ -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 diff --git a/Projects/Superalgos/UI/Utilities/Docs.js b/Projects/Superalgos/UI/Utilities/Docs.js index 7e3dc6f81..27151d24c 100644 --- a/Projects/Superalgos/UI/Utilities/Docs.js +++ b/Projects/Superalgos/UI/Utilities/Docs.js @@ -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 }