Build and maintain monorepo (monolithic repository) like a boss.


Keywords
git, monolithic, monorepo, php, split
License
MIT

Documentation

Deprecated - use shopsys/monorepo-tools instead


Monorepo - Build and Maintain Monorepo like a Boss

Build Status Downloads Subscribe

Usage

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 symplify/monorepo installed, e.g.

    composer require symplify/monorepo

Do all following steps in build directory.

3 Steps to Build Monorepo

  1. Create monorepo.yml with build section
parameters:
    build:
        # remote git repository => directory in monorepo to place the package to
        'git@github.com:shopsys/product-feed-zbozi.git': 'packages/ProductFeedZbozi'
        'git@github.com:shopsys/product-feed-heureka.git': 'packages/ProductFeedHeureka'
  1. Run build command with monorepo directory as argument

Remember, it must be outside this directory and must be empty.

vendor/bin/monorepo build ../new-monorepo
  1. A new /new-monorepo directory is created, with git history for all the packages
/new-monorepo
    /packages
        /ProductFeedZbozi
        /ProductFeedHeureka

2. Split Monolithic Repository to Many Repositories

  1. Create monorepo.yml with split section
parameters:
    split:
        directory in monorepo with package => remote git repository
        'packages/ProductFeedZbozi': 'git@github.com:shopsys/product-feed-zbozi.git'
        'packages/ProductFeedHeureka': 'git@github.com:shopsys/product-feed-heureka.git'
  1. Run split command
vendor/bin/monorepo split

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.

Other Features

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 (build command), e.g. for 7000 commits in 2500 files roughly 3 hours. Running script overnight is recommended.

Built With Help Of