Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: vite plugin electron forge 7.5 #666

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion assets/trayIndex.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const { ipcRenderer } = require('electron');
// const { ipcRenderer } = require('electron');
import { ipcRenderer } from 'electron';

const getIconKey = (status) => {
switch (status) {
Expand Down
2 changes: 1 addition & 1 deletion biome.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
},
"files": {
"ignore": [
"src/renderer/ethers.js",
"src/renderer/ethers.cjs",
"src/main/util/*.js",
"*genesis-l2.json"
]
Expand Down
66 changes: 36 additions & 30 deletions forge.config.cts → forge.config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import type { ForgeConfig, ForgePackagerOptions } from '@electron-forge/shared-types';
import type {
ForgeConfig,
ForgePackagerOptions,
} from '@electron-forge/shared-types';
// import { MakerSquirrel } from '@electron-forge/maker-squirrel';
import { MakerZIP } from '@electron-forge/maker-zip';
// import { MakerDeb } from '@electron-forge/maker-deb';
Expand All @@ -14,7 +17,7 @@ const { version } = packageJson;
const { versionPostfix } = process.env;

const iconDir = path.resolve('assets', 'icons');
console.log("forge.config.ts iconDir: ", iconDir);
console.log('forge.config.ts iconDir: ', iconDir);

const packagerConfig: ForgePackagerOptions = {
asar: true,
Expand All @@ -25,9 +28,9 @@ const packagerConfig: ForgePackagerOptions = {
{
name: 'NiceNode Protocol',
schemes: ['nice-node'],
}
},
],
appVersion: versionPostfix ? `${version}${versionPostfix}` : version
appVersion: versionPostfix ? `${version}${versionPostfix}` : version,
// unsure if this is needed below:
// ignore: [ /stories/, /__tests__/, /.storybook/, /storybook/, /storybook-static/ ],
};
Expand All @@ -48,28 +51,29 @@ const commonLinuxConfig = {
},
executableName: 'nice-node',
productName: 'NiceNode',
productDescription: "By running a node you become part of a global movement to decentralize a world of information. Prevent leaking your personal data to third party nodes. Ensure access when you need it, and don't be censored. Decentralization starts with you. Voice your choice, help your peers.",
maintainer: "NiceNode LLC <[email protected]>",
productDescription:
"By running a node you become part of a global movement to decentralize a world of information. Prevent leaking your personal data to third party nodes. Ensure access when you need it, and don't be censored. Decentralization starts with you. Voice your choice, help your peers.",
maintainer: 'NiceNode LLC <[email protected]>',
categories: ['Utility', 'System', 'Network', 'Development'],
mimeType: ['application/x-nice-node', 'x-scheme-handler/nice-node'],
}
};

// skip signing & notarizing on local builds
console.log("process.env.CI: ", process.env.CI);
if(process.env.CI && process.env.NO_CODE_SIGNING !== 'true') {
console.log("Setting packagerConfig.osxSign and osxNotarize");
if(process.env.APPLE_PROD_CERT_NAME) {
console.log("process.env.APPLE_PROD_CERT_NAME is not null");
console.log('process.env.CI: ', process.env.CI);
if (process.env.CI && process.env.NO_CODE_SIGNING !== 'true') {
console.log('Setting packagerConfig.osxSign and osxNotarize');
if (process.env.APPLE_PROD_CERT_NAME) {
console.log('process.env.APPLE_PROD_CERT_NAME is not null');
}
packagerConfig.osxSign = {
identity: process.env.APPLE_PROD_CERT_NAME,
};
packagerConfig.osxNotarize = {
appleId: process.env.APPLE_ID,
appleIdPassword: process.env.APPLE_ID_PASSWORD,
teamId: process.env.APPLE_TEAM_ID
teamId: process.env.APPLE_TEAM_ID,
};
} else if(process.env.LOCAL_MAC_SIGNING === 'true') {
} else if (process.env.LOCAL_MAC_SIGNING === 'true') {
packagerConfig.osxSign = {}; // local keychain works automatically
}

Expand All @@ -87,27 +91,27 @@ const config: ForgeConfig = {
exe: 'nice-node.exe',
noMsi: true,
setupExe: `NiceNode-${version}-windows-${arch}-setup.exe`,
setupIcon: path.resolve(iconDir, '..', 'icon.ico')
setupIcon: path.resolve(iconDir, '..', 'icon.ico'),
}),
},
new MakerZIP({}),
{
name: '@electron-forge/maker-rpm',
platforms: ['linux'],
config: commonLinuxConfig
config: commonLinuxConfig,
},
{
name: '@electron-forge/maker-deb',
platforms: ['linux'],
config: commonLinuxConfig
config: commonLinuxConfig,
},
{
name: '@electron-forge/maker-dmg',
config: {
background: './assets/installer.icns',
overwrite: true,
},
},
new MakerDMG({
background: './assets/dmg-background.tiff',
// installer name. default includes version number in filename
// name: "NiceNode Installer",
icon: './assets/installer.icns',
overwrite: true,
}),
],
plugins: [
new VitePlugin({
Expand All @@ -117,23 +121,25 @@ const config: ForgeConfig = {
{
// `entry` is just an alias for `build.lib.entry` in the corresponding file of `config`.
entry: 'src/main/main.ts',
config: 'vite.main.config.ts',
config: 'vite.main.config.mts',
target: 'main',
},
{
entry: 'src/main/preload.ts',
config: 'vite.preload.config.ts',
config: 'vite.preload.config.mts',
target: 'preload',
},
],
renderer: [
{
name: 'main_window',
config: 'vite.renderer.config.ts',
config: 'vite.renderer.config.mts',
},
],
}),
{
name: '@electron-forge/plugin-auto-unpack-natives',
config: {}
config: {},
},
// Fuses are used to enable/disable various Electron functionality
// at package time, before code signing the application
Expand All @@ -156,10 +162,10 @@ const config: ForgeConfig = {
name: 'nice-node',
},
prerelease: true,
generateReleaseNotes: true
generateReleaseNotes: true,
},
},
]
],
};

export default config;
Loading
Loading