Created
January 5, 2019 22:36
-
-
Save sheerun/7af754ab0e73b0b05deaf435abe392a3 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
require 'open-uri' | |
require 'json' | |
require 'parallel' | |
packages = File.read('01.most-dependent-upon.md').scan(/\[([\w-]+)\]/m).to_a.map(&:first) | |
Parallel.each(packages) do |package| | |
begin | |
parsed = JSON.parse(open('https://registry.npmjs.org/' + package).read) | |
url = URI.parse(parsed['repository']['url']) | |
if url.host == 'github.com' | |
path = url.path.gsub(/.git$/, '') | |
manifest = 'https://raw.githubusercontent.com'+path+'/master/package.json' | |
puts manifest | |
File.write('packages/' + package + '.json', open(manifest).read) | |
end | |
rescue | |
puts "FAILED" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment