papers 2.4.2 → 2.4.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.gitignore +2 -0
- data/CHANGELOG.md +6 -0
- data/Gemfile +8 -2
- data/README.md +10 -0
- data/lib/papers/dependency_specification.rb +18 -18
- data/lib/papers/manifest_updater.rb +14 -8
- data/lib/papers/version.rb +1 -1
- data/spec/manifest_updater_spec.rb +84 -13
- data/spec/spec_helper.rb +2 -0
- metadata +6 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 174c6341ec833049a5cb09f89779966021a1c50b8152e96bb9be8866a4446b7e
|
4
|
+
data.tar.gz: f7b0dc8ef6a71ef26698f95eb9264fb66c2235c13113eacba5694c506f64946b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1b187474da6f2d1d898916db86b673935618c9e3dc9fbc2c005d7363d7a45eeccce39ee1742662eb94a31097a320475e64371189df8dad0321ebfcaeb8578d87
|
7
|
+
data.tar.gz: f151154a7a5f36bd62acec733f17fa5d9313765d11bdddab9dce97a85643d81b0736669f0e1ea447e818676a723820e71a4735e437dd30e501259c04da48c6cf
|
data/.gitignore
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,11 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## 2.4.4
|
4
|
+
* Fix to not re-apply already present license change warnings.
|
5
|
+
|
6
|
+
## 2.4.3
|
7
|
+
* Better whitespace output to avoid trailing spaces.
|
8
|
+
|
3
9
|
## 2.4.2
|
4
10
|
* Support for `package_whitelist` in configuration.
|
5
11
|
* Fix help output from command-line tool
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -164,6 +164,16 @@ Finished in 0.01043 seconds
|
|
164
164
|
1 examples, 1 failures
|
165
165
|
```
|
166
166
|
|
167
|
+
### Generating the manifest from inside your tests
|
168
|
+
If you update your gems on a frequent basis, failing to remember to update the Papers manifest can be a time-consuming effort in getting your tests to pass. You can add this to your test to generate the manifest automatically:
|
169
|
+
|
170
|
+
```ruby
|
171
|
+
Papers::ManifestUpdater.new.update!
|
172
|
+
```
|
173
|
+
|
174
|
+
Note that you should not do this if you manually edit your manifest!
|
175
|
+
|
176
|
+
|
167
177
|
## License
|
168
178
|
|
169
179
|
The Papers Gem is licensed under the __MIT License__. See [MIT-LICENSE](https://github.com/newrelic/papers/blob/master/MIT-LICENSE) for full text.
|
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'set'
|
2
|
+
|
1
3
|
module Papers
|
2
4
|
class DependencySpecification
|
3
5
|
attr_accessor :name, :license, :license_url, :project_url
|
@@ -16,27 +18,25 @@ module Papers
|
|
16
18
|
|
17
19
|
def acceptable_license?
|
18
20
|
Papers.config.license_whitelist.include?(license) ||
|
19
|
-
|
20
|
-
|
21
|
+
Papers.config.version_whitelisted_license == license ||
|
22
|
+
Papers.config.package_whitelist.include?(name)
|
21
23
|
end
|
22
24
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
end.sort { |a, b| a.name.downcase <=> b.name.downcase }
|
32
|
-
end
|
25
|
+
def self.all_from_manifest(manifest)
|
26
|
+
(manifest[manifest_key] || []).map do |name, info|
|
27
|
+
license_url = info['license_url']
|
28
|
+
license = info['license']
|
29
|
+
project_url = info['project_url']
|
30
|
+
new(name: name, license: license, license_url: license_url, project_url: project_url)
|
31
|
+
end.sort { |a, b| a.name.downcase <=> b.name.downcase }
|
32
|
+
end
|
33
33
|
|
34
|
-
|
35
|
-
|
36
|
-
|
34
|
+
def self.missing_from_manifest(manifest)
|
35
|
+
introspected.to_set - all_from_manifest(manifest).map(&:name).to_set
|
36
|
+
end
|
37
37
|
|
38
|
-
|
39
|
-
|
40
|
-
|
38
|
+
def self.unknown_in_manifest(manifest)
|
39
|
+
all_from_manifest(manifest).map(&:name).to_set - introspected.to_set
|
40
|
+
end
|
41
41
|
end
|
42
42
|
end
|
@@ -27,15 +27,18 @@ module Papers
|
|
27
27
|
result = YAML.load(original_content)
|
28
28
|
|
29
29
|
update_gems(result)
|
30
|
-
update_javascript(result,
|
31
|
-
update_javascript(result,
|
32
|
-
update_javascript(result,
|
30
|
+
update_javascript(result, 'javascripts', get_installed_javascripts)
|
31
|
+
update_javascript(result, 'bower_components', get_installed_bower_components)
|
32
|
+
update_javascript(result, 'npm_packages', get_installed_npm_packages)
|
33
33
|
|
34
|
-
build_header + YAML.dump(result)
|
34
|
+
manifest_content = build_header + YAML.dump(result)
|
35
|
+
|
36
|
+
# strip trailing whitespace, ensure file ends with a newline
|
37
|
+
manifest_content.gsub(/\s*$/, '') + "\n"
|
35
38
|
end
|
36
39
|
|
37
40
|
def update_gems(result)
|
38
|
-
result_gems = result[
|
41
|
+
result_gems = result['gems']
|
39
42
|
return unless result_gems
|
40
43
|
|
41
44
|
manifest_names = manifest_names(result_gems)
|
@@ -69,12 +72,15 @@ module Papers
|
|
69
72
|
|
70
73
|
def update_gem(result_gems, gemspec, manifest_gem_key)
|
71
74
|
manifest_gem = result_gems.delete(manifest_gem_key)
|
72
|
-
if gemspec.license && gemspec.license != manifest_gem[
|
75
|
+
if gemspec.license && gemspec.license != manifest_gem['license']
|
73
76
|
new_licenses = gemspec.licenses || []
|
74
77
|
new_licenses << gemspec.license
|
75
78
|
new_licenses.uniq!
|
76
79
|
|
77
|
-
|
80
|
+
# license key could be an array to_s to protect against that
|
81
|
+
unless manifest_gem['license'].to_s.match(/^License Change! Was '.+', is now .+$/)
|
82
|
+
manifest_gem['license'] = "License Change! Was '#{manifest_gem['license']}', is now #{new_licenses}"
|
83
|
+
end
|
78
84
|
end
|
79
85
|
|
80
86
|
name = gem_name_and_version(gemspec)
|
@@ -96,7 +102,7 @@ module Papers
|
|
96
102
|
end
|
97
103
|
|
98
104
|
def name_from_key(key)
|
99
|
-
key.include?(
|
105
|
+
key.include?('-') ? key.rpartition('-').first : key
|
100
106
|
end
|
101
107
|
|
102
108
|
def manifest_names(result_gems)
|
data/lib/papers/version.rb
CHANGED
@@ -28,11 +28,11 @@ EOS
|
|
28
28
|
gems:
|
29
29
|
rails-4.2.0:
|
30
30
|
license: MIT
|
31
|
-
license_url:
|
31
|
+
license_url:
|
32
32
|
project_url: https://github.com/rails/rails
|
33
33
|
newrelic_rpm:
|
34
34
|
license: New Relic
|
35
|
-
license_url:
|
35
|
+
license_url:
|
36
36
|
project_url: https://github.com/newrelic/rpm
|
37
37
|
EOS
|
38
38
|
}
|
@@ -40,11 +40,82 @@ EOS
|
|
40
40
|
let(:shoes_license) { <<EOS
|
41
41
|
shoes-4.0.0:
|
42
42
|
license: MIT
|
43
|
-
license_url:
|
43
|
+
license_url:
|
44
44
|
project_url: http://shoesrb.com
|
45
45
|
EOS
|
46
46
|
}
|
47
47
|
|
48
|
+
let(:foo_license) { <<EOS
|
49
|
+
signed_payload-2.0.1:
|
50
|
+
license: License Change! Was 'New Relic', is now ["Nonstandard"]
|
51
|
+
license_url:
|
52
|
+
project_url: https://source.datanerd.us/account-auth-and-access/signed_payload
|
53
|
+
EOS
|
54
|
+
}
|
55
|
+
|
56
|
+
it 'should avoid nesting license change messages' do
|
57
|
+
gemspec = double(name: 'foo', version: '1.2.3', license: "some License Change! Was 'New Relic', is now [\"Nonstandard\"]", licenses: [], homepage: 'foo.com')
|
58
|
+
|
59
|
+
result_gems = {}
|
60
|
+
manifest_gem_key = 'foo'
|
61
|
+
allow(result_gems).to receive(:delete).with(manifest_gem_key).and_return({
|
62
|
+
'name' => 'foo',
|
63
|
+
'version' => '1.2.3',
|
64
|
+
'license' => "License Change! Was 'New Relic', is now [\"Nonstandard\"]",
|
65
|
+
'homepage' => 'foo.com'
|
66
|
+
})
|
67
|
+
|
68
|
+
updater.update_gem(result_gems, gemspec, manifest_gem_key)
|
69
|
+
expect(result_gems['foo']).to eq({
|
70
|
+
'name' => 'foo',
|
71
|
+
'version' => '1.2.3',
|
72
|
+
'license' => "License Change! Was 'New Relic', is now [\"Nonstandard\"]",
|
73
|
+
'homepage' => 'foo.com'
|
74
|
+
})
|
75
|
+
end
|
76
|
+
|
77
|
+
it 'should work as normal for non nested changes' do
|
78
|
+
gemspec = double(name: 'foo', version: '1.2.3', license: "asdf", licenses: [], homepage: 'foo.com')
|
79
|
+
|
80
|
+
result_gems = {}
|
81
|
+
manifest_gem_key = 'foo'
|
82
|
+
allow(result_gems).to receive(:delete).with(manifest_gem_key).and_return({
|
83
|
+
'name' => 'foo',
|
84
|
+
'version' => '1.2.3',
|
85
|
+
'license' => "ldkadfaldfjalkdsfj",
|
86
|
+
'homepage' => 'foo.com'
|
87
|
+
})
|
88
|
+
|
89
|
+
updater.update_gem(result_gems, gemspec, manifest_gem_key)
|
90
|
+
expect(result_gems['foo']).to eq({
|
91
|
+
'name' => 'foo',
|
92
|
+
'version' => '1.2.3',
|
93
|
+
'license' => "License Change! Was 'ldkadfaldfjalkdsfj', is now [\"asdf\"]",
|
94
|
+
'homepage' => 'foo.com'
|
95
|
+
})
|
96
|
+
end
|
97
|
+
|
98
|
+
# We don't want to support it fully, but don't bomb out if we find an array
|
99
|
+
it 'should handle array in manifest' do
|
100
|
+
gemspec = double(name: 'foo', version: '1.2.3', license: "asdf", licenses: ["asdf", "new"], homepage: 'foo.com')
|
101
|
+
|
102
|
+
result_gems = {}
|
103
|
+
manifest_gem_key = 'foo'
|
104
|
+
allow(result_gems).to receive(:delete).with(manifest_gem_key).and_return({
|
105
|
+
'name' => 'foo',
|
106
|
+
'version' => '1.2.3',
|
107
|
+
'license' => ["asdf", "old"],
|
108
|
+
'homepage' => 'foo.com'
|
109
|
+
})
|
110
|
+
|
111
|
+
updater.update_gem(result_gems, gemspec, manifest_gem_key)
|
112
|
+
expect(result_gems['foo']).to eq({
|
113
|
+
'name' => 'foo',
|
114
|
+
'version' => '1.2.3',
|
115
|
+
'license' => "License Change! Was '[\"asdf\", \"old\"]', is now [\"asdf\", \"new\"]",
|
116
|
+
'homepage' => 'foo.com'
|
117
|
+
})
|
118
|
+
end
|
48
119
|
|
49
120
|
it "avoids unnecessary updates" do
|
50
121
|
allow(updater).to receive(:gemspecs).and_return([
|
@@ -117,26 +188,26 @@ javascripts:
|
|
117
188
|
project_url: http://newrelic.com
|
118
189
|
app/javascripts/instances/show.js:
|
119
190
|
license: Unknown
|
120
|
-
license_url:
|
121
|
-
project_url:
|
191
|
+
license_url:
|
192
|
+
project_url:
|
122
193
|
bower_components:
|
123
194
|
angular:
|
124
195
|
license: MIT
|
125
|
-
license_url:
|
126
|
-
project_url:
|
196
|
+
license_url:
|
197
|
+
project_url:
|
127
198
|
lodash:
|
128
199
|
license: Unknown
|
129
|
-
license_url:
|
130
|
-
project_url:
|
200
|
+
license_url:
|
201
|
+
project_url:
|
131
202
|
npm_packages:
|
132
203
|
react:
|
133
204
|
license: MIT
|
134
|
-
license_url:
|
135
|
-
project_url:
|
205
|
+
license_url:
|
206
|
+
project_url:
|
136
207
|
redux:
|
137
208
|
license: Unknown
|
138
|
-
license_url:
|
139
|
-
project_url:
|
209
|
+
license_url:
|
210
|
+
project_url:
|
140
211
|
EOS
|
141
212
|
}
|
142
213
|
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: papers
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.4.
|
4
|
+
version: 2.4.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ralph Bodenner
|
@@ -9,10 +9,10 @@ authors:
|
|
9
9
|
- Andrew Bloomgarden
|
10
10
|
- Lucas Charles
|
11
11
|
- David Celis
|
12
|
-
autorequire:
|
12
|
+
autorequire:
|
13
13
|
bindir: bin
|
14
14
|
cert_chain: []
|
15
|
-
date:
|
15
|
+
date: 2022-11-03 00:00:00.000000000 Z
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
18
18
|
name: rake
|
@@ -84,7 +84,7 @@ homepage: http://github.com/newrelic/papers
|
|
84
84
|
licenses:
|
85
85
|
- MIT
|
86
86
|
metadata: {}
|
87
|
-
post_install_message:
|
87
|
+
post_install_message:
|
88
88
|
rdoc_options: []
|
89
89
|
require_paths:
|
90
90
|
- lib
|
@@ -99,9 +99,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
99
99
|
- !ruby/object:Gem::Version
|
100
100
|
version: '0'
|
101
101
|
requirements: []
|
102
|
-
|
103
|
-
|
104
|
-
signing_key:
|
102
|
+
rubygems_version: 3.1.4
|
103
|
+
signing_key:
|
105
104
|
specification_version: 4
|
106
105
|
summary: Validate the licenses of software dependencies you use
|
107
106
|
test_files:
|