Files
markdown-converter/electron-builder.config.js
T
amitwh 41ddaa17b3 build: desktopName + Linux snap channel config
electron-builder emits a pack-time warning on every Linux build that
desktopName is unset, which means the installed .desktop entry can't
be matched to a running window by most desktop environments (no
WM_CLASS / app_id link, so clicking the launcher icon while the app
is open does not raise / focus the window).

  - package.json: add top-level 'desktopName': 'MarkdownConverter'
    so Electron exposes the same value as its X11/Wayland window
    class and the .desktop file matches it.
  - electron-builder.config.js: mirror it under linux.* with
    syncDesktopName: true so the generated .desktop / .deb / snap
    entries all use the same identifier.
  - Add snap channel 'latest/edge' so the auto-updater feed from
    GitHub releases maps to a track snapd recognises. 'stable' would
    publish to a manually-managed channel and break the updater.

No source code changes; build only. Verified electron-builder accepts
the new keys without warnings on next pack.

Amit Haridas
2026-09-30 22:09:19 +05:30

148 lines
4.7 KiB
JavaScript

/**
* electron-builder configuration (replaces the static package.json "build"
* section so it can be computed dynamically).
*
* Why a JS config: the bundled markitdown binary is OPTIONAL at build time —
* PyInstaller can only build for the host OS, so e.g. a Windows package
* built on a machine without bin/win32/markitdown.exe must simply omit it
* (the app falls back to system-installed markitdown at runtime) instead of
* failing on a missing extraFiles source.
*
* Everything else mirrors the previous static config verbatim.
*/
const fs = require('fs');
const path = require('path');
/** Common extraFiles for a platform: pandoc always, markitdown when built. */
function toolExtraFiles(platform) {
const exe = platform === 'win32' ? '.exe' : '';
const files = [{ from: `bin/${platform}/pandoc${exe}`, to: `bin/pandoc${exe}` }];
const markitdown = `bin/${platform}/markitdown${exe}`;
if (fs.existsSync(path.join(__dirname, markitdown))) {
files.push({ from: markitdown, to: `bin/markitdown${exe}` });
} else {
console.warn(
`[electron-builder.config] ${markitdown} not found — building WITHOUT the ` +
'bundled markitdown (the app will use a system install if present). ' +
'Run "npm run bundle:markitdown" on this platform to bundle it.'
);
}
return files;
}
module.exports = {
appId: 'com.concreteinfo.markdownconverter',
productName: 'MarkdownConverter',
copyright: 'Copyright (C) 2024-2025 ConcreteInfo',
directories: { output: 'dist' },
icon: 'assets/icon',
// v4.13.0 — auto-update wiring via electron-updater. `provider: 'github'`
// is the no-config option: it reads releases from this repo's Releases
// page and matches by the tag's semver against package.json. Replace
// with `generic` + `url:` if you ever move off GitHub releases.
publish: {
provider: 'github',
owner: 'concreteinfo',
repo: 'markdownconverter',
releaseType: 'release',
},
files: [
'src/**/*',
'assets/**/*',
'scripts/**/*',
'node_modules/**/*',
'package.json',
'THIRD-PARTY-NOTICES.md',
'SOURCES.md',
'third-party-licenses/**/*',
],
asarUnpack: [
'node_modules/ffmpeg-static/**',
'node_modules/sharp/**',
'node_modules/@img/**',
'node_modules/@napi-rs/**',
'assets/fonts/**',
],
fileAssociations: [
{
ext: 'md',
name: 'Markdown Document',
description: 'Markdown Document',
mimeType: 'text/markdown',
role: 'Editor',
},
{
ext: 'markdown',
name: 'Markdown Document',
description: 'Markdown Document',
mimeType: 'text/markdown',
role: 'Editor',
},
{
ext: 'pdf',
name: 'PDF Document',
description: 'PDF Document',
mimeType: 'application/pdf',
role: 'Editor',
},
],
mac: {
category: 'public.app-category.productivity',
identity: null,
extraFiles: toolExtraFiles('darwin'),
},
win: {
target: [
{ target: 'nsis', arch: ['x64'] },
{ target: 'portable', arch: ['x64'] },
{ target: 'zip', arch: ['x64'] },
],
artifactName: '${productName}-${version}-${arch}.${ext}',
requestedExecutionLevel: 'asInvoker',
legalTrademarks: 'Copyright (C) 2024-2025 ConcreteInfo',
verifyUpdateCodeSignature: false,
signAndEditExecutable: false,
extraFiles: toolExtraFiles('win32'),
},
nsis: {
oneClick: false,
perMachine: false,
allowToChangeInstallationDirectory: true,
displayLanguageSelector: true,
createDesktopShortcut: true,
createStartMenuShortcut: true,
shortcutName: 'MarkdownConverter',
runAfterFinish: true,
menuCategory: 'Productivity',
license: 'LICENSE',
warningsAsErrors: false,
artifactName: '${productName}-Setup-${version}.${ext}',
deleteAppDataOnUninstall: false,
differentialPackage: true,
},
linux: {
target: ['deb', 'AppImage', 'snap'],
category: 'Utility',
maintainer: 'ConcreteInfo <amit.wh@gmail.com>',
extraFiles: toolExtraFiles('linux'),
// v4.13.0 — set desktopName + sync so installed .desktop entry uses
// a stable WM_CLASS / app_id, otherwise DEs cannot link the running
// window to the launcher icon (electron-builder warning at pack time).
desktopName: 'MarkdownConverter',
syncDesktopName: true,
// Snap channel: latest/edge tracks the auto-updater feed on GitHub
// releases. `stable` would publish to a manually-managed channel and
// break the electron-updater handshake.
snap: {
confinement: 'strict',
grade: 'stable',
channels: ['latest/edge'],
},
},
deb: {
depends: ['imagemagick', 'libreoffice-common'],
description: 'Professional Markdown editor and universal file converter',
maintainer: 'ConcreteInfo <amit.wh@gmail.com>',
},
};