web-node_upm-proxy-github v0.0.5
JS Proxy for Github packages and Unity Scoped Registry
About
This lightweight proxy ensures Unity 2019 and 2020 can read your private org packages through the Unity Scoped package manager. There's minimal setup required for the org members.
Unfortunately Github does not support a few NPM endpoints and doesn't seem to have it on their roadmap. Using Github as an uplink in the exquisite Verdaccio proxy can be an alternative, however you'll need to either use a reverseproxy to do some magic with URLs or do some custom coding to support UPM.
Since this application is a thin layer of nodeJS and proxies the endpoints and streams the binaries, it could even run serverless on request only.
Authentication
As an authentication layer the Github Personal Access Token is used. A minimum requirement is to allow reading packages scope read:packages
. This means that org members only have access to packages visible to them.
Add an entry to ~/.upmconfig
in this format:
[npmAuth."HOST/upm/SCOPE"]
token = "TOKEN"
alwaysAuth = true
- HOST: The url you decide to publish this app to. ex.
https://www.acme.com/upm/@acmecorp
- SCOPE: The org name prefixed with @, ex.
@acmecorp
- TOKEN: The Personal Access Token with scope read:packages
More info on the upmconfig on the official Unity documentation
Unity configuration
Scoped Registries in the Package Manager:
- Name: Reference name for the scoped registry
- URL: The full URL needs to be the exact copy of the complete
HOST/upm/SCOPE
url filled in the Authentication step. ex.https://www.acme.com/upm/@acmecorp
- Scope(s): The package name filter, ex.
com.acme
Creating packages
In order for Unity to read the packages there's a naming convention quirk to take in to account which differs from the standard scope package naming convention.
Changes in the package.json:
Naming
Remove the scope from the name
field
"name": "com.my-company.my-package",
Publish Config
Add the scope to the url in the publishConfig setting in the pack
"publishConfig": { "registry": "https://npm.pkg.github.com/@SCOPE" },
More info https://forum.unity.com/threads/using-github-packages-registry-with-unity-package-manager.861076/
Environment variables
The following server-side environment variables can be set. For development a local .env
is supported.
PORT
(Default: 8080) Server listening portSCOPE
Force the scope to use a certain organisation/user. When not set, everyone out of the org can use the proxy.CLEAR_TOKEN
A token to clear the cached responses. Useful in a github action after a new package has been published.CACHE_TTL
(Default: 7200) The ttl for keeping data in memory cache in seconds
Disclaimers
- Only tested on MacOS and with our org settings. In theory, it should work for any org.
- There's currently a max of 100 packages in the github query
TODO
- Add Heroku deploy
- Add tests
- Add /search endpoint with paging
- Add docker and/or AWS lambda support
- Add nginx
3 years ago