Icarus-Mod-Tools 1.6.0 → 1.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +6 -4
- data/icarus-mod-tools.gemspec +1 -1
- data/lib/icarus/mod/cli/base.rb +3 -2
- data/lib/icarus/mod/cli/command.rb +4 -0
- data/lib/icarus/mod/cli/sync.rb +4 -1
- data/lib/icarus/mod/cli/validate.rb +45 -0
- data/lib/icarus/mod/tools/modinfo.rb +40 -1
- data/lib/icarus/mod/tools/modinfo_validate.rb +16 -0
- data/lib/icarus/mod/version.rb +1 -1
- metadata +18 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ce305187a0a91ed7a8574f418d6c2afc50380323b3d5fe4d4fa215b61bc1e59c
|
4
|
+
data.tar.gz: 28b19fe811f5eec20f5c79d2b9e567a2703cd266a7f1cf122df328f1018c04fb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 49adc06788394d6015d23d33312a63058fcfb57bd0585c60325383501ee8950e5ba31fc90be13c765d45d397eb099aa494c9723a1bdaef379a4a62c8842f3ee8
|
7
|
+
data.tar.gz: a233c109a0f8addcbba424b460ca2cca4100de71e5c771ae79487f13504f1b31ea195c07aa93108df4bc0de5e6fc2a75c09cd4dbf84acafe267c1333da8df3ad
|
data/Gemfile.lock
CHANGED
@@ -1,9 +1,10 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
Icarus-Mod-Tools (1.
|
4
|
+
Icarus-Mod-Tools (1.7.0)
|
5
5
|
google-cloud-firestore (~> 2.7)
|
6
6
|
octokit (~> 6.0)
|
7
|
+
paint (~> 2.3)
|
7
8
|
thor (~> 1.2)
|
8
9
|
|
9
10
|
GEM
|
@@ -15,7 +16,7 @@ GEM
|
|
15
16
|
coderay (1.1.3)
|
16
17
|
concurrent-ruby (1.1.10)
|
17
18
|
diff-lcs (1.5.0)
|
18
|
-
faraday (2.7.
|
19
|
+
faraday (2.7.3)
|
19
20
|
faraday-net_http (>= 2.0, < 3.1)
|
20
21
|
ruby2_keywords (>= 0.0.4)
|
21
22
|
faraday-net_http (3.0.2)
|
@@ -46,8 +47,8 @@ GEM
|
|
46
47
|
gapic-common (>= 0.10, < 2.a)
|
47
48
|
google-cloud-errors (~> 1.0)
|
48
49
|
google-cloud-location (>= 0.0, < 2.a)
|
49
|
-
google-cloud-location (0.
|
50
|
-
gapic-common (>= 0.
|
50
|
+
google-cloud-location (0.3.0)
|
51
|
+
gapic-common (>= 0.16.0, < 2.a)
|
51
52
|
google-cloud-errors (~> 1.0)
|
52
53
|
google-protobuf (3.21.12-x86_64-darwin)
|
53
54
|
googleapis-common-protos (1.4.0)
|
@@ -97,6 +98,7 @@ GEM
|
|
97
98
|
faraday (>= 1, < 3)
|
98
99
|
sawyer (~> 0.9)
|
99
100
|
os (1.1.4)
|
101
|
+
paint (2.3.0)
|
100
102
|
parallel (1.22.1)
|
101
103
|
parser (3.2.0.0)
|
102
104
|
ast (~> 2.4.1)
|
data/icarus-mod-tools.gemspec
CHANGED
@@ -33,8 +33,8 @@ Gem::Specification.new do |spec|
|
|
33
33
|
# spec.add_dependency "example-gem", "~> 1.0"
|
34
34
|
spec.add_dependency "google-cloud-firestore", "~> 2.7"
|
35
35
|
spec.add_dependency "octokit", "~> 6.0"
|
36
|
+
spec.add_dependency "paint", "~> 2.3"
|
36
37
|
spec.add_dependency "thor", "~> 1.2"
|
37
|
-
|
38
38
|
# For more information and examples about making a new gem, check out our
|
39
39
|
# guide at: https://bundler.io/guides/creating_gem.html
|
40
40
|
end
|
data/lib/icarus/mod/cli/base.rb
CHANGED
@@ -5,6 +5,7 @@ require "cli/subcommand_base"
|
|
5
5
|
require "cli/sync"
|
6
6
|
require "cli/list"
|
7
7
|
require "cli/add"
|
8
|
+
require "cli/validate"
|
8
9
|
|
9
10
|
module Icarus
|
10
11
|
module Mod
|
@@ -35,6 +36,9 @@ module Icarus
|
|
35
36
|
|
36
37
|
desc "add", "Adds entries to the databases"
|
37
38
|
subcommand "add", Add
|
39
|
+
|
40
|
+
desc "validate", "Validates various entries"
|
41
|
+
subcommand "validate", Validate
|
38
42
|
end
|
39
43
|
end
|
40
44
|
end
|
data/lib/icarus/mod/cli/sync.rb
CHANGED
@@ -43,8 +43,11 @@ module Icarus
|
|
43
43
|
puts "Updating mod Data..." if verbose?
|
44
44
|
modinfo_array.each do |mod|
|
45
45
|
verb = "Creating"
|
46
|
-
doc_id = modsync.find_mod(mod)
|
47
46
|
|
47
|
+
puts "Validating modinfo Data for #{mod.uniq_name}..." if verbose > 2
|
48
|
+
warn "Skipping mod #{mod.uniq_name} due to validation errors" && next unless mod.validate
|
49
|
+
|
50
|
+
doc_id = modsync.find_mod(mod)
|
48
51
|
if doc_id
|
49
52
|
puts "Found existing mod #{mod.name} at #{doc_id}" if verbose > 2
|
50
53
|
mod.id = doc_id
|
@@ -0,0 +1,45 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "tools/modinfo_validate"
|
4
|
+
|
5
|
+
module Icarus
|
6
|
+
module Mod
|
7
|
+
module CLI
|
8
|
+
# Sync CLI command definitions
|
9
|
+
class Validate < SubcommandBase
|
10
|
+
desc "modinfo", "Reads modinfo data from 'meta/modinfo/list' and Validates syntax of modfiles"
|
11
|
+
def modinfo
|
12
|
+
exit_code = 0
|
13
|
+
modinfo_validate = Icarus::Mod::Tools::ModinfoValidate.new
|
14
|
+
|
15
|
+
puts "Validating Entries..." if verbose?
|
16
|
+
max_length = modinfo_validate.modinfo_array.map { |modinfo| modinfo.uniq_name.length }.max
|
17
|
+
|
18
|
+
modinfo_validate.modinfo_array.each do |modinfo|
|
19
|
+
print Paint[format("%s %-#{max_length}s", "Running validation steps on", modinfo.uniq_name), :cyan, :bright] if verbose > 1
|
20
|
+
|
21
|
+
modinfo.validate
|
22
|
+
|
23
|
+
if modinfo.errors.empty? && modinfo.warnings.empty?
|
24
|
+
puts Paint["SUCCESS", :green, :bright] if verbose > 1
|
25
|
+
next
|
26
|
+
end
|
27
|
+
|
28
|
+
if modinfo.errors.any?
|
29
|
+
exit_code = 1
|
30
|
+
puts Paint["ERROR", :red, :bright] if verbose? && verbose > 1
|
31
|
+
warn modinfo.errors.map { |error| Paint[error, :red] }.join("\n")
|
32
|
+
puts "\n" if verbose > 1
|
33
|
+
end
|
34
|
+
|
35
|
+
puts Paint["WARNING", :yellow, :bright] if modinfo.warnings.any? && verbose > 1
|
36
|
+
puts modinfo.warnings.map { |warning| Paint["#{warning} in #{modinfo.uniq_name}", :yellow] }.join("\n")
|
37
|
+
puts "\n" if verbose > 1
|
38
|
+
end
|
39
|
+
|
40
|
+
exit exit_code
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -5,7 +5,7 @@ module Icarus
|
|
5
5
|
module Tools
|
6
6
|
# Sync methods
|
7
7
|
class Modinfo
|
8
|
-
attr_reader :data, :id, :created_at, :updated_at
|
8
|
+
attr_reader :data, :errors, :id, :created_at, :updated_at, :warnings
|
9
9
|
|
10
10
|
HASHKEYS = %i[name author version compatibility description long_description fileType fileURL imageURL readmeURL].freeze
|
11
11
|
|
@@ -13,6 +13,9 @@ module Icarus
|
|
13
13
|
@id = id
|
14
14
|
@created_at = created
|
15
15
|
@updated_at = updated
|
16
|
+
@errors = []
|
17
|
+
@warnings = []
|
18
|
+
|
16
19
|
read(data)
|
17
20
|
end
|
18
21
|
|
@@ -20,6 +23,10 @@ module Icarus
|
|
20
23
|
@data = data.is_a?(String) ? JSON.parse(data, symbolize_names: true) : data
|
21
24
|
end
|
22
25
|
|
26
|
+
def uniq_name
|
27
|
+
"#{author}/#{name}"
|
28
|
+
end
|
29
|
+
|
23
30
|
# rubocop:disable Naming/MethodName
|
24
31
|
def fileType
|
25
32
|
@data[:fileType] || "pak"
|
@@ -45,6 +52,22 @@ module Icarus
|
|
45
52
|
}
|
46
53
|
end
|
47
54
|
|
55
|
+
def validate
|
56
|
+
@warnings << "Version should not be blank" unless validate_string(version)
|
57
|
+
|
58
|
+
%w[name author description].each do |key|
|
59
|
+
@errors << "#{key.capitalize} cannot be blank" unless validate_string(@data[key.to_sym])
|
60
|
+
end
|
61
|
+
|
62
|
+
@errors << "Invalid FileType: #{fileType || "blank"}" unless validate_filetype(fileType)
|
63
|
+
|
64
|
+
%w[fileURL imageURL readmeURL].each do |key|
|
65
|
+
@errors << "Invalid URL #{key.capitalize}: #{@data[key.to_sym] || "blank"}" unless validate_url(@data[key.to_sym])
|
66
|
+
end
|
67
|
+
|
68
|
+
@errors.empty?
|
69
|
+
end
|
70
|
+
|
48
71
|
def method_missing(method_name, *_args, &)
|
49
72
|
@data[method_name.to_sym]&.strip
|
50
73
|
end
|
@@ -52,6 +75,22 @@ module Icarus
|
|
52
75
|
def respond_to_missing?(method_name, include_private = false)
|
53
76
|
HASHKEYS.include?(method_name.to_sym) || super
|
54
77
|
end
|
78
|
+
|
79
|
+
private
|
80
|
+
|
81
|
+
def validate_url(url)
|
82
|
+
return true if url.nil? || url.empty?
|
83
|
+
|
84
|
+
url =~ URI::DEFAULT_PARSER.make_regexp
|
85
|
+
end
|
86
|
+
|
87
|
+
def validate_filetype(filetype)
|
88
|
+
%w[pak zip exmod].include?(filetype.downcase)
|
89
|
+
end
|
90
|
+
|
91
|
+
def validate_string(string)
|
92
|
+
!(string.nil? || string.empty?)
|
93
|
+
end
|
55
94
|
end
|
56
95
|
end
|
57
96
|
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Icarus
|
4
|
+
module Mod
|
5
|
+
module Tools
|
6
|
+
# Validate Methods
|
7
|
+
class ModinfoValidate
|
8
|
+
attr_reader :modinfo_array
|
9
|
+
|
10
|
+
def initialize
|
11
|
+
@modinfo_array = ModSync.new.modinfo_array
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
data/lib/icarus/mod/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: Icarus-Mod-Tools
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Donovan Young
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-01-
|
11
|
+
date: 2023-01-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: google-cloud-firestore
|
@@ -38,6 +38,20 @@ dependencies:
|
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '6.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: paint
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '2.3'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '2.3'
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: thor
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -78,6 +92,7 @@ files:
|
|
78
92
|
- lib/icarus/mod/cli/list.rb
|
79
93
|
- lib/icarus/mod/cli/subcommand_base.rb
|
80
94
|
- lib/icarus/mod/cli/sync.rb
|
95
|
+
- lib/icarus/mod/cli/validate.rb
|
81
96
|
- lib/icarus/mod/config.rb
|
82
97
|
- lib/icarus/mod/firestore.rb
|
83
98
|
- lib/icarus/mod/github.rb
|
@@ -85,6 +100,7 @@ files:
|
|
85
100
|
- lib/icarus/mod/tools/mod_sync.rb
|
86
101
|
- lib/icarus/mod/tools/modinfo.rb
|
87
102
|
- lib/icarus/mod/tools/modinfo_sync.rb
|
103
|
+
- lib/icarus/mod/tools/modinfo_validate.rb
|
88
104
|
- lib/icarus/mod/tools/sync_helpers.rb
|
89
105
|
- lib/icarus/mod/version.rb
|
90
106
|
- sig/database/sync/sync.rbs
|