Files
markdown-converter/electron-builder.config.js
T
Amit Haridas 47315add80 feat(updater): electron-updater wiring + IPC bridge
electron-updater integration so users get fixes automatically:
  - new dependency electron-updater@^6.6.2 in package.json
  - electron-builder.config.js publishes to GitHub releases
    (owner: concreteinfo, repo: markdownconverter)
  - new src/main/auto-updater.js wraps autoUpdater: wires the six
    lifecycle events to a 'updates:status' IPC channel, exposes
    check() and install() helpers, dev-gates via isDev(), and
    swallows the 'missing app-update.yml' error that dev runs hit
  - main.js: ensureAutoUpdater() forwards status to the renderer
    via mainWindow.webContents.send; ipcMain handlers for
    'updates:check' (invoke) and 'updates:install' (invoke)
  - preload.js: 'updates:check' / 'updates:install' added to
    ALLOWED_SEND_CHANNELS; 'updates:status' added to receive
    channels; electronAPI.updates.{check, install, onStatus}
    exposed

7 new tests cover event registration, dev-gate behaviour,
'not-available' fallback for missing app-update.yml, typed event
payloads, error forwarding, and install() quitAndInstall.

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

135 lines
4.2 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'),
},
deb: {
depends: ['imagemagick', 'libreoffice-common'],
description: 'Professional Markdown editor and universal file converter',
maintainer: 'ConcreteInfo <amit.wh@gmail.com>',
},
};