Icarus-Mod-Tools 2.7.0 → 3.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 +55 -0
- data/.rubocop_todo.yml +142 -0
- data/.ruby-version +1 -1
- data/CHANGELOG.md +41 -0
- data/CLAUDE.md +4 -4
- data/Gemfile +4 -6
- data/Gemfile.lock +90 -71
- data/Guardfile +2 -0
- data/README.md +8 -2
- data/icarus-mod-tools.gemspec +4 -3
- 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 +64 -62
- data/lib/icarus/mod/cli/subcommand_base.rb +2 -2
- data/lib/icarus/mod/cli/sync.rb +68 -23
- data/lib/icarus/mod/cli/validate.rb +1 -4
- data/lib/icarus/mod/config.rb +2 -2
- data/lib/icarus/mod/firestore.rb +38 -21
- data/lib/icarus/mod/github.rb +39 -22
- data/lib/icarus/mod/tools/baseinfo.rb +84 -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 +6 -2
- data/lib/icarus/mod/tools/sync/mods.rb +6 -79
- data/lib/icarus/mod/tools/sync/tools.rb +6 -81
- 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 +24 -8
- data/sig/database/sync/sync.rbs +0 -15
|
@@ -1,95 +1,20 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require "
|
|
4
|
-
require "firestore"
|
|
5
|
-
require "tools/sync/helpers"
|
|
3
|
+
require "tools/sync/entities"
|
|
6
4
|
|
|
7
5
|
module Icarus
|
|
8
6
|
module Mod
|
|
9
7
|
module Tools
|
|
10
8
|
module Sync
|
|
11
|
-
#
|
|
12
|
-
class Tools
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
@firestore = client || Firestore.new
|
|
17
|
-
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
|
|
18
14
|
|
|
19
15
|
def tools
|
|
20
16
|
@firestore.tools
|
|
21
17
|
end
|
|
22
|
-
|
|
23
|
-
# Every tool we could read from the toolinfo URLs this run. URLs that failed transiently
|
|
24
|
-
# (see #transient_failures) contribute nothing here, so their tools must not be deleted.
|
|
25
|
-
def info_array
|
|
26
|
-
return @info_array if @info_array
|
|
27
|
-
|
|
28
|
-
@transient_failures = []
|
|
29
|
-
@info_array = @firestore.toolinfo.map do |url|
|
|
30
|
-
next unless url
|
|
31
|
-
|
|
32
|
-
tools_from(url)
|
|
33
|
-
rescue Icarus::Mod::Tools::Sync::RequestFailed => e
|
|
34
|
-
@transient_failures << url if e.transient?
|
|
35
|
-
warn "Skipped; Failed to retrieve #{url}#{' (transient; its existing entries are kept)' if e.transient?}"
|
|
36
|
-
next
|
|
37
|
-
rescue JSON::ParserError => e
|
|
38
|
-
@transient_failures << url
|
|
39
|
-
warn Paint["WARNING: Skipped; Invalid JSON in #{url}: #{e.message}", :red, :bright]
|
|
40
|
-
warn Paint["WARNING: Existing entries from #{url} are kept until it parses again; " \
|
|
41
|
-
"remove or rename the file to remove them", :red, :bright]
|
|
42
|
-
next
|
|
43
|
-
end.flatten.compact.uniq { |tool| [tool.name, tool.author] }
|
|
44
|
-
end
|
|
45
|
-
|
|
46
|
-
# The toolinfo URLs that could not be read this run for a reason that may clear up
|
|
47
|
-
# (network error, 5xx, rate limit, invalid JSON). Gone (404/410) URLs are not included.
|
|
48
|
-
def transient_failures
|
|
49
|
-
info_array
|
|
50
|
-
@transient_failures || []
|
|
51
|
-
end
|
|
52
|
-
|
|
53
|
-
def find(toolinfo)
|
|
54
|
-
@firestore.find_by_type(type: "tools", name: toolinfo.name, author: toolinfo.author)&.id
|
|
55
|
-
end
|
|
56
|
-
|
|
57
|
-
def find_info(toolinfo)
|
|
58
|
-
@info_array.find { |tool| tool.name == toolinfo.name && tool.author == toolinfo.author }
|
|
59
|
-
end
|
|
60
|
-
|
|
61
|
-
def update(toolinfo)
|
|
62
|
-
success = @firestore.update(:tool, toolinfo, merge: false)
|
|
63
|
-
@firestore.record_source(:tools, toolinfo.id, toolinfo.source_url) if success && toolinfo.source_url
|
|
64
|
-
|
|
65
|
-
success
|
|
66
|
-
end
|
|
67
|
-
|
|
68
|
-
# doc ID => toolinfo URL it was last synced from (see Firestore#sources)
|
|
69
|
-
def sources
|
|
70
|
-
@firestore.sources(:tools)
|
|
71
|
-
end
|
|
72
|
-
|
|
73
|
-
def save_sources
|
|
74
|
-
@firestore.save_sources(:tools)
|
|
75
|
-
end
|
|
76
|
-
|
|
77
|
-
def delete(toolinfo)
|
|
78
|
-
@firestore.delete(:tool, toolinfo)
|
|
79
|
-
end
|
|
80
|
-
|
|
81
|
-
private
|
|
82
|
-
|
|
83
|
-
def tools_from(url)
|
|
84
|
-
tools = retrieve_from_url(url)[:tools]
|
|
85
|
-
raise JSON::ParserError, "no 'tools' array" unless tools.is_a?(Array)
|
|
86
|
-
|
|
87
|
-
tools.filter_map do |data|
|
|
88
|
-
next unless /[a-z0-9]+/i.match?(data[:name])
|
|
89
|
-
|
|
90
|
-
Icarus::Mod::Tools::Toolinfo.new(data).tap { |tool| tool.source_url = url }
|
|
91
|
-
end
|
|
92
|
-
end
|
|
93
18
|
end
|
|
94
19
|
end
|
|
95
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.1.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Donovan Young
|
|
@@ -15,28 +15,42 @@ dependencies:
|
|
|
15
15
|
requirements:
|
|
16
16
|
- - "~>"
|
|
17
17
|
- !ruby/object:Gem::Version
|
|
18
|
-
version: '
|
|
18
|
+
version: '3.3'
|
|
19
19
|
type: :runtime
|
|
20
20
|
prerelease: false
|
|
21
21
|
version_requirements: !ruby/object:Gem::Requirement
|
|
22
22
|
requirements:
|
|
23
23
|
- - "~>"
|
|
24
24
|
- !ruby/object:Gem::Version
|
|
25
|
-
version: '
|
|
25
|
+
version: '3.3'
|
|
26
26
|
- !ruby/object:Gem::Dependency
|
|
27
27
|
name: octokit
|
|
28
28
|
requirement: !ruby/object:Gem::Requirement
|
|
29
29
|
requirements:
|
|
30
30
|
- - "~>"
|
|
31
31
|
- !ruby/object:Gem::Version
|
|
32
|
-
version: '
|
|
32
|
+
version: '10.0'
|
|
33
33
|
type: :runtime
|
|
34
34
|
prerelease: false
|
|
35
35
|
version_requirements: !ruby/object:Gem::Requirement
|
|
36
36
|
requirements:
|
|
37
37
|
- - "~>"
|
|
38
38
|
- !ruby/object:Gem::Version
|
|
39
|
-
version: '
|
|
39
|
+
version: '10.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:
|
|
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
|