create-croissant 0.1.10 → 0.1.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/template/.env.example +5 -0
- package/template/README.md +65 -8
package/package.json
CHANGED
package/template/README.md
CHANGED
|
@@ -16,17 +16,28 @@ npx create-croissant@latest
|
|
|
16
16
|
|
|
17
17
|
- **Frontend**: [TanStack Start](https://tanstack.com/start) for a seamless, type-safe React experience.
|
|
18
18
|
- **Authentication**: [Better Auth](https://www.better-auth.com/) with Drizzle adapter and PostgreSQL.
|
|
19
|
-
- **API**: [oRPC](https://orpc.sh/) for end-to-end type-safety
|
|
19
|
+
- **API**: [oRPC](https://orpc.sh/) with a modular, namespaced router for end-to-end type-safety.
|
|
20
20
|
- **Database**: [Drizzle ORM](https://orm.drizzle.team/) with PostgreSQL and Docker Compose setup.
|
|
21
21
|
- **Styling**: [shadcn/ui](https://ui.shadcn.com/) components with Tailwind CSS.
|
|
22
|
-
- **Monorepo**:
|
|
22
|
+
- **Monorepo**: Powered by [Turborepo](https://turbo.build/) for lightning-fast builds and smart task orchestration.
|
|
23
|
+
- **Developer Experience**: Path aliases (`@/`), strict TypeScript, and automated linting/formatting.
|
|
24
|
+
|
|
25
|
+
## 🚀 Monorepo Management with Turborepo
|
|
26
|
+
|
|
27
|
+
This project uses **Turborepo** to manage the monorepo efficiently. Turbo understands the dependency graph between our packages and optimizes our workflow in several ways:
|
|
28
|
+
|
|
29
|
+
- **Smart Caching**: Tasks like `build` and `lint` are cached. If the code hasn't changed, Turbo will replay the logs and output instantly.
|
|
30
|
+
- **Parallel Execution**: Run tasks across multiple packages simultaneously without stepping on each other's toes.
|
|
31
|
+
- **Task Pipelines**: Defines the relationship between tasks (e.g., "don't build the app until its dependencies are built").
|
|
32
|
+
|
|
33
|
+
You can see the configuration in `turbo.json`.
|
|
23
34
|
|
|
24
35
|
## 📁 Project Structure
|
|
25
36
|
|
|
26
|
-
- `apps/web`: The main TanStack Start application.
|
|
37
|
+
- `apps/web`: The main TanStack Start application. Uses `@/` path alias for clean imports.
|
|
27
38
|
- `packages/auth`: Authentication logic and Better Auth configuration.
|
|
28
39
|
- `packages/db`: Database schema, migrations, and Drizzle client.
|
|
29
|
-
- `packages/orpc`: Type-safe API router
|
|
40
|
+
- `packages/orpc`: Type-safe API router. Organized into modular files (e.g., `lib/planets.ts`).
|
|
30
41
|
- `packages/ui`: Shared UI components and styles.
|
|
31
42
|
|
|
32
43
|
## 🛠️ Getting Started
|
|
@@ -49,11 +60,18 @@ This command runs a PostgreSQL container named `samstack` on port `5432`.
|
|
|
49
60
|
|
|
50
61
|
### 3. Environment Variables
|
|
51
62
|
|
|
52
|
-
Create a `.env` file in the root directory
|
|
63
|
+
Create a `.env` file in the root directory by copying the example:
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
cp .env.example .env
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
Ensure you provide the necessary variables:
|
|
53
70
|
|
|
54
71
|
```env
|
|
55
72
|
DATABASE_URL=postgresql://postgres:postgres@localhost:5432/auth
|
|
56
73
|
BETTER_AUTH_URL=http://localhost:3000
|
|
74
|
+
BETTER_AUTH_SECRET=your-secret-here
|
|
57
75
|
```
|
|
58
76
|
|
|
59
77
|
### 4. Push Database Schema
|
|
@@ -75,20 +93,59 @@ The application will be available at `http://localhost:3000`.
|
|
|
75
93
|
|
|
76
94
|
## 📦 Scripts
|
|
77
95
|
|
|
96
|
+
All scripts are orchestrated by Turborepo. You can run them from the root directory:
|
|
97
|
+
|
|
78
98
|
- `npm run dev`: Start all applications in development mode.
|
|
79
99
|
- `npm run build`: Build all applications for production.
|
|
100
|
+
- `npm run lint`: Lint all packages (uses Turbo's caching).
|
|
101
|
+
- `npm run format`: Format all packages using Prettier.
|
|
102
|
+
- `npm run typecheck`: Run TypeScript type checking across the workspace.
|
|
103
|
+
|
|
104
|
+
### 🗄️ Database Scripts
|
|
105
|
+
|
|
106
|
+
These handle Docker and Drizzle operations:
|
|
107
|
+
|
|
80
108
|
- `npm run db:up`: Start the PostgreSQL Docker container.
|
|
81
109
|
- `npm run db:down`: Stop and remove the database container.
|
|
82
110
|
- `npm run db:logs`: Tail logs from the database container.
|
|
83
|
-
- `npm run
|
|
84
|
-
- `npm run
|
|
111
|
+
- `npm run db:push --filter @workspace/db`: Push Drizzle schema to the database.
|
|
112
|
+
- `npm run db:studio --filter @workspace/db`: Open Drizzle Studio to explore your data.
|
|
113
|
+
|
|
114
|
+
### 🎯 Filtering Tasks
|
|
115
|
+
|
|
116
|
+
Turbo allows you to run tasks for specific packages using the `--filter` flag:
|
|
117
|
+
|
|
118
|
+
```bash
|
|
119
|
+
# Only lint the web app
|
|
120
|
+
npm run lint -- --filter web
|
|
121
|
+
|
|
122
|
+
# Build the db package and everything that depends on it
|
|
123
|
+
npm run build -- --filter @workspace/db...
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
## 🔗 oRPC & Type Safety
|
|
127
|
+
|
|
128
|
+
The project uses oRPC for end-to-end type safety. The router is modularized for better maintainability:
|
|
129
|
+
|
|
130
|
+
- `packages/orpc/src/lib/router.ts`: Main router entry point.
|
|
131
|
+
- `packages/orpc/src/lib/planets.ts`: Planet-related procedures.
|
|
132
|
+
|
|
133
|
+
On the client side, you can infer types directly from the router:
|
|
134
|
+
|
|
135
|
+
```typescript
|
|
136
|
+
import type { router } from "@workspace/orpc/router"
|
|
137
|
+
import type { InferRouterInputs, InferRouterOutputs } from "@orpc/server"
|
|
138
|
+
|
|
139
|
+
type Inputs = InferRouterInputs<typeof router>
|
|
140
|
+
type Outputs = InferRouterOutputs<typeof router>
|
|
141
|
+
```
|
|
85
142
|
|
|
86
143
|
## 🧱 Adding Components
|
|
87
144
|
|
|
88
145
|
To add components to the shared UI package:
|
|
89
146
|
|
|
90
147
|
```bash
|
|
91
|
-
|
|
148
|
+
npx shadcn@latest add [component-name] -c apps/web
|
|
92
149
|
```
|
|
93
150
|
|
|
94
151
|
This will place the UI components in `packages/ui/src/components`.
|