private-packages-on-github
v1.0.3
Published
Install NPM package hosted by private Github repo. Support both SSH and HTTPS Github connections.
Downloads
13
Maintainers
Readme
private-packages-on-github
Install NPM package hosted by private Github repo. Support both SSH and HTTPS Github connections.
Using private git repositories that requires authentication is often necessary when running npm install, but you don't want to put keys, tokens or passwords in your code, so instead you can use this module that allows you to define packages with environment variable names to inject your keys, passwords or tokens.
Also support dev-only dependencies with devPrivatePackagesOnGithub.
Inspired by https://github.com/porsager/env-install.
Usage
- Install via
npm install -D private-packages-on-github - Add a
postinstallscript with commandinstall-private-packages-from-github - Declare your dependencies containing environment variables in
privatePackagesOnGithub
package.json example
"scripts": {
"postinstall": "install-private-packages-from-github"
},
"dependencies": {
"private-packages-on-github": "^1.0.0"
},
"privatePackagesOnGithub": {
"some-secret-module": "github.com/you/private-repo"
},
"devPrivatePackagesOnGithub": {
"some-dev-secret-module": "github.com/you/private-repo"
},In the above example some-secret-module, depend on if we have provided ENV GITHUB_TOKEN,
If
GITHUB_TOKENis defined, packages will be installed as# export GITHUB_TOKEN=abcdefg123456 npm install https://abcdefg123456:[email protected]/you/private-repoIf
GITHUB_TOKENis not defined, we will assume you have configured SSH access on the machine and install packages asnpm install git+ssh://[email protected]/you/private-repo
To obtain GITHUB_TOKEN, check Github doc here
Deploy NPM Package
Update version in package.json
Publish NPM package
npm adduser npm publish --access public
