mirror of
				https://github.com/TriliumNext/Notes.git
				synced 2025-10-31 13:01:31 +08:00 
			
		
		
		
	chore(nx): clean up package JSON
This commit is contained in:
		
							parent
							
								
									64f315437e
								
							
						
					
					
						commit
						fdcdc41ea6
					
				| @ -1,41 +0,0 @@ | ||||
| { | ||||
|   "name": "@triliumnext/client", | ||||
|   "version": "0.0.1", | ||||
|   "description": "JQuery-based client for TriliumNext, used for both web and desktop (via Electron)", | ||||
|   "homepage": "https://github.com/TriliumNext/Notes#readme", | ||||
|   "bugs": { | ||||
|     "url": "https://github.com/TriliumNext/Notes/issues" | ||||
|   }, | ||||
|   "repository": { | ||||
|     "type": "git", | ||||
|     "url": "git+https://github.com/TriliumNext/Notes.git" | ||||
|   }, | ||||
|   "license": "AGPL-3.0-only", | ||||
|   "author": { | ||||
|     "name": "TriliumNext Notes Team", | ||||
|     "email": "contact@eliandoran.me", | ||||
|     "url": "https://github.com/TriliumNext/Notes" | ||||
|   }, | ||||
|   "copyright": "", | ||||
|   "type": "module", | ||||
|   "main": "index.js", | ||||
|   "scripts": { | ||||
|     "build:webpack": "tsx ../../node_modules/webpack/bin/webpack.js -c webpack.config.ts", | ||||
|     "test": "vitest" | ||||
|   }, | ||||
|   "devDependencies": { | ||||
|     "autoprefixer": "10.4.21",     | ||||
|     "mini-css-extract-plugin": "2.9.2", | ||||
|     "ts-loader": "9.5.2", | ||||
|     "tsx": "4.19.3", | ||||
|     "webpack-cli": "6.0.1",     | ||||
|     "webpack": "5.99.6", | ||||
|     "sass": "1.86.3", | ||||
|     "sass-loader": "16.0.5", | ||||
|     "electron": "35.1.5", | ||||
|     "debounce": "2.2.0", | ||||
|     "vitest": "3.1.1", | ||||
|     "css-loader": "7.1.2", | ||||
|     "postcss-loader": "8.1.1" | ||||
|   } | ||||
| } | ||||
| @ -1,40 +0,0 @@ | ||||
| { | ||||
|   "name": "@triliumnext/electron", | ||||
|   "version": "0.0.1", | ||||
|   "description": "Desktop client for TriliumNext, embedding both the client and the server.", | ||||
|   "homepage": "https://github.com/TriliumNext/Notes#readme", | ||||
|   "bugs": { | ||||
|     "url": "https://github.com/TriliumNext/Notes/issues" | ||||
|   }, | ||||
|   "repository": { | ||||
|     "type": "git", | ||||
|     "url": "git+https://github.com/TriliumNext/Notes.git" | ||||
|   }, | ||||
|   "license": "AGPL-3.0-only", | ||||
|   "author": { | ||||
|     "name": "TriliumNext Notes Team", | ||||
|     "email": "contact@eliandoran.me", | ||||
|     "url": "https://github.com/TriliumNext/Notes" | ||||
|   }, | ||||
|   "type": "module", | ||||
|   "main": "src/electron-main.js", | ||||
|   "scripts": { | ||||
|     "start": "cross-env NODE_OPTIONS=\"--import tsx\" TRILIUM_DATA_DIR=./data TRILIUM_ENV=dev electron ./src/electron-main.ts --inspect=5858 .", | ||||
|     "start-prod": "npm run build:prepare-dist && npx electron-rebuild -m build && cross-env TRILIUM_DATA_DIR=./data TRILIUM_ENV=prod electron ./build/src/electron-main.js --inspect=5858 .", | ||||
| 
 | ||||
|     "build:clean": "rimraf ./dist ./build", | ||||
|     "build:copy-dist": "tsx ./scripts/copy-dist.ts", | ||||
|     "build:prepare-dist": "npm run build:clean && npm run build:copy-dist && npm run build:ts", | ||||
|     "build:ts": "tsc", | ||||
| 
 | ||||
|     "electron-forge:start": "npm run build:prepare-dist && cd ./build && electron-forge start", | ||||
|     "electron-forge:make": "npm run build:prepare-dist && cross-env DEBUG=electron-windows-installer:* electron-forge make ./build", | ||||
|     "electron-forge:package": "npm run build:prepare-dist && cd ./build && electron-forge package" | ||||
|   }, | ||||
|   "dependencies": {     | ||||
|     "@triliumnext/server": "0.0.1" | ||||
|   }, | ||||
|   "devDependencies": {         | ||||
|     "tsx": "4.19.3" | ||||
|   } | ||||
| } | ||||
| @ -1,88 +0,0 @@ | ||||
| import { execSync } from "child_process"; | ||||
| import fs from "fs-extra"; | ||||
| import path from "path"; | ||||
| 
 | ||||
| const DEST_DIR = "./build"; | ||||
| 
 | ||||
| const VERBOSE = process.env.VERBOSE; | ||||
| 
 | ||||
| function log(...args: any[]) { | ||||
|     if (VERBOSE) { | ||||
|         console.log(...args); | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| try { | ||||
|     fs.mkdirpSync(DEST_DIR); | ||||
|     copyNodeModules("./package.json"); | ||||
|     copyPackageJson(); | ||||
| 
 | ||||
|     /** | ||||
|      * Copy the server. | ||||
|      */ | ||||
|     fs.copySync("../server/build", path.join(DEST_DIR, "node_modules", "@triliumnext/server")); | ||||
| 
 | ||||
|     /** | ||||
|      * Copy assets. | ||||
|      */ | ||||
|     const assetsToCopy = new Set([ | ||||
|         "./tsconfig.json", | ||||
|         "./forge.config.cjs", | ||||
|         "./scripts/electron-forge/desktop.ejs", | ||||
|         "./scripts/electron-forge/sign-windows.cjs", | ||||
|     ]); | ||||
| 
 | ||||
|     for (const asset of assetsToCopy) { | ||||
|         log(`Copying ${asset}`); | ||||
|         fs.copySync(asset, path.join(DEST_DIR, asset)); | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * Directories to be copied relative to the project root into <resource_dir>/src/public/app-dist. | ||||
|      */ | ||||
|     const publicDirsToCopy = ["../server/src/public/app/doc_notes"]; | ||||
|     const PUBLIC_DIR = path.join(DEST_DIR, "src", "public", "app-dist"); | ||||
|     for (const dir of publicDirsToCopy) { | ||||
|         fs.copySync(dir, path.join(PUBLIC_DIR, path.basename(dir))); | ||||
|     } | ||||
| 
 | ||||
|     console.log("Copying complete!") | ||||
| 
 | ||||
| } catch(err) { | ||||
|     console.error("Error during copy:", err) | ||||
|     process.exit(1) | ||||
| } | ||||
| 
 | ||||
| /** | ||||
|  * We cannot copy the node_modules directory directly because we are in a monorepo and all the packages are gathered at root level. | ||||
|  * We cannot copy the files manually because we'd have to implement all the npm lookup logic, especially since there are issues with the same library having multiple versions across dependencies. | ||||
|  * | ||||
|  * @param packageJsonPath | ||||
|  */ | ||||
| function copyNodeModules(packageJsonPath: string) { | ||||
|     const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, "utf8")); | ||||
| 
 | ||||
|     // Skip monorepo packages
 | ||||
|     packageJson.dependencies = Object.fromEntries( | ||||
|         Object.entries(packageJson.dependencies).filter(([key]) => { | ||||
|             return !key.startsWith("@triliumnext"); | ||||
|         })); | ||||
| 
 | ||||
|     // Trigger an npm install to obtain the dependencies.
 | ||||
|     fs.writeFileSync(path.join(DEST_DIR, "package.json"), JSON.stringify(packageJson)); | ||||
|     execSync(`npm install --omit=dev`, { | ||||
|         cwd: DEST_DIR, | ||||
|         stdio: "inherit", | ||||
|     }); | ||||
| } | ||||
| 
 | ||||
| /** | ||||
|  * Rewrite the name field of `package.json` since electron-forge does not support forward slashes in the name. | ||||
|  * Other attempts to rewrite the name field in the forge config have failed. | ||||
|  */ | ||||
| function copyPackageJson() { | ||||
|     const packageJsonPath = path.join("package.json"); | ||||
|     const packageJson = fs.readJSONSync(packageJsonPath); | ||||
|     packageJson.name = "trilium"; | ||||
|     fs.writeJSONSync(path.join(DEST_DIR, "package.json"), packageJson, { spaces: 2 }); | ||||
| } | ||||
| @ -1,30 +0,0 @@ | ||||
| { | ||||
|   "name": "@triliumnext/commons", | ||||
|   "version": "0.0.1", | ||||
|   "description": "Shared library between the clients (e.g. browser, Electron) and the server, mostly for type definitions and utility methods.", | ||||
|   "homepage": "https://github.com/TriliumNext/Notes#readme", | ||||
|   "bugs": { | ||||
|     "url": "https://github.com/TriliumNext/Notes/issues" | ||||
|   }, | ||||
|   "repository": { | ||||
|     "type": "git", | ||||
|     "url": "git+https://github.com/TriliumNext/Notes.git" | ||||
|   }, | ||||
|   "license": "AGPL-3.0-only", | ||||
|   "author": { | ||||
|     "name": "TriliumNext Notes Team", | ||||
|     "email": "contact@eliandoran.me", | ||||
|     "url": "https://github.com/TriliumNext/Notes" | ||||
|   }, | ||||
|   "type": "module", | ||||
|   "main": "build/index.js", | ||||
|   "types": "build/index.d.ts", | ||||
|   "scripts": { | ||||
|     "build": "tsc" | ||||
|   }, | ||||
|   "devDependencies": { | ||||
|     "@types/node": "^22.14.1", | ||||
|     "typescript": "5.8.3", | ||||
|     "vitest": "^3.1.1" | ||||
|   } | ||||
| } | ||||
| @ -1,8 +0,0 @@ | ||||
| { | ||||
|     "compilerOptions": { | ||||
|         "module": "NodeNext", | ||||
|         "declaration": true, | ||||
|         "outDir": "build", | ||||
|     }, | ||||
|     "include": [ "./src/**/*.ts" ] | ||||
| } | ||||
| @ -1,7 +1,14 @@ | ||||
| { | ||||
|   "name": "@triliumnext/client", | ||||
|   "version": "0.0.1", | ||||
|   "description": "JQuery-based client for TriliumNext, used for both web and desktop (via Electron)", | ||||
|   "private": true, | ||||
|   "license": "AGPL-3.0-only", | ||||
|   "author": { | ||||
|     "name": "TriliumNext Notes Team", | ||||
|     "email": "contact@eliandoran.me", | ||||
|     "url": "https://github.com/TriliumNext/Notes" | ||||
|   }, | ||||
|   "dependencies": { | ||||
|     "@eslint/js": "9.25.0", | ||||
|     "@excalidraw/excalidraw": "0.18.0", | ||||
|  | ||||
| @ -1,6 +1,7 @@ | ||||
| { | ||||
|   "name": "@triliumnext/server", | ||||
|   "version": "0.0.1", | ||||
|   "description": "Desktop client for TriliumNext, embedding both the client and the server.", | ||||
|   "private": true, | ||||
|   "dependencies": {     | ||||
|     "better-sqlite3": "11.9.1", | ||||
|  | ||||
| @ -1,6 +1,7 @@ | ||||
| { | ||||
|   "name": "@triliumnext/commons", | ||||
|   "version": "0.0.1", | ||||
|   "description": "Shared library between the clients (e.g. browser, Electron) and the server, mostly for type definitions and utility methods.", | ||||
|   "private": true, | ||||
|   "type": "module", | ||||
|   "main": "./dist/index.js", | ||||
| @ -15,6 +16,12 @@ | ||||
|       "default": "./dist/index.js" | ||||
|     } | ||||
|   }, | ||||
|   "license": "AGPL-3.0-only", | ||||
|   "author": { | ||||
|     "name": "TriliumNext Notes Team", | ||||
|     "email": "contact@eliandoran.me", | ||||
|     "url": "https://github.com/TriliumNext/Notes" | ||||
|   }, | ||||
|   "nx": { | ||||
|     "sourceRoot": "packages/commons/src", | ||||
|     "targets": { | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Elian Doran
						Elian Doran