Icarus-Mod-Tools 1.9.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/Gemfile.lock +2 -2
- data/lib/icarus/mod/cli/add.rb +24 -0
- data/lib/icarus/mod/cli/sync.rb +2 -0
- data/lib/icarus/mod/tools/baseinfo.rb +30 -12
- data/lib/icarus/mod/tools/modinfo.rb +19 -1
- data/lib/icarus/mod/tools/toolinfo.rb +2 -0
- data/lib/icarus/mod/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: aba02b8c9f3f8a95dfaff8dc2a13914d9ec71153da336e2dc2ab954d6e5d6560
|
4
|
+
data.tar.gz: aad3f90f121957a893282dfc91cd424e21ecdbb155ecde1135f35644f86e8a3d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 54dd466afe7f4f01a2deb0999752cc298ee52a2b1f4da0e1abf26c82677ecabf1a9f293765dc081d6f5c5e05ea017c57da1cbf9ac114a287df922c8ab40ba696
|
7
|
+
data.tar.gz: b6f4a7bf87a62d190928cbf42ca57864c8651a2f7e353869e6221364f7f3e2c7ce59e51b69818636afe99c1ada9dfdbde4dcc29a43981b6caeab913856d1a779
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
Icarus-Mod-Tools (
|
4
|
+
Icarus-Mod-Tools (2.0)
|
5
5
|
google-cloud-firestore (~> 2.7)
|
6
6
|
octokit (~> 6.0)
|
7
7
|
paint (~> 2.3)
|
@@ -86,7 +86,7 @@ GEM
|
|
86
86
|
guard-compat (~> 1.1)
|
87
87
|
rspec (>= 2.99.0, < 4.0)
|
88
88
|
json (2.6.3)
|
89
|
-
jwt (2.
|
89
|
+
jwt (2.7.0)
|
90
90
|
listen (3.8.0)
|
91
91
|
rb-fsevent (~> 0.10, >= 0.10.3)
|
92
92
|
rb-inotify (~> 0.9, >= 0.9.10)
|
data/lib/icarus/mod/cli/add.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require "firestore"
|
4
|
+
require "tools/modinfo"
|
4
5
|
|
5
6
|
module Icarus
|
6
7
|
module Mod
|
@@ -30,6 +31,29 @@ module Icarus
|
|
30
31
|
|
31
32
|
puts firestore.update(:repositories, payload, merge: true) ? "Success" : "Failure"
|
32
33
|
end
|
34
|
+
|
35
|
+
desc "mod", "Adds an entry to 'mods'"
|
36
|
+
method_option :modinfo, type: :string, required: true, default: "modinfo.json", desc: "Path to the modinfo.json file"
|
37
|
+
def mod
|
38
|
+
firestore = Firestore.new
|
39
|
+
data = options[:modinfo]
|
40
|
+
|
41
|
+
if data.nil? || !File.exist?(data)
|
42
|
+
warn "Invalid data file: #{data}"
|
43
|
+
exit 1
|
44
|
+
end
|
45
|
+
|
46
|
+
JSON.parse(File.read(data), symbolize_names: true)[:mods].each do |mod|
|
47
|
+
modinfo = Icarus::Mod::Tools::Modinfo.new(mod)
|
48
|
+
|
49
|
+
unless modinfo.valid?
|
50
|
+
warn "Invalid modinfo: #{modinfo.errors}"
|
51
|
+
exit 1
|
52
|
+
end
|
53
|
+
|
54
|
+
puts firestore.update(:mod, modinfo, merge: true) ? "Success" : "Failure"
|
55
|
+
end
|
56
|
+
end
|
33
57
|
end
|
34
58
|
end
|
35
59
|
end
|
data/lib/icarus/mod/cli/sync.rb
CHANGED
@@ -85,6 +85,8 @@ module Icarus
|
|
85
85
|
def sync_list(type)
|
86
86
|
sync = (type == :mods ? Icarus::Mod::Tools::Sync::Mods : Icarus::Mod::Tools::Sync::Tools).new(client: firestore)
|
87
87
|
|
88
|
+
puts "Syncing #{type} to #{Config.firebase.collections.send(type)}" if verbose > 1
|
89
|
+
|
88
90
|
puts "Retrieving Info Data..." if verbose?
|
89
91
|
info_array = sync.info_array
|
90
92
|
|
@@ -7,7 +7,7 @@ module Icarus
|
|
7
7
|
class Baseinfo
|
8
8
|
attr_reader :data, :id, :created_at, :updated_at
|
9
9
|
|
10
|
-
HASHKEYS = %i[name author version compatibility description
|
10
|
+
HASHKEYS = %i[name author version compatibility description files imageURL readmeURL].freeze
|
11
11
|
|
12
12
|
def initialize(data, id: nil, created: nil, updated: nil)
|
13
13
|
@id = id
|
@@ -52,14 +52,14 @@ module Icarus
|
|
52
52
|
end
|
53
53
|
|
54
54
|
def valid?
|
55
|
-
|
55
|
+
validate_version
|
56
|
+
validate_files if @data.key?(:files)
|
57
|
+
validate_filetype(fileType) if @data.key?(:fileType)
|
56
58
|
|
57
59
|
%w[name author description].each do |key|
|
58
60
|
@errors << "#{key.capitalize} cannot be blank" unless validate_string(@data[key.to_sym])
|
59
61
|
end
|
60
62
|
|
61
|
-
@errors << "Invalid fileType: #{fileType || "blank"}" unless validate_filetype(fileType)
|
62
|
-
|
63
63
|
%w[fileURL imageURL readmeURL].each do |key|
|
64
64
|
@errors << "Invalid URL #{key.capitalize}: #{@data[key.to_sym] || "blank"}" unless validate_url(@data[key.to_sym])
|
65
65
|
end
|
@@ -67,12 +67,20 @@ module Icarus
|
|
67
67
|
!errors?
|
68
68
|
end
|
69
69
|
|
70
|
+
def file_types
|
71
|
+
files&.keys || []
|
72
|
+
end
|
73
|
+
|
74
|
+
def file_urls
|
75
|
+
files&.values || []
|
76
|
+
end
|
77
|
+
|
70
78
|
def method_missing(method_name, *_args, &_block)
|
71
|
-
@data[method_name.to_sym]
|
79
|
+
@data[method_name.to_sym] if @data.keys.include?(method_name.to_sym)
|
72
80
|
end
|
73
81
|
|
74
82
|
def respond_to_missing?(method_name, include_private = false)
|
75
|
-
|
83
|
+
@data.keys.include?(method_name.to_sym) || super
|
76
84
|
end
|
77
85
|
|
78
86
|
private
|
@@ -81,22 +89,32 @@ module Icarus
|
|
81
89
|
/(zip|pak|exmodz?)/i
|
82
90
|
end
|
83
91
|
|
92
|
+
def validate_string(string)
|
93
|
+
!(string.nil? || string.empty?)
|
94
|
+
end
|
95
|
+
|
84
96
|
def validate_url(url)
|
85
97
|
return true if url.nil? || url.empty?
|
86
98
|
|
87
99
|
url =~ URI::DEFAULT_PARSER.make_regexp
|
88
100
|
end
|
89
101
|
|
90
|
-
def
|
91
|
-
|
102
|
+
def validate_files
|
103
|
+
@errors << "files cannot be blank" if @data.key?(:files) && @data[:files].keys.empty?
|
104
|
+
|
105
|
+
file_types.each { |file_type| validate_filetype(file_type) }
|
106
|
+
|
107
|
+
file_urls.each do |file_url|
|
108
|
+
@errors << "Invalid URL: #{file_url}" unless validate_url(file_url)
|
109
|
+
end
|
92
110
|
end
|
93
111
|
|
94
|
-
def
|
95
|
-
|
112
|
+
def validate_filetype(file_type)
|
113
|
+
@errors << "Invalid fileType: #{file_type.upcase}" unless file_type&.match?(filetype_pattern)
|
96
114
|
end
|
97
115
|
|
98
|
-
def validate_version
|
99
|
-
version =~
|
116
|
+
def validate_version
|
117
|
+
@warnings << "Version should be a version string" unless version =~ /^\d+[.\d+]*/
|
100
118
|
end
|
101
119
|
end
|
102
120
|
end
|
@@ -7,7 +7,25 @@ module Icarus
|
|
7
7
|
module Tools
|
8
8
|
# Sync methods
|
9
9
|
class Modinfo < Baseinfo
|
10
|
-
HASHKEYS = %i[name author version compatibility description long_description fileType fileURL imageURL readmeURL].freeze
|
10
|
+
HASHKEYS = %i[name author version compatibility description long_description files fileType fileURL imageURL readmeURL].freeze
|
11
|
+
|
12
|
+
def to_h
|
13
|
+
HASHKEYS.each_with_object({}) do |key, hash|
|
14
|
+
next if key == :files && @data[:files].nil?
|
15
|
+
next if %i[fileType fileURL].include?(key.to_sym) && !@data[:files].nil?
|
16
|
+
next if key == :long_description && @data[:long_description].nil?
|
17
|
+
|
18
|
+
hash[key] = @data[key]
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def file_types
|
23
|
+
files&.keys || [@data[:fileType] || "pak"]
|
24
|
+
end
|
25
|
+
|
26
|
+
def file_urls
|
27
|
+
files&.values || [@data[:fileURL]].compact
|
28
|
+
end
|
11
29
|
|
12
30
|
# rubocop:disable Naming/MethodName
|
13
31
|
def fileType
|
@@ -7,6 +7,8 @@ module Icarus
|
|
7
7
|
module Tools
|
8
8
|
# Sync methods
|
9
9
|
class Toolinfo < Baseinfo
|
10
|
+
HASHKEYS = %i[name author version compatibility description fileType fileURL imageURL readmeURL].freeze
|
11
|
+
|
10
12
|
# rubocop:disable Naming/MethodName
|
11
13
|
def fileType
|
12
14
|
@data[:fileType] || "zip"
|
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:
|
4
|
+
version: '2.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-
|
11
|
+
date: 2023-02-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: google-cloud-firestore
|