IT:AD:Bower:HowTo:Create and manage a bower.json file
Summary
Your app has dependencies.
You can record those dependencies as a bower.json
file that you source control and/or share with others.
Process
Let's say you've create a project, and used bower to download the packages you've used.
It's time to start managing the packages you've created.
bower init
And answer the questions it shows:
c:\tmp\bower.demo>bower init ? name: (bower.demo) foo ? name: foo ? version: 0.0.0 ? description: A footurist library ? main file: ? what types of modules does this package expose?: amd ? keywords: foo bar ? authors: Sky <skysigal@xact-solutions.com> ? license: MIT ? homepage: skysigal.com ? set currently installed components as dependencies?: Yes ? add commonly ignored files to ignore list?: Yes ? would you like to mark this package as private which prevents it from being accidentally published to the registry?: Yes
and it will generate a bower.json
file:
c:\tmp\bower.demo>dir Directory of c:\tmp\bower.demo 26/10/2014 08:55 p.m. 461 bower.json 26/10/2014 05:31 p.m. <DIR> bower_components c:\tmp\bower.demo>
The contents of the bower.json
file will be something like the following:
{ name: 'foo', version: '0.0.0', authors: [ 'Foo Smith <foo@xact-solutions.com>' ], description: 'A footurist library', moduleType: [ 'amd' ], keywords: [ 'foo', 'bar' ], license: 'MIT', homepage: 'http://foo.com', private: true, ignore: [ '**/.*', 'node_modules', 'bower_components', 'test', 'tests' ], dependencies: { angular: '~1.3.0', durandal: '~2.1.0' } }
When ever you want to update the file with a new package, or update an existing one, add the --save
flag to the operation:
bower update angular --save