People can visit bower and find JavaScript libraries to solve the most diverse problems and empower their applications with lots of cool things.
Amber Smalltalk allows easy integration of these libraries. But besides using third party JavaScript libraries, your Amber application can use your own Amber libraries.
In this guide you’ll see how to create, publish and use Amber libraries.
amber init
in an empty directory; same as to start a new Amber project.
answer the questions to get your project scaffolded (see tips about naming your library below)git init
to make the directory a git repository.config.js
and the.js
into .gitignore
because a library has no need to commit them in your git repo.amber serve
.git commit -am "I've made this Amber library and this version rocks!"
.When you create a new Amber project, one of the things you need to answer is the name of the project. In this case you will be deciding about the name of your new library. Also, you define the namespace of the library. This namespace is important because it is used by requirejs to locate and properly load the code in your project.
After the library is published, the namespace can not be changed anymore since it would break other people’s code. Therefore, it is e essential to come up with a good name at library creation time. Keep in mind that the namespace you define has to be the same as the one in the “paths” section of the local.amd.json
file in the root of your project.
0.x.y
for pre-production stages and x.y.z
with x>=1
when that library is used in production and cares about backwards compatibility. For more about semantic versioning read here: http://semver.org/.git tag 0.9.2
in your master branch.bower version 0.9.2 -m “Release 0.9.2”
. See here for more details about that.git push origin 0.9.2
.And here comes the best part. Because you did all that with your Amber library, anyone can install it quite easily using one single command thanks to the bower.io package management system.
This is the command to register your library in bower:
bower register [lib-name] [git endpoint]
e.g.:
bower register amber-awesome-trick git@github.com/amberguy/amber-awesome-trick.git
###A couple of tips about publishing in bower
amber-
. For example, if you write a D3 wrapper you can publish it as amber-d3
. If you create code to use three.js, your library will be easier to find if it is named amber-threejs
and so on.bower.json
file has a section named keywords
, for Amber libraries, we suggest that you tag it like this "keywords": [ "Amber","Smalltalk","AnyAdditionalTagYouWant" ]
, when you do that, it gets listed when people search for http://bower.io/search/?q=amber or http://bower.io/search/?q=smalltalk.You have published your library in bower, great! Congratulations! Now, how do you use it in other Amber projects? This is the easy part:
deploy.json
and devel.json
so your app knows what to load.Here are the commands:
bower install lib-name --save
.deploy.js
to setup the list of packages from the library that your app needs, for example: amber-d3/AmberD3-View
and amber-d3/AmberD3-Core
and any other package that your app might be using from that library.grunt devel
.That’s how you do Amber libraries, publish them for reuse and load them into other Amber apps.
The bower repository is extremely popular these days and a source of great libraries for many people building application frontends or html5-based applications.
Additionally, getting your Amber-based software there will make fellow Amber programmers able to do even more powerful things with their software.
Have you made some Amber libraries?
Please announce the libraries you publish on the Amber mailing list so that people know it was added to our growing catalogue of Amber libraries.
And see what others Amber users have published here.