main.js 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  1. // Generated by IcedCoffeeScript 1.7.1-g
  2. (function() {
  3. var BaseCommand, HelpCommand, Installer, KeyJsonCommand, Main, VersionCommand, bin, constants, fullname, getopt, hash_json, iced, keyring, keyset, log, make_esc, os, path, run, version, __iced_k, __iced_k_noop, _ref,
  4. __hasProp = {}.hasOwnProperty,
  5. __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
  6. iced = require('iced-runtime');
  7. __iced_k = __iced_k_noop = function() {};
  8. getopt = require('iced-utils').getopt;
  9. _ref = require('./package'), fullname = _ref.fullname, bin = _ref.bin, version = _ref.version;
  10. make_esc = require('iced-error').make_esc;
  11. BaseCommand = require('./base').BaseCommand;
  12. Installer = require('./installer').Installer;
  13. keyring = require('gpg-wrapper').keyring;
  14. constants = require('./constants').constants;
  15. hash_json = require('./util').hash_json;
  16. keyset = require('../json/keyset');
  17. log = require('./log');
  18. os = require('os');
  19. path = require('path');
  20. VersionCommand = (function(_super) {
  21. __extends(VersionCommand, _super);
  22. function VersionCommand() {
  23. return VersionCommand.__super__.constructor.apply(this, arguments);
  24. }
  25. VersionCommand.prototype.run = function(cb) {
  26. console.log(fullname());
  27. return cb(null);
  28. };
  29. return VersionCommand;
  30. })(BaseCommand);
  31. HelpCommand = (function(_super) {
  32. __extends(HelpCommand, _super);
  33. function HelpCommand(argv, err) {
  34. this.err = err != null ? err : null;
  35. HelpCommand.__super__.constructor.call(this, argv);
  36. }
  37. HelpCommand.prototype.run = function(cb) {
  38. console.log("usage: " + (bin()) + " [-dhjvCS] [-p <install-prefix>] [<keybase-version>]\n\n\tUpgrade or install a version of keybase. Check signatures with\n\tKeybase.io's signing key. You can provide a specific version\n\tor by default you'll get the most recent version.\n\nBoolean Flags:\n\n\t-d/--debug -- Turn on debugging output\n\t-h/--help -- Print the help message and quit\n\t-j/--key-json -- Output the hash of the JSON file of the built-in keyset\n\t-v/--version -- Print the version and quit\n\t-C/--skip-cleanup -- Don't delete temporary files after install\n\t-S/--no-https -- Don't use HTTPS. Safe since we check PGP sigs on everything.\n\t-O/--no-gpg-options -- Turn off GPG options file for temporary keyring operations\n\nOptions:\n\n\t-g/--gpg <cmd>\n\t\tUse a GPG command other than `gpg`\n\n\t-k/--keyring-dir <dir>\n\t\tWhere to store our GPG keys.\n\t\t(default: ~/.keybase-installer/keyring)\n\n\t-n/--npm <cmd>\n\t\tUse an npm command other than `npm`\n\n\t-p/--prefix <dir>\n\t\tInstall to the given prefix\n\t\t(rather than where `npm` installs by default)\n\n\t-u/--url-prefix <prfx>\n\t\tSpecify a URL prefix for fetching\n\t\t(default: " + constants.url_prefix.https + ")\n\n\t-x/--proxy <url>\n\t\tProxy all downloads through the given proxy\n\nEnvironment Variables:\n\n\thttp_proxy=<full-url> OR https_proxy=<full-url>\n\t\tAs --proxy above, proxy all requests through the\n\t\tgiven proxy.\n\n\tPREFIX\n\t\tAn install prefix\n\nVersion: " + (version()) + "\n");
  39. return cb(this.err);
  40. };
  41. return HelpCommand;
  42. })(BaseCommand);
  43. KeyJsonCommand = (function(_super) {
  44. __extends(KeyJsonCommand, _super);
  45. function KeyJsonCommand() {
  46. return KeyJsonCommand.__super__.constructor.apply(this, arguments);
  47. }
  48. KeyJsonCommand.prototype.run = function(cb) {
  49. keyset.self_sig = null;
  50. process.stdout.write(hash_json(keyset));
  51. return cb(null);
  52. };
  53. return KeyJsonCommand;
  54. })(BaseCommand);
  55. Main = (function() {
  56. function Main() {
  57. this.cmd = null;
  58. }
  59. Main.prototype.parse_args = function(cb) {
  60. var err, flags;
  61. err = null;
  62. flags = ["d", "h", "v", "j", "C", "?", "S", "O", "debug", "key-json", "hash", "help", "version", "skip-cleanup", "no-https", "no-gpg-options"];
  63. this.argv = getopt(process.argv.slice(2), {
  64. flags: flags
  65. });
  66. if (this.argv.get("v", "version")) {
  67. this.cmd = new VersionCommand();
  68. } else if (this.argv.get("h", "?", "help")) {
  69. this.cmd = new HelpCommand();
  70. } else if (this.argv.get("j", "key-json")) {
  71. this.cmd = new KeyJsonCommand(this.argv);
  72. } else if (this.argv.get().length > 1) {
  73. this.cmd = new HelpCommand(this.argv, new Error("Usage error: only zero or one argument allowed"));
  74. } else {
  75. this.cmd = new Installer(this.argv);
  76. }
  77. return cb(err);
  78. };
  79. Main.prototype.run = function(cb) {
  80. var esc, ___iced_passed_deferral, __iced_deferrals, __iced_k;
  81. __iced_k = __iced_k_noop;
  82. ___iced_passed_deferral = iced.findDeferral(arguments);
  83. esc = make_esc(cb, "run");
  84. (function(_this) {
  85. return (function(__iced_k) {
  86. __iced_deferrals = new iced.Deferrals(__iced_k, {
  87. parent: ___iced_passed_deferral,
  88. filename: "/Users/max/src/keybase/node-installer/src/main.iced",
  89. funcname: "Main.run"
  90. });
  91. _this.setup(esc(__iced_deferrals.defer({
  92. lineno: 140
  93. })));
  94. __iced_deferrals._fulfill();
  95. });
  96. })(this)((function(_this) {
  97. return function() {
  98. log.debug("+ cmd.run " + (version()));
  99. (function(__iced_k) {
  100. __iced_deferrals = new iced.Deferrals(__iced_k, {
  101. parent: ___iced_passed_deferral,
  102. filename: "/Users/max/src/keybase/node-installer/src/main.iced",
  103. funcname: "Main.run"
  104. });
  105. _this.cmd.run(esc(__iced_deferrals.defer({
  106. lineno: 142
  107. })));
  108. __iced_deferrals._fulfill();
  109. })(function() {
  110. log.debug("- cmd.run");
  111. return cb(null);
  112. });
  113. };
  114. })(this));
  115. };
  116. Main.prototype.main = function() {
  117. var err, ___iced_passed_deferral, __iced_deferrals, __iced_k;
  118. __iced_k = __iced_k_noop;
  119. ___iced_passed_deferral = iced.findDeferral(arguments);
  120. (function(_this) {
  121. return (function(__iced_k) {
  122. __iced_deferrals = new iced.Deferrals(__iced_k, {
  123. parent: ___iced_passed_deferral,
  124. filename: "/Users/max/src/keybase/node-installer/src/main.iced",
  125. funcname: "Main.main"
  126. });
  127. _this.run(__iced_deferrals.defer({
  128. assign_fn: (function() {
  129. return function() {
  130. return err = arguments[0];
  131. };
  132. })(),
  133. lineno: 149
  134. }));
  135. __iced_deferrals._fulfill();
  136. });
  137. })(this)((function(_this) {
  138. return function() {
  139. if (typeof err !== "undefined" && err !== null) {
  140. log.error(err.message);
  141. if (err.stderr != null) {
  142. log.warn(err.stderr.toString('utf8'));
  143. }
  144. }
  145. return process.exit(typeof err !== "undefined" && err !== null ? -2 : 0);
  146. };
  147. })(this));
  148. };
  149. Main.prototype.setup_logger = function() {
  150. var p;
  151. p = log["package"]();
  152. if (this.argv.get("d", "debug")) {
  153. return p.env().set_level(p.DEBUG);
  154. }
  155. };
  156. Main.prototype.setup = function(cb) {
  157. var esc, ___iced_passed_deferral, __iced_deferrals, __iced_k;
  158. __iced_k = __iced_k_noop;
  159. ___iced_passed_deferral = iced.findDeferral(arguments);
  160. esc = make_esc(cb, "setup");
  161. (function(_this) {
  162. return (function(__iced_k) {
  163. __iced_deferrals = new iced.Deferrals(__iced_k, {
  164. parent: ___iced_passed_deferral,
  165. filename: "/Users/max/src/keybase/node-installer/src/main.iced",
  166. funcname: "Main.setup"
  167. });
  168. _this.parse_args(esc(__iced_deferrals.defer({
  169. lineno: 165
  170. })));
  171. __iced_deferrals._fulfill();
  172. });
  173. })(this)((function(_this) {
  174. return function() {
  175. _this.setup_logger();
  176. return cb(null);
  177. };
  178. })(this));
  179. };
  180. return Main;
  181. })();
  182. exports.run = run = function() {
  183. return (new Main).main();
  184. };
  185. }).call(this);