@donotdev/cli 0.0.3 → 0.0.5
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 +194 -110
- package/dist/bin/commands/bump.d.ts +1 -1
- package/dist/bin/commands/bump.js +103 -96
- package/dist/bin/commands/create-app.js +40 -28
- package/dist/bin/commands/create-project.js +40 -28
- package/dist/bin/commands/format.d.ts +1 -1
- package/dist/bin/commands/lint.d.ts +1 -1
- package/dist/index.js +40 -28
- package/package.json +1 -9
- package/templates/app-demo/src/pages/components/DemoLayout.tsx.example +5 -5
- package/templates/app-demo/src/themes.css.example +108 -156
- package/templates/app-next/src/app/ClientLayout.tsx.example +1 -1
- package/templates/app-next/src/locales/home_en.json.example +6 -0
- package/templates/app-next/src/pages/HomePage.tsx.example +152 -8
- package/templates/app-next/src/themes.css.example +92 -140
- package/templates/app-vite/src/App.tsx.example +3 -3
- package/templates/app-vite/src/locales/home_en.json.example +6 -0
- package/templates/app-vite/src/pages/HomePage.tsx.example +149 -8
- package/templates/app-vite/src/themes.css.example +90 -138
- package/templates/root-consumer/guides/AGENT_START_HERE.md.example +297 -53
- package/templates/root-consumer/guides/COMPONENTS_ADV.md.example +360 -0
- package/templates/root-consumer/guides/COMPONENTS_ATOMIC.md.example +134 -0
- package/templates/root-consumer/guides/COMPONENTS_CRUD.md.example +70 -0
- package/templates/root-consumer/guides/COMPONENTS_UI.md.example +141 -0
- package/templates/root-consumer/guides/ENV_SETUP.md.example +14 -0
- package/templates/root-consumer/guides/INDEX.md.example +17 -25
- package/templates/root-consumer/guides/SETUP_AUTH.md.example +77 -0
- package/templates/root-consumer/guides/SETUP_BILLING.md.example +78 -0
- package/templates/root-consumer/guides/SETUP_FUNCTIONS.md.example +62 -0
- package/templates/root-consumer/guides/SETUP_I18N.md.example +187 -0
- package/templates/root-consumer/guides/SETUP_LAYOUTS.md.example +126 -0
- package/templates/root-consumer/guides/SETUP_OAUTH.md.example +53 -0
- package/templates/root-consumer/guides/SETUP_PAGES.md.example +120 -0
- package/templates/root-consumer/guides/SETUP_THEMES.md.example +107 -0
- package/templates/root-consumer/guides/advanced/COOKIE_REFERENCE.md.example +252 -0
- package/templates/root-consumer/guides/{EMULATOR_SETUP.md.example → advanced/EMULATORS.md.example} +1 -1
- package/templates/root-consumer/guides/{VERSION_CONTROL.md.example → advanced/VERSION_CONTROL.md.example} +0 -7
- package/templates/root-consumer/guides/AUTH_SETUP.md.example +0 -92
- package/templates/root-consumer/guides/BILLING_SETUP.md.example +0 -120
- package/templates/root-consumer/guides/CLI.md.example +0 -293
- package/templates/root-consumer/guides/COMPONENTS.md.example +0 -875
- package/templates/root-consumer/guides/FEATURES.md.example +0 -286
- package/templates/root-consumer/guides/FRAMEWORK_OVERVIEW.md.example +0 -97
- package/templates/root-consumer/guides/FUNCTIONS.md.example +0 -177
- package/templates/root-consumer/guides/GETTING_STARTED.md.example +0 -451
- package/templates/root-consumer/guides/HOW_TO_USE.md.example +0 -296
- package/templates/root-consumer/guides/I18N_SETUP.md.example +0 -204
- package/templates/root-consumer/guides/IMPORT_PATTERNS.md.example +0 -79
- package/templates/root-consumer/guides/INSTALLATION.md.example +0 -296
- package/templates/root-consumer/guides/LAYOUTS.md.example +0 -310
- package/templates/root-consumer/guides/PAGES_SETUP.md.example +0 -123
- package/templates/root-consumer/guides/STYLING.md.example +0 -273
- package/templates/root-consumer/guides/THEMING_SETUP.md.example +0 -119
- /package/templates/root-consumer/guides/{CONFIG_SETUP.md.example → SETUP_APP_CONFIG.md.example} +0 -0
- /package/templates/root-consumer/guides/{APP_CHECK_SETUP.md.example → advanced/APP_CHECK.md.example} +0 -0
|
@@ -1,286 +0,0 @@
|
|
|
1
|
-
# Using Features
|
|
2
|
-
|
|
3
|
-
**Optional features with graceful degradation**
|
|
4
|
-
|
|
5
|
-
---
|
|
6
|
-
|
|
7
|
-
## Available Features
|
|
8
|
-
|
|
9
|
-
DoNotDev provides 4 optional feature packages:
|
|
10
|
-
|
|
11
|
-
1. **@donotdev/auth** - Firebase Authentication
|
|
12
|
-
2. **@donotdev/billing** - Stripe subscriptions
|
|
13
|
-
3. **@donotdev/oauth** - OAuth providers (GitHub, Google)
|
|
14
|
-
|
|
15
|
-
---
|
|
16
|
-
|
|
17
|
-
## Installation
|
|
18
|
-
|
|
19
|
-
Install only the features you need:
|
|
20
|
-
|
|
21
|
-
```bash
|
|
22
|
-
# Authentication
|
|
23
|
-
bun add @donotdev/auth
|
|
24
|
-
|
|
25
|
-
# Billing (requires auth)
|
|
26
|
-
bun add @donotdev/billing
|
|
27
|
-
|
|
28
|
-
# OAuth
|
|
29
|
-
bun add @donotdev/oauth
|
|
30
|
-
```
|
|
31
|
-
|
|
32
|
-
---
|
|
33
|
-
|
|
34
|
-
## Using Auth
|
|
35
|
-
|
|
36
|
-
### Basic Usage
|
|
37
|
-
|
|
38
|
-
```typescript
|
|
39
|
-
import { useAuth } from '@donotdev/auth';
|
|
40
|
-
|
|
41
|
-
export function ProfilePage() {
|
|
42
|
-
const isEnabled = useAuth('isAvailable');
|
|
43
|
-
const isLoading = useAuth('loading');
|
|
44
|
-
const user = useAuth('user');
|
|
45
|
-
const signOut = useAuth('signOut');
|
|
46
|
-
|
|
47
|
-
if (!isEnabled) {
|
|
48
|
-
return <div>Auth not available</div>;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
if (isLoading) {
|
|
52
|
-
return <div>Loading...</div>;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
if (!user) {
|
|
56
|
-
return <LoginPage />;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
return (
|
|
60
|
-
<div>
|
|
61
|
-
<h1>Welcome, {user.displayName}!</h1>
|
|
62
|
-
<button onClick={() => signOut()}>Logout</button>
|
|
63
|
-
</div>
|
|
64
|
-
);
|
|
65
|
-
}
|
|
66
|
-
```
|
|
67
|
-
|
|
68
|
-
### Login
|
|
69
|
-
|
|
70
|
-
```typescript
|
|
71
|
-
const signInWithEmail = useAuth('signInWithEmail');
|
|
72
|
-
|
|
73
|
-
async function handleLogin(email: string, password: string) {
|
|
74
|
-
try {
|
|
75
|
-
await signInWithEmail(email, password);
|
|
76
|
-
// User is now authenticated
|
|
77
|
-
} catch (error) {
|
|
78
|
-
console.error('Login failed:', error);
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
```
|
|
82
|
-
|
|
83
|
-
### Sign Up
|
|
84
|
-
|
|
85
|
-
```typescript
|
|
86
|
-
const signUpWithEmail = useAuth('signUpWithEmail');
|
|
87
|
-
|
|
88
|
-
async function handleSignUp(email: string, password: string) {
|
|
89
|
-
try {
|
|
90
|
-
await signUpWithEmail(email, password);
|
|
91
|
-
// User account created and authenticated
|
|
92
|
-
} catch (error) {
|
|
93
|
-
console.error('Sign up failed:', error);
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
```
|
|
97
|
-
|
|
98
|
-
---
|
|
99
|
-
|
|
100
|
-
## Using Billing
|
|
101
|
-
|
|
102
|
-
**Requires:** `@donotdev/auth` installed
|
|
103
|
-
|
|
104
|
-
### Check Subscription
|
|
105
|
-
|
|
106
|
-
```typescript
|
|
107
|
-
import { useStripeBilling } from '@donotdev/billing';
|
|
108
|
-
|
|
109
|
-
export function UpgradePage() {
|
|
110
|
-
const isEnabled = useStripeBilling('isAvailable');
|
|
111
|
-
const subscription = useStripeBilling('subscription');
|
|
112
|
-
const checkout = useStripeBilling('checkout');
|
|
113
|
-
|
|
114
|
-
if (!isEnabled) {
|
|
115
|
-
return <div>Billing not available</div>;
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
return (
|
|
119
|
-
<div>
|
|
120
|
-
<h2>Current Plan: {subscription?.planId || 'Free'}</h2>
|
|
121
|
-
<button onClick={() => checkout({ priceId: 'pro', mode: 'subscription' })}>
|
|
122
|
-
Upgrade to Pro
|
|
123
|
-
</button>
|
|
124
|
-
</div>
|
|
125
|
-
);
|
|
126
|
-
}
|
|
127
|
-
```
|
|
128
|
-
|
|
129
|
-
### Create Checkout Session
|
|
130
|
-
|
|
131
|
-
```typescript
|
|
132
|
-
const checkout = useStripeBilling('checkout');
|
|
133
|
-
|
|
134
|
-
async function handleUpgrade() {
|
|
135
|
-
try {
|
|
136
|
-
// The checkout function handles redirecting to Stripe
|
|
137
|
-
await checkout({
|
|
138
|
-
priceId: 'pro', // The ID of the Stripe Price
|
|
139
|
-
mode: 'subscription',
|
|
140
|
-
successUrl: window.location.href, // Optional: URL to redirect on success
|
|
141
|
-
cancelUrl: window.location.origin, // Optional: URL to redirect on cancellation
|
|
142
|
-
});
|
|
143
|
-
} catch (error) {
|
|
144
|
-
console.error('Checkout failed:', error);
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
```
|
|
148
|
-
|
|
149
|
-
---
|
|
150
|
-
|
|
151
|
-
## Using OAuth
|
|
152
|
-
|
|
153
|
-
### GitHub OAuth
|
|
154
|
-
|
|
155
|
-
```typescript
|
|
156
|
-
import { useOAuth } from '@donotdev/oauth';
|
|
157
|
-
|
|
158
|
-
export function ConnectGitHub() {
|
|
159
|
-
const isEnabled = useOAuth('isAvailable');
|
|
160
|
-
const signInWithGitHub = useOAuth('signInWithGitHub');
|
|
161
|
-
|
|
162
|
-
if (!isEnabled) {
|
|
163
|
-
return null;
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
async function handleConnect() {
|
|
167
|
-
try {
|
|
168
|
-
await signInWithGitHub();
|
|
169
|
-
// User connected to GitHub
|
|
170
|
-
} catch (error) {
|
|
171
|
-
console.error('GitHub connection failed:', error);
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
return (
|
|
176
|
-
<button onClick={handleConnect}>
|
|
177
|
-
Connect GitHub
|
|
178
|
-
</button>
|
|
179
|
-
);
|
|
180
|
-
}
|
|
181
|
-
```
|
|
182
|
-
|
|
183
|
-
---
|
|
184
|
-
|
|
185
|
-
## Feature Detection
|
|
186
|
-
|
|
187
|
-
All features export `use{Feature}()` hooks that include `isAvailable` check:
|
|
188
|
-
|
|
189
|
-
```typescript
|
|
190
|
-
import { useAuth } from '@donotdev/auth';
|
|
191
|
-
import { useStripeBilling } from '@donotdev/billing';
|
|
192
|
-
|
|
193
|
-
export function Navigation() {
|
|
194
|
-
const authIsAvailable = useAuth('isAvailable');
|
|
195
|
-
const user = useAuth('user');
|
|
196
|
-
const billingIsAvailable = useStripeBilling('isAvailable');
|
|
197
|
-
|
|
198
|
-
return (
|
|
199
|
-
<nav>
|
|
200
|
-
<Link to="/home">Home</Link>
|
|
201
|
-
|
|
202
|
-
{authIsAvailable && user && (
|
|
203
|
-
<Link to="/dashboard">Dashboard</Link>
|
|
204
|
-
)}
|
|
205
|
-
|
|
206
|
-
{billingIsAvailable && (
|
|
207
|
-
<Link to="/upgrade">Upgrade</Link>
|
|
208
|
-
)}
|
|
209
|
-
</nav>
|
|
210
|
-
);
|
|
211
|
-
}
|
|
212
|
-
```
|
|
213
|
-
|
|
214
|
-
**Benefits:**
|
|
215
|
-
|
|
216
|
-
- Features lazy-load when needed
|
|
217
|
-
- Graceful degradation if not installed
|
|
218
|
-
- Tree-shaking removes unused features
|
|
219
|
-
|
|
220
|
-
---
|
|
221
|
-
|
|
222
|
-
## Configuration
|
|
223
|
-
|
|
224
|
-
### Firebase (for Auth)
|
|
225
|
-
|
|
226
|
-
```typescript
|
|
227
|
-
// src/App.tsx
|
|
228
|
-
import { ViteAppProviders } from '@donotdev/ui';
|
|
229
|
-
|
|
230
|
-
<ViteAppProviders
|
|
231
|
-
firebaseConfig={{
|
|
232
|
-
apiKey: import.meta.env.VITE_FIREBASE_API_KEY,
|
|
233
|
-
authDomain: import.meta.env.VITE_FIREBASE_AUTH_DOMAIN,
|
|
234
|
-
projectId: import.meta.env.VITE_FIREBASE_PROJECT_ID,
|
|
235
|
-
// ...
|
|
236
|
-
}}
|
|
237
|
-
>
|
|
238
|
-
{/* Your app */}
|
|
239
|
-
</ViteAppProviders>
|
|
240
|
-
```
|
|
241
|
-
|
|
242
|
-
### Stripe (for Billing)
|
|
243
|
-
|
|
244
|
-
Set environment variables:
|
|
245
|
-
|
|
246
|
-
```bash
|
|
247
|
-
# .env
|
|
248
|
-
VITE_STRIPE_PUBLISHABLE_KEY=pk_test_...
|
|
249
|
-
```
|
|
250
|
-
|
|
251
|
-
---
|
|
252
|
-
|
|
253
|
-
## Protected Routes
|
|
254
|
-
|
|
255
|
-
Use `meta.auth.required` to protect pages:
|
|
256
|
-
|
|
257
|
-
```typescript
|
|
258
|
-
import type { PageMeta } from '@donotdev/core';
|
|
259
|
-
|
|
260
|
-
export const meta: PageMeta = {
|
|
261
|
-
auth: { required: true },
|
|
262
|
-
};
|
|
263
|
-
|
|
264
|
-
export function DashboardPage() {
|
|
265
|
-
// User is guaranteed to be authenticated here
|
|
266
|
-
return <div>Dashboard</div>;
|
|
267
|
-
}
|
|
268
|
-
```
|
|
269
|
-
|
|
270
|
-
---
|
|
271
|
-
|
|
272
|
-
## Best Practices
|
|
273
|
-
|
|
274
|
-
- ✅ Always check `isEnabled` before using features
|
|
275
|
-
- ✅ Handle loading and error states
|
|
276
|
-
- ✅ Use feature detection for conditional UI
|
|
277
|
-
- ✅ Set up environment variables properly
|
|
278
|
-
- ❌ Don't assume features are installed
|
|
279
|
-
- ❌ Don't call feature methods without checking `isEnabled`
|
|
280
|
-
|
|
281
|
-
---
|
|
282
|
-
|
|
283
|
-
**Related:**
|
|
284
|
-
|
|
285
|
-
- [INSTALLATION.md](../../INSTALLATION.md) - Installing packages
|
|
286
|
-
- [docs/architecture/FEATURE_DETECTION.md](../architecture/FEATURE_DETECTION.md) - How feature detection works
|
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
# Framework Overview
|
|
2
|
-
|
|
3
|
-
**DoNotDev Package Ecosystem**
|
|
4
|
-
|
|
5
|
-
---
|
|
6
|
-
|
|
7
|
-
## Free Public Tools
|
|
8
|
-
|
|
9
|
-
**`@donotdev/cli`** - Command-line tool for scaffolding, dev servers, deployment
|
|
10
|
-
|
|
11
|
-
**`@donotdev/components`** - UI component library (standalone, can use anywhere)
|
|
12
|
-
|
|
13
|
-
**`@donotdev/templates`** - Pre-built page templates (open to contributions)
|
|
14
|
-
|
|
15
|
-
---
|
|
16
|
-
|
|
17
|
-
## Paid Framework Packages
|
|
18
|
-
|
|
19
|
-
**Foundation:**
|
|
20
|
-
|
|
21
|
-
- `@donotdev/core` - Engine (utilities, hooks, types, state management)
|
|
22
|
-
- `@donotdev/ui` - Composition layer (layouts, routing, feature integration)
|
|
23
|
-
|
|
24
|
-
**Features** (install what you need):
|
|
25
|
-
|
|
26
|
-
- `@donotdev/auth` - Authentication & authorization
|
|
27
|
-
- `@donotdev/billing` - Stripe integration
|
|
28
|
-
- `@donotdev/crud` - Data operations (forms, tables)
|
|
29
|
-
- `@donotdev/oauth` - Social sign-on
|
|
30
|
-
|
|
31
|
-
**Backend:**
|
|
32
|
-
|
|
33
|
-
- `@donotdev/firebase` - Firebase platform
|
|
34
|
-
- `@donotdev/functions` - Serverless function templates (Firebase/Vercel)
|
|
35
|
-
|
|
36
|
-
---
|
|
37
|
-
|
|
38
|
-
## Architecture
|
|
39
|
-
|
|
40
|
-
```
|
|
41
|
-
Your App
|
|
42
|
-
├── @donotdev/ui (Layouts, Routing)
|
|
43
|
-
├── @donotdev/templates (Pre-built Pages)
|
|
44
|
-
├── Features (auth, billing, crud - optional)
|
|
45
|
-
└── @donotdev/core (Foundation)
|
|
46
|
-
```
|
|
47
|
-
|
|
48
|
-
**Key:** Framework detects installed features, keeps bundle lean.
|
|
49
|
-
|
|
50
|
-
---
|
|
51
|
-
|
|
52
|
-
## Getting Started
|
|
53
|
-
|
|
54
|
-
**1. Install CLI:**
|
|
55
|
-
|
|
56
|
-
```bash
|
|
57
|
-
npm install -g @donotdev/cli
|
|
58
|
-
```
|
|
59
|
-
|
|
60
|
-
**2. Create project:**
|
|
61
|
-
|
|
62
|
-
```bash
|
|
63
|
-
dndev init my-app
|
|
64
|
-
```
|
|
65
|
-
|
|
66
|
-
**3. Add features:**
|
|
67
|
-
|
|
68
|
-
```bash
|
|
69
|
-
cd my-app
|
|
70
|
-
npm install @donotdev/auth @donotdev/billing
|
|
71
|
-
```
|
|
72
|
-
|
|
73
|
-
**4. Start dev server:**
|
|
74
|
-
|
|
75
|
-
```bash
|
|
76
|
-
dndev dev
|
|
77
|
-
```
|
|
78
|
-
|
|
79
|
-
---
|
|
80
|
-
|
|
81
|
-
## Import Pattern
|
|
82
|
-
|
|
83
|
-
Import everything from `@donotdev/core`:
|
|
84
|
-
|
|
85
|
-
```typescript
|
|
86
|
-
import { useAuth, useTranslation, useThemeStore } from '@donotdev/core';
|
|
87
|
-
```
|
|
88
|
-
|
|
89
|
-
Import UI components from `@donotdev/ui`:
|
|
90
|
-
|
|
91
|
-
```typescript
|
|
92
|
-
import { Button, Card } from '@donotdev/ui';
|
|
93
|
-
```
|
|
94
|
-
|
|
95
|
-
---
|
|
96
|
-
|
|
97
|
-
**Simple. Modular. Type-safe.**
|
|
@@ -1,177 +0,0 @@
|
|
|
1
|
-
# Firebase Functions Setup
|
|
2
|
-
|
|
3
|
-
This guide covers Firebase Cloud Functions setup, deployment, and the critical `functions.yaml` file.
|
|
4
|
-
|
|
5
|
-
## Overview
|
|
6
|
-
|
|
7
|
-
Firebase Functions provide serverless backend capabilities for your DoNotDev application. Functions are scaffolded into your app's `functions/` directory and deployed to Firebase Cloud Functions.
|
|
8
|
-
|
|
9
|
-
## Structure
|
|
10
|
-
|
|
11
|
-
```
|
|
12
|
-
functions/
|
|
13
|
-
├── src/
|
|
14
|
-
│ ├── auth/ # Authentication functions
|
|
15
|
-
│ ├── oauth/ # OAuth functions
|
|
16
|
-
│ ├── billing/ # Billing functions
|
|
17
|
-
│ └── index.ts # Main functions entry point
|
|
18
|
-
├── package.json # Dependencies and scripts
|
|
19
|
-
├── tsconfig.json # TypeScript configuration
|
|
20
|
-
├── functions.yaml # Firebase function manifest (auto-generated)
|
|
21
|
-
├── .env.example # Environment variables template
|
|
22
|
-
├── service-account-key.json # Firebase service account key
|
|
23
|
-
└── README.md # Functions documentation
|
|
24
|
-
```
|
|
25
|
-
|
|
26
|
-
## Critical: functions.yaml
|
|
27
|
-
|
|
28
|
-
**`functions.yaml` must be manually created and maintained.** This file serves as a manifest that tells Firebase which functions to deploy and their configuration.
|
|
29
|
-
|
|
30
|
-
### Important Notes
|
|
31
|
-
|
|
32
|
-
1. **Manually Maintained**: You must create and maintain this file yourself
|
|
33
|
-
2. **Must Include All Functions**: Every function exported from `src/index.ts` must be listed in `functions.yaml`
|
|
34
|
-
3. **Deployment Dependency**: If a function is missing from `functions.yaml`, it won't be deployed
|
|
35
|
-
4. **Cleared Before Build**: The deployment script clears `functions.yaml` before building, so you must recreate it with all your functions
|
|
36
|
-
|
|
37
|
-
### How It Works
|
|
38
|
-
|
|
39
|
-
1. **Export in `src/index.ts`**: All functions must be exported from `src/index.ts`
|
|
40
|
-
```typescript
|
|
41
|
-
export * from './billing/createCustomerPortal.js';
|
|
42
|
-
```
|
|
43
|
-
|
|
44
|
-
2. **Create Entry in `functions.yaml`**: For each exported function, add an entry:
|
|
45
|
-
```yaml
|
|
46
|
-
endpoints:
|
|
47
|
-
createCustomerPortal:
|
|
48
|
-
region:
|
|
49
|
-
- europe-west1
|
|
50
|
-
platform: gcfv2
|
|
51
|
-
httpsTrigger: {}
|
|
52
|
-
entryPoint: createCustomerPortal
|
|
53
|
-
labels: {}
|
|
54
|
-
```
|
|
55
|
-
|
|
56
|
-
3. **Deployment Process**: During `dndev deploy`:
|
|
57
|
-
- Functions are built to `lib/`
|
|
58
|
-
- Firebase CLI deploys functions listed in `functions.yaml`
|
|
59
|
-
- `functions.yaml` is preserved and not modified by the deployment script
|
|
60
|
-
|
|
61
|
-
### Troubleshooting Missing Functions
|
|
62
|
-
|
|
63
|
-
If a function isn't being deployed:
|
|
64
|
-
|
|
65
|
-
1. **Check Export**: Ensure the function is exported in `src/index.ts`
|
|
66
|
-
2. **Check Build**: Verify the function exists in `lib/index.js` after build
|
|
67
|
-
3. **Check functions.yaml**: Verify the function is listed in `functions.yaml` with correct `entryPoint` name matching the export name
|
|
68
|
-
|
|
69
|
-
### Example functions.yaml
|
|
70
|
-
|
|
71
|
-
```yaml
|
|
72
|
-
endpoints:
|
|
73
|
-
functionName1:
|
|
74
|
-
region:
|
|
75
|
-
- europe-west1
|
|
76
|
-
platform: gcfv2
|
|
77
|
-
httpsTrigger: {}
|
|
78
|
-
entryPoint: functionName1
|
|
79
|
-
labels: {}
|
|
80
|
-
functionName2:
|
|
81
|
-
region:
|
|
82
|
-
- europe-west1
|
|
83
|
-
platform: gcfv2
|
|
84
|
-
httpsTrigger: {}
|
|
85
|
-
entryPoint: functionName2
|
|
86
|
-
labels: {}
|
|
87
|
-
specVersion: v1alpha1
|
|
88
|
-
requiredAPIs: []
|
|
89
|
-
```
|
|
90
|
-
|
|
91
|
-
## Environment Variables
|
|
92
|
-
|
|
93
|
-
Functions use a different `.env` system than Vite/Next.js:
|
|
94
|
-
|
|
95
|
-
- **Local Development**: `.env.local` file (Loaded automatically by `dn emu`)
|
|
96
|
-
- **Production Secrets**: `.env` file (Used by `dn sync-secrets` to update Cloud Functions)
|
|
97
|
-
|
|
98
|
-
**Note:** Functions don't follow Vite/Next.js `.env.local` priority rules. We enforce a strict separation: `.env` is ONLY for production, `.env.local` is ONLY for emulators.
|
|
99
|
-
|
|
100
|
-
See [EMULATOR_SETUP.md](./EMULATOR_SETUP.md) for more details.
|
|
101
|
-
|
|
102
|
-
### Required Environment Variables (.env.local for development)
|
|
103
|
-
|
|
104
|
-
```bash
|
|
105
|
-
# Stripe Configuration
|
|
106
|
-
STRIPE_SECRET_KEY=sk_test_...
|
|
107
|
-
STRIPE_WEBHOOK_SECRET=whsec_...
|
|
108
|
-
```
|
|
109
|
-
|
|
110
|
-
## Deployment
|
|
111
|
-
|
|
112
|
-
Use the unified deployment command from workspace root:
|
|
113
|
-
|
|
114
|
-
```bash
|
|
115
|
-
# Deploy everything (interactive)
|
|
116
|
-
dndev deploy
|
|
117
|
-
|
|
118
|
-
# Deploy specific app
|
|
119
|
-
dndev deploy <app-name>
|
|
120
|
-
```
|
|
121
|
-
|
|
122
|
-
The deployment process:
|
|
123
|
-
1. Clears `lib/` folder for fresh build
|
|
124
|
-
2. Builds functions to `lib/`
|
|
125
|
-
3. Deploys all functions listed in `functions.yaml` (manually maintained, not modified by deployment)
|
|
126
|
-
|
|
127
|
-
## Development
|
|
128
|
-
|
|
129
|
-
```bash
|
|
130
|
-
# Start Firebase emulators
|
|
131
|
-
bun run serve
|
|
132
|
-
|
|
133
|
-
# Start with debugging
|
|
134
|
-
bun run dev
|
|
135
|
-
```
|
|
136
|
-
|
|
137
|
-
## Adding New Functions
|
|
138
|
-
|
|
139
|
-
1. **Create Function File**: Add your function in `src/` (e.g., `src/billing/myNewFunction.ts`)
|
|
140
|
-
2. **Export in index.ts**: Add export to `src/index.ts`:
|
|
141
|
-
```typescript
|
|
142
|
-
export * from './billing/myNewFunction.js';
|
|
143
|
-
```
|
|
144
|
-
3. **Add to functions.yaml**: Add entry to `functions.yaml`:
|
|
145
|
-
```yaml
|
|
146
|
-
myNewFunction:
|
|
147
|
-
region:
|
|
148
|
-
- europe-west1
|
|
149
|
-
platform: gcfv2
|
|
150
|
-
httpsTrigger: {}
|
|
151
|
-
entryPoint: myNewFunction
|
|
152
|
-
labels: {}
|
|
153
|
-
```
|
|
154
|
-
4. **Deploy**: Run `dndev deploy` - the function will be deployed if listed in `functions.yaml`
|
|
155
|
-
|
|
156
|
-
## Security
|
|
157
|
-
|
|
158
|
-
- All functions require authentication
|
|
159
|
-
- Webhook signature verification
|
|
160
|
-
- Secure token management
|
|
161
|
-
- Firebase custom claims for user status
|
|
162
|
-
|
|
163
|
-
## Framework Integration
|
|
164
|
-
|
|
165
|
-
Functions use the framework's `@donotdev/functions` package:
|
|
166
|
-
|
|
167
|
-
```typescript
|
|
168
|
-
// apps/your-app/functions/src/billing/createCheckoutSession.ts
|
|
169
|
-
import { createCheckoutSession as generic } from '@donotdev/functions/firebase';
|
|
170
|
-
import { stripeBackConfig } from '../config/stripeBackConfig';
|
|
171
|
-
|
|
172
|
-
// Your app's function = framework + your config
|
|
173
|
-
export const createCheckoutSession = generic(stripeBackConfig);
|
|
174
|
-
```
|
|
175
|
-
|
|
176
|
-
See [Functions Package Architecture](../../../docs/architecture/packages/FUNCTIONS_PACKAGE.md) for detailed explanation.
|
|
177
|
-
|