diff --git a/ui/desktop/electron-app/.gitignore b/ui/desktop/electron-app/.gitignore index 75a95bf75..3aca4c453 100644 --- a/ui/desktop/electron-app/.gitignore +++ b/ui/desktop/electron-app/.gitignore @@ -88,6 +88,9 @@ typings/ # Electron-Forge out/ +# Generated config +config/config.js + # Ember build ember-dist/ ember-test/ diff --git a/ui/desktop/electron-app/config/macos/icon.icns b/ui/desktop/electron-app/assets/app-icons/icon.icns similarity index 100% rename from ui/desktop/electron-app/config/macos/icon.icns rename to ui/desktop/electron-app/assets/app-icons/icon.icns diff --git a/ui/desktop/electron-app/config/macos/background.png b/ui/desktop/electron-app/assets/macos/background.png similarity index 100% rename from ui/desktop/electron-app/config/macos/background.png rename to ui/desktop/electron-app/assets/macos/background.png diff --git a/ui/desktop/electron-app/config/macos/background@2x.png b/ui/desktop/electron-app/assets/macos/background@2x.png similarity index 100% rename from ui/desktop/electron-app/config/macos/background@2x.png rename to ui/desktop/electron-app/assets/macos/background@2x.png diff --git a/ui/desktop/electron-app/config/macos/disk.icns b/ui/desktop/electron-app/assets/macos/disk.icns similarity index 100% rename from ui/desktop/electron-app/config/macos/disk.icns rename to ui/desktop/electron-app/assets/macos/disk.icns diff --git a/ui/desktop/electron-app/config/macos/entitlements.plist b/ui/desktop/electron-app/assets/macos/entitlements.plist similarity index 100% rename from ui/desktop/electron-app/config/macos/entitlements.plist rename to ui/desktop/electron-app/assets/macos/entitlements.plist diff --git a/ui/desktop/electron-app/config/desktop.js b/ui/desktop/electron-app/config/desktop.js new file mode 100644 index 000000000..95c15ff3b --- /dev/null +++ b/ui/desktop/electron-app/config/desktop.js @@ -0,0 +1,32 @@ +const fs = require('fs'); +const path = require('path'); + +// Create config for use in electron forge +const createConfig = () => { + const config = { + name: 'boundary', + productName: 'Boundary', + copyright: `Copyright © ${new Date().getFullYear()} HashiCorp, Inc.`, + releaseVersion: process.env.RELEASE_VERSION, + releaseCommit: process.env.RELEASE_COMMIT, + }; + + if (!config.releaseVersion) config.releaseVersion = '0.0.0'; + return config; +}; + +// Save config file +const saveConfig = (config, destination) => { + const configPath = `${destination}/config.js`; + const content = `module.exports = ${JSON.stringify(config, null, 2)}`; + fs.writeFileSync(configPath, content); + console.log(`Create: ${configPath}`); +}; + +module.exports = { + setup: () => { + const config = createConfig(); + const destination = path.resolve(__dirname); + saveConfig(config, destination); + }, +}; diff --git a/ui/desktop/electron-app/config/forge.config.js b/ui/desktop/electron-app/config/forge.config.js index c426f9aff..4db3e2f8a 100644 --- a/ui/desktop/electron-app/config/forge.config.js +++ b/ui/desktop/electron-app/config/forge.config.js @@ -1,59 +1,43 @@ -const process = require('process'); -const { version } = require('../src/cli/index.js'); +// Generated during build +const config = require('./config.js'); -const formattedCLIVersion = version().formatted; +console.log(`\n[forge-config] Release commit: ${config.releaseCommit}`); +console.log(`[forge-config] Release version: ${config.releaseVersion}`); -const appVersion = process.env.RELEASE_VERSION - ? `Version: ${process.env.RELEASE_VERSION}\n` - : ''; -const appCommit = process.env.RELEASE_COMMIT - ? `Commit: ${process.env.RELEASE_COMMIT}\n` - : ''; - -const formattedAppVersion = `${appVersion}${appCommit}`; - -// Output version strings for debugging -console.log('\n\nVersion Env Vars:'); -console.log('RELEASE_VERSION ', process.env.RELEASE_VERSION); -console.log('RELEASE_COMMIT ', process.env.RELEASE_COMMIT); +// MacOS signing identity +if (process.env.BOUNDARY_DESKTOP_SIGNING_IDENTITY) + console.warn( + '[forge-config] WARNING: Could not find signing identity. Proceeding without signing.' + ); module.exports = { - releaseVersion: process.env.RELEASE_VERSION, - hooks: { - prePackage: () => { - if (!process.env.BOUNDARY_DESKTOP_SIGNING_IDENTITY) { - console.warn('\nWARNING: Could not find signing identity.'); - } - }, - }, packagerConfig: { ignore: ['/ember-test(/|$)', '/tests(/|$)'], - name: 'Boundary', + icon: './assets/app-icons/icon', + name: config.productName, + appVersion: config.version, appBundleId: 'com.electron.boundary', - // TODO: where should the client version number come from? - appVersion: `${formattedAppVersion}${formattedCLIVersion}\n`, - appCopyright: 'Copyright © 2021 HashiCorp, Inc.', - icon: './config/macos/icon.icns', + appCopyright: config.copyright, osxSign: { identity: process.env.BOUNDARY_DESKTOP_SIGNING_IDENTITY, 'hardened-runtime': true, - entitlements: './config/macos/entitlements.plist', - 'entitlements-inherit': './config/macos/entitlements.plist', + entitlements: './assets/macos/entitlements.plist', + 'entitlements-inherit': './assets/macos/entitlements.plist', 'signature-flags': 'library', }, }, makers: [ { - name: '@electron-forge/maker-dmg', - config: { - title: 'Boundary', - name: 'boundary', - icon: './config/macos/disk.icns', - background: './config/macos/background.png', - }, + name: '@electron-forge/maker-zip', }, { - name: '@electron-forge/maker-zip', + name: '@electron-forge/maker-dmg', + config: { + title: config.productName, + name: config.name, + icon: './assets/macos/disk.icns', + background: './assets/macos/background.png', + }, }, ], }; diff --git a/ui/desktop/electron-app/package.json b/ui/desktop/electron-app/package.json index d9df381c8..49454d45e 100644 --- a/ui/desktop/electron-app/package.json +++ b/ui/desktop/electron-app/package.json @@ -9,9 +9,10 @@ "main": "src/index.js", "scripts": { "build:cli": "node -e 'require(\"./config/cli.js\").setup()'", + "build:config": "node -e 'require(\"./config/desktop.js\").setup()'", "start": "electron-forge start", "package": "electron-forge package", - "premake": "yarn build:cli", + "premake": "yarn build:cli && yarn build:config", "make": "electron-forge make", "publish": "electron-forge publish", "lint": "echo \"No linting configured\"" diff --git a/ui/desktop/electron-app/src/config/menu.js b/ui/desktop/electron-app/src/config/menu.js index 5f669e4bb..baa8e1da2 100644 --- a/ui/desktop/electron-app/src/config/menu.js +++ b/ui/desktop/electron-app/src/config/menu.js @@ -1,5 +1,7 @@ -const { shell } = require('electron'); +const { shell, dialog } = require('electron'); const appUpdater = require('../helpers/app-updater.js'); +const config = require('../../config/config.js'); +const { version } = require('../cli/index.js'); const generateMenuTemplate = () => { return [ @@ -7,7 +9,23 @@ const generateMenuTemplate = () => { { label: 'Boundary', submenu: [ - { role: 'about' }, + // { role: 'about' }, + { + label: `About ${config.productName}`, + click: () => { + const appVersion = `Version: ${config.releaseVersion}`; + const appCommit = `Commit: ${config.releaseCommit}`; + const cliVersion = version().formatted; + const copyright = config.copyright; + + const dialogOpts = { + type: 'none', + message: config.productName, + detail: `${appVersion}\n${appCommit}\n\n${cliVersion}\n\n${copyright}`, + }; + dialog.showMessageBox(dialogOpts); + }, + }, { id: 'update', label: 'Check for Updates', diff --git a/ui/desktop/package.json b/ui/desktop/package.json index dd4b5b794..a9ca4bd7d 100755 --- a/ui/desktop/package.json +++ b/ui/desktop/package.json @@ -29,7 +29,7 @@ "format:sass": "prettier --write app/**/*.scss", "lint:js:fix": "eslint . --fix", "start": "ember serve", - "prestart:desktop": "cd electron-app && yarn build:cli", + "prestart:desktop": "cd electron-app && yarn premake", "start:desktop": "ember electron", "clean:coverage": "rm -rf coverage_*", "pretest": "yarn clean:coverage",