metadata_json_deps 0.1.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE +20 -0
- data/README.md +6 -4
- data/bin/generate-fixtures-yaml +16 -0
- data/bin/metadata-json-deps +3 -5
- data/lib/metadata_json_deps.rb +69 -3
- metadata +56 -17
- data/lib/metadata_json_deps/forge_versions.rb +0 -31
- data/lib/metadata_json_deps/metadata_checker.rb +0 -26
- data/lib/metadata_json_deps/runner.rb +0 -32
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 376a5a0f5181d0d6095b02fd5eb968c8acc887c8f85c1127c80d3fd622ed4a14
|
4
|
+
data.tar.gz: 2a8978e1c706f98b80a82c04e9bc4cb5721d72026ab7089b044d0981e1db16c7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d7a981df5b61c4ff15f7f016ce4f90ad5045f47c3556db8d686c6cd5ada2eff218daa240507f73c071f249c255bae1c39073ba04a675bb4426158ca3f9b56b68
|
7
|
+
data.tar.gz: 28fabc4c9c1cfe758875314d137117a7c7b437d39f15e94b160469f2a7fade2a3a59eba9eaa39e4d5f71e054d9aa1df9b760f3c1a7a63db860fbb27d9c0dcdb4
|
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2017-2021 Ewoud Kohl van Wijngaarden
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
CHANGED
@@ -4,18 +4,18 @@ The metadata-json-deps tool validates dependencies in `metadata.json` files in P
|
|
4
4
|
|
5
5
|
## Compatibility
|
6
6
|
|
7
|
-
metadata-json-deps is compatible with Ruby versions 2.
|
7
|
+
metadata-json-deps is compatible with Ruby versions 2.4.0 and newer.
|
8
8
|
|
9
9
|
## Installation
|
10
10
|
|
11
11
|
via `gem` command:
|
12
12
|
``` shell
|
13
|
-
gem install
|
13
|
+
gem install metadata_json_deps
|
14
14
|
```
|
15
15
|
|
16
16
|
via Gemfile:
|
17
17
|
``` ruby
|
18
|
-
gem '
|
18
|
+
gem 'metadata_json_deps'
|
19
19
|
```
|
20
20
|
|
21
21
|
## Usage
|
@@ -40,8 +40,10 @@ You can also integrate `metadata-json-deps` checks into your tests using a Rake
|
|
40
40
|
|
41
41
|
```ruby
|
42
42
|
require 'metadata_json_deps'
|
43
|
+
|
44
|
+
desc 'Run metadata-json-deps'
|
43
45
|
task :metadata_deps do
|
44
46
|
files = FileList['modules/*/metadata.json']
|
45
|
-
|
47
|
+
MetadataJsonDeps::run(files)
|
46
48
|
end
|
47
49
|
```
|
@@ -0,0 +1,16 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'optparse'
|
4
|
+
require 'metadata_json_deps'
|
5
|
+
|
6
|
+
parser = OptionParser.new do |opts|
|
7
|
+
opts.banner = "Usage: #{opts.program_name} metadata"
|
8
|
+
end
|
9
|
+
|
10
|
+
parser.parse!
|
11
|
+
if ARGV.empty?
|
12
|
+
puts parser.help
|
13
|
+
exit 1
|
14
|
+
end
|
15
|
+
|
16
|
+
MetadataJsonDeps.build_fixtures(ARGV.first)
|
data/bin/metadata-json-deps
CHANGED
@@ -5,9 +5,7 @@ require 'metadata_json_deps'
|
|
5
5
|
|
6
6
|
options = {}
|
7
7
|
OptionParser.new do |opts|
|
8
|
-
opts.on("-v", "--[no-]verbose", "Run verbosely")
|
9
|
-
|
10
|
-
end
|
11
|
-
end.parse!
|
8
|
+
opts.on("-v", "--[no-]verbose", "Run verbosely")
|
9
|
+
end.parse!(into: options)
|
12
10
|
|
13
|
-
MetadataJsonDeps
|
11
|
+
MetadataJsonDeps.run(ARGV, options[:verbose])
|
data/lib/metadata_json_deps.rb
CHANGED
@@ -1,5 +1,71 @@
|
|
1
|
+
require 'puppet_forge'
|
2
|
+
require 'puppet_metadata'
|
3
|
+
|
1
4
|
module MetadataJsonDeps
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
+
class ForgeVersions
|
6
|
+
def initialize(cache = {})
|
7
|
+
@cache = cache
|
8
|
+
end
|
9
|
+
|
10
|
+
def get_module(name)
|
11
|
+
name = PuppetForge::V3.normalize_name(name)
|
12
|
+
@cache[name] ||= PuppetForge::Module.find(name)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.build_fixtures(filename)
|
17
|
+
require 'yaml'
|
18
|
+
|
19
|
+
result = {}
|
20
|
+
|
21
|
+
dependencies = PuppetMetadata.read(filename).dependencies
|
22
|
+
if dependencies.any?
|
23
|
+
forge = ForgeVersions.new
|
24
|
+
|
25
|
+
repositories = {}
|
26
|
+
result['fixtures'] = {'repositories' => repositories}
|
27
|
+
|
28
|
+
dependencies.each do |dependency, _constraint|
|
29
|
+
mod = forge.get_module(dependency)
|
30
|
+
# TODO: The forge should expose the source URL directly
|
31
|
+
repositories[mod.name] = mod.current_release.metadata[:source]
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
puts result.to_yaml
|
36
|
+
end
|
37
|
+
|
38
|
+
def self.run(filenames, verbose = false)
|
39
|
+
forge = ForgeVersions.new
|
40
|
+
|
41
|
+
filenames.each do |filename|
|
42
|
+
puts "Checking #{filename}"
|
43
|
+
metadata = PuppetMetadata.read(filename)
|
44
|
+
|
45
|
+
metadata.dependencies.map do |dependency, constraint|
|
46
|
+
mod = forge.get_module(dependency)
|
47
|
+
|
48
|
+
if mod.deprecated_at
|
49
|
+
if mod.superseded_by
|
50
|
+
puts " #{dependency} was superseded by #{mod.superseded_by[:slug]}"
|
51
|
+
elsif mod.deprecated_for
|
52
|
+
puts " #{dependency} was deprecated: #{mod.deprecated_for}"
|
53
|
+
else
|
54
|
+
puts " #{dependency} was deprecated"
|
55
|
+
end
|
56
|
+
else
|
57
|
+
current = mod.current_release.version
|
58
|
+
|
59
|
+
if metadata.satisfies_dependency?(dependency, current)
|
60
|
+
if verbose
|
61
|
+
puts " #{dependency} (#{constraint}) matches #{current}"
|
62
|
+
end
|
63
|
+
else
|
64
|
+
puts " #{dependency} (#{constraint}) doesn't match #{current}"
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
rescue Interrupt
|
70
|
+
end
|
5
71
|
end
|
metadata
CHANGED
@@ -1,63 +1,103 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: metadata_json_deps
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ewoud Kohl van Wijngaarden
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-02-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: puppet_forge
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '2.2'
|
20
|
+
- - "<"
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '4'
|
20
23
|
type: :runtime
|
21
24
|
prerelease: false
|
22
25
|
version_requirements: !ruby/object:Gem::Requirement
|
23
26
|
requirements:
|
24
|
-
- - "
|
27
|
+
- - ">="
|
25
28
|
- !ruby/object:Gem::Version
|
26
29
|
version: '2.2'
|
30
|
+
- - "<"
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '4'
|
27
33
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
34
|
+
name: puppet_metadata
|
29
35
|
requirement: !ruby/object:Gem::Requirement
|
30
36
|
requirements:
|
31
|
-
- - "
|
37
|
+
- - ">="
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: 0.3.0
|
40
|
+
- - "<"
|
32
41
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
42
|
+
version: '2'
|
34
43
|
type: :runtime
|
35
44
|
prerelease: false
|
45
|
+
version_requirements: !ruby/object:Gem::Requirement
|
46
|
+
requirements:
|
47
|
+
- - ">="
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: 0.3.0
|
50
|
+
- - "<"
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: '2'
|
53
|
+
- !ruby/object:Gem::Dependency
|
54
|
+
name: rspec
|
55
|
+
requirement: !ruby/object:Gem::Requirement
|
56
|
+
requirements:
|
57
|
+
- - "~>"
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
version: '3.0'
|
60
|
+
type: :development
|
61
|
+
prerelease: false
|
62
|
+
version_requirements: !ruby/object:Gem::Requirement
|
63
|
+
requirements:
|
64
|
+
- - "~>"
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
version: '3.0'
|
67
|
+
- !ruby/object:Gem::Dependency
|
68
|
+
name: rake
|
69
|
+
requirement: !ruby/object:Gem::Requirement
|
70
|
+
requirements:
|
71
|
+
- - "~>"
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
version: '13.0'
|
74
|
+
type: :development
|
75
|
+
prerelease: false
|
36
76
|
version_requirements: !ruby/object:Gem::Requirement
|
37
77
|
requirements:
|
38
78
|
- - "~>"
|
39
79
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
80
|
+
version: '13.0'
|
41
81
|
description: Verify all your dependencies allow the latest versions on Puppet Forge
|
42
82
|
email: ewoud+rubygems@kohlvanwijngaarden.nl
|
43
83
|
executables:
|
84
|
+
- generate-fixtures-yaml
|
44
85
|
- metadata-json-deps
|
45
86
|
extensions: []
|
46
87
|
extra_rdoc_files:
|
47
88
|
- README.md
|
48
89
|
files:
|
90
|
+
- LICENSE
|
49
91
|
- README.md
|
92
|
+
- bin/generate-fixtures-yaml
|
50
93
|
- bin/metadata-json-deps
|
51
94
|
- lib/metadata_json_deps.rb
|
52
|
-
- lib/metadata_json_deps/forge_versions.rb
|
53
|
-
- lib/metadata_json_deps/metadata_checker.rb
|
54
|
-
- lib/metadata_json_deps/runner.rb
|
55
95
|
homepage: https://github.com/ekohl/metadata_json_deps
|
56
96
|
licenses:
|
57
97
|
- MIT
|
58
98
|
metadata:
|
59
99
|
source_code_uri: https://github.com/ekohl/metadata_json_deps
|
60
|
-
post_install_message:
|
100
|
+
post_install_message:
|
61
101
|
rdoc_options: []
|
62
102
|
require_paths:
|
63
103
|
- lib
|
@@ -65,16 +105,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
65
105
|
requirements:
|
66
106
|
- - ">="
|
67
107
|
- !ruby/object:Gem::Version
|
68
|
-
version: 2.
|
108
|
+
version: 2.4.0
|
69
109
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
70
110
|
requirements:
|
71
111
|
- - ">="
|
72
112
|
- !ruby/object:Gem::Version
|
73
113
|
version: '0'
|
74
114
|
requirements: []
|
75
|
-
|
76
|
-
|
77
|
-
signing_key:
|
115
|
+
rubygems_version: 3.2.22
|
116
|
+
signing_key:
|
78
117
|
specification_version: 4
|
79
118
|
summary: Check your Puppet metadata dependencies
|
80
119
|
test_files: []
|
@@ -1,31 +0,0 @@
|
|
1
|
-
require 'puppet_forge'
|
2
|
-
require 'semantic_puppet'
|
3
|
-
|
4
|
-
module MetadataJsonDeps
|
5
|
-
class ForgeVersions
|
6
|
-
def initialize(cache = {})
|
7
|
-
@cache = cache
|
8
|
-
end
|
9
|
-
|
10
|
-
def get_current_version(name)
|
11
|
-
name = name.sub('/', '-')
|
12
|
-
version = @cache[name]
|
13
|
-
|
14
|
-
unless version
|
15
|
-
@cache[name] = version = get_version(get_mod(name))
|
16
|
-
end
|
17
|
-
|
18
|
-
version
|
19
|
-
end
|
20
|
-
|
21
|
-
private
|
22
|
-
|
23
|
-
def get_mod(name)
|
24
|
-
PuppetForge::Module.find(name)
|
25
|
-
end
|
26
|
-
|
27
|
-
def get_version(mod)
|
28
|
-
SemanticPuppet::Version.parse(mod.current_release.version)
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
@@ -1,26 +0,0 @@
|
|
1
|
-
require 'semantic_puppet'
|
2
|
-
|
3
|
-
module MetadataJsonDeps
|
4
|
-
class MetadataChecker
|
5
|
-
def initialize(metadata, forge)
|
6
|
-
@metadata = metadata
|
7
|
-
@forge = forge
|
8
|
-
end
|
9
|
-
|
10
|
-
def module_dependencies
|
11
|
-
return [] unless @metadata['dependencies']
|
12
|
-
|
13
|
-
@metadata['dependencies'].map do |dep|
|
14
|
-
constraint = dep['version_requirement'] || '>= 0'
|
15
|
-
[dep['name'], SemanticPuppet::VersionRange.parse(constraint)]
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
def dependencies
|
20
|
-
module_dependencies.map do |dependency, constraint|
|
21
|
-
current = @forge.get_current_version(dependency)
|
22
|
-
[dependency, constraint, current, constraint.include?(current)]
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
@@ -1,32 +0,0 @@
|
|
1
|
-
require 'json'
|
2
|
-
|
3
|
-
module MetadataJsonDeps
|
4
|
-
class Runner
|
5
|
-
def initialize(filenames, verbose)
|
6
|
-
@filenames = filenames
|
7
|
-
@verbose = verbose
|
8
|
-
@forge = MetadataJsonDeps::ForgeVersions.new
|
9
|
-
end
|
10
|
-
|
11
|
-
def run
|
12
|
-
@filenames.each do |filename|
|
13
|
-
puts "Checking #{filename}"
|
14
|
-
checker = MetadataJsonDeps::MetadataChecker.new(JSON.parse(File.read(filename)), @forge)
|
15
|
-
checker.dependencies.each do |dependency, constraint, current, satisfied|
|
16
|
-
if satisfied
|
17
|
-
if @verbose
|
18
|
-
puts " #{dependency} (#{constraint}) matches #{current}"
|
19
|
-
end
|
20
|
-
else
|
21
|
-
puts " #{dependency} (#{constraint}) doesn't match #{current}"
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
rescue Interrupt
|
26
|
-
end
|
27
|
-
|
28
|
-
def self.run(filenames, verbose = false)
|
29
|
-
self.new(filenames, verbose).run
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|