- Implement --config (-c) flag to allow custom configuration file paths.
- Add --help (-h) flag to display tool usage and available options.
- Add --version (-v) flag to display the current Trilium version.
- Update electron-start.mts to correctly pass command-line arguments to Electron.
- Synchronize edit-docs version with the root package.json via update-version.ts.
- Resolve config paths relative to the configuration file's directory.
This makes edit-docs more robust and easier to use from external projects
and immutable environments like Nix.
This removes hardcoded configuration from edit-docs.ts and replaces
it with dynamic loading from edit-docs-config.yaml.
Changes:
- Removed BASE_URL and NOTE_MAPPINGS constants
- Removed DOCS_ROOT and USER_GUIDE_ROOT environment variable dependencies
- Added js-yaml for YAML parsing
- Config paths are resolved relative to repository root
The tool now reads configuration from edit-docs-config.yaml, making it
easier to customize without code changes. The pnpm script is simplified
since it no longer needs to pass complex environment variables.
The edit-docs tool would hang on startup when the Electron 'ready' event
fired before the event listener was registered. This race condition occurred
because:
1. startElectron() creates a deferred promise and registers a 'ready' listener
2. The 'ready' event fires asynchronously at some point during app initialization
3. If async work (like config loading) delays the listener registration,
Electron may already be ready when app.on('ready', ...) is called
4. Once fired, the 'ready' event doesn't fire again, leaving the listener
waiting forever
The fix checks electron.app.isReady() before registering the listener:
- If already ready: execute the handler immediately
- If not ready: register the listener as before
This ensures the initialization sequence completes regardless of timing.
The issue became apparent while working on making edit-docs reusable from
other projects (see #8343), where config loading added enough async delay
to consistently trigger the race condition.
Related: https://github.com/TriliumNext/Trilium/issues/8343