Skip to content

Commit

Permalink
fix: try to show latest version on sync log (#375)
Browse files Browse the repository at this point in the history
  • Loading branch information
fengmk2 authored Jan 18, 2023
1 parent d6b35ca commit 1c64a57
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
5 changes: 5 additions & 0 deletions app/core/service/PackageSyncerService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,11 @@ export class PackageSyncerService extends AbstractService {
const versionMap = data.versions || {};
const distTags = data['dist-tags'] || {};

// show latest infomations
if (distTags.latest) {
logs.push(`[${isoNow()}] 📖 ${fullname} latest version: ${distTags.latest ?? '-'}, published time: ${JSON.stringify(timeMap[distTags.latest])}`);
}

// 1. save maintainers
// maintainers: [
// { name: 'bomsy', email: 'b4bomsy@gmail.com' },
Expand Down
3 changes: 3 additions & 0 deletions test/core/service/PackageSyncerService/executeTask.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -565,6 +565,7 @@ describe('test/core/service/PackageSyncerService/executeTask.test.ts', () => {
persist: false,
});
const result = await npmRegistry.getFullManifests(name);
const latestVersion = result.data['dist-tags'].latest;
result.data['dist-tags'].foo = '2.0.0';
mock.data(NPMRegistry.prototype, 'getFullManifests', result);
mock.data(PackageManagerService.prototype, 'savePackageTag', null);
Expand All @@ -578,6 +579,8 @@ describe('test/core/service/PackageSyncerService/executeTask.test.ts', () => {
// console.log(log);
assert(log.includes('] 🚧 Remote tag(foo: 2.0.0) not exists in local dist-tags'));
assert(!log.includes('] 🚧 Refreshing manifests to dists ......'));
assert(log.includes('] 🚧 Syncing versions 2 => 2'));
assert(log.includes(`] 📖 @cnpmcore/test-sync-package-has-two-versions latest version: ${latestVersion}, published time: ${JSON.stringify(result.data.time[latestVersion])}`));
app.mockAgent().assertNoPendingInterceptors();
});

Expand Down

0 comments on commit 1c64a57

Please sign in to comment.