From bfb5d47a055d5789056c570bdb22ab9844378107 Mon Sep 17 00:00:00 2001 From: zhangmo8 Date: Tue, 3 Jun 2025 13:40:18 +0800 Subject: [PATCH 01/18] chore: yarn to pnpm --- .github/workflows/build.yml | 42 ++++++++++++++++++++++++------------- package.json | 29 ++++++++++++++----------- 2 files changed, 44 insertions(+), 27 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index aa4dcf4d0..63c16ddbd 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -31,18 +31,22 @@ jobs: - name: Setup Node.js uses: actions/setup-node@v4 with: - node-version: '22' + node-version: '20.12.2' + - name: Setup pnpm + uses: pnpm/action-setup@v2 + with: + version: 10.11.0 - name: Install dependencies - run: npm install + run: pnpm install env: npm_config_platform: win32 npm_config_arch: ${{ matrix.arch }} - name: Install Node Runtime - run: npm run installRuntime:win:${{ matrix.arch }} + run: pnpm run installRuntime:win:${{ matrix.arch }} - name: Install Sharp - run: npm install sharp --build-from-source + run: pnpm install sharp --build-from-source - name: Build Windows - run: npm run build:win:${{ matrix.arch }} + run: pnpm run build:win:${{ matrix.arch }} env: VITE_GITHUB_CLIENT_ID: ${{ secrets.DC_GITHUB_CLIENT_ID }} VITE_GITHUB_CLIENT_SECRET: ${{ secrets.DC_GITHUB_CLIENT_SECRET }} @@ -70,18 +74,22 @@ jobs: - name: Setup Node.js uses: actions/setup-node@v4 with: - node-version: '22' + node-version: '20.12.2' + - name: Setup pnpm + uses: pnpm/action-setup@v2 + with: + version: 10.11.0 - name: Install dependencies - run: npm install + run: pnpm install env: npm_config_platform: linux npm_config_arch: ${{ matrix.arch }} - name: Install Node Runtime - run: npm run installRuntime:linux:${{ matrix.arch }} + run: pnpm run installRuntime:linux:${{ matrix.arch }} - name: Install Sharp - run: npm install --cpu=wasm32 sharp + run: pnpm install --cpu=wasm32 sharp - name: Build Linux - run: npm run build:linux:${{ matrix.arch }} + run: pnpm run build:linux:${{ matrix.arch }} env: VITE_GITHUB_CLIENT_ID: ${{ secrets.DC_GITHUB_CLIENT_ID }} VITE_GITHUB_CLIENT_SECRET: ${{ secrets.DC_GITHUB_CLIENT_SECRET }} @@ -110,18 +118,22 @@ jobs: - name: Setup Node.js uses: actions/setup-node@v4 with: - node-version: '22' + node-version: '20.12.2' + - name: Setup pnpm + uses: pnpm/action-setup@v2 + with: + version: 10.11.0 - name: Install dependencies - run: npm install + run: pnpm install env: npm_config_platform: darwin npm_config_arch: ${{ matrix.arch }} - name: Install Node Runtime - run: npm run installRuntime:mac:${{ matrix.arch }} + run: pnpm run installRuntime:mac:${{ matrix.arch }} - name: Install Sharp - run: npm i --cpu=${{ matrix.arch }} --os=darwin sharp + run: pnpm install --cpu=${{ matrix.arch }} --os=darwin sharp - name: Build Mac - run: npm run build:mac:${{ matrix.arch }} + run: pnpm run build:mac:${{ matrix.arch }} env: CSC_LINK: ${{ secrets.DEEPCHAT_CSC_LINK }} CSC_KEY_PASSWORD: ${{ secrets.DEEPCHAT_CSC_KEY_PASS }} diff --git a/package.json b/package.json index 584318682..a015327a6 100644 --- a/package.json +++ b/package.json @@ -5,28 +5,33 @@ "main": "./out/main/index.js", "author": "ThinkInAIXYZ", "type": "module", + "engines": { + "node": ">=20.12.2", + "pnpm": ">=10.11.0" + }, + "packageManager": "pnpm@10.11.0", "scripts": { "format": "prettier --write .", "lint": "eslint --cache .", "typecheck:node": "tsc --noEmit -p tsconfig.node.json --composite false", "typecheck:web": "vue-tsc --noEmit -p tsconfig.web.json --composite false", - "typecheck": "npm run typecheck:node && npm run typecheck:web", + "typecheck": "pnpm run typecheck:node && pnpm run typecheck:web", "start": "electron-vite preview", "dev": "electron-vite dev --watch", "dev:inspect": "electron-vite dev --watch --inspect=9229", "dev:linux": "electron-vite dev --watch --noSandbox", - "build": "npm run typecheck && electron-vite build", + "build": "pnpm run typecheck && electron-vite build", "postinstall": "node scripts/postinstall.js && electron-builder install-app-deps", - "build:unpack": "npm run build && electron-builder --dir", - "build:win": "npm run build && electron-builder --win", - "build:win:x64": "npm run build && electron-builder --win --x64", - "build:win:arm64": "npm run build && electron-builder --win --arm64", - "build:mac": "npm run build && electron-builder --mac", - "build:mac:arm64": "npm run build && electron-builder --mac --arm64", - "build:mac:x64": "npm run build && electron-builder -c electron-builder-macx64.yml --mac --x64 ", - "build:linux": "npm run build && electron-builder --linux", - "build:linux:x64": "npm run build && electron-builder --linux --x64", - "build:linux:arm64": "npm run build && electron-builder --linux --arm64", + "build:unpack": "pnpm run build && electron-builder --dir", + "build:win": "pnpm run build && electron-builder --win", + "build:win:x64": "pnpm run build && electron-builder --win --x64", + "build:win:arm64": "pnpm run build && electron-builder --win --arm64", + "build:mac": "pnpm run build && electron-builder --mac", + "build:mac:arm64": "pnpm run build && electron-builder --mac --arm64", + "build:mac:x64": "pnpm run build && electron-builder -c electron-builder-macx64.yml --mac --x64 ", + "build:linux": "pnpm run build && electron-builder --linux", + "build:linux:x64": "pnpm run build && electron-builder --linux --x64", + "build:linux:arm64": "pnpm run build && electron-builder --linux --arm64", "afterSign": "scripts/notarize.js", "installRuntime": "tiny-runtime-injector -d runtime/node -n v22.15.0 --no-docs --no-dev --no-sourcemaps", "installRuntime:win:x64": "tiny-runtime-injector -d runtime/node -n v22.15.0 -a x64 -p win32 --no-docs --no-dev --no-sourcemaps", From ea7da039615e441747dbb65ec2daa988d5201e96 Mon Sep 17 00:00:00 2001 From: zhangmo8 Date: Tue, 3 Jun 2025 13:49:10 +0800 Subject: [PATCH 02/18] fix: fix ci for pnpm --- .github/workflows/build.yml | 13 ++- package.json | 190 ------------------------------------ 2 files changed, 10 insertions(+), 193 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 63c16ddbd..638bd5a5b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -44,7 +44,9 @@ jobs: - name: Install Node Runtime run: pnpm run installRuntime:win:${{ matrix.arch }} - name: Install Sharp - run: pnpm install sharp --build-from-source + run: pnpm install sharp + env: + npm_config_build_from_source: true - name: Build Windows run: pnpm run build:win:${{ matrix.arch }} env: @@ -87,7 +89,9 @@ jobs: - name: Install Node Runtime run: pnpm run installRuntime:linux:${{ matrix.arch }} - name: Install Sharp - run: pnpm install --cpu=wasm32 sharp + run: pnpm install sharp + env: + npm_config_cpu: wasm32 - name: Build Linux run: pnpm run build:linux:${{ matrix.arch }} env: @@ -131,7 +135,10 @@ jobs: - name: Install Node Runtime run: pnpm run installRuntime:mac:${{ matrix.arch }} - name: Install Sharp - run: pnpm install --cpu=${{ matrix.arch }} --os=darwin sharp + run: pnpm install sharp + env: + npm_config_cpu: ${{ matrix.arch }} + npm_config_os: darwin - name: Build Mac run: pnpm run build:mac:${{ matrix.arch }} env: diff --git a/package.json b/package.json index a015327a6..e69de29bb 100644 --- a/package.json +++ b/package.json @@ -1,190 +0,0 @@ -{ - "name": "DeepChat", - "version": "0.2.2", - "description": "DeepChat,一个简单易用的AI客户端", - "main": "./out/main/index.js", - "author": "ThinkInAIXYZ", - "type": "module", - "engines": { - "node": ">=20.12.2", - "pnpm": ">=10.11.0" - }, - "packageManager": "pnpm@10.11.0", - "scripts": { - "format": "prettier --write .", - "lint": "eslint --cache .", - "typecheck:node": "tsc --noEmit -p tsconfig.node.json --composite false", - "typecheck:web": "vue-tsc --noEmit -p tsconfig.web.json --composite false", - "typecheck": "pnpm run typecheck:node && pnpm run typecheck:web", - "start": "electron-vite preview", - "dev": "electron-vite dev --watch", - "dev:inspect": "electron-vite dev --watch --inspect=9229", - "dev:linux": "electron-vite dev --watch --noSandbox", - "build": "pnpm run typecheck && electron-vite build", - "postinstall": "node scripts/postinstall.js && electron-builder install-app-deps", - "build:unpack": "pnpm run build && electron-builder --dir", - "build:win": "pnpm run build && electron-builder --win", - "build:win:x64": "pnpm run build && electron-builder --win --x64", - "build:win:arm64": "pnpm run build && electron-builder --win --arm64", - "build:mac": "pnpm run build && electron-builder --mac", - "build:mac:arm64": "pnpm run build && electron-builder --mac --arm64", - "build:mac:x64": "pnpm run build && electron-builder -c electron-builder-macx64.yml --mac --x64 ", - "build:linux": "pnpm run build && electron-builder --linux", - "build:linux:x64": "pnpm run build && electron-builder --linux --x64", - "build:linux:arm64": "pnpm run build && electron-builder --linux --arm64", - "afterSign": "scripts/notarize.js", - "installRuntime": "tiny-runtime-injector -d runtime/node -n v22.15.0 --no-docs --no-dev --no-sourcemaps", - "installRuntime:win:x64": "tiny-runtime-injector -d runtime/node -n v22.15.0 -a x64 -p win32 --no-docs --no-dev --no-sourcemaps", - "installRuntime:win:arm64": "tiny-runtime-injector -d runtime/node -n v22.15.0 -a arm64 -p win32 --no-docs --no-dev --no-sourcemaps", - "installRuntime:mac:arm64": "tiny-runtime-injector -d runtime/node -n v22.15.0 -a arm64 -p darwin --no-docs --no-dev --no-sourcemaps", - "installRuntime:mac:x64": "tiny-runtime-injector -d runtime/node -n v22.15.0 -a x64 -p darwin --no-docs --no-dev --no-sourcemaps", - "installRuntime:linux:x64": "tiny-runtime-injector -d runtime/node -n v22.15.0 -a x64 -p linux --no-docs --no-dev --no-sourcemaps", - "installRuntime:linux:arm64": "tiny-runtime-injector -d runtime/node -n v22.15.0 -a arm64 -p linux --no-docs --no-dev --no-sourcemaps", - "i18n": "i18n-check -s zh-CN -f i18next --locales src/renderer/src/i18n", - "i18n:en": "i18n-check -s en-US -f i18next --locales src/renderer/src/i18n", - "cleanRuntime": "rm -rf runtime/node" - }, - "dependencies": { - "@anthropic-ai/sdk": "^0.40.1", - "@electron-toolkit/preload": "^3.0.1", - "@electron-toolkit/utils": "^4.0.0", - "@google/genai": "^1.0.1", - "@modelcontextprotocol/sdk": "^1.12.0", - "axios": "^1.7.9", - "better-sqlite3-multiple-ciphers": "11.10.0", - "cheerio": "^1.0.0", - "compare-versions": "^6.1.1", - "diff": "^7.0.0", - "electron-log": "^5.3.3", - "electron-store": "^8.2.0", - "electron-updater": "^6.1.7", - "electron-window-state": "^5.0.3", - "fflate": "^0.8.2", - "file-type": "^20.5.0", - "https-proxy-agent": "^7.0.6", - "jsonrepair": "^3.12.0", - "mammoth": "^1.9.0", - "mime-types": "^2.1.35", - "nanoid": "^5.1.5", - "ollama": "^0.5.15", - "openai": "^4.103.0", - "pdf-parse-new": "^1.3.9", - "pyodide": "^0.27.5", - "sharp": "^0.33.5", - "tokenx": "^0.4.1", - "turndown": "^7.2.0", - "undici": "^7.8.0", - "xlsx": "https://cdn.sheetjs.com/xlsx-0.20.3/xlsx-0.20.3.tgz", - "xml2js": "^0.6.2", - "zod": "^3.24.3" - }, - "devDependencies": { - "@codemirror/state": "^6.5.2", - "@electron-toolkit/eslint-config-prettier": "3.0.0", - "@electron-toolkit/eslint-config-ts": "^3.0.0", - "@electron-toolkit/tsconfig": "^1.0.1", - "@electron/notarize": "^2.5.0", - "@iconify-json/lucide": "^1.2.39", - "@iconify-json/vscode-icons": "^1.2.20", - "@iconify/vue": "^4.3.0", - "@lezer/highlight": "^1.2.1", - "@lingual/i18n-check": "^0.8.4", - "@radix-icons/vue": "^1.0.0", - "@rushstack/eslint-patch": "^1.10.3", - "@tailwindcss/typography": "^0.5.16", - "@tailwindcss/vite": "^4.0.4", - "@tiptap/core": "^2.11.7", - "@tiptap/extension-code-block": "^2.11.9", - "@tiptap/extension-document": "^2.11.7", - "@tiptap/extension-hard-break": "^2.11.7", - "@tiptap/extension-history": "^2.12.0", - "@tiptap/extension-mention": "^2.11.7", - "@tiptap/extension-paragraph": "^2.11.7", - "@tiptap/extension-placeholder": "^2.11.7", - "@tiptap/extension-text": "^2.11.7", - "@tiptap/pm": "^2.11.7", - "@tiptap/suggestion": "^2.11.7", - "@tiptap/vue-3": "^2.11.7", - "@types/better-sqlite3": "^7.6.0", - "@types/dompurify": "^3.0.5", - "@types/katex": "^0.16.7", - "@types/markdown-it": "^14.1.2", - "@types/mermaid": "^9.1.0", - "@types/node": "^22.14.1", - "@types/xlsx": "^0.0.35", - "@uiw/codemirror-extensions-langs": "^4.23.11", - "@vitejs/plugin-vue": "^5.2.3", - "@vscode/markdown-it-katex": "^1.1.1", - "@vue/eslint-config-prettier": "^10.2.0", - "@vue/eslint-config-typescript": "^14.5.0", - "@vueuse/core": "^12.7.0", - "@xsai/model": "^0.1.0-beta.4", - "autoprefixer": "^10.4.20", - "class-variance-authority": "^0.7.1", - "clsx": "^2.1.1", - "codemirror": "^6.0.1", - "codemirror-lang-glsl": "^0.5.0", - "codemirror-lang-makefile": "^0.1.1", - "codemirror-lang-terraform": "^0.1.1", - "dompurify": "^3.2.4", - "electron": "^35.4.0", - "electron-builder": "26.0.12", - "electron-vite": "^3.1.0", - "eslint": "^9.24.0", - "eslint-plugin-vue": "^10.1.0", - "glob": "^11.0.1", - "highlight.js": "^11.11.1", - "katex": "^0.16.21", - "lucide-vue-next": "^0.511.0", - "markdown-it": "^14.1.0", - "markdown-it-container": "^4.0.0", - "markdown-it-del": "^0.1.0", - "markdown-it-emoji": "^3.0.0", - "markdown-it-footnote": "^4.0.0", - "markdown-it-ins": "^4.0.0", - "markdown-it-mark": "^4.0.0", - "markdown-it-mathjax3": "^4.3.2", - "markdown-it-sub": "^2.0.0", - "markdown-it-sup": "^2.0.0", - "markdown-it-task-checkbox": "^1.0.6", - "markdown-it-task-list": "^0.1.2", - "markdown-it-texmath": "^1.0.0", - "marked": "^15.0.7", - "marked-katex-extension": "^5.1.4", - "mermaid": "^11.6.0", - "minimatch": "^10.0.1", - "pinia": "^3.0.2", - "prettier": "^3.5.3", - "radix-vue": "^1.9.14", - "tailwind-merge": "^2.6.0", - "tailwind-scrollbar-hide": "^2.0.0", - "tailwindcss": "3.4.17", - "tailwindcss-animate": "^1.0.7", - "tiny-runtime-injector": "^0.0.2", - "tippy.js": "^6.3.7", - "typescript": "^5.8.3", - "vite": "^6.3.4", - "vite-plugin-vue-devtools": "^7.7.6", - "vite-svg-loader": "^5.1.0", - "vue": "^3.5.14", - "vue-eslint-parser": "^10.1.3", - "vue-i18n": "^11.1.3", - "vue-renderer-markdown": "^0.0.14", - "vue-router": "4", - "vue-tsc": "^2.2.10", - "vuedraggable": "^4.1.0", - "zod-to-json-schema": "^3.24.5" - }, - "pnpm": { - "onlyBuiltDependencies": [ - "electron" - ], - "ignoredBuiltDependencies": [ - "better-sqlite3-multiple-ciphers", - "esbuild", - "maplibre-gl", - "sharp", - "vue-demi" - ] - } -} From d52b1a2e3e8d20890680c16e1fdbb1912e54ec1d Mon Sep 17 00:00:00 2001 From: zhangmo8 Date: Tue, 3 Jun 2025 13:52:27 +0800 Subject: [PATCH 03/18] fix: fix ci for pnpm --- package.json | 190 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 190 insertions(+) diff --git a/package.json b/package.json index e69de29bb..a015327a6 100644 --- a/package.json +++ b/package.json @@ -0,0 +1,190 @@ +{ + "name": "DeepChat", + "version": "0.2.2", + "description": "DeepChat,一个简单易用的AI客户端", + "main": "./out/main/index.js", + "author": "ThinkInAIXYZ", + "type": "module", + "engines": { + "node": ">=20.12.2", + "pnpm": ">=10.11.0" + }, + "packageManager": "pnpm@10.11.0", + "scripts": { + "format": "prettier --write .", + "lint": "eslint --cache .", + "typecheck:node": "tsc --noEmit -p tsconfig.node.json --composite false", + "typecheck:web": "vue-tsc --noEmit -p tsconfig.web.json --composite false", + "typecheck": "pnpm run typecheck:node && pnpm run typecheck:web", + "start": "electron-vite preview", + "dev": "electron-vite dev --watch", + "dev:inspect": "electron-vite dev --watch --inspect=9229", + "dev:linux": "electron-vite dev --watch --noSandbox", + "build": "pnpm run typecheck && electron-vite build", + "postinstall": "node scripts/postinstall.js && electron-builder install-app-deps", + "build:unpack": "pnpm run build && electron-builder --dir", + "build:win": "pnpm run build && electron-builder --win", + "build:win:x64": "pnpm run build && electron-builder --win --x64", + "build:win:arm64": "pnpm run build && electron-builder --win --arm64", + "build:mac": "pnpm run build && electron-builder --mac", + "build:mac:arm64": "pnpm run build && electron-builder --mac --arm64", + "build:mac:x64": "pnpm run build && electron-builder -c electron-builder-macx64.yml --mac --x64 ", + "build:linux": "pnpm run build && electron-builder --linux", + "build:linux:x64": "pnpm run build && electron-builder --linux --x64", + "build:linux:arm64": "pnpm run build && electron-builder --linux --arm64", + "afterSign": "scripts/notarize.js", + "installRuntime": "tiny-runtime-injector -d runtime/node -n v22.15.0 --no-docs --no-dev --no-sourcemaps", + "installRuntime:win:x64": "tiny-runtime-injector -d runtime/node -n v22.15.0 -a x64 -p win32 --no-docs --no-dev --no-sourcemaps", + "installRuntime:win:arm64": "tiny-runtime-injector -d runtime/node -n v22.15.0 -a arm64 -p win32 --no-docs --no-dev --no-sourcemaps", + "installRuntime:mac:arm64": "tiny-runtime-injector -d runtime/node -n v22.15.0 -a arm64 -p darwin --no-docs --no-dev --no-sourcemaps", + "installRuntime:mac:x64": "tiny-runtime-injector -d runtime/node -n v22.15.0 -a x64 -p darwin --no-docs --no-dev --no-sourcemaps", + "installRuntime:linux:x64": "tiny-runtime-injector -d runtime/node -n v22.15.0 -a x64 -p linux --no-docs --no-dev --no-sourcemaps", + "installRuntime:linux:arm64": "tiny-runtime-injector -d runtime/node -n v22.15.0 -a arm64 -p linux --no-docs --no-dev --no-sourcemaps", + "i18n": "i18n-check -s zh-CN -f i18next --locales src/renderer/src/i18n", + "i18n:en": "i18n-check -s en-US -f i18next --locales src/renderer/src/i18n", + "cleanRuntime": "rm -rf runtime/node" + }, + "dependencies": { + "@anthropic-ai/sdk": "^0.40.1", + "@electron-toolkit/preload": "^3.0.1", + "@electron-toolkit/utils": "^4.0.0", + "@google/genai": "^1.0.1", + "@modelcontextprotocol/sdk": "^1.12.0", + "axios": "^1.7.9", + "better-sqlite3-multiple-ciphers": "11.10.0", + "cheerio": "^1.0.0", + "compare-versions": "^6.1.1", + "diff": "^7.0.0", + "electron-log": "^5.3.3", + "electron-store": "^8.2.0", + "electron-updater": "^6.1.7", + "electron-window-state": "^5.0.3", + "fflate": "^0.8.2", + "file-type": "^20.5.0", + "https-proxy-agent": "^7.0.6", + "jsonrepair": "^3.12.0", + "mammoth": "^1.9.0", + "mime-types": "^2.1.35", + "nanoid": "^5.1.5", + "ollama": "^0.5.15", + "openai": "^4.103.0", + "pdf-parse-new": "^1.3.9", + "pyodide": "^0.27.5", + "sharp": "^0.33.5", + "tokenx": "^0.4.1", + "turndown": "^7.2.0", + "undici": "^7.8.0", + "xlsx": "https://cdn.sheetjs.com/xlsx-0.20.3/xlsx-0.20.3.tgz", + "xml2js": "^0.6.2", + "zod": "^3.24.3" + }, + "devDependencies": { + "@codemirror/state": "^6.5.2", + "@electron-toolkit/eslint-config-prettier": "3.0.0", + "@electron-toolkit/eslint-config-ts": "^3.0.0", + "@electron-toolkit/tsconfig": "^1.0.1", + "@electron/notarize": "^2.5.0", + "@iconify-json/lucide": "^1.2.39", + "@iconify-json/vscode-icons": "^1.2.20", + "@iconify/vue": "^4.3.0", + "@lezer/highlight": "^1.2.1", + "@lingual/i18n-check": "^0.8.4", + "@radix-icons/vue": "^1.0.0", + "@rushstack/eslint-patch": "^1.10.3", + "@tailwindcss/typography": "^0.5.16", + "@tailwindcss/vite": "^4.0.4", + "@tiptap/core": "^2.11.7", + "@tiptap/extension-code-block": "^2.11.9", + "@tiptap/extension-document": "^2.11.7", + "@tiptap/extension-hard-break": "^2.11.7", + "@tiptap/extension-history": "^2.12.0", + "@tiptap/extension-mention": "^2.11.7", + "@tiptap/extension-paragraph": "^2.11.7", + "@tiptap/extension-placeholder": "^2.11.7", + "@tiptap/extension-text": "^2.11.7", + "@tiptap/pm": "^2.11.7", + "@tiptap/suggestion": "^2.11.7", + "@tiptap/vue-3": "^2.11.7", + "@types/better-sqlite3": "^7.6.0", + "@types/dompurify": "^3.0.5", + "@types/katex": "^0.16.7", + "@types/markdown-it": "^14.1.2", + "@types/mermaid": "^9.1.0", + "@types/node": "^22.14.1", + "@types/xlsx": "^0.0.35", + "@uiw/codemirror-extensions-langs": "^4.23.11", + "@vitejs/plugin-vue": "^5.2.3", + "@vscode/markdown-it-katex": "^1.1.1", + "@vue/eslint-config-prettier": "^10.2.0", + "@vue/eslint-config-typescript": "^14.5.0", + "@vueuse/core": "^12.7.0", + "@xsai/model": "^0.1.0-beta.4", + "autoprefixer": "^10.4.20", + "class-variance-authority": "^0.7.1", + "clsx": "^2.1.1", + "codemirror": "^6.0.1", + "codemirror-lang-glsl": "^0.5.0", + "codemirror-lang-makefile": "^0.1.1", + "codemirror-lang-terraform": "^0.1.1", + "dompurify": "^3.2.4", + "electron": "^35.4.0", + "electron-builder": "26.0.12", + "electron-vite": "^3.1.0", + "eslint": "^9.24.0", + "eslint-plugin-vue": "^10.1.0", + "glob": "^11.0.1", + "highlight.js": "^11.11.1", + "katex": "^0.16.21", + "lucide-vue-next": "^0.511.0", + "markdown-it": "^14.1.0", + "markdown-it-container": "^4.0.0", + "markdown-it-del": "^0.1.0", + "markdown-it-emoji": "^3.0.0", + "markdown-it-footnote": "^4.0.0", + "markdown-it-ins": "^4.0.0", + "markdown-it-mark": "^4.0.0", + "markdown-it-mathjax3": "^4.3.2", + "markdown-it-sub": "^2.0.0", + "markdown-it-sup": "^2.0.0", + "markdown-it-task-checkbox": "^1.0.6", + "markdown-it-task-list": "^0.1.2", + "markdown-it-texmath": "^1.0.0", + "marked": "^15.0.7", + "marked-katex-extension": "^5.1.4", + "mermaid": "^11.6.0", + "minimatch": "^10.0.1", + "pinia": "^3.0.2", + "prettier": "^3.5.3", + "radix-vue": "^1.9.14", + "tailwind-merge": "^2.6.0", + "tailwind-scrollbar-hide": "^2.0.0", + "tailwindcss": "3.4.17", + "tailwindcss-animate": "^1.0.7", + "tiny-runtime-injector": "^0.0.2", + "tippy.js": "^6.3.7", + "typescript": "^5.8.3", + "vite": "^6.3.4", + "vite-plugin-vue-devtools": "^7.7.6", + "vite-svg-loader": "^5.1.0", + "vue": "^3.5.14", + "vue-eslint-parser": "^10.1.3", + "vue-i18n": "^11.1.3", + "vue-renderer-markdown": "^0.0.14", + "vue-router": "4", + "vue-tsc": "^2.2.10", + "vuedraggable": "^4.1.0", + "zod-to-json-schema": "^3.24.5" + }, + "pnpm": { + "onlyBuiltDependencies": [ + "electron" + ], + "ignoredBuiltDependencies": [ + "better-sqlite3-multiple-ciphers", + "esbuild", + "maplibre-gl", + "sharp", + "vue-demi" + ] + } +} From e46da0afba8c889fbd22d9fc363018862bc530cf Mon Sep 17 00:00:00 2001 From: zhangmo8 Date: Tue, 3 Jun 2025 14:35:05 +0800 Subject: [PATCH 04/18] chore: only pnpm --- package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/package.json b/package.json index a015327a6..55d37cca3 100644 --- a/package.json +++ b/package.json @@ -11,6 +11,7 @@ }, "packageManager": "pnpm@10.11.0", "scripts": { + "preinstall": "npx only-allow pnpm", "format": "prettier --write .", "lint": "eslint --cache .", "typecheck:node": "tsc --noEmit -p tsconfig.node.json --composite false", From 89fbeecb26363c6c1faee94fc5236a93c5cbb880 Mon Sep 17 00:00:00 2001 From: zhangmo8 Date: Tue, 3 Jun 2025 16:41:55 +0800 Subject: [PATCH 05/18] fix: fix sharp on mac arm build by x64 --- .github/workflows/build.yml | 6 ++++ package.json | 7 ++-- scripts/fix-sharp.js | 70 +++++++++++++++++++++++++++++++++++++ 3 files changed, 80 insertions(+), 3 deletions(-) create mode 100644 scripts/fix-sharp.js diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 638bd5a5b..d0fe2d817 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -137,8 +137,14 @@ jobs: - name: Install Sharp run: pnpm install sharp env: + npm_config_build_from_source: true npm_config_cpu: ${{ matrix.arch }} npm_config_os: darwin + - name: Copy Sharp binaries + run: | + mkdir -p dist/sharp-binaries + cp -R node_modules/sharp/vendor/lib dist/sharp-binaries/ + cp -R node_modules/sharp/build/Release dist/sharp-binaries/ - name: Build Mac run: pnpm run build:mac:${{ matrix.arch }} env: diff --git a/package.json b/package.json index 55d37cca3..92061641f 100644 --- a/package.json +++ b/package.json @@ -27,9 +27,10 @@ "build:win": "pnpm run build && electron-builder --win", "build:win:x64": "pnpm run build && electron-builder --win --x64", "build:win:arm64": "pnpm run build && electron-builder --win --arm64", - "build:mac": "pnpm run build && electron-builder --mac", - "build:mac:arm64": "pnpm run build && electron-builder --mac --arm64", - "build:mac:x64": "pnpm run build && electron-builder -c electron-builder-macx64.yml --mac --x64 ", + "fix:sharp": "node scripts/fix-sharp.js", + "build:mac": "pnpm run build && pnpm run fix:sharp && electron-builder --mac", + "build:mac:arm64": "pnpm run build && pnpm run fix:sharp && electron-builder --mac --arm64", + "build:mac:x64": "pnpm run build && pnpm run fix:sharp && electron-builder -c electron-builder-macx64.yml --mac --x64 ", "build:linux": "pnpm run build && electron-builder --linux", "build:linux:x64": "pnpm run build && electron-builder --linux --x64", "build:linux:arm64": "pnpm run build && electron-builder --linux --arm64", diff --git a/scripts/fix-sharp.js b/scripts/fix-sharp.js new file mode 100644 index 000000000..777895958 --- /dev/null +++ b/scripts/fix-sharp.js @@ -0,0 +1,70 @@ +// fix-sharp.js +// 该脚本用于修复跨平台构建时 sharp 模块的兼容性问题 +import fs from 'fs' +import path from 'path' +import { execSync } from 'child_process' + +/** + * 该函数在应用打包前执行,确保 sharp 模块能够在跨平台环境中正确加载 + */ +function fixSharpForCrossPlatform() { + console.log('开始修复 sharp 模块跨平台兼容性问题...'); + + try { + // 获取当前平台和目标架构信息 + const currentPlatform = process.platform; + const targetArch = process.env.npm_config_arch || process.arch; + + console.log(`当前平台: ${currentPlatform}, 目标架构: ${targetArch}`); + + // 如果是在 macOS 上构建 + if (currentPlatform === 'darwin') { + console.log('检测到 macOS 平台,准备处理 sharp 依赖...'); + + // 强制重新安装 sharp,确保二进制文件正确 + console.log('重新安装 sharp 模块...'); + + // 设置环境变量,确保使用正确的平台和架构 + const env = { + ...process.env, + npm_config_build_from_source: 'true', + npm_config_cpu: targetArch, + npm_config_os: 'darwin' + }; + + // 执行安装命令 + execSync('pnpm install sharp --force', { + stdio: 'inherit', + env + }); + + // 创建目标目录 + const sharpBinDir = path.join(process.cwd(), 'resources', 'sharp-bin', targetArch); + fs.mkdirSync(sharpBinDir, { recursive: true }); + + // 复制 sharp 的二进制文件到资源目录 + const sharpVendorDir = path.join(process.cwd(), 'node_modules', 'sharp', 'vendor'); + const sharpBuildDir = path.join(process.cwd(), 'node_modules', 'sharp', 'build', 'Release'); + + if (fs.existsSync(sharpVendorDir)) { + console.log(`复制 sharp vendor 文件从 ${sharpVendorDir} 到 ${sharpBinDir}`); + execSync(`cp -R "${sharpVendorDir}" "${sharpBinDir}"`); + } + + if (fs.existsSync(sharpBuildDir)) { + console.log(`复制 sharp build 文件从 ${sharpBuildDir} 到 ${sharpBinDir}`); + execSync(`cp -R "${sharpBuildDir}" "${sharpBinDir}"`); + } + + console.log('Sharp 二进制文件已复制到资源目录'); + } + + console.log('Sharp 模块跨平台兼容性修复完成!'); + } catch (error) { + console.error('修复 sharp 模块时出错:', error); + process.exit(1); + } +} + +// 执行修复函数 +fixSharpForCrossPlatform(); From 333be7968369dd1d7836935dff718e01eaddaa0a Mon Sep 17 00:00:00 2001 From: zerob13 Date: Fri, 13 Jun 2025 22:34:42 +0800 Subject: [PATCH 06/18] ci: try to support cross system build in pnpm --- .github/workflows/build.yml | 74 ++++++++------- package.json | 3 +- pnpm-workspace.yaml | 7 ++ scripts/install-sharp-for-platform.js | 125 ++++++++++++++++++++++++++ 4 files changed, 177 insertions(+), 32 deletions(-) create mode 100644 pnpm-workspace.yaml create mode 100644 scripts/install-sharp-for-platform.js diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 808f6d198..6b53a5aa6 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -28,31 +28,40 @@ jobs: platform: win-arm64 steps: - uses: actions/checkout@v4 + - name: Setup Node.js uses: actions/setup-node@v4 with: - node-version: '20.12.2' + node-version: '22.13.1' + - name: Setup pnpm uses: pnpm/action-setup@v2 with: - version: 10.11.0 + version: 10.12.1 + + - name: Configure pnpm workspace for Windows ${{ matrix.arch }} + run: pnpm run install:sharp + env: + TARGET_OS: win32 + TARGET_ARCH: ${{ matrix.arch }} + - name: Install dependencies run: pnpm install env: + npm_config_build_from_source: true npm_config_platform: win32 npm_config_arch: ${{ matrix.arch }} + - name: Install Node Runtime run: pnpm run installRuntime:win:${{ matrix.arch }} - - name: Install Sharp - run: pnpm install sharp - env: - npm_config_build_from_source: true + - name: Build Windows run: pnpm run build:win:${{ matrix.arch }} env: VITE_GITHUB_CLIENT_ID: ${{ secrets.DC_GITHUB_CLIENT_ID }} VITE_GITHUB_CLIENT_SECRET: ${{ secrets.DC_GITHUB_CLIENT_SECRET }} VITE_GITHUB_REDIRECT_URI: ${{ secrets.DC_GITHUB_REDIRECT_URI }} + - name: Upload artifacts uses: actions/upload-artifact@v4 with: @@ -73,31 +82,36 @@ jobs: platform: linux-x64 steps: - uses: actions/checkout@v4 + - name: Setup Node.js uses: actions/setup-node@v4 with: - node-version: '20.12.2' + node-version: '22.13.1' + - name: Setup pnpm uses: pnpm/action-setup@v2 with: - version: 10.11.0 + version: 10.12.1 + + - name: Configure pnpm workspace for Linux ${{ matrix.arch }} + run: pnpm run install:sharp + env: + TARGET_OS: linux + TARGET_ARCH: ${{ matrix.arch }} + - name: Install dependencies run: pnpm install - env: - npm_config_platform: linux - npm_config_arch: ${{ matrix.arch }} + - name: Install Node Runtime run: pnpm run installRuntime:linux:${{ matrix.arch }} - - name: Install Sharp - run: pnpm install sharp - env: - npm_config_cpu: wasm32 + - name: Build Linux run: pnpm run build:linux:${{ matrix.arch }} env: VITE_GITHUB_CLIENT_ID: ${{ secrets.DC_GITHUB_CLIENT_ID }} VITE_GITHUB_CLIENT_SECRET: ${{ secrets.DC_GITHUB_CLIENT_SECRET }} VITE_GITHUB_REDIRECT_URI: ${{ secrets.DC_GITHUB_REDIRECT_URI }} + - name: Upload artifacts uses: actions/upload-artifact@v4 with: @@ -119,32 +133,29 @@ jobs: platform: mac-arm64 steps: - uses: actions/checkout@v4 + - name: Setup Node.js uses: actions/setup-node@v4 with: - node-version: '20.12.2' + node-version: '22.13.1' + - name: Setup pnpm uses: pnpm/action-setup@v2 with: - version: 10.11.0 + version: 10.12.1 + + - name: Configure pnpm workspace for macOS ${{ matrix.arch }} + run: pnpm run install:sharp + env: + TARGET_OS: darwin + TARGET_ARCH: ${{ matrix.arch }} + - name: Install dependencies run: pnpm install - env: - npm_config_platform: darwin - npm_config_arch: ${{ matrix.arch }} + - name: Install Node Runtime run: pnpm run installRuntime:mac:${{ matrix.arch }} - - name: Install Sharp - run: pnpm install sharp - env: - npm_config_build_from_source: true - npm_config_cpu: ${{ matrix.arch }} - npm_config_os: darwin - - name: Copy Sharp binaries - run: | - mkdir -p dist/sharp-binaries - cp -R node_modules/sharp/vendor/lib dist/sharp-binaries/ - cp -R node_modules/sharp/build/Release dist/sharp-binaries/ + - name: Build Mac run: pnpm run build:mac:${{ matrix.arch }} env: @@ -158,6 +169,7 @@ jobs: VITE_GITHUB_CLIENT_SECRET: ${{ secrets.DC_GITHUB_CLIENT_SECRET }} VITE_GITHUB_REDIRECT_URI: ${{ secrets.DC_GITHUB_REDIRECT_URI }} NODE_OPTIONS: '--max-old-space-size=4096' + - name: Upload artifacts uses: actions/upload-artifact@v4 with: diff --git a/package.json b/package.json index e942de081..8a7bd6c73 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,7 @@ "node": ">=20.12.2", "pnpm": ">=10.11.0" }, - "packageManager": "pnpm@10.11.0", + "packageManager": "pnpm@10.12.1+sha512.f0dda8580f0ee9481c5c79a1d927b9164f2c478e90992ad268bbb2465a736984391d6333d2c327913578b2804af33474ca554ba29c04a8b13060a717675ae3ac", "scripts": { "preinstall": "npx only-allow pnpm", "test": "vitest", @@ -34,6 +34,7 @@ "build:win:x64": "pnpm run build && electron-builder --win --x64", "build:win:arm64": "pnpm run build && electron-builder --win --arm64", "fix:sharp": "node scripts/fix-sharp.js", + "install:sharp": "node scripts/install-sharp-for-platform.js", "build:mac": "pnpm run build && pnpm run fix:sharp && electron-builder --mac", "build:mac:arm64": "pnpm run build && pnpm run fix:sharp && electron-builder --mac --arm64", "build:mac:x64": "pnpm run build && pnpm run fix:sharp && electron-builder -c electron-builder-macx64.yml --mac --x64 ", diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yaml new file mode 100644 index 000000000..af397cb32 --- /dev/null +++ b/pnpm-workspace.yaml @@ -0,0 +1,7 @@ +supportedArchitectures: + os: + - current + cpu: + - current + libc: + - current diff --git a/scripts/install-sharp-for-platform.js b/scripts/install-sharp-for-platform.js new file mode 100644 index 000000000..d34d2bd88 --- /dev/null +++ b/scripts/install-sharp-for-platform.js @@ -0,0 +1,125 @@ +#!/usr/bin/env node + +/** + * Update pnpm-workspace.yaml supportedArchitectures for different platforms + * 根据不同平台动态修改 pnpm-workspace.yaml 的 supportedArchitectures 配置 + */ + +import { readFileSync, writeFileSync, existsSync } from 'fs'; +import { platform, arch } from 'os'; + +// Get platform info from environment or system +const targetOS = process.env.TARGET_OS || process.env.npm_config_os || platform(); +const targetArch = process.env.TARGET_ARCH || process.env.npm_config_arch || arch(); + +console.log(`🎯 Configuring pnpm workspace for platform: ${targetOS}-${targetArch}`); + +// Define platform-specific configurations +const platformConfigs = { + 'win32-x64': { + os: ['win32'], + cpu: [, 'x64'] + }, + 'win32-arm64': { + os: ['win32'], + cpu: ['arm64'] + }, + 'linux-x64': { + os: ['linux'], + cpu: ['wasm32'], // Include wasm32 for Sharp WebAssembly + }, + 'linux-arm64': { + os: ['linux'], + cpu: ['wasm32'], + }, + 'darwin-x64': { + os: ['darwin'], + cpu: ['x64'], + }, + 'darwin-arm64': { + os: ['darwin'], + cpu: ['arm64'], + } +}; + +const platformKey = `${targetOS}-${targetArch}`; +const config = platformConfigs[platformKey]; + +if (!config) { + console.warn(`⚠️ No specific configuration for ${platformKey}, using default`); + console.log(`📝 Keeping existing pnpm-workspace.yaml configuration`); + process.exit(0); +} + +const workspaceFile = 'pnpm-workspace.yaml'; + +try { + let existingContent = ''; + let otherConfigurations = []; + + // Read existing file if it exists + if (existsSync(workspaceFile)) { + existingContent = readFileSync(workspaceFile, 'utf8'); + + // Parse existing content to extract non-supportedArchitectures configurations + const lines = existingContent.split('\n'); + let inSupportedArchitectures = false; + + for (const line of lines) { + const trimmed = line.trim(); + + if (trimmed.startsWith('supportedArchitectures:')) { + inSupportedArchitectures = true; + continue; + } + + if (inSupportedArchitectures) { + // Check if we've reached a new top-level configuration + if (trimmed && !line.startsWith(' ') && !trimmed.startsWith('-')) { + inSupportedArchitectures = false; + otherConfigurations.push(line); + } + // Skip lines that are part of supportedArchitectures + } else if (trimmed) { + // This is a non-supportedArchitectures configuration + otherConfigurations.push(line); + } else if (otherConfigurations.length > 0) { + // Keep empty lines between configurations + otherConfigurations.push(line); + } + } + } + + // Generate supportedArchitectures section + const supportedArchitecturesSection = `supportedArchitectures: + os: +${config.os.map(os => ` - ${os}`).join('\n')} + cpu: +${config.cpu.map(cpu => ` - ${cpu}`).join('\n')} + libc: +${config.libc.map(libc => ` - ${libc}`).join('\n')}`; + + let finalContent; + + if (otherConfigurations.length > 0) { + // If there are other configurations, preserve them + console.log(`📝 Updating supportedArchitectures while preserving other configurations`); + const otherContent = otherConfigurations.join('\n').trim(); + finalContent = supportedArchitecturesSection + '\n\n' + otherContent + '\n'; + } else { + // If no other configurations, just write the supportedArchitectures section + finalContent = supportedArchitecturesSection + '\n'; + } + + writeFileSync(workspaceFile, finalContent, 'utf8'); + console.log(`✅ Updated pnpm-workspace.yaml for ${platformKey}`); + console.log(`📋 Configuration:`); + console.log(` OS: ${config.os.join(', ')}`); + console.log(` CPU: ${config.cpu.join(', ')}`); + console.log(` libc: ${config.libc.join(', ')}`); +} catch (error) { + console.error(`❌ Failed to update pnpm-workspace.yaml: ${error.message}`); + process.exit(1); +} + +console.log(`🎉 Platform configuration completed. Run 'pnpm install' to install dependencies.`); From 3c205c21d73879e123885fdf7006789692bc2ce3 Mon Sep 17 00:00:00 2001 From: zerob13 Date: Fri, 13 Jun 2025 22:36:36 +0800 Subject: [PATCH 07/18] fix: typo --- scripts/install-sharp-for-platform.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/install-sharp-for-platform.js b/scripts/install-sharp-for-platform.js index d34d2bd88..cea4b5451 100644 --- a/scripts/install-sharp-for-platform.js +++ b/scripts/install-sharp-for-platform.js @@ -18,7 +18,7 @@ console.log(`🎯 Configuring pnpm workspace for platform: ${targetOS}-${targetA const platformConfigs = { 'win32-x64': { os: ['win32'], - cpu: [, 'x64'] + cpu: ['x64'] }, 'win32-arm64': { os: ['win32'], From 384aca6174e1a63945252b4f43c46ab8ad217a94 Mon Sep 17 00:00:00 2001 From: zerob13 Date: Fri, 13 Jun 2025 22:38:43 +0800 Subject: [PATCH 08/18] fix: remove glibc --- pnpm-workspace.yaml | 2 +- scripts/install-sharp-for-platform.js | 5 +---- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yaml index af397cb32..2ffb72965 100644 --- a/pnpm-workspace.yaml +++ b/pnpm-workspace.yaml @@ -4,4 +4,4 @@ supportedArchitectures: cpu: - current libc: - - current + - current \ No newline at end of file diff --git a/scripts/install-sharp-for-platform.js b/scripts/install-sharp-for-platform.js index cea4b5451..3fa1de574 100644 --- a/scripts/install-sharp-for-platform.js +++ b/scripts/install-sharp-for-platform.js @@ -89,15 +89,12 @@ try { } } } - // Generate supportedArchitectures section const supportedArchitecturesSection = `supportedArchitectures: os: ${config.os.map(os => ` - ${os}`).join('\n')} cpu: -${config.cpu.map(cpu => ` - ${cpu}`).join('\n')} - libc: -${config.libc.map(libc => ` - ${libc}`).join('\n')}`; +${config.cpu.map(cpu => ` - ${cpu}`).join('\n')}`; let finalContent; From f47907ac881c20187183e49eb9de9dca5f36e691 Mon Sep 17 00:00:00 2001 From: zerob13 Date: Fri, 13 Jun 2025 22:41:07 +0800 Subject: [PATCH 09/18] fix: fix script --- pnpm-workspace.yaml | 2 -- scripts/install-sharp-for-platform.js | 1 - 2 files changed, 3 deletions(-) diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yaml index 2ffb72965..fec0b8aca 100644 --- a/pnpm-workspace.yaml +++ b/pnpm-workspace.yaml @@ -3,5 +3,3 @@ supportedArchitectures: - current cpu: - current - libc: - - current \ No newline at end of file diff --git a/scripts/install-sharp-for-platform.js b/scripts/install-sharp-for-platform.js index 3fa1de574..8b6e5f5f2 100644 --- a/scripts/install-sharp-for-platform.js +++ b/scripts/install-sharp-for-platform.js @@ -113,7 +113,6 @@ ${config.cpu.map(cpu => ` - ${cpu}`).join('\n')}`; console.log(`📋 Configuration:`); console.log(` OS: ${config.os.join(', ')}`); console.log(` CPU: ${config.cpu.join(', ')}`); - console.log(` libc: ${config.libc.join(', ')}`); } catch (error) { console.error(`❌ Failed to update pnpm-workspace.yaml: ${error.message}`); process.exit(1); From dd8b701b43b0fc4b89c4e8ce4c03b3d52746dd29 Mon Sep 17 00:00:00 2001 From: zerob13 Date: Fri, 13 Jun 2025 22:50:15 +0800 Subject: [PATCH 10/18] ci: fix cross build --- package.json | 7 ++- scripts/fix-sharp.js | 70 --------------------------- scripts/install-sharp-for-platform.js | 22 ++++----- 3 files changed, 14 insertions(+), 85 deletions(-) delete mode 100644 scripts/fix-sharp.js diff --git a/package.json b/package.json index 8a7bd6c73..a3b90ee5b 100644 --- a/package.json +++ b/package.json @@ -33,11 +33,10 @@ "build:win": "pnpm run build && electron-builder --win", "build:win:x64": "pnpm run build && electron-builder --win --x64", "build:win:arm64": "pnpm run build && electron-builder --win --arm64", - "fix:sharp": "node scripts/fix-sharp.js", "install:sharp": "node scripts/install-sharp-for-platform.js", - "build:mac": "pnpm run build && pnpm run fix:sharp && electron-builder --mac", - "build:mac:arm64": "pnpm run build && pnpm run fix:sharp && electron-builder --mac --arm64", - "build:mac:x64": "pnpm run build && pnpm run fix:sharp && electron-builder -c electron-builder-macx64.yml --mac --x64 ", + "build:mac": "pnpm run build && electron-builder --mac", + "build:mac:arm64": "pnpm run build && electron-builder --mac --arm64", + "build:mac:x64": "pnpm run build && electron-builder -c electron-builder-macx64.yml --mac --x64 ", "build:linux": "pnpm run build && electron-builder --linux", "build:linux:x64": "pnpm run build && electron-builder --linux --x64", "build:linux:arm64": "pnpm run build && electron-builder --linux --arm64", diff --git a/scripts/fix-sharp.js b/scripts/fix-sharp.js deleted file mode 100644 index 777895958..000000000 --- a/scripts/fix-sharp.js +++ /dev/null @@ -1,70 +0,0 @@ -// fix-sharp.js -// 该脚本用于修复跨平台构建时 sharp 模块的兼容性问题 -import fs from 'fs' -import path from 'path' -import { execSync } from 'child_process' - -/** - * 该函数在应用打包前执行,确保 sharp 模块能够在跨平台环境中正确加载 - */ -function fixSharpForCrossPlatform() { - console.log('开始修复 sharp 模块跨平台兼容性问题...'); - - try { - // 获取当前平台和目标架构信息 - const currentPlatform = process.platform; - const targetArch = process.env.npm_config_arch || process.arch; - - console.log(`当前平台: ${currentPlatform}, 目标架构: ${targetArch}`); - - // 如果是在 macOS 上构建 - if (currentPlatform === 'darwin') { - console.log('检测到 macOS 平台,准备处理 sharp 依赖...'); - - // 强制重新安装 sharp,确保二进制文件正确 - console.log('重新安装 sharp 模块...'); - - // 设置环境变量,确保使用正确的平台和架构 - const env = { - ...process.env, - npm_config_build_from_source: 'true', - npm_config_cpu: targetArch, - npm_config_os: 'darwin' - }; - - // 执行安装命令 - execSync('pnpm install sharp --force', { - stdio: 'inherit', - env - }); - - // 创建目标目录 - const sharpBinDir = path.join(process.cwd(), 'resources', 'sharp-bin', targetArch); - fs.mkdirSync(sharpBinDir, { recursive: true }); - - // 复制 sharp 的二进制文件到资源目录 - const sharpVendorDir = path.join(process.cwd(), 'node_modules', 'sharp', 'vendor'); - const sharpBuildDir = path.join(process.cwd(), 'node_modules', 'sharp', 'build', 'Release'); - - if (fs.existsSync(sharpVendorDir)) { - console.log(`复制 sharp vendor 文件从 ${sharpVendorDir} 到 ${sharpBinDir}`); - execSync(`cp -R "${sharpVendorDir}" "${sharpBinDir}"`); - } - - if (fs.existsSync(sharpBuildDir)) { - console.log(`复制 sharp build 文件从 ${sharpBuildDir} 到 ${sharpBinDir}`); - execSync(`cp -R "${sharpBuildDir}" "${sharpBinDir}"`); - } - - console.log('Sharp 二进制文件已复制到资源目录'); - } - - console.log('Sharp 模块跨平台兼容性修复完成!'); - } catch (error) { - console.error('修复 sharp 模块时出错:', error); - process.exit(1); - } -} - -// 执行修复函数 -fixSharpForCrossPlatform(); diff --git a/scripts/install-sharp-for-platform.js b/scripts/install-sharp-for-platform.js index 8b6e5f5f2..cdd5fc967 100644 --- a/scripts/install-sharp-for-platform.js +++ b/scripts/install-sharp-for-platform.js @@ -17,28 +17,28 @@ console.log(`🎯 Configuring pnpm workspace for platform: ${targetOS}-${targetA // Define platform-specific configurations const platformConfigs = { 'win32-x64': { - os: ['win32'], - cpu: ['x64'] + os: ['current', 'win32'], + cpu: ['current', 'x64'] }, 'win32-arm64': { - os: ['win32'], - cpu: ['arm64'] + os: ['current', 'win32'], + cpu: ['current', 'arm64'] }, 'linux-x64': { - os: ['linux'], - cpu: ['wasm32'], // Include wasm32 for Sharp WebAssembly + os: ['current', 'linux'], + cpu: ['current', 'wasm32'], // Include wasm32 for Sharp WebAssembly }, 'linux-arm64': { os: ['linux'], - cpu: ['wasm32'], + cpu: ['current', 'wasm32'], }, 'darwin-x64': { - os: ['darwin'], - cpu: ['x64'], + os: ['current', 'darwin'], + cpu: ['current', 'x64'], }, 'darwin-arm64': { - os: ['darwin'], - cpu: ['arm64'], + os: ['current', 'darwin'], + cpu: ['current', 'arm64'], } }; From 1e6e56e0b8831d260fe360c967293a1da545c0e9 Mon Sep 17 00:00:00 2001 From: zerob13 Date: Fri, 13 Jun 2025 22:53:08 +0800 Subject: [PATCH 11/18] chore: remove useless @type package --- package.json | 2 -- 1 file changed, 2 deletions(-) diff --git a/package.json b/package.json index a3b90ee5b..bfe2f73de 100644 --- a/package.json +++ b/package.json @@ -110,8 +110,6 @@ "@tiptap/suggestion": "^2.11.7", "@tiptap/vue-3": "^2.11.7", "@types/better-sqlite3": "^7.6.0", - "@types/dompurify": "^3.0.5", - "@types/mermaid": "^9.1.0", "@types/node": "^22.14.1", "@types/xlsx": "^0.0.35", "@vitejs/plugin-vue": "^5.2.3", From 2b0b430c8af0415d90728fef69ee66f88495ea9b Mon Sep 17 00:00:00 2001 From: zerob13 Date: Fri, 13 Jun 2025 23:27:05 +0800 Subject: [PATCH 12/18] doc: update readme and contributing --- CONTRIBUTING.md | 12 +++++++----- CONTRIBUTING.zh.md | 13 +++++++------ README.jp.md | 32 ++++++++++++-------------------- README.md | 32 ++++++++++++-------------------- README.zh.md | 32 ++++++++++++-------------------- 5 files changed, 50 insertions(+), 71 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 38a758637..abb95362f 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -20,7 +20,7 @@ We use GitHub to host code, to track issues and feature requests, as well as acc - Code submitted to the `dev` branch must ensure: - Basic functionality works - No compilation errors - - Project can start normally with `npm run dev` + - Project can start normally with `pnpm run dev` #### Major Features or Refactoring @@ -84,12 +84,13 @@ We use GitHub to host code, to track issues and feature requests, as well as acc 4. Install project dependencies: ```bash - npm install + pnpm install + pnpm run installRuntime ``` 5. Start the development server: ```bash - npm run dev + pnpm run dev ``` ## Project Structure @@ -109,8 +110,9 @@ We use GitHub to host code, to track issues and feature requests, as well as acc Please ensure your code follows our style guidelines by running: ```bash -npm run build -npm run i18n +pnpm run lint +pnpm run build +pnpm run i18n ``` ## Pull Request Process diff --git a/CONTRIBUTING.zh.md b/CONTRIBUTING.zh.md index 7cb70642a..395b10e24 100644 --- a/CONTRIBUTING.zh.md +++ b/CONTRIBUTING.zh.md @@ -20,7 +20,7 @@ - 提交到 `dev` 分支的代码必须确保: - 功能基本正常 - 无编译错误 - - 至少能够 `npm run dev` 正常启动 + - 至少能够 `pnpm run dev` 正常启动 #### 大型功能新增或重构 @@ -84,13 +84,13 @@ 4. 安装项目依赖: ```bash - npm install - npm run installRuntime + pnpm install + pnpm run installRuntime ``` 5. 启动开发服务器: ```bash -npm run dev +pnpm run dev ``` ## 项目结构 @@ -110,8 +110,9 @@ npm run dev 请确保您的代码符合我们的代码风格指南,可以运行以下命令: ```bash -npm run build -npm run i18n +pnpm run lint +pnpm run i18n +pnpm run build ``` ## Pull Request 流程 diff --git a/README.jp.md b/README.jp.md index 5554a8ab0..51553ab04 100644 --- a/README.jp.md +++ b/README.jp.md @@ -259,45 +259,37 @@ Mac関連の署名とパッケージングについては、[Mac リリースガ ### 依存関係のインストール ```bash -$ npm install -$ npm run installRuntime +$ pnpm install +$ pnpm run installRuntime # エラーが出た場合: No module named 'distutils' $ pip install setuptools -# Windows x64の場合 -$ npm install --cpu=x64 --os=win32 sharp -# Mac Apple Siliconの場合 -$ npm install --cpu=arm64 --os=darwin sharp -# Mac Intelの場合 -$ npm install --cpu=x64 --os=darwin sharp -# Linux x64の場合 -$ npm install --cpu=x64 --os=linux sharp ``` ### 開発を開始 ```bash -$ npm run dev +$ pnpm run dev ``` ### ビルド ```bash # Windowsの場合 -$ npm run build:win +$ pnpm run build:win # macOSの場合 -$ npm run build:mac +$ pnpm run build:mac # Linuxの場合 -$ npm run build:linux +$ pnpm run build:linux # アーキテクチャを指定してパッケージング -$ npm run build:win:x64 -$ npm run build:win:arm64 -$ npm run build:mac:x64 -$ npm run build:mac:arm64 -$ npm run build:linux:x64 -$ npm run build:linux:arm64 +$ pnpm run build:win:x64 +$ pnpm run build:win:arm64 +$ pnpm run build:mac:x64 +$ pnpm run build:mac:arm64 +$ pnpm run build:linux:x64 +$ pnpm run build:linux:arm64 ``` ## 👥 コミュニティと貢献 diff --git a/README.md b/README.md index 85eab2456..bb61e955b 100644 --- a/README.md +++ b/README.md @@ -263,45 +263,37 @@ For Mac-related signing and packaging, please refer to the [Mac Release Guide](h ### Install Dependencies ```bash -$ npm install -$ npm run installRuntime +$ pnpm install +$ pnpm run installRuntime # if got err: No module named 'distutils' $ pip install setuptools -# for windows x64 -$ npm install --cpu=x64 --os=win32 sharp -# for mac apple silicon -$ npm install --cpu=arm64 --os=darwin sharp -# for mac intel -$ npm install --cpu=x64 --os=darwin sharp -# for linux x64 -$ npm install --cpu=x64 --os=linux sharp ``` ### Start Development ```bash -$ npm run dev +$ pnpm run dev ``` ### Build ```bash # For Windows -$ npm run build:win +$ pnpm run build:win # For macOS -$ npm run build:mac +$ pnpm run build:mac # For Linux -$ npm run build:linux +$ pnpm run build:linux # Specify architecture packaging -$ npm run build:win:x64 -$ npm run build:win:arm64 -$ npm run build:mac:x64 -$ npm run build:mac:arm64 -$ npm run build:linux:x64 -$ npm run build:linux:arm64 +$ pnpm run build:win:x64 +$ pnpm run build:win:arm64 +$ pnpm run build:mac:x64 +$ pnpm run build:mac:arm64 +$ pnpm run build:linux:x64 +$ pnpm run build:linux:arm64 ``` For a more detailed guide on development, project structure, and architecture, please see the [Developer Guide](./docs/developer-guide.md). diff --git a/README.zh.md b/README.zh.md index 23c5b1765..0aed71819 100644 --- a/README.zh.md +++ b/README.zh.md @@ -259,45 +259,37 @@ Windows和Linux通过GitHub Action打包。 ### 安装依赖 ```bash -$ npm install -$ npm run installRuntime +$ pnpm install +$ pnpm run installRuntime # 如果出现错误:No module named 'distutils' $ pip install setuptools -# 对于Windows x64 -$ npm install --cpu=x64 --os=win32 sharp -# 对于Mac Apple Silicon -$ npm install --cpu=arm64 --os=darwin sharp -# 对于Mac Intel -$ npm install --cpu=x64 --os=darwin sharp -# 对于Linux x64 -$ npm install --cpu=x64 --os=linux sharp ``` ### 开始开发 ```bash -$ npm run dev +$ pnpm run dev ``` ### 构建 ```bash # Windows -$ npm run build:win +$ pnpm run build:win # macOS -$ npm run build:mac +$ pnpm run build:mac # Linux -$ npm run build:linux +$ pnpm run build:linux # 指定架构打包 -$ npm run build:win:x64 -$ npm run build:win:arm64 -$ npm run build:mac:x64 -$ npm run build:mac:arm64 -$ npm run build:linux:x64 -$ npm run build:linux:arm64 +$ pnpm run build:win:x64 +$ pnpm run build:win:arm64 +$ pnpm run build:mac:x64 +$ pnpm run build:mac:arm64 +$ pnpm run build:linux:x64 +$ pnpm run build:linux:arm64 ``` ## 👥 社区与贡献 From 734fa3cb9d4b4f6a366c40a112bc8bf99c831dd9 Mon Sep 17 00:00:00 2001 From: zerob13 Date: Fri, 13 Jun 2025 23:33:57 +0800 Subject: [PATCH 13/18] ci: update prcheck for pnpm --- .github/workflows/prcheck.yml | 33 ++++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/.github/workflows/prcheck.yml b/.github/workflows/prcheck.yml index affe0c5e5..6ebc238bd 100644 --- a/.github/workflows/prcheck.yml +++ b/.github/workflows/prcheck.yml @@ -16,20 +16,31 @@ jobs: - arch: x64 steps: - uses: actions/checkout@v4 + - name: Setup Node.js uses: actions/setup-node@v4 with: - node-version: '22' - - name: Check Lint - run: npm run lint - - name: Install dependencies - run: npm install + node-version: '22.13.1' + + - name: Setup pnpm + uses: pnpm/action-setup@v2 + with: + version: 10.12.1 + + - name: Configure pnpm workspace for Linux ${{ matrix.arch }} + run: pnpm run install:sharp env: - npm_config_platform: linux - npm_config_arch: ${{ matrix.arch }} - - name: Install Sharp - run: npm install --cpu=wasm32 sharp + TARGET_OS: linux + TARGET_ARCH: ${{ matrix.arch }} + + - name: Install dependencies + run: pnpm install + + - name: Check Lint + run: pnpm run lint + - name: Check translations - run: npm run i18n && npm run i18n:en + run: pnpm run i18n + - name: Build - run: npm run build \ No newline at end of file + run: pnpm run build \ No newline at end of file From b1e1d2bc497bdf7ae58f62a2d8a3d9a8dc816e20 Mon Sep 17 00:00:00 2001 From: duskzhen Date: Sat, 14 Jun 2025 00:25:35 +0800 Subject: [PATCH 14/18] Update scripts/install-sharp-for-platform.js Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --- scripts/install-sharp-for-platform.js | 48 +++++++++++---------------- 1 file changed, 20 insertions(+), 28 deletions(-) diff --git a/scripts/install-sharp-for-platform.js b/scripts/install-sharp-for-platform.js index cdd5fc967..ba3563e7c 100644 --- a/scripts/install-sharp-for-platform.js +++ b/scripts/install-sharp-for-platform.js @@ -53,6 +53,9 @@ if (!config) { const workspaceFile = 'pnpm-workspace.yaml'; +import { readFileSync, writeFileSync, existsSync } from 'fs'; +import YAML from 'yaml'; +... try { let existingContent = ''; let otherConfigurations = []; @@ -60,35 +63,24 @@ try { // Read existing file if it exists if (existsSync(workspaceFile)) { existingContent = readFileSync(workspaceFile, 'utf8'); - - // Parse existing content to extract non-supportedArchitectures configurations - const lines = existingContent.split('\n'); - let inSupportedArchitectures = false; - - for (const line of lines) { - const trimmed = line.trim(); - - if (trimmed.startsWith('supportedArchitectures:')) { - inSupportedArchitectures = true; - continue; - } - - if (inSupportedArchitectures) { - // Check if we've reached a new top-level configuration - if (trimmed && !line.startsWith(' ') && !trimmed.startsWith('-')) { - inSupportedArchitectures = false; - otherConfigurations.push(line); - } - // Skip lines that are part of supportedArchitectures - } else if (trimmed) { - // This is a non-supportedArchitectures configuration - otherConfigurations.push(line); - } else if (otherConfigurations.length > 0) { - // Keep empty lines between configurations - otherConfigurations.push(line); - } - } } + + // Update supportedArchitectures via YAML parser + const doc = existingContent + ? YAML.parseDocument(existingContent) + : new YAML.Document(); + + doc.set('supportedArchitectures', { + os: config.os, + cpu: config.cpu, + }); + + const finalContent = doc.toString(); + + writeFileSync(workspaceFile, finalContent, 'utf8'); + return; +} +... // Generate supportedArchitectures section const supportedArchitecturesSection = `supportedArchitectures: os: From 2ae25aa9f82eab70e7b8e3fba551dbd80ccae3fc Mon Sep 17 00:00:00 2001 From: zerob13 Date: Sat, 14 Jun 2025 00:25:50 +0800 Subject: [PATCH 15/18] fix: add current to linux arm --- scripts/install-sharp-for-platform.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/install-sharp-for-platform.js b/scripts/install-sharp-for-platform.js index ba3563e7c..79a887e6b 100644 --- a/scripts/install-sharp-for-platform.js +++ b/scripts/install-sharp-for-platform.js @@ -29,7 +29,7 @@ const platformConfigs = { cpu: ['current', 'wasm32'], // Include wasm32 for Sharp WebAssembly }, 'linux-arm64': { - os: ['linux'], + os: ['current', 'linux'], cpu: ['current', 'wasm32'], }, 'darwin-x64': { From b7da2f4434462e9adfb64aa630136dee47203b53 Mon Sep 17 00:00:00 2001 From: zerob13 Date: Sat, 14 Jun 2025 00:28:17 +0800 Subject: [PATCH 16/18] ci: change to yaml to parse yaml --- package.json | 1 + scripts/install-sharp-for-platform.js | 62 ++++++++++----------------- 2 files changed, 23 insertions(+), 40 deletions(-) diff --git a/package.json b/package.json index bfe2f73de..a5b3b0986 100644 --- a/package.json +++ b/package.json @@ -151,6 +151,7 @@ "vue-use-monaco": "^0.0.6", "vue-virtual-scroller": "^2.0.0-beta.8", "vuedraggable": "^4.1.0", + "yaml": "^2.8.0", "zod-to-json-schema": "^3.24.5" }, "pnpm": { diff --git a/scripts/install-sharp-for-platform.js b/scripts/install-sharp-for-platform.js index 79a887e6b..8d73a46e1 100644 --- a/scripts/install-sharp-for-platform.js +++ b/scripts/install-sharp-for-platform.js @@ -7,6 +7,7 @@ import { readFileSync, writeFileSync, existsSync } from 'fs'; import { platform, arch } from 'os'; +import YAML from 'yaml'; // Get platform info from environment or system const targetOS = process.env.TARGET_OS || process.env.npm_config_os || platform(); @@ -29,7 +30,7 @@ const platformConfigs = { cpu: ['current', 'wasm32'], // Include wasm32 for Sharp WebAssembly }, 'linux-arm64': { - os: ['current', 'linux'], + os: ['current','linux'], cpu: ['current', 'wasm32'], }, 'darwin-x64': { @@ -53,53 +54,34 @@ if (!config) { const workspaceFile = 'pnpm-workspace.yaml'; -import { readFileSync, writeFileSync, existsSync } from 'fs'; -import YAML from 'yaml'; -... try { - let existingContent = ''; - let otherConfigurations = []; + let workspaceConfig = {}; - // Read existing file if it exists + // Read and parse existing file if it exists if (existsSync(workspaceFile)) { - existingContent = readFileSync(workspaceFile, 'utf8'); + const existingContent = readFileSync(workspaceFile, 'utf8'); + try { + workspaceConfig = YAML.parse(existingContent) || {}; + console.log(`📖 Parsed existing pnpm-workspace.yaml`); + } catch (parseError) { + console.warn(`⚠️ Failed to parse existing YAML, creating new config: ${parseError.message}`); + workspaceConfig = {}; + } } - // Update supportedArchitectures via YAML parser - const doc = existingContent - ? YAML.parseDocument(existingContent) - : new YAML.Document(); - - doc.set('supportedArchitectures', { + // Update supportedArchitectures configuration + workspaceConfig.supportedArchitectures = { os: config.os, - cpu: config.cpu, + cpu: config.cpu + }; + + // Convert back to YAML with proper formatting + const finalContent = YAML.stringify(workspaceConfig, { + indent: 2, + lineWidth: 0, + minContentWidth: 0 }); - const finalContent = doc.toString(); - - writeFileSync(workspaceFile, finalContent, 'utf8'); - return; -} -... - // Generate supportedArchitectures section - const supportedArchitecturesSection = `supportedArchitectures: - os: -${config.os.map(os => ` - ${os}`).join('\n')} - cpu: -${config.cpu.map(cpu => ` - ${cpu}`).join('\n')}`; - - let finalContent; - - if (otherConfigurations.length > 0) { - // If there are other configurations, preserve them - console.log(`📝 Updating supportedArchitectures while preserving other configurations`); - const otherContent = otherConfigurations.join('\n').trim(); - finalContent = supportedArchitecturesSection + '\n\n' + otherContent + '\n'; - } else { - // If no other configurations, just write the supportedArchitectures section - finalContent = supportedArchitecturesSection + '\n'; - } - writeFileSync(workspaceFile, finalContent, 'utf8'); console.log(`✅ Updated pnpm-workspace.yaml for ${platformKey}`); console.log(`📋 Configuration:`); From 08e03dcd5e831fc5263dbd5555552f00f6190307 Mon Sep 17 00:00:00 2001 From: zerob13 Date: Sat, 14 Jun 2025 00:30:15 +0800 Subject: [PATCH 17/18] ci: need install yaml for edit script --- .github/workflows/build.yml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 6b53a5aa6..42e027858 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -39,6 +39,9 @@ jobs: with: version: 10.12.1 + - name: Install dependencies + run: pnpm install + - name: Configure pnpm workspace for Windows ${{ matrix.arch }} run: pnpm run install:sharp env: @@ -93,6 +96,9 @@ jobs: with: version: 10.12.1 + - name: Install dependencies + run: pnpm install + - name: Configure pnpm workspace for Linux ${{ matrix.arch }} run: pnpm run install:sharp env: @@ -144,6 +150,9 @@ jobs: with: version: 10.12.1 + - name: Install dependencies + run: pnpm install + - name: Configure pnpm workspace for macOS ${{ matrix.arch }} run: pnpm run install:sharp env: From baf950ad0c25ca66aa9c8aba1fd573adf60d7531 Mon Sep 17 00:00:00 2001 From: zerob13 Date: Sat, 14 Jun 2025 00:31:25 +0800 Subject: [PATCH 18/18] ci: update prchck --- .github/workflows/prcheck.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/prcheck.yml b/.github/workflows/prcheck.yml index 6ebc238bd..1e78197d1 100644 --- a/.github/workflows/prcheck.yml +++ b/.github/workflows/prcheck.yml @@ -27,6 +27,9 @@ jobs: with: version: 10.12.1 + - name: Install dependencies + run: pnpm install + - name: Configure pnpm workspace for Linux ${{ matrix.arch }} run: pnpm run install:sharp env: