licensed 2.12.2 → 2.13.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/test.yml +1 -1
- data/CHANGELOG.md +13 -2
- data/lib/licensed/cli.rb +4 -2
- data/lib/licensed/commands/cache.rb +3 -3
- data/lib/licensed/commands/command.rb +20 -4
- data/lib/licensed/commands/environment.rb +7 -7
- data/lib/licensed/commands/list.rb +2 -2
- data/lib/licensed/commands/notices.rb +3 -3
- data/lib/licensed/commands/status.rb +2 -2
- data/lib/licensed/dependency_record.rb +4 -0
- data/lib/licensed/sources/bundler.rb +4 -3
- data/lib/licensed/sources/npm.rb +13 -1
- data/lib/licensed/version.rb +1 -1
- data/licensed.gemspec +0 -1
- metadata +2 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a4477f07cae2650a7d8679a9042f73a7d14d8de019088be22d09f30e0f8af4c2
|
4
|
+
data.tar.gz: b4cbd8769c1f98b1a0729e5d603ff08c15d2d5c5e4e8e029cd3bce7f69f395c1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 83e7612e7a1fe2dbb77d48893c68db036630a45cdbc37f38f6630be0380231d9ac7fc0d37298d3a8a349d4bd43eb1dad64b7ec26a4b8d795806fb682091d94b7
|
7
|
+
data.tar.gz: 26e4fed8cede2d4de43fc511a85a82507dcc0cbcc9a66537d39a189d533a7cfbb22fdf2be5ad242ae72f4943fde6676c23b0bdcdf906beeecef813369177c158
|
data/.github/workflows/test.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -6,6 +6,17 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
|
|
6
6
|
|
7
7
|
## [Unreleased]
|
8
8
|
|
9
|
+
## 2.13.0
|
10
|
+
2020-09-23
|
11
|
+
|
12
|
+
### Added
|
13
|
+
- `status` command results can be output in YAML and JSON formats (:tada: @julianvilas https://github.com/github/licensed/pull/303)
|
14
|
+
|
15
|
+
### Fixed
|
16
|
+
- `licensed` no longer crashes when parsing invalid YAML from cached records (https://github.com/github/licensed/pull/306)
|
17
|
+
- NPM source will no longer crash when invalid JSON is returned from npm CLI calls (https://github.com/github/licensed/pull/300)
|
18
|
+
- Bundler source is fixed to work properly with `gems.rb` lockfiles (https://github.com/github/licensed/pull/299)
|
19
|
+
|
9
20
|
## 2.12.2
|
10
21
|
2020-07-07
|
11
22
|
|
@@ -17,7 +28,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
|
|
17
28
|
2020-06-30
|
18
29
|
|
19
30
|
### Fixed
|
20
|
-
- `licensed` no longer exits an error code when using the `--sources` CLI argument(https://github.com/github/licensed/pull/290)
|
31
|
+
- `licensed` no longer exits an error code when using the `--sources` CLI argument (https://github.com/github/licensed/pull/290)
|
21
32
|
|
22
33
|
## 2.12.0
|
23
34
|
2020-06-19
|
@@ -340,4 +351,4 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
|
|
340
351
|
|
341
352
|
Initial release :tada:
|
342
353
|
|
343
|
-
[Unreleased]: https://github.com/github/licensed/compare/2.
|
354
|
+
[Unreleased]: https://github.com/github/licensed/compare/2.13.0...HEAD
|
data/lib/licensed/cli.rb
CHANGED
@@ -18,12 +18,14 @@ module Licensed
|
|
18
18
|
end
|
19
19
|
|
20
20
|
desc "status", "Check status of dependencies' cached licenses"
|
21
|
+
method_option :format, enum: ["yaml", "json"],
|
22
|
+
desc: "Output format"
|
21
23
|
method_option :config, aliases: "-c", type: :string,
|
22
24
|
desc: "Path to licensed configuration file"
|
23
25
|
method_option :sources, aliases: "-s", type: :array,
|
24
26
|
desc: "Individual source(s) to evaluate. Must also be enabled via configuration."
|
25
27
|
def status
|
26
|
-
run Licensed::Commands::Status.new(config: config), sources: options[:sources]
|
28
|
+
run Licensed::Commands::Status.new(config: config), sources: options[:sources], reporter: options[:format]
|
27
29
|
end
|
28
30
|
|
29
31
|
desc "list", "List dependencies"
|
@@ -57,7 +59,7 @@ module Licensed
|
|
57
59
|
method_option :config, aliases: "-c", type: :string,
|
58
60
|
desc: "Path to licensed configuration file"
|
59
61
|
def env
|
60
|
-
run Licensed::Commands::Environment.new(config: config),
|
62
|
+
run Licensed::Commands::Environment.new(config: config), reporter: options[:format]
|
61
63
|
end
|
62
64
|
|
63
65
|
desc "migrate", "Migrate from a previous version of licensed"
|
@@ -2,12 +2,12 @@
|
|
2
2
|
module Licensed
|
3
3
|
module Commands
|
4
4
|
class Cache < Command
|
5
|
-
#
|
5
|
+
# Returns the default reporter to use during the command run
|
6
6
|
#
|
7
7
|
# options - The options the command was run with
|
8
8
|
#
|
9
|
-
#
|
10
|
-
def
|
9
|
+
# Returns a Licensed::Reporters::CacheReporter
|
10
|
+
def default_reporter(options)
|
11
11
|
Licensed::Reporters::CacheReporter.new
|
12
12
|
end
|
13
13
|
|
@@ -37,13 +37,29 @@ module Licensed
|
|
37
37
|
result
|
38
38
|
end
|
39
39
|
|
40
|
-
#
|
40
|
+
# Creates a reporter to use during a command run
|
41
41
|
#
|
42
42
|
# options - The options the command was run with
|
43
43
|
#
|
44
|
-
#
|
44
|
+
# Returns the reporter to use during the command run
|
45
45
|
def create_reporter(options)
|
46
|
-
|
46
|
+
return options[:reporter] if options[:reporter].is_a?(Licensed::Reporters::Reporter)
|
47
|
+
|
48
|
+
if options[:reporter].is_a?(String)
|
49
|
+
klass = "#{options[:reporter].capitalize}Reporter"
|
50
|
+
return Licensed::Reporters.const_get(klass).new if Licensed::Reporters.const_defined?(klass)
|
51
|
+
end
|
52
|
+
|
53
|
+
default_reporter(options)
|
54
|
+
end
|
55
|
+
|
56
|
+
# Returns the default reporter to use during the command run
|
57
|
+
#
|
58
|
+
# options - The options the command was run with
|
59
|
+
#
|
60
|
+
# Raises an error
|
61
|
+
def default_reporter(options)
|
62
|
+
raise "`default_reporter` must be implemented by commands"
|
47
63
|
end
|
48
64
|
|
49
65
|
protected
|
@@ -125,7 +141,7 @@ module Licensed
|
|
125
141
|
end
|
126
142
|
|
127
143
|
evaluate_dependency(app, source, dependency, report)
|
128
|
-
rescue Licensed::Shell::Error => err
|
144
|
+
rescue Licensed::DependencyRecord::Error, Licensed::Shell::Error => err
|
129
145
|
report.errors << err.message
|
130
146
|
false
|
131
147
|
end
|
@@ -35,13 +35,13 @@ module Licensed
|
|
35
35
|
end
|
36
36
|
end
|
37
37
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
38
|
+
# Returns the default reporter to use during the command run
|
39
|
+
#
|
40
|
+
# options - The options the command was run with
|
41
|
+
#
|
42
|
+
# Returns a Licensed::Reporters::StatusReporter
|
43
|
+
def default_reporter(options)
|
44
|
+
Licensed::Reporters::YamlReporter.new
|
45
45
|
end
|
46
46
|
|
47
47
|
protected
|
@@ -2,12 +2,12 @@
|
|
2
2
|
module Licensed
|
3
3
|
module Commands
|
4
4
|
class List < Command
|
5
|
-
#
|
5
|
+
# Returns the default reporter to use during the command run
|
6
6
|
#
|
7
7
|
# options - The options the command was run with
|
8
8
|
#
|
9
9
|
# Returns a Licensed::Reporters::ListReporter
|
10
|
-
def
|
10
|
+
def default_reporter(options)
|
11
11
|
Licensed::Reporters::ListReporter.new
|
12
12
|
end
|
13
13
|
|
@@ -2,12 +2,12 @@
|
|
2
2
|
module Licensed
|
3
3
|
module Commands
|
4
4
|
class Notices < Command
|
5
|
-
#
|
5
|
+
# Returns the default reporter to use during the command run
|
6
6
|
#
|
7
7
|
# options - The options the command was run with
|
8
8
|
#
|
9
|
-
#
|
10
|
-
def
|
9
|
+
# Returns a Licensed::Reporters::CacheReporter
|
10
|
+
def default_reporter(options)
|
11
11
|
Licensed::Reporters::NoticesReporter.new
|
12
12
|
end
|
13
13
|
|
@@ -4,12 +4,12 @@ require "yaml"
|
|
4
4
|
module Licensed
|
5
5
|
module Commands
|
6
6
|
class Status < Command
|
7
|
-
#
|
7
|
+
# Returns the default reporter to use during the command run
|
8
8
|
#
|
9
9
|
# options - The options the command was run with
|
10
10
|
#
|
11
11
|
# Returns a Licensed::Reporters::StatusReporter
|
12
|
-
def
|
12
|
+
def default_reporter(options)
|
13
13
|
Licensed::Reporters::StatusReporter.new
|
14
14
|
end
|
15
15
|
|
@@ -5,6 +5,8 @@ require "licensee"
|
|
5
5
|
|
6
6
|
module Licensed
|
7
7
|
class DependencyRecord
|
8
|
+
class Error < StandardError; end
|
9
|
+
|
8
10
|
class License
|
9
11
|
attr_reader :text, :sources
|
10
12
|
def initialize(content)
|
@@ -46,6 +48,8 @@ module Licensed
|
|
46
48
|
notices: data.delete("notices"),
|
47
49
|
metadata: data
|
48
50
|
)
|
51
|
+
rescue Psych::SyntaxError => e
|
52
|
+
raise Licensed::DependencyRecord::Error.new(e.message)
|
49
53
|
end
|
50
54
|
|
51
55
|
def_delegators :@metadata, :[], :[]=
|
@@ -74,7 +74,7 @@ module Licensed
|
|
74
74
|
end
|
75
75
|
end
|
76
76
|
|
77
|
-
GEMFILES =
|
77
|
+
GEMFILES = { "Gemfile" => "Gemfile.lock", "gems.rb" => "gems.locked" }
|
78
78
|
DEFAULT_WITHOUT_GROUPS = %i{development test}
|
79
79
|
|
80
80
|
def enabled?
|
@@ -272,14 +272,15 @@ module Licensed
|
|
272
272
|
|
273
273
|
# Returns the path to the Bundler Gemfile
|
274
274
|
def gemfile_path
|
275
|
-
@gemfile_path ||= GEMFILES.
|
275
|
+
@gemfile_path ||= GEMFILES.keys
|
276
|
+
.map { |g| config.pwd.join g }
|
276
277
|
.find { |f| f.exist? }
|
277
278
|
end
|
278
279
|
|
279
280
|
# Returns the path to the Bundler Gemfile.lock
|
280
281
|
def lockfile_path
|
281
282
|
return unless gemfile_path
|
282
|
-
@lockfile_path ||= gemfile_path.dirname.join(
|
283
|
+
@lockfile_path ||= gemfile_path.dirname.join(GEMFILES[gemfile_path.basename.to_s])
|
283
284
|
end
|
284
285
|
|
285
286
|
# Returns the configured bundler executable to use, or "bundle" by default.
|
data/lib/licensed/sources/npm.rb
CHANGED
@@ -30,7 +30,7 @@ module Licensed
|
|
30
30
|
end
|
31
31
|
|
32
32
|
def packages
|
33
|
-
root_dependencies =
|
33
|
+
root_dependencies = package_metadata["dependencies"]
|
34
34
|
recursive_dependencies(root_dependencies).each_with_object({}) do |(name, results), hsh|
|
35
35
|
results.uniq! { |package| package["version"] }
|
36
36
|
if results.size == 1
|
@@ -56,6 +56,18 @@ module Licensed
|
|
56
56
|
result
|
57
57
|
end
|
58
58
|
|
59
|
+
# Returns parsed package metadata returned from `npm list`
|
60
|
+
def package_metadata
|
61
|
+
return @package_metadata if defined?(@package_metadata)
|
62
|
+
|
63
|
+
@package_metadata = begin
|
64
|
+
JSON.parse(package_metadata_command)
|
65
|
+
rescue JSON::ParserError => e
|
66
|
+
raise Licensed::Sources::Source::Error,
|
67
|
+
"Licensed was unable to parse the output from 'npm list'. Please run 'npm list --json --long' and check for errors. Error: #{e.message}"
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
59
71
|
# Returns the output from running `npm list` to get package metadata
|
60
72
|
def package_metadata_command
|
61
73
|
args = %w(--json --long)
|
data/lib/licensed/version.rb
CHANGED
data/licensed.gemspec
CHANGED
@@ -38,5 +38,4 @@ Gem::Specification.new do |spec|
|
|
38
38
|
spec.add_development_dependency "rubocop", "~> 0.49", "< 0.67"
|
39
39
|
spec.add_development_dependency "rubocop-github", "~> 0.6"
|
40
40
|
spec.add_development_dependency "byebug", "~> 10.0.0"
|
41
|
-
spec.add_development_dependency "spy", "~> 1.0.0"
|
42
41
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: licensed
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.13.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- GitHub
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-09-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: licensee
|
@@ -218,20 +218,6 @@ dependencies:
|
|
218
218
|
- - "~>"
|
219
219
|
- !ruby/object:Gem::Version
|
220
220
|
version: 10.0.0
|
221
|
-
- !ruby/object:Gem::Dependency
|
222
|
-
name: spy
|
223
|
-
requirement: !ruby/object:Gem::Requirement
|
224
|
-
requirements:
|
225
|
-
- - "~>"
|
226
|
-
- !ruby/object:Gem::Version
|
227
|
-
version: 1.0.0
|
228
|
-
type: :development
|
229
|
-
prerelease: false
|
230
|
-
version_requirements: !ruby/object:Gem::Requirement
|
231
|
-
requirements:
|
232
|
-
- - "~>"
|
233
|
-
- !ruby/object:Gem::Version
|
234
|
-
version: 1.0.0
|
235
221
|
description: Licensed automates extracting and validating the licenses of dependencies.
|
236
222
|
email:
|
237
223
|
- opensource+licensed@github.com
|