licensed 0.11.1 → 1.0.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.
Files changed (47) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +13 -4
  3. data/.rubocop.yml +3 -0
  4. data/.ruby-version +1 -0
  5. data/CHANGELOG.md +13 -0
  6. data/CODE_OF_CONDUCT.md +14 -12
  7. data/CONTRIBUTING.md +51 -0
  8. data/Gemfile +2 -1
  9. data/{LICENSE.txt → LICENSE} +1 -1
  10. data/README.md +55 -76
  11. data/Rakefile +3 -2
  12. data/docs/configuration.md +131 -0
  13. data/docs/sources/bower.md +5 -0
  14. data/docs/sources/bundler.md +7 -0
  15. data/docs/sources/cabal.md +39 -0
  16. data/docs/sources/go.md +12 -0
  17. data/docs/sources/manifests.md +26 -0
  18. data/docs/sources/npm.md +3 -0
  19. data/docs/sources/stack.md +3 -0
  20. data/exe/licensed +1 -0
  21. data/lib/licensed.rb +9 -5
  22. data/lib/licensed/cli.rb +22 -14
  23. data/lib/licensed/command/cache.rb +46 -29
  24. data/lib/licensed/command/list.rb +17 -9
  25. data/lib/licensed/command/status.rb +78 -0
  26. data/lib/licensed/configuration.rb +127 -25
  27. data/lib/licensed/dependency.rb +8 -2
  28. data/lib/licensed/git.rb +39 -0
  29. data/lib/licensed/license.rb +1 -0
  30. data/lib/licensed/shell.rb +28 -0
  31. data/lib/licensed/source/bower.rb +4 -0
  32. data/lib/licensed/source/bundler.rb +4 -0
  33. data/lib/licensed/source/cabal.rb +72 -24
  34. data/lib/licensed/source/go.rb +23 -36
  35. data/lib/licensed/source/manifest.rb +26 -23
  36. data/lib/licensed/source/npm.rb +19 -8
  37. data/lib/licensed/ui/shell.rb +2 -1
  38. data/lib/licensed/version.rb +2 -1
  39. data/licensed.gemspec +9 -5
  40. data/{bin/setup → script/bootstrap} +13 -8
  41. data/script/cibuild +7 -0
  42. data/{bin → script}/console +1 -0
  43. metadata +53 -158
  44. data/.bowerrc +0 -3
  45. data/exe/licensor +0 -5
  46. data/lib/licensed/command/verify.rb +0 -73
  47. data/lib/licensed/source/stack.rb +0 -66
data/.bowerrc DELETED
@@ -1,3 +0,0 @@
1
- {
2
- "cwd": "test/fixtures"
3
- }
@@ -1,5 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- warn "The `licensor` command has been renamed to `licensed` and is deprecated."
4
-
5
- load File.expand_path("../licensed", __FILE__)
@@ -1,73 +0,0 @@
1
- require 'yaml'
2
-
3
- module Licensed
4
- module Command
5
- class Verify
6
- attr_reader :config
7
-
8
- def initialize(config)
9
- @config = config
10
- end
11
-
12
- def approved?(dependency)
13
- @config.whitelisted?(dependency) || @config.reviewed?(dependency)
14
- end
15
-
16
- def dependencies
17
- @dependencies ||= @config.sources
18
- .map(&:dependencies)
19
- .flatten
20
- .select { |d| !@config.ignored?(d) }
21
- end
22
-
23
- def run
24
- @config.ui.info "Verifying licenses for #{dependencies.size} dependencies"
25
-
26
- @results = dependencies.map do |dependency|
27
- filename = @config.path.join("#{dependency["type"]}/#{dependency["name"]}.txt")
28
-
29
- warnings = []
30
-
31
- if File.exists?(filename)
32
- license = License.read(filename)
33
-
34
- if license["version"] != dependency["version"]
35
- warnings << "cached license data out of date"
36
- end
37
- warnings << "missing license text" if license.text.strip.empty?
38
- unless approved?(license)
39
- warnings << "license needs reviewed: #{license["license"]}."
40
- end
41
- else
42
- warnings << "missing license data"
43
- end
44
-
45
- if warnings.size > 0
46
- @config.ui.error("F", false)
47
- [filename, warnings]
48
- else
49
- @config.ui.confirm(".", false)
50
- nil
51
- end
52
- end.compact
53
-
54
- unless success?
55
- @config.ui.warn "\n\nWarnings:"
56
-
57
- @results.each do |filename, warnings|
58
- @config.ui.info "\n#{filename}:"
59
- warnings.each do |warning|
60
- @config.ui.error " - #{warning}"
61
- end
62
- end
63
- end
64
-
65
- puts "\n#{dependencies.size} dependencies checked, #{@results.size} warnings found."
66
- end
67
-
68
- def success?
69
- @results.empty?
70
- end
71
- end
72
- end
73
- end
@@ -1,66 +0,0 @@
1
- module Licensed
2
- module Source
3
- class Stack
4
- def initialize(config)
5
- @config = config
6
- end
7
-
8
- def type
9
- "stack"
10
- end
11
-
12
- def enabled?
13
- @config.enabled?(type) && File.exist?(@config.pwd.join("stack.yaml"))
14
- end
15
-
16
- def dependencies
17
- @dependencies ||= packages.map do |(name, version)|
18
- package_id = "#{name}-#{version}"
19
- package = package_info package_id
20
-
21
- if package.empty?
22
- next if @config.ignored?('type' => type, 'name' => name)
23
- raise "couldn't locate #{package_id} with ghc-pkg"
24
- end
25
-
26
- path = package["haddock-html"] || File.join(@config.pwd, "vendor", name)
27
- Dependency.new(path, {
28
- "type" => type,
29
- "name" => package["name"] || name,
30
- "version" => package["version"] || version,
31
- "summary" => package["synopsis"],
32
- "homepage" => safe_homepage(package["homepage"])
33
- })
34
- end.compact
35
- end
36
-
37
- def safe_homepage(homepage)
38
- return unless homepage
39
- # use https and remove url fragment
40
- homepage.gsub(/http:/, "https:")
41
- .gsub(/#[^?]*\z/, "")
42
- end
43
-
44
- def packages
45
- list_packages_command.lines.map(&:split)
46
- end
47
-
48
- def list_packages_command
49
- `stack list-dependencies --no-include-base`
50
- end
51
-
52
- def package_info(package_id)
53
- package_info_command(package_id).lines.each_with_object({}) do |line, info|
54
- key, value = line.split(':', 2).map(&:strip)
55
- next unless key && value
56
-
57
- info[key] = value
58
- end
59
- end
60
-
61
- def package_info_command(package_id)
62
- `stack exec -- ghc-pkg field #{package_id} name,version,synopsis,homepage,haddock-html 2>/dev/null`
63
- end
64
- end
65
- end
66
- end