Advanced
Monorepo
Monorepos allow you to manage multiple Eventvisor projects from a single Git repository.
Why monorepo?#
- Have a single source of truth for all your Eventvisor projects across the organization
- Easily add new projects to the monorepo (could be completely isolated projects, or for different environments)
- Review and approve Pull Requests for all projects in one place
- Reuse same deployment strategy for all projects
Initialize monorepo#
There's a handy example monorepo setup that you can scaffold using the Eventvisor CLI:
$ mkdir my-monorepo && cd my-monorepo$ npx @eventvisor/cli init --project=monorepo
This will scaffold a monorepo with 2 separate projects, one for staging and one for production.
projects/├── production/└── staging/
You can of course add more projects to the monorepo as needed, including completely isolated projects with or without environment-level separation, like:
projects/├── mobile-production/├── mobile-staging/├── web-production/└── web-staging/
You are required to maintain a separate package.json
like in projects/production/package.json
with a unique name
for each project.
Install dependencies#
From the root of the monorepo, install the dependencies:
$ npm install
Build datafiles#
Build the datafiles for each project from root:
$ make build
You can do the same for lint
and test
as well.
Output#
This will generate the datafiles for each project in their respective directories:
Project-specific datafiles#
projects/├── production/│ └── datafiles/│ ├── eventvisor-tag-mobile.json│ └── eventvisor-tag-web.json└── staging/ └── datafiles/ ├── eventvisor-tag-mobile.json └── eventvisor-tag-web.json
All datafiles together#
Additionally, all the projects' datafiles will be merged into a single datafiles
directory in root, with a structure as below:
datafiles/├── production/│ └── eventvisor-tag-mobile.json│ └── eventvisor-tag-web.json└── staging/ └── eventvisor-tag-mobile.json └── eventvisor-tag-web.json
Deploy datafiles#
Since all the projects' generated datafiles are together, now it is as easy as just uploading the contents of root datafiles
directory to your CDN or your own web server in one go.
Revision from hash#
Since there are multiple Eventvisor projects in the monorepo, you can pass the --revision-from-hash
flag to the build
npm script in each of your projects. Learn more in building datafiles page.
This way, when you are just making changes to one project's entities, the generated datafiles of other projects will not have any content changes, leading to better caching.
Incremental revision numbers#
If you would like to maintain the default behaviour of incremental revision numbers, you are then advised to commit the .eventvisor
directories of each project to your Git repository, so that future builds can build on top of the last known revision numbers:
$ git add .$ git commit -m "[skip ci] Eventvisor revision"$ git push