Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

[api docs] Finished implementing command pattern. Created docco docs

  • Loading branch information...
commit cd6b8fdaec75c9dab1bb4fb486b5cc7549285eee 1 parent fac08e2
@indexzero indexzero authored
View
2  bin/jitsu
@@ -16,6 +16,6 @@ var operations = [
];
-jitsu.start(argv._.join(''), function () {
+jitsu.start(argv._.join(' '), function () {
});
View
194 docs/docco.css
@@ -0,0 +1,194 @@
+/*--------------------- Layout and Typography ----------------------------*/
+body {
+ font-family: 'Palatino Linotype', 'Book Antiqua', Palatino, FreeSerif, serif;
+ font-size: 15px;
+ line-height: 22px;
+ color: #252519;
+ margin: 0; padding: 0;
+}
+a {
+ color: #261a3b;
+}
+ a:visited {
+ color: #261a3b;
+ }
+p {
+ margin: 0 0 15px 0;
+}
+h4, h5, h6 {
+ color: #333;
+ margin: 6px 0 6px 0;
+ font-size: 13px;
+}
+ h2, h3 {
+ margin-bottom: 0;
+ color: #000;
+ }
+ h1 {
+ margin-top: 40px;
+ margin-bottom: 15px;
+ color: #000;
+ }
+#container {
+ position: relative;
+}
+#background {
+ position: fixed;
+ top: 0; left: 525px; right: 0; bottom: 0;
+ background: #f5f5ff;
+ border-left: 1px solid #e5e5ee;
+ z-index: -1;
+}
+#jump_to, #jump_page {
+ background: white;
+ -webkit-box-shadow: 0 0 25px #777; -moz-box-shadow: 0 0 25px #777;
+ -webkit-border-bottom-left-radius: 5px; -moz-border-radius-bottomleft: 5px;
+ font: 10px Arial;
+ text-transform: uppercase;
+ cursor: pointer;
+ text-align: right;
+}
+#jump_to, #jump_wrapper {
+ position: fixed;
+ right: 0; top: 0;
+ padding: 5px 10px;
+}
+ #jump_wrapper {
+ padding: 0;
+ display: none;
+ }
+ #jump_to:hover #jump_wrapper {
+ display: block;
+ }
+ #jump_page {
+ padding: 5px 0 3px;
+ margin: 0 0 25px 25px;
+ }
+ #jump_page .source {
+ display: block;
+ padding: 5px 10px;
+ text-decoration: none;
+ border-top: 1px solid #eee;
+ }
+ #jump_page .source:hover {
+ background: #f5f5ff;
+ }
+ #jump_page .source:first-child {
+ }
+table td {
+ border: 0;
+ outline: 0;
+}
+ td.docs, th.docs {
+ max-width: 450px;
+ min-width: 450px;
+ min-height: 5px;
+ padding: 10px 25px 1px 50px;
+ overflow-x: hidden;
+ vertical-align: top;
+ text-align: left;
+ }
+ .docs pre {
+ margin: 15px 0 15px;
+ padding-left: 15px;
+ }
+ .docs p tt, .docs p code {
+ background: #f8f8ff;
+ border: 1px solid #dedede;
+ font-size: 12px;
+ padding: 0 0.2em;
+ }
+ .pilwrap {
+ position: relative;
+ }
+ .pilcrow {
+ font: 12px Arial;
+ text-decoration: none;
+ color: #454545;
+ position: absolute;
+ top: 3px; left: -20px;
+ padding: 1px 2px;
+ opacity: 0;
+ -webkit-transition: opacity 0.2s linear;
+ }
+ td.docs:hover .pilcrow {
+ opacity: 1;
+ }
+ td.code, th.code {
+ padding: 14px 15px 16px 25px;
+ width: 100%;
+ vertical-align: top;
+ background: #f5f5ff;
+ border-left: 1px solid #e5e5ee;
+ }
+ pre, tt, code {
+ font-size: 12px; line-height: 18px;
+ font-family: Monaco, Consolas, "Lucida Console", monospace;
+ margin: 0; padding: 0;
+ }
+
+
+/*---------------------- Syntax Highlighting -----------------------------*/
+td.linenos { background-color: #f0f0f0; padding-right: 10px; }
+span.lineno { background-color: #f0f0f0; padding: 0 5px 0 5px; }
+body .hll { background-color: #ffffcc }
+body .c { color: #408080; font-style: italic } /* Comment */
+body .err { border: 1px solid #FF0000 } /* Error */
+body .k { color: #954121 } /* Keyword */
+body .o { color: #666666 } /* Operator */
+body .cm { color: #408080; font-style: italic } /* Comment.Multiline */
+body .cp { color: #BC7A00 } /* Comment.Preproc */
+body .c1 { color: #408080; font-style: italic } /* Comment.Single */
+body .cs { color: #408080; font-style: italic } /* Comment.Special */
+body .gd { color: #A00000 } /* Generic.Deleted */
+body .ge { font-style: italic } /* Generic.Emph */
+body .gr { color: #FF0000 } /* Generic.Error */
+body .gh { color: #000080; font-weight: bold } /* Generic.Heading */
+body .gi { color: #00A000 } /* Generic.Inserted */
+body .go { color: #808080 } /* Generic.Output */
+body .gp { color: #000080; font-weight: bold } /* Generic.Prompt */
+body .gs { font-weight: bold } /* Generic.Strong */
+body .gu { color: #800080; font-weight: bold } /* Generic.Subheading */
+body .gt { color: #0040D0 } /* Generic.Traceback */
+body .kc { color: #954121 } /* Keyword.Constant */
+body .kd { color: #954121; font-weight: bold } /* Keyword.Declaration */
+body .kn { color: #954121; font-weight: bold } /* Keyword.Namespace */
+body .kp { color: #954121 } /* Keyword.Pseudo */
+body .kr { color: #954121; font-weight: bold } /* Keyword.Reserved */
+body .kt { color: #B00040 } /* Keyword.Type */
+body .m { color: #666666 } /* Literal.Number */
+body .s { color: #219161 } /* Literal.String */
+body .na { color: #7D9029 } /* Name.Attribute */
+body .nb { color: #954121 } /* Name.Builtin */
+body .nc { color: #0000FF; font-weight: bold } /* Name.Class */
+body .no { color: #880000 } /* Name.Constant */
+body .nd { color: #AA22FF } /* Name.Decorator */
+body .ni { color: #999999; font-weight: bold } /* Name.Entity */
+body .ne { color: #D2413A; font-weight: bold } /* Name.Exception */
+body .nf { color: #0000FF } /* Name.Function */
+body .nl { color: #A0A000 } /* Name.Label */
+body .nn { color: #0000FF; font-weight: bold } /* Name.Namespace */
+body .nt { color: #954121; font-weight: bold } /* Name.Tag */
+body .nv { color: #19469D } /* Name.Variable */
+body .ow { color: #AA22FF; font-weight: bold } /* Operator.Word */
+body .w { color: #bbbbbb } /* Text.Whitespace */
+body .mf { color: #666666 } /* Literal.Number.Float */
+body .mh { color: #666666 } /* Literal.Number.Hex */
+body .mi { color: #666666 } /* Literal.Number.Integer */
+body .mo { color: #666666 } /* Literal.Number.Oct */
+body .sb { color: #219161 } /* Literal.String.Backtick */
+body .sc { color: #219161 } /* Literal.String.Char */
+body .sd { color: #219161; font-style: italic } /* Literal.String.Doc */
+body .s2 { color: #219161 } /* Literal.String.Double */
+body .se { color: #BB6622; font-weight: bold } /* Literal.String.Escape */
+body .sh { color: #219161 } /* Literal.String.Heredoc */
+body .si { color: #BB6688; font-weight: bold } /* Literal.String.Interpol */
+body .sx { color: #954121 } /* Literal.String.Other */
+body .sr { color: #BB6688 } /* Literal.String.Regex */
+body .s1 { color: #219161 } /* Literal.String.Single */
+body .ss { color: #19469D } /* Literal.String.Symbol */
+body .bp { color: #954121 } /* Name.Builtin.Pseudo */
+body .vc { color: #19469D } /* Name.Variable.Class */
+body .vg { color: #19469D } /* Name.Variable.Global */
+body .vi { color: #19469D } /* Name.Variable.Instance */
+body .il { color: #666666 } /* Literal.Number.Integer.Long */
View
125 docs/jitsu.html
@@ -0,0 +1,125 @@
+<!DOCTYPE html> <html> <head> <title>jitsu.js</title> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <link rel="stylesheet" media="all" href="docco.css" /> </head> <body> <div id="container"> <div id="background"></div> <div id="jump_to"> Jump To &hellip; <div id="jump_wrapper"> <div id="jump_page"> <a class="source" href="jitsu/apps.html"> jitsu/apps.html </a> <a class="source" href="jitsu/client.html"> jitsu/client.html </a> <a class="source" href="jitsu/commands/apps.html"> jitsu/commands/apps.html </a> <a class="source" href="jitsu/commands/config.html"> jitsu/commands/config.html </a> <a class="source" href="jitsu/commands.html"> jitsu/commands.html </a> <a class="source" href="jitsu/config.html"> jitsu/config.html </a> <a class="source" href="jitsu/log.html"> jitsu/log.html </a> <a class="source" href="jitsu/prompt.html"> jitsu/prompt.html </a> <a class="source" href="jitsu/users.html"> jitsu/users.html </a> <a class="source" href="jitsu/utils/base64.html"> jitsu/utils/base64.html </a> <a class="source" href="jitsu/utils/index.html"> jitsu/utils/index.html </a> <a class="source" href="jitsu.html"> jitsu.html </a> </div> </div> </div> <table cellpadding="0" cellspacing="0"> <thead> <tr> <th class="docs"> <h1> jitsu.js </h1> </th> <th class="code"> </th> </tr> </thead> <tbody> <tr id="section-1"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-1">&#182;</a> </div> </td> <td class="code"> <div class="highlight"><pre><span class="cm">/*</span>
+<span class="cm"> * jitsu.js: Top-level include for the jitsu module.</span>
+<span class="cm"> *</span>
+<span class="cm"> * (C) 2010, Nodejitsu Inc.</span>
+<span class="cm"> *</span>
+<span class="cm"> */</span>
+
+<span class="nx">require</span><span class="p">.</span><span class="nx">paths</span><span class="p">.</span><span class="nx">unshift</span><span class="p">(</span><span class="nx">__dirname</span><span class="p">);</span>
+
+<span class="kd">var</span> <span class="nx">eyes</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="s1">&#39;eyes&#39;</span><span class="p">),</span>
+ <span class="nx">winston</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="s1">&#39;winston&#39;</span><span class="p">),</span>
+ <span class="nx">colors</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="s1">&#39;colors&#39;</span><span class="p">);</span>
+
+<span class="kd">var</span> <span class="nx">jitsu</span> <span class="o">=</span> <span class="nx">exports</span><span class="p">,</span>
+ <span class="nx">auth</span> <span class="o">=</span> <span class="kc">false</span><span class="p">,</span>
+ <span class="nx">started</span> <span class="o">=</span> <span class="kc">false</span><span class="p">;</span></pre></div> </td> </tr> <tr id="section-2"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-2">&#182;</a> </div> <p>Failure HTTP Response codes based
+off of <code>/lib/broodmother/slave/service.js</code></p> </td> <td class="code"> <div class="highlight"><pre><span class="kd">var</span> <span class="nx">failCodes</span> <span class="o">=</span> <span class="nx">jitsu</span><span class="p">.</span><span class="nx">failCodes</span> <span class="o">=</span> <span class="p">{</span>
+ <span class="mi">400</span><span class="o">:</span> <span class="s2">&quot;Bad Request&quot;</span><span class="p">,</span>
+ <span class="mi">403</span><span class="o">:</span> <span class="s2">&quot;Not Authorized&quot;</span><span class="p">,</span>
+ <span class="mi">404</span><span class="o">:</span> <span class="s2">&quot;Item not found&quot;</span><span class="p">,</span>
+ <span class="mi">500</span><span class="o">:</span> <span class="s2">&quot;Internal Server Error&quot;</span>
+<span class="p">};</span></pre></div> </td> </tr> <tr id="section-3"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-3">&#182;</a> </div> <p>Success HTTP Response codes based
+off of <code>/lib/broodmother/slave/service.js</code></p> </td> <td class="code"> <div class="highlight"><pre><span class="kd">var</span> <span class="nx">successCodes</span> <span class="o">=</span> <span class="nx">jitsu</span><span class="p">.</span><span class="nx">successCodes</span> <span class="o">=</span> <span class="p">{</span>
+ <span class="mi">200</span><span class="o">:</span> <span class="s2">&quot;OK&quot;</span><span class="p">,</span>
+ <span class="mi">201</span><span class="o">:</span> <span class="s2">&quot;Created&quot;</span>
+<span class="p">};</span>
+
+<span class="nx">jitsu</span><span class="p">.</span><span class="nx">utils</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="s1">&#39;jitsu/utils&#39;</span><span class="p">);</span>
+<span class="nx">jitsu</span><span class="p">.</span><span class="nx">Client</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="s1">&#39;jitsu/client&#39;</span><span class="p">).</span><span class="nx">Client</span><span class="p">;</span>
+<span class="nx">jitsu</span><span class="p">.</span><span class="nx">Apps</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="s1">&#39;jitsu/apps&#39;</span><span class="p">).</span><span class="nx">Apps</span><span class="p">;</span>
+<span class="nx">jitsu</span><span class="p">.</span><span class="nx">Users</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="s1">&#39;jitsu/users&#39;</span><span class="p">).</span><span class="nx">Users</span><span class="p">;</span>
+<span class="nx">jitsu</span><span class="p">.</span><span class="nx">prompt</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="s1">&#39;jitsu/prompt&#39;</span><span class="p">);</span>
+<span class="nx">jitsu</span><span class="p">.</span><span class="nx">config</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="s1">&#39;jitsu/config&#39;</span><span class="p">);</span>
+<span class="nx">jitsu</span><span class="p">.</span><span class="nx">commands</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="s1">&#39;jitsu/commands&#39;</span><span class="p">);</span></pre></div> </td> </tr> <tr id="section-4"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-4">&#182;</a> </div> <h3>function start (command, callback)</h3>
+
+<h4>@command {string} Command to execute once started</h4>
+
+<h4>@callback {function} Continuation to pass control to when complete.</h4>
+
+<p>Starts the jitsu CLI and runs the specified command.</p> </td> <td class="code"> <div class="highlight"><pre><span class="nx">jitsu</span><span class="p">.</span><span class="nx">start</span> <span class="o">=</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">command</span><span class="p">,</span> <span class="nx">callback</span><span class="p">)</span> <span class="p">{</span></pre></div> </td> </tr> <tr id="section-5"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-5">&#182;</a> </div> <p>Setup the initial prompt but don't leave it open</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nx">jitsu</span><span class="p">.</span><span class="nx">prompt</span><span class="p">.</span><span class="nx">start</span><span class="p">().</span><span class="nx">pause</span><span class="p">();</span>
+
+ <span class="nx">winston</span><span class="p">.</span><span class="nx">info</span><span class="p">(</span><span class="s1">&#39;Welcome to &#39;</span> <span class="o">+</span> <span class="s1">&#39;Nodejitsu&#39;</span><span class="p">.</span><span class="nx">grey</span><span class="p">);</span>
+ <span class="nx">jitsu</span><span class="p">.</span><span class="nx">config</span><span class="p">.</span><span class="nx">load</span><span class="p">(</span><span class="kd">function</span> <span class="p">(</span><span class="nx">err</span><span class="p">)</span> <span class="p">{</span>
+ <span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">jitsu</span><span class="p">.</span><span class="nx">config</span><span class="p">.</span><span class="nx">settings</span><span class="p">.</span><span class="nx">auth</span><span class="p">)</span> <span class="p">{</span>
+ <span class="k">return</span> <span class="nx">jitsu</span><span class="p">.</span><span class="nx">setupUser</span><span class="p">(</span><span class="kd">function</span> <span class="p">(</span><span class="nx">err</span><span class="p">)</span> <span class="p">{</span>
+ <span class="k">return</span> <span class="nx">err</span> <span class="o">?</span> <span class="nx">callback</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> <span class="o">:</span> <span class="nx">jitsu</span><span class="p">.</span><span class="nx">exec</span><span class="p">(</span><span class="nx">command</span><span class="p">,</span> <span class="nx">callback</span><span class="p">);</span>
+ <span class="p">});</span>
+ <span class="p">}</span>
+
+ <span class="k">return</span> <span class="nx">err</span> <span class="o">?</span> <span class="nx">callback</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> <span class="o">:</span> <span class="nx">jitsu</span><span class="p">.</span><span class="nx">exec</span><span class="p">(</span><span class="nx">command</span><span class="p">,</span> <span class="nx">callback</span><span class="p">);</span>
+ <span class="p">});</span>
+<span class="p">};</span></pre></div> </td> </tr> <tr id="section-6"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-6">&#182;</a> </div> <h3>function exec (command, callback)</h3>
+
+<h4>@command {string} Command to execute</h4>
+
+<h4>@callback {function} Continuation to pass control to when complete.</h4>
+
+<p>Runs the specified command in the jitsu CLI.</p> </td> <td class="code"> <div class="highlight"><pre><span class="nx">jitsu</span><span class="p">.</span><span class="nx">exec</span> <span class="o">=</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">command</span><span class="p">,</span> <span class="nx">callback</span><span class="p">)</span> <span class="p">{</span>
+ <span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">command</span><span class="p">)</span> <span class="p">{</span>
+ <span class="k">return</span> <span class="nx">winston</span><span class="p">.</span><span class="nx">error</span><span class="p">(</span><span class="s1">&#39;No command supplied&#39;</span><span class="p">);</span>
+ <span class="p">}</span>
+ <span class="k">else</span> <span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">started</span><span class="p">)</span> <span class="p">{</span>
+ <span class="nx">jitsu</span><span class="p">.</span><span class="nx">setup</span><span class="p">();</span>
+ <span class="p">}</span>
+
+ <span class="nx">winston</span><span class="p">.</span><span class="nx">info</span><span class="p">(</span><span class="s1">&#39;Executing command &#39;</span> <span class="o">+</span> <span class="nx">jitsu</span><span class="p">.</span><span class="nx">commands</span><span class="p">.</span><span class="nx">parse</span><span class="p">(</span><span class="nx">command</span><span class="p">).</span><span class="nx">splice</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span><span class="mi">2</span><span class="p">).</span><span class="nx">join</span><span class="p">(</span><span class="s1">&#39; &#39;</span><span class="p">).</span><span class="nx">magenta</span><span class="p">);</span>
+ <span class="nx">jitsu</span><span class="p">.</span><span class="nx">commands</span><span class="p">.</span><span class="nx">run</span><span class="p">(</span><span class="nx">command</span><span class="p">,</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">err</span><span class="p">)</span> <span class="p">{</span>
+ <span class="k">if</span> <span class="p">(</span><span class="nx">err</span> <span class="o">&amp;&amp;</span> <span class="o">!</span><span class="sr">/403/</span><span class="p">.</span><span class="nx">test</span><span class="p">(</span><span class="nx">err</span><span class="p">.</span><span class="nx">message</span><span class="p">))</span> <span class="p">{</span>
+ <span class="nx">winston</span><span class="p">.</span><span class="nx">error</span><span class="p">(</span><span class="s1">&#39;Error running command &#39;</span> <span class="o">+</span> <span class="nx">command</span><span class="p">.</span><span class="nx">magenta</span><span class="p">);</span>
+ <span class="nx">winston</span><span class="p">.</span><span class="nx">error</span><span class="p">(</span><span class="nx">err</span><span class="p">.</span><span class="nx">message</span><span class="p">);</span>
+ <span class="k">return</span>
+ <span class="p">}</span>
+ </pre></div> </td> </tr> <tr id="section-7"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-7">&#182;</a> </div> <p>TODO (indexzero): Something here</p> </td> <td class="code"> <div class="highlight"><pre> <span class="p">});</span>
+<span class="p">};</span></pre></div> </td> </tr> <tr id="section-8"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-8">&#182;</a> </div> <h3>function setup (callback)</h3>
+
+<h4>@callback {function} Continuation to pass control to when complete.</h4>
+
+<p>Sets up the instances of the Resource clients for jitsu and tests
+the username/password combo for the authenticated user.</p> </td> <td class="code"> <div class="highlight"><pre><span class="nx">jitsu</span><span class="p">.</span><span class="nx">setup</span> <span class="o">=</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">callback</span><span class="p">)</span> <span class="p">{</span>
+ <span class="k">if</span> <span class="p">(</span><span class="nx">started</span><span class="p">)</span> <span class="p">{</span>
+ <span class="k">return</span><span class="p">;</span>
+ <span class="p">}</span>
+
+ <span class="nx">jitsu</span><span class="p">.</span><span class="nx">users</span> <span class="o">=</span> <span class="k">new</span> <span class="nx">jitsu</span><span class="p">.</span><span class="nx">Users</span><span class="p">(</span><span class="nx">jitsu</span><span class="p">.</span><span class="nx">config</span><span class="p">.</span><span class="nx">settings</span><span class="p">);</span>
+ <span class="nx">jitsu</span><span class="p">.</span><span class="nx">apps</span> <span class="o">=</span> <span class="k">new</span> <span class="nx">jitsu</span><span class="p">.</span><span class="nx">Apps</span><span class="p">(</span><span class="nx">jitsu</span><span class="p">.</span><span class="nx">config</span><span class="p">.</span><span class="nx">settings</span><span class="p">);</span>
+ <span class="nx">started</span> <span class="o">=</span> <span class="kc">true</span><span class="p">;</span>
+<span class="p">};</span></pre></div> </td> </tr> <tr id="section-9"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-9">&#182;</a> </div> <h3>function auth (callback)</h3>
+
+<h4>@callback {function} Continuation to pass control to when complete.</h4>
+
+<p>Attempts to authenicate the user identified in <code>jitsu.config.settings.auth</code></p> </td> <td class="code"> <div class="highlight"><pre><span class="nx">jitsu</span><span class="p">.</span><span class="nx">auth</span> <span class="o">=</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">callback</span><span class="p">)</span> <span class="p">{</span>
+ <span class="k">if</span> <span class="p">(</span><span class="nx">auth</span><span class="p">)</span> <span class="p">{</span>
+ <span class="k">return</span> <span class="nx">callback</span><span class="p">();</span>
+ <span class="p">}</span>
+
+ <span class="nx">jitsu</span><span class="p">.</span><span class="nx">users</span><span class="p">.</span><span class="nx">auth</span><span class="p">(</span><span class="kd">function</span> <span class="p">(</span><span class="nx">err</span><span class="p">,</span> <span class="nx">success</span><span class="p">)</span> <span class="p">{</span>
+ <span class="k">if</span> <span class="p">(</span><span class="nx">err</span> <span class="o">||</span> <span class="o">!</span><span class="nx">success</span><span class="p">)</span> <span class="p">{</span>
+ <span class="nx">winston</span><span class="p">.</span><span class="nx">error</span><span class="p">(</span><span class="s1">&#39;Unable to Autenticate as &#39;</span> <span class="o">+</span> <span class="nx">jitsu</span><span class="p">.</span><span class="nx">config</span><span class="p">.</span><span class="nx">settings</span><span class="p">.</span><span class="nx">auth</span><span class="p">.</span><span class="nx">split</span><span class="p">(</span><span class="s1">&#39;:&#39;</span><span class="p">)[</span><span class="mi">0</span><span class="p">].</span><span class="nx">magenta</span><span class="p">);</span>
+ <span class="nx">winston</span><span class="p">.</span><span class="nx">error</span><span class="p">(</span><span class="nx">err</span><span class="p">.</span><span class="nx">message</span><span class="p">);</span>
+ <span class="k">return</span> <span class="nx">callback</span><span class="p">(</span><span class="nx">err</span><span class="p">);</span>
+ <span class="p">}</span>
+
+ <span class="nx">auth</span> <span class="o">=</span> <span class="kc">true</span><span class="p">;</span>
+ <span class="nx">winston</span><span class="p">.</span><span class="nx">info</span><span class="p">(</span><span class="s1">&#39;Authenticated as &#39;</span> <span class="o">+</span> <span class="nx">jitsu</span><span class="p">.</span><span class="nx">config</span><span class="p">.</span><span class="nx">settings</span><span class="p">.</span><span class="nx">auth</span><span class="p">.</span><span class="nx">split</span><span class="p">(</span><span class="s1">&#39;:&#39;</span><span class="p">)[</span><span class="mi">0</span><span class="p">].</span><span class="nx">magenta</span><span class="p">);</span>
+ <span class="nx">callback</span><span class="p">();</span>
+ <span class="p">});</span>
+<span class="p">}</span></pre></div> </td> </tr> <tr id="section-10"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-10">&#182;</a> </div> <h3>function setupUser (callback)</h3>
+
+<h4>@callback {function} Continuation to pass control to when complete.</h4>
+
+<p>Prompts the user for their username / password combo, then sets up the jitsu CLI,
+and saves the resulting configuration to disk.</p> </td> <td class="code"> <div class="highlight"><pre><span class="nx">jitsu</span><span class="p">.</span><span class="nx">setupUser</span> <span class="o">=</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">callback</span><span class="p">)</span> <span class="p">{</span>
+ <span class="nx">winston</span><span class="p">.</span><span class="nx">info</span><span class="p">(</span><span class="s1">&#39;No user has been setup on this machine&#39;</span><span class="p">)</span>
+ <span class="nx">jitsu</span><span class="p">.</span><span class="nx">prompt</span><span class="p">.</span><span class="nx">get</span><span class="p">([</span><span class="s1">&#39;username&#39;</span><span class="p">,</span> <span class="s1">&#39;password&#39;</span><span class="p">],</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">result</span><span class="p">)</span> <span class="p">{</span>
+ <span class="nx">jitsu</span><span class="p">.</span><span class="nx">config</span><span class="p">.</span><span class="nx">settings</span><span class="p">.</span><span class="nx">auth</span> <span class="o">=</span> <span class="p">[</span><span class="nx">result</span><span class="p">.</span><span class="nx">username</span><span class="p">,</span> <span class="nx">result</span><span class="p">.</span><span class="nx">password</span><span class="p">].</span><span class="nx">join</span><span class="p">(</span><span class="s1">&#39;:&#39;</span><span class="p">);</span>
+ <span class="nx">jitsu</span><span class="p">.</span><span class="nx">setup</span><span class="p">();</span>
+ <span class="nx">jitsu</span><span class="p">.</span><span class="nx">auth</span><span class="p">(</span><span class="kd">function</span> <span class="p">()</span> <span class="p">{</span>
+ <span class="nx">jitsu</span><span class="p">.</span><span class="nx">config</span><span class="p">.</span><span class="nx">save</span><span class="p">(</span><span class="kd">function</span> <span class="p">(</span><span class="nx">err</span><span class="p">)</span> <span class="p">{</span>
+ <span class="k">return</span> <span class="nx">setupErr</span> <span class="o">||</span> <span class="nx">err</span> <span class="o">?</span> <span class="nx">callback</span><span class="p">(</span><span class="nx">setupErr</span> <span class="o">||</span> <span class="nx">err</span><span class="p">)</span> <span class="o">:</span> <span class="nx">callback</span><span class="p">();</span>
+ <span class="p">});</span>
+ <span class="p">});</span>
+ <span class="p">});</span>
+<span class="p">};</span>
+
+</pre></div> </td> </tr> </tbody> </table> </div> </body> </html>
View
60 docs/jitsu/apps.html
@@ -0,0 +1,60 @@
+<!DOCTYPE html> <html> <head> <title>apps.js</title> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <link rel="stylesheet" media="all" href="../docco.css" /> </head> <body> <div id="container"> <div id="background"></div> <div id="jump_to"> Jump To &hellip; <div id="jump_wrapper"> <div id="jump_page"> <a class="source" href="..//jitsu/apps.html"> jitsu/apps.html </a> <a class="source" href="..//jitsu/client.html"> jitsu/client.html </a> <a class="source" href="..//jitsu/commands/apps.html"> jitsu/commands/apps.html </a> <a class="source" href="..//jitsu/commands/config.html"> jitsu/commands/config.html </a> <a class="source" href="..//jitsu/commands.html"> jitsu/commands.html </a> <a class="source" href="..//jitsu/config.html"> jitsu/config.html </a> <a class="source" href="..//jitsu/log.html"> jitsu/log.html </a> <a class="source" href="..//jitsu/prompt.html"> jitsu/prompt.html </a> <a class="source" href="..//jitsu/users.html"> jitsu/users.html </a> <a class="source" href="..//jitsu/utils/base64.html"> jitsu/utils/base64.html </a> <a class="source" href="..//jitsu/utils/index.html"> jitsu/utils/index.html </a> <a class="source" href="..//jitsu.html"> jitsu.html </a> </div> </div> </div> <table cellpadding="0" cellspacing="0"> <thead> <tr> <th class="docs"> <h1> apps.js </h1> </th> <th class="code"> </th> </tr> </thead> <tbody> <tr id="section-1"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-1">&#182;</a> </div> </td> <td class="code"> <div class="highlight"><pre><span class="cm">/*</span>
+<span class="cm"> * app.js: Client for the Nodejitsu apps API.</span>
+<span class="cm"> *</span>
+<span class="cm"> * (C) 2010, Nodejitsu Inc.</span>
+<span class="cm"> *</span>
+<span class="cm"> */</span>
+
+<span class="kd">var</span> <span class="nx">util</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="s1">&#39;util&#39;</span><span class="p">),</span>
+ <span class="nx">winston</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="s1">&#39;winston&#39;</span><span class="p">),</span>
+ <span class="nx">jitsu</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="s1">&#39;jitsu&#39;</span><span class="p">);</span></pre></div> </td> </tr> <tr id="section-2"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-2">&#182;</a> </div> <h3>function Apps (options)</h3>
+
+<h4>@options {Object} Options for this instance</h4>
+
+<p>Constructor function for the Apps resource responsible
+with Nodejitsu's Apps API</p> </td> <td class="code"> <div class="highlight"><pre><span class="kd">var</span> <span class="nx">Apps</span> <span class="o">=</span> <span class="nx">exports</span><span class="p">.</span><span class="nx">Apps</span> <span class="o">=</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">options</span><span class="p">)</span> <span class="p">{</span>
+ <span class="nx">jitsu</span><span class="p">.</span><span class="nx">Client</span><span class="p">.</span><span class="nx">call</span><span class="p">(</span><span class="k">this</span><span class="p">,</span> <span class="nx">options</span><span class="p">);</span>
+<span class="p">};</span></pre></div> </td> </tr> <tr id="section-3"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-3">&#182;</a> </div> <p>Inherit from Client base object</p> </td> <td class="code"> <div class="highlight"><pre><span class="nx">util</span><span class="p">.</span><span class="nx">inherits</span><span class="p">(</span><span class="nx">Apps</span><span class="p">,</span> <span class="nx">jitsu</span><span class="p">.</span><span class="nx">Client</span><span class="p">);</span></pre></div> </td> </tr> <tr id="section-4"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-4">&#182;</a> </div> <h3>function list (callback)</h3>
+
+<h4>@callback {function} Continuation to pass control to when complete</h4>
+
+<p>Lists all applications for the authenticated user</p> </td> <td class="code"> <div class="highlight"><pre><span class="nx">Apps</span><span class="p">.</span><span class="nx">prototype</span><span class="p">.</span><span class="nx">list</span> <span class="o">=</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">callback</span><span class="p">)</span> <span class="p">{</span>
+ <span class="nx">winston</span><span class="p">.</span><span class="nx">info</span><span class="p">(</span><span class="s1">&#39;Listing apps&#39;</span><span class="p">);</span>
+ <span class="k">this</span><span class="p">.</span><span class="nx">_request</span><span class="p">(</span><span class="s1">&#39;GET&#39;</span><span class="p">,</span> <span class="p">[</span><span class="s1">&#39;apps&#39;</span><span class="p">],</span> <span class="nx">callback</span><span class="p">,</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">res</span><span class="p">,</span> <span class="nx">result</span><span class="p">)</span> <span class="p">{</span>
+ <span class="nx">callback</span><span class="p">(</span><span class="kc">null</span><span class="p">,</span> <span class="nx">result</span><span class="p">.</span><span class="nx">apps</span><span class="p">);</span>
+ <span class="p">});</span>
+<span class="p">};</span></pre></div> </td> </tr> <tr id="section-5"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-5">&#182;</a> </div> <h3>function create (app, callback)</h3>
+
+<h4>@app {Object} Package.json manifest for the application.</h4>
+
+<h4>@callback {function} Continuation to pass control to when complete</h4>
+
+<p>Creates an application with the specified package.json manifest in <code>app</code>. </p> </td> <td class="code"> <div class="highlight"><pre><span class="nx">Apps</span><span class="p">.</span><span class="nx">prototype</span><span class="p">.</span><span class="nx">create</span> <span class="o">=</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">app</span><span class="p">,</span> <span class="nx">callback</span><span class="p">)</span> <span class="p">{</span>
+ <span class="k">this</span><span class="p">.</span><span class="nx">_request</span><span class="p">(</span><span class="s1">&#39;POST&#39;</span><span class="p">,</span> <span class="p">[</span><span class="s1">&#39;apps&#39;</span><span class="p">,</span> <span class="nx">app</span><span class="p">.</span><span class="nx">name</span><span class="p">],</span> <span class="nx">app</span><span class="p">,</span> <span class="nx">callback</span><span class="p">,</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">err</span><span class="p">,</span> <span class="nx">res</span><span class="p">,</span> <span class="nx">body</span><span class="p">)</span> <span class="p">{</span>
+
+ <span class="p">});</span>
+<span class="p">};</span></pre></div> </td> </tr> <tr id="section-6"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-6">&#182;</a> </div> <h3>function update (name, attrs, callback)</h3>
+
+<h4>@name {string} Name of the application to update</h4>
+
+<h4>@attrs {Object} Attributes to update for this application.</h4>
+
+<h4>@callback {function} Continuation to pass control to when complete</h4>
+
+<p>Updates the application with <code>name</code> with the specified attributes in <code>attrs</code></p> </td> <td class="code"> <div class="highlight"><pre><span class="nx">Apps</span><span class="p">.</span><span class="nx">prototype</span><span class="p">.</span><span class="nx">update</span> <span class="o">=</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">name</span><span class="p">,</span> <span class="nx">attrs</span><span class="p">,</span> <span class="nx">callback</span><span class="p">)</span> <span class="p">{</span>
+ <span class="k">this</span><span class="p">.</span><span class="nx">_request</span><span class="p">(</span><span class="s1">&#39;PUT&#39;</span><span class="p">,</span> <span class="p">[</span><span class="s1">&#39;apps&#39;</span><span class="p">,</span> <span class="nx">name</span><span class="p">],</span> <span class="nx">attrs</span><span class="p">,</span> <span class="nx">callback</span><span class="p">,</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">err</span><span class="p">,</span> <span class="nx">res</span><span class="p">,</span> <span class="nx">body</span><span class="p">)</span> <span class="p">{</span>
+
+ <span class="p">});</span>
+<span class="p">};</span></pre></div> </td> </tr> <tr id="section-7"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-7">&#182;</a> </div> <h3>function destroy (name, callback)</h3>
+
+<h4>@name {string} Name of the application to destroy</h4>
+
+<h4>@callback {function} Continuation to pass control to when complete</h4>
+
+<p>Destroys the application with <code>name</code> for the authenticated user. </p> </td> <td class="code"> <div class="highlight"><pre><span class="nx">Apps</span><span class="p">.</span><span class="nx">prototype</span><span class="p">.</span><span class="nx">destory</span> <span class="o">=</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">name</span><span class="p">,</span> <span class="nx">callback</span><span class="p">)</span> <span class="p">{</span>
+ <span class="k">this</span><span class="p">.</span><span class="nx">_request</span><span class="p">(</span><span class="s1">&#39;DELETE&#39;</span><span class="p">,</span> <span class="p">[</span><span class="s1">&#39;apps&#39;</span><span class="p">,</span> <span class="nx">name</span><span class="p">],</span> <span class="nx">callback</span><span class="p">,</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">err</span><span class="p">,</span> <span class="nx">res</span><span class="p">,</span> <span class="nx">body</span><span class="p">)</span> <span class="p">{</span>
+
+ <span class="p">});</span>
+<span class="p">};</span>
+
+</pre></div> </td> </tr> </tbody> </table> </div> </body> </html>
View
72 docs/jitsu/client.html
@@ -0,0 +1,72 @@
+<!DOCTYPE html> <html> <head> <title>client.js</title> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <link rel="stylesheet" media="all" href="../docco.css" /> </head> <body> <div id="container"> <div id="background"></div> <div id="jump_to"> Jump To &hellip; <div id="jump_wrapper"> <div id="jump_page"> <a class="source" href="..//jitsu/apps.html"> jitsu/apps.html </a> <a class="source" href="..//jitsu/client.html"> jitsu/client.html </a> <a class="source" href="..//jitsu/commands/apps.html"> jitsu/commands/apps.html </a> <a class="source" href="..//jitsu/commands/config.html"> jitsu/commands/config.html </a> <a class="source" href="..//jitsu/commands.html"> jitsu/commands.html </a> <a class="source" href="..//jitsu/config.html"> jitsu/config.html </a> <a class="source" href="..//jitsu/log.html"> jitsu/log.html </a> <a class="source" href="..//jitsu/prompt.html"> jitsu/prompt.html </a> <a class="source" href="..//jitsu/users.html"> jitsu/users.html </a> <a class="source" href="..//jitsu/utils/base64.html"> jitsu/utils/base64.html </a> <a class="source" href="..//jitsu/utils/index.html"> jitsu/utils/index.html </a> <a class="source" href="..//jitsu.html"> jitsu.html </a> </div> </div> </div> <table cellpadding="0" cellspacing="0"> <thead> <tr> <th class="docs"> <h1> client.js </h1> </th> <th class="code"> </th> </tr> </thead> <tbody> <tr id="section-1"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-1">&#182;</a> </div> </td> <td class="code"> <div class="highlight"><pre><span class="cm">/*</span>
+<span class="cm"> * client.js: Client base for the Nodejitsu API clients.</span>
+<span class="cm"> *</span>
+<span class="cm"> * (C) 2010, Nodejitsu Inc.</span>
+<span class="cm"> *</span>
+<span class="cm"> */</span>
+
+<span class="kd">var</span> <span class="nx">eyes</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="s1">&#39;eyes&#39;</span><span class="p">),</span>
+ <span class="nx">request</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="s1">&#39;request&#39;</span><span class="p">),</span>
+ <span class="nx">jitsu</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="s1">&#39;jitsu&#39;</span><span class="p">);</span></pre></div> </td> </tr> <tr id="section-2"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-2">&#182;</a> </div> <h3>function Client (options)</h3>
+
+<h4>@options {Object} Options for this instance</h4>
+
+<p>Constructor function for the Client base responsible
+for communicating with Nodejitsu's API</p> </td> <td class="code"> <div class="highlight"><pre><span class="kd">var</span> <span class="nx">Client</span> <span class="o">=</span> <span class="nx">exports</span><span class="p">.</span><span class="nx">Client</span> <span class="o">=</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">options</span><span class="p">)</span> <span class="p">{</span>
+ <span class="k">this</span><span class="p">.</span><span class="nx">options</span> <span class="o">=</span> <span class="nx">options</span><span class="p">;</span>
+<span class="p">};</span></pre></div> </td> </tr> <tr id="section-3"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-3">&#182;</a> </div> <h3>@private function _request (method, uri, [body], success, callback)</h3>
+
+<h4>@method {string} HTTP method to use</h4>
+
+<h4>@uri {Array} Locator for the Remote Resource</h4>
+
+<h4>@body {Object} <strong>optional</strong> JSON Request Body</h4>
+
+<h4>@success {function} Continuation to call upon successful transactions</h4>
+
+<h4>@callback {function} Continuation to call if errors occur.</h4>
+
+<p>Makes a request to <code>this.remoteUri + uri</code> using <code>method</code> and any
+<code>body</code> (JSON-only) if supplied. Short circuits to <code>callback</code> if the response
+code from Nodejitsu matches <code>jitsu.failCodes</code>. </p> </td> <td class="code"> <div class="highlight"><pre><span class="nx">Client</span><span class="p">.</span><span class="nx">prototype</span><span class="p">.</span><span class="nx">_request</span> <span class="o">=</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">method</span><span class="p">,</span> <span class="nx">uri</span> <span class="cm">/* variable arguments */</span><span class="p">)</span> <span class="p">{</span>
+ <span class="kd">var</span> <span class="nx">options</span><span class="p">,</span> <span class="nx">args</span> <span class="o">=</span> <span class="nb">Array</span><span class="p">.</span><span class="nx">prototype</span><span class="p">.</span><span class="nx">slice</span><span class="p">.</span><span class="nx">call</span><span class="p">(</span><span class="nx">arguments</span><span class="p">),</span>
+ <span class="nx">success</span> <span class="o">=</span> <span class="nx">args</span><span class="p">.</span><span class="nx">pop</span><span class="p">(),</span>
+ <span class="nx">callback</span> <span class="o">=</span> <span class="nx">args</span><span class="p">.</span><span class="nx">pop</span><span class="p">(),</span>
+ <span class="nx">body</span> <span class="o">=</span> <span class="k">typeof</span> <span class="nx">args</span><span class="p">[</span><span class="nx">args</span><span class="p">.</span><span class="nx">length</span> <span class="o">-</span> <span class="mi">1</span><span class="p">]</span> <span class="o">===</span> <span class="s1">&#39;object&#39;</span> <span class="o">&amp;&amp;</span> <span class="nx">args</span><span class="p">.</span><span class="nx">pop</span><span class="p">(),</span>
+ <span class="nx">encoded</span> <span class="o">=</span> <span class="nx">jitsu</span><span class="p">.</span><span class="nx">utils</span><span class="p">.</span><span class="nx">base64</span><span class="p">.</span><span class="nx">encode</span><span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">options</span><span class="p">.</span><span class="nx">auth</span><span class="p">);</span>
+
+ <span class="nx">options</span> <span class="o">=</span> <span class="p">{</span>
+ <span class="nx">method</span><span class="o">:</span> <span class="nx">method</span> <span class="o">||</span> <span class="s1">&#39;GET&#39;</span><span class="p">,</span>
+ <span class="nx">uri</span><span class="o">:</span> <span class="k">this</span><span class="p">.</span><span class="nx">options</span><span class="p">.</span><span class="nx">remoteUri</span> <span class="o">+</span> <span class="s1">&#39;/&#39;</span> <span class="o">+</span> <span class="nx">uri</span><span class="p">.</span><span class="nx">join</span><span class="p">(</span><span class="s1">&#39;/&#39;</span><span class="p">),</span>
+ <span class="nx">headers</span><span class="o">:</span> <span class="p">{</span>
+ <span class="s1">&#39;Authorization&#39;</span><span class="o">:</span> <span class="s1">&#39;Basic &#39;</span> <span class="o">+</span> <span class="nx">encoded</span><span class="p">,</span>
+ <span class="s1">&#39;Content-Type&#39;</span><span class="o">:</span> <span class="s1">&#39;application/json&#39;</span>
+ <span class="p">}</span>
+ <span class="p">};</span>
+
+ <span class="k">if</span> <span class="p">(</span><span class="nx">body</span><span class="p">)</span> <span class="p">{</span>
+ <span class="nx">options</span><span class="p">.</span><span class="nx">body</span> <span class="o">=</span> <span class="nx">JSON</span><span class="p">.</span><span class="nx">stringify</span><span class="p">(</span><span class="nx">body</span><span class="p">);</span>
+ <span class="p">}</span>
+
+ <span class="nx">request</span><span class="p">(</span><span class="nx">options</span><span class="p">,</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">err</span><span class="p">,</span> <span class="nx">response</span><span class="p">,</span> <span class="nx">body</span><span class="p">)</span> <span class="p">{</span>
+ <span class="k">if</span> <span class="p">(</span><span class="nx">err</span><span class="p">)</span> <span class="p">{</span>
+ <span class="k">return</span> <span class="nx">callback</span><span class="p">(</span><span class="nx">err</span><span class="p">);</span>
+ <span class="p">}</span>
+
+ <span class="k">try</span> <span class="p">{</span>
+ <span class="kd">var</span> <span class="nx">statusCode</span> <span class="o">=</span> <span class="nx">response</span><span class="p">.</span><span class="nx">statusCode</span><span class="p">.</span><span class="nx">toString</span><span class="p">(),</span>
+ <span class="nx">result</span> <span class="o">=</span> <span class="nx">JSON</span><span class="p">.</span><span class="nx">parse</span><span class="p">(</span><span class="nx">body</span><span class="p">);</span>
+ <span class="p">}</span>
+ <span class="k">catch</span> <span class="p">(</span><span class="nx">ex</span><span class="p">)</span> <span class="p">{</span></pre></div> </td> </tr> <tr id="section-4"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-4">&#182;</a> </div> <p>Ignore Errors</p> </td> <td class="code"> <div class="highlight"><pre> <span class="p">}</span>
+
+ <span class="k">if</span> <span class="p">(</span><span class="nb">Object</span><span class="p">.</span><span class="nx">keys</span><span class="p">(</span><span class="nx">jitsu</span><span class="p">.</span><span class="nx">failCodes</span><span class="p">).</span><span class="nx">indexOf</span><span class="p">(</span><span class="nx">statusCode</span><span class="p">)</span> <span class="o">!==</span> <span class="o">-</span><span class="mi">1</span><span class="p">)</span> <span class="p">{</span>
+ <span class="kd">var</span> <span class="nx">error</span> <span class="o">=</span> <span class="k">new</span> <span class="nb">Error</span><span class="p">(</span><span class="s1">&#39;Nodejitsu Error (&#39;</span> <span class="o">+</span> <span class="nx">statusCode</span> <span class="o">+</span> <span class="s1">&#39;): &#39;</span> <span class="o">+</span> <span class="nx">jitsu</span><span class="p">.</span><span class="nx">failCodes</span><span class="p">[</span><span class="nx">statusCode</span><span class="p">]);</span>
+ <span class="nx">error</span><span class="p">.</span><span class="nx">result</span> <span class="o">=</span> <span class="nx">result</span><span class="p">;</span>
+ <span class="k">return</span> <span class="nx">callback</span><span class="p">(</span><span class="nx">error</span><span class="p">);</span>
+ <span class="p">}</span>
+
+ <span class="nx">success</span><span class="p">(</span><span class="nx">response</span><span class="p">,</span> <span class="nx">result</span><span class="p">);</span>
+ <span class="p">});</span>
+<span class="p">};</span>
+
+</pre></div> </td> </tr> </tbody> </table> </div> </body> </html>
View
58 docs/jitsu/commands.html
@@ -0,0 +1,58 @@
+<!DOCTYPE html> <html> <head> <title>commands.js</title> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <link rel="stylesheet" media="all" href="../docco.css" /> </head> <body> <div id="container"> <div id="background"></div> <div id="jump_to"> Jump To &hellip; <div id="jump_wrapper"> <div id="jump_page"> <a class="source" href="..//jitsu/apps.html"> jitsu/apps.html </a> <a class="source" href="..//jitsu/client.html"> jitsu/client.html </a> <a class="source" href="..//jitsu/commands/apps.html"> jitsu/commands/apps.html </a> <a class="source" href="..//jitsu/commands/config.html"> jitsu/commands/config.html </a> <a class="source" href="..//jitsu/commands.html"> jitsu/commands.html </a> <a class="source" href="..//jitsu/config.html"> jitsu/config.html </a> <a class="source" href="..//jitsu/log.html"> jitsu/log.html </a> <a class="source" href="..//jitsu/prompt.html"> jitsu/prompt.html </a> <a class="source" href="..//jitsu/users.html"> jitsu/users.html </a> <a class="source" href="..//jitsu/utils/base64.html"> jitsu/utils/base64.html </a> <a class="source" href="..//jitsu/utils/index.html"> jitsu/utils/index.html </a> <a class="source" href="..//jitsu.html"> jitsu.html </a> </div> </div> </div> <table cellpadding="0" cellspacing="0"> <thead> <tr> <th class="docs"> <h1> commands.js </h1> </th> <th class="code"> </th> </tr> </thead> <tbody> <tr id="section-1"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-1">&#182;</a> </div> </td> <td class="code"> <div class="highlight"><pre><span class="kd">var</span> <span class="nx">jitsu</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="s1">&#39;jitsu&#39;</span><span class="p">);</span>
+
+<span class="kd">var</span> <span class="nx">commands</span> <span class="o">=</span> <span class="nx">exports</span><span class="p">;</span></pre></div> </td> </tr> <tr id="section-2"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-2">&#182;</a> </div> <p>Setup the commands organized by resource</p> </td> <td class="code"> <div class="highlight"><pre><span class="nx">commands</span><span class="p">.</span><span class="nx">commands</span> <span class="o">=</span> <span class="p">{</span>
+ <span class="nx">apps</span><span class="o">:</span> <span class="nx">require</span><span class="p">(</span><span class="s1">&#39;jitsu/commands/apps&#39;</span><span class="p">),</span>
+ <span class="nx">config</span><span class="o">:</span> <span class="nx">require</span><span class="p">(</span><span class="s1">&#39;jitsu/commands/config&#39;</span><span class="p">)</span>
+<span class="p">};</span>
+
+<span class="kd">var</span> <span class="nx">requireAuth</span> <span class="o">=</span> <span class="p">[</span><span class="s1">&#39;apps&#39;</span><span class="p">,</span> <span class="s1">&#39;users&#39;</span><span class="p">,</span> <span class="s1">&#39;snapshots&#39;</span><span class="p">,</span> <span class="s1">&#39;logs&#39;</span><span class="p">];</span></pre></div> </td> </tr> <tr id="section-3"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-3">&#182;</a> </div> <h3>function parse (command)</h3>
+
+<h4>@command {string} Command to parse</h4>
+
+<p>Parses the specified command string.</p> </td> <td class="code"> <div class="highlight"><pre><span class="nx">commands</span><span class="p">.</span><span class="nx">parse</span> <span class="o">=</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">command</span><span class="p">)</span> <span class="p">{</span></pre></div> </td> </tr> <tr id="section-4"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-4">&#182;</a> </div> <p>Remark (indexzero): Do we need more parsing than this?</p> </td> <td class="code"> <div class="highlight"><pre> <span class="k">return</span> <span class="nx">command</span><span class="p">.</span><span class="nx">split</span><span class="p">(</span><span class="s1">&#39; &#39;</span><span class="p">);</span>
+<span class="p">};</span></pre></div> </td> </tr> <tr id="section-5"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-5">&#182;</a> </div> <h3>function run (command, callback)</h3>
+
+<h4>@command {Array} Command to run</h4>
+
+<h4>@callback {function} Continuation to pass control to when complete.</h4>
+
+<p>Runs the specified command.</p> </td> <td class="code"> <div class="highlight"><pre><span class="nx">commands</span><span class="p">.</span><span class="nx">run</span> <span class="o">=</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">command</span><span class="p">,</span> <span class="nx">callback</span><span class="p">)</span> <span class="p">{</span>
+ <span class="kd">var</span> <span class="nx">parts</span> <span class="o">=</span> <span class="nx">commands</span><span class="p">.</span><span class="nx">parse</span><span class="p">(</span><span class="nx">command</span><span class="p">),</span>
+ <span class="nx">name</span> <span class="o">=</span> <span class="nx">parts</span><span class="p">.</span><span class="nx">shift</span><span class="p">(),</span>
+ <span class="nx">action</span> <span class="o">=</span> <span class="nx">parts</span><span class="p">.</span><span class="nx">shift</span><span class="p">(),</span>
+ <span class="nx">expected</span><span class="p">,</span> <span class="nx">resource</span><span class="p">;</span>
+
+ <span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">commands</span><span class="p">.</span><span class="nx">commands</span><span class="p">[</span><span class="nx">name</span><span class="p">])</span> <span class="p">{</span>
+ <span class="k">return</span> <span class="nx">callback</span><span class="p">(</span><span class="k">new</span> <span class="nb">Error</span><span class="p">(</span><span class="s1">&#39;Cannot run command on unknown resource: &#39;</span> <span class="o">+</span> <span class="nx">name</span><span class="p">));</span>
+ <span class="p">}</span>
+
+ <span class="nx">resource</span> <span class="o">=</span> <span class="nx">commands</span><span class="p">.</span><span class="nx">commands</span><span class="p">[</span><span class="nx">name</span><span class="p">];</span>
+ <span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">resource</span><span class="p">[</span><span class="nx">action</span><span class="p">])</span> <span class="p">{</span>
+ <span class="k">return</span> <span class="nx">callback</span><span class="p">(</span><span class="k">new</span> <span class="nb">Error</span><span class="p">(</span><span class="s1">&#39;Cannot run unknown action &#39;</span> <span class="o">+</span> <span class="nx">action</span> <span class="o">+</span> <span class="s1">&#39; on resource &#39;</span> <span class="o">+</span> <span class="nx">name</span><span class="p">));</span>
+ <span class="p">}</span>
+ </pre></div> </td> </tr> <tr id="section-6"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-6">&#182;</a> </div> <p>Append the callback to the arguments to pass the command,
+check the arguments length then execute the command.</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nx">parts</span><span class="p">.</span><span class="nx">push</span><span class="p">(</span><span class="nx">callback</span><span class="p">);</span>
+ <span class="nx">expected</span> <span class="o">=</span> <span class="nx">resource</span><span class="p">[</span><span class="nx">action</span><span class="p">].</span><span class="nx">length</span><span class="p">;</span>
+
+ <span class="k">if</span> <span class="p">(</span><span class="nx">parts</span><span class="p">.</span><span class="nx">length</span> <span class="o">!==</span> <span class="nx">expected</span><span class="p">)</span> <span class="p">{</span>
+ <span class="k">return</span> <span class="nx">callback</span><span class="p">(</span><span class="k">new</span> <span class="nb">Error</span><span class="p">(</span><span class="s1">&#39;Wrong number of arguments: &#39;</span> <span class="o">+</span> <span class="nx">parts</span><span class="p">.</span><span class="nx">length</span> <span class="o">+</span> <span class="s1">&#39; for &#39;</span> <span class="o">+</span> <span class="nx">expected</span><span class="p">))</span>
+ <span class="p">}</span>
+
+ <span class="kd">function</span> <span class="nx">runCommand</span> <span class="p">()</span> <span class="p">{</span>
+ <span class="nx">resource</span><span class="p">[</span><span class="nx">action</span><span class="p">].</span><span class="nx">apply</span><span class="p">(</span><span class="nx">resource</span><span class="p">,</span> <span class="nx">parts</span><span class="p">);</span>
+ <span class="p">}</span>
+
+ <span class="k">if</span> <span class="p">(</span><span class="nx">requireAuth</span><span class="p">.</span><span class="nx">indexOf</span><span class="p">(</span><span class="nx">name</span><span class="p">)</span> <span class="o">!==</span> <span class="o">-</span><span class="mi">1</span><span class="p">)</span> <span class="p">{</span>
+ <span class="k">return</span> <span class="nx">jitsu</span><span class="p">.</span><span class="nx">auth</span><span class="p">(</span><span class="kd">function</span> <span class="p">(</span><span class="nx">err</span><span class="p">)</span> <span class="p">{</span>
+ <span class="k">if</span> <span class="p">(</span><span class="nx">err</span><span class="p">)</span> <span class="p">{</span>
+ <span class="k">return</span> <span class="nx">callback</span><span class="p">(</span><span class="nx">err</span><span class="p">);</span>
+ <span class="p">}</span>
+
+ <span class="nx">runCommand</span><span class="p">();</span>
+ <span class="p">});</span>
+ <span class="p">}</span>
+
+ <span class="nx">runCommand</span><span class="p">();</span>
+<span class="p">};</span>
+
+</pre></div> </td> </tr> </tbody> </table> </div> </body> </html>
View
20 docs/jitsu/commands/apps.html
@@ -0,0 +1,20 @@
+<!DOCTYPE html> <html> <head> <title>apps.js</title> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <link rel="stylesheet" media="all" href="../../docco.css" /> </head> <body> <div id="container"> <div id="background"></div> <div id="jump_to"> Jump To &hellip; <div id="jump_wrapper"> <div id="jump_page"> <a class="source" href="../..//jitsu/apps.html"> jitsu/apps.html </a> <a class="source" href="../..//jitsu/client.html"> jitsu/client.html </a> <a class="source" href="../..//jitsu/commands/apps.html"> jitsu/commands/apps.html </a> <a class="source" href="../..//jitsu/commands/config.html"> jitsu/commands/config.html </a> <a class="source" href="../..//jitsu/commands.html"> jitsu/commands.html </a> <a class="source" href="../..//jitsu/config.html"> jitsu/config.html </a> <a class="source" href="../..//jitsu/log.html"> jitsu/log.html </a> <a class="source" href="../..//jitsu/prompt.html"> jitsu/prompt.html </a> <a class="source" href="../..//jitsu/users.html"> jitsu/users.html </a> <a class="source" href="../..//jitsu/utils/base64.html"> jitsu/utils/base64.html </a> <a class="source" href="../..//jitsu/utils/index.html"> jitsu/utils/index.html </a> <a class="source" href="../..//jitsu.html"> jitsu.html </a> </div> </div> </div> <table cellpadding="0" cellspacing="0"> <thead> <tr> <th class="docs"> <h1> apps.js </h1> </th> <th class="code"> </th> </tr> </thead> <tbody> <tr id="section-1"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-1">&#182;</a> </div> </td> <td class="code"> <div class="highlight"><pre><span class="cm">/*</span>
+<span class="cm"> * apps.js: Commands related to app resources</span>
+<span class="cm"> *</span>
+<span class="cm"> * (C) 2010, Nodejitsu Inc.</span>
+<span class="cm"> *</span>
+<span class="cm"> */</span>
+
+<span class="kd">var</span> <span class="nx">jitsu</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="s1">&#39;jitsu&#39;</span><span class="p">);</span>
+
+<span class="kd">var</span> <span class="nx">apps</span> <span class="o">=</span> <span class="nx">exports</span><span class="p">;</span>
+
+<span class="nx">apps</span><span class="p">.</span><span class="nx">list</span> <span class="o">=</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">callback</span><span class="p">)</span> <span class="p">{</span>
+ <span class="nx">jitsu</span><span class="p">.</span><span class="nx">apps</span><span class="p">.</span><span class="nx">list</span><span class="p">(</span><span class="kd">function</span> <span class="p">(</span><span class="nx">err</span><span class="p">,</span> <span class="nx">apps</span><span class="p">)</span> <span class="p">{</span>
+ <span class="nx">apps</span><span class="p">.</span><span class="nx">forEach</span><span class="p">(</span><span class="kd">function</span> <span class="p">(</span><span class="nx">app</span><span class="p">)</span> <span class="p">{</span>
+ <span class="nx">require</span><span class="p">(</span><span class="s1">&#39;eyes&#39;</span><span class="p">).</span><span class="nx">inspect</span><span class="p">(</span><span class="nx">app</span><span class="p">);</span>
+ <span class="p">})</span>
+ <span class="p">});</span>
+<span class="p">};</span>
+
+</pre></div> </td> </tr> </tbody> </table> </div> </body> </html>
View
17 docs/jitsu/commands/config.html
@@ -0,0 +1,17 @@
+<!DOCTYPE html> <html> <head> <title>config.js</title> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <link rel="stylesheet" media="all" href="../../docco.css" /> </head> <body> <div id="container"> <div id="background"></div> <div id="jump_to"> Jump To &hellip; <div id="jump_wrapper"> <div id="jump_page"> <a class="source" href="../..//jitsu/apps.html"> jitsu/apps.html </a> <a class="source" href="../..//jitsu/client.html"> jitsu/client.html </a> <a class="source" href="../..//jitsu/commands/apps.html"> jitsu/commands/apps.html </a> <a class="source" href="../..//jitsu/commands/config.html"> jitsu/commands/config.html </a> <a class="source" href="../..//jitsu/commands.html"> jitsu/commands.html </a> <a class="source" href="../..//jitsu/config.html"> jitsu/config.html </a> <a class="source" href="../..//jitsu/log.html"> jitsu/log.html </a> <a class="source" href="../..//jitsu/prompt.html"> jitsu/prompt.html </a> <a class="source" href="../..//jitsu/users.html"> jitsu/users.html </a> <a class="source" href="../..//jitsu/utils/base64.html"> jitsu/utils/base64.html </a> <a class="source" href="../..//jitsu/utils/index.html"> jitsu/utils/index.html </a> <a class="source" href="../..//jitsu.html"> jitsu.html </a> </div> </div> </div> <table cellpadding="0" cellspacing="0"> <thead> <tr> <th class="docs"> <h1> config.js </h1> </th> <th class="code"> </th> </tr> </thead> <tbody> <tr id="section-1"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-1">&#182;</a> </div> </td> <td class="code"> <div class="highlight"><pre><span class="cm">/*</span>
+<span class="cm"> * config.js: Command related to jitsu configuration</span>
+<span class="cm"> *</span>
+<span class="cm"> * (C) 2010, Nodejitsu Inc.</span>
+<span class="cm"> *</span>
+<span class="cm"> */</span>
+
+<span class="kd">var</span> <span class="nx">jitsu</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="s1">&#39;jitsu&#39;</span><span class="p">);</span>
+
+<span class="kd">var</span> <span class="nx">config</span> <span class="o">=</span> <span class="nx">exports</span><span class="p">;</span>
+
+<span class="nx">config</span><span class="p">.</span><span class="nx">set</span> <span class="o">=</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">key</span><span class="p">,</span> <span class="nx">value</span><span class="p">,</span> <span class="nx">callback</span><span class="p">)</span> <span class="p">{</span>
+ <span class="nx">jitsu</span><span class="p">.</span><span class="nx">config</span><span class="p">.</span><span class="nx">settings</span><span class="p">[</span><span class="nx">key</span><span class="p">]</span> <span class="o">=</span> <span class="nx">value</span><span class="p">;</span>
+ <span class="nx">jitsu</span><span class="p">.</span><span class="nx">config</span><span class="p">.</span><span class="nx">save</span><span class="p">(</span><span class="nx">callback</span><span class="p">);</span>
+<span class="p">};</span>
+
+</pre></div> </td> </tr> </tbody> </table> </div> </body> </html>
View
60 docs/jitsu/config.html
@@ -0,0 +1,60 @@
+<!DOCTYPE html> <html> <head> <title>config.js</title> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <link rel="stylesheet" media="all" href="../docco.css" /> </head> <body> <div id="container"> <div id="background"></div> <div id="jump_to"> Jump To &hellip; <div id="jump_wrapper"> <div id="jump_page"> <a class="source" href="..//jitsu/apps.html"> jitsu/apps.html </a> <a class="source" href="..//jitsu/client.html"> jitsu/client.html </a> <a class="source" href="..//jitsu/commands/apps.html"> jitsu/commands/apps.html </a> <a class="source" href="..//jitsu/commands/config.html"> jitsu/commands/config.html </a> <a class="source" href="..//jitsu/commands.html"> jitsu/commands.html </a> <a class="source" href="..//jitsu/config.html"> jitsu/config.html </a> <a class="source" href="..//jitsu/log.html"> jitsu/log.html </a> <a class="source" href="..//jitsu/prompt.html"> jitsu/prompt.html </a> <a class="source" href="..//jitsu/users.html"> jitsu/users.html </a> <a class="source" href="..//jitsu/utils/base64.html"> jitsu/utils/base64.html </a> <a class="source" href="..//jitsu/utils/index.html"> jitsu/utils/index.html </a> <a class="source" href="..//jitsu.html"> jitsu.html </a> </div> </div> </div> <table cellpadding="0" cellspacing="0"> <thead> <tr> <th class="docs"> <h1> config.js </h1> </th> <th class="code"> </th> </tr> </thead> <tbody> <tr id="section-1"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-1">&#182;</a> </div> </td> <td class="code"> <div class="highlight"><pre><span class="cm">/*</span>
+<span class="cm"> * config.js: Configuration for the jitsu CLI.</span>
+<span class="cm"> *</span>
+<span class="cm"> * (C) 2010, Nodejitsu Inc.</span>
+<span class="cm"> *</span>
+<span class="cm"> */</span>
+
+<span class="kd">var</span> <span class="nx">path</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="s1">&#39;path&#39;</span><span class="p">),</span>
+ <span class="nx">log</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="s1">&#39;jitsu/log&#39;</span><span class="p">);</span>
+ <span class="nx">fs</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="s1">&#39;fs&#39;</span><span class="p">);</span>
+
+<span class="kd">var</span> <span class="nx">config</span> <span class="o">=</span> <span class="nx">exports</span><span class="p">,</span> <span class="nx">settings</span> <span class="o">=</span> <span class="nx">config</span><span class="p">.</span><span class="nx">settings</span> <span class="o">=</span> <span class="p">{</span>
+ <span class="nx">root</span><span class="o">:</span> <span class="nx">process</span><span class="p">.</span><span class="nx">env</span><span class="p">.</span><span class="nx">HOME</span><span class="p">,</span>
+ <span class="nx">remoteUri</span><span class="o">:</span> <span class="s1">&#39;http://localhost&#39;</span><span class="p">,</span>
+ <span class="nx">files</span><span class="o">:</span> <span class="p">{</span>
+ <span class="nx">config</span><span class="o">:</span> <span class="s1">&#39;.jitsuconf&#39;</span>
+ <span class="p">}</span>
+<span class="p">};</span></pre></div> </td> </tr> <tr id="section-2"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-2">&#182;</a> </div> <p>Export the log configuration</p> </td> <td class="code"> <div class="highlight"><pre><span class="nx">config</span><span class="p">.</span><span class="nx">log</span> <span class="o">=</span> <span class="nx">log</span><span class="p">.</span><span class="nx">config</span><span class="p">;</span></pre></div> </td> </tr> <tr id="section-3"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-3">&#182;</a> </div> <h3>function load (callback)</h3>
+
+<h4>@callback {function} Continuation to pass control to when complete.</h4>
+
+<p>Loads the settings for this process.</p> </td> <td class="code"> <div class="highlight"><pre><span class="nx">config</span><span class="p">.</span><span class="nx">load</span> <span class="o">=</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">callback</span><span class="p">)</span> <span class="p">{</span>
+ <span class="nx">fs</span><span class="p">.</span><span class="nx">readFile</span><span class="p">(</span><span class="nx">config</span><span class="p">.</span><span class="nx">file</span><span class="p">(</span><span class="s1">&#39;config&#39;</span><span class="p">),</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">err</span><span class="p">,</span> <span class="nx">data</span><span class="p">)</span> <span class="p">{</span>
+ <span class="k">if</span> <span class="p">(</span><span class="nx">err</span> <span class="o">&amp;&amp;</span> <span class="sr">/ENOENT, No such file/</span><span class="p">.</span><span class="nx">test</span><span class="p">(</span><span class="nx">err</span><span class="p">.</span><span class="nx">message</span><span class="p">))</span> <span class="p">{</span>
+ <span class="k">return</span> <span class="nx">config</span><span class="p">.</span><span class="nx">save</span><span class="p">(</span><span class="kd">function</span> <span class="p">(</span><span class="nx">err</span><span class="p">)</span> <span class="p">{</span>
+ <span class="k">return</span> <span class="nx">err</span> <span class="o">?</span> <span class="nx">callback</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> <span class="o">:</span> <span class="nx">callback</span><span class="p">();</span>
+ <span class="p">});</span>
+ <span class="p">}</span>
+ <span class="k">else</span> <span class="k">if</span> <span class="p">(</span><span class="nx">err</span><span class="p">)</span> <span class="p">{</span>
+ <span class="k">return</span> <span class="nx">callback</span><span class="p">(</span><span class="nx">err</span><span class="p">);</span>
+ <span class="p">}</span>
+
+ <span class="nx">data</span> <span class="o">=</span> <span class="nx">JSON</span><span class="p">.</span><span class="nx">parse</span><span class="p">(</span><span class="nx">data</span><span class="p">.</span><span class="nx">toString</span><span class="p">());</span>
+ <span class="nb">Object</span><span class="p">.</span><span class="nx">keys</span><span class="p">(</span><span class="nx">data</span><span class="p">).</span><span class="nx">forEach</span><span class="p">(</span><span class="kd">function</span> <span class="p">(</span><span class="nx">key</span><span class="p">)</span> <span class="p">{</span>
+ <span class="nx">config</span><span class="p">.</span><span class="nx">settings</span><span class="p">[</span><span class="nx">key</span><span class="p">]</span> <span class="o">=</span> <span class="nx">data</span><span class="p">[</span><span class="nx">key</span><span class="p">];</span>
+ <span class="p">});</span>
+
+ <span class="nx">callback</span><span class="p">();</span>
+ <span class="p">});</span>
+<span class="p">};</span></pre></div> </td> </tr> <tr id="section-4"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-4">&#182;</a> </div> <h3>function save (callback)</h3>
+
+<h4>@callback {function} Continuation to pass control to when complete.</h4>
+
+<p>Saves the settings to the specified location for <code>.jitsuconf</code></p> </td> <td class="code"> <div class="highlight"><pre><span class="nx">config</span><span class="p">.</span><span class="nx">save</span> <span class="o">=</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">callback</span><span class="p">)</span> <span class="p">{</span>
+ <span class="nx">fs</span><span class="p">.</span><span class="nx">writeFile</span><span class="p">(</span><span class="nx">config</span><span class="p">.</span><span class="nx">file</span><span class="p">(</span><span class="s1">&#39;config&#39;</span><span class="p">),</span> <span class="nx">JSON</span><span class="p">.</span><span class="nx">stringify</span><span class="p">(</span><span class="nx">config</span><span class="p">.</span><span class="nx">settings</span><span class="p">),</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">err</span><span class="p">)</span> <span class="p">{</span>
+ <span class="k">return</span> <span class="nx">err</span> <span class="o">?</span> <span class="nx">callback</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> <span class="o">:</span> <span class="nx">callback</span><span class="p">();</span>
+ <span class="p">});</span>
+<span class="p">};</span></pre></div> </td> </tr> <tr id="section-5"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-5">&#182;</a> </div> <h3>function file (file)</h3>
+
+<h4>@file {string} Name of the file to get the path for</h4>
+
+<p>Gets the full path for the file supplied </p> </td> <td class="code"> <div class="highlight"><pre><span class="nx">config</span><span class="p">.</span><span class="nx">file</span> <span class="o">=</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">file</span><span class="p">)</span> <span class="p">{</span>
+ <span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">settings</span><span class="p">.</span><span class="nx">files</span><span class="p">[</span><span class="nx">file</span><span class="p">])</span> <span class="p">{</span>
+ <span class="k">return</span> <span class="kc">null</span><span class="p">;</span>
+ <span class="p">}</span>
+
+ <span class="k">return</span> <span class="nx">path</span><span class="p">.</span><span class="nx">join</span><span class="p">(</span><span class="nx">settings</span><span class="p">.</span><span class="nx">root</span><span class="p">,</span> <span class="nx">settings</span><span class="p">.</span><span class="nx">files</span><span class="p">[</span><span class="nx">file</span><span class="p">]);</span>
+<span class="p">};</span>
+
+</pre></div> </td> </tr> </tbody> </table> </div> </body> </html>
View
38 docs/jitsu/log.html
@@ -0,0 +1,38 @@
+<!DOCTYPE html> <html> <head> <title>log.js</title> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <link rel="stylesheet" media="all" href="../docco.css" /> </head> <body> <div id="container"> <div id="background"></div> <div id="jump_to"> Jump To &hellip; <div id="jump_wrapper"> <div id="jump_page"> <a class="source" href="..//jitsu/apps.html"> jitsu/apps.html </a> <a class="source" href="..//jitsu/client.html"> jitsu/client.html </a> <a class="source" href="..//jitsu/commands/apps.html"> jitsu/commands/apps.html </a> <a class="source" href="..//jitsu/commands/config.html"> jitsu/commands/config.html </a> <a class="source" href="..//jitsu/commands.html"> jitsu/commands.html </a> <a class="source" href="..//jitsu/config.html"> jitsu/config.html </a> <a class="source" href="..//jitsu/log.html"> jitsu/log.html </a> <a class="source" href="..//jitsu/prompt.html"> jitsu/prompt.html </a> <a class="source" href="..//jitsu/users.html"> jitsu/users.html </a> <a class="source" href="..//jitsu/utils/base64.html"> jitsu/utils/base64.html </a> <a class="source" href="..//jitsu/utils/index.html"> jitsu/utils/index.html </a> <a class="source" href="..//jitsu.html"> jitsu.html </a> </div> </div> </div> <table cellpadding="0" cellspacing="0"> <thead> <tr> <th class="docs"> <h1> log.js </h1> </th> <th class="code"> </th> </tr> </thead> <tbody> <tr id="section-1"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-1">&#182;</a> </div> </td> <td class="code"> <div class="highlight"><pre><span class="cm">/*</span>
+<span class="cm"> * log.js: Tools for configuring winston in jitsu.</span>
+<span class="cm"> *</span>
+<span class="cm"> * (C) 2010, Nodejitsu Inc.</span>
+<span class="cm"> *</span>
+<span class="cm"> */</span>
+
+<span class="kd">var</span> <span class="nx">winston</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="s1">&#39;winston&#39;</span><span class="p">);</span></pre></div> </td> </tr> <tr id="section-2"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-2">&#182;</a> </div> <h3>@config</h3>
+
+<p>Log level configuration for jitsu.</p> </td> <td class="code"> <div class="highlight"><pre><span class="kd">var</span> <span class="nx">config</span> <span class="o">=</span> <span class="nx">exports</span><span class="p">.</span><span class="nx">config</span> <span class="o">=</span> <span class="p">{</span>
+ <span class="nx">levels</span><span class="o">:</span> <span class="p">{</span>
+ <span class="nx">silly</span><span class="o">:</span> <span class="mi">0</span><span class="p">,</span>
+ <span class="nx">input</span><span class="o">:</span> <span class="mi">1</span><span class="p">,</span>
+ <span class="nx">verbose</span><span class="o">:</span> <span class="mi">2</span><span class="p">,</span>
+ <span class="nx">prompt</span><span class="o">:</span> <span class="mi">3</span><span class="p">,</span>
+ <span class="nx">info</span><span class="o">:</span> <span class="mi">4</span><span class="p">,</span>
+ <span class="nx">warn</span><span class="o">:</span> <span class="mi">5</span><span class="p">,</span>
+ <span class="nx">debug</span><span class="o">:</span> <span class="mi">6</span><span class="p">,</span>
+ <span class="nx">error</span><span class="o">:</span> <span class="mi">7</span>
+ <span class="p">},</span>
+ <span class="nx">colors</span><span class="o">:</span> <span class="p">{</span>
+ <span class="nx">silly</span><span class="o">:</span> <span class="s1">&#39;magenta&#39;</span><span class="p">,</span>
+ <span class="nx">input</span><span class="o">:</span> <span class="s1">&#39;grey&#39;</span><span class="p">,</span>
+ <span class="nx">verbose</span><span class="o">:</span> <span class="s1">&#39;cyan&#39;</span><span class="p">,</span>
+ <span class="nx">prompt</span><span class="o">:</span> <span class="s1">&#39;grey&#39;</span><span class="p">,</span>
+ <span class="nx">info</span><span class="o">:</span> <span class="s1">&#39;green&#39;</span><span class="p">,</span>
+ <span class="nx">warn</span><span class="o">:</span> <span class="s1">&#39;yellow&#39;</span><span class="p">,</span>
+ <span class="nx">debug</span><span class="o">:</span> <span class="s1">&#39;blue&#39;</span><span class="p">,</span>
+ <span class="nx">error</span><span class="o">:</span> <span class="s1">&#39;red&#39;</span>
+ <span class="p">}</span>
+<span class="p">};</span></pre></div> </td> </tr> <tr id="section-3"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-3">&#182;</a> </div> <p>Configure winston with the levels and colors that we've defined</p> </td> <td class="code"> <div class="highlight"><pre><span class="nx">winston</span><span class="p">.</span><span class="nx">emitErrs</span> <span class="o">=</span> <span class="kc">false</span><span class="p">;</span>
+<span class="nx">winston</span><span class="p">.</span><span class="nx">defaultTransports</span><span class="p">().</span><span class="nx">console</span><span class="p">.</span><span class="nx">colorize</span> <span class="o">=</span> <span class="kc">true</span><span class="p">;</span>
+<span class="nx">winston</span><span class="p">.</span><span class="nx">defaultTransports</span><span class="p">().</span><span class="nx">console</span><span class="p">.</span><span class="nx">timestamp</span> <span class="o">=</span> <span class="kc">false</span><span class="p">;</span>
+<span class="nx">winston</span><span class="p">.</span><span class="nx">padLevels</span> <span class="o">=</span> <span class="kc">true</span><span class="p">;</span>
+<span class="nx">winston</span><span class="p">.</span><span class="nx">setLevels</span><span class="p">(</span><span class="nx">config</span><span class="p">.</span><span class="nx">levels</span><span class="p">);</span>
+<span class="nx">winston</span><span class="p">.</span><span class="nx">addColors</span><span class="p">(</span><span class="nx">config</span><span class="p">.</span><span class="nx">colors</span><span class="p">);</span></pre></div> </td> </tr> <tr id="section-4"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-4">&#182;</a> </div> <p>TODO (indexzero): Load this in config.js</p> </td> <td class="code"> <div class="highlight"><pre><span class="nx">winston</span><span class="p">.</span><span class="nx">defaultTransports</span><span class="p">().</span><span class="nx">console</span><span class="p">.</span><span class="nx">level</span> <span class="o">=</span> <span class="s1">&#39;silly&#39;</span><span class="p">;</span>
+
+</pre></div> </td> </tr> </tbody> </table> </div> </body> </html>
View
112 docs/jitsu/prompt.html
@@ -0,0 +1,112 @@
+<!DOCTYPE html> <html> <head> <title>prompt.js</title> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <link rel="stylesheet" media="all" href="../docco.css" /> </head> <body> <div id="container"> <div id="background"></div> <div id="jump_to"> Jump To &hellip; <div id="jump_wrapper"> <div id="jump_page"> <a class="source" href="..//jitsu/apps.html"> jitsu/apps.html </a> <a class="source" href="..//jitsu/client.html"> jitsu/client.html </a> <a class="source" href="..//jitsu/commands/apps.html"> jitsu/commands/apps.html </a> <a class="source" href="..//jitsu/commands/config.html"> jitsu/commands/config.html </a> <a class="source" href="..//jitsu/commands.html"> jitsu/commands.html </a> <a class="source" href="..//jitsu/config.html"> jitsu/config.html </a> <a class="source" href="..//jitsu/log.html"> jitsu/log.html </a> <a class="source" href="..//jitsu/prompt.html"> jitsu/prompt.html </a> <a class="source" href="..//jitsu/users.html"> jitsu/users.html </a> <a class="source" href="..//jitsu/utils/base64.html"> jitsu/utils/base64.html </a> <a class="source" href="..//jitsu/utils/index.html"> jitsu/utils/index.html </a> <a class="source" href="..//jitsu.html"> jitsu.html </a> </div> </div> </div> <table cellpadding="0" cellspacing="0"> <thead> <tr> <th class="docs"> <h1> prompt.js </h1> </th> <th class="code"> </th> </tr> </thead> <tbody> <tr id="section-1"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-1">&#182;</a> </div> </td> <td class="code"> <div class="highlight"><pre><span class="cm">/*</span>
+<span class="cm"> * prompt.js: Tools for interacting with a prompt in the jitsu CLI.</span>
+<span class="cm"> *</span>
+<span class="cm"> * (C) 2010, Nodejitsu Inc.</span>
+<span class="cm"> *</span>
+<span class="cm"> */</span>
+
+<span class="kd">var</span> <span class="nx">async</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="s1">&#39;async&#39;</span><span class="p">),</span>
+ <span class="nx">colors</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="s1">&#39;colors&#39;</span><span class="p">),</span>
+ <span class="nx">winston</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="s1">&#39;winston&#39;</span><span class="p">),</span>
+ <span class="nx">readline</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="s1">&#39;readline&#39;</span><span class="p">);</span></pre></div> </td> </tr> <tr id="section-2"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-2">&#182;</a> </div> <h3>@private function capitalize (str)</h3>
+
+<h4>str {string} String to capitalize</h4>
+
+<p>Capitalizes the string supplied.</p> </td> <td class="code"> <div class="highlight"><pre><span class="kd">function</span> <span class="nx">capitalize</span><span class="p">(</span><span class="nx">str</span><span class="p">)</span> <span class="p">{</span>
+ <span class="k">return</span> <span class="nx">str</span><span class="p">.</span><span class="nx">charAt</span><span class="p">(</span><span class="mi">0</span><span class="p">).</span><span class="nx">toUpperCase</span><span class="p">()</span> <span class="o">+</span> <span class="nx">str</span><span class="p">.</span><span class="nx">slice</span><span class="p">(</span><span class="mi">1</span><span class="p">);</span>
+<span class="p">}</span>
+
+<span class="kd">var</span> <span class="nx">prompt</span> <span class="o">=</span> <span class="nx">exports</span><span class="p">,</span>
+ <span class="nx">started</span> <span class="o">=</span> <span class="kc">false</span><span class="p">,</span>
+ <span class="nx">paused</span> <span class="o">=</span> <span class="kc">false</span><span class="p">,</span>
+ <span class="nx">linereader</span><span class="p">;</span></pre></div> </td> </tr> <tr id="section-3"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-3">&#182;</a> </div> <h3>function start ()</h3>
+
+<p>Starts the prompt by opening stdin and
+creating an interface for the <code>readline</code> module.</p> </td> <td class="code"> <div class="highlight"><pre><span class="nx">prompt</span><span class="p">.</span><span class="nx">start</span> <span class="o">=</span> <span class="kd">function</span> <span class="p">()</span> <span class="p">{</span>
+ <span class="k">if</span> <span class="p">(</span><span class="nx">started</span><span class="p">)</span> <span class="p">{</span>
+ <span class="k">return</span><span class="p">;</span>
+ <span class="p">}</span>
+
+ <span class="nx">process</span><span class="p">.</span><span class="nx">openStdin</span><span class="p">();</span>
+ <span class="nx">linereader</span> <span class="o">=</span> <span class="nx">readline</span><span class="p">.</span><span class="nx">createInterface</span><span class="p">(</span><span class="nx">process</span><span class="p">.</span><span class="nx">stdin</span><span class="p">,</span> <span class="nx">process</span><span class="p">.</span><span class="nx">stdout</span><span class="p">);</span>
+ <span class="nx">started</span> <span class="o">=</span> <span class="kc">true</span><span class="p">;</span>
+
+ <span class="k">return</span> <span class="nx">prompt</span><span class="p">;</span>
+<span class="p">};</span></pre></div> </td> </tr> <tr id="section-4"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-4">&#182;</a> </div> <h3>function pause ()</h3>
+
+<p>Pauses input coming in from stdin</p> </td> <td class="code"> <div class="highlight"><pre><span class="nx">prompt</span><span class="p">.</span><span class="nx">pause</span> <span class="o">=</span> <span class="kd">function</span> <span class="p">()</span> <span class="p">{</span>
+ <span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">started</span> <span class="o">||</span> <span class="nx">paused</span><span class="p">)</span> <span class="p">{</span>
+ <span class="k">return</span><span class="p">;</span>
+ <span class="p">}</span>
+
+ <span class="nx">process</span><span class="p">.</span><span class="nx">stdin</span><span class="p">.</span><span class="nx">pause</span><span class="p">();</span>
+ <span class="nx">paused</span> <span class="o">=</span> <span class="kc">true</span><span class="p">;</span>
+ <span class="k">return</span> <span class="nx">prompt</span><span class="p">;</span>
+<span class="p">};</span></pre></div> </td> </tr> <tr id="section-5"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-5">&#182;</a> </div> <h3>function resume ()</h3>
+
+<p>Resumes input coming in from stdin </p> </td> <td class="code"> <div class="highlight"><pre><span class="nx">prompt</span><span class="p">.</span><span class="nx">resume</span> <span class="o">=</span> <span class="kd">function</span> <span class="p">()</span> <span class="p">{</span>
+ <span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">started</span> <span class="o">||</span> <span class="o">!</span><span class="nx">paused</span><span class="p">)</span> <span class="p">{</span>
+ <span class="k">return</span><span class="p">;</span>
+ <span class="p">}</span>
+
+ <span class="nx">process</span><span class="p">.</span><span class="nx">stdin</span><span class="p">.</span><span class="nx">resume</span><span class="p">();</span>
+ <span class="nx">paused</span> <span class="o">=</span> <span class="kc">false</span><span class="p">;</span>
+ <span class="k">return</span> <span class="nx">prompt</span><span class="p">;</span>
+<span class="p">};</span></pre></div> </td> </tr> <tr id="section-6"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-6">&#182;</a> </div> <h3>function get (msg, [validator,] callback)</h3>
+
+<h4>@msg {Array|string} Set of variables to get input for.</h4>
+
+<h4>@validator {function} Validation function to check input received against.</h4>
+
+<h4>@callback {function} Continuation to pass control to when complete.</h4>
+
+<p>Gets input from the user via stdin for the specified message(s) <code>msg</code>.</p> </td> <td class="code"> <div class="highlight"><pre><span class="nx">prompt</span><span class="p">.</span><span class="nx">get</span> <span class="o">=</span> <span class="kd">function</span> <span class="p">(</span><span class="cm">/* msg, [validator,] callback */</span><span class="p">)</span> <span class="p">{</span>
+ <span class="kd">var</span> <span class="nx">args</span> <span class="o">=</span> <span class="nb">Array</span><span class="p">.</span><span class="nx">prototype</span><span class="p">.</span><span class="nx">slice</span><span class="p">.</span><span class="nx">call</span><span class="p">(</span><span class="nx">arguments</span><span class="p">),</span>
+ <span class="nx">msg</span> <span class="o">=</span> <span class="nx">args</span><span class="p">.</span><span class="nx">shift</span><span class="p">(),</span>
+ <span class="nx">callback</span> <span class="o">=</span> <span class="nx">args</span><span class="p">.</span><span class="nx">pop</span><span class="p">(),</span>
+ <span class="nx">validator</span> <span class="o">=</span> <span class="nx">args</span><span class="p">.</span><span class="nx">length</span> <span class="o">&gt;</span> <span class="mi">0</span> <span class="o">&amp;&amp;</span> <span class="nx">args</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span>
+ <span class="nx">vars</span> <span class="o">=</span> <span class="k">typeof</span> <span class="nx">msg</span> <span class="o">===</span> <span class="s1">&#39;string&#39;</span> <span class="o">?</span> <span class="p">[</span><span class="nx">msg</span><span class="p">]</span> <span class="o">:</span> <span class="nx">msg</span><span class="p">,</span>
+ <span class="nx">result</span> <span class="o">=</span> <span class="p">{};</span>
+
+ <span class="nx">vars</span> <span class="o">=</span> <span class="nx">vars</span><span class="p">.</span><span class="nx">map</span><span class="p">(</span><span class="kd">function</span> <span class="p">(</span><span class="nx">s</span><span class="p">)</span> <span class="p">{</span>
+ <span class="k">return</span> <span class="nx">s</span><span class="p">.</span><span class="nx">toLowerCase</span><span class="p">();</span>
+ <span class="p">});</span>
+
+ <span class="kd">function</span> <span class="nx">get</span><span class="p">(</span><span class="nx">promptMsg</span><span class="p">,</span> <span class="nx">next</span><span class="p">)</span> <span class="p">{</span>
+ <span class="nx">prompt</span><span class="p">.</span><span class="nx">getInput</span><span class="p">(</span><span class="nx">capitalize</span><span class="p">(</span><span class="nx">promptMsg</span><span class="p">),</span> <span class="nx">validator</span><span class="p">,</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">line</span><span class="p">)</span> <span class="p">{</span>
+ <span class="nx">result</span><span class="p">[</span><span class="nx">promptMsg</span><span class="p">]</span> <span class="o">=</span> <span class="nx">line</span><span class="p">;</span>
+ <span class="nx">next</span><span class="p">();</span>
+ <span class="p">});</span>
+ <span class="p">}</span>
+
+ <span class="nx">async</span><span class="p">.</span><span class="nx">forEachSeries</span><span class="p">(</span><span class="nx">vars</span><span class="p">,</span> <span class="nx">get</span><span class="p">,</span> <span class="kd">function</span> <span class="p">()</span> <span class="p">{</span>
+ <span class="nx">callback</span><span class="p">(</span><span class="nx">result</span><span class="p">);</span>
+ <span class="p">});</span>
+<span class="p">};</span></pre></div> </td> </tr> <tr id="section-7"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-7">&#182;</a> </div> <h3>function getInput (msg, validator, callback)</h3>
+
+<h4>@msg {string} Variables to get input for.</h4>
+
+<h4>@validator {function} Validation function to check input received against.</h4>
+
+<h4>@callback {function} Continuation to pass control to when complete.</h4>
+
+<p>Gets input from the user via stdin for the specified message <code>msg</code>.</p> </td> <td class="code"> <div class="highlight"><pre><span class="nx">prompt</span><span class="p">.</span><span class="nx">getInput</span> <span class="o">=</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">msg</span><span class="p">,</span> <span class="nx">validator</span><span class="p">,</span> <span class="nx">callback</span><span class="p">)</span> <span class="p">{</span>
+ <span class="kd">var</span> <span class="nx">raw</span> <span class="o">=</span> <span class="p">[</span><span class="s1">&#39;prompt&#39;</span><span class="p">,</span> <span class="s1">&#39;: &#39;</span> <span class="o">+</span> <span class="nx">msg</span> <span class="o">+</span> <span class="s1">&#39;: &#39;</span><span class="p">],</span>
+ <span class="nx">length</span> <span class="o">=</span> <span class="nx">raw</span><span class="p">.</span><span class="nx">join</span><span class="p">(</span><span class="s1">&#39;&#39;</span><span class="p">).</span><span class="nx">length</span><span class="p">,</span>
+ <span class="nx">promptMsg</span><span class="p">;</span>
+ </pre></div> </td> </tr> <tr id="section-8"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-8">&#182;</a> </div> <p>Colorize the prompt now that we have the raw length</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nx">raw</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">=</span> <span class="nx">raw</span><span class="p">[</span><span class="mi">0</span><span class="p">].</span><span class="nx">magenta</span><span class="p">;</span>
+ <span class="nx">promptMsg</span> <span class="o">=</span> <span class="nx">raw</span><span class="p">.</span><span class="nx">join</span><span class="p">(</span><span class="s1">&#39;&#39;</span><span class="p">);</span>
+
+ <span class="nx">linereader</span><span class="p">.</span><span class="nx">once</span><span class="p">(</span><span class="s1">&#39;line&#39;</span><span class="p">,</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">line</span><span class="p">)</span> <span class="p">{</span></pre></div> </td> </tr> <tr id="section-9"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-9">&#182;</a> </div> <p>TODO (indexzero): Validate this result</p> </td> <td class="code"> <div class="highlight"><pre>
+ <span class="nx">prompt</span><span class="p">.</span><span class="nx">pause</span><span class="p">();</span>
+ <span class="nx">winston</span><span class="p">.</span><span class="nx">input</span><span class="p">(</span><span class="nx">line</span><span class="p">.</span><span class="nx">yellow</span><span class="p">);</span>
+ <span class="nx">callback</span><span class="p">(</span><span class="nx">line</span><span class="p">);</span>
+ <span class="p">});</span>
+
+ <span class="nx">linereader</span><span class="p">.</span><span class="nx">setPrompt</span><span class="p">(</span><span class="nx">promptMsg</span><span class="p">,</span> <span class="nx">length</span><span class="p">);</span>
+ <span class="nx">linereader</span><span class="p">.</span><span class="nx">prompt</span><span class="p">();</span>
+ <span class="nx">prompt</span><span class="p">.</span><span class="nx">resume</span><span class="p">();</span>
+ <span class="k">return</span> <span class="nx">prompt</span><span class="p">;</span>
+<span class="p">};</span>
+
+</pre></div> </td> </tr> </tbody> </table> </div> </body> </html>
View
29 docs/jitsu/users.html
@@ -0,0 +1,29 @@
+<!DOCTYPE html> <html> <head> <title>users.js</title> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <link rel="stylesheet" media="all" href="../docco.css" /> </head> <body> <div id="container"> <div id="background"></div> <div id="jump_to"> Jump To &hellip; <div id="jump_wrapper"> <div id="jump_page"> <a class="source" href="..//jitsu/apps.html"> jitsu/apps.html </a> <a class="source" href="..//jitsu/client.html"> jitsu/client.html </a> <a class="source" href="..//jitsu/commands/apps.html"> jitsu/commands/apps.html </a> <a class="source" href="..//jitsu/commands/config.html"> jitsu/commands/config.html </a> <a class="source" href="..//jitsu/commands.html"> jitsu/commands.html </a> <a class="source" href="..//jitsu/config.html"> jitsu/config.html </a> <a class="source" href="..//jitsu/log.html"> jitsu/log.html </a> <a class="source" href="..//jitsu/prompt.html"> jitsu/prompt.html </a> <a class="source" href="..//jitsu/users.html"> jitsu/users.html </a> <a class="source" href="..//jitsu/utils/base64.html"> jitsu/utils/base64.html </a> <a class="source" href="..//jitsu/utils/index.html"> jitsu/utils/index.html </a> <a class="source" href="..//jitsu.html"> jitsu.html </a> </div> </div> </div> <table cellpadding="0" cellspacing="0"> <thead> <tr> <th class="docs"> <h1> users.js </h1> </th> <th class="code"> </th> </tr> </thead> <tbody> <tr id="section-1"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-1">&#182;</a> </div> </td> <td class="code"> <div class="highlight"><pre><span class="cm">/*</span>
+<span class="cm"> * users.js: Client for the Nodejitsu users API.</span>
+<span class="cm"> *</span>
+<span class="cm"> * (C) 2010, Nodejitsu Inc.</span>
+<span class="cm"> *</span>
+<span class="cm"> */</span>
+
+<span class="kd">var</span> <span class="nx">util</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="s1">&#39;util&#39;</span><span class="p">),</span>
+ <span class="nx">winston</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="s1">&#39;winston&#39;</span><span class="p">),</span>
+ <span class="nx">jitsu</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="s1">&#39;jitsu&#39;</span><span class="p">);</span>
+ </pre></div> </td> </tr> <tr id="section-2"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-2">&#182;</a> </div> <h3>function Users (options)</h3>
+
+<h4>@options {Object} Options for this instance</h4>
+
+<p>Constructor function for the Users resource responsible
+with Nodejitsu's Users API</p> </td> <td class="code"> <div class="highlight"><pre><span class="kd">var</span> <span class="nx">Users</span> <span class="o">=</span> <span class="nx">exports</span><span class="p">.</span><span class="nx">Users</span> <span class="o">=</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">options</span><span class="p">)</span> <span class="p">{</span>
+ <span class="nx">jitsu</span><span class="p">.</span><span class="nx">Client</span><span class="p">.</span><span class="nx">call</span><span class="p">(</span><span class="k">this</span><span class="p">,</span> <span class="nx">options</span><span class="p">);</span>
+<span class="p">};</span></pre></div> </td> </tr> <tr id="section-3"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-3">&#182;</a> </div> <p>Inherit from Client base object</p> </td> <td class="code"> <div class="highlight"><pre><span class="nx">util</span><span class="p">.</span><span class="nx">inherits</span><span class="p">(</span><span class="nx">Users</span><span class="p">,</span> <span class="nx">jitsu</span><span class="p">.</span><span class="nx">Client</span><span class="p">);</span></pre></div> </td> </tr> <tr id="section-4"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-4">&#182;</a> </div> <h3>function auth (callback)</h3>
+
+<h4>@callback {function} Continuation to pass control to when complete</h4>
+
+<p>Tests the authentication of the user identified in this process.</p> </td> <td class="code"> <div class="highlight"><pre><span class="nx">Users</span><span class="p">.</span><span class="nx">prototype</span><span class="p">.</span><span class="nx">auth</span> <span class="o">=</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">callback</span><span class="p">)</span> <span class="p">{</span>
+ <span class="nx">winston</span><span class="p">.</span><span class="nx">info</span><span class="p">(</span><span class="s1">&#39;Attempting to authenticate as &#39;</span> <span class="o">+</span> <span class="nx">jitsu</span><span class="p">.</span><span class="nx">config</span><span class="p">.</span><span class="nx">settings</span><span class="p">.</span><span class="nx">auth</span><span class="p">.</span><span class="nx">split</span><span class="p">(</span><span class="s1">&#39;:&#39;</span><span class="p">)[</span><span class="mi">0</span><span class="p">].</span><span class="nx">magenta</span><span class="p">);</span>
+ <span class="k">this</span><span class="p">.</span><span class="nx">_request</span><span class="p">(</span><span class="s1">&#39;GET&#39;</span><span class="p">,</span> <span class="p">[</span><span class="s1">&#39;auth&#39;</span><span class="p">],</span> <span class="nx">callback</span><span class="p">,</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">res</span><span class="p">,</span> <span class="nx">body</span><span class="p">)</span> <span class="p">{</span>
+ <span class="nx">callback</span><span class="p">(</span><span class="kc">null</span><span class="p">,</span> <span class="kc">true</span><span class="p">);</span>
+ <span class="p">});</span>
+<span class="p">};</span>
+
+</pre></div> </td> </tr> </tbody> </table> </div> </body> </html>
View
22 docs/jitsu/utils/base64.html
@@ -0,0 +1,22 @@
+<!DOCTYPE html> <html> <head> <title>base64.js</title> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <link rel="stylesheet" media="all" href="../../docco.css" /> </head> <body> <div id="container"> <div id="background"></div> <div id="jump_to"> Jump To &hellip; <div id="jump_wrapper"> <div id="jump_page"> <a class="source" href="../..//jitsu/apps.html"> jitsu/apps.html </a> <a class="source" href="../..//jitsu/client.html"> jitsu/client.html </a> <a class="source" href="../..//jitsu/commands/apps.html"> jitsu/commands/apps.html </a> <a class="source" href="../..//jitsu/commands/config.html"> jitsu/commands/config.html </a> <a class="source" href="../..//jitsu/commands.html"> jitsu/commands.html </a> <a class="source" href="../..//jitsu/config.html"> jitsu/config.html </a> <a class="source" href="../..//jitsu/log.html"> jitsu/log.html </a> <a class="source" href="../..//jitsu/prompt.html"> jitsu/prompt.html </a> <a class="source" href="../..//jitsu/users.html"> jitsu/users.html </a> <a class="source" href="../..//jitsu/utils/base64.html"> jitsu/utils/base64.html </a> <a class="source" href="../..//jitsu/utils/index.html"> jitsu/utils/index.html </a> <a class="source" href="../..//jitsu.html"> jitsu.html </a> </div> </div> </div> <table cellpadding="0" cellspacing="0"> <thead> <tr> <th class="docs"> <h1> base64.js </h1> </th> <th class="code"> </th> </tr> </thead> <tbody> <tr id="section-1"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-1">&#182;</a> </div> </td> <td class="code"> <div class="highlight"><pre><span class="cm">/*</span>
+<span class="cm"> * base64.js: An extremely simple implementation of base64 encoding / decoding using node.js Buffers</span>
+<span class="cm"> *</span>
+<span class="cm"> * (C) 2010, Nodejitsu Inc.</span>
+<span class="cm"> *</span>
+<span class="cm"> */</span>
+
+<span class="kd">var</span> <span class="nx">base64</span> <span class="o">=</span> <span class="nx">exports</span><span class="p">;</span></pre></div> </td> </tr> <tr id="section-2"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-2">&#182;</a> </div> <h3>function encode (unencoded)</h3>
+
+<h4>@unencoded {string} The string to base64 encode</h4>
+
+<p>Encodes the specified string to base64 using node.js Buffers.</p> </td> <td class="code"> <div class="highlight"><pre><span class="nx">base64</span><span class="p">.</span><span class="nx">encode</span> <span class="o">=</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">unencoded</span><span class="p">)</span> <span class="p">{</span>
+ <span class="k">return</span> <span class="k">new</span> <span class="nx">Buffer</span><span class="p">(</span><span class="nx">unencoded</span> <span class="o">||</span> <span class="s1">&#39;&#39;</span><span class="p">).</span><span class="nx">toString</span><span class="p">(</span><span class="s1">&#39;base64&#39;</span><span class="p">);</span>
+<span class="p">};</span></pre></div> </td> </tr> <tr id="section-3"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-3">&#182;</a> </div> <h3>function decode (encoded)</h3>
+
+<h4>@encoded {string} The string to base64 decode</h4>
+
+<p>Decodes the specified string from base64 using node.js Buffers.</p> </td> <td class="code"> <div class="highlight"><pre><span class="nx">base64</span><span class="p">.</span><span class="nx">decode</span> <span class="o">=</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">encoded</span><span class="p">)</span> <span class="p">{</span>
+ <span class="k">return</span> <span class="k">new</span> <span class="nx">Buffer</span><span class="p">(</span><span class="nx">encoded</span> <span class="o">||</span> <span class="s1">&#39;&#39;</span><span class="p">,</span> <span class="s1">&#39;base64&#39;</span><span class="p">).</span><span class="nx">toString</span><span class="p">(</span><span class="s1">&#39;utf8&#39;</span><span class="p">);</span>
+<span class="p">};</span>
+
+</pre></div> </td> </tr> </tbody> </table> </div> </body> </html>
View
12 docs/jitsu/utils/index.html
@@ -0,0 +1,12 @@
+<!DOCTYPE html> <html> <head> <title>index.js</title> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <link rel="stylesheet" media="all" href="../../docco.css" /> </head> <body> <div id="container"> <div id="background"></div> <div id="jump_to"> Jump To &hellip; <div id="jump_wrapper"> <div id="jump_page"> <a class="source" href="../..//jitsu/apps.html"> jitsu/apps.html </a> <a class="source" href="../..//jitsu/client.html"> jitsu/client.html </a> <a class="source" href="../..//jitsu/commands/apps.html"> jitsu/commands/apps.html </a> <a class="source" href="../..//jitsu/commands/config.html"> jitsu/commands/config.html </a> <a class="source" href="../..//jitsu/commands.html"> jitsu/commands.html </a> <a class="source" href="../..//jitsu/config.html"> jitsu/config.html </a> <a class="source" href="../..//jitsu/log.html"> jitsu/log.html </a> <a class="source" href="../..//jitsu/prompt.html"> jitsu/prompt.html </a> <a class="source" href="../..//jitsu/users.html"> jitsu/users.html </a> <a class="source" href="../..//jitsu/utils/base64.html"> jitsu/utils/base64.html </a> <a class="source" href="../..//jitsu/utils/index.html"> jitsu/utils/index.html </a> <a class="source" href="../..//jitsu.html"> jitsu.html </a> </div> </div> </div> <table cellpadding="0" cellspacing="0"> <thead> <tr> <th class="docs"> <h1> index.js </h1> </th> <th class="code"> </th> </tr> </thead> <tbody> <tr id="section-1"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-1">&#182;</a> </div> </td> <td class="code"> <div class="highlight"><pre><span class="cm">/*</span>
+<span class="cm"> * index.js: Top-level include for the utils module.</span>
+<span class="cm"> *</span>
+<span class="cm"> * (C) 2010, Nodejitsu Inc.</span>
+<span class="cm"> *</span>
+<span class="cm"> */</span>
+
+<span class="kd">var</span> <span class="nx">utils</span> <span class="o">=</span> <span class="nx">exports</span><span class="p">;</span>
+
+<span class="nx">utils</span><span class="p">.</span><span class="nx">base64</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="s1">&#39;./base64&#39;</span><span class="p">);</span>
+
+</pre></div> </td> </tr> </tbody> </table> </div> </body> </html>
View
69 lib/jitsu.js
@@ -12,6 +12,7 @@ var eyes = require('eyes'),
colors = require('colors');
var jitsu = exports,
+ auth = false,
started = false;
// Failure HTTP Response codes based
@@ -30,12 +31,13 @@ var successCodes = jitsu.successCodes = {
201: "Created"
};
-jitsu.utils = require('jitsu/utils');
-jitsu.Client = require('jitsu/client').Client;
-jitsu.Apps = require('jitsu/apps').Apps;
-jitsu.Users = require('jitsu/users').Users;
-jitsu.prompt = require('jitsu/prompt');
-jitsu.config = require('jitsu/config');
+jitsu.utils = require('jitsu/utils');
+jitsu.Client = require('jitsu/client').Client;
+jitsu.Apps = require('jitsu/apps').Apps;
+jitsu.Users = require('jitsu/users').Users;
+jitsu.prompt = require('jitsu/prompt');
+jitsu.config = require('jitsu/config');
+jitsu.commands = require('jitsu/commands');
//
</