-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #285 from thunderstore-io/preconstruct-rework
Use Preconstruct to manage monorepo
- Loading branch information
Showing
47 changed files
with
3,611 additions
and
5,971 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
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
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,78 @@ | ||
# Thunderstore UI | ||
|
||
Monorepo containing Next.js frontend for [thunderstore.io](https://thunderstore.io) | ||
and reusable UI components. | ||
|
||
## Monorepo Setup | ||
|
||
- [`yarn` workspaces](https://classic.yarnpkg.com/en/docs/workspaces/) manages | ||
the packages in the monorepo (see `packages` key in base `package.json` file) | ||
and handles dependency installation/deduplication. | ||
- [`preconstruct`](https://preconstruct.tools/) automates building and linking | ||
the packages within the monorepo. Instead of using relative paths, local | ||
packages can be imported as if they were installed via a package manager. | ||
- Packages can be linked locally by running `yarn preconstruct dev`, but this | ||
is handled automatically by `postinstall` hook, so developers don't need to | ||
worry about it. | ||
|
||
``` | ||
// first time setup | ||
git clone [email protected]:thunderstore-io/thunderstore-ui.git thunderstore-ui | ||
cd thunderstore-ui | ||
yarn install | ||
// start Next.js dev server | ||
yarn workspace @thunderstore/nextjs dev | ||
``` | ||
|
||
That's it. Changes done to `apps/nextjs` and `packages/components` should both | ||
be automatically visible at [http://localhost:3000/]. | ||
|
||
### Adding dependencies | ||
|
||
To add new dependencies to existing packages, simply run something like: | ||
|
||
``` | ||
yarn workspace @thunderstore/components add react-table @types/react-table | ||
``` | ||
|
||
### Adding a new package | ||
|
||
To add a completely new package, start by creating the following file structure: | ||
|
||
``` | ||
// packages/greeter/package.json: | ||
{ | ||
"name": "@thunderstore/greeter", | ||
"version": "1.0.0", | ||
"description": "Example package" | ||
} | ||
// packages/greeter/src/index.tsx: | ||
import React from "react"; | ||
export const Greeter: React.FC = () => <p>Hello, world!</p>; | ||
``` | ||
|
||
To add some required fields to the new package's `package.json`, run | ||
`yarn preconstruct init` and allow modifying `package.json` when asked. | ||
|
||
To install dependencies, if any, run e.g. | ||
`yarn workspace @thunderstore/greeter add react react-dom @types/react`. | ||
|
||
To "install" the new package to Next.js app, update the `dependencies` section | ||
in `apps/nextjs/package.json` with `"@thunderstore/greeter": "^1.0.0",`. | ||
|
||
Then run `yarn` one more time to let Preconstruct work its magic. After that the | ||
new package should be usable in the Next.js app by simply importing it: | ||
|
||
``` | ||
import { Greeter } from "@thunderstore/greeter"; | ||
``` | ||
|
||
### About VS Code... | ||
|
||
VS Code may have problem detecting installed packages in this monorepo/workspace | ||
setup. Installing | ||
[Monorepo Workspace extension](https://marketplace.visualstudio.com/items?itemName=folke.vscode-monorepo-workspace) | ||
may solve them. |
File renamed without changes.
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 |
---|---|---|
@@ -1,3 +1,6 @@ | ||
/// <reference types="next" /> | ||
/// <reference types="next/types/global" /> | ||
/// <reference types="next/image-types/global" /> | ||
|
||
// NOTE: This file should not be edited | ||
// see https://nextjs.org/docs/basic-features/typescript for more information. |
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 @@ | ||
const withPreconstruct = require("@preconstruct/next"); | ||
|
||
module.exports = withPreconstruct(); |
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 @@ | ||
{ | ||
"name": "@thunderstore/nextjs", | ||
"version": "0.1.0", | ||
"repository": "https://github.com/thunderstore-io/thunderstore-ui/tree/master/apps/nextjs", | ||
"private": true, | ||
"scripts": { | ||
"dev": "next dev", | ||
"build": "next build", | ||
"start": "next start" | ||
}, | ||
"dependencies": { | ||
"@chakra-ui/react": "^1.6.8", | ||
"@emotion/react": "^11.4.1", | ||
"@emotion/styled": "^11.3.0", | ||
"@thunderstore/components": "^0.1.0", | ||
"@types/react": "^17.0.19", | ||
"framer-motion": "^4.1.17", | ||
"next": "^11.1.0", | ||
"react": "^17.0.2", | ||
"react-dom": "^17.0.2" | ||
}, | ||
"devDependencies": { | ||
"@preconstruct/next": "^3.0.1", | ||
"eslint-config-next": "^11.1.2" | ||
} | ||
} |
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
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
nextjs/pages/community-picker.tsx → apps/nextjs/pages/community-picker.tsx
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
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
nextjs/pages/package-upload.tsx → apps/nextjs/pages/package-upload.tsx
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
2 changes: 1 addition & 1 deletion
2
nextjs/pages/team-picker.tsx → apps/nextjs/pages/team-picker.tsx
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
File renamed without changes.
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
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,14 @@ | ||
module.exports = { | ||
presets: [ | ||
[ | ||
"@babel/preset-env", | ||
{ | ||
modules: false, | ||
loose: true, | ||
}, | ||
], | ||
"@babel/preset-react", | ||
"@babel/preset-typescript", | ||
], | ||
plugins: ["@babel/plugin-transform-runtime"], | ||
}; |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.