licensed 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +3 -0
- data/.rubocop.yml +5 -0
- data/.travis.yml +55 -4
- data/CHANGELOG.md +13 -2
- data/CONTRIBUTING.md +11 -1
- data/README.md +2 -0
- data/Rakefile +53 -0
- data/docs/configuration.md +6 -6
- data/docs/sources/go.md +14 -1
- data/lib/licensed/command/cache.rb +11 -8
- data/lib/licensed/command/status.rb +1 -1
- data/lib/licensed/dependency.rb +8 -3
- data/lib/licensed/license.rb +26 -2
- data/lib/licensed/source/bundler.rb +43 -13
- data/lib/licensed/source/cabal.rb +1 -1
- data/lib/licensed/source/go.rb +51 -21
- data/lib/licensed/version.rb +1 -1
- data/licensed.gemspec +1 -0
- data/script/bootstrap +1 -39
- data/script/setup +5 -0
- data/script/source-setup/bower +12 -0
- data/script/source-setup/bundler +16 -0
- data/script/source-setup/cabal +12 -0
- data/script/source-setup/go +13 -0
- data/script/source-setup/npm +12 -0
- data/script/test +16 -0
- metadata +23 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9e7af8fc6ca23f14500bc88d7766153dbc21ef30
|
4
|
+
data.tar.gz: 50c1b4ffdf8ef72d4b7bfd20e3b0aff031e7e843
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 587c4b056a4741e0d25b41551612f287140636bef7a9ddb76dd1231a8e2316a1e50ea2438b599216f6f63c6fc2268b32761df9e098d04587c8848b8e68cbc0cb
|
7
|
+
data.tar.gz: ede02755d459ecf6a42f4c7b9c9a0339b0e9294d9db94c271d3b00984de3825c504a43fa8c8792ac3d355356f90119d8757077237078bb3ee2d973654a4c27af
|
data/.gitignore
CHANGED
data/.rubocop.yml
CHANGED
data/.travis.yml
CHANGED
@@ -1,4 +1,55 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
1
|
+
install: ./script/bootstrap
|
2
|
+
|
3
|
+
matrix:
|
4
|
+
include:
|
5
|
+
# lint and build
|
6
|
+
- language: ruby
|
7
|
+
rvm: 2.4.0
|
8
|
+
script: bundle exec rake rubocop build
|
9
|
+
env: NAME="Lint and Build"
|
10
|
+
|
11
|
+
# go tests
|
12
|
+
- language: go
|
13
|
+
go: 1.7.x
|
14
|
+
before_script: ./script/source-setup/go
|
15
|
+
script: ./script/test go
|
16
|
+
env: NAME="go"
|
17
|
+
|
18
|
+
# cabal tests
|
19
|
+
- language: haskell
|
20
|
+
ghc: "8.2"
|
21
|
+
before_script: ./script/source-setup/cabal
|
22
|
+
script: ./script/test cabal
|
23
|
+
env: NAME="cabal"
|
24
|
+
|
25
|
+
# npm tests
|
26
|
+
- language: node_js
|
27
|
+
node_js: "8"
|
28
|
+
before_script: ./script/source-setup/npm
|
29
|
+
script: ./script/test npm
|
30
|
+
env: NAME="npm"
|
31
|
+
|
32
|
+
# bower tests
|
33
|
+
- language: node_js
|
34
|
+
node_js: "8"
|
35
|
+
before_script:
|
36
|
+
- npm install -g bower
|
37
|
+
- ./script/source-setup/bower
|
38
|
+
script: ./script/test bower
|
39
|
+
env: NAME="bower"
|
40
|
+
|
41
|
+
# bundler tests
|
42
|
+
- language: ruby
|
43
|
+
rvm: 2.4.0
|
44
|
+
before_script: ./script/source-setup/bundler
|
45
|
+
script: ./script/test bundler
|
46
|
+
env: NAME="bundler"
|
47
|
+
|
48
|
+
# manifest tests
|
49
|
+
- language: ruby
|
50
|
+
rvm: 2.4.0
|
51
|
+
script: ./script/test manifest
|
52
|
+
env: NAME="manifest"
|
53
|
+
|
54
|
+
notifications:
|
55
|
+
disable: true
|
data/CHANGELOG.md
CHANGED
@@ -6,8 +6,19 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
|
|
6
6
|
|
7
7
|
## [Unreleased]
|
8
8
|
|
9
|
-
## 1.0.
|
9
|
+
## 1.0.1 - 2018-04-26
|
10
|
+
### Added
|
11
|
+
- GOPATH settable in configuration file
|
12
|
+
|
13
|
+
### Changed
|
14
|
+
- Reuse "license" metadata property when license text has not changed
|
15
|
+
|
16
|
+
### Fixed
|
17
|
+
- Path expansion for cabal "ghc_package_db" configuration setting occurs from repository root
|
18
|
+
- Local Gemfile(.lock) files correctly used in enumerating Bundler source dependencies
|
19
|
+
|
20
|
+
## 1.0.0 - 2018-02-20
|
10
21
|
|
11
22
|
Initial release :tada:
|
12
23
|
|
13
|
-
[Unreleased]: https://github.com/github/licensed/compare/v1.0.
|
24
|
+
[Unreleased]: https://github.com/github/licensed/compare/v1.0.1...HEAD
|
data/CONTRIBUTING.md
CHANGED
@@ -13,7 +13,8 @@ Please note that this project is released with a [Contributor Code of Conduct][c
|
|
13
13
|
|
14
14
|
0. [Fork][fork] and clone the repository
|
15
15
|
0. Configure and install the dependencies: `script/bootstrap`
|
16
|
-
0.
|
16
|
+
0. Setup test fixtures: `rake setup`
|
17
|
+
0. Make sure the tests pass on your machine: `rake test`
|
17
18
|
0. Create a new branch: `git checkout -b my-branch-name`
|
18
19
|
0. Make your change, add tests, and make sure the tests still pass
|
19
20
|
0. Push to your fork and [submit a pull request][pr]
|
@@ -26,6 +27,15 @@ Here are a few things you can do that will increase the likelihood of your pull
|
|
26
27
|
- Keep your change as focused as possible. If there are multiple changes you would like to make that are not dependent upon each other, consider submitting them as separate pull requests.
|
27
28
|
- Write a [good commit message](http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html).
|
28
29
|
|
30
|
+
#### Adding a new Dependency Source
|
31
|
+
|
32
|
+
Pull requests that include a new dependency source must also
|
33
|
+
|
34
|
+
- Include [documentation](docs/sources) for the new source and update the [documented source list](README.md#sources).
|
35
|
+
- Add a [setup script](script/source-setup) if needed.
|
36
|
+
- Include [tests](test/source) and [test fixtures](test/fixtures) needed to verify the source in CI.
|
37
|
+
- Add a CI job to [.travis.yml](.travis.yml).
|
38
|
+
|
29
39
|
## Releasing
|
30
40
|
If you are the current maintainer of this gem:
|
31
41
|
|
data/README.md
CHANGED
@@ -6,6 +6,8 @@ Licensed is **not** a complete open source license compliance solution. Please u
|
|
6
6
|
|
7
7
|
## Current Status
|
8
8
|
|
9
|
+
[![Build Status](https://travis-ci.org/github/licensed.svg?branch=master)](https://travis-ci.org/github/licensed)
|
10
|
+
|
9
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.
|
10
12
|
|
11
13
|
## Installation
|
data/Rakefile
CHANGED
@@ -1,6 +1,53 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
require "bundler/gem_tasks"
|
3
3
|
require "rake/testtask"
|
4
|
+
require "rubocop/rake_task"
|
5
|
+
|
6
|
+
desc "Run source setup scripts"
|
7
|
+
task :setup do
|
8
|
+
Dir["script/source-setup/*"].each do |script|
|
9
|
+
# green
|
10
|
+
puts "\033[32mRunning #{script}.\e[0m"
|
11
|
+
|
12
|
+
if system(script)
|
13
|
+
# green
|
14
|
+
puts "\033[32mCompleted #{script}.\e[0m"
|
15
|
+
elsif $?.exitstatus == 127
|
16
|
+
# yellow
|
17
|
+
puts "\033[33mSkipped #{script}.\e[0m"
|
18
|
+
else
|
19
|
+
# red
|
20
|
+
puts "\033[31mEncountered an error running #{script}.\e[0m"
|
21
|
+
end
|
22
|
+
|
23
|
+
puts
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
sources_search = File.expand_path("lib/licensed/source/*.rb", __dir__)
|
28
|
+
sources = Dir[sources_search].map { |f| File.basename(f, ".*") }
|
29
|
+
|
30
|
+
namespace :test do
|
31
|
+
sources.each do |source|
|
32
|
+
# hidden task to set ENV and filter tests to the given source
|
33
|
+
# see `each_source` in test/test_helper.rb
|
34
|
+
namespace source.to_sym do
|
35
|
+
task :env do
|
36
|
+
ENV["SOURCE"] = source
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
Rake::TestTask.new(source => "test:#{source}:env") do |t|
|
41
|
+
t.description = "Run #{source} tests"
|
42
|
+
t.libs << "test"
|
43
|
+
t.libs << "lib"
|
44
|
+
|
45
|
+
# use negative lookahead to exclude all source tests except
|
46
|
+
# the tests for `source`
|
47
|
+
t.test_files = FileList["test/**/*_test.rb"].exclude(/test\/source\/(?!#{source}).*?_test.rb/)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
4
51
|
|
5
52
|
Rake::TestTask.new(:test) do |t|
|
6
53
|
t.libs << "test"
|
@@ -8,4 +55,10 @@ Rake::TestTask.new(:test) do |t|
|
|
8
55
|
t.test_files = FileList["test/**/*_test.rb"]
|
9
56
|
end
|
10
57
|
|
58
|
+
# add rubocop task
|
59
|
+
# -S adds styleguide urls to offense messages
|
60
|
+
RuboCop::RakeTask.new do |t|
|
61
|
+
t.options.push "-S"
|
62
|
+
end
|
63
|
+
|
11
64
|
task default: :test
|
data/docs/configuration.md
CHANGED
@@ -25,8 +25,8 @@ source_path: 'relative/path/to/source'
|
|
25
25
|
# Sources of metadata
|
26
26
|
# All sources will attempt to run unless explicitly disabled
|
27
27
|
sources:
|
28
|
-
|
29
|
-
|
28
|
+
bower: true
|
29
|
+
rubygem: false
|
30
30
|
|
31
31
|
# Dependencies with these licenses are allowed by default.
|
32
32
|
allowed:
|
@@ -71,8 +71,8 @@ Here are some examples:
|
|
71
71
|
#### Inheriting configuration
|
72
72
|
```yml
|
73
73
|
sources:
|
74
|
-
|
75
|
-
|
74
|
+
go: true
|
75
|
+
rubygem: false
|
76
76
|
|
77
77
|
ignored:
|
78
78
|
rubygem:
|
@@ -87,8 +87,8 @@ apps:
|
|
87
87
|
- source_path: 'path/to/app1'
|
88
88
|
- source_path: 'path/to/app2'
|
89
89
|
sources:
|
90
|
-
|
91
|
-
|
90
|
+
rubygem: true
|
91
|
+
go: false
|
92
92
|
```
|
93
93
|
|
94
94
|
In this example, two apps have been declared. The first app, with `source_path` `path/to/app1`, inherits all configuration settings from the root configuration. The second app, with `source_path` `path/to/app2`, overrides the `sources` configuration and inherits all other settings.
|
data/docs/sources/go.md
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
# Go
|
2
2
|
|
3
|
-
The go source uses `go` CLI commands to enumerate dependencies and properties. It is expected that `go` projects have been built, and that `
|
3
|
+
The go source uses `go` CLI commands to enumerate dependencies and properties. It is expected that `go` projects have been built, and that `go` environment variables are properly set before running `licensed`.
|
4
4
|
|
5
|
+
#### Source paths
|
5
6
|
Source paths for go projects should point to a location that contains an entrypoint to the executable or library.
|
6
7
|
|
7
8
|
An example usage might see a configuration like:
|
@@ -10,3 +11,15 @@ source_path: go/path/src/github.com/BurntSushi/toml/cmd/tomlv
|
|
10
11
|
```
|
11
12
|
|
12
13
|
Note that this configuration points directly to the tomlv command source, which contains `func main`.
|
14
|
+
|
15
|
+
#### GOPATH
|
16
|
+
A valid `GOPATH` is required to successfully find `go` dependencies. If `GOPATH` is not available in the calling environment, or if a different `GOPATH` is needed than what is set in the calling environment, a value can be set in the `licensed` configuration file.
|
17
|
+
|
18
|
+
```yaml
|
19
|
+
go:
|
20
|
+
GOPATH: ~/go
|
21
|
+
```
|
22
|
+
|
23
|
+
The setting supports absolute, relative and expandable (e.g. "~") paths. Relative paths are considered relative to the repository root.
|
24
|
+
|
25
|
+
Non-empty `GOPATH` configuration settings will override the `GOPATH` environment variable while enumerating `go` dependencies. The `GOPATH` environment variable is restored once dependencies have been enumerated.
|
@@ -34,19 +34,22 @@ module Licensed
|
|
34
34
|
names << name
|
35
35
|
filename = cache_path.join("#{name}.txt")
|
36
36
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
37
|
+
# try to load existing license from disk
|
38
|
+
# or default to a blank license
|
39
|
+
license = Licensed::License.read(filename) || Licensed::License.new
|
40
|
+
|
41
|
+
# Version did not change, no need to re-cache
|
42
|
+
if !force && version == license["version"]
|
43
|
+
@config.ui.info " Using #{name} (#{version})"
|
44
|
+
next
|
45
45
|
end
|
46
46
|
|
47
47
|
@config.ui.info " Caching #{name} (#{version})"
|
48
48
|
|
49
49
|
dependency.detect_license!
|
50
|
+
# use the cached license value if the license text wasn't updated
|
51
|
+
dependency["license"] = license["license"] if dependency.license_text_match?(license)
|
52
|
+
|
50
53
|
dependency.save(filename)
|
51
54
|
end
|
52
55
|
|
@@ -36,7 +36,7 @@ module Licensed
|
|
36
36
|
if license["version"] != dependency["version"]
|
37
37
|
warnings << "cached license data out of date"
|
38
38
|
end
|
39
|
-
warnings << "missing license text" if license.
|
39
|
+
warnings << "missing license text" if license.license_text.empty?
|
40
40
|
unless allowed_or_reviewed?(app, license)
|
41
41
|
warnings << "license needs reviewed: #{license["license"]}."
|
42
42
|
end
|
data/lib/licensed/dependency.rb
CHANGED
@@ -32,12 +32,16 @@ module Licensed
|
|
32
32
|
# `dependency["license"]` and legal text is set to `dependency.text`
|
33
33
|
def detect_license!
|
34
34
|
self["license"] = license_key
|
35
|
-
self.text =
|
35
|
+
self.text = [license_text, *notices].join("\n" + TEXT_SEPARATOR + "\n").strip
|
36
36
|
end
|
37
37
|
|
38
38
|
# Extract legal notices from the dependency source
|
39
39
|
def notices
|
40
|
-
local_files.uniq
|
40
|
+
local_files.uniq # unique local file paths
|
41
|
+
.sort # sorted by the path
|
42
|
+
.map { |f| File.read(f) } # read the file contents
|
43
|
+
.map(&:strip) # strip whitespace
|
44
|
+
.select { |t| t.length > 0 } # files with content only
|
41
45
|
end
|
42
46
|
|
43
47
|
# Returns an array of file paths used to locate legal notices
|
@@ -74,7 +78,8 @@ module Licensed
|
|
74
78
|
# Returns a Licensee::LicenseFile with the content of the license in the
|
75
79
|
# dependency's repository to account for LICENSE files not being distributed
|
76
80
|
def remote_license_file
|
77
|
-
@remote_license_file
|
81
|
+
return @remote_license_file if defined?(@remote_license_file)
|
82
|
+
@remote_license_file = Licensed.from_github(self["homepage"])
|
78
83
|
end
|
79
84
|
|
80
85
|
# Regardless of the license detected, try to pull the license content
|
data/lib/licensed/license.rb
CHANGED
@@ -2,11 +2,15 @@
|
|
2
2
|
require "yaml"
|
3
3
|
require "fileutils"
|
4
4
|
require "forwardable"
|
5
|
+
require "licensee"
|
5
6
|
|
6
7
|
module Licensed
|
7
8
|
class License
|
9
|
+
include Licensee::ContentHelper
|
10
|
+
extend Forwardable
|
11
|
+
|
8
12
|
YAML_FRONTMATTER_PATTERN = /\A---\s*\n(.*?\n?)^---\s*$\n?(.*)\z/m
|
9
|
-
|
13
|
+
TEXT_SEPARATOR = ("-" * 80).freeze
|
10
14
|
|
11
15
|
# Read an existing license file
|
12
16
|
#
|
@@ -14,11 +18,11 @@ module Licensed
|
|
14
18
|
#
|
15
19
|
# Returns a Licensed::License
|
16
20
|
def self.read(filename)
|
21
|
+
return unless File.exist?(filename)
|
17
22
|
match = File.read(filename).scrub.match(YAML_FRONTMATTER_PATTERN)
|
18
23
|
new(YAML.load(match[1]), match[2])
|
19
24
|
end
|
20
25
|
|
21
|
-
extend Forwardable
|
22
26
|
def_delegators :@metadata, :[], :[]=
|
23
27
|
|
24
28
|
# The license text and other legal notices
|
@@ -39,5 +43,25 @@ module Licensed
|
|
39
43
|
FileUtils.mkdir_p(File.dirname(filename))
|
40
44
|
File.write(filename, YAML.dump(@metadata) + "---\n#{text}")
|
41
45
|
end
|
46
|
+
|
47
|
+
# Returns the license text without any notices
|
48
|
+
def license_text
|
49
|
+
return unless text
|
50
|
+
|
51
|
+
# if the text contains the separator, the first string in the array
|
52
|
+
# should always be the license text whether empty or not.
|
53
|
+
# if the text didn't contain the separator, the text itself is the entirety
|
54
|
+
# of the license text
|
55
|
+
split = text.split(TEXT_SEPARATOR)
|
56
|
+
split.length > 1 ? split.first.strip : text.strip
|
57
|
+
end
|
58
|
+
alias_method :content, :license_text # use license_text for content matching
|
59
|
+
|
60
|
+
# Returns whether the current license should be updated to `other`
|
61
|
+
# based on whether the normalized license content matches
|
62
|
+
def license_text_match?(other)
|
63
|
+
return false unless other.is_a?(License)
|
64
|
+
self.content_normalized == other.content_normalized
|
65
|
+
end
|
42
66
|
end
|
43
67
|
end
|
@@ -4,12 +4,14 @@ require "bundler"
|
|
4
4
|
module Licensed
|
5
5
|
module Source
|
6
6
|
class Bundler
|
7
|
+
GEMFILES = %w{Gemfile gems.rb}.freeze
|
8
|
+
|
7
9
|
def initialize(config)
|
8
10
|
@config = config
|
9
11
|
end
|
10
12
|
|
11
13
|
def enabled?
|
12
|
-
@config.enabled?(type) &&
|
14
|
+
@config.enabled?(type) && lockfile_path && lockfile_path.exist?
|
13
15
|
end
|
14
16
|
|
15
17
|
def type
|
@@ -17,14 +19,16 @@ module Licensed
|
|
17
19
|
end
|
18
20
|
|
19
21
|
def dependencies
|
20
|
-
@dependencies ||=
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
22
|
+
@dependencies ||= with_local_configuration do
|
23
|
+
definition.specs_for(groups).map do |spec|
|
24
|
+
Dependency.new(spec.gem_dir, {
|
25
|
+
"type" => type,
|
26
|
+
"name" => spec.name,
|
27
|
+
"version" => spec.version.to_s,
|
28
|
+
"summary" => spec.summary,
|
29
|
+
"homepage" => spec.homepage
|
30
|
+
})
|
31
|
+
end
|
28
32
|
end
|
29
33
|
end
|
30
34
|
|
@@ -38,16 +42,42 @@ module Licensed
|
|
38
42
|
definition.groups - [:test, :development]
|
39
43
|
end
|
40
44
|
|
41
|
-
# Returns the
|
45
|
+
# Returns the path to the Bundler Gemfile
|
42
46
|
def gemfile_path
|
43
|
-
@config.pwd.join
|
47
|
+
@gemfile_path ||= GEMFILES.map { |g| @config.pwd.join g }
|
48
|
+
.find { |f| f.exist? }
|
44
49
|
end
|
45
50
|
|
46
|
-
# Returns the
|
51
|
+
# Returns the path to the Bundler Gemfile.lock
|
47
52
|
def lockfile_path
|
48
|
-
|
53
|
+
return unless gemfile_path
|
54
|
+
@lockfile_path ||= gemfile_path.dirname.join("#{gemfile_path.basename}.lock")
|
49
55
|
end
|
50
56
|
|
57
|
+
private
|
58
|
+
|
59
|
+
# helper to clear all bundler environment around a yielded block
|
60
|
+
def with_local_configuration
|
61
|
+
original_bundle_gemfile = ENV["BUNDLE_GEMFILE"]
|
62
|
+
|
63
|
+
# with a clean, original environment
|
64
|
+
::Bundler.with_original_env do
|
65
|
+
# force bundler to use the local gem file
|
66
|
+
ENV["BUNDLE_GEMFILE"] = gemfile_path.to_s
|
67
|
+
|
68
|
+
# reset all bundler configuration
|
69
|
+
::Bundler.reset!
|
70
|
+
# and re-configure with settings for current directory
|
71
|
+
::Bundler.configure
|
72
|
+
|
73
|
+
yield
|
74
|
+
end
|
75
|
+
ensure
|
76
|
+
ENV["BUNDLE_GEMFILE"] = original_bundle_gemfile
|
77
|
+
# restore bundler configuration
|
78
|
+
::Bundler.reset!
|
79
|
+
::Bundler.configure
|
80
|
+
end
|
51
81
|
end
|
52
82
|
end
|
53
83
|
end
|
@@ -135,7 +135,7 @@ module Licensed
|
|
135
135
|
Array(@config["cabal"]["ghc_package_db"]).map do |path|
|
136
136
|
next "--#{path}" if %w(global user).include?(path)
|
137
137
|
path = realized_ghc_package_path(path)
|
138
|
-
path = File.expand_path(path,
|
138
|
+
path = File.expand_path(path, Licensed::Git.repository_root)
|
139
139
|
|
140
140
|
next unless File.exist?(path)
|
141
141
|
"--package-db=#{path}"
|
data/lib/licensed/source/go.rb
CHANGED
@@ -18,25 +18,27 @@ module Licensed
|
|
18
18
|
end
|
19
19
|
|
20
20
|
def dependencies
|
21
|
-
@dependencies ||=
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
21
|
+
@dependencies ||= with_configured_gopath do
|
22
|
+
packages.map do |package_name|
|
23
|
+
package = package_info(package_name)
|
24
|
+
import_path = non_vendored_import_path(package_name)
|
25
|
+
|
26
|
+
if package.empty?
|
27
|
+
next if @config.ignored?("type" => type, "name" => package_name)
|
28
|
+
raise "couldn't find package for #{import_path}"
|
29
|
+
end
|
30
|
+
|
31
|
+
package_dir = package["Dir"]
|
32
|
+
Dependency.new(package_dir, {
|
33
|
+
"type" => type,
|
34
|
+
"name" => import_path,
|
35
|
+
"summary" => package["Doc"],
|
36
|
+
"homepage" => homepage(import_path),
|
37
|
+
"search_root" => search_root(package_dir),
|
38
|
+
"version" => Licensed::Git.version(package_dir)
|
39
|
+
})
|
40
|
+
end.compact
|
41
|
+
end
|
40
42
|
end
|
41
43
|
|
42
44
|
# Returns the homepage for a package import_path. Assumes that the
|
@@ -70,7 +72,7 @@ module Licensed
|
|
70
72
|
# 2. GOPATH
|
71
73
|
# 3. nil (no search up directory hierarchy)
|
72
74
|
return package_dir.match("^(.*/vendor)/.*$")[1] if vendored_path?(package_dir)
|
73
|
-
|
75
|
+
gopath
|
74
76
|
end
|
75
77
|
|
76
78
|
# Returns whether a package is vendored or not based on the package
|
@@ -114,13 +116,41 @@ module Licensed
|
|
114
116
|
|
115
117
|
# Returns whether go source is found
|
116
118
|
def go_source?
|
117
|
-
@go_source ||= Licensed::Shell.success?("go", "doc")
|
119
|
+
@go_source ||= with_configured_gopath { Licensed::Shell.success?("go", "doc") }
|
118
120
|
end
|
119
121
|
|
120
122
|
# Returns a list of go standard packages
|
121
123
|
def go_std_packages
|
122
124
|
@std_packages ||= Licensed::Shell.execute("go", "list", "std").lines.map(&:strip)
|
123
125
|
end
|
126
|
+
|
127
|
+
# Returns a GOPATH value from either a configuration value or ENV["GOPATH"],
|
128
|
+
# with the configuration value preferred over the ENV var
|
129
|
+
def gopath
|
130
|
+
return @gopath if defined?(@gopath)
|
131
|
+
|
132
|
+
path = @config.dig("go", "GOPATH")
|
133
|
+
@gopath = if path.nil? || path.empty?
|
134
|
+
ENV["GOPATH"]
|
135
|
+
else
|
136
|
+
File.expand_path(path, Licensed::Git.repository_root)
|
137
|
+
end
|
138
|
+
end
|
139
|
+
|
140
|
+
private
|
141
|
+
|
142
|
+
# Execute a block with ENV["GOPATH"] set to the value of #gopath.
|
143
|
+
# Any pre-existing ENV["GOPATH"] value is restored after the block ends.
|
144
|
+
def with_configured_gopath(&block)
|
145
|
+
begin
|
146
|
+
original_gopath = ENV["GOPATH"]
|
147
|
+
ENV["GOPATH"] = gopath
|
148
|
+
|
149
|
+
block.call
|
150
|
+
ensure
|
151
|
+
ENV["GOPATH"] = original_gopath
|
152
|
+
end
|
153
|
+
end
|
124
154
|
end
|
125
155
|
end
|
126
156
|
end
|
data/lib/licensed/version.rb
CHANGED
data/licensed.gemspec
CHANGED
data/script/bootstrap
CHANGED
@@ -2,42 +2,4 @@
|
|
2
2
|
set -euo pipefail
|
3
3
|
IFS=$'\n\t'
|
4
4
|
|
5
|
-
|
6
|
-
bundle install --path vendor/gems
|
7
|
-
fi
|
8
|
-
|
9
|
-
cd test/fixtures
|
10
|
-
|
11
|
-
if [ -n "$(which bundle)" ]; then
|
12
|
-
pushd bundler
|
13
|
-
bundle install --path vendor/gems
|
14
|
-
popd
|
15
|
-
fi
|
16
|
-
|
17
|
-
# Install bower fixtures
|
18
|
-
if [ -n "$(which bower)" ]; then
|
19
|
-
pushd bower
|
20
|
-
bower install
|
21
|
-
popd
|
22
|
-
fi
|
23
|
-
|
24
|
-
# Install npm fixtures
|
25
|
-
if [ -n "$(which npm)" ]; then
|
26
|
-
pushd npm
|
27
|
-
npm install
|
28
|
-
popd
|
29
|
-
fi
|
30
|
-
|
31
|
-
if [ -n "$(which go)" ]; then
|
32
|
-
export GOPATH="`pwd`/go"
|
33
|
-
|
34
|
-
pushd go/src/test
|
35
|
-
go get || true
|
36
|
-
popd
|
37
|
-
fi
|
38
|
-
|
39
|
-
if [ -n "$(which cabal)" ]; then
|
40
|
-
pushd haskell
|
41
|
-
cabal new-build
|
42
|
-
popd
|
43
|
-
fi
|
5
|
+
bundle install --path vendor/gems
|
data/script/setup
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
#!/bin/bash
|
2
|
+
set -e
|
3
|
+
|
4
|
+
if [ -z "$(which bower)" ]; then
|
5
|
+
echo "A local bower installation is required for bower development." >&2
|
6
|
+
exit 127
|
7
|
+
fi
|
8
|
+
|
9
|
+
# setup test fixtures
|
10
|
+
BASE_PATH="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
|
11
|
+
cd $BASE_PATH/test/fixtures/bower
|
12
|
+
bower install
|
@@ -0,0 +1,16 @@
|
|
1
|
+
#!/bin/bash
|
2
|
+
set -e
|
3
|
+
|
4
|
+
if [ -z "$(which bundle)" ]; then
|
5
|
+
echo "A local bundler instalation is required for bundler development." >&2
|
6
|
+
exit 127
|
7
|
+
fi
|
8
|
+
|
9
|
+
# setup test fixtures
|
10
|
+
BASE_PATH="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
|
11
|
+
cd $BASE_PATH/test/fixtures/bundler
|
12
|
+
|
13
|
+
# unset any pre-existing gemfile when installing test fixtures
|
14
|
+
unset BUNDLE_GEMFILE
|
15
|
+
|
16
|
+
bundle install --path $BASE_PATH/test/fixtures/bundler/vendor/gems
|
@@ -0,0 +1,12 @@
|
|
1
|
+
#!/bin/bash
|
2
|
+
set -e
|
3
|
+
|
4
|
+
if [ -z "$(which cabal)" ]; then
|
5
|
+
echo "A local cabal installation is required for cabal development." >&2
|
6
|
+
exit 127
|
7
|
+
fi
|
8
|
+
|
9
|
+
# setup test fixtures
|
10
|
+
BASE_PATH="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
|
11
|
+
cd $BASE_PATH/test/fixtures/haskell
|
12
|
+
cabal new-build
|
@@ -0,0 +1,13 @@
|
|
1
|
+
#!/bin/bash
|
2
|
+
set -e
|
3
|
+
|
4
|
+
if [ -z "$(which go)" ]; then
|
5
|
+
echo "A local Go installation is required for go development." >&2
|
6
|
+
exit 127
|
7
|
+
fi
|
8
|
+
|
9
|
+
# setup test fixtures
|
10
|
+
BASE_PATH="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
|
11
|
+
export GOPATH="$BASE_PATH/test/fixtures/go"
|
12
|
+
cd $BASE_PATH/test/fixtures/go/src/test
|
13
|
+
go get
|
@@ -0,0 +1,12 @@
|
|
1
|
+
#!/bin/bash
|
2
|
+
set -e
|
3
|
+
|
4
|
+
if [ -z "$(which npm)" ]; then
|
5
|
+
echo "A local npm installation is required for npm development." >&2
|
6
|
+
exit 127
|
7
|
+
fi
|
8
|
+
|
9
|
+
# setup test fixtures
|
10
|
+
BASE_PATH="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
|
11
|
+
cd $BASE_PATH/test/fixtures/npm
|
12
|
+
npm install
|
data/script/test
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
#!/bin/bash
|
2
|
+
|
3
|
+
set -e
|
4
|
+
|
5
|
+
if [ "$#" -gt "0" ] ; then
|
6
|
+
if [ -f "$1" ]; then
|
7
|
+
# argument was a file, run it's tests only
|
8
|
+
bundle exec rake test TEST="$1"
|
9
|
+
else
|
10
|
+
# argument was not a file, execute it as a test suite identifier
|
11
|
+
bundle exec rake test:"$1"
|
12
|
+
fi
|
13
|
+
else
|
14
|
+
# no arguments, run all tests
|
15
|
+
bundle exec rake test
|
16
|
+
fi
|
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: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- GitHub
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-04-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: licensee
|
@@ -164,6 +164,20 @@ dependencies:
|
|
164
164
|
- - "~>"
|
165
165
|
- !ruby/object:Gem::Version
|
166
166
|
version: '0.6'
|
167
|
+
- !ruby/object:Gem::Dependency
|
168
|
+
name: byebug
|
169
|
+
requirement: !ruby/object:Gem::Requirement
|
170
|
+
requirements:
|
171
|
+
- - ">="
|
172
|
+
- !ruby/object:Gem::Version
|
173
|
+
version: '0'
|
174
|
+
type: :development
|
175
|
+
prerelease: false
|
176
|
+
version_requirements: !ruby/object:Gem::Requirement
|
177
|
+
requirements:
|
178
|
+
- - ">="
|
179
|
+
- !ruby/object:Gem::Version
|
180
|
+
version: '0'
|
167
181
|
description: Licensed automates extracting and validating the licenses of dependencies.
|
168
182
|
email:
|
169
183
|
- opensource+licensed@github.com
|
@@ -214,6 +228,13 @@ files:
|
|
214
228
|
- script/bootstrap
|
215
229
|
- script/cibuild
|
216
230
|
- script/console
|
231
|
+
- script/setup
|
232
|
+
- script/source-setup/bower
|
233
|
+
- script/source-setup/bundler
|
234
|
+
- script/source-setup/cabal
|
235
|
+
- script/source-setup/go
|
236
|
+
- script/source-setup/npm
|
237
|
+
- script/test
|
217
238
|
homepage: https://github.com/github/licensed
|
218
239
|
licenses:
|
219
240
|
- MIT
|