Skip to content

Change JSON key dist_tags to dist-tags in npm metadata cache

What does this MR do and why?

Part of #393655 (closed)

Align JSON key dist-tags in npm metadata cache with origin package metadata:
https://github.com/npm/registry/blob/master/docs/responses/package-metadata.md#abbreviated-metadata-format
to avoid any confusion between dist_tags and dist-tags.

Screenshots or screen recordings

No.

How to set up and validate locally

All steps need to be executed in rails console

  1. Create a new npm package:

    def fixture_file_upload(*args, **kwargs)
      Rack::Test::UploadedFile.new(*args, **kwargs)
    end
    
    package = FactoryBot.create(:npm_package, project: Project.first)
  2. Execute the service to create a new entity of Packages::Npm::MetadataCache:

    Packages::Npm::CreateMetadataCacheService.new(package.project, package.name).execute
  3. Verify that the metadata JSON from a new entity of Packages::Npm::MetadataCache contains dist-tags key on the top level:

    metadata_cache = Packages::Npm::MetadataCache.last
    Gitlab::Json.parse(metadata_cache.file.read)

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Related to #393655 (closed)

Edited by Dzmitry (Dima) Meshcharakou

Merge request reports