Skip to content

Commit a88ba47

Browse files
maantjeGiteaBot
authored andcommitted
Add bin to Composer Metadata (go-gitea#32099)
This PR addresses the missing `bin` field in Composer metadata, which currently causes vendor-provided binaries to not be symlinked to `vendor/bin` during installation. In the current implementation, running `composer install` does not publish the binaries, leading to issues where expected binaries are not available. By properly declaring the `bin` field, this PR ensures that binaries are correctly symlinked upon installation, as described in the [Composer documentation](https://getcomposer.org/doc/articles/vendor-binaries.md).
1 parent ea9e09a commit a88ba47

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

modules/packages/composer/metadata.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ type Metadata struct {
4343
Homepage string `json:"homepage,omitempty"`
4444
License Licenses `json:"license,omitempty"`
4545
Authors []Author `json:"authors,omitempty"`
46+
Bin []string `json:"bin,omitempty"`
4647
Autoload map[string]any `json:"autoload,omitempty"`
4748
AutoloadDev map[string]any `json:"autoload-dev,omitempty"`
4849
Extra map[string]any `json:"extra,omitempty"`

tests/integration/api_packages_composer_test.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ func TestPackageComposer(t *testing.T) {
3636
packageType := "composer-plugin"
3737
packageAuthor := "Gitea Authors"
3838
packageLicense := "MIT"
39+
packageBin := "./bin/script"
3940

4041
var buf bytes.Buffer
4142
archive := zip.NewWriter(&buf)
@@ -49,6 +50,9 @@ func TestPackageComposer(t *testing.T) {
4950
{
5051
"name": "` + packageAuthor + `"
5152
}
53+
],
54+
"bin": [
55+
"` + packageBin + `"
5256
]
5357
}`))
5458
archive.Close()
@@ -210,6 +214,8 @@ func TestPackageComposer(t *testing.T) {
210214
assert.Len(t, pkgs[0].Authors, 1)
211215
assert.Equal(t, packageAuthor, pkgs[0].Authors[0].Name)
212216
assert.Equal(t, "zip", pkgs[0].Dist.Type)
213-
assert.Equal(t, "7b40bfd6da811b2b78deec1e944f156dbb2c747b", pkgs[0].Dist.Checksum)
217+
assert.Equal(t, "4f5fa464c3cb808a1df191dbf6cb75363f8b7072", pkgs[0].Dist.Checksum)
218+
assert.Len(t, pkgs[0].Bin, 1)
219+
assert.Equal(t, packageBin, pkgs[0].Bin[0])
214220
})
215221
}

0 commit comments

Comments
 (0)