Skip to content

Commit

Permalink
Bump io.github.rads/deps-info to v0.0.10
Browse files Browse the repository at this point in the history
New features:
- Support inference for private Git repos (resolves #48)
- Support all possible "lib to url" cases (resolves #3)
  • Loading branch information
rads committed Jan 16, 2023
1 parent 52df3fd commit 6a3b28c
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 34 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ jobs:
steps:
- name: Check out repository code
uses: actions/checkout@v3
- uses: webfactory/[email protected]
with:
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}
- name: Install clojure tools
uses: DeLaGuardo/[email protected]
with:
Expand All @@ -16,6 +19,9 @@ jobs:
steps:
- name: Check out repository code
uses: actions/checkout@v3
- uses: webfactory/[email protected]
with:
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}
- name: Install clojure tools
uses: DeLaGuardo/[email protected]
with:
Expand Down
11 changes: 2 additions & 9 deletions bbin
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
fipp/fipp {:mvn/version "0.6.26"},
com.taoensso/timbre {:mvn/version "5.2.1"},
selmer/selmer {:mvn/version "1.12.53"},
io.github.rads/deps-info {:git/tag "v0.0.9", :git/sha "01f34ac"}}})
io.github.rads/deps-info {:git/tag "v0.0.10", :git/sha "b5144db"}}})

(ns babashka.bbin.meta)
(def min-bb-version "This def was generated by the bbin build script." "0.9.162")
Expand Down Expand Up @@ -161,7 +161,6 @@ WARNING: - Set the BABASHKA_BBIN_BIN_DIR env variable to \"$HOME/.babashka/bbi
(:require [babashka.bbin.util :as util :refer [sh]]
[babashka.deps :as deps]
[babashka.fs :as fs]
[cheshire.core :as json]
[clojure.edn :as edn]
[clojure.java.io :as io]
[clojure.pprint :as pprint]
Expand Down Expand Up @@ -503,16 +502,10 @@ WARNING: - Set the BABASHKA_BBIN_BIN_DIR env variable to \"$HOME/.babashka/bbi
{:main-opts ["-m" (str top "." name)]
:ns-default (str top "." name)}))

(def ^:private deps-info-client
{:http-get-json #(json/parse-string (:body @(apply http/get %&)) true)})

(defn- deps-info-infer [& {:as opts}]
(deps-info-infer/infer deps-info-client opts))

(defn- install-deps-git-or-local [cli-opts {:keys [procurer] :as _summary}]
(let [script-deps (if (and (#{:local} procurer) (not (:local/root cli-opts)))
{::no-lib {:local/root (str (fs/canonicalize (:script/lib cli-opts) {:nofollow-links true}))}}
(deps-info-infer (assoc cli-opts :lib (:script/lib cli-opts))))
(deps-info-infer/infer (assoc cli-opts :lib (:script/lib cli-opts))))
lib (key (first script-deps))
coords (val (first script-deps))
header (merge {:coords coords} (when-not (#{::no-lib} lib) {:lib lib}))
Expand Down
2 changes: 1 addition & 1 deletion deps.edn
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
fipp/fipp {:mvn/version "0.6.26"}
com.taoensso/timbre {:mvn/version "5.2.1"}
selmer/selmer {:mvn/version "1.12.53"}
io.github.rads/deps-info {:git/tag "v0.0.9" :git/sha "01f34ac"}}
io.github.rads/deps-info {:git/tag "v0.0.10" :git/sha "b5144db"}}
:aliases {:neil {:project {:name babashka/bbin
:version "0.1.5"}}}}
9 changes: 1 addition & 8 deletions src/babashka/bbin/scripts.clj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
(:require [babashka.bbin.util :as util :refer [sh]]
[babashka.deps :as deps]
[babashka.fs :as fs]
[cheshire.core :as json]
[clojure.edn :as edn]
[clojure.java.io :as io]
[clojure.pprint :as pprint]
Expand Down Expand Up @@ -344,16 +343,10 @@
{:main-opts ["-m" (str top "." name)]
:ns-default (str top "." name)}))

(def ^:private deps-info-client
{:http-get-json #(json/parse-string (:body @(apply http/get %&)) true)})

(defn- deps-info-infer [& {:as opts}]
(deps-info-infer/infer deps-info-client opts))

(defn- install-deps-git-or-local [cli-opts {:keys [procurer] :as _summary}]
(let [script-deps (if (and (#{:local} procurer) (not (:local/root cli-opts)))
{::no-lib {:local/root (str (fs/canonicalize (:script/lib cli-opts) {:nofollow-links true}))}}
(deps-info-infer (assoc cli-opts :lib (:script/lib cli-opts))))
(deps-info-infer/infer (assoc cli-opts :lib (:script/lib cli-opts))))
lib (key (first script-deps))
coords (val (first script-deps))
header (merge {:coords coords} (when-not (#{::no-lib} lib) {:lib lib}))
Expand Down
38 changes: 22 additions & 16 deletions test/babashka/bbin/scripts_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,13 @@

(def bbin-test-lib
'{:lib io.github.rads/bbin-test-lib,
:coords {:git/url "https://github.com/rads/bbin-test-lib",
:coords {:git/url "https://github.com/rads/bbin-test-lib.git",
:git/tag "v0.0.1",
:git/sha "9140acfc12d8e1567fc6164a50d486de09433919"}})

(def bbin-test-lib-private
'{:lib io.github.rads/bbin-test-lib-private,
:coords {:git/url "[email protected]:rads/bbin-test-lib-private.git",
:git/tag "v0.0.1",
:git/sha "9140acfc12d8e1567fc6164a50d486de09433919"}})

Expand All @@ -25,18 +31,7 @@
(util/ensure-bbin-dirs cli-opts)
(is (= {} (scripts/load-scripts cli-opts)))
(spit (fs/file (util/bin-dir cli-opts) "test-script") test-script)
(is (= '{test-script
{:lib io.github.rads/bbin-test-lib,
:coords {:git/url "https://github.com/rads/bbin-test-lib",
:git/tag "v0.0.1",
:git/sha "9140acfc12d8e1567fc6164a50d486de09433919"}}}
(scripts/load-scripts cli-opts)))))

(def test-lib
{:lib 'io.github.rads/bbin-test-lib
:coords {:git/url "https://github.com/rads/bbin-test-lib"
:git/tag "v0.0.1"
:git/sha "9140acfc12d8e1567fc6164a50d486de09433919"}})
(is (= {'test-script bbin-test-lib} (scripts/load-scripts cli-opts)))))

(def portal-script-url
(str "https://gist.githubusercontent.com"
Expand All @@ -56,14 +51,25 @@
{:keys [out]} (sh args {:err :inherit})]
(str/trim out)))

(deftest install-from-qualified-lib-name-test
(testing "install */*"
(deftest install-from-qualified-lib-name-public-test
(testing "install */* (public Git repo)"
(reset-test-dir)
(util/ensure-bbin-dirs {})
(let [cli-opts {:script/lib "io.github.rads/bbin-test-lib"}
out (run-install cli-opts)
bin-file (fs/file bin-dir "hello")]
(is (= test-lib out))
(is (= bbin-test-lib out))
(is (fs/exists? bin-file))
(is (= "Hello world!" (run-bin-script 'hello))))))

(deftest install-from-qualified-lib-name-private-test
(testing "install */* (private Git repo)"
(reset-test-dir)
(util/ensure-bbin-dirs {})
(let [cli-opts {:script/lib "io.github.rads/bbin-test-lib-private"}
out (run-install cli-opts)
bin-file (fs/file bin-dir "hello")]
(is (= bbin-test-lib-private out))
(is (fs/exists? bin-file))
(is (= "Hello world!" (run-bin-script 'hello))))))

Expand Down

0 comments on commit 6a3b28c

Please sign in to comment.