feat: add glob pattern support to copyFiles option#346
Open
sleicht wants to merge 1 commit intoaku11i:mainfrom
Open
feat: add glob pattern support to copyFiles option#346sleicht wants to merge 1 commit intoaku11i:mainfrom
sleicht wants to merge 1 commit intoaku11i:mainfrom
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: dfd7a8b60d
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
4249d30 to
9c0b1b3
Compare
72d905e to
557167b
Compare
Adds support for glob patterns in the postCreate.copyFiles configuration option, allowing users to specify patterns like *.env, **/*.local.yml, and other standard glob patterns instead of listing each file individually. Features: - Created glob-resolver module with pattern detection and expansion - Support for *, **, ?, and [abc] glob patterns - Handles literal filenames containing glob metacharacters - Custom **/ pattern matcher for dotfiles (works around Node.js limitation) - Excludes .git directory from recursive searches - Full backward compatibility with exact file paths Implementation: - Integrated glob resolution into file-copier workflow - Added recursiveReaddir() for walking directory trees - Added matchesPattern() for regex-based glob matching - Literal file paths take precedence over glob patterns - Zero dependencies added (uses Node.js native globSync) Testing: - Added comprehensive test coverage (22 glob resolver tests) - Added 12 file-copier integration tests - Fixed attach.test.js module mocking for globSync - All tests passing (193 tests total) Documentation: - Updated configuration.md with glob syntax reference and examples
cb29a6d to
93f4922
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #345
Summary
Adds glob pattern support to the
postCreate.copyFilesconfiguration option, allowing users to match multiple files with a single pattern instead of listing each file individually.This enhancement significantly improves the developer experience by enabling flexible file matching whilst maintaining full backward compatibility with exact file paths.
Changes
Examples
Before:
{ "postCreate": { "copyFiles": [".env", ".env.local", ".env.development", ".env.production"] } }After:
{ "postCreate": { "copyFiles": [".env*"] } }Advanced patterns:
{ "postCreate": { "copyFiles": [ ".env*", "config/**/*.local.yml", "secrets/[ab]*.json" ] } }Supported Patterns
*- Matches any characters except/(e.g.,*.envmatches.envbut notconfig/.env)**- Matches any characters including/(recursive, e.g.,**/*.ymlmatches all.ymlfiles in any subdirectory)?- Matches any single character (e.g.,file?.txtmatchesfile1.txtbut notfile10.txt)[abc]- Matches any character in the brackets (e.g.,file-[ab].txtmatchesfile-a.txtandfile-b.txt)Implementation Highlights
glob-resolver module:
resolveGlobPatterns()- Main resolution function with glob expansionrecursiveReaddir()- Walks directory trees for **/ patternsmatchesPattern()- Regex-based glob pattern matchingfile-copier integration:
globSync)Testing
22 glob-resolver unit tests covering:
*.env,.env*)config/**/*.local.yml)?,[abc])12 file-copier integration tests verifying:
All tests passing: 193 tests total (existing + new)
Technical Details
fs.globSync()(zero dependencies).gitdirectory from recursive searches--copy-fileflagVerification Steps
pnpm installpnpm testpnpm lintBackward Compatibility
✅ Fully backward compatible - all existing exact file paths continue to work unchanged. Literal file paths take precedence over glob pattern matching, so files with glob characters in their names are handled correctly.