In this guide you’ll see how to create, publish and use Amber libraries.
amber initin 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 initto make the directory a git repository.
.gitignorebecause a library has no need to commit them in your git repo.
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.yfor pre-production stages and
x>=1when 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.2in 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]
bower register amber-awesome-trick firstname.lastname@example.org/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-threejsand so on.
bower.jsonfile 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:
devel.jsonso your app knows what to load.
Here are the commands:
bower install lib-name --save.
deploy.jsto setup the list of packages from the library that your app needs, for example:
amber-d3/AmberD3-Coreand any other package that your app might be using from that library.
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.