Created
May 6, 2020 13:02
-
-
Save hkdsun/17198aef6c700a450824e0adcd17eb13 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'yaml' | |
def get_inward_dependencies_from(filename, pkg) | |
shitlist = YAML.load_file(filename) | |
shitlist[pkg] | |
end | |
def save_to_file(pkg, aggregate) | |
message = <<~MESSAGE | |
# Auto-generated by: #{__FILE__} | |
# | |
# This file contains an aggregated list of dependencies that are not part of the long term plan for #{pkg} | |
# | |
# This defers from the usual deprecated_references.yml file in that it includes both: | |
# | |
# 1) outward dependencies (constants not part of #{pkg}'s dependencies being called from inside #{pkg}) | |
# 2) inward dependencies (constants outside #{pkg} referencing a constant inside #{pkg} | |
# | |
# This file does NOT get updated by linters. You must run the following command at the root of your project | |
# in order to update it: | |
# | |
# aggregate_shitlists #{pkg} | |
# | |
MESSAGE | |
File.open("#{pkg}_aggregate_deprecated_references.yml", "w") do |f| | |
f.write(message) | |
f.write(aggregate.to_yaml) | |
end | |
end | |
def run(args) | |
pkg = args.shift | |
root_path = args.shift || "." | |
aggregate = [] | |
outward_deprecations_file = Dir["#{root_path}/**/#{pkg}/deprecated_references.yml"] | |
raise unless outward_deprecations_file.size == 1 | |
puts "Finding deprecated outward dependencies..." | |
file = outward_deprecations_file.first | |
shitlist = YAML.load_file(file) | |
aggregate << { file => shitlist } | |
puts "Finding deprecated inward dependencies..." | |
inward_deprecations_files = Dir["#{root_path}/**/deprecated_references.yml"] | |
inward_deprecations_files.each do |file| | |
shitlist = get_inward_dependencies_from(file, pkg) | |
aggregate << { file => shitlist } if shitlist | |
end | |
save_to_file(pkg, aggregate) | |
end | |
run(ARGV) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment