licensed 3.8.0 → 3.9.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
  SHA256:
3
- metadata.gz: a8ae3ae52bbb8b7a7b9bca992046e870a917fa891600ecb81386d1aaeee3c65a
4
- data.tar.gz: 31988f8d467f49ae8b3ba0765479a9ae5be4e2de4b60f58de6a40ab8578c50e5
3
+ metadata.gz: f4df54260766353e4cd56b9ae56ded611ed4d6a312469d43e18ab47b6b9cabde
4
+ data.tar.gz: 8f04c9e9d11bcaf7f47698a174ee1269346e798eaa176e28ac3282de482ef237
5
5
  SHA512:
6
- metadata.gz: 6a14c36d7d1c0060114ff1b30176e148ba85f8a211249e8b4964af00a818677a4252ffc88428355a09e8070b765803ddf6a68d35db8ea14cf0253855f6cfd299
7
- data.tar.gz: f735c4a13b0d8aa00c496e2d7f502e7fd23680865a2530f6262689f3484faa7a34297e05f7db6deb2b539b991cc4e8415816b3ecd10ce8d0d9e89830d277d3d6
6
+ metadata.gz: 0006a278b5b2a7af75ad7634fe11f418f310e7c7506e1ae3cc68bdfca873cdbf74b9bd359d2a9b917c8c79df3a91b589c0c7e8f0b6ad2c03349a81e3bfbc91cd
7
+ data.tar.gz: 0c6275c87fe724a747f0432395b568341c495453f0072aa78e0f1ee48e075ebfbd94de5ef85d3eb46adf7dfb16e203c725a90929be6dfe801bf53a7b55c783e8
data/CHANGELOG.md CHANGED
@@ -6,6 +6,12 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
+ ## 3.9.0
10
+
11
+ ### Added
12
+
13
+ - `NOTICE` files can now be generated without cached files in a repository (https://github.com/github/licensed/pull/572)
14
+
9
15
  ## 3.8.0
10
16
 
11
17
  ### Added
@@ -649,4 +655,4 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
649
655
 
650
656
  Initial release :tada:
651
657
 
652
- [Unreleased]: https://github.com/github/licensed/compare/3.8.0...HEAD
658
+ [Unreleased]: https://github.com/github/licensed/compare/3.9.0...HEAD
@@ -2,7 +2,7 @@
2
2
 
3
3
  Outputs license and notice text for all dependencies in each app into a `NOTICE` file in the app's `cache_path`. If an app uses a shared cache path, the file name will contain the app name as well, e.g. `NOTICE.my_app`.
4
4
 
5
- `NOTICE` file contents are retrieved from cached records, with the assumption that cached records have already been reviewed in a compliance workflow.
5
+ `NOTICE` file contents are retrieved from cached records when the `--computed`/`-l` option is not set, with the assumption that cached records have already been reviewed in a compliance workflow. When the `--computed`/`-l` option is set and a dependency's license is not found, that dependency's license text will be empty in the `NOTICE` file.
6
6
 
7
7
  ## Options
8
8
 
@@ -10,3 +10,5 @@ Outputs license and notice text for all dependencies in each app into a `NOTICE`
10
10
  - default value: `./.licensed.yml`
11
11
  - `--sources`/`-s`: runtime filter on which dependency sources are run. Sources must also be enabled in the licensed configuration file.
12
12
  - default value: not set, all configured sources
13
+ - `--computed`/`-l`: use live computed when generating a `NOTICE` file
14
+ - default value: not set, `NOTICE` file generated from cached records
data/lib/licensed/cli.rb CHANGED
@@ -46,13 +46,15 @@ module Licensed
46
46
  run Licensed::Commands::List.new(config: config), sources: options[:sources], reporter: options[:format], licenses: options[:licenses]
47
47
  end
48
48
 
49
- desc "notices", "Generate a NOTICE file from cached records"
49
+ desc "notices", "Generate a NOTICE file with dependency data"
50
50
  method_option :config, aliases: "-c", type: :string,
51
51
  desc: "Path to licensed configuration file"
52
52
  method_option :sources, aliases: "-s", type: :array,
53
53
  desc: "Individual source(s) to evaluate. Must also be enabled via configuration."
54
+ method_option :computed, aliases: "-l", type: :boolean,
55
+ desc: "Whether to generate a NOTICE file using computed data or cached records"
54
56
  def notices
55
- run Licensed::Commands::Notices.new(config: config), sources: options[:sources]
57
+ run Licensed::Commands::Notices.new(config: config), sources: options[:sources], computed: options[:computed]
56
58
  end
57
59
 
58
60
  map "-v" => :version
@@ -13,7 +13,7 @@ module Licensed
13
13
 
14
14
  protected
15
15
 
16
- # Load stored dependency record data to add to the notices report.
16
+ # Load a dependency record data and add it to the notices report.
17
17
  #
18
18
  # app - The application configuration for the dependency
19
19
  # source - The dependency source enumerator for the dependency
@@ -22,13 +22,36 @@ module Licensed
22
22
  #
23
23
  # Returns true.
24
24
  def evaluate_dependency(app, source, dependency, report)
25
+ report["record"] =
26
+ if load_dependency_record_from_files
27
+ load_cached_dependency_record(app, source, dependency, report)
28
+ else
29
+ dependency.record
30
+ end
31
+
32
+ true
33
+ end
34
+
35
+ # Loads a dependency record from a cached file.
36
+ #
37
+ # app - The application configuration for the dependency
38
+ # source - The dependency source enumerator for the dependency
39
+ # dependency - An application dependency
40
+ # report - A report hash for the command to provide extra data for the report output.
41
+ #
42
+ # Returns a dependency record or nil if one doesn't exist
43
+ def load_cached_dependency_record(app, source, dependency, report)
25
44
  filename = app.cache_path.join(source.class.type, "#{dependency.name}.#{DependencyRecord::EXTENSION}")
26
- report["cached_record"] = Licensed::DependencyRecord.read(filename)
27
- if !report["cached_record"]
45
+ record = Licensed::DependencyRecord.read(filename)
46
+ if !record
28
47
  report.warnings << "expected cached record not found at #{filename}"
29
48
  end
30
49
 
31
- true
50
+ record
51
+ end
52
+
53
+ def load_dependency_record_from_files
54
+ !options.fetch(:computed, false)
32
55
  end
33
56
  end
34
57
  end
@@ -54,11 +54,11 @@ module Licensed
54
54
  def notices(report)
55
55
  return unless report.target.is_a?(Licensed::Dependency)
56
56
 
57
- cached_record = report["cached_record"]
58
- return unless cached_record
57
+ record = report["record"]
58
+ return unless record
59
59
 
60
- texts = cached_record.licenses.map(&:text)
61
- cached_record.notices.each do |notice|
60
+ texts = record.licenses.map(&:text)
61
+ record.notices.each do |notice|
62
62
  case notice
63
63
  when Hash
64
64
  texts << notice["text"]
@@ -70,7 +70,7 @@ module Licensed
70
70
  end
71
71
 
72
72
  <<~NOTICE
73
- #{cached_record["name"]}@#{cached_record["version"]}
73
+ #{record["name"]}@#{record["version"]}
74
74
 
75
75
  #{texts.map(&:strip).reject(&:empty?).compact.join(TEXT_SEPARATOR)}
76
76
  NOTICE
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
  module Licensed
3
- VERSION = "3.8.0".freeze
3
+ VERSION = "3.9.0".freeze
4
4
 
5
5
  def self.previous_major_versions
6
6
  major_version = Gem::Version.new(Licensed::VERSION).segments.first
data/licensed.gemspec CHANGED
@@ -35,7 +35,7 @@ Gem::Specification.new do |spec|
35
35
 
36
36
  spec.add_development_dependency "rake", ">= 12.3.3"
37
37
  spec.add_development_dependency "minitest", "~> 5.8"
38
- spec.add_development_dependency "mocha", "~> 1.0"
38
+ spec.add_development_dependency "mocha", "~> 2.0"
39
39
  spec.add_development_dependency "rubocop-github", "~> 0.6"
40
40
  spec.add_development_dependency "byebug", "~> 11.1.3"
41
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: 3.8.0
4
+ version: 3.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - GitHub
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-10-29 00:00:00.000000000 Z
11
+ date: 2022-11-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: licensee
@@ -188,14 +188,14 @@ dependencies:
188
188
  requirements:
189
189
  - - "~>"
190
190
  - !ruby/object:Gem::Version
191
- version: '1.0'
191
+ version: '2.0'
192
192
  type: :development
193
193
  prerelease: false
194
194
  version_requirements: !ruby/object:Gem::Requirement
195
195
  requirements:
196
196
  - - "~>"
197
197
  - !ruby/object:Gem::Version
198
- version: '1.0'
198
+ version: '2.0'
199
199
  - !ruby/object:Gem::Dependency
200
200
  name: rubocop-github
201
201
  requirement: !ruby/object:Gem::Requirement