Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Polylith and monorepo jack-in/connect better #1254

Closed
PEZ opened this issue Aug 7, 2021 · 6 comments
Closed

Support Polylith and monorepo jack-in/connect better #1254

PEZ opened this issue Aug 7, 2021 · 6 comments

Comments

@PEZ
Copy link
Collaborator

PEZ commented Aug 7, 2021

Polylith repositories are monorepos where you are supposed to start one REPL to be able to develop and ”reach” all sub-projects, etcetera. deps.edn files are used to configure things on many levels, but there is seldom any use for starting separate REPLs for these.

Today Calva only considers the regular monorepo case with separate projects and separate REPLs. So when jacking in to a project, Calva looks for the ”closest” (from the current directory and up to the repo/window/workspace root) project file (deps.edn, project.clj, shadow-cljs.edn) and presents a jack-in menu based in this file. This doesn't make sense for Polylith projects.

Generally, I think what makes sense is for Calva to ”collect” project files from the current file up to the repo/window/workspace root and present a menu where the user can select one of those. This makes sense regardless of if it is a monorepo or not and regardless if it is a regular monorepo or a Polylith project.

We could consider recognizing Polylith projects as well and give even more guidance, but that might be for a separate issue to request.

@furkan3ayraktar
Copy link

This sounds great! I usually start my REPL with clj -A:dev:+default:test. dev and test gets all the components and their respective tests and +default gets default components where I have two components implementing the same interface. These aliases come from the root deps.edn in my Polylith workspace. I don't recall any time that I started a REPL for a specific project since they are only deployment configurations.

@PEZ PEZ changed the title Support Polylith repositor jack-in/connect better Support Polylith repository jack-in/connect better Aug 7, 2021
@PEZ
Copy link
Collaborator Author

PEZ commented Aug 7, 2021

I don't recall any time that I started a REPL for a specific project since they are only deployment configuration

Thanks for confirming this!

The selection of aliases is left up to the user today. Right now I can't think of a general solution for adding suggestions for this to a project type. But we should of course add something like:

When selecting aliases, always include :dev, :test, and (when present) :+default.

To the documentation of how to use Calva with Polylith: https://calva.io/polylith/

@bpringe
Copy link
Member

bpringe commented Aug 8, 2021

Generally, I think what makes sense is for Calva to ”collect” project files from the current file up to the repo/window/workspace root and present a menu where the user can select one of those.

Wow, I've actually been thinking about this menu feature too recently! I've been using Polylith for a project for my job, and have repeatedly tried to jack-in while I have some source file open, and then I have to close that menu (because it uses some sub-level deps.edn) and open my top-level deps.edn then run jack-in again. It's been a bit annoying.

@armed
Copy link
Contributor

armed commented Sep 20, 2021

Thats going to be major improvement to monorepo projects.

We started our project few years before polylith emerged. But our case is something polylith-like. One root deps file with all aliases and dependencies to subprojects and one subproject (commons) with all external dependencies.

Now I'm evaluating Calva for our new team members and trying to configure all connect sequences etc. The one thing that always we have to do before jack-in is select root deps.edn, it would be great to launch repl from any nested project without needing to focus on root file.

Additionally we have several remote repl servers and configured .remote-<project-name>-port files for each of them in root directory.

I wish I could just set some flag (e.q. useRootProject = true) to all my connect sequences to launch from workspace context.

@PEZ PEZ changed the title Support Polylith repository jack-in/connect better Support Polylith and monorepo jack-in/connect better Sep 20, 2021
PEZ added a commit that referenced this issue Mar 20, 2022
Let the user pick if there are more than one
Changes the way we find the closest project root
Not using node fs module at all
Fixes #1254
@PEZ
Copy link
Collaborator Author

PEZ commented Mar 21, 2022

Here's a VSIX addressing this issue.

https://19850-125431277-gh.circle-artifacts.com/0/tmp/artifacts/calva-2.0.257-1254-multiple-project-roots-20c13d0e.vsix

I took a slightly different, simpler, path than what I described above. The connect process now starts by figuring out possible project roots,. If there are more than one, it will present a menu where the user can pick. Then connect continues as before.

See updated connect docs here: https://github.com/BetterThanTomorrow/calva/blob/1254-multiple-project-roots/docs/site/connect.md

Even if simpler than what I first planed for, it is still a significant change. Please test it throughly. ❤️

@brettrowberry
Copy link
Contributor

This broke my connect sequence in my monorepo. Trying to create a minimal project to reproduce.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants