This document discusses setting up private npm and bower package registries within an organization by using Sinopia for npm and private-bower for bower. It describes three cases: 1) acting as a proxy to public registries and caching packages locally, 2) serving packages from the private registry without accessing public registries, and 3) publishing local packages to the private registries.
2. Case 1: acting as a proxy to public npm registry
– forming local registry
– warming up cache
Step 1.
Registry:
yourvm.com:4873
Request:
bower
Step 2.
bower is not in npm local cache
Request from public registry
Step 3.
bower returns
Put it in local cache
Step 4.
bower returns
npm -> sinopia
$ npm install
3. Case 2: serve private registry + cache
– without creating public traffic
– error: npm install packageA, not in cache, fail!
Step 1.
Registry:
yourcompany.com:4873
Request:
bower
Step 2.
Package ‘bower’ is found in npm local
cache
No request from public registry
#proxy: npmjs
Step 3.
bower returns
npm -> sinopia
$ npm install
4. Case 3: npm publish to private registry
Step 1.
publishConfig.registry:
yourcompany.com:4873
publish
Current directory
Package.json says project name is
build-tester
Step 2.
No conflict name
Store buidler-tester and its content in local cache
$ npm publish ./
Step 3.
ack
#proxy: npmjs
npm -> sinopia
5. npm -> sinopia
What is sinopia
– https://github.com/rlidwka/sinopia
– a private/caching npm repository server.
– have a local npm registry with zero configuration.
6. bower – private-bower
Case 1: acting as a proxy to public bower registry
– forming local registry
– warming up cache
Step 1.
Registry:
yourcompany.com:5678
Request:
"requirejs-text”
Step 2.
"requirejs-text”
is not found in private bower registry
request from public registry
Step 3.
"requirejs-text“
Returns, put into registry
Step 6,7,8
6, after seeing the mapping, “requirejs-text”:
git://yourcompany.com:6789/requirejs-text
7, git clone
8, return
$ bower install
private bower registry
public bower registry
…
Step 4.
"requirejs-text“:
"url":"git://github.com/requirejs/text”
Step 5.
git clone (I guess)
“requirejs-text” is in git cache folder
7. bower – private-bower
Case 2: serve private registry + cache (git daemon as git server)
– without creating public traffic
– error: bower install packageA
Step 1.
Registry:
yourcompany.com:5678
Request:
"requirejs-text”
Step 2,3,4
2, after seeing the mapping, “requirejs-text”:
git://yourcompany.com:6789/requirejs-text
3, git clone
4, return
$ bower install
private bower registry
"disablePublic": true
8. bower – private-bower
Case 3: publish local bower project to private-bower
Step 3.
bower register project1
git://yourcompany.com:6789/project1
$ npm publish ./Step 2. client side
mkdir project1 & git init & git add *
git commit -m "My initial commit message"
git remote add origin git://yourcompany.com:6789/project1
git push -u origin master
bower register project1 git://yourcompany.com:6789/project1
Step 4
ack
private bower registry
"disablePublic": true
Step 1. server side
mkdir project1
cd project1
git init --bare