ºÝºÝߣ

ºÝºÝߣShare a Scribd company logo
Build Javascript in private environment
? Current:
¨C npm
? http://registry.npmjs.org
¨C bower
? https://bower.herokuapp.com/packages
¨C Sample
? [{"name":"10digit-geo","url":"git://github.com/10digit/geo.git","hits":4561},{"name":"10digit-
invoices","url":"git://github.com/10digit/invoices.git","hits":3937},{"name":"10digit-legal","url":"git://github.com/10digit/legal.git","hits":3518},{"name":"10digit-
payment","url":"git://github.com/10digit/payment.git","hits":3432}, ¡­ ¡­ ]
¨C git
? [url "https://"]
insteadOf = git://
¨C proxy
? http(s)://yourcompany.com:80
? Case 1: acting as a proxy to public npm registry
¨C forming local registry
¨C 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
? Case 2: serve private registry + cache
¨C without creating public traffic
¨C 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
? 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
npm -> sinopia
? What is sinopia
¨C https://github.com/rlidwka/sinopia
¨C a private/caching npm repository server.
¨C have a local npm registry with zero configuration.
bower ¨C private-bower
? Case 1: acting as a proxy to public bower registry
¨C forming local registry
¨C 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
bower ¨C private-bower
? Case 2: serve private registry + cache (git daemon as git server)
¨C without creating public traffic
¨C 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
bower ¨C 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
? bower
¨C private-bower, https://github.com/Hacklone/private-bower
? git
¨C git daemon, http://git-scm.com/book/en/v2/Git-on-the-Server-Git-Daemon
? Light weight, no authentication
? enable/disable receiving git push request: --enable=receive-pack
¨C git daemon --reuseaddr --verbose --base-path="/scratch/mingtzha/_scscheckout/dev/build/gitRepoCache" --listen=yourcompany.com --
port=6789 --export-all --enable=receive-pack
? Sample from https://bower.herokuapp.com/packages (one more time)
¨C [{"name":"10digit-geo","url":"git://github.com/10digit/geo.git","hits":4561},{"name":"10digit-
invoices","url":"git://github.com/10digit/invoices.git","hits":3937},{"name":"10digit-
legal","url":"git://github.com/10digit/legal.git","hits":3518},{"name":"10digit-
payment","url":"git://github.com/10digit/payment.git","hits":3432}, ¡­ ¡­ ]
bower ¨C private-bower
? http://thelucid.com/2008/12/02/git-setting-up-a-remote-repository-and-doing-an-initial-push
? https://github.com/npm/npm/issues/5239 (pictures ...)
? https://github.com/bower/bower/issues/329 (bower is tighly coupled with git)
Source not listed inline

More Related Content

Build javascript in private environment

  • 1. Build Javascript in private environment ? Current: ¨C npm ? http://registry.npmjs.org ¨C bower ? https://bower.herokuapp.com/packages ¨C Sample ? [{"name":"10digit-geo","url":"git://github.com/10digit/geo.git","hits":4561},{"name":"10digit- invoices","url":"git://github.com/10digit/invoices.git","hits":3937},{"name":"10digit-legal","url":"git://github.com/10digit/legal.git","hits":3518},{"name":"10digit- payment","url":"git://github.com/10digit/payment.git","hits":3432}, ¡­ ¡­ ] ¨C git ? [url "https://"] insteadOf = git:// ¨C proxy ? http(s)://yourcompany.com:80
  • 2. ? Case 1: acting as a proxy to public npm registry ¨C forming local registry ¨C 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 ¨C without creating public traffic ¨C 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 ¨C https://github.com/rlidwka/sinopia ¨C a private/caching npm repository server. ¨C have a local npm registry with zero configuration.
  • 6. bower ¨C private-bower ? Case 1: acting as a proxy to public bower registry ¨C forming local registry ¨C 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 ¨C private-bower ? Case 2: serve private registry + cache (git daemon as git server) ¨C without creating public traffic ¨C 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 ¨C 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
  • 9. ? bower ¨C private-bower, https://github.com/Hacklone/private-bower ? git ¨C git daemon, http://git-scm.com/book/en/v2/Git-on-the-Server-Git-Daemon ? Light weight, no authentication ? enable/disable receiving git push request: --enable=receive-pack ¨C git daemon --reuseaddr --verbose --base-path="/scratch/mingtzha/_scscheckout/dev/build/gitRepoCache" --listen=yourcompany.com -- port=6789 --export-all --enable=receive-pack ? Sample from https://bower.herokuapp.com/packages (one more time) ¨C [{"name":"10digit-geo","url":"git://github.com/10digit/geo.git","hits":4561},{"name":"10digit- invoices","url":"git://github.com/10digit/invoices.git","hits":3937},{"name":"10digit- legal","url":"git://github.com/10digit/legal.git","hits":3518},{"name":"10digit- payment","url":"git://github.com/10digit/payment.git","hits":3432}, ¡­ ¡­ ] bower ¨C private-bower
  • 10. ? http://thelucid.com/2008/12/02/git-setting-up-a-remote-repository-and-doing-an-initial-push ? https://github.com/npm/npm/issues/5239 (pictures ...) ? https://github.com/bower/bower/issues/329 (bower is tighly coupled with git) Source not listed inline