metadata-json-lint 5.0.0 → 5.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/release.yml +7 -7
- data/.github/workflows/test.yml +3 -3
- data/.rubocop.yml +0 -3
- data/CHANGELOG.md +14 -0
- data/Gemfile +1 -1
- data/lib/metadata-json-lint/schema.rb +1 -0
- data/lib/metadata_json_lint.rb +42 -29
- data/metadata-json-lint.gemspec +3 -3
- data/tests/bad_license/expected +1 -1
- data/tests/broken/expected +1 -1
- data/tests/duplicate-dep/expected +1 -1
- data/tests/duplicate-requirement/expected +1 -1
- data/tests/invalid_escape_char/expected +1 -1
- data/tests/missing_newline/expected +1 -1
- data/tests/missing_version_requirement/expected +1 -1
- data/tests/multiple_problems/expected +3 -3
- data/tests/no_files/expected +1 -1
- data/tests/open_ended_dependency/expected +1 -1
- data/tests/rake_global_options/expected +1 -1
- data/tests/requirements_eol_version/expected +1 -2
- data/tests/types/expected +1 -1
- metadata +8 -14
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: c467d226e16135a5214b501c5f8a0add829bdb412e9281d1852e4a1e8cc8c69f
|
|
4
|
+
data.tar.gz: 712cd43498297e11ea9b0762174ef5cbafd1fa119b3284f530f7e76256a9de2f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 4483c4829b41974bfd0465df70bf7926d9177a85111e7af15e0dcf3b0bc0b144d5ae9a000f12712dd3332f3bd7a09c4112b98e7b2a3f518f3691abdff764614b
|
|
7
|
+
data.tar.gz: 44413f5005605132685f8a8d3d4f3188e984606a3399fbee7367a8fb904d820746f01f0cdcf2d303e4007d2f90bbcd7d1ef614e6c13de9cdea2a2e0f2bcb63f9
|
|
@@ -15,7 +15,7 @@ jobs:
|
|
|
15
15
|
name: Build the gem
|
|
16
16
|
runs-on: ubuntu-24.04
|
|
17
17
|
steps:
|
|
18
|
-
- uses: actions/checkout@
|
|
18
|
+
- uses: actions/checkout@v7
|
|
19
19
|
- name: Install Ruby
|
|
20
20
|
uses: ruby/setup-ruby@v1
|
|
21
21
|
with:
|
|
@@ -24,7 +24,7 @@ jobs:
|
|
|
24
24
|
shell: bash
|
|
25
25
|
run: gem build --verbose *.gemspec
|
|
26
26
|
- name: Upload gem to GitHub cache
|
|
27
|
-
uses: actions/upload-artifact@
|
|
27
|
+
uses: actions/upload-artifact@v7
|
|
28
28
|
with:
|
|
29
29
|
name: gem-artifact
|
|
30
30
|
path: '*.gem'
|
|
@@ -39,7 +39,7 @@ jobs:
|
|
|
39
39
|
contents: write # clone repo and create release
|
|
40
40
|
steps:
|
|
41
41
|
- name: Download gem from GitHub cache
|
|
42
|
-
uses: actions/download-artifact@
|
|
42
|
+
uses: actions/download-artifact@v8
|
|
43
43
|
with:
|
|
44
44
|
name: gem-artifact
|
|
45
45
|
- name: Create Release
|
|
@@ -56,7 +56,7 @@ jobs:
|
|
|
56
56
|
packages: write # publish to rubygems.pkg.github.com
|
|
57
57
|
steps:
|
|
58
58
|
- name: Download gem from GitHub cache
|
|
59
|
-
uses: actions/download-artifact@
|
|
59
|
+
uses: actions/download-artifact@v8
|
|
60
60
|
with:
|
|
61
61
|
name: gem-artifact
|
|
62
62
|
- name: Publish gem to GitHub packages
|
|
@@ -73,10 +73,10 @@ jobs:
|
|
|
73
73
|
id-token: write # rubygems.org authentication
|
|
74
74
|
steps:
|
|
75
75
|
- name: Download gem from GitHub cache
|
|
76
|
-
uses: actions/download-artifact@
|
|
76
|
+
uses: actions/download-artifact@v8
|
|
77
77
|
with:
|
|
78
78
|
name: gem-artifact
|
|
79
|
-
- uses: rubygems/configure-rubygems-credentials@
|
|
79
|
+
- uses: rubygems/configure-rubygems-credentials@v2.1.0
|
|
80
80
|
- name: Publish gem to rubygems.org
|
|
81
81
|
shell: bash
|
|
82
82
|
run: gem push *.gem
|
|
@@ -92,7 +92,7 @@ jobs:
|
|
|
92
92
|
- release-to-rubygems
|
|
93
93
|
steps:
|
|
94
94
|
- name: Download gem from GitHub cache
|
|
95
|
-
uses: actions/download-artifact@
|
|
95
|
+
uses: actions/download-artifact@v8
|
|
96
96
|
with:
|
|
97
97
|
name: gem-artifact
|
|
98
98
|
- name: Install Ruby
|
data/.github/workflows/test.yml
CHANGED
|
@@ -16,7 +16,7 @@ jobs:
|
|
|
16
16
|
outputs:
|
|
17
17
|
ruby: ${{ steps.ruby.outputs.versions }}
|
|
18
18
|
steps:
|
|
19
|
-
- uses: actions/checkout@
|
|
19
|
+
- uses: actions/checkout@v7
|
|
20
20
|
- name: Install Ruby 3.4
|
|
21
21
|
uses: ruby/setup-ruby@v1
|
|
22
22
|
with:
|
|
@@ -25,7 +25,7 @@ jobs:
|
|
|
25
25
|
- name: Run RuboCop
|
|
26
26
|
run: bundle exec rake rubocop
|
|
27
27
|
- id: ruby
|
|
28
|
-
uses: voxpupuli/ruby-version@
|
|
28
|
+
uses: voxpupuli/ruby-version@v2
|
|
29
29
|
|
|
30
30
|
test:
|
|
31
31
|
name: "Ruby ${{ matrix.ruby }}"
|
|
@@ -36,7 +36,7 @@ jobs:
|
|
|
36
36
|
matrix:
|
|
37
37
|
ruby: ${{ fromJSON(needs.rubocop_and_matrix.outputs.ruby) }}
|
|
38
38
|
steps:
|
|
39
|
-
- uses: actions/checkout@
|
|
39
|
+
- uses: actions/checkout@v7
|
|
40
40
|
- name: Setup ruby
|
|
41
41
|
uses: ruby/setup-ruby@v1
|
|
42
42
|
with:
|
data/.rubocop.yml
CHANGED
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [5.1.0](https://github.com/voxpupuli/metadata-json-lint/tree/5.1.0) (2026-08-13)
|
|
4
|
+
|
|
5
|
+
[Full Changelog](https://github.com/voxpupuli/metadata-json-lint/compare/5.0.0...5.1.0)
|
|
6
|
+
|
|
7
|
+
**Implemented enhancements:**
|
|
8
|
+
|
|
9
|
+
- Disable multi\_json deprecation warning [\#186](https://github.com/voxpupuli/metadata-json-lint/pull/186) ([bastelfreak](https://github.com/bastelfreak))
|
|
10
|
+
- Parse whole file and print all errors [\#177](https://github.com/voxpupuli/metadata-json-lint/pull/177) ([bwitt](https://github.com/bwitt))
|
|
11
|
+
- Add Ruby 4.0 support [\#176](https://github.com/voxpupuli/metadata-json-lint/pull/176) ([dependabot[bot]](https://github.com/apps/dependabot))
|
|
12
|
+
|
|
13
|
+
**Closed issues:**
|
|
14
|
+
|
|
15
|
+
- Post install message [\#90](https://github.com/voxpupuli/metadata-json-lint/issues/90)
|
|
16
|
+
|
|
3
17
|
## [5.0.0](https://github.com/voxpupuli/metadata-json-lint/tree/5.0.0) (2025-08-12)
|
|
4
18
|
|
|
5
19
|
[Full Changelog](https://github.com/voxpupuli/metadata-json-lint/compare/4.3.0...5.0.0)
|
data/Gemfile
CHANGED
|
@@ -121,6 +121,7 @@ module MetadataJsonLint
|
|
|
121
121
|
end
|
|
122
122
|
|
|
123
123
|
def validate(data, options = {})
|
|
124
|
+
JSON::Validator.use_multi_json = false
|
|
124
125
|
JSON::Validator.register_format_validator('semver', method(:semver_validator))
|
|
125
126
|
|
|
126
127
|
JSON::Validator.fully_validate(schema, data, options.merge(errors_as_objects: true)).map do |error|
|
data/lib/metadata_json_lint.rb
CHANGED
|
@@ -90,26 +90,56 @@ module MetadataJsonLint
|
|
|
90
90
|
options = options().clone
|
|
91
91
|
# Configuration from rake tasks
|
|
92
92
|
yield options if block_given?
|
|
93
|
+
|
|
94
|
+
validate_metadata(metadata, options) do |level, check, message|
|
|
95
|
+
send(level, check, message)
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
if !@errors.empty? || !@warnings.empty?
|
|
99
|
+
result = @errors.empty? ? "Warnings found in #{metadata}" : "Errors found in #{metadata}"
|
|
100
|
+
|
|
101
|
+
case options[:format]
|
|
102
|
+
when :json
|
|
103
|
+
puts JSON.fast_generate(result: result, warnings: @warnings, errors: @errors)
|
|
104
|
+
else
|
|
105
|
+
@warnings.each { |warn| puts "(WARN) #{warn}" }
|
|
106
|
+
@errors.each { |err| puts "(ERROR) #{err}" }
|
|
107
|
+
puts result
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
return false if !@errors.empty? || (!@warnings.empty? && (options[:fail_on_warnings] == true))
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
true
|
|
114
|
+
end
|
|
115
|
+
module_function :parse
|
|
116
|
+
|
|
117
|
+
def validate_metadata(metadata, options)
|
|
93
118
|
begin
|
|
94
119
|
f = File.read(metadata)
|
|
95
|
-
rescue
|
|
96
|
-
|
|
120
|
+
rescue StandardError => e
|
|
121
|
+
yield :error, :file, "Unable to read metadata file: #{e.message.split(' @ ').first}"
|
|
122
|
+
return
|
|
97
123
|
end
|
|
98
124
|
|
|
99
|
-
|
|
125
|
+
yield :error, :file, 'metadata.json does not have a valid newline at the end' if misses_newline_at_end?(f)
|
|
100
126
|
|
|
101
|
-
|
|
127
|
+
if contains_invalid_escape?(f)
|
|
128
|
+
yield :error, :file, 'Unable to parse metadata.json: Invalid escape character in string'
|
|
129
|
+
return
|
|
130
|
+
end
|
|
102
131
|
|
|
103
132
|
begin
|
|
104
133
|
parsed = JSON.parse(f)
|
|
105
|
-
rescue
|
|
106
|
-
|
|
134
|
+
rescue JSON::ParserError => e
|
|
135
|
+
yield :error, :file, "Unable to parse metadata.json: #{e.message}"
|
|
136
|
+
return
|
|
107
137
|
end
|
|
108
138
|
|
|
109
139
|
# Validate basic structure against JSON schema
|
|
110
140
|
schema_errors = Schema.new.validate(parsed)
|
|
111
141
|
schema_errors.each do |err|
|
|
112
|
-
error ((err[:field] == 'root') ? :required_fields : err[:field]), err[:message]
|
|
142
|
+
yield :error, ((err[:field] == 'root') ? :required_fields : err[:field]), err[:message]
|
|
113
143
|
end
|
|
114
144
|
|
|
115
145
|
validate_dependencies!(parsed['dependencies']) if parsed['dependencies']
|
|
@@ -118,7 +148,7 @@ module MetadataJsonLint
|
|
|
118
148
|
# From: https://docs.puppetlabs.com/puppet/latest/reference/modules_publishing.html#write-a-metadatajson-file
|
|
119
149
|
deprecated_fields = %w[types checksum]
|
|
120
150
|
deprecated_fields.each do |field|
|
|
121
|
-
error :deprecated_fields, "Deprecated field '#{field}' found in metadata.json." unless parsed[field].nil?
|
|
151
|
+
yield :error, :deprecated_fields, "Deprecated field '#{field}' found in metadata.json." unless parsed[field].nil?
|
|
122
152
|
end
|
|
123
153
|
|
|
124
154
|
# The nested 'requirements' name of 'pe' is deprecated as well.
|
|
@@ -128,29 +158,12 @@ module MetadataJsonLint
|
|
|
128
158
|
# Shoulds/recommendations
|
|
129
159
|
# From: https://docs.puppetlabs.com/puppet/latest/reference/modules_publishing.html#write-a-metadatajson-file
|
|
130
160
|
#
|
|
131
|
-
|
|
132
|
-
msg = "License identifier #{parsed['license']} is not in the SPDX list: http://spdx.org/licenses/"
|
|
133
|
-
warn(:license, msg)
|
|
134
|
-
end
|
|
135
|
-
|
|
136
|
-
if !@errors.empty? || !@warnings.empty?
|
|
137
|
-
result = @errors.empty? ? "Warnings found in #{metadata}" : "Errors found in #{metadata}"
|
|
138
|
-
|
|
139
|
-
case options[:format]
|
|
140
|
-
when :json
|
|
141
|
-
puts JSON.fast_generate(result: result, warnings: @warnings, errors: @errors)
|
|
142
|
-
else
|
|
143
|
-
@warnings.each { |warn| puts "(WARN) #{warn}" }
|
|
144
|
-
@errors.each { |err| puts "(ERROR) #{err}" }
|
|
145
|
-
puts result
|
|
146
|
-
end
|
|
161
|
+
return unless options[:strict_license] && !parsed['license'].nil? && !SpdxLicenses.exist?(parsed['license']) && parsed['license'] != 'proprietary'
|
|
147
162
|
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
true
|
|
163
|
+
msg = "License identifier #{parsed['license']} is not in the SPDX list: http://spdx.org/licenses/"
|
|
164
|
+
yield :warn, :license, msg
|
|
152
165
|
end
|
|
153
|
-
module_function :
|
|
166
|
+
module_function :validate_metadata
|
|
154
167
|
|
|
155
168
|
def validate_requirements_unique(requirements)
|
|
156
169
|
names = requirements.map { |x| x['name'] }
|
data/metadata-json-lint.gemspec
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Gem::Specification.new do |s|
|
|
2
2
|
s.name = 'metadata-json-lint'
|
|
3
|
-
s.version = '5.
|
|
3
|
+
s.version = '5.1.0'
|
|
4
4
|
s.summary = 'metadata-json-lint /path/to/metadata.json'
|
|
5
5
|
s.description = 'Utility to verify Puppet metadata.json files'
|
|
6
6
|
s.authors = ['Vox Pupuli']
|
|
@@ -14,10 +14,10 @@ Gem::Specification.new do |s|
|
|
|
14
14
|
|
|
15
15
|
s.required_ruby_version = '>= 3.2.0'
|
|
16
16
|
|
|
17
|
-
s.add_dependency 'json-schema', '
|
|
17
|
+
s.add_dependency 'json-schema', '~> 6.2'
|
|
18
18
|
s.add_dependency 'semantic_puppet', '~> 1.0'
|
|
19
19
|
s.add_dependency 'spdx-licenses', '~> 1.0'
|
|
20
20
|
s.add_development_dependency 'rake', '~> 13.0', '>= 13.0.6'
|
|
21
21
|
s.add_development_dependency 'rspec', '~> 3.12'
|
|
22
|
-
s.add_development_dependency 'voxpupuli-rubocop', '~>
|
|
22
|
+
s.add_development_dependency 'voxpupuli-rubocop', '~> 5.2.0'
|
|
23
23
|
end
|
data/tests/bad_license/expected
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
License identifier Unknown-1.0 is not in the SPDX list: http://spdx.org/licenses/
|
|
1
|
+
(WARN) license: License identifier Unknown-1.0 is not in the SPDX list: http://spdx.org/licenses/
|
data/tests/broken/expected
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
(ERROR) file: Unable to parse metadata.json:
|
|
@@ -1 +1 @@
|
|
|
1
|
-
Duplicate dependencies on puppetlabs/stdlib
|
|
1
|
+
(WARN) dependencies: Duplicate dependencies on puppetlabs/stdlib
|
|
@@ -1 +1 @@
|
|
|
1
|
-
Duplicate entries in the 'requirements' list with the name 'puppet'
|
|
1
|
+
(ERROR) requirements: Duplicate entries in the 'requirements' list with the name 'puppet'
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
(ERROR) file: Unable to parse metadata.json: Invalid escape character in string
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
(ERROR) file: metadata.json does not have a valid newline at the end
|
|
@@ -1 +1 @@
|
|
|
1
|
-
Dependency puppetlabs/stdlib has an open ended dependency version requirement
|
|
1
|
+
(WARN) dependencies: Dependency puppetlabs/stdlib has an open ended dependency version requirement
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Deprecated field 'types' found in metadata.json.
|
|
1
|
+
(ERROR) required_fields: The file did not contain a required property of 'license'
|
|
2
|
+
(ERROR) required_fields: The file did not contain a required property of 'summary'
|
|
3
|
+
(ERROR) deprecated_fields: Deprecated field 'types' found in metadata.json.
|
data/tests/no_files/expected
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
(ERROR) file: Unable to read metadata file: No such file or directory
|
|
@@ -1 +1 @@
|
|
|
1
|
-
Dependency puppetlabs/stdlib has an open ended dependency version requirement >= 3.2.0
|
|
1
|
+
(WARN) dependencies: Dependency puppetlabs/stdlib has an open ended dependency version requirement >= 3.2.0
|
|
@@ -1 +1 @@
|
|
|
1
|
-
License identifier invalid_license is not in the SPDX list: http://spdx.org/licenses/
|
|
1
|
+
(WARN) license: License identifier invalid_license is not in the SPDX list: http://spdx.org/licenses/
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
(WARN)
|
|
2
|
-
Warnings found in metadata.json
|
|
1
|
+
(WARN) requirement: 3.2.0 is no longer supported. Minimum supported version is 4.10.0
|
data/tests/types/expected
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Deprecated field 'types' found in metadata.json.
|
|
1
|
+
(ERROR) deprecated_fields: Deprecated field 'types' found in metadata.json.
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: metadata-json-lint
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 5.
|
|
4
|
+
version: 5.1.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Vox Pupuli
|
|
@@ -13,22 +13,16 @@ dependencies:
|
|
|
13
13
|
name: json-schema
|
|
14
14
|
requirement: !ruby/object:Gem::Requirement
|
|
15
15
|
requirements:
|
|
16
|
-
- - "
|
|
17
|
-
- !ruby/object:Gem::Version
|
|
18
|
-
version: '2.8'
|
|
19
|
-
- - "<"
|
|
16
|
+
- - "~>"
|
|
20
17
|
- !ruby/object:Gem::Version
|
|
21
|
-
version: '
|
|
18
|
+
version: '6.2'
|
|
22
19
|
type: :runtime
|
|
23
20
|
prerelease: false
|
|
24
21
|
version_requirements: !ruby/object:Gem::Requirement
|
|
25
22
|
requirements:
|
|
26
|
-
- - "
|
|
27
|
-
- !ruby/object:Gem::Version
|
|
28
|
-
version: '2.8'
|
|
29
|
-
- - "<"
|
|
23
|
+
- - "~>"
|
|
30
24
|
- !ruby/object:Gem::Version
|
|
31
|
-
version: '
|
|
25
|
+
version: '6.2'
|
|
32
26
|
- !ruby/object:Gem::Dependency
|
|
33
27
|
name: semantic_puppet
|
|
34
28
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -97,14 +91,14 @@ dependencies:
|
|
|
97
91
|
requirements:
|
|
98
92
|
- - "~>"
|
|
99
93
|
- !ruby/object:Gem::Version
|
|
100
|
-
version:
|
|
94
|
+
version: 5.2.0
|
|
101
95
|
type: :development
|
|
102
96
|
prerelease: false
|
|
103
97
|
version_requirements: !ruby/object:Gem::Requirement
|
|
104
98
|
requirements:
|
|
105
99
|
- - "~>"
|
|
106
100
|
- !ruby/object:Gem::Version
|
|
107
|
-
version:
|
|
101
|
+
version: 5.2.0
|
|
108
102
|
description: Utility to verify Puppet metadata.json files
|
|
109
103
|
email: voxpupuli@groups.io
|
|
110
104
|
executables:
|
|
@@ -228,7 +222,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
228
222
|
- !ruby/object:Gem::Version
|
|
229
223
|
version: '0'
|
|
230
224
|
requirements: []
|
|
231
|
-
rubygems_version:
|
|
225
|
+
rubygems_version: 4.0.16
|
|
232
226
|
specification_version: 4
|
|
233
227
|
summary: metadata-json-lint /path/to/metadata.json
|
|
234
228
|
test_files: []
|