From 82ba74248f7aa06829db9f2934319df25ebc0aa9 Mon Sep 17 00:00:00 2001 From: sunerpy Date: Thu, 24 Jul 2025 17:39:12 +0800 Subject: [PATCH 1/2] =?UTF-8?q?fix:=20=E7=A7=BB=E9=99=A4=20activationEvent?= =?UTF-8?q?s=20=E7=A9=BA=E6=95=B0=E7=BB=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 删除 package.json 里的 "activationEvents": [] 。 由于vscode为所有命令生成激活事件 --- package.json | 1 - 1 file changed, 1 deletion(-) diff --git a/package.json b/package.json index baa2397..f9dea62 100644 --- a/package.json +++ b/package.json @@ -15,7 +15,6 @@ "categories": [ "Other" ], - "activationEvents": [], "main": "./dist/extension.js", "contributes": { "commands": [ From abc77f313dc98764ae647c2a03d87a70a0675724 Mon Sep 17 00:00:00 2001 From: sunerpy Date: Fri, 25 Jul 2025 15:02:09 +0800 Subject: [PATCH 2/2] =?UTF-8?q?fix(esbuild):=20=E4=BF=AE=E5=A4=8D=E5=BC=95?= =?UTF-8?q?=E5=85=A5=E5=A4=96=E9=83=A8=E4=BE=9D=E8=B5=96=E6=97=B6pnpm?= =?UTF-8?q?=E6=9E=84=E5=BB=BA=E5=BC=82=E5=B8=B8=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 修改了 DataCollector 类中获取用户设置和工作区设置的方式,直接返回字符串内容 - 更新了 SettingsExport 接口,将 user 和 workspace 的类型改为 string --- package.json | 14 ++++++-------- pnpm-lock.yaml | 4 ---- src/dataCollector.ts | 15 ++++++--------- src/types/types.ts | 4 ++-- 4 files changed, 14 insertions(+), 23 deletions(-) diff --git a/package.json b/package.json index f9dea62..657be96 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "vscode-syncing", "displayName": "vscode-syncing", "description": "vscode-syncing extension", - "version": "0.2.2", + "version": "0.2.3", "publisher": "sunerpy", "icon": "resources/logo.png", "engines": { @@ -124,12 +124,13 @@ "prepare": "husky", "lint": "eslint src", "format": "prettier --write \"src/**/*.{ts,tsx,js,jsx,json,css,md}\"", - "vscode:prepublish": "pnpm run package", + "vscode:prepublish": "npm run esbuild-base -- --minify", + "esbuild-base": "esbuild ./src/extension.ts --bundle --outfile=dist/extension.js --external:vscode --format=cjs --platform=node", "compile": "pnpm run check-types && pnpm run lint && node esbuild.js", "watch": "npm-run-all -p watch:*", "watch:esbuild": "node esbuild.js --watch", "watch:tsc": "tsc --noEmit --watch --project tsconfig.json", - "package": "pnpm run check-types && pnpm run lint && node esbuild.js --production", + "package": "pnpm run vscode:prepublish", "package:vsix": "pnpm run package && pnpm vsce package --no-dependencies", "compile-tests": "tsc -p . --outDir out", "watch-tests": "tsc -p . -w --outDir out", @@ -167,8 +168,5 @@ "prettier": "3.6.2", "typescript": "^5.8.3" }, - "packageManager": "pnpm@9.4.0+sha512.f549b8a52c9d2b8536762f99c0722205efc5af913e77835dbccc3b0b0b2ca9e7dc8022b78062c17291c48e88749c70ce88eb5a74f1fa8c4bf5e18bb46c8bd83a", - "dependencies": { - "jsonc-parser": "^3.3.1" - } -} + "packageManager": "pnpm@9.4.0+sha512.f549b8a52c9d2b8536762f99c0722205efc5af913e77835dbccc3b0b0b2ca9e7dc8022b78062c17291c48e88749c70ce88eb5a74f1fa8c4bf5e18bb46c8bd83a" +} \ No newline at end of file diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index ae5d763..78502f8 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -7,10 +7,6 @@ settings: importers: .: - dependencies: - jsonc-parser: - specifier: ^3.3.1 - version: 3.3.1 devDependencies: '@types/mocha': specifier: ^10.0.10 diff --git a/src/dataCollector.ts b/src/dataCollector.ts index 6361dd7..d784803 100644 --- a/src/dataCollector.ts +++ b/src/dataCollector.ts @@ -17,7 +17,6 @@ import { getPlatform, } from './utils/vscodeEnvironment'; import { VSCodeEdition, Platform } from './types/vscodeEdition'; -import * as jsonc from 'jsonc-parser'; export class DataCollector { public readonly vscodeEdition: VSCodeEdition; @@ -107,13 +106,13 @@ export class DataCollector { // 获取用户设置 const userSettings = this.getUserSettings(); if (userSettings) { - settings.user = userSettings; + (settings as any).user = userSettings; } // 获取工作区设置 const workspaceSettings = this.getWorkspaceSettings(); if (workspaceSettings) { - settings.workspace = workspaceSettings; + (settings as any).workspace = workspaceSettings; } return settings; @@ -215,12 +214,11 @@ export class DataCollector { return snippets; } - private getUserSettings(): Record | null { + private getUserSettings(): string | null { try { const settingsPath = this.getUserSettingsPath(); if (fs.existsSync(settingsPath)) { - const content = fs.readFileSync(settingsPath, 'utf8'); - return jsonc.parse(content); + return fs.readFileSync(settingsPath, 'utf8'); } } catch (error) { if (this.outputChannel) { @@ -230,14 +228,13 @@ export class DataCollector { return null; } - private getWorkspaceSettings(): Record | null { + private getWorkspaceSettings(): string | null { try { if (vscode.workspace.workspaceFolders) { const workspaceFolder = vscode.workspace.workspaceFolders[0]; const settingsPath = path.join(workspaceFolder.uri.fsPath, '.vscode', 'settings.json'); if (fs.existsSync(settingsPath)) { - const content = fs.readFileSync(settingsPath, 'utf8'); - return jsonc.parse(content); + return fs.readFileSync(settingsPath, 'utf8'); } } } catch (error) { diff --git a/src/types/types.ts b/src/types/types.ts index 01b4cb9..48da048 100644 --- a/src/types/types.ts +++ b/src/types/types.ts @@ -24,8 +24,8 @@ export interface ExtensionsExport { } export interface SettingsExport { - user?: Record; - workspace?: Record; + user?: string; + workspace?: string; } export interface ThemeInfo {