bower - a package manager for the web

76
BOWER - A PACKAGE MANAGER FOR THE WEB Larry Nung

Upload: larry-nung

Post on 24-Jan-2017

518 views

Category:

Technology


1 download

TRANSCRIPT

Page 1: Bower - A package manager for the web

BOWER - A PACKAGE MANAGER FOR THE WEBLarry Nung

Page 2: Bower - A package manager for the web

AGENDAIntroductionInstallBower Commandbower.json.bowerrcLabReferenceQ & AAppendix

2

Page 3: Bower - A package manager for the web

INTRODUCTION

Page 4: Bower - A package manager for the web

INTRODUCTION

Page 5: Bower - A package manager for the web

INSTALL

Page 6: Bower - A package manager for the web

REQUIREMENT Node.js Git

Page 7: Bower - A package manager for the web

INSTALL Linux

Ubuntu sudo apt-get purge nodejs npm sudo apt-get update sudo apt-get install -y python-software-properties

python g++ make sudo add-apt-repository ppa:chris-lea/node.js sudo apt-get update sudo apt-get install -y nodejs sudo apt-get install -y git sudo npm install -g bower

Page 8: Bower - A package manager for the web

INSTALL Windows

npm install -g bower

Page 9: Bower - A package manager for the web

BOWER COMMAND

Page 10: Bower - A package manager for the web

BOWER HELP Function

Display help information about Bower

Usage bower help bower help <command>

Bower help install

Page 11: Bower - A package manager for the web

BOWER HELP

Page 12: Bower - A package manager for the web

BOWER INIT Function

Interactively create a bower.json file

Usage bower init

Page 13: Bower - A package manager for the web

BOWER INIT

Page 14: Bower - A package manager for the web

BOWER SEARCH Function

Search for a package by name

Usage bower search <package>

bower search jquery

Page 15: Bower - A package manager for the web

BOWER SEARCH

Page 16: Bower - A package manager for the web

BOWER INSTALL Function

Install a package locally

Usage bower install bower install <package>

bower install bootstrap spine jquery bower install <package>#<version>

bower install jquery-ui#1.10.4 bower install https://github.com/jquery/jquery.git#2.0.3

bower install <package> --save

Page 17: Bower - A package manager for the web

BOWER INSTALL

Page 18: Bower - A package manager for the web

BOWER UNINSTALL Function

Remove a local package

Usage bower uninstall <package>

bower uninstall jquery

Page 19: Bower - A package manager for the web

BOWER UNINSTALL

Page 20: Bower - A package manager for the web

BOWER LIST Function

List local packages - and possible updates

Usage bower list bower list –r bower list -p

Page 21: Bower - A package manager for the web

BOWER LIST

Page 22: Bower - A package manager for the web

BOWER LIST

Page 23: Bower - A package manager for the web

BOWER UPDATE Function

Update a local package

Usage bower update <package>

bower update jquery

Page 24: Bower - A package manager for the web

BOWER UPDATE

Page 25: Bower - A package manager for the web

BOWER CACHE Function

Manage bower cache

SubCommand list clean

Page 26: Bower - A package manager for the web

BOWER CACHE LIST Function

List cached packages

Usage bower cache list

Page 27: Bower - A package manager for the web

BOWER CACHE LIST

Page 28: Bower - A package manager for the web

BOWER CACHE CLEAN Function

Clean cached packages

Usage bower cache clean

Page 29: Bower - A package manager for the web

BOWER CACHE CLEAN

Page 30: Bower - A package manager for the web

BOWER INFO Function

Info of a particular package

Usage bower info <package>

bower info bootstrap bower info <package>#<version>

bower info jquery#1.0.1

Page 31: Bower - A package manager for the web

BOWER INFO

Page 32: Bower - A package manager for the web

BOWER INFO

Page 33: Bower - A package manager for the web

BOWER LOOKUP Function

Look up a package URL by name

Usage bower lookup <name>

bower lookup jquery

Page 34: Bower - A package manager for the web

BOWER LOOKUP

Page 35: Bower - A package manager for the web

BOWER PRUNE Function

Removes local extraneous packages

Usage bower prune

Page 36: Bower - A package manager for the web

BOWER PRUNE

Page 37: Bower - A package manager for the web

BOWER HOME Function

Opens a package homepage into your favorite browser

Usage bower home <package>

bower home jquery

Page 38: Bower - A package manager for the web

BOWER VERSION Function

Bump a package version

Usage bower version <version>

bower version v1.0.0 bower patch bower minor bower major

Page 39: Bower - A package manager for the web

BOWER VERSION

Page 40: Bower - A package manager for the web

BOWER VERSION

Page 41: Bower - A package manager for the web

BOWER VERSION

Page 42: Bower - A package manager for the web

BOWER VERSION

Page 43: Bower - A package manager for the web

BOWER REGISTER Function

Register a package

Usage bower register <name> <endpoint>

bower register jquery_2.1.4 https://github.com/jquery/jquery.git#2.1.4

Page 44: Bower - A package manager for the web

BOWER LOGIN Function

Authenticate with GitHub and store credentials

Usage bower login

Page 45: Bower - A package manager for the web

BOWER UNREGISTER Function

Remove a package from the registry

Usage bower unregister <package>

bower unregister jquery_2.1.4

Page 46: Bower - A package manager for the web

BOWER LINK Function

Symlink a package folder

Page 47: Bower - A package manager for the web

BOWER.JSON

Page 48: Bower - A package manager for the web

BOWER.JSON{ "name": "blue-leaf", "description": "Physics-like animations for pretty particles", "main": [ "js/motion.js", "sass/motion.scss" ], "dependencies": { "get-size": "~1.2.2", "eventEmitter": "~4.2.11" }, "devDependencies": { "qunit": "~1.16.0" }, "moduleType": [ "amd", "globals", "node" ], "keywords": [ "motion", "physics", "particles" ], "authors": [ "Betty Beta " ], "license": "MIT", "ignore": [ "**/.*", "node_modules", "bower_components", "test", "tests" ], "private": true }

Page 49: Bower - A package manager for the web

BOWER.JSONName Type Require

dDescription

name String true The name of the package as stored in the registry

description String false The description of the package as stored in the registry

version String false Use git or svn tags instead. This field is ignored by Bower

main StringString[]

false The entry-point files necessary to use your package.

moduleType StringString[]

false The type of module defined in the main JavaScript file

Page 50: Bower - A package manager for the web

BOWER.JSONName Type Required Descriptionlicense String

String[]false SPDX license identifier or

path/url to a licenseignore String[] false A list of files for Bower to

ignore when installing your package

keywords String[] false Used for search by keyword

authors String[]Object[]

false A list of people that authored the contents of the package

homepage String false URL to learn more about the package

repository Object false The repository in which the source code can be found

Page 51: Bower - A package manager for the web

BOWER.JSONName Type Required Descriptiondependencies

Object false Dependencies are specified with a simple hash of package name to a semver compatible identifier or URL

devDependencies

Object false Dependencies that are only needed for development of the package

resolutions Object false Dependency versions to automatically resolve with if conflicts occur between packages

private Boolean false If set to true, Bower will refuse to publish it.

Page 52: Bower - A package manager for the web

.BOWERRC

Page 53: Bower - A package manager for the web

.BOWERRC Location

~/bowerrc .bowerrc

Page 54: Bower - A package manager for the web

.BOWERRC{ "analytics": true, "cwd": "~/.my-project", "directory": "bower_components", "registry": "https://bower.herokuapp.com", "shorthand-resolver": "git://github.com/{{owner}}/{{package}}.git", "proxy": "http://proxy.local", "https-proxy": "https://proxy.local", "ca": "/var/certificate.pem", "color": true, "timeout": 60000, "storage": { "packages" : "~/.bower/packages", "registry" : "~/.bower/registry", "links" : "~/.bower/links" }, "interactive": true, "resolvers": [ "mercurial-bower-resolver" ], "shallowCloneHosts": [ "myGitHost.example.com" ] }

Page 55: Bower - A package manager for the web

.BOWERRCName Type Descriptionanalytics Boolean Does Bower can collect

anonymous usage statistics?cwd String Current working directorydirectory String The path in which installed

components should be savedregistry Object 

StringThe registry config

shorthand-resolver

String Define a custom template for shorthand package names

proxy String The proxy to use for http requests

https-proxy String The proxy to use for https requests

user-agent String Sets the User-Agent for each request made

Page 56: Bower - A package manager for the web

.BOWERRCName Type Descriptiontimeout Number The timeout to be used when

making requests in milliseconds, defaults to 60000 ms.

strict-ssl Boolean Whether or not to do SSL key validation when making requests via https

ca ObjectString

The CA certificates to be used

color Boolean Enable or disable use of colors in the CLI output. Defaults to true.

storage Object Where to store persistent data, such as cache, needed by bower.

tmp String Where to store temporary files and folders.

Page 57: Bower - A package manager for the web

.BOWERRCName Type Descriptioninteractive Boolean Makes bower interactive,

prompting whenever necessary. Defaults to null which means auto.

resolvers Array List of Pluggable Resolvers to use for locating and fetching packages

shallowCloneHosts

Array Bower's default behavior is to not use shallow cloning

Page 58: Bower - A package manager for the web

LAB

Page 59: Bower - A package manager for the web

LAB1 Search jQuery package Look up jQuery package's info List bower's cache Look up jQuery package's info which version

is 2.1.4 Clear bower's cache List bower's cache Install jQuery with version 2.1.4 List package List bower's cache

Page 60: Bower - A package manager for the web

LAB2 Install Bootstrap List package Uninstall jQuery List package Update package List package

Page 61: Bower - A package manager for the web

LAB3 Init bower.json Install d3 with version 1.0.0 and let it save to

bower.json List package Open bower.json and change d3's version to

3.5.12 Update package List package

Page 62: Bower - A package manager for the web

LAB4 Init bower.json Open bower.json and add jQueryUI package

with version 1.11.4 Open bower.json and add AngularJS package

with version 1.4.8 Install package from bower.json List package

Page 63: Bower - A package manager for the web

REFERENCE63

Page 64: Bower - A package manager for the web

REFERENCE Bower

http://bower.io/

Bower 管理網站套件的好工具 | 小惡魔 - 電腦技術 - 工作筆記 - AppleBOY https://blog.wu-boy.com/2013/01/bower-is-a-pack

age-manager-for-the-web/

Bower 前端套件管理工具 « Eden Tsai http://edentsai231.logdown.com/posts/198741-b

ower-front-end-kit-management-tool64

Page 65: Bower - A package manager for the web

REFERENCE The Will Will Web | 如何在強制使用代理伺服器的環境下設定 git, npm, bower, gem, ionic 工具

http://blog.miniasp.com/post/2015/09/03/proxy-settings-for-git-npm-bower-gem-ionic.aspx

Visual-Bower Studio: 網頁程式開發的現代化工具 https://msdn.microsoft.com/zh-tw/magazine/mt5

73714.aspx

Getting Started with Bower - Treehouse Blog http://blog.teamtreehouse.com/getting-started-b

ower 65

Page 66: Bower - A package manager for the web

REFERENCE Bower 手冊 - iFantasticMe - 博客園

http://www.cnblogs.com/ifantastic/p/4651451.html

[Web]Bower 前端套件管理工具 | 佛祖球球 http://blog.johnsonlu.org/bower-front-end-kit-man

agement-tool/

[Javascript] bower javascript 套件管理工具 初探 - Mr. 一顆痣 a.k.a. bigd - 工程屍的日子 http://iambigd.blogspot.tw/2014/06/javascript-bo

wer-javascript.html 66

Page 67: Bower - A package manager for the web

REFERENCE spec/json.md at master · bower/spec

https://github.com/bower/spec/blob/master/json.md

spec/config.md at master · bower/spec https://github.com/bower/spec/blob/master/confi

g.md

Installing Node.js properly on Ubuntu · Steven Lu http://stevenlu.com/posts/2014/04/05/installing-n

odejs-on-ubuntu/ 67

Page 69: Bower - A package manager for the web

Q&A69

Page 70: Bower - A package manager for the web

QUESTION & ANSWER

70

Page 71: Bower - A package manager for the web

APPENDIX

Page 72: Bower - A package manager for the web

NPM PROXY SETTING npm config set proxy http://127.0.0.1:8080 npm config set https-proxy

https://127.0.0.1:8080

Page 73: Bower - A package manager for the web

NPM PROXY SETTING

Page 74: Bower - A package manager for the web

BOWER PROXY SETTING{ "proxy": "http://127.0.0.1:8080", "https-proxy": "https://127.0.0.1:8080", "strict-ssl": false }

Page 75: Bower - A package manager for the web

BOWER PROXY SETTING

Page 76: Bower - A package manager for the web

BOWER VAGRANT BOXVagrant.configure(2) do |config| config.vm.box = "precise64" config.vm.box_url = "http://files.vagrantup.com/precise64.box" config.vm.provision "file", source: ".bowerrc", destination: "bowerrc" config.vm.provision "file", source: ".npmrc", destination: ".npmrc" config.vm.provision "shell", inline: $script end

$script = <<SCRIPT sudo apt-get purge nodejs npm sudo apt-get update sudo apt-get install -y python-software-properties python g++ make sudo add-apt-repository ppa:chris-lea/node.js sudo apt-get update sudo apt-get install -y nodejs sudo apt-get install -y git sudo npm install -g bower SCRIPT