|
49 | 49 | (defn save-outputs [file stack-id outputs]
|
50 | 50 | (->> outputs (merge {:stack-id stack-id}) pp/pprint with-out-str (spit file)))
|
51 | 51 |
|
| 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 | + |
52 | 58 | (defn find-confetti-edn [id]
|
53 | 59 | (let [f (io/file (if (.endsWith id ".confetti.edn") id (str id ".confetti.edn")))]
|
54 | 60 | (assert-exit (.exists f) (str "The file " (.getName f) " could not be found!"))
|
|
87 | 93 | (println "(You may now want to set these as nameservers in your domain management console.)")
|
88 | 94 | (newline)
|
89 | 95 | (doseq [ns nameservers]
|
90 |
| - (println " " ns)) |
| 96 | + (println "\t" ns)) |
91 | 97 | (newline))
|
92 | 98 |
|
93 | 99 | (b/deftask fetch-outputs
|
|
107 | 113 | (filter #(.endsWith (.getName %) ".confetti.edn"))
|
108 | 114 | (remove (comp :cloudfront-url edn/read-string slurp))))]
|
109 | 115 | (doseq [p preliminary]
|
110 |
| - (u/info "Fetching outputs for %s... " (.getName p)) |
| 116 | + (u/info "Fetching outputs for %s...\n" (.getName p)) |
111 | 117 | ;; TODO implement complete? check and skip fetching if so
|
112 | 118 | (let [stack-id (-> p slurp edn/read-string :stack-id)
|
113 | 119 | outputs (-> (fetch-stack-outputs cpod creds stack-id) process-outputs)
|
114 | 120 | nameservers (when-let [hzid (:hosted-zone-id outputs)]
|
115 | 121 | (fetch-nameservers cpod creds hzid))
|
116 | 122 | domain (string/replace (:website-url outputs) #"^http.*:\/\/" "")]
|
117 | 123 | (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") |
120 | 131 | ;; Route53 not used, user probably wants to point some CNAME to the Cloudfront distribution
|
121 | 132 | (when-not (seq nameservers)
|
122 | 133 | (newline)
|
|
0 commit comments