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.
$ [sudo] npm install cli-js -g
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
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 = require'cli-js';// set up config variables (defaults shown below)cli_jsconfigurl = '';cli_jsconfigcache_path = '/tmp/cdnjs-cache.json';cli_jsconfigdays_to_cache_expire = 2;cli_jsconfigdownload_path = processcwd;// read all packages from cdnjs, returns array of objectscli_jscommandslistconsole.logpkg;;// update cache regardless of cache expirecli_jscacherefreshconsole.log'done';;// fuzzy search, returns array of resultscli_jscommandssearch'jquery'console.logresults;;// find one specific package by name, returns an objectcli_jscommandsfind'jquery'console.logresult;;// get the cdn hosted url for a specific packagecli_jscommandsget_url'jquery'console.logurl;;// download the specified package to the specified pathcli_jscommandsdownload'jquery' './components'console.log'installed ' + packagename;;// or skip the second parameter and it will default to the download pathcli_jscommandsdownload'jquery'console.log'installed ' + packagename;;
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
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 😄
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.