Permalink
Browse files

Added ability to redeploy apps

  • Loading branch information...
1 parent 84d2765 commit 05b9257468da0f661417f599663d69a0eaea88a4 @Echo3ToEcho7 committed Apr 3, 2012
Showing with 42 additions and 4 deletions.
  1. +41 −3 lib/deploy.iced
  2. +1 −1 package.json
View
@@ -1,5 +1,6 @@
request = require 'request'
jsdom = require 'jsdom'
+fs = require 'fs'
class Deploy
constructor: (@username, @password, @server) ->
@@ -26,6 +27,8 @@ class Deploy
await request options, defer error, results, body
#console.log "Error", error
+
+ #fs.writeFileSync "#{process.cwd()}/_test.html", body
#console.log "Results", results
#console.log "Body", body
@@ -34,7 +37,44 @@ class Deploy
callback(oidElt?[0]?.value)
- updatePage: (oid, content) ->
+ updatePage: (oid, cpoid, content, callback) ->
+ callback ?= () ->
+ await @_login defer err, res, b
+
+ options =
+ url: "https://#{@server}/slm/wt/edit.sp?cpoid=#{cpoid}&oid=#{oid}"
+ method: 'GET'
+ followAllRedirects: true
+
+ await request options, defer error, results, body
+
+ await jsdom.env body, defer errors, window
+ #fs.writeFileSync "#{process.cwd()}/_test.html", body
+ version = (window.document.getElementsByName 'version')?[0]?.value
+
+ console.log "Version", version
+
+ options =
+ url: "https://#{@server}/slm/wt/edit/update.sp?cpoid=#{cpoid}&oid=#{oid}"
+ method: 'POST'
+ followAllRedirects: true
+ form:
+ html: content
+ type: 'HTML'
+# pid: tab or 'myhome'
+ editorMode: 'edit'
+ cpoid: cpoid
+ typechange: false
+ version: parseInt(version, 10)
+ #jar: @cookieJar
+
+ await request options, defer error, results, body
+ #fs.writeFileSync "#{process.cwd()}/_test2.html", body
+
+ await jsdom.env body, defer errors, window
+ oidElt = window.document.getElementsByName 'oid'
+
+ callback(oidElt?[0]?.value)
_login: (callback) ->
callback ?= () ->
@@ -46,8 +86,6 @@ class Deploy
form:
j_username: @username
j_password: @password
- #body: "j_username=#{@username}&j_password=#{@password}"
- #jar: @cookieJar
await request options, defer err, res, body
#console.log "Error", err
View
@@ -2,7 +2,7 @@
"author": "Colin O'Brien <cobrien@rallydev.com>",
"name": "rabt",
"description": "Rally App Building Toolkit",
- "version": "0.0.1",
+ "version": "0.0.2",
"homepage": "https://github.com/Echo3ToEcho7/Rabt",
"repository": {
"type": "git",

0 comments on commit 05b9257

Please sign in to comment.