macoselectrondmgelectron-forge

electron-forge @maker-dmg how to change icon positions in the dmg installer


I have been trying to modify some parameters in the maker-dmg, so far I got all I wanted but the icon position.

this is what I have at the moment:

      name: "@electron-forge/maker-dmg",
      config: {
        title: "Gallery",
        background: "src/assets/installer-assets/installBackground.png",
        format: "ULFO",
        icon: "src/assets/installer-assets/brand-icon.icns",
        contents: [
          { x: 192, y: 344, type: "file", path: "Gallery.app" },
          { x: 428, y: 344, type: "link", path: "/Applications" }
        ]
      }

but I am getting an error saying it can't find the Gallery.app.

An error occured while making for target: dmg "Gallery.app" not found at: /var/folders/07/rvgsd3wx7_949217htsn84pw0000gn/T/Gallery.app

I know that the maker only forwards information to the appdmg library. I have been going through their documentation, all I found is that all are treated as relative paths.

Basically I don't know what is the temporary mounting location, I only wanted to specify the x and y variables from the content object, but it forces me to specify type and path.

Has anyone changed the dmg style before? Please any help is highly appreciated.

PD. this works when I mount a dmg before without specify content and then I add content like:

{ x: 192, y: 344, type: "file", path: "/Volumes/Gallery/Gallery.app" },

But once I eject it and update the forge config to include the above line It breaks.


Solution

  • If anyone going through the same bs, just used process.cwd().

    See example:

    contents: [
          {
            x: 192,
            y: 240,
            type: "file",
            path: `${process.cwd()}/out/Gallery-darwin-x64/Gallery.app`
          },
          { x: 466, y: 240, type: "link", path: "/Applications" }
        ]
    

    and I can finally play around with icon positions! Happy coding.