Identifying headers added to generated files.

This commit is contained in:
Simon Brooke 2018-03-17 19:06:02 +00:00
parent 0800756288
commit 05623f0168
2 changed files with 16 additions and 3 deletions

View file

@ -4,6 +4,8 @@
(:require [clojure.java.io :refer [file]] (:require [clojure.java.io :refer [file]]
[clojure.math.combinatorics :refer [combinations]] [clojure.math.combinatorics :refer [combinations]]
[clojure.string :as s] [clojure.string :as s]
[clj-time.core :as t]
[clj-time.format :as f]
[squirrel-parse.to-adl :refer [migrations-to-xml]] [squirrel-parse.to-adl :refer [migrations-to-xml]]
[squirrel-parse.utils :refer [is-link-table? singularise]])) [squirrel-parse.utils :refer [is-link-table? singularise]]))
@ -281,13 +283,20 @@
[adl-struct (migrations-to-xml migrations-path "Ignored") [adl-struct (migrations-to-xml migrations-path "Ignored")
file-content (apply file-content (apply
str str
(doall (map (cons
(str "-- "
output
" autogenerated by \n-- [squirrel-parse](https://github.com/simon-brooke/squirrel-parse)\n-- at "
(f/unparse (f/formatters :basic-date-time) (t/now))
"\n\n")
(doall
(map
#(:query %) #(:query %)
(vals (vals
(apply (apply
merge merge
(map (map
#(queries % adl-struct) #(queries % adl-struct)
(vals adl-struct)))))))] (vals adl-struct))))))))]
(spit output file-content) (spit output file-content)
file-content))) file-content)))

View file

@ -5,6 +5,8 @@
[clojure.math.combinatorics :refer [combinations]] [clojure.math.combinatorics :refer [combinations]]
[clojure.pprint :refer [pprint write]] [clojure.pprint :refer [pprint write]]
[clojure.string :as s] [clojure.string :as s]
[clj-time.core :as t]
[clj-time.format :as f]
[squirrel-parse.to-adl :refer [migrations-to-xml]] [squirrel-parse.to-adl :refer [migrations-to-xml]]
[squirrel-parse.to-hugsql-queries :refer [queries]] [squirrel-parse.to-hugsql-queries :refer [queries]]
[squirrel-parse.utils :refer [is-link-table? singularise]])) [squirrel-parse.utils :refer [is-link-table? singularise]]))
@ -40,8 +42,10 @@
(defn file-header [parent-name this-name] (defn file-header [parent-name this-name]
(list (list
'ns 'ns
^{:doc "JSON routes auto-generated by squirrel-parse"}
(symbol (str parent-name "." this-name)) (symbol (str parent-name "." this-name))
(str "JSON routes for " parent-name
" auto-generated by [squirrel-parse](https://github.com/simon-brooke/squirrel-parse) at "
(f/unparse (f/formatters :basic-date-time) (t/now)))
(list (list
'require 'require
'[noir.response :as nresponse] '[noir.response :as nresponse]