From 9e1fcbeca958eac0ce7b37c04dc9460f68adb464 Mon Sep 17 00:00:00 2001 From: lread Date: Sat, 28 Dec 2024 17:11:56 -0500 Subject: [PATCH] dev: cljdoc-preview tweaks 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. --- script/cljdoc_preview.clj | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/script/cljdoc_preview.clj b/script/cljdoc_preview.clj index d5125b1..cc8fd0e 100644 --- a/script/cljdoc_preview.clj +++ b/script/cljdoc_preview.clj @@ -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] @@ -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" @@ -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))) @@ -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 ;;