Improve app and add more install options (and fix old .dmg files)
This commit is contained in:
104
build/build-app.js
Normal file
104
build/build-app.js
Normal file
@@ -0,0 +1,104 @@
|
||||
const path = require('path');
|
||||
const process = require('process');
|
||||
const builder = require('electron-builder');
|
||||
const { Platform, Arch } = builder;
|
||||
|
||||
// Parse command-line arguments
|
||||
const supportedPlatforms = ['win', 'mac', 'linux'];
|
||||
const supportedArchitectures = ['x64', 'armv7l', 'arm64', 'ia32', 'universal'];
|
||||
const args = process.argv.slice(2);
|
||||
const carch = args.includes('--arch') ? args[args.indexOf('--arch') + 1] : null;
|
||||
const cplatform = args.includes('--platform') ? args[args.indexOf('--platform') + 1] : null;
|
||||
const pack = args.includes('--pack'); // Keep track of --pack as a boolean flag
|
||||
|
||||
// Determine platform
|
||||
let platform;
|
||||
if (!cplatform) {
|
||||
platform = process.platform === 'win32' ? 'win' :
|
||||
process.platform === 'darwin' ? 'mac' :
|
||||
process.platform === 'linux' ? 'linux' : null;
|
||||
} else if (!supportedPlatforms.includes(cplatform)) {
|
||||
console.error(`Invalid platform specified. Supported platforms: ${supportedPlatforms.join(', ')}`);
|
||||
process.exit(1);
|
||||
} else {
|
||||
platform = cplatform;
|
||||
}
|
||||
|
||||
// Determine architecture
|
||||
let arch = carch || (process.arch === 'arm' ? 'armv7l' : process.arch);
|
||||
if (!supportedArchitectures.includes(arch)) {
|
||||
console.error(`Invalid architecture specified. Supported architectures: ${supportedArchitectures.join(', ')}`);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
// Map platform and architecture to electron-builder enums
|
||||
const platformEnum = {
|
||||
win: Platform.WINDOWS,
|
||||
mac: Platform.MAC,
|
||||
linux: Platform.LINUX
|
||||
}[platform];
|
||||
|
||||
const archEnum = {
|
||||
x64: Arch.x64,
|
||||
armv7l: Arch.armv7l,
|
||||
arm64: Arch.arm64,
|
||||
ia32: Arch.ia32,
|
||||
universal: Arch.universal
|
||||
}[arch];
|
||||
|
||||
// Additional build arguments: (starting with --eb-)
|
||||
const buildArgs = args.filter((arg) => arg.startsWith('--eb-'));
|
||||
|
||||
// If additional args are present, add them to the buildArgs array
|
||||
if (buildArgs.length > 0) {
|
||||
console.log('Additional build arguments:', buildArgs);
|
||||
}
|
||||
|
||||
// If pack is true, add --dir to buildArgs
|
||||
if (pack) {
|
||||
buildArgs.push('--dir');
|
||||
}
|
||||
|
||||
// Read build-config.json
|
||||
const buildConfigPath = path.join(__dirname, 'build-config.json');
|
||||
let buildConfig;
|
||||
try {
|
||||
buildConfig = require(buildConfigPath);
|
||||
} catch (err) {
|
||||
console.error(`Failed to read build-config.json: ${err.message}`);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
// Generate artifact name
|
||||
const packageJson = require('../package.json');
|
||||
const artifactName = `${buildConfig.productName}-${packageJson.version}-${platform}-${arch}.\${ext}`;
|
||||
|
||||
// Electron Builder configuration
|
||||
/**
|
||||
* @type {import('electron-builder').Configuration}
|
||||
*/
|
||||
const options = {
|
||||
artifactName,
|
||||
nsis: {
|
||||
deleteAppDataOnUninstall: true,
|
||||
oneClick: true,
|
||||
perMachine: false
|
||||
},
|
||||
dmg: {
|
||||
contents: [
|
||||
{ type: 'file', x: 255, y: 85 },
|
||||
{ type: 'link', path: '/Applications', x: 253, y: 325 }
|
||||
]
|
||||
},
|
||||
...buildConfig
|
||||
};
|
||||
|
||||
// Build process
|
||||
builder.build({
|
||||
targets: platformEnum.createTarget(null, archEnum),
|
||||
config: options
|
||||
}).then(result => {
|
||||
console.log("Build completed:", JSON.stringify(result, null, 2));
|
||||
}).catch(error => {
|
||||
console.error("Build failed:", error);
|
||||
});
|
||||
55
build/build-config.json
Normal file
55
build/build-config.json
Normal file
@@ -0,0 +1,55 @@
|
||||
{
|
||||
"appId": "com.oxmc.bskyDesktop",
|
||||
"productName": "bskyDesktop",
|
||||
"asarUnpack": [
|
||||
"./node_modules/node-notifier/**/*"
|
||||
],
|
||||
"removePackageScripts": true,
|
||||
"mac": {
|
||||
"target": [
|
||||
"dmg",
|
||||
"pkg",
|
||||
"zip"
|
||||
],
|
||||
"icon": "src/ui/images/mac.icns",
|
||||
"category": "Network"
|
||||
},
|
||||
"pkg": {
|
||||
"installLocation": "/Applications",
|
||||
"allowAnywhere": true,
|
||||
"allowCurrentUserHome": true,
|
||||
"allowRootDirectory": true,
|
||||
"isVersionChecked": true,
|
||||
"isRelocatable": false,
|
||||
"overwriteAction": "upgrade"
|
||||
},
|
||||
"linux": {
|
||||
"target": [
|
||||
"appimage",
|
||||
"deb",
|
||||
"zip"
|
||||
],
|
||||
"icon": "src/ui/images/icons",
|
||||
"category": "Network"
|
||||
},
|
||||
"win": {
|
||||
"target": [
|
||||
"nsis",
|
||||
"appx",
|
||||
"msi",
|
||||
"zip"
|
||||
],
|
||||
"icon": "src/ui/images/logo.ico"
|
||||
},
|
||||
"appx": {
|
||||
"identityName": "BskyDesktop"
|
||||
},
|
||||
"protocols": [
|
||||
{
|
||||
"name": "bsky",
|
||||
"schemes": [
|
||||
"bsky"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user