migrate
Migrate workspace
If you have an old workspace and start using v0.2.0-alpha10
or later, then all commands will still work except for the
create component,
create base and
create project commands.
Another difference is that the ws command will create files with a richer format
than before, which is not backward compatible with the previous format.
The good thing is that old ws
files can still be read by the latest poly
tool but will lack some
information like library dependencies for the test
context which was not calculated prior to
version v0.2.0-alpha10.
The advice is therefore to migrate as soon as possible!
A workspace can be migrated by executing the migrate command. A migration will perform these steps:
- Extract the
:polylith
key from./deps.edn
and create aworkspace.edn
file with the same information including a few changes to its format::vcs
becomes a map with the keys:name
and:auto-add
where the latter determines whether files should automatically be added togit
when thecreate
command is used (create workspace
is an exception, which will always perform an initial commit to git).:stable-tag-pattern
and:release-tag-pattern
is now stored in:tag-patterns
as the keysstable
andrelease
.:ns-to-lib
is removed.:project-to-alias
is replaced by:projects
where each project stores a map with the name as its key and a map as value with the key:alias
and optionally:test
that can be set to[]
if no tests should be executed from that project.
- Each brick will get its own
deps.edn
file that specifies thesrc
,test
andresources
directories + dependencies to libraries if any. The old:ns-to-lib
mapping is used to figure out which libraries are used (before it's scrapped) and the versions to use are picked from the./deps.edn
file. - All the
deps.edn
files under theprojects
directory are updated for each project:- Paths to bricks are replaced by
:local/root
dependencies and libraries that are defined by these bricks are removed from the project, and will instead be implicitly included via:local/root
definitions (which also means that you don't have to explicitly specify thesrc
,resources
andtest
directories anymore, only the bricks). Notice thattest
directories are not inherited bytools.deps
when:local-root
dependencies are used, but that they are included when you run the built-in polytest
command. If you rely ontest
paths via other tooling, you may therefore keep these paths. - Notice that the
development
environment, with its./deps.edn
file, is not converted to use:local/root
and the reason is that the:local/root
definitions will not be picked up by all IDE's as source code.
- Paths to bricks are replaced by
- Finally, the migration command tells you to manually remove the
:polylith
key from./deps.edn
.
Before you start the migration, here are some tips:
- Decide how to run the
migrate
command, either by executingpoly migrate
orclojure -M:poly migrate
. If you choose the first alternative, make sure you have the latest version of thepoly
tool. If you choose the second alternative, make sure you update thesha
of the:poly
alias in./deps.edn
to the latest sha. - Make sure the workspace doesn't have any uncommitted changes.
- It can be an idea to run the migration in a separate git branch and merge it back when everything works (this is not mandatory).
- Update the
:ns-to-lib
key in./deps.edn
and make sure you use the correct library versions in./deps.edn
. This will make your life easier because both are used when thedeps.edn
files are created for the bricks. - Run all the tests to make sure that everything works correctly, e.g.
poly test :all
. - Run the
info
andlibs
commands and store the result to files, e.g.:poly info color-mode:none > info.txt
andpoly libs color-mode:none > libs.txt
.
After the migration:
- Run the
info
andlibs
commands again and make sure they have the same output as before the migration. - Fix formatting and ordering to your taste. Unfortunately, all libraries will end up sorted so you may want to fix the ordering, e.g. letting bricks come first followed by the library dependencies.
- Go through the paths and dependencies in the
deps.edn
files under theprojects
directory and remove misplaced libraries from the project'sdeps.edn
file and add them to the corresponding brick'sdeps.edn
file. This is only needed for dependencies that were not specified in:ns-to-lib
. If libraries are correctly specified in each brick'sdeps.edn
file they will also show up under each brick when running thelibs
command. - Run all the tests, e.g.
poly test :all
, and make sure everything passes. - When everything works, commit and push to git!
Another benefit of this update is that you will git rid of the warning from tools.deps
that relative paths will stop working in the future
(e.g. "../../components/my-component/src"
) which also is the main reason for this update.
You can find an example of how a project looks like before and after a migration in
examples/local-dep-old-format
and examples/local-dep
.
Good luck with this update of the tool!