shopsys/monorepo-tools insteadDeprecated - use
Monorepo - Build and Maintain Monorepo like a Boss
1. Build Monolithic Repository from Many Repositories
- Do you have many packages with long git history?
- Do you want to turn them into monorepo?
- Do you want keep their history?
That's exactly what
build command does.
Directories to work With
You're working with 2 directories:
monorepo directory - monorepo will be created there, it must be empty
build directory - where you have
composer require symplify/monorepo
Do all following steps in build directory.
3 Steps to Build Monorepo
parameters: build: # remote git repository => directory in monorepo to place the package to 'email@example.com:shopsys/product-feed-zbozi.git': 'packages/ProductFeedZbozi' 'firstname.lastname@example.org:shopsys/product-feed-heureka.git': 'packages/ProductFeedHeureka'
buildcommand with monorepo directory as argument
Remember, it must be outside this directory and must be empty.
vendor/bin/monorepo build ../new-monorepo
- A new
/new-monorepodirectory is created, with git history for all the packages
/new-monorepo /packages /ProductFeedZbozi /ProductFeedHeureka
2. Split Monolithic Repository to Many Repositories
parameters: split: directory in monorepo with package => remote git repository 'packages/ProductFeedZbozi': 'email@example.com:shopsys/product-feed-zbozi.git' 'packages/ProductFeedHeureka': 'firstname.lastname@example.org:shopsys/product-feed-heureka.git'
It splits current working directory, but you can use argument to change that:
vendor/bin/monorepo split ../new-monorepo
Your last tag and
master branch is now published in the repository.
Is Your Config in Other Location?
vendor/bin/monorepo split --config second-monorepo.yml
Rules of Monorepo
- Only committed files and directories can be split.
- It takes time to move commit history of big projects (
buildcommand), e.g. for 7000 commits in 2500 files roughly 3 hours. Running script overnight is recommended.