Icarus-Mod-Tools 2.6.0 → 3.0.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 +55 -0
- data/.rubocop_todo.yml +142 -0
- data/.ruby-version +1 -1
- data/CHANGELOG.md +48 -0
- data/CLAUDE.md +6 -4
- data/Gemfile +3 -5
- data/Gemfile.lock +18 -27
- data/Guardfile +2 -0
- data/README.md +9 -1
- data/icarus-mod-tools.gemspec +2 -1
- data/imtconfig.sample.json +2 -0
- data/lib/icarus/mod/cli/add.rb +53 -19
- data/lib/icarus/mod/cli/base.rb +4 -4
- data/lib/icarus/mod/cli/command.rb +6 -1
- data/lib/icarus/mod/cli/list.rb +19 -7
- data/lib/icarus/mod/cli/remove.rb +65 -62
- data/lib/icarus/mod/cli/subcommand_base.rb +2 -2
- data/lib/icarus/mod/cli/sync.rb +139 -35
- data/lib/icarus/mod/cli/validate.rb +1 -4
- data/lib/icarus/mod/config.rb +2 -2
- data/lib/icarus/mod/firestore.rb +132 -15
- data/lib/icarus/mod/github.rb +39 -22
- data/lib/icarus/mod/tools/baseinfo.rb +86 -22
- data/lib/icarus/mod/tools/modinfo.rb +1 -1
- data/lib/icarus/mod/tools/sync/entities.rb +102 -0
- data/lib/icarus/mod/tools/sync/helpers.rb +38 -4
- data/lib/icarus/mod/tools/sync/modinfo_list.rb +30 -10
- data/lib/icarus/mod/tools/sync/mods.rb +6 -37
- data/lib/icarus/mod/tools/sync/toolinfo_list.rb +30 -10
- data/lib/icarus/mod/tools/sync/tools.rb +6 -39
- data/lib/icarus/mod/tools/toolinfo.rb +12 -8
- data/lib/icarus/mod/tools/validator.rb +7 -7
- data/lib/icarus/mod/version.rb +1 -1
- metadata +20 -4
- data/sig/database/sync/sync.rbs +0 -15
|
@@ -16,8 +16,13 @@ module Icarus
|
|
|
16
16
|
@firestore = client || Firestore.new
|
|
17
17
|
@github = Github.new
|
|
18
18
|
@repositories = []
|
|
19
|
+
@transient_failures = []
|
|
19
20
|
end
|
|
20
21
|
|
|
22
|
+
# Repositories whose GitHub lookup failed this run for a reason that may clear up (rate limit,
|
|
23
|
+
# 5xx, network error). Their entries already in the list are kept: #update only ever adds (#16).
|
|
24
|
+
attr_reader :transient_failures
|
|
25
|
+
|
|
21
26
|
def repositories
|
|
22
27
|
@firestore.repositories
|
|
23
28
|
end
|
|
@@ -31,26 +36,41 @@ module Icarus
|
|
|
31
36
|
end
|
|
32
37
|
|
|
33
38
|
def data(repositories, verbose: false)
|
|
39
|
+
@transient_failures = []
|
|
40
|
+
|
|
34
41
|
repositories.map do |repo|
|
|
35
42
|
print "searching #{repo}..." if verbose
|
|
36
43
|
|
|
37
44
|
case repo
|
|
38
45
|
when /github/
|
|
39
|
-
|
|
40
|
-
modinfo_url = @github.find("modinfo.json")
|
|
41
|
-
|
|
42
|
-
unless modinfo_url
|
|
43
|
-
puts "Skipped...no modinfo.json" if verbose
|
|
44
|
-
next
|
|
45
|
-
end
|
|
46
|
-
|
|
47
|
-
puts "Found!" if verbose
|
|
48
|
-
modinfo_url
|
|
46
|
+
find_modinfo(repo, verbose:)
|
|
49
47
|
else
|
|
50
48
|
puts "Skipped...repository type not supported yet" if verbose
|
|
51
49
|
end
|
|
52
50
|
end.compact
|
|
53
51
|
end
|
|
52
|
+
|
|
53
|
+
private
|
|
54
|
+
|
|
55
|
+
def find_modinfo(repo, verbose: false)
|
|
56
|
+
@github.repository = repo
|
|
57
|
+
modinfo_url = @github.find("modinfo.json")
|
|
58
|
+
|
|
59
|
+
unless modinfo_url
|
|
60
|
+
puts "Skipped...no modinfo.json" if verbose
|
|
61
|
+
return
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
puts "Found!" if verbose
|
|
65
|
+
modinfo_url
|
|
66
|
+
rescue Octokit::NotFound
|
|
67
|
+
puts "Skipped...repository not found" if verbose
|
|
68
|
+
nil
|
|
69
|
+
rescue Octokit::Error, Faraday::Error => e
|
|
70
|
+
@transient_failures << repo
|
|
71
|
+
warn "Skipped; could not search #{repo} (#{e.class}); its existing modinfo entries are kept"
|
|
72
|
+
nil
|
|
73
|
+
end
|
|
54
74
|
end
|
|
55
75
|
end
|
|
56
76
|
end
|
|
@@ -1,51 +1,20 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require "
|
|
4
|
-
require "tools/sync/helpers"
|
|
3
|
+
require "tools/sync/entities"
|
|
5
4
|
|
|
6
5
|
module Icarus
|
|
7
6
|
module Mod
|
|
8
7
|
module Tools
|
|
9
8
|
module Sync
|
|
10
|
-
#
|
|
11
|
-
class Mods
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
@firestore = client || Firestore.new
|
|
16
|
-
end
|
|
9
|
+
# Syncs meta/modinfo to the mods collection (see Entities)
|
|
10
|
+
class Mods < Entities
|
|
11
|
+
TYPE = :mod
|
|
12
|
+
INFO = :modinfo
|
|
13
|
+
ENTITY = Icarus::Mod::Tools::Modinfo
|
|
17
14
|
|
|
18
15
|
def mods
|
|
19
16
|
@firestore.mods
|
|
20
17
|
end
|
|
21
|
-
|
|
22
|
-
def info_array
|
|
23
|
-
@info_array ||= @firestore.modinfo.map do |url|
|
|
24
|
-
retrieve_from_url(url)[:mods].map { |mod| Icarus::Mod::Tools::Modinfo.new(mod) if /[a-z0-9]+/i.match?(mod[:name]) }
|
|
25
|
-
rescue Icarus::Mod::Tools::Sync::RequestFailed
|
|
26
|
-
warn "Skipped; Failed to retrieve #{url}"
|
|
27
|
-
next
|
|
28
|
-
rescue JSON::ParserError => e
|
|
29
|
-
warn "Skipped; Invalid JSON in #{url}: #{e.message}"
|
|
30
|
-
next
|
|
31
|
-
end.flatten.compact.uniq { |mod| [mod.name, mod.author] }
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
def find(modinfo)
|
|
35
|
-
@firestore.find_by_type(type: "mods", name: modinfo.name, author: modinfo.author)&.id
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
def find_info(modinfo)
|
|
39
|
-
@info_array.find { |mod| mod.name == modinfo.name && mod.author == modinfo.author }
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
def update(modinfo)
|
|
43
|
-
@firestore.update(:mod, modinfo, merge: false)
|
|
44
|
-
end
|
|
45
|
-
|
|
46
|
-
def delete(modinfo)
|
|
47
|
-
@firestore.delete(:mod, modinfo)
|
|
48
|
-
end
|
|
49
18
|
end
|
|
50
19
|
end
|
|
51
20
|
end
|
|
@@ -16,8 +16,13 @@ module Icarus
|
|
|
16
16
|
@firestore = client || Firestore.new
|
|
17
17
|
@github = Github.new
|
|
18
18
|
@repositories = []
|
|
19
|
+
@transient_failures = []
|
|
19
20
|
end
|
|
20
21
|
|
|
22
|
+
# Repositories whose GitHub lookup failed this run for a reason that may clear up (rate limit,
|
|
23
|
+
# 5xx, network error). Their entries already in the list are kept: #update only ever adds (#16).
|
|
24
|
+
attr_reader :transient_failures
|
|
25
|
+
|
|
21
26
|
def repositories
|
|
22
27
|
@firestore.repositories
|
|
23
28
|
end
|
|
@@ -31,26 +36,41 @@ module Icarus
|
|
|
31
36
|
end
|
|
32
37
|
|
|
33
38
|
def data(repositories, verbose: false)
|
|
39
|
+
@transient_failures = []
|
|
40
|
+
|
|
34
41
|
repositories.map do |repo|
|
|
35
42
|
print "searching #{repo}..." if verbose
|
|
36
43
|
|
|
37
44
|
case repo
|
|
38
45
|
when /github/
|
|
39
|
-
|
|
40
|
-
toolinfo_url = @github.find("toolinfo.json")
|
|
41
|
-
|
|
42
|
-
unless toolinfo_url
|
|
43
|
-
puts "Skipped...no toolinfo.json" if verbose
|
|
44
|
-
next
|
|
45
|
-
end
|
|
46
|
-
|
|
47
|
-
puts "Found!" if verbose
|
|
48
|
-
toolinfo_url
|
|
46
|
+
find_toolinfo(repo, verbose:)
|
|
49
47
|
else
|
|
50
48
|
puts "Skipped...repository type not supported yet" if verbose
|
|
51
49
|
end
|
|
52
50
|
end.compact
|
|
53
51
|
end
|
|
52
|
+
|
|
53
|
+
private
|
|
54
|
+
|
|
55
|
+
def find_toolinfo(repo, verbose: false)
|
|
56
|
+
@github.repository = repo
|
|
57
|
+
toolinfo_url = @github.find("toolinfo.json")
|
|
58
|
+
|
|
59
|
+
unless toolinfo_url
|
|
60
|
+
puts "Skipped...no toolinfo.json" if verbose
|
|
61
|
+
return
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
puts "Found!" if verbose
|
|
65
|
+
toolinfo_url
|
|
66
|
+
rescue Octokit::NotFound
|
|
67
|
+
puts "Skipped...repository not found" if verbose
|
|
68
|
+
nil
|
|
69
|
+
rescue Octokit::Error, Faraday::Error => e
|
|
70
|
+
@transient_failures << repo
|
|
71
|
+
warn "Skipped; could not search #{repo} (#{e.class}); its existing toolinfo entries are kept"
|
|
72
|
+
nil
|
|
73
|
+
end
|
|
54
74
|
end
|
|
55
75
|
end
|
|
56
76
|
end
|
|
@@ -1,53 +1,20 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require "
|
|
4
|
-
require "tools/sync/helpers"
|
|
3
|
+
require "tools/sync/entities"
|
|
5
4
|
|
|
6
5
|
module Icarus
|
|
7
6
|
module Mod
|
|
8
7
|
module Tools
|
|
9
8
|
module Sync
|
|
10
|
-
#
|
|
11
|
-
class Tools
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
@firestore = client || Firestore.new
|
|
16
|
-
end
|
|
9
|
+
# Syncs meta/toolinfo to the tools collection (see Entities)
|
|
10
|
+
class Tools < Entities
|
|
11
|
+
TYPE = :tool
|
|
12
|
+
INFO = :toolinfo
|
|
13
|
+
ENTITY = Icarus::Mod::Tools::Toolinfo
|
|
17
14
|
|
|
18
15
|
def tools
|
|
19
16
|
@firestore.tools
|
|
20
17
|
end
|
|
21
|
-
|
|
22
|
-
def info_array
|
|
23
|
-
@info_array ||= @firestore.toolinfo.map do |url|
|
|
24
|
-
next unless url
|
|
25
|
-
|
|
26
|
-
retrieve_from_url(url)[:tools].map { |tool| Icarus::Mod::Tools::Toolinfo.new(tool) if /[a-z0-9]+/i.match?(tool[:name]) }
|
|
27
|
-
rescue Icarus::Mod::Tools::Sync::RequestFailed
|
|
28
|
-
warn "Skipped; Failed to retrieve #{url}"
|
|
29
|
-
next
|
|
30
|
-
rescue JSON::ParserError => e
|
|
31
|
-
warn "Skipped; Invalid JSON in #{url}: #{e.message}"
|
|
32
|
-
next
|
|
33
|
-
end.flatten.compact.uniq { |tool| [tool.name, tool.author] }
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
def find(toolinfo)
|
|
37
|
-
@firestore.find_by_type(type: "tools", name: toolinfo.name, author: toolinfo.author)&.id
|
|
38
|
-
end
|
|
39
|
-
|
|
40
|
-
def find_info(toolinfo)
|
|
41
|
-
@info_array.find { |tool| tool.name == toolinfo.name && tool.author == toolinfo.author }
|
|
42
|
-
end
|
|
43
|
-
|
|
44
|
-
def update(toolinfo)
|
|
45
|
-
@firestore.update(:tool, toolinfo, merge: false)
|
|
46
|
-
end
|
|
47
|
-
|
|
48
|
-
def delete(toolinfo)
|
|
49
|
-
@firestore.delete(:tool, toolinfo)
|
|
50
|
-
end
|
|
51
18
|
end
|
|
52
19
|
end
|
|
53
20
|
end
|
|
@@ -19,6 +19,15 @@ module Icarus
|
|
|
19
19
|
HASHKEYS.each_with_object({}) { |key, hash| hash[key] = @data[key] }
|
|
20
20
|
end
|
|
21
21
|
|
|
22
|
+
def validate
|
|
23
|
+
return true if @validated
|
|
24
|
+
|
|
25
|
+
validate_filetype(fileType)
|
|
26
|
+
check_url(fileURL, "Invalid fileURL: #{@data[:fileURL] || "blank"}")
|
|
27
|
+
|
|
28
|
+
super
|
|
29
|
+
end
|
|
30
|
+
|
|
22
31
|
private
|
|
23
32
|
|
|
24
33
|
def normalize_github_urls_in_data
|
|
@@ -32,16 +41,11 @@ module Icarus
|
|
|
32
41
|
end
|
|
33
42
|
|
|
34
43
|
def filetype_pattern
|
|
35
|
-
|
|
44
|
+
/\A\.?(zip|exe)\z/i
|
|
36
45
|
end
|
|
37
46
|
|
|
38
|
-
def
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
validate_filetype(fileType)
|
|
42
|
-
@errors << "Invalid fileURL: #{@data[:fileURL] || "blank"}" unless validate_url(fileURL)
|
|
43
|
-
|
|
44
|
-
super
|
|
47
|
+
def legacy_filetype_pattern
|
|
48
|
+
/(zip|exe)/i
|
|
45
49
|
end
|
|
46
50
|
end
|
|
47
51
|
end
|
|
@@ -9,13 +9,13 @@ module Icarus
|
|
|
9
9
|
|
|
10
10
|
def initialize(type)
|
|
11
11
|
@array = case type
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
12
|
+
when :modinfo
|
|
13
|
+
Sync::Mods.new.info_array
|
|
14
|
+
when :toolinfo
|
|
15
|
+
Sync::Tools.new.info_array
|
|
16
|
+
else
|
|
17
|
+
raise ArgumentError, "Invalid type: #{type}"
|
|
18
|
+
end
|
|
19
19
|
end
|
|
20
20
|
end
|
|
21
21
|
end
|
data/lib/icarus/mod/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: Icarus-Mod-Tools
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version:
|
|
4
|
+
version: 3.0.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Donovan Young
|
|
@@ -37,6 +37,20 @@ dependencies:
|
|
|
37
37
|
- - "~>"
|
|
38
38
|
- !ruby/object:Gem::Version
|
|
39
39
|
version: '6.0'
|
|
40
|
+
- !ruby/object:Gem::Dependency
|
|
41
|
+
name: ostruct
|
|
42
|
+
requirement: !ruby/object:Gem::Requirement
|
|
43
|
+
requirements:
|
|
44
|
+
- - "~>"
|
|
45
|
+
- !ruby/object:Gem::Version
|
|
46
|
+
version: '0.6'
|
|
47
|
+
type: :runtime
|
|
48
|
+
prerelease: false
|
|
49
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
50
|
+
requirements:
|
|
51
|
+
- - "~>"
|
|
52
|
+
- !ruby/object:Gem::Version
|
|
53
|
+
version: '0.6'
|
|
40
54
|
- !ruby/object:Gem::Dependency
|
|
41
55
|
name: paint
|
|
42
56
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -75,6 +89,8 @@ extra_rdoc_files: []
|
|
|
75
89
|
files:
|
|
76
90
|
- ".claude-context.md"
|
|
77
91
|
- ".rspec"
|
|
92
|
+
- ".rubocop.yml"
|
|
93
|
+
- ".rubocop_todo.yml"
|
|
78
94
|
- ".ruby-version"
|
|
79
95
|
- CHANGELOG.md
|
|
80
96
|
- CLAUDE.md
|
|
@@ -101,6 +117,7 @@ files:
|
|
|
101
117
|
- lib/icarus/mod/tools.rb
|
|
102
118
|
- lib/icarus/mod/tools/baseinfo.rb
|
|
103
119
|
- lib/icarus/mod/tools/modinfo.rb
|
|
120
|
+
- lib/icarus/mod/tools/sync/entities.rb
|
|
104
121
|
- lib/icarus/mod/tools/sync/helpers.rb
|
|
105
122
|
- lib/icarus/mod/tools/sync/modinfo_list.rb
|
|
106
123
|
- lib/icarus/mod/tools/sync/mods.rb
|
|
@@ -109,7 +126,6 @@ files:
|
|
|
109
126
|
- lib/icarus/mod/tools/toolinfo.rb
|
|
110
127
|
- lib/icarus/mod/tools/validator.rb
|
|
111
128
|
- lib/icarus/mod/version.rb
|
|
112
|
-
- sig/database/sync/sync.rbs
|
|
113
129
|
homepage: https://github.com/DonovanMods/icarus-mod-tools
|
|
114
130
|
licenses: []
|
|
115
131
|
metadata:
|
|
@@ -125,14 +141,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
125
141
|
requirements:
|
|
126
142
|
- - ">="
|
|
127
143
|
- !ruby/object:Gem::Version
|
|
128
|
-
version: '
|
|
144
|
+
version: '4.0'
|
|
129
145
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
130
146
|
requirements:
|
|
131
147
|
- - ">="
|
|
132
148
|
- !ruby/object:Gem::Version
|
|
133
149
|
version: '0'
|
|
134
150
|
requirements: []
|
|
135
|
-
rubygems_version: 4.0.
|
|
151
|
+
rubygems_version: 4.0.20
|
|
136
152
|
specification_version: 4
|
|
137
153
|
summary: Various tools for Icarus Modding
|
|
138
154
|
test_files: []
|
data/sig/database/sync/sync.rbs
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
# See the writing guide of rbs: https://github.com/ruby/rbs#guides
|
|
2
|
-
#
|
|
3
|
-
module Icarus
|
|
4
|
-
module Mod
|
|
5
|
-
class Github
|
|
6
|
-
attr_reader :client: Octokit::Client
|
|
7
|
-
attr_accessor :repo: String
|
|
8
|
-
|
|
9
|
-
def initialize: (void) -> void
|
|
10
|
-
def all_files: (String) -> Array[String]
|
|
11
|
-
|
|
12
|
-
VERSION: String
|
|
13
|
-
end
|
|
14
|
-
end
|
|
15
|
-
end
|