<commit_before>(ns shadow.build.targets.azure-app
  (:require
    [clojure.spec.alpha :as s]
    [clojure.java.io :as io]
    [clojure.data.json :as json]
    [shadow.build :as build]
    [shadow.build.targets.shared :as shared]
    [shadow.build.targets.node-library :as node-lib]
    [shadow.build.config :as config]
    [cljs.compiler :as cljs-comp]
    [shadow.build.data :as data]
    [shadow.build.npm :as npm]))

(s/def ::fn-map
  (s/map-of simple-keyword? shared/unquoted-qualified-symbol?))

(s/def ::app-dir shared/non-empty-string?)

(s/def ::target
  (s/keys
    :req-un
    [::fn-map
     ::app-dir]))

(defmethod config/target-spec :azure-fn [_]
  (s/spec ::target))

(defn do-configure [state mode {:keys [fn-map app-dir] :as config}]
  (-> state
      (assoc ::app-dir (io/file app-dir)
             ::fn-data {}
             ::fn-map fn-map)
      (assoc-in [:compiler-options :optimizations] :advanced)
      (assoc-in [::build/config :devtools :enabled] false)
      (update ::build/config merge {:exports fn-map
                                    ;; FIXME: can't have a {:cljs some.ns/fn} function when using cljs dir
                                    :output-to (str app-dir "/cljs/shared.js")})
      ))

(defn flush-fn-file [{::keys [app-dir] :as state} fn-id azure-fn]
  (let [fn-ns (-> azure-fn namespace symbol)
        fn-sym (-> azure-fn name symbol)

        fn-id-s
        (name fn-id)
<commit_msg>properly munge azure fn names<commit_after>(ns shadow.build.targets.azure-app
  (:require
    [clojure.spec.alpha :as s]
    [clojure.java.io :as io]
    [clojure.data.json :as json]
    [shadow.build :as build]
    [shadow.build.targets.shared :as shared]
    [shadow.build.targets.node-library :as node-lib]
    [shadow.build.config :as config]
    [cljs.compiler :as cljs-comp]
    [shadow.build.data :as data]
    [shadow.build.npm :as npm]))

(s/def ::fn-map
  (s/map-of simple-keyword? shared/unquoted-qualified-symbol?))

(s/def ::app-dir shared/non-empty-string?)

(s/def ::target
  (s/keys
    :req-un
    [::fn-map
     ::app-dir]))

(defmethod config/target-spec :azure-fn [_]
  (s/spec ::target))

(defn do-configure [state mode {:keys [fn-map app-dir] :as config}]
  (-> state
      (assoc ::app-dir (io/file app-dir)
             ::fn-data {}
             ::fn-map fn-map)
      (assoc-in [:compiler-options :optimizations] :advanced)
      (assoc-in [::build/config :devtools :enabled] false)
      (update ::build/config merge {:exports fn-map
                                    ;; FIXME: can't have a {:cljs some.ns/fn} function when using cljs dir
                                    :output-to (str app-dir "/cljs/shared.js")})
      ))

(defn flush-fn-file [{::keys [app-dir] :as state} fn-id azure-fn]
  (let [fn-ns (-> azure-fn namespace symbol)
        fn-sym (-> azure-fn name symbol)

        fn-id-s
        (-> fn-id name cljs-comp/munge)

{'fraction_non_alphanumeric': 0.16557433597792343, 'fraction_numerical': 0.0, 'mean_word_length': 2.2954545454545454, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 10, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5097407', 'n_tokens_mistral': 1069, 'n_tokens_neox': 1035, 'n_words': 241}