Skip to content

Commit

Permalink
Bug fixes (#419)
Browse files Browse the repository at this point in the history
* toc, no longer parse x-tukui values
* specs, catalogue/location 'source' is now a url, not an addon/source,
  which seems completely wrong and is only passing because 'unknown?' is a 'string'
* bug, wrath toc files were being ignored
* tests, removed tukui source precedence
* toc, adds precedence test for github
* toc, adds support for detecting github url via 'x-website'
* moves Dockerfiles into CircleCI dir
  • Loading branch information
torkus authored Dec 21, 2023
1 parent e744108 commit 3dccc82
Show file tree
Hide file tree
Showing 9 changed files with 77 additions and 31 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,18 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Added

* `x-website` Github URLs in `.toc` files are now treated as a Github source that an addon can be switched to.
- when both `x-github` and Github `x-website` sources exist, `x-github` takes priority.

### Changed

### Fixed

* fixed bug preventing classic Wrath `.toc` from being detected and loaded.
* fixed bug in catalogue location spec where a value that should have been validating as a URL was not.
* removed `x-tukui-id` source detection in `.toc` files. Tukui no longer hosts addons so these can't be used.
- overlooked, should have been part of 7.0.0 major version.

### Removed

## 7.1.0 - 2023-11-26
Expand Down
File renamed without changes.
File renamed without changes.
15 changes: 10 additions & 5 deletions TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,22 @@ see CHANGELOG.md for a more formal list of changes by release

## done

## todo

* cataclysm classic support
* move Dockerfile* files into a CircleCI folder
- done

* *.sh, consolidate these root-level bash scripts into a manage.sh
* toc, what is the usage of 'x-github'. we're expecting a url but a foo/bar seems fine as well
- check the github catalogue
- I'm seeing more usage of 'x-website'
- done

* move Dockerfile* files into a CircleCI folder
## todo

* *.sh, consolidate these root-level bash scripts into a manage.sh

## todo bucket (no particular order)

* cataclysm classic support

* nfo, replace the URL as the group-id with something random

* github, catalogue, no download counts.
Expand Down
3 changes: 2 additions & 1 deletion src/strongbox/addon.clj
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,8 @@
group-addons))

(defn-spec load-installed-addon (s/or :ok-toc :addon/toc, :ok-nfo :addon/nfo, :error nil?)
"reads and merges the toc data and the nfo data from a specific `addon-dir` and all those in it's group, groups them up (again) and returns the grouped mooshed data.
"reads and merges the toc data and the nfo data for a specific addon at `addon-dir` (bad name) and all those in it's group,
groups them up (again) and returns the grouped mooshed data.
this was introduced much later than `load-all-installed-addons` as parallel installation and loading of addons was introduced."
[addon-dir ::sp/addon-dir, game-track ::sp/game-track]
(logging/with-addon {:dirname (-> addon-dir fs/base-name str)}
Expand Down
3 changes: 2 additions & 1 deletion src/strongbox/specs.clj
Original file line number Diff line number Diff line change
Expand Up @@ -451,9 +451,10 @@
;; catalogue locations

(s/def :catalogue/name keyword?)
(s/def :catalogue/source ::url)

;; a `catalogue/location` is a description of a catalogue and where to find it, not the catalogue itself.
(s/def :catalogue/location (s/keys :req-un [:catalogue/name ::label :addon/source]))
(s/def :catalogue/location (s/keys :req-un [:catalogue/name ::label :catalogue/source]))
(s/def :catalogue/location-list (s/or :ok (s/coll-of :catalogue/location)
:empty ::empty-coll))

Expand Down
25 changes: 16 additions & 9 deletions src/strongbox/toc.clj
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
"returns a list of file names as `[[game-track, filename.toc], ...]` in the given `addon-dir`.
`game-track` is `nil` if it can't be guessed from the filename (and not 'retail')."
[addon-dir ::sp/extant-dir]
(let [pattern (Pattern/compile "(?u)^(.+?)(?:[\\-_]{1}(Mainline|Classic|Vanilla|TBC|BCC){1})?\\.toc$")
(let [pattern (Pattern/compile "(?u)^(.+?)(?:[\\-_]{1}(Mainline|Classic|Vanilla|TBC|BCC|Wrath){1})?\\.toc$")
matching-toc-pattern (fn [filename]
(let [toc-bname (str (fs/base-name filename))
[toc-bname-match game-track-match] (rest (re-matches pattern toc-bname))]
Expand Down Expand Up @@ -121,16 +121,22 @@
;; {:source "curseforge"
;; :source-id x-curse-id})

tukui-source (when-let [x-tukui-id (-> keyvals :x-tukui-projectid utils/to-int)]
{:source "tukui"
:source-id x-tukui-id})
;;tukui-source (when-let [x-tukui-id (-> keyvals :x-tukui-projectid utils/to-int)]
;; {:source "tukui"
;; :source-id x-tukui-id})

github-source (when-let [x-github (-> keyvals :x-github)]
{:source "github"
:source-id (utils/github-url-to-source-id x-github)})

source-map-list (when-let [items (->> [wowi-source tukui-source github-source
;;curse-source
github-website-source (when-let [x-website (-> keyvals :x-website)]
(when (and (not github-source)
(.startsWith x-website "https://github.com"))
{:source "github"
:source-id (utils/github-url-to-source-id x-website)}))

source-map-list (when-let [items (->> [wowi-source github-source github-website-source
;;curse-source tukui-source
]
utils/items
utils/nilable)]
Expand Down Expand Up @@ -177,10 +183,11 @@
(assoc addon :dirsize dirsize)
addon)

;; prefers tukui over wowi, wowi over github. I'd like to prefer github over wowi, but github
;; requires API calls to interact with and these are limited unless authenticated.
;; prefers wowi over github and github over github-via-website.
;; I'd like to prefer github over wowi, but github requires API calls to interact with and these are limited unless authenticated.
addon (merge addon
github-source wowi-source tukui-source
github-website-source github-source wowi-source
;; curse-source tukui-source
ignore-flag source-map-list)]

(if-not (s/valid? :addon/toc addon)
Expand Down
Binary file modified test/fixtures/everyaddon--1-2-3--multi-toc.zip
Binary file not shown.
54 changes: 39 additions & 15 deletions test/strongbox/toc_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,22 @@ SomeAddon.lua")
:source-map-list [{:source "wowinterface" :source-id 123}]}]
[{:x-wowi-id "abc"} {:label "dirname *" :name "dirname"}] ;; bad case, non-numeric wowi ID

;; github
[{:x-github "https://github.com/foo/bar"} {:label "dirname *" :name "dirname"
:source "github" :source-id "foo/bar"
:source-map-list [{:source "github" :source-id "foo/bar"}]}]

;; github via x-website
[{:x-website "https://github.com/SFX-WoW/Masque"} {:label "dirname *" :name "dirname"
:source "github" :source-id "SFX-WoW/Masque"
:source-map-list [{:source "github" :source-id "SFX-WoW/Masque"}]}]

;; github vs github via x-website. when both are present, github is preferred.
[{:x-website "https://github.com/SFX-WoW/Masque"
:x-github "https://github.com/foo/bar"} {:label "dirname *" :name "dirname"
:source "github" :source-id "foo/bar"
:source-map-list [{:source "github" :source-id "foo/bar"}]}]

;; curse
;;[{:x-curse-project-id "123"} {:label "dirname *" :name "dirname"
;; :source "curseforge" :source-id 123
Expand All @@ -160,25 +176,32 @@ SomeAddon.lua")
;;[{:x-curse-project-id "abc"} {:label "dirname *" :name "dirname"}] ;; bad case, non-numeric curse ID

;; tukui
[{:x-tukui-projectid "123"} {:label "dirname *" :name "dirname"
:source "tukui" :source-id 123
:source-map-list [{:source "tukui" :source-id 123}]}]
[{:x-tukui-projectid "-1"} {:label "dirname *" :name "dirname"
:source "tukui" :source-id -1
:source-map-list [{:source "tukui" :source-id -1}]}]
[{:x-tukui-projectid 123} {:label "dirname *" :name "dirname"
:source "tukui" :source-id 123
:source-map-list [{:source "tukui" :source-id 123}]}]
[{:x-tukui-projectid "abc"} {:label "dirname *" :name "dirname"}] ;; bad case
;;[{:x-tukui-projectid "123"} {:label "dirname *" :name "dirname"
;; :source "tukui" :source-id 123
;; :source-map-list [{:source "tukui" :source-id 123}]}]
;;[{:x-tukui-projectid "-1"} {:label "dirname *" :name "dirname"
;; :source "tukui" :source-id -1
;; :source-map-list [{:source "tukui" :source-id -1}]}]
;;[{:x-tukui-projectid 123} {:label "dirname *" :name "dirname"
;; :source "tukui" :source-id 123
;; :source-map-list [{:source "tukui" :source-id 123}]}]
;;[{:x-tukui-projectid "abc"} {:label "dirname *" :name "dirname"}] ;; bad case

;; mixed
[{:x-wowi-id "123"
:x-tukui-projectid "123"
:x-curse-project-id "123"} {:label "dirname *" :name "dirname"
:source "tukui" :source-id 123 ;; todo: this precedence is interesting ...
:source-map-list [{:source "wowinterface" :source-id 123}
;;{:source "curseforge" :source-id 123}
{:source "tukui" :source-id 123}]}]]]
:x-curse-project-id "123"
:x-github "https://github.com/foo/bar"
:x-website "https://github.com/bar/foo"}

{:label "dirname *" :name "dirname"
:source "wowinterface" :source-id 123 ;; todo: this precedence is interesting ...
:source-map-list [{:source "wowinterface" :source-id 123}
{:source "github" :source-id "foo/bar"}

;;{:source "curseforge" :source-id 123}
;;{:source "tukui" :source-id 123}
]}]]]

(fs/mkdir addon-dir)
(doseq [[given expected] cases
Expand Down Expand Up @@ -223,6 +246,7 @@ SomeAddon.lua")
[:retail "EveryAddon-Mainline.toc"]
[:classic-tbc "EveryAddon-TBC.toc"]
[:classic "EveryAddon-Vanilla.toc"]
[:classic-wotlk "EveryAddon-Wrath.toc"]
[nil "EveryAddon.toc"]]
fixture (helper/fixture-path "everyaddon--1-2-3--multi-toc.zip")
addon-dir (join (helper/install-dir) "EveryAddon")]
Expand Down

0 comments on commit 3dccc82

Please sign in to comment.