amperity / lein-monolith

Leiningen plugin for working with monorepos.
Other
214 stars 18 forks source link

Example workflow #34

Closed lilactown closed 5 years ago

lilactown commented 6 years ago

I'm a bit of a newbie when it comes to Clojure(Script) development, and am looking for some guidance on how to set up my workflow. Is there anywhere I can get an idea of what an example workflow should look like; doing things like compiling, running a REPL, etc.?

Say I have a bunch of clojurescript projects like so:

repo/
  - project.clj
  - server/
    - project.clj
  - components/
    - dashboard/
      - project.clj
    - inbox/
      - project.clj

Basically, the server project should import the dashboard and inbox projects.

I followed the example and set up the projects using the monolith plugin. Now, I'd like to iterate on the dashboard project - how do I set it up so that when I run figwheel inside of server, it picks up changes to dashboard?

Also, I apologize for opening up an issue for what is really a support question. If there's a better place for this, please let me know!

greglook commented 6 years ago

Hey, no problem. There's two main ways for your workflow to pick up changes to the other projects from the server.

The slow version is to run an install on all the projects your server depends on:

# from repo/server/
$ lein monolith each :upstream install

# from anywhere
$ lein monolith each :upstream-of server install

# or just full clean install everything as a sanity check
$ lein monolith each do clean, install

This will ensure that the latest code is registered in your local Maven repository when you run build commands in the server project.

However, given that you mention figwheel, I'm guessing you're more interested in live code reloading. For that, you want to use Leiningen's checkouts feature:

# from repo/server/
$ lein monolith link

The above will create a checkouts/ directory and symlink to each of the subprojects that project depends on. Leiningen will use the code from those linked projects directly rather than the version installed in your Maven repo, so figwheel should pick up the changes 'live' the way you are used to.

lilactown commented 6 years ago

Thanks for the response!

I'm running into an issue - wondering if my config is wrong. In one of my child's project.clj I have something like:

:profiles {:server {:clean-targets ["target"]}}

When in the top-level I run: lein monolith each clean

I get:

Deleting path outside of the project root ["target"] is not allowed.
Check :clean-targets or override this behavior by adding metadata ->
  :clean-targets ^{:protect false} [...targets...]

Changing it to "server-directory/target" fixes the error, but obviously breaks the clean command when run inside the project.

Have I configured something wrong?

greglook commented 6 years ago

I'm curious why you feel the need to set :clean-targets like that - target is already present by default there. The interaction you're seeing is an issue with the relative path getting resolved at the repo root when you load the subproject, rather than when the task is running in the subproject.

greglook commented 5 years ago

Closing this since it's stale - using clean with each does work for me without the extra :clean-targets config.