<commit_before>(ns leiningen.new.kraken-works
  (:require [leiningen.new.templates :refer [renderer name-to-path ->files]]
            [leiningen.core.main :as main]
            [clojure.string :as str]))

(def render (renderer "kraken-works"))

(def default-options {:datomic? true})

(def valid-options {"--datomic" {:datomic? true}
                    "--no-datomic" {:datomic? false}})

(defn parse-opt [opt]
  (if-let [opt-map (valid-options opt)]
    opt-map
    (main/abort "Invalid option:" opt)))

(defn make-data [name opts]
  (apply merge
    {:name name
     :sanitized (name-to-path name)
     :env-var-style (-> name name-to-path str/upper-case)}
    default-options
    (map parse-opt opts)))

(defn kraken-works
  "FIXME: write documentation"
  [name & opts]
  (let [data (make-data name opts)]
    (main/info (str "Generating fresh kraken-works project in directory " (:sanitized data) "/."))

    (main/info (str "TODO: (you probably want to `cd " name "` first)"))
    (main/info " * Review and address the TODO items in the README.")
    (main/info " * `chmod +x script/*`")
    (main/info " * `git init`")
    (main/info " * `git add .`")
    (main/info " * `git commit -am \"initial commit\"`")
    (main/info " * push this to github")
    (main/info " * make a Buildkite project")
    (->> [[".gitignore" (render ".gitignore" data)]
           ["Dockerfile" (render "Dockerfile" data)]
           ["{{name}}@.service.template" (render "PROJECT@.service.template" data)]
           ["docker-compose.yml" (render "docker-compose.yml" data)]
           ["newrelic.yml" (render "newrelic.yml" data)]
           (when (:datomic? data)
             ["profiles.clj.sample" (render "profiles.clj.sample" data)])
           ["project.clj" (render "project.clj" data)]
           ["README.md" (render "README.md" data)]
           ["LICENSE" (render "LICENSE" data)]

           ["script/deploy" (render "script/deploy" data)]
           ["script/build" (render "script/build" data)]

           ["resources/config.edn" (render "config.edn" data)]
           (when (:datomic? data)
             ["resources/schemas/.gitkeep" ""])
           ["resources/logback.xml" (render "logback.xml" data)]

           ["src/{{sanitized}}/core.clj" (render "core.clj" data)]
           ["src/{{sanitized}}/queue.clj" (render "queue.clj" data)]
           ["src/{{sanitized}}/channels.clj" (render "channels.clj" data)]
           ["src/{{sanitized}}/handlers.clj" (render "handlers.clj" data)]
           ["test/{{sanitized}}/handlers_test.clj" (render "handlers_test.clj" data)]]
         (remove nil?)
         (apply ->files data))))<commit_msg>Align template vector (whitespace-only)<commit_after>(ns leiningen.new.kraken-works
  (:require [leiningen.new.templates :refer [renderer name-to-path ->files]]
            [leiningen.core.main :as main]
            [clojure.string :as str]))

(def render (renderer "kraken-works"))

(def default-options {:datomic? true})

(def valid-options {"--datomic" {:datomic? true}
                    "--no-datomic" {:datomic? false}})

(defn parse-opt [opt]
  (if-let [opt-map (valid-options opt)]
    opt-map
    (main/abort "Invalid option:" opt)))

(defn make-data [name opts]
  (apply merge
    {:name name
     :sanitized (name-to-path name)
     :env-var-style (-> name name-to-path str/upper-case)}
    default-options
    (map parse-opt opts)))

(defn kraken-works
  "FIXME: write documentation"
  [name & opts]
  (let [data (make-data name opts)]
    (main/info (str "Generating fresh kraken-works project in directory " (:sanitized data) "/."))

    (main/info (str "TODO: (you probably want to `cd " name "` first)"))
    (main/info " * Review and address the TODO items in the README.")
    (main/info " * `chmod +x script/*`")
    (main/info " * `git init`")
    (main/info " * `git add .`")
    (main/info " * `git commit -am \"initial commit\"`")
    (main/info " * push this to github")
    (main/info " * make a Buildkite project")
    (->> [[".gitignore" (render ".gitignore" data)]
          ["Dockerfile" (render "Dockerfile" data)]
          ["{{name}}@.service.template" (render "PROJECT@.service.template" data)]
          ["docker-compose.yml" (render "docker-compose.yml" data)]
          ["newrelic.yml" (render "newrelic.yml" data)]
          (when (:datomic? data)
            ["profiles.clj.sample" (render "profiles.clj.sample" data)])
          ["project.clj" (render "project.clj" data)]
          ["README.md" (render "README.md" data)]
          ["LICENSE" (render "LICENSE" data)]

          ["script/deploy" (render "script/deploy" data)]
          ["script/build" (render "script/build" data)]

          ["resources/config.edn" (render "config.edn" data)]
          (when (:datomic? data)
            ["resources/schemas/.gitkeep" ""])
          ["resources/logback.xml" (render "logback.xml" data)]

          ["src/{{sanitized}}/core.clj" (render "core.clj" data)]
          ["src/{{sanitized}}/queue.clj" (render "queue.clj" data)]
          ["src/{{sanitized}}/channels.clj" (render "channels.clj" data)]
          ["src/{{sanitized}}/handlers.clj" (render "handlers.clj" data)]
          ["test/{{sanitized}}/handlers_test.clj" (render "handlers_test.clj" data)]]
         (remove nil?)
         (apply ->files data))))
{'fraction_non_alphanumeric': 0.18080693815987933, 'fraction_numerical': 0.0, 'mean_word_length': 2.696864111498258, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 4}, 'pii_count': 2, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '346339', 'n_tokens_mistral': 1812, 'n_tokens_neox': 1768, 'n_words': 428}