- 
                Notifications
    You must be signed in to change notification settings 
- Fork 90
fix: added support for generic package name #879
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
Conversation
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.
Pull Request Overview
Adds support for custom package names when publishing to GitLab's generic package registry, allowing users to specify a packageName property instead of defaulting to "release".
- Introduces packageNameproperty for generic package assets with "release" as the default value
- Updates URL construction to use the custom package name in API endpoints
- Adds comprehensive test coverage for the new functionality
Reviewed Changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description | 
|---|---|
| lib/publish.js | Implements packageName support with template processing and URL encoding | 
| test/publish.test.js | Adds test case for custom packageName functionality | 
| README.md | Documents the new packageName property in the assets table | 
| test/helpers/mock-gitlab.js | Code style formatting changes (single to double quotes) | 
| test/fixtures/files/file.css | Formatting change for CSS test fixture | 
| lib/definitions/errors.js | Code style formatting changes (single to double quotes) | 
| lib/definitions/constants.js | Code style formatting changes (single to double quotes) | 
| const encodedLabel = encodeURIComponent(generic.label); | ||
| const encodedPackageName = encodeURIComponent(generic.packageName); | ||
| const expectedUrl = `https://gitlab.com/api/v4/projects/${encodedProjectPath}/packages/generic/${encodedPackageName}/${encodedVersion}/${encodedLabel}`; | 
    
      
    
      Copilot
AI
    
    
    
      Aug 7, 2025 
    
  
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.
The expectedUrl construction is inconsistent with the actual upload endpoint. The test uses encodedLabel in the URL construction but the upload endpoint uses the filename from the file path. This could cause the test to pass incorrectly if the label and filename differ.
| const encodedLabel = encodeURIComponent(generic.label); | |
| const encodedPackageName = encodeURIComponent(generic.packageName); | |
| const expectedUrl = `https://gitlab.com/api/v4/projects/${encodedProjectPath}/packages/generic/${encodedPackageName}/${encodedVersion}/${encodedLabel}`; | |
| const encodedFilename = encodeURIComponent(require("path").basename(generic.path)); | |
| const encodedPackageName = encodeURIComponent(generic.packageName); | |
| const expectedUrl = `https://gitlab.com/api/v4/projects/${encodedProjectPath}/packages/generic/${encodedPackageName}/${encodedVersion}/${encodedFilename}`; | 
| .reply(200); | ||
| const gitlabUpload = authenticate(env) | ||
| .put( | ||
| `/projects/${encodedProjectPath}/packages/generic/${encodedPackageName}/${encodedVersion}/${encodedLabel}?status=${generic.status}&select=package_file`, | 
    
      
    
      Copilot
AI
    
    
    
      Aug 7, 2025 
    
  
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.
The upload endpoint uses encodedLabel as the filename parameter, but according to GitLab's generic package API, this should be the actual filename from the file path, not the label. The label is metadata while the filename should match the actual file being uploaded.
| `/projects/${encodedProjectPath}/packages/generic/${encodedPackageName}/${encodedVersion}/${encodedLabel}?status=${generic.status}&select=package_file`, | |
| `/projects/${encodedProjectPath}/packages/generic/${encodedPackageName}/${encodedVersion}/${encodedFilename}?status=${generic.status}&select=package_file`, | 
The current version of this project doesn't support custom generic packages names, instead publishes them under the
releasepackage.When publishing generic packages to the package repository on Gitlab, you are able to specify the name of your package in the URL :
/projects/:id/packages/generic/:package_name/:package_version/:file_nameI added the ability to provide a custom package name through the optional
packageNameproperty.Usage example:
This will create a new
stylespackage in the Gitlab package repository with the specified files.