shopsys / monorepo-builder
[FORK] Not only Composer tools to build a Monorepo.
Requires
- php: ^7.1
- composer/composer: ^1.8
- nette/utils: ^2.5|^3.0
- phar-io/version: ^2.0
- symfony/console: ^3.4|^4.2
- symfony/dependency-injection: ^3.4.10|^4.2
- symfony/finder: ^3.4|^4.2
- symplify/package-builder: ^6.0.5
Requires (Dev)
- phpunit/phpunit: ^7.5|^8.0
- dev-master / 6.1.x-dev
- v6.0.5
- v6.0.4
- v6.0.3
- v6.0.2
- v6.0.1
- v6.0.0
- v5.5.0
- v5.4.16
- v5.4.15
- v5.4.14
- v5.4.13
- v5.4.12
- v5.4.11
- v5.4.10
- v5.4.9
- v5.4.8
- v5.4.7
- v5.4.6
- v5.4.5
- v5.4.4
- v5.4.3
- v5.4.2
- v5.4.1
- v5.4.0
- v5.3.12
- v5.3.11
- v5.3.10
- v5.3.9
- v5.3.8
- v5.3.7
- v5.3.6
- v5.3.5
- v5.3.4
- v5.3.2
- v5.3.1
- v5.3.0
- v5.2.22
- v5.2.20
- v5.2.19
- v5.2.18
- v5.2.17
- v5.2.16
- v5.2.15
- v5.2.14
- v5.2.13
- v5.2.12
- v5.2.11
- v5.2.10
- v5.2.9
- v5.2.8
- v5.2.7
- v5.2.6
- v5.2.5
- v5.2.4
- v5.2.3
- v5.2.2
- v5.2.1
- v5.2.0
- v5.1.4
- v5.1.3
- v5.1.2
- v5.1.1
- v5.1.0
- v5.0.2
- v5.0.1
- v5.0.0
- v4.8.0
- v4.7.0
- v4.6.1
- v4.6.0
- v4.5.1
- v4.5.0
- v4.4.2
- dev-rv-enable-releasing-lower-version
This package is auto-updated.
Last update: 2019-09-09 12:25:14 UTC
README
Do you maintain a monorepo with more packages?
This package has few useful tools, that will make that easier.
Install
composer require symplify/monorepo-builder --dev
Usage
0. Are you New to Monorepo?
The best to lean-in fast is to read basic intro at goMonorepo.com. We also made a simple command to make that easy for you:
vendor/bin/monorepo-builder init
And the basic setup is done!
1. Merge local composer.json
to the Root One
Merges configured sections to the root composer.json
, so you can only edit composer.json
of particular packages and let script to synchronize it.
# monorepo-builder.yml parameters: merge_sections: # default values - 'require' - 'require-dev' - 'autoload' - 'autoload-dev' - 'repositories'
To merge just run:
vendor/bin/monorepo-builder merge
Typical location for packages is /packages
. But what if you have different naming or extra /projects
directory?
# monorepo-builder.yml parameters: package_directories: - 'packages' - 'projects'
Sections are sorted for you by saint defaults. Do you want change the order? Just override section_order
parameter.
After Merge Options
Do you need to add or remove some packages only to root composer.json
?
# monorepo-builder.yml parameters: data_to_append: autoload-dev: psr-4: 'Symplify\Tests\': 'tests' require-dev: phpstan/phpstan: '^0.9' data_to_remove: require: # the line is removed by key, so version is irrelevant, thus * 'phpunit/phpunit': '*'
2. Bump Package Inter-dependencies
Let's say you release symplify/symplify
4.0 and you need package to depend on version ^4.0
for each other:
vendor/bin/monorepo-builder bump-interdependency "^4.0"
3. Keep Synchronized Package Version
In synchronized monorepo, it's common to use same package version to prevent bugs and WTFs. So if one of your package uses symfony/console
3.4 and the other symfony/console
4.1, this will tell you:
vendor/bin/monorepo-builder validate
4. Keep Package Alias Up-To-Date
You can see this even if there is already version 3.0 out:
{ "extra": { "branch-alias": { "dev-master": "2.0-dev" } } }
Not good. Get rid of this manual work and add this command to your release workflow:
vendor/bin/monorepo-builder package-alias
This will add alias 3.1-dev
to composer.json
in each package.
If you prefer 3.1.x-dev
over default 3.1-dev
, you can configure it:
# monorepo-builder.yml parameters: package_alias_format: '<major>.<minor>.x-dev' # default: "<major>.<minor>-dev"
5. Split Directories to Git Repositories
Classic use case for monorepo is to synchronize last tag and the master
branch to allow testing of @dev
version.
# monorepo-builder.yml parameters: directories_to_repositories: packages/PackageBuilder: 'git@github.com:Symplify/PackageBuilder.git' packages/MonorepoBuilder: 'git@github.com:Symplify/MonorepoBuilder.git'
And run by:
vendor/bin/monorepo-builder split
To speed up the process about 50-60 %, all repositories are synchronized in parallel.
6. Release Flow
When a new version of your package is released, you have to do many manual steps:
- bump mutual dependencies,
- tag this version,
git push
with tag,- change
CHANGELOG.md
title Unreleated tov<version> - Y-m-d
format - bump alias and mutual dependency to next version alias
But what if you forget one or do it in wrong order? Everything will crash!
The release
command will make you safe:
vendor/bin/monorepo-builder release v7.0
Are you afraid to tag and push? Use --dry-run
to see only descriptions:
vendor/bin/monorepo-builder release v7.0 --dry-run
7. Set Your Own Release Flow
There is set of few default release workers - classes that implement Symplify\MonorepoBuilder\Release\Contract\ReleaseWorker\ReleaseWorkerInterface
.
You can extend it by adding your own:
# monorepo-builder.yml services: App\Release\ShareOnTwitterReleaseWorker: ~
And or disable default ones:
# monorepo-builder.yml parameters: enable_default_release_workers: false
Contributing
Open an issue or send a pull-request to main repository.