Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the recommended manifest JSON format for Bower packages?

Tags:

json

bower

yeoman

Using the $ bower init command, I have created a bower.json for my package and registered it with Bower, no problem.

After looking at the Github homepages for some popular Bower packages, e.g. RequireJS and Modernizr, I've noticed their repo's don't contain a bower.json or a component.json. How is this possible?

I've also noticed that when I download any Bower package, the package contains a .bower.json file (note the dot in the beginning) and that file contains quite a bit more information than what I was asked during $ bower init for my package. For example, below is the .bower.json from Modernizr:

{
    "name": "modernizr",
    "homepage": "https://github.com/Modernizr/Modernizr",
    "version": "2.6.2",
    "_release": "2.6.2",
    "_resolution": {
        "type": "version",
        "tag": "v2.6.2",
        "commit": "ca45d02757b83367d8455d477e3cbc42dfdee035"
    },
    "_source": "git://github.com/Modernizr/Modernizr.git",
    "_target": "~2.6.2",
    "_direct": true
}

When I download my newly created package, it just contains the same info that I originally checked in to git.

Is there a new format for bower.json that I should be using? Or did I simply miss something in the setup process?

like image 428
micjamking Avatar asked Feb 16 '23 10:02

micjamking


2 Answers

Bower doesn't need a bower.json or a component.json to install packages. The manifest file provide some useful info, like dependencies, ignored files, version and etc, but in the end it just downloads Git commits and place them somewhere.
In the case of Modernizr/Require.js, someone just registered their repos and Bower is retrieving a tag.

About the .bower.json file: this is generated by Bower itself after installing a package. It contains some more verbose info about a package, like the commit from which the package was retrieved, for example.

TL;DR: Keep using bower init, it'll do the right thing for you!

like image 154
gustavohenke Avatar answered Feb 17 '23 23:02

gustavohenke


I am using Yeoman and the following is the content of my bower.json file. I thought it might help you. (I have installed all the latest versions of bower and grunt)

{
  "name": "yowebapp",
  "version": "0.0.0",
  "dependencies": {
    "sass-bootstrap": "~3.0",
    "requirejs": "~2.1.4",
    "modernizr": "~2.6.2",
    "jquery": "~1.9.1",
    "d3":"~3.3.2",
    "angular":"1.0.7"

  },
  "devDependencies": {}
}

and I download my dependencies with bower install.

like image 37
AJ Meyghani Avatar answered Feb 18 '23 00:02

AJ Meyghani