Skip to content

Commit 9108b2b

Browse files
authored
Merge pull request #59 from FlowTestAI/distributable-pacakge
Ability to create distributable package for mac
2 parents 69d8c6f + 92e5a14 commit 9108b2b

File tree

4 files changed

+125
-23
lines changed

4 files changed

+125
-23
lines changed

packages/flowtest-electron/electron-main.js

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
11
// Modules to control application life and create native browser window
2-
const { app, BrowserWindow } = require('electron');
2+
const { app, BrowserWindow, Menu } = require('electron');
33
const path = require('path');
44
const url = require('url');
5+
const template = require('./electron-menu');
56
const Watcher = require('./src/app/watcher');
67
const registerRendererEventHandlers = require('./src/ipc/collection');
78

89
let mainWindow;
910
let watcher;
1011

11-
function createWindow() {
12+
app.on('ready', async () => {
13+
const menu = Menu.buildFromTemplate(template);
14+
Menu.setApplicationMenu(menu);
15+
1216
// Create the browser window.
1317
mainWindow = new BrowserWindow({
1418
width: 1280,
@@ -37,19 +41,6 @@ function createWindow() {
3741
watcher = new Watcher();
3842

3943
registerRendererEventHandlers(mainWindow, watcher);
40-
}
41-
42-
// This method will be called when Electron has finished
43-
// initialization and is ready to create browser windows.
44-
// Some APIs can only be used after this event occurs.
45-
app.whenReady().then(() => {
46-
createWindow;
47-
48-
app.on('activate', function () {
49-
// On macOS it's common to re-create a window in the app when the
50-
// dock icon is clicked and there are no other windows open.
51-
if (BrowserWindow.getAllWindows().length === 0) createWindow();
52-
});
5344
});
5445

5546
// Quit when all windows are closed, except on macOS. There, it's common
@@ -59,6 +50,3 @@ app.on('window-all-closed', function () {
5950
//if (process.platform !== 'darwin')
6051
app.quit();
6152
});
62-
63-
// In this file you can include the rest of your app's specific main process
64-
// code. You can also put them in separate files and require them here.
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
const { shell } = require('electron');
2+
3+
const template = [
4+
{
5+
label: 'FlowTestAI',
6+
submenu: [
7+
{ type: 'separator' },
8+
{
9+
role: 'quit',
10+
label: 'Exit FlowTestAI',
11+
},
12+
],
13+
},
14+
{
15+
label: 'Edit',
16+
submenu: [
17+
{ role: 'undo' },
18+
{ role: 'redo' },
19+
{ type: 'separator' },
20+
{ role: 'cut' },
21+
{ role: 'copy' },
22+
{ role: 'paste' },
23+
{ role: 'selectAll' },
24+
{ type: 'separator' },
25+
{ role: 'hide' },
26+
{ role: 'hideOthers' },
27+
],
28+
},
29+
{
30+
label: 'View',
31+
submenu: [
32+
{ role: 'toggledevtools' },
33+
{ type: 'separator' },
34+
{ role: 'resetzoom' },
35+
{ role: 'zoomin' },
36+
{ role: 'zoomout' },
37+
{ type: 'separator' },
38+
{ role: 'togglefullscreen' },
39+
],
40+
},
41+
{
42+
role: 'window',
43+
submenu: [{ role: 'minimize' }, { role: 'close', accelerator: 'CommandOrControl+Shift+Q' }],
44+
},
45+
{
46+
role: 'help',
47+
label: 'Help',
48+
submenu: [
49+
{
50+
label: 'About',
51+
click: async () => {
52+
await shell.openExternal('https://github.com/FlowTestAI/FlowTest');
53+
},
54+
},
55+
],
56+
},
57+
];
58+
59+
module.exports = template;
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
require('dotenv').config();
2+
const { notarize } = require('@electron/notarize');
3+
4+
exports.default = async function notarizing(context) {
5+
const { electronPlatformName, appOutDir } = context;
6+
if (electronPlatformName !== 'darwin') {
7+
return;
8+
}
9+
10+
const appName = context.packager.appInfo.productFilename;
11+
12+
return await notarize({
13+
appBundleId: 'com.flowtestai.app',
14+
appPath: `${appOutDir}/${appName}.app`,
15+
appleId: process.env.APPLE_ID,
16+
appleIdPassword: process.env.APPLE_ID_PASSWORD,
17+
teamId: process.env.TEAM_ID,
18+
});
19+
};

packages/flowtest-electron/package.json

Lines changed: 41 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,25 @@
11
{
2-
"name": "flowtest-electron",
2+
"name": "flowtestai",
3+
"productName": "FlowTestAI",
34
"version": "1.0.0",
4-
"homepage": ".",
5-
"description": "",
5+
"homepage": "https://github.com/FlowTestAI/FlowTest/tree/main",
6+
"description": "OpenSource IDE for designing API powered flows",
67
"main": "electron-main.js",
8+
"bugs": {
9+
"url": "https://github.com/FlowTestAI/FlowTest/issues"
10+
},
711
"scripts": {
812
"start": "electron .",
9-
"test": "jest"
13+
"test": "jest",
14+
"pack": "electron-builder --dir",
15+
"dist": "electron-builder"
1016
},
11-
"author": "",
17+
"author": "Sajal Jain <jsajal1993@gmail.com>",
1218
"license": "MIT",
1319
"devDependencies": {
20+
"@electron/notarize": "^2.3.0",
1421
"electron": "^29.0.0",
22+
"electron-builder": "^24.13.3",
1523
"jest": "^29.7.0"
1624
},
1725
"dependencies": {
@@ -27,5 +35,33 @@
2735
"openai": "^4.29.1",
2836
"path": "^0.12.7",
2937
"uuid": "^9.0.1"
38+
},
39+
"build": {
40+
"appId": "com.flowtestai.app",
41+
"productName": "FlowTestAI",
42+
"directories": {
43+
"buildResources": "resources",
44+
"output": "dist"
45+
},
46+
"files": [
47+
"**/*"
48+
],
49+
"afterSign": "notarize.js",
50+
"win": {
51+
"target": "nsis"
52+
},
53+
"mac": {
54+
"target": "dmg",
55+
"category": "public.app-category.developer-tools",
56+
"identity": "Sajal Jain (Z25C545DT5)",
57+
"hardenedRuntime": true,
58+
"gatekeeperAssess": false
59+
},
60+
"linux": {
61+
"target": [
62+
"AppImage",
63+
"deb"
64+
]
65+
}
3066
}
3167
}

0 commit comments

Comments
 (0)