closeheat
Version:
Static Website Hosting with CMS without touching your code.
67 lines (53 loc) • 1.76 kB
text/coffeescript
Promise = require 'bluebird'
_ = require 'lodash'
Git = require 'git-wrapper'
Log = require './log'
Color = require './color'
Authorized = require './authorized'
Urls = require './urls'
BackendLogger = require './backend_logger'
Website = require './website'
module.exports =
class DeployLog
constructor: ->
= new BackendLogger()
= new Git()
fromCurrentCommit: ->
new Promise (resolve, reject) =>
().then =>
Log.br()
resolve()
pollAndLogUntilDeployed: ->
new Promise (resolve, reject) =>
= 'none'
Log.br()
(
(=> !_.contains(['success', 'failed', null], )),
(=> ())
).then(resolve)
requestAndLogStatus: =>
Website.get().then (website) =>
(website)
().then (sha) =>
Authorized.post(Urls.buildForCLI(website.slug), commit_sha: sha).then (resp) =>
build = resp.build
.log(build)
= build.status
handleNonExistingWebsite: (website) ->
return if website.exists
Log.p "You don't have a published website connected to this folder."
Log.p "Write #{Color.violet('closeheat publish')} to publish it first."
process.exit()
getSha: ->
new Promise (resolve, reject) =>
.exec 'rev-parse', ['HEAD'], (err, resp) ->
return reject(err) if err
resolve(resp.trim())
promiseWhile: (condition, action) ->
new Promise (resolve, reject) ->
repeat = ->
if !condition()
return resolve()
Promise.cast(action()).then(->
_.delay(repeat, 1000)).catch(reject)
process.nextTick repeat