Skip to content

0.1.0-beta.6

Pre-release
Pre-release

Choose a tag to compare

@WillTDA WillTDA released this 03 Oct 19:24
· 61 commits to master since this release
1b53c8e

@diamonddigitaldev/electron-kit | Beta Preview (v0.1.0-beta.6)

Important

A beta: the API can still change between 0.x versions. It's published under npm's next tag.

The installer asks before it claims a file type or adds a right-click entry, and asks who it's for. On Linux, an app is in Open With for the files it opens, and the dock knows its window. An app on 0.1.0-beta.5 runs on it without a change, but its build config should move to the kit's config() to get either: see below.

npm install @diamonddigitaldev/electron-kit@next

New

  • config(), from @diamonddigitaldev/electron-kit/builder: an app's whole electron-builder config, on the kit's base, from its own options, the files it opens and its right-click entry. It goes in electron-builder.cjs, beside package.json, and package.json's build goes (electron-builder would read it first). .cjs, never .js: on Windows, electron-builder typed in a folder holding electron-builder.js runs that file with Windows Script Host instead.
const { config } = require("@diamonddigitaldev/electron-kit/builder");

module.exports = config(require("./package.json"), {
    build: { appId, productName, publish, win, linux: { icon, category: "AudioVideo" }, nsis, ... },
    fileTypes: [{ name: "Audio File", ext: ["mp3", "wav"] }, { name: "Video File", ext: ["mp4"] }],
    contextMenu: { label: "Convert with App", folders: true },
});
  • The asking installer (Windows). It asks who it's for: "Only for me" by default, with no administrator prompt, or everyone. An install for everyone already there is upgraded in place, never joined by a second copy. Then a box for each file type, in the app's groups, all ticked, and one for the right-click entry. A ticked type puts the app in Open With and in Settings > Apps > Default apps, and becomes the default only where no app has been chosen; an unticked one gets nothing. The choices are kept, so an update never adds back what was unticked. Uninstalling takes away everything the installer added. Silently, /FILETYPES=all, none or a list, and /NOCONTEXTMENU.
  • Linux's desktop entry. The .desktop file lists the file types' MIME types, so the app is in the file manager's Open With, and gets every selected file. It's named for the app's appId, which Electron gives the running window, so the dock shows the app's own icon. allFiles: true, for an app that takes any file, puts it in Open With for every file.
  • assertBuildExtendsKit() takes the config itself: assertBuildExtendsKit(require("../electron-builder.cjs")).

Changed

  • config() never sets electron-builder's fileAssociations, which claim every type on Windows without asking, and refuses them, with an app's own nsis.include (its installer.nsh), perMachine and oneClick: the kit's installer asks instead. build.linux.category is needed.

Docs

  • Building: config(), the asking installer, the files an app opens on Linux, and the .deb and .rpm updating themselves (after a password prompt).
  • Getting Started and Testing an App: the builder export, and the build config's check.

The docs are in the repository: start at docs/README.md.

Found something wrong? Open an issue.