如何注册删除自己的js库到bower私库

来源:互联网 发布:淘宝生意参谋在哪里 编辑:程序博客网 时间:2024/05/17 21:07

建立自己的bower 私库的方式参考http://blog.csdn.net/nsrainbow/article/details/35988611 这篇文章

我们如果想注册自己创造的js库到私库怎么办呢?


前提条件

你必须在 github 有一个库

在你的项目根目录下要有bower.json文件,例子

[javascript] view plaincopy在CODE上查看代码片派生到我的代码片
  1. {  
  2.   "name""testbowerregistry",  
  3.   "version""0.0.1",  
  4.   "homepage""https://github.com/alexxiyang/testbowerregistry",  
  5.   "description""just test bower registry",  
  6.   "main""app.js",  
  7.   "license""MIT",  
  8.   "ignore": [  
  9.     "**/.*",  
  10.     "node_modules",  
  11.     "bower_components",  
  12.     "test",  
  13.     "tests"  
  14.   ]  
  15. }  


版本

bower 是根据你的git tag 来划分版本的:
git建立tag方法
[plain] view plaincopy在CODE上查看代码片派生到我的代码片
  1. git tag -a 0.0.2 -m 'my version 0.02'  
  2. git push --tags  

这样在你要install这个包的时候可以用这样的语法指定版本
[plain] view plaincopy在CODE上查看代码片派生到我的代码片
  1. $ bower install testbowerregistry#0.0.2  

注册

[plain] view plaincopy在CODE上查看代码片派生到我的代码片
  1. $ curl -X POST http://<span style="font-family: Consolas, 'Courier New', Courier, mono, serif; line-height: 18px;">yourserverip</span>:5678/registerPackages -d '{"packages":[{"name":"testbowerregistry","repo":"https://github.com/alexxiyang/testbowerregistry.git"}]}' -H "Content-Type: application/json"   

如果有带权限控制的话

[plain] view plaincopy在CODE上查看代码片派生到我的代码片
  1. $ curl -X POST http://yourserverip:5678/registerPackages -d '{"packages":[{"name":"testbowerregistry","repo":"https://github.com/alexxiyang/testbowerregistry.git"}]}' -H "Content-Type: application/json" --header "Auth-Key:123456"  

删除

[plain] view plaincopy在CODE上查看代码片派生到我的代码片
  1. $ curl -X POST http://yourserverip:5678/removePackage -d '{"name":"testbowerregistry"}' -H "Content-Type: application/json"  
0 0