Skip to content

Commit

Permalink
update known_plugins
Browse files Browse the repository at this point in the history
and update the rake task. use RubyGems itself to fetch data from
rubygems.org, and actually filter gems by ones that have a proper
Bundler plugins.rb
  • Loading branch information
ccutrer committed Sep 13, 2023
1 parent 4799bbe commit 55e3f59
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 77 deletions.
32 changes: 30 additions & 2 deletions data/known_plugins.yml
Original file line number Diff line number Diff line change
@@ -1,21 +1,49 @@
---
- :name: bootboot
:uri: https://github.com/shopify/bootboot
- :name: bundler-as_of
:uri: https://github.com/flavorjones/bundler-as_of
- :name: bundler-changelogs
:uri: https://github.com/jdar/bundler-changelogs
- :name: bundler-audit
:uri: https://github.com/rubysec/bundler-audit
- :name: bundler-commentate
:uri: https://gitlab.com/fjc/bundler-commentate
- :name: bundler-console
:uri: https://github.com/kddnewton/bundler-console
- :name: bundler-ctags_generator
:uri: https://github.com/okuramasafumi/bundler-ctags_generator
- :name: bundler-dependency_graph
:uri: https://github.com/kerrizor/bundler-dependency_graph
- :name: bundler-download
:uri: http://github.com/AndyObtiva/bundler-download
- :name: bundler-ecology
:uri: https://github.com/eco-rb/bundler-ecology
- :name: bundler-explain
:uri: https://github.com/jhawthorn/bundler-explain
- :name: bundler-fast_git
:uri: https://github.com/mtsmfm/bundler-fast_git
- :name: bundler-graph
:uri: https://github.com/rubygems/bundler-graph
- :name: bundler-inject
:uri: https://github.com/ManageIQ/bundler-inject
- :name: bundler-install_dash_docs
:uri: https://github.com/e28eta/bundler-install_dash_docs
- :name: bundler-licensed
:uri: https://github.com/sergey-alekseev/bundler-licensed
- :name: bundler-mac
:uri: https://github.com/indirect/bundler-mac
- :name: bundler-multilock
:uri: https://github.com/instructure/bundler-multilock
- :name: bundler-override
:uri: https://github.com/tarnowsc/bundler-override
- :name: bundler-path-build-ext
:uri:
- :name: bundler-private_install
:uri: https://github.com/fphilipe/bundler-private_install
- :name: bundler-shellsplit-plugin
:uri: https://github.com/wovnio/bundler-shellsplit-plugin
- :name: bundler-source-aws-s3
:uri: https://github.com/eki/bundler-source-aws-s3
- :name: bundler-symlink
:uri: https://github.com/petekinnecom/bundler-symlink
- :name: bundler-why
:uri: https://github.com/jaredbeck/bundler-why
97 changes: 22 additions & 75 deletions lib/tasks/regenerate_known_plugins_yml.rake
Original file line number Diff line number Diff line change
@@ -1,91 +1,38 @@
desc "Recreate data/known_plugins.yml from RubyGems.org data. " \
"Look for gems with bundler- prefix names, and get their information, " \
"skipping invalid gems. Run with RUBYOPT=-W1 enabled to see diagnostic " \
"output about data not found. Uses curl, grep."
desc "Recreate data/known_plugins.yml from RubyGems.org data."
task :regenerate_known_plugins_yml do
require "json"
require "rubygems/package"
require "rubygems/remote_fetcher"
require "yaml"

names_content = `curl --silent https://index.rubygems.org/names | grep '^bundler-'`
all_plugin_names = names_content.lines.map(&:chomp)

skipped_gem_names = %w[
bundler-add functionality-exists-in-bundler-now
bundler-auto-update
bundler-bootstrap empty
bundler-budit not-authoritative
bundler-changelog empty
bundler-fastupdate
bundler-fu
bundler-gem-hg
bundler-geminabox
bundler-gem_version_tasks
bundler-github functionality-exists-in-bundler-now
bundler-bouncer
known_plugins = %w[
bootboot
]
skipped_gems = %w[
bundler-interactive source-does-not-exist yanked-all-but-last
bundler-maglev-
bundler-next
bundler-norelease
bundler-pgs
bundler-prehistoric
bundler-sass
bundler-turbo
bundler-updater
]
not_plugins = %w[
bundler-audit
bundler-audited_update
bundler-audit-ng
bundler-advise
bundler-bower
bundler-commentator
bundler-dependencies
bundler-diff
bundler-fixture
bundler-grep
bundler-gtags
bundler-leak
bundler-native-gems
bundler-organization_audit
bundler-patch
bundler-reorganizer
bundler-security
bundler-squash
bundler-stats
bundler-update_stdout
bundler-talks
bundler-unload
bundler-verbose
]
# Suspected:
# bundler-fastupdate
plugin_names = all_plugin_names - skipped_gem_names - not_plugins

# https://guides.rubygems.org/rubygems-org-api/#gem-methods
# /api/v1/gems/[GEM NAME].(json|yaml)
# Example: https://rubygems.org/api/v1/gems/rails.json
plugins = plugin_names.map do |gem_name|
json_string = `curl --silent https://rubygems.org/api/v1/gems/#{gem_name}.json`
next "<#{gem_name.inspect} is unknown by the API>" if json_string == "This rubygem could not be found."
rubygems = Gem::Source.new("https://rubygems.org")
known_plugins = rubygems.load_specs(:latest).filter_map do |name_tuple|
next unless name_tuple.name.start_with?("bundler-") ||
known_plugins.include?(name_tuple.name)
next if skipped_gems.include?(name_tuple.name)

gem_info = JSON.parse(json_string)

uri = if gem_info["homepage_uri"].to_s == ""
gem_info["project_uri"]
else
gem_info["homepage_uri"]
end
spec = rubygems.fetch_spec(name_tuple)
path = rubygems.download(spec, Gem.dir)
gem = Gem::Package.new(path)
# make sure it's actually a Bundler plugin
next unless gem.contents.include?("plugins.rb")

{
name: gem_name,
uri: uri
name: spec.name,
uri: spec.homepage
}
end
# RUBYOPT=-W1 will display this diagnostic output
warn plugins.reject { |e| e.is_a?(Hash) }.inspect

valid_plugins = plugins.select { |e| e.is_a?(Hash) }

File.write(File.expand_path("../../data/known_plugins.yml", __dir__), YAML.dump(valid_plugins))
puts "Saved #{valid_plugins.size} plugins as data/known_plugins.yml"
File.write(File.expand_path("../../data/known_plugins.yml", __dir__), YAML.dump(known_plugins))
puts "Saved #{known_plugins.size} plugins as data/known_plugins.yml"
puts "Done."
end

0 comments on commit 55e3f59

Please sign in to comment.