All Projects → shopsys → Monorepo Tools

shopsys / Monorepo Tools

Licence: mit
[READ-ONLY] Tools for building and splitting monolithic repository from existing packages (with their history unchanged). This package is used for splitting our monorepo and we share it with our community as it is. We do not intend to support or develop it any further. Feel free to fork it and adjust for your own need.

Programming Languages

shell
77523 projects

Labels

Projects that are alternatives of or similar to Monorepo Tools

xlib
Your isomorphic toolbox
Stars: ✭ 18 (-96.34%)
Mutual labels:  monorepo
Redux Requests
Declarative AJAX requests and automatic network state management for single-page applications
Stars: ✭ 330 (-32.93%)
Mutual labels:  monorepo
Opensource
Delivering delightful digital solutions. Open Source packages with combined ~85M/month downloads, semantically versioned following @conventional-commits. Fully powered by Jest, @Babel TypeScript, @Airbnb @ESLint + @Prettier, @YarnPKG + @Lerna independent versioning, GH @Actions & automated dep updates with @RenovateBot.
Stars: ✭ 459 (-6.71%)
Mutual labels:  monorepo
Imodeljs
Monorepo for iModel.js Library
Stars: ✭ 256 (-47.97%)
Mutual labels:  monorepo
Graphql Starter
💥 Monorepo template (seed project) pre-configured with GraphQL API, PostgreSQL, React, Relay, and Material UI.
Stars: ✭ 3,377 (+586.38%)
Mutual labels:  monorepo
Nx Examples
Example repo for nx workspace
Stars: ✭ 372 (-24.39%)
Mutual labels:  monorepo
go
Monorepo for small Go modules maintained by Tawesoft
Stars: ✭ 16 (-96.75%)
Mutual labels:  monorepo
Browser
🌍 Take back your privacy with Dot Browser, the privacy-conscious web browser that protects you from being tracked and monitored online.
Stars: ✭ 475 (-3.46%)
Mutual labels:  monorepo
Jsonnet Libs
Grafana Labs' Jsonnet libraries
Stars: ✭ 309 (-37.2%)
Mutual labels:  monorepo
Symplify
Do you use Symfony, Coding Standards, maintain PHP packages, automate monorepo, generate static website and are you lazy? You'll love the candies you find here! :)
Stars: ✭ 430 (-12.6%)
Mutual labels:  monorepo
Awesome Monorepo
A curated list of awesome Monorepo tools, software and architectures.
Stars: ✭ 3,413 (+593.7%)
Mutual labels:  monorepo
Baur
baur manages builds and artifacts in mono repositories
Stars: ✭ 285 (-42.07%)
Mutual labels:  monorepo
Mapbox Gl Native
Interactive, thoroughly customizable maps in native Android, iOS, macOS, Node.js, and Qt applications, powered by vector tiles and OpenGL
Stars: ✭ 4,091 (+731.5%)
Mutual labels:  monorepo
mono.ts
A minimal example of a typescript mono repo with pre-build support (tests, vscode).
Stars: ✭ 58 (-88.21%)
Mutual labels:  monorepo
Ts Monorepo
Template for setting up a TypeScript monorepo
Stars: ✭ 459 (-6.71%)
Mutual labels:  monorepo
lerna-learning
基于Lerna管理packages的Monorepo项目最佳实践
Stars: ✭ 105 (-78.66%)
Mutual labels:  monorepo
Syncpack
Manage multiple package.json files, such as in Lerna Monorepos and Yarn/Pnpm Workspaces
Stars: ✭ 356 (-27.64%)
Mutual labels:  monorepo
Ngx Starter Kit
🅰️ Angular 🚀 NestJS 🐒 Starter Kit
Stars: ✭ 479 (-2.64%)
Mutual labels:  monorepo
Berty
Berty is a secure peer-to-peer messaging app that works with or without internet access, cellular data or trust in the network
Stars: ✭ 5,101 (+936.79%)
Mutual labels:  monorepo
Entria Fullstack
Monorepo Playground with GraphQL, React, React Native, Relay Modern, TypeScript and Jest
Stars: ✭ 434 (-11.79%)
Mutual labels:  monorepo

Shopsys Monorepo Tools

Mentioned in Awesome Monorepo

This package is used for splitting our monorepo and we share it with our community as it is. We do not intend to support or develop it any further. Feel free to fork it and adjust for your own need.

Tools for building and splitting monolithic repository from existing packages. You can read about pros and cons of monorepo approach on the Shopsys Framework Blog.

We created these scripts because we couldn't find a tool that would keep the git history of subpackages unchanged.

You may need to update your git (tested on 2.16.1).

This repository is maintained by shopsys/shopsys monorepo, information about changes is in monorepo CHANGELOG.md.

Quick start

1. Download

First download this repository so you can use the tools (eg. into ~/monorepo-tools).

git clone https://github.com/shopsys/monorepo-tools ~/monorepo-tools

2. Preparing an empty repository with added remotes

You have to create a new git repository for your monorepo and add all your existing packages as remotes. You can add as many remotes as you want.

In this example we will prepare 3 packages from github for merging into monorepo.

git init
git remote add main-repository http://github.com/vendor/main-repository.git
git remote add package-alpha http://github.com/vendor/alpha.git
git remote add package-beta http://github.com/vendor/beta.git
git fetch --all --no-tags

3. Building the monorepo

Then you can build your monorepo using monorepo_build.sh. Just list the names of all your previously added remotes as arguments. Optionally you can specify a directory where the repository will be located by providing <remote-name>:<subdirectory>, otherwise remote name will be used.

The command will rewrite history of all mentioned repositories as if they were developed in separate subdirectories.

Only branches master will be merged together, other branches will be kept only from first package to avoid possible branch name conflicts.

~/monorepo-tools/monorepo_build.sh \
    main-repository package-alpha:packages/alpha package-beta:packages/beta

This may take a while, depending on the size of your repositories.

Now your master branch should contain all packages in separate directories. For our example it would mean:

  • main-repository/ - contains repository vendor/main-repository
  • packages/
    • alpha/ - contains repository vendor/alpha
    • beta/ - contains repository vendor/beta

4. Splitting into original repositories

You should develop all your packages in this repository from now on.

When you made your changes and would like to update the original repositories use monorepo_split.sh with the same arguments as before.

~/monorepo-tools/monorepo_split.sh \
    main-repository package-alpha:packages/alpha package-beta:packages/beta

This will push all relevant changes into all of your remotes. It will split and push your master branch along with all tags you added in this repository. Other branches are not pushed.

It may again take a while, depending on the size of your monorepo.

Note:
The commits in the split repositories should be identical to those from the original repo, keeping the git history intact. Thus, if you have checked out the original master previously, you should be able to fast-forward to the new version after splitting.
The only known exception is a signed commit (note that GitHub signs commits made via its web UI by default). If you have signed commits in your original repository, the split commits will NOT be signed. This will prevent monorepo_split.sh from pushing the unsigned commits to the remote.
To overcome this you can add the --force flag to the git push calls in the script, but it may cause unforeseen consequences if you're not sure what you're doing.

Add a new package into the monorepo

When you have the monorepo, you may find a reason for adding a new package after some time you already use the monorepo. In this case, don't use monorepo_build.sh, but do following steps:

  • Create a new repository, for example, vendor/gamma
  • Add remote into the monorepo git remote add package-gamma http://github.com/vendor/gamma.git
  • Create a new directory in the monorepo packages/gamma
  • Add the code and commit it
  • Use split tool with the new package
    ~/monorepo-tools/monorepo_split.sh \
        main-repository package-alpha:packages/alpha package-beta:packages/beta package-gamma:packages/gamma
    

Reference

This is just a short description and usage of all the tools in the package. For detailed information go to the scripts themselves and read the comments.

monorepo_build.sh

Build monorepo from specified remotes. The remotes must be already added to your repository and fetched.

Usage: monorepo_build.sh <remote-name>[:<subdirectory>] <remote-name>[:<subdirectory>] ...

monorepo_split.sh

Split monorepo built by monorepo_build.sh and push all master branches along with all tags into specified remotes.

Usage: monorepo_split.sh <remote-name>[:<subdirectory>] <remote-name>[:<subdirectory>] ...

monorepo_add.sh

Add repositories to an existing monorepo from specified remotes. The remotes must be already added to your repository and fetched. Only master branch will be added from each repo.

Usage: monorepo_add.sh <remote-name>[:<subdirectory>] <remote-name>[:<subdirectory>] ...

rewrite_history_into.sh

Rewrite git history (even tags) so that all filepaths are in a specific subdirectory.

Usage: rewrite_history_into.sh <subdirectory> [<rev-list-args>]

rewrite_history_from.sh

Rewrite git history (even tags) so that only commits that made changes in a subdirectory are kept and rewrite all filepaths as if it was root.

Usage: rewrite_history_from.sh <subdirectory> [<rev-list-args>]

original_refs_restore.sh

Restore original git history after rewrite.

Usage: original_refs_restore.sh

original_refs_wipe.sh

Wipe original git history after rewrite.

Usage: original_refs_wipe.sh

load_branches_from_remote.sh

Delete all local branches and create all non-remote-tracking branches of a specified remote.

Usage: load_branches_from_remote.sh <remote-name>

tag_refs_backup.sh

Backup tag refs into refs/original-tags/

Usage: tag_refs_backup.sh

tag_refs_move_to_original.sh

Move tag refs from refs/original-tags/ into refs/original/

Usage: tag_refs_move_to_original.sh

Contributing

Thank you for your contributions to Shopsys Monorepo Tools package. Together we are making Shopsys Framework better.

This repository is READ-ONLY. If you want to report issues and/or send pull requests, please use the main Shopsys repository.

Please, check our Contribution Guide before contributing.

Support

What to do when you are in troubles or need some help? Best way is to contact us on our Slack http://slack.shopsys-framework.com/

If you want to report issues, please use the main Shopsys repository.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].