Skip to content

Commit

Permalink
lsp-rename not working
Browse files Browse the repository at this point in the history
  • Loading branch information
Kaspazza committed Jan 12, 2024
1 parent 28c9eb7 commit 01612a0
Show file tree
Hide file tree
Showing 13 changed files with 252 additions and 80 deletions.
5 changes: 3 additions & 2 deletions bb.edn
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
{:deps {org.clojars.hephaistox/automaton-build-app {:mvn/version "0.0.72"}}
;;The file is updated automatically
{:deps {org.clojars.hephaistox/automaton-build-app {:mvn/version "0.0.74"}}
:paths []
:tasks {:requires [[automaton-build-app.tasks.launcher.bb-entrypoint :as build-task-bb-entrypoint] [babashka.process :as babahska-process]]
heph-task {:doc "Launch an Hephaistox task"
:task (System/exit (build-task-bb-entrypoint/-main *command-line-args*))}
lconnect {:doc "Repl in case automaton-core is failing. Using -f or --force cli arguments to force start if some part are failing"
:task (try (-> (babahska-process/shell "clojure" "-M:common-test:env-development-repl:build" *command-line-args*)
System/exit)
(catch Exception e (println "Repl failed also - error during repl startup" (ex-message e))))}}}
(catch Exception e (println "Repl failed also - error during repl startup" (ex-message e))))}}}
7 changes: 1 addition & 6 deletions build_config.edn
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
{:app-name "automaton-core"
:task-shared {:gha {}
:mermaid-dir "docs/code/"
:publication {:as-lib org.clojars.hephaistox/automaton-core
:branch "main"
:deploy-to :clojars
:jar-path "target/prod/automaton-core.jar"
:major-version "0.0.%d"
:pom-path "target/prod/class/META-INF/maven/org.clojars.hephaistox/automaton-core/pom.xml"
:repo "[email protected]:hephaistox/automaton-core.git"}
:repl-aliases [:common-test :env-development-repl :build]
:storage-datomic {:datomic-ver "1.0.7021"}}
:repl-aliases [:common-test :env-development-repl :build]}
:tasks {:clean {:dirs [".cpcache/" ".clj-kondo/.cache/" "tmp/" "target/" "node_modules/" ".shadow-cljs/builds/"]}
:reports {:forbiddenwords-words #{"automaton-web" "landing" "tap>"}}}}
6 changes: 3 additions & 3 deletions deps.edn
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{:aliases {:bb-deps {:extra-deps {org.clojars.hephaistox/automaton-build-app {:mvn/version "0.0.72"}}}
:build {:extra-deps {org.clojars.hephaistox/automaton-build-app {:mvn/version "0.0.72"}}}
{:aliases {:bb-deps {:extra-deps {org.clojars.hephaistox/automaton-build-app {:mvn/version "0.0.74"}}}
:build {:extra-deps {org.clojars.hephaistox/automaton-build-app {:mvn/version "0.0.74"}}}
:cljs-deps {:extra-deps {binaryage/devtools {:mvn/version "1.0.7"}
cider/cider-nrepl {:mvn/version "0.30.0"}
thheller/shadow-cljs {:mvn/version "2.26.2"}}
Expand Down Expand Up @@ -28,7 +28,7 @@
org.clojure/data.json {:mvn/version "2.5.0"}
com.taoensso/tempura {:mvn/version "1.5.3"}
danlentz/clj-uuid {:mvn/version "0.1.9"}
djblue/portal {:mvn/version "0.51.0"} ;; developer tooling
djblue/portal {:mvn/version "0.51.1"} ;; developer tooling
http-kit/http-kit {:mvn/version "2.7.0"}
io.sentry/sentry {:mvn/version "7.1.0"}
io.sentry/sentry-clj {:mvn/version "6.33.209"}
Expand Down
151 changes: 151 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<packaging>jar</packaging>
<groupId>org.clojars.hephaistox</groupId>
<artifactId>automaton-core</artifactId>
<version>0.0.55</version>
<name>automaton-core</name>
<dependencies>
<dependency>
<groupId>org.clojure</groupId>
<artifactId>data.json</artifactId>
<version>2.5.0</version>
</dependency>
<dependency>
<groupId>org.clojure</groupId>
<artifactId>clojure</artifactId>
<version>1.11.1</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j2-impl</artifactId>
<version>2.22.1</version>
</dependency>
<dependency>
<groupId>org.clojure</groupId>
<artifactId>tools.logging</artifactId>
<version>1.2.4</version>
</dependency>
<dependency>
<groupId>org.clojure</groupId>
<artifactId>tools.cli</artifactId>
<version>1.0.219</version>
</dependency>
<dependency>
<groupId>danlentz</groupId>
<artifactId>clj-uuid</artifactId>
<version>0.1.9</version>
</dependency>
<dependency>
<groupId>com.clojure-goes-fast</groupId>
<artifactId>clj-memory-meter</artifactId>
<version>0.3.0</version>
</dependency>
<dependency>
<groupId>com.taoensso</groupId>
<artifactId>encore</artifactId>
<version>3.62.1</version>
</dependency>
<dependency>
<groupId>io.sentry</groupId>
<artifactId>sentry</artifactId>
<version>7.1.0</version>
</dependency>
<dependency>
<groupId>com.datomic</groupId>
<artifactId>peer</artifactId>
<version>1.0.7075</version>
</dependency>
<dependency>
<groupId>io.sentry</groupId>
<artifactId>sentry-clj</artifactId>
<version>6.33.209</version>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>42.7.1</version>
</dependency>
<dependency>
<groupId>com.taoensso</groupId>
<artifactId>tempura</artifactId>
<version>1.5.3</version>
</dependency>
<dependency>
<groupId>refactor-nrepl</groupId>
<artifactId>refactor-nrepl</artifactId>
<version>3.6.0</version>
</dependency>
<dependency>
<groupId>djblue</groupId>
<artifactId>portal</artifactId>
<version>0.51.1</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.22.1</version>
</dependency>
<dependency>
<groupId>zprint</groupId>
<artifactId>zprint</artifactId>
<version>1.2.8</version>
</dependency>
<dependency>
<groupId>metosin</groupId>
<artifactId>malli</artifactId>
<version>0.13.0</version>
</dependency>
<dependency>
<groupId>babashka</groupId>
<artifactId>process</artifactId>
<version>0.5.21</version>
</dependency>
<dependency>
<groupId>nrepl</groupId>
<artifactId>nrepl</artifactId>
<version>1.1.0</version>
</dependency>
<dependency>
<groupId>mount</groupId>
<artifactId>mount</artifactId>
<version>0.1.17</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>2.22.1</version>
</dependency>
<dependency>
<groupId>lambdaisland</groupId>
<artifactId>uri</artifactId>
<version>1.16.134</version>
</dependency>
<dependency>
<groupId>babashka</groupId>
<artifactId>fs</artifactId>
<version>0.5.20</version>
</dependency>
<dependency>
<groupId>http-kit</groupId>
<artifactId>http-kit</artifactId>
<version>2.7.0</version>
</dependency>
</dependencies>
<build>
<sourceDirectory>env/development/src/clj/</sourceDirectory>
</build>
<repositories>
<repository>
<id>clojars</id>
<url>https://repo.clojars.org/</url>
</repository>
</repositories>
<licenses>
<license>
<name>Eclipse Public License 1.0</name>
<url>https://opensource.org/license/epl-1-0/</url>
</license>
</licenses>
</project>
5 changes: 3 additions & 2 deletions src/clj/automaton_core/log/be_log.clj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
Current structure is generic for logging level, as they are the same right now in sense of this proxy.
In future it may develop if needed to e.g. have the same number of macros as in `automaton-core.log`."
(:require [automaton-core.log.be-registry :as log-be-registry]
[automaton-core.log.tracking.be-error-tracking :as exs]))
[automaton-core.log.tracking.be-error-tracking :as exs]
[automaton-core.log.terminal :as core-terminal]))

(defn log-init!
[{:keys [dsn env]}]
Expand All @@ -17,7 +18,7 @@
(reduce (fn [acc logger-id]
(if-let [logger-strategy (get-in log-be-registry/strategies-registry [logger-id :impl])]
(conj acc logger-strategy)
(do (print "WARN: Logging strategy is nil for id: " logger-id) acc)))
(do (core-terminal/log "WARN: Logging strategy is nil for id: " logger-id) acc)))
[]
logger-ids))

Expand Down
3 changes: 2 additions & 1 deletion src/clj/automaton_core/storage/component.clj
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
(try (core-log/info "Start storage component")
(let [dc (datomic/make-datomic-client datomic-schema/all-schema)
db-uri (conf/read-param [:storage :datomic :url])
_db-uri-valid? (when-not db-uri (throw (ex-info "Database uri was not found." {})))
_db-uri-valid? (when-not db-uri
(throw (ex-info "Database uri was not found. Are you sure that env variable STORAGE_DATOMIC_URL is set?" {})))
conn (storage/connection dc db-uri)
access (datomic/make-datomic-access)]
(core-log/trace "Storage component is started")
Expand Down
20 changes: 11 additions & 9 deletions src/cljc/automaton_core/configuration.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
gathering all classpath, so all `config.edn` versions. The solution was to be based on environment
parameter. So each alias can tell which version it uses, especially monorepo could be different."
(:require [automaton-core.configuration.protocol :as core-conf-prot]
[automaton-core.configuration.simple-files :as simple-files]
[automaton-core.configuration.files :as core-conf-files]
[automaton-core.configuration.environment :as core-conf-env]
[mount.core :refer [defstate in-cljc-mode]]))

;; Force the use of `cljc mode` in mount library, so call to `@` will work
Expand All @@ -20,9 +21,10 @@
(defn start-conf
[]
(try (println "Starting configuration component")
(let [conf (simple-files/->SimpleConf)]
(let [conf (core-conf-files/->SimpleConf)
env-conf (core-conf-env/->EnvConf)]
(println "Configuration component is started")
conf)
[conf env-conf])
(catch #?(:clj Throwable
:cljs :default)
e
Expand All @@ -35,11 +37,11 @@
(defn read-param
"Returns value under `key-path` vector."
([key-path default-value]
(let [value (core-conf-prot/read-conf-param @conf-state key-path)]
(if (nil? value)
(do (println "Value for " key-path " is not set, use default value" default-value) default-value)
(do (println "Read key-path " key-path " = " value) value))))
(let [value (or (core-conf-prot/read-conf-param (first @conf-state) key-path)
(core-conf-prot/read-conf-param (second @conf-state) key-path))]
(when (nil? value)
(println "Value for " key-path " is not set, use default value")
default-value)))
([key-path] (read-param key-path nil)))

#_{:clj-kondo/ignore [:clojure-lsp/unused-public-var]}
(defn all-config "Returns whole configuration map, with all the keys and values." [] (core-conf-prot/config @conf-state))

54 changes: 54 additions & 0 deletions src/cljc/automaton_core/configuration/environment.cljc
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
(ns automaton-core.configuration.environment
(:require #?@(:clj [[clojure.edn :as edn]]
:cljs [[cljs.reader :as edn] [goog.object :as obj]])
[automaton-core.configuration.protocol :as core-conf-prot]
[automaton-core.utils.keyword :as utils-keyword]
[clojure.string :as str]))

#?(:cljs (def ^:private nodejs? (exists? js/require)))

#?(:cljs (def ^:private process (when nodejs? (js/require "process"))))

(defn env-key-path
"Turns key-path ([:a :b :c] -> 'a-b-c') into environment type key."
[key-path]
(let [path-str (str/join "-" (map name key-path))] (when-not (str/blank? path-str) (utils-keyword/keywordize path-str))))

(defn parse-number
[^String v]
(try #?(:clj (Long/parseLong v)
:cljs (parse-long v))
#?(:clj (catch NumberFormatException _ (BigInteger. v)))
(catch #?(:clj Exception
:cljs js/Error)
_
v)))

#_{:clj-kondo/ignore [:clojure-lsp/unused-public-var]}
(defn parse-system-env
"Turns string type into number. In case of failure in parsing it's returned in a format as it was (a string)."
[v]
(cond (re-matches #"[0-9]+" v) (parse-number v)
(re-matches #"^(true|false)$" v) #?(:clj (Boolean/parseBoolean v)
:cljs (parse-boolean v))
(re-matches #"\w+" v) v
:else (try (let [parsed (edn/read-string v)] (if (symbol? parsed) v parsed))
(catch #?(:clj Exception
:cljs js/Error)
_
v))))

(defn read-all
"Reads all system env properties and converts to appropriate type."
[]
(->> #?(:clj (System/getenv)
:cljs (if process (let [env (.-env process)] (zipmap (obj/getKeys env) (obj/getValues env))) {}))
(map (fn [[k v]] [(utils-keyword/keywordize k) v]))
(into {})))

(def ^{:doc "A map of configuration variables."} conf (memoize read-all))

(defrecord EnvConf []
core-conf-prot/Conf
(read-conf-param [_this key-path] (get (conf) (env-key-path key-path)))
(config [_this] (conf)))
Loading

0 comments on commit 01612a0

Please sign in to comment.