Add DMG background images and update asset management
All checks were successful
farmcontrol/farmcontrol-server/pipeline/head This commit looks good

- Introduced new background images for macOS DMG packaging, including standard and retina versions.
- Updated the finalize-desktop-artifacts.mjs script to check for the presence of these background images, enhancing error handling.
- Refactored the ensureMacDmgAssets function to improve asset validation and streamline the DMG building process.
This commit is contained in:
Tom Butcher 2026-08-01 23:14:13 +01:00
parent f63b1fbc37
commit eb49ba7ce3
3 changed files with 24 additions and 15 deletions

BIN
assets/dmg/background.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 29 KiB

View File

@ -190,13 +190,19 @@ function cleanStagingArtifacts(keepNames) {
}
const MAC_DMG_ASSETS_DIR = path.join(rootDir, "packaging/macos/dmg");
const MAC_DMG_BACKGROUND_PATH = path.join(rootDir, "assets/dmg/background.png");
const MAC_DMG_BACKGROUND_RETINA_PATH = path.join(
rootDir,
"assets/dmg/background@2x.png",
);
const MAC_DMG_APP_NAME = "Farm Control Server.app";
const MAC_DMG_WINDOW_WIDTH = 380;
const MAC_DMG_WINDOW_HEIGHT = 540;
async function ensureMacDmgAssets() {
function ensureMacDmgAssets() {
mkdirSync(MAC_DMG_ASSETS_DIR, { recursive: true });
const voliconPath = path.join(MAC_DMG_ASSETS_DIR, "volicon.icns");
const backgroundPath = path.join(MAC_DMG_ASSETS_DIR, "background.png");
const iconsetPath = path.join(rootDir, "assets/icon.iconset");
if (!existsSync(voliconPath) && existsSync(iconsetPath)) {
@ -213,16 +219,19 @@ async function ensureMacDmgAssets() {
}
}
if (!existsSync(backgroundPath)) {
const { Jimp } = await import("jimp");
const background = new Jimp({ width: 700, height: 450, color: "#1f1f1f" });
await background.write(backgroundPath);
console.log(`finalize-desktop-artifacts: generated DMG background at ${backgroundPath}`);
if (!existsSync(MAC_DMG_BACKGROUND_PATH)) {
throw new Error(`DMG background not found at ${MAC_DMG_BACKGROUND_PATH}`);
}
if (!existsSync(MAC_DMG_BACKGROUND_RETINA_PATH)) {
console.warn(
`finalize-desktop-artifacts: retina DMG background not found at ${MAC_DMG_BACKGROUND_RETINA_PATH}`,
);
}
return {
volicon: existsSync(voliconPath) ? voliconPath : null,
background: existsSync(backgroundPath) ? backgroundPath : null,
background: MAC_DMG_BACKGROUND_PATH,
};
}
@ -260,19 +269,19 @@ function buildMacDmgWithCreateDmg(
"200",
"120",
"--window-size",
"700",
"450",
String(MAC_DMG_WINDOW_WIDTH),
String(MAC_DMG_WINDOW_HEIGHT),
"--icon-size",
"120",
"--icon",
appBundleName,
"180",
"200",
"98",
"270",
"--hide-extension",
appBundleName,
"--app-drop-link",
"520",
"200",
"282",
"270",
"--format",
"UDZO",
];
@ -367,7 +376,7 @@ async function buildMacDmg(appBundlePath, arch) {
}
let builtDmgPath;
const dmgAssets = await ensureMacDmgAssets();
const dmgAssets = ensureMacDmgAssets();
try {
builtDmgPath = buildMacDmgWithCreateDmg(