[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/cider 83f18a9ad4: [#3133] Check the version of cider-injec
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/cider 83f18a9ad4: [#3133] Check the version of cider-injected-nrepl-version at runtime |
Date: |
Sun, 13 Feb 2022 08:57:56 -0500 (EST) |
branch: elpa/cider
commit 83f18a9ad4b97614bf1ec9e65444ebc90dd8bddf
Author: Bozhidar Batsov <bozhidar@batsov.dev>
Commit: Bozhidar Batsov <bozhidar@batsov.dev>
[#3133] Check the version of cider-injected-nrepl-version at runtime
Basically, we extend the fix for cider-injected-middleware-version and
encapsulate the required deps nREPL and cider-nrepl in a reusable function.
---
cider.el | 18 +++++----
doc/modules/ROOT/pages/basics/up_and_running.adoc | 3 --
test/cider-tests.el | 48 +++++++++++------------
3 files changed, 34 insertions(+), 35 deletions(-)
diff --git a/cider.el b/cider.el
index c246f69e2f..3620b9e7ff 100644
--- a/cider.el
+++ b/cider.el
@@ -394,9 +394,6 @@ your version of Boot or Leiningen is bundling an older one."
:package-version '(cider . "1.2.0")
:safe #'stringp)
-(cider-add-to-alist 'cider-jack-in-dependencies
- "nrepl/nrepl" cider-injected-nrepl-version)
-
(defvar cider-jack-in-cljs-dependencies nil
"List of dependencies where elements are lists of artifact name and version.
Added to `cider-jack-in-dependencies' when doing `cider-jack-in-cljs'.")
@@ -540,6 +537,13 @@ LIST should have the form (ARTIFACT-NAME
ARTIFACT-VERSION). The returned
string is quoted for passing as argument to an inferior shell."
(concat "-d " (shell-quote-argument (format "%s:%s" (car list) (cadr
list)))))
+(defun cider--jack-in-required-dependencies ()
+ "Returns the required CIDER deps.
+They are normally added to `cider-jack-in-dependencies',
+unless it's a Lein project."
+ `(("nrepl/nrepl" ,cider-injected-nrepl-version)
+ ("cider/cider-nrepl" ,cider-injected-middleware-version)))
+
(defun cider-boot-dependencies (dependencies)
"Return a list of boot artifact strings created from DEPENDENCIES."
(concat (mapconcat #'cider--list-as-boot-artifact dependencies " ")
@@ -563,7 +567,7 @@ and MIDDLEWARES. PARAMS and MIDDLEWARES are passed on to
(concat global-opts
(unless (seq-empty-p global-opts) " ")
"-i \"(require 'cider.tasks)\" " ;; Note the space at the end here
- (cider-boot-dependencies (append dependencies `(("cider/cider-nrepl"
,cider-injected-middleware-version))))
+ (cider-boot-dependencies (append
(cider--jack-in-required-dependencies) dependencies))
(cider-boot-middleware-task params middlewares)))
(defun cider--lein-artifact-exclusions (exclusions)
@@ -613,7 +617,7 @@ one used."
(let* ((deps-string (string-join
(seq-map (lambda (dep)
(format "%s {:mvn/version \"%s\"}" (car dep)
(cadr dep)))
- (append dependencies `(("cider/cider-nrepl"
,cider-injected-middleware-version))))
+ (append (cider--jack-in-required-dependencies)
dependencies))
" "))
(middleware (mapconcat
(apply-partially #'format "%s")
@@ -633,7 +637,7 @@ one used."
(defun cider-shadow-cljs-jack-in-dependencies (global-opts params dependencies)
"Create shadow-cljs jack-in deps.
Does so by concatenating GLOBAL-OPTS, DEPENDENCIES finally PARAMS."
- (let ((dependencies (append dependencies `(("cider/cider-nrepl"
,cider-injected-middleware-version)))))
+ (let ((dependencies (append (cider--jack-in-required-dependencies)
dependencies)))
(concat
global-opts
(unless (seq-empty-p global-opts) " ")
@@ -672,7 +676,7 @@ dependencies."
global-opts
params
(cider-add-clojure-dependencies-maybe
- cider-jack-in-dependencies)
+ (append `(("nrepl/nrepl" ,cider-injected-nrepl-version))
cider-jack-in-dependencies))
cider-jack-in-dependencies-exclusions
(cider-jack-in-normalized-lein-plugins)
(if cider-enrich-classpath
diff --git a/doc/modules/ROOT/pages/basics/up_and_running.adoc
b/doc/modules/ROOT/pages/basics/up_and_running.adoc
index 1c737d080e..8b91749188 100644
--- a/doc/modules/ROOT/pages/basics/up_and_running.adoc
+++ b/doc/modules/ROOT/pages/basics/up_and_running.adoc
@@ -99,9 +99,6 @@ Generally you should avoid doing this, but it may be useful
if you want to try
a newer version or you encounter some regression that forces you to
temporarily use
an older version.
-NOTE: You'll have to restart Emacs for such changes to take effect, if you've
already loaded CIDER. Alternatively you can update
-manually the underlying dependencies list (e.g. `cider-jack-in-dependencies`).
-
CIDER can also inject a Clojure dependency into your project, which is useful,
for example, if your project defaults to an older version of Clojure than that
supported by the CIDER middleware. Set `cider-jack-in-auto-inject-clojure`
diff --git a/test/cider-tests.el b/test/cider-tests.el
index 873307df94..e7fcaf9b2e 100644
--- a/test/cider-tests.el
+++ b/test/cider-tests.el
@@ -111,7 +111,7 @@
(describe "when there is a single dependency"
(before-each
- (setq-local cider-jack-in-dependencies '(("nrepl/nrepl" "0.5.3")))
+ (setq-local cider-injected-nrepl-version "0.9.0")
(setq-local cider-injected-middleware-version "0.28.1")
(setq-local cider-jack-in-nrepl-middlewares
'("cider.nrepl/cider-middleware"))
(setq-local cider-jack-in-dependencies-exclusions '())
@@ -120,7 +120,7 @@
(it "can inject dependencies in a lein project"
(expect (cider-inject-jack-in-dependencies "" "repl :headless" 'lein)
:to-equal (concat "update-in :dependencies conj "
- (shell-quote-argument "[nrepl/nrepl
\"0.5.3\"]")
+ (shell-quote-argument "[nrepl/nrepl
\"0.9.0\"]")
" -- update-in :plugins conj "
(shell-quote-argument "[cider/cider-nrepl
\"0.28.1\"]")
" -- update-in :plugins conj "
@@ -133,7 +133,7 @@
(expect (cider-inject-jack-in-dependencies "" "repl :headless" 'lein)
:to-equal (concat
"update-in :dependencies conj "
- (shell-quote-argument "[nrepl/nrepl \"0.5.3\"
:exclusions [org.clojure/clojure]]")
+ (shell-quote-argument "[nrepl/nrepl \"0.9.0\"
:exclusions [org.clojure/clojure]]")
" -- update-in :plugins conj "
(shell-quote-argument "[cider/cider-nrepl
\"0.28.1\"]")
" -- update-in :plugins conj "
@@ -145,7 +145,7 @@
(setq-local cider-jack-in-dependencies-exclusions '(("nrepl/nrepl"
("org.clojure/clojure" "foo.bar/baz"))))
(expect (cider-inject-jack-in-dependencies "" "repl :headless" 'lein)
:to-equal (concat "update-in :dependencies conj "
- (shell-quote-argument "[nrepl/nrepl \"0.5.3\"
:exclusions [org.clojure/clojure foo.bar/baz]]")
+ (shell-quote-argument "[nrepl/nrepl \"0.9.0\"
:exclusions [org.clojure/clojure foo.bar/baz]]")
" -- update-in :plugins conj "
(shell-quote-argument "[cider/cider-nrepl
\"0.28.1\"]")
" -- update-in :plugins conj "
@@ -158,7 +158,7 @@
:to-equal (concat
"-i \"(require 'cider.tasks)\""
" -d "
- (shell-quote-argument "nrepl/nrepl:0.5.3")
+ (shell-quote-argument "nrepl/nrepl:0.9.0")
" -d "
(shell-quote-argument "cider/cider-nrepl:0.28.1")
" cider.tasks/add-middleware"
@@ -179,7 +179,7 @@
(it "can inject dependencies in a lein project"
(expect (cider-inject-jack-in-dependencies "" "repl :headless" 'lein)
:to-equal (concat "update-in :dependencies conj "
- (shell-quote-argument "[nrepl/nrepl
\"0.5.3\"]")
+ (shell-quote-argument "[nrepl/nrepl
\"0.9.0\"]")
" -- update-in :plugins conj "
(shell-quote-argument "[refactor-nrepl
\"2.0.0\"]")
" -- update-in :plugins conj "
@@ -190,15 +190,15 @@
" -- repl :headless")))
(it "can inject dependencies in a boot project"
- (setq-local cider-jack-in-dependencies '(("nrepl/nrepl" "0.5.3")
("refactor-nrepl" "2.0.0")))
+ (setq-local cider-jack-in-dependencies '(("refactor-nrepl" "2.0.0")))
(expect (cider-inject-jack-in-dependencies "" "repl -s wait" 'boot)
:to-equal (concat "-i \"(require 'cider.tasks)\""
" -d "
- (shell-quote-argument "nrepl/nrepl:0.5.3")
- " -d "
- (shell-quote-argument "refactor-nrepl:2.0.0")
+ (shell-quote-argument "nrepl/nrepl:0.9.0")
" -d "
(shell-quote-argument
"cider/cider-nrepl:0.28.1")
+ " -d "
+ (shell-quote-argument "refactor-nrepl:2.0.0")
" cider.tasks/add-middleware"
" -m "
(shell-quote-argument
"refactor-nrepl.middleware/wrap-refactor")
@@ -210,13 +210,12 @@
(before-each
;; FIXME: Needed because its set in an earlier test
(setq-local cider-jack-in-lein-plugins nil)
- (setq-local cider-jack-in-dependencies '(("nrepl/nrepl" "0.5.3")))
(setq-local cider-jack-in-nrepl-middlewares
'("cider.nrepl/cider-middleware"))
(setq-local cider-jack-in-dependencies-exclusions '()))
(it "can concat in a lein project"
(expect (cider-inject-jack-in-dependencies "-o -U" "repl :headless"
'lein)
:to-equal (concat "-o -U update-in :dependencies conj "
- (shell-quote-argument "[nrepl/nrepl
\"0.5.3\"]")
+ (shell-quote-argument "[nrepl/nrepl
\"0.9.0\"]")
" -- update-in :plugins conj "
(shell-quote-argument "[cider/cider-nrepl
\"0.28.1\"]")
" -- update-in :plugins conj "
@@ -227,7 +226,7 @@
(expect (cider-inject-jack-in-dependencies "-C -o" "repl -s wait" 'boot)
:to-equal (concat "-C -o -i \"(require 'cider.tasks)\""
" -d "
- (shell-quote-argument "nrepl/nrepl:0.5.3")
+ (shell-quote-argument "nrepl/nrepl:0.9.0")
" -d "
(shell-quote-argument
"cider/cider-nrepl:0.28.1")
" cider.tasks/add-middleware"
@@ -292,7 +291,7 @@
(it "uses them in a lein project"
(expect (cider-inject-jack-in-dependencies "" "repl :headless" 'lein)
:to-equal (concat "update-in :dependencies conj "
- (shell-quote-argument "[nrepl/nrepl
\"0.5.3\"]")
+ (shell-quote-argument "[nrepl/nrepl
\"0.9.0\"]")
" -- update-in :plugins conj "
(shell-quote-argument "[refactor-nrepl
\"2.0.0\"]")
" -- update-in :plugins conj "
@@ -306,17 +305,17 @@
(before-each
(spy-on 'cider-jack-in-normalized-nrepl-middlewares
:and-return-value '("refactor-nrepl.middleware/wrap-refactor"
"cider.nrepl/cider-middleware"))
- (setq-local cider-jack-in-dependencies '(("nrepl/nrepl" "0.5.3")
("refactor-nrepl" "2.0.0")))
+ (setq-local cider-jack-in-dependencies '(("refactor-nrepl" "2.0.0")))
(setq-local cider-jack-in-dependencies-exclusions '()))
(it "uses them in a boot project"
(expect (cider-inject-jack-in-dependencies "" "repl -s wait" 'boot)
:to-equal (concat "-i \"(require 'cider.tasks)\""
" -d "
- (shell-quote-argument "nrepl/nrepl:0.5.3")
- " -d "
- (shell-quote-argument "refactor-nrepl:2.0.0")
+ (shell-quote-argument "nrepl/nrepl:0.9.0")
" -d "
(shell-quote-argument
"cider/cider-nrepl:0.28.1")
+ " -d "
+ (shell-quote-argument "refactor-nrepl:2.0.0")
" cider.tasks/add-middleware"
" -m "
(shell-quote-argument
"refactor-nrepl.middleware/wrap-refactor")
@@ -398,9 +397,8 @@
"YwBsAG8AagB1AHIAZQAgACIAIgBjAG0AZAAtAHAAYQByAGEAbQBzACIAIgA="))))
(describe "when 'clojure-cli project type"
(it "uses main opts in an alias to prevent other mains from winning"
- (setq-local cider-jack-in-dependencies '(("nrepl/nrepl" "0.8.3")))
(setq-local cider-jack-in-nrepl-middlewares
'("cider.nrepl/cider-middleware"))
- (let ((expected (string-join '("clojure -Sdeps '{:deps {nrepl/nrepl
{:mvn/version \"0.8.3\"} "
+ (let ((expected (string-join '("clojure -Sdeps '{:deps {nrepl/nrepl
{:mvn/version \"0.9.0\"} "
"cider/cider-nrepl {:mvn/version
\"0.28.1\"}} "
":aliases {:cider/nrepl {:main-opts
[\"-m\" \"nrepl.cmdline\" \"--middleware\""
" \"[cider.nrepl/cider-middleware]\"]}}}'
-M:cider/nrepl")
@@ -414,7 +412,7 @@
(expect (plist-get (cider--update-jack-in-cmd nil) :jack-in-cmd)
:to-equal expected)))
(it "allows specifying custom aliases with `cider-clojure-cli-aliases`"
- (let ((expected (string-join '("clojure -Sdeps '{:deps {nrepl/nrepl
{:mvn/version \"0.8.3\"} "
+ (let ((expected (string-join '("clojure -Sdeps '{:deps {nrepl/nrepl
{:mvn/version \"0.9.0\"} "
"cider/cider-nrepl {:mvn/version
\"0.28.1\"}} "
":aliases {:cider/nrepl {:main-opts
[\"-m\" \"nrepl.cmdline\" \"--middleware\""
" \"[cider.nrepl/cider-middleware]\"]}}}'
-M:dev:test:cider/nrepl")
@@ -428,12 +426,12 @@
(expect (plist-get (cider--update-jack-in-cmd nil) :jack-in-cmd)
:to-equal expected)))
(it "handles aliases correctly"
- (let ((expected (string-join '("-Sdeps '{:deps {nrepl/nrepl
{:mvn/version \"0.8.3\"} "
+ (let ((expected (string-join '("-Sdeps '{:deps {nrepl/nrepl
{:mvn/version \"0.9.0\"} "
"cider/cider-nrepl {:mvn/version
\"0.28.1\"}} "
":aliases {:cider/nrepl {:main-opts
[\"-m\" \"nrepl.cmdline\" \"--middleware\""
" \"[cider.nrepl/cider-middleware]\"]}}}'
-M:test:cider/nrepl")
""))
- (deps '(("nrepl/nrepl" "0.8.3"))))
+ (deps '(("nrepl/nrepl" "0.9.0"))))
(let ((cider-clojure-cli-aliases ":test"))
(expect (cider-clojure-cli-jack-in-dependencies nil nil deps)
:to-equal expected))
@@ -451,12 +449,12 @@
(expect (cider-clojure-cli-jack-in-dependencies nil nil deps)
:to-equal expected)))))
(it "allows for global options"
- (let ((expected (string-join '("-J-Djdk.attach.allowAttachSelf -Sdeps
'{:deps {nrepl/nrepl {:mvn/version \"0.8.3\"} "
+ (let ((expected (string-join '("-J-Djdk.attach.allowAttachSelf -Sdeps
'{:deps {nrepl/nrepl {:mvn/version \"0.9.0\"} "
"cider/cider-nrepl {:mvn/version
\"0.28.1\"}} "
":aliases {:cider/nrepl {:main-opts
[\"-m\" \"nrepl.cmdline\" \"--middleware\""
" \"[cider.nrepl/cider-middleware]\"]}}}'
-M:test:cider/nrepl")
""))
- (deps '(("nrepl/nrepl" "0.8.3"))))
+ (deps '(("nrepl/nrepl" "0.9.0"))))
(let ((cider-clojure-cli-aliases ":test"))
(expect (cider-clojure-cli-jack-in-dependencies
"-J-Djdk.attach.allowAttachSelf" nil deps)
:to-equal expected))))))
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [nongnu] elpa/cider 83f18a9ad4: [#3133] Check the version of cider-injected-nrepl-version at runtime,
ELPA Syncer <=