-
Notifications
You must be signed in to change notification settings - Fork 461
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
Chore: monorepo setup #4690
Merged
Chore: monorepo setup #4690
Changes from 1 commit
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
v22.11.0 |
File renamed without changes.
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,158 @@ | ||
# Safe Global Monorepo 🙋♂️ | ||
|
||
## Overview | ||
|
||
Welcome to the Safe Global Monorepo! This repository houses multiple applications and packages managed under a unified | ||
structure using Yarn Workspaces. The monorepo setup simplifies dependency management and ensures consistent development | ||
practices across projects. | ||
|
||
### Key Components | ||
|
||
- **apps/**: Contains application projects (e.g., `mobile` for the Safe Mobile App). | ||
- **packages/**: Shared libraries and utilities. | ||
- **config/**: Configuration files for the monorepo. | ||
|
||
## Getting Started | ||
|
||
To get started, ensure you have the required tools installed and follow these steps: | ||
|
||
### Prerequisites | ||
|
||
- **Node.js**: Install the latest stable version from [Node.js](https://nodejs.org/). | ||
- **Yarn**: Use Yarn version 4.5.3 or later | ||
|
||
to install it with the latest node version you can simply do | ||
|
||
```bash | ||
corepack enable | ||
``` | ||
|
||
and then just run | ||
|
||
```bash | ||
yarn | ||
``` | ||
|
||
This will install the required version of yarn and resolve all dependencies. | ||
|
||
> [!INFO] | ||
> | ||
> Corepack is a tool to help with managing versions of your package managers. It exposes binary proxies for each supported package manager that, when called, will identify whatever package manager is | ||
> configured for the current project, download it if needed, and finally run it. | ||
|
||
### Initial Setup | ||
|
||
1. Clone the repository: | ||
|
||
```bash | ||
git clone <repo-url> | ||
cd monorepo | ||
``` | ||
|
||
2. Install dependencies: | ||
|
||
```bash | ||
yarn install | ||
``` | ||
|
||
## Monorepo Commands | ||
|
||
Here are some essential commands to help you navigate the monorepo: | ||
|
||
### Workspace Management | ||
|
||
- **Run a script in a specific workspace:** | ||
|
||
```bash | ||
yarn workspace <workspace-name> <script> | ||
``` | ||
|
||
Example: | ||
|
||
```bash | ||
yarn workspace @safe-global/web start | ||
``` | ||
|
||
- **Add a dependency to a specific workspace:** | ||
|
||
```bash | ||
yarn workspace <workspace-name> add <package-name> | ||
``` | ||
|
||
- **Remove a dependency from a specific workspace:** | ||
|
||
```bash | ||
yarn workspace <workspace-name> remove <package-name> | ||
``` | ||
|
||
> [!Note] | ||
> | ||
> Yarn treats commands that contain a semicolon as global commands. For example if you have a | ||
compojoom marked this conversation as resolved.
Show resolved
Hide resolved
|
||
> command in a workspace that has a semicolon and there isn't another workspace that has the same command, | ||
> you can run the command without specifying the workspace name. For example: | ||
> | ||
> ```bash | ||
> yarn cypress:open | ||
> ``` | ||
> | ||
> is equivalent to: | ||
> | ||
> ```bash | ||
> yarn workspace @safe-global/web cypress:open | ||
> ``` | ||
|
||
### Linting and Formatting | ||
|
||
- **Run ESLint across all workspaces:** | ||
|
||
```bash | ||
yarn lint | ||
``` | ||
|
||
### Testing | ||
|
||
- **Run unit tests across all workspaces:** | ||
|
||
```bash | ||
yarn test | ||
``` | ||
|
||
## Contributing | ||
|
||
### Adding a New Workspace | ||
|
||
1. Create a new directory under `apps/` or `packages/`. | ||
2. Add a `package.json` file with the appropriate configuration. | ||
3. Run: | ||
|
||
```bash | ||
yarn install | ||
``` | ||
|
||
### Best Practices | ||
|
||
- Use Yarn Workspaces commands for managing dependencies. | ||
- Ensure tests and linting pass before pushing changes. | ||
- Follow the commit message guidelines. | ||
|
||
### Tools & Configurations | ||
|
||
- **Husky**: Pre-commit hooks for linting and tests. | ||
- **ESLint & Prettier**: Enforce coding standards and formatting. | ||
- **Jest**: Unit testing framework. | ||
- **Expo**: Mobile app framework for the `mobile` workspace. | ||
- **Next.js**: React framework for the `web` workspace. | ||
|
||
## Useful Links | ||
|
||
- [Yarn Workspaces Documentation](https://classic.yarnpkg.com/en/docs/workspaces/) | ||
- [Expo Documentation](https://docs.expo.dev/) | ||
- [Next.js Documentation](https://nextjs.org/docs) | ||
- [Jest Documentation](https://jestjs.io/) | ||
- [ESLint Documentation](https://eslint.org/) | ||
- [Prettier Documentation](https://prettier.io/) | ||
|
||
--- | ||
|
||
If you have any questions or run into issues, feel free to open a discussion or contact the maintainers. Happy coding! | ||
🚀 |
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
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,26 @@ | ||
{ | ||
"private": true, | ||
"name": "@safe-global/safe-wallet", | ||
"version": "1.0.0", | ||
"workspaces": [ | ||
"apps/*", | ||
"packages/*" | ||
], | ||
"scripts": { | ||
"lint": "yarn workspaces foreach --all -pt run lint", | ||
"test": "yarn workspaces foreach --all -pt run test", | ||
"prettier:fix": "yarn workspaces foreach --all -pt run prettier:fix", | ||
"eslint": "yarn workspaces foreach --all -pt run eslint" | ||
}, | ||
"resolutions": { | ||
"@safe-global/safe-core-sdk-types/ethers": "6.13.4", | ||
"@safe-global/protocol-kit/ethers": "6.13.4", | ||
"@safe-global/api-kit/ethers": "6.13.4", | ||
"@gnosis.pm/zodiac/ethers": "6.13.4" | ||
}, | ||
"devDependencies": { | ||
"husky": "^9.1.6", | ||
"lint-staged": "^15.2.10" | ||
}, | ||
"packageManager": "[email protected]" | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a difference to navigating into an app and running
yarn add <package-name>
there directly?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No. When you execute the command it would run in the package directory context (meaning root will be the directory). Sometimes the output coloring is a bit off and yarn is adding some prefixes to every line (but I can't tell you when this exactly occurs)