diff options
Diffstat (limited to 'utils/lib/narwhal/tusk/create-catalog.js')
-rwxr-xr-x | utils/lib/narwhal/tusk/create-catalog.js | 79 |
1 files changed, 0 insertions, 79 deletions
diff --git a/utils/lib/narwhal/tusk/create-catalog.js b/utils/lib/narwhal/tusk/create-catalog.js deleted file mode 100755 index f717cea..0000000 --- a/utils/lib/narwhal/tusk/create-catalog.js +++ /dev/null @@ -1,79 +0,0 @@ - -var tusk = require("../tusk"); -var util = require("util"); -var args = require("args"); -var http = require("http"); -var json = require("json"); - -var parser = exports.parser = new args.Parser(); - -parser.help('creates a catalog of packages from sources.json'); - -parser.action(function (options) { - var self = this; - var sources = tusk.readSources(); - var catalog = {}; - catalog['!'] = "This file is generated by 'tusk create-catalog', copied from '.tusk', and committed only so that it may be downloaded from Github with 'tusk update'."; - catalog.version = util.copy(sources.version); - var packages = catalog.packages = {}; - util.forEachApply( - util.items(sources.packages || {}), - function (name, source) { - var info; - - if (source['package.json']) - info = util.copy(source['package.json']); - - if (source.type == "inline") { - if (!info) { - self.print( - "\0red(dropped:\0) " + name + - " \0blue(because it did not provide a " + - "package.json inline.\0)" - ); - return; - } - - } else if (source.type == "github") { - - var githubName = source.name || name; - if (!source.user) - throw new Error("package source " + util.enquote(name) + " did not have a github user name"); - var project = source.user + '/' + githubName; - var url = "http://github.com/" + project + "/raw/master/package.json"; - - // download package.json if not already provided - if (!info) { - try { - var text = http.read(url).toString('utf-8'); - } catch (exception) { - self.print("\0red(dropped:\0) " + name + " \0blue(because of an HTTP error\0)"); - return; - } - try { - info = json.decode(text); - } catch (exception) { - self.print("\0red(dropped:\0) " + name + " \0blue(because of a JSON error\0)"); - return; - } - } - - info.githubName = githubName; - info.type = "zip"; - info.location = 'http://github.com/' + source.user + '/' + githubName + '/zipball/master'; - - } else { - throw new Error( - "Project " + util.enquote(name) + - " has an urecognized type: " + - util.enquote(source.type) - ); - } - - self.print('\0green(' + name + '\0)'); - packages[name] = info; - } - ); - tusk.writeCatalog(catalog); -}); - |