Icarus-Mod-Tools 1.8.0 → 1.8.2
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 +7 -1
- data/CHANGES.md +14 -4
- data/Gemfile.lock +6 -6
- data/README.md +24 -0
- data/lib/icarus/mod/cli/add.rb +8 -0
- data/lib/icarus/mod/cli/list.rb +55 -43
- data/lib/icarus/mod/cli/sync.rb +75 -133
- data/lib/icarus/mod/cli/validate.rb +34 -21
- data/lib/icarus/mod/firestore.rb +5 -5
- data/lib/icarus/mod/tools/baseinfo.rb +26 -6
- data/lib/icarus/mod/tools/proginfo.rb +6 -0
- data/lib/icarus/mod/tools/sync/helpers.rb +26 -0
- data/lib/icarus/mod/tools/sync/modinfo.rb +58 -0
- data/lib/icarus/mod/tools/sync/mods.rb +53 -0
- data/lib/icarus/mod/tools/sync/proginfo.rb +58 -0
- data/lib/icarus/mod/tools/sync/progs.rb +53 -0
- data/lib/icarus/mod/tools/validator.rb +23 -0
- data/lib/icarus/mod/version.rb +1 -1
- metadata +8 -8
- data/lib/icarus/mod/tools/mod_sync.rb +0 -51
- data/lib/icarus/mod/tools/modinfo_sync.rb +0 -56
- data/lib/icarus/mod/tools/modinfo_validate.rb +0 -16
- data/lib/icarus/mod/tools/prog_sync.rb +0 -51
- data/lib/icarus/mod/tools/proginfo_sync.rb +0 -56
- data/lib/icarus/mod/tools/sync_helpers.rb +0 -24
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 63aa634da9108a8b439681f4bce95519bd04ba0e2cc416c5c2632502e8aa3c35
|
|
4
|
+
data.tar.gz: dce88dc6da4c3c43199973de099c7a578641ce03082bbac2a8943fcd69e6aa40
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 030db22ed72e78fec9a03a6f5412d35143492cd19080095b59efcafb47feb3db78b4a5cafc04edc1880e626f30d6127d35a470a7998ffe4403873672bf4002d0
|
|
7
|
+
data.tar.gz: 025040c5268bc151ea186573fb21dc083c51d4e9a5b5666fad8c988642aabbe4fe515fb882fe4ba0c03500357a8ea37cd868cfe1f1b5dc25c1f4456066f8d4d2
|
data/.rubocop.yml
CHANGED
|
@@ -38,11 +38,17 @@ Metrics/AbcSize:
|
|
|
38
38
|
Exclude:
|
|
39
39
|
- lib/icarus/mod/cli/*.rb # Thor command files
|
|
40
40
|
|
|
41
|
+
Metrics/BlockLength:
|
|
42
|
+
Enabled: false
|
|
43
|
+
|
|
41
44
|
Metrics/ClassLength:
|
|
42
45
|
Enabled: false
|
|
43
46
|
|
|
44
47
|
Metrics/MethodLength:
|
|
45
|
-
|
|
48
|
+
Enabled: false
|
|
49
|
+
|
|
50
|
+
Naming/BlockForwarding:
|
|
51
|
+
EnforcedStyle: explicit
|
|
46
52
|
|
|
47
53
|
RSpec/MultipleMemoizedHelpers:
|
|
48
54
|
Enabled: false
|
data/CHANGES.md
CHANGED
|
@@ -4,19 +4,29 @@ All notable changes to this project will be documented in this file.
|
|
|
4
4
|
|
|
5
5
|
## History (reverse chronological order)
|
|
6
6
|
|
|
7
|
-
### v1.
|
|
7
|
+
### v1.8 - 2023-01-27
|
|
8
|
+
|
|
9
|
+
- Added support for `proginfo.json` files
|
|
10
|
+
- Refactored to better utilize caching
|
|
11
|
+
|
|
12
|
+
### v1.7 - 2023-01-20
|
|
13
|
+
|
|
14
|
+
- Added `validation` command
|
|
15
|
+
- Added `--dry-run` to `sync` commands
|
|
16
|
+
|
|
17
|
+
### v1.6 - 2023-01-15
|
|
8
18
|
|
|
9
19
|
- Added `--check` to `sync mods` to check for updates without downloading
|
|
10
20
|
- Added support for `readmeURL` in `modinfo.json`
|
|
11
21
|
|
|
12
|
-
### v1.5 - 2023-08
|
|
22
|
+
### v1.5 - 2023-01-08
|
|
13
23
|
|
|
14
24
|
- Moved source into the DonovanMods Github organization
|
|
15
25
|
- Added `long_description` to `modinfo.json`
|
|
16
26
|
- Added `imageURL` to `modinfo.json`
|
|
17
27
|
- bugfixes
|
|
18
28
|
|
|
19
|
-
### v1.4 - 2023-03
|
|
29
|
+
### v1.4 - 2023-01-03
|
|
20
30
|
|
|
21
31
|
**BREAKING CHANGES!**
|
|
22
32
|
|
|
@@ -25,7 +35,7 @@ You'll need to move your ENV variables to a config file. See the README for more
|
|
|
25
35
|
- Read configuration from `~/.imtconfig.json`
|
|
26
36
|
- bugfixes
|
|
27
37
|
|
|
28
|
-
### v1.3 - 2023-02
|
|
38
|
+
### v1.3 - 2023-01-02
|
|
29
39
|
|
|
30
40
|
- First public release
|
|
31
41
|
- Added sorting and filtering to the `list mods` command
|
data/Gemfile.lock
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
Icarus-Mod-Tools (1.8.
|
|
4
|
+
Icarus-Mod-Tools (1.8.2)
|
|
5
5
|
google-cloud-firestore (~> 2.7)
|
|
6
6
|
octokit (~> 6.0)
|
|
7
7
|
paint (~> 2.3)
|
|
@@ -14,7 +14,7 @@ GEM
|
|
|
14
14
|
public_suffix (>= 2.0.2, < 6.0)
|
|
15
15
|
ast (2.4.2)
|
|
16
16
|
coderay (1.1.3)
|
|
17
|
-
concurrent-ruby (1.
|
|
17
|
+
concurrent-ruby (1.2.0)
|
|
18
18
|
diff-lcs (1.5.0)
|
|
19
19
|
faraday (2.7.4)
|
|
20
20
|
faraday-net_http (>= 2.0, < 3.1)
|
|
@@ -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.9.0)
|
|
42
42
|
concurrent-ruby (~> 1.0)
|
|
43
43
|
google-cloud-core (~> 1.5)
|
|
44
44
|
google-cloud-firestore-v1 (~> 0.0)
|
|
@@ -65,10 +65,10 @@ GEM
|
|
|
65
65
|
multi_json (~> 1.11)
|
|
66
66
|
os (>= 0.9, < 2.0)
|
|
67
67
|
signet (>= 0.16, < 2.a)
|
|
68
|
-
grpc (1.
|
|
68
|
+
grpc (1.51.0-x86_64-darwin)
|
|
69
69
|
google-protobuf (~> 3.21)
|
|
70
70
|
googleapis-common-protos-types (~> 1.0)
|
|
71
|
-
grpc (1.
|
|
71
|
+
grpc (1.51.0-x86_64-linux)
|
|
72
72
|
google-protobuf (~> 3.21)
|
|
73
73
|
googleapis-common-protos-types (~> 1.0)
|
|
74
74
|
guard (2.18.0)
|
|
@@ -131,7 +131,7 @@ GEM
|
|
|
131
131
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
132
132
|
rspec-support (~> 3.12.0)
|
|
133
133
|
rspec-support (3.12.0)
|
|
134
|
-
rubocop (1.
|
|
134
|
+
rubocop (1.44.1)
|
|
135
135
|
json (~> 2.3)
|
|
136
136
|
parallel (~> 1.10)
|
|
137
137
|
parser (>= 3.2.0.0)
|
data/README.md
CHANGED
|
@@ -52,9 +52,17 @@ imt [options] [command]
|
|
|
52
52
|
### Commands
|
|
53
53
|
|
|
54
54
|
```sh
|
|
55
|
+
Commands:
|
|
55
56
|
imt add # Adds entries to the databases
|
|
57
|
+
imt help [COMMAND] # Describe available commands or one specific command
|
|
56
58
|
imt list # Lists the databases
|
|
57
59
|
imt sync # Syncs the databases
|
|
60
|
+
imt validate # Validates various entries
|
|
61
|
+
|
|
62
|
+
Options:
|
|
63
|
+
-C, [--config=CONFIG] # Path to the config file
|
|
64
|
+
# Default: /Users/dyoung/.imtconfig.json
|
|
65
|
+
-V, [--version], [--no-version] # Print the version and exit
|
|
58
66
|
```
|
|
59
67
|
|
|
60
68
|
#### `imt add`
|
|
@@ -63,9 +71,13 @@ imt [options] [command]
|
|
|
63
71
|
Commands:
|
|
64
72
|
imt add help [COMMAND] # Describe subcommands or one specific subcommand
|
|
65
73
|
imt add modinfo # Adds an entry to 'meta/modinfo/list'
|
|
74
|
+
imt add proginfo # Adds an entry to 'meta/proginfo/list'
|
|
66
75
|
imt add repos # Adds an entry to 'meta/repos/list'
|
|
67
76
|
|
|
68
77
|
Options:
|
|
78
|
+
-C, [--config=CONFIG] # Path to the config file
|
|
79
|
+
# Default: /Users/dyoung/.imtconfig.json
|
|
80
|
+
-V, [--version], [--no-version] # Print the version and exit
|
|
69
81
|
-v, [--verbose], [--no-verbose] # Increase verbosity. May be repeated for even more verbosity.
|
|
70
82
|
# Default: [true]
|
|
71
83
|
```
|
|
@@ -77,9 +89,14 @@ Commands:
|
|
|
77
89
|
imt list help [COMMAND] # Describe subcommands or one specific subcommand
|
|
78
90
|
imt list modinfo # Displays data from 'meta/modinfo/list'
|
|
79
91
|
imt list mods # Displays data from 'mods'
|
|
92
|
+
imt list proginfo # Displays data from 'meta/proginfo/list'
|
|
93
|
+
imt list progs # Displays data from 'progs'
|
|
80
94
|
imt list repos # Displays data from 'meta/repos/list'
|
|
81
95
|
|
|
82
96
|
Options:
|
|
97
|
+
-C, [--config=CONFIG] # Path to the config file
|
|
98
|
+
# Default: /Users/dyoung/.imtconfig.json
|
|
99
|
+
-V, [--version], [--no-version] # Print the version and exit
|
|
83
100
|
-v, [--verbose], [--no-verbose] # Increase verbosity. May be repeated for even more verbosity.
|
|
84
101
|
# Default: [true]
|
|
85
102
|
```
|
|
@@ -88,13 +105,20 @@ Options:
|
|
|
88
105
|
|
|
89
106
|
```sh
|
|
90
107
|
Commands:
|
|
108
|
+
imt sync all # Run all sync jobs
|
|
91
109
|
imt sync help [COMMAND] # Describe subcommands or one specific subcommand
|
|
92
110
|
imt sync modinfo # Reads from 'meta/repos/list' and Syncs any modinfo files we find (github only for now)
|
|
93
111
|
imt sync mods # Reads from 'meta/modinfo/list' and updates the 'mods' database accordingly
|
|
112
|
+
imt sync proginfo # Reads from 'meta/repos/list' and Syncs any proginfo files we find (github only for now)
|
|
113
|
+
imt sync progs # Reads from 'meta/proginfo/list' and updates the 'progs' database accordingly
|
|
94
114
|
|
|
95
115
|
Options:
|
|
116
|
+
-C, [--config=CONFIG] # Path to the config file
|
|
117
|
+
# Default: /Users/dyoung/.imtconfig.json
|
|
118
|
+
-V, [--version], [--no-version] # Print the version and exit
|
|
96
119
|
-v, [--verbose], [--no-verbose] # Increase verbosity. May be repeated for even more verbosity.
|
|
97
120
|
# Default: [true]
|
|
121
|
+
[--dry-run], [--no-dry-run] # Dry run (no changes will be made)
|
|
98
122
|
```
|
|
99
123
|
|
|
100
124
|
## Development
|
data/lib/icarus/mod/cli/add.rb
CHANGED
|
@@ -15,6 +15,14 @@ module Icarus
|
|
|
15
15
|
puts firestore.update(:modinfo, payload, merge: true) ? "Success" : "Failure"
|
|
16
16
|
end
|
|
17
17
|
|
|
18
|
+
desc "proginfo", "Adds an entry to 'meta/proginfo/list'"
|
|
19
|
+
def proginfo(item)
|
|
20
|
+
firestore = Firestore.new
|
|
21
|
+
payload = [firestore.list(:proginfo), item].flatten.compact
|
|
22
|
+
|
|
23
|
+
puts firestore.update(:proginfo, payload, merge: true) ? "Success" : "Failure"
|
|
24
|
+
end
|
|
25
|
+
|
|
18
26
|
desc "repos", "Adds an entry to 'meta/repos/list'"
|
|
19
27
|
def repos(item)
|
|
20
28
|
firestore = Firestore.new
|
data/lib/icarus/mod/cli/list.rb
CHANGED
|
@@ -33,63 +33,75 @@ module Icarus
|
|
|
33
33
|
method_option :sort, type: :string, default: "name", desc: "Sort by field (name, author, etc.)"
|
|
34
34
|
method_option :filter, type: :array, default: [], desc: "Filter by field (name, author, etc.)"
|
|
35
35
|
def mods
|
|
36
|
-
|
|
36
|
+
list_for_type(:mods)
|
|
37
|
+
end
|
|
37
38
|
|
|
38
|
-
|
|
39
|
+
desc "progs", "Displays data from 'progs'"
|
|
40
|
+
method_option :sort, type: :string, default: "name", desc: "Sort by field (name, author, etc.)"
|
|
41
|
+
method_option :filter, type: :array, default: [], desc: "Filter by field (name, author, etc.)"
|
|
42
|
+
def progs
|
|
43
|
+
list_for_type(:progs)
|
|
44
|
+
end
|
|
39
45
|
|
|
40
|
-
|
|
46
|
+
no_commands do
|
|
47
|
+
def list_for_type(type)
|
|
48
|
+
klass = type == :mods ? Icarus::Mod::Tools::Modinfo : Icarus::Mod::Tools::Proginfo
|
|
49
|
+
valid_keys = klass::HASHKEYS + [:updated_at]
|
|
50
|
+
sort_field = options[:sort]&.to_sym
|
|
51
|
+
filter = !options[:filter].empty?
|
|
41
52
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
53
|
+
if filter
|
|
54
|
+
filter_field = options[:filter].first&.to_sym
|
|
55
|
+
filter_value = options[:filter].last&.to_s
|
|
45
56
|
|
|
46
|
-
|
|
57
|
+
raise Icarus::Mod::Tools::Error, "Invalid filter option #{options[:filter]}" unless options[:filter].empty? || options[:filter]&.count == 2
|
|
47
58
|
|
|
48
|
-
|
|
49
|
-
|
|
59
|
+
raise Icarus::Mod::Tools::Error, "Invalid filter field '#{filter_field}'" unless filter_field && valid_keys.include?(filter_field)
|
|
60
|
+
end
|
|
50
61
|
|
|
51
|
-
|
|
62
|
+
raise Icarus::Mod::Tools::Error, "Invalid sort field '#{sort_field}'" unless valid_keys.include?(sort_field)
|
|
52
63
|
|
|
53
|
-
|
|
54
|
-
|
|
64
|
+
puts "Sorted by #{sort_field}" if sort_field && verbose > 2
|
|
65
|
+
puts "Filtered by #{filter_field} = #{filter_value}" if filter_field && verbose > 2
|
|
55
66
|
|
|
56
|
-
|
|
67
|
+
items = Firestore.new.list(type)
|
|
57
68
|
|
|
58
|
-
|
|
59
|
-
|
|
69
|
+
# Filter by field
|
|
70
|
+
items.select! { |item| item.send(filter_field).downcase =~ /#{filter_value&.downcase}/ } if filter_field
|
|
60
71
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
72
|
+
if items.empty?
|
|
73
|
+
puts "no entries found" if verbose?
|
|
74
|
+
return
|
|
75
|
+
end
|
|
65
76
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
if verbose?
|
|
70
|
-
puts format(
|
|
71
|
-
header_format,
|
|
72
|
-
name: "NAME",
|
|
73
|
-
author: "AUTHOR",
|
|
74
|
-
version: "VERSION",
|
|
75
|
-
updated_at: "LAST UPDATED",
|
|
76
|
-
id: "ID",
|
|
77
|
-
description: "DESCRIPTION"
|
|
78
|
-
)
|
|
79
|
-
end
|
|
77
|
+
header_format = "%-<name>50s %-<author>20s %-<version>10s %-<updated_at>20s"
|
|
78
|
+
header_format += " %-<id>20s %<description>s" if verbose > 1
|
|
80
79
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
80
|
+
if verbose?
|
|
81
|
+
puts format(
|
|
82
|
+
header_format,
|
|
83
|
+
name: "NAME",
|
|
84
|
+
author: "AUTHOR",
|
|
85
|
+
version: "VERSION",
|
|
86
|
+
updated_at: "LAST UPDATED",
|
|
87
|
+
id: "ID",
|
|
88
|
+
description: "DESCRIPTION"
|
|
89
|
+
)
|
|
90
|
+
end
|
|
85
91
|
|
|
86
|
-
|
|
87
|
-
|
|
92
|
+
# Sort by field, optionally subsorting by name
|
|
93
|
+
(sort_field == :name ? items.sort_by(&:name) : items.sort_by { |item| [item.send(sort_field), item.name] }).each do |item|
|
|
94
|
+
data_format = "%-<name>50s %-<author>20s v%-<version>10s%-<updated_at>20s"
|
|
95
|
+
data_format += " %-<id>20s %<description>s" if verbose > 1
|
|
88
96
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
97
|
+
puts format(data_format, item.to_h.merge(id: item.id, updated_at: item.updated_at.strftime("%Y-%m-%d %H:%M:%S")))
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
puts "Total: #{items.count}" if verbose?
|
|
101
|
+
rescue Icarus::Mod::Tools::Error => e
|
|
102
|
+
puts e.message
|
|
103
|
+
exit 1
|
|
104
|
+
end
|
|
93
105
|
end
|
|
94
106
|
end
|
|
95
107
|
end
|
data/lib/icarus/mod/cli/sync.rb
CHANGED
|
@@ -1,15 +1,18 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require "tools/
|
|
4
|
-
require "tools/
|
|
5
|
-
require "tools/
|
|
6
|
-
require "tools/
|
|
3
|
+
require "tools/sync/modinfo"
|
|
4
|
+
require "tools/sync/proginfo"
|
|
5
|
+
require "tools/sync/mods"
|
|
6
|
+
require "tools/sync/progs"
|
|
7
7
|
|
|
8
8
|
module Icarus
|
|
9
9
|
module Mod
|
|
10
10
|
module CLI
|
|
11
11
|
# Sync CLI command definitions
|
|
12
|
+
# rubocop:disable Style/GlobalVars
|
|
12
13
|
class Sync < SubcommandBase
|
|
14
|
+
$firestore = nil
|
|
15
|
+
|
|
13
16
|
class_option :dry_run, type: :boolean, default: false, desc: "Dry run (no changes will be made)"
|
|
14
17
|
|
|
15
18
|
desc "all", "Run all sync jobs"
|
|
@@ -22,178 +25,117 @@ module Icarus
|
|
|
22
25
|
|
|
23
26
|
desc "modinfo", "Reads from 'meta/repos/list' and Syncs any modinfo files we find (github only for now)"
|
|
24
27
|
def modinfo
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
puts "Retrieving repository Data..." if verbose?
|
|
28
|
-
repositories = modinfo_sync.repositories
|
|
29
|
-
|
|
30
|
-
raise Icarus::Mod::Tools::Error, "Unable to find any repositories!" unless repositories.any?
|
|
31
|
-
|
|
32
|
-
puts "Retrieving modinfo Array..." if verbose?
|
|
33
|
-
modinfo_array = modinfo_sync.modinfo_data(repositories, verbose: verbose > 1)&.map(&:download_url)&.compact
|
|
34
|
-
|
|
35
|
-
raise Icarus::Mod::Tools::Error, "No modinfo.json files found" unless modinfo_array&.any?
|
|
36
|
-
|
|
37
|
-
if options[:dry_run]
|
|
38
|
-
puts "Dry run; no changes will be made"
|
|
39
|
-
return
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
puts "Saving to Firestore..." if verbose?
|
|
43
|
-
response = modinfo_sync.update(modinfo_array)
|
|
44
|
-
puts response ? "Success" : "Failure (may be no changes)" if verbose?
|
|
45
|
-
rescue Icarus::Mod::Tools::Error => e
|
|
46
|
-
warn e.message
|
|
28
|
+
sync_info(:modinfo)
|
|
47
29
|
end
|
|
48
30
|
|
|
49
31
|
desc "proginfo", "Reads from 'meta/repos/list' and Syncs any proginfo files we find (github only for now)"
|
|
50
32
|
def proginfo
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
puts "Retrieving repository Data..." if verbose?
|
|
54
|
-
repositories = proginfo_sync.repositories
|
|
55
|
-
|
|
56
|
-
raise Icarus::Mod::Tools::Error, "Unable to find any repositories!" unless repositories.any?
|
|
57
|
-
|
|
58
|
-
puts "Retrieving proginfo Array..." if verbose?
|
|
59
|
-
proginfo_array = proginfo_sync.proginfo_data(repositories, verbose: verbose > 1)&.map(&:download_url)&.compact
|
|
60
|
-
|
|
61
|
-
raise Icarus::Mod::Tools::Error, "no proginfo.json files found" unless proginfo_array&.any?
|
|
62
|
-
|
|
63
|
-
if options[:dry_run]
|
|
64
|
-
puts "Dry run; no changes will be made"
|
|
65
|
-
return
|
|
66
|
-
end
|
|
67
|
-
|
|
68
|
-
puts "Saving to Firestore..." if verbose?
|
|
69
|
-
response = proginfo_sync.update(proginfo_array)
|
|
70
|
-
puts response ? "Success" : "Failure (may be no changes)" if verbose?
|
|
71
|
-
rescue Icarus::Mod::Tools::Error => e
|
|
72
|
-
warn e.message
|
|
33
|
+
sync_info(:proginfo)
|
|
73
34
|
end
|
|
74
35
|
|
|
75
36
|
desc "mods", "Reads from 'meta/modinfo/list' and updates the 'mods' database accordingly"
|
|
76
37
|
method_option :check, type: :boolean, default: false, desc: "Validate modinfo without applying changes"
|
|
77
38
|
def mods
|
|
78
|
-
|
|
39
|
+
sync_list(:mods)
|
|
40
|
+
end
|
|
79
41
|
|
|
80
|
-
|
|
81
|
-
|
|
42
|
+
desc "progs", "Reads from 'meta/proginfo/list' and updates the 'progs' database accordingly"
|
|
43
|
+
method_option :check, type: :boolean, default: false, desc: "Validate proginfo without applying changes"
|
|
44
|
+
def progs
|
|
45
|
+
sync_list(:progs)
|
|
46
|
+
end
|
|
82
47
|
|
|
83
|
-
|
|
84
|
-
|
|
48
|
+
no_commands do
|
|
49
|
+
def firestore
|
|
50
|
+
$firestore ||= Firestore.new
|
|
51
|
+
end
|
|
85
52
|
|
|
86
|
-
|
|
53
|
+
def sync_info(type)
|
|
54
|
+
sync = (type == :modinfo ? Icarus::Mod::Tools::Sync::Modinfo : Icarus::Mod::Tools::Sync::Proginfo).new(client: firestore)
|
|
87
55
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
verb = "Creating"
|
|
56
|
+
puts "Retrieving repository Data..." if verbose?
|
|
57
|
+
repositories = sync.repositories
|
|
91
58
|
|
|
92
|
-
|
|
93
|
-
warn "Skipping mod #{mod.uniq_name} due to validation errors" && next unless mod.validate
|
|
59
|
+
raise Icarus::Mod::Tools::Error, "Unable to find any repositories!" unless repositories.any?
|
|
94
60
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
puts "Found existing mod #{mod.name} at #{doc_id}" if verbose > 2
|
|
98
|
-
mod.id = doc_id
|
|
99
|
-
verb = "Updating"
|
|
100
|
-
end
|
|
61
|
+
puts "Retrieving Info Array..." if verbose?
|
|
62
|
+
info_array = sync.data(repositories, verbose: verbose > 1)&.map(&:download_url)&.compact
|
|
101
63
|
|
|
102
|
-
|
|
64
|
+
raise Icarus::Mod::Tools::Error, "no .json files found for #{type}" unless info_array&.any?
|
|
103
65
|
|
|
104
66
|
if options[:dry_run]
|
|
105
|
-
puts "Dry run; no changes will be made"
|
|
106
|
-
|
|
67
|
+
puts "Dry run; no changes will be made"
|
|
68
|
+
return
|
|
107
69
|
end
|
|
108
70
|
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
puts "Dry run; no changes will be made" if verbose?
|
|
115
|
-
return
|
|
71
|
+
puts "Saving to Firestore..." if verbose?
|
|
72
|
+
response = sync.update(info_array)
|
|
73
|
+
puts response ? "Success" : "Failure (may be no changes)" if verbose?
|
|
74
|
+
rescue Icarus::Mod::Tools::Error => e
|
|
75
|
+
warn e.message
|
|
116
76
|
end
|
|
117
77
|
|
|
118
|
-
|
|
78
|
+
def sync_list(type)
|
|
79
|
+
sync = (type == :mods ? Icarus::Mod::Tools::Sync::Mods : Icarus::Mod::Tools::Sync::Progs).new(client: firestore)
|
|
119
80
|
|
|
120
|
-
|
|
81
|
+
puts "Retrieving Info Data..." if verbose?
|
|
82
|
+
info_array = sync.info_array
|
|
121
83
|
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
puts "Deleting outdated mods..." if verbose?
|
|
125
|
-
delete_array.each do |mod|
|
|
126
|
-
print format("Deleting %-<name>60s", name: "'#{mod.author || "NoOne"}/#{mod.name || "Unnamed'"}") if verbose > 1
|
|
127
|
-
response = modsync.delete(mod)
|
|
128
|
-
puts format("%<status>10s", status: response ? "Success" : "Failure") if verbose > 1
|
|
129
|
-
end
|
|
130
|
-
|
|
131
|
-
puts "Deleted #{delete_array.count} outdated mods" if verbose?
|
|
132
|
-
rescue Icarus::Mod::Tools::Error => e
|
|
133
|
-
warn e.message
|
|
134
|
-
end
|
|
84
|
+
puts "Retrieving List Data..." if verbose?
|
|
85
|
+
list_array = sync.send(type)
|
|
135
86
|
|
|
136
|
-
|
|
137
|
-
method_option :check, type: :boolean, default: false, desc: "Validate proginfo without applying changes"
|
|
138
|
-
def progs
|
|
139
|
-
progsync = Icarus::Mod::Tools::ProgSync.new
|
|
87
|
+
return if options[:check]
|
|
140
88
|
|
|
141
|
-
|
|
142
|
-
|
|
89
|
+
puts "Updating List Data..." if verbose?
|
|
90
|
+
info_array.each do |list|
|
|
91
|
+
verb = "Creating"
|
|
143
92
|
|
|
144
|
-
|
|
145
|
-
|
|
93
|
+
puts "Validating Info Data for #{list.uniq_name}..." if verbose > 2
|
|
94
|
+
warn "Skipping List #{list.uniq_name} due to validation errors" && next unless list.valid?
|
|
146
95
|
|
|
147
|
-
|
|
96
|
+
doc_id = sync.find(list)
|
|
97
|
+
if doc_id
|
|
98
|
+
puts "Found existing list #{list.name} at #{doc_id}" if verbose > 2
|
|
99
|
+
list.id = doc_id
|
|
100
|
+
verb = "Updating"
|
|
101
|
+
end
|
|
148
102
|
|
|
149
|
-
|
|
150
|
-
proginfo_array.each do |prog|
|
|
151
|
-
verb = "Creating"
|
|
103
|
+
print format("#{verb} %-<name>60s", name: "'#{list.author || "NoOne"}/#{list.name || "Unnamed"}'") if verbose > 1
|
|
152
104
|
|
|
153
|
-
|
|
154
|
-
|
|
105
|
+
if options[:dry_run]
|
|
106
|
+
puts "Dry run; no changes will be made" if verbose > 1
|
|
107
|
+
next
|
|
108
|
+
end
|
|
155
109
|
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
puts "Found existing program #{prog.name} at #{doc_id}" if verbose > 2
|
|
159
|
-
prog.id = doc_id
|
|
160
|
-
verb = "Updating"
|
|
110
|
+
response = sync.update(list)
|
|
111
|
+
puts format("%<status>10s", status: response ? "Success" : "Failure") if verbose > 1
|
|
161
112
|
end
|
|
162
113
|
|
|
163
|
-
print format("#{verb} %-<name>60s", name: "'#{prog.author || "NoOne"}/#{prog.name || "Unnamed"}'") if verbose > 1
|
|
164
|
-
|
|
165
114
|
if options[:dry_run]
|
|
166
|
-
puts "Dry run; no changes will be made" if verbose
|
|
167
|
-
|
|
115
|
+
puts "Dry run; no changes will be made" if verbose?
|
|
116
|
+
return
|
|
168
117
|
end
|
|
169
118
|
|
|
170
|
-
|
|
171
|
-
puts format("%<status>10s", status: response ? "Success" : "Failure") if verbose > 1
|
|
172
|
-
end
|
|
119
|
+
puts "Created/Updated #{info_array.count} Items" if verbose?
|
|
173
120
|
|
|
174
|
-
|
|
175
|
-
puts "Dry run; no changes will be made" if verbose?
|
|
176
|
-
return
|
|
177
|
-
end
|
|
178
|
-
|
|
179
|
-
puts "Created/Updated #{proginfo_array.count} Programs" if verbose?
|
|
121
|
+
delete_array = list_array.filter { |list| sync.find_info(list).nil? }
|
|
180
122
|
|
|
181
|
-
|
|
123
|
+
return unless delete_array.any?
|
|
182
124
|
|
|
183
|
-
|
|
125
|
+
puts "Deleting outdated items..." if verbose?
|
|
126
|
+
delete_array.each do |list|
|
|
127
|
+
print format("Deleting %-<name>60s", name: "'#{list.author || "NoOne"}/#{list.name || "Unnamed'"}") if verbose > 1
|
|
128
|
+
response = sync.delete(list)
|
|
129
|
+
puts format("%<status>10s", status: response ? "Success" : "Failure") if verbose > 1
|
|
130
|
+
end
|
|
184
131
|
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
response = progsync.delete(prog)
|
|
189
|
-
puts format("%<status>10s", status: response ? "Success" : "Failure") if verbose > 1
|
|
132
|
+
puts "Deleted #{delete_array.count} outdated items" if verbose?
|
|
133
|
+
rescue Icarus::Mod::Tools::Error => e
|
|
134
|
+
warn e.message
|
|
190
135
|
end
|
|
191
|
-
|
|
192
|
-
puts "Deleted #{delete_array.count} outdated programs" if verbose?
|
|
193
|
-
rescue Icarus::Mod::Tools::Error => e
|
|
194
|
-
warn e.message
|
|
195
136
|
end
|
|
196
137
|
end
|
|
138
|
+
# rubocop:enable Style/GlobalVars
|
|
197
139
|
end
|
|
198
140
|
end
|
|
199
141
|
end
|