repo_dependency_graph 0.0.1 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/bin/repo-dependency-graph +9 -0
- data/lib/repo_dependency_graph/version.rb +1 -1
- data/lib/repo_dependency_graph.rb +26 -16
- data.tar.gz.sig +0 -0
- metadata +1 -1
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 30f8ee043be9fed10a15b604a369e494dc4a740e
|
4
|
+
data.tar.gz: f66647427820e295656b41930024a4f994165d9d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c17277cff804fd4db0932de66a85da4e6732aa47b9843b29bfe4b951b8ac9fb27c3c73e5966d1d3d302fea57d69333d0d6cda42032dd3b67bfc1688b31b890a2
|
7
|
+
data.tar.gz: 16243ed26be4070a0ddd2e54806e075cbd3d145d180feed641e1ee98da01601a56dd5e1cb65c2824fb9bb230a01d6097211ce81a2a5d4f868fb34e91b83fbd6c
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/bin/repo-dependency-graph
CHANGED
@@ -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!
|
@@ -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
|
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
|
-
|
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 =
|
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
|
49
|
-
if
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
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
metadata.gz.sig
CHANGED
Binary file
|