cli-js
Small, fast, and well-tested command line interface to cdnjs with fuzzy package search and a public api for easy integration into other node apps.
Installation
$ [sudo] npm install cli-js -g
Usage
cdnjs list
- lists all packages
cdnjs search [name]
- search packages for a keyword
cdnjs info [name]
- more information on a specific package
cdnjs copy [name]
- copies the cdnjs link to your clipboard
cdnjs update
- updates the cache
cdnjs install [name] [path]
- downloads the specified package to an optional path
Public API
I've made sure to keep a very clean separation in place between the utilities that process data and those that print results. Because of this, it's easy for other node app authors to integrate cli-js into whatever app it may be needed in and customize the output how they like. The public api gives direct access to the functions below:
var cli_js = ; // set up config variables (defaults shown below)cli_jsconfigurl = 'http://cdnjs.com/packages.json';cli_jsconfigcache_path = '/tmp/cdnjs-cache.json';cli_jsconfigdays_to_cache_expire = 2;cli_jsconfigdownload_path = process; // read all packages from cdnjs, returns array of objectscli_jscommands; // update cache regardless of cache expirecli_jscache; // fuzzy search, returns array of resultscli_jscommands; // find one specific package by name, returns an objectcli_jscommands; // get the cdn hosted url for a specific packagecli_jscommands; // download the specified package to the specified pathcli_jscommands; // or skip the second parameter and it will default to the download pathcli_jscommands;
It should be noted that the cacheing is handled internally, so no need to ever worry about it. If you do want to update the cache on demand, you can use the cache.refresh()
function.
There are a few more functions that are not documented here that I feel like it's very unlikely will be used, but if you want to check them out, it's a pretty small and clearly structured project and it should be no problem finding what you need in the source 😄
License
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.