thor-tropo 1.2.0 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/thor-tropo/uploader.rb +1 -1
- data/lib/thor-tropo.rb +47 -33
- metadata +1 -1
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.
|
1
|
+
1.3.0
|
data/lib/thor-tropo/uploader.rb
CHANGED
@@ -78,7 +78,7 @@ module ThorTropo
|
|
78
78
|
local_file = opts[:local_file]
|
79
79
|
remote_file = opts[:remote_file]
|
80
80
|
|
81
|
-
say "[ TROPO ] - Uploading file. [#{File.basename(opts[:local_file])}", :blue
|
81
|
+
say "[ TROPO ] - Uploading file. [ #{File.basename(opts[:local_file])} ]", :blue
|
82
82
|
unless opts[:noop]
|
83
83
|
file = @bucket_name.files.create(
|
84
84
|
:key => remote_file,
|
data/lib/thor-tropo.rb
CHANGED
@@ -22,9 +22,15 @@ module ThorTropo
|
|
22
22
|
|
23
23
|
namespace "tropo"
|
24
24
|
|
25
|
+
# class_option :called_path,
|
26
|
+
# :type => :string,
|
27
|
+
# :default => Dir.pwd
|
25
28
|
class_option :called_path,
|
26
|
-
:type
|
27
|
-
:
|
29
|
+
:type => :string,
|
30
|
+
:aliases => "-d",
|
31
|
+
:default => Dir.pwd,
|
32
|
+
:desc => "Directory of your Berksfile",
|
33
|
+
:banner => "Directory of your Berksfile"
|
28
34
|
|
29
35
|
class_option :verbose,
|
30
36
|
:type => :boolean,
|
@@ -67,16 +73,10 @@ module ThorTropo
|
|
67
73
|
:desc => "Delete lockfile before running `Berks install`",
|
68
74
|
:banner => "Delete lockfile before running `Berks install`"
|
69
75
|
|
70
|
-
# def version
|
71
|
-
# OLDVERSION=`sed -n -e "s/version.*\"\(.*\)\"/\1/p" metadata.rb`
|
72
|
-
# sed -ie "s/\(version *\)\".*\"/\1\"$OLDVERSION\"/" metadata.rb
|
73
|
-
# git add metadata.rb
|
74
|
-
# end
|
75
|
-
|
76
|
-
|
77
76
|
def package
|
78
77
|
|
79
|
-
|
78
|
+
#$config = ThorTropo::Configuration.new(options[:called_path])
|
79
|
+
$config = ThorTropo::Configuration.new(source_root)
|
80
80
|
|
81
81
|
unless clean?
|
82
82
|
unless options[:ignore_dirty]
|
@@ -85,15 +85,21 @@ module ThorTropo
|
|
85
85
|
end
|
86
86
|
end
|
87
87
|
|
88
|
-
|
88
|
+
tag_version {
|
89
|
+
bundle_cookbook
|
90
|
+
upload_cookbook @packaged_cookbook, $config.project_name, {:force => options[:force],:noop => options[:noop]}
|
91
|
+
}
|
89
92
|
|
90
|
-
upload_cookbook @packaged_cookbook, $config.project_name, {:force => options[:force],:noop => options[:noop]}
|
91
|
-
# tag_version {
|
92
|
-
# publish_cookbook(options)
|
93
|
-
# }
|
94
93
|
end
|
95
94
|
|
96
95
|
|
96
|
+
|
97
|
+
# def version
|
98
|
+
# OLDVERSION=`sed -n -e "s/version.*\"\(.*\)\"/\1/p" metadata.rb`
|
99
|
+
# sed -ie "s/\(version *\)\".*\"/\1\"$OLDVERSION\"/" metadata.rb
|
100
|
+
# git add metadata.rb
|
101
|
+
# end
|
102
|
+
|
97
103
|
# desc "build", "Package cookbook"
|
98
104
|
|
99
105
|
# def build
|
@@ -118,15 +124,17 @@ module ThorTropo
|
|
118
124
|
end
|
119
125
|
|
120
126
|
def clean?
|
121
|
-
sh_with_excode("cd #{options[:called_path]}; git diff --exit-code")[1] == 0
|
127
|
+
#sh_with_excode("cd #{options[:called_path]}; git diff --exit-code")[1] == 0
|
128
|
+
sh_with_excode("cd #{source_root}; git diff --exit-code")[1] == 0
|
122
129
|
end
|
123
130
|
|
124
131
|
def clean_lockfile
|
125
|
-
berksfile = "#{options[:called_path]}/Berksfile.lock"
|
132
|
+
#berksfile = "#{options[:called_path]}/Berksfile.lock"
|
133
|
+
berksfile = "#{source_root}/Berksfile.lock"
|
126
134
|
|
127
135
|
if File.exists? berksfile
|
128
136
|
say "[ TROPO ] - Removing Berksfile.lock before running Berkshelf", :blue
|
129
|
-
remove_file
|
137
|
+
remove_file(berksfile) unless options[:noop]
|
130
138
|
else
|
131
139
|
say "[ TROPO ] - Unable to find berksfile to delete - [ #{berksfile} ]", :yellow
|
132
140
|
end
|
@@ -138,13 +146,14 @@ module ThorTropo
|
|
138
146
|
say "[ TROPO ] - Packaging cookbooks from Berksfile", :blue
|
139
147
|
@tmp_dir = Dir.mktmpdir
|
140
148
|
opts = {
|
141
|
-
berksfile: File.join(options[:called_path],"/Berksfile"),
|
149
|
+
#berksfile: File.join(options[:called_path],"/Berksfile"),
|
150
|
+
berksfile: File.join(source_root,"/Berksfile"),
|
142
151
|
path: "#{@tmp_dir}/cookbooks"
|
143
152
|
}
|
144
153
|
|
145
154
|
invoke("berkshelf:install", [], opts)
|
146
|
-
output = File.expand_path(File.join(@tmp_dir, "#{options[:called_path].split("/")[-1]}-#{current_version}.tar.gz"))
|
147
|
-
|
155
|
+
#output = File.expand_path(File.join(@tmp_dir, "#{options[:called_path].split("/")[-1]}-#{current_version}.tar.gz"))
|
156
|
+
output = File.expand_path(File.join(@tmp_dir, "#{source_root.split("/")[-1]}-#{current_version}.tar.gz"))
|
148
157
|
|
149
158
|
Dir.chdir(@tmp_dir) do |dir|
|
150
159
|
tgz = Zlib::GzipWriter.new(File.open(output, 'wb'))
|
@@ -158,25 +167,35 @@ module ThorTropo
|
|
158
167
|
if options[:"version-override"]
|
159
168
|
options[:"version-override"]
|
160
169
|
else
|
161
|
-
metadata = Ridley::Chef::Cookbook::Metadata.from_file(File.join(options[:called_path],"metadata.rb"))
|
170
|
+
#metadata = Ridley::Chef::Cookbook::Metadata.from_file(File.join(options[:called_path],"metadata.rb"))
|
171
|
+
metadata = Ridley::Chef::Cookbook::Metadata.from_file(File.join(source_root,"metadata.rb"))
|
162
172
|
metadata.version
|
163
173
|
end
|
164
174
|
end
|
165
175
|
|
166
176
|
def tag_version
|
167
|
-
sh "git tag -a -m \"Version #{current_version}\" #{current_version}"
|
168
|
-
say "Tagged: #{current_version}", :
|
177
|
+
sh "git tag -a -m \"Version #{current_version}\" #{current_version}" unless options[:noop]
|
178
|
+
say "[ TROPO ] - Tagged: #{current_version}", :blue
|
169
179
|
yield if block_given?
|
170
|
-
sh "git push --tags"
|
180
|
+
sh "git push --tags" unless options[:noop]
|
171
181
|
rescue => e
|
172
|
-
say "Untagging: #{current_version} due to error", :red
|
182
|
+
say "[ TROPO ] - Untagging: #{current_version} due to error", :red
|
173
183
|
sh_with_excode "git tag -d #{current_version}"
|
174
|
-
say e, :red
|
184
|
+
say "[ TROPO ] - #{e}", :red
|
175
185
|
exit 1
|
176
186
|
end
|
177
187
|
|
188
|
+
|
189
|
+
## Get the directory Thor script was called from
|
178
190
|
def source_root
|
179
|
-
|
191
|
+
|
192
|
+
berks_path = File.expand_path(options[:called_path])
|
193
|
+
if File.exists? berks_path
|
194
|
+
berks_path
|
195
|
+
else
|
196
|
+
raise Errno::ENOENT, "#{berks_path} does not contain a Berksfile"
|
197
|
+
end
|
198
|
+
#File.expand_path(Dir.pwd)
|
180
199
|
end
|
181
200
|
|
182
201
|
def sh(cmd, dir = source_root, &block)
|
@@ -198,11 +217,6 @@ module ThorTropo
|
|
198
217
|
[ outbuf, $? ]
|
199
218
|
end
|
200
219
|
|
201
|
-
def cleanup
|
202
|
-
FileUtils.rm_r(pkg_path, :force => true)
|
203
|
-
FileUtils.mkdir_p pkg_path
|
204
|
-
end
|
205
|
-
|
206
220
|
end
|
207
221
|
|
208
222
|
end
|