-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs(repo): add monorepo documentation
- Loading branch information
1 parent
cccd6df
commit f998335
Showing
7 changed files
with
153 additions
and
83 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# Architecture | ||
|
||
## Introduction | ||
|
||
The repository setup and folder structure is heavily inspired by the turborepo [kitchen sink starter monorepo templates](https://github.com/vercel/turbo/tree/main/examples/kitchen-sink) and the [design system monorepo template](https://github.com/vercel/turbo/tree/main/examples/design-system). | ||
|
||
## Folder Structure | ||
|
||
```bash | ||
apps/ | ||
configs/ | ||
docs/ | ||
packages/ | ||
... | ||
package.json | ||
pnpm-workspace.yaml | ||
``` | ||
|
||
**`apps`** - Contains standalone applications / SPAs that can consume modules in `packages` | ||
|
||
**`configs`** - Contains linters / configurations such as `eslint` / `tsconfig` shared across the monorepo | ||
|
||
**`docs`** - Contains documentation for ui components and other documentation | ||
|
||
**`packages`** - Contains utilities and tools published to `npm` that are used across the monorepo | ||
|
||
## Turborepo Differences | ||
|
||
- Tooling and configurations such as `eslint` and `tsconfig` are included in their own `config` folder. This is a personal preference to separate from the `packages` folder where reusable packages and utilities shared across projects are stored. | ||
- Configurations such as `eslint` and `tsconfig` in the `config` folder do not reference other shareable configurations, for example, my own personal `eslint` config I use across projects. This is a personal preference so that configuration complexity and inheritence is kept to a minimum. This keeps configuration code more readable and self contained to the monorepo. | ||
- Package naming for public packages published to `npm` have the `@` alias scoping while private packages do not have an alias. This is a personal preference to maintain the distinction between published and non-published packages more easily. | ||
- The `apps` and `docs` folders remain separate and both are top-level folders. This is a personal preference to make the distinction between SPA and UI component documentation code / other documentation. I opt for more top-level folders. | ||
|
||
## Turborepo Similarities | ||
|
||
- Under `docs` is where `storybook` component code is stored, however it is common to house this along with the UI component for simplicity. If kept together, you would need to update the project to ignore `storybook` files when building and publishing the UI components to `npm`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
# Additional Commands | ||
|
||
Commit changes using conventional changelog: | ||
|
||
```bash | ||
pnpm commit | ||
``` | ||
|
||
Delete workspace root `node_modules` and `pnpm-lock.yaml` files: | ||
|
||
**Note**: Install `rimraf` globally and make sure it is not installed in the workspace root so errors aren't thrown. | ||
|
||
```bash | ||
pnpm delete | ||
``` | ||
|
||
Lint root and `configs/` `js/cjs` files, check for secrets, lint dependency versions, validate published packages, and verify monorepo best practices: | ||
|
||
```bash | ||
pnpm lint:mr | ||
``` | ||
|
||
Visualize the project structure/dependencies: | ||
|
||
```bash | ||
pnpm nx:graph | ||
``` | ||
|
||
Format all files in the monorepo: | ||
|
||
```bash | ||
pnpm format | ||
``` | ||
|
||
Preview the output result of the `version` command without actually executing it: | ||
|
||
**Note**: Set your personal access token as an environment variable in your operating system as `GH_TOKEN` with the token unique identifier as the value. | ||
|
||
```bash | ||
pnpm preview:version | ||
``` | ||
|
||
Preview the output result of the `publish` command without actually executing it: | ||
|
||
```bash | ||
pnpm preview:publish | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
Copyright 2023 Matthew Waldron | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# Monorepo Documentation | ||
|
||
[Architecture](ARCHTIECTURE.md) | ||
|
||
[Additional Commands](COMMANDS.md) | ||
|
||
[Workspace Commands](WORKSPACE.md) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# Workspace Commands | ||
|
||
pnpm workspace commands | ||
|
||
## Add Packages | ||
|
||
Install dependecies to the root of the workspace: | ||
|
||
```bash | ||
pnpm add -w [package-name] | ||
``` | ||
|
||
Add a package as a dependency for another local package: | ||
|
||
```bash | ||
pnpm add react --filter vite-project --workspace | ||
``` | ||
|
||
Add a **local** package as a development dependency for another local package: | ||
|
||
```bash | ||
pnpm add -D eslint-config-custom --filter vite-project --workspace | ||
``` | ||
|
||
## Remove Packages | ||
|
||
Remove a local package from another local package: | ||
|
||
```bash | ||
pnpm remove eslint-config-custom --filter vite-project | ||
``` | ||
|
||
## Run Commands | ||
|
||
Install / run commands for a specific sub-package: | ||
|
||
```bash | ||
pnpm dev --filter vite-project | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"name": "monorepo-docs", | ||
"version": "1.0.0", | ||
"private": true, | ||
"license": "MIT" | ||
} |