From 15db6789f48f2d2da796ef62d9f17c8dae886fb6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antti=20M=C3=A4ki?= Date: Fri, 26 Nov 2021 10:22:34 +0200 Subject: [PATCH] Change project structure https://monorepo.guide/getting-started suggests that apps directory should contain "user-facing apps and websites" and packages directory should contain "packages designed to be consumed by other packages (published OR internal)". I'm not sure if this is a common convention, but it lookes simple and clear enough for me. Rename our nextjs app to @thunderstore/nextjs and components package to @thunderstore/components. Fix imports to reflect the changes. Update the references in GitHub Actions files to reflect the new file paths. --- .github/workflows/static-analysis.yml | 2 +- .github/workflows/test.yml | 12 ++++-------- {nextjs => apps/nextjs}/.env.development | 0 {nextjs => apps/nextjs}/.gitignore | 0 {nextjs => apps/nextjs}/README.md | 0 {nextjs => apps/nextjs}/next-env.d.ts | 0 {nextjs => apps/nextjs}/package.json | 4 ++-- {nextjs => apps/nextjs}/pages/_app.tsx | 2 +- {nextjs => apps/nextjs}/pages/_document.tsx | 0 {nextjs => apps/nextjs}/pages/community-picker.tsx | 2 +- {nextjs => apps/nextjs}/pages/index.tsx | 0 {nextjs => apps/nextjs}/pages/package-upload.tsx | 2 +- {nextjs => apps/nextjs}/pages/team-picker.tsx | 2 +- {nextjs => apps/nextjs}/public/favicon.ico | Bin {nextjs => apps/nextjs}/public/vercel.svg | 0 {nextjs => apps/nextjs}/tsconfig.json | 2 +- {nextjs => apps/nextjs}/yarn.lock | 0 .../components}/.gitignore | 0 .../components}/README.md | 0 .../components}/package.json | 2 +- .../components}/src/components/CommunityPicker.tsx | 0 .../components}/src/components/FileUpload.tsx | 0 .../components}/src/components/Markdown.tsx | 0 .../components}/src/components/PackageUpload.tsx | 0 .../components}/src/components/RootWrapper.tsx | 0 .../components}/src/components/Select.tsx | 0 .../components}/src/components/StickyFooter.tsx | 0 .../components}/src/components/TeamPicker.tsx | 0 .../src/components/ThunderstoreProvider.tsx | 0 .../components}/src/constants.ts | 0 .../components}/src/fetch.ts | 0 .../components}/src/index.ts | 0 .../components}/src/theme.ts | 0 .../components}/tsconfig.json | 0 .../components}/yarn.lock | 0 35 files changed, 13 insertions(+), 17 deletions(-) rename {nextjs => apps/nextjs}/.env.development (100%) rename {nextjs => apps/nextjs}/.gitignore (100%) rename {nextjs => apps/nextjs}/README.md (100%) rename {nextjs => apps/nextjs}/next-env.d.ts (100%) rename {nextjs => apps/nextjs}/package.json (91%) rename {nextjs => apps/nextjs}/pages/_app.tsx (85%) rename {nextjs => apps/nextjs}/pages/_document.tsx (100%) rename {nextjs => apps/nextjs}/pages/community-picker.tsx (93%) rename {nextjs => apps/nextjs}/pages/index.tsx (100%) rename {nextjs => apps/nextjs}/pages/package-upload.tsx (73%) rename {nextjs => apps/nextjs}/pages/team-picker.tsx (94%) rename {nextjs => apps/nextjs}/public/favicon.ico (100%) rename {nextjs => apps/nextjs}/public/vercel.svg (100%) rename {nextjs => apps/nextjs}/tsconfig.json (93%) rename {nextjs => apps/nextjs}/yarn.lock (100%) rename {thunderstore-components => packages/components}/.gitignore (100%) rename {thunderstore-components => packages/components}/README.md (100%) rename {thunderstore-components => packages/components}/package.json (95%) rename {thunderstore-components => packages/components}/src/components/CommunityPicker.tsx (100%) rename {thunderstore-components => packages/components}/src/components/FileUpload.tsx (100%) rename {thunderstore-components => packages/components}/src/components/Markdown.tsx (100%) rename {thunderstore-components => packages/components}/src/components/PackageUpload.tsx (100%) rename {thunderstore-components => packages/components}/src/components/RootWrapper.tsx (100%) rename {thunderstore-components => packages/components}/src/components/Select.tsx (100%) rename {thunderstore-components => packages/components}/src/components/StickyFooter.tsx (100%) rename {thunderstore-components => packages/components}/src/components/TeamPicker.tsx (100%) rename {thunderstore-components => packages/components}/src/components/ThunderstoreProvider.tsx (100%) rename {thunderstore-components => packages/components}/src/constants.ts (100%) rename {thunderstore-components => packages/components}/src/fetch.ts (100%) rename {thunderstore-components => packages/components}/src/index.ts (100%) rename {thunderstore-components => packages/components}/src/theme.ts (100%) rename {thunderstore-components => packages/components}/tsconfig.json (100%) rename {thunderstore-components => packages/components}/yarn.lock (100%) diff --git a/.github/workflows/static-analysis.yml b/.github/workflows/static-analysis.yml index fa4fb7dc7..f60da7f5b 100644 --- a/.github/workflows/static-analysis.yml +++ b/.github/workflows/static-analysis.yml @@ -52,7 +52,7 @@ jobs: - name: Install yarn dependencies run: yarn install - name: Run ESLint - run: yarn run eslint nextjs thunderstore-components -f node_modules/@microsoft/eslint-formatter-sarif/sarif.js -o results.sarif || ":" + run: yarn run eslint apps packages -f node_modules/@microsoft/eslint-formatter-sarif/sarif.js -o results.sarif || ":" - name: Upload SARIF uses: github/codeql-action/upload-sarif@v1 with: diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 9120895e0..46ebf66f4 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -47,11 +47,7 @@ jobs: yarn-${{ runner.os }}- - name: Install Yarn dependencies run: yarn install --frozen-lockfile - - name: Build thunderstore-components - run: | - cd thunderstore-components - yarn build - - name: Build nextjs - run: | - cd nextjs - yarn build + - name: Build @thunderstore/components + run: yarn workspace @thunderstore/components build + - name: Build @thunderstore/nextjs + run: yarn workspace @thunderstore/nextjs build diff --git a/nextjs/.env.development b/apps/nextjs/.env.development similarity index 100% rename from nextjs/.env.development rename to apps/nextjs/.env.development diff --git a/nextjs/.gitignore b/apps/nextjs/.gitignore similarity index 100% rename from nextjs/.gitignore rename to apps/nextjs/.gitignore diff --git a/nextjs/README.md b/apps/nextjs/README.md similarity index 100% rename from nextjs/README.md rename to apps/nextjs/README.md diff --git a/nextjs/next-env.d.ts b/apps/nextjs/next-env.d.ts similarity index 100% rename from nextjs/next-env.d.ts rename to apps/nextjs/next-env.d.ts diff --git a/nextjs/package.json b/apps/nextjs/package.json similarity index 91% rename from nextjs/package.json rename to apps/nextjs/package.json index 9c6ac93e5..49c0af19a 100644 --- a/nextjs/package.json +++ b/apps/nextjs/package.json @@ -1,8 +1,8 @@ { - "name": "nextjs", + "name": "@thunderstore/nextjs", "version": "0.1.0", - "private": true, "repository": "https://github.com/thunderstore-io/thunderstore-ui/tree/master/nextjs", + "private": true, "scripts": { "dev": "next dev", "build": "next build", diff --git a/nextjs/pages/_app.tsx b/apps/nextjs/pages/_app.tsx similarity index 85% rename from nextjs/pages/_app.tsx rename to apps/nextjs/pages/_app.tsx index 34d18d82d..fb97e6f9f 100644 --- a/nextjs/pages/_app.tsx +++ b/apps/nextjs/pages/_app.tsx @@ -1,5 +1,5 @@ import { AppProps } from "next/app"; -import { RootWrapper, theme } from "thunderstore-components"; +import { RootWrapper, theme } from "@thunderstore/components"; function MyApp({ Component, pageProps }: AppProps): JSX.Element { return ( diff --git a/nextjs/pages/_document.tsx b/apps/nextjs/pages/_document.tsx similarity index 100% rename from nextjs/pages/_document.tsx rename to apps/nextjs/pages/_document.tsx diff --git a/nextjs/pages/community-picker.tsx b/apps/nextjs/pages/community-picker.tsx similarity index 93% rename from nextjs/pages/community-picker.tsx rename to apps/nextjs/pages/community-picker.tsx index b20725baf..9ba1e1fd2 100644 --- a/nextjs/pages/community-picker.tsx +++ b/apps/nextjs/pages/community-picker.tsx @@ -1,4 +1,4 @@ -import { Community, MultiCommunityPicker } from "thunderstore-components"; +import { Community, MultiCommunityPicker } from "@thunderstore/components"; import React, { useState } from "react"; import { Box, Button, List, ListItem } from "@chakra-ui/react"; diff --git a/nextjs/pages/index.tsx b/apps/nextjs/pages/index.tsx similarity index 100% rename from nextjs/pages/index.tsx rename to apps/nextjs/pages/index.tsx diff --git a/nextjs/pages/package-upload.tsx b/apps/nextjs/pages/package-upload.tsx similarity index 73% rename from nextjs/pages/package-upload.tsx rename to apps/nextjs/pages/package-upload.tsx index 4b219aac7..ea580039f 100644 --- a/nextjs/pages/package-upload.tsx +++ b/apps/nextjs/pages/package-upload.tsx @@ -1,4 +1,4 @@ -import { PackageUpload } from "thunderstore-components"; +import { PackageUpload } from "@thunderstore/components"; import React from "react"; const PackageUploadPage: React.FC> = () => { diff --git a/nextjs/pages/team-picker.tsx b/apps/nextjs/pages/team-picker.tsx similarity index 94% rename from nextjs/pages/team-picker.tsx rename to apps/nextjs/pages/team-picker.tsx index bd9a8abf7..08646cbd2 100644 --- a/nextjs/pages/team-picker.tsx +++ b/apps/nextjs/pages/team-picker.tsx @@ -1,4 +1,4 @@ -import { TeamPicker } from "thunderstore-components"; +import { TeamPicker } from "@thunderstore/components"; import React, { useState } from "react"; import { Box, Button, Text } from "@chakra-ui/react"; diff --git a/nextjs/public/favicon.ico b/apps/nextjs/public/favicon.ico similarity index 100% rename from nextjs/public/favicon.ico rename to apps/nextjs/public/favicon.ico diff --git a/nextjs/public/vercel.svg b/apps/nextjs/public/vercel.svg similarity index 100% rename from nextjs/public/vercel.svg rename to apps/nextjs/public/vercel.svg diff --git a/nextjs/tsconfig.json b/apps/nextjs/tsconfig.json similarity index 93% rename from nextjs/tsconfig.json rename to apps/nextjs/tsconfig.json index e7a61ed0c..ce10b5163 100644 --- a/nextjs/tsconfig.json +++ b/apps/nextjs/tsconfig.json @@ -28,5 +28,5 @@ }, "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"], "exclude": ["node_modules"], - "references": [{ "path": "../thunderstore-components" }] + "references": [{ "path": "../../packages/components" }] } diff --git a/nextjs/yarn.lock b/apps/nextjs/yarn.lock similarity index 100% rename from nextjs/yarn.lock rename to apps/nextjs/yarn.lock diff --git a/thunderstore-components/.gitignore b/packages/components/.gitignore similarity index 100% rename from thunderstore-components/.gitignore rename to packages/components/.gitignore diff --git a/thunderstore-components/README.md b/packages/components/README.md similarity index 100% rename from thunderstore-components/README.md rename to packages/components/README.md diff --git a/thunderstore-components/package.json b/packages/components/package.json similarity index 95% rename from thunderstore-components/package.json rename to packages/components/package.json index 3032dbf16..b3573f141 100644 --- a/thunderstore-components/package.json +++ b/packages/components/package.json @@ -1,5 +1,5 @@ { - "name": "thunderstore-components", + "name": "@thunderstore/components", "version": "0.1.0", "description": "Shared components for Thunderstore", "repository": "https://github.com/thunderstore-io/thunderstore-ui/tree/master/thunderstore-components", diff --git a/thunderstore-components/src/components/CommunityPicker.tsx b/packages/components/src/components/CommunityPicker.tsx similarity index 100% rename from thunderstore-components/src/components/CommunityPicker.tsx rename to packages/components/src/components/CommunityPicker.tsx diff --git a/thunderstore-components/src/components/FileUpload.tsx b/packages/components/src/components/FileUpload.tsx similarity index 100% rename from thunderstore-components/src/components/FileUpload.tsx rename to packages/components/src/components/FileUpload.tsx diff --git a/thunderstore-components/src/components/Markdown.tsx b/packages/components/src/components/Markdown.tsx similarity index 100% rename from thunderstore-components/src/components/Markdown.tsx rename to packages/components/src/components/Markdown.tsx diff --git a/thunderstore-components/src/components/PackageUpload.tsx b/packages/components/src/components/PackageUpload.tsx similarity index 100% rename from thunderstore-components/src/components/PackageUpload.tsx rename to packages/components/src/components/PackageUpload.tsx diff --git a/thunderstore-components/src/components/RootWrapper.tsx b/packages/components/src/components/RootWrapper.tsx similarity index 100% rename from thunderstore-components/src/components/RootWrapper.tsx rename to packages/components/src/components/RootWrapper.tsx diff --git a/thunderstore-components/src/components/Select.tsx b/packages/components/src/components/Select.tsx similarity index 100% rename from thunderstore-components/src/components/Select.tsx rename to packages/components/src/components/Select.tsx diff --git a/thunderstore-components/src/components/StickyFooter.tsx b/packages/components/src/components/StickyFooter.tsx similarity index 100% rename from thunderstore-components/src/components/StickyFooter.tsx rename to packages/components/src/components/StickyFooter.tsx diff --git a/thunderstore-components/src/components/TeamPicker.tsx b/packages/components/src/components/TeamPicker.tsx similarity index 100% rename from thunderstore-components/src/components/TeamPicker.tsx rename to packages/components/src/components/TeamPicker.tsx diff --git a/thunderstore-components/src/components/ThunderstoreProvider.tsx b/packages/components/src/components/ThunderstoreProvider.tsx similarity index 100% rename from thunderstore-components/src/components/ThunderstoreProvider.tsx rename to packages/components/src/components/ThunderstoreProvider.tsx diff --git a/thunderstore-components/src/constants.ts b/packages/components/src/constants.ts similarity index 100% rename from thunderstore-components/src/constants.ts rename to packages/components/src/constants.ts diff --git a/thunderstore-components/src/fetch.ts b/packages/components/src/fetch.ts similarity index 100% rename from thunderstore-components/src/fetch.ts rename to packages/components/src/fetch.ts diff --git a/thunderstore-components/src/index.ts b/packages/components/src/index.ts similarity index 100% rename from thunderstore-components/src/index.ts rename to packages/components/src/index.ts diff --git a/thunderstore-components/src/theme.ts b/packages/components/src/theme.ts similarity index 100% rename from thunderstore-components/src/theme.ts rename to packages/components/src/theme.ts diff --git a/thunderstore-components/tsconfig.json b/packages/components/tsconfig.json similarity index 100% rename from thunderstore-components/tsconfig.json rename to packages/components/tsconfig.json diff --git a/thunderstore-components/yarn.lock b/packages/components/yarn.lock similarity index 100% rename from thunderstore-components/yarn.lock rename to packages/components/yarn.lock