-
Notifications
You must be signed in to change notification settings - Fork 0
feat: support windows platform #11
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: master
Are you sure you want to change the base?
Conversation
Signed-off-by: seven <[email protected]>
Signed-off-by: seven <[email protected]>
|
@copilot finish the implementation |
Completes Windows platform support by fixing zip file extraction and
cross-platform path handling. The initial implementation had incomplete
zip extraction logic with incorrect parameter passing and path
concatenation that would fail on Windows.
## Changes
- **Fixed `downloadZip` function**: Added missing `extractPath`
parameter, proper directory creation per file, and error handling for
read/write streams
- **Cross-platform paths**: Replaced string concatenation
(`${path}/${file}`) with `path.join()` and `path.dirname()` for Windows
compatibility
- **Corrected function call**: Pass both zip file path and extraction
directory to `downloadZip()`
- **Standardized permissions**: Use 0o755 consistently (Windows ignores
Unix modes without error)
## Example
The zip extraction now properly handles nested paths on both Unix and
Windows:
```typescript
// Before: Failed on Windows with hardcoded forward slashes
const filePath = `${extractPath}/${entry.fileName}`;
const fileDir = filePath.substring(0, filePath.lastIndexOf('/'));
// After: Cross-platform path handling
const filePath = path.join(extractPath, entry.fileName);
const fileDir = path.dirname(filePath);
```
This enables Windows users to run jest-search with Elasticsearch,
OpenSearch, and ZincSearch, which all distribute Windows binaries as zip
files.
<!-- START COPILOT CODING AGENT TIPS -->
---
💬 We'd love your input! Share your thoughts on Copilot coding agent in
our [2 minute survey](https://gh.io/copilot-coding-agent-survey).
---------
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: Blankll <[email protected]>
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 adds Windows platform support to the project by implementing ZIP file handling capabilities alongside the existing tar.gz extraction. The main changes include adding the yauzl library for ZIP extraction, updating platform detection logic to recognize Windows (win32), and modifying URL generation for all supported search engines.
Key changes:
- Implemented ZIP file detection and extraction using the
yauzllibrary - Updated
isFileExistsfrom async to sync implementation - Modified platform-specific URL generation for Elasticsearch, OpenSearch, and ZincSearch to support Windows
Reviewed changes
Copilot reviewed 2 out of 3 changed files in this pull request and generated 9 comments.
| File | Description |
|---|---|
| src/utils.ts | Core implementation of Windows support including ZIP handling functions, platform detection updates, and binary URL generation for win32 |
| package.json | Added yauzl dependency for ZIP extraction and @types/yauzl dev dependency for TypeScript support |
| package-lock.json | Lock file updates for new dependencies including yauzl, buffer-crc32, and pend packages |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
@copilot fix the test failure issues |
…ities (#26) CI failures were caused by incorrect OpenSearch URL generation for macOS and critical npm audit security vulnerabilities. ## Changes - **OpenSearch URL generation**: Fixed to use `linux` for non-Windows platforms. OpenSearch only provides Windows and Linux builds; the Linux build works on macOS and other Unix-like systems. - **Windows test coverage**: Added test cases for win32 platform across all three engines (Elasticsearch, OpenSearch, ZincSearch). - **Resource management**: - Fixed file descriptor leak in `isZipFile` - now properly closes FDs in all code paths - Added cleanup handler for zip extraction errors - Added file renaming when `.zip` download is actually gzipped - **Error handling**: Enhanced download errors to include HTTP status codes and response text. - **Security**: Resolved npm audit vulnerabilities including critical form-data issue. ```typescript // Before: darwin would generate opensearch-2.9.0-darwin-x64.tar.gz (doesn't exist) const systemName = sysName === 'win32' ? 'windows' : sysName; // After: darwin uses linux build which works on macOS const systemName = sysName === 'win32' ? 'windows' : 'linux'; ``` <!-- START COPILOT CODING AGENT TIPS --> --- 💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more [Copilot coding agent tips](https://gh.io/copilot-coding-agent-tips) in the docs. --------- Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: Blankll <[email protected]>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #11 +/- ##
==========================================
- Coverage 85.21% 79.17% -6.04%
==========================================
Files 9 9
Lines 230 317 +87
Branches 38 56 +18
==========================================
+ Hits 196 251 +55
- Misses 26 51 +25
- Partials 8 15 +7 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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
Copilot reviewed 3 out of 4 changed files in this pull request and generated 6 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Addresses three critical issues in the Windows ZIP extraction
implementation: missing test coverage, promise settling race condition,
and path traversal vulnerability.
## Changes
- **Security**: Fixed path traversal vulnerability in `downloadZip` by
validating extracted paths with `path.resolve()` before file creation
```typescript
const resolvedExtractPath = path.resolve(extractPath);
const resolvedFilePath = path.resolve(extractPath, entry.fileName);
if (!resolvedFilePath.startsWith(resolvedExtractPath + path.sep)) {
return cleanup(new Error(`Path traversal attempt detected:
${entry.fileName}`));
}
```
- **Promise handling**: Added `settled` flag in `downloadZip` cleanup to
prevent double resolution/rejection when zipfile events fire after
errors
- **Test coverage**: Added 11 unit tests for `isZipFile` and
`downloadZip` covering normal operation, edge cases (empty files,
non-existent files, subdirectories), and security scenarios (path
traversal attempts with `../` and `../../`)
- **Exports**: Made `isZipFile` and `downloadZip` publicly exported for
testing
Defense in depth: Both yauzl library validation and custom path checking
reject malicious ZIP entries.
<!-- START COPILOT CODING AGENT TIPS -->
---
✨ Let Copilot coding agent [set things up for
you](https://github.com/geek-fun/jest-search/issues/new?title=✨+Set+up+Copilot+instructions&body=Configure%20instructions%20for%20this%20repository%20as%20documented%20in%20%5BBest%20practices%20for%20Copilot%20coding%20agent%20in%20your%20repository%5D%28https://gh.io/copilot-coding-agent-tips%29%2E%0A%0A%3COnboard%20this%20repo%3E&assignees=copilot)
— coding agent works faster and does higher quality work when set up for
your repo.
---------
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: Blankll <[email protected]>
|
@copilot add Windows Runtime in GitHub action pipeline |
The PR introduced Windows platform support with ZIP file handling, but the CI pipeline only tested on macOS and Linux. **CI coverage:** - Added `windows-latest` to the GitHub Actions OS matrix to validate Windows-specific code paths (ZIP extraction, platform detection, binary URL generation) This ensures all three target platforms are tested in CI, catching platform-specific issues before merge. <!-- START COPILOT CODING AGENT TIPS --> --- ✨ Let Copilot coding agent [set things up for you](https://github.com/geek-fun/jest-search/issues/new?title=✨+Set+up+Copilot+instructions&body=Configure%20instructions%20for%20this%20repository%20as%20documented%20in%20%5BBest%20practices%20for%20Copilot%20coding%20agent%20in%20your%20repository%5D%28https://gh.io/copilot-coding-agent-tips%29%2E%0A%0A%3COnboard%20this%20repo%3E&assignees=copilot) — coding agent works faster and does higher quality work when set up for your repo. --------- Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: Blankll <[email protected]>
|
@copilot 1. Git Configuration (
|
Implements standardized line ending handling across macOS, Windows, and Linux to prevent CRLF/LF inconsistencies in the codebase. **Configuration files added:** * `.gitattributes` - Minimal configuration with auto-detection to normalize text files to LF, excludes README.md from normalization * `.editorconfig` - Minimal configuration enforcing LF endings and 2-space indentation **Normalization:** * Applied Prettier formatting to workflow files with the already-configured `endOfLine: "lf"` setting * README.md is preserved in its original state and excluded from line ending normalization * Renormalized repository with Git to apply new attributes This ensures consistent line endings for code files regardless of developer platform, preventing spurious diffs and merge conflicts from line ending variations, while preserving documentation files as-is. The configuration files use minimal rules, relying on Git's auto-detection and Prettier for formatting. <!-- START COPILOT CODING AGENT TIPS --> --- 💬 We'd love your input! Share your thoughts on Copilot coding agent in our [2 minute survey](https://gh.io/copilot-coding-agent-survey). --------- Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: Blankll <[email protected]>
This pull request enhances the cross-platform download and extraction logic for search engine binaries, with a focus on supporting Windows systems and zip file handling. The main improvements include robust detection and extraction of zip files, dynamic URL generation based on platform, and better error handling during downloads.
Platform and archive handling improvements:
yauzllibrary, enabling proper handling of Windows zip binaries and fallback to gzip extraction if mislabelled. (src/utils.ts,package.json, [1] [2] [3] [4]src/utils.ts, src/utils.tsR154-R255)File and directory utilities:
src/utils.ts, [1] [2]Download and extraction robustness:
src/utils.ts, src/utils.tsL65-R139)tests/utils.test.ts, tests/utils.test.tsR84-R104)