Add app icon generation script and update related processes
- Introduced a new script `generate-app-icons.mjs` to automate the generation of application and installer icons. - Updated error messages in the Windows MSI build script and the finalize artifacts script to reference the new icon generation command. - Refactored the pre-build process to call the new icon generation script, ensuring required icons are created before building.
This commit is contained in:
parent
ee62045416
commit
cfd0849cba
@ -92,6 +92,7 @@
|
|||||||
"build:cloudflare": "cross-env VITE_DEPLOY_TARGET=cloudflare vite build",
|
"build:cloudflare": "cross-env VITE_DEPLOY_TARGET=cloudflare vite build",
|
||||||
"deploy": "npm run build:cloudflare && wrangler pages deploy --branch main",
|
"deploy": "npm run build:cloudflare && wrangler pages deploy --branch main",
|
||||||
"postinstall": "bun scripts/patch-electrobun-src.mjs && bun scripts/build-macos-effects.mjs",
|
"postinstall": "bun scripts/patch-electrobun-src.mjs && bun scripts/build-macos-effects.mjs",
|
||||||
|
"generate-app-icons": "bun scripts/generate-app-icons.mjs",
|
||||||
"build:macos-effects": "bun scripts/build-macos-effects.mjs",
|
"build:macos-effects": "bun scripts/build-macos-effects.mjs",
|
||||||
"clean": "bun scripts/clean-build.mjs"
|
"clean": "bun scripts/clean-build.mjs"
|
||||||
},
|
},
|
||||||
|
|||||||
@ -89,7 +89,7 @@ if ($outputDir -and -not (Test-Path $outputDir)) {
|
|||||||
|
|
||||||
$installerIconPath = Join-Path $rootDir "assets\installer.ico"
|
$installerIconPath = Join-Path $rootDir "assets\installer.ico"
|
||||||
if (-not (Test-Path $installerIconPath)) {
|
if (-not (Test-Path $installerIconPath)) {
|
||||||
throw "Installer icon not found at $installerIconPath. Run scripts/prepare-installer-icons.mjs first."
|
throw "Installer icon not found at $installerIconPath. Run 'bun run generate-app-icons' first."
|
||||||
}
|
}
|
||||||
|
|
||||||
$installerIconWorkPath = Join-Path $workDir "installer.ico"
|
$installerIconWorkPath = Join-Path $workDir "installer.ico"
|
||||||
|
|||||||
@ -211,7 +211,7 @@ function findCommand(command) {
|
|||||||
function buildInstallerIcns(destinationPath) {
|
function buildInstallerIcns(destinationPath) {
|
||||||
if (!existsSync(MAC_INSTALLER_ICONSET_PATH)) {
|
if (!existsSync(MAC_INSTALLER_ICONSET_PATH)) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
`Installer iconset not found at ${MAC_INSTALLER_ICONSET_PATH}. Run scripts/prepare-installer-icons.mjs first.`
|
`Installer iconset not found at ${MAC_INSTALLER_ICONSET_PATH}. Run \`bun run generate-app-icons\` first.`
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
27
scripts/generate-app-icons.mjs
Normal file
27
scripts/generate-app-icons.mjs
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
import path from 'node:path'
|
||||||
|
import { spawnSync } from 'node:child_process'
|
||||||
|
import { fileURLToPath } from 'node:url'
|
||||||
|
|
||||||
|
const rootDir = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..')
|
||||||
|
|
||||||
|
const steps = [
|
||||||
|
[
|
||||||
|
path.join(rootDir, 'scripts/prepare-app-icons.mjs'),
|
||||||
|
'assets/logos/farmcontrolicon.png'
|
||||||
|
],
|
||||||
|
[path.join(rootDir, 'scripts/prepare-installer-icons.mjs')]
|
||||||
|
]
|
||||||
|
|
||||||
|
for (const args of steps) {
|
||||||
|
const result = spawnSync('bun', args, {
|
||||||
|
cwd: rootDir,
|
||||||
|
stdio: 'inherit',
|
||||||
|
env: process.env
|
||||||
|
})
|
||||||
|
|
||||||
|
if (result.status !== 0) {
|
||||||
|
process.exit(result.status ?? 1)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log('generate-app-icons: done')
|
||||||
@ -61,33 +61,31 @@ if (process.platform === "darwin") {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const prepareIcons = spawnSync(
|
const requiredIconPaths = [
|
||||||
"bun",
|
path.join(rootDir, "assets/icon.ico"),
|
||||||
[
|
path.join(rootDir, "assets/icon.png"),
|
||||||
path.join(rootDir, "scripts/prepare-app-icons.mjs"),
|
path.join(rootDir, "assets/icon.iconset/icon_256x256.png"),
|
||||||
"assets/logos/farmcontrolicon.png",
|
path.join(rootDir, "assets/installer.ico"),
|
||||||
],
|
];
|
||||||
{ cwd: rootDir, stdio: "inherit", env: process.env },
|
|
||||||
);
|
|
||||||
|
|
||||||
if (prepareIcons.status !== 0) {
|
if (buildEnv === "stable") {
|
||||||
process.exit(prepareIcons.status ?? 1);
|
const prepareIcons = spawnSync(
|
||||||
|
"bun",
|
||||||
|
[path.join(rootDir, "scripts/generate-app-icons.mjs")],
|
||||||
|
{ cwd: rootDir, stdio: "inherit", env: process.env },
|
||||||
|
);
|
||||||
|
|
||||||
|
if (prepareIcons.status !== 0) {
|
||||||
|
process.exit(prepareIcons.status ?? 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const prepareInstallerIcons = spawnSync(
|
const missingIcons = requiredIconPaths.filter((filePath) => !existsSync(filePath));
|
||||||
"bun",
|
if (missingIcons.length > 0) {
|
||||||
[path.join(rootDir, "scripts/prepare-installer-icons.mjs")],
|
|
||||||
{ cwd: rootDir, stdio: "inherit", env: process.env },
|
|
||||||
);
|
|
||||||
|
|
||||||
if (prepareInstallerIcons.status !== 0) {
|
|
||||||
process.exit(prepareInstallerIcons.status ?? 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
const windowsIconPath = path.join(rootDir, "assets/icon.ico");
|
|
||||||
if (!existsSync(windowsIconPath)) {
|
|
||||||
console.error(
|
console.error(
|
||||||
"pre-build: assets/icon.ico not found after prepare-app-icons (required for build.win.icon)",
|
`pre-build: missing generated icons:\n${missingIcons
|
||||||
|
.map((filePath) => ` - ${path.relative(rootDir, filePath)}`)
|
||||||
|
.join("\n")}\nRun \`bun run generate-app-icons\` to create them.`,
|
||||||
);
|
);
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user