From 8261b9b8eef295207cc494a0a8c524263c319e5b Mon Sep 17 00:00:00 2001 From: Philip Jackson Date: Thu, 11 Apr 2024 20:26:20 +1200 Subject: [PATCH] Invoke electron-installer-dmg directly to create DMG --- package-lock.json | 3 +-- package.json | 3 +++ scripts/make-dmg.mjs | 44 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 48 insertions(+), 2 deletions(-) create mode 100644 scripts/make-dmg.mjs diff --git a/package-lock.json b/package-lock.json index 64e560a5a..3323cf710 100644 --- a/package-lock.json +++ b/package-lock.json @@ -66,6 +66,7 @@ "css-loader": "^6.0.0", "ejs": "^3.1.9", "electron": "29.1.0", + "electron-installer-dmg": "^4.0.0", "electron-playwright-helpers": "^1.7.0", "eslint": "^8.0.1", "eslint-config-prettier": "^9.1.0", @@ -9339,7 +9340,6 @@ "resolved": "https://registry.npmjs.org/electron-installer-dmg/-/electron-installer-dmg-4.0.0.tgz", "integrity": "sha512-g3W6XnyUa7QGrAF7ViewHdt6bXV2KYU1Pm1CY3pZpp+H6mOjCHHAhf/iZAxtaX1ERCb+SQHz7xSsAHuNH9I8ZQ==", "dev": true, - "optional": true, "dependencies": { "debug": "^4.3.2", "minimist": "^1.1.1" @@ -27577,7 +27577,6 @@ "resolved": "https://registry.npmjs.org/electron-installer-dmg/-/electron-installer-dmg-4.0.0.tgz", "integrity": "sha512-g3W6XnyUa7QGrAF7ViewHdt6bXV2KYU1Pm1CY3pZpp+H6mOjCHHAhf/iZAxtaX1ERCb+SQHz7xSsAHuNH9I8ZQ==", "dev": true, - "optional": true, "requires": { "appdmg": "^0.6.4", "debug": "^4.3.2", diff --git a/package.json b/package.json index ae04a4b77..b9fac4a89 100644 --- a/package.json +++ b/package.json @@ -20,6 +20,8 @@ "make": "electron-forge make", "make:macos-x64": "SKIP_DMG=true FILE_ARCHITECTURE=x64 electron-forge make --arch=x64 --platform=darwin", "make:macos-arm64": "SKIP_DMG=true FILE_ARCHITECTURE=arm64 electron-forge make --arch=arm64 --platform=darwin", + "make:dmg-x64": "FILE_ARCHITECTURE=x64 node ./scripts/make-dmg.mjs", + "make:dmg-arm64": "FILE_ARCHITECTURE=arm64 node ./scripts/make-dmg.mjs", "publish": "electron-forge publish", "lint": "eslint --ext .ts,.tsx,.js,.jsx,.mjs .", "format": "prettier . --write", @@ -60,6 +62,7 @@ "css-loader": "^6.0.0", "ejs": "^3.1.9", "electron": "29.1.0", + "electron-installer-dmg": "^4.0.0", "electron-playwright-helpers": "^1.7.0", "eslint": "^8.0.1", "eslint-config-prettier": "^9.1.0", diff --git a/scripts/make-dmg.mjs b/scripts/make-dmg.mjs new file mode 100644 index 000000000..7d46b9bc9 --- /dev/null +++ b/scripts/make-dmg.mjs @@ -0,0 +1,44 @@ +import * as path from 'path'; +import { fileURLToPath } from 'url'; +import createDMG from 'electron-installer-dmg'; +import packageJson from '../package.json' assert { type: 'json' }; + +const __dirname = path.dirname( fileURLToPath( import.meta.url ) ); + +const appPath = path.resolve( + __dirname, + '../out', + `${ packageJson.productName }-darwin-${ process.env.FILE_ARCHITECTURE }`, + `${ packageJson.productName }.app` +); + +const dmgPath = path.resolve( + __dirname, + '../out', + `${ packageJson.productName }-darwin-${ process.env.FILE_ARCHITECTURE }.dmg` +); + +await createDMG( { + appPath, + dmgPath, + name: packageJson.productName, + icon: path.resolve( __dirname, '../assets/studio-app-icon.icns' ), + background: path.resolve( __dirname, '../assets/dmg-background.png' ), + contents: [ + { + x: 533, + y: 122, + type: 'file', + path: appPath, + }, + { x: 533, y: 354, type: 'link', path: '/Applications' }, + ], + additionalDMGOptions: { + window: { + size: { + width: 710, + height: 502, + }, + }, + }, +} );