@donotdev/cli 0.0.16 → 0.0.17
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/dependencies-matrix.json +33 -129
- package/dist/bin/commands/bump.js +9 -2
- package/dist/bin/commands/create-app.js +195 -40
- package/dist/bin/commands/create-project.js +195 -40
- package/dist/bin/commands/deploy.js +51 -20
- package/dist/bin/commands/doctor.js +249 -56
- package/dist/bin/commands/emu.js +18 -20
- package/dist/bin/commands/make-admin.js +30 -10
- package/dist/bin/commands/setup.js +512 -122
- package/dist/bin/commands/type-check.d.ts.map +1 -1
- package/dist/bin/commands/type-check.js +7 -3
- package/dist/bin/commands/type-check.js.map +1 -1
- package/dist/bin/donotdev.js +26 -14
- package/dist/index.js +264 -80
- package/package.json +1 -1
- package/templates/root-consumer/guides/dndev/ENV_SETUP.md.example +6 -6
- package/templates/root-consumer/guides/dndev/INDEX.md.example +2 -2
- package/templates/root-consumer/guides/dndev/SETUP_AUTH.md.example +13 -6
- package/templates/root-consumer/guides/dndev/SETUP_CRUD.md.example +149 -1086
- package/templates/root-consumer/guides/dndev/SETUP_FIREBASE.md.example +68 -16
- package/templates/root-consumer/guides/dndev/SETUP_FUNCTIONS.md.example +6 -111
- package/templates/root-consumer/guides/dndev/SETUP_SUPABASE.md.example +123 -32
- package/templates/root-consumer/guides/dndev/SETUP_VERCEL.md.example +108 -91
- package/templates/root-consumer/guides/dndev/advanced/EMULATORS.md.example +2 -2
- package/dist/bin/commands/firebase-setup.d.ts +0 -6
- package/dist/bin/commands/firebase-setup.d.ts.map +0 -1
- package/dist/bin/commands/firebase-setup.js +0 -7
- package/dist/bin/commands/firebase-setup.js.map +0 -1
- package/dist/bin/commands/supabase-setup.d.ts +0 -6
- package/dist/bin/commands/supabase-setup.d.ts.map +0 -1
- package/dist/bin/commands/supabase-setup.js +0 -7
- package/dist/bin/commands/supabase-setup.js.map +0 -1
|
@@ -1,51 +1,39 @@
|
|
|
1
|
-
# Setup: Vercel
|
|
1
|
+
# Setup: Vercel (Hosting & Functions)
|
|
2
2
|
|
|
3
|
-
**
|
|
3
|
+
**Deploy your frontend (and optionally serverless functions) to Vercel. Works with any backend (Firebase, Supabase, or both).**
|
|
4
4
|
|
|
5
5
|
---
|
|
6
6
|
|
|
7
7
|
## Architecture
|
|
8
8
|
|
|
9
|
-
Vercel
|
|
10
|
-
Firebase is your **data layer** — Firestore (CRUD), Firebase Auth (users), Firebase Storage (files).
|
|
9
|
+
Vercel serves your built Vite or Next.js app on a global CDN. It can also run **Vercel Functions** (serverless API routes).
|
|
11
10
|
|
|
12
|
-
|
|
11
|
+
**Vercel as hosting only** (backend elsewhere):
|
|
12
|
+
- **Firebase** → Cloud Functions + Firestore + Auth + Storage
|
|
13
|
+
- **Supabase** → Edge Functions + PostgreSQL + Auth + Storage
|
|
13
14
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
Even though you deploy to Vercel, you still need Firebase for data.
|
|
19
|
-
|
|
20
|
-
1. Go to [Firebase Console](https://console.firebase.google.com) → Create a project
|
|
21
|
-
2. Enable **Authentication** → Email/Password (+ OAuth providers if needed)
|
|
22
|
-
3. Enable **Cloud Firestore** → Create Database → select region
|
|
23
|
-
4. Enable **Storage** if your app uploads files
|
|
15
|
+
**Vercel as hosting + functions** (alongside a backend):
|
|
16
|
+
- Vercel Functions handle API routes (`/api/*`)
|
|
17
|
+
- Combine with Firebase/Supabase for auth + database
|
|
24
18
|
|
|
25
|
-
|
|
19
|
+
The framework scaffolds `vercel.json` with CSP headers, rewrites, and caching rules.
|
|
26
20
|
|
|
27
21
|
---
|
|
28
22
|
|
|
29
|
-
## Step
|
|
30
|
-
|
|
31
|
-
```bash
|
|
32
|
-
dndev setup firebase
|
|
33
|
-
```
|
|
23
|
+
## Step 1: Create Vercel Project
|
|
34
24
|
|
|
35
|
-
|
|
25
|
+
1. Create a [Vercel](https://vercel.com) account
|
|
26
|
+
2. Import your Git repo from the Vercel Dashboard
|
|
27
|
+
3. Set the **Root Directory** to `apps/<your-app>` (or leave blank if monorepo auto-detected)
|
|
28
|
+
4. Set **Framework Preset** to Vite (or Next.js if using Next)
|
|
36
29
|
|
|
37
30
|
---
|
|
38
31
|
|
|
39
|
-
## Step
|
|
32
|
+
## Step 2: Set Environment Variables
|
|
40
33
|
|
|
41
|
-
|
|
42
|
-
2. Import the project in Vercel Dashboard
|
|
43
|
-
3. Set the **Root Directory** to `apps/<your-app>` (or leave blank if monorepo auto-detected)
|
|
44
|
-
4. Set **Framework Preset** to Vite (or Next.js if using Next)
|
|
34
|
+
In Vercel Dashboard → Settings → Environment Variables, copy the env vars from your `apps/<app>/.env`:
|
|
45
35
|
|
|
46
|
-
**
|
|
47
|
-
|
|
48
|
-
Copy your Firebase vars from `.env`:
|
|
36
|
+
**If using Firebase:**
|
|
49
37
|
- `VITE_FIREBASE_API_KEY`
|
|
50
38
|
- `VITE_FIREBASE_PROJECT_ID`
|
|
51
39
|
- `VITE_FIREBASE_AUTH_DOMAIN`
|
|
@@ -53,81 +41,122 @@ Copy your Firebase vars from `.env`:
|
|
|
53
41
|
- `VITE_FIREBASE_MESSAGING_SENDER_ID`
|
|
54
42
|
- `VITE_FIREBASE_APP_ID`
|
|
55
43
|
|
|
56
|
-
|
|
44
|
+
**If using Supabase:**
|
|
45
|
+
- `VITE_SUPABASE_URL`
|
|
46
|
+
- `VITE_SUPABASE_PUBLIC_KEY`
|
|
47
|
+
|
|
48
|
+
**Common (all backends):**
|
|
49
|
+
- `VITE_DONOTDEV_LICENSE_KEY`
|
|
50
|
+
- `VITE_STRIPE_PUBLISHABLE_KEY` (if using billing)
|
|
51
|
+
|
|
52
|
+
**Server-side (Vercel Functions only):**
|
|
53
|
+
- `STRIPE_SECRET_KEY` (if using billing)
|
|
54
|
+
- `SUPABASE_SERVICE_ROLE_KEY` (if using Supabase)
|
|
57
55
|
|
|
58
|
-
|
|
59
|
-
- `STRIPE_SECRET_KEY`
|
|
60
|
-
- `STRIPE_WEBHOOK_SECRET`
|
|
61
|
-
- Any OAuth client secrets
|
|
56
|
+
For Next.js apps, replace the `VITE_` prefix with `NEXT_PUBLIC_` (same var names, different prefix).
|
|
62
57
|
|
|
63
58
|
---
|
|
64
59
|
|
|
65
|
-
## Step
|
|
60
|
+
## Step 3: Deploy
|
|
66
61
|
|
|
67
|
-
|
|
62
|
+
**Option A — Git push (recommended)**
|
|
63
|
+
|
|
64
|
+
Push to your connected branch. Vercel auto-deploys.
|
|
68
65
|
|
|
66
|
+
```bash
|
|
67
|
+
git push origin main
|
|
69
68
|
```
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
│ └── oauth/ # OAuth callback handlers
|
|
76
|
-
├── vercel.json # Route configuration
|
|
77
|
-
├── tsconfig.json
|
|
78
|
-
└── package.json
|
|
69
|
+
|
|
70
|
+
**Option B — CLI**
|
|
71
|
+
|
|
72
|
+
```bash
|
|
73
|
+
dndev deploy
|
|
79
74
|
```
|
|
80
75
|
|
|
81
|
-
|
|
76
|
+
Or directly:
|
|
77
|
+
|
|
78
|
+
```bash
|
|
79
|
+
bunx vercel --prod
|
|
80
|
+
```
|
|
82
81
|
|
|
83
82
|
---
|
|
84
83
|
|
|
85
|
-
##
|
|
84
|
+
## Vercel Functions (Optional)
|
|
86
85
|
|
|
87
|
-
|
|
86
|
+
The framework provides helpers for Vercel Functions via `@donotdev/functions/vercel`. Place your API routes in `pages/api/` (Next.js) or `api/` (Vite).
|
|
88
87
|
|
|
89
|
-
|
|
88
|
+
### Custom Functions
|
|
90
89
|
|
|
91
|
-
```
|
|
92
|
-
|
|
90
|
+
```typescript
|
|
91
|
+
// pages/api/product-details.ts
|
|
92
|
+
import * as v from 'valibot';
|
|
93
|
+
import { createVercelBaseFunction } from '@donotdev/functions/vercel';
|
|
94
|
+
|
|
95
|
+
const schema = v.object({ productId: v.string() });
|
|
96
|
+
|
|
97
|
+
export default createVercelBaseFunction(
|
|
98
|
+
'POST',
|
|
99
|
+
schema,
|
|
100
|
+
'get_product_details',
|
|
101
|
+
async (req, res, data, { uid }) => {
|
|
102
|
+
// data is validated, uid is the authenticated user
|
|
103
|
+
const product = await getProduct(data.productId);
|
|
104
|
+
return res.status(200).json(product);
|
|
105
|
+
}
|
|
106
|
+
);
|
|
93
107
|
```
|
|
94
108
|
|
|
95
|
-
|
|
109
|
+
Auth, rate limiting, schema validation, and metrics — all included by default.
|
|
96
110
|
|
|
97
|
-
|
|
98
|
-
|
|
111
|
+
### Pre-built Endpoints
|
|
112
|
+
|
|
113
|
+
The framework ships ready-made API handlers:
|
|
114
|
+
|
|
115
|
+
```typescript
|
|
116
|
+
// pages/api/auth/claims.ts
|
|
117
|
+
import { setCustomClaims } from '@donotdev/functions/vercel';
|
|
118
|
+
export default setCustomClaims;
|
|
119
|
+
|
|
120
|
+
// pages/api/billing/checkout.ts
|
|
121
|
+
import { createCheckoutSession } from '@donotdev/functions/vercel';
|
|
122
|
+
import { billingConfig } from '../../../config/billing';
|
|
123
|
+
export default createCheckoutSession(billingConfig);
|
|
99
124
|
```
|
|
100
125
|
|
|
126
|
+
Available: auth (claims, status, delete account), billing (checkout, cancel, portal, change plan), OAuth (token exchange, access grants).
|
|
127
|
+
|
|
128
|
+
### When to use Vercel Functions vs Firebase/Supabase functions
|
|
129
|
+
|
|
130
|
+
- **Vercel Functions:** API routes, webhooks, third-party proxies — especially in Next.js apps
|
|
131
|
+
- **Firebase Cloud Functions:** Firestore triggers, heavy backend logic tied to Firebase
|
|
132
|
+
- **Supabase Edge Functions:** Database triggers, logic tied to Supabase
|
|
133
|
+
|
|
134
|
+
**Server secrets** for Vercel Functions go in Vercel Dashboard → Environment Variables (not `VITE_*` or `NEXT_PUBLIC_*` prefixed — those are exposed to the browser).
|
|
135
|
+
|
|
101
136
|
---
|
|
102
137
|
|
|
103
138
|
## Environment Variables
|
|
104
139
|
|
|
105
140
|
| File | What Goes Here | Loaded By |
|
|
106
141
|
|------|---------------|-----------|
|
|
107
|
-
| `apps/<app>/.env` |
|
|
142
|
+
| `apps/<app>/.env` | Public keys (backend config, license key, Stripe publishable) | Vite/Next.js (dev + build) |
|
|
108
143
|
| `apps/<app>/.env.local` | Local overrides (gitignored) | Vite/Next.js (overrides .env) |
|
|
109
144
|
| `apps/<app>/.env.production` | Production overrides | Vite/Next.js (build --mode production) |
|
|
110
|
-
| `functions/.env` | Server secrets: STRIPE_SECRET_KEY, OAuth secrets | API routes runtime |
|
|
111
145
|
| Vercel Dashboard | All production env vars (client + server) | Vercel runtime |
|
|
112
146
|
|
|
113
147
|
**Client vars** (browser-safe): `VITE_*` or `NEXT_PUBLIC_*` prefix.
|
|
114
|
-
**Server vars** (secrets): No prefix needed in Vercel Dashboard — only accessible in API routes.
|
|
115
148
|
|
|
116
149
|
---
|
|
117
150
|
|
|
118
151
|
## Local Development
|
|
119
152
|
|
|
120
153
|
```bash
|
|
121
|
-
|
|
154
|
+
dndev dev
|
|
122
155
|
```
|
|
123
156
|
|
|
124
|
-
The app runs locally, talking to your Firebase
|
|
125
|
-
|
|
126
|
-
```bash
|
|
127
|
-
vercel dev
|
|
128
|
-
```
|
|
157
|
+
The app runs locally, talking to your backend (Firebase or Supabase) directly.
|
|
129
158
|
|
|
130
|
-
|
|
159
|
+
For local function emulation:
|
|
131
160
|
|
|
132
161
|
```bash
|
|
133
162
|
dndev emu start
|
|
@@ -135,42 +164,30 @@ dndev emu start
|
|
|
135
164
|
|
|
136
165
|
---
|
|
137
166
|
|
|
138
|
-
##
|
|
167
|
+
## Custom Domain
|
|
139
168
|
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
```bash
|
|
145
|
-
# functions/.env
|
|
146
|
-
STRIPE_SECRET_KEY=sk_live_...
|
|
147
|
-
STRIPE_WEBHOOK_SECRET=whsec_...
|
|
148
|
-
```
|
|
149
|
-
|
|
150
|
-
Then add the same values in Vercel Dashboard → Settings → Environment Variables.
|
|
151
|
-
|
|
152
|
-
See [ENV_SETUP.md → Secrets Philosophy](./ENV_SETUP.md#secrets-philosophy) for the full policy.
|
|
169
|
+
1. Vercel Dashboard → Settings → Domains
|
|
170
|
+
2. Add your domain
|
|
171
|
+
3. Update DNS records as instructed by Vercel
|
|
172
|
+
4. If using Firebase Auth: update your `FIREBASE_AUTH_DOMAIN` env var to your custom domain
|
|
153
173
|
|
|
154
174
|
---
|
|
155
175
|
|
|
156
176
|
## Troubleshooting
|
|
157
177
|
|
|
158
|
-
**"
|
|
159
|
-
→ Check
|
|
160
|
-
→
|
|
161
|
-
|
|
162
|
-
**"401 / Permission denied on API routes"**
|
|
163
|
-
→ Check Firebase service account key is configured in Vercel env vars
|
|
164
|
-
→ Verify `GOOGLE_APPLICATION_CREDENTIALS` or inline credentials in API routes
|
|
178
|
+
**"Build fails on Vercel"**
|
|
179
|
+
→ Check Root Directory is set to your app directory
|
|
180
|
+
→ Ensure `package.json` has correct `build` script
|
|
181
|
+
→ Check all `VITE_*` env vars are set in Vercel Dashboard
|
|
165
182
|
|
|
166
183
|
**"CORS error"**
|
|
167
184
|
→ Vercel handles CORS for same-origin requests automatically
|
|
168
|
-
→ For cross-origin:
|
|
185
|
+
→ For cross-origin: CSP headers in `vercel.json` are pre-configured for your backend
|
|
169
186
|
|
|
170
|
-
**"
|
|
171
|
-
→
|
|
172
|
-
→
|
|
187
|
+
**".env values not loading"**
|
|
188
|
+
→ Vercel only reads env vars from its Dashboard, not from `.env` files
|
|
189
|
+
→ Make sure all required vars are set in Vercel Dashboard → Environment Variables
|
|
173
190
|
|
|
174
191
|
---
|
|
175
192
|
|
|
176
|
-
|
|
193
|
+
**Import repo in Vercel → set env vars → `git push`. Vercel deploys automatically.**
|
|
@@ -10,7 +10,7 @@ The DoNotDev framework uses a strict separation between local development and pr
|
|
|
10
10
|
|
|
11
11
|
**`.env.local` is the exclusive source of truth for emulators.**
|
|
12
12
|
|
|
13
|
-
When you run `
|
|
13
|
+
When you run `dndev emu <app-name>`, the framework loads environment variables **ONLY** from `functions/.env.local`.
|
|
14
14
|
|
|
15
15
|
1. Create `functions/.env.local` (it is git-ignored by default).
|
|
16
16
|
2. Add your local development keys (e.g., Stripe ephemeral webhook secret).
|
|
@@ -25,7 +25,7 @@ STRIPE_WEBHOOK_SECRET=whsec_... # Get this from 'stripe listen' output
|
|
|
25
25
|
|
|
26
26
|
**`.env` is the source of truth for production secrets.**
|
|
27
27
|
|
|
28
|
-
These are the secrets that will be synced to Firebase Cloud Functions when you run `
|
|
28
|
+
These are the secrets that will be synced to Firebase Cloud Functions when you run `dndev deploy` or `dndev sync-secrets`.
|
|
29
29
|
|
|
30
30
|
```bash
|
|
31
31
|
# functions/.env
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"firebase-setup.d.ts","sourceRoot":"","sources":["../../../src/bin/commands/firebase-setup.ts"],"names":[],"mappings":"AACA;;;GAGG;AAEH,OAAO,EAAE,aAAa,IAAI,IAAI,EAAE,MAAM,mBAAmB,CAAC"}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
// packages/cli/src/bin/commands/firebase-setup.ts
|
|
2
|
-
/**
|
|
3
|
-
* @fileoverview Firebase Setup Command Wrapper
|
|
4
|
-
* @description Re-exports firebaseSetup from tooling for CLI bundling.
|
|
5
|
-
*/
|
|
6
|
-
export { firebaseSetup as main } from '@donotdev/tooling';
|
|
7
|
-
//# sourceMappingURL=firebase-setup.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"firebase-setup.js","sourceRoot":"","sources":["../../../src/bin/commands/firebase-setup.ts"],"names":[],"mappings":"AAAA,kDAAkD;AAClD;;;GAGG;AAEH,OAAO,EAAE,aAAa,IAAI,IAAI,EAAE,MAAM,mBAAmB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"supabase-setup.d.ts","sourceRoot":"","sources":["../../../src/bin/commands/supabase-setup.ts"],"names":[],"mappings":"AACA;;;GAGG;AAEH,OAAO,EAAE,aAAa,IAAI,IAAI,EAAE,MAAM,mBAAmB,CAAC"}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
// packages/cli/src/bin/commands/supabase-setup.ts
|
|
2
|
-
/**
|
|
3
|
-
* @fileoverview Supabase Setup Command Wrapper
|
|
4
|
-
* @description Re-exports supabaseSetup from tooling for CLI bundling.
|
|
5
|
-
*/
|
|
6
|
-
export { supabaseSetup as main } from '@donotdev/tooling';
|
|
7
|
-
//# sourceMappingURL=supabase-setup.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"supabase-setup.js","sourceRoot":"","sources":["../../../src/bin/commands/supabase-setup.ts"],"names":[],"mappings":"AAAA,kDAAkD;AAClD;;;GAGG;AAEH,OAAO,EAAE,aAAa,IAAI,IAAI,EAAE,MAAM,mBAAmB,CAAC"}
|