dune
dune copied to clipboard
pkg: dune watch mode with autolocking
I'm opening this PR to discuss the best way to introduce the auto locking inside the watch-mode. Being able to auto-lock the dependencies will developing would be really useful. The solution I have in mind would remove some of the problem that were raised.
The solution would consist in 3 stages:
- First, we would need to track the
dune.lockdirectory as a target of thedune pkg lockcommand and as an input for thedune buildcommand. We could use the "promote" mechanism to make it changes the file in the source directory. This is what is currently used bydune fmtand we could imaginedune pkg lockfollowing the same pattern. - The next stage would be that in watch mode, when you change the dependencies in a
dune-projector*.opamfile, it would update the generateddune.lockentry only for the new package. We would provide the exact version we already have for the other packages. If it fails to build, we would ask the user to manually rundune pkg lockbecause it would mean a "strong" upgrade. - To prevent the user from going into this auto lock mode, @Alizter suggested guarding it with an ``--auto-lock` flag. IMO, this is a good idea. It would allow users to quickly add their dependencies when beginning a project and later remove the flag when they don't expect to introduce dependencies.
Solving being the costly part in the process, doing it only with the flag would prevent it from happening when users don't expect it.
I have started to dig a bit in the code on how to do this. However, before going further, I would like to get your feedback on this @rgrinberg. WDTY of this solution?