-
Notifications
You must be signed in to change notification settings - Fork 88
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
fix: block tgz #763
fix: block tgz #763
Conversation
WalkthroughThis PR introduces new dependencies and logic to handle package blocking. The Changes
Possibly related PRs
Suggested reviewers
Poem
Warning There were issues while running some tools. Please review the errors and either fix the tool’s configuration or disable the tool if it’s a critical failure. 🔧 ESLint
app/port/controller/package/DownloadPackageVersionTar.tsOops! Something went wrong! :( ESLint: 8.57.1 ESLint couldn't find the plugin "eslint-plugin-eggache". (The package "eslint-plugin-eggache" was not found when loaded as a Node module from the directory "".) It's likely that the plugin isn't installed correctly. Try reinstalling by running the following:
The plugin "eslint-plugin-eggache" was referenced from the config file in ".eslintrc » eslint-config-egg/typescript » ./index.js". If you still can't figure out the problem, please stop by https://eslint.org/chat/help to chat with the team. 📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
⏰ Context from checks skipped due to timeout of 90000ms (10)
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
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.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
app/core/service/PackageVersionService.ts
(3 hunks)app/port/controller/package/DownloadPackageVersionTar.ts
(3 hunks)test/port/controller/package/DownloadPackageVersionTarController.test.ts
(5 hunks)
🧰 Additional context used
🪛 GitHub Check: test-postgresql-fs-nfs (22, ubuntu-latest)
app/core/service/PackageVersionService.ts
[failure] 127-127:
A space is required after '['
[failure] 127-127:
A space is required before ']'
🪛 GitHub Check: test-postgresql-fs-nfs (20, ubuntu-latest)
app/core/service/PackageVersionService.ts
[failure] 127-127:
A space is required after '['
[failure] 127-127:
A space is required before ']'
🪛 GitHub Check: test-mysql57-fs-nfs (22, ubuntu-latest)
app/core/service/PackageVersionService.ts
[failure] 127-127:
A space is required after '['
[failure] 127-127:
A space is required before ']'
🪛 GitHub Check: test-mysql57-fs-nfs (20, ubuntu-latest)
app/core/service/PackageVersionService.ts
[failure] 127-127:
A space is required after '['
[failure] 127-127:
A space is required before ']'
🪛 GitHub Check: test-postgresql-fs-nfs (18, ubuntu-latest)
app/core/service/PackageVersionService.ts
[failure] 127-127:
A space is required after '['
[failure] 127-127:
A space is required before ']'
🪛 GitHub Check: test-mysql57-fs-nfs (18, ubuntu-latest)
app/core/service/PackageVersionService.ts
[failure] 127-127:
A space is required after '['
[failure] 127-127:
A space is required before ']'
🪛 GitHub Check: test-postgresql-fs-nfs (18.20.0, ubuntu-latest)
app/core/service/PackageVersionService.ts
[failure] 127-127:
A space is required after '['
[failure] 127-127:
A space is required before ']'
🪛 GitHub Check: test-mysql57-fs-nfs (18.20.0, ubuntu-latest)
app/core/service/PackageVersionService.ts
[failure] 127-127:
A space is required after '['
[failure] 127-127:
A space is required before ']'
🪛 GitHub Actions: Node.js CI
app/core/service/PackageVersionService.ts
[error] 127-127: ESLint: A space is required after '[' (array-bracket-spacing)
⏰ Context from checks skipped due to timeout of 90000ms (2)
- GitHub Check: Analyze (typescript)
- GitHub Check: Analyze (javascript)
🔇 Additional comments (7)
app/port/controller/package/DownloadPackageVersionTar.ts (2)
61-69
: Review of block check implementation.The implementation properly checks for package blocking before proceeding with the download. It correctly handles error messaging and sets appropriate headers.
A couple of observations:
- The comment "block tgz only all versions have been blocked" suggests this is a package-level block, not a version-specific block
- The code correctly follows the "fail fast" principle by checking for blocks early in the flow
22-22
: Dependencies are properly injected.The PackageVersionService import and injection are correctly implemented.
Also applies to: 34-35
test/port/controller/package/DownloadPackageVersionTarController.test.ts (4)
7-7
: Test setup is properly prepared.The test correctly imports and initializes the PackageManagerService. The explicit unblocking in the beforeEach setup ensures tests start with a clean state, which is good practice.
Also applies to: 12-12, 16-16, 45-45
64-70
: Test case for blocking functionality is well-designed.This test case properly verifies that a blocked package returns a 451 status code with an appropriate error message when using the main download endpoint.
353-359
: Test case for blocking via deprecated download path.This test correctly verifies the blocking functionality works with the deprecated download path.
409-415
: Test case for blocking via Verdaccio-style path.This test verifies that the blocking functionality works with the Verdaccio-style path, ensuring comprehensive coverage of all download endpoints.
app/core/service/PackageVersionService.ts (1)
8-8
: Dependencies are properly imported and injected.The required repositories are correctly imported and injected into the service.
Also applies to: 11-11, 20-24
async findBlockInfo(fullname: string) { | ||
const [scope, name] = getScopeAndName(fullname); | ||
const pkg = await this.packageRepository.findPackage(scope, name); | ||
if (!pkg) { | ||
return null; | ||
} | ||
return await this.packageVersionBlockRepository.findPackageBlock(pkg.packageId); | ||
} |
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.
🛠️ Refactor suggestion
Fix linting issues with array bracket spacing.
The implementation of findBlockInfo looks correct, but there's a linting issue with the array bracket spacing according to the static analysis and pipeline failures.
Apply this fix to resolve the linting issue:
- const [scope, name] = getScopeAndName(fullname);
+ const [ scope, name ] = getScopeAndName(fullname);
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
async findBlockInfo(fullname: string) { | |
const [scope, name] = getScopeAndName(fullname); | |
const pkg = await this.packageRepository.findPackage(scope, name); | |
if (!pkg) { | |
return null; | |
} | |
return await this.packageVersionBlockRepository.findPackageBlock(pkg.packageId); | |
} | |
async findBlockInfo(fullname: string) { | |
- const [scope, name] = getScopeAndName(fullname); | |
+ const [ scope, name ] = getScopeAndName(fullname); | |
const pkg = await this.packageRepository.findPackage(scope, name); | |
if (!pkg) { | |
return null; | |
} | |
return await this.packageVersionBlockRepository.findPackageBlock(pkg.packageId); | |
} |
🧰 Tools
🪛 GitHub Check: test-postgresql-fs-nfs (22, ubuntu-latest)
[failure] 127-127:
A space is required after '['
[failure] 127-127:
A space is required before ']'
🪛 GitHub Check: test-postgresql-fs-nfs (20, ubuntu-latest)
[failure] 127-127:
A space is required after '['
[failure] 127-127:
A space is required before ']'
🪛 GitHub Check: test-mysql57-fs-nfs (22, ubuntu-latest)
[failure] 127-127:
A space is required after '['
[failure] 127-127:
A space is required before ']'
🪛 GitHub Check: test-mysql57-fs-nfs (20, ubuntu-latest)
[failure] 127-127:
A space is required after '['
[failure] 127-127:
A space is required before ']'
🪛 GitHub Check: test-postgresql-fs-nfs (18, ubuntu-latest)
[failure] 127-127:
A space is required after '['
[failure] 127-127:
A space is required before ']'
🪛 GitHub Check: test-mysql57-fs-nfs (18, ubuntu-latest)
[failure] 127-127:
A space is required after '['
[failure] 127-127:
A space is required before ']'
🪛 GitHub Check: test-postgresql-fs-nfs (18.20.0, ubuntu-latest)
[failure] 127-127:
A space is required after '['
[failure] 127-127:
A space is required before ']'
🪛 GitHub Check: test-mysql57-fs-nfs (18.20.0, ubuntu-latest)
[failure] 127-127:
A space is required after '['
[failure] 127-127:
A space is required before ']'
🪛 GitHub Actions: Node.js CI
[error] 127-127: ESLint: A space is required after '[' (array-bracket-spacing)
c6be752
to
56135e5
Compare
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.
ci 需要修复一下
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #763 +/- ##
==========================================
+ Coverage 96.33% 96.43% +0.10%
==========================================
Files 191 192 +1
Lines 19070 19306 +236
Branches 2483 2526 +43
==========================================
+ Hits 18371 18618 +247
+ Misses 699 688 -11 ☔ View full report in Codecov by Sentry. |
[skip ci] ## [3.74.2](v3.74.1...v3.74.2) (2025-02-27) ### Bug Fixes * block tgz ([#763](#763)) ([3054577](3054577))
@elrrrrrrr 你来部署一下呗 |
DownloadPackageVersionTarController#download
接口新增校验逻辑,判断是否允许下载Summary by CodeRabbit
New Features
Tests