mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-11-21 08:31:27 -05:00
Add bin to Composer Metadata (#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).
(cherry picked from commit d351a42494e71b5e2da63302c2f9b46c78e6dbde)
(cherry picked from commit 9d34731198
)
This commit is contained in:
parent
6c16834d28
commit
74712e3400
2 changed files with 8 additions and 1 deletions
|
@ -48,6 +48,7 @@ type Metadata struct {
|
||||||
Homepage string `json:"homepage,omitempty"`
|
Homepage string `json:"homepage,omitempty"`
|
||||||
License Licenses `json:"license,omitempty"`
|
License Licenses `json:"license,omitempty"`
|
||||||
Authors []Author `json:"authors,omitempty"`
|
Authors []Author `json:"authors,omitempty"`
|
||||||
|
Bin []string `json:"bin,omitempty"`
|
||||||
Autoload map[string]any `json:"autoload,omitempty"`
|
Autoload map[string]any `json:"autoload,omitempty"`
|
||||||
AutoloadDev map[string]any `json:"autoload-dev,omitempty"`
|
AutoloadDev map[string]any `json:"autoload-dev,omitempty"`
|
||||||
Extra map[string]any `json:"extra,omitempty"`
|
Extra map[string]any `json:"extra,omitempty"`
|
||||||
|
|
|
@ -37,6 +37,7 @@ func TestPackageComposer(t *testing.T) {
|
||||||
packageType := "composer-plugin"
|
packageType := "composer-plugin"
|
||||||
packageAuthor := "Gitea Authors"
|
packageAuthor := "Gitea Authors"
|
||||||
packageLicense := "MIT"
|
packageLicense := "MIT"
|
||||||
|
packageBin := "./bin/script"
|
||||||
|
|
||||||
var buf bytes.Buffer
|
var buf bytes.Buffer
|
||||||
archive := zip.NewWriter(&buf)
|
archive := zip.NewWriter(&buf)
|
||||||
|
@ -50,6 +51,9 @@ func TestPackageComposer(t *testing.T) {
|
||||||
{
|
{
|
||||||
"name": "` + packageAuthor + `"
|
"name": "` + packageAuthor + `"
|
||||||
}
|
}
|
||||||
|
],
|
||||||
|
"bin": [
|
||||||
|
"` + packageBin + `"
|
||||||
]
|
]
|
||||||
}`))
|
}`))
|
||||||
archive.Close()
|
archive.Close()
|
||||||
|
@ -211,6 +215,8 @@ func TestPackageComposer(t *testing.T) {
|
||||||
assert.Len(t, pkgs[0].Authors, 1)
|
assert.Len(t, pkgs[0].Authors, 1)
|
||||||
assert.Equal(t, packageAuthor, pkgs[0].Authors[0].Name)
|
assert.Equal(t, packageAuthor, pkgs[0].Authors[0].Name)
|
||||||
assert.Equal(t, "zip", pkgs[0].Dist.Type)
|
assert.Equal(t, "zip", pkgs[0].Dist.Type)
|
||||||
assert.Equal(t, "7b40bfd6da811b2b78deec1e944f156dbb2c747b", pkgs[0].Dist.Checksum)
|
assert.Equal(t, "4f5fa464c3cb808a1df191dbf6cb75363f8b7072", pkgs[0].Dist.Checksum)
|
||||||
|
assert.Len(t, pkgs[0].Bin, 1)
|
||||||
|
assert.Equal(t, packageBin, pkgs[0].Bin[0])
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue