Functions for resolving npm dependencies declared in deps.cljs
files on the
classpath.
This code is a simplified version of code in thheller's shadow-cljs library and the clerk-utils library.
Functions for resolving npm dependencies declared in `deps.cljs` files on the classpath. This code is a simplified version of code in thheller's [shadow-cljs](https://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/cljs/devtools/server/npm_deps.clj) library and the [clerk-utils](https://github.com/mentat-collective/Clerk-Utils/blob/main/src/mentat/clerk_utils/build/shadow.clj) library.
(dep->str dep-id)
Given a dependency name (specified as a key in the :npm-deps
map of
deps.cljs
), returns an npm-compatible (string) name for the dependency.
Given a dependency name (specified as a key in the `:npm-deps` map of `deps.cljs`), returns an npm-compatible (string) name for the dependency.
(get-deps-from-classpath)
Returns a sequence of maps of the form {:id <str> :version <str> :url
<url-of-this-deps.cljs>} for every dependency specified via the :npm-deps
key of each deps.cljs
file on the classpath.
Returns a sequence of maps of the form {:id <str> :version <str> :url <url-of-this-deps.cljs>} for every dependency specified via the `:npm-deps` key of each `deps.cljs` file on the classpath.
(is-installed? {:keys [id]} package-json)
Returns true if the supplied dependency is already present in some entry in the
parsed package-json
, false otherwise.
Returns true if the supplied dependency is already present in some entry in the parsed `package-json`, false otherwise.
System-specific NPM command, tuned for Windows or non-Windows.
System-specific NPM command, tuned for Windows or non-Windows.
(npm-install!)
This command:
npm install
(if ./package.json is present)deps.cljs
file on the classpathThe npm install
makes sure that if some dependency specified in a
deps.cljs
is already present in package.json
that it actually ends up in
node_modules
.
This command: - Triggers an `npm install` (if ./package.json is present) - Installs any dependency referenced by a `deps.cljs` file on the classpath The `npm install` makes sure that if some dependency specified in a `deps.cljs` is already present in `package.json` that it actually ends up in `node_modules`.
(read-package-json)
(read-package-json install-dir)
Returns a map with the contents of package.json if it exists in
install-dir
(default "."), {} otherwise.
Returns a map with the contents of package.json if it exists in `install-dir` (default "."), {} otherwise.
(resolve-conflicts deps)
Given a sequence of dependencies, returns a sequence of dependencies distinct by ID generated by picking the first one on the classpath.
Not ideal, but this is how shadow currently does it!
Given a sequence of dependencies, returns a sequence of dependencies distinct by ID generated by picking the first one on the classpath. Not ideal, but this is how shadow currently does it!
(sh-print command)
Takes a vector of command pieces, prints the command and prints the results.
Takes a vector of command pieces, prints the command and prints the results.
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close