chore: pull CLI git rev and version into about dialog

This commit is contained in:
Randall Morey committed 2021-02-02 12:03:50 -05:00
1 parent c40068f211
commit 8e3241d7fd
3 files changed
+32 -4

No files matched your search

@@ -1,4 +1,7 @@
const process = require('process');
const { version } = require('../src/boundary-cli.js');
const formattedCLIVersion = version().formatted;
module.exports = {
hooks: {
@@ -24,7 +27,8 @@ module.exports = {
],
name: "Boundary Desktop",
appBundleId: "com.electron.boundary",
appVersion: "0.0.1",
// TODO: where should the client version number come from?
appVersion: `1.0.0 ${formattedCLIVersion}`,
appCopyright: "Copyright © 2021 HashiCorp, Inc."
},
makers: [
+15 -1
View File
@@ -1,5 +1,5 @@
const path = require('path');
const { spawnAsyncJSONPromise } = require('./spawn-promise');
const { spawnAsyncJSONPromise, spawnSync } = require('./spawn-promise');
const cliPath = async () => path.resolve(__dirname, '..', 'cli', 'boundary');
@@ -17,5 +17,19 @@ module.exports = {
'--output-json-errors'
];
return spawnAsyncJSONPromise(command);
},
// Returns JSON-formatted version information from the CLI
version: () => {
const command = [ '-v' ];
const rawOutput = spawnSync(command);
let gitRevision = /Git Revision:\s*(?<rev>.*)\n/.exec(rawOutput);
let versionNumber = /Version Number:\s*(?<ver>.*)\n/.exec(rawOutput);
if (gitRevision) gitRevision = gitRevision.groups.rev;
if (versionNumber) versionNumber = versionNumber.groups.ver;
const formatted = versionNumber
? `CLI Version ${versionNumber}; Git Rev ${gitRevision}`
: `CLI Git Rev ${gitRevision}`;
return { gitRevision, versionNumber, formatted };
return rawOutput;
}
}
+12 -2
View File
@@ -1,5 +1,7 @@
const path = require('path');
const { spawn } = require('child_process');
const { spawn, spawnSync } = require('child_process');
const boundaryPath = path.resolve(__dirname, '..', 'cli', 'boundary');
// Convert to json
const jsonify = (data) => {
@@ -37,7 +39,6 @@ module.exports = {
*/
spawnAsyncJSONPromise(command) {
return new Promise((resolve, reject) => {
const boundaryPath = path.resolve(__dirname, '..', 'cli', 'boundary');
const childProcess = spawn(boundaryPath, command);
let outputStream = '';
let errorStream = '';
@@ -57,4 +58,13 @@ module.exports = {
});
},
/**
*
*/
spawnSync(command) {
const childProcess = spawnSync(boundaryPath, command);
const rawOutput = childProcess.output.toString();
return rawOutput;
}
};