-
Notifications
You must be signed in to change notification settings - Fork 5
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/4391/devtooling #2
Merged
Merged
Changes from all commits
Commits
Show all changes
30 commits
Select commit
Hold shift + click to select a range
72af065
chore: install prettier config to workspace to share across monorepo
pete-watters 4415331
chore(prettier-config): setup prettier in monorepo base to use pretti…
pete-watters a03580c
chore(eslint-config): setup eslint-config package
pete-watters d5f6e66
chore(tsconfig-config): setup tsconfig-config package
pete-watters f5cce95
chore(eslint-config): setup eslint-config package
pete-watters f275678
chore(prettier-config): setup prettier in monorepo base to use pretti…
pete-watters d39dde1
chore(docs): add basic documentation boilerplate
pete-watters 5f32b25
chore(mono): setup monorepo to use sub packages for code quality
pete-watters ad16d5e
chore(tsconfig-config): avoid ts error about no inputs were found in …
pete-watters db1ba5a
chore(eslint-config): exclude react checks from eslint
pete-watters 14bcfc2
chore(husky): setup husky and configure it to run commitlint and lint…
pete-watters 3328622
chore(git): attempt git action setup
pete-watters d23ba0a
chore(git): update codechecks
pete-watters 5eb634e
chore(git): setup actions with pnpm
pete-watters 7faf92e
chore(git): setup PNPM workspace
pete-watters ffb3fa0
chore(git): git action setup
pete-watters 6c79903
chore: remove unneeded script
pete-watters b54e8cd
chore(pnpm): test clean scripts and update naming
pete-watters b51170d
chore: only run pnpm install in provision
pete-watters 2826daf
chore: add more code check jobs
pete-watters 4bf905b
chore: update node and pnpm versions
pete-watters b94e423
chore(docs): add monorepo setup documentation
pete-watters e35ead7
chore(mono): add .npmrc and remove unnecessary configs
pete-watters ca04a03
chore(docs): update docs and packages package.json
pete-watters f16f3d7
chore(eslint): update eslint docs and ignore
pete-watters e5347f0
chore(prettier): update prettier docs
pete-watters 15a94b3
chore(tsconfig): update tsconfig docs
pete-watters 193b4e0
fix: remove TODOs, use * workspace install, name code-checks
pete-watters d48aa9e
fix: revert to ^ workspace install
pete-watters a26e422
chore: don't duplicate license files
pete-watters 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 @@ | ||
module.exports = require('@commitlint/config-conventional'); |
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 @@ | ||
!.* | ||
node_modules/ | ||
|
||
pnpm-lock.yaml | ||
.commitlintrc.js | ||
.prettierrc.js | ||
.eslintrc.js |
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,3 @@ | ||
{ | ||
"extends": ["@leather-wallet/eslint-config"] | ||
} |
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,17 @@ | ||
name: Provision | ||
description: Set up job with tasks needed to run a code check | ||
runs: | ||
using: 'composite' | ||
steps: | ||
- name: Install pnpm | ||
uses: pnpm/action-setup@v2 | ||
with: | ||
version: 8 | ||
- name: Set up node | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: 20 | ||
cache: 'pnpm' | ||
- name: install dependencies | ||
run: pnpm install | ||
shell: bash |
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,42 @@ | ||
name: Code checks | ||
|
||
on: | ||
merge_group: | ||
push: | ||
branches: | ||
- '**' | ||
|
||
jobs: | ||
lint-prettier: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: ./.github/actions/provision | ||
- name: Lint Prettier | ||
run: pnpm lint:prettier | ||
|
||
lint-eslint: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: ./.github/actions/provision | ||
- name: Lint Eslint | ||
run: pnpm lint:eslint | ||
|
||
typecheck: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: ./.github/actions/provision | ||
- name: Lint Types | ||
run: pnpm lint:types | ||
|
||
lint-commit: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Lint commit message | ||
uses: wagoid/commitlint-github-action@v4 |
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,4 @@ | ||
#!/usr/bin/env sh | ||
. "$(dirname -- "$0")/_/husky.sh" | ||
|
||
pnpm commitlint --edit $1 |
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,4 @@ | ||
#!/usr/bin/env sh | ||
. "$(dirname -- "$0")/_/husky.sh" | ||
|
||
pnpm lint-staged --quiet |
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,4 @@ | ||
export default { | ||
'*.{mjs,js,ts,tsx,json,yaml}': 'pnpm lint:prettier', | ||
'*.{mjs,js,ts,tsx}': 'pnpm lint:eslint', | ||
}; |
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,2 @@ | ||
engine-strict = true | ||
auto-install-peers = true | ||
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,2 @@ | ||
node_modules/ | ||
pnpm-lock.yaml |
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,5 @@ | ||
const defaultConfig = require('@leather-wallet/prettier-config'); | ||
|
||
module.exports = { | ||
...defaultConfig, | ||
}; |
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,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2023 Leather Wallet LLC [a subsidiary of Nassau Machines] | ||
|
||
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 |
---|---|---|
@@ -1,61 +1,44 @@ | ||
# Sample repo for Leather monorepo setup | ||
|
||
Here we review a few monorepo approaches and how they may fit into our codebase | ||
|
||
# Motivation | ||
|
||
As a largely single-product company, with a vision for being a multi-product company, we need a way to share code between our various projects. Consider how, when we begin work on the mobile wallet, much code needs to be refactored out of the Web Extension, into an environment-agnostic home. For use elsewhere, such as a React Native or Electron app. | ||
|
||
## Requirements | ||
|
||
- Well organised monorepo | ||
- Automated package releases | ||
- Publishing to npm | ||
- [with NX](https://nx.dev/concepts/more-concepts/buildable-and-publishable-libraries) | ||
- Enables developers to easily create new packages | ||
- Easy to work with in local development | ||
- Easy to set up package-specific CI jobs | ||
- monorepo vs. one big npm package? | ||
|
||
|
||
Ideally we want to: | ||
- not change the existing extension too much | ||
- facilitate sharing of code between platforms - web, native, desktop | ||
- re-use our new panda + radix system as much as possible | ||
- extract shared library code | ||
- allow independant publishing of packages | ||
- solution must work with panda css | ||
- storybook for UI lib demos | ||
- storybook to replace test-app also? | ||
|
||
## Basic Leather monorepo architecture | ||
|
||
|
||
```md | ||
leather-mono | ||
├─ apps | ||
│ ├─ extension | ||
│ ├─ mobile | ||
│ ├─ desktop | ||
│ ├─ storybook <-- replaces test-app, place to view UI components with context + tests | ||
│ ├─ website <-- maybe we can get rid of Framer and just host our site ourself, keeping code here? | ||
├─ docs -> should we host out dev docs here? | ||
├─ packages | ||
│ ├─ api <-- leather API / wrapper interface to other libs: here / under apps, | ||
│ ├─ tsconfig | ||
│ ├─ lib | ||
│ ├─ utils <-- shared utils, | ||
│ ├─ ui <-- using definePreset(), contains the theme base (tokens.colors, semantic tokens, etc) | ||
│ └─ button <-- consuming the preset, provides a button recipe (in a buttonPreset) + a ShadcnButton component | ||
│ └─ some-component <-- consuming the preset, provides a component using internal `css` calls, ships a panda.json extract result | ||
``` | ||
|
||
|
||
## Items for further consideration | ||
|
||
- migration from `yarn` to [`pnpm`](https://pnpm.io/) | ||
- upgrading from `webpack` to [`esbuild`](https://esbuild.github.io/) | ||
- Can use Nx + Lerna or just Nx | ||
- for HTML Ordinals, do we want to use SSR so we can show them? Maybe we can have a library/package using Next.js just to render those that gets imported? | ||
- how do we manage our documentation? could we host that here also? | ||
- do we still need Framer? It helped us release fast but now we could manage the site as a monorepo app | ||
# Monorepo Setup | ||
|
||
The purpose of this configuration is to ensure strict coding standards and facilitate code sharing. The monorepo uses `pnpm workspaces` at its core and provides several shared packages to be found under the `packages` folder. | ||
|
||
### Monorepo setup | ||
|
||
- [Architecture](docs/core/ARCHITECTURE.md) | ||
- [Monorepo](docs/core/MONOREPO.md) | ||
|
||
Coding standards are enforced through the use of | ||
|
||
- `eslint` | ||
- `prettier` | ||
- `typescripts` | ||
|
||
Shared configuration files for these tools exist in `packages` and the same base configurations are used in the monorepo itself. | ||
|
||
Some other configured tools are: | ||
|
||
- [Husky](docs/tools/HUSKY.md): run code checks and enforce standards locally as a first prevention | ||
- [LintStaged](docs/tools/LINTSTAGED.md): only run checks on staged files | ||
- [CommitLint](docs/tools/COMMITLINT.md) enforce [Conventional Commit](https://www.conventionalcommits.org/en/v1.0.0/) standard | ||
|
||
### Monorepo packages | ||
|
||
The current packages are listed below | ||
|
||
- [ESLint](packages/eslint-config/README.md) | ||
- [Prettier](packages/prettier-config/README.md) | ||
- [TSconfig](packages/tsconfig-config/README.md) | ||
|
||
### Git Actions | ||
|
||
Basic CI actions to run code quality checks have been setup in | ||
|
||
- [Code checks](.github/workflows/code-checks.yml) | ||
|
||
### Documentation | ||
|
||
Documentation has been provided from the outset and can be found in `docs/tools/` along with a [TEMPLATE.md](docs/core/TEMPLATE.md) file | ||
|
||
## License | ||
|
||
[MIT](LICENSE) © [Leather Wallet LLC](https://github.com/leather-wallet/mono) |
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,54 @@ | ||
# Leather monorepo setup | ||
|
||
We reviewed a few monorepo approaches and how they may fit into our codebase and decided upon starting with `pnpm workspaces` before then adding `Nx` if needed | ||
|
||
# Motivation | ||
|
||
As a largely single-product company, with a vision for being a multi-product company, we need a way to share code between our various projects. We also need to ensure high code standards and have the best developer experience we can | ||
|
||
## Requirements | ||
|
||
- Well organised monorepo | ||
- Automated package releases | ||
- Publishing to npm | ||
- [with NX](https://nx.dev/concepts/more-concepts/buildable-and-publishable-libraries) | ||
- Enable developers to easily create new packages | ||
- Easy to work with in local development | ||
- Easy to set up package-specific CI jobs | ||
|
||
## Basic Leather monorepo architecture | ||
|
||
This is a basic blueprint of the monorepo. We will begin with a package based monorepo and then decide whether to also host `apps` here too | ||
|
||
```md | ||
leather-mono | ||
├─ apps | ||
│ ├─ extension | ||
│ ├─ mobile | ||
│ ├─ desktop | ||
│ ├─ storybook <-- replaces test-app, place to view UI components with context + tests | ||
├─ docs | ||
├─ packages | ||
│ ├─ api <-- leather API / wrapper interface to other libs: here / under apps, | ||
│ ├─ eslint-config | ||
│ ├─ prettier-config | ||
│ ├─ tsconfig-config | ||
│ ├─ lib | ||
│ ├─ utils <-- shared utils, | ||
│ ├─ ui <-- using definePreset(), contains the theme base (tokens.colors, semantic tokens, etc) | ||
│ │ └─ button <-- consuming the preset, provides a button recipe (in a buttonPreset) | ||
│ │ └─ some-component <-- consuming the preset, provides a component using internal `css` calls, ships a panda.json extract result | ||
``` | ||
|
||
## Items for further consideration | ||
|
||
- migration from `yarn` to [`pnpm`](https://pnpm.io/) | ||
- upgrading from `webpack` to [`esbuild`](https://esbuild.github.io/) | ||
|
||
# Useful references | ||
|
||
- https://medium.com/reactbrasil/reuse-your-eslint-prettier-config-in-a-monorepo-with-lerna-54c1800cacdc | ||
- https://github.com/muravjev/configs/ | ||
- https://www.raulmelo.me/en/blog/replacing-lerna-and-yarn-with-pnpm-workspaces | ||
- https://medium.com/@guysenpai89/nx-monorepo-publish-your-libraries-to-github-packages-with-github-actions-semantic-release-fa9822467b24 | ||
- https://www.javierbrea.com/blog/pnpm-nx-monorepo-01/ |
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,71 @@ | ||
# Package configuration | ||
|
||
The purpose of this monorepo is to host various **[npm packages ↗](https://docs.npmjs.com/about-packages-and-modules)** to facilitate code sharing and at high standards. At it's core it uses `pnpm workspaces` to manage the monorepo | ||
|
||
## Contents | ||
|
||
- [Setup](#setup) | ||
- [License](#license) | ||
|
||
## Setup | ||
|
||
- Create `package.json` file: | ||
|
||
```jsonc | ||
// package.json | ||
|
||
{ | ||
// Package info | ||
|
||
"name": "eather-mono", | ||
"description": "...", | ||
"author": "...", | ||
"license": "MIT", | ||
|
||
// Common scripts | ||
|
||
"scripts": { | ||
"install:clean": "rm -rf \"**/node_modules\" && pnpm -r clean", | ||
"install:fresh": "pnpm install:clean && pnpm i", | ||
"install:nuke": "rm -rf pnpm-lock.yaml && pnpm install:fresh" | ||
}, | ||
|
||
// Only allow pnpm as package manager | ||
|
||
"engines": { | ||
"node": ">=14.16.0", | ||
"pnpm": ">=7.10.0", | ||
"npm": "please-use-pnpm", | ||
"yarn": "please-use-pnpm" | ||
}, | ||
"packageManager": "[email protected]" | ||
} | ||
``` | ||
|
||
- Add npm configuration file: | ||
|
||
```yaml | ||
# .npmrc | ||
|
||
engine-strict = true | ||
auto-install-peers = true | ||
``` | ||
|
||
- Add pnpm workspace file: | ||
|
||
```yaml | ||
# pnpm-workspace.yaml | ||
|
||
packages: | ||
- 'packages/*' | ||
``` | ||
|
||
## License | ||
|
||
[MIT](../../LICENSE) © [Leather Wallet LLC](https://github.com/leather-wallet/mono) | ||
|
||
--- | ||
|
||
[⬅ Back](../../README.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,18 @@ | ||
# TEMPLATE | ||
|
||
## Contents | ||
|
||
- [Setup](#setup) | ||
- [License](#license) | ||
|
||
## Setup | ||
|
||
## License | ||
|
||
[MIT](../../LICENSE) © [Leather Wallet LLC](https://github.com/leather-wallet/mono) | ||
|
||
--- | ||
|
||
[⬅ Back](../../README.md) | ||
|
||
--- |
Oops, something went wrong.
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.
needed if we're using pnpm?
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.
Not 100% needed - works without so I can remove if you think we don't need to add it?
I just added it based on a monorepo template I was following and it seemed useful