Icarus-Mod-Tools 1.6.0 → 1.7.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c0a960947869f1869c8fd0cfb500817169d4bdff4a725898d3d97459220e0843
4
- data.tar.gz: 9bfa76062cdb5441198a176b273f49a915fa3c960f723268dc9395532b780ab5
3
+ metadata.gz: fd3e0ae69c6ef23c28a6f91e0ea2bef191fb23cb497624c4a6861542f0d55529
4
+ data.tar.gz: 74f1b174266c581ab857fd8079bc08345e055c12de0df175a24b84d5cf943c0b
5
5
  SHA512:
6
- metadata.gz: 2266c6ffd007d98c9cd0269889634204f10e1a04bf217b68c915c194aec584851e84e11b0b2c8c55204420e302d92a6df638e24e9dc15aa64b3db3ebb1b21597
7
- data.tar.gz: db7ee61fafa8279e1604de8fea770936548c6abeb4ade7d36a2b187c7514f2f1ef093238c8409aa3af1df477136bb2339c647982b1db64350a934cca19030a2d
6
+ metadata.gz: 3e2065dcd3968f5e692db72955f6c898e16c442c47cca55681586fb6c9b07c1ba7ed19c48b402b73b02004f70fb6c25def55d4f9daa4a46b1316ec5a2489e019
7
+ data.tar.gz: e56b480e1bd28fe040e0cd7a561f848596a654bb492457c92244902dbc046fe8a5ce8634f49455322ef03587c2762dc4003eb38e2b9c1fea5a7681562572a700
data/Gemfile.lock CHANGED
@@ -1,9 +1,10 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- Icarus-Mod-Tools (1.6.0)
4
+ Icarus-Mod-Tools (1.7.1)
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.2)
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.2.0)
50
- gapic-common (>= 0.10, < 2.a)
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)
@@ -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
@@ -1,8 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "version"
4
- require "tools"
3
+ require "paint"
5
4
  require "thor"
5
+ require "tools"
6
+ require "version"
6
7
 
7
8
  module Icarus
8
9
  module Mod
@@ -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
@@ -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 be a version string" unless validate_version(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,26 @@ 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
94
+
95
+ def validate_version(version)
96
+ version =~ /\d+\.\d+[.\d+]?/
97
+ end
55
98
  end
56
99
  end
57
100
  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
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Icarus
4
4
  module Mod
5
- VERSION = "1.6.0"
5
+ VERSION = "1.7.1"
6
6
  end
7
7
  end
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.6.0
4
+ version: 1.7.1
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-15 00:00:00.000000000 Z
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