Skip to content

Build your personal knowledge base with Trilium Notes

fix: restore start-electron script functionality

alexpietschc8adf2a68542
diff --git a/bin/copy-dist.sh b/bin/copy-dist.sh
new file mode 100644
index 0000000000..d173455c38
--- /dev/null
+++ b/bin/copy-dist.sh
@@ -0,0 +1,12 @@
+DEST_DIR="./dist"
+DEST_DIR_SRC="$DEST_DIR/src"
+
+for d in 'images' 'libraries' 'db' 'node_modules' ; do
+ echo "Copying $d"
+ cp -r "$d" "$DEST_DIR"/
+done
+
+for d in './src/public' './src/views' ; do
+ echo "Copying $d"
+ cp -r "$d" "$DEST_DIR_SRC"/
+done
\ No newline at end of file
diff --git a/electron.js b/electron.js
deleted file mode 100644
index 69f403dd83..0000000000
--- a/electron.js
+++ /dev/null
@@ -1,62 +0,0 @@
-'use strict';
-
-const {app, globalShortcut, BrowserWindow} = require('electron');
-const sqlInit = require('./src/services/sql_init');
-const appIconService = require('./src/services/app_icon.js');
-const windowService = require('./src/services/window');
-const tray = require('./src/services/tray');
-
-// Adds debug features like hotkeys for triggering dev tools and reload
-require('electron-debug')();
-
-appIconService.installLocalAppIcon();
-
-require('electron-dl')({ saveAs: true });
-
-// needed for excalidraw export https://github.com/zadam/trilium/issues/4271
-app.commandLine.appendSwitch("enable-experimental-web-platform-features");
-
-// Quit when all windows are closed, except on macOS. There, it's common
-// for applications and their menu bar to stay active until the user quits
-// explicitly with Cmd + Q.
-app.on('window-all-closed', () => {
- if (process.platform !== 'darwin') {
- app.quit()
- }
-});
-
-app.on('ready', async () => {
-// app.setAppUserModelId('com.github.zadam.trilium');
-
- // if db is not initialized -> setup process
- // if db is initialized, then we need to wait until the migration process is finished
- if (sqlInit.isDbInitialized()) {
- await sqlInit.dbReady;
-
- await windowService.createMainWindow(app);
-
- if (process.platform === 'darwin') {
- app.on('activate', async () => {
- if (BrowserWindow.getAllWindows().length === 0) {
- await windowService.createMainWindow(app);
- }
- });
- }
-
- tray.createTray();
- }
- else {
- await windowService.createSetupWindow();
- }
-
- await windowService.registerGlobalShortcuts();
-});
-
-app.on('will-quit', () => {
- globalShortcut.unregisterAll();
-});
-
-// this is to disable electron warning spam in the dev console (local development only)
-process.env['ELECTRON_DISABLE_SECURITY_WARNINGS'] = 'true';
-
-require('./src/www.js');
diff --git a/electron.ts b/electron.ts
new file mode 100644
index 0000000000..1cd5abdbd0
--- /dev/null
+++ b/electron.ts
@@ -0,0 +1,61 @@
+"use strict";
+
+const { app, globalShortcut, BrowserWindow } = require("electron");
+const sqlInit = require("./src/services/sql_init");
+const appIconService = require("./src/services/app_icon.js");
+const windowService = require("./src/services/window");
+const tray = require("./src/services/tray");
+
+// Adds debug features like hotkeys for triggering dev tools and reload
+require("electron-debug")();
+
+appIconService.installLocalAppIcon();
+
+require("electron-dl")({ saveAs: true });
+
+// needed for excalidraw export https://github.com/zadam/trilium/issues/4271
+app.commandLine.appendSwitch("enable-experimental-web-platform-features");
+
+// Quit when all windows are closed, except on macOS. There, it's common
+// for applications and their menu bar to stay active until the user quits
+// explicitly with Cmd + Q.
+app.on("window-all-closed", () => {
+ if (process.platform !== "darwin") {
+ app.quit();
+ }
+});
+
+app.on("ready", async () => {
+ // app.setAppUserModelId('com.github.zadam.trilium');
+
+ // if db is not initialized -> setup process
+ // if db is initialized, then we need to wait until the migration process is finished
+ if (sqlInit.isDbInitialized()) {
+ await sqlInit.dbReady;
+
+ await windowService.createMainWindow(app);
+
+ if (process.platform === "darwin") {
+ app.on("activate", async () => {
+ if (BrowserWindow.getAllWindows().length === 0) {
+ await windowService.createMainWindow(app);
+ }
+ });
+ }
+
+ tray.createTray();
+ } else {
+ await windowService.createSetupWindow();
+ }
+
+ await windowService.registerGlobalShortcuts();
+});
+
+app.on("will-quit", () => {
+ globalShortcut.unregisterAll();
+});
+
+// this is to disable electron warning spam in the dev console (local development only)
+process.env["ELECTRON_DISABLE_SECURITY_WARNINGS"] = "true";
+
+require("./src/www.js");
diff --git a/package.json b/package.json
index cbfcd7e325..bfb0c5aae7 100644
--- a/package.json
+++ b/package.json
@@ -16,12 +16,13 @@
"start-server": "cross-env TRILIUM_SAFE_MODE=1 TRILIUM_DATA_DIR=./data TRILIUM_ENV=dev TRILIUM_SYNC_SERVER_HOST=http://tsyncserver:4000 nodemon src/www.ts",
"start-server-no-dir": "cross-env TRILIUM_SAFE_MODE=1 TRILIUM_ENV=dev TRILIUM_SYNC_SERVER_HOST=http://tsyncserver:4000 nodemon src/www.ts",
"qstart-server": "npm run qswitch-server && TRILIUM_SAFE_MODE=1 TRILIUM_DATA_DIR=./data TRILIUM_ENV=dev TRILIUM_SYNC_SERVER_HOST=http://tsyncserver:4000 nodemon src/www.ts",
- "start-electron": "cross-env TRILIUM_SAFE_MODE=1 TRILIUM_DATA_DIR=./data TRILIUM_SYNC_SERVER_HOST=http://tsyncserver:4000 TRILIUM_ENV=dev electron --inspect=5858 .",
+ "start-electron": "rimraf ./dist && tsc && ./bin/copy-dist.sh && cross-env TRILIUM_SAFE_MODE=1 TRILIUM_DATA_DIR=./data TRILIUM_SYNC_SERVER_HOST=http://tsyncserver:4000 TRILIUM_ENV=dev electron ./dist/electron.js --inspect=5858 .",
"start-electron-no-dir": "cross-env TRILIUM_SAFE_MODE=1 TRILIUM_ENV=dev TRILIUM_SYNC_SERVER_HOST=http://tsyncserver:4000 electron --inspect=5858 .",
"qstart-electron": "npm run qswitch-electron && TRILIUM_SAFE_MODE=1 TRILIUM_DATA_DIR=./data TRILIUM_SYNC_SERVER_HOST=http://tsyncserver:4000 TRILIUM_ENV=dev electron --inspect=5858 .",
- "start-test-server": "npm run qswitch-server; rm -rf ./data-test; cross-env TRILIUM_SAFE_MODE=1 TRILIUM_DATA_DIR=./data-test TRILIUM_SYNC_SERVER_HOST=http://tsyncserver:4000 TRILIUM_ENV=dev TRILIUM_PORT=9999 node src/www.js",
+ "start-test-server": "npm run qswitch-server; rm -rf ./data-test; cross-env TRILIUM_SAFE_MODE=1 TRILIUM_DATA_DIR=./data-test TRILIUM_SYNC_SERVER_HOST=http://tsyncserver:4000 TRILIUM_ENV=dev TRILIUM_PORT=9999 ts-node src/www.ts",
"switch-server": "rm -rf ./node_modules/better-sqlite3 && npm install",
"switch-electron": "./node_modules/.bin/electron-rebuild",
+ "rebuild": "electron-rebuild -f",
"qswitch-server": "rm -rf ./node_modules/better-sqlite3/bin ; mkdir -p ./node_modules/better-sqlite3/build ; cp ./bin/better-sqlite3/linux-server-better_sqlite3.node ./node_modules/better-sqlite3/build/better_sqlite3.node",
"qswitch-electron": "rm -rf ./node_modules/better-sqlite3/bin ; mkdir -p ./node_modules/better-sqlite3/build ; cp ./bin/better-sqlite3/linux-desktop-better_sqlite3.node ./node_modules/better-sqlite3/build/better_sqlite3.node",
"build-backend-docs": "rm -rf ./docs/backend_api && ./node_modules/.bin/jsdoc -c jsdoc-conf.json -d ./docs/backend_api src/becca/entities/*.js src/services/backend_script_api.js src/services/sql.js",
@@ -155,4 +156,4 @@
"optionalDependencies": {
"electron-installer-debian": "3.2.0"
}
-}
\ No newline at end of file
+}
diff --git a/tsconfig.json b/tsconfig.json
index 31aa526d23..b7fb43db68 100644
--- a/tsconfig.json
+++ b/tsconfig.json
@@ -12,7 +12,8 @@
},
"include": [
"./src/**/*.js",
- "./src/**/*.ts"
+ "./src/**/*.ts",
+ "./*.ts"
],
"exclude": ["./node_modules/**/*"],
"ts-node": {