Skip to content

Commit

Permalink
Invoke electron-installer-dmg directly to create DMG
Browse files Browse the repository at this point in the history
  • Loading branch information
p-jackson committed Apr 16, 2024
1 parent 3af2855 commit 8261b9b
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 2 deletions.
3 changes: 1 addition & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
44 changes: 44 additions & 0 deletions scripts/make-dmg.mjs
Original file line number Diff line number Diff line change
@@ -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,
},
},
},
} );

0 comments on commit 8261b9b

Please sign in to comment.