UNPKG

netlify

Version:
164 lines (155 loc) 6.18 kB
<!DOCTYPE html> <html> <head> <meta name="viewport" content="width=device-width" charset="utf-8"> <title>Netlify Node</title> <link rel="stylesheet" href="css/bootstrap.min.css"> <link rel="stylesheet" href="css/cayman.min.css"> <link rel="stylesheet" href="css/prism.min.css"> <link rel="stylesheet" href="css/index.min.css"> <link rel="stylesheet" href="css/docs.min.css"> <link rel="stylesheet" href="css/bootstrap-responsive.min.css"> </head> <body data-spy="scroll" data-target=".scrollspy"> <div class="navbar navbar-inverse navbar-fixed-top"> <div class="navbar-inner"> <div class="container"><a class="brand">Mr. Doc</a> <div class="nav-collapse collapse"> <ul class="nav pull-right sponsored"></ul> </div> </div> </div> </div> <header id="overview" class="jumbotron subhead"> <div class="container"> <h1>Netlify Node</h1> <p class="lead"></p> </div> </header> <div class="container"> <div class="row"> <div class="span3 bs-docs-sidebar"> <ul class="nav nav-list bs-docs-sidenav affix-top"> <li><a href="index.html">Main</a></li> <li><a href="access-token.js.html">access-token.js</a></li> <li><a href="client.js.html">client.js</a></li> <li class="active"><a href="deploy.js.html">deploy.js</a></li> <li><a href="deploy_key.js.html">deploy_key.js</a></li> <li><a href="dns-record.js.html">dns-record.js</a></li> <li><a href="dns-zone.js.html">dns-zone.js</a></li> <li><a href="file.js.html">file.js</a></li> <li><a href="form.js.html">form.js</a></li> <li><a href="model.js.html">model.js</a></li> <li><a href="netlify.js.html">netlify.js</a></li> <li><a href="site.js.html">site.js</a></li> <li><a href="snippet.js.html">snippet.js</a></li> <li><a href="submission.js.html">submission.js</a></li> <li><a href="ticket.js.html">ticket.js</a></li> <li><a href="user.js.html">user.js</a></li> </ul> <div class="scrollspy"> <ul class="nav nav-list bs-docs-sidenav affix-top"> <li><a href="#model"><i class="alert alert-success"></i><span>model</span></a> </li> </ul> </div> </div> <div class="span9"> <section id="model"> <h1>model</h1> <h5 class="subheader"></h5> <p> <div class="label label-success radius ctx-type">declaration</div><span>&nbsp;</span><span>model</span><span>&nbsp;</span> </p> </section> <div class="description"></div> <pre><code class="language-javascript">var model = require(&quot;./model&quot;); if (typeof(require) !== 'undefined') { var fs = require(&quot;graceful-fs&quot;); } var Deploy = model.constructor(); Deploy.path = &quot;/deploys&quot;; Deploy.prototype = { isReady: function() { return this.state == &quot;ready&quot; || this.state == &quot;current&quot;; }, restore: function(cb) { var self = this; this.client.request({ url: &quot;/sites/&quot; + this.site_id + &quot;/deploys/&quot; + this.id + &quot;/restore&quot;, type: &quot;post&quot; }, function(err, data, client) { if (err) return cb(err); Deploy.call(self, client, data); cb(null, self); }); }, publish: function(cb) { this.restore(cb); }, waitForReady: function(cb) { var self = this; if (this.isReady()) { process.nextTick(function() { cb(null, self); }); } else { setTimeout(function() { self.refresh(function(err) { if (err) return cb(err); self.waitForReady(cb); }); }, 1000); } }, uploadFiles: function(files, cb) { if (this.state !== &quot;uploading&quot;) return cb(null, this); if (files.length == 0) { return this.refresh(cb); } var self = this, cbCalled = false, uploaded = []; files.forEach(function(file) { fs.readFile(file.abs, function(err, data) { if (cbCalled) return null; if (err) { cbCalled = true; return cb(err); } var filePath = file.rel.split(&quot;/&quot;).map(function(segment) { return encodeURIComponent(segment); }).join(&quot;/&quot;); self.client.request({ url: &quot;/deploys/&quot; + self.id + &quot;/files/&quot; + filePath, type: &quot;put&quot;, body: data, contentType: &quot;application/octet-stream&quot;, ignoreResponse: true }, function(err) { if (cbCalled) return null; if (err) { cbCalled = true; return cb(err); } uploaded.push(file); if (uploaded.length == files.length) { self.refresh(cb); } }); }); }); } }; exports.Deploy = Deploy;</code></pre> </div> </div> </div> <footer class="footer"> <div class="container"> <p>Documentation generated with <a href="https://github.com/mr-doc/mr-doc">Mr. Doc </a> created by <a href="https://twitter.com/FGRibreau" data-show-count="false" class="twitter-follow-button">Francois-Guillaume Ribreau </a></p> <p>Mr. Doc is sponsored by <a href="http://bringr.net/?btt" title="Outil d'analyse des réseaux sociaux" class="bringr">Bringr </a> and <a href="https://redsmin.com/?btt" title="Full Redis GUI" class="redsmin">Redsmin</a></p> <p>Theme borrowed from Twitter Bootstrap</p> </div> </footer> <script src="js/twitter-widget.min.js"></script> <script src="js/jquery.min.js"></script> <script src="js/bootstrap-transition.min.js"></script> <script src="js/bootstrap-scrollspy.min.js"></script> <script src="js/bootstrap-dropdown.min.js"></script> <script src="js/bootstrap-collapse.min.js"></script> <script src="js/bootstrap-affix.min.js"></script> <script src="js/prism.min.js"></script> <script src="js/index.min.js"></script> </body> </html>