Skip to content

Commit 7e2cd75

Browse files
committed
Create README and document monorepo structure
1 parent d5328d6 commit 7e2cd75

File tree

3 files changed

+78
-12
lines changed

3 files changed

+78
-12
lines changed

README.md

+78
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
# Thunderstore UI
2+
3+
Monorepo containing Next.js frontend for [thunderstore.io](https://thunderstore.io)
4+
and reusable UI components.
5+
6+
## Monorepo Setup
7+
8+
- [`yarn` workspaces](https://classic.yarnpkg.com/en/docs/workspaces/) manages
9+
the packages in the monorepo (see `packages` key in base `package.json` file)
10+
and handles dependency installation/deduplication.
11+
- [`preconstruct`](https://preconstruct.tools/) automates building and linking
12+
the packages within the monorepo. Instead of using relative paths, local
13+
packages can be imported as if they were installed via a package manager.
14+
- Packages can be linked locally by running `yarn preconstruct dev`, but this
15+
is handled automatically by `postinstall` hook, so developers don't need to
16+
worry about it.
17+
18+
```
19+
// first time setup
20+
git clone git@github.com:thunderstore-io/thunderstore-ui.git thunderstore-ui
21+
cd thunderstore-ui
22+
yarn install
23+
24+
// start Next.js dev server
25+
yarn workspace @thunderstore/nextjs dev
26+
```
27+
28+
That's it. Changes done to `apps/nextjs` and `packages/components` should both
29+
be automatically visible at [http://localhost:3000/].
30+
31+
### Adding dependencies
32+
33+
To add new dependencies to existing packages, simply run something like:
34+
35+
```
36+
yarn workspace @thunderstore/components add react-table @types/react-table
37+
```
38+
39+
### Adding a new package
40+
41+
To add a completely new package, start by creating the following file structure:
42+
43+
```
44+
// packages/greeter/package.json:
45+
{
46+
"name": "@thunderstore/greeter",
47+
"version": "1.0.0",
48+
"description": "Example package"
49+
}
50+
51+
// packages/greeter/src/index.tsx:
52+
import React from "react";
53+
54+
export const Greeter: React.FC = () => <p>Hello, world!</p>;
55+
```
56+
57+
To add some required fields to the new package's `package.json`, run
58+
`yarn preconstruct init` and allow modifying `package.json` when asked.
59+
60+
To install dependencies, if any, run e.g.
61+
`yarn workspace @thunderstore/greeter add react react-dom @types/react`.
62+
63+
To "install" the new package to Next.js app, update the `dependencies` section
64+
in `apps/nextjs/package.json` with `"@thunderstore/greeter": "^1.0.0",`.
65+
66+
Then run `yarn` one more time to let Preconstruct work its magic. After that the
67+
new package should be usable in the Next.js app by simply importing it:
68+
69+
```
70+
import { Greeter } from "@thunderstore/greeter";
71+
```
72+
73+
### About VS Code...
74+
75+
VS Code may have problem detecting installed packages in this monorepo/workspace
76+
setup. Installing
77+
[Monorepo Workspace extension](https://marketplace.visualstudio.com/items?itemName=folke.vscode-monorepo-workspace)
78+
may solve them.

apps/nextjs/README.md

-11
This file was deleted.

packages/components/README.md

-1
This file was deleted.

0 commit comments

Comments
 (0)