Skip to content

Commit

Permalink
build: add Squirrel.Windows
Browse files Browse the repository at this point in the history
Signed-off-by: Grigorii K. Shartsev <[email protected]>
  • Loading branch information
ShGKme committed Oct 24, 2024
1 parent 93a89e6 commit d5438e0
Show file tree
Hide file tree
Showing 3 changed files with 79 additions and 24 deletions.
84 changes: 67 additions & 17 deletions forge.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,30 @@
const path = require('node:path')
const fs = require('node:fs')
const semver = require('semver')
const packageJSON = require('./package.json')
const { MIN_REQUIRED_BUILT_IN_TALK_VERSION } = require('./src/constants.js')

require('dotenv').config()

const CONFIG = {
// General
applicationName: packageJSON.productName,
applicationNameSanitized: packageJSON.productName.replaceAll(' ', '-'),
companyName: 'Nextcloud GmbH',
description: packageJSON.description,

// macOS
macAppId: 'com.nextcloud.NextcloudTalk',
// Windows
winAppId: 'NextcloudTalk',
}

const YEAR = new Date().getFullYear()

const TALK_PATH = path.resolve(__dirname, process.env.TALK_PATH ?? 'spreed')
let talkPackageJson

module.exports = {
packagerConfig: {
icon: './img/icons/icon',
},

hooks: {
generateAssets() {
if (!fs.existsSync(process.env.TALK_PATH)) {
Expand Down Expand Up @@ -50,23 +62,61 @@ module.exports = {

rebuildConfig: {},

packagerConfig: {
// Common
name: CONFIG.applicationName,
icon: path.join(__dirname, './img/icons/icon'),
appCopyright: `Copyright © ${YEAR} ${CONFIG.companyName}`,
asar: true,

// Windows
win32metadata: {
CompanyName: CONFIG.companyName,
},

// macOS
appBundleId: CONFIG.macAppId,
darwinDarkModeSupport: true,
appCategoryType: 'public.app-category.social-networking', // LSApplicationCategoryType | https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/LaunchServicesKeys.html
},

makers: [
// {
// name: '@electron-forge/maker-squirrel',
// config: {},
// },
{
name: '@electron-forge/maker-squirrel',
platforms: ['win32'],
config: {
// App/Filenames
name: CONFIG.winAppId,
setupExe: `${CONFIG.applicationNameSanitized}-v${packageJSON.version}-win-x64.exe`,
exe: `${CONFIG.applicationName}.exe`,

// Meta
title: CONFIG.applicationName,
authors: CONFIG.companyName,
owners: CONFIG.companyName,
description: CONFIG.description,

// Icons
setupIcon: path.join(__dirname, './img/icons/icon.ico'),
iconUrl: 'https://raw.githubusercontent.com/nextcloud/talk-desktop/refs/heads/main/img/icons/icon.ico',

// Install/Update Loading
loadingGif: path.join(__dirname, './img/squirrel-install-loading.gif'),

// TODO: Check if this is as useful as WIX
// noMsi: false,
// setupMsi: `${CONFIG.applicationNameSanitized}-v${packageJSON.version}-win-x64.msi`,

// TODO: Sign
// certificateFile:
// certificatePassword:
},
},

// Portable, all platforms
{
name: '@electron-forge/maker-zip',
// platforms: ['darwin'],
},
// {
// name: '@electron-forge/maker-deb',
// config: {},
// },
// {
// name: '@electron-forge/maker-rpm',
// config: {},
// },
],

plugins: [
Expand Down
Binary file added img/squirrel-install-loading.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
19 changes: 12 additions & 7 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const { createAuthenticationWindow } = require('./authentication/authentication.
const { openLoginWebView } = require('./authentication/login.window.js')
const { createHelpWindow } = require('./help/help.window.js')
const { createUpgradeWindow } = require('./upgrade/upgrade.window.js')
const { getOs, isLinux, isMac, isWayland } = require('./shared/os.utils.js')
const { getOs, isLinux, isMac, isWayland, isWindows } = require('./shared/os.utils.js')
const { createTalkWindow } = require('./talk/talk.window.js')
const { createWelcomeWindow } = require('./welcome/welcome.window.js')
const { installVueDevtools } = require('./install-vue-devtools.js')
Expand All @@ -33,7 +33,17 @@ const ARGUMENTS = {
const APP_NAME = process.env.NODE_ENV !== 'development' ? path.parse(app.getPath('exe')).name : 'Nextcloud Talk (dev)'
app.setName(APP_NAME)
app.setPath('userData', path.join(app.getPath('appData'), app.getName()))
app.setAppUserModelId(app.getName())
if (isWindows()) {
// TODO: get actual name from the build
app.setAppUserModelId('com.squirrel.NextcloudTalk.NextcloudTalk')
}

/**
* Handle creating/removing shortcuts on Windows when installing/uninstalling
*/
if (require('electron-squirrel-startup')) {
app.quit()
}

/**
* Only one instance is allowed at time
Expand All @@ -49,11 +59,6 @@ if (process.env.NODE_ENV === 'production') {
setupReleaseNotificationScheduler(2 * 60)
}

// Handle creating/removing shortcuts on Windows when installing/uninstalling.
// if (require('electron-squirrel-startup')) {
// app.quit();
// }

ipcMain.on('app:quit', () => app.quit())
ipcMain.handle('app:getOs', () => getOs())
ipcMain.handle('app:getAppName', () => app.getName())
Expand Down

0 comments on commit d5438e0

Please sign in to comment.