chore(docs): restructure developer guide for monorepo

This commit is contained in:
Elian Doran
2025-05-02 20:51:13 +03:00
parent 27d1948bb1
commit 81ebbb9390
111 changed files with 2632 additions and 2202 deletions

View File

@@ -0,0 +1,2 @@
# Updating dependencies
<figure class="table" style="width:100%;"><table class="ck-table-resized"><colgroup><col> <col> <col> <col> <col></colgroup><thead><tr><th>Dependency</th><th>Name in <code>library_loader</code></th><th>Things to check for a basic sanity check</th><th>&nbsp;</th><th>Protected by unit tests</th></tr></thead><tbody><tr><td><code>better-sqlite3</code></td><td>&nbsp;</td><td>See&nbsp;<a class="reference-link" href="Updating%20dependencies/bettersqlite%20binaries.md">bettersqlite binaries</a>.</td><td>&nbsp;</td><td>&nbsp;</td></tr><tr><td><code>jsdom</code></td><td>&nbsp;</td><td><ul><li>Note map</li><li>Clipper</li><li>Note similarity</li></ul></td><td>Protected by typings, should catch any potential changes in API.</td><td>Yes</td></tr><tr><td><code>async-mutex</code></td><td>&nbsp;</td><td><ul><li>Sync</li></ul></td><td>&nbsp;</td><td>&nbsp;</td></tr><tr><td><code>axios</code></td><td>&nbsp;</td><td><ul><li>Can't be directly tested, as it's exposed only via the backend script API.</li></ul></td><td>&nbsp;</td><td>&nbsp;</td></tr><tr><td><code>sax</code></td><td>&nbsp;</td><td><ul><li>EverNote imports</li></ul></td><td>&nbsp;</td><td>&nbsp;</td></tr><tr><td><ul><li><code>ws</code></li><li><code>debounce</code></li></ul></td><td>&nbsp;</td><td><ul><li>Check any action is reported from server to client (e.g. delete a note).</li></ul></td><td>&nbsp;</td><td>&nbsp;</td></tr><tr><td><code>ejs</code></td><td>&nbsp;</td><td><ul><li>Onboarding / first setup</li></ul></td><td>&nbsp;</td><td>&nbsp;</td></tr><tr><td><code>dayjs</code></td><td>&nbsp;</td><td><ul><li>Day notes</li></ul></td><td>&nbsp;</td><td>&nbsp;</td></tr><tr><td><code>semver</code></td><td>&nbsp;</td><td><ul><li>Application should start.</li></ul></td><td>&nbsp;</td><td>&nbsp;</td></tr><tr><td><code>https-proxy-agent</code></td><td>&nbsp;</td><td>???</td><td>&nbsp;</td><td>&nbsp;</td></tr><tr><td><code>sax</code></td><td>&nbsp;</td><td><ul><li>EverNote import</li></ul></td><td>&nbsp;</td><td>&nbsp;</td></tr><tr><td><code>ini</code></td><td>&nbsp;</td><td><ul><li>Affects config, generally if the application starts then it should be OK.</li></ul></td><td>&nbsp;</td><td>&nbsp;</td></tr><tr><td><code>jsplumb</code></td><td><code>RELATION_MAP</code></td><td><ul><li>Relation map note type</li></ul></td><td>&nbsp;</td><td>&nbsp;</td></tr><tr><td><code>jquery.mark.es6</code></td><td><code>MARKJS</code></td><td><ul><li>In search, when highlighting the text that matched.</li><li>In search in HTML, which might not actually be used since it seems to have been replaced by CKEditor's own find &amp; replace dialog.</li></ul></td><td>&nbsp;</td><td>&nbsp;</td></tr><tr><td><code>knockout.js</code></td><td>&nbsp;</td><td><ul><li>Used in rendering the login and main layout of the application.</li></ul></td><td>&nbsp;</td><td>&nbsp;</td></tr><tr><td><code>normalize.min.css</code></td><td>&nbsp;</td><td><ul><li>Used in shared notes.</li></ul></td><td>&nbsp;</td><td>&nbsp;</td></tr><tr><td><code>wheel-zoom.min.js</code></td><td><code>WHEEL_ZOOM</code></td><td><ul><li>When opening a image that is in attachment.</li><li>When opening a stand-alone image note.</li><li>When zooming in a mermaid chart.</li></ul></td><td>&nbsp;</td><td>&nbsp;</td></tr><tr><td><code>fancytree</code></td><td>&nbsp;</td><td><ul><li>The note tree should be fully functional.</li></ul></td><td>&nbsp;</td><td>&nbsp;</td></tr><tr><td><code>bootstrap</code></td><td>&nbsp;</td><td><ul><li>Check mostly the on-boarding pages, when there is no database.</li></ul></td><td>&nbsp;</td><td>&nbsp;</td></tr><tr><td><code>electron-debug</code></td><td>&nbsp;</td><td><ul><li>Run electron using <code>npm run start-electron</code> and check that the debug hotkeys are still working (Ctrl+Shift+I on Windows/Linux, Cmd+Alt+I for dev tools, Cmd/Ctrl+R for reload).</li></ul></td><td>&nbsp;</td><td>&nbsp;</td></tr><tr><td><code>electron-dl</code></td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td></tr><tr><td><code>eslint</code></td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td></tr><tr><td><code>marked</code></td><td>&nbsp;</td><td><ul><li>Importing a markdown note.</li></ul></td><td>&nbsp;</td><td>Yes</td></tr><tr><td><code>force-graph</code></td><td>&nbsp;</td><td><ul><li>Note map</li></ul></td><td>&nbsp;</td><td>&nbsp;</td></tr></tbody></table></figure>

View File

@@ -0,0 +1,8 @@
# Node.js, Electron and `better-sqlite3`
## Node.js, Electron and `better-sqlite3`
`better-sqlite3` requires a native module in order to work. In order to ease the installation process, prebuilt binaries are provided by the library developers.
Trilium Next started with version [8.4.0](https://github.com/WiseLibs/better-sqlite3/releases/tag/v8.4.0) for `better-sqlite3`
<figure class="table" style="width:100%;"><table class="ck-table-resized"><colgroup><col> <col> <col> <col></colgroup><tbody><tr><td><code>better-sqlite3</code> version</td><td>SQLite version</td><td>Node.js prebuilds</td><td>Electron.js prebuilds</td></tr><tr><td>8.4.0</td><td>&lt;3.43.0</td><td>v20</td><td>???</td></tr><tr><td>8.5.0</td><td>v20</td><td>v25</td></tr><tr><td>8.5.1</td><td>&nbsp;</td><td>v26</td></tr><tr><td>8.5.2</td><td>v20 (macOS + arm64)</td></tr><tr><td>8.6.0</td><td>3.43.0</td><td>&nbsp;</td></tr><tr><td>8.7.0</td><td>3.43.1</td><td>&nbsp;</td></tr><tr><td>9.0.0</td><td>3.43.2</td><td>&nbsp;</td><td>v27</td></tr><tr><td>9.1.0</td><td>3.44.0</td><td>&nbsp;</td></tr><tr><td>9.1.1</td><td>macOS + Alpine</td></tr><tr><td>9.2.0</td><td>3.44.2</td><td>&nbsp;</td></tr><tr><td>9.2.1 / 9.2.2</td><td>&nbsp;</td><td>v28</td></tr><tr><td>9.3.0</td><td>3.45.0</td><td>&nbsp;</td></tr><tr><td>9.4.0</td><td>3.45.1</td><td>&nbsp;</td></tr><tr><td>9.4.1</td><td>Windows arm, arm64</td></tr><tr><td>9.4.2</td><td>&nbsp;</td><td>&lt;v29</td></tr><tr><td>9.4.3</td><td>&nbsp;</td><td>&lt;v29</td></tr><tr><td>9.4.4</td><td>&nbsp;</td><td>v29</td></tr><tr><td>9.4.5</td><td>Better prebuilds</td></tr><tr><td>9.5.0</td><td>3.45.2</td><td>&nbsp;</td></tr><tr><td>9.6.0</td><td>3.45.3</td><td>&nbsp;</td><td>v30</td></tr><tr><td>10.0.0</td><td>v22</td></tr><tr><td>10.1.0</td><td>3.46.0</td><td>&nbsp;</td></tr><tr><td>11.0.0</td><td>&gt;21</td></tr><tr><td>11.1.0 (prerelease)</td><td>&nbsp;</td><td>&nbsp;</td><td>v31</td></tr><tr><td>11.1.1</td><td>&nbsp;</td><td>&nbsp;</td></tr><tr><td>11.1.2</td><td>&nbsp;</td><td>&nbsp;</td></tr></tbody></table></figure>

View File

@@ -0,0 +1,2 @@
# Testing compatibility
<figure class="table" style="width:100%;"><table class="ck-table-resized"><colgroup><col> <col> <col></colgroup><thead><tr><th><code>better-sqlite3</code> version<br><a href="https://github.com/WiseLibs/better-sqlite3/releases">Change log</a></th><th>SQLite version<br><a href="https://www.sqlite.org/changes.html">Change log</a></th><th>Compatibility with upstream Trilium</th></tr></thead><tbody><tr><td>8.4.0</td><td>&lt;3.43.0</td><td>Compatible, same version.</td></tr><tr><td>8.6.0</td><td>3.43.0</td><td>&nbsp;</td></tr><tr><td>8.7.0</td><td>3.43.1</td><td>&nbsp;</td></tr><tr><td>9.0.0</td><td>3.43.2</td><td>&nbsp;</td></tr><tr><td>9.1.0 + 9.1.1</td><td>3.44.0</td><td>&nbsp;</td></tr><tr><td>9.2.0 + 9.2.1 + 9.2.2</td><td>3.44.2</td><td>&nbsp;</td></tr><tr><td>9.3.0</td><td>3.45.0</td><td>&nbsp;</td></tr><tr><td>9.4.0, 9.4.1, 9.4.2, 9.4.3, 9.4.4, 9.4.5</td><td>3.45.1</td><td>&nbsp;</td></tr><tr><td>9.5.0</td><td>3.45.2</td><td>&nbsp;</td></tr><tr><td>9.6.0 / 10.0.0</td><td>3.45.3</td><td>&nbsp;</td></tr><tr><td>10.1.0 / 11.0.0 / 11.1.1 / 11.1.2 / 11.2.0 / 11.2.1</td><td>3.46.0</td><td>&nbsp;</td></tr><tr><td>11.3.0</td><td>3.46.1</td><td>&nbsp;</td></tr></tbody></table></figure>

View File

@@ -0,0 +1,41 @@
# bettersqlite binaries
### The native node bindings
`better-sqlite3` has native Node bindings. With updates of `better-sqlite3`, but also of Electron and Node.js versions, these bindings need to be updated.
Note that Electron and Node.js versions need different versions of these bindings, since Electron usually packs a different version of Node.js.
During development, `npm install` tries to build or reuse prebuilt natives for the current Node.js version. This makes `npm run start-server` work out of the box. Trying to run `npm run start-electron` with these versions generally causes an error such as this:
```
Uncaught Exception:
Error: The module '/Users/elian/Projects/Notes/node_modules/better-sqlite3/build/Release/better_sqlite3.node'
was compiled against a different Node.js version using
NODE_MODULE_VERSION 108. This version of Node.js requires
NODE_MODULE_VERSION 116. Please try re-compiling or re-installing
the module (for instance, using `npm rebuild` or `npm install`).
```
### How the natives are handled
Locally, this can be fixed by rebuilding the binaries, which is what `npm run switch-electron` does, which uses `electron-rebuild` under the hood.
When the deliveries are built (see <a class="reference-link" href="../../Build%20deliveries%20locally.md">Build deliveries locally</a>), it is not feasible to rebuild the dependencies since we are building for multiple platforms. Luckily, `better-sqlite3` provides these prebuilt binaries from us, available as artifacts on [their GitHub releases page](https://github.com/WiseLibs/better-sqlite3/releases/). 
The build script manages the natives for `better-sqlite3` by keeping a copy of the `.node` file for every platform in `bin/better-sqlite3`.
Whenever the version of `better-sqlite3` changes, the `.node` files must also be renewed based on their releases page. To simplify this process, a script was created in `bin/better-sqlite3/update.sh`.
## How to update the natives
The update script needs to know the version of Electron or Node.js for which to download the prebuilt binaries.
If you get errors during download, check on the [releases page](https://github.com/WiseLibs/better-sqlite3/releases/) to ensure that this particular combination of Electron/Node actually exists for the given release.
To determine the `NODE_MODULE_VERSION` that is required, look for `This version of Node.js requires`
`NODE_MODULE_VERSION` in the error when starting Trilium via:
* `npm run start-electron` (or run any Electron [delivery](../../Build%20deliveries%20locally.md)), case in which the `ELECTRON_VERSION` variable needs to be changed.
* `npm run start-server` (or run the Linux server delivery), case in which the `NODE_VERSION` variable needs to be changed.
Check which files got changed after running the update script and for each platform that got changed, test it locally via <a class="reference-link" href="../../Build%20deliveries%20locally.md">Build deliveries locally</a> or via the CI.