forge icon indicating copy to clipboard operation
forge copied to clipboard

Unclear Forge maker config specificity rules

Open AlexStormwood opened this issue 11 months ago • 1 comments

Pre-flight checklist

  • [x] I have read the contribution documentation for this project.
  • [x] I agree to follow the code of conduct that this project uses.
  • [x] I have searched the issue tracker for a bug that matches the one I want to file, without success.

Forge version

7.6.1

Electron version

34.1.0

Operating system

Windows 11, Linux Mint 22.1 (Ubuntu 24.04)

Last known working Forge version

7.4.0

Expected behavior

Build configuration options for these properties should be respected, with more-specific instances of those options (e.g. maker config objects) overriding the more-generic instances of those options (e.g. packagerConfig properties and package.json properties):

  • name
  • productName
  • executableName
  • title
  • setupExe

Actual behavior

Not all properties mentioned in the "Expected Behaviour" section are on all platforms, but I have encountered this issue on both Maker Deb and Maker Squirrel - completely different platforms. Essentially, a value such as the name declared in the project's package.json is used and a name declared in a maker config or even packager config is ignored.

Steps to reproduce

  1. Make a project - I have this happening on Electron + Vite + TypeScript projects from a template made with this command: npx create-electron-app@latest repro-project --template=vite-typescript
  2. Run the make command to confirm things work with default project settings. npm run make
  3. Add properties to the forge.config.ts file that would be used in place of the package.json file's name value, such as:
// contents of forge.config.ts trimmed for brevity, only providing what was changed:

const config: ForgeConfig = {
  packagerConfig: {
    asar: true,
    name: "repro new name 1",
    executableName: "repro exe name 1",
  },
  rebuildConfig: {},
  makers: [
    new MakerSquirrel({
      exe: "repro exe name 2",
      name: "repro new name 2",
      setupExe:"repro setup name 1",
      title: "repro nuget name 1",

    }), 

// contents after the Squirrel maker cut for brevity
  1. Change the package.json file's productName property as well, for good measure.
{
  "name": "repro-project",
  "productName": "Repro Project Product Name 1",
  "version": "1.0.0",
  "description": "My Electron application description",
// contents cut for brevity, but it's unchanged below the productName line anyway
  1. Run the npm run make command again, and check the output files generated. For example, with the properties used above, my output is (on the left):

Image

  1. Install the made app, and check the installed files to see how else the properties are used:

Image


A repro is attached, but the steps above are it. Behaviour happens to my projects made with the 7.6.1 version of the template on both Linux Mint (Ubuntu) and Windows 11 (no WSL, just Windows).

electron-package-name-repro.zip

Additional information

I wasn't getting this issue ~6 months ago, but I wanted to update and overhaul a couple of Electron projects and moved to the latest version of things... so... the "last working version" may be slightly off, but that's the general time range of changes that I'm looking at.

This issue was also explored a bit here: https://github.com/electron/forge/issues/3753#issuecomment-2641436481

And some at-a-glance maybe-related issues:

  • https://github.com/electron/forge/issues/3840
  • https://github.com/electron/forge/issues/3660

AlexStormwood avatar Feb 11 '25 07:02 AlexStormwood

Related as well: https://github.com/electron/forge/issues/3118

erickzhao avatar Feb 14 '25 02:02 erickzhao