Skip to content

Commit

Permalink
Merge branch 'main' into feat/link-vercel
Browse files Browse the repository at this point in the history
  • Loading branch information
KarolinaKopacz authored Oct 21, 2024
2 parents 4764084 + b814f1a commit fbfdb82
Show file tree
Hide file tree
Showing 6 changed files with 201 additions and 2 deletions.
4 changes: 4 additions & 0 deletions packages/core/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import { installSupabase } from './utils/supabase/install';
import { createTurboRepo } from './utils/turbo/create';
import { deployVercelProject } from './utils/vercel/deploy';
import { setupAndCreateVercelProject } from './utils/vercel/setupAndCreate';
import { createDocFiles } from './utils/docs/create';


interface ProjectOptions {
name: string;
Expand All @@ -31,6 +33,8 @@ export async function createProject(options: ProjectOptions) {

installSupabase(currentDir);

createDocFiles();

await prettify();

await initializeRepository({
Expand Down
63 changes: 63 additions & 0 deletions packages/core/templates/docs/files/ARCHITECTURE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
## Repository Structure

```bash
.
├── .env # Contains all the environment variables.
├── README.md # Main project documentation file explaining overall usage and features.
├── apps # Contains all the main application code (frontend or backend).
│ ├── docs # Documentation app, possibly a Next.js site or documentation tool.
│ │ ├── README.md # Documentation for the `docs` app itself.
│ │ ├── app # Main Next.js `app` directory.
│ │ ├── next-env.d.ts # TypeScript definitions for Next.js.
│ │ ├── next.config.mjs # Configuration for the Next.js app.
│ │ ├── package.json # Dependencies and scripts for the `docs` app.
│ │ ├── public # Public static files (e.g., images, icons) for the `docs` app.
│ │ └── tsconfig.json # TypeScript configuration for the `docs` app.
│ └── web # The main web app of the project, likely built with Next.js and Payload CMS.
│ ├── README.md # Documentation specific to the `web` app.
│ ├── app # Main directory for the `web` app.
│   │   ├── (app) # Main directory for the Next.js app.
│   │   ├── (payload) # Main directory for the Payload CMS app.
│   │   └── my-route # Example route created by Payload.
│ ├── collections # Payload CMS collections for managing database entities.
│ ├── next-env.d.ts # TypeScript definitions for Next.js.
│ ├── next.config.mjs # Configuration for the Next.js `web` app.
│ ├── package.json # Dependencies and scripts for the `web` app.
│ ├── payload-types.ts # Auto-generated TypeScript types based on Payload CMS collections.
│ ├── payload.config.ts # Payload CMS configuration file.
│ ├── public # Public static files (e.g., images, fonts) for the `web` app.
│ └── tsconfig.json # TypeScript configuration for the `web` app.
├── package.json # Root project dependencies and scripts (workspace-wide or shared).
├── packages # Reusable packages or configurations shared across apps.
│ ├── eslint-config # ESLint configuration for linting the project.
│ │ ├── README.md # Documentation for the ESLint configuration package.
│ │ ├── library.js # ESLint rules for JavaScript libraries.
│ │ ├── next.js # ESLint rules for Next.js apps.
│ │ ├── package.json # Dependencies for the ESLint configuration package.
│ │ └── react-internal.js # ESLint rules for React-related code.
│ ├── typescript-config # Shared TypeScript configuration across different apps.
│ │ ├── base.json # Base TypeScript configuration.
│ │ ├── nextjs.json # TypeScript configuration specific to Next.js.
│ │ ├── package.json # Package.json for the TypeScript configuration package.
│ │ └── react-library.json # TypeScript configuration for React libraries.
│ └── ui # Reusable UI components or shared UI library.
│ ├── package.json # Dependencies for the `ui` package.
│ ├── src # Source code for shared UI components.
│ ├── tsconfig.json # TypeScript configuration for the `ui` package.
│ ├── tsconfig.lint.json # TypeScript configuration for linting purposes.
│ └── turbo # Turbo configuration for optimizing builds in the `ui` package.
├── pnpm-lock.yaml # Lock file for pnpm, ensures consistency across installations.
├── pnpm-workspace.yaml # Configuration file for managing the pnpm workspace.
├── supabase # Contains code and configuration for the Supabase backend.
│ ├── config.toml # Supabase configuration file.
│ ├── package.json # Dependencies and scripts for the Supabase backend.
│ ├── seed.sql # SQL seed file for initializing the database.
│ └── src # Source code for Supabase-related server and client logic.
│ ├── client.ts # Supabase client setup.
│ ├── index.ts # Main entry point for Supabase backend.
│ ├── middleware.ts # Middleware logic for handling requests.
│ ├── server.ts # Server-side logic for Supabase.
│ └── types.ts # TypeScript types for Supabase-related entities.
└── turbo.json # Turbo configuration for managing and optimizing monorepo tasks.

```
115 changes: 115 additions & 0 deletions packages/core/templates/docs/files/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
# My Fullstack App

This project was generated using the **Stapler CLI**. It sets up a fullstack monorepo with **Next.js**, **Supabase**, **Payload CMS**, and more, leveraging **Turbo** and **pnpm** to streamline your development workflow.

### Key Directories

- **apps/web**: This is the main frontend for your project. Built with Next.js, it also optionally integrates **Payload CMS** for content management.
- **apps/docs**: This could serve as your project's documentation site or any other static content site.
- **supabase**: Contains the configuration and code for Supabase, which serves as your project's backend (database, authentication, and API).
- **packages**: Shared utilities, TypeScript configurations, ESLint rules, and UI components that can be reused across different apps.

## Getting Started

### Prerequisites

Ensure that you have the following installed on your machine:

- [Node.js](https://nodejs.org/) (version >= 16)
- [pnpm](https://pnpm.io/installation) (package manager)
- [Supabase CLI](https://supabase.com/docs/guides/cli)
- [GitHub CLI](https://cli.github.com/) (for repo management)

### Install Dependencies

To install all the necessary dependencies across the monorepo, run:

```bash
pnpm install
```

## Running the Project

### Frontend (Next.js)

To start the `web` app (frontend):

```bash
cd apps/web
pnpm dev
```

This will launch the Next.js frontend on `http://localhost:3000`.

### Documentation (Optional)

To start the documentation site (if configured):

```bash
cd apps/docs
pnpm dev
```

This will run the documentation app at `http://localhost:3001`.

### Supabase Backend

To start the backend server with Supabase:

```bash
cd supabase
supabase start
```

This will launch Supabase services locally, including the database and API.

## Environment Variables

Next.js and Supabase environment variables are automatically stored in the `.env` file in the project's root folder.
Payload CMS environment variables are generated in `apps/web`.

## Development Workflow

### Turbo Tasks

The monorepo uses **Turbo** to manage and speed up tasks across different apps. To see the available tasks, run:

```bash
pnpm turbo run
```

You can execute tasks like building, linting, or testing across all apps simultaneously.
Linting

To lint the entire project with ESLint:

```bash
pnpm lint
```

### Building for Production

To create a production build of the project:

```bash
pnpm build
```

## Project Structure

Refer to the [ARCHITECTURE](ARCHITECTURE.md) document for an in-depth overview of the project structure.

## Customization

You can extend the project by:

- Adding new apps: Create a new directory in apps/ and set up another service (e.g., a mobile app).

To add your own `packages` and `apps`, run:

```bash
pnpm turbo gen workspace
```

- Adding Payload CMS collections: Modify the `payload.config.ts` file in `apps/web` to add new content types.
- Customizing Supabase: Write custom SQL queries or functions in Supabase.
6 changes: 6 additions & 0 deletions packages/core/templates/docs/installConfig.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export const docFiles = [
{
path: './',
files: ['README.md', 'ARCHITECTURE.md'],
},
];
4 changes: 2 additions & 2 deletions packages/core/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@
"declaration": true, // Ensure TypeScript generates declaration files
"emitDeclarationOnly": true // Only emit declaration files without compiling the code
},
"include": ["index.ts", "utils/**/*.ts", "templates/supabase/installConfig.ts"],
"exclude": ["node_modules", "dist", "templates/supabase/files/**/*"]
"include": ["index.ts", "utils/**/*.ts", "templates/supabase/installConfig.ts", "templates/docs/installConfig.ts"],
"exclude": ["node_modules", "dist", "templates/supabase/files/**/*", "templates/docs/files/**/*"]
}
11 changes: 11 additions & 0 deletions packages/core/utils/docs/create.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import path from 'path';
import { templateGenerator } from '../generator/generator';
import { docFiles } from '../../templates/docs/installConfig';

export const createDocFiles = () => {
console.log('🖇️ Writing docs...');
const templateDirectory = path.join(__dirname, '../templates/docs/files');
const destinationDirectory = process.cwd();

templateGenerator(docFiles, templateDirectory, destinationDirectory);
};

0 comments on commit fbfdb82

Please sign in to comment.