Skip to content
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

npm package registry support for bin #21372

Merged
merged 4 commits into from
Oct 8, 2022

Conversation

eleith
Copy link
Contributor

@eleith eleith commented Oct 7, 2022

npm package.json supports binary packaging:
https://docs.npmjs.com/cli/v8/configuring-npm/package-json#bin

the npm registry documents that the binary references will be attached to the abbreviated version object:
https://github.com/npm/registry/blob/master/docs/responses/package-metadata.md#abbreviated-version-object

unfortunately their api documentation leaves this out: https://github.com/npm/registry/blob/master/docs/responses/package-metadata.md#abbreviated-version-objectdoc

which is likely to be the reason this was left out in gitea's initial implementation

this response is critical for npm to install the binary in the .bin folder so as to be included on the users default bin path, resulting in immediate access to any binaries provided by the package

i have tested upload and installing through npm and can confirm the npm registry now responds with bin in the version metadata and results in the binary being available after install.

this fixes #21303

npm package.json supports binary packaging:
https://docs.npmjs.com/cli/v8/configuring-npm/package-json#bin

the npm registry documents that the binary references will be attached
to the abbreviated version object:
https://github.com/npm/registry/blob/master/docs/responses/package-metadata.md#abbreviated-version-object

unfortunately their api documentation leaves this out:
https://github.com/npm/registry/blob/master/docs/responses/package-metadata.md#abbreviated-version-objectdoc

which is likely to be the reason this was left out in gitea's initial
implementation

this response is critical for npm to install the binary in the `.bin`
folder so as to be included on the users default bin path, resulting in
immediate access to any binaries provied by the package

Signed-off-by: eleith <[email protected]>
@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Oct 7, 2022
@silverwind silverwind added this to the 1.18.0 milestone Oct 7, 2022
@GiteaBot GiteaBot added lgtm/need 1 This PR needs approval from one additional maintainer to be merged. and removed lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. labels Oct 7, 2022
@GiteaBot GiteaBot added lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. and removed lgtm/need 1 This PR needs approval from one additional maintainer to be merged. labels Oct 8, 2022
@wxiaoguang wxiaoguang merged commit bbbf9a4 into go-gitea:main Oct 8, 2022
@eleith eleith deleted the eleith-npm-versions-bin branch October 8, 2022 06:25
@eleith eleith restored the eleith-npm-versions-bin branch October 8, 2022 06:26
@eleith eleith deleted the eleith-npm-versions-bin branch October 8, 2022 13:05
zjjhot added a commit to zjjhot/gitea that referenced this pull request Oct 11, 2022
* upstream/main:
  Add user/organization code search (go-gitea#19977)
  Stop logging CheckPath returns error: context canceled (go-gitea#21064)
  Hook go-licenses into tidy again (go-gitea#21353)
  Fix missing left and right carets in TRANSLATORS (go-gitea#21397)
  Fix calls to i18n in templates (go-gitea#21394)
  Update JS dependencies and eslint config (go-gitea#21388)
  Allow creation of OAuth2 applications for orgs (go-gitea#18084)
  Fix typos in PullRequestMergeForm.vue header comment (go-gitea#21378)
  Use weighted algorithm for string matching when finding files in repo (go-gitea#21370)
  Bump playwright to 1.26.1 (go-gitea#21357)
  npm package registry support for `bin` (go-gitea#21372)
  Removed one extra whitespace in footer after "Template" (go-gitea#21364)
@lunny
Copy link
Member

lunny commented Oct 24, 2022

Please send backport

@eleith
Copy link
Contributor Author

eleith commented Oct 25, 2022

Please send backport

@lunny sent PR adding these changes to v1.17.3

@lunny lunny added the backport/done All backports for this PR have been created label Oct 25, 2022
lunny added a commit that referenced this pull request Oct 25, 2022
backport of #21372 for v1.17.4

-------------------

npm package.json supports binary packaging:
https://docs.npmjs.com/cli/v8/configuring-npm/package-json#bin

the npm registry documents that the binary references will be attached
to the abbreviated version object:

https://github.com/npm/registry/blob/master/docs/responses/package-metadata.md#abbreviated-version-object

unfortunately their api documentation leaves this out:
https://github.com/npm/registry/blob/master/docs/responses/package-metadata.md#abbreviated-version-objectdoc

which is likely to be the reason this was left out in gitea's initial
implementation

this response is critical for npm to install the binary in the .bin
folder so as to be included on the users default bin path, resulting in
immediate access to any binaries provided by the package

i have tested upload and installing through npm and can confirm the npm
registry now responds with bin in the version metadata and results in
the binary being available after install.

this fixes #21303

Co-authored-by: eleith <[email protected]>
Co-authored-by: Lunny Xiao <[email protected]>
@go-gitea go-gitea locked and limited conversation to collaborators May 3, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
backport/done All backports for this PR have been created lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. topic/packages
Projects
None yet
Development

Successfully merging this pull request may close these issues.

publishing an npm package with a specified binary does not install the binary when installed with npm
5 participants