Browse files

First real commit

  • Loading branch information...
1 parent c98fc9a commit abf56a20ce6afabdf8a12d05ed3bc3b6314167e9 @nitidosid nitidosid committed Nov 13, 2013
Showing with 135 additions and 0 deletions.
  1. +12 −0 .npmignore
  2. +94 −0 bin/cordova-plugins
  3. +29 −0 package.json
View
12 .npmignore
@@ -0,0 +1,12 @@
+.*.swp
+._*
+.DS_Store
+.git
+.hg
+.lock-wscript
+.svn
+.wafpickle-*
+CVS
+npm-debug.log
+docs
+*.tgz
View
94 bin/cordova-plugins
@@ -0,0 +1,94 @@
+#!/usr/bin/env node
+
+var path = require("path"),
+ fs = require("fs"),
+ exit = require("exit"),
+ nopt = require("nopt"),
+ clc = require('cli-color'),
+ shell = require("shelljs"),
+ // prompt = require( "prompt" ),
+ bootstrapdir = path.join(path.dirname(fs.realpathSync(__filename)), "../bootstrap"),
+ scriptsdir = path.join(path.dirname(fs.realpathSync(__filename)), "../scripts"),
+ tmp = shell.tempdir(),
+ pluginsfile = tmp + "plugins.json",
+ knownOpts = {
+ "dir" : path
+ },
+ shortHands = {
+ "d" : ["--dir", tmp ]
+ },
+ parsed = nopt(knownOpts, shortHands, process.argv, 2),
+ args = process.argv.splice(2);
+
+function printPluginList(obj, filter) {
+ "use strict";
+
+ var plugin;
+ for (var key in obj) {
+ if (obj.hasOwnProperty(key)) {
+ if (key !== '_updated') {
+ plugin = obj[key];
+ if (!filter || (filter && filter.trim() !== '' &&
+ ((plugin.name.indexOf(filter) !== -1) || (plugin.description && plugin.description.indexOf(filter) !== -1))) ) {
+ shell.echo("Name: " + plugin.name.trim());
+ shell.echo("Description: " + (plugin.description ? plugin.description.trim() : "No description available."));
+ shell.echo("Version: " + plugin["dist-tags"].latest.trim());
+ shell.echo("Last Modified: " + new Date(plugin.time.modified));
+ shell.echo(clc.greenBright("Url: http://registry.cordova.io/" + key + "/-/" + key + "-" + plugin["dist-tags"].latest.trim() + ".tgz \n"));
+ }
+ }
+ }
+ }
+ }
+
+ function retrievePluginList() {
+ shell.exec("curl -s -o " + pluginsfile + " http://registry.cordova.io/-/all 2>&1");
+ var plugins = require(pluginsfile);
+ return plugins;
+ }
+
+ if (args.length === 0) {
+ // "se.sanitarium.cordova.exitapp":{
+ // "name":"se.sanitarium.cordova.exitapp",
+ // "description":"Implements navigator.app.exitApp on WP8",
+ // "dist-tags":{
+ // "latest":"1.0.0"
+ // },
+ // "maintainers":[
+ // {
+ // "name":"gaqzi",
+ // "email":"ba@sanitarium.se"
+ // }
+ // ],
+ // "time":{
+ // "modified":"2013-11-06T07:56:10.217Z"
+ // },
+ // "versions":{
+ // "1.0.0":"latest"
+ // },
+ // "keywords":[
+ // "cordova",
+ // "terminate"
+ // ]
+ // }
+ var list = retrievePluginList();
+ printPluginList(list || {});
+ }
+ else {
+ var directory = parsed.dir,
+ command = directory ? parsed.argv.remain[1] : parsed.argv.remain[0],
+ plugin = directory ? parsed.argv.remain[2] : parsed.argv.remain[1];
+
+ switch (command.toLowerCase()) {
+ case "search":
+ var list = retrievePluginList();
+ printPluginList(list || {}, plugin);
+ break;
+ case "get":
+ directory = directory || tmp;
+ shell.exec("curl -s -o " + directory + plugin.substring(plugin.lastIndexOf("/")) + " " + plugin + " 2>&1");
+ shell.echo( directory + plugin.substring(plugin.lastIndexOf("/")) );
+ break;
+ default:
+ }
+ }
View
29 package.json
@@ -0,0 +1,29 @@
+{
+ "name": "cordova-plugins",
+ "version": "0.0.1",
+ "author": "Ceisdio DiBenedetto <sid.dibenedetto@gmail.com>",
+ "description": "List/download available plugins from registry.cordova.io",
+ "keywords": [
+ "cordova",
+ "plugins"
+ ],
+ "repository": {
+ "type": "git",
+ "url": "https://github.com/cdibened/cordova-plugins.git"
+ },
+ "homepage": "https://github.com/cdibened/cordova-plugins",
+ "bin": {
+ "venue": "./bin/cordova-plugins"
+ },
+ "dependencies": {
+ "shelljs": ">=0.2.6",
+ "cordova": ">=3.*",
+ "nopt": ">=2.1.2",
+ "cli-color": ">=0.2.3",
+ "prompt": ">=0.2.*",
+ "exit": ">=0.0.1"
+ },
+ "engines": {
+ "node": ">=0.8.0"
+ }
+}

0 comments on commit abf56a2

Please sign in to comment.