Skip to content

Commit

Permalink
dev: cljdoc-preview tweaks
Browse files Browse the repository at this point in the history
For security reasons, docker is no longer so happy to mount volumes from
`/tmp`, so move our cljdoc db dir to `~/.cljdoc-preview`.

Also minor babashka modernizations.
  • Loading branch information
lread committed Dec 28, 2024
1 parent 2179920 commit 9e1fcbe
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions script/cljdoc_preview.clj
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#!/usr/bin/env bb

(ns cljdoc-preview
(:require [babashka.curl :as curl]
[babashka.fs :as fs]
(:require [babashka.fs :as fs]
[babashka.http-client :as http]
[clojure.java.browse :as browse]
[clojure.string :as string]
[helper.git :as git]
Expand All @@ -28,7 +28,7 @@
;; constants
;;

(def cljdoc-root-temp-dir "/tmp/cljdoc-preview")
(def cljdoc-root-temp-dir "./.cljdoc-preview")
(def cljdoc-db-dir (str cljdoc-root-temp-dir "/db"))
(def cljdoc-container {:name "cljdoc-server"
:image "cljdoc/cljdoc"
Expand Down Expand Up @@ -140,7 +140,7 @@
(let [url (str "http://localhost:" (:port container))]
(loop []
(if-not (try
(curl/get url)
(http/get url)
url
(catch Exception _e
(Thread/sleep 4000)))
Expand Down Expand Up @@ -193,11 +193,10 @@

(defn view-in-browser [url]
(status/line :head "opening %s in browser" url)
(when (not= 200 (:status (curl/get url {:throw false})))
(when (not= 200 (:status (http/get url {:throw false})))
(status/die 1 "Could not reach:\n%s\nDid you run the ingest command yet?" url))
(browse/browse-url url))


;;
;; main
;;
Expand Down

0 comments on commit 9e1fcbe

Please sign in to comment.