licensed 3.9.1 → 4.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +53 -1
- data/CONTRIBUTING.md +0 -2
- data/Gemfile.lock +112 -0
- data/README.md +7 -12
- data/Rakefile +0 -26
- data/docs/configuration/README.md +1 -0
- data/docs/configuration/additional_terms.md +41 -0
- data/docs/configuration.md +7 -0
- data/docs/sources/bundler.md +0 -2
- data/docs/sources/cocoapods.md +17 -0
- data/docs/sources/gradle.md +18 -0
- data/docs/sources/pnpm.md +18 -0
- data/lib/licensed/configuration.rb +6 -1
- data/lib/licensed/dependency.rb +27 -0
- data/lib/licensed/sources/bundler/definition.rb +9 -1
- data/lib/licensed/sources/bundler/missing_specification.rb +2 -2
- data/lib/licensed/sources/bundler.rb +0 -12
- data/lib/licensed/sources/cocoapods.rb +68 -0
- data/lib/licensed/sources/go.rb +1 -36
- data/lib/licensed/sources/gradle.rb +127 -94
- data/lib/licensed/sources/pnpm.rb +52 -0
- data/lib/licensed/sources/source.rb +8 -1
- data/lib/licensed/sources.rb +4 -2
- data/lib/licensed/version.rb +1 -1
- data/licensed.gemspec +13 -13
- metadata +46 -73
- data/docs/packaging.md +0 -53
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7606d0b5e5f3755ee329a1963cda970c021deab08680c619731ed6fb3ba547da
|
4
|
+
data.tar.gz: 668a2d87d8019284b6ce02bccdda851ad186f03cc7d389fbdd659473affc08cf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '064129baadae7345b5c05e2635cc1850b8ce8321f1e2df803b5fc6d6704556a1337c7d1561024775801cf5cb4158b6c25657b06a0a9baf5ccac7a7453f35fa53'
|
7
|
+
data.tar.gz: b3c6ba7179d7b777665f29b5cace4536181a428a5995c5e7d1d168b4ba6012fd333d191eb6ce23ab7b971a9cb8231dbfb999743c72bf91a1efe78ddec78223b7
|
data/CHANGELOG.md
CHANGED
@@ -6,6 +6,58 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
|
|
6
6
|
|
7
7
|
## [Unreleased]
|
8
8
|
|
9
|
+
## 4.1.0
|
10
|
+
|
11
|
+
### Added
|
12
|
+
|
13
|
+
- Custom license terms can be added to dependencies via new configuration options (https://github.com/github/licensed/pull/624)
|
14
|
+
- Licensed is now integrated with pnpm to enumerate dependencies (https://github.com/github/licensed/pull/626)
|
15
|
+
|
16
|
+
## 4.0.4
|
17
|
+
|
18
|
+
### Changed
|
19
|
+
|
20
|
+
- Dependency version requirements are more relaxed (https://github.com/github/licensed/pull/619)
|
21
|
+
|
22
|
+
## 4.0.3
|
23
|
+
|
24
|
+
### Changed
|
25
|
+
|
26
|
+
- Cocoapods dependency enumeration has been disabled (https://github.com/github/licensed/pull/616)
|
27
|
+
|
28
|
+
### Fixed
|
29
|
+
|
30
|
+
- Fixed method signature change in Bundler API with Bundler >= 2.4.4 (:tada: @CvX https://github.com/github/licensed/pull/614)
|
31
|
+
- Fixed installation dependency compatibility with Rails >= 7.0 (https://github.com/github/licensed/pull/616)
|
32
|
+
|
33
|
+
## 4.0.2
|
34
|
+
|
35
|
+
### Fixed
|
36
|
+
|
37
|
+
- The path to a gradlew executable can be configured when enumerating gradle dependencies (:tada: @LouisBoudreau https://github.com/github/licensed/pull/610)
|
38
|
+
|
39
|
+
## 4.0.1
|
40
|
+
|
41
|
+
### Fixed
|
42
|
+
|
43
|
+
- Running gradle tests will no longer fail when gradle is not available (https://github.com/github/licensed/pull/606)
|
44
|
+
|
45
|
+
## 4.0.0
|
46
|
+
|
47
|
+
### Added
|
48
|
+
|
49
|
+
- Licensed supports Cocoapods as a dependency source (:tada: @LouisBoudreau https://github.com/github/licensed/pull/584)
|
50
|
+
- Licensed supports Gradle multi-project builds (:tada: @LouisBoudreau https://github.com/github/licensed/pull/583)
|
51
|
+
|
52
|
+
### Fixed
|
53
|
+
|
54
|
+
- Licensed no longer crashes when run with Bundler >= 2.4.0 (:tada: @JoshReedSchramm https://github.com/github/licensed/pull/597)
|
55
|
+
|
56
|
+
### Changed
|
57
|
+
|
58
|
+
- BREAKING: Licensed no longer ships executables with releases (https://github.com/github/licensed/pull/586)
|
59
|
+
- BREAKING: Licensed no longer includes support for Go <= 1.11 (https://github.com/github/licensed/pull/602)
|
60
|
+
|
9
61
|
## 3.9.1
|
10
62
|
|
11
63
|
### Fixed
|
@@ -661,4 +713,4 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
|
|
661
713
|
|
662
714
|
Initial release :tada:
|
663
715
|
|
664
|
-
[Unreleased]: https://github.com/github/licensed/compare/
|
716
|
+
[Unreleased]: https://github.com/github/licensed/compare/4.1.0...HEAD
|
data/CONTRIBUTING.md
CHANGED
@@ -59,8 +59,6 @@ The following steps will happen automatically from a GitHub Actions workflow
|
|
59
59
|
after creating the release. In case that fails, the following steps can be performed manually
|
60
60
|
|
61
61
|
11. Push the gem from (7) to rubygems.org -- `gem push licensed-x.xx.xx.gem`
|
62
|
-
12. Build packages for new tag: `VERSION=x.xx.xx bundle exec rake package`
|
63
|
-
13. Upload packages from (12) to release from (10)
|
64
62
|
|
65
63
|
## Resources
|
66
64
|
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,112 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
licensed (4.1.0)
|
5
|
+
json (~> 2.6)
|
6
|
+
licensee (~> 9.16)
|
7
|
+
parallel (~> 1.22)
|
8
|
+
pathname-common_prefix (~> 0.0.1)
|
9
|
+
reverse_markdown (~> 2.1)
|
10
|
+
ruby-xxHash (~> 0.4.0)
|
11
|
+
thor (~> 1.2)
|
12
|
+
tomlrb (~> 2.0)
|
13
|
+
|
14
|
+
GEM
|
15
|
+
remote: https://rubygems.org/
|
16
|
+
specs:
|
17
|
+
activesupport (7.0.4.2)
|
18
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
19
|
+
i18n (>= 1.6, < 2)
|
20
|
+
minitest (>= 5.1)
|
21
|
+
tzinfo (~> 2.0)
|
22
|
+
addressable (2.8.1)
|
23
|
+
public_suffix (>= 2.0.2, < 6.0)
|
24
|
+
ast (2.4.2)
|
25
|
+
byebug (11.1.3)
|
26
|
+
concurrent-ruby (1.2.0)
|
27
|
+
dotenv (2.8.1)
|
28
|
+
faraday (2.7.4)
|
29
|
+
faraday-net_http (>= 2.0, < 3.1)
|
30
|
+
ruby2_keywords (>= 0.0.4)
|
31
|
+
faraday-net_http (3.0.2)
|
32
|
+
i18n (1.12.0)
|
33
|
+
concurrent-ruby (~> 1.0)
|
34
|
+
json (2.6.3)
|
35
|
+
licensee (9.16.0)
|
36
|
+
dotenv (~> 2.0)
|
37
|
+
octokit (>= 4.20, < 7.0)
|
38
|
+
reverse_markdown (>= 1, < 3)
|
39
|
+
rugged (>= 0.24, < 2.0)
|
40
|
+
thor (>= 0.19, < 2.0)
|
41
|
+
mini_portile2 (2.8.1)
|
42
|
+
minitest (5.17.0)
|
43
|
+
mocha (2.0.2)
|
44
|
+
ruby2_keywords (>= 0.0.5)
|
45
|
+
nokogiri (1.14.0)
|
46
|
+
mini_portile2 (~> 2.8.0)
|
47
|
+
racc (~> 1.4)
|
48
|
+
octokit (6.0.1)
|
49
|
+
faraday (>= 1, < 3)
|
50
|
+
sawyer (~> 0.9)
|
51
|
+
parallel (1.22.1)
|
52
|
+
parser (3.2.0.0)
|
53
|
+
ast (~> 2.4.1)
|
54
|
+
pathname-common_prefix (0.0.1)
|
55
|
+
public_suffix (5.0.1)
|
56
|
+
racc (1.6.2)
|
57
|
+
rack (3.0.4.1)
|
58
|
+
rainbow (3.1.1)
|
59
|
+
rake (13.0.6)
|
60
|
+
regexp_parser (2.6.2)
|
61
|
+
reverse_markdown (2.1.1)
|
62
|
+
nokogiri
|
63
|
+
rexml (3.2.5)
|
64
|
+
rubocop (1.44.1)
|
65
|
+
json (~> 2.3)
|
66
|
+
parallel (~> 1.10)
|
67
|
+
parser (>= 3.2.0.0)
|
68
|
+
rainbow (>= 2.2.2, < 4.0)
|
69
|
+
regexp_parser (>= 1.8, < 3.0)
|
70
|
+
rexml (>= 3.2.5, < 4.0)
|
71
|
+
rubocop-ast (>= 1.24.1, < 2.0)
|
72
|
+
ruby-progressbar (~> 1.7)
|
73
|
+
unicode-display_width (>= 2.4.0, < 3.0)
|
74
|
+
rubocop-ast (1.24.1)
|
75
|
+
parser (>= 3.1.1.0)
|
76
|
+
rubocop-github (0.20.0)
|
77
|
+
rubocop (>= 1.37)
|
78
|
+
rubocop-performance (>= 1.15)
|
79
|
+
rubocop-rails (>= 2.17)
|
80
|
+
rubocop-performance (1.15.2)
|
81
|
+
rubocop (>= 1.7.0, < 2.0)
|
82
|
+
rubocop-ast (>= 0.4.0)
|
83
|
+
rubocop-rails (2.17.4)
|
84
|
+
activesupport (>= 4.2.0)
|
85
|
+
rack (>= 1.1)
|
86
|
+
rubocop (>= 1.33.0, < 2.0)
|
87
|
+
ruby-progressbar (1.11.0)
|
88
|
+
ruby-xxHash (0.4.0.2)
|
89
|
+
ruby2_keywords (0.0.5)
|
90
|
+
rugged (1.5.1)
|
91
|
+
sawyer (0.9.2)
|
92
|
+
addressable (>= 2.3.5)
|
93
|
+
faraday (>= 0.17.3, < 3)
|
94
|
+
thor (1.2.1)
|
95
|
+
tomlrb (2.0.3)
|
96
|
+
tzinfo (2.0.5)
|
97
|
+
concurrent-ruby (~> 1.0)
|
98
|
+
unicode-display_width (2.4.2)
|
99
|
+
|
100
|
+
PLATFORMS
|
101
|
+
ruby
|
102
|
+
|
103
|
+
DEPENDENCIES
|
104
|
+
byebug (~> 11.1)
|
105
|
+
licensed!
|
106
|
+
minitest (~> 5.17)
|
107
|
+
mocha (~> 2.0)
|
108
|
+
rake (~> 13.0)
|
109
|
+
rubocop-github (~> 0.20)
|
110
|
+
|
111
|
+
BUNDLED WITH
|
112
|
+
2.3.26
|
data/README.md
CHANGED
@@ -1,8 +1,6 @@
|
|
1
1
|
# Licensed
|
2
2
|
|
3
|
-
Licensed caches the licenses of dependencies and checks their status.
|
4
|
-
|
5
|
-
Licensed is available as a Ruby gem for Ruby environments, and as a self-contained executable for non-Ruby environments.
|
3
|
+
Licensed caches the licenses of dependencies and checks their status, and is available as a Ruby gem.
|
6
4
|
|
7
5
|
Licensed is **not** a complete open source license compliance solution. Please understand the important [disclaimer](#disclaimer) below to make appropriate use of Licensed.
|
8
6
|
|
@@ -12,6 +10,10 @@ Licensed is **not** a complete open source license compliance solution. Please u
|
|
12
10
|
|
13
11
|
Licensed is in active development and currently used at GitHub. See the [open issues](https://github.com/github/licensed/issues) for a list of potential work.
|
14
12
|
|
13
|
+
## Licensed v4 - **Removed support for non-Ruby environments**
|
14
|
+
|
15
|
+
Licensed v4 no longer provides a self-contained executable build of licensed. Please see [the deprecation notice](https://github.com/github/licensed/issues/585) for more context.
|
16
|
+
|
15
17
|
## Licensed v3
|
16
18
|
|
17
19
|
Licensed v3 includes a breaking change if both of the following are true:
|
@@ -59,19 +61,12 @@ And then execute:
|
|
59
61
|
$> bundle
|
60
62
|
```
|
61
63
|
|
62
|
-
###
|
63
|
-
|
64
|
-
Download a package from GitHub and extract the executable. Executable packages are available for each release starting with version 1.2.0.
|
64
|
+
### With a Homebrew (on macOS)
|
65
65
|
|
66
66
|
```bash
|
67
|
-
|
68
|
-
$> tar -xzf licensed.tar.gz
|
69
|
-
$> rm -f licensed.tar.gz
|
70
|
-
$> ./licensed list
|
67
|
+
brew install licensed
|
71
68
|
```
|
72
69
|
|
73
|
-
For system wide usage, install licensed to a location on `$PATH`, e.g. `/usr/local/bin`.
|
74
|
-
|
75
70
|
## Usage
|
76
71
|
|
77
72
|
See [getting started](./docs/getting_started.md) for guidance using Licensed as part of your developer workflow.
|
data/Rakefile
CHANGED
@@ -72,32 +72,6 @@ Rake::TestTask.new(:test) do |t|
|
|
72
72
|
t.test_files = FileList["test/**/*_test.rb"].exclude("test/fixtures/**/*_test.rb")
|
73
73
|
end
|
74
74
|
|
75
|
-
packages_search = File.expand_path("script/packages/*", __dir__)
|
76
|
-
platforms = Dir[packages_search].map { |f| File.basename(f, ".*") }
|
77
|
-
.reject { |f| f == "build" }
|
78
|
-
|
79
|
-
namespace :package do
|
80
|
-
platforms.each do |platform|
|
81
|
-
desc "Package licensed for #{platform}"
|
82
|
-
task platform.to_sym do
|
83
|
-
puts "Packaging licensed for #{platform}"
|
84
|
-
|
85
|
-
if Bundler.with_original_env { system("script/packages/#{platform}") }
|
86
|
-
# green
|
87
|
-
puts "\033[32mCompleted packaging for #{platform}.\e[0m"
|
88
|
-
else
|
89
|
-
# red
|
90
|
-
puts "\033[31mEncountered an error packaging for #{platform}.\e[0m"
|
91
|
-
end
|
92
|
-
|
93
|
-
puts
|
94
|
-
end
|
95
|
-
end
|
96
|
-
end
|
97
|
-
|
98
|
-
desc "Package licensed for all platforms"
|
99
|
-
task package: platforms.map { |platform| "package:#{platform}" }
|
100
|
-
|
101
75
|
# add rubocop task
|
102
76
|
# -S adds styleguide urls to offense messages
|
103
77
|
RuboCop::RakeTask.new do |t|
|
@@ -0,0 +1,41 @@
|
|
1
|
+
# Additional terms
|
2
|
+
|
3
|
+
The `additional_terms` configuration option is used to specify paths to files containing extra licensing terms that do not ship with the dependency package. All files specified are expected to be plain text.
|
4
|
+
|
5
|
+
Files containing additional content can be located anywhere on disk that is accessible to licensed. File paths can be specified as a string or array and can contain glob values to simplify configuration inputs. All file paths are evaluated from the [configuration root](./configuration_root.md).
|
6
|
+
|
7
|
+
## Examples
|
8
|
+
|
9
|
+
**Note** The examples below specify paths to additional files under the `.licenses` folder. This is a logical place to store files containing license terms, but be careful not to store files under paths managed by licensed like `.licenses/<source type>/...`. Running `licensed cache` in the future will delete any files under licensed managed paths that licensed did not create. This is why the below examples use paths like `.licenses/amendments/bundler/...` instead of not `.licenses/bundler/amendments/...`.
|
10
|
+
|
11
|
+
### With a string
|
12
|
+
|
13
|
+
```yaml
|
14
|
+
additional_terms:
|
15
|
+
# specify the type of dependency
|
16
|
+
bundler:
|
17
|
+
# specify the dependency name and path to an additional file
|
18
|
+
<gem-name>: .licenses/amendments/bundler/<gem-name>/terms.txt
|
19
|
+
```
|
20
|
+
|
21
|
+
### With a glob string
|
22
|
+
|
23
|
+
```yaml
|
24
|
+
additional_terms:
|
25
|
+
# specify the type of dependency
|
26
|
+
bundler:
|
27
|
+
# specify the dependency name and one or more additional files with a glob pattern
|
28
|
+
<gem-name>: .licenses/amendments/bundler/<gem-name>/*.txt
|
29
|
+
```
|
30
|
+
|
31
|
+
### With an array of strings
|
32
|
+
|
33
|
+
```yaml
|
34
|
+
additional_terms:
|
35
|
+
# specify the type of dependency
|
36
|
+
bundler:
|
37
|
+
# specify the dependency name and array of paths to additional files
|
38
|
+
<gem-name>:
|
39
|
+
- .licenses/amendments/bundler/<gem-name>/terms-1.txt
|
40
|
+
- .licenses/amendments/bundler/<gem-name>/terms-2.txt
|
41
|
+
```
|
data/docs/configuration.md
CHANGED
@@ -67,6 +67,13 @@ reviewed:
|
|
67
67
|
- classlist # public domain
|
68
68
|
- octicons
|
69
69
|
|
70
|
+
# Specify additional license terms that have been obtained from a dependency's owner
|
71
|
+
# which apply to the dependency's license
|
72
|
+
additional_terms:
|
73
|
+
bundler:
|
74
|
+
bcrypt-ruby:
|
75
|
+
- .licenses/amendments/bundler/bcrypt-ruby/amendment.txt
|
76
|
+
|
70
77
|
# A single configuration file can be used to enumerate dependencies for multiple
|
71
78
|
# projects. Each configuration is referred to as an "application" and must include
|
72
79
|
# a source path, at a minimum
|
data/docs/sources/bundler.md
CHANGED
@@ -2,8 +2,6 @@
|
|
2
2
|
|
3
3
|
The bundler source will detect dependencies `Gemfile` and `Gemfile.lock` files are found at an apps `source_path`. The source uses the `Bundler` API to enumerate dependencies from `Gemfile` and `Gemfile.lock`.
|
4
4
|
|
5
|
-
**Note** The bundler source cannot be used when running the [packaged licensed executable](../packaging.md)
|
6
|
-
|
7
5
|
### Excluding gem groups
|
8
6
|
|
9
7
|
The bundler source determines which gem groups to include or exclude with the following logic, in order of precedence.
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# CocoaPods
|
2
|
+
|
3
|
+
**NOTE!**: Enumerating Cocoapods dependencies is disabled until the cocoapods-core gem is compatible with Rails 7+. See https://github.com/CocoaPods/Core/pull/733
|
4
|
+
|
5
|
+
The cocoapods source will detect dependencies when `Podfile` and `Podfile.lock` are found at an app's `source_path`.
|
6
|
+
|
7
|
+
It uses the `pod` CLI commands to enumerate dependencies and gather metadata on each package.
|
8
|
+
|
9
|
+
## Evaluating dependencies from a specific target
|
10
|
+
|
11
|
+
The `cocoapods.targets` property is used to specify which targets to analyze dependencies from. By default, dependencies from all targets will be analyzed.
|
12
|
+
|
13
|
+
```yml
|
14
|
+
cocoapods:
|
15
|
+
targets:
|
16
|
+
- ios
|
17
|
+
```
|
data/docs/sources/gradle.md
CHANGED
@@ -14,3 +14,21 @@ gradle:
|
|
14
14
|
- runtime
|
15
15
|
- runtimeClassPath
|
16
16
|
```
|
17
|
+
|
18
|
+
### Multi-build projects
|
19
|
+
|
20
|
+
To run `licensed` for specific projects in a [multi-build project](https://docs.gradle.org/current/userguide/multi_project_builds.html) you must specify the [apps](../configuration/application_source.md) configuration key.
|
21
|
+
|
22
|
+
```yml
|
23
|
+
apps:
|
24
|
+
- source_path: ./path/to/subproject
|
25
|
+
```
|
26
|
+
|
27
|
+
### Gradlew
|
28
|
+
|
29
|
+
The `gradle.gradlew` property is used to determine where the `gradlew` executable is. The default location the [configuration root](../configuration/configuration_root.md).
|
30
|
+
|
31
|
+
```yml
|
32
|
+
gradle:
|
33
|
+
gradlew: path/from/root/to/gradle/gradlew
|
34
|
+
```
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# pnpm
|
2
|
+
|
3
|
+
The npm source will detect dependencies when `pnpm-lock.yaml` is found at an apps `source_path`. It uses `pnpm licenses list` to enumerate dependencies and metadata.
|
4
|
+
|
5
|
+
**NOTE** [pnpm licenses list](https://pnpm.io/cli/licenses) is an experimental CLI command and subject to change. If changes to pnpm result in unexpected or broken behavior in licensed please open an [issue](https://github.com/github/licensed/issues/new).
|
6
|
+
|
7
|
+
## Including development dependencies
|
8
|
+
|
9
|
+
By default, the npm source will exclude all development dependencies. To include development or test dependencies, set `production_only: false` in the licensed configuration.
|
10
|
+
|
11
|
+
```yml
|
12
|
+
pnpm:
|
13
|
+
production_only: false
|
14
|
+
```
|
15
|
+
|
16
|
+
## Using licensed with pnpm workspaces
|
17
|
+
|
18
|
+
Licensed will locate all dependencies from all pnpm workspaces and cannot enumerate dependencies from individual project workspaces. This is a limitation from the pnpm CLI.
|
@@ -109,6 +109,12 @@ module Licensed
|
|
109
109
|
self["allowed"] << license
|
110
110
|
end
|
111
111
|
|
112
|
+
# Returns an array of paths to files containing additional license terms.
|
113
|
+
def additional_terms_for_dependency(dependency)
|
114
|
+
amendment_paths = Array(self.dig("additional_terms", dependency["type"], dependency["name"]))
|
115
|
+
amendment_paths.flat_map { |path| Dir.glob(self.root.join(path)) }
|
116
|
+
end
|
117
|
+
|
112
118
|
private
|
113
119
|
|
114
120
|
def any_list_pattern_matched?(list, dependency, match_version: false)
|
@@ -355,7 +361,6 @@ module Licensed
|
|
355
361
|
def default_options
|
356
362
|
# manually set a cache path without additional name
|
357
363
|
{
|
358
|
-
"source_path" => Dir.pwd,
|
359
364
|
"cache_path" => AppConfiguration::DEFAULT_CACHE_PATH
|
360
365
|
}
|
361
366
|
end
|
data/lib/licensed/dependency.rb
CHANGED
@@ -9,6 +9,7 @@ module Licensed
|
|
9
9
|
attr_reader :version
|
10
10
|
attr_reader :errors
|
11
11
|
attr_reader :path
|
12
|
+
attr_reader :additional_terms
|
12
13
|
|
13
14
|
# Create a new project dependency
|
14
15
|
#
|
@@ -28,6 +29,7 @@ module Licensed
|
|
28
29
|
@errors = errors
|
29
30
|
path = path.to_s
|
30
31
|
@path = path
|
32
|
+
@additional_terms = []
|
31
33
|
|
32
34
|
# enforcing absolute paths makes life much easier when determining
|
33
35
|
# an absolute file path in #notices
|
@@ -80,6 +82,13 @@ module Licensed
|
|
80
82
|
files.compact
|
81
83
|
end
|
82
84
|
|
85
|
+
|
86
|
+
# Override the behavior of Licensee::Projects::FSProject#project_files to include
|
87
|
+
# additional license terms
|
88
|
+
def project_files
|
89
|
+
super + additional_license_terms_files
|
90
|
+
end
|
91
|
+
|
83
92
|
# Returns legal notices found at the dependency path
|
84
93
|
def notice_contents
|
85
94
|
Dir.glob(dir_path.join("*"))
|
@@ -102,6 +111,7 @@ module Licensed
|
|
102
111
|
def license_content_sources(files)
|
103
112
|
paths = Array(files).map do |file|
|
104
113
|
next file[:uri] if file[:uri]
|
114
|
+
next file[:source] if file[:source]
|
105
115
|
|
106
116
|
path = dir_path.join(file[:dir], file[:name])
|
107
117
|
normalize_source_path(path)
|
@@ -157,5 +167,22 @@ module Licensed
|
|
157
167
|
"text" => text
|
158
168
|
}
|
159
169
|
end
|
170
|
+
|
171
|
+
# Returns an array of Licensee::ProjectFiles::LicenseFile created from
|
172
|
+
# this dependency's additional license terms
|
173
|
+
def additional_license_terms_files
|
174
|
+
@additional_license_terms_files ||= begin
|
175
|
+
files = additional_terms.map do |path|
|
176
|
+
next unless File.file?(path)
|
177
|
+
|
178
|
+
metadata = { dir: File.dirname(path), name: File.basename(path) }
|
179
|
+
Licensee::ProjectFiles::LicenseFile.new(
|
180
|
+
load_file(metadata),
|
181
|
+
{ source: "License terms loaded from #{metadata[:name]}" }
|
182
|
+
)
|
183
|
+
end
|
184
|
+
files.compact
|
185
|
+
end
|
186
|
+
end
|
160
187
|
end
|
161
188
|
end
|
@@ -18,7 +18,7 @@ module Licensed
|
|
18
18
|
|
19
19
|
all_dependencies = requested_dependencies.concat(specs.flat_map(&:dependencies))
|
20
20
|
if all_dependencies.any? { |d| d.name == "bundler" } && !specs["bundler"].any?
|
21
|
-
bundler = sources.metadata_source.specs.search(
|
21
|
+
bundler = sources.metadata_source.specs.search(bundler_query).last
|
22
22
|
specs["bundler"] = bundler
|
23
23
|
end
|
24
24
|
|
@@ -26,6 +26,14 @@ module Licensed
|
|
26
26
|
end
|
27
27
|
end
|
28
28
|
|
29
|
+
def bundler_query
|
30
|
+
if Gem::Version.new(::Bundler::VERSION) >= Gem::Version.new("2.4.0")
|
31
|
+
["bundler", ::Bundler.gem_version]
|
32
|
+
else
|
33
|
+
Gem::Dependency.new("bundler", ::Bundler::VERSION)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
29
37
|
# Override requested_groups to also exclude any groups that are
|
30
38
|
# in the "bundler.without" section of the licensed configuration file.
|
31
39
|
def requested_groups
|
@@ -47,8 +47,8 @@ module Licensed
|
|
47
47
|
Licensed::Bundler::MissingSpecification.new(name: name, version: version, platform: platform, source: source)
|
48
48
|
end
|
49
49
|
|
50
|
-
def __materialize__(*args)
|
51
|
-
spec = super(*args)
|
50
|
+
def __materialize__(*args, **kwargs)
|
51
|
+
spec = super(*args, **kwargs)
|
52
52
|
return spec if spec
|
53
53
|
|
54
54
|
Licensed::Bundler::MissingSpecification.new(name: name, version: version, platform: platform, source: source)
|
@@ -39,13 +39,8 @@ module Licensed
|
|
39
39
|
end
|
40
40
|
|
41
41
|
DEFAULT_WITHOUT_GROUPS = %i{development test}
|
42
|
-
RUBY_PACKER_ERROR = "The bundler source cannot be used from the executable built with ruby-packer. Please install licensed using `gem install` or using bundler."
|
43
42
|
|
44
43
|
def enabled?
|
45
|
-
# running a ruby-packer-built licensed exe when ruby isn't available
|
46
|
-
# could lead to errors if the host ruby doesn't exist
|
47
|
-
return false if ruby_packer? && !Licensed::Shell.tool_available?("ruby")
|
48
|
-
|
49
44
|
# if Bundler isn't loaded, this enumerator won't work!
|
50
45
|
return false unless defined?(::Bundler)
|
51
46
|
|
@@ -55,8 +50,6 @@ module Licensed
|
|
55
50
|
end
|
56
51
|
|
57
52
|
def enumerate_dependencies
|
58
|
-
raise Licensed::Sources::Source::Error.new(RUBY_PACKER_ERROR) if ruby_packer?
|
59
|
-
|
60
53
|
with_application_environment do
|
61
54
|
definition.specs.map do |spec|
|
62
55
|
next if spec.name == config["name"]
|
@@ -126,11 +119,6 @@ module Licensed
|
|
126
119
|
# reload the bundler environment after enumeration
|
127
120
|
::Bundler.load
|
128
121
|
end
|
129
|
-
|
130
|
-
# Returns whether the current licensed execution is running ruby-packer
|
131
|
-
def ruby_packer?
|
132
|
-
@ruby_packer ||= RbConfig::TOPDIR =~ /__enclose_io_memfs__/
|
133
|
-
end
|
134
122
|
end
|
135
123
|
end
|
136
124
|
end
|
@@ -0,0 +1,68 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require "json"
|
3
|
+
require "pathname"
|
4
|
+
require "uri"
|
5
|
+
|
6
|
+
# **NOTE** Cocoapods is disabled until cocoapods-core supports recent rails versions
|
7
|
+
# https://github.com/CocoaPods/Core/pull/733
|
8
|
+
# require "cocoapods-core"
|
9
|
+
|
10
|
+
module Licensed
|
11
|
+
module Sources
|
12
|
+
class Cocoapods < Source
|
13
|
+
def enabled?
|
14
|
+
false
|
15
|
+
|
16
|
+
# return unless Licensed::Shell.tool_available?("pod")
|
17
|
+
|
18
|
+
# config.pwd.join("Podfile").exist? && config.pwd.join("Podfile.lock").exist?
|
19
|
+
end
|
20
|
+
|
21
|
+
def enumerate_dependencies
|
22
|
+
pods.map do |pod|
|
23
|
+
name = pod.name
|
24
|
+
path = dependency_path(pod.root_name)
|
25
|
+
version = lockfile.version(name).version
|
26
|
+
|
27
|
+
Dependency.new(
|
28
|
+
path: path,
|
29
|
+
name: name,
|
30
|
+
version: version,
|
31
|
+
metadata: { "type" => Cocoapods.type }
|
32
|
+
)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
private
|
37
|
+
|
38
|
+
def pods
|
39
|
+
return lockfile.dependencies if targets.nil?
|
40
|
+
|
41
|
+
targets_to_validate = podfile.target_definition_list.filter { |t| targets.include?(t.label) }
|
42
|
+
if targets_to_validate.any?
|
43
|
+
targets_to_validate.map(&:dependencies).flatten
|
44
|
+
else
|
45
|
+
raise Licensed::Sources::Source::Error, "Unable to find any target in the Podfile matching the ones provided in the config."
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
def targets
|
50
|
+
@targets ||= config.dig("cocoapods", "targets")&.map { |t| "Pods-#{t}" }
|
51
|
+
end
|
52
|
+
|
53
|
+
def lockfile
|
54
|
+
@lockfile = nil
|
55
|
+
# @lockfile ||= Pod::Lockfile.from_file(config.pwd.join("Podfile.lock"))
|
56
|
+
end
|
57
|
+
|
58
|
+
def podfile
|
59
|
+
@podfile = nil
|
60
|
+
# @podfile ||= Pod::Podfile.from_file(config.pwd.join("Podfile"))
|
61
|
+
end
|
62
|
+
|
63
|
+
def dependency_path(name)
|
64
|
+
config.pwd.join("Pods/#{name}")
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|