From 9e39753bb32f2472e734cc7c08619dd95e6294af Mon Sep 17 00:00:00 2001 From: Lau Kondrup Date: Tue, 16 Sep 2025 21:52:25 +0200 Subject: [PATCH 1/7] fix: only look at .gitignores from within the current repository --- .../__tests__/common/getFilesList.test.ts | 36 +++++++++++++++ packages/core/src/getFilesList.ts | 46 +++++++++++++++---- 2 files changed, 73 insertions(+), 9 deletions(-) diff --git a/packages/core/__tests__/common/getFilesList.test.ts b/packages/core/__tests__/common/getFilesList.test.ts index 5c8b144..8945b62 100644 --- a/packages/core/__tests__/common/getFilesList.test.ts +++ b/packages/core/__tests__/common/getFilesList.test.ts @@ -273,6 +273,41 @@ it('should return files for project root with omitting gitignore', async () => { ) }) +it('should use .gitignore only within the current repository', async () => { + mockFs({ + [root]: { + '.git': {}, + project: { + 'fileA.ts': 'content', + '.gitignore': 'packageA/*', + packageA: { + '.git': {}, + '.env': 'content', + '.gitignore': ` + .env + `, + src: { + 'fileE.json': '', + }, + }, + }, + }, + }) + + const filesList = removeCwd( + await getFilesList({ + searchRoot: toPlatformSpecificPath(`${root}/project/packageA`), + }), + ) + mockFs.restore() + + expect(filesList.sort()).toMatchObject( + [`${root}/project/packageA/src/fileE.json`] + .sort() + .map(toPlatformSpecificPath), + ) +}) + // We will add option to search in ignored files, so that exception is not needed it.skip('should return files for project root ignored by parent gitignore, but ignore the nested directories', async () => { mockFs({ @@ -321,6 +356,7 @@ it.skip('should return files for project root ignored by parent gitignore, but i it('should ignore files from parent .gitignore', async () => { mockFs({ [root]: { + '.git': {}, project: { 'fileA.ts': 'content', 'fileB.js': 'content', diff --git a/packages/core/src/getFilesList.ts b/packages/core/src/getFilesList.ts index 96dffd9..9828c51 100644 --- a/packages/core/src/getFilesList.ts +++ b/packages/core/src/getFilesList.ts @@ -179,6 +179,30 @@ export type GetFilesListArgs = { extensionTester?: RegExp } +// Helper to find the repository root (directory containing .git) +const findRepoRoot = async ( + startDir: string, + fsRoot: string, +): Promise => { + let currentDir = path.resolve(startDir) + while (true) { + try { + const gitDir = path.join(currentDir, '.git') + const stat = await fs.lstat(gitDir) + if (stat.isDirectory() || stat.isFile()) { + return currentDir + } + } catch (_e) { + // .git not found, continue + } + if (currentDir === fsRoot) break + const parentDir = path.dirname(currentDir) + if (parentDir === currentDir) break + currentDir = parentDir + } + return startDir // fallback: treat startDir as repo root +} + export const getFilesList = async ({ searchRoot: _searchRoot, entryPoint = undefined, @@ -204,25 +228,29 @@ export const getFilesList = async ({ } else { const InitialIgnore = ignoreNodeModules ? ['node_modules'] : [] - // Get parent to root gitignore + // Get parent to root gitignore, but stop at repo root if (!omitGitIgnore) { + // Find the repo root (directory containing .git) + const repoRoot = await findRepoRoot(searchRoot, fsRoot) const searchRootSegments = searchRoot .replace(fsRoot, '') .split(pathSeparatorChar) - - const pathSegmentsToSystemRoot = [] - + const pathSegmentsToRepoRoot = [] for (let i = 0; i < searchRootSegments.length; i++) { let currentPath = searchRootSegments.slice(0, i).join(pathSeparatorChar) - currentPath = fsRoot + currentPath - - pathSegmentsToSystemRoot.push(currentPath) + // Only add if currentPath is within repoRoot + if (path.resolve(currentPath).startsWith(path.resolve(repoRoot))) { + pathSegmentsToRepoRoot.push(currentPath) + } + } + // Always include the repoRoot itself + if (!pathSegmentsToRepoRoot.includes(repoRoot)) { + pathSegmentsToRepoRoot.push(repoRoot) } - const parentDirsIgnore = ( await Promise.all( - pathSegmentsToSystemRoot.map((parentPath) => + pathSegmentsToRepoRoot.map((parentPath) => getGitIgnoreContentForDirectory(parentPath), ), ) From f2de031e365f1bf6f3eac65be9df83249d09ca8f Mon Sep 17 00:00:00 2001 From: Lau Kondrup Date: Fri, 19 Sep 2025 12:32:12 +0200 Subject: [PATCH 2/7] simplify a bit --- packages/core/src/getFilesList.ts | 56 +++++++++++++------------------ 1 file changed, 23 insertions(+), 33 deletions(-) diff --git a/packages/core/src/getFilesList.ts b/packages/core/src/getFilesList.ts index 9828c51..f351111 100644 --- a/packages/core/src/getFilesList.ts +++ b/packages/core/src/getFilesList.ts @@ -2,7 +2,7 @@ import path from 'path' import { promises as fs } from 'fs' import ignore from 'ignore' -import { asyncFilter, measureStart } from './utils' +import { measureStart } from './utils' import minimatch from 'minimatch' import { parseDependencyTree } from 'dpdm/lib/index.js' import { spawnSync } from 'child_process' @@ -179,28 +179,27 @@ export type GetFilesListArgs = { extensionTester?: RegExp } -// Helper to find the repository root (directory containing .git) -const findRepoRoot = async ( - startDir: string, - fsRoot: string, -): Promise => { - let currentDir = path.resolve(startDir) - while (true) { +const findRepoRoot = async ({ + searchRoot, + fsRoot, +}: { + searchRoot: string + fsRoot: string +}) => { + let currentDir = path.resolve(searchRoot) + while (currentDir !== fsRoot) { try { const gitDir = path.join(currentDir, '.git') const stat = await fs.lstat(gitDir) - if (stat.isDirectory() || stat.isFile()) { + if (stat.isDirectory()) { return currentDir } } catch (_e) { // .git not found, continue } - if (currentDir === fsRoot) break - const parentDir = path.dirname(currentDir) - if (parentDir === currentDir) break - currentDir = parentDir + currentDir = path.dirname(currentDir) } - return startDir // fallback: treat startDir as repo root + return searchRoot } export const getFilesList = async ({ @@ -228,29 +227,20 @@ export const getFilesList = async ({ } else { const InitialIgnore = ignoreNodeModules ? ['node_modules'] : [] - // Get parent to root gitignore, but stop at repo root if (!omitGitIgnore) { - // Find the repo root (directory containing .git) - const repoRoot = await findRepoRoot(searchRoot, fsRoot) - const searchRootSegments = searchRoot - .replace(fsRoot, '') - .split(pathSeparatorChar) - const pathSegmentsToRepoRoot = [] - for (let i = 0; i < searchRootSegments.length; i++) { - let currentPath = searchRootSegments.slice(0, i).join(pathSeparatorChar) - currentPath = fsRoot + currentPath - // Only add if currentPath is within repoRoot - if (path.resolve(currentPath).startsWith(path.resolve(repoRoot))) { - pathSegmentsToRepoRoot.push(currentPath) - } - } - // Always include the repoRoot itself - if (!pathSegmentsToRepoRoot.includes(repoRoot)) { - pathSegmentsToRepoRoot.push(repoRoot) + const repoRoot = await findRepoRoot({ searchRoot, fsRoot }) + const parentPaths = [] + let currentPath = searchRoot + + while (currentPath !== repoRoot) { + parentPaths.push(currentPath) + currentPath = path.dirname(currentPath) } + parentPaths.push(repoRoot) + const parentDirsIgnore = ( await Promise.all( - pathSegmentsToRepoRoot.map((parentPath) => + parentPaths.map((parentPath) => getGitIgnoreContentForDirectory(parentPath), ), ) From 91c67c9f83790d9349e7da30e048b7a9871af610 Mon Sep 17 00:00:00 2001 From: "Jakub Mazurek (@jayu)" Date: Sat, 27 Sep 2025 12:45:28 +0200 Subject: [PATCH 3/7] docs: improve readome about building locally --- packages/core/package.json | 1 + packages/vscode/InternalReadme.md | 17 +++++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/packages/core/package.json b/packages/core/package.json index f23860d..14e8c9b 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -78,6 +78,7 @@ "typecheck": "tsc --project tsconfig.json", "test": "yarn build:test && NODE_OPTIONS=--max-old-space-size=4000 yarn jest --maxWorkers=25%", "test:babel": "jest --selectProjects=babel", + "test:common": "jest --selectProjects=common", "test:babel:traversal": "jest --selectProjects=babel:traversal", "test:babel-eslint-parser": "jest --selectProjects=babel-eslint-parser", "test:babel-eslint-parser:traversal": "jest --selectProjects=babel-eslint-parser:traversal", diff --git a/packages/vscode/InternalReadme.md b/packages/vscode/InternalReadme.md index af090a9..57a7cd8 100644 --- a/packages/vscode/InternalReadme.md +++ b/packages/vscode/InternalReadme.md @@ -1,5 +1,7 @@ ## Development +Make sure to build core package first `yarn workspace @codeque/core build` + Run `yarn watch:extension` and `yarn watch:webviews` Open Vscode and run `Run extension` configuration in debugger @@ -8,6 +10,21 @@ While in VSCode with extension host run `> Reload Extension` to refresh webview To refresh extension backed re-run debugger configuration. +## Testing production build locally +Make sure to build core package first `yarn workspace @codeque/core build` + +Then change version in package.json to include `-local` suffix, eg. `0.35.1-local`. + +Otherwise vscode will confuse locally installed version and you won't be able to download published version with the same version code, unless you uninstall local version manually + +Package the extension into vsix file `cd packages/vscode && vsce package` + +Command runs checks, run webpack build and package extension into `vsix` (kind of archive file) + +You will get file `codeque-.vsix` + +The install extension from command pallette in vscode `cmd+p` -> `install from VSIX` -> select generated file -> Hit "Restart Extensions" button + ## Publish to official Visual Studio Code Marketplace Bump version manually in package.json From d094ce46ff076143408bc1c191e8a29fda0767a7 Mon Sep 17 00:00:00 2001 From: "Jakub Mazurek (@jayu)" Date: Sat, 27 Sep 2025 12:54:41 +0200 Subject: [PATCH 4/7] chore: bump extension version --- packages/core/src/getFilesList.ts | 4 ++++ packages/vscode/package.json | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/core/src/getFilesList.ts b/packages/core/src/getFilesList.ts index f351111..f64b20a 100644 --- a/packages/core/src/getFilesList.ts +++ b/packages/core/src/getFilesList.ts @@ -191,14 +191,17 @@ const findRepoRoot = async ({ try { const gitDir = path.join(currentDir, '.git') const stat = await fs.lstat(gitDir) + if (stat.isDirectory()) { return currentDir } } catch (_e) { // .git not found, continue } + currentDir = path.dirname(currentDir) } + return searchRoot } @@ -236,6 +239,7 @@ export const getFilesList = async ({ parentPaths.push(currentPath) currentPath = path.dirname(currentPath) } + parentPaths.push(repoRoot) const parentDirsIgnore = ( diff --git a/packages/vscode/package.json b/packages/vscode/package.json index f0d1ce0..00a2940 100644 --- a/packages/vscode/package.json +++ b/packages/vscode/package.json @@ -10,7 +10,7 @@ "bugs": { "url": "https://github.com/codeque-co/codeque/issues" }, - "version": "0.35.0", + "version": "0.36.0", "engines": { "vscode": "^1.68.0", "node": ">=14" From ac8e9382821314ca7b22c7d99ebf3a78b4045cc9 Mon Sep 17 00:00:00 2001 From: "Jakub Mazurek (@jayu)" Date: Fri, 14 Nov 2025 19:50:27 +0100 Subject: [PATCH 5/7] feat: upgrade babel parser --- package.json | 4 +- packages/core/package.json | 11 +- packages/tree-sitter-port/package.json | 2 +- packages/vscode/InternalReadme.md | 4 +- packages/vscode/package.json | 4 +- packages/vscode/src/extension.ts | 1 + .../components/FileLink.tsx | 1 + .../Sidebar/components/SearchSettings.tsx | 1 + .../components/ButtonWithOptionSelect.tsx | 6 +- yarn.lock | 135 +++++++++++++----- 10 files changed, 118 insertions(+), 51 deletions(-) diff --git a/package.json b/package.json index ea36d0b..b763d8e 100644 --- a/package.json +++ b/package.json @@ -23,7 +23,7 @@ "eslint-plugin-jest": "^24.1.0", "eslint-plugin-node": "^11.1.0", "eslint-plugin-prettier": "^4.0.0", - "typescript": "^4.5.2" + "typescript": "5.9.3" }, "scripts": { "lint": "yarn workspaces run lint", @@ -36,4 +36,4 @@ "dependencies": { "@codeque/eslint-plugin": "^0.1.1" } -} +} \ No newline at end of file diff --git a/packages/core/package.json b/packages/core/package.json index 14e8c9b..ce75449 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -27,8 +27,8 @@ }, "devDependencies": { "@angular-eslint/template-parser": "^15.2.1", - "@babel/eslint-parser": "^7.21.8", - "@babel/generator": "^7.21.4", + "@babel/eslint-parser": "7.28.5", + "@babel/generator": "7.28.5", "@types/dedent": "^0.7.0", "@types/esprima": "^4.0.3", "@types/glob": "^7.2.0", @@ -51,11 +51,12 @@ "node-fetch-commonjs": "^3.1.1", "release-it": "^15.0.0", "ts-jest": "^27.1.1", - "unzipper": "^0.10.11" + "unzipper": "^0.10.11", + "typescript": "5.9.3" }, "dependencies": { - "@babel/parser": "7.19.4", - "@babel/plugin-syntax-typescript": "7.18.6", + "@babel/parser": "7.28.5", + "@babel/plugin-syntax-typescript": "7.27.1", "@types/css-tree": "^2.3.1", "dedent": "^0.7.0", "dpdm": "^3.12.0", diff --git a/packages/tree-sitter-port/package.json b/packages/tree-sitter-port/package.json index a1712c9..237c5e7 100644 --- a/packages/tree-sitter-port/package.json +++ b/packages/tree-sitter-port/package.json @@ -26,7 +26,7 @@ "eslint": "^8.18.0", "tree-sitter-cli": "^0.20.8", "ts-node": "^10.9.1", - "typescript": "^4.7.4" + "typescript": "5.9.3" }, "dependencies": {} } diff --git a/packages/vscode/InternalReadme.md b/packages/vscode/InternalReadme.md index 57a7cd8..7a06c88 100644 --- a/packages/vscode/InternalReadme.md +++ b/packages/vscode/InternalReadme.md @@ -31,7 +31,7 @@ Bump version manually in package.json And just run -`vsce publish` +`vsce publish -p ` `vsce` will automatically run pre-publish hooks from script `vscode:prepublish` to run checks and build package @@ -41,4 +41,4 @@ You might be asked to [get new PAT](https://code.visualstudio.com/api/working-wi Same procedure as above, but run -`ovsx publish` +`ovsx publish -p ` diff --git a/packages/vscode/package.json b/packages/vscode/package.json index 00a2940..9b85985 100644 --- a/packages/vscode/package.json +++ b/packages/vscode/package.json @@ -10,7 +10,7 @@ "bugs": { "url": "https://github.com/codeque-co/codeque/issues" }, - "version": "0.36.0", + "version": "0.37.0", "engines": { "vscode": "^1.68.0", "node": ">=14" @@ -166,7 +166,7 @@ "mocha": "^10.0.0", "process": "^0.11.10", "ts-loader": "^9.3.1", - "typescript": "^4.9.4", + "typescript": "5.9.3", "webpack": "^5.73.0", "webpack-cli": "^4.10.0" }, diff --git a/packages/vscode/src/extension.ts b/packages/vscode/src/extension.ts index 23004d4..d7ab735 100644 --- a/packages/vscode/src/extension.ts +++ b/packages/vscode/src/extension.ts @@ -319,6 +319,7 @@ export function activate(context: vscode.ExtensionContext) { const fileUri = vscode.Uri.file(`${storagePath}/extension.vsix`) + //@ts-ignore await vscode.workspace.fs.writeFile(fileUri, Buffer.from(buffer)) await vscode.commands.executeCommand( diff --git a/packages/vscode/src/webviews/SearchResultsPanel/components/FileLink.tsx b/packages/vscode/src/webviews/SearchResultsPanel/components/FileLink.tsx index b5059a6..6c6e54c 100644 --- a/packages/vscode/src/webviews/SearchResultsPanel/components/FileLink.tsx +++ b/packages/vscode/src/webviews/SearchResultsPanel/components/FileLink.tsx @@ -29,6 +29,7 @@ export function FileLink({ : relativeFilePath return ( + //@ts-ignore { ev.stopPropagation() diff --git a/packages/vscode/src/webviews/Sidebar/components/SearchSettings.tsx b/packages/vscode/src/webviews/Sidebar/components/SearchSettings.tsx index 9d09039..82858ac 100644 --- a/packages/vscode/src/webviews/Sidebar/components/SearchSettings.tsx +++ b/packages/vscode/src/webviews/Sidebar/components/SearchSettings.tsx @@ -294,6 +294,7 @@ export function SearchSettings({ : {} return ( + //@ts-ignore {!resultsPanelVisible && ( ({ ) return ( + // @ts-ignore