dvm 0.0.2 → 0.0.4

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: a93e5adbb6cbf54f7fcebe1dfafe07ad0ffb1d6b
4
- data.tar.gz: ba33799b277afa2fa8231d190d91f8c64adf933d
3
+ metadata.gz: 71e70bdb65f78d2c520342c19dec08eef4b83b3c
4
+ data.tar.gz: 02867445b40a77984ed89dfa36e4ff79eb3afe99
5
5
  SHA512:
6
- metadata.gz: 6f19a2cfa7a33acfdb9b50d017187761286143667bf508497ec3dc822dc82862058374175a2223df6dd73f5ba5a2fc2f56cccae86a46733eedd5c119b95a937a
7
- data.tar.gz: b8be6e1fbde43cc255a861fc9dcc52f947a0b8a5a35f0201036281491b93cdd26cdfcdc91565680552750cf69db37073b623aa692ddef4196fb6e2a0724a0555
6
+ metadata.gz: 32afefa28d7fcad21a0dedae9795f840ebdfb96798eed83005ec3217838bc2635d4aeee3a954f1f5c1a7361d192f23905e3a77440a31755294673d8bf3a5592f
7
+ data.tar.gz: 0287e292392bffe58cc5d2af64eef8b28660545e01ff1890924ab9f6b02cea0c17b6c6740aaa7b122a4d71cd0fa51c91becb78a1444e20a2a330ee0cc7f8ca55
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Dvm
2
2
 
3
- TODO: Write a gem description
3
+ Distribution version manager
4
4
 
5
5
  ## Installation
6
6
 
data/Rakefile CHANGED
@@ -1,2 +1,2 @@
1
- require "bundler/gem_tasks"
1
+ require 'bundler/gem_tasks'
2
2
 
data/bin/dvm CHANGED
@@ -2,4 +2,4 @@
2
2
 
3
3
  require 'dvm'
4
4
 
5
- DVM::CLI.run(ARGV)
5
+ Dvm::CLI.run(ARGV)
data/dvm.gemspec CHANGED
@@ -5,7 +5,7 @@ require 'dvm/version'
5
5
 
6
6
  Gem::Specification.new do |spec|
7
7
  spec.name = 'dvm'
8
- spec.version = DVM::VERSION
8
+ spec.version = Dvm::VERSION
9
9
  spec.authors = ['Xingjian Xu']
10
10
  spec.email = ['dotswing@gmail.com']
11
11
  spec.summary = %q{Deploy version manager}
data/lib/dvm/cli.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  require 'fileutils'
2
+ require 'colorize'
2
3
 
3
- module DVM
4
+ module Dvm
4
5
  class CLI
5
6
 
6
7
  def initialize(root, repo)
@@ -64,7 +65,7 @@ module DVM
64
65
 
65
66
 
66
67
  def clone
67
- `git clone --bare #{@repo} #{scm}`
68
+ run_cmd "git clone --bare #{@repo} #{scm}"
68
69
  end
69
70
 
70
71
 
@@ -72,8 +73,8 @@ module DVM
72
73
  version = `cd #{scm};git rev-parse --short HEAD`.strip
73
74
  vd = release version
74
75
  FileUtils.makedirs vd
75
- `cd #{scm};git archive master | tar -x -f - -C #{vd}`
76
- `echo #{version} > #{vd}/REVISION`
76
+ run_cmd "cd #{scm};git archive master | tar -x -f - -C #{vd}"
77
+ run_cmd "echo #{version} > #{vd}/REVISION"
77
78
  new_version version
78
79
  version
79
80
  end
@@ -88,52 +89,94 @@ module DVM
88
89
 
89
90
 
90
91
  def link_current(v)
91
- `unlink #{current}` if File.directory? current
92
- `ln -s #{release(v)} #{current}`
92
+ run_cmd "unlink #{current}" if File.directory? current
93
+ run_cmd "ln -s #{release(v)} #{current}"
93
94
  end
94
95
 
95
96
 
96
97
  def link_shared
97
98
  shared_dirs.each do |e|
98
- `rm -rf #{current_path(e)};ln -s #{share_path(e)} #{File.dirname(current_path(e))}`
99
+ run_cmd "rm -rf #{current_path(e)};ln -s #{share_path(e)} #{File.dirname(current_path(e))}"
99
100
  end
100
101
 
101
102
  shared_files.each do |e|
102
- `rm -f #{current_path(e)};ln -s #{share_path(e)} #{current_path(e)}`
103
+ run_cmd "rm -f #{current_path(e)};ln -s #{share_path(e)} #{current_path(e)}"
103
104
  end
104
105
  end
105
106
 
106
107
 
108
+ def vam_install
109
+ log_action 'Vam install'
110
+ run_cmd "cd #{current};vam install" if File.exist? File.join(current, 'Vamfile')
111
+ end
112
+
113
+
114
+ def assets_precompile
115
+ log_action 'Rails assets precompile'
116
+ run_cmd "cd #{current};RAILS_ENV=production bundle exec rake assets:precompile"
117
+ end
118
+
119
+
120
+ def db_setup
121
+ log_action 'Rails db setup'
122
+ run_cmd "cd #{current};RAILS_ENV=production bundle exec rake db:setup"
123
+ end
124
+
125
+
126
+ def bundle_install
127
+ log_action 'Rails bundle install'
128
+ run_cmd "cd #{current};RAILS_ENV=production bundle install"
129
+ end
130
+
131
+
107
132
  def init_install
133
+ log_action 'Git clone'
108
134
  clone
109
135
  link_current checkout
136
+
137
+ log_action 'Copy & Link config files'
110
138
  shared_dirs.each { |e| FileUtils.makedirs share_path(e) }
111
139
  shared_files.each { |e| FileUtils.makedirs File.dirname(share_path(e)) }
112
140
  copy_config
113
141
  link_shared
114
- `cd #{current};RAILS_ENV=production bundle install`
115
- `cd #{current};vam install`
116
- `cd #{current};RAILS_ENV=production rake assets:precompile`
117
- `cd #{current};RAILS_ENV=production rake db:setup`
118
142
 
119
- puts '======= Deploy success ======'
143
+ bundle_install
144
+ vam_install
145
+ assets_precompile
146
+
147
+ puts '======= Deploy success ======'.colorize :green
120
148
  end
121
149
 
122
150
 
123
151
  def pull
124
- `cd #{scm};git pull`
152
+ run_cmd "cd #{scm};git fetch origin master:master"
125
153
  end
126
154
 
127
155
 
128
156
  def update
157
+ log_action 'Git pull'
129
158
  pull
130
159
  link_current checkout
160
+
161
+ log_action 'Link config files'
131
162
  link_shared
132
- `cd #{current};RAILS_ENV=production bundle install`
133
- `cd #{current};vam install`
134
- `cd #{current};RAILS_ENV=production rake assets:precompile`
135
163
 
136
- puts '======= Deploy success ======'
164
+ bundle_install
165
+ vam_install
166
+ assets_precompile
167
+
168
+ puts '======= Deploy success ======'.colorize :green
169
+ end
170
+
171
+
172
+ def log_action(action)
173
+ puts "\n======= #{action} =======".colorize :blue
174
+ end
175
+
176
+
177
+ def run_cmd(cmd)
178
+ puts "#RUN[ #{cmd} ]"
179
+ system cmd
137
180
  end
138
181
 
139
182
 
data/lib/dvm/version.rb CHANGED
@@ -1,3 +1,3 @@
1
- module DVM
2
- VERSION = '0.0.2'
1
+ module Dvm
2
+ VERSION = '0.0.4'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dvm
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Xingjian Xu
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-11-05 00:00:00.000000000 Z
11
+ date: 2015-03-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler