Skip to content

itw-creative-works/electron-manager

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

61 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Electron Manager β€” all-in-one development framework for Electron apps. Sister project to Browser Extension Manager and Ultimate Jekyll Manager.

What it does

  • One-line bootstrap per Electron process: require('electron-manager/main'), /preload, /renderer.
  • Modular feature library β€” storage, IPC, tray, menu, context menu, window manager, startup, app-state, deep-link, auto-updater, web-manager auth, Sentry, analytics, context, usage, remote-config, restart-manager. Each feature is its own module with documented API.
  • Cross-platform analytics identity. GA4 Measurement Protocol with client_id = uuidv5(deviceId, projectIdNamespace) and user_id = uuidv5(firebaseUid, projectIdNamespace). Same Firebase project ID in BEM/UJM/web-manager/EM produces identical user_id outputs everywhere β†’ unified events for one human across desktop + web + backend, no manual stitching.
  • "Hot config" fetched from your brand site (<brand.url>/data/resources/main.json) and polled hourly β€” flip a force-update version, default user-agent, ad rotation, etc. without re-releasing. manager.remoteConfig.get('versionRequired'). Cached to storage so offline boots still have last-known values.
  • File-based feature definitions β€” trays, menus, and context-menus are JS files (full power, no DSL): src/integrations/{tray,menu,context-menu}/index.js. All three ship sensible id-tagged defaults (legacy-EM-style: about, preferences, check-for-updates, dev menu w/ inspector + log folders, etc.) and share the same id-path mutation API: find, update, remove, enable, show, hide, insertBefore, insertAfter, appendTo. Any default item is one line away from removal, customization, or repositioning.
  • Lazy windows + Discord-style hide-on-close. EM doesn't auto-create any windows β€” your main.js calls windows.create('main', { show: !startup.isLaunchHidden() }). The main window's X button hides instead of quitting on every platform; real quit only via Cmd+Q / menu Quit / tray Quit / auto-update install. Inset titlebar by default (mac hiddenInset traffic lights / win native overlay buttons / linux native frame) with a draggable topbar in the page template.
  • Zero-bounce hidden-launch on macOS. startup.mode = 'hidden' bakes LSUIElement: true into Info.plist at build time β†’ app launches completely invisible (no dock icon, no Cmd+Tab, no taskbar). Tray + notifications + networking still work. When the user double-clicks the running app's icon, EM's app.on('activate') (macOS) / app.on('second-instance') (win/linux) handler surfaces the main window and the dock icon appears alongside it. CleanMyMac-style "tray-only at login, full window when manually opened" is the default.
  • Auto-update background install. When a download finishes from a background poll (not user-initiated), EM auto-relaunches into the new version after 5s β€” apps update overnight without bothering the user. User-initiated checks skip this so your UI can prompt instead.
  • Webpack-bundled main / preload / renderer for source protection.
  • Built-in test framework β€” Jest-like syntax, four layers: build (plain Node), main (spawned Electron), renderer (hidden BrowserWindow), and boot (spawns the consumer's actual built dist/main.bundle.js for end-to-end smoke tests against the live manager β€” no npm start && sleep && kill shell hacks). Boot layer always rebuilds the bundle first so tests never see stale code.
  • Schema-validated config. Every field in config/electron-manager.json is declared in a canonical schema. Validation runs at app boot AND during gulp audit β€” a misconfigured app never reaches the "white window of confusion" stage; it tells you exactly which field is broken with a numbered list. Simple flag model β€” required: true | false | (config) => bool β€” and match / enum / type only fire on field presence so consumers never see a flood of redundant errors for the same field. Pure-JS validator, no Ajv/Joi/Zod dep. See config-schema.
  • Multi-platform build/release via GitHub Actions β€” macOS sign + notarize, Linux (deb + AppImage + optional Snap), Windows EV-token signing (self-hosted runner now, cloud-signing pluggable). Sensible installer defaults out of the box: NSIS one-click install on Windows (desktop + start menu shortcut, launch on finish), universal mac binary (one .dmg for Intel + Apple Silicon), app.category automatically mapped to per-platform values, copyright {YEAR} token always current. Snap Store publishing is on by default in the scaffold and auto-skipped at build time when SNAPCRAFT_STORE_CREDENTIALS isn't set β€” drop the credential blob into .env, run mgr push-secrets, and the next release ships to the Snap Store. See installer-options.

Quick start (consumer)

EM auto-syncs your system Node version to match whatever Node Electron's bundled runtime ships with. npx mgr setup queries the official Electron releases feed using your installed Electron version, then writes the corresponding Node major to .nvmrc. Run nvm use afterward to switch your shell.

npm install electron-manager --save-dev
npx mgr setup            # scaffolds project; auto-resolves & writes correct .nvmrc from electron version
nvm use                  # switch to the Node version Electron uses (one-time per shell)
npm start                # dev: gulp β†’ webpack β†’ electron .
npm run build            # local production build (bundles only, no installer)
npm run package:quick    # fast packaged build for host platform/arch (.app/.exe-folder/linux-unpacked, ~20-30s) β€” for smoke-testing packaged behavior
npm run package          # full local production package (DMG/zip/universal-mac, NSIS-win, deb+AppImage-linux)
npm run release          # signed + published release via GitHub Actions
npx mgr test             # run framework + project test suites

Icons

Convention-only. Drop PNGs at:

config/icons/
  global/             ← used by any platform with no platform-specific override
    icon.png
    tray.png
  macos/              ← macOS overrides (beats global)
    icon.png
    tray.png          ← 32Γ—32 β€” EM renames to trayTemplate.png in dist for OS dark-mode magic
    dmg.png           ← 1080Γ—760 DMG background
  windows/            ← Windows overrides
    icon.png
    tray.png
  linux/              ← Linux overrides (otherwise falls back to global β†’ windows)
    icon.png
    tray.png

Resolution per slot/platform (most specific wins): <platform>/<slot> β†’ global/<slot> β†’ (Linux only) windows/<slot> β†’ EM bundled default. Tray missing falls back to app icon.

Ship native (@2x) size only β€” EM downscales the @1x sibling automatically. macOS tray must be 32Γ—32; macOS DMG must be 1080Γ—760. EM emits both <slot>.png and <slot>@2x.png into dist/config/icons/<platform>/. No app.icons config block β€” files are the source of truth.

Logs

Three logs in <projectRoot>/logs/, each with its own purpose:

File What Lifetime
runtime.log Your packaged app's runtime β€” main + preload + renderer all converge here via electron-log Persistent, rotates at 10 MB
dev.log Gulp pipeline output β€” sass, webpack, html, electron child stdout from npm start Truncated each run
build.log npm run release β€” streamed GH Actions output during a CI release Truncated each run
npx mgr logs                  # tail last 50 of runtime.log
npx mgr logs --tail           # follow runtime.log live
tail -f logs/dev.log          # gulp pipeline output
grep -i error logs/runtime.log

In production, runtime.log lives at app.getPath('logs'):

  • macOS: ~/Library/Logs/<AppName>/runtime.log
  • Windows: %APPDATA%\<AppName>\logs\runtime.log
  • Linux: ~/.config/<AppName>/logs/runtime.log

See docs/logging.md for the full picture (renderer forwarding, log levels, programmatic path access).

Override gulp's dev.log path via EM_LOG_FILE=<path>; disable entirely via EM_LOG_FILE=false. The default .gitignore includes logs/.

Per-process imports

// src/main.js
new (require('electron-manager/main'))().initialize();

// src/preload.js
new (require('electron-manager/preload'))().initialize();

// src/assets/js/components/<view>/index.js
new (require('electron-manager/renderer'))().initialize();

Documentation

Each subsystem has its own API reference under docs/:

  • storage β€” KV store, sync in main, async (via IPC) in renderer, dot-notation paths, change broadcasts
  • ipc β€” typed channel bus, handle / invoke / broadcast
  • windows β€” lazy named-window registry (no auto-create), bounds persistence, inset titlebar, hide-on-close
  • tray β€” file-based tray definition, dynamic items, runtime mutators
  • menu β€” file-based application menu, platform-aware default template
  • context-menu β€” file-based right-click menus, called per-event with params
  • startup β€” launch modes (normal / hidden), LSUIElement on macOS, login-item handling
  • app-state β€” first-launch / launch-count / crash-sentinel flags
  • deep-link β€” cross-platform deep links, single-instance, pattern routing, built-in routes
  • web-manager-bridge β€” Firebase auth state synchronized across main + every renderer
  • auto-updater β€” startup + periodic checks, 30-day max-age gate, dev simulation
  • analytics β€” GA4 Measurement Protocol with cross-platform uuidv5 identity (same human β†’ same user_id across desktop/web/backend)
  • context β€” runtime info block (geolocation, client, session, app) β€” BEM-shaped
  • usage β€” opens / hoursTotal / hoursThisSession; clean-exit accumulation
  • remote-config β€” "hot config" fetched from brand site for runtime flag flips without re-releases
  • restart-manager β€” auxiliary helper app for relaunches; auto-installs via signed mac.zip / NSIS exe / browser-opened .deb
  • config-schema β€” canonical schema + validator for config/electron-manager.json. Hard-fails boot AND gulp audit on missing required fields, regex mismatches, enum violations, type mismatches. Single source of truth in src/config/schema.js
  • templating β€” {{ var }} token replacement, page template, body-only views
  • themes β€” classy + bootstrap themes, @use 'electron-manager' as * with (...) overrides, per-page CSS bundles
  • sentry β€” error/crash reporting, dev-mode gating, auto auth attribution, release tagging
  • hooks β€” lifecycle hooks (build/pre, build/post, release/pre, release/post, notarize)
  • installer-options β€” installer/distribution config: NSIS one-click defaults, ia32 inclusion, app.category mapping, {YEAR} copyright token, snap publishing (default-on with cred-gated auto-skip), MAS roadmap
  • signing β€” macOS + Windows code signing reference, cert files, env vars
  • releasing β€” end-to-end release walkthrough (.env β†’ GitHub Release)
  • runner β€” Windows EV-token signing runner β€” npx mgr runner install, auto-onboards new GH orgs, npx mgr runner monitor for a live signing event tail
  • test-framework β€” writing tests, running them, layers
  • test-boot-layer β€” boot test layer (spawns the consumer's actual built bundle for end-to-end smoke tests)
  • build-system β€” gulp, webpack, electron-builder pipeline

Status

Active development on v1. See PROGRESS.md for pass-by-pass progress.

About

An NPM module with tools, helper functions, and utilities for building a flawless Electron app πŸš€

Topics

Resources

Stars

Watchers

Forks

Contributors