Skip to content

Latest commit

 

History

History
321 lines (222 loc) · 14.9 KB

API.md

File metadata and controls

321 lines (222 loc) · 14.9 KB

Table of contents


Port of https://github.com/clojure/brew-install/blob/1.11.1/src/main/resources/clojure/install/clojure in Clojure

(*aux-process-fn* {:keys [cmd out]})

Invokes java with arguments to calculate classpath, etc. May be replaced by rebinding this dynamic var.

Called with a map of:

  • :cmd: a vector of strings
  • :out: if set to :string, :out key in result must contains stdout

Returns a map of:

  • :exit, the exit code of the process
  • :out, the string of stdout, if the input :out was set to :string

Source

(*clojure-process-fn* {:keys [cmd]})

Invokes java with arguments to clojure.main to start Clojure. May be replaced by rebinding this dynamic var.

Called with a map of:

  • :cmd: a vector of strings

Must return a map of :exit, the exit code of the process.

Source

Can be dynamically rebound to customise the download of the Clojure tools. Should be bound to a function accepting a map with:

  • :url: The URL to download, as a string
  • :dest: The path to the file to download it to, as a string
  • :proxy-opts: a map as returned by get-proxy-info
  • :clj-jvm-opts: a vector of JVM opts (as passed on the command line).

Should return true if the download was successful, or false if not.

Source

Directory in which deps.clj should be executed.

Source

(*exit-fn* {:keys [exit message]})

Function that is called on exit with :exit code and :message, an exceptional message when exit is non-zero

Source

(*getenv-fn* env)

Get ENV'ironment variable, typically used for getting CLJ_CONFIG, etc.

Source

(-main & command-line-args)

See help-text.

In addition

  • the values of the CLJ_JVM_OPTS and JAVA_OPTIONS environment variables are passed to the java subprocess as command line options when downloading dependencies and running any other commands respectively.

  • if the clojure tools jar cannot be located and the clojure tools archive is not found, an attempt is made to download the archive from the official site and extract its contents locally. The archive is downloaded from this process directly, unless the CLJ_JVM_OPTS env variable is set and a succesful attempt is made to download the archive by invoking a java subprocess passing the env variable value as command line options.

Source

(clojure-tools-download-direct! {:keys [url dest]})

Downloads from :url to :dest file returning true on success.

Source

(clojure-tools-download-java! {:keys [url dest proxy-opts clj-jvm-opts]})

Downloads :url zip file to :dest by invoking java with :proxy options on a .java program file, and returns true on success. Requires Java 11+ (JEP 330).

Source

(clojure-tools-install! {:keys [out-dir debug proxy-opts clj-jvm-opts]})

Installs clojure tools archive by downloading it in :out-dir, if not already there, and extracting in-place.

If *clojure-tools-download-fn* is set, it will be called for download the tools archive. This function should return a truthy value to indicate a successful download.

The download is attempted directly from this process, unless :clj-jvm-opts is set, in which case a java subprocess is created to download the archive passing in its value as command line options.

It calls *exit-fn* if it cannot download the archive, with instructions how to manually download it.

Source

The current version of deps.clj

Source

(get-basis-file {:keys [cache-dir checksum]})

Returns path to basis file. Required options:

    • checksum as returned by get-check-sum

Source

(get-cache-dir {:keys [deps-edn config-dir]})

Returns cache dir (.cpcache) from either local dir, if deps-edn exists, or the user cache dir.

Source

(get-checksum {:keys [cli-opts config-paths]})

Returns checksum based on cli-opts (as returned by parse-cli-opts) and config-paths (as returned by get-config-paths)

Source

(get-config-dir)

Retrieves configuration directory. First tries CLJ_CONFIG env var, then $XDG_CONFIG_HOME/clojure, then ~/.clojure.

Source

(get-config-paths {:keys [cli-opts deps-edn config-dir install-dir]})

Returns vec of configuration paths, i.e. deps.edn from:

Source

(get-help)

Returns help text as string.

Source

(get-install-dir)

Retrieves the install directory where tools jar is located (after download). Defaults to ~/.deps.clj//ClojureTools.

Source

(get-local-deps-edn {:keys [cli-opts]})

Returns the path of the deps.edn file (as string) in the current directory or as set by -Sdeps-file. Required options:

  • :cli-opts: command line options as parsed by parse-opts

Source

(get-proxy-info)

Returns a map with proxy information parsed from env vars. The map will contain :http-proxy and :https-proxy entries if the relevant env vars are set and parsed correctly. The value for each is a map with :host and :port entries.

Source

(parse-cli-opts args)

Parses the command line options.

Source

(print-help)

Print help text

Source

(proxy-jvm-opts {:keys [http-proxy https-proxy]})

Returns a vector containing the JVM system property arguments to be passed to a new process to set its proxy system properties. proxy-info parameter is as returned from get-proxy-info.

Source

(set-proxy-system-props! {:keys [http-proxy https-proxy]})

Sets the proxy system properties in the current JVM. proxy-info parameter is as returned from get-proxy-info.

Source