metadata_json_deps 0.1.1 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -2
- data/bin/metadata-json-deps +1 -1
- data/lib/metadata_json_deps.rb +35 -3
- metadata +18 -16
- 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: 2bcbe32a5563efc72e3d20dca1bde1f7b6fd04daed604ac244b1b7b3a5248c0f
|
4
|
+
data.tar.gz: fdae66bfdaebacb7e019ccb762b63c85bce412f2b5b24e45319a241bd7321b35
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 69e42cca04c2f04382d09f3e387684624395e5ebace94842fe721ae56fbdfc13a8609e8b82ccfc9388fbc7d1da8d218808a3ff760b5ddcc7c64bb088b55790f2
|
7
|
+
data.tar.gz: 0f354fcca5932a92401c14615de0a8b62bfdd91008719cb5e53bb64a8cf0a6b063244d77dfce02de39210558e42e2abc0ea8d30bfaddcf6d90a25520e1d9ec04
|
data/README.md
CHANGED
@@ -4,7 +4,7 @@ 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
|
|
@@ -44,6 +44,6 @@ require 'metadata_json_deps'
|
|
44
44
|
desc 'Run metadata-json-deps'
|
45
45
|
task :metadata_deps do
|
46
46
|
files = FileList['modules/*/metadata.json']
|
47
|
-
MetadataJsonDeps::
|
47
|
+
MetadataJsonDeps::run(files)
|
48
48
|
end
|
49
49
|
```
|
data/bin/metadata-json-deps
CHANGED
data/lib/metadata_json_deps.rb
CHANGED
@@ -1,5 +1,37 @@
|
|
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_current_version(name)
|
11
|
+
name = name.sub('/', '-')
|
12
|
+
@cache[name] ||= PuppetForge::Module.find(name).current_release.version
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.run(filenames, verbose = false)
|
17
|
+
forge = ForgeVersions.new
|
18
|
+
|
19
|
+
filenames.each do |filename|
|
20
|
+
puts "Checking #{filename}"
|
21
|
+
metadata = PuppetMetadata.read(filename)
|
22
|
+
|
23
|
+
metadata.dependencies.map do |dependency, constraint|
|
24
|
+
current = forge.get_current_version(dependency)
|
25
|
+
|
26
|
+
if metadata.satisfies_dependency?(dependency, current)
|
27
|
+
if verbose
|
28
|
+
puts " #{dependency} (#{constraint}) matches #{current}"
|
29
|
+
end
|
30
|
+
else
|
31
|
+
puts " #{dependency} (#{constraint}) doesn't match #{current}"
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
rescue Interrupt
|
36
|
+
end
|
5
37
|
end
|
metadata
CHANGED
@@ -1,43 +1,49 @@
|
|
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.2.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: 2021-08-05 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
|
- - "~>"
|
32
38
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
39
|
+
version: 0.3.0
|
34
40
|
type: :runtime
|
35
41
|
prerelease: false
|
36
42
|
version_requirements: !ruby/object:Gem::Requirement
|
37
43
|
requirements:
|
38
44
|
- - "~>"
|
39
45
|
- !ruby/object:Gem::Version
|
40
|
-
version:
|
46
|
+
version: 0.3.0
|
41
47
|
description: Verify all your dependencies allow the latest versions on Puppet Forge
|
42
48
|
email: ewoud+rubygems@kohlvanwijngaarden.nl
|
43
49
|
executables:
|
@@ -49,15 +55,12 @@ files:
|
|
49
55
|
- README.md
|
50
56
|
- bin/metadata-json-deps
|
51
57
|
- 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
58
|
homepage: https://github.com/ekohl/metadata_json_deps
|
56
59
|
licenses:
|
57
60
|
- MIT
|
58
61
|
metadata:
|
59
62
|
source_code_uri: https://github.com/ekohl/metadata_json_deps
|
60
|
-
post_install_message:
|
63
|
+
post_install_message:
|
61
64
|
rdoc_options: []
|
62
65
|
require_paths:
|
63
66
|
- lib
|
@@ -65,16 +68,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
65
68
|
requirements:
|
66
69
|
- - ">="
|
67
70
|
- !ruby/object:Gem::Version
|
68
|
-
version: 2.
|
71
|
+
version: 2.4.0
|
69
72
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
70
73
|
requirements:
|
71
74
|
- - ">="
|
72
75
|
- !ruby/object:Gem::Version
|
73
76
|
version: '0'
|
74
77
|
requirements: []
|
75
|
-
|
76
|
-
|
77
|
-
signing_key:
|
78
|
+
rubygems_version: 3.2.22
|
79
|
+
signing_key:
|
78
80
|
specification_version: 4
|
79
81
|
summary: Check your Puppet metadata dependencies
|
80
82
|
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
|