Skip to content

Instantly share code, notes, and snippets.

@macrotea
Last active August 29, 2015 14:00
Show Gist options
  • Select an option

  • Save macrotea/11308837 to your computer and use it in GitHub Desktop.

Select an option

Save macrotea/11308837 to your computer and use it in GitHub Desktop.
实践bower的相关操作命令
在Window下通过CMD命令行实践bower的过程,bower需要依赖nodejs和npm,请正确安装!
D:\>mkdir bower-demo && cd bower-demo
D:\bower-demo>node -v
v0.10.26
D:\bower-demo>npm -v
1.4.3
D:\bower-demo>npm install bower -g
npm http GET https://registry.npmjs.org/bower
npm http 200 https://registry.npmjs.org/bower
npm http GET https://registry.npmjs.org/bower/-/bower-1.3.3.tgz
npm http 200 https://registry.npmjs.org/bower/-/bower-1.3.3.tgz
npm http GET https://registry.npmjs.org/abbrev
npm http GET https://registry.npmjs.org/bower-config
........
├── handlebars@1.3.0 (optimist@0.3.7, uglify-js@2.3.6)
├── decompress-zip@0.0.6 (mkpath@0.1.0, touch@0.0.2, readable-stream@1.1.13-1, binary@0.3.0)
├── request@2.34.0 (json-stringify-safe@5.0.0, qs@0.6.6, forever-agent@0.5.2, aws-sign2@0.5.0, tunnel-agent@0.3.0, oauth-sign@0.3.0, mime@1.2.11, node-uuid@1.4.1, tough-cookie@0.12.1, hawk@1.0.0, http-signature@0.10.0, form-data@0.1.2)
├── bower-registry-client@0.2.0 (request-replay@0.2.0, lru-cache@2.3.1, async@0.2.10, bower-config@0.4.5, request@2.27.0)
├── update-notifier@0.1.8 (semver@2.1.0, configstore@0.2.3, request@2.27.0)
└── insight@0.3.1 (object-assign@0.1.2, async@0.2.10, lodash.debounce@2.4.1, configstore@0.2.3, request@2.27.0)
C:\Users\Lenovo>bower -v
1.3.3
C:\Users\Lenovo>bower help
[?] May bower anonymously report usage statistics to improve the tool over time?
[?] May bower anonymously report usage statistics to improve the tool over time?
Yes
Usage:
bower <command> [<args>] [<options>]
Commands:
cache Manage bower cache
help Display help information about Bower
home Opens a package homepage into your favorite browser
info Info of a particular package
init Interactively create a bower.json file
install Install a package locally
link Symlink a package folder
list List local packages
lookup Look up a package URL by name
prune Removes local extraneous packages
register Register a package
search Search for a package by name
update Update a local package
uninstall Remove a local package
version Bump a package version
Options:
-f, --force Makes various commands more forceful
-j, --json Output consumable JSON
-l, --log-level What level of logs to report
-o, --offline Do not hit the network
-q, --quiet Only output important information
-s, --silent Do not output anything, besides errors
-V, --verbose Makes output more verbose
--allow-root Allows running commands as root
See 'bower help <command>' for more information on a specific command.
D:\bower-demo>## but in my network , git:// is blocked , so we let git use https:// instead of git://
D:\bower-demo>git config --global url."https://".insteadOf git://
D:\bower-demo>git config --list
core.symlinks=false
core.autocrlf=true
color.diff=auto
color.status=auto
color.branch=auto
color.interactive=true
pack.packsizelimit=2g
help.format=html
http.sslcainfo=/bin/curl-ca-bundle.crt
sendemail.smtpserver=/bin/msmtp.exe
diff.astextplain.textconv=astextplain
rebase.autosquash=true
user.name=macrotea
user.email=macrotea@qq.com
alias.ci=commit
alias.co=checkout
alias.st=status
alias.br=branch
alias.throw=reset --hard HEAD
alias.throwh=reset --hard HEAD^
credential.helper=store
url.https://.insteadof=git://
D:\bower-demo>type C:\Users\Lenovo\.gitconfig
[user]
name = macrotea
email = macrotea@qq.com
[alias]
ci = commit
co = checkout
st = status
br = branch
throw = reset --hard HEAD
throwh = reset --hard HEAD^
[credential]
helper = store
[url "https://"]
insteadOf = git://
D:\bower-demo>dir
D:\bower-demo 的目录
2014/04/25 22:52 <DIR> .
2014/04/25 22:52 <DIR> ..
0 个文件 0 字节
2 个目录 35,609,079,808 可用字节
D:\bower-demo>cat > .bowerrc
{
"directory": "components"
}
D:\bower-demo>type .bowerrc
{
"directory": "components"
}
D:\bower-demo>bower install jquery
bower not-cached git://github.com/jquery/jquery.git#*
bower resolve git://github.com/jquery/jquery.git#*
bower extract jquery#* archive.tar.gz
bower resolved git://github.com/jquery/jquery.git#2.1.0
bower install jquery#2.1.0
jquery#2.1.0 components\jquery
D:\bower-demo>## this fetch process do not cache the jquery#2.1.0,now let download jquery#2.1.0 again but cache it
D:\bower-demo>rmdir /s/q components\
D:\bower-demo>dir
2014/04/26 08:39 <DIR> .
2014/04/26 08:39 <DIR> ..
2014/04/26 08:35 33 .bowerrc
D:\bower-demo>bower install jquery#2.1.0 -offline
bower cached git://github.com/jquery/jquery.git#2.1.0
bower install jquery#2.1.0
jquery#2.1.0 components\jquery
D:\bower-demo>## watch the cache of bower
D:\bower-demo>bower cache
Usage:
bower cache <command> [<args>] [<options>]
Commands:
clean Clean cached packages
list List cached packages
D:\bower-demo>bower cache list
jquery=git://github.com/jquery/jquery.git#2.1.0
D:\bower-demo>cd C:\Users\Lenovo\AppData\Roaming\bower\cache\packages\fe2fe255e91d251051d543998aa8327a
C:\Users\Lenovo\AppData\Roaming\bower\cache\packages\fe2fe255e91d251051d543998aa8327a>dir
2014/04/26 08:37 <DIR> .
2014/04/26 08:37 <DIR> ..
2014/04/26 08:37 <DIR> 2.1.0
C:\Users\Lenovo\AppData\Roaming\bower\cache\packages\fe2fe255e91d251051d543998aa8327a>cd 2.1.0\
C:\Users\Lenovo\AppData\Roaming\bower\cache\packages\fe2fe255e91d251051d543998aa8327a\2.1.0>ls
MIT-LICENSE.txt bower.json dist src
C:\Users\Lenovo\AppData\Roaming\bower\cache\packages\fe2fe255e91d251051d543998aa8327a\2.1.0>cd src\
C:\Users\Lenovo\AppData\Roaming\bower\cache\packages\fe2fe255e91d251051d543998aa8327a\2.1.0\src>dir
2014/04/26 08:37 <DIR> .
2014/04/26 08:37 <DIR> ..
2014/04/26 08:37 <DIR> ajax
2014/04/26 08:37 21,719 ajax.js
2014/04/26 08:37 <DIR> attributes
2014/04/26 08:37 200 attributes.js
2014/04/26 08:37 5,506 callbacks.js
2014/04/26 08:37 <DIR> core
2014/04/26 08:37 11,757 core.js
2014/04/26 08:37 <DIR> css
2014/04/26 08:37 12,883 css.js
2014/04/26 08:37 <DIR> data
2014/04/26 08:37 4,817 data.js
2014/04/26 08:37 4,414 deferred.js
2014/04/26 08:37 223 deprecated.js
2014/04/26 08:37 1,776 dimensions.js
2014/04/26 08:37 <DIR> effects
2014/04/26 08:37 16,602 effects.js
2014/04/26 08:37 <DIR> event
2014/04/26 08:37 24,299 event.js
2014/04/26 08:37 <DIR> exports
2014/04/26 08:37 1,405 intro.js
2014/04/26 08:37 557 jquery.js
2014/04/26 08:37 <DIR> manipulation
2014/04/26 08:37 15,110 manipulation.js
2014/04/26 08:37 5,481 offset.js
2014/04/26 08:37 5 outro.js
2014/04/26 08:37 <DIR> queue
2014/04/26 08:37 3,090 queue.js
2014/04/26 08:37 4,413 selector-native.js
2014/04/26 08:37 294 selector-sizzle.js
2014/04/26 08:37 33 selector.js
2014/04/26 08:37 3,214 serialize.js
2014/04/26 08:37 <DIR> sizzle
2014/04/26 08:37 <DIR> traversing
2014/04/26 08:37 4,559 traversing.js
2014/04/26 08:37 <DIR> var
2014/04/26 08:37 1,468 wrap.js
C:\Users\Lenovo\AppData\Roaming\bower\cache\packages\fe2fe255e91d251051d543998aa8327a\2.1.0\src>
## yeah it is the jquery#2.1 cache,it is stored on your dist ,when u bower install jquery#2.1 will so quick because not download it
C:\Users\Lenovo\AppData\Roaming\bower\cache\packages\fe2fe255e91d251051d543998aa8327a\2.1.0\src>
## now we clean the cache
d:\bower-demo>cls
d:\bower-demo>bower cache clean
bower deleted
Cached package jquery: C:\Users\Lenovo\AppData\Roaming\bower\cache\packages\fe2fe255e91d251051d543998aa8327a\2.1.0
d:\bower-demo>cd C:\Users\Lenovo\AppData\Roaming\bower\cache\packages
C:\Users\Lenovo\AppData\Roaming\bower\cache\packages>dir
2014/04/26 08:46 <DIR> .
2014/04/26 08:46 <DIR> ..
C:\Users\Lenovo\AppData\Roaming\bower\cache\packages>## it is empty now
C:\Users\Lenovo\AppData\Roaming\bower\cache\packages>cd d:\bower-demo\
d:\bower-demo>## let us learn how to uninsall your installed package eg: jquery#2.1
d:\bower-demo>bower list
....
bower-demo d:\bower-demo
└── jquery#2.1.0 extraneous (latest is 2.1.1-rc2)
d:\bower-demo>bower install underscore
...
d:\bower-demo>bower list
bower-demo d:\bower-demo
├── jquery#2.1.0 extraneous (latest is 2.1.1-rc2)
└── underscore#1.6.0 extraneous
d:\bower-demo>bower uninstall underscore#1.6.0
d:\bower-demo>bower list
...
bower-demo d:\bower-demo
└── jquery#2.1.0 extraneous (latest is 2.1.1-rc2)
d:\bower-demo>## finish , make by macrotea@qq.com
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment