Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/update-built-in-talk.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,13 @@ jobs:
- name: Set up npm ${{ steps.versions.outputs.npmVersion }}
run: npm i -g 'npm@${{ steps.versions.outputs.npmVersion }}'

- name: Run update-built-in-talk.mjs
- name: Run update-built-in-talk.js
id: update
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
# Execute the script and capture the output
stdout=$(npx -y zx ./scripts/update-built-in-talk.mjs)
stdout=$(npx -y zx ./scripts/update-built-in-talk.js)
# Pass the result to the next steps
echo "stdout<<EOF" >> $GITHUB_OUTPUT
echo "$stdout" >> $GITHUB_OUTPUT
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,8 @@ npm run generate-icons
Talk frontend depends on the global Nextcloud server styles. To manually get them run:

```bah
# node ./scripts/fetch-server-styles.mjs <VERSION>, for example
node ./scripts/fetch-server-styles.mjs stable29
# node ./scripts/fetch-server-styles.js <VERSION>, for example
node ./scripts/fetch-server-styles.js stable29
```

## 📦 Packaging distributions
Expand Down
8 changes: 2 additions & 6 deletions build/UUIDv5.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* SPDX-License-Identifier: AGPL-3.0-or-later
*/

const crypto = require('node:crypto')
import crypto from 'node:crypto'

const DNS_NAMESPACE = '6ba7b810-9dad-11d1-80b4-00c04fd430c8'

Expand All @@ -14,7 +14,7 @@ const DNS_NAMESPACE = '6ba7b810-9dad-11d1-80b4-00c04fd430c8'
* @param {string} namespace - Namespace UUID (e.g., '6ba7b810-9dad-11d1-80b4-00c04fd430c8')
* @return {string} UUIDv5
*/
function UUIDv5(name, namespace = DNS_NAMESPACE) {
export function UUIDv5(name, namespace = DNS_NAMESPACE) {
const namespaceBytes = Buffer.from(namespace.replace(/-/g, ''), 'hex')

const hash = crypto.createHash('sha1')
Expand All @@ -37,7 +37,3 @@ function UUIDv5(name, namespace = DNS_NAMESPACE) {
hex.slice(20, 32),
].join('-')
}

module.exports = {
UUIDv5,
}
16 changes: 5 additions & 11 deletions build/appinfo.utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
* SPDX-License-Identifier: AGPL-3.0-or-later
*/

const { readFileSync } = require('node:fs')
const { join } = require('node:path')
import { readFileSync } from 'node:fs'
import { join } from 'node:path'

/**
* @typedef {object} AppInfo
* @property {number} minVersion

Check warning on line 11 in build/appinfo.utils.js

View workflow job for this annotation

GitHub Actions / NPM lint

Missing JSDoc @Property "minVersion" description
* @property {number} maxVersion

Check warning on line 12 in build/appinfo.utils.js

View workflow job for this annotation

GitHub Actions / NPM lint

Missing JSDoc @Property "maxVersion" description
*/

/**
Expand All @@ -18,7 +18,7 @@
* @param {string} dir - path to the app directory
* @return {string} - the content of the file
*/
function readAppInfoContent(dir) {
export function readAppInfoContent(dir) {
return readFileSync(join(dir, 'appinfo/info.xml'), 'utf-8')
}

Expand All @@ -28,7 +28,7 @@
* @param {string} content - the content of the appinfo/info.xml file
* @return {AppInfo|null} - the parsed app info object
*/
function parseAppInfo(content) {
export function parseAppInfo(content) {
const versionsRE = /<nextcloud\s+min-version="(\d+)"\s+max-version="(\d+)"\s*\/>/im
const versions = content.match(versionsRE)

Expand All @@ -48,13 +48,7 @@
* @param {string} dir - The directory of the app with appinfo
* @return {AppInfo|null} - The app info object
*/
function getAppInfo(dir) {
export function getAppInfo(dir) {
const content = readAppInfoContent(dir)
return parseAppInfo(content)
}

module.exports = {
readAppInfoContent,
parseAppInfo,
getAppInfo,
}
40 changes: 16 additions & 24 deletions build/resolveBuildConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
* SPDX-License-Identifier: AGPL-3.0-or-later
*/

const { existsSync, readFileSync } = require('node:fs')
const { join, resolve } = require('node:path')
const { getAppInfo } = require('./appinfo.utils.js')
const buildConfigDefaults = require('./build.config.json')
const { UUIDv5 } = require('./UUIDv5.js')
import { existsSync, readFileSync } from 'node:fs'
import { join, resolve } from 'node:path'
import { getAppInfo } from './appinfo.utils.js'
import buildConfigDefaults from './build.config.json' with { type: 'json' }
import { UUIDv5 } from './UUIDv5.js'

// DO NOT CHANGE
const TALK_DESKTOP_UUID = '007a0d7d-9595-41d2-b5aa-740a5a63e38a'
Expand All @@ -17,8 +17,8 @@ const TALK_DESKTOP_UUID = '007a0d7d-9595-41d2-b5aa-740a5a63e38a'
*
* @return {import('./BuildConfig.types.ts').BuildConfig} - Resolved configuration object
*/
function resolveBuildConfig() {
const buildConfigOverridesPath = join(__dirname, '../.overrides/build.config.json')
export function resolveBuildConfig() {
const buildConfigOverridesPath = join(import.meta.dirname, '../.overrides/build.config.json')

const isBranded = existsSync(buildConfigOverridesPath)

Expand Down Expand Up @@ -75,14 +75,14 @@ function resolveBuildConfig() {
/**
* Resolve path to the build-in Talk
*/
function resolveTalkPath() {
return process.env.TALK_PATH ? resolve(process.env.TALK_PATH) : resolve(__dirname, '../spreed')
export function resolveTalkPath() {
return process.env.TALK_PATH ? resolve(process.env.TALK_PATH) : resolve(import.meta.dirname, '../spreed')
}

/**
* Get the built-in Talk's Nextcloud version
*/
function getNextcloudVersionForTalk() {
export function getNextcloudVersionForTalk() {
return getAppInfo(resolveTalkPath()).maxVersion
}

Expand Down Expand Up @@ -110,11 +110,11 @@ function tryGetNextcloudStyles(directory, version) {
*
* @param {string} version - Nextcloud major version (e.g. 34)
*/
function getNextcloudStyles(version = getNextcloudVersionForTalk()) {
export function getNextcloudStyles(version = getNextcloudVersionForTalk()) {
const BUILD_CONFIG = resolveBuildConfig()

const base = tryGetNextcloudStyles(join(__dirname, '../resources/server-global-styles'), version)
const overrides = tryGetNextcloudStyles(join(__dirname, '../.overrides/styles'), version)
const base = tryGetNextcloudStyles(join(import.meta.dirname, '../resources/server-global-styles'), version)
const overrides = tryGetNextcloudStyles(join(import.meta.dirname, '../.overrides/styles'), version)

if (!base) {
throw new Error(`Nextcloud ${version} is not supported: no styles found`)
Expand All @@ -138,26 +138,18 @@ function getNextcloudStyles(version = getNextcloudVersionForTalk()) {
*
* @param {string} version - Nextcloud major version (e.g. 34)
*/
function resolveNextcloudStylesPath(version = getNextcloudVersionForTalk()) {
export function resolveNextcloudStylesPath(version = getNextcloudVersionForTalk()) {
const styles = getNextcloudStyles(version)

if (!styles.overrides && styles.overridesRequired) {
throw new Error(`Nextcloud ${version} styles overrides are missing. `
+ `If you are testing the build locally, run "node scripts/override-nextcloud-styles.mjs --version ${version}".`)
+ `If you are testing the build locally, run "node scripts/override-nextcloud-styles.js --version ${version}".`)
}

if (styles.overrides && !styles.overridesUpToDate) {
throw new Error(`Nextcloud ${version} styles overrides are not up-to-date with the current styles version or the build configuration. `
+ `If you are testing the build locally, run "node scripts/override-nextcloud-styles.mjs --version ${version}".`)
+ `If you are testing the build locally, run "node scripts/override-nextcloud-styles.js --version ${version}".`)
}

return styles.overrides?.path ?? styles.base.path
}

module.exports = {
resolveBuildConfig,
resolveTalkPath,
getNextcloudVersionForTalk,
getNextcloudStyles,
resolveNextcloudStylesPath,
}
2 changes: 1 addition & 1 deletion eslint.config.mjs → eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export default [
},
{
name: 'talk-desktop/rules/zx-scripts',
files: ['scripts/**/*.mjs'],
files: ['scripts/**/*.js'],
rules: {
// Let TypeScript handle undefined variables instead of ESLint
'no-undef': 'off',
Expand Down
55 changes: 29 additions & 26 deletions forge.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,24 @@
* SPDX-License-Identifier: AGPL-3.0-or-later
*/

const { MakerDMG } = require('@electron-forge/maker-dmg')
const { MakerFlatpak } = require('@electron-forge/maker-flatpak')
const { MakerSquirrel } = require('@electron-forge/maker-squirrel')
const { MakerWix } = require('@electron-forge/maker-wix')
const { MakerZIP } = require('@electron-forge/maker-zip')
const cheerio = require('cheerio')
const mri = require('mri')
const fs = require('node:fs')
const path = require('node:path')
const semver = require('semver')
const { resolveBuildConfig, resolveTalkPath } = require('./build/resolveBuildConfig.js')
const packageJSON = require('./package.json')
const { MIN_REQUIRED_BUILT_IN_TALK_VERSION } = require('./src/constants.js')

require('dotenv').config()
import { MakerDMG } from '@electron-forge/maker-dmg'
import { MakerFlatpak } from '@electron-forge/maker-flatpak'
import { MakerSquirrel } from '@electron-forge/maker-squirrel'
import { MakerWix } from '@electron-forge/maker-wix'
import { MakerZIP } from '@electron-forge/maker-zip'
import * as cheerio from 'cheerio'
import mri from 'mri'
import fs from 'node:fs'
import { createRequire } from 'node:module'
import path from 'node:path'
import semver from 'semver'
import { resolveBuildConfig, resolveTalkPath } from './build/resolveBuildConfig.js'
import packageJSON from './package.json' with { type: 'json' }
import { MIN_REQUIRED_BUILT_IN_TALK_VERSION } from './src/constants.js'

import 'dotenv/config'

const require = createRequire(import.meta.url)

const SUPPORTED_ARCHS = ['x64', 'arm64', 'universal']
const argArch = mri(process.argv).arch
Expand Down Expand Up @@ -147,7 +150,7 @@ const hasWindowsSign = !!process.env.WINDOWS_SIGN_PARAMS

let talkPackageJson

module.exports = {
export default {
hooks: {
generateAssets() {
if (!fs.existsSync(TALK_PATH)) {
Expand Down Expand Up @@ -205,7 +208,7 @@ module.exports = {
packagerConfig: {
// Common
name: BUILD_CONFIG.applicationName,
icon: path.join(__dirname, './img/icons/icon'),
icon: path.join(import.meta.dirname, './img/icons/icon'),
appCopyright: BUILD_CONFIG.copyright,
asar: true,

Expand All @@ -219,7 +222,7 @@ module.exports = {
darwinDarkModeSupport: true,
// https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/LaunchServicesKeys.html#//apple_ref/doc/uid/TP40009250-SW8
appCategoryType: 'public.app-category.business',
extendInfo: path.join(__dirname, './resources/macos/entitlements.plist'),
extendInfo: path.join(import.meta.dirname, './resources/macos/entitlements.plist'),
osxSign: hasMacosSign && {},
osxNotarize: hasMacosSign && {
appleId: process.env.APPLE_ID,
Expand All @@ -240,7 +243,7 @@ module.exports = {
description: BUILD_CONFIG.description,
exe: `${BUILD_CONFIG.applicationName}.exe`,
name: BUILD_CONFIG.applicationName,
icon: path.join(__dirname, 'img/icons/icon.ico'),
icon: path.join(import.meta.dirname, 'img/icons/icon.ico'),
manufacturer: BUILD_CONFIG.companyName,
shortName: BUILD_CONFIG.applicationNameSanitized,
upgradeCode: BUILD_CONFIG.winUpgradeCode,
Expand All @@ -252,8 +255,8 @@ module.exports = {
version: packageJSON.version,
ui: {
images: {
background: path.join(__dirname, 'img/wix-background.bmp'),
banner: path.join(__dirname, 'img/wix-banner.bmp'),
background: path.join(import.meta.dirname, 'img/wix-background.bmp'),
banner: path.join(import.meta.dirname, 'img/wix-banner.bmp'),
},
},
windowsSign: hasWindowsSign && signWithParamsToWindowsSignOptions(process.env.WINDOWS_SIGN_PARAMS),
Expand Down Expand Up @@ -320,20 +323,20 @@ module.exports = {
description: BUILD_CONFIG.description,

// Icons
setupIcon: path.join(__dirname, './img/icons/icon.ico'),
setupIcon: path.join(import.meta.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'),
loadingGif: path.join(import.meta.dirname, './img/squirrel-install-loading.gif'),

// Signing
signWithParams: hasWindowsSign && process.env.WINDOWS_SIGN_PARAMS,
}),

// https://js.electronforge.io/interfaces/_electron_forge_maker_dmg.MakerDMGConfig.html
BUILD_CONFIG.macosDmg && new MakerDMG({
icon: path.join(__dirname, 'img/icons/icon.icns'),
background: path.join(__dirname, 'img/dmg-background.png'),
icon: path.join(import.meta.dirname, 'img/icons/icon.icns'),
background: path.join(import.meta.dirname, 'img/dmg-background.png'),
// https://github.com/LinusU/node-appdmg?tab=readme-ov-file#specification
additionalDMGOptions: {
// Background does not work when the title has spaces or special characters
Expand All @@ -355,7 +358,7 @@ module.exports = {
branch: 'stable',
// https://specifications.freedesktop.org/icon-theme-spec/latest/
icon: {
scalable: path.resolve(__dirname, 'img/talk-icon-rounded-spaced.svg'),
scalable: path.resolve(import.meta.dirname, 'img/talk-icon-rounded-spaced.svg'),
},
// https://specifications.freedesktop.org/menu-spec/latest/category-registry.html
categories: [
Expand Down
Loading
Loading