Skip to content

Conversation

@maharajamihir
Copy link

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.

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.
Copy link

Copilot AI left a 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)) {
Copy link

Copilot AI Jun 30, 2025

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.

Suggested change
if (isPathIgnored(editor.document.uri.fsPath)) {
const isIgnored = isPathIgnored(editor.document.uri.fsPath)
if (isIgnored) {

Copilot uses AI. Check for mistakes.
Comment on lines +154 to +164
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);
Copy link

Copilot AI Jun 30, 2025

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.

Suggested change
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);

Copilot uses AI. Check for mistakes.
@maharajamihir maharajamihir removed the request for review from emergenz June 30, 2025 18:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants