diff --git a/ui/desktop/electron-app/.gitignore b/ui/desktop/electron-app/.gitignore index 0928c4d31..75a95bf75 100644 --- a/ui/desktop/electron-app/.gitignore +++ b/ui/desktop/electron-app/.gitignore @@ -93,7 +93,7 @@ ember-dist/ ember-test/ # CLI -cli/ +/cli/ # Autoupdate nextVersion/ diff --git a/ui/desktop/electron-app/src/cli/index.js b/ui/desktop/electron-app/src/cli/index.js new file mode 100644 index 000000000..cfb5153a5 --- /dev/null +++ b/ui/desktop/electron-app/src/cli/index.js @@ -0,0 +1,23 @@ +const path = require('path'); +const { spawnSync } = require('../helpers/spawn-promise.js'); + +const cliPath = async () => path.resolve(__dirname, '..', 'cli', 'boundary'); + +module.exports = { + // Check boundary cli existence + exists: () => Boolean(cliPath()), + + // Returns JSON-formatted version information from the CLI + version: () => { + const command = ['-v']; + const rawOutput = spawnSync(command); + let gitRevision = /Git Revision:\s*(?.*)\n/.exec(rawOutput); + let versionNumber = /Version Number:\s*(?.*)\n/.exec(rawOutput); + if (gitRevision) gitRevision = gitRevision.groups.rev; + if (versionNumber) versionNumber = versionNumber.groups.ver; + const formatted = versionNumber + ? `CLI Version: ${versionNumber}\nCLI Commit: ${gitRevision}` + : `CLI Commit: ${gitRevision}`; + return { gitRevision, versionNumber, formatted }; + }, +};