license_finder_upgrade 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +2 -0
- data/.travis.yml +14 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +56 -0
- data/Rakefile +2 -0
- data/bin/license_finder_upgrade +5 -0
- data/config/license_finder.yml +12 -0
- data/doc/dependencies.db +0 -0
- data/lib/license_finder_upgrade.rb +19 -0
- data/lib/license_finder_upgrade/configuration.rb +96 -0
- data/lib/license_finder_upgrade/decisions.rb +66 -0
- data/lib/license_finder_upgrade/platform.rb +20 -0
- data/lib/license_finder_upgrade/tables.rb +6 -0
- data/lib/license_finder_upgrade/tables/dependency.rb +29 -0
- data/lib/license_finder_upgrade/tables/manual_approval.rb +9 -0
- data/lib/license_finder_upgrade/to_decisions.rb +70 -0
- data/license_finder_upgrade.gemspec +32 -0
- data/spec/lib/license_finder_upgrade/to_decisions_spec.rb +135 -0
- data/spec/spec_helper.rb +13 -0
- metadata +109 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 54502dc1413ec8b94cf58bfe26ae100a9b50e2f7
|
4
|
+
data.tar.gz: 534f72d26c6e09d8af281394c929f1a7d2be94c6
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: f94d4a83505d6934d06a0a8be7c9f49f430e7d5afe28d7b8247dd2c4d1f237631f65295e13d765a0e54c49f6ccea6200744f8e448ddf4c6fb8692f8f280a5e8f
|
7
|
+
data.tar.gz: bc83d887416ec044f966a6c3412bbd86fc56ab4c907beb5a7cec51c843ea5bbc72a2dc33e526467e28b75d3c0e76ac54418886b67d650c3b8b1a327633ebc60f
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Harlan Wood & Jacob Maine
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
# license_finder_upgrade
|
2
|
+
|
3
|
+
`license_finder_upgrade` helps upgrade [`license_finder`](https://github.com/pivotal/LicenseFinder)
|
4
|
+
projects from version ~1.2 to 2.0.
|
5
|
+
|
6
|
+
[![Build Status](https://travis-ci.org/mainej/license_finder_upgrade.svg?branch=master)](https://travis-ci.org/mainej/license_finder_upgrade)
|
7
|
+
[![Code Climate](https://codeclimate.com/github/mainej/license_finder_upgrade/badges/gpa.svg)](https://codeclimate.com/github/mainej/license_finder_upgrade)
|
8
|
+
|
9
|
+
|
10
|
+
## Installation
|
11
|
+
|
12
|
+
1. Make sure you've upgraded to the latest version of `license_finder` _less
|
13
|
+
than_ version 2.0. You can check this with `gem list --local license_finder`.
|
14
|
+
2. Run `license_finder` at least once with this lower version of
|
15
|
+
`license_finder`. This will ensure that the `license_finder` database is in a
|
16
|
+
state which `license_finder_upgrade` understands.
|
17
|
+
3. Install with `gem install license_finder_upgrade`
|
18
|
+
|
19
|
+
|
20
|
+
## Usage
|
21
|
+
|
22
|
+
Run the command once, in your project directory:
|
23
|
+
|
24
|
+
$ license_finder_upgrade
|
25
|
+
|
26
|
+
There should be no output, but a new file should exist in your `doc/` directory
|
27
|
+
(or whichever directory `license_finder` typically stores files in) called
|
28
|
+
`dependency_decisions.yml`. Your `config/license_finder.yml` file may also be
|
29
|
+
changed, or if you no longer need it, removed.
|
30
|
+
|
31
|
+
|
32
|
+
## Finalization
|
33
|
+
|
34
|
+
1. Review `dependency_decisions.yml` for accuracy and completeness. See the
|
35
|
+
`license_finder` README for information about the format of the file.
|
36
|
+
2. Review `config/license_finder.yml`, if it still exists. Unused keys have
|
37
|
+
been removed.
|
38
|
+
3. Delete `doc/dependencies.db`. It is not used by `license_finder` version
|
39
|
+
2.0.
|
40
|
+
4. Delete all the other `doc/dependencies*` files, if you want. If you
|
41
|
+
want to keep some textual reports, see the `license_finder report` README
|
42
|
+
docs. `license_finder` 2.0 will not automatically updates these reports, so
|
43
|
+
if you expect them to change, you must learn to run `license_finder report`.
|
44
|
+
5. Install `license_finder >= 2.0`. After installing, when you run
|
45
|
+
`license_finder` you should see the same list of action items you had before
|
46
|
+
upgrading.
|
47
|
+
6. Store your changes in version control.
|
48
|
+
|
49
|
+
|
50
|
+
## Contributing
|
51
|
+
|
52
|
+
1. Fork it ( https://github.com/mainej/license_finder_upgrade/fork )
|
53
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
54
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
55
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
56
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
---
|
2
|
+
whitelist:
|
3
|
+
#- MIT
|
4
|
+
#- Apache 2.0
|
5
|
+
ignore_groups:
|
6
|
+
#- test
|
7
|
+
#- development
|
8
|
+
ignore_dependencies:
|
9
|
+
#- bundler
|
10
|
+
dependencies_file_dir: './doc/'
|
11
|
+
project_name: # project name
|
12
|
+
gradle_command: # only meaningful if used with a Java/gradle project. Defaults to "gradle".
|
data/doc/dependencies.db
ADDED
Binary file
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
|
3
|
+
module LicenseFinderUpgrade
|
4
|
+
def self.config
|
5
|
+
@config ||= Configuration.ensure_default
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
|
10
|
+
require 'license_finder_upgrade/platform'
|
11
|
+
require 'license_finder_upgrade/configuration'
|
12
|
+
|
13
|
+
require 'license_finder_upgrade/decisions'
|
14
|
+
|
15
|
+
require 'license_finder_upgrade/tables'
|
16
|
+
require 'license_finder_upgrade/tables/manual_approval'
|
17
|
+
require 'license_finder_upgrade/tables/dependency'
|
18
|
+
|
19
|
+
require 'license_finder_upgrade/to_decisions'
|
@@ -0,0 +1,96 @@
|
|
1
|
+
require "delegate"
|
2
|
+
|
3
|
+
module LicenseFinderUpgrade
|
4
|
+
class Configuration
|
5
|
+
def self.ensure_default
|
6
|
+
prepare(Persistence.get)
|
7
|
+
end
|
8
|
+
|
9
|
+
# It's nice to keep destructive file system manipulation out of the
|
10
|
+
# initializer. That reduces test polution, but is slightly inconvenient
|
11
|
+
# for methods like Configuration.ensure_default and Configuration.move!,
|
12
|
+
# which need a working artifacts directory. This helper is a compromise.
|
13
|
+
def self.prepare(config)
|
14
|
+
result = new(config)
|
15
|
+
result.artifacts.init
|
16
|
+
result
|
17
|
+
end
|
18
|
+
|
19
|
+
attr_accessor :whitelist, :ignore_groups, :ignore_dependencies, :artifacts, :project_name, :gradle_command
|
20
|
+
|
21
|
+
def initialize(config)
|
22
|
+
@whitelist = Array(config['whitelist'])
|
23
|
+
@ignore_groups = Array(config["ignore_groups"])
|
24
|
+
@ignore_dependencies = Array(config["ignore_dependencies"])
|
25
|
+
@artifacts = Artifacts.new(Pathname(config['dependencies_file_dir'] || './doc/'))
|
26
|
+
@project_name = config['project_name'] || determine_project_name
|
27
|
+
@gradle_command = config['gradle_command'] || 'gradle'
|
28
|
+
end
|
29
|
+
|
30
|
+
def save!
|
31
|
+
hash = to_hash
|
32
|
+
if hash.empty?
|
33
|
+
Persistence.delete
|
34
|
+
else
|
35
|
+
Persistence.set(hash)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def to_hash
|
40
|
+
result = {}
|
41
|
+
if gradle_command != "gradle"
|
42
|
+
result['gradle_command'] = gradle_command
|
43
|
+
end
|
44
|
+
if artifacts.decisions_file.cleanpath != Pathname.new("doc/dependency_decisions.yml").cleanpath
|
45
|
+
result['decisions_file'] = artifacts.decisions_file.to_s
|
46
|
+
end
|
47
|
+
result
|
48
|
+
end
|
49
|
+
|
50
|
+
def determine_project_name
|
51
|
+
Pathname.pwd.basename.to_s
|
52
|
+
end
|
53
|
+
|
54
|
+
class Artifacts < SimpleDelegator
|
55
|
+
def init
|
56
|
+
mkpath
|
57
|
+
end
|
58
|
+
|
59
|
+
def database_uri
|
60
|
+
URI.escape(database_file.expand_path.to_s)
|
61
|
+
end
|
62
|
+
|
63
|
+
def decisions_file
|
64
|
+
join("dependency_decisions.yml")
|
65
|
+
end
|
66
|
+
|
67
|
+
private
|
68
|
+
|
69
|
+
def database_file
|
70
|
+
join("dependencies.db")
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
module Persistence
|
75
|
+
extend self
|
76
|
+
|
77
|
+
def get
|
78
|
+
YAML.load(file.read)
|
79
|
+
end
|
80
|
+
|
81
|
+
def set(hash)
|
82
|
+
file.open('w') { |f| f.write(YAML.dump(hash)) }
|
83
|
+
end
|
84
|
+
|
85
|
+
def delete
|
86
|
+
file.unlink
|
87
|
+
end
|
88
|
+
|
89
|
+
private
|
90
|
+
|
91
|
+
def file
|
92
|
+
Pathname.new('.').join('config', 'license_finder.yml')
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
@@ -0,0 +1,66 @@
|
|
1
|
+
module LicenseFinderUpgrade
|
2
|
+
class Decisions
|
3
|
+
#######
|
4
|
+
# WRITE
|
5
|
+
#######
|
6
|
+
|
7
|
+
attr_reader :decisions
|
8
|
+
|
9
|
+
def initialize
|
10
|
+
@decisions = []
|
11
|
+
end
|
12
|
+
|
13
|
+
def add_package(name, version, txn = {})
|
14
|
+
@decisions << [:add_package, name, version, txn]
|
15
|
+
self
|
16
|
+
end
|
17
|
+
|
18
|
+
def license(name, lic, txn = {})
|
19
|
+
@decisions << [:license, name, lic, txn]
|
20
|
+
self
|
21
|
+
end
|
22
|
+
|
23
|
+
def approve(name, txn = {})
|
24
|
+
@decisions << [:approve, name, txn]
|
25
|
+
self
|
26
|
+
end
|
27
|
+
|
28
|
+
def whitelist(lic, txn = {})
|
29
|
+
@decisions << [:whitelist, lic, txn]
|
30
|
+
self
|
31
|
+
end
|
32
|
+
|
33
|
+
def ignore(name, txn = {})
|
34
|
+
@decisions << [:ignore, name, txn]
|
35
|
+
self
|
36
|
+
end
|
37
|
+
|
38
|
+
def ignore_group(name, txn = {})
|
39
|
+
@decisions << [:ignore_group, name, txn]
|
40
|
+
self
|
41
|
+
end
|
42
|
+
|
43
|
+
def name_project(name, txn = {})
|
44
|
+
@decisions << [:name_project, name, txn]
|
45
|
+
self
|
46
|
+
end
|
47
|
+
|
48
|
+
#########
|
49
|
+
# PERSIST
|
50
|
+
#########
|
51
|
+
|
52
|
+
def save!
|
53
|
+
write!(persist)
|
54
|
+
end
|
55
|
+
|
56
|
+
def persist
|
57
|
+
YAML.dump(@decisions)
|
58
|
+
end
|
59
|
+
|
60
|
+
def write!(value)
|
61
|
+
LicenseFinderUpgrade.config.artifacts.decisions_file.open('w+') do |f|
|
62
|
+
f.print value
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module LicenseFinderUpgrade
|
2
|
+
module Platform
|
3
|
+
def self.sqlite_adapter
|
4
|
+
java? ? 'jdbc:sqlite' : 'sqlite'
|
5
|
+
end
|
6
|
+
|
7
|
+
def self.sqlite_gem
|
8
|
+
java? ? 'jdbc-sqlite3' : 'sqlite3'
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.sqlite_load_path
|
12
|
+
java? ? 'jdbc/sqlite3' : 'sqlite3'
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.java?
|
16
|
+
RUBY_PLATFORM =~ /java/
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'json'
|
2
|
+
|
3
|
+
module LicenseFinderUpgrade
|
4
|
+
class Dependency < Sequel::Model
|
5
|
+
plugin :composition
|
6
|
+
composition :licenses,
|
7
|
+
composer: ->(d) do
|
8
|
+
if d.license_names.nil?
|
9
|
+
Set.new
|
10
|
+
else
|
11
|
+
JSON.parse(d.license_names).to_set
|
12
|
+
end
|
13
|
+
end,
|
14
|
+
decomposer: ->(d) { self.license_names = licenses.to_json }
|
15
|
+
|
16
|
+
one_to_one :manual_approval
|
17
|
+
|
18
|
+
dataset_module do
|
19
|
+
def added_manually
|
20
|
+
where(added_manually: true)
|
21
|
+
end
|
22
|
+
|
23
|
+
def license_assigned_manually
|
24
|
+
where(license_assigned_manually: true)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
@@ -0,0 +1,70 @@
|
|
1
|
+
module LicenseFinderUpgrade
|
2
|
+
class ToDecisions
|
3
|
+
def self.default_txn
|
4
|
+
{
|
5
|
+
who: "license_finder_upgrade script",
|
6
|
+
why: "Upgrading from license_finder 1.2 to 2.0",
|
7
|
+
when: Time.now.getutc
|
8
|
+
}
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.upgrade
|
12
|
+
upgrader = new(
|
13
|
+
config: LicenseFinderUpgrade.config,
|
14
|
+
dependencies: Dependency
|
15
|
+
)
|
16
|
+
upgrader.decisions.save!
|
17
|
+
upgrader.config.save!
|
18
|
+
end
|
19
|
+
|
20
|
+
def initialize(options)
|
21
|
+
@config = options.fetch(:config)
|
22
|
+
@dependencies = options.fetch(:dependencies)
|
23
|
+
@txn = options.fetch(:txn) { self.class.default_txn }
|
24
|
+
@decisions = Decisions.new
|
25
|
+
prepare
|
26
|
+
end
|
27
|
+
|
28
|
+
attr_reader :decisions, :config
|
29
|
+
|
30
|
+
private
|
31
|
+
|
32
|
+
def prepare
|
33
|
+
@decisions.name_project(@config.project_name, @txn)
|
34
|
+
@config.whitelist.each do |license|
|
35
|
+
@decisions.whitelist(license, @txn)
|
36
|
+
end
|
37
|
+
@config.ignore_dependencies.each do |dep|
|
38
|
+
@decisions.ignore(dep, @txn)
|
39
|
+
end
|
40
|
+
@config.ignore_groups.each do |group|
|
41
|
+
@decisions.ignore_group(group, @txn)
|
42
|
+
end
|
43
|
+
@dependencies.added_manually.each do |dep|
|
44
|
+
@decisions.add_package(dep.name, dep.version, @txn)
|
45
|
+
prepare_licenses(dep)
|
46
|
+
end
|
47
|
+
@dependencies.license_assigned_manually.each do |dep|
|
48
|
+
prepare_licenses(dep)
|
49
|
+
end
|
50
|
+
@dependencies.each do |dep|
|
51
|
+
if approval = dep.manual_approval
|
52
|
+
txn = {
|
53
|
+
who: approval.approver,
|
54
|
+
why: approval.notes,
|
55
|
+
when: approval.safe_created_at
|
56
|
+
}
|
57
|
+
@decisions.approve(dep.name, txn)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
def prepare_licenses(dep)
|
63
|
+
unknown_licenses = ["other", "unknown"].to_set
|
64
|
+
dep.
|
65
|
+
licenses.
|
66
|
+
reject { |license| unknown_licenses.include? license }.
|
67
|
+
each { |license| @decisions.license(dep.name, license, @txn) }
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
|
5
|
+
require 'license_finder_upgrade/platform'
|
6
|
+
|
7
|
+
Gem::Specification.new do |spec|
|
8
|
+
spec.required_ruby_version = '>= 1.9.3'
|
9
|
+
spec.name = "license_finder_upgrade"
|
10
|
+
spec.version = "0.0.1"
|
11
|
+
|
12
|
+
spec.authors = ["Jacob Maine"]
|
13
|
+
|
14
|
+
spec.email = [""]
|
15
|
+
spec.homepage = "https://github.com/mainej/license_finder_upgrade"
|
16
|
+
spec.summary = %q{Upgrade helper for license_finder}
|
17
|
+
spec.description = %q{This tool helps upgrade license_finder projects from version 1.2 to 2.0.}
|
18
|
+
|
19
|
+
spec.license = "MIT"
|
20
|
+
|
21
|
+
spec.files = `git ls-files -z`.split("\x0")
|
22
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
23
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
24
|
+
spec.require_paths = ["lib"]
|
25
|
+
|
26
|
+
spec.add_dependency "sequel"
|
27
|
+
spec.add_dependency LicenseFinderUpgrade::Platform.sqlite_gem
|
28
|
+
|
29
|
+
spec.add_development_dependency "rspec", "~> 3"
|
30
|
+
|
31
|
+
spec.platform = "java" if LicenseFinderUpgrade::Platform.java?
|
32
|
+
end
|
@@ -0,0 +1,135 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
module LicenseFinderUpgrade
|
4
|
+
describe ToDecisions do
|
5
|
+
let(:txn) { {some: 'txn data'} }
|
6
|
+
|
7
|
+
context "config" do
|
8
|
+
def from_config(config)
|
9
|
+
described_class.new(
|
10
|
+
config: Configuration.new(config),
|
11
|
+
dependencies: Dependency,
|
12
|
+
txn: txn
|
13
|
+
).config.to_hash
|
14
|
+
end
|
15
|
+
|
16
|
+
it "includes gradle_command if it was custom" do
|
17
|
+
config = from_config("gradle_command" => "gradlew")
|
18
|
+
expect(config["gradle_command"]).to eq "gradlew"
|
19
|
+
end
|
20
|
+
|
21
|
+
it "does not have gradle_command if it was 'gradle'" do
|
22
|
+
config = from_config("gradle_command" => "gradle")
|
23
|
+
expect(config).not_to have_key "gradle_command"
|
24
|
+
end
|
25
|
+
|
26
|
+
it "includes decisions_file if it was custom" do
|
27
|
+
config = from_config("dependencies_file_dir" => "/tmp/path")
|
28
|
+
expect(config["decisions_file"]).to eq "/tmp/path/dependency_decisions.yml"
|
29
|
+
end
|
30
|
+
|
31
|
+
it "does not have decisions_file if it was the default" do
|
32
|
+
config = from_config("dependencies_file_dir" => "./doc/")
|
33
|
+
expect(config).not_to have_key "decisions_file"
|
34
|
+
config = from_config("dependencies_file_dir" => "doc")
|
35
|
+
expect(config).not_to have_key "decisions_file"
|
36
|
+
end
|
37
|
+
|
38
|
+
it "is empty if everything was the default" do
|
39
|
+
config = from_config(
|
40
|
+
"gradle_command" => "gradle",
|
41
|
+
"dependencies_file_dir" => "./doc/"
|
42
|
+
)
|
43
|
+
expect(config).to be_empty
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
context "decisions" do
|
48
|
+
def from_config(config)
|
49
|
+
described_class.new(
|
50
|
+
config: Configuration.new(config),
|
51
|
+
dependencies: Dependency,
|
52
|
+
txn: txn
|
53
|
+
).decisions.decisions
|
54
|
+
end
|
55
|
+
|
56
|
+
def from_db
|
57
|
+
described_class.new(
|
58
|
+
config: Configuration.new({}),
|
59
|
+
dependencies: Dependency,
|
60
|
+
txn: txn
|
61
|
+
).decisions.decisions
|
62
|
+
end
|
63
|
+
|
64
|
+
it "copies project name from yaml" do
|
65
|
+
expect(from_config("project_name" => "proj")).to include [:name_project, "proj", txn]
|
66
|
+
end
|
67
|
+
|
68
|
+
it "copies whitelist from yaml" do
|
69
|
+
decisions = from_config("whitelist" => ["lic1", "lic2"])
|
70
|
+
expect(decisions).to include [:whitelist, "lic1", txn]
|
71
|
+
expect(decisions).to include [:whitelist, "lic2", txn]
|
72
|
+
end
|
73
|
+
|
74
|
+
it "copies ignored dependencies from yaml" do
|
75
|
+
decisions = from_config("ignore_dependencies" => ["dep1", "dep2"])
|
76
|
+
expect(decisions).to include [:ignore, "dep1", txn]
|
77
|
+
expect(decisions).to include [:ignore, "dep2", txn]
|
78
|
+
end
|
79
|
+
|
80
|
+
it "copies ignored groups from yaml" do
|
81
|
+
decisions = from_config("ignore_groups" => ["grp1", "grp2"])
|
82
|
+
expect(decisions).to include [:ignore_group, "grp1", txn]
|
83
|
+
expect(decisions).to include [:ignore_group, "grp2", txn]
|
84
|
+
end
|
85
|
+
|
86
|
+
it "copies manually created dependencies from db" do
|
87
|
+
Dependency.create(name: "system", version: "0.1.2")
|
88
|
+
Dependency.create(name: "manual", added_manually: true, version: "0.1.2")
|
89
|
+
decisions = from_db
|
90
|
+
expect(decisions).to include [:add_package, 'manual', '0.1.2', txn]
|
91
|
+
expect(decisions).not_to include [:add_package, 'system', '0.1.2', txn]
|
92
|
+
end
|
93
|
+
|
94
|
+
it "copies manualy created dependencies' licenses from db" do
|
95
|
+
Dependency.create(name: "system", licenses: ["lic1", "lic2"])
|
96
|
+
Dependency.create(name: "manual", added_manually: true, licenses: ["lic1", "lic2"])
|
97
|
+
decisions = from_db
|
98
|
+
expect(decisions).to include [:license, 'manual', 'lic1', txn]
|
99
|
+
expect(decisions).to include [:license, 'manual', 'lic2', txn]
|
100
|
+
expect(decisions).not_to include [:license, 'system', 'lic1', txn]
|
101
|
+
expect(decisions).not_to include [:license, 'system', 'lic2', txn]
|
102
|
+
end
|
103
|
+
|
104
|
+
it "does not copy manually created dependencies' 'other' licenses from db" do
|
105
|
+
Dependency.create(name: "manual", added_manually: true, licenses: ["other", "unknown"])
|
106
|
+
decisions = from_db
|
107
|
+
expect(decisions).not_to include [:license, 'manual', 'other', txn]
|
108
|
+
# 'unknown', in case https://github.com/pivotal/LicenseFinder/pull/124 is merged
|
109
|
+
expect(decisions).not_to include [:license, 'manual', 'unknown', txn]
|
110
|
+
end
|
111
|
+
|
112
|
+
it "copies manually licensed dependencies from db" do
|
113
|
+
Dependency.create(name: "system", licenses: ["lic1", "lic2"])
|
114
|
+
Dependency.create(name: "manual", license_assigned_manually: true, licenses: ["lic1", "lic2"])
|
115
|
+
decisions = from_db
|
116
|
+
expect(decisions).to include [:license, 'manual', 'lic1', txn]
|
117
|
+
expect(decisions).to include [:license, 'manual', 'lic2', txn]
|
118
|
+
expect(decisions).not_to include [:license, 'system', 'lic1', txn]
|
119
|
+
expect(decisions).not_to include [:license, 'system', 'lic2', txn]
|
120
|
+
end
|
121
|
+
|
122
|
+
it "copies manually approved licenses from db" do
|
123
|
+
time = Time.new(10000)
|
124
|
+
Dependency.create(name: "system")
|
125
|
+
manual = Dependency.create(name: "manual")
|
126
|
+
manual.manual_approval = ManualApproval.create(approver: "Someone", notes: "Some reason", created_at: time)
|
127
|
+
manual.save
|
128
|
+
|
129
|
+
decisions = from_db
|
130
|
+
expect(decisions).to include [:approve, 'manual', { who: "Someone", why: "Some reason", when: time }]
|
131
|
+
expect(decisions).not_to include [:approve, 'system', anything]
|
132
|
+
end
|
133
|
+
end
|
134
|
+
end
|
135
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'bundler/setup'
|
3
|
+
|
4
|
+
require 'license_finder_upgrade'
|
5
|
+
require 'rspec'
|
6
|
+
|
7
|
+
RSpec.configure do |config|
|
8
|
+
config.mock_with :rspec
|
9
|
+
|
10
|
+
config.around do |example|
|
11
|
+
LicenseFinderUpgrade::DB.transaction(rollback: :always) { example.run }
|
12
|
+
end
|
13
|
+
end
|
metadata
ADDED
@@ -0,0 +1,109 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: license_finder_upgrade
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Jacob Maine
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-01-26 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: sequel
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: sqlite3
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3'
|
55
|
+
description: This tool helps upgrade license_finder projects from version 1.2 to 2.0.
|
56
|
+
email:
|
57
|
+
- ''
|
58
|
+
executables:
|
59
|
+
- license_finder_upgrade
|
60
|
+
extensions: []
|
61
|
+
extra_rdoc_files: []
|
62
|
+
files:
|
63
|
+
- ".gitignore"
|
64
|
+
- ".travis.yml"
|
65
|
+
- Gemfile
|
66
|
+
- LICENSE.txt
|
67
|
+
- README.md
|
68
|
+
- Rakefile
|
69
|
+
- bin/license_finder_upgrade
|
70
|
+
- config/license_finder.yml
|
71
|
+
- doc/dependencies.db
|
72
|
+
- lib/license_finder_upgrade.rb
|
73
|
+
- lib/license_finder_upgrade/configuration.rb
|
74
|
+
- lib/license_finder_upgrade/decisions.rb
|
75
|
+
- lib/license_finder_upgrade/platform.rb
|
76
|
+
- lib/license_finder_upgrade/tables.rb
|
77
|
+
- lib/license_finder_upgrade/tables/dependency.rb
|
78
|
+
- lib/license_finder_upgrade/tables/manual_approval.rb
|
79
|
+
- lib/license_finder_upgrade/to_decisions.rb
|
80
|
+
- license_finder_upgrade.gemspec
|
81
|
+
- spec/lib/license_finder_upgrade/to_decisions_spec.rb
|
82
|
+
- spec/spec_helper.rb
|
83
|
+
homepage: https://github.com/mainej/license_finder_upgrade
|
84
|
+
licenses:
|
85
|
+
- MIT
|
86
|
+
metadata: {}
|
87
|
+
post_install_message:
|
88
|
+
rdoc_options: []
|
89
|
+
require_paths:
|
90
|
+
- lib
|
91
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
92
|
+
requirements:
|
93
|
+
- - ">="
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: 1.9.3
|
96
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
97
|
+
requirements:
|
98
|
+
- - ">="
|
99
|
+
- !ruby/object:Gem::Version
|
100
|
+
version: '0'
|
101
|
+
requirements: []
|
102
|
+
rubyforge_project:
|
103
|
+
rubygems_version: 2.2.2
|
104
|
+
signing_key:
|
105
|
+
specification_version: 4
|
106
|
+
summary: Upgrade helper for license_finder
|
107
|
+
test_files:
|
108
|
+
- spec/lib/license_finder_upgrade/to_decisions_spec.rb
|
109
|
+
- spec/spec_helper.rb
|