repo_dependency_graph 0.0.1 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 01e2c01278bbf6e49d232e3ba2565cb1fb94664b
4
- data.tar.gz: f4f43571cda21bb4c0c5847e15627181bb9d0219
3
+ metadata.gz: 30f8ee043be9fed10a15b604a369e494dc4a740e
4
+ data.tar.gz: f66647427820e295656b41930024a4f994165d9d
5
5
  SHA512:
6
- metadata.gz: 288ea662bb0f323273b8175c6df68c21b564ff5beb9a68f2cf4f14bb7d5e7926844c4b604fb8fb6fa08f6b8dd19fba27ef4a4f894f2964bf8885254bfef14307
7
- data.tar.gz: e9bf2f56c5e91c58c0a48bc4da35dbe0c0678842105026b607ac9e7fa877a4b0feeca948c901a284bab1329354d7a65006546d7ea3f7849f60d99b727532bbe6
6
+ metadata.gz: c17277cff804fd4db0932de66a85da4e6732aa47b9843b29bfe4b951b8ac9fb27c3c73e5966d1d3d302fea57d69333d0d6cda42032dd3b67bfc1688b31b890a2
7
+ data.tar.gz: 16243ed26be4070a0ddd2e54806e075cbd3d145d180feed641e1ee98da01601a56dd5e1cb65c2824fb9bb230a01d6097211ce81a2a5d4f868fb34e91b83fbd6c
checksums.yaml.gz.sig CHANGED
Binary file
@@ -25,6 +25,15 @@ BANNER
25
25
  opts.on("--token TOKEN", "Use token") { |token| options[:token] = token }
26
26
  opts.on("--user USER", "Use user") { |user| options[:user] = user }
27
27
  opts.on("--organization ORGANIZATION", "Use user") { |organization| options[:organization] = organization }
28
+ opts.on("--private", "Only show private repos") { options[:private] = true }
29
+ opts.on("--external", "Also include external projects in graph (can get super-messy)") { options[:external] = true }
30
+ opts.on("--map SEARCH=REPLACE", "Replace in project name to find them as internal: 'foo=bar' -> replace foo in repo names to bar") do |map|
31
+ options[:map] = map.split("=")
32
+ options[:map][0] = Regexp.new(options[:map][0])
33
+ end
34
+ opts.on("--chef", "Parse chef metadata.rb files") { options[:chef] = true }
35
+ opts.on("--select REGEX", "Only include repos with matching names") { |regex| options[:select] = Regexp.new(regex) }
36
+ opts.on("--reject REGEX", "Exclude repos with matching names") { |regex| options[:reject] = Regexp.new(regex) }
28
37
  opts.on("-h", "--help", "Show this.") { puts opts; exit }
29
38
  opts.on("-v", "--version", "Show Version"){ puts RepoDependencyGraph::VERSION; exit}
30
39
  end.parse!
@@ -1,3 +1,3 @@
1
1
  module RepoDependencyGraph
2
- VERSION = "0.0.1"
2
+ VERSION = "0.1.0"
3
3
  end
@@ -5,11 +5,7 @@ require "bundler" # get all dependency for lockfile_parser
5
5
  module RepoDependencyGraph
6
6
  class << self
7
7
  def run(options)
8
- dependencies = dependencies(options)
9
- dependencies.map do |project, dependencies|
10
- puts "#{project}: #{dependencies.join(",")}"
11
- end
12
- draw(dependencies)
8
+ draw(dependencies(options))
13
9
  0
14
10
  end
15
11
 
@@ -33,11 +29,19 @@ module RepoDependencyGraph
33
29
  end
34
30
 
35
31
  def dependencies(options)
36
- all = Bundler::OrganizationAudit::Repo.all(options).select(&:private?).sort_by(&:project)
32
+ raise ArgumentError, "Map only makes sense when searching for internal repos" if options[:map] && options[:external]
33
+
34
+ all = Bundler::OrganizationAudit::Repo.all(options).sort_by(&:project)
35
+ all.select!(&:private?) if options[:private]
36
+ all.select! { |r| r.project =~ options[:select] } if options[:select]
37
+ all.reject! { |r| r.project =~ options[:reject] } if options[:reject]
38
+
37
39
  possible = all.map(&:project)
40
+ possible.map! { |p| p.sub(options[:map][0], options[:map][1].to_s) } if options[:map]
41
+
38
42
  dependencies = all.map do |repo|
39
- found = dependent_gems(repo) || []
40
- found = found & possible
43
+ found = dependent_repos(repo, options) || []
44
+ found = found & possible unless options[:external]
41
45
  next if found.empty?
42
46
  puts "#{repo.project}: #{found.join(", ")}"
43
47
  [repo.project, found]
@@ -45,13 +49,19 @@ module RepoDependencyGraph
45
49
  Hash[dependencies]
46
50
  end
47
51
 
48
- def dependent_gems(repo)
49
- if repo.gem?
50
- load_spec(repo.gemspec_content).runtime_dependencies.map(&:name)
51
- elsif content = repo.content("Gemfile.lock")
52
- Bundler::LockfileParser.new(content).specs.map(&:name)
53
- elsif content = repo.content("Gemfile")
54
- content.scan(/gem ['"](.*?)['"]/).flatten
52
+ def dependent_repos(repo, options)
53
+ if options[:chef]
54
+ if content = repo.content("metadata.rb")
55
+ content.scan(/^\s*depends ['"](.*?)['"]/).flatten
56
+ end
57
+ else
58
+ if repo.gem?
59
+ load_spec(repo.gemspec_content).runtime_dependencies.map(&:name)
60
+ elsif content = repo.content("Gemfile.lock")
61
+ Bundler::LockfileParser.new(content).specs.map(&:name)
62
+ elsif content = repo.content("Gemfile")
63
+ content.scan(/^\s*gem ['"](.*?)['"]/).flatten
64
+ end
55
65
  end
56
66
  end
57
67
 
@@ -60,7 +70,7 @@ module RepoDependencyGraph
60
70
  gsub(/^\s*require .*$/, "").
61
71
  gsub(/([a-z\d]+::)+version/i, '"1.2.3"').
62
72
  gsub(/^\s*\$(:|LOAD_PATH).*/, "").
63
- gsub(/File\.read\(.*?\)/, '"1.2.3"')
73
+ gsub(/(File|IO)\.read\(.*?\)/, '"1.2.3"')
64
74
  end
65
75
  end
66
76
  end
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: repo_dependency_graph
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Grosser
metadata.gz.sig CHANGED
Binary file