-
Notifications
You must be signed in to change notification settings - Fork 80
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: sync self pkg #532
fix: sync self pkg #532
Conversation
elrrrrrrr
commented
Jun 25, 2023
- 🐞 When executing the syncTask, filter out scenarios where the target registry is the self registry.
- 🐞 syncTask 执行时,先过滤目标 registry 是当前 registry 的场景。
task.taskId, task.targetName); | ||
return; | ||
} | ||
|
||
if (pkg && pkg?.registryId !== registry?.registryId) { | ||
if (pkg.registryId) { | ||
logs.push(`[${isoNow()}] ❌❌❌❌❌ ${fullname} registry is ${pkg.registryId} not belong to ${registry?.registryId}, skip sync ❌❌❌❌❌`); |
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.
这段代码的变更是将 SyncDeleteMode 移动到 constants.ts 中并添加了 PresetRegistryName 常量。
对于代码中的修改,似乎没有风险或错误。添加PreserRegistryName 可以使代码更加清晰且易于维护。
在行号为 372 处,如果 registry?.name 是 PresetRegistryName.self 则不需要执行同步操作,会记录一条日志并退出该方法。这样做使代码结构更清晰,也可以避免意外的同步错误。
assert(log.includes(`${name} has been published to the self registry, skip sync ❌❌❌❌❌`)); | ||
|
||
}); | ||
|
||
it('should updated package manifests when version insert duplicated', async () => { | ||
// https://www.npmjs.com/package/@cnpmcore/test-sync-package-has-two-versions | ||
const name = '@cnpmcore/test-sync-package-has-two-versions'; |
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.
这段代码是针对 test/core/service/PackageSyncerService/executeTask.test.ts
中的一个测试用例。在添加一个新的测试用例,用于确保当同步任务是自注册表时,跳过同步。在测试之前,该用例创建了一个名为 @cnpmcore/test-self-sync
的包,并将它发布到自注册表中进行测试。测试执行后,通过读取任务日志来验证是否成功地跳过了同步任务,并输出消息“已将***发布到自注册表中,跳过同步”。建议对日志编写更加详细的测试用例,以方便调试和验证。
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.
LGTM
Codecov Report
@@ Coverage Diff @@
## master #532 +/- ##
==========================================
- Coverage 97.03% 96.97% -0.06%
==========================================
Files 174 174
Lines 16546 16554 +8
Branches 2168 2165 -3
==========================================
- Hits 16055 16054 -1
- Misses 491 500 +9
|
[skip ci] ## [3.34.7](v3.34.6...v3.34.7) (2023-06-25) ### Bug Fixes * sync self pkg ([#532](#532)) ([ada3e22](ada3e22))