Refactor finalize-desktop-artifacts.mjs for improved readability and consistency
All checks were successful
farmcontrol/farmcontrol-server/pipeline/head This commit looks good

- Reformatted code for better readability by adjusting line breaks and indentation.
- Updated macOS DMG window dimensions for improved layout.
- Streamlined the build architecture retrieval process for clarity.
- Enhanced filtering logic in the canUseDirectDmgSourceFolder function for consistency.
This commit is contained in:
Tom Butcher 2026-08-01 23:24:31 +01:00
parent d0d43aebb7
commit ffe8bce3a5

View File

@ -22,7 +22,10 @@ import {
import { codesignMacAppBundle } from "./codesign-macos-app.mjs"; import { codesignMacAppBundle } from "./codesign-macos-app.mjs";
import { prepareWindowsAppBinaries } from "./prepare-windows-app-binaries.mjs"; import { prepareWindowsAppBinaries } from "./prepare-windows-app-binaries.mjs";
const rootDir = path.resolve(path.dirname(fileURLToPath(import.meta.url)), ".."); const rootDir = path.resolve(
path.dirname(fileURLToPath(import.meta.url)),
"..",
);
const packageJson = JSON.parse( const packageJson = JSON.parse(
readFileSync(path.join(rootDir, "package.json"), "utf8"), readFileSync(path.join(rootDir, "package.json"), "utf8"),
); );
@ -36,9 +39,7 @@ const targetOs =
: process.platform === "linux" : process.platform === "linux"
? "linux" ? "linux"
: null); : null);
const buildArch = getReleaseArch( const buildArch = getReleaseArch(process.env.ELECTROBUN_ARCH || process.arch);
process.env.ELECTROBUN_ARCH || process.arch,
);
const version = const version =
process.env.ELECTROBUN_APP_VERSION || getReleaseVersion(packageJson); process.env.ELECTROBUN_APP_VERSION || getReleaseVersion(packageJson);
const artifactDir = const artifactDir =
@ -197,8 +198,8 @@ const MAC_DMG_BACKGROUND_RETINA_PATH = path.join(
"assets/dmg/background@2x.png", "assets/dmg/background@2x.png",
); );
const MAC_DMG_APP_NAME = "Farm Control Server.app"; const MAC_DMG_APP_NAME = "Farm Control Server.app";
const MAC_DMG_WINDOW_WIDTH = 380; const MAC_DMG_WINDOW_WIDTH = 540;
const MAC_DMG_WINDOW_HEIGHT = 540; const MAC_DMG_WINDOW_HEIGHT = 380;
function ensureMacDmgAssets() { function ensureMacDmgAssets() {
mkdirSync(MAC_DMG_ASSETS_DIR, { recursive: true }); mkdirSync(MAC_DMG_ASSETS_DIR, { recursive: true });
@ -327,8 +328,7 @@ function canUseDirectDmgSourceFolder(appBundlePath) {
const platformDir = path.dirname(appBundlePath); const platformDir = path.dirname(appBundlePath);
const appName = path.basename(appBundlePath); const appName = path.basename(appBundlePath);
const entries = readdirSync(platformDir).filter( const entries = readdirSync(platformDir).filter(
(entry) => (entry) => !entry.startsWith(".") && entry !== ".finalize-dmg-staging",
!entry.startsWith(".") && entry !== ".finalize-dmg-staging",
); );
return entries.length === 1 && entries[0] === appName; return entries.length === 1 && entries[0] === appName;
@ -368,10 +368,7 @@ async function buildMacDmg(appBundlePath, arch) {
if (!useDirectSource) { if (!useDirectSource) {
rmSync(stagingDir, { recursive: true, force: true }); rmSync(stagingDir, { recursive: true, force: true });
mkdirSync(stagingDir, { recursive: true }); mkdirSync(stagingDir, { recursive: true });
const stagedAppPath = path.join( const stagedAppPath = path.join(stagingDir, path.basename(appBundlePath));
stagingDir,
path.basename(appBundlePath),
);
copyMacAppBundle(appBundlePath, stagedAppPath); copyMacAppBundle(appBundlePath, stagedAppPath);
codesignMacAppBundle(stagedAppPath); codesignMacAppBundle(stagedAppPath);
} }
@ -449,8 +446,7 @@ function buildWindowsNsis(appDir, arch) {
artifactDir, artifactDir,
getReleaseArtifactName(version, arch, "exe"), getReleaseArtifactName(version, arch, "exe"),
); );
const powershell = const powershell = process.env.SystemRoot
process.env.SystemRoot
? path.join( ? path.join(
process.env.SystemRoot, process.env.SystemRoot,
"System32", "System32",
@ -494,8 +490,7 @@ function buildWindowsMsi(setupExePath, arch) {
artifactDir, artifactDir,
getReleaseArtifactName(version, arch, "msi"), getReleaseArtifactName(version, arch, "msi"),
); );
const powershell = const powershell = process.env.SystemRoot
process.env.SystemRoot
? path.join( ? path.join(
process.env.SystemRoot, process.env.SystemRoot,
"System32", "System32",