license_finder 7.0.1 → 7.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (65) hide show
  1. checksums.yaml +4 -4
  2. data/.github/dependabot.yml +7 -0
  3. data/.pre-commit-hooks.yaml +10 -0
  4. data/.rubocop.yml +5 -1
  5. data/CHANGELOG.md +41 -0
  6. data/CONTRIBUTING.md +1 -0
  7. data/Dockerfile +129 -122
  8. data/README.md +53 -14
  9. data/Rakefile +1 -1
  10. data/VERSION +1 -1
  11. data/ci/pipelines/pull-request.yml.erb +29 -32
  12. data/ci/pipelines/release.yml.erb +17 -41
  13. data/ci/scripts/run-tests.sh +20 -4
  14. data/ci/tasks/rubocop.yml +3 -3
  15. data/ci/tasks/update-changelog.yml +2 -2
  16. data/dlf +6 -1
  17. data/lib/license_finder/cli/base.rb +2 -0
  18. data/lib/license_finder/cli/licenses.rb +8 -3
  19. data/lib/license_finder/cli/main.rb +3 -1
  20. data/lib/license_finder/configuration.rb +8 -0
  21. data/lib/license_finder/core.rb +4 -2
  22. data/lib/license_finder/decision_applier.rb +1 -1
  23. data/lib/license_finder/decisions.rb +24 -6
  24. data/lib/license_finder/license/definitions.rb +129 -19
  25. data/lib/license_finder/license/templates/AGPL3.txt +661 -0
  26. data/lib/license_finder/license/templates/Apache2.txt +0 -2
  27. data/lib/license_finder/license/templates/Artistic.txt +128 -0
  28. data/lib/license_finder/license/templates/CC01_alt.txt +31 -0
  29. data/lib/license_finder/license/templates/CDDL1_1.txt +123 -0
  30. data/lib/license_finder/license/templates/CPL1.txt +217 -0
  31. data/lib/license_finder/license/templates/EPL2.txt +80 -0
  32. data/lib/license_finder/license/templates/Unlicense.txt +24 -0
  33. data/lib/license_finder/license/text.rb +4 -0
  34. data/lib/license_finder/license.rb +1 -1
  35. data/lib/license_finder/manual_licenses.rb +79 -0
  36. data/lib/license_finder/package.rb +1 -0
  37. data/lib/license_finder/package_manager.rb +2 -1
  38. data/lib/license_finder/package_managers/cargo.rb +1 -1
  39. data/lib/license_finder/package_managers/conan.rb +50 -8
  40. data/lib/license_finder/package_managers/dep.rb +43 -41
  41. data/lib/license_finder/package_managers/dotnet.rb +5 -2
  42. data/lib/license_finder/package_managers/go_dep.rb +1 -1
  43. data/lib/license_finder/package_managers/go_workspace.rb +3 -2
  44. data/lib/license_finder/package_managers/maven.rb +18 -10
  45. data/lib/license_finder/package_managers/npm.rb +14 -1
  46. data/lib/license_finder/package_managers/nuget.rb +5 -0
  47. data/lib/license_finder/package_managers/pip.rb +1 -1
  48. data/lib/license_finder/package_managers/pnpm.rb +126 -0
  49. data/lib/license_finder/package_managers/yarn.rb +69 -20
  50. data/lib/license_finder/package_utils/conan_info_parser.rb +2 -2
  51. data/lib/license_finder/package_utils/conan_info_parser_v2.rb +82 -0
  52. data/lib/license_finder/package_utils/license_files.rb +12 -2
  53. data/lib/license_finder/package_utils/licensing.rb +2 -1
  54. data/lib/license_finder/package_utils/maven_dependency_finder.rb +43 -1
  55. data/lib/license_finder/package_utils/notice_files.rb +14 -3
  56. data/lib/license_finder/package_utils/possible_license_file.rb +8 -2
  57. data/lib/license_finder/package_utils/pypi.rb +3 -1
  58. data/lib/license_finder/packages/maven_package.rb +13 -1
  59. data/lib/license_finder/packages/npm_package.rb +56 -9
  60. data/lib/license_finder/packages/pnpm_package.rb +13 -0
  61. data/lib/license_finder/printer.rb +2 -2
  62. data/lib/license_finder/reports/csv_report.rb +10 -1
  63. data/lib/license_finder/scanner.rb +3 -3
  64. data/license_finder.gemspec +12 -11
  65. metadata +54 -28
@@ -13,27 +13,34 @@ resource_types:
13
13
  source:
14
14
  repository: cfcommunity/slack-notification-resource
15
15
  tag: latest
16
- username: ((LicenseFinderDocker.username))
17
- password: ((LicenseFinderDocker.password))
16
+ username: ((license-finder-docker-username))
17
+ password: ((license-finder-docker-password))
18
18
  <% end %>
19
19
 
20
20
  resources:
21
+ - name: lf-git
22
+ type: git
23
+ source:
24
+ uri: git@github.com:pivotal/LicenseFinder.git
25
+ private_key: ((github-cf-osl-bot-private-key))
26
+ branch: master
27
+
21
28
  - name: github-pull-request
22
29
  type: pull-request
23
30
  check_every: 24h
24
- webhook_token: ((GithubPullRequestWebhookToken))
31
+ webhook_token: ((github-pull-request-webhook-token))
25
32
  source:
26
33
  repository: pivotal/LicenseFinder
27
- access_token: ((GithubApiPullRequestToken))
34
+ access_token: ((github-api-pull-request-token))
28
35
 
29
36
  - name: dockerhub-pr
30
37
  type: docker-image
31
38
  source:
32
39
  tag: edge-pr
33
40
  repository: licensefinder/license_finder
34
- email: ((LicenseFinderDockerEmail))
35
- username: ((LicenseFinderDocker.username))
36
- password: ((LicenseFinderDocker.password))
41
+ email: ((license-finder-docker-email))
42
+ username: ((license-finder-docker-username))
43
+ password: ((license-finder-docker-password))
37
44
 
38
45
  <% if setup_slack %>
39
46
  - name: slack-alert
@@ -47,23 +54,19 @@ jobs:
47
54
  public: true
48
55
  plan:
49
56
  - get: github-pull-request
50
- tags: ["private-worker"]
51
57
  version: every
52
58
  trigger: true
53
59
  - put: dockerhub-pr
54
- tags: ["private-worker"]
55
60
  params:
56
61
  build: github-pull-request
57
62
  on_success:
58
63
  put: github-pull-request
59
- tags: ["private-worker"]
60
64
  params:
61
65
  path: github-pull-request
62
66
  status: success
63
67
  context: build-docker-image
64
68
  on_failure:
65
69
  put: github-pull-request
66
- tags: ["private-worker"]
67
70
  params:
68
71
  path: github-pull-request
69
72
  status: failure
@@ -72,32 +75,29 @@ jobs:
72
75
  - name: PR-ruby-<%= ruby_version %>-linux
73
76
  public: true
74
77
  plan:
75
- - get: github-pull-request
76
- tags: ["private-worker"]
77
- passed: [build-docker-image]
78
- version: every
79
- - get: dockerhub-pr
80
- tags: ["private-worker"]
81
- passed: [build-docker-image]
82
- trigger: true
78
+ - in_parallel:
79
+ - get: github-pull-request
80
+ passed: [build-docker-image]
81
+ version: every
82
+ - get: dockerhub-pr
83
+ passed: [build-docker-image]
84
+ trigger: true
85
+ - get: lf-git
83
86
  - task: ruby-<%= ruby_version %>
84
- tags: ["private-worker"]
85
87
  privileged: true
86
88
  image: dockerhub-pr
87
- file: github-pull-request/ci/tasks/run-tests.yml
89
+ file: lf-git/ci/tasks/run-tests.yml
88
90
  params:
89
91
  RUBY_VERSION_UNDER_TEST: <%= ruby_version %>
90
92
  input_mapping: { LicenseFinder: github-pull-request }
91
93
  on_success:
92
94
  put: github-pull-request
93
- tags: ["private-worker"]
94
95
  params:
95
96
  path: github-pull-request
96
97
  status: success
97
98
  context: ruby-<%= ruby_version %>
98
99
  on_failure:
99
100
  put: github-pull-request
100
- tags: ["private-worker"]
101
101
  params:
102
102
  path: github-pull-request
103
103
  status: failure
@@ -105,7 +105,6 @@ jobs:
105
105
  <% if setup_slack %>
106
106
  on_failure:
107
107
  put: slack-alert
108
- tags: ["private-worker"]
109
108
  params:
110
109
  channel: '<%= slack_channel %>'
111
110
  icon_emoji: ':crying_cat_face:'
@@ -116,25 +115,23 @@ jobs:
116
115
  - name: PR-rubocop
117
116
  public: true
118
117
  plan:
119
- - get: github-pull-request
120
- tags: ["private-worker"]
121
- trigger: true
122
- version: every
118
+ - in_parallel:
119
+ - get: github-pull-request
120
+ trigger: true
121
+ version: every
122
+ - get: lf-git
123
123
  - task: run-rubocop
124
- tags: ["private-worker"]
125
124
  privileged: true
126
- file: github-pull-request/ci/tasks/rubocop.yml
125
+ file: lf-git/ci/tasks/rubocop.yml
127
126
  input_mapping: { LicenseFinder: github-pull-request }
128
127
  on_success:
129
128
  put: github-pull-request
130
- tags: ["private-worker"]
131
129
  params:
132
130
  path: github-pull-request
133
131
  status: success
134
132
  context: run-rubocop
135
133
  on_failure:
136
134
  put: github-pull-request
137
- tags: ["private-worker"]
138
135
  params:
139
136
  path: github-pull-request
140
137
  status: failure
@@ -8,8 +8,8 @@ resource_types:
8
8
  source:
9
9
  repository: cfcommunity/slack-notification-resource
10
10
  tag: latest
11
- username: ((LicenseFinderDocker.username))
12
- password: ((LicenseFinderDocker.password))
11
+ username: ((license-finder-docker-username))
12
+ password: ((license-finder-docker-password))
13
13
  <% end %>
14
14
 
15
15
  resources:
@@ -17,7 +17,7 @@ resources:
17
17
  type: git
18
18
  source:
19
19
  uri: git@github.com:pivotal/LicenseFinder.git
20
- private_key: ((CfOslBot.private_key))
20
+ private_key: ((github-cf-osl-bot-private-key))
21
21
  branch: master
22
22
  ignore_paths: [VERSION, CHANGELOG.md]
23
23
 
@@ -27,24 +27,24 @@ resources:
27
27
  driver: gcs
28
28
  bucket: lf-semver-version
29
29
  key: version
30
- json_key: ((GCPQueuedReportsBucketCredentials))
30
+ json_key: ((lf-bucket-credentials))
31
31
 
32
32
  - name: dockerhub-edge
33
33
  type: docker-image
34
34
  source:
35
35
  tag: edge
36
36
  repository: licensefinder/license_finder
37
- email: ((LicenseFinderDockerEmail))
38
- username: ((LicenseFinderDocker.username))
39
- password: ((LicenseFinderDocker.password))
37
+ email: ((license-finder-docker-email))
38
+ username: ((license-finder-docker-username))
39
+ password: ((license-finder-docker-password))
40
40
 
41
41
  - name: dockerhub
42
42
  type: docker-image
43
43
  source:
44
44
  repository: licensefinder/license_finder
45
- email: ((LicenseFinderDockerEmail))
46
- username: ((LicenseFinderDocker.username))
47
- password: ((LicenseFinderDocker.password))
45
+ email: ((license-finder-docker-email))
46
+ username: ((license-finder-docker-username))
47
+ password: ((license-finder-docker-password))
48
48
 
49
49
  - name: lf-release
50
50
  type: github-release
@@ -52,7 +52,7 @@ resources:
52
52
  source:
53
53
  owner: pivotal
54
54
  repository: LicenseFinder
55
- access_token: ((GithubApiRootToken))
55
+ access_token: ((github-api-root-token))
56
56
 
57
57
  <% if setup_slack %>
58
58
  - name: slack-alert
@@ -66,10 +66,8 @@ jobs:
66
66
  public: true
67
67
  plan:
68
68
  - get: lf-git
69
- tags: ["private-worker"]
70
69
  trigger: true
71
70
  - put: dockerhub-edge
72
- tags: ["private-worker"]
73
71
  params:
74
72
  build: lf-git
75
73
 
@@ -78,16 +76,13 @@ jobs:
78
76
  public: true
79
77
  plan:
80
78
  - get: dockerhub-edge
81
- tags: ["private-worker"]
82
79
  passed: [build-docker-image]
83
80
  trigger: true
84
81
  - get: LicenseFinder
85
- tags: ["private-worker"]
86
82
  resource: lf-git
87
83
  passed: [build-docker-image]
88
84
  version: every
89
85
  - task: ruby-<%= ruby_version %>
90
- tags: ["private-worker"]
91
86
  privileged: true
92
87
  image: dockerhub-edge
93
88
  file: LicenseFinder/ci/tasks/run-tests.yml
@@ -97,7 +92,6 @@ jobs:
97
92
  <% if setup_slack %>
98
93
  on_failure:
99
94
  put: slack-alert
100
- tags: ["private-worker"]
101
95
  params:
102
96
  channel: '<%= slack_channel %>'
103
97
  icon_emoji: ':crying_cat_face:'
@@ -109,16 +103,13 @@ jobs:
109
103
  public: true
110
104
  plan:
111
105
  - get: dockerhub-edge
112
- tags: ["private-worker"]
113
106
  passed: [build-docker-image]
114
107
  trigger: true
115
108
  - get: LicenseFinder
116
- tags: ["private-worker"]
117
109
  resource: lf-git
118
110
  version: every
119
111
  passed: [build-docker-image]
120
112
  - task: run-rubocop
121
- tags: ["private-worker"]
122
113
  privileged: true
123
114
  file: LicenseFinder/ci/tasks/rubocop.yml
124
115
  input_mapping: { LicenseFinder: LicenseFinder }
@@ -126,74 +117,59 @@ jobs:
126
117
  - name: bump-major
127
118
  plan:
128
119
  - get: semver-version
129
- tags: ["private-worker"]
130
120
  params: {bump: major}
131
121
  - put: semver-version
132
- tags: ["private-worker"]
133
122
  params: {file: semver-version/version}
134
123
 
135
124
 
136
125
  - name: bump-minor
137
126
  plan:
138
127
  - get: semver-version
139
- tags: ["private-worker"]
140
128
  params: {bump: minor}
141
129
  - put: semver-version
142
- tags: ["private-worker"]
143
130
  params: {file: semver-version/version}
144
131
 
145
132
  - name: bump-patch
146
133
  plan:
147
134
  - get: semver-version
148
- tags: ["private-worker"]
149
135
  params: {bump: patch}
150
136
  - put: semver-version
151
- tags: ["private-worker"]
152
137
  params: {file: semver-version/version}
153
138
 
154
139
  - name: release
155
140
  disable_manual_trigger: true
156
141
  plan:
157
142
  - get: lf-git
158
- tags: ["private-worker"]
159
143
  passed: [<%= "#{ruby_versions.map{ |version| "ruby-#{version}" unless version == "jruby-9.3.1.0" }.compact.join(', ') }, rubocop" %>]
160
144
  - get: semver-version
161
- tags: ["private-worker"]
162
145
  trigger: true
163
146
  - get: dockerhub
164
- tags: ["private-worker"]
165
147
  params:
166
148
  save: true
167
149
  - get: lf-release
168
- tags: ["private-worker"]
169
150
  - task: update-changelog
170
- tags: ["private-worker"]
171
151
  image: dockerhub
172
152
  params:
173
- GIT_USERNAME: ((GithubApiUser))
174
- GIT_EMAIL: ((GithubApiEmail))
153
+ GIT_USERNAME: ((github-api-user))
154
+ GIT_EMAIL: ((github-api-email))
175
155
  file: lf-git/ci/tasks/update-changelog.yml
176
156
  - put: dockerhub
177
- tags: ["private-worker"]
178
157
  params:
179
158
  build: lf-git-changed
180
159
  tag: version/version.txt
181
160
  tag_as_latest: true
182
161
  - put: lf-git
183
- tags: ["private-worker"]
184
162
  params:
185
163
  repository: lf-git-changed
186
164
  - task: build-and-push-gem
187
- tags: ["private-worker"]
188
165
  image: dockerhub
189
166
  params:
190
- GIT_USERNAME: ((GithubApiUser))
191
- GIT_EMAIL: ((GithubApiEmail))
192
- GIT_PRIVATE_KEY: ((CfOslBot.private_key))
193
- GEM_API_KEY: ((LicenseFinderGemApiKey))
167
+ GIT_USERNAME: ((github-api-user))
168
+ GIT_EMAIL: ((github-api-email))
169
+ GIT_PRIVATE_KEY: ((github-cf-osl-bot-private-key))
170
+ GEM_API_KEY: ((license-finder-gem-api-key))
194
171
  file: lf-git/ci/tasks/build-and-push-gem.yml
195
172
  - put: lf-release
196
- tags: ["private-worker"]
197
173
  params:
198
174
  name: version/tag.txt
199
175
  tag: version/tag.txt
@@ -6,14 +6,30 @@ DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
6
6
  PROJECT_ROOT="$( dirname "$( dirname $DIR )" )"
7
7
 
8
8
  pushd "$PROJECT_ROOT"
9
-
10
- rvm install --default $RUBY_VERSION_UNDER_TEST
9
+ DISABLE_BINARY=""
10
+ if [[ $RUBY_VERSION_UNDER_TEST == "2.6.10" ]]; then
11
+ DISABLE_BINARY="--disable-binary"
12
+ fi
13
+
14
+ # This is needed for 2.7 but also works for 2.6. For 2.6, you can also downgrade the openssl version to 1.1.1l-1ubuntu1.4 in the dockerfile with allowing downgrades for apt install -y libssl-dev=1.1.1l-1ubuntu1.4
15
+ if [[ $RUBY_VERSION_UNDER_TEST == "2.6.10" || $RUBY_VERSION_UNDER_TEST == "2.7.8" ]]; then
16
+ OPEN_SSL_FLAG="--with-openssl-dir=/usr/share/rvm/usr/"
17
+ rvm pkg install openssl
18
+ fi
19
+
20
+ rvm install --default $RUBY_VERSION_UNDER_TEST $DISABLE_BINARY $OPEN_SSL_FLAG
11
21
  ruby --version
12
22
 
13
23
  export GOPATH=$HOME/go
14
- export RUBYOPT='-E utf-8'
24
+ if [[ $RUBY_VERSION_UNDER_TEST == "2.6.10" || $RUBY_VERSION_UNDER_TEST == "2.7.8" ]]; then
25
+ export RUBYOPT='-E utf-8 -W0'
26
+ gem install "rubygems-update:<3.5.0" --no-document
27
+ gem update --system --conservative
28
+ else
29
+ export RUBYOPT='-E utf-8'
30
+ gem update --system
31
+ fi
15
32
 
16
- gem update --system
17
33
  gem install bundler
18
34
  bundle install
19
35
  bundle pristine
data/ci/tasks/rubocop.yml CHANGED
@@ -4,9 +4,9 @@ image_resource:
4
4
  type: registry-image
5
5
  source:
6
6
  repository: ruby
7
- tag: 3.1.1
8
- username: ((LicenseFinderDocker.username))
9
- password: ((LicenseFinderDocker.password))
7
+ tag: 3.2.3
8
+ username: ((license-finder-docker-username))
9
+ password: ((license-finder-docker-password))
10
10
 
11
11
  inputs:
12
12
  - name: LicenseFinder
@@ -4,8 +4,8 @@ image_resource:
4
4
  source:
5
5
  repository: brenix/alpine-bash-git-ssh
6
6
  tag: latest
7
- username: ((LicenseFinderDocker.username))
8
- password: ((LicenseFinderDocker.password))
7
+ username: ((license-finder-docker-username))
8
+ password: ((license-finder-docker-password))
9
9
  platform: linux
10
10
  inputs:
11
11
  - name: lf-git
data/dlf CHANGED
@@ -7,7 +7,12 @@ if `which docker > /dev/null`; then
7
7
  for p in "$@"; do
8
8
  escaped_params="$escaped_params \"$p\""
9
9
  done
10
- docker run -v $PWD:/scan -it licensefinder/license_finder /bin/bash -lc "cd /scan && $escaped_params"
10
+ if [[ $escaped_params =~ "&&" ]]; then
11
+ command=${escaped_params:2:${#escaped_params}-3}
12
+ else
13
+ command=$escaped_params
14
+ fi
15
+ docker run -v $PWD:/scan -it licensefinder/license_finder /bin/bash -lc "cd /scan && $command"
11
16
  fi
12
17
  else
13
18
  echo "You do not have docker installed. Please install it:"
@@ -46,6 +46,8 @@ module LicenseFinder
46
46
  :maven_include_groups,
47
47
  :maven_options,
48
48
  :npm_options,
49
+ :yarn_options,
50
+ :pnpm_options,
49
51
  :pip_requirements_path,
50
52
  :python_version,
51
53
  :rebar_command,
@@ -7,19 +7,24 @@ module LicenseFinder
7
7
  include MakesDecisions
8
8
 
9
9
  auditable
10
+ method_option :version, desc: 'The version associated with the license'
10
11
  desc 'add DEPENDENCY LICENSE', "Set a dependency's licenses, overwriting any license_finder has found"
11
12
  def add(name, license)
12
13
  modifying { decisions.license(name, license, txn) }
13
14
 
14
- printer.say "The #{name} dependency has been marked as using #{license} license!", :green
15
+ version_info = options[:version] ? " with version #{options[:version]}" : ''
16
+ printer.say "The #{name} dependency#{version_info} has been marked as using #{license} license!", :green
15
17
  end
16
18
 
17
19
  auditable
20
+ method_option :version, desc: 'The version associated with the license'
18
21
  desc 'remove DEPENDENCY LICENSE', 'Remove a manually set license'
19
- def remove(dep, lic)
22
+ def remove(dep, lic = nil)
20
23
  modifying { decisions.unlicense(dep, lic, txn) }
21
24
 
22
- printer.say "The dependency #{dep} no longer has a manual license"
25
+ version_info = options[:version] ? " with version #{options[:version]}" : ''
26
+ suffix = lic ? " of #{lic}" : ''
27
+ printer.say "The dependency #{dep}#{version_info} no longer has a manual license#{suffix}"
23
28
  end
24
29
  end
25
30
  end
@@ -32,6 +32,8 @@ module LicenseFinder
32
32
  class_option :maven_include_groups, desc: 'Whether dependency name should include group id. Only meaningful if used with a Java/maven project. Defaults to false.'
33
33
  class_option :maven_options, desc: 'Maven options to append to command. Defaults to empty.'
34
34
  class_option :npm_options, desc: 'npm options to append to command. Defaults to empty.'
35
+ class_option :yarn_options, desc: 'yarn options to append to command. Defaults to empty.'
36
+ class_option :pnpm_options, desc: 'pnpm options to append to command. Defaults to empty.'
35
37
  class_option :pip_requirements_path, desc: 'Path to python requirements file. Defaults to requirements.txt.'
36
38
  class_option :python_version, desc: 'Python version to invoke pip with. Valid versions: 2 or 3. Default: 2'
37
39
  class_option :rebar_command, desc: "Command to use when fetching rebar packages. Only meaningful if used with a Erlang/rebar project. Defaults to 'rebar'."
@@ -152,7 +154,7 @@ module LicenseFinder
152
154
  shared_options
153
155
  format_option
154
156
  method_option :write_headers, type: :boolean, desc: 'Write exported columns as header row (csv).', default: false, required: false
155
- method_option :save, desc: "Save report to a file. Default: 'license_report.csv' in project root.", lazy_default: 'license_report'
157
+ method_option :save, desc: "Save report to a file. Default: 'license_report' in project root.", lazy_default: 'license_report'
156
158
 
157
159
  def report
158
160
  finder = LicenseAggregator.new(config, aggregate_paths)
@@ -97,6 +97,14 @@ module LicenseFinder
97
97
  get(:npm_options)
98
98
  end
99
99
 
100
+ def yarn_options
101
+ get(:yarn_options)
102
+ end
103
+
104
+ def pnpm_options
105
+ get(:pnpm_options)
106
+ end
107
+
100
108
  def pip_requirements_path
101
109
  get(:pip_requirements_path)
102
110
  end
@@ -61,9 +61,9 @@ module LicenseFinder
61
61
  clear_logs
62
62
  package_managers = @scanner.active_package_managers
63
63
  package_managers.each do |manager|
64
- logger.debug manager.class, 'Running prepare on project'
64
+ logger.debug manager.class, "Running prepare on project '#{config.project_path}'"
65
65
  manager.prepare
66
- logger.debug manager.class, 'Finished prepare on project', color: :green
66
+ logger.debug manager.class, "Finished prepare on project '#{config.project_path}'", color: :green
67
67
  end
68
68
  end
69
69
 
@@ -101,6 +101,8 @@ module LicenseFinder
101
101
  maven_include_groups: config.maven_include_groups,
102
102
  maven_options: config.maven_options,
103
103
  npm_options: config.npm_options,
104
+ yarn_options: config.yarn_options,
105
+ pnpm_options: config.pnpm_options,
104
106
  pip_requirements_path: config.pip_requirements_path,
105
107
  python_version: config.python_version,
106
108
  rebar_command: config.rebar_command,
@@ -44,7 +44,7 @@ module LicenseFinder
44
44
  end
45
45
 
46
46
  def with_decided_licenses(package)
47
- decisions.licenses_of(package.name).each do |license|
47
+ decisions.licenses_of(package.name, package.version).each do |license|
48
48
  package.decide_on_license license
49
49
  end
50
50
  package
@@ -2,6 +2,7 @@
2
2
 
3
3
  require 'open-uri'
4
4
  require 'license_finder/license'
5
+ require 'license_finder/manual_licenses'
5
6
 
6
7
  module LicenseFinder
7
8
  class Decisions
@@ -11,8 +12,8 @@ module LicenseFinder
11
12
 
12
13
  attr_reader :packages, :permitted, :restricted, :ignored, :ignored_groups, :project_name, :inherited_decisions
13
14
 
14
- def licenses_of(name)
15
- @licenses[name]
15
+ def licenses_of(name, version = nil)
16
+ @manual_licenses.licenses_of(name, version)
16
17
  end
17
18
 
18
19
  def homepage_of(name)
@@ -76,7 +77,7 @@ module LicenseFinder
76
77
  def initialize
77
78
  @decisions = []
78
79
  @packages = Set.new
79
- @licenses = Hash.new { |h, k| h[k] = Set.new }
80
+ @manual_licenses = ManualLicenses.new
80
81
  @homepages = {}
81
82
  @approvals = {}
82
83
  @permitted = Set.new
@@ -100,13 +101,29 @@ module LicenseFinder
100
101
 
101
102
  def license(name, lic, txn = {})
102
103
  add_decision [:license, name, lic, txn]
103
- @licenses[name] << License.find_by_name(lic)
104
+
105
+ versions = txn[:versions]
106
+
107
+ if versions.nil? || versions.empty?
108
+ @manual_licenses.assign_to_all_versions(name, lic)
109
+ else
110
+ @manual_licenses.assign_to_specific_versions(name, lic, versions)
111
+ end
112
+
104
113
  self
105
114
  end
106
115
 
107
116
  def unlicense(name, lic, txn = {})
108
117
  add_decision [:unlicense, name, lic, txn]
109
- @licenses[name].delete(License.find_by_name(lic))
118
+
119
+ versions = txn[:versions]
120
+
121
+ if versions.nil? || versions.empty?
122
+ @manual_licenses.unassign_from_all_versions(name, lic)
123
+ else
124
+ @manual_licenses.unassign_from_specific_versions(name, lic, versions)
125
+ end
126
+
110
127
  self
111
128
  end
112
129
 
@@ -235,9 +252,10 @@ module LicenseFinder
235
252
  end
236
253
 
237
254
  def restore_inheritance(decisions)
255
+ previous_value = @inherited
238
256
  @inherited = true
239
257
  self.class.restore(decisions, self)
240
- @inherited = false
258
+ @inherited = previous_value
241
259
  self
242
260
  end
243
261