Fork me on GitHub
#fulcro
<
2024-02-29
>
roklenarcic07:02:37

Quick q about guardrails: I have a clj CLI tool and I want to run guardrails even when the tool is packaged and in “production”. How do I do that?

roklenarcic08:02:38

Another q: if I define guardrails-export.edn to exclude some namespaces for upstream users of my library, don’t I also disable guardrails for these NSs for my own dev of the library? Unless I explicitly clear exclusions whenever I start REPL?

tony.kay16:02:16

That is correct, that’s why there are functions to toggle them.

tony.kay16:02:37

if you have some better ideas, I’m all ears

tony.kay17:02:16

In my statecharts lib, for example, I just put the toggles in my tests to ensure they are on all when my tests run. You could also add toggles to your “user” ns that is not on your export classpath so they always get turned off when your project loads in dev mode

tony.kay17:02:25

seems easy enough to work with to me

roklenarcic19:02:03

There’s something very janky that would work.

(System/getProperty "user.dir")
=> "/Users/roklenarcic/clojure-projects/my-project"

(let [cl (.. Thread currentThread getContextClassLoader)]
  (enumeration-seq (.getResources cl "guardrails-export.edn")))
=> (#object[java.net.URL 0x5924d5bd "file:/Users/roklenarcic/clojure-projects/my-project/src/guardrails-export.edn"])

roklenarcic19:02:47

So basically you can figure out which edn files are from subfolders of your work dir, which means you can ignore them, that would work provided you start your process so that the work dir is your project dir

roklenarcic19:02:53

usually the case

roklenarcic19:02:05

the rest of them are from dependencies

roklenarcic19:02:36

now obviously this is janky and might lead to suprises for some people who run their REPL differently

roklenarcic19:02:03

of course you can make this an explicit config option

tony.kay05:03:45

hm. It’s not terrible. Could also look for entries that are coming from JAR files vs file files

roklenarcic08:03:26

True, but with new deps people can have dependencies in folder form in which case the entries will not be from jar

roklenarcic08:03:10

e.g. specifying the dep as a git coordinate will clone the repo and add the sources folder to classpath IIRC

tony.kay13:03:04

Right. So if you want to try contributing a patch, I'd take it