Skip to content

Commit

Permalink
we can now build the Electron app
Browse files Browse the repository at this point in the history
  • Loading branch information
jbilcke-hf committed Jul 21, 2024
1 parent eca0313 commit 3cddcc8
Show file tree
Hide file tree
Showing 16 changed files with 298 additions and 17 deletions.
57 changes: 51 additions & 6 deletions forge.config.js
Original file line number Diff line number Diff line change
@@ -1,32 +1,76 @@
// for some reason using forge.config.ts doesn't work,
//
// it says:
// Failed to load: /Users/jbilcke/Projects/clapper/forge.config.ts
// An unhandled rejection has occurred inside Forge:
// SyntaxError: Unexpected token 'export'
//
// so we cannot use this:
// import type { ForgeConfig } from '@electron-forge/shared-types';
// export const config: ForgeConfig = {
module.exports = {
packagerConfig: {
asar: false, // true,
icon: "./public/icon",
osxSign: {}
name: "Clapper",
asar: true,
icon: "./public/logos/CL.png",
osxSign: {},

// One or more files to be copied directly into the app's
// Contents/Resources directory for macOS target platforms
// and the resources directory for other target platforms.
// The resources directory can be referenced in the packaged
// app via the process.resourcesPath value.
extraResource: [
".next/standalone"
],
// ignore: ['^\\/public$', '^\\/node_modules$', '^\\/src$', '^\\/[.].+'],

// Walks the node_modules dependency tree to remove all of
// the packages specified in the devDependencies section of
// package.json from the outputted Electron app.
prune: true,

ignore: [
'^\\/.next$',
'^\\/src$',
'^\\/documentation$',
'^\\/test-results$',
'^\\/playwright-report$',
'^\\/.github$',
'^\\/public$',
'^\\/out$',
'^\\/tests$',
'^\\/Dockerfile$',
'^\\/package-lock.json$',
'^\\/.git$',
],
},
rebuildConfig: {},
makers: [
{
name: '@electron-forge/maker-squirrel',
config: {},
config: {
authors: "Clapper contributors"
}
},
{
name: '@electron-forge/maker-zip',
platforms: ['darwin'],
config: {},
},
{
name: '@electron-forge/maker-deb',
config: {
options: {
icon: './public/icon.png'
icon: './public/logos/CL.png'
}
},
},
{
name: '@electron-forge/maker-dmg',
config: {
options: {
icon: './public/icon.icns'
icon: './public/logos/CL.icns'
}
},
},
Expand All @@ -45,3 +89,4 @@ module.exports = {
*/
],
};

22 changes: 17 additions & 5 deletions main.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
const fs = require('fs')
const path = require('path')

// -----------------------------------------------------------
//
// attention: if you add dependencies here, you might have to edit
// forge.config.js, , the part about:
// '^\\/node_modules/(?!dotenv)$',
//
// if you have an idea to do that automatically, let me know
const dotenv = require('dotenv')
//
// -----------------------------------------------------------

dotenv.config()

Expand All @@ -20,12 +30,14 @@ try {

const { app, BrowserWindow, screen } = require('electron')

const currentDir = process.cwd()

const mainServerPath = path.join(currentDir, '.next/standalone/server.js')

// now we load the main server
require(mainServerPath)
try {
// used when the app is built with `npm run electron:make`
require(path.join(process.resourcesPath, 'standalone/server.js'))
} catch (err) {
// used when the app is started with `npm run electron:start`
require(path.join(process.cwd(), '.next/standalone/server.js'))
}

// TODO: load the proxy server (for AI providers that refuse browser-side clients)
// const proxyServerPath = path.join(currentDir, '.next/standalone/proxy-server.js')
Expand Down
Loading

0 comments on commit 3cddcc8

Please sign in to comment.