Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Turborepo docs #2813

Merged
merged 1 commit into from
Feb 4, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions docs/turborepo.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Turborepo and Telescope

Telescope is configured as a monorepo: a single repository that holds many projects. [Turborepo](https://turborepo.org/) is the tool we use to manage every project within Telescope.

You will probably not have to interact with Turborepo directly but it is worth understanding how it works. The [Turborepo docs](https://turborepo.org/docs) do a good job at explaining its benefits and features.

We have a `package.json` file at the root of Telescope that defines the rules in what is called a `"pipeline"`.

The pipeline includes all the Turborepo commands that are available to use.

Example:

```
{
"pipeline": {
"build": {
"dependsOn": ["^build"]
},
"lint": {}
}
}
```

Using Turborepo:

```
# To run the build command
pnpm turbo run build

# To run the lint command
pnpm turbo run lint
```

Turborepo will look inside each workspace's `package.json` defined in `pnpm-workspace.yaml` for the specified command. More specifically, it will look at the `scripts` property and find the script that has the name matching the specified command. For each workspace, if Turborepo finds the script, it will run it.

menghif marked this conversation as resolved.
Show resolved Hide resolved
As an example, suppose we use the pipeline mentioned above. When you run `pnpm turbo run lint`, Turborepo will go through all projects found in the `pnpm-workspace.yaml`, and look at the project's `package.json` to find the script named `lint`, and thus will run `lint` for each project that has such script.

Thanks to scripts set in the root's `package.json`, running `pnpm build` or `pnpm lint` will automatically use Turborepo so there is no need to memorize the [Turborepo CLI](https://turborepo.org/docs/reference/command-line-reference) syntax used above.