Skip to content

Commit 48e1d16

Browse files
committed
Add Rake task to run bundle update in examples
Introduces a new Rake task `examples:bundle_update` that iterates through all example folders, running `bundle update` in each one that contains a Gemfile. The task reports success or failure for each folder and exits with an error if any updates fail.
1 parent b3487c6 commit 48e1d16

File tree

1 file changed

+54
-0
lines changed

1 file changed

+54
-0
lines changed

Rakefile

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,4 +148,58 @@ namespace :examples do
148148
exit 1
149149
end
150150
end
151+
152+
desc 'Run bundle update on all example folders'
153+
task :bundle_update do
154+
examples_dir = File.join(Dir.pwd, 'examples')
155+
156+
unless Dir.exist?(examples_dir)
157+
puts 'Examples directory not found'
158+
exit 1
159+
end
160+
161+
example_folders = Dir.glob(File.join(examples_dir, '*')).select { |path| Dir.exist?(path) }
162+
163+
if example_folders.empty?
164+
puts 'No example folders found'
165+
return
166+
end
167+
168+
puts "Found #{example_folders.length} example folders:"
169+
example_folders.each { |folder| puts " - #{File.basename(folder)}" }
170+
puts
171+
172+
failed_folders = []
173+
174+
example_folders.each do |folder|
175+
gemfile_path = File.join(folder, 'Gemfile')
176+
177+
unless File.exist?(gemfile_path)
178+
puts "Skipping #{File.basename(folder)} - no Gemfile found"
179+
next
180+
end
181+
182+
puts "Running bundle update in #{File.basename(folder)}..."
183+
184+
Dir.chdir(folder) do
185+
system('bundle update')
186+
187+
if $CHILD_STATUS.success?
188+
puts " ✓ Successfully updated gems in #{File.basename(folder)}"
189+
else
190+
failed_folders << File.basename(folder)
191+
puts " ✗ Failed to bundle update in #{File.basename(folder)}"
192+
end
193+
end
194+
195+
puts
196+
end
197+
198+
if failed_folders.empty?
199+
puts 'All example folders processed successfully!'
200+
else
201+
puts "Failed to process #{failed_folders.length} folders: #{failed_folders.join(", ")}"
202+
exit 1
203+
end
204+
end
151205
end

0 commit comments

Comments
 (0)