Icarus-Mod-Tools 2.0.4 → 2.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/.rubocop.yml +1 -1
- data/.ruby-version +1 -0
- data/Gemfile.lock +13 -9
- data/imtconfig.sample.json +6 -3
- data/lib/icarus/mod/cli/validate.rb +1 -1
- data/lib/icarus/mod/firestore.rb +13 -13
- data/lib/icarus/mod/tools/baseinfo.rb +38 -5
- data/lib/icarus/mod/tools/modinfo.rb +2 -16
- data/lib/icarus/mod/tools/toolinfo.rb +0 -4
- data/lib/icarus/mod/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 86f364e215cfc35b2fd3f0dbee4b21cd6a4c5582f0a13157f8d0a439b4011db6
|
|
4
|
+
data.tar.gz: 9ef8581f16f9bb88281e5c5141b9736ffc144a3ffbe5c00b4b174201e8403e12
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 0ff3c9d47c79c3ec2d7cfb096b9e242fe5b662fb6f6c1f75f32cf2739628e5e8cb2685e863b83c0e664271685b4e641e5619e630a42cceb7ef209e2943e06b7c
|
|
7
|
+
data.tar.gz: 52b61a53f9eea61ad77163fb4ebd08a03258eb946086815089707dbe619c24dc88185a570855711f6854c7130164cb01c63bad9c9d7fcf19fd528f5a6b949b1f
|
data/.rubocop.yml
CHANGED
data/.ruby-version
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
3.1.3
|
data/Gemfile.lock
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
Icarus-Mod-Tools (2.0
|
|
4
|
+
Icarus-Mod-Tools (2.1.0)
|
|
5
5
|
google-cloud-firestore (~> 2.7)
|
|
6
6
|
octokit (~> 6.0)
|
|
7
7
|
paint (~> 2.3)
|
|
@@ -24,7 +24,7 @@ GEM
|
|
|
24
24
|
faraday (~> 2.0)
|
|
25
25
|
ffi (1.15.5)
|
|
26
26
|
formatador (1.1.0)
|
|
27
|
-
gapic-common (0.
|
|
27
|
+
gapic-common (0.17.1)
|
|
28
28
|
faraday (>= 1.9, < 3.a)
|
|
29
29
|
faraday-retry (>= 1.0, < 3.a)
|
|
30
30
|
google-protobuf (~> 3.14)
|
|
@@ -38,7 +38,7 @@ GEM
|
|
|
38
38
|
google-cloud-env (1.6.0)
|
|
39
39
|
faraday (>= 0.17.3, < 3.0)
|
|
40
40
|
google-cloud-errors (1.3.0)
|
|
41
|
-
google-cloud-firestore (2.
|
|
41
|
+
google-cloud-firestore (2.10.0)
|
|
42
42
|
concurrent-ruby (~> 1.0)
|
|
43
43
|
google-cloud-core (~> 1.5)
|
|
44
44
|
google-cloud-firestore-v1 (~> 0.0)
|
|
@@ -50,6 +50,7 @@ GEM
|
|
|
50
50
|
google-cloud-location (0.3.0)
|
|
51
51
|
gapic-common (>= 0.16.0, < 2.a)
|
|
52
52
|
google-cloud-errors (~> 1.0)
|
|
53
|
+
google-protobuf (3.21.12-x86_64-darwin)
|
|
53
54
|
google-protobuf (3.21.12-x86_64-linux)
|
|
54
55
|
googleapis-common-protos (1.4.0)
|
|
55
56
|
google-protobuf (~> 3.14)
|
|
@@ -64,7 +65,10 @@ GEM
|
|
|
64
65
|
multi_json (~> 1.11)
|
|
65
66
|
os (>= 0.9, < 2.0)
|
|
66
67
|
signet (>= 0.16, < 2.a)
|
|
67
|
-
grpc (1.
|
|
68
|
+
grpc (1.52.0-x86_64-darwin)
|
|
69
|
+
google-protobuf (~> 3.21)
|
|
70
|
+
googleapis-common-protos-types (~> 1.0)
|
|
71
|
+
grpc (1.52.0-x86_64-linux)
|
|
68
72
|
google-protobuf (~> 3.21)
|
|
69
73
|
googleapis-common-protos-types (~> 1.0)
|
|
70
74
|
guard (2.18.0)
|
|
@@ -100,7 +104,7 @@ GEM
|
|
|
100
104
|
os (1.1.4)
|
|
101
105
|
paint (2.3.0)
|
|
102
106
|
parallel (1.22.1)
|
|
103
|
-
parser (3.2.
|
|
107
|
+
parser (3.2.1.0)
|
|
104
108
|
ast (~> 2.4.1)
|
|
105
109
|
pry (0.14.2)
|
|
106
110
|
coderay (~> 1.1)
|
|
@@ -112,7 +116,7 @@ GEM
|
|
|
112
116
|
rb-inotify (0.10.1)
|
|
113
117
|
ffi (~> 1.0)
|
|
114
118
|
rbtree (0.4.6)
|
|
115
|
-
regexp_parser (2.
|
|
119
|
+
regexp_parser (2.7.0)
|
|
116
120
|
rexml (3.2.5)
|
|
117
121
|
rspec (3.12.0)
|
|
118
122
|
rspec-core (~> 3.12.0)
|
|
@@ -127,7 +131,7 @@ GEM
|
|
|
127
131
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
128
132
|
rspec-support (~> 3.12.0)
|
|
129
133
|
rspec-support (3.12.0)
|
|
130
|
-
rubocop (1.
|
|
134
|
+
rubocop (1.45.1)
|
|
131
135
|
json (~> 2.3)
|
|
132
136
|
parallel (~> 1.10)
|
|
133
137
|
parser (>= 3.2.0.0)
|
|
@@ -137,8 +141,8 @@ GEM
|
|
|
137
141
|
rubocop-ast (>= 1.24.1, < 2.0)
|
|
138
142
|
ruby-progressbar (~> 1.7)
|
|
139
143
|
unicode-display_width (>= 2.4.0, < 3.0)
|
|
140
|
-
rubocop-ast (1.
|
|
141
|
-
parser (>= 3.
|
|
144
|
+
rubocop-ast (1.26.0)
|
|
145
|
+
parser (>= 3.2.1.0)
|
|
142
146
|
rubocop-capybara (2.17.0)
|
|
143
147
|
rubocop (~> 1.41)
|
|
144
148
|
rubocop-rspec (2.18.1)
|
data/imtconfig.sample.json
CHANGED
|
@@ -13,9 +13,12 @@
|
|
|
13
13
|
"client_x509_cert_url": "YOUR-x509-CERT-URL"
|
|
14
14
|
},
|
|
15
15
|
"collections": {
|
|
16
|
-
"
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
"meta": {
|
|
17
|
+
"modinfo": "meta/modinfo",
|
|
18
|
+
"repositories": "meta/repos",
|
|
19
|
+
"status": "meta/status",
|
|
20
|
+
"toolinfo": "meta/toolinfo"
|
|
21
|
+
},
|
|
19
22
|
"mods": "mods",
|
|
20
23
|
"tools": "tools"
|
|
21
24
|
}
|
|
@@ -29,7 +29,7 @@ module Icarus
|
|
|
29
29
|
validator.array.each do |info|
|
|
30
30
|
print Paint[format("%s %-#{max_length}s", "Running validation steps on", info.uniq_name), :cyan, :bright] if verbose > 1
|
|
31
31
|
|
|
32
|
-
info.
|
|
32
|
+
info.validate
|
|
33
33
|
|
|
34
34
|
unless info.errors? || info.warnings?
|
|
35
35
|
puts Paint["SUCCESS", :green, :bright] if verbose > 1
|
data/lib/icarus/mod/firestore.rb
CHANGED
|
@@ -47,17 +47,17 @@ module Icarus
|
|
|
47
47
|
def update(type, payload, merge: false)
|
|
48
48
|
raise "You must specify a payload to update" if payload&.empty? || payload.nil?
|
|
49
49
|
|
|
50
|
-
case type.to_sym
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
50
|
+
response = case type.to_sym
|
|
51
|
+
when :modinfo, :toolinfo
|
|
52
|
+
update_array = (send(type) + [payload]).flatten.uniq
|
|
53
|
+
@client.doc(collections.meta.send(type)).set({ list: update_array }, merge:) if update_array.any?
|
|
54
|
+
when :repositories
|
|
55
|
+
@client.doc(collections.meta.repositories).set({ list: payload }, merge:)
|
|
56
|
+
when :mod, :tool
|
|
57
|
+
create_or_update(pluralize(type), payload, merge:)
|
|
58
|
+
else
|
|
59
|
+
raise "Invalid type: #{type}"
|
|
60
|
+
end
|
|
61
61
|
|
|
62
62
|
response.is_a?(Google::Cloud::Firestore::DocumentReference) || response.is_a?(Google::Cloud::Firestore::CommitResponse::WriteResult)
|
|
63
63
|
end
|
|
@@ -78,7 +78,7 @@ module Icarus
|
|
|
78
78
|
def list(type)
|
|
79
79
|
case type.to_sym
|
|
80
80
|
when :modinfo, :toolinfo, :repositories
|
|
81
|
-
@client.doc(collections.send(type)).get[:list]
|
|
81
|
+
@client.doc(collections.meta.send(type)).get[:list]
|
|
82
82
|
when :mods, :tools
|
|
83
83
|
@client.col(collections.send(type)).get.map do |doc|
|
|
84
84
|
klass = type == :mods ? Icarus::Mod::Tools::Modinfo : Icarus::Mod::Tools::Toolinfo
|
|
@@ -89,7 +89,7 @@ module Icarus
|
|
|
89
89
|
end
|
|
90
90
|
end
|
|
91
91
|
|
|
92
|
-
def
|
|
92
|
+
def create_or_update(type, payload, merge:)
|
|
93
93
|
doc_id = payload.id || find_by_type(type:, name: payload.name, author: payload.author)&.id
|
|
94
94
|
|
|
95
95
|
return @client.doc("#{collections.send(type)}/#{doc_id}").set(payload.to_h, merge:) if doc_id
|
|
@@ -15,28 +15,44 @@ module Icarus
|
|
|
15
15
|
@updated_at = updated
|
|
16
16
|
@errors = []
|
|
17
17
|
@warnings = []
|
|
18
|
+
@validated = false
|
|
18
19
|
|
|
19
20
|
read(data)
|
|
20
21
|
end
|
|
21
22
|
|
|
23
|
+
def author_id
|
|
24
|
+
author.downcase.gsub(/\s+/, "_")
|
|
25
|
+
end
|
|
26
|
+
|
|
22
27
|
def read(data)
|
|
23
28
|
@data = data.is_a?(String) ? JSON.parse(data, symbolize_names: true) : data
|
|
24
29
|
end
|
|
25
30
|
|
|
26
31
|
def errors
|
|
32
|
+
validate
|
|
27
33
|
@errors.compact.uniq
|
|
28
34
|
end
|
|
29
35
|
|
|
30
36
|
def errors?
|
|
31
|
-
|
|
37
|
+
errors.any?
|
|
32
38
|
end
|
|
33
39
|
|
|
34
40
|
def warnings
|
|
41
|
+
validate
|
|
35
42
|
@warnings.compact.uniq
|
|
36
43
|
end
|
|
37
44
|
|
|
38
45
|
def warnings?
|
|
39
|
-
|
|
46
|
+
warnings.any?
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def status
|
|
50
|
+
validate
|
|
51
|
+
|
|
52
|
+
{
|
|
53
|
+
errors:,
|
|
54
|
+
warnings:
|
|
55
|
+
}
|
|
40
56
|
end
|
|
41
57
|
|
|
42
58
|
def uniq_name
|
|
@@ -48,10 +64,16 @@ module Icarus
|
|
|
48
64
|
end
|
|
49
65
|
|
|
50
66
|
def to_h
|
|
51
|
-
HASHKEYS.each_with_object({}) { |key, hash| hash[key] = @data[key] }
|
|
67
|
+
db_hash = HASHKEYS.each_with_object({}) { |key, hash| hash[key] = @data[key] }
|
|
68
|
+
|
|
69
|
+
db_hash[:version] = "1.0" if version.nil?
|
|
70
|
+
|
|
71
|
+
db_hash
|
|
52
72
|
end
|
|
53
73
|
|
|
54
|
-
def
|
|
74
|
+
def validate
|
|
75
|
+
return true if @validated
|
|
76
|
+
|
|
55
77
|
validate_version
|
|
56
78
|
validate_files if @data.key?(:files)
|
|
57
79
|
validate_filetype(fileType) if @data.key?(:fileType)
|
|
@@ -64,6 +86,12 @@ module Icarus
|
|
|
64
86
|
@errors << "Invalid URL #{key.capitalize}: #{@data[key.to_sym] || "blank"}" unless validate_url(@data[key.to_sym])
|
|
65
87
|
end
|
|
66
88
|
|
|
89
|
+
@validated = true
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
def valid?
|
|
93
|
+
validate
|
|
94
|
+
|
|
67
95
|
!errors?
|
|
68
96
|
end
|
|
69
97
|
|
|
@@ -100,6 +128,7 @@ module Icarus
|
|
|
100
128
|
end
|
|
101
129
|
|
|
102
130
|
def validate_files
|
|
131
|
+
@errors << "This mod uses deprecated fields (fileType and fileURL)" if @data.key?(:file_type) || @data.key?(:file_url)
|
|
103
132
|
@errors << "files cannot be blank" if @data.key?(:files) && @data[:files].keys.empty?
|
|
104
133
|
|
|
105
134
|
file_types.each { |file_type| validate_filetype(file_type) }
|
|
@@ -114,7 +143,11 @@ module Icarus
|
|
|
114
143
|
end
|
|
115
144
|
|
|
116
145
|
def validate_version
|
|
117
|
-
|
|
146
|
+
if version.nil?
|
|
147
|
+
@warnings << "Version was nil, it has been defaulted to 1.0"
|
|
148
|
+
else
|
|
149
|
+
@warnings << "Version should be a version string" unless version =~ /^\d+[.\d+]*/
|
|
150
|
+
end
|
|
118
151
|
end
|
|
119
152
|
end
|
|
120
153
|
end
|
|
@@ -7,26 +7,12 @@ 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 files fileType fileURL imageURL readmeURL].freeze
|
|
11
|
-
|
|
12
|
-
# rubocop:disable Metrics/AbcSize
|
|
13
10
|
def to_h
|
|
14
|
-
db_hash =
|
|
15
|
-
|
|
16
|
-
next if key == :long_description && @data[:long_description].nil?
|
|
17
|
-
|
|
18
|
-
hash[key] = @data[key]
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
db_hash[:files] = { @data[:fileType].downcase.to_sym => @data[:fileURL] } if db_hash[:files].nil? && !@data[:fileType].nil?
|
|
22
|
-
|
|
23
|
-
# Remove this once all mods have been updated
|
|
24
|
-
db_hash[:fileType] = db_hash[:files].keys.first.to_s if db_hash[:fileType].nil? && !db_hash[:files].nil?
|
|
25
|
-
db_hash[:fileURL] = db_hash[:files].values.first if db_hash[:fileURL].nil? && !db_hash[:files].nil?
|
|
11
|
+
db_hash = super
|
|
12
|
+
db_hash[:meta] = { status: } # Add metadata
|
|
26
13
|
|
|
27
14
|
db_hash
|
|
28
15
|
end
|
|
29
|
-
# rubocop:enable Metrics/AbcSize
|
|
30
16
|
|
|
31
17
|
def file_types
|
|
32
18
|
files&.keys || [@data[:fileType] || "pak"]
|
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: 2.0
|
|
4
|
+
version: 2.1.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-02-
|
|
11
|
+
date: 2023-02-11 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: google-cloud-firestore
|
|
@@ -76,6 +76,7 @@ extra_rdoc_files: []
|
|
|
76
76
|
files:
|
|
77
77
|
- ".rspec"
|
|
78
78
|
- ".rubocop.yml"
|
|
79
|
+
- ".ruby-version"
|
|
79
80
|
- CHANGELOG.md
|
|
80
81
|
- Gemfile
|
|
81
82
|
- Gemfile.lock
|