2025-05-11 20:33:07 +02:00

146 lines
6.2 KiB
JavaScript

require("v8-compile-cache")
const path = require("node:path")
const builder = require("electron-builder")
function getMonthName(monthIndex) {
const monthNames = [
"Janvier", "Février", "Mars", "Avril", "Mai", "Juin",
"Juillet", "Août", "Septembre", "Octobre", "Novembre", "Décembre"
]
return monthNames[monthIndex]
}
function getFormattedProductionDate() {
const now = new Date()
const day = now.getDate()
const month = getMonthName(now.getMonth())
const year = now.getFullYear()
const hours = now.getHours().toString().padStart(2, "0")
const minutes = now.getMinutes().toString().padStart(2, "0")
return `${day} ${month} ${year}, ${hours}:${minutes}`
}
async function buildApp() {
const package = require("./package.json")
try {
const build = await builder.build({
config: {
copyright: "TheAlfiteam",
productName: "CatBoat Launcher",
directories: {
output: "dist",
buildResources: path.join(__dirname, "build")
},
files: [
"!encryptNewFile.js",
"!.gitignore",
"!.github/**",
"!README.md",
"!.git/**",
"!test.js",
"!build.js",
"!dist",
"!.env"
],
buildNumber: 2,
buildVersion: `${package.version}`,
releaseInfo: {
releaseDate: getFormattedProductionDate(),
releaseName: "CatBoat Launcher",
vendor: "TheAfliteam, Azures04"
},
asar: true,
win: {
icon: path.join(__dirname, "build", "icon.png"),
target: ["nsis", "msi", "portable"],
artifactName: "${productName}-setup-%version%.${ext}".replace("%version%", package.version),
releaseInfo: {
releaseDate: getFormattedProductionDate(),
vendor: "TheAfliteam, Azures04"
}
},
msi: {
createDesktopShortcut: "always",
oneClick: false,
perMachine: false,
artifactName: "${productName}-setup-%version%.${ext}".replace("%version%", package.version)
},
portable: {
useZip: true,
splashImage: path.join(__dirname, "build", "icon.png"),
requestExecutionLevel: "user",
artifactName: "${productName}-%version%.${ext}".replace("%version%", package.version)
},
nsis: {
perMachine: false,
allowToChangeInstallationDirectory: true,
oneClick: false,
createDesktopShortcut: "always",
createStartMenuShortcut: true,
deleteAppDataOnUninstall: true,
license: path.join(__dirname, "build", "LICENSE"),
installerIcon: path.join(__dirname, "build", "icon.ico"),
uninstallerIcon: path.join(__dirname, "build", "icon.ico"),
installerHeaderIcon: path.join(__dirname, "build", "icon.ico"),
artifactName: "${productName}-setup-%version%.${ext}".replace("%version%", package.version),
},
appx: {
identityName: "catboat_launcher",
applicationId: "catboat_launcher",
publisherDisplayName: "TheAfliteam, Azures04",
displayName: "CatBoat Launcher",
artifactName: "${productName}-%version%.${ext}".replace("%version%", package.version),
},
mac: {
target: ["dmg", "pkg", "zip"],
type: "distribution",
releaseInfo: {
releaseDate: getFormattedProductionDate(),
vendor: "TheAfliteam, Azures04"
},
artifactName: "${productName}-setup-%version%.${ext}".replace("%version%", package.version)
},
dmg: {
background: path.join(__dirname, "build", "background.png"),
title: "CatBoat Launcher Installer",
writeUpdateInfo: true,
artifactName: "${productName}-setup-%version%.${ext}".replace("%version%", package.version)
},
appImage: {
artifactName: "${productName}-setup-%version%.${ext}".replace("%version%", package.version),
license: path.join(__dirname, "build", "LICENSE")
},
linux: {
target: ["AppImage", "deb", "rpm"],
maintainer: "https://gitea.azures.fr/azures04/",
releaseInfo: {
releaseDate: getFormattedProductionDate(),
vendor: "TheAfliteam, Azures04"
},
artifactName: "${productName}-setup-%version%.${ext}".replace("%version%", package.version),
},
deb: {
packageName: "catboat_launcher",
vendor: "TheAfliteam, Azures04",
maintainer: "https://gitea.azures.fr/azures04/",
icon: path.join(__dirname, "build", "icon.png"),
artifactName: "${productName}-setup-%version%.${ext}".replace("%version%", package.version),
},
pkg: {
allowAnywhere: true,
allowCurrentUserHome: true,
allowRootDirectory: true,
isRelocatable: true,
artifactName: "${productName}-setup-%version%.${ext}".replace("%version%", package.version),
}
},
publish: typeof githubToken !== "undefined" ? "always" : "never",
})
console.log(build)
} catch (error) {
console.log(error)
}
}
buildApp()