From 1c64a57dbe65f062751b11df7e5aa698e8fb1c77 Mon Sep 17 00:00:00 2001 From: fengmk2 Date: Wed, 18 Jan 2023 09:35:10 +0800 Subject: [PATCH] fix: try to show latest version on sync log (#375) --- app/core/service/PackageSyncerService.ts | 5 +++++ test/core/service/PackageSyncerService/executeTask.test.ts | 3 +++ 2 files changed, 8 insertions(+) diff --git a/app/core/service/PackageSyncerService.ts b/app/core/service/PackageSyncerService.ts index 8ad19f3e..fb3a51a5 100644 --- a/app/core/service/PackageSyncerService.ts +++ b/app/core/service/PackageSyncerService.ts @@ -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' }, diff --git a/test/core/service/PackageSyncerService/executeTask.test.ts b/test/core/service/PackageSyncerService/executeTask.test.ts index 181c9bf9..30beb31e 100644 --- a/test/core/service/PackageSyncerService/executeTask.test.ts +++ b/test/core/service/PackageSyncerService/executeTask.test.ts @@ -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); @@ -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(); });