How to create an own bower-asset? - bower

I need to create my own bower-asset with my fork of Gentelella Theme (ColorlibHQ/gentelella), because I need a light weight vendor version.
I've done these following code on terminal:
bower init
and than I remove some package and i have digit
bower prune
to purify from libraries not used.
Than I use
bower register myname-gentelella https://github.com/USERNAME/PACKAGENAME.git
But I don't see it to https://bower.io/search/, and it seems don't exist if I call from another application.

Related

How do I install a project built with bazel?

I am working on a project that is transitioning from CMake to Bazel. One critical feature that we are apparently losing in the bargain is the ability to install the project, so that it can be used by other (not necessarily Bazel) projects.
AFAICT, there is currently no built in support for installing a project?!
I need to create a portable (must work on at least Linux and MacOS) way to install the project. Specifically:
I need to be able to specify libraries, headers, executables, and other files (e.g. LICENSE) that need to be installed.
The user needs to be able to specify an absolute prefix where things should be installed.
I really, really should be able to execute the "install" step more than once, giving different prefixes each time, without Bazel getting confused (i.e. it must not try to "remember" what files it already installed, or if it does, must understand when the prefix is different from last time).
Libraries should be installed to the right place (e.g. lib64), or at least it should be possible for the user to specify the correct libdir.
The install step MUST NOT touch the time stamp on any file from a previous install that has not changed. (Ideally, Bazel itself would handle this; using the install command is tricky and has potential portability issues. Note platform requirements, above.)
What is the best way to go about doing this?
Unless you want to do specific package (e.g. deb or rpm), you probably want to create an executable rule that does the install for you.
You can create a rule that would create an executable (e.g. a shell script) that does the install for you (e.g. do checksums to check if there are change to the installed file and does the actual copy of the files if they have changed). You would have to use the extension language to do, that would look similar to what the docker rules does to load an image with the incremental loader
Addition: I forgot to say that the install itself would be run by using the run command: bazel run install if the rule is named install in the top level BUILD file.

How to specify a particular provider of a bower dependency

I want to use angular-cookies from bower but when I do:
bower install angular-cookies it sometimes fetches the one published by the angular team and sometimes some other old incompatible one from an independent author (angularify)
If I do manage to get the official one, then whenever I run bower install ... again, for some other reason, bower will switch the version of angular-cookies that I already have, breaking my application.
How can I do something like:
bower install --force https://github.com/angular/bower-angular-cookies
As the doc specifies - you can add something like:
"dependencies": {
"angular-cookies": "git://github.com/angular/bower-angular-cookies"
}
Which will cause bower to get the dependency from the git repo you want. You can also use git://github.com/angular/bower-angular-cookies#branch_name or git://github.com/angular/bower-angular-cookies#tag_name to specify a specific branch or tag.
See this question as well.

How to search for Bower packages that depend on another package?

I would like to do a search for bower packages that depend on another bower package. For example, I might want to search for bower packages related to "json directive" that depend on the angular package. How can this be done if at all?
If you only need to search in locally installed packages
go to your local bower_components (the place you install bower packages)
and run:
grep -Hnri '"<package name>":' ./**/bower.json
for example:
➜ bower_components# grep -Hnri '"font-roboto":' ./**/bower.json
./paper-styles/bower.json:25: "font-roboto": "PolymerElements/font-roboto#^1.0.1",
If you would like to do it for all bower packages in http://bower.herokuapp.com/packages
then you need to write code that will
download bower.json
from repository of every component and all versions of this component
and search it for package that you are looking for
(it will take a lot of time)
you could also try something faster and play with github search:
https://github.com/search?utf8=%E2%9C%93&q=font-roboto+language%3AJSON&type=Code&ref=searchresults

Is Bower only about automatically installing dependencies?

Does Bower actually do anything else than resolve dependecies? I'm trying hard to understand how it is meant to be used, but I guess I'm missing some points...
Say, I have Bower package A, which depends on Bower package B. In my application I'm just interested in package A, since that's what I'm going to use. Of course, that means that somehow both packages must be loaded into the Browser, so that package A can work.
Using Bower I can just do bower install a and will then find both packages A & B in my bower_components. So far, awesome.
But now? Am I forced to find out myself (manually) which files from A and B need to be loaded in my HTML page? I don't think that the full bower_components directly shall be accessible via web, so I have to configure myself manually my Grunt (or whatever) build-file to copy the relevant files?
What am I missing here? If what I wrote above is true, what's the point using Bower when I still need to be aware of all implicit dependencies?
Bower manages dependencies, and it will add the correct files into your HTML if you use it with the --save (or -S) flag. You would need appPath set in your bower.json if your index.html isn't in the same directory.
$ bower help install
Usage:
bower install [<options>]
bower install <endpoint> [<endpoint> ..] [<options>]
Options:
-F, --force-latest Force latest version on conflict
-h, --help Show this help message
-p, --production Do not install project devDependencies
-S, --save Save installed packages into the project's bower.json dependencies
-D, --save-dev Save installed packages into the project's bower.json devDependencies
Additionally all global options listed in 'bower help' are available
Description:
Installs the project dependencies or a specific set of endpoints.
Endpoints can have multiple forms:
- <source>
- <source>#<target>
- <name>=<source>#<target>
Where:
- <source> is a package URL, physical location or registry name
- <target> is a valid range, commit, branch, etc.
- <name> is the name it should have locally.
```
You're actually not missing anything. Bower doesn't deal with loading your dependencies, just installing them. Loading them is something you have to do on your own. Also, there are a lot various ways in which people load there dependencies; the most common probably being Require.JS, Browserify (have too few credits to post links) and plain script includes in an index.html page. So, basically you have a few options here
You can just deal with load registrations manually. This would mean adding <script src="..."></script> tags to your index.html page, or adding registrations for dependencies and similar to your app.js if you're using Require.JS. Note that this step would mean that you'd manually have to look at each dependency, read documentation or bower.json files to figure out transitive dependencies and file paths.
If you're using plain script includes, you can use Wiredep to have that done automatically for you through Wiredep's inspection of the bower.json files of dependencies.
If you're using RequireJS (or similar) you can look at Yeoman's grunt-require-js to do this automatically for you.
Note that both 2 and 3 relies on library authors provide the correct output files. You might e.g. have to declare overrides or explicitly declare if you want minified or non-minified versions.
As for publicly allowing access to "bower_components", I find that this is the most common approach. What things there would you like to prevent access to?
I'm a recent bower user myself. And as far as I know the short answer is: YES, bower is meant to download dependencies, however, apart from being able to configure the bower_components directory to anything you like, the idea is that bower installed components won't be edited by you at all, if you want to include them manually, you type
bower list --paths
and this will list all the files you need to include from the dependencies (in relative urls).
You can also use bower-installer (npm install -g bower-installer) which allows you to copy the files you need to any path you like. With a fine grained controll, or choose the minified versions, for example.
Here's an example output.
C:\Users\german\test>bower install bootstrap
bower bootstrap#* not-cached git://github.com/twbs/bootstrap.git#*
bower bootstrap#* resolve git://github.com/twbs/bootstrap.git#*
bower bootstrap#* download https://github.com/twbs/bootstrap/archive/v3.3.4.tar.gz
bower bootstrap#* extract archive.tar.gz
bower bootstrap#* resolved git://github.com/twbs/bootstrap.git#3.3.4
bower jquery#>= 1.9.1 not-cached git://github.com/jquery/jquery.git#>= 1.9.1
bower jquery#>= 1.9.1 resolve git://github.com/jquery/jquery.git#>= 1.9.1
bower jquery#>= 1.9.1 download https://github.com/jquery/jquery/archive/2.1.4.tar.gz
bower jquery#>= 1.9.1 extract archive.tar.gz
bower jquery#>= 1.9.1 resolved git://github.com/jquery/jquery.git#2.1.4
bower bootstrap#~3.3.4 install bootstrap#3.3.4
bower jquery#>= 1.9.1 install jquery#2.1.4
bootstrap#3.3.4 bower_components\bootstrap
└── jquery#2.1.4
jquery#2.1.4 bower_components\jquery
C:\Users\german\test>bower list --paths
jquery: 'bower_components/jquery/dist/jquery.js',
bootstrap: [
'bower_components/bootstrap/less/bootstrap.less',
'bower_components/bootstrap/dist/css/bootstrap.css',
'bower_components/bootstrap/dist/js/bootstrap.js',
'bower_components/bootstrap/dist/fonts/glyphicons-halflings-regular.eot',
'bower_components/bootstrap/dist/fonts/glyphicons-halflings-regular.svg',
'bower_components/bootstrap/dist/fonts/glyphicons-halflings-regular.ttf',
'bower_components/bootstrap/dist/fonts/glyphicons-halflings-regular.woff',
'bower_components/bootstrap/dist/fonts/glyphicons-halflings-regular.woff2'
]
after
bower list --paths
bootstrap[] shows all the files I need to include according to bower_components/bootstrap/bower.json
main:[]
part
Hope this helps! cheers.

Installing non-bower-ready library with Bower

I am using Bower (http://bower.io/) to manage my app's third-party libraries and now I want to use a library which doesn't have a registered bower package, namely jquery.cloudinary.js from Cloudinary (http://cloudinary.com).
I would really love to include cloudinary amongst my bower-managed libraries because it really helps cloning my development environment when I need to.
Is it possible to install any library available in the internet with Bower by just editing my bower.json file? If so, how?
I guess I could either ask Cloudinary to create and register a Bower package or do it myself but I am still in doubt whether I should do any of these.
Register it or install with the git url directly: bower install http://website.com/repo.git
From the Bower readme:
Bower offers several ways to install packages:
Using a local or remote package
bower install <package>
Where <package> can be any one of the following:
A name that maps to a package registered with Bower, e.g, jquery. ‡
A remote Git endpoint, e.g., git://github.com/someone/some-package.git. Can be public or private. ‡
A local endpoint, i.e., a folder that's a Git repository. ‡
A shorthand endpoint, e.g., someone/some-package (defaults to GitHub). ‡
A URL to a file, including zip and tar files. Its contents will be extracted.

Resources