怎样建立一个bower私库
生活随笔
收集整理的這篇文章主要介紹了
怎样建立一个bower私库
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
本教程適用于centos
安裝之前
檢查nodejs
假設沒安裝nodejs依照下面步驟安裝$ su - $ yum install openssl-devel $ cd /usr/local/src $ wget http://nodejs.org/dist/v0.10.29/node-v0.10.29.tar.gz $ tar zxvf node-v0.10.29.tar.gz $ cd node-v0.10.29 $ ./configure $ make $ make install
查一下版本,看有沒有成功安裝: ?
$ node -v v0.10.29
檢查git
假設沒安裝,請依照下面步驟安裝
$ sudo yum -y install git開始安裝bower私庫
STEP 1 安裝 git 和 git-deamon
$ sudo yum install -y git git-daemonSTEP 2 安裝 private-bower
$ sudo npm install -g private-bowerSTEP 3 設置 private-bower?
$ sudo su - $ cd /data $ mkdir private-bower $ vim /data/private-bower-config.json將下面內容粘貼進去:
{"port": 5678,"registryFile": "./private-bower/bowerRepository.json","disablePublic": false,"publicRegistry": "http://bower.herokuapp.com/packages/","repositoryCache": {"git": {"enabled": true,"cacheDirectory": "./private-bower/gitRepoCache","host": "<bower server ip>","port": 6789},"svn": {"enabled": true,"cacheDirectory": "./private-bower/svnRepoCache","host": "<span style="font-family: Arial, Helvetica, sans-serif;"><bower server ip></span><span style="font-family: Arial, Helvetica, sans-serif;">",</span>"port": 7891}},"log4js" : {"enabled": true,"configPath" : "./private-bower/log4js.conf.json"} }
當中的 <bower server ip> 換成你server在外部看起來的ip,由于假設有人已經用過這個庫,比方 jquery,再次使用private-bower會讓client直接連接server的6789port去獲取緩存,所以這個host是給client識別用的
{"appenders": [{"type": "dateFile","filename": "./private-bower/private-bower.log","pattern": "-yyyy-MM-dd","alwaysIncludePattern": false},{"type": "console"}],"replaceConsole": true }
啟動 private-bower
$ sudo su - $ cd /data $ private-bower --config ./private-bower-config.json [2014-06-30 10:00:22.481] [INFO] console - [bower] Refreshing public packages... [2014-06-30 10:00:22.512] [INFO] console - [bower] Bower server started on port 5678 [2014-06-30 10:00:22.538] [INFO] console - [bower] Starting git cache server [2014-06-30 10:00:22.543] [INFO] console - [bower] Starting svn cache server [2014-06-30 10:01:09.167] [INFO] console - [bower] Loaded public packages
確保 private-bower 正常啟動:
打開一個新窗體來訪問:
$ lynx http://localhost:5678/
會顯示:
? ?
? ?Fork me on GitHub
Private Bower
? ?____________________
? ?Docs Public Packages
? ?Private Bower service is down
? ?No private packages registered read docs about how to register packages.
? ?Loading Packages...
{{ package.name }}
? ?hits: {{ package.hits }}
? ?{{ package.repo }}
Created by
? ?BarnaToth
Barna Tóth
假設是這樣。就安裝完成了
client測試
$ sudo su - $ npm install -g bower $ su - wlsuser $ bower help $ vim .bowerrc { "registry": "http://<your private repository ip>:5678" } $ cd <testdir> $ bower install jquery有用命令
刪除庫
使用 POST 方式發送json到 removePackage 路徑bower-server:5678/removePackage
{ "name": "package-name" }
清除本地bower緩存
$ bower cache clean總結
以上是生活随笔為你收集整理的怎样建立一个bower私库的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 说说JSON和JSONP
- 下一篇: Java发邮件-QQ服务器认证