Skip to content
This repository has been archived by the owner on Nov 19, 2024. It is now read-only.

Commit

Permalink
Improve 'rake whatsnew' (#8018)
Browse files Browse the repository at this point in the history
  • Loading branch information
dshevtsov authored Oct 12, 2020
1 parent f91d6cd commit 8f25793
Show file tree
Hide file tree
Showing 2 changed files with 278 additions and 2,811 deletions.
30 changes: 23 additions & 7 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -69,15 +69,31 @@ task check: %w[check:image_optim check:mdl]

desc 'Generate data for a news digest. Default timeframe is a week since today. For other period, use "since" argument: since="jul 4"'
task :whatsnew do
date = ENV['since']
print 'Generating data for the weekly digest: $ '.magenta
if date.nil? || date.empty?
sh 'bin/whatsup_github'
elsif date.is_a? String
sh 'bin/whatsup_github', 'since', ENV['since'].to_s
since = ENV['since']
current_file = 'src/_data/whats-new.yml'
generated_file = 'tmp/whats-new.yml'
current_data = YAML.load_file current_file
last_update = current_data['updated']

print 'Generating data for the What\'s New digest: $ '.magenta

# Generate tmp/whats-new.yml
if since.nil? || since.empty?
sh 'bin/whatsup_github', 'since', last_update
elsif since.is_a? String
sh 'bin/whatsup_github', 'since', since
else
puts 'The "since" argument must be a string. Example: "jul 4"'
abort 'The "since" argument must be a string. Example: "jul 4"'
end

# Merge generated tmp/whats-new.yml with existing src/_data/whats-new.yml
generated_data = YAML.load_file generated_file
current_data['updated'] = generated_data['updated']
current_data['entries'].prepend(generated_data['entries']).flatten!
current_data['entries'].uniq! { |entry| entry['link'] }

puts "Writing updates to #{current_file}"
File.write current_file, current_data.to_yaml
end

desc 'Generate index for Algolia'
Expand Down
Loading

0 comments on commit 8f25793

Please sign in to comment.