license_finder 3.0.4 → 3.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +56 -0
- data/CHANGELOG.md +29 -2
- data/CONTRIBUTING.md +5 -1
- data/Dockerfile +33 -10
- data/Gemfile +2 -2
- data/README.md +27 -5
- data/Rakefile +15 -21
- data/ci/pipelines/pipeline.yml.erb +40 -6
- data/ci/pipelines/release.yml +11 -5
- data/ci/scripts/containerize-tests.sh +16 -0
- data/ci/scripts/run-rubocop.sh +8 -0
- data/ci/scripts/run-tests.sh +22 -0
- data/ci/scripts/test.ps1 +81 -0
- data/ci/tasks/build-windows.yml +6 -0
- data/ci/tasks/build.yml +2 -2
- data/ci/tasks/rubocop.yml +13 -0
- data/features/features/cli/cli_spec.rb +8 -8
- data/features/features/configure/add_dependencies_spec.rb +7 -7
- data/features/features/configure/approve_dependencies_spec.rb +15 -15
- data/features/features/configure/assign_licenses_spec.rb +4 -4
- data/features/features/configure/blacklist_licenses_spec.rb +3 -3
- data/features/features/configure/ignore_dependencies_spec.rb +3 -3
- data/features/features/configure/ignore_groups_spec.rb +4 -4
- data/features/features/configure/name_project_spec.rb +4 -4
- data/features/features/configure/set_project_path_spec.rb +2 -2
- data/features/features/configure/whitelist_licenses_spec.rb +4 -4
- data/features/features/package_managers/bower_spec.rb +3 -3
- data/features/features/package_managers/carthage_spec.rb +14 -0
- data/features/features/package_managers/cocoapods_spec.rb +3 -3
- data/features/features/package_managers/conan_spec.rb +11 -0
- data/features/features/package_managers/dep_spec.rb +15 -0
- data/features/features/package_managers/glide_spec.rb +14 -0
- data/features/features/package_managers/govendor_spec.rb +15 -0
- data/features/features/package_managers/gradle_spec.rb +1 -1
- data/features/features/package_managers/gvt_spec.rb +14 -0
- data/features/features/package_managers/maven_spec.rb +2 -3
- data/features/features/package_managers/mix_spec.rb +16 -0
- data/features/features/package_managers/npm_spec.rb +3 -3
- data/features/features/package_managers/nuget_spec.rb +4 -4
- data/features/features/package_managers/pip_spec.rb +2 -2
- data/features/features/package_managers/rebar_spec.rb +3 -3
- data/features/features/package_managers/yarn_spec.rb +14 -0
- data/features/features/report/composite_spec.rb +1 -1
- data/features/features/report/csv_spec.rb +3 -3
- data/features/features/report/diff_spec.rb +20 -10
- data/features/features/report/html_spec.rb +10 -10
- data/features/features/report/subproject_spec.rb +15 -4
- data/features/fixtures/Cartfile +1 -0
- data/features/fixtures/Podfile +1 -1
- data/features/fixtures/alternate-build-file-gradle/build-alt.gradle +5 -15
- data/features/fixtures/build.gradle +5 -15
- data/features/fixtures/conanfile.txt +11 -0
- data/features/fixtures/file-based-libs-gradle/build.gradle +5 -7
- data/features/fixtures/gopath_dep/src/foo-dep/Gopkg.lock +9 -0
- data/features/fixtures/gopath_dep/src/foo-dep/Gopkg.toml +7 -0
- data/features/fixtures/gopath_dep/src/foo-dep/bar/bar.go +10 -0
- data/features/fixtures/gopath_dep/src/foo-dep/foo.go +7 -0
- data/features/fixtures/gopath_glide/src/glide.lock +9 -0
- data/features/fixtures/gopath_glide/src/glide.yaml +6 -0
- data/features/fixtures/gopath_govendor/src/vendor/vendor.json +19 -0
- data/features/fixtures/gopath_gvt/src/vendor/manifest +22 -0
- data/features/fixtures/gradle-wrapper/build.gradle +5 -15
- data/features/fixtures/gradle-wrapper/gradlew +6 -1
- data/features/fixtures/gradle-wrapper/gradlew.bat +9 -1
- data/features/fixtures/mix.exs +22 -0
- data/features/fixtures/multi-module-gradle/build.gradle +7 -15
- data/features/fixtures/single-module-gradle/build.gradle +5 -15
- data/features/support/testing_dsl.rb +155 -43
- data/lib/license_finder.rb +4 -3
- data/lib/license_finder/cli.rb +0 -3
- data/lib/license_finder/cli/approvals.rb +3 -3
- data/lib/license_finder/cli/base.rb +11 -8
- data/lib/license_finder/cli/blacklist.rb +7 -7
- data/lib/license_finder/cli/dependencies.rb +8 -8
- data/lib/license_finder/cli/ignored_dependencies.rb +4 -4
- data/lib/license_finder/cli/ignored_groups.rb +4 -4
- data/lib/license_finder/cli/licenses.rb +2 -2
- data/lib/license_finder/cli/main.rb +59 -39
- data/lib/license_finder/cli/makes_decisions.rb +2 -2
- data/lib/license_finder/cli/patched_thor.rb +6 -7
- data/lib/license_finder/cli/project_name.rb +5 -6
- data/lib/license_finder/cli/whitelist.rb +7 -7
- data/lib/license_finder/configuration.rb +15 -4
- data/lib/license_finder/core.rb +20 -4
- data/lib/license_finder/decision_applier.rb +0 -1
- data/lib/license_finder/decisions.rb +12 -14
- data/lib/license_finder/diff.rb +33 -31
- data/lib/license_finder/license.rb +13 -9
- data/lib/license_finder/license/definitions.rb +55 -55
- data/lib/license_finder/license/none_matcher.rb +1 -1
- data/lib/license_finder/license/template.rb +1 -1
- data/lib/license_finder/license/text.rb +0 -1
- data/lib/license_finder/license_aggregator.rb +1 -0
- data/lib/license_finder/logger.rb +18 -61
- data/lib/license_finder/package.rb +25 -11
- data/lib/license_finder/package_delta.rb +3 -6
- data/lib/license_finder/package_manager.rb +77 -34
- data/lib/license_finder/package_managers/bower.rb +8 -8
- data/lib/license_finder/package_managers/bower_package.rb +12 -12
- data/lib/license_finder/package_managers/bundler.rb +21 -9
- data/lib/license_finder/package_managers/bundler_package.rb +1 -1
- data/lib/license_finder/package_managers/carthage.rb +66 -0
- data/lib/license_finder/package_managers/carthage_package.rb +16 -0
- data/lib/license_finder/package_managers/cocoa_pods.rb +13 -13
- data/lib/license_finder/package_managers/cocoa_pods_package.rb +1 -1
- data/lib/license_finder/package_managers/conan.rb +26 -0
- data/lib/license_finder/package_managers/conan_info_parser.rb +74 -0
- data/lib/license_finder/package_managers/conan_package.rb +17 -0
- data/lib/license_finder/package_managers/dep.rb +33 -0
- data/lib/license_finder/package_managers/glide.rb +30 -0
- data/lib/license_finder/package_managers/{go_vendor.rb → go_15vendorexperiment.rb} +19 -24
- data/lib/license_finder/package_managers/go_dep.rb +15 -12
- data/lib/license_finder/package_managers/go_package.rb +15 -13
- data/lib/license_finder/package_managers/go_workspace.rb +39 -34
- data/lib/license_finder/package_managers/govendor.rb +32 -0
- data/lib/license_finder/package_managers/gradle.rb +16 -16
- data/lib/license_finder/package_managers/gradle_package.rb +8 -8
- data/lib/license_finder/package_managers/gvt.rb +61 -0
- data/lib/license_finder/package_managers/maven.rb +17 -18
- data/lib/license_finder/package_managers/maven_package.rb +4 -6
- data/lib/license_finder/package_managers/merged_package.rb +25 -2
- data/lib/license_finder/package_managers/mix.rb +51 -0
- data/lib/license_finder/package_managers/mix_package.rb +7 -0
- data/lib/license_finder/package_managers/npm.rb +8 -32
- data/lib/license_finder/package_managers/npm_package.rb +51 -48
- data/lib/license_finder/package_managers/nuget.rb +30 -40
- data/lib/license_finder/package_managers/pip.rb +11 -11
- data/lib/license_finder/package_managers/pip_package.rb +8 -8
- data/lib/license_finder/package_managers/rebar.rb +11 -11
- data/lib/license_finder/package_managers/yarn.rb +62 -0
- data/lib/license_finder/packages/activation.rb +2 -2
- data/lib/license_finder/packages/license_files.rb +6 -6
- data/lib/license_finder/packages/licensing.rb +8 -10
- data/lib/license_finder/packages/manual_package.rb +2 -2
- data/lib/license_finder/project_finder.rb +6 -5
- data/lib/license_finder/report.rb +1 -0
- data/lib/license_finder/reports/csv_report.rb +4 -4
- data/lib/license_finder/reports/diff_report.rb +2 -2
- data/lib/license_finder/reports/erb_report.rb +2 -4
- data/lib/license_finder/reports/html_report.rb +2 -2
- data/lib/license_finder/reports/markdown_report.rb +1 -1
- data/lib/license_finder/reports/merged_report.rb +1 -1
- data/lib/license_finder/reports/text_report.rb +3 -5
- data/lib/license_finder/shared_helpers/cmd.rb +11 -0
- data/lib/license_finder/version.rb +1 -1
- data/license_finder-2.1.2.gem +0 -0
- data/license_finder.gemspec +38 -38
- metadata +84 -118
- data/ci/scripts/test.sh +0 -26
- data/ci/tasks/create-source-archives.yml +0 -23
- data/spec/dummy_app/Gemfile +0 -6
- data/spec/fixtures/all_pms/.envrc +0 -1
- data/spec/fixtures/all_pms/.nuget/.keep +0 -0
- data/spec/fixtures/all_pms/Gemfile +0 -0
- data/spec/fixtures/all_pms/Godeps/Godeps.json +0 -0
- data/spec/fixtures/all_pms/Podfile +0 -0
- data/spec/fixtures/all_pms/bower.json +0 -0
- data/spec/fixtures/all_pms/build.gradle +0 -0
- data/spec/fixtures/all_pms/package.json +0 -0
- data/spec/fixtures/all_pms/pom.xml +0 -0
- data/spec/fixtures/all_pms/rebar.config +0 -0
- data/spec/fixtures/all_pms/requirements.txt +0 -0
- data/spec/fixtures/all_pms/vendor/.gitkeep +0 -0
- data/spec/fixtures/composite/Gemfile +0 -0
- data/spec/fixtures/composite/nested_project/.envrc +0 -8
- data/spec/fixtures/composite/nested_project/src/github.com/pivotal/foo/Godeps/Godeps.json +0 -16
- data/spec/fixtures/composite/nested_project/src/github.com/pivotal/foo/Godeps/Readme +0 -5
- data/spec/fixtures/composite/nested_project/src/github.com/pivotal/foo/foo.go +0 -6
- data/spec/fixtures/composite/not_a_project/DONTREADME.md +0 -0
- data/spec/fixtures/composite/project1/Gemfile +0 -0
- data/spec/fixtures/composite/project2/package.json +0 -0
- data/spec/fixtures/config/license_finder.yml +0 -5
- data/spec/fixtures/license_directory/COPYING +0 -1
- data/spec/fixtures/license_directory/LICENSE/MIT.txt +0 -1
- data/spec/fixtures/license_directory/LICENSE/lib/unrelated.txt +0 -2
- data/spec/fixtures/license_names/COPYING.txt +0 -1
- data/spec/fixtures/license_names/LICENSE +0 -1
- data/spec/fixtures/license_names/Licence.rdoc +0 -1
- data/spec/fixtures/license_names/Mit-License +0 -1
- data/spec/fixtures/license_names/README.rdoc +0 -1
- data/spec/fixtures/nested_gem/vendor/LICENSE +0 -1
- data/spec/fixtures/npm-circular-dependencies/npm-list.json +0 -5339
- data/spec/fixtures/npm-circular-dependencies/package.json +0 -5
- data/spec/fixtures/npm-circular-licenses/npm-list.json +0 -7597
- data/spec/fixtures/npm-circular-licenses/package.json +0 -23
- data/spec/fixtures/npm-licenses-string/npm-list.json +0 -7597
- data/spec/fixtures/npm-licenses-string/package.json +0 -23
- data/spec/fixtures/npm-recursive-dependencies/npm-list.json +0 -5158
- data/spec/fixtures/npm-recursive-dependencies/package.json +0 -15
- data/spec/fixtures/npm-stack-too-deep/npm-list.json +0 -13464
- data/spec/fixtures/npm-stack-too-deep/package.json +0 -5
- data/spec/fixtures/utf8_gem/README +0 -210
- data/spec/lib/license_finder/cli/approvals_spec.rb +0 -71
- data/spec/lib/license_finder/cli/blacklist_spec.rb +0 -58
- data/spec/lib/license_finder/cli/dependencies_spec.rb +0 -73
- data/spec/lib/license_finder/cli/ignored_dependencies_spec.rb +0 -47
- data/spec/lib/license_finder/cli/ignored_groups_spec.rb +0 -40
- data/spec/lib/license_finder/cli/licenses_spec.rb +0 -60
- data/spec/lib/license_finder/cli/main_spec.rb +0 -243
- data/spec/lib/license_finder/cli/project_name_spec.rb +0 -40
- data/spec/lib/license_finder/cli/whitelist_spec.rb +0 -58
- data/spec/lib/license_finder/configuration_spec.rb +0 -115
- data/spec/lib/license_finder/core_spec.rb +0 -54
- data/spec/lib/license_finder/decision_applier_spec.rb +0 -219
- data/spec/lib/license_finder/decisions_spec.rb +0 -408
- data/spec/lib/license_finder/diff_spec.rb +0 -129
- data/spec/lib/license_finder/license/definitions_spec.rb +0 -177
- data/spec/lib/license_finder/license_aggregator_spec.rb +0 -61
- data/spec/lib/license_finder/license_spec.rb +0 -106
- data/spec/lib/license_finder/package_delta_spec.rb +0 -18
- data/spec/lib/license_finder/package_manager_spec.rb +0 -62
- data/spec/lib/license_finder/package_managers/bower_package_spec.rb +0 -71
- data/spec/lib/license_finder/package_managers/bower_spec.rb +0 -39
- data/spec/lib/license_finder/package_managers/bundler_package_spec.rb +0 -35
- data/spec/lib/license_finder/package_managers/bundler_spec.rb +0 -56
- data/spec/lib/license_finder/package_managers/cocoa_pods_package_spec.rb +0 -48
- data/spec/lib/license_finder/package_managers/cocoa_pods_spec.rb +0 -59
- data/spec/lib/license_finder/package_managers/go_dep_spec.rb +0 -126
- data/spec/lib/license_finder/package_managers/go_package_spec.rb +0 -33
- data/spec/lib/license_finder/package_managers/go_vendor_spec.rb +0 -144
- data/spec/lib/license_finder/package_managers/go_workspace_spec.rb +0 -286
- data/spec/lib/license_finder/package_managers/gradle_package_spec.rb +0 -80
- data/spec/lib/license_finder/package_managers/gradle_spec.rb +0 -180
- data/spec/lib/license_finder/package_managers/maven_package_spec.rb +0 -63
- data/spec/lib/license_finder/package_managers/maven_spec.rb +0 -128
- data/spec/lib/license_finder/package_managers/merged_package_spec.rb +0 -60
- data/spec/lib/license_finder/package_managers/npm_package_spec.rb +0 -57
- data/spec/lib/license_finder/package_managers/npm_spec.rb +0 -253
- data/spec/lib/license_finder/package_managers/nuget_package_spec.rb +0 -9
- data/spec/lib/license_finder/package_managers/nuget_spec.rb +0 -157
- data/spec/lib/license_finder/package_managers/pip_package_spec.rb +0 -87
- data/spec/lib/license_finder/package_managers/pip_spec.rb +0 -47
- data/spec/lib/license_finder/package_managers/rebar_package_spec.rb +0 -24
- data/spec/lib/license_finder/package_managers/rebar_spec.rb +0 -50
- data/spec/lib/license_finder/package_spec.rb +0 -179
- data/spec/lib/license_finder/packages/activation_spec.rb +0 -41
- data/spec/lib/license_finder/packages/license_files_spec.rb +0 -46
- data/spec/lib/license_finder/packages/licensing_spec.rb +0 -1
- data/spec/lib/license_finder/packages/possible_license_file_spec.rb +0 -38
- data/spec/lib/license_finder/project_finder_spec.rb +0 -33
- data/spec/lib/license_finder/reports/csv_report_spec.rb +0 -70
- data/spec/lib/license_finder/reports/diff_report_spec.rb +0 -56
- data/spec/lib/license_finder/reports/html_report_spec.rb +0 -101
- data/spec/lib/license_finder/reports/markdown_report_spec.rb +0 -45
- data/spec/lib/license_finder/reports/merged_report_spec.rb +0 -21
- data/spec/lib/license_finder/reports/text_report_spec.rb +0 -43
- data/spec/spec_helper.rb +0 -27
- data/spec/support/shared_examples_for_package_manager.rb +0 -52
- data/spec/support/stdout_helpers.rb +0 -31
- data/spec/support/test_fixtures.rb +0 -7
@@ -1,18 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
module LicenseFinder
|
4
|
-
describe PackageDelta do
|
5
|
-
describe '#<=>' do
|
6
|
-
let(:foo) { Package.new('foo') }
|
7
|
-
let(:bar) { Package.new('bar') }
|
8
|
-
|
9
|
-
it 'sorts by status (added, removed, unchanged)' do
|
10
|
-
p1 = PackageDelta.added(foo)
|
11
|
-
p2 = PackageDelta.removed(bar)
|
12
|
-
p3 = PackageDelta.unchanged(foo, bar)
|
13
|
-
|
14
|
-
expect([p3, p2, p1].sort).to eq([p1, p2, p3])
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
@@ -1,62 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
module LicenseFinder
|
4
|
-
describe PackageManager do
|
5
|
-
describe "#current_packages_with_relations" do
|
6
|
-
it "sets packages' parents" do
|
7
|
-
grandparent = Package.new("grandparent", nil, children: ["parent"])
|
8
|
-
parent = Package.new("parent", nil, children: ["child"])
|
9
|
-
child = Package.new("child")
|
10
|
-
|
11
|
-
pm = described_class.new
|
12
|
-
allow(pm).to receive(:current_packages) { [grandparent, parent, child] }
|
13
|
-
|
14
|
-
expect(pm.current_packages_with_relations.map(&:parents)).to eq([
|
15
|
-
[].to_set,
|
16
|
-
["grandparent"].to_set,
|
17
|
-
["parent"].to_set
|
18
|
-
])
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
describe "#package_management_command" do
|
23
|
-
it "defaults to nil" do
|
24
|
-
expect(LicenseFinder::PackageManager.package_management_command).to be_nil
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
describe ".installed?" do
|
29
|
-
context "package_management_command is nil" do
|
30
|
-
before do
|
31
|
-
allow(LicenseFinder::PackageManager).to receive(:package_management_command).and_return(nil)
|
32
|
-
end
|
33
|
-
|
34
|
-
it "returns true" do
|
35
|
-
expect(LicenseFinder::PackageManager.installed?).to be_truthy
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
context "package_management_command exists" do
|
40
|
-
before do
|
41
|
-
allow(LicenseFinder::PackageManager).to receive(:package_management_command).and_return("foobar")
|
42
|
-
allow(LicenseFinder::PackageManager).to receive(:command_exists?).with("foobar").and_return(true)
|
43
|
-
end
|
44
|
-
|
45
|
-
it "returns true" do
|
46
|
-
expect(LicenseFinder::PackageManager.installed?).to be_truthy
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
context "package_management_command does not exist" do
|
51
|
-
before do
|
52
|
-
allow(LicenseFinder::PackageManager).to receive(:package_management_command).and_return("foobar")
|
53
|
-
allow(LicenseFinder::PackageManager).to receive(:command_exists?).with("foobar").and_return(false)
|
54
|
-
end
|
55
|
-
|
56
|
-
it "returns false" do
|
57
|
-
expect(LicenseFinder::PackageManager.installed?).to be_falsey
|
58
|
-
end
|
59
|
-
end
|
60
|
-
end
|
61
|
-
end
|
62
|
-
end
|
@@ -1,71 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
module LicenseFinder
|
4
|
-
describe BowerPackage do
|
5
|
-
subject do
|
6
|
-
described_class.new(
|
7
|
-
"canonicalDir" => "/path/to/thing",
|
8
|
-
"pkgMeta" => {
|
9
|
-
"name" => "dependency-library",
|
10
|
-
"description" => "description",
|
11
|
-
"version" => "1.3.3.7",
|
12
|
-
"readme" => "some readme stuff",
|
13
|
-
"homepage" => "homepage"
|
14
|
-
}
|
15
|
-
)
|
16
|
-
end
|
17
|
-
|
18
|
-
its(:name) { should == "dependency-library" }
|
19
|
-
its(:version) { should == "1.3.3.7" }
|
20
|
-
its(:summary) { should == "description" }
|
21
|
-
its(:description) { should == "some readme stuff" }
|
22
|
-
its(:homepage) { should == "homepage" }
|
23
|
-
its(:groups) { should == [] } # TODO: does `bower list` output devDependencies? If so, put them in 'dev' group?
|
24
|
-
its(:children) { should == [] } # TODO: get dependencies from dependencies and devDependencies, like NPM
|
25
|
-
its(:install_path) { should eq "/path/to/thing" }
|
26
|
-
its(:package_manager) { should eq 'Bower' }
|
27
|
-
|
28
|
-
context "when package is NOT installed" do
|
29
|
-
subject do
|
30
|
-
described_class.new(
|
31
|
-
"missing" => true,
|
32
|
-
"endpoint" => {
|
33
|
-
"name" => "some_package_that_is_not_installed",
|
34
|
-
"target" => ">=3.0"
|
35
|
-
}
|
36
|
-
)
|
37
|
-
end
|
38
|
-
|
39
|
-
it "shows the name and version from the endpoint block" do
|
40
|
-
expect(subject.name).to eq("some_package_that_is_not_installed")
|
41
|
-
expect(subject.version).to eq(">=3.0")
|
42
|
-
end
|
43
|
-
|
44
|
-
it 'reports itself as missing' do
|
45
|
-
expect(subject).to be_missing
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
describe '#license_names_from_spec' do
|
50
|
-
let(:package1) { { "pkgMeta" => {"license" => "MIT"} } }
|
51
|
-
let(:package2) { { "pkgMeta" => {"licenses" => [{"type" => "BSD"}]} } }
|
52
|
-
let(:package3) { { "pkgMeta" => {"license" => {"type" => "PSF"}} } }
|
53
|
-
let(:package4) { { "pkgMeta" => {"licenses" => ["MIT"]} } }
|
54
|
-
|
55
|
-
it 'finds the license for all license structures' do
|
56
|
-
package = BowerPackage.new(package1)
|
57
|
-
expect(package.license_names_from_spec).to eq ["MIT"]
|
58
|
-
|
59
|
-
package = BowerPackage.new(package2)
|
60
|
-
expect(package.license_names_from_spec).to eq ["BSD"]
|
61
|
-
|
62
|
-
package = BowerPackage.new(package3)
|
63
|
-
expect(package.license_names_from_spec).to eq ["PSF"]
|
64
|
-
|
65
|
-
package = BowerPackage.new(package4)
|
66
|
-
expect(package.license_names_from_spec).to eq ["MIT"]
|
67
|
-
end
|
68
|
-
end
|
69
|
-
end
|
70
|
-
end
|
71
|
-
|
@@ -1,39 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
module LicenseFinder
|
4
|
-
describe Bower do
|
5
|
-
subject { Bower.new(project_path: Pathname('/fake/path')) }
|
6
|
-
|
7
|
-
it_behaves_like 'a PackageManager'
|
8
|
-
|
9
|
-
describe '.current_packages' do
|
10
|
-
it 'lists all the current packages' do
|
11
|
-
json = <<-JSON
|
12
|
-
{
|
13
|
-
"dependencies": {
|
14
|
-
"dependency-library": {
|
15
|
-
"canonicalDir": "/path/to/thing",
|
16
|
-
"pkgMeta": {
|
17
|
-
"name": "dependency-library"
|
18
|
-
}
|
19
|
-
},
|
20
|
-
"another-dependency": {
|
21
|
-
"canonicalDir": "/path/to/thing2",
|
22
|
-
"pkgMeta": {
|
23
|
-
"name": "another-dependency"
|
24
|
-
}
|
25
|
-
}
|
26
|
-
}
|
27
|
-
}
|
28
|
-
JSON
|
29
|
-
|
30
|
-
allow(Dir).to receive(:chdir).with(Pathname('/fake/path')) { |&block| block.call }
|
31
|
-
allow(subject).to receive(:capture).with('bower list --json -l action --allow-root').and_return([json, true])
|
32
|
-
|
33
|
-
expect(subject.current_packages.map { |p| [p.name, p.install_path] }).to eq [
|
34
|
-
%w(dependency-library /path/to/thing), %w(another-dependency /path/to/thing2)
|
35
|
-
]
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
@@ -1,35 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
module LicenseFinder
|
4
|
-
describe BundlerPackage do
|
5
|
-
subject { described_class.new(gemspec, bundler_dependency) }
|
6
|
-
|
7
|
-
let(:gemspec) do
|
8
|
-
Gem::Specification.new do |s|
|
9
|
-
s.name = 'spec_name'
|
10
|
-
s.version = '2.1.3'
|
11
|
-
s.authors = ['first', 'second']
|
12
|
-
s.summary = 'summary'
|
13
|
-
s.description = 'description'
|
14
|
-
s.homepage = 'homepage'
|
15
|
-
s.licenses = ['MIT', 'GPL']
|
16
|
-
|
17
|
-
s.add_dependency 'foo'
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
let(:bundler_dependency) { double(:dependency, groups: [:staging, :assets]) }
|
22
|
-
|
23
|
-
its(:name) { should == 'spec_name' }
|
24
|
-
its(:version) { should == '2.1.3' }
|
25
|
-
its(:authors) { should == 'first, second' }
|
26
|
-
its(:summary) { should == "summary" }
|
27
|
-
its(:description) { should == "description" }
|
28
|
-
its(:homepage) { should == "homepage" }
|
29
|
-
its(:groups) { should == %w[staging assets] }
|
30
|
-
its(:children) { should == ['foo'] }
|
31
|
-
its(:license_names_from_spec) { should eq ['MIT', 'GPL'] }
|
32
|
-
its(:install_path) { should =~ /spec_name-2\.1\.3\z/ }
|
33
|
-
its(:package_manager) { should == "Bundler" }
|
34
|
-
end
|
35
|
-
end
|
@@ -1,56 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
module LicenseFinder
|
4
|
-
describe Bundler do
|
5
|
-
it_behaves_like "a PackageManager"
|
6
|
-
|
7
|
-
let(:definition) do
|
8
|
-
double('definition', {
|
9
|
-
:dependencies => [],
|
10
|
-
:groups => [:dev, :production],
|
11
|
-
:specs_for => [
|
12
|
-
build_gemspec('gem1', '1.2.3'),
|
13
|
-
build_gemspec('gem2', '0.4.2')
|
14
|
-
]
|
15
|
-
})
|
16
|
-
end
|
17
|
-
|
18
|
-
def build_gemspec(name, version, dependency=nil)
|
19
|
-
Gem::Specification.new do |s|
|
20
|
-
s.name = name
|
21
|
-
s.version = version
|
22
|
-
s.summary = 'summary'
|
23
|
-
s.description = 'description'
|
24
|
-
|
25
|
-
if dependency
|
26
|
-
s.add_dependency dependency
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
describe '.current_packages' do
|
32
|
-
subject do
|
33
|
-
Bundler.new(ignored_groups: ['dev', 'test'], definition: definition).current_packages
|
34
|
-
end
|
35
|
-
|
36
|
-
it "should have 2 dependencies" do
|
37
|
-
expect(subject.size).to eq(2)
|
38
|
-
end
|
39
|
-
|
40
|
-
context "when initialized with a parent and child gem" do
|
41
|
-
before do
|
42
|
-
allow(definition).to receive(:specs_for).with([:production]).and_return([
|
43
|
-
build_gemspec('gem1', '1.2.3', 'gem2'),
|
44
|
-
build_gemspec('gem2', '0.4.2', 'gem3')
|
45
|
-
])
|
46
|
-
end
|
47
|
-
|
48
|
-
it "should update the child dependency with its parent data" do
|
49
|
-
gem1 = subject.first
|
50
|
-
|
51
|
-
expect(gem1.children).to eq(["gem2"])
|
52
|
-
end
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
@@ -1,48 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
module LicenseFinder
|
4
|
-
describe CocoaPodsPackage do
|
5
|
-
subject do
|
6
|
-
described_class.new("Name", "1.0.0", license_text)
|
7
|
-
end
|
8
|
-
let(:license_text) { nil }
|
9
|
-
|
10
|
-
its(:name) { should == "Name" }
|
11
|
-
its(:version) { should == "1.0.0" }
|
12
|
-
its(:summary) { should eq "" }
|
13
|
-
its(:description) { should eq "" }
|
14
|
-
its(:homepage) { should eq "" }
|
15
|
-
its(:groups) { should == [] }
|
16
|
-
its(:children) { should == [] }
|
17
|
-
its(:package_manager) { should eq 'CocoaPods' }
|
18
|
-
|
19
|
-
describe '#licenses' do
|
20
|
-
context "when there's a license" do
|
21
|
-
let(:license_text) { "LicenseText" }
|
22
|
-
|
23
|
-
it "returns the name of the license if the license is found be text" do
|
24
|
-
license = double(:license, name: "LicenseName")
|
25
|
-
allow(License).to receive(:find_by_text).with(license_text).and_return(license)
|
26
|
-
|
27
|
-
expect(subject.licenses.map(&:name)).to eq ["LicenseName"]
|
28
|
-
end
|
29
|
-
|
30
|
-
it "returns unknown if the license can't be found by text" do
|
31
|
-
allow(License).to receive(:find_by_text).with(license_text).and_return(nil)
|
32
|
-
|
33
|
-
expect(subject.licenses.map(&:name)).to eq ["unknown"]
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
it "returns unknown when there's no license" do
|
38
|
-
expect(subject.licenses.map(&:name)).to eq ["unknown"]
|
39
|
-
end
|
40
|
-
|
41
|
-
it "respects license decisions" do
|
42
|
-
subject.decide_on_license(License.find_by_name("A"))
|
43
|
-
expect(subject.licenses.map(&:name)).to eq ["A"]
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
@@ -1,59 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
module LicenseFinder
|
4
|
-
describe CocoaPods do
|
5
|
-
let(:project_path) { fixture_path("all_pms") }
|
6
|
-
let(:cocoa_pods) { CocoaPods.new(project_path: project_path) }
|
7
|
-
it_behaves_like "a PackageManager"
|
8
|
-
|
9
|
-
def stub_acknowledgments(hash = {})
|
10
|
-
plist = {
|
11
|
-
"PreferenceSpecifiers" => [
|
12
|
-
{
|
13
|
-
"FooterText" => hash[:license],
|
14
|
-
"Title" => hash[:name]
|
15
|
-
}
|
16
|
-
]
|
17
|
-
}
|
18
|
-
|
19
|
-
expect(cocoa_pods).to receive(:read_plist).and_return(plist)
|
20
|
-
end
|
21
|
-
|
22
|
-
def stub_lockfile(pods)
|
23
|
-
allow(YAML).to receive(:load_file)
|
24
|
-
.with(project_path.join("Podfile.lock"))
|
25
|
-
.and_return("PODS" => pods)
|
26
|
-
end
|
27
|
-
|
28
|
-
describe '.current_packages' do
|
29
|
-
it 'lists all the current packages' do
|
30
|
-
stub_lockfile([
|
31
|
-
{ "ABTest (0.0.5)" => ["OpenUDID"] },
|
32
|
-
"JSONKit (1.5pre)",
|
33
|
-
"OpenUDID (1.0.0)"
|
34
|
-
])
|
35
|
-
stub_acknowledgments
|
36
|
-
|
37
|
-
expect(cocoa_pods.current_packages.map { |p| [p.name, p.version ] }).to eq [
|
38
|
-
["ABTest", "0.0.5"],
|
39
|
-
["JSONKit", "1.5pre"],
|
40
|
-
["OpenUDID", "1.0.0"]
|
41
|
-
]
|
42
|
-
end
|
43
|
-
|
44
|
-
it "passes the license text to the package" do
|
45
|
-
stub_lockfile(["Dependency Name (1.0)"])
|
46
|
-
stub_acknowledgments({name: "Dependency Name", license: "The MIT License"})
|
47
|
-
|
48
|
-
expect(cocoa_pods.current_packages.first.licenses.map(&:name)).to eq ['MIT']
|
49
|
-
end
|
50
|
-
|
51
|
-
it "handles no licenses" do
|
52
|
-
stub_lockfile(["Dependency Name (1.0)"])
|
53
|
-
stub_acknowledgments
|
54
|
-
|
55
|
-
expect(cocoa_pods.current_packages.first.licenses.map(&:name)).to eq ['unknown']
|
56
|
-
end
|
57
|
-
end
|
58
|
-
end
|
59
|
-
end
|
@@ -1,126 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
module LicenseFinder
|
4
|
-
describe GoDep do
|
5
|
-
let(:options) { {} }
|
6
|
-
subject { GoDep.new(options.merge(project_path: Pathname('/fake/path'))) }
|
7
|
-
|
8
|
-
|
9
|
-
it_behaves_like 'a PackageManager'
|
10
|
-
|
11
|
-
describe '#current_packages' do
|
12
|
-
let(:content) do
|
13
|
-
'{
|
14
|
-
"ImportPath": "github.com/pivotal/foo",
|
15
|
-
"GoVersion": "go1.4.2",
|
16
|
-
"Deps": [
|
17
|
-
{
|
18
|
-
"ImportPath": "github.com/pivotal/foo",
|
19
|
-
"Rev": "61164e49940b423ba1f12ddbdf01632ac793e5e9"
|
20
|
-
},
|
21
|
-
{
|
22
|
-
"ImportPath": "github.com/pivotal/bar",
|
23
|
-
"Rev": "3245708abcdef234589450649872346783298736"
|
24
|
-
},
|
25
|
-
{
|
26
|
-
"ImportPath": "code.google.com/foo/bar",
|
27
|
-
"Rev": "3245708abcdef234589450649872346783298735"
|
28
|
-
}
|
29
|
-
]
|
30
|
-
}'
|
31
|
-
end
|
32
|
-
|
33
|
-
before do
|
34
|
-
allow(IO).to receive(:read).with('/fake/path/Godeps/Godeps.json').and_return(content.to_s)
|
35
|
-
end
|
36
|
-
|
37
|
-
it 'sets the homepage for packages' do
|
38
|
-
packages = subject.current_packages
|
39
|
-
|
40
|
-
expect(packages[0].homepage).to eq("github.com/pivotal/foo")
|
41
|
-
expect(packages[1].homepage).to eq("github.com/pivotal/bar")
|
42
|
-
expect(packages[2].homepage).to eq("code.google.com/foo/bar")
|
43
|
-
end
|
44
|
-
|
45
|
-
context 'when dependencies are vendored' do
|
46
|
-
before do
|
47
|
-
allow(FileTest).to receive(:exist?).with('/fake/path/Godeps/_workspace').and_return(true)
|
48
|
-
end
|
49
|
-
|
50
|
-
it 'should return an array of packages' do
|
51
|
-
packages = subject.current_packages
|
52
|
-
expect(packages.map(&:name)).to include('github.com/pivotal/foo', 'github.com/pivotal/bar')
|
53
|
-
expect(packages.map(&:version)).to include('61164e4', '3245708')
|
54
|
-
end
|
55
|
-
|
56
|
-
it 'should set the install_path to the vendored directory' do
|
57
|
-
packages = subject.current_packages
|
58
|
-
expect(packages[0].install_path).to eq('/fake/path/Godeps/_workspace/src/github.com/pivotal/foo')
|
59
|
-
expect(packages[1].install_path).to eq('/fake/path/Godeps/_workspace/src/github.com/pivotal/bar')
|
60
|
-
end
|
61
|
-
|
62
|
-
context 'when requesting the full version' do
|
63
|
-
let(:options) { { go_full_version:true } }
|
64
|
-
it 'list the dependencies with full version' do
|
65
|
-
expect(subject.current_packages.map(&:version)).to eq [
|
66
|
-
"61164e49940b423ba1f12ddbdf01632ac793e5e9",
|
67
|
-
"3245708abcdef234589450649872346783298736",
|
68
|
-
"3245708abcdef234589450649872346783298735"]
|
69
|
-
end
|
70
|
-
end
|
71
|
-
end
|
72
|
-
|
73
|
-
context 'when there are duplicate dependencies' do
|
74
|
-
let(:content) do
|
75
|
-
'{
|
76
|
-
"ImportPath": "github.com/foo/bar",
|
77
|
-
"GoVersion": "go1.3",
|
78
|
-
"Deps": [
|
79
|
-
{
|
80
|
-
"ImportPath": "github.com/foo/baz/sub1",
|
81
|
-
"Rev": "28838aae6e8158e3695cf90e2f0ed2498b68ee1d"
|
82
|
-
},
|
83
|
-
{
|
84
|
-
"ImportPath": "github.com/foo/baz/sub2",
|
85
|
-
"Rev": "28838aae6e8158e3695cf90e2f0ed2498b68ee1d"
|
86
|
-
},
|
87
|
-
{
|
88
|
-
"ImportPath": "github.com/foo/baz/sub3",
|
89
|
-
"Rev": "28838aae6e8158e3695cf90e2f0ed2498b68ee1d"
|
90
|
-
}
|
91
|
-
]
|
92
|
-
}'
|
93
|
-
end
|
94
|
-
|
95
|
-
it 'should return one dependency only' do
|
96
|
-
packages = subject.current_packages
|
97
|
-
expect(packages.map(&:name)).to eq(['github.com/foo/baz'])
|
98
|
-
expect(packages.map(&:version)).to eq(['28838aa'])
|
99
|
-
end
|
100
|
-
end
|
101
|
-
|
102
|
-
context 'when dependencies are not vendored' do
|
103
|
-
before do
|
104
|
-
@orig_gopath = ENV['GOPATH']
|
105
|
-
ENV['GOPATH'] = '/fake/go/path'
|
106
|
-
end
|
107
|
-
|
108
|
-
after do
|
109
|
-
ENV['GOPATH'] = @orig_gopath
|
110
|
-
end
|
111
|
-
|
112
|
-
it 'should return an array of packages' do
|
113
|
-
packages = subject.current_packages
|
114
|
-
expect(packages.map(&:name)).to include('github.com/pivotal/foo', 'github.com/pivotal/bar')
|
115
|
-
expect(packages.map(&:version)).to include('61164e4', '3245708')
|
116
|
-
end
|
117
|
-
|
118
|
-
it 'should set the install_path to the GOPATH' do
|
119
|
-
packages = subject.current_packages
|
120
|
-
expect(packages[0].install_path).to eq('/fake/go/path/src/github.com/pivotal/foo')
|
121
|
-
expect(packages[1].install_path).to eq('/fake/go/path/src/github.com/pivotal/bar')
|
122
|
-
end
|
123
|
-
end
|
124
|
-
end
|
125
|
-
end
|
126
|
-
end
|