rdeis 0.0.4 → 0.0.8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3e431193be3f11c8a16ec86a1c8dca819c4d40c3
4
- data.tar.gz: 60b56e68e24f58cc963c7500a60f0ce3105d4b04
3
+ metadata.gz: 1df42fa5b070732b2b16e19b57508360a42c282e
4
+ data.tar.gz: 2361bb85b58778e8a68c325968c49b11d02ca5ee
5
5
  SHA512:
6
- metadata.gz: 11efa491d12bc6415c807e337dce9a71cc4a51bf4d82913cf92bcb4f1ee4b0d35cec2baa438b359e5434517c13d4343634ae6ea405c25ca524469ffc789deb27
7
- data.tar.gz: e1caf1870d1b832662fe507322e477844311e6d4197fa844a157b7c26bf1c022921df7cf740db426e28238fcbc347e6357c558a3ead0e10473711453f6391971
6
+ metadata.gz: 8bfaf8f5454b2499175d8336fd2fa1a6d3c20bbab7ba421feeb442b2cefdd254f8290f710007d3a0ea4274fb20fad3cfa24c58f67e92337d3d3dc0d95f18ddd6
7
+ data.tar.gz: 5609ff5c1e12fb08d3931e45a9c0395e920c9e2b083af77ff460817a7fccf6b83b28ea1e15e384d3d88314ff1698dd526b2651de22685a88d77e45418a917148
data/gemconversion CHANGED
@@ -23,9 +23,9 @@ if File.exists?(file)
23
23
  commit = `git commit Gemfile Gemfile.lock -m '[rdeis] Automated Gemfile conversion - #{Time.now.to_s}' 2>&1 | grep 'Error' | wc -l`.to_i if install == 1 && status > 0
24
24
 
25
25
  if status == 0
26
- $stdout.puts "Already converted & commited"
26
+ $stdout.puts "Converted and commited already"
27
27
  elsif install == 1 && commit == 0
28
- $stdout.puts "Converted & commited"
28
+ $stdout.puts "Converted and commited"
29
29
  else
30
30
  abort("Error: install / commit failed (#{install}/#{commit})")
31
31
  end
data/lib/rdeis/base.rb CHANGED
@@ -19,5 +19,22 @@ module DEIS
19
19
  end
20
20
  end
21
21
 
22
+ def local_shell
23
+ `echo $SHELL | sed -E "s#/bin/##"`.strip
24
+ end
25
+
26
+ def local_profile
27
+ "#{ENV['HOME']}/.profile"
28
+ end
29
+
30
+ def remote_profile
31
+ "$HOME/.profile"
32
+ end
33
+
34
+ def local_shell_env_include(profile, file_to_include)
35
+ content = File.open(profile, "r"){ |f| f.read }.gsub(". #{file_to_include}", "") + "\n. #{file_to_include}"
36
+ File.open(profile, "w") { |f| f.write(content) }
37
+ end
38
+
22
39
  end
23
40
  end
@@ -45,7 +45,7 @@ module DEIS
45
45
 
46
46
  # add a hush login file so we dont get the MOTD ouput in our shell commands
47
47
  def hush
48
- if yes? ("Does the deploy location run a Message of the Day? ")
48
+ if yes?("Does the deploy location run a Message of the Day? ", :yellow)
49
49
  run("if [[ ! -f $HOME/.hushlogin ]]; then > $HOME/.hushlogin ; fi ")
50
50
  end
51
51
  end
@@ -80,16 +80,15 @@ module DEIS
80
80
  # run remote, keep the $HOME notation as we want that evaluated in the cmd
81
81
  run("mkdir -p #{DEIS::Storage::BASE_PATH} ; echo -e '#{out}' > #{file}") if ! @proxy.nil?
82
82
  # remove any existing references from the various shell options on the local machine
83
- shell=`echo $SHELL | sed -E "s#/bin/##"`.strip
84
- profile = ["#{ENV['HOME']}/.#{shell}rc", "#{ENV['HOME']}/.#{shell}_profile", "#{ENV['HOME']}/.profile"].select{|f| File.exists?(f)}.first
83
+ shell = self.local_shell
84
+ profile = self.local_profile
85
85
  if ! profile.nil?
86
- content = File.open(profile, "r"){ |f| f.read }.gsub(". #{file}", "") + "\n. #{file}"
87
- File.open(profile, "w") { |f| f.write(content) }
86
+ self.local_shell_env_include(profile, file)
88
87
  else
89
88
  say "Could not save environment setup", :red
90
89
  end
91
90
  # add include to the remote profile
92
- run("echo -e '. #{file}\n' >> ~/.profile") if ! @proxy.nil?
91
+ run("echo -e '. #{file}\n' >> #{self.remote_profile}") if ! @proxy.nil?
93
92
  end
94
93
 
95
94
  end
data/lib/rdeis/deis.rb CHANGED
@@ -154,6 +154,7 @@ module DEIS
154
154
 
155
155
  desc "bootstrap <type>", "first run install setup funcs"
156
156
  def bootstrap(action="all")
157
+ self.updgrade
157
158
  if DEIS::Bootstrap.method_defined? action
158
159
  bootstrap = DEIS::Bootstrap.new(options)
159
160
  bootstrap.send(action)
@@ -162,6 +163,11 @@ module DEIS
162
163
  end
163
164
  end
164
165
 
166
+ desc "updgrade", "See if older version exists we can copy over"
167
+ def updgrade
168
+ run = DEIS::Upgrade.new(options)
169
+ run.all
170
+ end
165
171
 
166
172
  end
167
173
  end
data/lib/rdeis/deploy.rb CHANGED
@@ -133,7 +133,7 @@ module DEIS
133
133
  output[" init and remote"] = DEIS::Deploy::YES
134
134
  end
135
135
  # checkout to the correct branch from the remote
136
- checkout = run ("cd #{@deploy_to} && #{DEIS::Git.checkout_to_ref_cmd('origin/'+@ref)}")
136
+ checkout = run ("cd #{@deploy_to} && #{DEIS::Git.checkout_to_ref_cmd('origin/'+@ref, @branch)}")
137
137
  output[" checkout to #{@ref[0..8]}"] = if checkout then DEIS::Deploy::YES else DEIS::Deploy::NO end
138
138
  print_table output
139
139
  end
@@ -160,12 +160,18 @@ module DEIS
160
160
  def push
161
161
  output = {"PUSH" => ""}
162
162
  # make sure the profile is loaded, cd to the right place & run the converstion script.
163
- conversion = run(". $HOME/.profile && cd #{@deploy_to} && ./gemconversion | grep Error | wc -l").to_i
164
- output[" Gem conversion"] = if conversion == 0 then DEIS::Deploy::YES else DEIS::Deploy::NO end
163
+ conversion = run(". #{self.remote_profile} && cd #{@deploy_to} && ./gemconversion | grep 'Converted and commited' | wc -l").to_i
164
+ output[" Gem conversion"] = if conversion == 1 then DEIS::Deploy::YES else DEIS::Deploy::NO end
165
165
  # push the branch to deis
166
- deis = run("cd #{@deploy_to} && git push deis #{@branch} | grep Error | wc -l") if conversion == 0
166
+ remote_ref = run("cd #{@deploy_to} && #{DEIS::Git.ref_cmd}")
167
+ deis = run("cd #{@deploy_to} && git push deis #{@branch}:#{remote_ref} | grep Error | wc -l") if conversion == 1
167
168
  output[" Deis push"] = if deis.to_i == 0 then DEIS::Deploy::YES else DEIS::Deploy::NO end
168
169
  print_table output
170
+ if conversion != 1
171
+ say "Gem conversion & commit failed.", :red
172
+ say "This could be due to environment settings being missing; please make sure ruby is installed and env set in .profile", :red
173
+ exit
174
+ end
169
175
  end
170
176
 
171
177
  def scale(vars)
data/lib/rdeis/git.rb CHANGED
@@ -24,7 +24,11 @@ module DEIS
24
24
  end
25
25
 
26
26
  def self.ref
27
- `git rev-parse --verify HEAD 2>/dev/null`.strip
27
+ `#{DEIS::Git.ref_cmd}`.strip
28
+ end
29
+
30
+ def self.ref_cmd
31
+ "git rev-parse --verify HEAD 2>/dev/null"
28
32
  end
29
33
 
30
34
  def self.branch
@@ -35,8 +39,8 @@ module DEIS
35
39
  "git init && git remote add origin #{remote} 2>&1 | grep 'fatal:' -o | wc -l"
36
40
  end
37
41
 
38
- def self.checkout_to_ref_cmd(ref)
39
- "git fetch origin && git checkout -f #{ref} 2>&1 | grep 'error:' | wc -l"
42
+ def self.checkout_to_ref_cmd(ref, branch)
43
+ "git fetch origin && git checkout -f #{branch} && git checkout -f #{ref} 2>&1 | grep 'error:' | wc -l"
40
44
  end
41
45
 
42
46
  # find env based token
@@ -0,0 +1,46 @@
1
+ module DEIS
2
+ class Upgrade < Base
3
+ include Thor::Shell
4
+
5
+ attr_accessor :proxy, :token, :ssh, :deploy_to
6
+
7
+ def initialize(options)
8
+ @repo = DEIS::Git.name
9
+ @verbose = options[:verbose]
10
+ @environment = options[:environment]
11
+ @proxy = if ! options["proxy"].nil? then options["proxy"] elsif ! ENV['RDEIS_PROXY'].nil? then ENV['RDEIS_PROXY'] else nil end
12
+ @ssh = SSH.new({:host => @proxy, :user => nil}) if ! @proxy.nil?
13
+ end
14
+
15
+
16
+
17
+ def all
18
+ # check for current version
19
+ previous_version = DEIS::Storage::BASE_PATH.gsub(DEIS::VERSION, DEIS::LAST_VERSION)
20
+ local_prev = previous_version.gsub("$HOME", ENV['HOME'])
21
+ current_version = DEIS::Storage::BASE_PATH
22
+ local_curr = current_version.gsub("$HOME", ENV['HOME'])
23
+ # local
24
+ # if no found, look for previous version
25
+ if ! File.directory?(local_curr) && File.directory?(local_prev)
26
+ say("Found previous version config files locally, migrating..", :green)
27
+ `mv -f #{local_prev} #{local_curr}`
28
+ # find local profile
29
+ content = File.open(self.local_profile, "r"){|f| f.read }
30
+ File.open(self.local_profile, "w"){|f| f.write(content.gsub(previous_version, current_version)) }
31
+ end
32
+ # remote
33
+ remote_current = run("ls -lart #{current_version} | wc -l").to_i
34
+ remote_previous = run("ls -lart #{previous_version} | wc -l").to_i
35
+ if remote_current == 0 && remote_previous > 1
36
+ say("Found previous remote version, migration..", :green)
37
+ run("mv -f #{previous_version} #{current_version}")
38
+ # replace profile
39
+ run("cat #{self.remote_profile} | sed -E 's##{previous_version.gsub("$", "\\\$")}##{current_version.gsub("$", "\\\$")}#' > #{self.remote_profile}.new && mv #{self.remote_profile} #{self.remote_profile}.bk && mv #{self.remote_profile}.new #{self.remote_profile}")
40
+ end
41
+ end
42
+
43
+
44
+
45
+ end
46
+ end
data/lib/rdeis/version.rb CHANGED
@@ -1,3 +1,4 @@
1
1
  module DEIS
2
- VERSION='0.0.4'
2
+ VERSION='0.0.8'
3
+ LAST_VERSION='0.0.4'
3
4
  end
data/lib/rdeis.rb CHANGED
@@ -8,6 +8,7 @@ module DEIS
8
8
  require "rdeis/parse"
9
9
  require "rdeis/storage"
10
10
  require "rdeis/bootstrap"
11
+ require "rdeis/upgrade"
11
12
  require "rdeis/config"
12
13
  require "rdeis/domains"
13
14
  require "rdeis/deploy"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rdeis
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Charles Marshall
@@ -75,10 +75,11 @@ files:
75
75
  - lib/rdeis/git.rb
76
76
  - lib/rdeis/parse.rb
77
77
  - lib/rdeis/storage.rb
78
+ - lib/rdeis/upgrade.rb
78
79
  - lib/rdeis/version.rb
79
80
  - lib/ssh.rb
80
81
  - rdeis.gemspec
81
- homepage: https://github.com/charlesmarshall/deis_deploy/tree/0.0.4
82
+ homepage: https://github.com/charlesmarshall/deis_deploy/tree/0.0.8
82
83
  licenses:
83
84
  - MIT
84
85
  metadata: {}