-
Notifications
You must be signed in to change notification settings - Fork 1
refactor: Store default ignore patterns in a separate file #28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Refactors the way default .crowdcodeignore patterns are handled. Instead of a hardcoded array in extension.ts, the patterns are now stored in `src/defaults/crowdcodeignore.default`. Changes: - Added `src/defaults/crowdcodeignore.default` with the standard patterns. - Modified `extension.ts` to read from this file when creating a new `.crowdcode/.crowdcodeignore` in the user's workspace. It checks for the file in the packaged location (`out/defaults/`) first, then falls back to the source location (`src/defaults/`) for development. - Added `copy-webpack-plugin` to development dependencies. - Updated `webpack.config.js` to use `CopyWebpackPlugin` to ensure `crowdcodeignore.default` is copied to `out/defaults/` during packaging. - Commented out `.vscode/` from the default ignore list, allowing users to add it manually if their specific project's .vscode dir contains sensitive information. This makes the default patterns more maintainable and keeps `extension.ts` cleaner.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR refactors the handling of default ignore patterns by moving them into a separate defaults file and updating related logic. Key changes include:
- Adding the default ignore patterns file and copying it in the webpack build process.
- Updating utilities and extension activation to load and watch the .crowdcodeignore file.
- Modifying recording logic to respect the ignore rules.
Reviewed Changes
Copilot reviewed 6 out of 7 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| webpack.config.js | Added CopyWebpackPlugin configuration to copy the default ignore file. |
| src/utilities.ts | Renamed variables to avoid conflicts and added functions for ignore patterns. |
| src/recording.ts | Integrated ignore pattern checks into recording startup and tab event logic. |
| src/extension.ts | Added file watchers for .crowdcodeignore changes and created the file if missing. |
| src/defaults/crowdcodeignore.default | Introduced the new default ignore patterns file with updated content. |
| package.json | Added necessary dependencies (copy-webpack-plugin and picomatch). |
Comments suppressed due to low confidence (1)
src/extension.ts:97
- [nitpick] Consider supporting multiple workspace folders instead of only using the first one to improve multi-root workspace compatibility.
if (vscode.workspace.workspaceFolders) {
| return | ||
| } | ||
| // Check if the file should be ignored BEFORE attempting to read its content | ||
| if (isPathIgnored(editor.document.uri.fsPath)) { |
Copilot
AI
Jun 30, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] The ignored file check is performed twice; consider consolidating this logic to avoid redundancy.
| if (isPathIgnored(editor.document.uri.fsPath)) { | |
| const isIgnored = isPathIgnored(editor.document.uri.fsPath) | |
| if (isIgnored) { |
| if (fs.existsSync(defaultIgnoreSourcePath)) { | ||
| defaultPatternsContent = fs.readFileSync(defaultIgnoreSourcePath, 'utf-8'); | ||
| } else if (fs.existsSync(devDefaultIgnoreSourcePath)) { | ||
| logToOutput('Using dev default ignore path.', 'info'); | ||
| defaultPatternsContent = fs.readFileSync(devDefaultIgnoreSourcePath, 'utf-8'); | ||
| } else { | ||
| logToOutput('Default ignore patterns file not found at expected locations. Creating an empty .crowdcodeignore.', 'warn'); | ||
| // Create a minimal .crowdcodeignore if defaults are missing, so the file watcher still works. | ||
| defaultPatternsContent = '# Default patterns could not be loaded. Please add your ignore patterns here.\n'; | ||
| } | ||
| fs.writeFileSync(ignoreFilePath, defaultPatternsContent); |
Copilot
AI
Jun 30, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] Consider using asynchronous file reading (fs.promises.readFile) instead of synchronous fs.readFileSync to avoid blocking during extension activation.
| if (fs.existsSync(defaultIgnoreSourcePath)) { | |
| defaultPatternsContent = fs.readFileSync(defaultIgnoreSourcePath, 'utf-8'); | |
| } else if (fs.existsSync(devDefaultIgnoreSourcePath)) { | |
| logToOutput('Using dev default ignore path.', 'info'); | |
| defaultPatternsContent = fs.readFileSync(devDefaultIgnoreSourcePath, 'utf-8'); | |
| } else { | |
| logToOutput('Default ignore patterns file not found at expected locations. Creating an empty .crowdcodeignore.', 'warn'); | |
| // Create a minimal .crowdcodeignore if defaults are missing, so the file watcher still works. | |
| defaultPatternsContent = '# Default patterns could not be loaded. Please add your ignore patterns here.\n'; | |
| } | |
| fs.writeFileSync(ignoreFilePath, defaultPatternsContent); | |
| if (await fs.promises.access(defaultIgnoreSourcePath).then(() => true).catch(() => false)) { | |
| defaultPatternsContent = await fs.promises.readFile(defaultIgnoreSourcePath, 'utf-8'); | |
| } else if (await fs.promises.access(devDefaultIgnoreSourcePath).then(() => true).catch(() => false)) { | |
| logToOutput('Using dev default ignore path.', 'info'); | |
| defaultPatternsContent = await fs.promises.readFile(devDefaultIgnoreSourcePath, 'utf-8'); | |
| } else { | |
| logToOutput('Default ignore patterns file not found at expected locations. Creating an empty .crowdcodeignore.', 'warn'); | |
| // Create a minimal .crowdcodeignore if defaults are missing, so the file watcher still works. | |
| defaultPatternsContent = '# Default patterns could not be loaded. Please add your ignore patterns here.\n'; | |
| } | |
| await fs.promises.writeFile(ignoreFilePath, defaultPatternsContent); |
Refactors the way default .crowdcodeignore patterns are handled. Instead of a hardcoded array in extension.ts, the patterns are now stored in
src/defaults/crowdcodeignore.default.Changes:
src/defaults/crowdcodeignore.defaultwith the standard patterns.extension.tsto read from this file when creating a new.crowdcode/.crowdcodeignorein the user's workspace. It checks for the file in the packaged location (out/defaults/) first, then falls back to the source location (src/defaults/) for development.copy-webpack-pluginto development dependencies.webpack.config.jsto useCopyWebpackPluginto ensurecrowdcodeignore.defaultis copied toout/defaults/during packaging..vscode/from the default ignore list, allowing users to add it manually if their specific project's .vscode dir contains sensitive information.This makes the default patterns more maintainable and keeps
extension.tscleaner.