Does the Javascript community have a dependency retrieval (like maven or gem)?
Java has maven or ivy to retrieve dependent jars from various public repositories.
Ruby has even better dependency retrieval tools: gem and bundle.
Does the Javascript community have any equivalent tool? I have found a number of tools to manage dynamically loading dependencies into the browser. I am NOT looking for those tools.
Specifically, I am looking for a tool that a new developer uses to retrieve the javascript files they need. The developer runs this tool and:
- It looks at the project dependency description file
- Discovers that the project needs jquery-ui-1.8.7, tiny_mce-3.4.3.2 and prettyLoader-1.0.1
- Retrieves jquery-ui-1.8.7.min.js, prettyLoader-1.0.1.js, tiny_mce-3.4.3.2 from the web
- Installs the .js and the .css into a local repository
- Realizes that jquery-ui relies on j开发者_JAVA百科query-1.6.1 and downloads/installs jquery
- Determines that the tiny_mce needs the jquery plugin, and downloads and installs it.
After all this, the developer has a local copy of all the js/css files needed.
If a new tiny_mce or jquery comes out, the project file is updated and the developers just return the tool and they get all the new files.
If no version of a js library is specified then the latest release version is retrieved.
What I have just described is what maven/ivy/gem does in the java/ruby space.
Obviously, I could rig something up for my own needs with maven but does the javascript community have anything already in place?
Update:
npm was mentioned by Raynos. Npm is centered around node.js ( which is o.k. ). However, there are limited published libraries in the public repository and limited metadata ( version, author, project url is missing from easy discovery ).
However, it looks like npm is the solution today. Unfortunately, it will not quite be enough for us, but such is life.
I am actually pretty surprised that jquery or google-closure does not have a project management tool. (Tell me if I am wrong!)
Update: Now meteor has come along with meteorite to access and update the atmosphere libraries. Much awesomeness.
it looks like twitter is offering one answer :
cf. https://github.com/twitter/bower#readme
Bower (using Node and npm) is a package manager for the web. Bower lets you easily install assets such as images, CSS and JavaScript, and manages dependencies for you.
Bower is a generic tool which will resolve dependencies and lock packages down to a version. It runs over Git, and is package-agnostic. A package may contain JavaScript, CSS, images, etc., and doesn't rely on any particular transport (AMD, CommonJS, etc.).
Bower then makes available a simple programmatic API which exposes the package dependency model, so that existing build tools (like Sprockets, LoadBuilder, curls.js, Ender, etc.) can consume it and build files accordingly.
This depends on your server-side stack. Most dependency / package managers for server-side stacks also deal with javascript based dependencies.
npm
is the node.js dependency manager. It's very popular.
It's based on the CommonJS package.json format.
There are movements to port this to the client like:
- EnderJS
You can't really do this with JavaScript alone as it has no IO in it. Even ender's command line tool relies on npm being installed. You should just use whatever tool comes with your server-side stack
The Maven Javascript Tools project automatically folds in the Maven Javascript Import plugin. The latter plugin brings the world of maven dependency management to JavaScript.
http://mojo.codehaus.org/javascript-maven-tools/
A new project that combine npm and maven is : https://blogs.mulesoft.com/dev/mule-dev/introducing-the-npm-maven-plugin/
a very clean integration :
<plugin>
<groupId>org.mule.tools.javascript</groupId>
<artifactId>npm-maven-plugin</artifactId>
<version>1.0</version>
<executions>
<execution>
<phase>generate-sources</phase>
<goals>
<goal>fetch-modules</goal>
</goals>
<configuration>
<packages>
<package>colors:0.5.1</package>
<package>jshint:0.8.1</package>
</packages>
</configuration>
</execution>
</executions>
</plugin>
精彩评论