cache
:bower缓存管理help
:显示Bower命令的帮助信息home
:通过浏览器打开一个包的github发布页info
:查看包的信息init
:创建bower.json文件install
:安装包到项目link
:在本地bower库建立一个项目链接list
:列出项目已安装的包lookup
:根据包名查询包的URLprune
:删除项目无关的包register
:注册一个包search
:搜索包update:
更新项目的包uninstall:
删除项目的包
Bower使用
1. 安装框架或库到项目
进入项目目录,安装需要用到的框架或者库:
1
2
3
4
5
6
7
8
9
10
|
$ bower
install
bootstrap
$ bower
install
Angular
# 或者指定版本号
$ bower
install
Angular
#1.2.23
# 或者直接指定 git 库下载安装
$ bower
install
git:
//github
.com
/components/jquery
.git
# 或者按照github上的别名
$ bower
install
components
/jquery
# 或者本地库
$ bower
install
.
/repos/jquery
|
注意:Bower
依赖于版本控制工具git
,需要从github
拉取信息,需要安装git
且设置path。
2. 查看项目中已导入的类库
1
|
$ bower list
|
bower check-new Checking for new versions of the project dependencies..
atom-test /data/proj/atom-test
├── angular#1.2.23 extraneous (1.2.24-build.441+sha.5061d2c available, latestis 1.3.0-rc.0)
└─┬ bootstrap#3.2.0 extraneous
└── jquery#2.1.1
用bower提交自己类库
1. 生成bower.json配置文件
1
|
$ bower init
|
[?] name: bower-test
[?] version: 0.0.1
[?] description: bower tools test
[?] main file: bower-test.js
[?] what types of modules does this package expose?
[?] keywords: bower-test
[?] authors: alei
[?] license: MIT
[?] homepage: http://www.u396.com/
[?] set currently installed components as dependencies? No
[?] add commonly ignored files to ignore list? No
[?] would you like to mark this package as private which prevents it from being
[?] would you like to mark this package as private which prevents it from being
accidentally published to the registry? No{
name: ‘bower-test’,
version: ‘0.0.1’,
authors: [
‘alei’
],
description: ‘bower tools test’,
main: ‘bower-test.js’,
keywords: [
‘bower-test’
],
license: ‘MIT’,
homepage: ‘http://www.u396.com/’
}[?] Looks good? Yes
2. 在github创建资源库 bower-test
3. 将本地项目提交至github
1
2
3
4
5
|
$ git init
$ git add .
$ git commit -m "init"
$ git remote add origin https:
//github
.com
/alei817927/bower-test
$ git push -u origin master
|
4. 注册到bower官方类库
1
|
$ bower register nodejs-bower git@github.com:alei817927
/bower-test
.git
|
5. 查询自己的包
1
|
$ bower search bower-
test
|