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
:polylithkey from./deps.ednand create aworkspace.ednfile with the same information including a few changes to its format::vcsbecomes a map with the keys:nameand:auto-addwhere the latter determines whether files should automatically be added togitwhen thecreatecommand is used (create workspaceis an exception, which will always perform an initial commit to git).:stable-tag-patternand:release-tag-patternis now stored in:tag-patternsas the keysstableandrelease.:ns-to-libis removed.:project-to-aliasis replaced by:projectswhere each project stores a map with the name as its key and a map as value with the key:aliasand optionally:testthat can be set to[]if no tests should be executed from that project.
- Each brick will get its own
deps.ednfile that specifies thesrc,testandresourcesdirectories + dependencies to libraries if any. The old:ns-to-libmapping is used to figure out which libraries are used (before it's scrapped) and the versions to use are picked from the./deps.ednfile. - All the
deps.ednfiles under theprojectsdirectory are updated for each project:- Paths to bricks are replaced by
:local/rootdependencies and libraries that are defined by these bricks are removed from the project, and will instead be implicitly included via:local/rootdefinitions (which also means that you don't have to explicitly specify thesrc,resourcesandtestdirectories anymore, only the bricks). Notice thattestdirectories are not inherited bytools.depswhen:local-rootdependencies are used, but that they are included when you run the built-in polytestcommand. If you rely ontestpaths via other tooling, you may therefore keep these paths. - Notice that the
developmentenvironment, with its./deps.ednfile, is not converted to use:local/rootand the reason is that the:local/rootdefinitions 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
:polylithkey from./deps.edn.
Before you start the migration, here are some tips:
- Decide how to run the
migratecommand, either by executingpoly migrateorclojure -M:poly migrate. If you choose the first alternative, make sure you have the latest version of thepolytool. If you choose the second alternative, make sure you update theshaof the:polyalias in./deps.ednto 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-libkey in./deps.ednand make sure you use the correct library versions in./deps.edn. This will make your life easier because both are used when thedeps.ednfiles are created for the bricks. - Run all the tests to make sure that everything works correctly, e.g.
poly test :all. - Run the
infoandlibscommands and store the result to files, e.g.:poly info color-mode:none > info.txtandpoly libs color-mode:none > libs.txt.
After the migration:
- Run the
infoandlibscommands 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.ednfiles under theprojectsdirectory and remove misplaced libraries from the project'sdeps.ednfile and add them to the corresponding brick'sdeps.ednfile. This is only needed for dependencies that were not specified in:ns-to-lib. If libraries are correctly specified in each brick'sdeps.ednfile they will also show up under each brick when running thelibscommand. - 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!