-
Notifications
You must be signed in to change notification settings - Fork 84
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
Merged
fix: sync self pkg #532
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -719,6 +719,48 @@ describe('test/core/service/PackageSyncerService/executeTask.test.ts', () => { | |
|
||
}); | ||
|
||
it('should skip self registry', async () => { | ||
const name = '@cnpmcore/test-self-sync'; | ||
const { user } = await userService.create({ | ||
name: 'test-user', | ||
password: 'this-is-password', | ||
email: '[email protected]', | ||
ip: '127.0.0.1', | ||
}); | ||
|
||
const registry = await registryManagerService.ensureSelfRegistry(); | ||
|
||
const publishCmd = { | ||
scope: '@cnpmcore', | ||
name: 'test-self-sync', | ||
version: '1.0.0', | ||
description: '1.0.0', | ||
readme: '', | ||
registryId: registry.registryId, | ||
packageJson: { name, test: 'test', version: '1.0.0' }, | ||
dist: { | ||
content: Buffer.alloc(0), | ||
}, | ||
isPrivate: false, | ||
publishTime: new Date(), | ||
skipRefreshPackageManifests: false, | ||
}; | ||
const pkgVersion = await packageManagerService.publish(publishCmd, user); | ||
assert(pkgVersion.version === '1.0.0'); | ||
|
||
await packageSyncerService.createTask(name); | ||
const task = await packageSyncerService.findExecuteTask(); | ||
assert(task); | ||
await packageSyncerService.executeTask(task); | ||
|
||
const stream = await packageSyncerService.findTaskLog(task); | ||
assert(stream); | ||
const log = await TestUtil.readStreamToLog(stream); | ||
// console.log(log); | ||
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 commentThe reason will be displayed to describe this comment to others. Learn more. 这段代码是针对 |
||
|
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.
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 则不需要执行同步操作,会记录一条日志并退出该方法。这样做使代码结构更清晰,也可以避免意外的同步错误。