Просмотр исходного кода

Better organize package.json, optimize tasks.json, split extension and webview linting

Roo Code 10 месяцев назад
Родитель
Сommit
f913d567fa

+ 0 - 0
.env.integration.example → .env.e2e.example


+ 1 - 2
.eslintrc.json

@@ -17,8 +17,7 @@
 		"@typescript-eslint/semi": "off",
 		"eqeqeq": "warn",
 		"no-throw-literal": "warn",
-		"semi": "off",
-		"react-hooks/exhaustive-deps": "off"
+		"semi": "off"
 	},
 	"ignorePatterns": ["out", "dist", "**/*.d.ts"]
 }

+ 7 - 11
.github/workflows/code-qa.yml

@@ -9,7 +9,7 @@ on:
     branches: [main]
 
 jobs:
-  compile:
+  qa:
     runs-on: ubuntu-latest
     steps:
       - name: Checkout code
@@ -21,12 +21,8 @@ jobs:
           cache: 'npm'
       - name: Install dependencies
         run: npm run install:all
-      - name: Compile
-        run: npm run compile
-      - name: Check types
-        run: npm run check-types
-      - name: Lint
-        run: npm run lint
+      - name: Run lint, check types, and esbuild
+        run: npm run qa
 
   unit-test:
     runs-on: ubuntu-latest
@@ -70,9 +66,9 @@ jobs:
         with:
           node-version: '18'
           cache: 'npm'
-      - name: Create env.integration file
-        run: echo "OPENROUTER_API_KEY=${{ secrets.OPENROUTER_API_KEY }}" > .env.integration
+      - name: Create env.e2e file
+        run: echo "OPENROUTER_API_KEY=${{ secrets.OPENROUTER_API_KEY }}" > .env.e2e
       - name: Install dependencies
         run: npm run install:all
-      - name: Run integration tests
-        run: xvfb-run -a npm run test:integration
+      - name: Run end-to-end tests
+        run: xvfb-run -a npm run e2e

+ 2 - 2
.gitignore

@@ -1,6 +1,6 @@
 dist
 out
-out-integration
+out-*
 node_modules
 coverage/
 
@@ -21,4 +21,4 @@ roo-cline-*.vsix
 docs/_site/
 
 # Dotenv
-.env.integration
+.env.e2e

+ 0 - 4
.husky/pre-commit

@@ -6,7 +6,3 @@ if [ "$branch" = "main" ]; then
 fi
 
 npx lint-staged
-
-npm run compile
-npm run lint
-npm run check-types

+ 4 - 3
.husky/pre-push

@@ -5,13 +5,14 @@ if [ "$branch" = "main" ]; then
   exit 1
 fi
 
-npm run compile
+npm run qa
 
-# Check for new changesets
+# Check for new changesets.
 NEW_CHANGESETS=$(find .changeset -name "*.md" ! -name "README.md" | wc -l | tr -d ' ')
 echo "Changeset files: $NEW_CHANGESETS"
+
 if [ "$NEW_CHANGESETS" == "0" ]; then
   echo "-------------------------------------------------------------------------------------"
   echo "Changes detected. Please run 'npm run changeset' to create a changeset if applicable."
   echo "-------------------------------------------------------------------------------------"
-fi
+fi

+ 2 - 2
.vscode-test.mjs

@@ -5,8 +5,8 @@
 import { defineConfig } from '@vscode/test-cli';
 
 export default defineConfig({
-	label: 'integrationTest',
-	files: 'out-integration/test/**/*.test.js',
+	label: 'e2e',
+	files: 'out-e2e/test/**/*.test.js',
 	workspaceFolder: '.',
 	mocha: {
 		ui: 'tdd',

+ 1 - 1
.vscode/launch.json

@@ -13,7 +13,7 @@
 			"args": ["--extensionDevelopmentPath=${workspaceFolder}"],
 			"sourceMaps": true,
 			"outFiles": ["${workspaceFolder}/dist/**/*.js"],
-			"preLaunchTask": "debug-mode",
+			"preLaunchTask": "${defaultBuildTask}",
 			"env": {
 				"NODE_ENV": "development",
 				"VSCODE_DEBUG_MODE": "true"

+ 6 - 45
.vscode/tasks.json

@@ -3,42 +3,15 @@
 {
 	"version": "2.0.0",
 	"tasks": [
-		{
-			"label": "compile",
-			"type": "npm",
-			"script": "compile",
-			"group": {
-				"kind": "build",
-				"isDefault": true
-			},
-			"presentation": {
-				"reveal": "silent",
-				"panel": "shared"
-			},
-			"problemMatcher": ["$tsc", "$eslint-stylish"]
-		},
 		{
 			"label": "watch",
-			"dependsOn": ["npm: build:webview", "npm: watch:tsc", "npm: watch:esbuild"],
+			"dependsOn": ["npm: dev", "npm: watch:tsc", "npm: watch:esbuild"],
 			"presentation": {
 				"reveal": "never"
 			},
 			"group": {
 				"kind": "build",
-				"isDefault": false
-			}
-		},
-		{
-			"label": "debug-mode",
-			"dependsOn": ["compile", "npm: dev"],
-			"group": {
-				"kind": "build",
-				"isDefault": false
-			},
-			"dependsOrder": "parallel",
-			"presentation": {
-				"reveal": "always",
-				"panel": "new"
+				"isDefault": true
 			}
 		},
 		{
@@ -59,20 +32,8 @@
 			},
 			"isBackground": true,
 			"presentation": {
-				"group": "watch",
-				"reveal": "never"
-			}
-		},
-		{
-			"label": "npm: build:webview",
-			"type": "npm",
-			"script": "build:webview",
-			"group": "build",
-			"problemMatcher": [],
-			"isBackground": true,
-			"presentation": {
-				"group": "watch",
-				"reveal": "never"
+				"group": "webview-ui",
+				"reveal": "always"
 			}
 		},
 		{
@@ -84,7 +45,7 @@
 			"isBackground": true,
 			"presentation": {
 				"group": "watch",
-				"reveal": "never"
+				"reveal": "always"
 			}
 		},
 		{
@@ -96,7 +57,7 @@
 			"isBackground": true,
 			"presentation": {
 				"group": "watch",
-				"reveal": "never"
+				"reveal": "always"
 			}
 		}
 	]

+ 18 - 0
package-lock.json

@@ -56,6 +56,7 @@
 				"@changesets/cli": "^2.27.10",
 				"@changesets/types": "^6.0.0",
 				"@dotenvx/dotenvx": "^1.34.0",
+				"@types/debug": "^4.1.12",
 				"@types/diff": "^5.2.1",
 				"@types/diff-match-patch": "^1.0.36",
 				"@types/jest": "^29.5.14",
@@ -5895,6 +5896,16 @@
 			"resolved": "https://registry.npmjs.org/@types/clone-deep/-/clone-deep-4.0.4.tgz",
 			"integrity": "sha512-vXh6JuuaAha6sqEbJueYdh5zNBPPgG1OYumuz2UvLvriN6ABHDSW8ludREGWJb1MLIzbwZn4q4zUbUCerJTJfA=="
 		},
+		"node_modules/@types/debug": {
+			"version": "4.1.12",
+			"resolved": "https://registry.npmjs.org/@types/debug/-/debug-4.1.12.tgz",
+			"integrity": "sha512-vIChWdVG3LG1SMxEvI/AK+FWJthlrqlTu7fbrlywTkkaONwk/UAGaULXRlf8vkzFBLVm0zkMdCquhL5aOjhXPQ==",
+			"dev": true,
+			"license": "MIT",
+			"dependencies": {
+				"@types/ms": "*"
+			}
+		},
 		"node_modules/@types/diff": {
 			"version": "5.2.3",
 			"resolved": "https://registry.npmjs.org/@types/diff/-/diff-5.2.3.tgz",
@@ -5957,6 +5968,13 @@
 			"integrity": "sha512-xPyYSz1cMPnJQhl0CLMH68j3gprKZaTjG3s5Vi+fDgx+uhG9NOXwbVt52eFS8ECyXhyKcjDLCBEqBExKuiZb7Q==",
 			"dev": true
 		},
+		"node_modules/@types/ms": {
+			"version": "2.1.0",
+			"resolved": "https://registry.npmjs.org/@types/ms/-/ms-2.1.0.tgz",
+			"integrity": "sha512-GsCCIZDE/p3i96vtEqx+7dBUGXrc7zeSK3wwPHIaRThS+9OhWIXRqzs4d6k1SVU8g91DrNRWxWUGhp5KXQb2VA==",
+			"dev": true,
+			"license": "MIT"
+		},
 		"node_modules/@types/node": {
 			"version": "20.17.9",
 			"resolved": "https://registry.npmjs.org/@types/node/-/node-20.17.9.tgz",

+ 52 - 45
package.json

@@ -217,55 +217,34 @@
 		}
 	},
 	"scripts": {
-		"build": "npm run build:webview && npm run vsix",
+		"prepare": "husky",
+		"install:all": "npm run install:extension && npm run install:webview",
+		"install:extension": "npm install",
+		"install:webview": "cd webview-ui && npm install",
+		"lint": "npm-run-all -l -p lint:*",
+		"lint:extension": "eslint src --ext ts",
+		"lint:webview": "cd webview-ui && npm run lint",
+		"check-types": "npm-run-all -l -p check-types:*",
+		"check-types:extension": "tsc --noEmit",
+		"check-types:webview": "cd webview-ui && npm run check-types",
+		"test": "npm-run-all -l -s test:*",
+		"test:extension": "jest",
+		"test:webview": "cd webview-ui && npm run test",
+		"build": "npm-run-all -l -s build:webview build:extension",
+		"build:extension": "mkdir -p bin && npx vsce package --out bin",
 		"build:webview": "cd webview-ui && npm run build",
-		"changeset": "changeset",
-		"check-types": "tsc --noEmit",
-		"compile": "tsc -p . --outDir out && node esbuild.js",
-		"compile:integration": "tsc -p tsconfig.integration.json",
-		"install:all": "npm install && cd webview-ui && npm install",
-		"lint": "eslint src --ext ts && npm run lint --prefix webview-ui",
-		"package": "npm run build:webview && npm run check-types && npm run lint && node esbuild.js --production",
-		"pretest": "npm run compile && npm run compile:integration",
 		"dev": "cd webview-ui && npm run dev",
-		"test": "jest && npm run test:webview",
-		"test:webview": "cd webview-ui && npm run test",
-		"test:integration": "npm run build && npm run compile:integration && npx dotenvx run -f .env.integration -- vscode-test",
-		"prepare": "husky",
-		"publish:marketplace": "vsce publish && ovsx publish",
-		"publish": "npm run build && changeset publish && npm install --package-lock-only",
-		"version-packages": "changeset version && npm install --package-lock-only",
+		"qa": "npm-run-all -l -p lint check-types && node esbuild.js",
+		"e2e": "npm run build && tsc -p tsconfig.e2e.json && npx dotenvx run -f .env.e2e -- vscode-test",
 		"vscode:prepublish": "npm run package",
-		"vsix": "mkdir -p bin && npx vsce package --out bin",
 		"watch": "npm-run-all -p watch:*",
 		"watch:esbuild": "node esbuild.js --watch",
 		"watch:tsc": "tsc --noEmit --watch --project tsconfig.json",
-		"watch-tests": "tsc -p . -w --outDir out"
-	},
-	"devDependencies": {
-		"@changesets/cli": "^2.27.10",
-		"@changesets/types": "^6.0.0",
-		"@dotenvx/dotenvx": "^1.34.0",
-		"@types/diff": "^5.2.1",
-		"@types/diff-match-patch": "^1.0.36",
-		"@types/jest": "^29.5.14",
-		"@types/mocha": "^10.0.7",
-		"@types/node": "20.x",
-		"@types/string-similarity": "^4.0.2",
-		"@typescript-eslint/eslint-plugin": "^7.14.1",
-		"@typescript-eslint/parser": "^7.11.0",
-		"@vscode/test-cli": "^0.0.9",
-		"@vscode/test-electron": "^2.4.0",
-		"esbuild": "^0.24.0",
-		"eslint": "^8.57.0",
-		"husky": "^9.1.7",
-		"jest": "^29.7.0",
-		"jest-simple-dot-reporter": "^1.0.5",
-		"lint-staged": "^15.2.11",
-		"npm-run-all": "^4.1.5",
-		"prettier": "^3.4.2",
-		"ts-jest": "^29.2.5",
-		"typescript": "^5.4.5"
+		"package": "npm-run-all -l -p lint check-types && node esbuild.js --production",
+		"changeset": "changeset",
+		"version-packages": "changeset version && npm install --package-lock-only",
+		"publish": "npm run build && changeset publish && npm install --package-lock-only",
+		"publish:marketplace": "vsce publish && ovsx publish"
 	},
 	"dependencies": {
 		"@anthropic-ai/bedrock-sdk": "^0.10.2",
@@ -312,13 +291,41 @@
 		"web-tree-sitter": "^0.22.6",
 		"zod": "^3.23.8"
 	},
+	"devDependencies": {
+		"@changesets/cli": "^2.27.10",
+		"@changesets/types": "^6.0.0",
+		"@dotenvx/dotenvx": "^1.34.0",
+		"@types/debug": "^4.1.12",
+		"@types/diff": "^5.2.1",
+		"@types/diff-match-patch": "^1.0.36",
+		"@types/jest": "^29.5.14",
+		"@types/mocha": "^10.0.7",
+		"@types/node": "20.x",
+		"@types/string-similarity": "^4.0.2",
+		"@typescript-eslint/eslint-plugin": "^7.14.1",
+		"@typescript-eslint/parser": "^7.11.0",
+		"@vscode/test-cli": "^0.0.9",
+		"@vscode/test-electron": "^2.4.0",
+		"esbuild": "^0.24.0",
+		"eslint": "^8.57.0",
+		"husky": "^9.1.7",
+		"jest": "^29.7.0",
+		"jest-simple-dot-reporter": "^1.0.5",
+		"lint-staged": "^15.2.11",
+		"npm-run-all": "^4.1.5",
+		"prettier": "^3.4.2",
+		"ts-jest": "^29.2.5",
+		"typescript": "^5.4.5"
+	},
 	"lint-staged": {
 		"*.{js,jsx,ts,tsx,json,css,md}": [
 			"prettier --write"
 		],
 		"src/**/*.{ts,tsx}": [
-			"prettier --write",
-			"npx eslint -c .eslintrc.json --fix"
+			"npx eslint -c .eslintrc.json --max-warnings=0 --fix"
+		],
+		"webview-ui/**/*.{ts,tsx}": [
+			"npx eslint -c webview-ui/.eslintrc.json --max-warnings=0 --fix"
 		]
 	}
 }

+ 2 - 2
tsconfig.integration.json → tsconfig.e2e.json

@@ -10,8 +10,8 @@
 		"skipLibCheck": true,
 		"useUnknownInCatchVariables": false,
 		"rootDir": "src",
-		"outDir": "out-integration"
+		"outDir": "out-e2e"
 	},
 	"include": ["**/*.ts"],
-	"exclude": [".vscode-test", "benchmark", "dist", "**/node_modules/**", "out", "out-integration", "webview-ui"]
+	"exclude": [".vscode-test", "benchmark", "dist", "**/node_modules/**", "out", "out-e2e", "webview-ui"]
 }

+ 3 - 0
webview-ui/.eslintrc.json

@@ -0,0 +1,3 @@
+{
+	"extends": "react-app"
+}

Разница между файлами не показана из-за своего большого размера
+ 3915 - 1354
webview-ui/package-lock.json


+ 4 - 2
webview-ui/package.json

@@ -4,11 +4,12 @@
 	"private": true,
 	"type": "module",
 	"scripts": {
+		"lint": "eslint src --ext ts,tsx",
+		"check-types": "tsc --noEmit",
+		"test": "jest",
 		"dev": "vite",
 		"build": "tsc -b && vite build",
 		"preview": "vite preview",
-		"lint": "eslint src --ext ts,tsx",
-		"test": "jest",
 		"storybook": "storybook dev -p 6006",
 		"build-storybook": "storybook build"
 	},
@@ -58,6 +59,7 @@
 		"@typescript-eslint/parser": "^6.21.0",
 		"@vitejs/plugin-react": "^4.3.4",
 		"eslint": "^8.57.0",
+		"eslint-config-react-app": "^7.0.1",
 		"eslint-plugin-react": "^7.33.2",
 		"eslint-plugin-react-hooks": "^4.6.0",
 		"eslint-plugin-storybook": "^0.11.2",

+ 1 - 0
webview-ui/src/components/chat/ChatTextArea.tsx

@@ -238,6 +238,7 @@ const ChatTextArea = forwardRef<HTMLTextAreaElement, ChatTextAreaProps>(
 					}, 0)
 				}
 			},
+			// eslint-disable-next-line react-hooks/exhaustive-deps
 			[setInputValue, cursorPosition],
 		)
 

+ 1 - 0
webview-ui/src/components/prompts/PromptsView.tsx

@@ -192,6 +192,7 @@ const PromptsView = ({ onDone }: PromptsViewProps) => {
 		setNewModeRoleDefinition("")
 		setNewModeCustomInstructions("")
 		setNewModeGroups(availableGroups)
+		// eslint-disable-next-line react-hooks/exhaustive-deps
 	}, [newModeName, newModeSlug, newModeRoleDefinition, newModeCustomInstructions, newModeGroups, updateCustomMode])
 
 	const isNameOrSlugTaken = useCallback(

Некоторые файлы не были показаны из-за большого количества измененных файлов