diff --git a/packages/flowtest-electron/electron-main.js b/packages/flowtest-electron/electron-main.js index 18dddde..832b068 100644 --- a/packages/flowtest-electron/electron-main.js +++ b/packages/flowtest-electron/electron-main.js @@ -1,14 +1,18 @@ // Modules to control application life and create native browser window -const { app, BrowserWindow } = require('electron'); +const { app, BrowserWindow, Menu } = require('electron'); const path = require('path'); const url = require('url'); +const template = require('./electron-menu'); const Watcher = require('./src/app/watcher'); const registerRendererEventHandlers = require('./src/ipc/collection'); let mainWindow; let watcher; -function createWindow() { +app.on('ready', async () => { + const menu = Menu.buildFromTemplate(template); + Menu.setApplicationMenu(menu); + // Create the browser window. mainWindow = new BrowserWindow({ width: 1280, @@ -37,19 +41,6 @@ function createWindow() { watcher = new Watcher(); registerRendererEventHandlers(mainWindow, watcher); -} - -// This method will be called when Electron has finished -// initialization and is ready to create browser windows. -// Some APIs can only be used after this event occurs. -app.whenReady().then(() => { - createWindow; - - app.on('activate', function () { - // On macOS it's common to re-create a window in the app when the - // dock icon is clicked and there are no other windows open. - if (BrowserWindow.getAllWindows().length === 0) createWindow(); - }); }); // Quit when all windows are closed, except on macOS. There, it's common @@ -59,6 +50,3 @@ app.on('window-all-closed', function () { //if (process.platform !== 'darwin') app.quit(); }); - -// In this file you can include the rest of your app's specific main process -// code. You can also put them in separate files and require them here. diff --git a/packages/flowtest-electron/electron-menu.js b/packages/flowtest-electron/electron-menu.js new file mode 100644 index 0000000..28b233d --- /dev/null +++ b/packages/flowtest-electron/electron-menu.js @@ -0,0 +1,59 @@ +const { shell } = require('electron'); + +const template = [ + { + label: 'FlowTestAI', + submenu: [ + { type: 'separator' }, + { + role: 'quit', + label: 'Exit FlowTestAI', + }, + ], + }, + { + label: 'Edit', + submenu: [ + { role: 'undo' }, + { role: 'redo' }, + { type: 'separator' }, + { role: 'cut' }, + { role: 'copy' }, + { role: 'paste' }, + { role: 'selectAll' }, + { type: 'separator' }, + { role: 'hide' }, + { role: 'hideOthers' }, + ], + }, + { + label: 'View', + submenu: [ + { role: 'toggledevtools' }, + { type: 'separator' }, + { role: 'resetzoom' }, + { role: 'zoomin' }, + { role: 'zoomout' }, + { type: 'separator' }, + { role: 'togglefullscreen' }, + ], + }, + { + role: 'window', + submenu: [{ role: 'minimize' }, { role: 'close', accelerator: 'CommandOrControl+Shift+Q' }], + }, + { + role: 'help', + label: 'Help', + submenu: [ + { + label: 'About', + click: async () => { + await shell.openExternal('https://github.com/FlowTestAI/FlowTest'); + }, + }, + ], + }, +]; + +module.exports = template; diff --git a/packages/flowtest-electron/notarize.js b/packages/flowtest-electron/notarize.js new file mode 100644 index 0000000..96a3e6b --- /dev/null +++ b/packages/flowtest-electron/notarize.js @@ -0,0 +1,19 @@ +require('dotenv').config(); +const { notarize } = require('@electron/notarize'); + +exports.default = async function notarizing(context) { + const { electronPlatformName, appOutDir } = context; + if (electronPlatformName !== 'darwin') { + return; + } + + const appName = context.packager.appInfo.productFilename; + + return await notarize({ + appBundleId: 'com.flowtestai.app', + appPath: `${appOutDir}/${appName}.app`, + appleId: process.env.APPLE_ID, + appleIdPassword: process.env.APPLE_ID_PASSWORD, + teamId: process.env.TEAM_ID, + }); +}; diff --git a/packages/flowtest-electron/package.json b/packages/flowtest-electron/package.json index 8c50bc9..4e26d85 100644 --- a/packages/flowtest-electron/package.json +++ b/packages/flowtest-electron/package.json @@ -1,17 +1,25 @@ { - "name": "flowtest-electron", + "name": "flowtestai", + "productName": "FlowTestAI", "version": "1.0.0", - "homepage": ".", - "description": "", + "homepage": "https://github.com/FlowTestAI/FlowTest/tree/main", + "description": "OpenSource IDE for designing API powered flows", "main": "electron-main.js", + "bugs": { + "url": "https://github.com/FlowTestAI/FlowTest/issues" + }, "scripts": { "start": "electron .", - "test": "jest" + "test": "jest", + "pack": "electron-builder --dir", + "dist": "electron-builder" }, - "author": "", + "author": "Sajal Jain ", "license": "MIT", "devDependencies": { + "@electron/notarize": "^2.3.0", "electron": "^29.0.0", + "electron-builder": "^24.13.3", "jest": "^29.7.0" }, "dependencies": { @@ -27,5 +35,33 @@ "openai": "^4.29.1", "path": "^0.12.7", "uuid": "^9.0.1" + }, + "build": { + "appId": "com.flowtestai.app", + "productName": "FlowTestAI", + "directories": { + "buildResources": "resources", + "output": "dist" + }, + "files": [ + "**/*" + ], + "afterSign": "notarize.js", + "win": { + "target": "nsis" + }, + "mac": { + "target": "dmg", + "category": "public.app-category.developer-tools", + "identity": "Sajal Jain (Z25C545DT5)", + "hardenedRuntime": true, + "gatekeeperAssess": false + }, + "linux": { + "target": [ + "AppImage", + "deb" + ] + } } }