Icarus-Mod-Tools 2.5.2 → 2.6.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/CHANGELOG.md +9 -0
- data/Gemfile.lock +1 -1
- data/lib/icarus/mod/cli/sync.rb +52 -0
- data/lib/icarus/mod/tools/sync/mods.rb +1 -1
- data/lib/icarus/mod/tools/sync/tools.rb +1 -1
- data/lib/icarus/mod/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: f02e414cd84c6117e8ff650a1048c16eac751dae9cfe99a52a17a3e58682d1b0
|
|
4
|
+
data.tar.gz: f14a5bf74a4fcd74be9c71aba1debf378d45af6bc54290b35c2d20236e17d3af
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 636dfd397c992d7dd15d464584734f7e599417e1145f0cf139ffcf2f8eec9e409b473c4deae9abae453a42abbfe1f04138b36440669ead6db5c4386b6e33b4ca
|
|
7
|
+
data.tar.gz: b5085429a592dfc1bd8bbf0fde991ade384afcd88aedd50c6f0969a8a786b4c3e98c740fda3053aa48c52ea734dfe74381d2d8797dde0b0e563abc467ec3e75d
|
data/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,15 @@ All notable changes to this project will be documented in this file.
|
|
|
4
4
|
|
|
5
5
|
## History (reverse chronological order)
|
|
6
6
|
|
|
7
|
+
### v2.6.0 - 2026-03-04
|
|
8
|
+
|
|
9
|
+
- Add `imt sync cleanup` command to remove duplicate entries from mods and tools collections
|
|
10
|
+
- Groups entries by name+author and keeps the most recently updated
|
|
11
|
+
- Supports `--dry-run` to preview what would be deleted
|
|
12
|
+
- Fix `find_info` to match by both name AND author, not just name
|
|
13
|
+
- Previously, mods/tools with the same name but different authors could cause incorrect deletion logic
|
|
14
|
+
- Now consistent with `info_array` deduplication and `find_by_type` lookups
|
|
15
|
+
|
|
7
16
|
### v2.5.2 - 2026-02-09
|
|
8
17
|
|
|
9
18
|
- Fix duplicate entries created during sync operations
|
data/Gemfile.lock
CHANGED
data/lib/icarus/mod/cli/sync.rb
CHANGED
|
@@ -52,11 +52,63 @@ module Icarus
|
|
|
52
52
|
sync_list(:tools)
|
|
53
53
|
end
|
|
54
54
|
|
|
55
|
+
desc "cleanup", "Remove duplicate entries from mods and tools collections"
|
|
56
|
+
def cleanup
|
|
57
|
+
cleanup_duplicates(:mods)
|
|
58
|
+
cleanup_duplicates(:tools)
|
|
59
|
+
end
|
|
60
|
+
|
|
55
61
|
no_commands do
|
|
56
62
|
def firestore
|
|
57
63
|
$firestore ||= Firestore.new
|
|
58
64
|
end
|
|
59
65
|
|
|
66
|
+
def cleanup_duplicates(type)
|
|
67
|
+
singular_type = type.to_s.chomp("s").to_sym
|
|
68
|
+
collection = firestore.send(type)
|
|
69
|
+
|
|
70
|
+
puts "Scanning #{type} for duplicates..." if verbose?
|
|
71
|
+
|
|
72
|
+
# Group by [name, author]
|
|
73
|
+
grouped = collection.group_by { |item| [item.name, item.author] }
|
|
74
|
+
duplicates = grouped.select { |_, items| items.length > 1 }
|
|
75
|
+
|
|
76
|
+
if duplicates.empty?
|
|
77
|
+
puts "No duplicate #{type} found." if verbose?
|
|
78
|
+
return
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
puts "Found #{duplicates.length} duplicate #{singular_type}(s) to clean up:" if verbose?
|
|
82
|
+
|
|
83
|
+
duplicates.each do |key, items|
|
|
84
|
+
name, author = key
|
|
85
|
+
# Sort by updated_at descending, keep the most recent
|
|
86
|
+
sorted = items.sort_by { |item| item.updated_at || Time.at(0) }.reverse
|
|
87
|
+
keeper = sorted.first
|
|
88
|
+
to_delete = sorted[1..]
|
|
89
|
+
|
|
90
|
+
puts " #{author}/#{name}: #{items.length} entries" if verbose?
|
|
91
|
+
puts " Keeping: #{keeper.id} (updated: #{keeper.updated_at})" if verbose?
|
|
92
|
+
|
|
93
|
+
to_delete.each do |item|
|
|
94
|
+
if options[:dry_run]
|
|
95
|
+
puts Paint[" Would delete: #{item.id} (updated: #{item.updated_at})", :yellow] if verbose?
|
|
96
|
+
else
|
|
97
|
+
puts " Deleting: #{item.id} (updated: #{item.updated_at})" if verbose?
|
|
98
|
+
response = firestore.delete(singular_type, item)
|
|
99
|
+
puts " #{success_or_failure(response)}" if verbose > 1
|
|
100
|
+
end
|
|
101
|
+
end
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
deleted_count = duplicates.values.sum { |items| items.length - 1 }
|
|
105
|
+
if options[:dry_run]
|
|
106
|
+
puts Paint["Dry run; no changes made. Would have deleted #{deleted_count} duplicate #{type}.", :yellow] if verbose?
|
|
107
|
+
else
|
|
108
|
+
puts "Deleted #{deleted_count} duplicate #{type}." if verbose?
|
|
109
|
+
end
|
|
110
|
+
end
|
|
111
|
+
|
|
60
112
|
def success_or_failure(status)
|
|
61
113
|
format("%<status>10s", status: status ? Paint["Success", :green] : Paint["Failure", :red])
|
|
62
114
|
end
|
data/lib/icarus/mod/version.rb
CHANGED