LinusU / node-appdmg

💾 Generate your app dmgs
MIT License
1.69k stars 152 forks source link

Exposing disk image size option to user #197

Open kakyoism opened 3 years ago

kakyoism commented 3 years ago

I'm forwarding a problem I had when I build DMG with electron-forge, which is said to be an appdmg limitation.

TL;DR: Can node-appdmg expose an option similar to --disk-img-size of create-dmg ??

Please see below.

Issue Details

Expected Behavior

I'd love to insert custom data into the app folder and have them included into the DMG and show up in the mounted folder.

Actual Behavior

Trying to insert additional data into the output app folder and include it into the DMG, but after firing up a maker process, I saw a size calculation error that breaks the build

Making for the following targets: dmg
✖ Making for target: dmg - On platform: darwin - For arch: x64

An unhandled error has occurred inside Forge:
An error occured while making for target: dmg
Command failed: hdiutil create /var/folders/5j/ybqw096s7c162l_lgby0plw00000gn/T/N8YZNXR.dmg -ov -fs HFS+ -size 7313m -volname MAM-Hub
hdiutil: create failed - No space left on device

the size argument is incorrect and after digging into the source code of electron-forge, I found that this size is calculated internally and the hdiutil -size argument is not exposed.

To Reproduce

You should see the similar error above.

Additional Information

Here is my package.json

{
  "name": "myapp",
  "productName": "myapp",
  "version": "0.10.1",
  "description": "my app",
  "main": "src/main.js",
  "scripts": {
    "start": "electron-forge start",
    "package": "electron-forge package",
    "make": "electron-forge make",
    "publish": "electron-forge publish",
    "lint": "echo \"No linting configured\""
  },
  "keywords": [],
  "author": {
    "name": "me",
    "email": "me@me.com"
  },
  "license": "MIT",
  "config": {
    "forge": {
      "packagerConfig": {
        "icon": "src/images/myicon",
        "ignore": [
          "/.gitignore",
          "/.vscode",
          "/yarn.lock",
          "/node_modules/xyz/10.1.2/",
          "/node_modules/xyz/build/",
          "/node_modules/xyz/prebuilds/linux*"
        ]
      },
      "osxSign": {
        "entitlements": "entitlements.plist",
        "entitlements-inherit": "entitlements.plist",
        "gatekeeper-assess": false,
        "hardened-runtime": true,
        "identity": "my id",
        "signature-flags": "library"
      },
      "osxNotarize": "require:./notarize.js",
      "hooks": "require:./hooks.js",
      "makers": [
                {
          "name": "@electron-forge/maker-dmg",
          "platforms": [
            "darwin"
          ],
          "config": {
            "AdditionalDMGOptions": {
              "code-sign": {
                "identifier": "my certificate",
                "signing-identity": "my cert id"
              },
              "contents": [
                {
                  "name": "MAM-hub",
                  "path": "src/myapp/out/myapp-darwin-x64/myapp.app",
                  "type": "file",
                  "x": 370,
                  "y": 260
                },
                {
                  "name": "Applications",
                  "path": "/Applications",
                  "type": "link",
                  "x": 670,
                  "y": 260
                },
                {
                  "name": "My Dependency",
                  "path": "src/mam-hub/out/mam-hub-darwin-x64/mydep",
                  "type": "file",
                  "x": 240,
                  "y": 260
                },
                {
                  "name": "INSTALL.html",
                  "path": "../../temp/INSTALL_en.html",
                  "x": 240,
                  "y": 400
                },
                {
                  "name": "安装指南.html",
                  "path": "../../temp/INSTALL_zhs.html",
                  "x": 370,
                  "y": 400
                }
              ],
              "window": {
                "position": {
                  "x": 200,
                  "y": 120
                },
                "size": {
                  "height": 660,
                  "width": 1020
                }
              }
            },
            "background": "../../res/installer/macos/background-orange.png",
            "format": "UDZO",
            "icon": "src/images/myapp.icns",
            "iconSize": 90,
            "name": "myapp",
            "overwrite": true
          }
        },
        {
          "name": "@electron-forge/maker-wix",
          "platforms": [
            "win32"
          ],
          "config": {
            "arch": "x64",
            "appUserModelId": "com.me.myapp",
            "description": "description of myapp",
            "exe": "myapp",
            "iconPath": "src\\images\\me.ico",
            "language": 1033,
            "manufacturer": "me",
            "name": "my app",
            "programFilesFolderName": "myapp",
            "shortName": "myapp",
            "shortcutFolderName": "myapp",
            "ui": {
              "chooseDirectory": true,
              "images": {
                "background": "C:\\Temp\\background-orange.png",
                "banner": "C:\\Temp\\banner-orange.png"
              }
            },
            "version": "1.0.0"
          }
        }
      ]
    }
  },
  "dependencies": {
    "buffer-from": "^1.1.1",
    "zeromq": "^6.0.0-beta.6"
  },
  "devDependencies": {
    "@electron-forge/cli": "6.0.0-beta.53",
    "@electron-forge/maker-dmg": "6.0.0-beta.53",
    "@electron-forge/maker-wix": "6.0.0-beta.53",
    "electron": "10.1.2"
  }
}