mirror of
				https://github.com/zadam/trilium.git
				synced 2025-10-31 18:36:30 +01:00 
			
		
		
		
	server-ts: Port app* services
This commit is contained in:
		| @@ -26,9 +26,9 @@ jq '.version = "'$VERSION'"' package.json|sponge package.json | |||||||
|  |  | ||||||
| git add package.json | git add package.json | ||||||
|  |  | ||||||
| echo 'module.exports = { buildDate:"'`date --iso-8601=seconds`'", buildRevision: "'`git log -1 --format="%H"`'" };' > src/services/build.js | echo 'export = { buildDate:"'`date --iso-8601=seconds`'", buildRevision: "'`git log -1 --format="%H"`'" };' > src/services/build.ts | ||||||
|  |  | ||||||
| git add src/services/build.js | git add src/services/build.ts | ||||||
|  |  | ||||||
| TAG=v$VERSION | TAG=v$VERSION | ||||||
|  |  | ||||||
|   | |||||||
| @@ -1,4 +1,4 @@ | |||||||
| const assetPath = require('../services/asset_path.js'); | const assetPath = require('../services/asset_path'); | ||||||
| const path = require("path"); | const path = require("path"); | ||||||
| const express = require("express"); | const express = require("express"); | ||||||
| const env = require('../services/env'); | const env = require('../services/env'); | ||||||
|   | |||||||
| @@ -9,7 +9,7 @@ const env = require('../services/env'); | |||||||
| const utils = require('../services/utils'); | const utils = require('../services/utils'); | ||||||
| const protectedSessionService = require('../services/protected_session'); | const protectedSessionService = require('../services/protected_session'); | ||||||
| const packageJson = require('../../package.json'); | const packageJson = require('../../package.json'); | ||||||
| const assetPath = require('../services/asset_path.js'); | const assetPath = require('../services/asset_path'); | ||||||
| const appPath = require('../services/app_path.js'); | const appPath = require('../services/app_path.js'); | ||||||
|  |  | ||||||
| function index(req, res) { | function index(req, res) { | ||||||
|   | |||||||
| @@ -5,7 +5,7 @@ const optionService = require('../services/options'); | |||||||
| const myScryptService = require('../services/encryption/my_scrypt'); | const myScryptService = require('../services/encryption/my_scrypt'); | ||||||
| const log = require('../services/log'); | const log = require('../services/log'); | ||||||
| const passwordService = require('../services/encryption/password'); | const passwordService = require('../services/encryption/password'); | ||||||
| const assetPath = require('../services/asset_path.js'); | const assetPath = require('../services/asset_path'); | ||||||
| const appPath = require('../services/app_path.js'); | const appPath = require('../services/app_path.js'); | ||||||
| const ValidationError = require('../errors/validation_error'); | const ValidationError = require('../errors/validation_error'); | ||||||
|  |  | ||||||
|   | |||||||
| @@ -3,7 +3,7 @@ | |||||||
| const sqlInit = require('../services/sql_init.js'); | const sqlInit = require('../services/sql_init.js'); | ||||||
| const setupService = require('../services/setup.js'); | const setupService = require('../services/setup.js'); | ||||||
| const utils = require('../services/utils'); | const utils = require('../services/utils'); | ||||||
| const assetPath = require('../services/asset_path.js'); | const assetPath = require('../services/asset_path'); | ||||||
| const appPath = require('../services/app_path.js'); | const appPath = require('../services/app_path.js'); | ||||||
|  |  | ||||||
| function setupPage(req, res) { | function setupPage(req, res) { | ||||||
|   | |||||||
| @@ -1,12 +1,12 @@ | |||||||
| "use strict"; | "use strict"; | ||||||
| 
 | 
 | ||||||
| const path = require('path'); | import path = require('path'); | ||||||
| const {ELECTRON_APP_ROOT_DIR} = require('./resource_dir'); | import resourceDir = require('./resource_dir'); | ||||||
| const log = require('./log'); | import log = require('./log'); | ||||||
| const os = require('os'); | import os = require('os'); | ||||||
| const fs = require('fs'); | import fs = require('fs'); | ||||||
| const config = require('./config'); | import config = require('./config'); | ||||||
| const utils = require('./utils'); | import utils = require('./utils'); | ||||||
| 
 | 
 | ||||||
| const template = `[Desktop Entry]
 | const template = `[Desktop Entry]
 | ||||||
| Type=Application | Type=Application | ||||||
| @@ -28,7 +28,7 @@ function installLocalAppIcon() { | |||||||
|         return; |         return; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     if (!fs.existsSync(path.resolve(ELECTRON_APP_ROOT_DIR, "trilium-portable.sh"))) { |     if (!fs.existsSync(path.resolve(resourceDir.ELECTRON_APP_ROOT_DIR, "trilium-portable.sh"))) { | ||||||
|         // simple heuristic to detect ".tar.xz" linux build (i.e., not flatpak, not debian)
 |         // simple heuristic to detect ".tar.xz" linux build (i.e., not flatpak, not debian)
 | ||||||
|         // only in such case it's necessary to create an icon
 |         // only in such case it's necessary to create an icon
 | ||||||
|         return; |         return; | ||||||
| @@ -56,16 +56,16 @@ function installLocalAppIcon() { | |||||||
| 
 | 
 | ||||||
| function getDesktopFileContent() { | function getDesktopFileContent() { | ||||||
|     return template |     return template | ||||||
|         .replace("#APP_ROOT_DIR#", escapePath(ELECTRON_APP_ROOT_DIR)) |         .replace("#APP_ROOT_DIR#", escapePath(resourceDir.ELECTRON_APP_ROOT_DIR)) | ||||||
|         .replace("#EXE_PATH#", escapePath(getExePath())); |         .replace("#EXE_PATH#", escapePath(getExePath())); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| function escapePath(path) { | function escapePath(path: string) { | ||||||
|     return path.replace(/ /g, "\\ "); |     return path.replace(/ /g, "\\ "); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| function getExePath() { | function getExePath() { | ||||||
|      return path.resolve(ELECTRON_APP_ROOT_DIR, 'trilium'); |      return path.resolve(resourceDir.ELECTRON_APP_ROOT_DIR, 'trilium'); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| module.exports = { | module.exports = { | ||||||
| @@ -1,8 +1,8 @@ | |||||||
| "use strict"; | "use strict"; | ||||||
| 
 | 
 | ||||||
| const build = require('./build.js'); | import build = require('./build'); | ||||||
| const packageJson = require('../../package.json'); | import packageJson = require('../../package.json'); | ||||||
| const {TRILIUM_DATA_DIR} = require('./data_dir'); | import dataDir = require('./data_dir'); | ||||||
| 
 | 
 | ||||||
| const APP_DB_VERSION = 228; | const APP_DB_VERSION = 228; | ||||||
| const SYNC_VERSION = 32; | const SYNC_VERSION = 32; | ||||||
| @@ -15,7 +15,7 @@ module.exports = { | |||||||
|     syncVersion: SYNC_VERSION, |     syncVersion: SYNC_VERSION, | ||||||
|     buildDate: build.buildDate, |     buildDate: build.buildDate, | ||||||
|     buildRevision: build.buildRevision, |     buildRevision: build.buildRevision, | ||||||
|     dataDirectory: TRILIUM_DATA_DIR, |     dataDirectory: dataDir.TRILIUM_DATA_DIR, | ||||||
|     clipperProtocolVersion: CLIPPER_PROTOCOL_VERSION, |     clipperProtocolVersion: CLIPPER_PROTOCOL_VERSION, | ||||||
|     utcDateTime: new Date().toISOString() // for timezone inference
 |     utcDateTime: new Date().toISOString() // for timezone inference
 | ||||||
| }; | }; | ||||||
| @@ -1,6 +0,0 @@ | |||||||
| const assetPath = require('./asset_path.js'); |  | ||||||
| const env = require('./env'); |  | ||||||
|  |  | ||||||
| module.exports = env.isDev() |  | ||||||
|     ? assetPath + "/app" |  | ||||||
|     : assetPath + "/app-dist"; |  | ||||||
							
								
								
									
										6
									
								
								src/services/app_path.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										6
									
								
								src/services/app_path.ts
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,6 @@ | |||||||
|  | import assetPath = require('./asset_path'); | ||||||
|  | import env = require('./env'); | ||||||
|  |  | ||||||
|  | export = env.isDev() | ||||||
|  |     ? assetPath + "/app" | ||||||
|  |     : assetPath + "/app-dist"; | ||||||
| @@ -1,3 +0,0 @@ | |||||||
| const packageJson = require('../../package.json'); |  | ||||||
|  |  | ||||||
| module.exports = `assets/v${packageJson.version}`; |  | ||||||
							
								
								
									
										3
									
								
								src/services/asset_path.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										3
									
								
								src/services/asset_path.ts
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,3 @@ | |||||||
|  | import packageJson = require('../../package.json'); | ||||||
|  |  | ||||||
|  | export = `assets/v${packageJson.version}`; | ||||||
| @@ -1 +0,0 @@ | |||||||
| module.exports = { buildDate:"2024-01-21T23:49:23+01:00", buildRevision: "4f8073daa7cff1b8b6737ae45792b2e87c2adf33" }; |  | ||||||
							
								
								
									
										1
									
								
								src/services/build.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								src/services/build.ts
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1 @@ | |||||||
|  | export = { buildDate:"2024-01-21T23:49:23+01:00", buildRevision: "4f8073daa7cff1b8b6737ae45792b2e87c2adf33" }; | ||||||
| @@ -1,6 +1,6 @@ | |||||||
| const {JSDOM} = require("jsdom"); | const {JSDOM} = require("jsdom"); | ||||||
| const shaca = require('./shaca/shaca.js'); | const shaca = require('./shaca/shaca.js'); | ||||||
| const assetPath = require('../services/asset_path.js'); | const assetPath = require('../services/asset_path'); | ||||||
| const shareRoot = require('./share_root.js'); | const shareRoot = require('./share_root.js'); | ||||||
| const escapeHtml = require('escape-html'); | const escapeHtml = require('escape-html'); | ||||||
|  |  | ||||||
|   | |||||||
| @@ -7,7 +7,7 @@ const shaca = require('./shaca/shaca.js'); | |||||||
| const shacaLoader = require('./shaca/shaca_loader.js'); | const shacaLoader = require('./shaca/shaca_loader.js'); | ||||||
| const shareRoot = require('./share_root.js'); | const shareRoot = require('./share_root.js'); | ||||||
| const contentRenderer = require('./content_renderer.js'); | const contentRenderer = require('./content_renderer.js'); | ||||||
| const assetPath = require('../services/asset_path.js'); | const assetPath = require('../services/asset_path'); | ||||||
| const appPath = require('../services/app_path.js'); | const appPath = require('../services/app_path.js'); | ||||||
| const searchService = require('../services/search/services/search.js'); | const searchService = require('../services/search/services/search.js'); | ||||||
| const SearchContext = require('../services/search/search_context.js'); | const SearchContext = require('../services/search/search_context.js'); | ||||||
|   | |||||||
| @@ -6,6 +6,7 @@ | |||||||
| 	  "outDir": "./build", | 	  "outDir": "./build", | ||||||
| 	  "strict": true, | 	  "strict": true, | ||||||
| 	  "noImplicitAny": true, | 	  "noImplicitAny": true, | ||||||
|  | 	  "resolveJsonModule": true, | ||||||
| 	  "lib": ["ES2021"] | 	  "lib": ["ES2021"] | ||||||
| 	}, | 	}, | ||||||
| 	"include": [ | 	"include": [ | ||||||
|   | |||||||
| @@ -1,5 +1,5 @@ | |||||||
| const path = require('path'); | const path = require('path'); | ||||||
| const assetPath = require('./src/services/asset_path.js'); | const assetPath = require('./src/services/asset_path'); | ||||||
|  |  | ||||||
| module.exports = { | module.exports = { | ||||||
|     mode: 'production', |     mode: 'production', | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user