From 1372b0afb6064d701ac0bc433538f4e43469d93e Mon Sep 17 00:00:00 2001 From: sunerpy Date: Sun, 26 Oct 2025 16:37:25 +0800 Subject: [PATCH 1/2] =?UTF-8?q?feat(core):=20=E6=94=B9=E8=BF=9B=E6=89=A9?= =?UTF-8?q?=E5=B1=95=E7=9B=AE=E5=BD=95=E8=8E=B7=E5=8F=96=E9=80=BB=E8=BE=91?= =?UTF-8?q?=E4=BB=A5=E6=8F=90=E9=AB=98=E5=85=BC=E5=AE=B9=E6=80=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 重构了 `getExtensionsDirectory` 方法,优先通过已安装的扩展路径推断扩展目录, 如果无法获取,则回退到使用 `getVSCodeExtensionsDirectory` 工具函数。 此举增强了在不同 VS Code 环境下的兼容性和鲁棒性。 --- src/core/extensionManager.ts | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/src/core/extensionManager.ts b/src/core/extensionManager.ts index a346eef..cd3e54a 100644 --- a/src/core/extensionManager.ts +++ b/src/core/extensionManager.ts @@ -7,6 +7,7 @@ import { ErrorHandler, ErrorType } from './errorHandler'; import { logger } from './logger'; import { ExtensionImportResult } from './reportManager'; import { isExtensionIgnored } from '../types/constants'; +import { getVSCodeExtensionsDirectory } from '../utils/vscodeEnvironment'; export interface ExtensionComparisonResult { id: string; @@ -347,21 +348,22 @@ export class ExtensionManager { * 获取扩展目录 */ private getExtensionsDirectory(): string { - if (process.env.VSCODE_PORTABLE) { - return path.join(process.env.VSCODE_PORTABLE, 'data', 'extensions'); + // 方法1: 从已安装的扩展路径推断扩展目录 + const installedExtensions = vscode.extensions.all.filter((ext) => !ext.packageJSON.isBuiltin); + + if (installedExtensions.length > 0) { + // 获取第一个非内置扩展的路径 + const firstExtPath = installedExtensions[0].extensionPath; + // 扩展路径格式: /path/to/extensions/publisher.name-version + // 我们需要获取 extensions 目录 + const extensionsDir = path.dirname(firstExtPath); + logger.debug(`从已安装扩展推断扩展目录: ${extensionsDir}`); + return extensionsDir; } - const platform = os.platform(); - const homeDir = os.homedir(); - - switch (platform) { - case 'win32': - case 'darwin': - case 'linux': - return path.join(homeDir, '.vscode', 'extensions'); - default: - return path.join(homeDir, '.vscode', 'extensions'); - } + // 方法2: 如果没有已安装的扩展,使用 vscodeEnvironment 工具函数作为后备 + logger.debug('没有找到已安装的扩展,使用后备方法获取扩展目录'); + return getVSCodeExtensionsDirectory(); } /** From dc684b923b2295f6f3f66cde8890de5fcd46d451 Mon Sep 17 00:00:00 2001 From: sunerpy Date: Sun, 26 Oct 2025 18:04:00 +0800 Subject: [PATCH 2/2] =?UTF-8?q?fix:=20=E7=A7=BB=E9=99=A4audit=20ci/cd?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/ci.yml | 8 -------- .github/workflows/nightly.yml | 7 ------- package.json | 1 - 3 files changed, 16 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4a391b4..3d14bb1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -36,11 +36,6 @@ jobs: echo "🔍 Checking for unused dependencies..." npx depcheck || echo "⚠️ Some dependencies might be unused" - - name: Security audit - run: | - echo "🔒 Running security audit..." - pnpm audit --audit-level moderate || echo "⚠️ Security vulnerabilities found" - security: name: Security Check runs-on: ubuntu-latest @@ -52,9 +47,6 @@ jobs: - name: Setup Node.js and pnpm uses: ./.github/actions/setup-node-pnpm - - name: Run security audit - run: pnpm audit --audit-level moderate - - name: Check for secrets uses: trufflesecurity/trufflehog@main with: diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index 53c5c4c..a78a850 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -43,11 +43,6 @@ jobs: build-info.txt retention-days: 30 - - name: Check for security vulnerabilities - run: | - echo "🔒 Running security audit..." - pnpm audit --audit-level moderate || echo "⚠️ Security vulnerabilities found" - - name: Check for outdated dependencies run: | echo "📦 Checking for outdated dependencies..." @@ -61,8 +56,6 @@ jobs: echo "## Outdated Dependencies" >> dependency-report.md pnpm outdated >> dependency-report.md 2>&1 || echo "All dependencies are up to date" >> dependency-report.md echo "" >> dependency-report.md - echo "## Security Audit" >> dependency-report.md - pnpm audit --audit-level moderate >> dependency-report.md 2>&1 || echo "No security issues found" >> dependency-report.md - name: Upload dependency report uses: actions/upload-artifact@v4 diff --git a/package.json b/package.json index be58eb0..f82d806 100644 --- a/package.json +++ b/package.json @@ -155,7 +155,6 @@ "build": "pnpm run package", "build:vsix": "vsce package", "publish:vsix": "pnpm vsce publish --no-dependencies", - "security:audit": "pnpm audit --audit-level moderate", "deps:check": "depcheck", "deps:outdated": "pnpm outdated" },