<commit_before>(ns frontend.less
  (:require [clojure.java.shell :as shell]
            [clojure.java.io :as io]
            [clojure.string :as str]
            [clojure.tools.logging :as log]
            [fs])
  (:import [java.nio.file
            Path Paths FileSystems WatchEvent$Kind StandardWatchEventKinds
            Files WatchService FileVisitor FileVisitResult LinkOption]
           [java.nio.file.attribute BasicFileAttributes FileAttribute]
           [java.io Reader File BufferedReader InputStreamReader]
           [java.nio.charset StandardCharsets]
           [java.net URL URI]
           [com.sun.nio.file SensitivityWatchEventModifier]))

;; Compiles less file on every save. Most of this was extracted from
;; https://github.com/montoux/lein-less

(def less-dir "resources/assets/css")
(def less-file "resources/assets/css/app.css.less")
(def less-map "resources/app.css.map")
(def less-map-url "/app.css.map")
(def output-file "resources/assets/css/app.css")

(def lessc-path "node_modules/.bin/lessc")

(def watch-opts-cdm
  (into-array WatchEvent$Kind [StandardWatchEventKinds/ENTRY_CREATE
                               StandardWatchEventKinds/ENTRY_DELETE
                               StandardWatchEventKinds/ENTRY_MODIFY]))

(defn compile! [& {:keys [src dest minify]
                   :or {src less-file, dest output-file, minify false}}]
  (let [standard-flags (format "--source-map-basepath=$PWD/resources --source-map=%s --source-map-url=%s --relative-urls" less-map less-map-url)
        flags (if minify
                (str standard-flags " --compress")
                standard-flags)
        cmd (format "%s %s %s > %s" lessc-path flags src dest)
        res (shell/sh "bash" "-c" cmd)]
    (if (not= 0 (:exit res))
      (throw (Exception. (format "Couldn't compile less with %s returned exit code %s: %s %s" cmd (:exit res) (:out res) (:err res))))
      (:out res))))

(defn ->path [path]
  (.getPath (FileSystems/getDefault) path (into-array String [])))

(defn all-dirs<commit_msg>Remove --relative-urls flag from less compiler.<commit_after>(ns frontend.less
  (:require [clojure.java.shell :as shell]
            [clojure.java.io :as io]
            [clojure.string :as str]
            [clojure.tools.logging :as log]
            [fs])
  (:import [java.nio.file
            Path Paths FileSystems WatchEvent$Kind StandardWatchEventKinds
            Files WatchService FileVisitor FileVisitResult LinkOption]
           [java.nio.file.attribute BasicFileAttributes FileAttribute]
           [java.io Reader File BufferedReader InputStreamReader]
           [java.nio.charset StandardCharsets]
           [java.net URL URI]
           [com.sun.nio.file SensitivityWatchEventModifier]))

;; Compiles less file on every save. Most of this was extracted from
;; https://github.com/montoux/lein-less

(def less-dir "resources/assets/css")
(def less-file "resources/assets/css/app.css.less")
(def less-map "resources/app.css.map")
(def less-map-url "/app.css.map")
(def output-file "resources/assets/css/app.css")

(def lessc-path "node_modules/.bin/lessc")

(def watch-opts-cdm
  (into-array WatchEvent$Kind [StandardWatchEventKinds/ENTRY_CREATE
                               StandardWatchEventKinds/ENTRY_DELETE
                               StandardWatchEventKinds/ENTRY_MODIFY]))

(defn compile! [& {:keys [src dest minify]
                   :or {src less-file, dest output-file, minify false}}]
  (let [standard-flags (format "--source-map-basepath=$PWD/resources --source-map=%s --source-map-url=%s" less-map less-map-url)
        flags (if minify
                (str standard-flags " --compress")
                standard-flags)
        cmd (format "%s %s %s > %s" lessc-path flags src dest)
        res (shell/sh "bash" "-c" cmd)]
    (if (not= 0 (:exit res))
      (throw (Exception. (format "Couldn't compile less with %s returned exit code %s: %s %s" cmd (:exit res) (:out res) (:err res))))
      (:out res))))

(defn ->path [path]
  (.getPath (FileSystems/getDefault) path (into-array String [])))

(defn all-dirs
{'fraction_non_alphanumeric': 0.13138506876227898, 'fraction_numerical': 0.0004911591355599214, 'mean_word_length': 2.623665480427046, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, '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': '3268347', 'n_tokens_mistral': 1275, 'n_tokens_neox': 1238, 'n_words': 329}