-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Zen schemas sourcing and dependency loading #27
Comments
Suggestion:
zen module = git repo: zen jar could provide tools for doing this Example module: app/
Example usage:
zen jar could use git under the hood zen jar could be compiled with graal/work on bb zen pull-deps:
zen build:
zen clone : zen init: git add . && git push
|
From aa66252e947a618d02e72910f78dd50fde0e01c6 Mon Sep 17 00:00:00 2001
From: Oleg Veschin <[email protected]>
Date: Wed, 31 Aug 2022 13:38:40 +0300
Subject: [PATCH] add zen-pm POC
Co-authored-by: @islambegkatibov <[email protected]>
---
src/zen/package.clj | 68 +++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 68 insertions(+)
create mode 100644 src/zen/package.clj
diff --git a/src/zen/package.clj b/src/zen/package.clj
new file mode 100644
index 0000000..3017aea
--- /dev/null
+++ b/src/zen/package.clj
@@ -0,0 +1,68 @@
+(ns zen.package
+ (:require
+ clojure.edn
+ [clojure.java.shell :as sh]
+ ;; [clojure.java.io :as io]
+ [clojure.string :as string]
+ [clojure.test :as t]))
+
+(def root "/tmp/zen")
+
+(defn git-init [path] (sh/sh "git" "init" :dir path))
+
+(defn zen-clone [package-file]
+ (->> package-file
+ slurp
+ clojure.edn/read-string
+ (map (comp #(->> (string/replace (first %) #"\." "/")
+ (str root "/zen_modules/")
+ (sh/sh "git" "clone" (second %)))
+ #(update % 0 str)))))
+
+(comment
+
+ (doseq [repo ["/a" "/b" "/c"]
+ :let [dir (str "/tmp" repo)]]
+ (sh/sh "mkdir" "-p" dir)
+ (git-init dir)
+ (spit (str dir "/main.edn") (str {'ns 'main (symbol (str (random-uuid))) {}}))
+ (sh/sh "git" "add" "." :dir dir)
+ (sh/sh "git" "commit" "-m" "\"Initial commit\"" :dir dir))
+
+ (do
+ (def zrc (str root "/zrc"))
+ (sh/sh "rm" "-rf" root)
+ (.mkdir (java.io.File. root))
+ (.mkdir (java.io.File. zrc))
+ (git-init root)
+ (spit (str root "/.gitignore") "/zen_modules")
+
+ (def precommit-hook-file (str root "/.git/hooks/pre-commit"))
+ (spit precommit-hook-file "#!/bin/bash \n\necho \"hello world!\"")
+ (sh/sh "chmod" "+x" precommit-hook-file)
+
+ (spit (str zrc "/module1.edn") (str '{ns module1}))
+
+ (def package-file (str zrc "/../package.edn"))
+ (spit package-file (str '[[a "/tmp/a"]
+ [b.dir "/tmp/b"]
+ [c "/tmp/c"]]))
+ (zen-clone package-file))
+ )
+
+(defn get-hash [path]
+ (->> "/.git/refs/heads/master"
+ (str path)
+ slurp
+ string/trim-newline))
+
+(t/deftest zen-pm
+
+ (t/is (= (get-hash "/tmp/a")
+ (get-hash "/tmp/zen/zen_modules/a")))
+
+ (t/is (= (get-hash "/tmp/b")
+ (get-hash "/tmp/zen/zen_modules/b/dir")))
+
+ (t/is (= (get-hash "/tmp/c")
+ (get-hash "/tmp/zen/zen_modules/c"))))
--
2.37.2
|
Currently I have to solve a problem of distributing my zen schemas. It would be good if zen offered tools or guidelines.
Use-case:
Urgency: medium
Currently I already implemented solutions for all of these problems in one of my projects, but in my upcoming project I will have to solve all of this problems again
The text was updated successfully, but these errors were encountered: