Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@bltavares
Copy link
Contributor

Since #123 it is now possible to use cljfmt without integrating it with lein.
This is very useful for CI scripts, where you might want to check for indentation, but would rather not download all the projects dependencies.

This commit documents the usage with deps-tools, using the clojure command line to execute cljfmt without using the pluging interface. It includes how to configure the tool without using the lein profile setup.

Closes #93

bltavares added a commit to bltavares/actions that referenced this pull request Feb 4, 2019
When using `cljfmt` action, we ended up downloading all the dependencies
of the project, as it would be integrated as a `lein` plugin.

This was cumbersome, as it required exposing extra configuration to
access the project's dependencies as well. Ideally, to reduce the
adoption, it would be better to use `cljfmt` as a globally accessible
tool, without the need to access the project's dependencies from GitHub
Actions' execution environment.

There is a [previously undocumented feature](weavejester/cljfmt#164)
on `cljfmt` which exposes it as a `deps-tools` executable.

This commit refactors the execution to run the formatter from a global
execution path. This means we don't need extra access to the project
dependencies.

The configuration to use the formatter don't live anymore inside
`lein`'s `project.clj`, and now is expected to live on their own
file inside the project, as it is documented.

We are also taking a chance to refactor a couple of things on the
`zprint` action, which is somewhat complementary to `cljfmt`.
Copy link
Owner

@weavejester weavejester left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the patch! I have a few changes which need to be addressed before I can merge this.

Please also ensure the commit message follows the contributing guidelines, and uses plain text rather than markdown.

README.md Outdated

lein cljfmt fix src/foo/core.clj

### deps-tools usage
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be deps.tools.

README.md Outdated

### deps-tools usage

It is possible to execute `cljfmt` using the [clojure](https://clojure.org/guides/deps_and_cli) CLI, without integrating with `lein`.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line should be wrapped at. 72 characters. Use reference link format, e.g.

using the [clojure CLI][],, without Leiningen.

[clojure cli]: https://clojure.org/guides/deps_and_cli

README.md Outdated
It is possible to execute `cljfmt` using the [clojure](https://clojure.org/guides/deps_and_cli) CLI, without integrating with `lein`.

```bash
clojure -Sdeps '{:deps {lein-cljfmt {:mvn/version "0.6.4"}}}' -m cljfmt.main [check|fix]
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use cljfmt, not lein-cljfmt.

README.md Outdated
clojure -Sdeps '{:deps {lein-cljfmt {:mvn/version "0.6.4"}}}' -m cljfmt.main [check|fix]
```

Customizing the rules is possible passing `edn` formated files, using the same content used on lein profiles.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wrap line.

README.md Outdated

Customizing the rules is possible passing `edn` formated files, using the same content used on lein profiles.

As example, with the following content to the `indentation.edn` file, it is possible to customize the rules.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wrap line.

README.md Outdated
```

```bash
clojure -Sdeps '{:deps {lein-cljfmt {:mvn/version "0.6.4"}}}' -m cljfmt.main check --indents indentation.edn
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use cljfmt instead of lein-cljfmt.

@bltavares
Copy link
Contributor Author

@weavejester I've updated the document according to the feedback. Let me know if there are still anything else :)

@bltavares bltavares changed the title Documents usage with deps-tools Documents usage with deps.tools Feb 26, 2019
@weavejester
Copy link
Owner

Sorry for leaving this PR hanging. It got a little lost in my inbox! There's still a few formatting changes that are missed out, and the commit message has a bunch of backticks in it.

Do you want me to list the changes, or shall I edit your commit with the changes directly?

@bltavares
Copy link
Contributor Author

Sorry for taking longer to check back as well.

I've removed backticks from the commit message, as I was not sure if they should be replaced by simple quotes, but let me know if it would be better to quote any word.

I've made sure both readme and commit message have short lines as well.

@weavejester
Copy link
Owner

Thanks! Can you change the commit message to:

Document usage with deps.tools

Since #123 it is now possible to use cljfmt without integrating it with
Leiningen. This commit adds documentation to the README on how to
achieve that.

Closes #93.

I'm using standard formatting here: imperative mood, wrap subject at 50, body at 72.

Can you also change line 68 onward, as per my earlier comment:

It is possible to execute cljfmt using the [clojure CLI][], without
integrating with Leiningen.

[clojure cli]: https://clojure.org/guides/deps_and_cli

I'm happy to make the changes to the commit and merge if you don't have the time.

Since weavejester#123 it is now possible to use cljfmt without integrating it with
Leiningen. This commit adds documentation to the README on how to
achieve that.

Closes weavejester#93.
@lread
Copy link
Contributor

lread commented Jul 28, 2019

This is useful info, much thanks!

@weavejester weavejester merged commit bb0aeae into weavejester:master Dec 20, 2019
@bltavares bltavares deleted the patch-1 branch February 20, 2021 02:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Non-lein configurability

3 participants