mirror of
				https://github.com/zadam/trilium.git
				synced 2025-10-31 18:36:30 +01:00 
			
		
		
		
	fix(nx/edit-docs): rebuild script not working properly
This commit is contained in:
		| @@ -14,28 +14,26 @@ | |||||||
|   "nx": { |   "nx": { | ||||||
|     "name": "edit-docs", |     "name": "edit-docs", | ||||||
|     "targets": { |     "targets": { | ||||||
|       "postbuild": { |       "rebuild-deps": { | ||||||
|         "executor": "nx:run-commands", |         "executor": "nx:run-commands", | ||||||
|         "dependsOn": [ |         "dependsOn": [ "build" ], | ||||||
|           "build" |  | ||||||
|         ], |  | ||||||
|         "defaultConfiguration": "default", |         "defaultConfiguration": "default", | ||||||
|         "cache": true, |         "cache": true, | ||||||
|         "configurations": { |         "configurations": { | ||||||
|           "default": { |           "default": { | ||||||
|             "command": "electron-rebuild", |             "command": "cross-env DEBUG=* tsx scripts/rebuild.ts", | ||||||
|             "cwd": "{projectRoot}/dist" |             "cwd": "{projectRoot}" | ||||||
|           }, |           }, | ||||||
|           "nixos": { |           "nixos": { | ||||||
|             "command": "electron-rebuild -v $(nix-shell -p electron_35 --run \"electron --version\")", |             "command": "electron-rebuild -f -v $(nix-shell -p electron_35 --run \"electron --version\") dist/main.js -m dist", | ||||||
|             "cwd": "{projectRoot}/dist" |             "cwd": "{projectRoot}" | ||||||
|           } |           } | ||||||
|         }         |         }         | ||||||
|       }, |       }, | ||||||
|       "serve": { |       "serve": { | ||||||
|         "executor": "nx:run-commands", |         "executor": "nx:run-commands", | ||||||
|         "dependsOn": [ |         "dependsOn": [ | ||||||
|           "postbuild" |           "rebuild-deps" | ||||||
|         ], |         ], | ||||||
|         "defaultConfiguration": "default", |         "defaultConfiguration": "default", | ||||||
|         "configurations": { |         "configurations": { | ||||||
|   | |||||||
							
								
								
									
										37
									
								
								apps/edit-docs/scripts/rebuild.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										37
									
								
								apps/edit-docs/scripts/rebuild.ts
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,37 @@ | |||||||
|  | /** | ||||||
|  |  * @module | ||||||
|  |  * | ||||||
|  |  * This script is used internally by the `rebuild-deps` target of the `desktop`. Normally we could use | ||||||
|  |  * `electron-rebuild` CLI directly, but it would rebuild the monorepo-level dependencies and breaks | ||||||
|  |  * the server build (and it doesn't expose a CLI option to override this). | ||||||
|  |  */ | ||||||
|  |  | ||||||
|  | // TODO: Deduplicate with apps/desktop/scripts/rebuild.ts. | ||||||
|  |  | ||||||
|  | import { fileURLToPath } from "url"; | ||||||
|  | import { dirname, join } from "path"; | ||||||
|  | import rebuild from "@electron/rebuild" | ||||||
|  | import { readFileSync } from "fs"; | ||||||
|  |  | ||||||
|  | const scriptDir = dirname(fileURLToPath(import.meta.url)); | ||||||
|  | const rootDir = join(scriptDir, ".."); | ||||||
|  |  | ||||||
|  | function getElectronVersion() { | ||||||
|  |     const packageJsonPath = join(rootDir, "package.json"); | ||||||
|  |     const packageJson = JSON.parse(readFileSync(packageJsonPath, "utf-8")); | ||||||
|  |     return packageJson.devDependencies.electron; | ||||||
|  | } | ||||||
|  |  | ||||||
|  | function main() { | ||||||
|  |     const distDir = join(rootDir, "dist"); | ||||||
|  |  | ||||||
|  |     rebuild({ | ||||||
|  |         // We force the project root path to avoid electron-rebuild from rebuilding the monorepo-level dependency and breaking the server. | ||||||
|  |         projectRootPath: distDir, | ||||||
|  |         buildPath: distDir, | ||||||
|  |         force: true, | ||||||
|  |         electronVersion: getElectronVersion(), | ||||||
|  |     }); | ||||||
|  | } | ||||||
|  |  | ||||||
|  | main(); | ||||||
		Reference in New Issue
	
	Block a user