Skip to content

Commit 3b64170

Browse files
committed
print direnv stanza once outputs are fetched #33
1 parent aa18f38 commit 3b64170

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

src/confetti/boot_confetti.clj

+15-4
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,12 @@
4949
(defn save-outputs [file stack-id outputs]
5050
(->> outputs (merge {:stack-id stack-id}) pp/pprint with-out-str (spit file)))
5151

52+
(defn envrc-contents [outputs]
53+
(->> outputs
54+
(map (fn [[k v]]
55+
(str "\texport " (-> k name (string/upper-case) (string/replace "-" "_")) "=" v)))
56+
(string/join "\n")))
57+
5258
(defn find-confetti-edn [id]
5359
(let [f (io/file (if (.endsWith id ".confetti.edn") id (str id ".confetti.edn")))]
5460
(assert-exit (.exists f) (str "The file " (.getName f) " could not be found!"))
@@ -87,7 +93,7 @@
8793
(println "(You may now want to set these as nameservers in your domain management console.)")
8894
(newline)
8995
(doseq [ns nameservers]
90-
(println " " ns))
96+
(println "\t" ns))
9197
(newline))
9298

9399
(b/deftask fetch-outputs
@@ -107,16 +113,21 @@
107113
(filter #(.endsWith (.getName %) ".confetti.edn"))
108114
(remove (comp :cloudfront-url edn/read-string slurp))))]
109115
(doseq [p preliminary]
110-
(u/info "Fetching outputs for %s... " (.getName p))
116+
(u/info "Fetching outputs for %s...\n" (.getName p))
111117
;; TODO implement complete? check and skip fetching if so
112118
(let [stack-id (-> p slurp edn/read-string :stack-id)
113119
outputs (-> (fetch-stack-outputs cpod creds stack-id) process-outputs)
114120
nameservers (when-let [hzid (:hosted-zone-id outputs)]
115121
(fetch-nameservers cpod creds hzid))
116122
domain (string/replace (:website-url outputs) #"^http.*:\/\/" "")]
117123
(when outputs
118-
(save-outputs p stack-id (cond-> outputs nameservers (assoc :name-servers nameservers)))
119-
(u/info "saved.\n")
124+
(u/info "Here are all important things about your new site, suitable to be used with direnv\n")
125+
(println "(To learn more about direnv: https://github.com/direnv/direnv)")
126+
(newline)
127+
(println (envrc-contents outputs))
128+
;; (.delete p)
129+
;; (save-outputs p stack-id (cond-> outputs nameservers (assoc :name-servers nameservers)))
130+
;; (u/info "saved.\n")
120131
;; Route53 not used, user probably wants to point some CNAME to the Cloudfront distribution
121132
(when-not (seq nameservers)
122133
(newline)

0 commit comments

Comments
 (0)