diff --git a/src/playground/data/config.clj b/src/playground/data/config.clj index 19b8836..66073f5 100644 --- a/src/playground/data/config.clj +++ b/src/playground/data/config.clj @@ -1,6 +1,7 @@ (ns playground.data.config (:require [cheshire.core :as json] [clj-http.client :as http] + [clojure.string :as string] [playground.utils.utils :as utils])) @@ -33,12 +34,32 @@ (defonce *anychart-versions (atom [])) +(defn- gh-names + "Fetch the :name field from a GitHub list endpoint (branches/tags)." + [url] + (->> (http/get url) :body (#(json/parse-string % true)) (map :name))) + + +(defn- tag->version + "Strip the leading v from semver release tags (v8.14.1 -> 8.14.1) so the + cdn.anychart.com/releases// URLs resolve; leave aliases like v7/v8 as-is." + [name] + (string/replace name #"^v(\d+\.\d+\.\d+)$" "$1")) + + (defn update-anychart-versions [] + ;; ACWEB-6: include release TAGS (v8.8.0..v8.14.1), not just branches, so the + ;; editor's AnyChart-version selector shows the full release list. Tags are + ;; v-prefixed but CDN release paths are bare, so strip the v from semver tags. + ;; NOTE: per_page=100 single page (engine has ~24 branches / ~50 tags); add + ;; pagination if either ever exceeds 100. (try - (let [data (http/get "https://api.github.com/repos/AnyChart/AnyChart/branches?per_page=100") - branches (json/parse-string (:body data) true) - branches (map :name branches)] - (reset! *anychart-versions branches)) + (reset! *anychart-versions + (distinct + (concat + (gh-names "https://api.github.com/repos/AnyChart/AnyChart/branches?per_page=100") + (map tag->version + (gh-names "https://api.github.com/repos/AnyChart/AnyChart/tags?per_page=100"))))) (catch Exception _ (reset! *anychart-versions '())))) diff --git a/src/playground/generator/core.clj b/src/playground/generator/core.clj index 6ccc0c1..68f3e9d 100644 --- a/src/playground/generator/core.clj +++ b/src/playground/generator/core.clj @@ -162,7 +162,11 @@ (timbre/info "Delete repos: " (pr-str (map :name deleted-repos))) (doseq [repo deleted-repos] (delete-repo db repo)) - (let [result (map #(check-repository generator db % (get-repo-by-name-fn @% db-repos)) repos)] + ;; ACWEB-6: force realization — check-repository must run for every repo + ;; (sets :git, triggers startup sync). The notifier is a no-op stub, so the + ;; lazy `map` was never realized → check-repository never ran → repos had + ;; :git nil and no startup sync. `doall` decouples the sync from the notifier. + (let [result (doall (map #(check-repository generator db % (get-repo-by-name-fn @% db-repos)) repos))] (notifier/complete-sync notifier (remove :e result) (filter :e result)))))