Fork me on GitHub
#polylith
<
2023-09-22
>
tengstrand04:09:46

Hi everyone! I'm getting great help from @lee going through all the poly tool documentation in issue 318. Now we've reached the install and workspace pages, and an old idea of min came to the surface. The idea is to make clojure -M:poly (that starts a shell) the default way of working with the poly tool. Installing the stand-alone poly tool will then be something you do when you really need it (if ever). The first time we create a workspace, we can bootstrap it with clojure -Sdeps '{:deps {polylith/clj-poly {:mvn/version "RELEASE"}}}' -M -m polylith.clj.core.poly-cli.core create workspace name:example top-ns:se.example :commit and after that, we can start a shell from the example workspace directory with clojure -M:poly which removes the need to install the stand-alone tool. Now I want to ask the community if this makes sense to you. It will make it easier to get started with the poly tool, as we only rely on the tools.deps machinery that installs the poly tool for us in the local Maven repo in ~/.m2/repository/polylith/clj-poly.

seancorfield04:09:19

One thing I will say is that clojure -M:poly is pretty slow to start up. I've been thinking about AOT-compiling this (once) into each repo to make tool startup faster but haven't quite got around to figuring out the mechanics of it in an ergonomic way.

☝️ 1
seancorfield04:09:12

Similarly, I think the initial "bootstrap" command is way overly complex, given that creating new projects is something beginners do a lot but experienced devs do very rarely.

seancorfield04:09:22

I think that having a good Polylith project template for deps-new would be a good approach. I have one for clj-new -- https://github.com/seancorfield/clj-new/#the-polylith-template -- but I'm trying to retire that and encourage folks to switch to deps-new.

seancorfield04:09:22

Then setup becomes:

# do this just once:
clojure -Ttools install-latest :lib io.github.seancorfield/deps-new :as new
# then create new poly repos:
clojure -Tnew polylith :name my.new/repo

seancorfield04:09:24

My assumptions in the clj-new polylith template are quite opinionated -- it creates a workspace with a base, a component, and a project rather than just a sparse workspace -- so I'd really like the deps-new polylith template to be more in keeping with what clojure -M:poly create workspace name:whatever top-ns:some.thing creates.

tengstrand05:09:44

A problem I see with this is to introduce one more "tool" to create a workspace. It's not a big issue, but having only one way is simpler. I think keeping the installation instruction pretty much as it is today and then adding the bootstrap option is maybe the way to go.

tengstrand05:09:26

A way to experiment with creating workspaces would also be to install it as a Clojure CLI Tool with clojure -Ttools install io.github.polyfy/polylith '{:git/tag "v0.2.18" :deps/root "projects/poly"}' :as poly and then they can use clojure -Tpoly create workspace name:whatever top-ns:some.thing.

seancorfield05:09:58

clojure -Ttools install-latest :lib io.github.polyfy/polylith :as poly would be better -- but you lose the :deps/root config 😞

seancorfield05:09:39

And also, the poly "tool" has to use the EDN arguments so it isn't create workspace etc.

seancorfield05:09:26

Besides, if you install deps-new :as new you get to create all sorts of things -- if it gets a polylith template project...

tengstrand05:09:56

Yes, you are right. But they can start a shell with clojure -Tpoly shell first, and then create a workspace from there (then they also get autocomplete when doing that).

seancorfield05:09:57

My dot-clojure repo has poly as an installed tool BTW (although I probably need to update it).

tengstrand05:09:44

I still think skipping the installation step initially, feels like a good idea, as it will get people started more quickly. We can tell the user to install the poly tool as a Clojure CLI Tool, and use the -T syntax to start a shell to create the initial workspace, and then use -T or -M when going forward. If they execute commands outside of a shell and feel that is slow, then they can install the stand-alone tool.

1
seancorfield05:09:14

I will admit that I like the shell a lot 🙂

❤️ 2
lread16:09:13

This is all very interesting info, thanks! @U1G0HH87L and I have decided not to try to solve all the issues we discover while reviewing the docs. We can raise git issues as needed. This one, to me, seems like a great candidate for a decision matrix.

tengstrand16:09:53

Yes, let's wait with this.

tengstrand16:09:12

Let's postpone this and create a decision matrix or similar in the future.

Paavo Pokkinen05:09:43

Thoughts on how nicely Poly tool integrates with build system like Bazel? As I understand, Poly does some magic to resolve dependencies and knows which tests to run, but does that overlap with Bazel? Haven’t used either one (yet), we’re about to adopt monorepo architecture, and probably also some polyglot tool like Bazel (as we have other software in stack than just clojure)

seancorfield05:09:01

poly relies on the Clojure CLI and tools.deps so it doesn't overlap with Bazel at all.

seancorfield05:09:56

You can definitely have a polyglot repo, but the poly tool isn't going to know how to deal with the non-Clojure parts of your repo. What other languages are you using?

Paavo Pokkinen06:09:27

Frontend part is svelte/JS. But really, it could be anything that will be stored in monorepo. Poly tool doesn’t help with building at all, so there might be some need to trigger builds for projects when specific component used there changes. I still haven’t decided if we’ll have one or multiple Polylith workspaces within the monorepo.