metadata-json-lint 4.1.0 → 4.2.1
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 +2 -2
- data/.github/workflows/test.yml +18 -22
- data/CHANGELOG.md +29 -0
- data/Gemfile +0 -5
- data/Rakefile +2 -9
- data/lib/metadata_json_lint.rb +17 -0
- data/metadata-json-lint.gemspec +5 -5
- data/spec/metadata_json_lint_spec.rb +21 -0
- data/spec/spec_helper.rb +0 -24
- data/tests/broken/expected +1 -1
- data/tests/invalid_escape_char/Rakefile +2 -0
- data/tests/invalid_escape_char/expected +1 -0
- data/tests/invalid_escape_char/metadata.json +16 -0
- data/tests/missing_newline/Rakefile +2 -0
- data/tests/missing_newline/expected +1 -0
- data/tests/missing_newline/metadata.json +16 -0
- data/tests/test.sh +6 -0
- metadata +11 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 618157af48848153bddab21052da6d58df6f5c88af598b1722a3e0d76d2e1817
|
4
|
+
data.tar.gz: a55aca8b94ff158854a4a8997de5d6639323a5da7b83d47c0e16a09a6c206438
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5960265ab1a4e15345c5c17a60f4eddf1ccc4a1ba21c7c58dd4a695a1dacff7251acc3cac09eaee3a3b8e540533d8cf431de1d9253cd207752176b027ad9b433
|
7
|
+
data.tar.gz: 70d54d7bb0d4a686b630815bb63b8d7b7681030c13de32e67a96fbc41d5a72e7167c2e4dabfbffd719c03e520be3c9fe3cd92577be4575fee04a3d23e800718d
|
@@ -11,10 +11,10 @@ jobs:
|
|
11
11
|
if: github.repository_owner == 'voxpupuli'
|
12
12
|
steps:
|
13
13
|
- uses: actions/checkout@v4
|
14
|
-
- name: Install Ruby 3.
|
14
|
+
- name: Install Ruby 3.4
|
15
15
|
uses: ruby/setup-ruby@v1
|
16
16
|
with:
|
17
|
-
ruby-version: '3.
|
17
|
+
ruby-version: '3.4'
|
18
18
|
env:
|
19
19
|
BUNDLE_WITHOUT: release
|
20
20
|
- name: Build gem
|
data/.github/workflows/test.yml
CHANGED
@@ -10,49 +10,45 @@ env:
|
|
10
10
|
BUNDLE_WITHOUT: release
|
11
11
|
|
12
12
|
jobs:
|
13
|
-
|
13
|
+
rubocop_and_matrix:
|
14
14
|
runs-on: ubuntu-latest
|
15
|
+
outputs:
|
16
|
+
ruby: ${{ steps.ruby.outputs.versions }}
|
15
17
|
steps:
|
16
18
|
- uses: actions/checkout@v4
|
17
|
-
- name: Install Ruby
|
19
|
+
- name: Install Ruby 3.4
|
18
20
|
uses: ruby/setup-ruby@v1
|
19
21
|
with:
|
20
|
-
ruby-version:
|
22
|
+
ruby-version: '3.4'
|
21
23
|
bundler-cache: true
|
22
|
-
- name: Run
|
24
|
+
- name: Run RuboCop
|
23
25
|
run: bundle exec rake rubocop
|
24
|
-
|
26
|
+
- id: ruby
|
27
|
+
uses: voxpupuli/ruby-version@v1
|
28
|
+
|
29
|
+
test:
|
30
|
+
name: "Ruby ${{ matrix.ruby }}"
|
25
31
|
runs-on: ubuntu-latest
|
32
|
+
needs: rubocop_and_matrix
|
26
33
|
strategy:
|
34
|
+
fail-fast: false
|
27
35
|
matrix:
|
28
|
-
|
29
|
-
- ruby: "2.7"
|
30
|
-
- ruby: "3.0"
|
31
|
-
- ruby: "3.1"
|
32
|
-
coverage: "yes"
|
33
|
-
- ruby: "3.2"
|
34
|
-
- ruby: "3.3"
|
35
|
-
env:
|
36
|
-
COVERAGE: ${{ matrix.coverage }}
|
37
|
-
# https://github.com/rubygems/rubygems/issues/5234#issuecomment-1003773622
|
38
|
-
RUBYOPT: '--disable-did_you_mean'
|
39
|
-
name: RSpec - Ruby ${{ matrix.ruby }}
|
36
|
+
ruby: ${{ fromJSON(needs.rubocop_and_matrix.outputs.ruby) }}
|
40
37
|
steps:
|
41
38
|
- uses: actions/checkout@v4
|
42
|
-
- name:
|
39
|
+
- name: Setup ruby
|
43
40
|
uses: ruby/setup-ruby@v1
|
44
41
|
with:
|
45
42
|
ruby-version: ${{ matrix.ruby }}
|
46
43
|
bundler-cache: true
|
47
|
-
- name:
|
44
|
+
- name: Run tests
|
48
45
|
run: bundle exec rake test
|
49
|
-
- name:
|
46
|
+
- name: Build the gem
|
50
47
|
run: gem build --strict --verbose *.gemspec
|
51
48
|
|
52
49
|
tests:
|
53
50
|
needs:
|
54
|
-
-
|
55
|
-
- rspec
|
51
|
+
- test
|
56
52
|
runs-on: ubuntu-latest
|
57
53
|
name: Test suite
|
58
54
|
steps:
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,34 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## [4.2.1](https://github.com/voxpupuli/metadata-json-lint/tree/4.2.1) (2025-02-23)
|
4
|
+
|
5
|
+
[Full Changelog](https://github.com/voxpupuli/metadata-json-lint/compare/4.2.0...4.2.1)
|
6
|
+
|
7
|
+
**Fixed bugs:**
|
8
|
+
|
9
|
+
- Update test for new json 2.10.0 release [\#159](https://github.com/voxpupuli/metadata-json-lint/pull/159) ([bastelfreak](https://github.com/bastelfreak))
|
10
|
+
|
11
|
+
**Merged pull requests:**
|
12
|
+
|
13
|
+
- Add test for openvox requirement [\#148](https://github.com/voxpupuli/metadata-json-lint/pull/148) ([bastelfreak](https://github.com/bastelfreak))
|
14
|
+
|
15
|
+
## [4.2.0](https://github.com/voxpupuli/metadata-json-lint/tree/4.2.0) (2025-01-24)
|
16
|
+
|
17
|
+
[Full Changelog](https://github.com/voxpupuli/metadata-json-lint/compare/4.1.0...4.2.0)
|
18
|
+
|
19
|
+
**Implemented enhancements:**
|
20
|
+
|
21
|
+
- Fail if metadata.json has no proper newline [\#154](https://github.com/voxpupuli/metadata-json-lint/pull/154) ([bastelfreak](https://github.com/bastelfreak))
|
22
|
+
- Fail on escape sequences in metadata.json [\#152](https://github.com/voxpupuli/metadata-json-lint/pull/152) ([bastelfreak](https://github.com/bastelfreak))
|
23
|
+
- Rake: Use RuboCop tasks from voxpupuli-rubocop [\#150](https://github.com/voxpupuli/metadata-json-lint/pull/150) ([bastelfreak](https://github.com/bastelfreak))
|
24
|
+
- Add Ruby 3.4 to CI [\#149](https://github.com/voxpupuli/metadata-json-lint/pull/149) ([bastelfreak](https://github.com/bastelfreak))
|
25
|
+
|
26
|
+
**Merged pull requests:**
|
27
|
+
|
28
|
+
- CI: Switch to voxpupuli/ruby-version [\#156](https://github.com/voxpupuli/metadata-json-lint/pull/156) ([bastelfreak](https://github.com/bastelfreak))
|
29
|
+
- Drop code coverage in testing [\#153](https://github.com/voxpupuli/metadata-json-lint/pull/153) ([ekohl](https://github.com/ekohl))
|
30
|
+
- Update voxpupuli-rubocop requirement from ~\> 2.8.0 to ~\> 3.0.0 [\#147](https://github.com/voxpupuli/metadata-json-lint/pull/147) ([dependabot[bot]](https://github.com/apps/dependabot))
|
31
|
+
|
3
32
|
## [4.1.0](https://github.com/voxpupuli/metadata-json-lint/tree/4.1.0) (2024-08-19)
|
4
33
|
|
5
34
|
[Full Changelog](https://github.com/voxpupuli/metadata-json-lint/compare/4.0.0...4.1.0)
|
data/Gemfile
CHANGED
data/Rakefile
CHANGED
@@ -2,16 +2,9 @@ desc 'Run all tests'
|
|
2
2
|
task test: %i[spec test:acceptance]
|
3
3
|
|
4
4
|
begin
|
5
|
-
require 'rubocop/
|
5
|
+
require 'voxpupuli/rubocop/rake'
|
6
6
|
rescue LoadError
|
7
|
-
#
|
8
|
-
else
|
9
|
-
RuboCop::RakeTask.new(:rubocop) do |task|
|
10
|
-
# These make the rubocop experience maybe slightly less terrible
|
11
|
-
task.options = ['--display-cop-names', '--display-style-guide', '--extra-details']
|
12
|
-
# Use Rubocop's Github Actions formatter if possible
|
13
|
-
task.formatters << 'github' if ENV['GITHUB_ACTIONS'] == 'true'
|
14
|
-
end
|
7
|
+
# the voxpupuli-rubocop gem is optional
|
15
8
|
end
|
16
9
|
|
17
10
|
namespace :test do
|
data/lib/metadata_json_lint.rb
CHANGED
@@ -8,6 +8,9 @@ require 'metadata-json-lint/version_requirement'
|
|
8
8
|
|
9
9
|
module MetadataJsonLint
|
10
10
|
MIN_PUPPET_VER = '4.10.0'.freeze
|
11
|
+
# Regex looks for:
|
12
|
+
# 1. Invalid escape sequences (\x or incomplete \u)
|
13
|
+
INVALID_ESCAPE_REGEX = %r{\\[^"/bfnrtu]|\\u(?![0-9a-fA-F]{4})}.freeze
|
11
14
|
|
12
15
|
def options
|
13
16
|
@options ||= Struct.new(
|
@@ -69,6 +72,16 @@ module MetadataJsonLint
|
|
69
72
|
end
|
70
73
|
module_function :run
|
71
74
|
|
75
|
+
def contains_invalid_escape?(content)
|
76
|
+
content.match?(INVALID_ESCAPE_REGEX)
|
77
|
+
end
|
78
|
+
module_function :contains_invalid_escape?
|
79
|
+
|
80
|
+
def misses_newline_at_end?(content)
|
81
|
+
content[-1] != "\n"
|
82
|
+
end
|
83
|
+
module_function :misses_newline_at_end?
|
84
|
+
|
72
85
|
def parse(metadata)
|
73
86
|
@errors = []
|
74
87
|
@warnings = []
|
@@ -83,6 +96,10 @@ module MetadataJsonLint
|
|
83
96
|
abort("Error: Unable to read metadata file: #{e.exception}")
|
84
97
|
end
|
85
98
|
|
99
|
+
abort('Error: metadata.json does not have a valid newline at the end') if misses_newline_at_end?(f)
|
100
|
+
|
101
|
+
abort('Error: Unable to parse metadata.json: Invalid escape character in string') if contains_invalid_escape?(f)
|
102
|
+
|
86
103
|
begin
|
87
104
|
parsed = JSON.parse(f)
|
88
105
|
rescue Exception => e
|
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 = '4.1
|
3
|
+
s.version = '4.2.1'
|
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 = '>= 2.7.0'
|
16
16
|
|
17
|
-
s.
|
18
|
-
s.
|
19
|
-
s.
|
17
|
+
s.add_dependency 'json-schema', '>= 2.8', '< 6.0'
|
18
|
+
s.add_dependency 'semantic_puppet', '~> 1.0'
|
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', '~> 3.0.0'
|
23
23
|
end
|
@@ -8,6 +8,27 @@ describe MetadataJsonLint do
|
|
8
8
|
it { expect { described_class.validate_requirements!(requirements) }.not_to raise_error }
|
9
9
|
end
|
10
10
|
|
11
|
+
context 'with openvox' do
|
12
|
+
let :requirements do
|
13
|
+
[
|
14
|
+
{ 'name' => 'openvox', 'version_requirement' => '>= 7.0.0 < 9.0.0' },
|
15
|
+
]
|
16
|
+
end
|
17
|
+
|
18
|
+
it { expect { described_class.validate_requirements!(requirements) }.not_to raise_error }
|
19
|
+
end
|
20
|
+
|
21
|
+
context 'with openvox and puppet' do
|
22
|
+
let :requirements do
|
23
|
+
[
|
24
|
+
{ 'name' => 'puppet', 'version_requirement' => '>= 6.0.0 < 8.0.0' },
|
25
|
+
{ 'name' => 'openvox', 'version_requirement' => '>= 7.0.0 < 9.0.0' },
|
26
|
+
]
|
27
|
+
end
|
28
|
+
|
29
|
+
it { expect { described_class.validate_requirements!(requirements) }.not_to raise_error }
|
30
|
+
end
|
31
|
+
|
11
32
|
context 'with pe' do
|
12
33
|
let :requirements do
|
13
34
|
[
|
data/spec/spec_helper.rb
CHANGED
@@ -1,27 +1,3 @@
|
|
1
|
-
begin
|
2
|
-
require 'simplecov'
|
3
|
-
require 'simplecov-console'
|
4
|
-
require 'codecov'
|
5
|
-
rescue LoadError
|
6
|
-
else
|
7
|
-
SimpleCov.start do
|
8
|
-
track_files 'lib/**/*.rb'
|
9
|
-
|
10
|
-
add_filter '/spec'
|
11
|
-
|
12
|
-
enable_coverage :branch
|
13
|
-
|
14
|
-
# do not track vendored files
|
15
|
-
add_filter '/vendor'
|
16
|
-
add_filter '/.vendor'
|
17
|
-
end
|
18
|
-
|
19
|
-
SimpleCov.formatters = [
|
20
|
-
SimpleCov::Formatter::Console,
|
21
|
-
SimpleCov::Formatter::Codecov,
|
22
|
-
]
|
23
|
-
end
|
24
|
-
|
25
1
|
require 'metadata_json_lint'
|
26
2
|
|
27
3
|
# This file was generated by the `rspec --init` command
|
data/tests/broken/expected
CHANGED
@@ -1 +1 @@
|
|
1
|
-
Error: Unable to parse metadata.json
|
1
|
+
Error: Unable to parse metadata.json:
|
@@ -0,0 +1 @@
|
|
1
|
+
Error: Unable to parse metadata.json: Invalid escape character in string
|
@@ -0,0 +1,16 @@
|
|
1
|
+
{
|
2
|
+
"name": "puppetlabs-postgresql",
|
3
|
+
"version": "3.4.1",
|
4
|
+
"author": "Inkling/Puppet Labs",
|
5
|
+
"summary": "A description with an invalid \( escape sequence",
|
6
|
+
"license": "Apache-2.0",
|
7
|
+
"source": "git://github.com/puppetlabs/puppet-postgresql.git",
|
8
|
+
"project_page": "https://github.com/puppetlabs/puppet-postgresql",
|
9
|
+
"issues_url": "https://github.com/puppetlabs/puppet-postgresql/issues",
|
10
|
+
"operatingsystem_support": [
|
11
|
+
],
|
12
|
+
"requirements": [
|
13
|
+
],
|
14
|
+
"dependencies": [
|
15
|
+
]
|
16
|
+
}
|
@@ -0,0 +1 @@
|
|
1
|
+
Error: metadata.json does not have a valid newline at the end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
{
|
2
|
+
"name": "puppetlabs-postgresql",
|
3
|
+
"version": "3.4.1",
|
4
|
+
"author": "Inkling/Puppet Labs",
|
5
|
+
"summary": "A metadata.json file without a newline at the end",
|
6
|
+
"license": "Apache-2.0",
|
7
|
+
"source": "git://github.com/puppetlabs/puppet-postgresql.git",
|
8
|
+
"project_page": "https://github.com/puppetlabs/puppet-postgresql",
|
9
|
+
"issues_url": "https://github.com/puppetlabs/puppet-postgresql/issues",
|
10
|
+
"operatingsystem_support": [
|
11
|
+
],
|
12
|
+
"requirements": [
|
13
|
+
],
|
14
|
+
"dependencies": [
|
15
|
+
]
|
16
|
+
}
|
data/tests/test.sh
CHANGED
@@ -103,6 +103,12 @@ test "bad_license" $SUCCESS --no-strict-license
|
|
103
103
|
# Run with --no-fail-on-warnings, expect SUCCESS
|
104
104
|
test "bad_license" $SUCCESS --no-fail-on-warnings
|
105
105
|
|
106
|
+
# Run a broken one, expect FAILURE
|
107
|
+
test "invalid_escape_char" $FAILURE
|
108
|
+
|
109
|
+
# Run a broken one, expect FAILURE
|
110
|
+
test "missing_newline" $FAILURE
|
111
|
+
|
106
112
|
# Run a broken one, expect FAILURE
|
107
113
|
test "long_summary" $FAILURE
|
108
114
|
|
metadata
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: metadata-json-lint
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.1
|
4
|
+
version: 4.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Vox Pupuli
|
8
|
-
autorequire:
|
9
8
|
bindir: bin
|
10
9
|
cert_chain: []
|
11
|
-
date:
|
10
|
+
date: 2025-02-23 00:00:00.000000000 Z
|
12
11
|
dependencies:
|
13
12
|
- !ruby/object:Gem::Dependency
|
14
13
|
name: json-schema
|
@@ -98,14 +97,14 @@ dependencies:
|
|
98
97
|
requirements:
|
99
98
|
- - "~>"
|
100
99
|
- !ruby/object:Gem::Version
|
101
|
-
version:
|
100
|
+
version: 3.0.0
|
102
101
|
type: :development
|
103
102
|
prerelease: false
|
104
103
|
version_requirements: !ruby/object:Gem::Requirement
|
105
104
|
requirements:
|
106
105
|
- - "~>"
|
107
106
|
- !ruby/object:Gem::Version
|
108
|
-
version:
|
107
|
+
version: 3.0.0
|
109
108
|
description: Utility to verify Puppet metadata.json files
|
110
109
|
email: voxpupuli@groups.io
|
111
110
|
executables:
|
@@ -148,12 +147,18 @@ files:
|
|
148
147
|
- tests/duplicate-requirement/Rakefile
|
149
148
|
- tests/duplicate-requirement/expected
|
150
149
|
- tests/duplicate-requirement/metadata.json
|
150
|
+
- tests/invalid_escape_char/Rakefile
|
151
|
+
- tests/invalid_escape_char/expected
|
152
|
+
- tests/invalid_escape_char/metadata.json
|
151
153
|
- tests/json_format/Rakefile
|
152
154
|
- tests/json_format/expected
|
153
155
|
- tests/json_format/metadata.json
|
154
156
|
- tests/long_summary/Rakefile
|
155
157
|
- tests/long_summary/expected
|
156
158
|
- tests/long_summary/metadata.json
|
159
|
+
- tests/missing_newline/Rakefile
|
160
|
+
- tests/missing_newline/expected
|
161
|
+
- tests/missing_newline/metadata.json
|
157
162
|
- tests/missing_version_requirement/Rakefile
|
158
163
|
- tests/missing_version_requirement/expected
|
159
164
|
- tests/missing_version_requirement/metadata.json
|
@@ -208,7 +213,6 @@ homepage: https://github.com/voxpupuli/metadata-json-lint
|
|
208
213
|
licenses:
|
209
214
|
- Apache-2.0
|
210
215
|
metadata: {}
|
211
|
-
post_install_message:
|
212
216
|
rdoc_options: []
|
213
217
|
require_paths:
|
214
218
|
- lib
|
@@ -223,8 +227,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
223
227
|
- !ruby/object:Gem::Version
|
224
228
|
version: '0'
|
225
229
|
requirements: []
|
226
|
-
rubygems_version: 3.
|
227
|
-
signing_key:
|
230
|
+
rubygems_version: 3.6.2
|
228
231
|
specification_version: 4
|
229
232
|
summary: metadata-json-lint /path/to/metadata.json
|
230
233
|
test_files: []
|