diff --git a/Readme.md b/Readme.md index 69217f2..89898fa 100644 --- a/Readme.md +++ b/Readme.md @@ -56,20 +56,18 @@ CodeQue will be soon available as:
- + - ## Visual Studio Code Extension 🔮 - VScode extension aims to make your workflow more efficient. -It addresses the problems of standard search by providing multiline support and offers an easy way to add gaps or use wildcards in the query. +It addresses the problems of standard search by providing multiline support and offers an easy way to add gaps or use wildcards in the query. -You don't need to have any Regex knowledge to query complex code patterns. +You don't need to have any Regex knowledge to query complex code patterns. With CodeQue, you can easily navigate and modify your codebase, making your development process faster and more efficient. -It will help you with code refactoring, speed up project discovery, and make it easy to find duplicated or similar code patterns. +It will help you with code refactoring, speed up project discovery, and make it easy to find duplicated or similar code patterns. Advanced code search options and todo-like list of accurate search results will streamline your workflow. @@ -154,7 +152,6 @@ Find more information in [`@codeque/eslint-plugin` package readme](https://www.n ## CLI tool 🔥 CodeQue CLI is a complementary tool that can be used for - - Searching code patterns right from terminal including headless environments - Building scripts to assert that some code patterns exist or not exist - Enhancing git hooks to avoid committing or pushing unwanted code @@ -187,7 +184,14 @@ Find more information in [`@codeque/cli` package readme](https://www.npmjs.com/p Feel free to use [Github Issues](https://github.com/codeque-co/codeque/issues) to - - ask for help with writing a query - report a bug or doubt - suggest feature or improvement + +## Made in 🇵🇱 with 🧠 by [@jayu](https://github.com/jayu) + +I hope that this small piece of software will help you. If this tool was useful, don't hesitate to give it a ⭐! + +### My other projects + +- [Rev-dep - High-speed linter for your dependency graph](https://rev-dep.com?utm_source=codeque-md) \ No newline at end of file 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/cli/README.md b/packages/cli/README.md index 8227db1..21ba25a 100644 --- a/packages/cli/README.md +++ b/packages/cli/README.md @@ -1,3 +1,5 @@ + +

@@ -58,13 +60,11 @@ CodeQue will be soon available as:
- + - ## CLI tool 🔥 CodeQue CLI is a complementary tool that can be used for - - Searching code patterns right from terminal including headless environments - Building scripts to assert that some code patterns exist or not exist - Enhancing git hooks to avoid committing or pushing unwanted code @@ -196,7 +196,14 @@ codeque [options] Feel free to use [Github Issues](https://github.com/codeque-co/codeque/issues) to - - ask for help with writing a query - report a bug or doubt - suggest feature or improvement + +## Made in 🇵🇱 with 🧠 by [@jayu](https://github.com/jayu) + +I hope that this small piece of software will help you. If this tool was useful, don't hesitate to give it a ⭐! + +### My other projects + +- [Rev-dep - High-speed linter for your dependency graph](https://rev-dep.com?utm_source=codeque-md) \ No newline at end of file diff --git a/packages/core/README.md b/packages/core/README.md index df42b08..8f5c514 100644 --- a/packages/core/README.md +++ b/packages/core/README.md @@ -1,3 +1,5 @@ + +

@@ -73,7 +75,14 @@ To use CodeQue check available platforms listed above. Feel free to use [Github Issues](https://github.com/codeque-co/codeque/issues) to - - ask for help with writing a query - report a bug or doubt - suggest feature or improvement + +## Made in 🇵🇱 with 🧠 by [@jayu](https://github.com/jayu) + +I hope that this small piece of software will help you. If this tool was useful, don't hesitate to give it a ⭐! + +### My other projects + +- [Rev-dep - High-speed linter for your dependency graph](https://rev-dep.com?utm_source=codeque-md) \ No newline at end of file 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/package.json b/packages/core/package.json index f23860d..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", @@ -78,6 +79,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/core/src/getFilesList.ts b/packages/core/src/getFilesList.ts index 96dffd9..f64b20a 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,6 +179,32 @@ export type GetFilesListArgs = { extensionTester?: RegExp } +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()) { + return currentDir + } + } catch (_e) { + // .git not found, continue + } + + currentDir = path.dirname(currentDir) + } + + return searchRoot +} + export const getFilesList = async ({ searchRoot: _searchRoot, entryPoint = undefined, @@ -204,25 +230,21 @@ export const getFilesList = async ({ } else { const InitialIgnore = ignoreNodeModules ? ['node_modules'] : [] - // Get parent to root gitignore if (!omitGitIgnore) { - const searchRootSegments = searchRoot - .replace(fsRoot, '') - .split(pathSeparatorChar) - - const pathSegmentsToSystemRoot = [] + const repoRoot = await findRepoRoot({ searchRoot, fsRoot }) + const parentPaths = [] + let currentPath = searchRoot - for (let i = 0; i < searchRootSegments.length; i++) { - let currentPath = searchRootSegments.slice(0, i).join(pathSeparatorChar) - - currentPath = fsRoot + currentPath - - pathSegmentsToSystemRoot.push(currentPath) + while (currentPath !== repoRoot) { + parentPaths.push(currentPath) + currentPath = path.dirname(currentPath) } + parentPaths.push(repoRoot) + const parentDirsIgnore = ( await Promise.all( - pathSegmentsToSystemRoot.map((parentPath) => + parentPaths.map((parentPath) => getGitIgnoreContentForDirectory(parentPath), ), ) diff --git a/packages/eslint/README.md b/packages/eslint/README.md index cd5e365..5aef8b0 100644 --- a/packages/eslint/README.md +++ b/packages/eslint/README.md @@ -1,3 +1,5 @@ + +

@@ -58,9 +60,8 @@ CodeQue will be soon available as:
- + - ## ESLint integration 💅 Using CodeQue ESLint plugin you can create your own custom linting rules in zero time. @@ -440,7 +441,14 @@ Learn more about [telemetry](https://codeque.co/docs/telemetry#es-lint-plugin) Feel free to use [Github Issues](https://github.com/codeque-co/codeque/issues) to - - ask for help with writing a query - report a bug or doubt - suggest feature or improvement + +## Made in 🇵🇱 with 🧠 by [@jayu](https://github.com/jayu) + +I hope that this small piece of software will help you. If this tool was useful, don't hesitate to give it a ⭐! + +### My other projects + +- [Rev-dep - High-speed linter for your dependency graph](https://rev-dep.com?utm_source=codeque-md) \ No newline at end of file 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 af090a9..7a06c88 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,13 +10,28 @@ 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 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 @@ -24,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/README.md b/packages/vscode/README.md index 77078ef..8ad76ac 100644 --- a/packages/vscode/README.md +++ b/packages/vscode/README.md @@ -64,20 +64,18 @@ CodeQue will be soon available as:
- + - ## Visual Studio Code Extension 🔮 - VScode extension aims to make your workflow more efficient. -It addresses the problems of standard search by providing multiline support and offers an easy way to add gaps or use wildcards in the query. +It addresses the problems of standard search by providing multiline support and offers an easy way to add gaps or use wildcards in the query. -You don't need to have any Regex knowledge to query complex code patterns. +You don't need to have any Regex knowledge to query complex code patterns. With CodeQue, you can easily navigate and modify your codebase, making your development process faster and more efficient. -It will help you with code refactoring, speed up project discovery, and make it easy to find duplicated or similar code patterns. +It will help you with code refactoring, speed up project discovery, and make it easy to find duplicated or similar code patterns. Advanced code search options and todo-like list of accurate search results will streamline your workflow. @@ -377,7 +375,14 @@ to Feel free to use [Github Issues](https://github.com/codeque-co/codeque/issues) to - - ask for help with writing a query - report a bug or doubt - suggest feature or improvement + +## Made in 🇵🇱 with 🧠 by [@jayu](https://github.com/jayu) + +I hope that this small piece of software will help you. If this tool was useful, don't hesitate to give it a ⭐! + +### My other projects + +- [Rev-dep - High-speed linter for your dependency graph](https://rev-dep.com?utm_source=codeque-md) \ No newline at end of file diff --git a/packages/vscode/check-tree-sitter.js b/packages/vscode/check-tree-sitter.js new file mode 100644 index 0000000..e808c76 --- /dev/null +++ b/packages/vscode/check-tree-sitter.js @@ -0,0 +1,4 @@ +const fs = require('fs') + +// will throw if not exist - that's what we want +const treeSitterWasm = fs.statSync('./dist-tree-sitter/tree-sitter.wasm') diff --git a/packages/vscode/package.json b/packages/vscode/package.json index f0d1ce0..267d44e 100644 --- a/packages/vscode/package.json +++ b/packages/vscode/package.json @@ -2,7 +2,7 @@ "name": "codeque", "publisher": "CodeQue", "displayName": "Multiline & Structural Code Search", - "description": "Multiline code search for every language. Structural code search for JavaScript, TypeScript, HTML, CSS, Python and Lua", + "description": "Multiline code search for every language. Structural code search for JavaScript, TypeScript, HTML, CSS, Python, Lua and C#", "repository": { "type": "git", "url": "https://github.com/codeque-co/codeque" @@ -10,7 +10,7 @@ "bugs": { "url": "https://github.com/codeque-co/codeque/issues" }, - "version": "0.35.0", + "version": "0.37.1", "engines": { "vscode": "^1.68.0", "node": ">=14" @@ -146,7 +146,8 @@ "package:extension": "webpack --config webpack.extension.config.js --mode production ", "watch:webviews": "webpack --config webpack.webviews.config.js --watch", "package:webviews": "webpack --config webpack.webviews.config.js --mode production", - "package": "yarn package:extension && yarn package:webviews", + "package:check-tree-sitter": "node ./check-tree-sitter.js", + "package": "yarn package:check-tree-sitter && yarn package:extension && yarn package:webviews", "compile-tests": "tsc -p . --outDir out", "watch-tests": "tsc -p . -w --outDir out", "lint": "eslint src --ext ts", @@ -166,7 +167,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..b1906b9 100644 --- a/packages/vscode/src/webviews/SearchResultsPanel/components/FileLink.tsx +++ b/packages/vscode/src/webviews/SearchResultsPanel/components/FileLink.tsx @@ -29,7 +29,9 @@ export function FileLink({ : relativeFilePath return ( + //@ts-ignore { ev.stopPropagation() onClick?.() 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