Merge branch 'master' into repl-deps

This commit is contained in:
Michiel Borkent 2024-09-06 17:40:40 +02:00
commit f9f1b25449
10 changed files with 26 additions and 51 deletions

1
.gitignore vendored
View file

@ -38,3 +38,4 @@ target
.DS_Store .DS_Store
.portal .portal
default.iprof default.iprof
scratch.clj

View file

@ -9,6 +9,8 @@ A preview of the next release can be installed from
## Unreleased ## Unreleased
- Upgrade Clojure to `1.12.0`
- [#1720](https://github.com/babashka/babashka/issues/1720): Include `clojure.java.process`
- [#1598](https://github.com/babashka/babashka/issues/1598): use Rosetta on CircleCI to build x64 images - [#1598](https://github.com/babashka/babashka/issues/1598): use Rosetta on CircleCI to build x64 images
- Bump SCI - Bump SCI
- Bump `fs` - Bump `fs`

View file

@ -40,10 +40,10 @@ As one user described it:
## Quickstart ## Quickstart
For installation options check [Installation](https://github.com/babashka/babashka#installation). For installation options check [Installation](https://github.com/babashka/babashka#installation).
For quick installation use: For quick installation using `bash`, use:
``` shell ``` shell
$ bash < <(curl -s https://raw.githubusercontent.com/babashka/babashka/master/install) bash < <(curl -s https://raw.githubusercontent.com/babashka/babashka/master/install)
``` ```
or grab a binary from [Github or grab a binary from [Github
@ -53,9 +53,12 @@ anywhere on the path.
Then you're ready to go: Then you're ready to go:
``` shellsession ``` shellsession
$ ls | bb -i '(filter fs/directory? *input*)' time bb -e '(->> (fs/list-dir ".") (filter fs/directory?) (map fs/normalize) (map str) (take 3))'
("doc" "resources" "sci" "script" "src" "target" "test") ```
bb took 4ms.
``` clojure
(".build" "feature-lanterna" ".repl")
bb -e 0,01s user 0,01s system 70% cpu 0,017 total
``` ```
## Support :heart: ## Support :heart:
@ -120,46 +123,6 @@ by Daniel Higginbotham, who has also helped a lot of people learn Clojure with
[Clojure for the Brave and [Clojure for the Brave and
True](https://www.braveclojure.com/clojure-for-the-brave-and-true/). True](https://www.braveclojure.com/clojure-for-the-brave-and-true/).
## Examples
Read the output from a shell command as a lazy seq of strings:
``` shell
$ ls | bb -i '(take 2 *input*)'
("CHANGES.md" "Dockerfile")
```
Read EDN from stdin and write the result to stdout:
``` shell
$ bb '(vec (dedupe *input*))' <<< '[1 1 1 1 2]'
[1 2]
```
Read more about `*input*` and in- and output flags
[here](https://book.babashka.org/#_input_and_output_flags).
Execute a script. E.g. print the current time in California using the
`java.time` API:
File `pst.clj`:
``` clojure
#!/usr/bin/env bb
(def now (java.time.ZonedDateTime/now))
(def LA-timezone (java.time.ZoneId/of "America/Los_Angeles"))
(def LA-time (.withZoneSameInstant now LA-timezone))
(def pattern (java.time.format.DateTimeFormatter/ofPattern "HH:mm"))
(println (.format LA-time pattern))
```
``` shell
$ bb pst.clj
05:17
```
More examples can be found [here](examples/README.md).
## Try online ## Try online
You can try babashka online with Nextjournal's babashka [notebook You can try babashka online with Nextjournal's babashka [notebook

View file

@ -18,7 +18,7 @@
"deps.clj/src" "deps.clj/resources" "deps.clj/src" "deps.clj/resources"
"resources" "sci/resources" "resources" "sci/resources"
"impl-java/src"], "impl-java/src"],
:deps {org.clojure/clojure {:mvn/version "1.11.2"}, :deps {org.clojure/clojure {:mvn/version "1.12.0"},
org.babashka/sci {:local/root "sci"} org.babashka/sci {:local/root "sci"}
org.babashka/babashka.impl.java {:mvn/version "0.1.8"} org.babashka/babashka.impl.java {:mvn/version "0.1.8"}
org.babashka/sci.impl.types {:mvn/version "0.0.2"} org.babashka/sci.impl.types {:mvn/version "0.0.2"}

2
fs

@ -1 +1 @@
Subproject commit 11121dedba416e93ce1eb69674c78f269a1f3e0a Subproject commit 99d6a3b2f55b851a6949ed6eee31412b299dcf01

View file

@ -21,8 +21,8 @@
:non-flaky (complement :flaky) :non-flaky (complement :flaky)
:flaky :flaky} :flaky :flaky}
:jvm-opts ["--enable-preview"] :jvm-opts ["--enable-preview"]
:dependencies [[org.clojure/clojure "1.11.2"] :dependencies [[org.clojure/clojure "1.12.0"]
[borkdude/edamame "1.4.24"] [borkdude/edamame "1.4.27"]
[borkdude/graal.locking "0.0.2"] [borkdude/graal.locking "0.0.2"]
[org.clojure/tools.cli "1.0.214"] [org.clojure/tools.cli "1.0.214"]
[cheshire "5.13.0"] [cheshire "5.13.0"]

2
sci

@ -1 +1 @@
Subproject commit c556f4474303c61da72e7a07eef496dcbf66a56e Subproject commit f766255d14647d46486546dc6afce1ae1bcd2c7b

View file

@ -0,0 +1,6 @@
(ns babashka.impl.clojure.java.process
(:require [clojure.java.process]
[sci.core :as sci]))
(def cjp (sci/create-ns 'clojure.java.process nil))
(def cjp-namespace (sci/copy-ns clojure.java.process cjp))

View file

@ -25,6 +25,7 @@
[babashka.impl.clojure.tools.reader-types :refer [edn-namespace [babashka.impl.clojure.tools.reader-types :refer [edn-namespace
reader-types-namespace]] reader-types-namespace]]
[babashka.impl.clojure.zip :refer [zip-namespace]] [babashka.impl.clojure.zip :refer [zip-namespace]]
[babashka.impl.clojure.java.process :refer [cjp-namespace]]
[babashka.impl.common :as common] [babashka.impl.common :as common]
[babashka.impl.core :as bbcore] [babashka.impl.core :as bbcore]
[babashka.impl.curl :refer [curl-namespace]] [babashka.impl.curl :refer [curl-namespace]]
@ -389,6 +390,7 @@ Use bb run --help to show this help output.
'main main-var} 'main main-var}
'clojure.test t/clojure-test-namespace 'clojure.test t/clojure-test-namespace
'clojure.math math-namespace 'clojure.math math-namespace
'clojure.java.process cjp-namespace
'babashka.classpath classpath-namespace 'babashka.classpath classpath-namespace
'babashka.classes classes-namespace 'babashka.classes classes-namespace
'clojure.pprint pprint-namespace 'clojure.pprint pprint-namespace

View file

@ -11,7 +11,8 @@
(-> line str/trimr (-> line str/trimr
;; take into account JDK14+ and native image differences ;; take into account JDK14+ and native image differences
(str/replace "class clojure.lang" "clojure.lang") (str/replace "class clojure.lang" "clojure.lang")
(str/replace #" \(.*\)$" ""))) (str/replace #" \(.*\)$" "")
(str/replace #"--\d\d\d\d" "")))
(defmacro multiline-equals [s1 s2] (defmacro multiline-equals [s1 s2]
`(let [lines-s1# (str/split-lines ~s1) `(let [lines-s1# (str/split-lines ~s1)