organization_license_audit 1.0.1 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/lib/organization_license_audit.rb +57 -16
- data/lib/organization_license_audit/version.rb +1 -1
- metadata +2 -2
- 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: 6376a3b06af0b760663b6b6f4d9dda4f920a6eb3
|
4
|
+
data.tar.gz: 205d9543e0f636ef1992dfdc68b10d8596b2d347
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a5ea40e035be68c4c306376628768ffcf0417396ab4e30349253958713120f8b364f9c0eac72f2a84090988722df8355da7b385d0bca8f8125833da40ab8d7bd
|
7
|
+
data.tar.gz: 270c40199f52268faa665637bab3f08e16a54bb4f73eb8d469a507726fad20b087df626ffdc12d548429c8a0e7503ddbc81c246646bcefacc56cc598babdbd88
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
@@ -77,27 +77,22 @@ module OrganizationLicenseAudit
|
|
77
77
|
end
|
78
78
|
|
79
79
|
def find_bad(options)
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
80
|
+
Dir.mktmpdir do |bundle_cache_dir|
|
81
|
+
OrganizationAudit.all(options).map do |repo|
|
82
|
+
next if options[:ignore_gems] and repo.gem?
|
83
|
+
success, output = audit_repo(repo, bundle_cache_dir, options)
|
84
|
+
$stderr.puts ""
|
85
|
+
[repo, output] unless success
|
86
|
+
end.compact
|
87
|
+
end
|
86
88
|
end
|
87
89
|
|
88
|
-
def audit_repo(repo, options)
|
90
|
+
def audit_repo(repo, bundle_cache_dir, options)
|
89
91
|
$stderr.puts repo.name
|
90
92
|
in_temp_dir do
|
91
93
|
raise "Clone failed" unless sh("git clone #{repo.clone_url} --depth 1 --quiet").first
|
92
94
|
Dir.chdir repo.name do
|
93
|
-
with_clean_env
|
94
|
-
bundled = File.exist?("Gemfile")
|
95
|
-
raise "Failed to bundle" if bundled && !sh("bundle --path #{BUNDLE_PATH} --quiet").first
|
96
|
-
options[:whitelist].each do |license|
|
97
|
-
raise "failed to approve #{license}" unless system("license_finder whitelist add '#{license}' >/dev/null")
|
98
|
-
end
|
99
|
-
sh("#{combined_gem_path if bundled}license_finder --quiet")
|
100
|
-
end
|
95
|
+
with_clean_env { audit_project(bundle_cache_dir, options) }
|
101
96
|
end
|
102
97
|
end
|
103
98
|
rescue Exception => e
|
@@ -106,7 +101,53 @@ module OrganizationLicenseAudit
|
|
106
101
|
true
|
107
102
|
end
|
108
103
|
|
109
|
-
|
104
|
+
def audit_project(bundle_cache_dir, options)
|
105
|
+
bundled = prepare_bundler bundle_cache_dir
|
106
|
+
prepare_npm
|
107
|
+
whitelist_licences options[:whitelist]
|
108
|
+
|
109
|
+
sh("#{combined_gem_path if bundled}license_finder --quiet")
|
110
|
+
end
|
111
|
+
|
112
|
+
def whitelist_licences(licenses)
|
113
|
+
licenses.each do |license|
|
114
|
+
unless system("license_finder whitelist add '#{license}' >/dev/null")
|
115
|
+
raise "failed to approve #{license}"
|
116
|
+
end
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
def prepare_bundler(bundle_cache_dir)
|
121
|
+
if File.exist?("Gemfile")
|
122
|
+
use_cache_dir_to_bundle(bundle_cache_dir)
|
123
|
+
raise "Failed to bundle" unless sh("bundle --path #{BUNDLE_PATH} --quiet").first
|
124
|
+
true
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
128
|
+
def prepare_npm
|
129
|
+
if File.exist?("package.json")
|
130
|
+
sh "npm install --quiet"
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
134
|
+
def use_cache_dir_to_bundle(cache_dir)
|
135
|
+
cache_dir = File.join(cache_dir, ruby_cache)
|
136
|
+
FileUtils.mkdir_p cache_dir
|
137
|
+
FileUtils.mkdir_p File.dirname(BUNDLE_PATH)
|
138
|
+
FileUtils.symlink cache_dir, BUNDLE_PATH
|
139
|
+
end
|
140
|
+
|
141
|
+
# use one directory per ruby-version (not the same for jruby or different patch releases)
|
142
|
+
def ruby_cache
|
143
|
+
ruby_version = [".ruby-version", ".rvmrc"].detect { |f| File.exist?(f) }
|
144
|
+
ruby_version = File.read(ruby_version) if ruby_version
|
145
|
+
ruby_version ||= "default"
|
146
|
+
ruby_version.gsub!(/[^a-z\d\.]/, "_") # .rvmrc might include weirdness...
|
147
|
+
ruby_version
|
148
|
+
end
|
149
|
+
|
150
|
+
# license_finder needs to find all gems in the target repo, which fails if their path is not in the GEM_PATH
|
110
151
|
# so we have to add the gems in vendor/bundle to the gems currently available from this bundle
|
111
152
|
def combined_gem_path
|
112
153
|
"GEM_PATH=#{`gem env path`.strip}:#{BUNDLE_PATH}/ruby/* "
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: organization_license_audit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Grosser
|
@@ -29,7 +29,7 @@ cert_chain:
|
|
29
29
|
y0kCSWmK6D+x/SbfS6r7Ke07MRqziJdB9GuE1+0cIRuFh8EQ+LN6HXCKM5pon/GU
|
30
30
|
ycwMXfl0
|
31
31
|
-----END CERTIFICATE-----
|
32
|
-
date: 2013-12-
|
32
|
+
date: 2013-12-23 00:00:00.000000000 Z
|
33
33
|
dependencies:
|
34
34
|
- !ruby/object:Gem::Dependency
|
35
35
|
name: organization_audit
|
metadata.gz.sig
CHANGED
Binary file
|